Module for working with DOM

Hierarchy

  • Dom

Constructors

Methods

  • Insert newElement after element

    Parameters

    Returns void

  • Insert newElement as last child inside element

    Parameters

    Returns void

  • Parameters

    Returns void

  • Insert newElement before element

    Parameters

    Returns void

  • Call functions for all nodes between start and end

    Parameters

    • start: Node
    • end: Node
    • callback: ((node) => boolean | void)
        • (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

    Parameters

    • elm: Node

      the element whose children and descendants you want to iterate over

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

      It called for each item found

        • (node): boolean | void
        • Parameters

          Returns boolean | void

    • leftToRight: boolean = true

    Returns boolean

    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
    }
    });
  • Find next/prev node what condition(next) === true

    Type Parameters

    Parameters

    Returns Nullable<T>

  • 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) => boolean) = ...
        • (n): boolean
        • Parameters

          Returns boolean

    Returns Nullable<Node>

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

    Parameters

    • node: Node
    • condition: NodeCondition
    • root: Node | HTMLElement
    • sibling: "nextSibling" | "previousSibling" = 'nextSibling'
    • child: "firstChild" | "lastChild" = 'firstChild'

    Returns Nullable<Node>

  • Check the node is a block element

    Parameters

    • node: unknown

      Object to check

    Returns node is HTMLDivElement

  • The node is editable

    Parameters

    Returns boolean

  • Check if element is element node

    Parameters

    • node: unknown

    Returns node is Element

  • Check if element is empty

    Parameters

    • node: Node
    • condNoEmptyElement: ((node) => boolean)
        • (node): boolean
        • Parameters

          Returns boolean

    Returns boolean

  • Parameters

    • node: Node
    • Optional noEmptyTags: Set<string>

    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

    Parameters

    Returns node is HTMLElementTagNameMap[K]

  • Type Parameters

    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

    Returns K

  • Move all content to another element

    Parameters

    • from: Node
    • to: Node
    • inStart: boolean = false
    • filter: ((node) => boolean) = ...
        • (node): boolean
        • Parameters

          Returns boolean

    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>

  • Insert newElement as first child inside element

    Parameters

    Returns void

  • Replace one tag to another transfer content

    Type Parameters

    Parameters

    • elm: Node

      The element that needs to be replaced by new

    • newTagName: HTMLTagNames

      tag name for which will change elm

    • create: ICreate
    • Optional withAttributes: boolean

      If true move tag's attributes

    • Optional notMoveContent: boolean

      false - Move content from elm to newTagName

    Returns T

    Example

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

    Parameters

    • elm: Node
    • newTagName: string | T
    • create: ICreate
    • Optional withAttributes: boolean
    • Optional notMoveContent: boolean

    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

  • It goes through all the elements in ascending order, and checks to see if they meet the predetermined condition

    Type Parameters

    Parameters

    Returns Nullable<T>

  • Wrap node inside another node

    Type Parameters

    Parameters

    Returns HTMLElementTagNameMap[K]

  • Wrap node inside another node

    Type Parameters

    Parameters

    Returns HTMLElementTagNameMap[K]

Jodit PRO

If you like Jodit - try Jodit PRO