@portabletext/editor 6.0.1-canary.2 → 6.0.1-canary.4

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.
@@ -1,9 +1,9 @@
1
1
  import * as _portabletext_schema6 from "@portabletext/schema";
2
- import { AnnotationDefinition, AnnotationSchemaType, AnnotationSchemaType as AnnotationSchemaType$1, BaseDefinition, BlockObjectDefinition, BlockObjectSchemaType, BlockObjectSchemaType as BlockObjectSchemaType$1, DecoratorDefinition, DecoratorSchemaType, DecoratorSchemaType as DecoratorSchemaType$1, FieldDefinition, InlineObjectDefinition, InlineObjectSchemaType, InlineObjectSchemaType as InlineObjectSchemaType$1, ListDefinition, ListSchemaType, ListSchemaType as ListSchemaType$1, PortableTextBlock, PortableTextBlock as PortableTextBlock$1, PortableTextChild, PortableTextChild as PortableTextChild$1, PortableTextListBlock, PortableTextObject, PortableTextObject as PortableTextObject$1, PortableTextSpan, PortableTextSpan as PortableTextSpan$1, PortableTextTextBlock, PortableTextTextBlock as PortableTextTextBlock$1, Schema, SchemaDefinition, SchemaDefinition as SchemaDefinition$1, StyleDefinition, StyleSchemaType, StyleSchemaType as StyleSchemaType$1, TypedObject, defineSchema } from "@portabletext/schema";
2
+ import { AnnotationDefinition, AnnotationSchemaType, AnnotationSchemaType as AnnotationSchemaType$1, BaseDefinition, BlockObjectDefinition, BlockObjectSchemaType, BlockObjectSchemaType as BlockObjectSchemaType$1, DecoratorDefinition, DecoratorSchemaType, DecoratorSchemaType as DecoratorSchemaType$1, FieldDefinition, InlineObjectDefinition, InlineObjectSchemaType, InlineObjectSchemaType as InlineObjectSchemaType$1, ListDefinition, ListSchemaType, ListSchemaType as ListSchemaType$1, PortableTextBlock, PortableTextBlock as PortableTextBlock$1, PortableTextChild, PortableTextChild as PortableTextChild$1, PortableTextObject, PortableTextObject as PortableTextObject$1, PortableTextSpan, PortableTextSpan as PortableTextSpan$1, PortableTextTextBlock, PortableTextTextBlock as PortableTextTextBlock$1, Schema, SchemaDefinition, SchemaDefinition as SchemaDefinition$1, StyleDefinition, StyleSchemaType, StyleSchemaType as StyleSchemaType$1, TypedObject, defineSchema } from "@portabletext/schema";
3
3
  import * as xstate73 from "xstate";
4
4
  import { ActorRef, ActorRefFrom, EventObject, Snapshot } from "xstate";
5
- import * as react13 from "react";
6
- import React$1, { BaseSyntheticEvent, ClipboardEvent as ClipboardEvent$1, FocusEvent, JSX, MutableRefObject, PropsWithChildren, ReactElement, RefObject, TextareaHTMLAttributes } from "react";
5
+ import * as react4 from "react";
6
+ import React$1, { BaseSyntheticEvent, ClipboardEvent as ClipboardEvent$1, FocusEvent, JSX, PropsWithChildren, ReactElement, RefObject, TextareaHTMLAttributes } from "react";
7
7
  import { Patch, Patch as Patch$1 } from "@portabletext/patches";
8
8
  type MIMEType = `${string}/${string}`;
