slate 0.56.1 → 0.57.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/dist/create-editor.d.ts +1 -1
  2. package/dist/create-editor.d.ts.map +1 -1
  3. package/dist/index.d.ts +1 -1
  4. package/dist/index.d.ts.map +1 -1
  5. package/dist/index.es.js +4435 -6433
  6. package/dist/index.es.js.map +1 -1
  7. package/dist/index.js +4435 -6434
  8. package/dist/index.js.map +1 -1
  9. package/dist/interfaces/editor.d.ts +344 -0
  10. package/dist/interfaces/editor.d.ts.map +1 -0
  11. package/dist/interfaces/text.d.ts +5 -0
  12. package/dist/interfaces/text.d.ts.map +1 -1
  13. package/dist/slate.js +8269 -7673
  14. package/dist/slate.min.js +3 -3
  15. package/dist/transforms/general.d.ts +8 -0
  16. package/dist/transforms/general.d.ts.map +1 -0
  17. package/dist/transforms/index.d.ts +108 -0
  18. package/dist/transforms/index.d.ts.map +1 -0
  19. package/dist/{interfaces/editor/transforms → transforms}/node.d.ts +1 -1
  20. package/dist/transforms/node.d.ts.map +1 -0
  21. package/dist/{interfaces/editor/transforms → transforms}/selection.d.ts +1 -1
  22. package/dist/transforms/selection.d.ts.map +1 -0
  23. package/dist/{interfaces/editor/transforms → transforms}/text.d.ts +1 -1
  24. package/dist/transforms/text.d.ts.map +1 -0
  25. package/dist/utils/string.d.ts +12 -0
  26. package/dist/utils/string.d.ts.map +1 -0
  27. package/dist/utils/weak-maps.d.ts +8 -0
  28. package/dist/utils/weak-maps.d.ts.map +1 -0
  29. package/package.json +2 -2
  30. package/dist/interfaces/command.d.ts +0 -91
  31. package/dist/interfaces/command.d.ts.map +0 -1
  32. package/dist/interfaces/editor/index.d.ts +0 -235
  33. package/dist/interfaces/editor/index.d.ts.map +0 -1
  34. package/dist/interfaces/editor/queries/element.d.ts +0 -20
  35. package/dist/interfaces/editor/queries/element.d.ts.map +0 -1
  36. package/dist/interfaces/editor/queries/general.d.ts +0 -69
  37. package/dist/interfaces/editor/queries/general.d.ts.map +0 -1
  38. package/dist/interfaces/editor/queries/location.d.ts +0 -170
  39. package/dist/interfaces/editor/queries/location.d.ts.map +0 -1
  40. package/dist/interfaces/editor/queries/range.d.ts +0 -10
  41. package/dist/interfaces/editor/queries/range.d.ts.map +0 -1
  42. package/dist/interfaces/editor/transforms/general.d.ts +0 -15
  43. package/dist/interfaces/editor/transforms/general.d.ts.map +0 -1
  44. package/dist/interfaces/editor/transforms/node.d.ts.map +0 -1
  45. package/dist/interfaces/editor/transforms/selection.d.ts.map +0 -1
  46. package/dist/interfaces/editor/transforms/text.d.ts.map +0 -1
