UNPKG

3.88 kBTypeScriptView Raw
1import { Editor, Element, Location, Node, Path } from '../../index';
2import { NodeMatch, PropsCompare, PropsMerge } from '../editor';
3import { MaximizeMode, RangeMode } from '../../types/types';
4export interface NodeInsertNodesOptions<T extends Node> {
5 at?: Location;
6 match?: NodeMatch<T>;
7 mode?: RangeMode;
8 hanging?: boolean;
9 select?: boolean;
10 voids?: boolean;
11 batchDirty?: boolean;
12}
13export interface NodeTransforms {
14 /**
15 * Insert nodes in the editor
16 * at the specified location or (if not defined) the current selection or (if not defined) the end of the document.
17 */
18 insertNodes: <T extends Node>(editor: Editor, nodes: Node | Node[], options?: NodeInsertNodesOptions<T>) => void;
19 /**
20 * Lift nodes at a specific location upwards in the document tree, splitting
21 * their parent in two if necessary.
22 */
23 liftNodes: <T extends Node>(editor: Editor, options?: {
24 at?: Location;
25 match?: NodeMatch<T>;
26 mode?: MaximizeMode;
27 voids?: boolean;
28 }) => void;
29 /**
30 * Merge a node at a location with the previous node of the same depth,
31 * removing any empty containing nodes after the merge if necessary.
32 */
33 mergeNodes: <T extends Node>(editor: Editor, options?: {
34 at?: Location;
35 match?: NodeMatch<T>;
36 mode?: RangeMode;
37 hanging?: boolean;
38 voids?: boolean;
39 }) => void;
40 /**
41 * Move the nodes at a location to a new location.
42 */
43 moveNodes: <T extends Node>(editor: Editor, options: {
44 at?: Location;
45 match?: NodeMatch<T>;
46 mode?: MaximizeMode;
47 to: Path;
48 voids?: boolean;
49 }) => void;
50 /**
51 * Remove the nodes at a specific location in the document.
52 */
53 removeNodes: <T extends Node>(editor: Editor, options?: {
54 at?: Location;
55 match?: NodeMatch<T>;
56 mode?: RangeMode;
57 hanging?: boolean;
58 voids?: boolean;
59 }) => void;
60 /**
61 * Set new properties on the nodes at a location.
62 */
63 setNodes: <T extends Node>(editor: Editor, props: Partial<T>, options?: {
64 at?: Location;
65 match?: NodeMatch<T>;
66 mode?: MaximizeMode;
67 hanging?: boolean;
68 split?: boolean;
69 voids?: boolean;
70 compare?: PropsCompare;
71 merge?: PropsMerge;
72 }) => void;
73 /**
74 * Split the nodes at a specific location.
75 */
76 splitNodes: <T extends Node>(editor: Editor, options?: {
77 at?: Location;
78 match?: NodeMatch<T>;
79 mode?: RangeMode;
80 always?: boolean;
81 height?: number;
82 voids?: boolean;
83 }) => void;
84 /**
85 * Unset properties on the nodes at a location.
86 */
87 unsetNodes: <T extends Node>(editor: Editor, props: string | string[], options?: {
88 at?: Location;
89 match?: NodeMatch<T>;
90 mode?: MaximizeMode;
91 hanging?: boolean;
92 split?: boolean;
93 voids?: boolean;
94 }) => void;
95 /**
96 * Unwrap the nodes at a location from a parent node, splitting the parent if
97 * necessary to ensure that only the content in the range is unwrapped.
98 */
99 unwrapNodes: <T extends Node>(editor: Editor, options?: {
100 at?: Location;
101 match?: NodeMatch<T>;
102 mode?: MaximizeMode;
103 split?: boolean;
104 voids?: boolean;
105 }) => void;
106 /**
107 * Wrap the nodes at a location in a new container node, splitting the edges
108 * of the range first to ensure that only the content in the range is wrapped.
109 */
110 wrapNodes: <T extends Node>(editor: Editor, element: Element, options?: {
111 at?: Location;
112 match?: NodeMatch<T>;
113 mode?: MaximizeMode;
114 split?: boolean;
115 voids?: boolean;
116 }) => void;
117}
118export declare const NodeTransforms: NodeTransforms;
119//# sourceMappingURL=node.d.ts.map
\No newline at end of file