9
9
  /**
@@ -106,771 +106,66 @@ type ChildPath = [{
106
106
  }, 'children', {
107
107
  _key: string;
108
108
  }];
109
- type LeafEdge = 'start' | 'end';
110
- type MaximizeMode = RangeMode | 'all';
111
- type MoveUnit = 'offset' | 'character' | 'word' | 'line';
112
- type RangeDirection = TextDirection | 'outward' | 'inward';
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 TextInsertFragmentOptions {
129
- at?: Location;
130
- hanging?: boolean;
131
- voids?: boolean;
132
- batchDirty?: boolean;
133
- }
134
- interface TextInsertTextOptions {
135
- at?: Location;
136
- voids?: boolean;
137
- }
138
- interface TextTransforms {
139
- /**
140
- * Delete content in the editor.
141
- */
142
- delete: (editor: Editor$1, options?: TextDeleteOptions) => void;
143
- /**
144
- * Insert a fragment in the editor
145
- * at the specified location or (if not defined) the current selection or (if not defined) the end of the document.
146
- */
147
- insertFragment: (editor: Editor$1, fragment: Node$1[], options?: TextInsertFragmentOptions) => void;
148
- /**
149
- * Insert a string of text in the editor
150
- * at the specified location or (if not defined) the current selection or (if not defined) the end of the document.
151
- */
152
- insertText: (editor: Editor$1, text: string, options?: TextInsertTextOptions) => void;
153
- }
154
- declare const TextTransforms: TextTransforms;
155
- /**
156
- * The `Editor` interface stores all the state of a Slate editor. It is extended
157
- * by plugins that wish to add their own helpers and implement new behaviors.
158
- */
159
- interface BaseEditor {
160
- children: Descendant[];
161
- selection: Selection$1;
162
- operations: Operation[];
163
- marks: EditorMarks | null;
164
- dirtyPaths: Path$1[];
165
- dirtyPathKeys: Set<string>;
166
- flushing: boolean;
167
- normalizing: boolean;
168
- batchingDirtyPaths: boolean;
169
- apply: (operation: Operation) => void;
170
- createSpan: () => Text$1;
171
- getDirtyPaths: (operation: Operation) => Path$1[];
172
- getFragment: () => Descendant[];
173
- isElementReadOnly: (element: Element$1) => boolean;
174
- isSelectable: (element: Element$1) => boolean;
175
- markableVoid: (element: Element$1) => boolean;
176
- normalizeNode: (entry: NodeEntry, options?: {
177
- operation?: Operation;
178
- fallbackElement?: () => Element$1;
179
- }) => void;
180
- onChange: (options?: {
181
- operation?: Operation;
182
- }) => void;
183
- shouldNormalize: ({
184
- iteration,
185
- dirtyPaths,
186
- operation
187
- }: {
188
- iteration: number;
189
- initialDirtyPathsLength: number;
190
- dirtyPaths: Path$1[];
191
- operation?: Operation;
192
- }) => boolean;
193
- collapse: OmitFirstArg<typeof Transforms.collapse>;
194
- delete: OmitFirstArg<typeof Transforms.delete>;
195
- deselect: OmitFirstArg<typeof Transforms.deselect>;
196
- insertBreak: OmitFirstArg<typeof Editor$1.insertBreak>;
197
- insertFragment: OmitFirstArg<typeof Transforms.insertFragment>;
198
- insertNodes: OmitFirstArg<typeof Transforms.insertNodes>;
199
- insertText: OmitFirstArg<typeof Transforms.insertText>;
200
- liftNodes: OmitFirstArg<typeof Transforms.liftNodes>;
201
- mergeNodes: OmitFirstArg<typeof Transforms.mergeNodes>;
202
- move: OmitFirstArg<typeof Transforms.move>;
203
- moveNodes: OmitFirstArg<typeof Transforms.moveNodes>;
204
- normalize: OmitFirstArg<typeof Editor$1.normalize>;
205
- removeNodes: OmitFirstArg<typeof Transforms.removeNodes>;
206
- select: OmitFirstArg<typeof Transforms.select>;
207
- setNodes: <T extends Node$1>(props: Partial<T>, options?: {
208
- at?: Location;
209
- match?: NodeMatch<T>;
210
- mode?: MaximizeMode;
211
- hanging?: boolean;
212
- split?: boolean;
213
- voids?: boolean;
214
- compare?: PropsCompare;
215
- merge?: PropsMerge;
216
- }) => void;
217
- setNormalizing: OmitFirstArg<typeof Editor$1.setNormalizing>;
218
- setSelection: OmitFirstArg<typeof Transforms.setSelection>;
219
- splitNodes: OmitFirstArg<typeof Transforms.splitNodes>;
220
- unsetNodes: OmitFirstArg<typeof Transforms.unsetNodes>;
221
- unwrapNodes: OmitFirstArg<typeof Transforms.unwrapNodes>;
222
- withoutNormalizing: OmitFirstArg<typeof Editor$1.withoutNormalizing>;
223
- wrapNodes: OmitFirstArg<typeof Transforms.wrapNodes>;
224
- above: <T extends Ancestor>(options?: EditorAboveOptions<T>) => NodeEntry<T> | undefined;
225
- after: OmitFirstArg<typeof Editor$1.after>;
226
- before: OmitFirstArg<typeof Editor$1.before>;
227
- elementReadOnly: OmitFirstArg<typeof Editor$1.elementReadOnly>;
228
- end: OmitFirstArg<typeof Editor$1.end>;
229
- getMarks: OmitFirstArg<typeof Editor$1.marks>;
230
- hasInlines: OmitFirstArg<typeof Editor$1.hasInlines>;
231
- hasPath: OmitFirstArg<typeof Editor$1.hasPath>;
232
- isBlock: OmitFirstArg<typeof Editor$1.isBlock>;
233
- isEdge: OmitFirstArg<typeof Editor$1.isEdge>;
234
- isEnd: OmitFirstArg<typeof Editor$1.isEnd>;
235
- isInline: OmitFirstArg<typeof Editor$1.isInline>;
236
- isNormalizing: OmitFirstArg<typeof Editor$1.isNormalizing>;
237
- isStart: OmitFirstArg<typeof Editor$1.isStart>;
238
- isVoid: OmitFirstArg<typeof Editor$1.isVoid>;
239
- leaf: OmitFirstArg<typeof Editor$1.leaf>;
240
- levels: <T extends Node$1>(options?: EditorLevelsOptions<T>) => Generator<NodeEntry<T>, void, undefined>;
241
- next: <T extends Descendant>(options?: EditorNextOptions<T>) => NodeEntry<T> | undefined;
242
- node: OmitFirstArg<typeof Editor$1.node>;
243
- nodes: <T extends Node$1>(options?: EditorNodesOptions<T>) => Generator<NodeEntry<T>, void, undefined>;
244
- parent: OmitFirstArg<typeof Editor$1.parent>;
245
- path: OmitFirstArg<typeof Editor$1.path>;
246
- pathRef: OmitFirstArg<typeof Editor$1.pathRef>;
247
- pathRefs: Set<PathRef>;
248
- point: OmitFirstArg<typeof Editor$1.point>;
249
- pointRef: OmitFirstArg<typeof Editor$1.pointRef>;
250
- pointRefs: Set<PointRef>;
251
- positions: OmitFirstArg<typeof Editor$1.positions>;
252
- previous: <T extends Node$1>(options?: EditorPreviousOptions<T>) => NodeEntry<T> | undefined;
253
- range: OmitFirstArg<typeof Editor$1.range>;
254
- rangeRef: OmitFirstArg<typeof Editor$1.rangeRef>;
255
- rangeRefs: Set<RangeRef>;
256
- start: OmitFirstArg<typeof Editor$1.start>;
257
- string: OmitFirstArg<typeof Editor$1.string>;
258
- unhangRange: OmitFirstArg<typeof Editor$1.unhangRange>;
259
- void: OmitFirstArg<typeof Editor$1.void>;
260
- shouldMergeNodesRemovePrevNode: OmitFirstArg<typeof Editor$1.shouldMergeNodesRemovePrevNode>;
261
- }
262
- type Editor$1 = ExtendedType<'Editor', BaseEditor>;
263
- type BaseSelection = Range | null;
264
- type Selection$1 = ExtendedType<'Selection', BaseSelection>;
265
- type EditorMarks = Omit<Text$1, 'text'>;
266
- interface EditorAboveOptions<T extends Ancestor> {
267
- at?: Location;
268
- match?: NodeMatch<T>;
269
- mode?: MaximizeMode;
270
- voids?: boolean;
271
- }
272
- interface EditorAfterOptions {
273
- distance?: number;
274
- unit?: TextUnitAdjustment;
275
- voids?: boolean;
276
- }
277
- interface EditorBeforeOptions {
278
- distance?: number;
279
- unit?: TextUnitAdjustment;
280
- voids?: boolean;
281
- }
282
- interface EditorElementReadOnlyOptions {
283
- at?: Location;
284
- mode?: MaximizeMode;
285
- voids?: boolean;
286
- }
287
- interface EditorIsEditorOptions {
288
- deep?: boolean;
289
- }
290
- interface EditorLeafOptions {
291
- depth?: number;
292
- edge?: LeafEdge;
293
- }
294
- interface EditorLevelsOptions<T extends Node$1> {
295
- at?: Location;
296
- match?: NodeMatch<T>;
297
- reverse?: boolean;
298
- voids?: boolean;
299
- }
300
- interface EditorNextOptions<T extends Descendant> {
301
- at?: Location;
302
- match?: NodeMatch<T>;
303
- mode?: SelectionMode;
304
- voids?: boolean;
305
- }
306
- interface EditorNodeOptions {
307
- depth?: number;
308
- edge?: LeafEdge;
309
- }
310
- interface EditorNodesOptions<T extends Node$1> {
311
- at?: Location | Span;
312
- match?: NodeMatch<T>;
313
- mode?: SelectionMode;
314
- universal?: boolean;
315
- reverse?: boolean;
316
- voids?: boolean;
317
- pass?: (entry: NodeEntry) => boolean;
318
- }
319
- interface EditorNormalizeOptions {
320
- force?: boolean;
321
- operation?: Operation;
322
- }
323
- interface EditorParentOptions {
324
- depth?: number;
325
- edge?: LeafEdge;
326
- }
327
- interface EditorPathOptions {
328
- depth?: number;
329
- edge?: LeafEdge;
330
- }
331
- interface EditorPathRefOptions {
332
- affinity?: TextDirection | null;
333
- }
334
- interface EditorPointOptions {
335
- edge?: LeafEdge;
336
- }
337
- interface EditorPointRefOptions {
338
- affinity?: TextDirection | null;
339
- }
340
- interface EditorPositionsOptions {
341
- at?: Location;
342
- unit?: TextUnitAdjustment;
343
- reverse?: boolean;
344
- voids?: boolean;
345
- }
346
- interface EditorPreviousOptions<T extends Node$1> {
347
- at?: Location;
348
- match?: NodeMatch<T>;
349
- mode?: SelectionMode;
350
- voids?: boolean;
351
- }
352
- interface EditorRangeRefOptions {
353
- affinity?: RangeDirection | null;
354
- }
355
- interface EditorStringOptions {
356
- voids?: boolean;
357
- }
358
- interface EditorUnhangRangeOptions {
359
- voids?: boolean;
360
- }
361
- interface EditorVoidOptions {
362
- at?: Location;
363
- mode?: MaximizeMode;
364
- voids?: boolean;
365
- }
366
- interface EditorInterface {
367
- /**
368
- * Get the ancestor above a location in the document.
369
- */
370
- above: <T extends Ancestor>(editor: Editor$1, options?: EditorAboveOptions<T>) => NodeEntry<T> | undefined;
371
- /**
372
- * Get the point after a location.
373
- */
374
- after: (editor: Editor$1, at: Location, options?: EditorAfterOptions) => Point | undefined;
375
- /**
376
- * Get the point before a location.
377
- */
378
- before: (editor: Editor$1, at: Location, options?: EditorBeforeOptions) => Point | undefined;
379
- /**
380
- * Match a read-only element in the current branch of the editor.
381
- */
382
- elementReadOnly: (editor: Editor$1, options?: EditorElementReadOnlyOptions) => NodeEntry<Element$1> | undefined;
383
- /**
384
- * Get the end point of a location.
385
- */
386
- end: (editor: Editor$1, at: Location) => Point;
387
- /**
388
- * Check if a node has inline and text children.
389
- */
390
- hasInlines: (editor: Editor$1, element: Element$1) => boolean;
391
- hasPath: (editor: Editor$1, path: Path$1) => boolean;
392
- /**
393
- * Insert a block break at the current selection.
394
- *
395
- * If the selection is currently expanded, it will be deleted first.
396
- */
397
- insertBreak: (editor: Editor$1) => void;
398
- /**
399
- * Inserts a fragment
400
- * at the specified location or (if not defined) the current selection or (if not defined) the end of the document.
401
- */
402
- insertFragment: (editor: Editor$1, fragment: Node$1[], options?: TextInsertFragmentOptions) => void;
403
- /**
404
- * Insert a string of text
405
- * at the specified location or (if not defined) the current selection or (if not defined) the end of the document.
406
- */
407
- insertText: (editor: Editor$1, text: string, options?: TextInsertTextOptions) => void;
408
- /**
409
- * Check if a value is a block `Element` object.
410
- */
411
- isBlock: (editor: Editor$1, value: Element$1) => boolean;
412
- /**
413
- * Check if a point is an edge of a location.
414
- */
415
- isEdge: (editor: Editor$1, point: Point, at: Location) => boolean;
416
- /**
417
- * Check if a value is an `Editor` object.
418
- */
419
- isEditor: (value: any, options?: EditorIsEditorOptions) => value is Editor$1;
420
- /**
421
- * Check if a value is a read-only `Element` object.
422
- */
423
- isElementReadOnly: (editor: Editor$1, element: Element$1) => boolean;
424
- /**
425
- * Check if a point is the end point of a location.
426
- */
427
- isEnd: (editor: Editor$1, point: Point, at: Location) => boolean;
428
- /**
429
- * Check if a value is an inline `Element` object.
430
- */
431
- isInline: (editor: Editor$1, value: Element$1) => boolean;
432
- /**
433
- * Check if the editor is currently normalizing after each operation.
434
- */
435
- isNormalizing: (editor: Editor$1) => boolean;
436
- /**
437
- * Check if a value is a selectable `Element` object.
438
- */
439
- isSelectable: (editor: Editor$1, element: Element$1) => boolean;
440
- /**
441
- * Check if a point is the start point of a location.
442
- */
443
- isStart: (editor: Editor$1, point: Point, at: Location) => boolean;
444
- /**
445
- * Check if a value is a void `Element` object.
446
- */
447
- isVoid: (editor: Editor$1, value: Element$1) => boolean;
448
- /**
449
- * Get the leaf text node at a location.
450
- */
451
- leaf: (editor: Editor$1, at: Location, options?: EditorLeafOptions) => NodeEntry<Text$1>;
452
- /**
453
- * Iterate through all of the levels at a location.
454
- */
455
- levels: <T extends Node$1>(editor: Editor$1, options?: EditorLevelsOptions<T>) => Generator<NodeEntry<T>, void, undefined>;
456
- /**
457
- * Get the marks that would be added to text at the current selection.
458
- */
459
- marks: (editor: Editor$1) => Omit<Text$1, 'text'> | null;
460
- /**
461
- * Get the matching node in the branch of the document after a location.
462
- */
463
- next: <T extends Descendant>(editor: Editor$1, options?: EditorNextOptions<T>) => NodeEntry<T> | undefined;
464
- /**
465
- * Get the node at a location.
466
- */
467
- node: (editor: Editor$1, at: Location, options?: EditorNodeOptions) => NodeEntry;
468
- /**
469
- * Iterate through all of the nodes in the Editor.
470
- */
471
- nodes: <T extends Node$1>(editor: Editor$1, options?: EditorNodesOptions<T>) => Generator<NodeEntry<T>, void, undefined>;
472
- /**
473
- * Normalize any dirty objects in the editor.
474
- */
475
- normalize: (editor: Editor$1, options?: EditorNormalizeOptions) => void;
476
- /**
477
- * Get the parent node of a location.
478
- */
479
- parent: (editor: Editor$1, at: Location, options?: EditorParentOptions) => NodeEntry<Ancestor>;
480
- /**
481
- * Get the path of a location.
482
- */
483
- path: (editor: Editor$1, at: Location, options?: EditorPathOptions) => Path$1;
484
- /**
485
- * Create a mutable ref for a `Path` object, which will stay in sync as new
486
- * operations are applied to the editor.
487
- */
488
- pathRef: (editor: Editor$1, path: Path$1, options?: EditorPathRefOptions) => PathRef;
489
- /**
490
- * Get the set of currently tracked path refs of the editor.
491
- */
492
- pathRefs: (editor: Editor$1) => Set<PathRef>;
493
- /**
494
- * Get the start or end point of a location.
495
- */
496
- point: (editor: Editor$1, at: Location, options?: EditorPointOptions) => Point;
497
- /**
498
- * Create a mutable ref for a `Point` object, which will stay in sync as new
499
- * operations are applied to the editor.
500
- */
501
- pointRef: (editor: Editor$1, point: Point, options?: EditorPointRefOptions) => PointRef;
502
- /**
503
- * Get the set of currently tracked point refs of the editor.
504
- */
505
- pointRefs: (editor: Editor$1) => Set<PointRef>;
506
- /**
507
- * Return all the positions in `at` range where a `Point` can be placed.
508
- *
509
- * By default, moves forward by individual offsets at a time, but
510
- * the `unit` option can be used to to move by character, word, line, or block.
511
- *
512
- * The `reverse` option can be used to change iteration direction.
513
- *
514
- * Note: By default void nodes are treated as a single point and iteration
515
- * will not happen inside their content unless you pass in true for the
516
- * `voids` option, then iteration will occur.
517
- */
518
- positions: (editor: Editor$1, options?: EditorPositionsOptions) => Generator<Point, void, undefined>;
519
- /**
520
- * Get the matching node in the branch of the document before a location.
521
- */
522
- previous: <T extends Node$1>(editor: Editor$1, options?: EditorPreviousOptions<T>) => NodeEntry<T> | undefined;
523
- /**
524
- * Get a range of a location.
525
- */
526
- range: (editor: Editor$1, at: Location, to?: Location) => Range;
527
- /**
528
- * Create a mutable ref for a `Range` object, which will stay in sync as new
529
- * operations are applied to the editor.
530
- */
531
- rangeRef: (editor: Editor$1, range: Range, options?: EditorRangeRefOptions) => RangeRef;
532
- /**
533
- * Get the set of currently tracked range refs of the editor.
534
- */
535
- rangeRefs: (editor: Editor$1) => Set<RangeRef>;
536
- /**
537
- * Manually set if the editor should currently be normalizing.
538
- *
539
- * Note: Using this incorrectly can leave the editor in an invalid state.
540
- *
541
- */
542
- setNormalizing: (editor: Editor$1, isNormalizing: boolean) => void;
543
- /**
544
- * Get the start point of a location.
545
- */
546
- start: (editor: Editor$1, at: Location) => Point;
547
- /**
548
- * Get the text string content of a location.
549
- *
550
- * Note: by default the text of void nodes is considered to be an empty
551
- * string, regardless of content, unless you pass in true for the voids option
552
- */
553
- string: (editor: Editor$1, at: Location, options?: EditorStringOptions) => string;
554
- /**
555
- * Convert a range into a non-hanging one.
556
- */
557
- unhangRange: (editor: Editor$1, range: Range, options?: EditorUnhangRangeOptions) => Range;
558
- /**
559
- * Match a void node in the current branch of the editor.
560
- */
561
- void: (editor: Editor$1, options?: EditorVoidOptions) => NodeEntry<Element$1> | undefined;
562
- /**
563
- * Call a function, deferring normalization until after it completes.
564
- */
565
- withoutNormalizing: (editor: Editor$1, fn: () => void) => void;
566
- /**
567
- * Call a function, Determine whether or not remove the previous node when merge.
568
- */
569
- shouldMergeNodesRemovePrevNode: (editor: Editor$1, prevNodeEntry: NodeEntry, curNodeEntry: NodeEntry) => boolean;
570
- }
571
- declare const Editor$1: EditorInterface;
572
- /**
573
- * A helper type for narrowing matched nodes with a predicate.
574
- */
575
- type NodeMatch<T extends Node$1> = ((node: Node$1, path: Path$1) => node is T) | ((node: Node$1, path: Path$1) => boolean);
576
- type PropsCompare = (prop: Partial<Node$1>, node: Partial<Node$1>) => boolean;
577
- type PropsMerge = (prop: Partial<Node$1>, node: Partial<Node$1>) => object;
578
109
  /**
579
- * `Element` objects are a type of node in a Slate document that contain other
580
- * element nodes or text nodes. They can be either "blocks" or "inlines"
581
- * depending on the Slate editor's configuration.
110
+ * @public
582
111
  */
