Options
All
  • Public
  • Public/Protected
  • All
Menu

An internal clipboard for wed editors.

Due to the limitations of the clipboard API, wed maintains an internal clipboard which allows it to transfer data in a way meaningful to wed.

Hierarchy

  • Clipboard

Index

Properties

Private _mode

_mode: SelectionMode = SelectionMode.SPAN

Private top

top: Element = this.tree.firstElementChild!

Private tree

tree: Document = new DOMParser().parseFromString("<div/>", "text/xml")

Accessors

mode

  • The clipboard switches selection mode on the basis of how data is added to it, and the mode remains in effect until data is added in a way that changes the mode.

    Note that this property is independent of what the GUI is showing to the user. The property "remembers", so to speak, how the clipboard has been used.

    Returns SelectionMode

Methods

canAddUnit

  • canAddUnit(node: Node): boolean
  • Check whether a node can be added to this clipboard's data. Clipboards cannot contain heterogenous data. An attribute can be added only if the clipboard is empty or contains attributes. Another type of node can be added only if the clipboard does not contain attributes.

    Parameters

    • node: Node

      The node to check.

    Returns boolean

    Whether the node can be added to this clipboard's data.

clear

  • clear(): void
  • Clear the clipboard.

    Note that this clears only the contents of this object. IT DOES NOT AFFECT THE BROWSER'S CLIPBOARD!

    Returns void

cloneTree

  • cloneTree(): Element

isSerializedTree

  • isSerializedTree(text: string): boolean
  • Determines whether, in a paste operation, the tree that is stored in this clipboard, serialized, is equal to some text.

    This can be used as an optimization to avoid parsing anew text if the tree in the clipboard is already a parsed representation of that text.

    Parameters

    • text: string

      The text to test against.

    Returns boolean

putSpan

  • putSpan(span: Node[] | string): void
  • Puts a span of nodes into the clipboard. This method switches the clipboard to the span mode.

    Note that the clipboard is cleared before adding the nodes.

    Parameters

    • span: Node[] | string

    Returns void

putUnit

  • putUnit(node: Node, add: boolean): void
  • Puts a DOM node in the clipboard. This method switches the clipboard to unit mode.

    Note that the clipboard is cleared before adding the node.

    Parameters

    • node: Node

      The node to put. This node becomes property of the clipboard after being added. If you want to keep it in another document, clone it first.

    • add: boolean

      Add to the clipboard, rather than replace the contents.

    Returns void

Private setMode

setupDOMClipboardData

  • setupDOMClipboardData(clipboardData: DataTransfer): void
  • Set the DOM clipboard data to reflect what is stored in this wed-internal clipboard. Note that any old data in the DOM clipboard data is cleared before setting the new data.

    Parameters

    • clipboardData: DataTransfer

      The object to set.

    Returns void

Generated using TypeDoc