@@ -0,0 +1,344 @@
1
+ import { Ancestor, Descendant, Element, Location, Node, NodeEntry, Operation, Path, PathRef, Point, PointRef, Range, RangeRef, Span, Text } from '..';
2
+ /**
3
+ * The `Editor` interface stores all the state of a Slate editor. It is extended
4
+ * by plugins that wish to add their own helpers and implement new behaviors.
5
+ */
6
+ export interface Editor {
7
+ children: Node[];
8
+ selection: Range | null;
9
+ operations: Operation[];
10
+ marks: Record<string, any> | null;
11
+ [key: string]: any;
12
+ isInline: (element: Element) => boolean;
13
+ isVoid: (element: Element) => boolean;
14
+ normalizeNode: (entry: NodeEntry) => void;
15
+ onChange: () => void;
16
+ addMark: (key: string, value: any) => void;
17
+ apply: (operation: Operation) => void;
18
+ deleteBackward: (unit: 'character' | 'word' | 'line' | 'block') => void;
19
+ deleteForward: (unit: 'character' | 'word' | 'line' | 'block') => void;
20
+ deleteFragment: () => void;
21
+ getFragment: () => Descendant[];
22
+ insertBreak: () => void;
23
+ insertFragment: (fragment: Node[]) => void;
24
+ insertNode: (node: Node) => void;
25
+ insertText: (text: string) => void;
26
+ removeMark: (key: string) => void;
27
+ }
28
+ export declare const Editor: {
29
+ /**
30
+ * Get the ancestor above a location in the document.
31
+ */
32
+ above<T extends Ancestor>(editor: Editor, options?: {
33
+ at?: Range | Path | Point | undefined;
34
+ match?: ((node: Node) => boolean) | ((node: Node) => node is T) | undefined;
35
+ mode?: "highest" | "lowest" | undefined;
36
+ voids?: boolean | undefined;
37
+ }): NodeEntry<T> | undefined;
38
+ /**
39
+ * Add a custom property to the leaf text nodes in the current selection.
40
+ *
41
+ * If the selection is currently collapsed, the marks will be added to the
42
+ * `editor.marks` property instead, and applied when text is inserted next.
43
+ */
44
+ addMark(editor: Editor, key: string, value: any): void;
45
+ /**
46
+ * Get the point after a location.
47
+ */
48
+ after(editor: Editor, at: Location, options?: {
49
+ distance?: number | undefined;
50
+ unit?: "character" | "word" | "line" | "block" | "offset" | undefined;
51
+ }): Point | undefined;
52
+ /**
53
+ * Get the point before a location.
54
+ */
55
+ before(editor: Editor, at: Location, options?: {
56
+ distance?: number | undefined;
57
+ unit?: "character" | "word" | "line" | "block" | "offset" | undefined;
58
+ }): Point | undefined;
59
+ /**
60
+ * Delete content in the editor backward from the current selection.
61
+ */
62
+ deleteBackward(editor: Editor, options?: {
63
+ unit?: "character" | "word" | "line" | "block" | undefined;
64
+ }): void;
65
+ /**
66
+ * Delete content in the editor forward from the current selection.
67
+ */
68
+ deleteForward(editor: Editor, options?: {
69
+ unit?: "character" | "word" | "line" | "block" | undefined;
70
+ }): void;
71
+ /**
72
+ * Delete the content in the current selection.
73
+ */
74
+ deleteFragment(editor: Editor): void;
75
+ /**
76
+ * Get the start and end points of a location.
77
+ */
78
+ edges(editor: Editor, at: Location): [Point, Point];
79
+ /**
80
+ * Get the end point of a location.
81
+ */
82
+ end(editor: Editor, at: Location): Point;
83
+ /**
84
+ * Get the first node at a location.
85
+ */
86
+ first(editor: Editor, at: Location): NodeEntry<Node>;
87
+ /**
88
+ * Get the fragment at a location.
89
+ */
90
+ fragment(editor: Editor, at: Location): Descendant[];
91
+ /**
92
+ * Check if a node has block children.
93
+ */
94
+ hasBlocks(editor: Editor, element: Element): boolean;
95
+ /**
96
+ * Check if a node has inline and text children.
97
+ */
98
+ hasInlines(editor: Editor, element: Element): boolean;
99
+ /**
100
+ * Check if a node has text children.
101
+ */
102
+ hasTexts(editor: Editor, element: Element): boolean;
103
+ /**
104
+ * Insert a block break at the current selection.
105
+ *
106
+ * If the selection is currently expanded, it will be deleted first.
107
+ */
108
+ insertBreak(editor: Editor): void;
109
+ /**
110
+ * Insert a fragment at the current selection.
111
+ *
112
+ * If the selection is currently expanded, it will be deleted first.
113
+ */
114
+ insertFragment(editor: Editor, fragment: Node[]): void;
115
+ /**
116
+ * Insert a node at the current selection.
117
+ *
118
+ * If the selection is currently expanded, it will be deleted first.
119
+ */
120
+ insertNode(editor: Editor, node: Node): void;
121
+ /**
122
+ * Insert text at the current selection.
123
+ *
124
+ * If the selection is currently expanded, it will be deleted first.
125
+ */
126
+ insertText(editor: Editor, text: string): void;
127
+ /**
128
+ * Check if a value is a block `Element` object.
129
+ */
130
+ isBlock(editor: Editor, value: any): value is Element;
131
+ /**
132
+ * Check if a value is an `Editor` object.
133
+ */
134
+ isEditor(value: any): value is Editor;
135
+ /**
136
+ * Check if a point is the end point of a location.
137
+ */
138
+ isEnd(editor: Editor, point: Point, at: Location): boolean;
139
+ /**
140
+ * Check if a point is an edge of a location.
141
+ */
142
+ isEdge(editor: Editor, point: Point, at: Location): boolean;
143
+ /**
144
+ * Check if an element is empty, accounting for void nodes.
145
+ */
146
+ isEmpty(editor: Editor, element: Element): boolean;
147
+ /**
148
+ * Check if a value is an inline `Element` object.
149
+ */
150
+ isInline(editor: Editor, value: any): value is Element;
151
+ /**
152
+ * Check if the editor is currently normalizing after each operation.
153
+ */
154
+ isNormalizing(editor: Editor): boolean;
155
+ /**
156
+ * Check if a point is the start point of a location.
157
+ */
158
+ isStart(editor: Editor, point: Point, at: Location): boolean;
159
+ /**
160
+ * Check if a value is a void `Element` object.
161
+ */
162
+ isVoid(editor: Editor, value: any): value is Element;
163
+ /**
164
+ * Get the last node at a location.
165
+ */
166
+ last(editor: Editor, at: Location): NodeEntry<Node>;
167
+ /**
168
+ * Get the leaf text node at a location.
169
+ */
170
+ leaf(editor: Editor, at: Location, options?: {
171
+ depth?: number | undefined;
172
+ edge?: "start" | "end" | undefined;
173
+ }): NodeEntry<Text>;
174
+ /**
175
+ * Iterate through all of the levels at a location.
176
+ */
177
+ levels<T_1 extends Node>(editor: Editor, options?: {
178
+ at?: Range | Path | Point | undefined;
179
+ match?: ((node: Node) => boolean) | ((node: Node) => node is T_1) | undefined;
180
+ reverse?: boolean | undefined;
181
+ voids?: boolean | undefined;
182
+ }): Iterable<NodeEntry<T_1>>;
183
+ /**
184
+ * Get the marks that would be added to text at the current selection.
185
+ */
186
+ marks(editor: Editor): Record<string, any> | null;
187
+ /**
188
+ * Get the matching node in the branch of the document after a location.
189
+ */
190
+ next<T_2 extends Node>(editor: Editor, options?: {
191
+ at?: Range | Path | Point | undefined;
192
+ match?: ((node: Node) => boolean) | ((node: Node) => node is T_2) | undefined;
193
+ mode?: "highest" | "lowest" | "all" | undefined;
194
+ voids?: boolean | undefined;
195
+ }): NodeEntry<T_2> | undefined;
196
+ /**
197
+ * Get the node at a location.
198
+ */
199
+ node(editor: Editor, at: Location, options?: {
200
+ depth?: number | undefined;
201
+ edge?: "start" | "end" | undefined;
202
+ }): NodeEntry<Node>;
203
+ /**
204
+ * Iterate through all of the nodes in the Editor.
205
+ */
206
+ nodes<T_3 extends Node>(editor: Editor, options?: {
207
+ at?: Range | Path | Point | Span | undefined;
208
+ match?: ((node: Node) => boolean) | ((node: Node) => node is T_3) | undefined;
209
+ mode?: "highest" | "lowest" | "all" | undefined;
210
+ universal?: boolean | undefined;
211
+ reverse?: boolean | undefined;
212
+ voids?: boolean | undefined;
213
+ }): Iterable<NodeEntry<T_3>>;
214
+ /**
215
+ * Normalize any dirty objects in the editor.
216
+ */
217
+ normalize(editor: Editor, options?: {
218
+ force?: boolean | undefined;
219
+ }): void;
220
+ /**
221
+ * Get the parent node of a location.
222
+ */
223
+ parent(editor: Editor, at: Location, options?: {
224
+ depth?: number | undefined;
225
+ edge?: "start" | "end" | undefined;
226
+ }): NodeEntry<Ancestor>;
227
+ /**
228
+ * Get the path of a location.
229
+ */
230
+ path(editor: Editor, at: Location, options?: {
231
+ depth?: number | undefined;
232
+ edge?: "start" | "end" | undefined;
233
+ }): Path;
234
+ /**
235
+ * Create a mutable ref for a `Path` object, which will stay in sync as new
236
+ * operations are applied to the editor.
237
+ */
238
+ pathRef(editor: Editor, path: Path, options?: {
239
+ affinity?: "backward" | "forward" | null | undefined;
240
+ }): PathRef;
241
+ /**
242
+ * Get the set of currently tracked path refs of the editor.
243
+ */
244
+ pathRefs(editor: Editor): Set<PathRef>;
245
+ /**
246
+ * Get the start or end point of a location.
247
+ */
248
+ point(editor: Editor, at: Location, options?: {
249
+ edge?: "start" | "end" | undefined;
250
+ }): Point;
251
+ /**
252
+ * Create a mutable ref for a `Point` object, which will stay in sync as new
253
+ * operations are applied to the editor.
254
+ */
255
+ pointRef(editor: Editor, point: Point, options?: {
256
+ affinity?: "backward" | "forward" | null | undefined;
257
+ }): PointRef;
258
+ /**
259
+ * Get the set of currently tracked point refs of the editor.
260
+ */
261
+ pointRefs(editor: Editor): Set<PointRef>;
262
+ /**
263
+ * Iterate through all of the positions in the document where a `Point` can be
264
+ * placed.
265
+ *
266
+ * By default it will move forward by individual offsets at a time, but you
267
+ * can pass the `unit: 'character'` option to moved forward one character, word,
268
+ * or line at at time.
269
+ *
270
+ * Note: void nodes are treated as a single point, and iteration will not
271
+ * happen inside their content.
272
+ */
273
+ positions(editor: Editor, options?: {
274
+ at?: Range | Path | Point | undefined;
275
+ unit?: "character" | "word" | "line" | "block" | "offset" | undefined;
276
+ reverse?: boolean | undefined;
277
+ }): Iterable<Point>;
278
+ /**
279
+ * Get the matching node in the branch of the document before a location.
280
+ */
281
+ previous<T_4 extends Node>(editor: Editor, options?: {
282
+ at?: Range | Path | Point | undefined;
283
+ match?: ((node: Node) => boolean) | ((node: Node) => node is T_4) | undefined;
284
+ mode?: "highest" | "lowest" | "all" | undefined;
285
+ voids?: boolean | undefined;
286
+ }): NodeEntry<T_4> | undefined;
287
+ /**
288
+ * Get a range of a location.
289
+ */
290
+ range(editor: Editor, at: Location, to?: Range | Path | Point | undefined): Range;
291
+ /**
292
+ * Create a mutable ref for a `Range` object, which will stay in sync as new
293
+ * operations are applied to the editor.
294
+ */
295
+ rangeRef(editor: Editor, range: Range, options?: {
296
+ affinity?: "backward" | "forward" | "outward" | "inward" | null | undefined;
297
+ }): RangeRef;
298
+ /**
299
+ * Get the set of currently tracked range refs of the editor.
300
+ */
301
+ rangeRefs(editor: Editor): Set<RangeRef>;
302
+ /**
303
+ * Remove a custom property from all of the leaf text nodes in the current
304
+ * selection.
305
+ *
306
+ * If the selection is currently collapsed, the removal will be stored on
307
+ * `editor.marks` and applied to the text inserted next.
308
+ */
309
+ removeMark(editor: Editor, key: string): void;
310
+ /**
311
+ * Get the start point of a location.
312
+ */
313
+ start(editor: Editor, at: Location): Point;
314
+ /**
315
+ * Get the text string content of a location.
316
+ *
317
+ * Note: the text of void nodes is presumed to be an empty string, regardless
318
+ * of what their actual content is.
319
+ */
320
+ string(editor: Editor, at: Location): string;
321
+ /**
322
+ * Transform the editor by an operation.
323
+ */
324
+ transform(editor: Editor, op: Operation): void;
325
+ /**
326
+ * Convert a range into a non-hanging one.
327
+ */
328
+ unhangRange(editor: Editor, range: Range, options?: {
329
+ voids?: boolean | undefined;
330
+ }): Range;
331
+ /**
332
+ * Match a void node in the current branch of the editor.
333
+ */
334
+ void(editor: Editor, options?: {
335
+ at?: Range | Path | Point | undefined;
336
+ mode?: "highest" | "lowest" | undefined;
337
+ voids?: boolean | undefined;
338
+ }): NodeEntry<Element> | undefined;
339
+ /**
340
+ * Call a function, deferring normalization until after it completes.
341
+ */
342
+ withoutNormalizing(editor: Editor, fn: () => void): void;
343
+ };
344
+ //# sourceMappingURL=editor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"editor.d.ts","sourceRoot":"","sources":["../packages/slate/src/interfaces/editor.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,QAA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I,EAAE,IAAI,KAAK,IAAI,CAAA;IAChC,UAAU,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAA;IAClC,UAAU,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAA;CAClC;AAED,eAAO,MAAM,MAAM;IACjB;;OAEG;;;;;;;IAqCH;;;;;OAKG;;IAMH;;OAEG;;;;;IAgCH;;OAEG;;;;;IAoCH;;OAEG;;;;IAYH;;OAEG;;;;IAYH;;OAEG;;IAMH;;OAEG;;IAMH;;OAEG;;IAMH;;OAEG;;IAOH;;OAEG;;IAOH;;OAEG;;IAMH;;OAEG;;IAQH;;OAEG;;IAMH;;;;OAIG;;IAMH;;;;OAIG;;IAMH;;;;OAIG;;IAMH;;;;OAIG;;IAMH;;OAEG;;IAMH;;OAEG;;IA0BH;;OAEG;;IAOH;;OAEG;;IAMH;;OAEG;;IAcH;;OAEG;;IAMH;;OAEG;;IAOH;;OAEG;;IAYH;;OAEG;;IAMH;;OAEG;;IAOH;;OAEG;;;;;IAeH;;OAEG;;;;;;;IA4CH;;OAEG;;IAiDH;;OAEG;;;;;;;IAuCH;;OAEG;;;;;IAeH;;OAEG;;;;;;;;;IA4GH;;OAEG;;;;IA6CH;;OAEG;;;;;IAgBH;;OAEG;;;;;IA2CH;;;OAGG;;;;IA2BH;;OAEG;;IAaH;;OAEG;;;;IAyCH;;;OAGG;;;;IA2BH;;OAEG;;IAaH;;;;;;;;;;OAUG;;;;;;IAgHH;;OAEG;;;;;;;IA8CH;;OAEG;;IAYH;;;OAGG;;;;IA2BH;;OAEG;;IAaH;;;;;;OAMG;;IAMH;;OAEG;;IAMH;;;;;OAKG;;IA2BH;;OAEG;;IA2QH;;OAEG;;;;IA8CH;;OAEG;;;;;;IAgBH;;OAEG;;CASJ,CAAA"}
@@ -1,3 +1,4 @@
1
+ import { Range } from '..';
1
2
  /**
2
3
  * `Text` objects represent the nodes that contain the actual text content of a
3
4
  * Slate document along with any formatting properties. They are always leaf
@@ -29,5 +30,9 @@ export declare const Text: {
29
30
  * the `text` property are two nodes equal.
30
31
  */