583
- interface BaseElement {
584
- children: Descendant[];
585
- }
586
- type Element$1 = ExtendedType<'Element', BaseElement>;
587
- interface ElementIsElementOptions {
588
- deep?: boolean;
589
- }
590
- interface ElementInterface {
591
- /**
592
- * Check if a value implements the 'Ancestor' interface.
593
- */
594
- isAncestor: (value: any, options?: ElementIsElementOptions) => value is Ancestor;
595
- /**
596
- * Check if a value implements the `Element` interface.
597
- */
598
- isElement: (value: any, options?: ElementIsElementOptions) => value is Element$1;
599
- /**
600
- * Check if a value is an array of `Element` objects.
601
- */
602
- isElementList: (value: any, options?: ElementIsElementOptions) => value is Element$1[];
603
- /**
604
- * Check if a set of props is a partial of Element.
605
- */
606
- isElementProps: (props: any) => props is Partial<Element$1>;
607
- /**
608
- * Check if a value implements the `Element` interface and has elementKey with selected value.
609
- * Default it check to `type` key value
610
- */
611
- isElementType: <T extends Element$1>(value: any, elementVal: string, elementKey?: string) => value is T;
612
- /**
613
- * Check if an element matches set of properties.
614
- *
615
- * Note: this checks custom properties, and it does not ensure that any
616
- * children are equivalent.
617
- */
618
- matches: (element: Element$1, props: Partial<Element$1>) => boolean;
619
- }
620
- declare const Element$1: ElementInterface;
112
+ type EditorSchema = Schema;
621
113
  /**
622
- * `ElementEntry` objects refer to an `Element` and the `Path` where it can be
623
- * found inside a root node.
114
+ * `Path` arrays are a list of indexes that describe a node's exact position in
115
+ * a Slate node tree. Although they are usually relative to the root `Editor`
116
+ * object, they can be relative to any `Node` object.
624
117
  */
625
- type ElementEntry = [Element$1, Path$1];
118
+ type Path$1 = number[];
119
+ type Node$1 = PortableTextTextBlock | PortableTextObject | PortableTextSpan;
120
+ type TextDirection = 'forward' | 'backward';
626
121
  /**
627
- * The `Location` interface is a union of the ways to refer to a specific
628
- * location in a Slate document: paths, points or ranges.
629
- *
630
- * Methods will often accept a `Location` instead of requiring only a `Path`,
631
- * `Point` or `Range`. This eliminates the need for developers to manage
632
- * converting between the different interfaces in their own code base.
122
+ * `Point` objects refer to a specific location in a text node in a Slate
123
+ * document. Its path refers to the location of the node in the tree, and its
124
+ * offset refers to the distance into the node's string of text. Points can
125
+ * only refer to `Text` nodes.
633
126
  */
