@umbraco-cms/backoffice
    Preparing search index...

    Interface ProseMirrorNode

    This class represents a node in the tree that makes up a ProseMirror document. So a document is an instance of Node, with children that are also instances of Node.

    Nodes are persistent data structures. Instead of changing them, you create new ones with the content you want. Old ones keep pointing at the old document shape. This is made cheaper by sharing structure between the old and new data as much as possible, which a tree shape like this (without back pointers) makes easy.

    Do not directly mutate the properties of a Node object. See the guide for more information.

    interface ProseMirrorNode {
        attrs: Attrs;
        content: Fragment;
        marks: readonly Mark[];
        text: undefined | string;
        type: NodeType;
        get childCount(): number;
        get children(): readonly ProseMirrorNode[];
        get firstChild(): null | ProseMirrorNode;
        get inlineContent(): boolean;
        get isAtom(): boolean;
        get isBlock(): boolean;
        get isInline(): boolean;
        get isLeaf(): boolean;
        get isText(): boolean;
        get isTextblock(): boolean;
        get lastChild(): null | ProseMirrorNode;
        get nodeSize(): number;
        get textContent(): string;
        canAppend(other: ProseMirrorNode): boolean;
        canReplace(
            from: number,
            to: number,
            replacement?: Fragment,
            start?: number,
            end?: number,
        ): boolean;
        canReplaceWith(
            from: number,
            to: number,
            type: NodeType,
            marks?: readonly Mark[],
        ): boolean;
        check(): void;
        child(index: number): ProseMirrorNode;
        childAfter(
            pos: number,
        ): { index: number; node: null | ProseMirrorNode; offset: number };
        childBefore(
            pos: number,
        ): { index: number; node: null | ProseMirrorNode; offset: number };
        contentMatchAt(index: number): ContentMatch;
        copy(content?: null | Fragment): ProseMirrorNode;
        cut(from: number, to?: number): ProseMirrorNode;
        descendants(
            f: (
                node: ProseMirrorNode,
                pos: number,
                parent: null | ProseMirrorNode,
                index: number,
            ) => boolean | void,
        ): void;
        eq(other: ProseMirrorNode): boolean;
        forEach(
            f: (node: ProseMirrorNode, offset: number, index: number) => void,
        ): void;
        hasMarkup(
            type: NodeType,
            attrs?: null | Attrs,
            marks?: readonly Mark[],
        ): boolean;
        mark(marks: readonly Mark[]): ProseMirrorNode;
        maybeChild(index: number): null | ProseMirrorNode;
        nodeAt(pos: number): null | ProseMirrorNode;
        nodesBetween(
            from: number,
            to: number,
            f: (
                node: ProseMirrorNode,
                pos: number,
                parent: null | ProseMirrorNode,
                index: number,
            ) => boolean | void,
            startPos?: number,
        ): void;
        rangeHasMark(from: number, to: number, type: MarkType | Mark): boolean;
        replace(from: number, to: number, slice: Slice): ProseMirrorNode;
        resolve(pos: number): ResolvedPos;
        sameMarkup(other: ProseMirrorNode): boolean;
        slice(from: number, to?: number, includeParents?: boolean): Slice;
        textBetween(
            from: number,
            to: number,
            blockSeparator?: null | string,
            leafText?: null | string | ((leafNode: ProseMirrorNode) => string),
        ): string;
        toJSON(): any;
        toString(): string;
    }
    Index

    Properties

    attrs: Attrs

    An object mapping attribute names to values. The kind of attributes allowed and required are determined by the node type.

    content: Fragment

    A container holding the node's children.

    marks: readonly Mark[]

    The marks (things like whether it is emphasized or part of a link) applied to this node.

    text: undefined | string

    For text nodes, this contains the node's text content.

    type: NodeType

    The type of node that this is.

    Accessors

    • get childCount(): number

      The number of children that the node has.

      Returns number

    • get children(): readonly ProseMirrorNode[]

      The array of this node's child nodes.

      Returns readonly ProseMirrorNode[]

    • get firstChild(): null | ProseMirrorNode

      Returns this node's first child, or null if there are no children.

      Returns null | ProseMirrorNode

    • get inlineContent(): boolean

      True when this node allows inline content.

      Returns boolean

    • get isAtom(): boolean

      True when this is an atom, i.e. when it does not have directly editable content. This is usually the same as isLeaf, but can be configured with the atom property on a node's spec (typically used when the node is displayed as an uneditable node view).

      Returns boolean

    • get isBlock(): boolean

      True when this is a block (non-inline node)

      Returns boolean

    • get isInline(): boolean

      True when this is an inline node (a text node or a node that can appear among text).

      Returns boolean

    • get isLeaf(): boolean

      True when this is a leaf node.

      Returns boolean

    • get isText(): boolean

      True when this is a text node.

      Returns boolean

    • get isTextblock(): boolean

      True when this is a textblock node, a block node with inline content.

      Returns boolean

    • get lastChild(): null | ProseMirrorNode

      Returns this node's last child, or null if there are no children.

      Returns null | ProseMirrorNode

    • get nodeSize(): number

      The size of this node, as defined by the integer-based indexing scheme. For text nodes, this is the amount of characters. For other leaf nodes, it is one. For non-leaf nodes, it is the size of the content plus two (the start and end token).

      Returns number

    • get textContent(): string

      Concatenates all the text nodes found in this fragment and its children.

      Returns string

    Methods

    • Test whether the given node's content could be appended to this node. If that node is empty, this will only return true if there is at least one node type that can appear in both nodes (to avoid merging completely incompatible nodes).

      Parameters

      Returns boolean

    • Test whether replacing the range between from and to (by child index) with the given replacement fragment (which defaults to the empty fragment) would leave the node's content valid. You can optionally pass start and end indices into the replacement fragment.

      Parameters

      • from: number
      • to: number
      • Optionalreplacement: Fragment
      • Optionalstart: number
      • Optionalend: number

      Returns boolean

    • Test whether replacing the range from to to (by index) with a node of the given type would leave the node's content valid.

      Parameters

      • from: number
      • to: number
      • type: NodeType
      • Optionalmarks: readonly Mark[]

      Returns boolean

    • Check whether this node and its descendants conform to the schema, and raise an exception when they do not.

      Returns void

    • Get the child node at the given index. Raises an error when the index is out of range.

      Parameters

      • index: number

      Returns ProseMirrorNode

    • Find the (direct) child node after the given offset, if any, and return it along with its index and offset relative to this node.

      Parameters

      • pos: number

      Returns { index: number; node: null | ProseMirrorNode; offset: number }

    • Find the (direct) child node before the given offset, if any, and return it along with its index and offset relative to this node.

      Parameters

      • pos: number

      Returns { index: number; node: null | ProseMirrorNode; offset: number }

    • Get the content match in this node at the given index.

      Parameters

      • index: number

      Returns ContentMatch

    • Create a new node with the same markup as this node, containing the given content (or empty, if no content is given).

      Parameters

      • Optionalcontent: null | Fragment

      Returns ProseMirrorNode

    • Create a copy of this node with only the content between the given positions. If to is not given, it defaults to the end of the node.

      Parameters

      • from: number
      • Optionalto: number

      Returns ProseMirrorNode

    • Call the given callback for every descendant node. Doesn't descend into a node when the callback returns false.

      Parameters

      Returns void

    • Test whether two nodes represent the same piece of document.

      Parameters

      Returns boolean

    • Call f for every child node, passing the node, its offset into this parent node, and its index.

      Parameters

      Returns void

    • Check whether this node's markup correspond to the given type, attributes, and marks.

      Parameters

      • type: NodeType
      • Optionalattrs: null | Attrs
      • Optionalmarks: readonly Mark[]

      Returns boolean

    • Create a copy of this node, with the given set of marks instead of the node's own marks.

      Parameters

      • marks: readonly Mark[]

      Returns ProseMirrorNode

    • Get the child node at the given index, if it exists.

      Parameters

      • index: number

      Returns null | ProseMirrorNode

    • Find the node directly after the given position.

      Parameters

      • pos: number

      Returns null | ProseMirrorNode

    • Invoke a callback for all descendant nodes recursively between the given two positions that are relative to start of this node's content. The callback is invoked with the node, its position relative to the original node (method receiver), its parent node, and its child index. When the callback returns false for a given node, that node's children will not be recursed over. The last parameter can be used to specify a starting position to count from.

      Parameters

      • from: number
      • to: number
      • f: (
            node: ProseMirrorNode,
            pos: number,
            parent: null | ProseMirrorNode,
            index: number,
        ) => boolean | void
      • OptionalstartPos: number

      Returns void

    • Test whether a given mark or mark type occurs in this document between the two given positions.

      Parameters

      • from: number
      • to: number
      • type: MarkType | Mark

      Returns boolean

    • Replace the part of the document between the given positions with the given slice. The slice must 'fit', meaning its open sides must be able to connect to the surrounding content, and its content nodes must be valid children for the node they are placed into. If any of this is violated, an error of type ReplaceError is thrown.

      Parameters

      • from: number
      • to: number
      • slice: Slice

      Returns ProseMirrorNode

    • Resolve the given position in the document, returning an object with information about its context.

      Parameters

      • pos: number

      Returns ResolvedPos

    • Compare the markup (type, attributes, and marks) of this node to those of another. Returns true if both have the same markup.

      Parameters

      Returns boolean

    • Cut out the part of the document between the given positions, and return it as a Slice object.

      Parameters

      • from: number
      • Optionalto: number
      • OptionalincludeParents: boolean

      Returns Slice

    • Get all text between positions from and to. When blockSeparator is given, it will be inserted to separate text from different block nodes. If leafText is given, it'll be inserted for every non-text leaf node encountered, otherwise leafText will be used.

      Parameters

      • from: number
      • to: number
      • OptionalblockSeparator: null | string
      • OptionalleafText: null | string | ((leafNode: ProseMirrorNode) => string)

      Returns string

    • Return a JSON-serializeable representation of this node.

      Returns any

    • Return a string representation of this node for debugging purposes.

      Returns string