@portabletext/editor 6.3.1 → 6.4.0

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.
@@ -2,7 +2,7 @@ import * as _portabletext_schema6 from "@portabletext/schema";
2
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";
3
3
  import * as xstate73 from "xstate";
4
4
  import { ActorRef, ActorRefFrom, EventObject, Snapshot } from "xstate";
5
- import * as react8 from "react";
5
+ import * as react4 from "react";
6
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}`;
@@ -106,900 +106,37 @@ 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 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;
144
- /**
145
- * The `Editor` interface stores all the state of a Slate editor. It is extended
146
- * by plugins that wish to add their own helpers and implement new behaviors.
147
- */
148
- interface BaseEditor {
149
- children: Descendant[];
150
- selection: Selection$1;
151
- operations: Operation[];
152
- marks: EditorMarks | null;
153
- dirtyPaths: Path$1[];
154
- dirtyPathKeys: Set<string>;
155
- flushing: boolean;
156
- normalizing: boolean;
157
- batchingDirtyPaths: boolean;
158
- apply: (operation: Operation) => void;
159
- createSpan: () => Text$1;
160
- getDirtyPaths: (operation: Operation) => Path$1[];
161
- getFragment: () => Descendant[];
162
- isElementReadOnly: (element: Element$1) => boolean;
163
- isSelectable: (element: Element$1) => boolean;
164
- normalizeNode: (entry: NodeEntry, options?: {
165
- operation?: Operation;
166
- }) => void;
167
- onChange: (options?: {
168
- operation?: Operation;
169
- }) => void;
170
- shouldNormalize: ({
171
- iteration,
172
- dirtyPaths,
173
- operation
174
- }: {
175
- iteration: number;
176
- initialDirtyPathsLength: number;
177
- dirtyPaths: Path$1[];
178
- operation?: Operation;
179
- }) => boolean;
180
- collapse: OmitFirstArg<typeof Transforms.collapse>;
181
- delete: OmitFirstArg<typeof Transforms.delete>;
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>;
228
- }
229
- type Editor$1 = ExtendedType<'Editor', BaseEditor>;
230
- type BaseSelection = Range | null;
231
- type Selection$1 = ExtendedType<'Selection', BaseSelection>;
232
- 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
- 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
- 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
- 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
- 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
- }
522
- 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
- /**
532
- * `Element` objects are a type of node in a Slate document that contain other
533
- * element nodes or text nodes. They can be either "blocks" or "inlines"
534
- * depending on the Slate editor's configuration.
535
- */
536
- interface BaseElement {
537
- children: Descendant[];
538
- }
539
- type Element$1 = ExtendedType<'Element', BaseElement>;
540
- interface ElementInterface {
541
- /**
542
- * Check if a value implements the 'Ancestor' interface.
543
- */
544
- isAncestor: (value: any, schema: EditorSchema) => value is Ancestor;
545
- /**
546
- * Check if a value implements the `Element` interface.
547
- */
548
- isElement: (value: any, schema: EditorSchema) => value is Element$1;
549
- }
550
- declare const Element$1: ElementInterface;
551
- /**
552
- * The `Location` interface is a union of the ways to refer to a specific
553
- * location in a Slate document: paths, points or ranges.
554
- *
555
- * Methods will often accept a `Location` instead of requiring only a `Path`,
556
- * `Point` or `Range`. This eliminates the need for developers to manage
557
- * converting between the different interfaces in their own code base.
558
- */
559
- 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
- /**
573
- * Extendable Custom Types Interface
574
- */
575
- type ExtendableTypes = 'Editor' | 'Element' | 'ObjectNode' | 'Text' | 'Selection' | 'Range' | 'Point' | 'Operation' | 'InsertNodeOperation' | 'InsertTextOperation' | 'RemoveNodeOperation' | 'RemoveTextOperation' | 'SetNodeOperation' | 'SetSelectionOperation';
576
- interface CustomTypes {
577
- [key: string]: unknown;
578
- }
579
- type ExtendedType<K$1 extends ExtendableTypes, B> = unknown extends CustomTypes[K$1] ? B : CustomTypes[K$1];
580
- /**
581
- * `ObjectNode` represents a node with semantic content but no children or text.
582
- * Block objects and inline objects are ObjectNodes in the tree.
583
- */
584
- interface BaseObjectNode {
109
+ interface ObjectElement {
585
110
  _type: string;
586
111
  _key: string;
112
+ children: Descendant[];
587
113
  [key: string]: unknown;
588
114
  }
589
- type ObjectNode = ExtendedType<'ObjectNode', BaseObjectNode>;
590
- 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
- /**
706
- * The `Descendant` union type represents nodes that are descendants in the
707
- * tree. It is returned as a convenience in certain cases to narrow a value
708
- * further than the more generic `Node` union.
709
- */
710
- type Descendant = Element$1 | ObjectNode | Text$1;
711
- /**
712
- * The `Ancestor` union type represents nodes that are ancestors in the tree.
713
- * It is returned as a convenience in certain cases to narrow a value further
714
- * than the more generic `Node` union.
715
- */
716
- type Ancestor = Editor$1 | Element$1;
717
- /**
718
- * `NodeEntry` objects are returned when iterating over the nodes in a Slate
719
- * document tree. They consist of the node and its `Path` relative to the root
720
- * node in the document.
721
- */
722
- 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
- type BaseInsertNodeOperation = {
728
- type: 'insert_node';
729
- path: Path$1;
730
- node: Node$1;
731
- };
732
- type InsertNodeOperation = ExtendedType<'InsertNodeOperation', BaseInsertNodeOperation>;
733
- type BaseInsertTextOperation = {
734
- type: 'insert_text';
735
- path: Path$1;
736
- offset: number;
737
- text: string;
738
- };
739
- type InsertTextOperation = ExtendedType<'InsertTextOperation', BaseInsertTextOperation>;
740
- type BaseRemoveNodeOperation = {
741
- type: 'remove_node';
742
- path: Path$1;
743
- node: Node$1;
744
- };
745
- type RemoveNodeOperation = ExtendedType<'RemoveNodeOperation', BaseRemoveNodeOperation>;
746
- type BaseRemoveTextOperation = {
747
- type: 'remove_text';
748
- path: Path$1;
749
- offset: number;
750
- text: string;
751
- };
752
- type RemoveTextOperation = ExtendedType<'RemoveTextOperation', BaseRemoveTextOperation>;
753
- type BaseSetNodeOperation = {
754
- type: 'set_node';
755
- path: Path$1;
756
- properties: Partial<Node$1>;
757
- newProperties: Partial<Node$1>;
758
- };
759
- type SetNodeOperation = ExtendedType<'SetNodeOperation', BaseSetNodeOperation>;
760
- type BaseSetSelectionOperation = {
761
- type: 'set_selection';
762
- properties: null;
763
- newProperties: Range;
764
- } | {
765
- type: 'set_selection';
766
- properties: Partial<Range>;
767
- newProperties: Partial<Range>;
768
- } | {
769
- type: 'set_selection';
770
- properties: Range;
771
- newProperties: null;
772
- };
773
- type SetSelectionOperation = ExtendedType<'SetSelectionOperation', BaseSetSelectionOperation>;
774
- type NodeOperation = InsertNodeOperation | RemoveNodeOperation | SetNodeOperation;
775
- type SelectionOperation = SetSelectionOperation;
776
- type TextOperation = InsertTextOperation | RemoveTextOperation;
777
- /**
778
- * `Operation` objects define the low-level instructions that Slate editors use
779
- * to apply changes to their internal state. Representing all changes as
780
- * operations is what allows Slate editors to easily implement history,
781
- * collaboration, and other features.
782
- */
783
- type BaseOperation = NodeOperation | SelectionOperation | TextOperation;
784
- type Operation = ExtendedType<'Operation', BaseOperation>;
785
- interface OperationInterface {
786
- /**
787
- * Check if a value is an `Operation` object.
788
- */
789
- isOperation: (value: any) => value is Operation;
790
- /**
791
- * Check if a value is a list of `Operation` objects.
792
- */
793
- isOperationList: (value: any) => value is Operation[];
794
- /**
795
- * Invert an operation, returning a new operation that will exactly undo the
796
- * original when applied.
797
- */
798
- inverse: (op: Operation) => Operation;
115
+ interface SlateTextBlock extends Omit<PortableTextTextBlock, 'children'> {
116
+ children: Descendant[];
799
117
  }
800
- declare const Operation: OperationInterface;
801
118
  /**
802
- * `PathRef` objects keep a specific path in a document synced over time as new
803
- * operations are applied to the editor. You can access their `current` property
804
- * at any time for the up-to-date path value.
119
+ * @public
805
120
  */
806
- interface PathRef {
807
- current: Path$1 | null;
808
- affinity: 'forward' | 'backward' | null;
809
- unref(): Path$1 | null;
810
- }
811
- interface PathRefInterface {
812
- /**
813
- * Transform the path ref's current value by an operation.
814
- */
815
- transform: (ref: PathRef, op: Operation) => void;
816
- }
817
- declare const PathRef: PathRefInterface;
121
+ type EditorSchema = Schema;
818
122
  /**
819
123
  * `Path` arrays are a list of indexes that describe a node's exact position in
820
- * a Slate node tree. Although they are usually relative to the root `Editor`
821
- * object, they can be relative to any `Node` object.
822
- */
823
- type Path$1 = number[];
824
- interface PathAncestorsOptions {
825
- reverse?: boolean;
826
- }
827
- interface PathLevelsOptions {
828
- reverse?: boolean;
829
- }
830
- interface PathInterface {
831
- /**
832
- * Get a list of ancestor paths for a given path.
833
- *
834
- * The paths are sorted from shallowest to deepest ancestor. However, if the
835
- * `reverse: true` option is passed, they are reversed.
836
- */
837
- ancestors: (path: Path$1, options?: PathAncestorsOptions) => Path$1[];
838
- /**
839
- * Get the common ancestor path of two paths.
840
- */
841
- common: (path: Path$1, another: Path$1) => Path$1;
842
- /**
843
- * Compare a path to another, returning an integer indicating whether the path
844
- * was before, at, or after the other.
845
- *
846
- * Note: Two paths of unequal length can still receive a `0` result if one is
847
- * directly above or below the other. If you want exact matching, use
848
- * [[Path.equals]] instead.
849
- */
850
- compare: (path: Path$1, another: Path$1) => -1 | 0 | 1;
851
- /**
852
- * Check if a path ends before one of the indexes in another.
853
- */
854
- endsBefore: (path: Path$1, another: Path$1) => boolean;
855
- /**
856
- * Check if a path is exactly equal to another.
857
- */
858
- equals: (path: Path$1, another: Path$1) => boolean;
859
- /**
860
- * Check if the path of previous sibling node exists
861
- */
862
- hasPrevious: (path: Path$1) => boolean;
863
- /**
864
- * Check if a path is after another.
865
- */
866
- isAfter: (path: Path$1, another: Path$1) => boolean;
867
- /**
868
- * Check if a path is an ancestor of another.
869
- */
870
- isAncestor: (path: Path$1, another: Path$1) => boolean;
871
- /**
872
- * Check if a path is before another.
873
- */
874
- isBefore: (path: Path$1, another: Path$1) => boolean;
875
- /**
876
- * Check if a path is equal to or an ancestor of another.
877
- */
878
- isCommon: (path: Path$1, another: Path$1) => boolean;
879
- /**
880
- * Check if a path is a descendant of another.
881
- */
882
- isDescendant: (path: Path$1, another: Path$1) => boolean;
883
- /**
884
- * Check is a value implements the `Path` interface.
885
- */
886
- isPath: (value: any) => value is Path$1;
887
- /**
888
- * Check if a path is a sibling of another.
889
- */
890
- isSibling: (path: Path$1, another: Path$1) => boolean;
891
- /**
892
- * Get a list of paths at every level down to a path. Note: this is the same
893
- * as `Path.ancestors`, but including the path itself.
894
- *
895
- * The paths are sorted from shallowest to deepest. However, if the `reverse:
896
- * true` option is passed, they are reversed.
897
- */
898
- levels: (path: Path$1, options?: PathLevelsOptions) => Path$1[];
899
- /**
900
- * Given a path, get the path to the next sibling node.
901
- */
902
- next: (path: Path$1) => Path$1;
903
- /**
904
- * Returns whether this operation can affect paths or not. Used as an
905
- * optimization when updating dirty paths during normalization.
906
- */
907
- operationCanTransformPath: (operation: Operation) => operation is InsertNodeOperation | RemoveNodeOperation;
908
- /**
909
- * Given a path, return a new path referring to the parent node above it.
910
- */
911
- parent: (path: Path$1) => Path$1;
912
- /**
913
- * Given a path, get the path to the previous sibling node.
914
- */
915
- previous: (path: Path$1) => Path$1;
916
- /**
917
- * Transform a path by an operation.
918
- */
919
- transform: (path: Path$1, operation: Operation) => Path$1 | null;
920
- }
921
- declare const Path$1: PathInterface;
922
- /**
923
- * `PointRef` objects keep a specific point in a document synced over time as new
924
- * operations are applied to the editor. You can access their `current` property
925
- * at any time for the up-to-date point value.
926
- */
927
- interface PointRef {
928
- current: Point | null;
929
- affinity: TextDirection | null;
930
- unref(): Point | null;
931
- }
932
- interface PointRefInterface {
933
- /**
934
- * Transform the point ref's current value by an operation.
935
- */
936
- transform: (ref: PointRef, op: Operation) => void;
937
- }
938
- declare const PointRef: PointRefInterface;
939
- /**
940
- * `Point` objects refer to a specific location in a text node in a Slate
941
- * document. Its path refers to the location of the node in the tree, and its
942
- * offset refers to the distance into the node's string of text. Points can
943
- * only refer to `Text` nodes.
944
- */
945
- interface BasePoint {
946
- path: Path$1;
947
- offset: number;
948
- }
949
- type Point = ExtendedType<'Point', BasePoint>;
950
- interface PointTransformOptions {
951
- affinity?: TextDirection | null;
952
- }
953
- interface PointInterface {
954
- /**
955
- * Compare a point to another, returning an integer indicating whether the
956
- * point was before, at, or after the other.
957
- */
958
- compare: (point: Point, another: Point) => -1 | 0 | 1;
959
- /**
960
- * Check if a point is after another.
961
- */
962
- isAfter: (point: Point, another: Point) => boolean;
963
- /**
964
- * Check if a point is before another.
965
- */
966
- isBefore: (point: Point, another: Point) => boolean;
967
- /**
968
- * Check if a point is exactly equal to another.
969
- */
970
- equals: (point: Point, another: Point) => boolean;
971
- /**
972
- * Check if a value implements the `Point` interface.
973
- */
974
- isPoint: (value: any) => value is Point;
975
- /**
976
- * Transform a point by an operation.
977
- */
978
- transform: (point: Point, op: Operation, options?: PointTransformOptions) => Point | null;
979
- }
980
- declare const Point: PointInterface;
981
- /**
982
- * `PointEntry` objects are returned when iterating over `Point` objects that
983
- * belong to a range.
124
+ * a Slate node tree. Although they are usually relative to the root `Editor`
125
+ * object, they can be relative to any `Node` object.
984
126
  */
985
- type PointEntry = [Point, 'anchor' | 'focus'];
127
+ type Path$1 = number[];
128
+ type TextDirection = 'forward' | 'backward';
986
129
  /**
987
- * `RangeRef` objects keep a specific range in a document synced over time as new
988
- * operations are applied to the editor. You can access their `current` property
989
- * at any time for the up-to-date range value.
130
+ * `Point` objects refer to a specific location in a text node in a Slate
131
+ * document. Its path refers to the location of the node in the tree, and its
132
+ * offset refers to the distance into the node's string of text. Points can
133
+ * only refer to `Text` nodes.
990
134
  */
991
- interface RangeRef {
992
- current: Range | null;
993
- affinity: 'forward' | 'backward' | 'outward' | 'inward' | null;
994
- unref(): Range | null;
995
- }
996
- interface RangeRefInterface {
997
- /**
998
- * Transform the range ref's current value by an operation.
999
- */
1000
- transform: (ref: RangeRef, op: Operation) => void;
135
+ interface BasePoint {
136
+ path: number[];
137
+ offset: number;
1001
138
  }
1002
- declare const RangeRef: RangeRefInterface;
139
+ type Point = BasePoint;
1003
140
  /**
1004
141
  * `Range` objects are a set of points that refer to a specific span of a Slate
1005
142
  * document. They can define a span inside a single node or a can span across
@@ -1009,191 +146,70 @@ interface BaseRange {
1009
146
  anchor: Point;
1010
147
  focus: Point;
1011
148
  }
1012
- type Range = ExtendedType<'Range', BaseRange>;
1013
- interface RangeEdgesOptions {
1014
- reverse?: boolean;
1015
- }
1016
- interface RangeTransformOptions {
1017
- affinity?: RangeDirection | null;
1018
- }
1019
- interface RangeInterface {
1020
- /**
1021
- * Get the start and end points of a range, in the order in which they appear
1022
- * in the document.
1023
- */
1024
- edges: (range: Range, options?: RangeEdgesOptions) => [Point, Point];
1025
- /**
1026
- * Get the end point of a range.
1027
- */
1028
- end: (range: Range) => Point;
1029
- /**
1030
- * Check if a range is exactly equal to another.
1031
- */
1032
- equals: (range: Range, another: Range) => boolean;
1033
- /**
1034
- * Check if a range includes a path, a point or part of another range.
1035
- */
1036
- includes: (range: Range, target: Path$1 | Point | Range) => boolean;
1037
- /**
1038
- * Get the intersection of a range with another.
1039
- */
1040
- intersection: (range: Range, another: Range) => Range | null;
1041
- /**
1042
- * Check if a range is backward, meaning that its anchor point appears in the
1043
- * document _after_ its focus point.
1044
- */
1045
- isBackward: (range: Range) => boolean;
1046
- /**
1047
- * Check if a range is collapsed, meaning that both its anchor and focus
1048
- * points refer to the exact same position in the document.
1049
- */
1050
- isCollapsed: (range: Range) => boolean;
1051
- /**
1052
- * Check if a range is expanded.
1053
- *
1054
- * This is the opposite of [[Range.isCollapsed]] and is provided for legibility.
1055
- */
1056
- isExpanded: (range: Range) => boolean;
1057
- /**
1058
- * Check if a range is forward.
1059
- *
1060
- * This is the opposite of [[Range.isBackward]] and is provided for legibility.
1061
- */
1062
- isForward: (range: Range) => boolean;
1063
- /**
1064
- * Check if a value implements the [[Range]] interface.
1065
- */
1066
- isRange: (value: any) => value is Range;
1067
- /**
1068
- * Iterate through all of the point entries in a range.
1069
- */
1070
- points: (range: Range) => Generator<PointEntry, void, undefined>;
1071
- /**
1072
- * Get the start point of a range.
1073
- */
1074
- start: (range: Range) => Point;
1075
- /**
1076
- * Transform a range by an operation.
1077
- */
1078
- transform: (range: Range, op: Operation, options?: RangeTransformOptions) => Range | null;
1079
- }
1080
- declare const Range: RangeInterface;
1081
- /**
1082
- * `Text` objects represent the nodes that contain the actual text content of a
1083
- * Slate document along with any formatting properties. They are always leaf
1084
- * nodes in the document tree as they cannot contain any children.
1085
- */
1086
- interface BaseText {
149
+ type Range = BaseRange;
150
+ type BaseInsertNodeOperation = {
151
+ type: 'insert_node';
152
+ path: Path$1;
153
+ node: Node$1;
154
+ };
155
+ type InsertNodeOperation = BaseInsertNodeOperation;
156
+ type BaseInsertTextOperation = {
157
+ type: 'insert_text';
158
+ path: Path$1;
159
+ offset: number;
1087
160
  text: string;
1088
- }
1089
- type Text$1 = ExtendedType<'Text', BaseText>;
1090
- interface LeafPosition {
1091
- start: number;
1092
- end: number;
1093
- isFirst?: true;
1094
- isLast?: true;
1095
- }
1096
- interface TextEqualsOptions {
1097
- loose?: boolean;
1098
- }
1099
- type DecoratedRange$1 = Range & {
1100
- /**
1101
- * Customize how another decoration is merged into a text node. If not specified, `Object.assign` would be used.
1102
- * It is useful for overlapping decorations with the same key but different values.
1103
- */
1104
- merge?: (leaf: Text$1, decoration: object) => void;
1105
161
  };
1106
- interface TextInterface {
1107
- /**
1108
- * Check if two text nodes are equal.
1109
- *
1110
- * When loose is set, the text is not compared. This is
1111
- * used to check whether sibling text nodes can be merged.
1112
- */
1113
- equals: (text: Text$1, another: Text$1, options?: TextEqualsOptions) => boolean;
1114
- /**
1115
- * Check if a value implements the `Text` interface.
1116
- */
1117
- isText: (value: any, schema: EditorSchema) => value is Text$1;
1118
- /**
1119
- * Get the leaves for a text node given decorations.
1120
- */
1121
- decorations: (node: Text$1, decorations: DecoratedRange$1[]) => {
1122
- leaf: Text$1;
1123
- position?: LeafPosition;
1124
- }[];
1125
- }
1126
- 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;
162
+ type InsertTextOperation = BaseInsertTextOperation;
163
+ type BaseRemoveNodeOperation = {
164
+ type: 'remove_node';
165
+ path: Path$1;
166
+ node: Node$1;
167
+ };
168
+ type RemoveNodeOperation = BaseRemoveNodeOperation;
169
+ type BaseRemoveTextOperation = {
170
+ type: 'remove_text';
171
+ path: Path$1;
172
+ offset: number;
173
+ text: string;
174
+ };
175
+ type RemoveTextOperation = BaseRemoveTextOperation;
176
+ type BaseSetNodeOperation = {
177
+ type: 'set_node';
178
+ path: Path$1;
179
+ properties: Partial<Node$1>;
180
+ newProperties: Partial<Node$1>;
181
+ };
182
+ type SetNodeOperation = BaseSetNodeOperation;
183
+ type BaseSetSelectionOperation = {
184
+ type: 'set_selection';
185
+ properties: null;
186
+ newProperties: Range;
187
+ } | {
188
+ type: 'set_selection';
189
+ properties: Partial<Range>;
190
+ newProperties: Partial<Range>;
191
+ } | {
192
+ type: 'set_selection';
193
+ properties: Range;
194
+ newProperties: null;
195
+ };
196
+ type SetSelectionOperation = BaseSetSelectionOperation;
197
+ type BaseOperation = InsertNodeOperation | RemoveNodeOperation | SetNodeOperation | SetSelectionOperation | InsertTextOperation | RemoveTextOperation;
198
+ type Operation = BaseOperation;
1194
199
  type DecoratedRange = BaseRange & {
1195
200
  rangeDecoration: RangeDecoration;
1196
201
  };
202
+ /**
203
+ * `RangeRef` objects keep a specific range in a document synced over time as new
204
+ * operations are applied to the editor. You can access their `current` property
205
+ * at any time for the up-to-date range value.
206
+ */
207
+ interface RangeRef {
208
+ current: Range | null;
209
+ affinity: 'forward' | 'backward' | 'outward' | 'inward' | null;
210
+ unref(): Range | null;
211
+ }
212
+ type Text$1 = PortableTextSpan;
1197
213
  type StringDiff = {
1198
214
  start: number;
1199
215
  end: number;
@@ -1242,8 +258,6 @@ interface DOMEditor extends BaseEditor {
1242
258
  hasRange: (editor: Editor$1, range: Range) => boolean;
1243
259
  hasSelectableTarget: (editor: Editor$1, target: EventTarget | null) => boolean;
1244
260
  hasTarget: (editor: Editor$1, target: EventTarget | null) => target is DOMNode;
1245
- insertData: (data: DataTransfer) => void;
1246
- insertTextData: (data: DataTransfer) => boolean;
1247
261
  isTargetInsideNonReadonlyVoid: (editor: Editor$1, target: EventTarget | null) => boolean;
1248
262
  isNodeMapDirty: boolean;
1249
263
  domWindow: Window | null;
@@ -1384,24 +398,6 @@ declare const DOMEditor: DOMEditorInterface;
1384
398
  interface ReactEditor extends DOMEditor {}
1385
399
  interface ReactEditorInterface extends DOMEditorInterface {}
1386
400
  declare const ReactEditor: ReactEditorInterface;
1387
- interface ObjectElement {
1388
- _type: string;
1389
- _key: string;
1390
- children: Descendant[];
1391
- [key: string]: unknown;
1392
- }
1393
- interface SlateTextBlock extends Omit<PortableTextTextBlock, 'children'> {
1394
- children: Descendant[];
1395
- }
1396
- declare module '../slate/index' {
1397
- interface CustomTypes {
1398
- Editor: BaseEditor & ReactEditor & PortableTextSlateEditor;
1399
- Element: SlateTextBlock | ObjectElement;
1400
- ObjectNode: ObjectElement;
1401
- Text: PortableTextSpan;
1402
- }
1403
- }
1404
- //# sourceMappingURL=slate.d.ts.map
1405
401
  type HistoryItem = {
1406
402
  operations: Operation[];
1407
403
  timestamp: Date;
@@ -1441,15 +437,115 @@ interface PortableTextSlateEditor extends ReactEditor {
1441
437
  isRedoing: boolean;
1442
438
  isUndoing: boolean;
1443
439
  withHistory: boolean;
1444
- /**
1445
- * Undo
1446
- */
1447
- undo: () => void;
1448
- /**
1449
- * Redo
1450
- */
1451
- redo: () => void;
1452
440
  }
441
+ type Element$1 = SlateTextBlock | ObjectElement;
442
+ /**
443
+ * The `Location` interface is a union of the ways to refer to a specific
444
+ * location in a Slate document: paths, points or ranges.
445
+ *
446
+ * Methods will often accept a `Location` instead of requiring only a `Path`,
447
+ * `Point` or `Range`. This eliminates the need for developers to manage
448
+ * converting between the different interfaces in their own code base.
449
+ */
450
+ type Location = Path$1 | Point | Range;
451
+ /**
452
+ * `PathRef` objects keep a specific path in a document synced over time as new
453
+ * operations are applied to the editor. You can access their `current` property
454
+ * at any time for the up-to-date path value.
455
+ */
456
+ interface PathRef {
457
+ current: Path$1 | null;
458
+ affinity: 'forward' | 'backward' | null;
459
+ unref(): Path$1 | null;
460
+ }
461
+ interface PathRefInterface {
462
+ transform: (ref: PathRef, op: Operation) => void;
463
+ }
464
+ declare const PathRef: PathRefInterface;
465
+ /**
466
+ * `PointRef` objects keep a specific point in a document synced over time as new
467
+ * operations are applied to the editor. You can access their `current` property
468
+ * at any time for the up-to-date point value.
469
+ */
470
+ interface PointRef {
471
+ current: Point | null;
472
+ affinity: TextDirection | null;
473
+ unref(): Point | null;
474
+ }
475
+ interface PointRefInterface {
476
+ transform: (ref: PointRef, op: Operation) => void;
477
+ }
478
+ declare const PointRef: PointRefInterface;
479
+ /**
480
+ * The `Editor` interface stores all the state of a Slate editor. It is extended
481
+ * by plugins that wish to add their own helpers and implement new behaviors.
482
+ */
483
+ interface BaseEditor {
484
+ children: Descendant[];
485
+ selection: Selection$1;
486
+ operations: Operation[];
487
+ marks: EditorMarks | null;
488
+ dirtyPaths: Path$1[];
489
+ dirtyPathKeys: Set<string>;
490
+ flushing: boolean;
491
+ normalizing: boolean;
492
+ batchingDirtyPaths: boolean;
493
+ pathRefs: Set<PathRef>;
494
+ pointRefs: Set<PointRef>;
495
+ rangeRefs: Set<RangeRef>;
496
+ apply: (operation: Operation) => void;
497
+ createSpan: () => Text$1;
498
+ getDirtyPaths: (operation: Operation) => Path$1[];
499
+ isElementReadOnly: (element: Element$1) => boolean;
500
+ isInline: (element: Element$1) => boolean;
501
+ isSelectable: (element: Element$1) => boolean;
502
+ normalizeNode: (entry: NodeEntry, options?: {
503
+ operation?: Operation;
504
+ }) => void;
505
+ onChange: (options?: {
506
+ operation?: Operation;
507
+ }) => void;
508
+ shouldNormalize: ({
509
+ iteration,
510
+ dirtyPaths,
511
+ operation
512
+ }: {
513
+ iteration: number;
514
+ initialDirtyPathsLength: number;
515
+ dirtyPaths: Path$1[];
516
+ operation?: Operation;
517
+ }) => boolean;
518
+ select: (target: Location) => void;
519
+ setSelection: (props: Partial<Range>) => void;
520
+ }
521
+ type Editor$1 = BaseEditor & ReactEditor & PortableTextSlateEditor;
522
+ type BaseSelection = Range | null;
523
+ type Selection$1 = BaseSelection;
524
+ type EditorMarks = Omit<Text$1, 'text'>;
525
+ type ObjectNode = ObjectElement;
526
+ /**
527
+ * The `Node` union type represents all of the different types of nodes that
528
+ * occur in a Slate document tree.
529
+ */
530
+ type Node$1 = Editor$1 | Element$1 | ObjectNode | Text$1;
531
+ /**
532
+ * The `Descendant` union type represents nodes that are descendants in the
533
+ * tree. It is returned as a convenience in certain cases to narrow a value
534
+ * further than the more generic `Node` union.
535
+ */
536
+ type Descendant = Element$1 | ObjectNode | Text$1;
537
+ /**
538
+ * The `Ancestor` union type represents nodes that are ancestors in the tree.
539
+ * It is returned as a convenience in certain cases to narrow a value further
540
+ * than the more generic `Node` union.
541
+ */
542
+ type Ancestor = Editor$1 | Element$1;
543
+ /**
544
+ * `NodeEntry` objects are returned when iterating over the nodes in a Slate
545
+ * document tree. They consist of the node and its `Path` relative to the root
546
+ * node in the document.
547
+ */
548
+ type NodeEntry<T extends Node$1 = Node$1> = [T, Path$1];
1453
549
  /**
1454
550
  * @public
1455
551
  */
@@ -1957,7 +1053,7 @@ type PortableTextEditableProps = Omit<TextareaHTMLAttributes<HTMLDivElement>, 'o
1957
1053
  * ```