634
- type Location = Path$1 | Point | Range;
635
- interface LocationInterface {
636
- /**
637
- * Check if a value implements the `Location` interface.
638
- */
639
- isLocation: (value: any) => value is Location;
127
+ interface Point {
128
+ path: number[];
129
+ offset: number;
640
130
  }
641
- declare const Location: LocationInterface;
642
131
  /**
643
- * The `Span` interface is a low-level way to refer to locations in nodes
644
- * without using `Point` which requires leaf text nodes to be present.
132
+ * `Range` objects are a set of points that refer to a specific span of a Slate
133
+ * document. They can define a span inside a single node or a can span across
134
+ * multiple nodes.
645
135
  */
646
- type Span = [Path$1, Path$1];
647
- interface SpanInterface {
648
- /**
649
- * Check if a value implements the `Span` interface.
650
- */
651
- isSpan: (value: any) => value is Span;
652
- }
653
- declare const Span: SpanInterface;
654
- type Node$1 = Editor$1 | Element$1 | Text$1;
655
- interface NodeAncestorsOptions {
656
- reverse?: boolean;
657
- }
658
- interface NodeChildrenOptions {
659
- reverse?: boolean;
660
- }
661
- interface NodeDescendantsOptions {
662
- from?: Path$1;
663
- to?: Path$1;
664
- reverse?: boolean;
665
- pass?: (node: NodeEntry) => boolean;
666
- }
667
- interface NodeElementsOptions {
668
- from?: Path$1;
669
- to?: Path$1;
670
- reverse?: boolean;
671
- pass?: (node: NodeEntry) => boolean;
672
- }
673
- interface NodeIsNodeOptions {
674
- deep?: boolean;
675
- }
676
- interface NodeLevelsOptions {
677
- reverse?: boolean;
678
- }
679
- interface NodeNodesOptions {
680
- from?: Path$1;
681
- to?: Path$1;
682
- reverse?: boolean;
683
- pass?: (entry: NodeEntry) => boolean;
684
- }
685
- interface NodeTextsOptions {
686
- from?: Path$1;
687
- to?: Path$1;
688
- reverse?: boolean;
689
- pass?: (node: NodeEntry) => boolean;
690
- }
691
- interface NodeInterface {
692
- /**
693
- * Get the node at a specific path, asserting that it's an ancestor node.
694
- */
695
- ancestor: (root: Node$1, path: Path$1) => Ancestor;
696
- /**
697
- * Return a generator of all the ancestor nodes above a specific path.
698
- *
699
- * By default the order is top-down, from highest to lowest ancestor in
700
- * the tree, but you can pass the `reverse: true` option to go bottom-up.
701
- */
702
- ancestors: (root: Node$1, path: Path$1, options?: NodeAncestorsOptions) => Generator<NodeEntry<Ancestor>, void, undefined>;
703
- /**
704
- * Get the child of a node at a specific index.
705
- */
706
- child: (root: Node$1, index: number) => Descendant;
707
- /**
708
- * Iterate over the children of a node at a specific path.
709
- */
710
- children: (root: Node$1, path: Path$1, options?: NodeChildrenOptions) => Generator<NodeEntry<Descendant>, void, undefined>;
711
- /**
712
- * Get an entry for the common ancesetor node of two paths.
713
- */
714
- common: (root: Node$1, path: Path$1, another: Path$1) => NodeEntry;
715
- /**
716
- * Get the node at a specific path, asserting that it's a descendant node.
717
- */
718
- descendant: (root: Node$1, path: Path$1) => Descendant;
719
- /**
720
- * Return a generator of all the descendant node entries inside a root node.
721
- */
722
- descendants: (root: Node$1, options?: NodeDescendantsOptions) => Generator<NodeEntry<Descendant>, void, undefined>;
723
- /**
724
- * Return a generator of all the element nodes inside a root node. Each iteration
725
- * will return an `ElementEntry` tuple consisting of `[Element, Path]`. If the
726
- * root node is an element it will be included in the iteration as well.
727
- */
728
- elements: (root: Node$1, options?: NodeElementsOptions) => Generator<ElementEntry, void, undefined>;
729
- /**
730
- * Extract props from a Node.
731
- */
732
- extractProps: (node: Node$1) => NodeProps;
733
- /**
734
- * Get the first leaf node entry in a root node from a path.
735
- */
736
- first: (root: Node$1, path: Path$1) => NodeEntry;
737
- /**
738
- * Get the sliced fragment represented by a range inside a root node.
739
- */
740
- fragment: <T extends Ancestor = Editor$1>(root: T, range: Range) => T['children'];
741
- /**
742
- * Get the descendant node referred to by a specific path. If the path is an
743
- * empty array, it refers to the root node itself.
744
- */
745
- get: (root: Node$1, path: Path$1) => Node$1;
746
- /**
747
- * Similar to get, but returns undefined if the node does not exist.
748
- */
749
- getIf: (root: Node$1, path: Path$1) => Node$1 | undefined;
750
- /**
751
- * Check if a descendant node exists at a specific path.
752
- */
753
- has: (root: Node$1, path: Path$1) => boolean;
754
- /**
755
- * Check if a value implements the `Node` interface.
756
- */
757
- isNode: (value: any, options?: NodeIsNodeOptions) => value is Node$1;
758
- /**
759
- * Check if a value is a list of `Node` objects.
760
- */
761
- isNodeList: (value: any, options?: NodeIsNodeOptions) => value is Node$1[];
762
- /**
763
- * Get the last leaf node entry in a root node from a path.
764
- */
765
- last: (root: Node$1, path: Path$1) => NodeEntry;
766
- /**
767
- * Get the node at a specific path, ensuring it's a leaf text node.
768
- */
769
- leaf: (root: Node$1, path: Path$1) => Text$1;
770
- /**
771
- * Return a generator of the in a branch of the tree, from a specific path.
772
- *
773
- * By default the order is top-down, from highest to lowest node in the tree,
774
- * but you can pass the `reverse: true` option to go bottom-up.
775
- */
776
- levels: (root: Node$1, path: Path$1, options?: NodeLevelsOptions) => Generator<NodeEntry, void, undefined>;
777
- /**
778
- * Check if a node matches a set of props.
779
- */
780
- matches: (node: Node$1, props: Partial<Node$1>) => boolean;
781
- /**
782
- * Return a generator of all the node entries of a root node. Each entry is
783
- * returned as a `[Node, Path]` tuple, with the path referring to the node's
784
- * position inside the root node.
785
- */
786
- nodes: (root: Node$1, options?: NodeNodesOptions) => Generator<NodeEntry, void, undefined>;
787
- /**
788
- * Get the parent of a node at a specific path.
789
- */
790
- parent: (root: Node$1, path: Path$1) => Ancestor;
791
- /**
792
- * Get the concatenated text string of a node's content.
793
- *
794
- * Note that this will not include spaces or line breaks between block nodes.
795
- * It is not a user-facing string, but a string for performing offset-related
796
- * computations for a node.
797
- */
798
- string: (node: Node$1) => string;
799
- /**
800
- * Return a generator of all leaf text nodes in a root node.
801
- */
802
- texts: (root: Node$1, options?: NodeTextsOptions) => Generator<NodeEntry<Text$1>, void, undefined>;
136
+ interface Range {
137
+ anchor: Point;
138
+ focus: Point;
803
139
  }
804
- declare const Node$1: NodeInterface;
805
- /**
806
- * The `Descendant` union type represents nodes that are descendants in the
807
- * tree. It is returned as a convenience in certain cases to narrow a value
808
- * further than the more generic `Node` union.
809
- */
810
- type Descendant = Element$1 | Text$1;
811
- /**
812
- * The `Ancestor` union type represents nodes that are ancestors in the tree.
813
- * It is returned as a convenience in certain cases to narrow a value further
814
- * than the more generic `Node` union.
815
- */
816
- type Ancestor = Editor$1 | Element$1;
817
- /**
818
- * `NodeEntry` objects are returned when iterating over the nodes in a Slate
819
- * document tree. They consist of the node and its `Path` relative to the root
820
- * node in the document.
821
- */
822
- type NodeEntry<T extends Node$1 = Node$1> = [T, Path$1];
823
- /**
824
- * Convenience type for returning the props of a node.
825
- */
826
- type NodeProps = Omit<Editor$1, 'children'> | Omit<Element$1, 'children'> | Omit<Text$1, 'text'>;
827
- type BaseInsertNodeOperation = {
140
+ type InsertNodeOperation = {
828
141
  type: 'insert_node';
829
142
  path: Path$1;
830
143
  node: Node$1;
831
144
  };
832
- type InsertNodeOperation = ExtendedType<'InsertNodeOperation', BaseInsertNodeOperation>;
833
- type BaseInsertTextOperation = {
145
+ type InsertTextOperation = {
834
146
  type: 'insert_text';
835
147
  path: Path$1;
836
148
  offset: number;
837
149
  text: string;
838
150
  };
839
- type InsertTextOperation = ExtendedType<'InsertTextOperation', BaseInsertTextOperation>;
840
- type BaseMergeNodeOperation = {
841
- type: 'merge_node';
842
- path: Path$1;
843
- position: number;
844
- properties: Partial<Node$1>;
845
- };
846
- type MergeNodeOperation = ExtendedType<'MergeNodeOperation', BaseMergeNodeOperation>;
847
- type BaseMoveNodeOperation = {
848
- type: 'move_node';
849
- path: Path$1;
850
- newPath: Path$1;
851
- };
852
- type MoveNodeOperation = ExtendedType<'MoveNodeOperation', BaseMoveNodeOperation>;
853
- type BaseRemoveNodeOperation = {
151
+ type RemoveNodeOperation = {
854
152
  type: 'remove_node';
855
153
  path: Path$1;
856
154
  node: Node$1;
857
155
  };
858
- type RemoveNodeOperation = ExtendedType<'RemoveNodeOperation', BaseRemoveNodeOperation>;
859
- type BaseRemoveTextOperation = {
156
+ type RemoveTextOperation = {
860
157
  type: 'remove_text';
861
158
  path: Path$1;
862
159
  offset: number;
863
160
  text: string;
864
161
  };
865
- type RemoveTextOperation = ExtendedType<'RemoveTextOperation', BaseRemoveTextOperation>;
866
- type BaseSetNodeOperation = {
162
+ type SetNodeOperation = {
867
163
  type: 'set_node';
868
164
  path: Path$1;
869
165
  properties: Partial<Node$1>;
870
166
  newProperties: Partial<Node$1>;
871
167
  };
872
- type SetNodeOperation = ExtendedType<'SetNodeOperation', BaseSetNodeOperation>;
873
- type BaseSetSelectionOperation = {
168
+ type SetSelectionOperation = {
874
169
  type: 'set_selection';
875
170
  properties: null;
876
171
  newProperties: Range;
@@ -883,53 +178,20 @@ type BaseSetSelectionOperation = {
883
178
  properties: Range;
884
179
  newProperties: null;
885
180
  };
886
- type SetSelectionOperation = ExtendedType<'SetSelectionOperation', BaseSetSelectionOperation>;
887
- type BaseSplitNodeOperation = {
888
- type: 'split_node';
889
- path: Path$1;
890
- position: number;
891
- properties: Partial<Node$1>;
181
+ type Operation = InsertNodeOperation | RemoveNodeOperation | SetNodeOperation | SetSelectionOperation | InsertTextOperation | RemoveTextOperation;
182
+ type DecoratedRange = Range & {
183
+ rangeDecoration: RangeDecoration;
184
+ merge: (leaf: Record<string, unknown>, decoration: Record<string, unknown>) => void;
892
185
  };
893
- type SplitNodeOperation = ExtendedType<'SplitNodeOperation', BaseSplitNodeOperation>;
894
- type NodeOperation = InsertNodeOperation | MergeNodeOperation | MoveNodeOperation | RemoveNodeOperation | SetNodeOperation | SplitNodeOperation;
895
- type SelectionOperation = SetSelectionOperation;
896
- type TextOperation = InsertTextOperation | RemoveTextOperation;
897
186
  /**
898
- * `Operation` objects define the low-level instructions that Slate editors use
899
- * to apply changes to their internal state. Representing all changes as
900
- * operations is what allows Slate editors to easily implement history,
901
- * collaboration, and other features.
187
+ * The `Location` interface is a union of the ways to refer to a specific
188
+ * location in a Slate document: paths, points or ranges.
189
+ *
190
+ * Methods will often accept a `Location` instead of requiring only a `Path`,
191
+ * `Point` or `Range`. This eliminates the need for developers to manage
192
+ * converting between the different interfaces in their own code base.
902
193
  */
903
- type BaseOperation = NodeOperation | SelectionOperation | TextOperation;
904
- type Operation = ExtendedType<'Operation', BaseOperation>;
905
- interface OperationInterface {
906
- /**
907
- * Check if a value is a `NodeOperation` object.
908
- */
909
- isNodeOperation: (value: any) => value is NodeOperation;
910
- /**
911
- * Check if a value is an `Operation` object.
912
- */
913
- isOperation: (value: any) => value is Operation;
914
- /**
915
- * Check if a value is a list of `Operation` objects.
916
- */
917
- isOperationList: (value: any) => value is Operation[];
918
- /**
919
- * Check if a value is a `SelectionOperation` object.
920
- */
921
- isSelectionOperation: (value: any) => value is SelectionOperation;
922
- /**
923
- * Check if a value is a `TextOperation` object.
924
- */
925
- isTextOperation: (value: any) => value is TextOperation;
926
- /**
927
- * Invert an operation, returning a new operation that will exactly undo the
928
- * original when applied.
929
- */
930
- inverse: (op: Operation) => Operation;
931
- }
932
- declare const Operation: OperationInterface;
194
+ type Location = Path$1 | Point | Range;
933
195
  /**
934
196
  * `PathRef` objects keep a specific path in a document synced over time as new
935
197
  * operations are applied to the editor. You can access their `current` property
@@ -940,207 +202,24 @@ interface PathRef {
940
202
  affinity: 'forward' | 'backward' | null;
941
203
  unref(): Path$1 | null;
942
204
  }
943
- interface PathRefInterface {
944
- /**
945
- * Transform the path ref's current value by an operation.
946
- */
947
- transform: (ref: PathRef, op: Operation) => void;
948
- }
949
- declare const PathRef: PathRefInterface;
950
- /**
951
- * `Path` arrays are a list of indexes that describe a node's exact position in
952
- * a Slate node tree. Although they are usually relative to the root `Editor`
953
- * object, they can be relative to any `Node` object.
954
- */
955
- type Path$1 = number[];
956
- interface PathAncestorsOptions {
957
- reverse?: boolean;
958
- }
959
- interface PathLevelsOptions {
960
- reverse?: boolean;
961
- }
962
- interface PathTransformOptions {
963
- affinity?: TextDirection | null;
964
- }
965
- interface PathInterface {
966
- /**
967
- * Get a list of ancestor paths for a given path.
968
- *
969
- * The paths are sorted from shallowest to deepest ancestor. However, if the
970
- * `reverse: true` option is passed, they are reversed.
971
- */
972
- ancestors: (path: Path$1, options?: PathAncestorsOptions) => Path$1[];
973
- /**
974
- * Get the common ancestor path of two paths.
975
- */
976
- common: (path: Path$1, another: Path$1) => Path$1;
977
- /**
978
- * Compare a path to another, returning an integer indicating whether the path
979
- * was before, at, or after the other.
980
- *
981
- * Note: Two paths of unequal length can still receive a `0` result if one is
982
- * directly above or below the other. If you want exact matching, use
983
- * [[Path.equals]] instead.
984
- */
985
- compare: (path: Path$1, another: Path$1) => -1 | 0 | 1;
986
- /**
987
- * Check if a path ends after one of the indexes in another.
988
- */
989
- endsAfter: (path: Path$1, another: Path$1) => boolean;
990
- /**
991
- * Check if a path ends at one of the indexes in another.
992
- */
993
- endsAt: (path: Path$1, another: Path$1) => boolean;
994
- /**
995
- * Check if a path ends before one of the indexes in another.
996
- */
997
- endsBefore: (path: Path$1, another: Path$1) => boolean;
998
- /**
999
- * Check if a path is exactly equal to another.
1000
- */
1001
- equals: (path: Path$1, another: Path$1) => boolean;
1002
- /**
1003
- * Check if the path of previous sibling node exists
1004
- */
1005
- hasPrevious: (path: Path$1) => boolean;
1006
- /**
1007
- * Check if a path is after another.
1008
- */
1009
- isAfter: (path: Path$1, another: Path$1) => boolean;
1010
- /**
1011
- * Check if a path is an ancestor of another.
1012
- */
1013
- isAncestor: (path: Path$1, another: Path$1) => boolean;
1014
- /**
1015
- * Check if a path is before another.
1016
- */
1017
- isBefore: (path: Path$1, another: Path$1) => boolean;
1018
- /**
1019
- * Check if a path is a child of another.
1020
- */
1021
- isChild: (path: Path$1, another: Path$1) => boolean;
1022
- /**
1023
- * Check if a path is equal to or an ancestor of another.
1024
- */
1025
- isCommon: (path: Path$1, another: Path$1) => boolean;
1026
- /**
1027
- * Check if a path is a descendant of another.
1028
- */
1029
- isDescendant: (path: Path$1, another: Path$1) => boolean;
1030
- /**
1031
- * Check if a path is the parent of another.
1032
- */
1033
- isParent: (path: Path$1, another: Path$1) => boolean;
1034
- /**
1035
- * Check is a value implements the `Path` interface.
1036
- */
1037
- isPath: (value: any) => value is Path$1;
1038
- /**
1039
- * Check if a path is a sibling of another.
1040
- */
1041
- isSibling: (path: Path$1, another: Path$1) => boolean;
1042
- /**
1043
- * Get a list of paths at every level down to a path. Note: this is the same
1044
- * as `Path.ancestors`, but including the path itself.
1045
- *
1046
- * The paths are sorted from shallowest to deepest. However, if the `reverse:
1047
- * true` option is passed, they are reversed.
1048
- */
1049
- levels: (path: Path$1, options?: PathLevelsOptions) => Path$1[];
1050
- /**
1051
- * Given a path, get the path to the next sibling node.
1052
- */
1053
- next: (path: Path$1) => Path$1;
1054
- /**
1055
- * Returns whether this operation can affect paths or not. Used as an
1056
- * optimization when updating dirty paths during normalization
1057
- *
1058
- * NOTE: This *must* be kept in sync with the implementation of 'transform'
1059
- * below
1060
- */
1061
- operationCanTransformPath: (operation: Operation) => operation is InsertNodeOperation | RemoveNodeOperation | MergeNodeOperation | SplitNodeOperation | MoveNodeOperation;
1062
- /**
1063
- * Given a path, return a new path referring to the parent node above it.
1064
- */
1065
- parent: (path: Path$1) => Path$1;
1066
- /**
1067
- * Given a path, get the path to the previous sibling node.
1068
- */
1069
- previous: (path: Path$1) => Path$1;
1070
- /**
1071
- * Get a path relative to an ancestor.
1072
- */
1073
- relative: (path: Path$1, ancestor: Path$1) => Path$1;
1074
- /**
1075
- * Transform a path by an operation.
1076
- */
1077
- transform: (path: Path$1, operation: Operation, options?: PathTransformOptions) => Path$1 | null;
1078
- }
1079
- declare const Path$1: PathInterface;
1080
- /**
1081
- * `PointRef` objects keep a specific point in a document synced over time as new
1082
- * operations are applied to the editor. You can access their `current` property
1083
- * at any time for the up-to-date point value.
1084
- */
1085
- interface PointRef {
1086
- current: Point | null;
1087
- affinity: TextDirection | null;
1088
- unref(): Point | null;
1089
- }
1090
- interface PointRefInterface {
1091
- /**
1092
- * Transform the point ref's current value by an operation.
1093
- */
1094
- transform: (ref: PointRef, op: Operation) => void;
1095
- }
1096
- declare const PointRef: PointRefInterface;
1097
- /**
1098
- * `Point` objects refer to a specific location in a text node in a Slate
1099
- * document. Its path refers to the location of the node in the tree, and its
1100
- * offset refers to the distance into the node's string of text. Points can
1101
- * only refer to `Text` nodes.
1102
- */
1103
- interface BasePoint {
1104
- path: Path$1;
1105
- offset: number;
1106
- }
1107
- type Point = ExtendedType<'Point', BasePoint>;
1108
- interface PointTransformOptions {
1109
- affinity?: TextDirection | null;
1110
- }
1111
- interface PointInterface {
1112
- /**
1113
- * Compare a point to another, returning an integer indicating whether the
1114
- * point was before, at, or after the other.
1115
- */
1116
- compare: (point: Point, another: Point) => -1 | 0 | 1;
1117
- /**
1118
- * Check if a point is after another.
1119
- */
1120
- isAfter: (point: Point, another: Point) => boolean;
1121
- /**
1122
- * Check if a point is before another.
1123
- */
1124
- isBefore: (point: Point, another: Point) => boolean;
1125
- /**
1126
- * Check if a point is exactly equal to another.
1127
- */
1128
- equals: (point: Point, another: Point) => boolean;
1129
- /**
1130
- * Check if a value implements the `Point` interface.
1131
- */
1132
- isPoint: (value: any) => value is Point;
1133
- /**
1134
- * Transform a point by an operation.
1135
- */
1136
- transform: (point: Point, op: Operation, options?: PointTransformOptions) => Point | null;
205
+ interface PathRefInterface {
206
+ transform: (ref: PathRef, op: Operation) => void;
1137
207
  }
1138
- declare const Point: PointInterface;
208
+ declare const PathRef: PathRefInterface;
1139
209
  /**
1140
- * `PointEntry` objects are returned when iterating over `Point` objects that
1141
- * belong to a range.
210
+ * `PointRef` objects keep a specific point in a document synced over time as new
211
+ * operations are applied to the editor. You can access their `current` property
212
+ * at any time for the up-to-date point value.
1142
213
  */
1143
- type PointEntry = [Point, 'anchor' | 'focus'];
214
+ interface PointRef {
215
+ current: Point | null;
216
+ affinity: TextDirection | null;
217
+ unref(): Point | null;
218
+ }
219
+ interface PointRefInterface {
220
+ transform: (ref: PointRef, op: Operation) => void;
221
+ }
222
+ declare const PointRef: PointRefInterface;
1144
223
  /**
1145
224
  * `RangeRef` objects keep a specific range in a document synced over time as new
1146
225
  * operations are applied to the editor. You can access their `current` property
@@ -1151,326 +230,46 @@ interface RangeRef {
1151
230
  affinity: 'forward' | 'backward' | 'outward' | 'inward' | null;
1152
231
  unref(): Range | null;
1153
232
  }
1154
- interface RangeRefInterface {
1155
- /**
1156
- * Transform the range ref's current value by an operation.
1157
- */
1158
- transform: (ref: RangeRef, op: Operation) => void;
1159
- }
1160
- declare const RangeRef: RangeRefInterface;
1161
- /**
1162
- * `Range` objects are a set of points that refer to a specific span of a Slate
1163
- * document. They can define a span inside a single node or a can span across
1164
- * multiple nodes.
1165
- */
1166
- interface BaseRange {
1167
- anchor: Point;
1168
- focus: Point;
1169
- }
1170
- type Range = ExtendedType<'Range', BaseRange>;
1171
- interface RangeEdgesOptions {
1172
- reverse?: boolean;
1173
- }
1174
- interface RangeTransformOptions {
1175
- affinity?: RangeDirection | null;
1176
- }
1177
- interface RangeInterface {
1178
- /**
1179
- * Get the start and end points of a range, in the order in which they appear
1180
- * in the document.
1181
- */
1182
- edges: (range: Range, options?: RangeEdgesOptions) => [Point, Point];
1183
- /**
1184
- * Get the end point of a range.
1185
- */
1186
- end: (range: Range) => Point;
1187
- /**
1188
- * Check if a range is exactly equal to another.
1189
- */
1190
- equals: (range: Range, another: Range) => boolean;
1191
- /**
1192
- * Check if a range includes a path, a point or part of another range.
1193
- */
1194
- includes: (range: Range, target: Path$1 | Point | Range) => boolean;
1195
- /**
1196
- * Check if a range includes another range.
1197
- */
1198
- surrounds: (range: Range, target: Range) => boolean;
1199
- /**
1200
- * Get the intersection of a range with another.
1201
- */
1202
- intersection: (range: Range, another: Range) => Range | null;
1203
- /**
1204
- * Check if a range is backward, meaning that its anchor point appears in the
1205
- * document _after_ its focus point.
1206
- */
1207
- isBackward: (range: Range) => boolean;
1208
- /**
1209
- * Check if a range is collapsed, meaning that both its anchor and focus
1210
- * points refer to the exact same position in the document.
1211
- */
1212
- isCollapsed: (range: Range) => boolean;
1213
- /**
1214
- * Check if a range is expanded.
1215
- *
1216
- * This is the opposite of [[Range.isCollapsed]] and is provided for legibility.
1217
- */
1218
- isExpanded: (range: Range) => boolean;
1219
- /**
1220
- * Check if a range is forward.
1221
- *
1222
- * This is the opposite of [[Range.isBackward]] and is provided for legibility.
1223
- */
1224
- isForward: (range: Range) => boolean;
1225
- /**
1226
- * Check if a value implements the [[Range]] interface.
1227
- */
1228
- isRange: (value: any) => value is Range;
1229
- /**
1230
- * Iterate through all of the point entries in a range.
1231
- */
1232
- points: (range: Range) => Generator<PointEntry, void, undefined>;
1233
- /**
1234
- * Get the start point of a range.
1235
- */
1236
- start: (range: Range) => Point;
1237
- /**
1238
- * Transform a range by an operation.
1239
- */
1240
- transform: (range: Range, op: Operation, options?: RangeTransformOptions) => Range | null;
1241
- }
1242
- declare const Range: RangeInterface;
1243
- /**
1244
- * Extendable Custom Types Interface
1245
- */
1246
- type ExtendableTypes = 'Editor' | 'Element' | 'Text' | 'Selection' | 'Range' | 'Point' | 'Operation' | 'InsertNodeOperation' | 'InsertTextOperation' | 'MergeNodeOperation' | 'MoveNodeOperation' | 'RemoveNodeOperation' | 'RemoveTextOperation' | 'SetNodeOperation' | 'SetSelectionOperation' | 'SplitNodeOperation';
1247
- interface CustomTypes {
1248
- [key: string]: unknown;
1249
- }
1250
- type ExtendedType<K$1 extends ExtendableTypes, B> = unknown extends CustomTypes[K$1] ? B : CustomTypes[K$1];
1251
233
  /**
1252
- * `Text` objects represent the nodes that contain the actual text content of a
1253
- * Slate document along with any formatting properties. They are always leaf
1254
- * nodes in the document tree as they cannot contain any children.
234
+ * The `Editor` interface stores all the state of a Slate editor. It is extended
235
+ * by plugins that wish to add their own helpers and implement new behaviors.
1255
236
  */
1256
- interface BaseText {
1257
- text: string;
1258
- }
1259
- type Text$1 = ExtendedType<'Text', BaseText>;
1260
- interface LeafPosition {
1261
- start: number;
1262
- end: number;
1263
- isFirst?: true;
1264
- isLast?: true;
1265
- }
1266
- interface TextEqualsOptions {
1267
- loose?: boolean;
1268
- }
1269
- type DecoratedRange$1 = Range & {
1270
- /**
1271
- * Customize how another decoration is merged into a text node. If not specified, `Object.assign` would be used.
1272
- * It is useful for overlapping decorations with the same key but different values.
1273
- */
1274
- merge?: (leaf: Text$1, decoration: object) => void;
1275
- };
1276
- interface TextInterface {
1277
- /**
1278
- * Check if two text nodes are equal.
1279
- *
1280
- * When loose is set, the text is not compared. This is
1281
- * used to check whether sibling text nodes can be merged.
1282
- */
1283
- equals: (text: Text$1, another: Text$1, options?: TextEqualsOptions) => boolean;
1284
- /**
1285
- * Check if a value implements the `Text` interface.
1286
- */
1287
- isText: (value: any) => value is Text$1;
1288
- /**
1289
- * Check if a value is a list of `Text` objects.
1290
- */
1291
- isTextList: (value: any) => value is Text$1[];
1292
- /**
1293
- * Check if some props are a partial of Text.
1294
- */
1295
- isTextProps: (props: any) => props is Partial<Text$1>;
1296
- /**
1297
- * Check if an text matches set of properties.
1298
- *
1299
- * Note: this is for matching custom properties, and it does not ensure that
1300
- * the `text` property are two nodes equal.
1301
- */
1302
- matches: (text: Text$1, props: Partial<Text$1>) => boolean;
1303
- /**
1304
- * Get the leaves for a text node given decorations.
1305
- */
1306
- decorations: (node: Text$1, decorations: DecoratedRange$1[]) => {
1307
- leaf: Text$1;
1308
- position?: LeafPosition;
1309
- }[];
1310
- }
1311
- declare const Text$1: TextInterface;
1312
- interface GeneralTransforms {
1313
- /**
1314
- * Transform the editor by an operation.
1315
- */
1316
- transform: (editor: Editor$1, op: Operation) => void;
1317
- }
1318
- declare const GeneralTransforms: GeneralTransforms;
1319
- interface NodeInsertNodesOptions<T extends Node$1> {
1320
- at?: Location;
1321
- match?: NodeMatch<T>;
1322
- mode?: RangeMode;
1323
- hanging?: boolean;
1324
- select?: boolean;
1325
- voids?: boolean;
1326
- batchDirty?: boolean;
1327
- }
1328
- interface NodeTransforms {
1329
- /**
1330
- * Insert nodes in the editor
1331
- * at the specified location or (if not defined) the current selection or (if not defined) the end of the document.
1332
- */
1333
- insertNodes: <T extends Node$1>(editor: Editor$1, nodes: Node$1 | Node$1[], options?: NodeInsertNodesOptions<T>) => void;
1334
- /**
1335
- * Lift nodes at a specific location upwards in the document tree, splitting
1336
- * their parent in two if necessary.
1337
- */
1338
- liftNodes: <T extends Node$1>(editor: Editor$1, options?: {
1339
- at?: Location;
1340
- match?: NodeMatch<T>;
1341
- mode?: MaximizeMode;
1342
- voids?: boolean;
1343
- }) => void;
1344
- /**
1345
- * Merge a node at a location with the previous node of the same depth,
1346
- * removing any empty containing nodes after the merge if necessary.
1347
- */
1348
- mergeNodes: <T extends Node$1>(editor: Editor$1, options?: {
1349
- at?: Location;
1350
- match?: NodeMatch<T>;
1351
- mode?: RangeMode;
1352
- hanging?: boolean;
1353
- voids?: boolean;
1354
- }) => void;
1355
- /**
1356
- * Move the nodes at a location to a new location.
1357
- */
1358
- moveNodes: <T extends Node$1>(editor: Editor$1, options: {
1359
- at?: Location;
1360
- match?: NodeMatch<T>;
1361
- mode?: MaximizeMode;
1362
- to: Path$1;
1363
- voids?: boolean;
1364
- }) => void;
1365
- /**
1366
- * Remove the nodes at a specific location in the document.
1367
- */
1368
- removeNodes: <T extends Node$1>(editor: Editor$1, options?: {
1369
- at?: Location;
1370
- match?: NodeMatch<T>;
1371
- mode?: RangeMode;
1372
- hanging?: boolean;
1373
- voids?: boolean;
1374
- }) => void;
1375
- /**
1376
- * Set new properties on the nodes at a location.
1377
- */
1378
- setNodes: <T extends Node$1>(editor: Editor$1, props: Partial<T>, options?: {
1379
- at?: Location;
1380
- match?: NodeMatch<T>;
1381
- mode?: MaximizeMode;
1382
- hanging?: boolean;
1383
- split?: boolean;
1384
- voids?: boolean;
1385
- compare?: PropsCompare;
1386
- merge?: PropsMerge;
1387
- }) => void;
1388
- /**
1389
- * Split the nodes at a specific location.
1390
- */
1391
- splitNodes: <T extends Node$1>(editor: Editor$1, options?: {
1392
- at?: Location;
1393
- match?: NodeMatch<T>;
1394
- mode?: RangeMode;
1395
- always?: boolean;
1396
- height?: number;
1397
- voids?: boolean;
1398
- }) => void;
1399
- /**
1400
- * Unset properties on the nodes at a location.
1401
- */
1402
- unsetNodes: <T extends Node$1>(editor: Editor$1, props: string | string[], options?: {
1403
- at?: Location;
1404
- match?: NodeMatch<T>;
1405
- mode?: MaximizeMode;
1406
- hanging?: boolean;
1407
- split?: boolean;
1408
- voids?: boolean;
1409
- }) => void;
1410
- /**
1411
- * Unwrap the nodes at a location from a parent node, splitting the parent if
1412
- * necessary to ensure that only the content in the range is unwrapped.
1413
- */
1414
- unwrapNodes: <T extends Node$1>(editor: Editor$1, options?: {
1415
- at?: Location;
1416
- match?: NodeMatch<T>;
1417
- mode?: MaximizeMode;
1418
- split?: boolean;
1419
- voids?: boolean;
237
+ interface BaseEditor {
238
+ children: PortableTextBlock[];
239
+ readonly value: PortableTextBlock[];
240
+ selection: Selection$1;
241
+ operations: Operation[];
242
+ marks: EditorMarks | null;
243
+ dirtyPaths: Path$1[];
244
+ dirtyPathKeys: Set<string>;
245
+ flushing: boolean;
246
+ normalizing: boolean;
247
+ pathRefs: Set<PathRef>;
248
+ pointRefs: Set<PointRef>;
249
+ rangeRefs: Set<RangeRef>;
250
+ apply: (operation: Operation) => void;
251
+ normalizeNode: (entry: [Editor$1 | Node$1, Path$1], options?: {
252
+ operation?: Operation;
1420
253
  }) => void;
1421
- /**
1422
- * Wrap the nodes at a location in a new container node, splitting the edges
1423
- * of the range first to ensure that only the content in the range is wrapped.
1424
- */
1425
- wrapNodes: <T extends Node$1>(editor: Editor$1, element: Element$1, options?: {
1426
- at?: Location;
1427
- match?: NodeMatch<T>;
1428
- mode?: MaximizeMode;
1429
- split?: boolean;
1430
- voids?: boolean;
254
+ onChange: (options?: {
255
+ operation?: Operation;
1431
256
  }) => void;
257
+ shouldNormalize: ({
258
+ iteration,
259
+ dirtyPaths,
260
+ operation
261
+ }: {
262
+ iteration: number;
263
+ initialDirtyPathsLength: number;
264
+ dirtyPaths: Path$1[];
265
+ operation?: Operation;
266
+ }) => boolean;
267
+ select: (target: Location) => void;
268
+ setSelection: (props: Partial<Range>) => void;
1432
269
  }
1433
- declare const NodeTransforms: NodeTransforms;
1434
- interface SelectionCollapseOptions {
1435
- edge?: SelectionEdge;
1436
- }
1437
- interface SelectionMoveOptions {
1438
- distance?: number;
1439
- unit?: MoveUnit;
1440
- reverse?: boolean;
1441
- edge?: SelectionEdge;
1442
- }
1443
- interface SelectionTransforms {
1444
- /**
1445
- * Collapse the selection.
1446
- */
1447
- collapse: (editor: Editor$1, options?: SelectionCollapseOptions) => void;
1448
- /**
1449
- * Unset the selection.
1450
- */
1451
- deselect: (editor: Editor$1) => void;
1452
- /**
1453
- * Move the selection's point forward or backward.
1454
- */
1455
- move: (editor: Editor$1, options?: SelectionMoveOptions) => void;
1456
- /**
1457
- * Set the selection to a new value.
1458
- */
1459
- select: (editor: Editor$1, target: Location) => void;
1460
- /**
1461
- * Set new properties on the selection.
1462
- */
1463
- setSelection: (editor: Editor$1, props: Partial<Range>) => void;
1464
- }
1465
- declare const SelectionTransforms: SelectionTransforms;
1466
- declare const Transforms: GeneralTransforms & NodeTransforms & SelectionTransforms & TextTransforms;
1467
- /**
1468
- * @public
1469
- */
1470
- type EditorSchema = Schema;
1471
- type DecoratedRange = BaseRange & {
1472
- rangeDecoration: RangeDecoration;
1473
- };
270
+ type Editor$1 = BaseEditor & ReactEditor & PortableTextSlateEditor;
271
+ type Selection$1 = Range | null;
272
+ type EditorMarks = Omit<PortableTextSpan, 'text'>;
1474
273
  type StringDiff = {
1475
274
  start: number;
1476
275
  end: number;
@@ -1496,17 +295,6 @@ declare global {
1496
295
  }
1497
296
  }
1498
297
  type DOMPoint = [Node, number];
1499
- /**
1500
- * An auto-incrementing identifier for keys.
1501
- */
1502
- /**
1503
- * A class that keeps track of a key string. We use a full class here because we
1504
- * want to be able to use them as keys in `WeakMap` objects.
1505
- */
1506
- declare class Key {
1507
- id: string;
1508
- constructor();
1509
- }
1510
298
  type Action = {
1511
299
  at?: Point | Range;
1512
300
  run: () => void;
@@ -1519,23 +307,12 @@ interface DOMEditor extends BaseEditor {
1519
307
  hasRange: (editor: Editor$1, range: Range) => boolean;
1520
308
  hasSelectableTarget: (editor: Editor$1, target: EventTarget | null) => boolean;
1521
309
  hasTarget: (editor: Editor$1, target: EventTarget | null) => target is DOMNode;
1522
- insertData: (data: DataTransfer) => void;
1523
- insertFragmentData: (data: DataTransfer) => boolean;
1524
- insertTextData: (data: DataTransfer) => boolean;
1525
310
  isTargetInsideNonReadonlyVoid: (editor: Editor$1, target: EventTarget | null) => boolean;
1526
- setFragmentData: (data: DataTransfer, originEvent?: 'drag' | 'copy' | 'cut') => void;
1527
311
  isNodeMapDirty: boolean;
1528
312
  domWindow: Window | null;
1529
313
  domElement: HTMLElement | null;
1530
314
  domPlaceholder: string;
1531
315
  domPlaceholderElement: HTMLElement | null;
1532
- keyToElement: WeakMap<Key, HTMLElement>;
1533
- nodeToIndex: WeakMap<Node$1, number>;
1534
- nodeToParent: WeakMap<Node$1, Ancestor>;
1535
- elementToNode: WeakMap<HTMLElement, Node$1>;
1536
- nodeToElement: WeakMap<Node$1, HTMLElement>;
1537
- nodeToKey: WeakMap<Node$1, Key>;
1538
- changeVersion: MutableRefObject<number>;
1539
316
  readOnly: boolean;
1540
317
  focused: boolean;
1541
318
  composing: boolean;
@@ -1544,46 +321,22 @@ interface DOMEditor extends BaseEditor {
1544
321
  operation?: Operation;
1545
322
  }) => void) | null;
1546
323
  scheduleFlush: (() => void) | null;
1547
- pendingInsertionMarks: Partial<Text$1> | null;
1548
- userMarks: Partial<Text$1> | null;
324
+ pendingInsertionMarks: EditorMarks | null;
325
+ userMarks: EditorMarks | null;
1549
326
  pendingDiffs: TextDiff[];
1550
327
  pendingAction: Action | null;
1551
328
  pendingSelection: Range | null;
1552
329
  forceRender: (() => void) | null;
1553
330
  }
1554
331
  interface DOMEditorInterface {
1555
- /**
1556
- * Experimental and android specific: Get pending diffs
1557
- */
1558
- androidPendingDiffs: (editor: Editor$1) => TextDiff[] | undefined;
1559
- /**
1560
- * Experimental and android specific: Flush all pending diffs and cancel composition at the next possible time.
1561
- */
1562
- androidScheduleFlush: (editor: Editor$1) => void;
1563
332
  /**
1564
333
  * Blur the editor.
1565
334
  */
1566
335
  blur: (editor: Editor$1) => void;
1567
- /**
1568
- * Deselect the editor.
1569
- */
1570
- deselect: (editor: Editor$1) => void;
1571
336
  /**
1572
337
  * Find the DOM node that implements DocumentOrShadowRoot for the editor.
1573
338
  */
1574
339
  findDocumentOrShadowRoot: (editor: Editor$1) => Document | ShadowRoot;
1575
- /**
1576
- * Get the target range from a DOM `event`.
1577
- */
1578
- findEventRange: (editor: Editor$1, event: any) => Range;
1579
- /**
1580
- * Find a key for a Slate node.
1581
- */
1582
- findKey: (editor: Editor$1, node: Node$1) => Key;
1583
- /**
1584
- * Find the path of Slate node.
1585
- */
1586
- findPath: (editor: Editor$1, node: Node$1) => Path$1;
1587
340
  /**
1588
341
  * Focus the editor.
1589
342
  */
@@ -1616,18 +369,6 @@ interface DOMEditorInterface {
1616
369
  * Check if the target is in the editor.
1617
370
  */
1618
371
  hasTarget: (editor: Editor$1, target: EventTarget | null) => target is DOMNode;
1619
- /**
1620
- * Insert data from a `DataTransfer` into the editor.
1621
- */
1622
- insertData: (editor: Editor$1, data: DataTransfer) => void;
1623
- /**
1624
- * Insert fragment data from a `DataTransfer` into the editor.
1625
- */
1626
- insertFragmentData: (editor: Editor$1, data: DataTransfer) => boolean;
1627
- /**
1628
- * Insert text data from a `DataTransfer` into the editor.
1629
- */
1630
- insertTextData: (editor: Editor$1, data: DataTransfer) => boolean;
1631
372
  /**
1632
373
  * Check if the user is currently composing inside the editor.
1633
374
  */
@@ -1636,22 +377,10 @@ interface DOMEditorInterface {
1636
377
  * Check if the editor is focused.
1637
378
  */
1638
379
  isFocused: (editor: Editor$1) => boolean;
1639
- /**
1640
- * Check if the editor is in read-only mode.
1641
- */
1642
- isReadOnly: (editor: Editor$1) => boolean;
1643
380
  /**
1644
381
  * Check if the target is inside void and in an non-readonly editor.
1645
382
  */
1646
383
  isTargetInsideNonReadonlyVoid: (editor: Editor$1, target: EventTarget | null) => boolean;
1647
- /**
1648
- * Sets data from the currently selected fragment on a `DataTransfer`.
1649
- */
1650
- setFragmentData: (editor: Editor$1, data: DataTransfer, originEvent?: 'drag' | 'copy' | 'cut') => void;
1651
- /**
1652
- * Find the native DOM element from a Slate node.
1653
- */
1654
- toDOMNode: (editor: Editor$1, node: Node$1) => HTMLElement;
1655
384
  /**
1656
385
  * Find a native DOM selection point from a Slate point.
1657
386
  */
@@ -1665,10 +394,6 @@ interface DOMEditorInterface {
1665
394
  * according to https://dom.spec.whatwg.org/#concept-range-bp-set.
1666
395
  */
1667
396
  toDOMRange: (editor: Editor$1, range: Range) => DOMRange;
1668
- /**
1669
- * Find a Slate node from a native DOM `element`.
1670
- */
1671
- toSlateNode: (editor: Editor$1, domNode: DOMNode) => Node$1;
1672
397
  /**
1673
398
  * Find a Slate point from a DOM selection's `domNode` and `domOffset`.
1674
399
  */
@@ -1690,81 +415,17 @@ interface DOMEditorInterface {
1690
415
  }) => T extends true ? Range | null : Range;
1691
416
  }
1692
417
  declare const DOMEditor: DOMEditorInterface;
1693
- interface ChunkTree {
1694
- type: 'root';
1695
- children: ChunkDescendant[];
1696
- /**
1697
- * The keys of any Slate nodes that have been moved using move_node since the
1698
- * last render
1699
- *
1700
- * Detecting when a node has been moved to a different position in the
1701
- * children array is impossible to do efficiently while reconciling the chunk
1702
- * tree. This interferes with the reconciliation logic since it is treated as
1703
- * if the intermediate nodes were inserted and removed, causing them to be
1704
- * re-chunked unnecessarily.
1705
- *
1706
- * This set is used to detect when a node has been moved so that this case
1707
- * can be handled correctly and efficiently.
1708
- */
1709
- movedNodeKeys: Set<Key>;
1710
- /**
1711
- * The chunks whose descendants have been modified during the most recent
1712
- * reconciliation
1713
- *
1714
- * Used to determine when the otherwise memoized React components for each
1715
- * chunk should be re-rendered.
1716
- */
1717
- modifiedChunks: Set<Chunk>;
1718
- }
1719
- interface Chunk {
1720
- type: 'chunk';
1721
- key: Key;
1722
- parent: ChunkAncestor;
1723
- children: ChunkDescendant[];
1724
- }
1725
- interface ChunkLeaf {
1726
- type: 'leaf';
1727
- key: Key;
1728
- node: Descendant;
1729
- index: number;
1730
- }
1731
- type ChunkAncestor = ChunkTree | Chunk;
1732
- type ChunkDescendant = Chunk | ChunkLeaf;
1733
418
  /**
1734
419
  * A React and DOM-specific version of the `Editor` interface.
1735
420
  */
1736
- interface ReactEditor extends DOMEditor {
1737
- /**
1738
- * Determines the chunk size used by the children chunking optimization. If
1739
- * null is returned (which is the default), the chunking optimization is
1740
- * disabled.
1741
- */
1742
- getChunkSize: (node: Ancestor) => number | null;
1743
- keyToChunkTree: WeakMap<Key, ChunkTree>;
1744
- }
421
+ interface ReactEditor extends DOMEditor {}
1745
422
  interface ReactEditorInterface extends DOMEditorInterface {}
1746
423
  declare const ReactEditor: ReactEditorInterface;
1747
- interface VoidElement {
1748
- _type: string;
1749
- _key: string;
1750
- children: Descendant[];
1751
- __inline: boolean;
1752
- value: Record<string, unknown>;
1753
- }
1754
- interface SlateTextBlock extends Omit<PortableTextTextBlock, 'children'> {
1755
- children: Descendant[];
1756
- }
1757
- declare module '../slate/index' {
1758
- interface CustomTypes {
1759
- Editor: BaseEditor & ReactEditor & PortableTextSlateEditor;
1760
- Element: SlateTextBlock | VoidElement;
1761
- Text: PortableTextSpan;
1762
- }
1763
- }
1764
- //# sourceMappingURL=slate.d.ts.map
1765
424
  type HistoryItem = {
1766
425
  operations: Operation[];
1767
426
  timestamp: Date;
427
+ splitContext?: SplitContext | null;
428
+ mergeContext?: MergeContext | null;
1768
429
  };
1769
430
  interface History {
1770
431
  redos: HistoryItem[];
@@ -1776,13 +437,75 @@ type RemotePatch = {
1776
437
  snapshot: PortableTextBlock[] | undefined;
1777
438
  previousSnapshot: PortableTextBlock[] | undefined;
1778
439
  };
440
+ /**
441
+ * Context passed during a split operation to help RangeDecorator
442
+ * recompute decoration positions correctly.
443
+ */
444
+ interface SplitContext {
445
+ /** The offset in the original block where the split occurs */
446
+ splitOffset: number;
447
+ /** The child index of the span being split */
448
+ splitChildIndex: number;
449
+ /** The _key of the block being split */
450
+ originalBlockKey: string;
451
+ /** The _key of the new block created after the split */
452
+ newBlockKey: string;
453
+ /** The _key of the original span (child) being split */
454
+ originalSpanKey: string;
455
+ /** The _key of the new span in the new block (may be same or different) */
456
+ newSpanKey: string;
457
+ }
458
+ /**
459
+ * Context passed during a merge operation to help RangeDecorator
460
+ * recompute decoration positions correctly.
461
+ *
462
+ * During a forward-delete merge (Delete at end of block 1) or
463
+ * backward-delete merge (Backspace at start of block 2), the
464
+ * second block is deleted and its content is re-inserted into
465
+ * the first block. This context helps track that relationship.
466
+ */
467
+ interface MergeContext {
468
+ /** The _key of the block being deleted (block whose content is moving) */
469
+ deletedBlockKey: string;
470
+ /** The _key of the block receiving the content */
471
+ targetBlockKey: string;
472
+ /** The text length of the target block before merge (insertion offset) */
473
+ targetBlockTextLength: number;
474
+ /** The index of the deleted block at the time context was created */
475
+ deletedBlockIndex: number;
476
+ /** The index of the target block at the time context was created */
477
+ targetBlockIndex: number;
478
+ /** The number of children in the target block before merge.
479
+ * Used to compute correct insertion indices for multi-child blocks
480
+ * (e.g., blocks with bold/italic spans). Child N from the deleted block
481
+ * ends up at index targetOriginalChildCount + N in the target block. */
482
+ targetOriginalChildCount: number;
483
+ }
1779
484
  interface PortableTextSlateEditor extends ReactEditor {
1780
485
  _key: 'editor';
1781
486
  _type: 'editor';
1782
- isTextBlock: (value: unknown) => value is PortableTextTextBlock;
1783
- isTextSpan: (value: unknown) => value is PortableTextSpan;
1784
- isListBlock: (value: unknown) => value is PortableTextListBlock;
487
+ schema: EditorSchema;
488
+ keyGenerator: () => string;
489
+ editableTypes: Set<string>;
1785
490
  decoratedRanges: Array<DecoratedRange>;
491
+ /**
492
+ * Snapshot of decoration state taken before a remote batch starts.
493
+ * Used by the reconciliation handler to diff pre-batch vs post-batch
494
+ * and fire a single onMoved callback per changed decoration.
495
+ * Stores both the Slate Range (for change detection) and the
496
+ * EditorSelection (for previousSelection in onMoved callbacks).
497
+ * Managed by the apply interceptor in range-decorations-machine.
498
+ */
499
+ preBatchDecorationRanges: Map<RangeDecoration, {
500
+ range: Range | null;
501
+ selection: EditorSelection;
502
+ }>;
503
+ /**
504
+ * Tracks decorations whose interior content was modified during a remote
505
+ * batch. Populated by the `move range decorations` action when callbacks
506
+ * are suppressed; consumed and cleared by `reconcile range decorations`.
507
+ */
508
+ batchContentChangedDecorations: Set<RangeDecoration>;
1786
509
  decoratorState: Record<string, boolean | undefined>;
1787
510
  blockIndexMap: Map<string, number>;
1788
511
  history: History;
@@ -1791,7 +514,41 @@ interface PortableTextSlateEditor extends ReactEditor {
1791
514
  listIndexMap: Map<string, number>;
1792
515
  remotePatches: Array<RemotePatch>;
1793
516
  undoStepId: string | undefined;
1794
- value: Array<PortableTextBlock>;
517
+ /**
518
+ * Context for the current split operation.
519
+ * Set before delete+insert operations, cleared after.
520
+ * Used by RangeDecorator to correctly recompute decoration positions.
521
+ */
522
+ splitContext: SplitContext | null;
523
+ /**
524
+ * Context for the current merge operation.
525
+ * Set before delete+insert operations, cleared after.
526
+ * Used by RangeDecorator to correctly recompute decoration positions.
527
+ */
528
+ mergeContext: MergeContext | null;
529
+ /**
530
+ * Tracks which decoration points were on the deleted block BEFORE
531
+ * `remove_node` shifts paths. Computed during `remove_node` and consumed
532
+ * during `insert_node` to avoid stale-index collisions where a shifted
533
+ * point coincidentally lands at `deletedBlockIndex`.
534
+ */
535
+ mergeDeletedBlockFlags: Map<RangeDecoration, {
536
+ anchor: boolean;
537
+ focus: boolean;
538
+ }> | null;
539
+ /**
540
+ * Accumulates decoration shift records between mutation flushes.
541
+ * Consumed and cleared by the mutation machine's `'emit mutations'`
542
+ * action so that `MutationEvent` includes `rangeDecorationShifts`.
543
+ */
544
+ pendingDecorationShifts: Array<RangeDecorationShift>;
545
+ /**
546
+ * When > 0, the decoration `sendBack` interceptor skips firing
547
+ * `slate operation` events. Used by `applyMergeNode` and `applySplitNode`
548
+ * to suppress events for their decomposed operations, which would
549
+ * otherwise double-transform or invalidate decoration ranges.
550
+ */
551
+ _suppressDecorationSendBack: number;
1795
552
  isDeferringMutations: boolean;
1796
553
  isNormalizingNode: boolean;
1797
554
  isPatching: boolean;
@@ -1800,15 +557,13 @@ interface PortableTextSlateEditor extends ReactEditor {
1800
557
  isRedoing: boolean;
1801
558
  isUndoing: boolean;
1802
559
  withHistory: boolean;
1803
- /**
1804
- * Undo
1805
- */
1806
- undo: () => void;
1807
- /**
1808
- * Redo
1809
- */
1810
- redo: () => void;
1811
560
  }
561
+ /**
562
+ * @public
563
+ */
564
+ type RangeDecorationShift = Omit<RangeDecorationOnMovedDetails, 'rangeDecoration'> & {
565
+ rangeDecoration: RangeDecoration;
566
+ };
1812
567
  /**
1813
568
  * @public
1814
569
  */
@@ -1861,20 +616,17 @@ type MutationEvent = {
1861
616
  type: 'mutation';
1862
617
  patches: Array<Patch>;
1863
618
  value: Array<PortableTextBlock> | undefined;
619
+ rangeDecorationShifts: Array<RangeDecorationShift>;
1864
620
  };
1865
621
  type PatchEvent = {
1866
622
  type: 'patch';
1867
623
  patch: Patch;
1868
624
  };
1869
- type SlateEditor = {
1870
- instance: PortableTextSlateEditor;
1871
- initialValue: Array<Descendant>;
1872
- };
1873
625
  type InternalEditor = Editor & {
1874
626
  _internal: {
1875
627
  editable: EditableAPI;
1876
628
  editorActor: EditorActor;
1877
- slateEditor: SlateEditor;
629
+ slateEditor: PortableTextSlateEditor;
1878
630
  };
1879
631
  };
1880
632
  /**
@@ -2316,7 +1068,7 @@ type PortableTextEditableProps = Omit<TextareaHTMLAttributes<HTMLDivElement>, 'o
2316
1068
  * ```
2317
1069
  * @group Components
2318
1070
  */
2319
- declare const PortableTextEditable: react13.ForwardRefExoticComponent<Omit<PortableTextEditableProps, "ref"> & react13.RefAttributes<Omit<HTMLDivElement, "as" | "onPaste" | "onBeforeInput">>>;
1071
+ declare const PortableTextEditable: react4.ForwardRefExoticComponent<Omit<PortableTextEditableProps, "ref"> & react4.RefAttributes<Omit<HTMLDivElement, "as" | "onPaste" | "onBeforeInput">>>;
2320
1072
  /** @beta */
2321
1073
  interface EditableAPIDeleteOptions {
2322
1074
  mode?: 'blocks' | 'children' | 'selected';
@@ -2373,8 +1125,8 @@ interface EditableAPI {
2373
1125
  isCollapsedSelection: () => boolean;
2374
1126
  isExpandedSelection: () => boolean;
2375
1127
  isMarkActive: (mark: string) => boolean;
2376
- isSelectionsOverlapping: (selectionA: EditorSelection, selectionB: EditorSelection) => boolean;
2377
1128
  isVoid: (element: PortableTextBlock | PortableTextChild) => boolean;
1129
+ isSelectionsOverlapping: (selectionA: EditorSelection, selectionB: EditorSelection) => boolean;
2378
1130
  marks: () => string[];
2379
1131
  redo: () => void;
2380
1132
  removeAnnotation: <TSchemaType extends {
@@ -2535,8 +1287,16 @@ type ScrollSelectionIntoViewFunction = (editor: PortableTextEditor, domRange: gl
2535
1287
  * @alpha */
2536
1288
  interface RangeDecorationOnMovedDetails {
2537
1289
  rangeDecoration: RangeDecoration;
1290
+ previousSelection: EditorSelection;
2538
1291
  newSelection: EditorSelection;
2539
1292
  origin: 'remote' | 'local';
1293
+ /**
1294
+ * - `'moved'` — the range's boundary points shifted or the range was
1295
+ * invalidated.
1296
+ * - `'contentChanged'` — the boundary points are unchanged but content
1297
+ * inside the range was modified.
1298
+ */
1299
+ reason: 'moved' | 'contentChanged';
2540
1300
  }
2541
1301
  /**
2542
1302
  * A range decoration is a UI affordance that wraps a given selection range in the editor
@@ -2563,9 +1323,17 @@ interface RangeDecoration {
2563
1323
  */
2564
1324
  selection: EditorSelection;
2565
1325
  /**
2566
- * A optional callback that will be called when the range decoration potentially moves according to user edits.
1326
+ * Called when the range decoration moves due to edits.
1327
+ *
1328
+ * For transactional handling of moves alongside content changes, use
1329
+ * `rangeDecorationShifts` on the `'mutation'` event instead.
2567
1330
  */
2568
1331
  onMoved?: (details: RangeDecorationOnMovedDetails) => void;
1332
+ /**
1333
+ * Stable identifier for matching to external data (e.g., annotation/comment ID).
1334
+ * Set by the consumer — PTE preserves it and passes it through in onMoved details.
1335
+ */
1336
+ id?: string;
2569
1337
  /**
2570
1338
  * A custom payload that can be set on the range decoration
2571
1339
  */
@@ -2952,7 +1720,7 @@ declare const editorMachine: xstate73.StateMachine<{
2952
1720
  initialValue?: Array<PortableTextBlock>;
2953
1721
  }, xstate73.NonReducibleUnknown, InternalPatchEvent | MutationEvent | PatchesEvent | {
2954
1722
  type: "blurred";
2955
- event: react13.FocusEvent<HTMLDivElement, Element>;
1723
+ event: react4.FocusEvent<HTMLDivElement, Element>;
2956
1724
  } | {
2957
1725
  type: "done loading";
2958
1726
  } | {
@@ -2964,7 +1732,7 @@ declare const editorMachine: xstate73.StateMachine<{
2964
1732
  data: unknown;
2965
1733
  } | {
2966
1734
  type: "focused";
2967
- event: react13.FocusEvent<HTMLDivElement, Element>;
1735
+ event: react4.FocusEvent<HTMLDivElement, Element>;
2968
1736
  } | {
2969
1737
  type: "invalid value";
2970
1738
  resolution: InvalidValueResolution | null;
@@ -3487,6 +2255,15 @@ type BehaviorAction = {
3487
2255
  * ```
3488
2256
  */
3489
2257
  send: (event: ExternalBehaviorEvent) => void;
2258
+ /**
2259
+ * The underlying Slate editor instance.
2260
+ *
2261
+ * Use this sparingly and only for setting transient state like
2262
+ * `splitContext` that coordinates between behaviors and other systems.
2263
+ *
2264
+ * @internal
2265
+ */
2266
+ slateEditor: PortableTextSlateEditor;
3490
2267
  }) => void;
3491
2268
  };
3492
2269
  /**
@@ -3630,5 +2407,5 @@ type BehaviorActionSet<TBehaviorEvent, TGuardResponse> = (payload: {
3630
2407
  event: TBehaviorEvent;
3631
2408
  dom: EditorDom;
3632
2409
  }, guardResponse: TGuardResponse) => Array<BehaviorAction>;
3633
- export { BlockAnnotationRenderProps as $, PortableTextTextBlock$1 as A, MutationEvent as At, EditorSelector as B, ListDefinition as C, RenderStyleFunction as Ct, PortableTextChild$1 as D, HotkeyOptions as Dt, PortableTextBlock$1 as E, PortableTextEditableProps as Et, BlockOffset as F, KeyedSegment as Ft, EditorConfig as G, EditorProvider as H, useEditor as I, Path as It, defineBehavior as J, EditorEvent as K, defaultKeyGenerator as L, StyleDefinition as M, AnnotationPath as Mt, StyleSchemaType$1 as N, BlockPath as Nt, PortableTextObject$1 as O, PortableTextEditor as Ot, defineSchema as P, ChildPath as Pt, AddedAnnotationPaths as Q, usePortableTextEditorSelection as R, InlineObjectSchemaType$1 as S, RenderPlaceholderFunction as St, Patch$1 as T, PortableTextEditable as Tt, EditorProviderProps as U, useEditorSelector as V, Editor as W, EditorContext as X, BehaviorGuard as Y, EditorSnapshot as Z, BlockObjectSchemaType$1 as _, RenderBlockFunction as _t, forward as a, EditableAPIDeleteOptions as at, FieldDefinition as b, RenderEditableFunction as bt, CustomBehaviorEvent as c, InvalidValueResolution as ct, SyntheticBehaviorEvent as d, OnPasteResult as dt, BlockChildRenderProps as et, PatchesEvent as f, OnPasteResultOrPromise as ft, BlockObjectDefinition as g, RenderAnnotationFunction as gt, BaseDefinition as h, RangeDecorationOnMovedDetails as ht, execute as i, BlockStyleRenderProps as it, SchemaDefinition$1 as j, EditorSchema as jt, PortableTextSpan$1 as k, EditorEmittedEvent as kt, InsertPlacement as l, OnCopyFn as lt, AnnotationSchemaType$1 as m, RangeDecoration as mt, BehaviorActionSet as n, BlockListItemRenderProps as nt, raise as o, EditorSelection as ot, AnnotationDefinition as p, PasteData as pt, Behavior as q, effect as r, BlockRenderProps as rt, BehaviorEvent as s, EditorSelectionPoint as st, BehaviorAction as t, BlockDecoratorRenderProps as tt, NativeBehaviorEvent as u, OnPasteFn as ut, DecoratorDefinition as v, RenderChildFunction as vt, ListSchemaType$1 as w, ScrollSelectionIntoViewFunction as wt, InlineObjectDefinition as x, RenderListItemFunction as xt, DecoratorSchemaType$1 as y, RenderDecoratorFunction as yt, usePortableTextEditor as z };
2410
+ export { BlockAnnotationRenderProps as $, PortableTextTextBlock$1 as A, MutationEvent as At, EditorSelector as B, ListDefinition as C, RenderStyleFunction as Ct, PortableTextChild$1 as D, HotkeyOptions as Dt, PortableTextBlock$1 as E, PortableTextEditableProps as Et, BlockOffset as F, ChildPath as Ft, EditorConfig as G, EditorProvider as H, useEditor as I, KeyedSegment as It, defineBehavior as J, EditorEvent as K, defaultKeyGenerator as L, Path as Lt, StyleDefinition as M, EditorSchema as Mt, StyleSchemaType$1 as N, AnnotationPath as Nt, PortableTextObject$1 as O, PortableTextEditor as Ot, defineSchema as P, BlockPath as Pt, AddedAnnotationPaths as Q, usePortableTextEditorSelection as R, InlineObjectSchemaType$1 as S, RenderPlaceholderFunction as St, Patch$1 as T, PortableTextEditable as Tt, EditorProviderProps as U, useEditorSelector as V, Editor as W, EditorContext as X, BehaviorGuard as Y, EditorSnapshot as Z, BlockObjectSchemaType$1 as _, RenderBlockFunction as _t, forward as a, EditableAPIDeleteOptions as at, FieldDefinition as b, RenderEditableFunction as bt, CustomBehaviorEvent as c, InvalidValueResolution as ct, SyntheticBehaviorEvent as d, OnPasteResult as dt, BlockChildRenderProps as et, PatchesEvent as f, OnPasteResultOrPromise as ft, BlockObjectDefinition as g, RenderAnnotationFunction as gt, BaseDefinition as h, RangeDecorationOnMovedDetails as ht, execute as i, BlockStyleRenderProps as it, SchemaDefinition$1 as j, RangeDecorationShift as jt, PortableTextSpan$1 as k, EditorEmittedEvent as kt, InsertPlacement as l, OnCopyFn as lt, AnnotationSchemaType$1 as m, RangeDecoration as mt, BehaviorActionSet as n, BlockListItemRenderProps as nt, raise as o, EditorSelection as ot, AnnotationDefinition as p, PasteData as pt, Behavior as q, effect as r, BlockRenderProps as rt, BehaviorEvent as s, EditorSelectionPoint as st, BehaviorAction as t, BlockDecoratorRenderProps as tt, NativeBehaviorEvent as u, OnPasteFn as ut, DecoratorDefinition as v, RenderChildFunction as vt, ListSchemaType$1 as w, ScrollSelectionIntoViewFunction as wt, InlineObjectDefinition as x, RenderListItemFunction as xt, DecoratorSchemaType$1 as y, RenderDecoratorFunction as yt, usePortableTextEditor as z };
3634
2411
  //# sourceMappingURL=behavior.types.action.d.ts.map