API Docs for: 3.11.0-git
Show:

Editor.DOM Class

DOM utility methods for Editor.Base

Item Index

Methods

Methods

copyStyles

(
  • from
  • to
  • styles
  • [options]
)

Copies styles from a node to another node

Parameters:

  • from HTMLElement | Node
  • to HTMLElement | Node
  • styles Array
  • [options] Object optional
    • [explicit=false] Boolean optional

      When set to true copy only explicitly set properties from the source node. IOW, don't use computedStyle.

    • [overwrite=false] Boolean optional

      When set to true properties from the source node will overwrite the same property set on the destination node.

isElementNode

(
  • node
)
Boolean static

Returns true if the given node is an element node, false otherwise

Parameters:

  • node HTMLNode | Node

Returns:

Boolean:

true if the given node is an element node, false otherwise

isEmptyNode

(
  • node
)
Boolean static

Returns true if the given node is empty

Nodes containing only returns, tabs or linefeeds are considered empty Nodes containing only whitespace or breaks (br) are not considered empty

Parameters:

  • node HTMLNode | Node

Returns:

Boolean:

true if the given node is a empty, false otherwise

isTextNode

(
  • node
)
Boolean static

Returns true if the given node is a text node, false otherwise

Parameters:

  • node HTMLNode | Node

Returns:

Boolean:

true if the given node is a text node, false otherwise

maxOffset

(
  • node
)
Number static

Returns the maximum offset of a given node as determined by the type of node.

Element nodes will return the number of childNodes Text nodes will return the length of the text

Parameters:

  • node HTMLNode | Node

Returns:

Number:

Number of child nodes or length of text

split

(
  • node
  • offset
)
Node

Splits the given node at the specified offset

Parameters:

  • node Node

    The node to split

  • offset Number | Node

    Position to split the node. For text nodes this is numerical offset, for element nodes can be a a number referencing a childNode of node or a childNode reference.

Returns:

Node:

Node reference to the node created after splitting. It will be the nextSibling of node. If offset is not valid, the original node is returned.