1958
1054
  * @group Components
1959
1055
  */
1960
- declare const PortableTextEditable: react8.ForwardRefExoticComponent<Omit<PortableTextEditableProps, "ref"> & react8.RefAttributes<Omit<HTMLDivElement, "as" | "onPaste" | "onBeforeInput">>>;
1056
+ declare const PortableTextEditable: react4.ForwardRefExoticComponent<Omit<PortableTextEditableProps, "ref"> & react4.RefAttributes<Omit<HTMLDivElement, "as" | "onPaste" | "onBeforeInput">>>;
1961
1057
  /** @beta */
1962
1058
  interface EditableAPIDeleteOptions {
1963
1059
  mode?: 'blocks' | 'children' | 'selected';
@@ -2593,7 +1689,7 @@ declare const editorMachine: xstate73.StateMachine<{
2593
1689
  initialValue?: Array<PortableTextBlock>;
2594
1690
  }, xstate73.NonReducibleUnknown, InternalPatchEvent | MutationEvent | PatchesEvent | {
2595
1691
  type: "blurred";
2596
- event: react8.FocusEvent<HTMLDivElement, Element>;
1692
+ event: react4.FocusEvent<HTMLDivElement, Element>;
2597
1693
  } | {
2598
1694
  type: "done loading";
2599
1695
  } | {
@@ -2605,7 +1701,7 @@ declare const editorMachine: xstate73.StateMachine<{
2605
1701
  data: unknown;
2606
1702
  } | {
2607
1703
  type: "focused";
2608
- event: react8.FocusEvent<HTMLDivElement, Element>;
1704
+ event: react4.FocusEvent<HTMLDivElement, Element>;
2609
1705
  } | {
2610
1706
  type: "invalid value";
2611
1707
  resolution: InvalidValueResolution | null;