@portabletext/editor 6.3.1 → 6.3.2
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.
- package/lib/_chunks-dts/behavior.types.action.d.ts +12 -583
- package/lib/_chunks-dts/behavior.types.action.d.ts.map +1 -1
- package/lib/index.js +2000 -2381
- package/lib/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -106,41 +106,10 @@ type ChildPath = [{
|
|
|
106
106
|
}, 'children', {
|
|
107
107
|
_key: string;
|
|
108
108
|
}];
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
type
|
|
113
|
-
type RangeMode = 'highest' | 'lowest';
|
|
114
|
-
type SelectionEdge = 'anchor' | 'focus' | 'start' | 'end';
|
|
115
|
-
type SelectionMode = 'all' | 'highest' | 'lowest';
|
|
116
|
-
type TextDirection = 'forward' | 'backward';
|
|
117
|
-
type TextUnit = 'character' | 'word' | 'line' | 'block';
|
|
118
|
-
type TextUnitAdjustment = TextUnit | 'offset';
|
|
119
|
-
type OmitFirstArg<F> = F extends ((x: any, ...args: infer P) => infer R) ? (...args: P) => R : never;
|
|
120
|
-
interface TextDeleteOptions {
|
|
121
|
-
at?: Location;
|
|
122
|
-
distance?: number;
|
|
123
|
-
unit?: TextUnit;
|
|
124
|
-
reverse?: boolean;
|
|
125
|
-
hanging?: boolean;
|
|
126
|
-
voids?: boolean;
|
|
127
|
-
}
|
|
128
|
-
interface TextInsertTextOptions {
|
|
129
|
-
at?: Location;
|
|
130
|
-
voids?: boolean;
|
|
131
|
-
}
|
|
132
|
-
interface TextTransforms {
|
|
133
|
-
/**
|
|
134
|
-
* Delete content in the editor.
|
|
135
|
-
*/
|
|
136
|
-
delete: (editor: Editor$1, options?: TextDeleteOptions) => void;
|
|
137
|
-
/**
|
|
138
|
-
* Insert a string of text in the editor
|
|
139
|
-
* at the specified location or (if not defined) the current selection or (if not defined) the end of the document.
|
|
140
|
-
*/
|
|
141
|
-
insertText: (editor: Editor$1, text: string, options?: TextInsertTextOptions) => void;
|
|
142
|
-
}
|
|
143
|
-
declare const TextTransforms: TextTransforms;
|
|
109
|
+
/**
|
|
110
|
+
* @public
|
|
111
|
+
*/
|
|
112
|
+
type EditorSchema = Schema;
|
|
144
113
|
/**
|
|
145
114
|
* The `Editor` interface stores all the state of a Slate editor. It is extended
|
|
146
115
|
* by plugins that wish to add their own helpers and implement new behaviors.
|
|
@@ -155,11 +124,14 @@ interface BaseEditor {
|
|
|
155
124
|
flushing: boolean;
|
|
156
125
|
normalizing: boolean;
|
|
157
126
|
batchingDirtyPaths: boolean;
|
|
127
|
+
pathRefs: Set<PathRef>;
|
|
128
|
+
pointRefs: Set<PointRef>;
|
|
129
|
+
rangeRefs: Set<RangeRef>;
|
|
158
130
|
apply: (operation: Operation) => void;
|
|
159
131
|
createSpan: () => Text$1;
|
|
160
132
|
getDirtyPaths: (operation: Operation) => Path$1[];
|
|
161
|
-
getFragment: () => Descendant[];
|
|
162
133
|
isElementReadOnly: (element: Element$1) => boolean;
|
|
134
|
+
isInline: (element: Element$1) => boolean;
|
|
163
135
|
isSelectable: (element: Element$1) => boolean;
|
|
164
136
|
normalizeNode: (entry: NodeEntry, options?: {
|
|
165
137
|
operation?: Operation;
|
|
@@ -177,357 +149,19 @@ interface BaseEditor {
|
|
|
177
149
|
dirtyPaths: Path$1[];
|
|
178
150
|
operation?: Operation;
|
|
179
151
|
}) => boolean;
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
deselect: OmitFirstArg<typeof Transforms.deselect>;
|
|
183
|
-
insertBreak: OmitFirstArg<typeof Editor$1.insertBreak>;
|
|
184
|
-
insertNodes: OmitFirstArg<typeof Transforms.insertNodes>;
|
|
185
|
-
insertText: OmitFirstArg<typeof Transforms.insertText>;
|
|
186
|
-
move: OmitFirstArg<typeof Transforms.move>;
|
|
187
|
-
normalize: OmitFirstArg<typeof Editor$1.normalize>;
|
|
188
|
-
removeNodes: OmitFirstArg<typeof Transforms.removeNodes>;
|
|
189
|
-
select: OmitFirstArg<typeof Transforms.select>;
|
|
190
|
-
setNormalizing: OmitFirstArg<typeof Editor$1.setNormalizing>;
|
|
191
|
-
setSelection: OmitFirstArg<typeof Transforms.setSelection>;
|
|
192
|
-
withoutNormalizing: OmitFirstArg<typeof Editor$1.withoutNormalizing>;
|
|
193
|
-
above: <T extends Ancestor>(options?: EditorAboveOptions<T>) => NodeEntry<T> | undefined;
|
|
194
|
-
after: OmitFirstArg<typeof Editor$1.after>;
|
|
195
|
-
before: OmitFirstArg<typeof Editor$1.before>;
|
|
196
|
-
elementReadOnly: OmitFirstArg<typeof Editor$1.elementReadOnly>;
|
|
197
|
-
end: OmitFirstArg<typeof Editor$1.end>;
|
|
198
|
-
hasInlines: OmitFirstArg<typeof Editor$1.hasInlines>;
|
|
199
|
-
hasPath: OmitFirstArg<typeof Editor$1.hasPath>;
|
|
200
|
-
isBlock: OmitFirstArg<typeof Editor$1.isBlock>;
|
|
201
|
-
isEdge: OmitFirstArg<typeof Editor$1.isEdge>;
|
|
202
|
-
isEnd: OmitFirstArg<typeof Editor$1.isEnd>;
|
|
203
|
-
isInline: OmitFirstArg<typeof Editor$1.isInline>;
|
|
204
|
-
isNormalizing: OmitFirstArg<typeof Editor$1.isNormalizing>;
|
|
205
|
-
isStart: OmitFirstArg<typeof Editor$1.isStart>;
|
|
206
|
-
leaf: OmitFirstArg<typeof Editor$1.leaf>;
|
|
207
|
-
levels: <T extends Node$1>(options?: EditorLevelsOptions<T>) => Generator<NodeEntry<T>, void, undefined>;
|
|
208
|
-
next: <T extends Descendant>(options?: EditorNextOptions<T>) => NodeEntry<T> | undefined;
|
|
209
|
-
node: OmitFirstArg<typeof Editor$1.node>;
|
|
210
|
-
nodes: <T extends Node$1>(options?: EditorNodesOptions<T>) => Generator<NodeEntry<T>, void, undefined>;
|
|
211
|
-
parent: OmitFirstArg<typeof Editor$1.parent>;
|
|
212
|
-
path: OmitFirstArg<typeof Editor$1.path>;
|
|
213
|
-
pathRef: OmitFirstArg<typeof Editor$1.pathRef>;
|
|
214
|
-
pathRefs: Set<PathRef>;
|
|
215
|
-
point: OmitFirstArg<typeof Editor$1.point>;
|
|
216
|
-
pointRef: OmitFirstArg<typeof Editor$1.pointRef>;
|
|
217
|
-
pointRefs: Set<PointRef>;
|
|
218
|
-
positions: OmitFirstArg<typeof Editor$1.positions>;
|
|
219
|
-
previous: <T extends Node$1>(options?: EditorPreviousOptions<T>) => NodeEntry<T> | undefined;
|
|
220
|
-
range: OmitFirstArg<typeof Editor$1.range>;
|
|
221
|
-
rangeRef: OmitFirstArg<typeof Editor$1.rangeRef>;
|
|
222
|
-
rangeRefs: Set<RangeRef>;
|
|
223
|
-
start: OmitFirstArg<typeof Editor$1.start>;
|
|
224
|
-
string: OmitFirstArg<typeof Editor$1.string>;
|
|
225
|
-
unhangRange: OmitFirstArg<typeof Editor$1.unhangRange>;
|
|
226
|
-
void: OmitFirstArg<typeof Editor$1.void>;
|
|
227
|
-
shouldMergeNodesRemovePrevNode: OmitFirstArg<typeof Editor$1.shouldMergeNodesRemovePrevNode>;
|
|
152
|
+
select: (target: Location) => void;
|
|
153
|
+
setSelection: (props: Partial<Range>) => void;
|
|
228
154
|
}
|
|
229
155
|
type Editor$1 = ExtendedType<'Editor', BaseEditor>;
|
|
230
156
|
type BaseSelection = Range | null;
|
|
231
157
|
type Selection$1 = ExtendedType<'Selection', BaseSelection>;
|
|
232
158
|
type EditorMarks = Omit<Text$1, 'text'>;
|
|
233
|
-
interface EditorAboveOptions<T extends Ancestor> {
|
|
234
|
-
at?: Location;
|
|
235
|
-
match?: NodeMatch<T>;
|
|
236
|
-
mode?: MaximizeMode;
|
|
237
|
-
voids?: boolean;
|
|
238
|
-
}
|
|
239
|
-
interface EditorAfterOptions {
|
|
240
|
-
distance?: number;
|
|
241
|
-
unit?: TextUnitAdjustment;
|
|
242
|
-
voids?: boolean;
|
|
243
|
-
}
|
|
244
|
-
interface EditorBeforeOptions {
|
|
245
|
-
distance?: number;
|
|
246
|
-
unit?: TextUnitAdjustment;
|
|
247
|
-
voids?: boolean;
|
|
248
|
-
}
|
|
249
|
-
interface EditorElementReadOnlyOptions {
|
|
250
|
-
at?: Location;
|
|
251
|
-
mode?: MaximizeMode;
|
|
252
|
-
voids?: boolean;
|
|
253
|
-
}
|
|
254
|
-
interface EditorLeafOptions {
|
|
255
|
-
depth?: number;
|
|
256
|
-
edge?: LeafEdge;
|
|
257
|
-
}
|
|
258
|
-
interface EditorLevelsOptions<T extends Node$1> {
|
|
259
|
-
at?: Location;
|
|
260
|
-
match?: NodeMatch<T>;
|
|
261
|
-
reverse?: boolean;
|
|
262
|
-
voids?: boolean;
|
|
263
|
-
}
|
|
264
|
-
interface EditorNextOptions<T extends Descendant> {
|
|
265
|
-
at?: Location;
|
|
266
|
-
match?: NodeMatch<T>;
|
|
267
|
-
mode?: SelectionMode;
|
|
268
|
-
voids?: boolean;
|
|
269
|
-
}
|
|
270
|
-
interface EditorNodeOptions {
|
|
271
|
-
depth?: number;
|
|
272
|
-
edge?: LeafEdge;
|
|
273
|
-
}
|
|
274
|
-
interface EditorNodesOptions<T extends Node$1> {
|
|
275
|
-
at?: Location | Span;
|
|
276
|
-
match?: NodeMatch<T>;
|
|
277
|
-
mode?: SelectionMode;
|
|
278
|
-
universal?: boolean;
|
|
279
|
-
reverse?: boolean;
|
|
280
|
-
voids?: boolean;
|
|
281
|
-
pass?: (entry: NodeEntry) => boolean;
|
|
282
|
-
}
|
|
283
|
-
interface EditorNormalizeOptions {
|
|
284
|
-
force?: boolean;
|
|
285
|
-
operation?: Operation;
|
|
286
|
-
}
|
|
287
|
-
interface EditorParentOptions {
|
|
288
|
-
depth?: number;
|
|
289
|
-
edge?: LeafEdge;
|
|
290
|
-
}
|
|
291
|
-
interface EditorPathOptions {
|
|
292
|
-
depth?: number;
|
|
293
|
-
edge?: LeafEdge;
|
|
294
|
-
}
|
|
295
|
-
interface EditorPathRefOptions {
|
|
296
|
-
affinity?: TextDirection | null;
|
|
297
|
-
}
|
|
298
|
-
interface EditorPointOptions {
|
|
299
|
-
edge?: LeafEdge;
|
|
300
|
-
}
|
|
301
|
-
interface EditorPointRefOptions {
|
|
302
|
-
affinity?: TextDirection | null;
|
|
303
|
-
}
|
|
304
|
-
interface EditorPositionsOptions {
|
|
305
|
-
at?: Location;
|
|
306
|
-
unit?: TextUnitAdjustment;
|
|
307
|
-
reverse?: boolean;
|
|
308
|
-
voids?: boolean;
|
|
309
|
-
}
|
|
310
|
-
interface EditorPreviousOptions<T extends Node$1> {
|
|
311
|
-
at?: Location;
|
|
312
|
-
match?: NodeMatch<T>;
|
|
313
|
-
mode?: SelectionMode;
|
|
314
|
-
voids?: boolean;
|
|
315
|
-
}
|
|
316
|
-
interface EditorRangeRefOptions {
|
|
317
|
-
affinity?: RangeDirection | null;
|
|
318
|
-
}
|
|
319
|
-
interface EditorStringOptions {
|
|
320
|
-
voids?: boolean;
|
|
321
|
-
}
|
|
322
|
-
interface EditorUnhangRangeOptions {
|
|
323
|
-
voids?: boolean;
|
|
324
|
-
}
|
|
325
|
-
interface EditorVoidOptions {
|
|
326
|
-
at?: Location;
|
|
327
|
-
mode?: MaximizeMode;
|
|
328
|
-
voids?: boolean;
|
|
329
|
-
}
|
|
330
159
|
interface EditorInterface {
|
|
331
|
-
/**
|
|
332
|
-
* Get the ancestor above a location in the document.
|
|
333
|
-
*/
|
|
334
|
-
above: <T extends Ancestor>(editor: Editor$1, options?: EditorAboveOptions<T>) => NodeEntry<T> | undefined;
|
|
335
|
-
/**
|
|
336
|
-
* Get the point after a location.
|
|
337
|
-
*/
|
|
338
|
-
after: (editor: Editor$1, at: Location, options?: EditorAfterOptions) => Point | undefined;
|
|
339
|
-
/**
|
|
340
|
-
* Get the point before a location.
|
|
341
|
-
*/
|
|
342
|
-
before: (editor: Editor$1, at: Location, options?: EditorBeforeOptions) => Point | undefined;
|
|
343
|
-
/**
|
|
344
|
-
* Match a read-only element in the current branch of the editor.
|
|
345
|
-
*/
|
|
346
|
-
elementReadOnly: (editor: Editor$1, options?: EditorElementReadOnlyOptions) => NodeEntry<Element$1> | undefined;
|
|
347
|
-
/**
|
|
348
|
-
* Get the end point of a location.
|
|
349
|
-
*/
|
|
350
|
-
end: (editor: Editor$1, at: Location) => Point;
|
|
351
|
-
/**
|
|
352
|
-
* Check if a node has inline and text children.
|
|
353
|
-
*/
|
|
354
|
-
hasInlines: (editor: Editor$1, element: Element$1) => boolean;
|
|
355
|
-
hasPath: (editor: Editor$1, path: Path$1) => boolean;
|
|
356
|
-
/**
|
|
357
|
-
* Insert a block break at the current selection.
|
|
358
|
-
*
|
|
359
|
-
* If the selection is currently expanded, it will be deleted first.
|
|
360
|
-
*/
|
|
361
|
-
insertBreak: (editor: Editor$1) => void;
|
|
362
|
-
/**
|
|
363
|
-
* Insert a string of text
|
|
364
|
-
* at the specified location or (if not defined) the current selection or (if not defined) the end of the document.
|
|
365
|
-
*/
|
|
366
|
-
insertText: (editor: Editor$1, text: string, options?: TextInsertTextOptions) => void;
|
|
367
|
-
/**
|
|
368
|
-
* Check if a value is a block `Element` object.
|
|
369
|
-
*/
|
|
370
|
-
isBlock: (editor: Editor$1, value: Element$1) => boolean;
|
|
371
|
-
/**
|
|
372
|
-
* Check if a point is an edge of a location.
|
|
373
|
-
*/
|
|
374
|
-
isEdge: (editor: Editor$1, point: Point, at: Location) => boolean;
|
|
375
|
-
/**
|
|
376
|
-
* Check if a value is an `Editor` object.
|
|
377
|
-
*/
|
|
378
|
-
isEditor: (value: any) => value is Editor$1;
|
|
379
|
-
/**
|
|
380
|
-
* Check if a value is a read-only `Element` object.
|
|
381
|
-
*/
|
|
382
160
|
isElementReadOnly: (editor: Editor$1, element: Element$1) => boolean;
|
|
383
|
-
/**
|
|
384
|
-
* Check if a point is the end point of a location.
|
|
385
|
-
*/
|
|
386
|
-
isEnd: (editor: Editor$1, point: Point, at: Location) => boolean;
|
|
387
|
-
/**
|
|
388
|
-
* Check if a value is an inline `Element` object.
|
|
389
|
-
*/
|
|
390
161
|
isInline: (editor: Editor$1, value: Element$1) => boolean;
|
|
391
|
-
/**
|
|
392
|
-
* Check if the editor is currently normalizing after each operation.
|
|
393
|
-
*/
|
|
394
|
-
isNormalizing: (editor: Editor$1) => boolean;
|
|
395
|
-
/**
|
|
396
|
-
* Check if a value is a selectable `Element` object.
|
|
397
|
-
*/
|
|
398
162
|
isSelectable: (editor: Editor$1, element: Element$1) => boolean;
|
|
399
|
-
/**
|
|
400
|
-
* Check if a point is the start point of a location.
|
|
401
|
-
*/
|
|
402
|
-
isStart: (editor: Editor$1, point: Point, at: Location) => boolean;
|
|
403
|
-
/**
|
|
404
|
-
* Get the leaf text node at a location.
|
|
405
|
-
*/
|
|
406
|
-
leaf: (editor: Editor$1, at: Location, options?: EditorLeafOptions) => NodeEntry<Text$1 | ObjectNode>;
|
|
407
|
-
/**
|
|
408
|
-
* Iterate through all of the levels at a location.
|
|
409
|
-
*/
|
|
410
|
-
levels: <T extends Node$1>(editor: Editor$1, options?: EditorLevelsOptions<T>) => Generator<NodeEntry<T>, void, undefined>;
|
|
411
|
-
/**
|
|
412
|
-
* Get the matching node in the branch of the document after a location.
|
|
413
|
-
*/
|
|
414
|
-
next: <T extends Descendant>(editor: Editor$1, options?: EditorNextOptions<T>) => NodeEntry<T> | undefined;
|
|
415
|
-
/**
|
|
416
|
-
* Get the node at a location.
|
|
417
|
-
*/
|
|
418
|
-
node: (editor: Editor$1, at: Location, options?: EditorNodeOptions) => NodeEntry;
|
|
419
|
-
/**
|
|
420
|
-
* Iterate through all of the nodes in the Editor.
|
|
421
|
-
*/
|
|
422
|
-
nodes: <T extends Node$1>(editor: Editor$1, options?: EditorNodesOptions<T>) => Generator<NodeEntry<T>, void, undefined>;
|
|
423
|
-
/**
|
|
424
|
-
* Normalize any dirty objects in the editor.
|
|
425
|
-
*/
|
|
426
|
-
normalize: (editor: Editor$1, options?: EditorNormalizeOptions) => void;
|
|
427
|
-
/**
|
|
428
|
-
* Get the parent node of a location.
|
|
429
|
-
*/
|
|
430
|
-
parent: (editor: Editor$1, at: Location, options?: EditorParentOptions) => NodeEntry<Ancestor>;
|
|
431
|
-
/**
|
|
432
|
-
* Get the path of a location.
|
|
433
|
-
*/
|
|
434
|
-
path: (editor: Editor$1, at: Location, options?: EditorPathOptions) => Path$1;
|
|
435
|
-
/**
|
|
436
|
-
* Create a mutable ref for a `Path` object, which will stay in sync as new
|
|
437
|
-
* operations are applied to the editor.
|
|
438
|
-
*/
|
|
439
|
-
pathRef: (editor: Editor$1, path: Path$1, options?: EditorPathRefOptions) => PathRef;
|
|
440
|
-
/**
|
|
441
|
-
* Get the set of currently tracked path refs of the editor.
|
|
442
|
-
*/
|
|
443
|
-
pathRefs: (editor: Editor$1) => Set<PathRef>;
|
|
444
|
-
/**
|
|
445
|
-
* Get the start or end point of a location.
|
|
446
|
-
*/
|
|
447
|
-
point: (editor: Editor$1, at: Location, options?: EditorPointOptions) => Point;
|
|
448
|
-
/**
|
|
449
|
-
* Create a mutable ref for a `Point` object, which will stay in sync as new
|
|
450
|
-
* operations are applied to the editor.
|
|
451
|
-
*/
|
|
452
|
-
pointRef: (editor: Editor$1, point: Point, options?: EditorPointRefOptions) => PointRef;
|
|
453
|
-
/**
|
|
454
|
-
* Get the set of currently tracked point refs of the editor.
|
|
455
|
-
*/
|
|
456
|
-
pointRefs: (editor: Editor$1) => Set<PointRef>;
|
|
457
|
-
/**
|
|
458
|
-
* Return all the positions in `at` range where a `Point` can be placed.
|
|
459
|
-
*
|
|
460
|
-
* By default, moves forward by individual offsets at a time, but
|
|
461
|
-
* the `unit` option can be used to to move by character, word, line, or block.
|
|
462
|
-
*
|
|
463
|
-
* The `reverse` option can be used to change iteration direction.
|
|
464
|
-
*
|
|
465
|
-
* Note: By default void nodes are treated as a single point and iteration
|
|
466
|
-
* will not happen inside their content unless you pass in true for the
|
|
467
|
-
* `voids` option, then iteration will occur.
|
|
468
|
-
*/
|
|
469
|
-
positions: (editor: Editor$1, options?: EditorPositionsOptions) => Generator<Point, void, undefined>;
|
|
470
|
-
/**
|
|
471
|
-
* Get the matching node in the branch of the document before a location.
|
|
472
|
-
*/
|
|
473
|
-
previous: <T extends Node$1>(editor: Editor$1, options?: EditorPreviousOptions<T>) => NodeEntry<T> | undefined;
|
|
474
|
-
/**
|
|
475
|
-
* Get a range of a location.
|
|
476
|
-
*/
|
|
477
|
-
range: (editor: Editor$1, at: Location, to?: Location) => Range;
|
|
478
|
-
/**
|
|
479
|
-
* Create a mutable ref for a `Range` object, which will stay in sync as new
|
|
480
|
-
* operations are applied to the editor.
|
|
481
|
-
*/
|
|
482
|
-
rangeRef: (editor: Editor$1, range: Range, options?: EditorRangeRefOptions) => RangeRef;
|
|
483
|
-
/**
|
|
484
|
-
* Get the set of currently tracked range refs of the editor.
|
|
485
|
-
*/
|
|
486
|
-
rangeRefs: (editor: Editor$1) => Set<RangeRef>;
|
|
487
|
-
/**
|
|
488
|
-
* Manually set if the editor should currently be normalizing.
|
|
489
|
-
*
|
|
490
|
-
* Note: Using this incorrectly can leave the editor in an invalid state.
|
|
491
|
-
*
|
|
492
|
-
*/
|
|
493
|
-
setNormalizing: (editor: Editor$1, isNormalizing: boolean) => void;
|
|
494
|
-
/**
|
|
495
|
-
* Get the start point of a location.
|
|
496
|
-
*/
|
|
497
|
-
start: (editor: Editor$1, at: Location) => Point;
|
|
498
|
-
/**
|
|
499
|
-
* Get the text string content of a location.
|
|
500
|
-
*
|
|
501
|
-
* Note: by default the text of void nodes is considered to be an empty
|
|
502
|
-
* string, regardless of content, unless you pass in true for the voids option
|
|
503
|
-
*/
|
|
504
|
-
string: (editor: Editor$1, at: Location, options?: EditorStringOptions) => string;
|
|
505
|
-
/**
|
|
506
|
-
* Convert a range into a non-hanging one.
|
|
507
|
-
*/
|
|
508
|
-
unhangRange: (editor: Editor$1, range: Range, options?: EditorUnhangRangeOptions) => Range;
|
|
509
|
-
/**
|
|
510
|
-
* Match a void node in the current branch of the editor.
|
|
511
|
-
*/
|
|
512
|
-
void: (editor: Editor$1, options?: EditorVoidOptions) => NodeEntry<Element$1> | undefined;
|
|
513
|
-
/**
|
|
514
|
-
* Call a function, deferring normalization until after it completes.
|
|
515
|
-
*/
|
|
516
|
-
withoutNormalizing: (editor: Editor$1, fn: () => void) => void;
|
|
517
|
-
/**
|
|
518
|
-
* Call a function, Determine whether or not remove the previous node when merge.
|
|
519
|
-
*/
|
|
520
|
-
shouldMergeNodesRemovePrevNode: (editor: Editor$1, prevNodeEntry: NodeEntry, curNodeEntry: NodeEntry) => boolean;
|
|
521
163
|
}
|
|
522
164
|
declare const Editor$1: EditorInterface;
|
|
523
|
-
/**
|
|
524
|
-
* A helper type for narrowing matched nodes with a predicate.
|
|
525
|
-
*/
|
|
526
|
-
type NodeMatch<T extends Node$1> = ((node: Node$1, path: Path$1) => node is T) | ((node: Node$1, path: Path$1) => boolean);
|
|
527
|
-
/**
|
|
528
|
-
* @public
|
|
529
|
-
*/
|
|
530
|
-
type EditorSchema = Schema;
|
|
531
165
|
/**
|
|
532
166
|
* `Element` objects are a type of node in a Slate document that contain other
|
|
533
167
|
* element nodes or text nodes. They can be either "blocks" or "inlines"
|
|
@@ -557,18 +191,6 @@ declare const Element$1: ElementInterface;
|
|
|
557
191
|
* converting between the different interfaces in their own code base.
|
|
558
192
|
*/
|
|
559
193
|
type Location = Path$1 | Point | Range;
|
|
560
|
-
/**
|
|
561
|
-
* The `Span` interface is a low-level way to refer to locations in nodes
|
|
562
|
-
* without using `Point` which requires leaf text nodes to be present.
|
|
563
|
-
*/
|
|
564
|
-
type Span = [Path$1, Path$1];
|
|
565
|
-
interface SpanInterface {
|
|
566
|
-
/**
|
|
567
|
-
* Check if a value implements the `Span` interface.
|
|
568
|
-
*/
|
|
569
|
-
isSpan: (value: any) => value is Span;
|
|
570
|
-
}
|
|
571
|
-
declare const Span: SpanInterface;
|
|
572
194
|
/**
|
|
573
195
|
* Extendable Custom Types Interface
|
|
574
196
|
*/
|
|
@@ -588,120 +210,6 @@ interface BaseObjectNode {
|
|
|
588
210
|
}
|
|
589
211
|
type ObjectNode = ExtendedType<'ObjectNode', BaseObjectNode>;
|
|
590
212
|
type Node$1 = Editor$1 | Element$1 | ObjectNode | Text$1;
|
|
591
|
-
interface NodeChildrenOptions {
|
|
592
|
-
reverse?: boolean;
|
|
593
|
-
}
|
|
594
|
-
interface NodeLevelsOptions {
|
|
595
|
-
reverse?: boolean;
|
|
596
|
-
}
|
|
597
|
-
interface NodeNodesOptions {
|
|
598
|
-
from?: Path$1;
|
|
599
|
-
to?: Path$1;
|
|
600
|
-
reverse?: boolean;
|
|
601
|
-
pass?: (entry: NodeEntry) => boolean;
|
|
602
|
-
}
|
|
603
|
-
interface NodeTextsOptions {
|
|
604
|
-
from?: Path$1;
|
|
605
|
-
to?: Path$1;
|
|
606
|
-
reverse?: boolean;
|
|
607
|
-
pass?: (node: NodeEntry) => boolean;
|
|
608
|
-
}
|
|
609
|
-
interface NodeInterface {
|
|
610
|
-
/**
|
|
611
|
-
* Get the node at a specific path, asserting that it's an ancestor node.
|
|
612
|
-
*/
|
|
613
|
-
ancestor: (root: Node$1, path: Path$1, schema: EditorSchema) => Ancestor;
|
|
614
|
-
/**
|
|
615
|
-
* Get the child of a node at a specific index.
|
|
616
|
-
*/
|
|
617
|
-
child: (root: Node$1, index: number, schema: EditorSchema) => Descendant;
|
|
618
|
-
/**
|
|
619
|
-
* Iterate over the children of a node at a specific path.
|
|
620
|
-
*/
|
|
621
|
-
children: (root: Node$1, path: Path$1, schema: EditorSchema, options?: NodeChildrenOptions) => Generator<NodeEntry<Descendant>, void, undefined>;
|
|
622
|
-
/**
|
|
623
|
-
* Extract props from a Node.
|
|
624
|
-
*/
|
|
625
|
-
extractProps: (node: Node$1, schema: EditorSchema) => NodeProps;
|
|
626
|
-
/**
|
|
627
|
-
* Get the first leaf node entry in a root node from a path.
|
|
628
|
-
*/
|
|
629
|
-
first: (root: Node$1, path: Path$1, schema: EditorSchema) => NodeEntry;
|
|
630
|
-
/**
|
|
631
|
-
* Get the sliced fragment represented by a range inside a root node.
|
|
632
|
-
*/
|
|
633
|
-
fragment: <T extends Ancestor = Editor$1>(root: T, range: Range, schema: EditorSchema) => T['children'];
|
|
634
|
-
/**
|
|
635
|
-
* Get the descendant node referred to by a specific path. If the path is an
|
|
636
|
-
* empty array, it refers to the root node itself.
|
|
637
|
-
*/
|
|
638
|
-
get: (root: Node$1, path: Path$1, schema: EditorSchema) => Node$1;
|
|
639
|
-
/**
|
|
640
|
-
* Similar to get, but returns undefined if the node does not exist.
|
|
641
|
-
*/
|
|
642
|
-
getIf: (root: Node$1, path: Path$1, schema: EditorSchema) => Node$1 | undefined;
|
|
643
|
-
/**
|
|
644
|
-
* Check if a descendant node exists at a specific path.
|
|
645
|
-
*/
|
|
646
|
-
has: (root: Node$1, path: Path$1, schema: EditorSchema) => boolean;
|
|
647
|
-
/**
|
|
648
|
-
* Check if a value implements the `Node` interface.
|
|
649
|
-
*/
|
|
650
|
-
isNode: (value: any, schema: EditorSchema) => value is Node$1;
|
|
651
|
-
/**
|
|
652
|
-
* Check if a value is a list of `Node` objects.
|
|
653
|
-
*/
|
|
654
|
-
isNodeList: (value: any, schema: EditorSchema) => value is Node$1[];
|
|
655
|
-
/**
|
|
656
|
-
* Check if a value is a leaf node (Text or ObjectNode).
|
|
657
|
-
* Leaf nodes have no children to descend into.
|
|
658
|
-
*/
|
|
659
|
-
isLeaf: (value: any, schema: EditorSchema) => boolean;
|
|
660
|
-
/**
|
|
661
|
-
* Check if a value is an ObjectNode. Uses schema to determine whether
|
|
662
|
-
* a node's _type is neither the block type name nor the span type name.
|
|
663
|
-
*/
|
|
664
|
-
isObjectNode: (value: any, schema: EditorSchema) => value is ObjectNode;
|
|
665
|
-
/**
|
|
666
|
-
* Get the last leaf node entry in a root node from a path.
|
|
667
|
-
*/
|
|
668
|
-
last: (root: Node$1, path: Path$1, schema: EditorSchema) => NodeEntry;
|
|
669
|
-
/**
|
|
670
|
-
* Get the node at a specific path, ensuring it's a leaf node (Text or
|
|
671
|
-
* ObjectNode).
|
|
672
|
-
*/
|
|
673
|
-
leaf: (root: Node$1, path: Path$1, schema: EditorSchema) => Text$1 | ObjectNode;
|
|
674
|
-
/**
|
|
675
|
-
* Return a generator of the in a branch of the tree, from a specific path.
|
|
676
|
-
*
|
|
677
|
-
* By default the order is top-down, from highest to lowest node in the tree,
|
|
678
|
-
* but you can pass the `reverse: true` option to go bottom-up.
|
|
679
|
-
*/
|
|
680
|
-
levels: (root: Node$1, path: Path$1, schema: EditorSchema, options?: NodeLevelsOptions) => Generator<NodeEntry, void, undefined>;
|
|
681
|
-
/**
|
|
682
|
-
* Return a generator of all the node entries of a root node. Each entry is
|
|
683
|
-
* returned as a `[Node, Path]` tuple, with the path referring to the node's
|
|
684
|
-
* position inside the root node.
|
|
685
|
-
*/
|
|
686
|
-
nodes: (root: Node$1, schema: EditorSchema, options?: NodeNodesOptions) => Generator<NodeEntry, void, undefined>;
|
|
687
|
-
/**
|
|
688
|
-
* Get the parent of a node at a specific path.
|
|
689
|
-
*/
|
|
690
|
-
parent: (root: Node$1, path: Path$1, schema: EditorSchema) => Ancestor;
|
|
691
|
-
/**
|
|
692
|
-
* Get the concatenated text string of a node's content.
|
|
693
|
-
*
|
|
694
|
-
* Note that this will not include spaces or line breaks between block nodes.
|
|
695
|
-
* It is not a user-facing string, but a string for performing offset-related
|
|
696
|
-
* computations for a node.
|
|
697
|
-
*/
|
|
698
|
-
string: (node: Node$1, schema: EditorSchema) => string;
|
|
699
|
-
/**
|
|
700
|
-
* Return a generator of all leaf text nodes in a root node.
|
|
701
|
-
*/
|
|
702
|
-
texts: (root: Node$1, schema: EditorSchema, options?: NodeTextsOptions) => Generator<NodeEntry<Text$1>, void, undefined>;
|
|
703
|
-
}
|
|
704
|
-
declare const Node$1: NodeInterface;
|
|
705
213
|
/**
|
|
706
214
|
* The `Descendant` union type represents nodes that are descendants in the
|
|
707
215
|
* tree. It is returned as a convenience in certain cases to narrow a value
|
|
@@ -720,10 +228,6 @@ type Ancestor = Editor$1 | Element$1;
|
|
|
720
228
|
* node in the document.
|
|
721
229
|
*/
|
|
722
230
|
type NodeEntry<T extends Node$1 = Node$1> = [T, Path$1];
|
|
723
|
-
/**
|
|
724
|
-
* Convenience type for returning the props of a node.
|
|
725
|
-
*/
|
|
726
|
-
type NodeProps = Omit<Editor$1, 'children'> | Omit<Element$1, 'children'> | ObjectNode | Omit<Text$1, 'text'>;
|
|
727
231
|
type BaseInsertNodeOperation = {
|
|
728
232
|
type: 'insert_node';
|
|
729
233
|
path: Path$1;
|
|
@@ -919,6 +423,8 @@ interface PathInterface {
|
|
|
919
423
|
transform: (path: Path$1, operation: Operation) => Path$1 | null;
|
|
920
424
|
}
|
|
921
425
|
declare const Path$1: PathInterface;
|
|
426
|
+
type RangeDirection = TextDirection | 'outward' | 'inward';
|
|
427
|
+
type TextDirection = 'forward' | 'backward';
|
|
922
428
|
/**
|
|
923
429
|
* `PointRef` objects keep a specific point in a document synced over time as new
|
|
924
430
|
* operations are applied to the editor. You can access their `current` property
|
|
@@ -1124,73 +630,6 @@ interface TextInterface {
|
|
|
1124
630
|
}[];
|
|
1125
631
|
}
|
|
1126
632
|
declare const Text$1: TextInterface;
|
|
1127
|
-
interface GeneralTransforms {
|
|
1128
|
-
/**
|
|
1129
|
-
* Transform the editor by an operation.
|
|
1130
|
-
*/
|
|
1131
|
-
transform: (editor: Editor$1, op: Operation) => void;
|
|
1132
|
-
}
|
|
1133
|
-
declare const GeneralTransforms: GeneralTransforms;
|
|
1134
|
-
interface NodeInsertNodesOptions<T extends Node$1> {
|
|
1135
|
-
at?: Location;
|
|
1136
|
-
match?: NodeMatch<T>;
|
|
1137
|
-
mode?: RangeMode;
|
|
1138
|
-
hanging?: boolean;
|
|
1139
|
-
select?: boolean;
|
|
1140
|
-
voids?: boolean;
|
|
1141
|
-
batchDirty?: boolean;
|
|
1142
|
-
}
|
|
1143
|
-
interface NodeTransforms {
|
|
1144
|
-
/**
|
|
1145
|
-
* Insert nodes in the editor
|
|
1146
|
-
* at the specified location or (if not defined) the current selection or (if not defined) the end of the document.
|
|
1147
|
-
*/
|
|
1148
|
-
insertNodes: <T extends Node$1>(editor: Editor$1, nodes: Node$1 | Node$1[], options?: NodeInsertNodesOptions<T>) => void;
|
|
1149
|
-
/**
|
|
1150
|
-
* Remove the nodes at a specific location in the document.
|
|
1151
|
-
*/
|
|
1152
|
-
removeNodes: <T extends Node$1>(editor: Editor$1, options?: {
|
|
1153
|
-
at?: Location;
|
|
1154
|
-
match?: NodeMatch<T>;
|
|
1155
|
-
mode?: RangeMode;
|
|
1156
|
-
hanging?: boolean;
|
|
1157
|
-
voids?: boolean;
|
|
1158
|
-
}) => void;
|
|
1159
|
-
}
|
|
1160
|
-
declare const NodeTransforms: NodeTransforms;
|
|
1161
|
-
interface SelectionCollapseOptions {
|
|
1162
|
-
edge?: SelectionEdge;
|
|
1163
|
-
}
|
|
1164
|
-
interface SelectionMoveOptions {
|
|
1165
|
-
distance?: number;
|
|
1166
|
-
unit?: MoveUnit;
|
|
1167
|
-
reverse?: boolean;
|
|
1168
|
-
edge?: SelectionEdge;
|
|
1169
|
-
}
|
|
1170
|
-
interface SelectionTransforms {
|
|
1171
|
-
/**
|
|
1172
|
-
* Collapse the selection.
|
|
1173
|
-
*/
|
|
1174
|
-
collapse: (editor: Editor$1, options?: SelectionCollapseOptions) => void;
|
|
1175
|
-
/**
|
|
1176
|
-
* Unset the selection.
|
|
1177
|
-
*/
|
|
1178
|
-
deselect: (editor: Editor$1) => void;
|
|
1179
|
-
/**
|
|
1180
|
-
* Move the selection's point forward or backward.
|
|
1181
|
-
*/
|
|
1182
|
-
move: (editor: Editor$1, options?: SelectionMoveOptions) => void;
|
|
1183
|
-
/**
|
|
1184
|
-
* Set the selection to a new value.
|
|
1185
|
-
*/
|
|
1186
|
-
select: (editor: Editor$1, target: Location) => void;
|
|
1187
|
-
/**
|
|
1188
|
-
* Set new properties on the selection.
|
|
1189
|
-
*/
|
|
1190
|
-
setSelection: (editor: Editor$1, props: Partial<Range>) => void;
|
|
1191
|
-
}
|
|
1192
|
-
declare const SelectionTransforms: SelectionTransforms;
|
|
1193
|
-
declare const Transforms: GeneralTransforms & NodeTransforms & SelectionTransforms & TextTransforms;
|
|
1194
633
|
type DecoratedRange = BaseRange & {
|
|
1195
634
|
rangeDecoration: RangeDecoration;
|
|
1196
635
|
};
|
|
@@ -1242,8 +681,6 @@ interface DOMEditor extends BaseEditor {
|
|
|
1242
681
|
hasRange: (editor: Editor$1, range: Range) => boolean;
|
|
1243
682
|
hasSelectableTarget: (editor: Editor$1, target: EventTarget | null) => boolean;
|
|
1244
683
|
hasTarget: (editor: Editor$1, target: EventTarget | null) => target is DOMNode;
|
|
1245
|
-
insertData: (data: DataTransfer) => void;
|
|
1246
|
-
insertTextData: (data: DataTransfer) => boolean;
|
|
1247
684
|
isTargetInsideNonReadonlyVoid: (editor: Editor$1, target: EventTarget | null) => boolean;
|
|
1248
685
|
isNodeMapDirty: boolean;
|
|
1249
686
|
domWindow: Window | null;
|
|
@@ -1441,14 +878,6 @@ interface PortableTextSlateEditor extends ReactEditor {
|
|
|
1441
878
|
isRedoing: boolean;
|
|
1442
879
|
isUndoing: boolean;
|
|
1443
880
|
withHistory: boolean;
|
|
1444
|
-
/**
|
|
1445
|
-
* Undo
|
|
1446
|
-
*/
|
|
1447
|
-
undo: () => void;
|
|
1448
|
-
/**
|
|
1449
|
-
* Redo
|
|
1450
|
-
*/
|
|
1451
|
-
redo: () => void;
|
|
1452
881
|
}
|
|
1453
882
|
/**
|
|
1454
883
|
* @public
|