31
32
  matches(text: Text, props: Partial<Text>): boolean;
33
+ /**
34
+ * Get the leaves for a text node given decorations.
35
+ */
36
+ decorations(node: Text, decorations: Range[]): Text[];
32
37
  };
33
38
  //# sourceMappingURL=text.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"text.d.ts","sourceRoot":"","sources":["../packages/slate/src/interfaces/text.ts"],"names":[],"mappings":"AAGA;;;;GAIG;AAEH,MAAM,WAAW,IAAI;IACnB,IAAI,EAAE,MAAM,CAAA;IACZ,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;CACnB;AAED,eAAO,MAAM,IAAI;IACf;;OAEG;;;;IAgCH;;OAEG;;IAMH;;OAEG;;IAMH;;;;;OAKG;;CAeJ,CAAA"}
1
+ {"version":3,"file":"text.d.ts","sourceRoot":"","sources":["../packages/slate/src/interfaces/text.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,IAAI,CAAA;AAE1B;;;;GAIG;AAEH,MAAM,WAAW,IAAI;IACnB,IAAI,EAAE,MAAM,CAAA;IACZ,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;CACnB;AAED,eAAO,MAAM,IAAI;IACf;;OAEG;;;;IAgCH;;OAEG;;IAMH;;OAEG;;IAMH;;;;;OAKG;;IAgBH;;OAEG;;CAsEJ,CAAA"}