CallioText API Reference - v0.0.22
    Preparing search index...

    Class EditorComponent

    因为slate实际上是编辑rootchildren,所以root的property要单独处理。

    Hierarchy

    • TreeOpeationsMixins
    • Component<
          EditorComponentProps,
          {
              root_property: Omit<AbstractNode, "children">;
              slate: SlateReact.ReactEditor;
          },
      >
      • EditorComponent
    Index
    add_nodes: <NT extends Node>(nodes: NT | NT[], path: number[]) => void
    add_nodes_after: <NT extends Node, TT extends Node & ConceptNode>(
        nodes: NT | NT[],
        target_node: TT,
    ) => void
    add_nodes_before: <NT extends Node, TT extends Node & ConceptNode>(
        nodes: NT | NT[],
        target_node: TT,
    ) => void
    add_nodes_here: <NT extends Node>(nodes: NT | NT[]) => void
    auto_set_parameter: <NT extends Node & ConceptNode>(
        node: NT,
        parameters: ParameterList,
    ) => void
    context: unknown

    If using the new style context, re-declare this in your class to be the React.ContextType of your static contextType. Should be used with type annotation or static contextType.

    static contextType = MyContext
    // For TS pre-3.7:
    context!: React.ContextType<typeof MyContext>
    // For TS 3.7 and above:
    declare context: React.ContextType<typeof MyContext>
    delete_concept_node: <NT extends Node & ConceptNode>(node: NT) => void
    delete_node_by_path: <NT extends Node>(path: number[]) => void
    delete_nodes_by_paths: <NT extends Node>(paths: number[][]) => void
    move_concept_node: <NT extends Node & ConceptNode>(
        node_from: NT,
        posto: number[],
    ) => void
    move_node_by_path: <NT extends Node>(posf: number[], posto: number[]) => void
    onFocusChange: (editor?: EditorComponent) => void

    改变光标位置的回调。

    onKeyDown: (e: KeyboardEvent<HTMLDivElement>) => void

    按键按下的回调。

    onKeyUp: (e: KeyboardEvent<HTMLDivElement>) => void

    按键弹起的回调。

    onUpdate: (v: any) => void

    节点树更新时的回调。

    props: Readonly<P>
    replace_nodes: <NT extends Node & ConceptNode, ST extends Node>(
        father_node: NT,
        nodes: ST[],
    ) => void
    set_node: <NT extends Node & ConceptNode>(
        node: NT,
        new_val: Partial<NT>,
    ) => void
    set_node_by_path: <NT extends Node & ConceptNode>(
        path: number[],
        new_val: Partial<NT>,
    ) => void
    state: Readonly<S>
    unwrap_node: <NT extends Node & ConceptNode>(node: NT) => void
    wrap_nodes: <NT extends BaseElement>(
        node: NT,
        from: BasePoint,
        to: BasePoint,
        options: { match?: (n: Node) => boolean; split?: boolean },
    ) => void
    wrap_selected_nodes: <NT extends BaseElement>(
        node: NT,
        options: { match?: (n: Node) => boolean; split?: boolean },
    ) => void
    contextType?: Context<any>

    If set, this.context will be set at runtime to the current value of the given Context.

    type MyContext = number
    const Ctx = React.createContext<MyContext>(0)

    class Foo extends React.Component {
    static contextType = Ctx
    context!: React.ContextType<typeof Ctx>
    render () {
    return <>My context's value: {this.context}</>;
    }
    }
    propTypes?: any

    Ignored by React.

    Only kept in types for backwards compatibility. Will be removed in a future major release.

    • 添加一个在下一个apply之后执行的回调。

      Parameters

      • cb: () => void

      Returns void

    • Catches exceptions generated in descendant components. Unhandled exceptions will cause the entire component tree to unmount.

      Parameters

      • error: Error
      • errorInfo: ErrorInfo

      Returns void

    • Called immediately after a component is mounted. Setting state here will trigger re-rendering.

      Returns void

    • Called immediately after updating occurs. Not called for the initial render.

      The snapshot is only present if getSnapshotBeforeUpdate is present and returns non-null.

      Parameters

      • prevProps: Readonly<P>
      • prevState: Readonly<S>
      • Optionalsnapshot: any

      Returns void

    • Called immediately before a component is destroyed. Perform any necessary cleanup in this method, such as cancelled network requests, or cleaning up any DOM elements created in componentDidMount.

      Returns void

    • Parameters

      • Optionalcallback: () => void

      Returns void

    • Returns (ConceptNode & Node) | undefined

    • Parameters

      • path: number[]

      Returns (Node & Node) | undefined

    • Runs before React applies the result of Component.render render to the document, and returns an object to be given to componentDidUpdate. Useful for saving things such as scroll position before Component.render render causes changes to it.

      Note: the presence of this method prevents any of the deprecated lifecycle events from running.

      Parameters

      • prevProps: Readonly<P>
      • prevState: Readonly<S>

      Returns any

    • 在当前位置新建一个指定概念的节点。

      Parameters

      • type: "group" | "inline" | "structure" | "support"
      • sec_ccpt: string

      Returns void

    • Parameters

      • props: RenderLeafProps

      Returns Element

    • Type Parameters

      • K extends "root_property" | "slate"

      Parameters

      • state:
            | { root_property: Omit<AbstractNode, "children">; slate: ReactEditor }
            | (
                (
                    prevState: Readonly<S>,
                    props: Readonly<P>,
                ) =>
                    | {
                        root_property: Omit<AbstractNode, "children">;
                        slate: ReactEditor;
                    }
                    | Pick<
                        { root_property: Omit<AbstractNode, "children">; slate: ReactEditor },
                        K,
                    >
                    | null
            )
            | Pick<
                { root_property: Omit<AbstractNode, "children">; slate: ReactEditor },
                K,
            >
            | null
      • Optionalcallback: () => void

      Returns void

    • Called to determine whether the change in props and state should trigger a re-render.

      Component always returns true. PureComponent implements a shallow comparison on props and state and returns true if any props or states have changed.

      If false is returned, Component.render, componentWillUpdate and componentDidUpdate will not be called.

      Parameters

      • nextProps: Readonly<P>
      • nextState: Readonly<S>
      • nextContext: any

      Returns boolean

    • Called when the component may be receiving new props. React may call this even if props have not changed, so be sure to compare new and existing props if you only want to handle changes.

      Calling Component.setState generally does not trigger this method.

      This method will not stop working in React 17.

      Note: the presence of NewLifecycle.getSnapshotBeforeUpdate getSnapshotBeforeUpdate or StaticLifecycle.getDerivedStateFromProps getDerivedStateFromProps prevents this from being invoked.

      Parameters

      • nextProps: Readonly<P>
      • nextContext: any

      Returns void