A wrapper for a given element, which allows storing changes to be applied to the DOM structure later on.

Hierarchy (view full)

Implements

Constructors

  • Constructor.

    Parameters

    • delegate: Element

      the original element to wrap

    • editor: default

      CKEditor instance

    • namespaces: Namespaces = DEFAULT_NAMESPACES

      the namespaces to take into account

    • mutable: boolean = true

      signals, if this proxy should be mutable; trying to modify an immutable proxy will raise an error.

    Returns ElementProxy

Properties

classList: DOMTokenList = ...

A mutable list of classes applied to the element.

node: ElementProxy = ...

Represents the node instance. For ElementProxy this is just the proxy class itself.

Mimics ElementFilterParams, which helps to deal with rule processing.

parentRule: ElementFilterRule = ...

Represents the parent rule. No-Operation rule for ElementProxy.

Mimics ElementFilterParams, which helps to deal with rule processing.

Accessors

  • get attributes(): AttributeMap
  • Provides access to the attributes of the element. Any modifications are interpreted as modification requests, thus, they are not directly forwarded to the element, but need to be persisted later on.

    Setting an attribute to a new value, will change the value later on. Deleting an attribute, or setting its value to null will later remove the attribute from the element.

    Returns AttributeMap

  • get delegate(): Element
  • Returns the wrapped delegate.

    This delegate should not be used for directly manipulating the DOM, as nested rules may not veto applied changes.

    If a manipulation is done, it must be ensured, that previously run rules on this node may be rerun. It is generally considered safe to do manipulation to child elements, as these are processed after this node, so that all applicable rules have a chance to modify these nodes again.

    Returns Element

  • get editor(): default
  • Represents the editor instance. May be used to access configuration options for example.

    Mimics ElementFilterParams, which helps to deal with rule processing.

    Returns default

  • get element(): Element
  • Get direct access to the delegate element.

    Returns Element

  • get empty(): boolean
  • Signals, if this node is empty, thus, has no child nodes.

    Returns boolean

    See

    isEmpty

  • get lastNode(): boolean
  • Signals, if this is the last node in parent. Always false if no parent exists.

    Returns boolean

  • get mutable(): boolean
  • Signals, if this element is mutable.

    Returns boolean

  • get name(): string
  • Retrieve the name of the element. If the name got changed, will return this changed name instead.

    Returns string

  • set name(newName): void
  • Set a new name for this element. Setting a name different to the original name signals, that in the end the delegate element shall be replaced by the new element.

    Parameters

    • newName: string

      new name for the element; case does not matter.

    Returns void

  • get namespaceURI(): null | string
  • Get namespace URI of current element.

    Returns null | string

  • get ownerDocument(): Document
  • Access owner document.

    Returns Document

  • get parentElement(): null | NodeProxy<HTMLElement>
  • Access to the parent element of this node.

    Returns null | NodeProxy<HTMLElement>

  • get parentNode(): null | NodeProxy<Node & ParentNode>
  • Access to the parent node of this node.

    Returns null | NodeProxy<Node & ParentNode>

  • get realName(): string
  • Retrieves the name of the node (lower case). If renaming is supported by this instance, it may differ from name, otherwise, it is the same.

    Returns string

  • get remove(): boolean
  • Signals, if this node is meant to be removed. This includes recursive removal (including children) as well as just removing this node (replacing it by its children).

    Returns boolean

  • set remove(remove): void
  • Signals, if this mutable element represents a state, where the element shall be removed, including all its children.

    It is important to note, that setting this modifies the NodeProxy#state, thus setting this overrides any other decisions upon the state of the node.

    Duplicate Spaces: If you apply this modification, it may end up having duplicate space characters in your DOM. For example if removing the `` element (and all its children) in this scenario:

    Lorem Ipsum Dolor
    
    you will end up having:
    Lorem  Dolor
    
    with two white space characters in the middle. You may want to detect such states, and remove the duplicate space. You shouldn't do this, though, if you are within a space preserving context such as `
    `.

    Parameters

    • remove: boolean

    Returns void

  • get removeChildren(): boolean
  • Signals, if this node represents a state, where the children of the node should be removed.

    Returns boolean

  • set removeChildren(remove): void
  • Sets, if this node represents a state, where the children of the node shall be removed.

    It is important to note, that setting this modifies the NodeProxy#state, thus setting this overrides any other decisions upon the state of the node.

    Parameters

    • remove: boolean

      true to mark as remove children; false otherwise.

    Returns void

  • get replaceByChildren(): boolean
  • Signals, if this node represents a state, where the node shall be removed, while attaching the children to the parent node.

    Returns boolean

  • set replaceByChildren(replace): void
  • Sets, if this node represents a state, where the node shall be removed, while attaching the children to the parent node.

    It is important to note, that setting this modifies the NodeProxy#state, thus setting this overrides any other decisions upon the state of the node.

    Parameters

    • replace: boolean

      true to mark as replace with children; false otherwise.

    Returns void

  • get singleton(): boolean
  • Signals, if this is the only child node at parent node.

    Returns boolean

Methods

  • Apply given rules. If any of the rules will invalidate this element either by deletion, no further rules will be applied.

    Parameters

    Returns null | Node

    a node, if filtering should be continued from this node; null for default as next node.

  • Get first (matching) child node of the given element.

    Parameters

    • Optional condition: string | ChildPredicate

      string: the node name to match (ignoring case), predicate: the predicate to apply.

    Returns null | NodeProxy<ChildNode>

  • Signals, if this element is empty.

    Parameters

    • Optional considerChildNode: ChildPredicate

      signals, if a given node shall be considered while determining empty state

    Returns boolean

  • This provides a light-weight proxy, which is unaware of the editor. It is meant for testing purpose only, thus, not recommended for production use, as filters may rely on the editor property being set.

    Parameters

    • delegate: Element

      the original element to wrap

    Returns ElementProxy

  • Wraps the given node into a NodeProxy. If the node is falsy, null will be returned.

    Type Parameters

    • T extends Node

    Parameters

    • node: undefined | null | T

      node to wrap

    • mutable: boolean = true

      signals, if this representation is mutable or not

    Returns null | NodeProxy<T>

    NodeProxy for given node; null for falsy values