UNPKG

wed

Version:

Wed is a schema-aware editor for XML documents.

103 lines (102 loc) 3.72 kB
import { SelectionMode } from "./selection-mode"; export declare const CLIPBOARD_NS = "http://mangalamresearch.org/ns/wed/clipboard"; /** * 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. */ export declare class Clipboard { private readonly tree; private readonly top; private _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. */ readonly mode: SelectionMode; /** * Sets the selection mode of this clipboard. * * @param vale The new mode. */ private setMode(value); /** * Clear the clipboard. * * Note that this clears only the contents of this object. **IT DOES NOT * AFFECT THE BROWSER'S CLIPBOARD!** */ clear(): 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. * * @param nodes The nodes to put. These nodes become property of the clipboard * after being added. If you want to keep the nodes in another document, clone * them first. */ putSpan(span: Node[] | string): void; /** * 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. * * @param node The node to check. * * @returns Whether the node can be added to this clipboard's data. */ canAddUnit(node: Node): boolean; /** * 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. * * @param 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. * * @param add Add to the clipboard, rather than replace the contents. */ putUnit(node: Node, add: boolean): void; /** * 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. * * @param text The text to test against. */ isSerializedTree(text: string): boolean; /** * @returns A deep copy of the tree in this clipboard. */ cloneTree(): Element; /** * 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. * * @param clipboardData The object to set. */ setupDOMClipboardData(clipboardData: DataTransfer): void; } /** * Check whether the element has a single child element which is a collection of * attributes. * * @param el The element to check. * * @returns Whether the element contains an attribute collection. */ export declare function containsClipboardAttributeCollection(el: Element): boolean;