Module for working with DOM

Hierarchy

  • Dom

Methods

  • Call functions for all nodes between start and end

    Parameters

    • start: Node
    • end: Node
    • callback: ((node: Node) => boolean | void)
        • (node: Node): boolean | void
        • Parameters

          Returns boolean | void

    Returns void

  • It's block and it can be split

    Parameters

    • node: unknown

    Returns boolean

  • Remove all content from element

    Parameters

    Returns void

  • It goes through all the internal elements of the node, causing a callback function

    Example

    Jodit.modules.Dom.each(editor.s.current(), function (node) {
    if (node.nodeType === Node.TEXT_NODE) {
    node.nodeValue = node.nodeValue.replace(Jodit.INVISIBLE_SPACE_REG_EX, '') // remove all of the text element codes invisible character
    }
    });

    Parameters

    • elm: Node

      the element whose children and descendants you want to iterate over

    • callback: ((node: Node) => boolean | void)

      It called for each item found

        • (node: Node): boolean | void
        • Parameters

          Returns boolean | void

    • leftToRight: boolean = true

    Returns boolean

  • Returns the nearest non-empty sibling

    Parameters

    • node: Node
    • left: boolean

    Returns Nullable<Node>

  • Get not empty sibling

    Parameters

    • node: Node
    • left: boolean = true
    • cond: ((n: Node) => boolean) = ...
        • (n: Node): boolean
        • Parameters

          Returns boolean

    Returns Nullable<Node>

  • Check the node is a block element

    Parameters

    • node: unknown

      Object to check

    Returns node is HTMLDivElement

  • Check if element is element node

    Parameters

    • node: unknown

    Returns node is Element

  • Check if element is empty

    Parameters

    Returns boolean

  • Parameters

    Returns boolean

  • Checks whether the Node text and blank (in this case it may contain invisible auxiliary characters , it is also empty )

    Parameters

    Returns boolean

  • Check if element is HTMLElement node

    Parameters

    • node: unknown

    Returns node is HTMLElement

  • Check element is inline block

    Parameters

    • node: null | false | Node

    Returns node is HTMLElement

  • Returns true if it is a DOM node

    Parameters

    • object: unknown

    Returns object is Node

  • Check root contains child or equal child

    Parameters

    • root: Node
    • child: Node
    • onlyContains: boolean = false

    Returns boolean

  • Check if element is some tag

    Type Parameters

    • K extends keyof HTMLElementTagNameMap

    Parameters

    Returns node is HTMLElementTagNameMap[K]

  • Type Parameters

    • K extends keyof HTMLElementTagNameMap

    Parameters

    Returns node is HTMLElementTagNameMap[K]

  • Check if element is temporary

    Parameters

    • element: unknown

    Returns boolean

  • Check if element is text node

    Parameters

    • node: null | false | Node

    Returns node is Text

  • Marks an item as temporary

    Type Parameters

    Parameters

    • element: K
    • Optional attributes: IDictionary<any, string>

    Returns K

  • Move all content to another element

    Parameters

    • from: Node
    • to: Node
    • inStart: boolean = false

    Returns void

  • Find next/prev node what condition(next) === true

    Parameters

    • start: Node
    • root: HTMLElement
    • leftToRight: boolean = true
    • withChild: boolean = true

    Returns Generator<Node, any, unknown>

  • Replace one tag to another transfer content

    Example

    Jodit.modules.Dom.replace(parent.editor.getElementsByTagName('span')[0], 'p');
    // Replace the first <span> element to the < p >

    Type Parameters

    Parameters

    • elm: Node

      The element that needs to be replaced by new

    • newTagName: string | Node

      tag name for which will change elm

    • create: ICreate
    • withAttributes: boolean = false

      If true move tag's attributes

    • notMoveContent: boolean = false

      false - Move content from elm to newTagName

    Returns T

  • Replace temporary elements from string

    Parameters

    • value: string

    Returns string

  • Parameters

    Returns void

  • Safe remove element from DOM

    Parameters

    • Rest ...nodes: unknown[]

    Returns void

  • Remove parent of node and insert this node instead that parent

    Parameters

    Returns void

  • Wrap node inside another node

    Type Parameters

    • K extends keyof HTMLElementTagNameMap

    Parameters

    Returns HTMLElementTagNameMap[K]

  • Wrap node inside another node

    Type Parameters

    • K extends keyof HTMLElementTagNameMap

    Parameters

    Returns HTMLElementTagNameMap[K]

Constructors

Jodit PRO

If you like Jodit - try Jodit PRO