@portabletext/editor 6.3.2 → 6.5.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.
@@ -1,8 +1,8 @@
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 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}`;
@@ -111,157 +111,61 @@ type ChildPath = [{
111
111
  */
112
112
  type EditorSchema = Schema;
113
113
  /**
114
- * The `Editor` interface stores all the state of a Slate editor. It is extended
115
- * by plugins that wish to add their own helpers and implement new behaviors.
116
- */
117
- interface BaseEditor {
118
- children: Descendant[];
119
- selection: Selection$1;
120
- operations: Operation[];
121
- marks: EditorMarks | null;
122
- dirtyPaths: Path$1[];
123
- dirtyPathKeys: Set<string>;
124
- flushing: boolean;
125
- normalizing: boolean;
126
- batchingDirtyPaths: boolean;
127
- pathRefs: Set<PathRef>;
128
- pointRefs: Set<PointRef>;
129
- rangeRefs: Set<RangeRef>;
130
- apply: (operation: Operation) => void;
131
- createSpan: () => Text$1;
132
- getDirtyPaths: (operation: Operation) => Path$1[];
133
- isElementReadOnly: (element: Element$1) => boolean;
134
- isInline: (element: Element$1) => boolean;
135
- isSelectable: (element: Element$1) => boolean;
136
- normalizeNode: (entry: NodeEntry, options?: {
137
- operation?: Operation;
138
- }) => void;
139
- onChange: (options?: {
140
- operation?: Operation;
141
- }) => void;
142
- shouldNormalize: ({
143
- iteration,
144
- dirtyPaths,
145
- operation
146
- }: {
147
- iteration: number;
148
- initialDirtyPathsLength: number;
149
- dirtyPaths: Path$1[];
150
- operation?: Operation;
151
- }) => boolean;
152
- select: (target: Location) => void;
153
- setSelection: (props: Partial<Range>) => void;
154
- }
155
- type Editor$1 = ExtendedType<'Editor', BaseEditor>;
156
- type BaseSelection = Range | null;
157
- type Selection$1 = ExtendedType<'Selection', BaseSelection>;
158
- type EditorMarks = Omit<Text$1, 'text'>;
159
- interface EditorInterface {
160
- isElementReadOnly: (editor: Editor$1, element: Element$1) => boolean;
161
- isInline: (editor: Editor$1, value: Element$1) => boolean;
162
- isSelectable: (editor: Editor$1, element: Element$1) => boolean;
163
- }
164
- declare const Editor$1: EditorInterface;
165
- /**
166
- * `Element` objects are a type of node in a Slate document that contain other
167
- * element nodes or text nodes. They can be either "blocks" or "inlines"
168
- * depending on the Slate editor's configuration.
169
- */
170
- interface BaseElement {
171
- children: Descendant[];
172
- }
173
- type Element$1 = ExtendedType<'Element', BaseElement>;
174
- interface ElementInterface {
175
- /**
176
- * Check if a value implements the 'Ancestor' interface.
177
- */
178
- isAncestor: (value: any, schema: EditorSchema) => value is Ancestor;
179
- /**
180
- * Check if a value implements the `Element` interface.
181
- */
182
- isElement: (value: any, schema: EditorSchema) => value is Element$1;
183
- }
184
- declare const Element$1: ElementInterface;
185
- /**
186
- * The `Location` interface is a union of the ways to refer to a specific
187
- * location in a Slate document: paths, points or ranges.
188
- *
189
- * Methods will often accept a `Location` instead of requiring only a `Path`,
190
- * `Point` or `Range`. This eliminates the need for developers to manage
191
- * converting between the different interfaces in their own code base.
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.
192
117
  */
193
- type Location = Path$1 | Point | Range;
118
+ type Path$1 = number[];
119
+ type Node$1 = PortableTextTextBlock | PortableTextObject | PortableTextSpan;
120
+ type TextDirection = 'forward' | 'backward';
194
121
  /**
195
- * Extendable Custom Types Interface
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.
196
126
  */
197
- type ExtendableTypes = 'Editor' | 'Element' | 'ObjectNode' | 'Text' | 'Selection' | 'Range' | 'Point' | 'Operation' | 'InsertNodeOperation' | 'InsertTextOperation' | 'RemoveNodeOperation' | 'RemoveTextOperation' | 'SetNodeOperation' | 'SetSelectionOperation';
198
- interface CustomTypes {
199
- [key: string]: unknown;
127
+ interface Point {
128
+ path: number[];
129
+ offset: number;
200
130
  }
201
- type ExtendedType<K$1 extends ExtendableTypes, B> = unknown extends CustomTypes[K$1] ? B : CustomTypes[K$1];
202
131
  /**
203
- * `ObjectNode` represents a node with semantic content but no children or text.
204
- * Block objects and inline objects are ObjectNodes in the tree.
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.
205
135
  */
206
- interface BaseObjectNode {
207
- _type: string;
208
- _key: string;
209
- [key: string]: unknown;
136
+ interface Range {
137
+ anchor: Point;
138
+ focus: Point;
210
139
  }
211
- type ObjectNode = ExtendedType<'ObjectNode', BaseObjectNode>;
212
- type Node$1 = Editor$1 | Element$1 | ObjectNode | Text$1;
213
- /**
214
- * The `Descendant` union type represents nodes that are descendants in the
215
- * tree. It is returned as a convenience in certain cases to narrow a value
216
- * further than the more generic `Node` union.
217
- */
218
- type Descendant = Element$1 | ObjectNode | Text$1;
219
- /**
220
- * The `Ancestor` union type represents nodes that are ancestors in the tree.
221
- * It is returned as a convenience in certain cases to narrow a value further
222
- * than the more generic `Node` union.
223
- */
224
- type Ancestor = Editor$1 | Element$1;
225
- /**
226
- * `NodeEntry` objects are returned when iterating over the nodes in a Slate
227
- * document tree. They consist of the node and its `Path` relative to the root
228
- * node in the document.
229
- */
230
- type NodeEntry<T extends Node$1 = Node$1> = [T, Path$1];
231
- type BaseInsertNodeOperation = {
140
+ type InsertNodeOperation = {
232
141
  type: 'insert_node';
233
142
  path: Path$1;
234
143
  node: Node$1;
235
144
  };
236
- type InsertNodeOperation = ExtendedType<'InsertNodeOperation', BaseInsertNodeOperation>;
237
- type BaseInsertTextOperation = {
145
+ type InsertTextOperation = {
238
146
  type: 'insert_text';
239
147
  path: Path$1;
240
148
  offset: number;
241
149
  text: string;
242
150
  };
243
- type InsertTextOperation = ExtendedType<'InsertTextOperation', BaseInsertTextOperation>;
244
- type BaseRemoveNodeOperation = {
151
+ type RemoveNodeOperation = {
245
152
  type: 'remove_node';
246
153
  path: Path$1;
247
154
  node: Node$1;
248
155
  };
249
- type RemoveNodeOperation = ExtendedType<'RemoveNodeOperation', BaseRemoveNodeOperation>;
250
- type BaseRemoveTextOperation = {
156
+ type RemoveTextOperation = {
251
157
  type: 'remove_text';
252
158
  path: Path$1;
253
159
  offset: number;
254
160
  text: string;
255
161
  };
256
- type RemoveTextOperation = ExtendedType<'RemoveTextOperation', BaseRemoveTextOperation>;
257
- type BaseSetNodeOperation = {
162
+ type SetNodeOperation = {
258
163
  type: 'set_node';
259
164
  path: Path$1;
260
165
  properties: Partial<Node$1>;
261
166
  newProperties: Partial<Node$1>;
262
167
  };
263
- type SetNodeOperation = ExtendedType<'SetNodeOperation', BaseSetNodeOperation>;
264
- type BaseSetSelectionOperation = {
168
+ type SetSelectionOperation = {
265
169
  type: 'set_selection';
266
170
  properties: null;
267
171
  newProperties: Range;
@@ -274,34 +178,19 @@ type BaseSetSelectionOperation = {
274
178
  properties: Range;
275
179
  newProperties: null;
276
180
  };
277
- type SetSelectionOperation = ExtendedType<'SetSelectionOperation', BaseSetSelectionOperation>;
278
- type NodeOperation = InsertNodeOperation | RemoveNodeOperation | SetNodeOperation;
279
- type SelectionOperation = SetSelectionOperation;
280
- type TextOperation = InsertTextOperation | RemoveTextOperation;
181
+ type Operation = InsertNodeOperation | RemoveNodeOperation | SetNodeOperation | SetSelectionOperation | InsertTextOperation | RemoveTextOperation;
182
+ type DecoratedRange = Range & {
183
+ rangeDecoration: RangeDecoration;
184
+ };
281
185
  /**
282
- * `Operation` objects define the low-level instructions that Slate editors use
283
- * to apply changes to their internal state. Representing all changes as
284
- * operations is what allows Slate editors to easily implement history,
285
- * collaboration, and other features.
186
+ * The `Location` interface is a union of the ways to refer to a specific
187
+ * location in a Slate document: paths, points or ranges.
188
+ *
189
+ * Methods will often accept a `Location` instead of requiring only a `Path`,
190
+ * `Point` or `Range`. This eliminates the need for developers to manage
191
+ * converting between the different interfaces in their own code base.
286
192
  */
287
- type BaseOperation = NodeOperation | SelectionOperation | TextOperation;
288
- type Operation = ExtendedType<'Operation', BaseOperation>;
289
- interface OperationInterface {
290
- /**
291
- * Check if a value is an `Operation` object.
292
- */
293
- isOperation: (value: any) => value is Operation;
294
- /**
295
- * Check if a value is a list of `Operation` objects.
296
- */
297
- isOperationList: (value: any) => value is Operation[];
298
- /**
299
- * Invert an operation, returning a new operation that will exactly undo the
300
- * original when applied.
301
- */
302
- inverse: (op: Operation) => Operation;
303
- }
304
- declare const Operation: OperationInterface;
193
+ type Location = Path$1 | Point | Range;
305
194
  /**
306
195
  * `PathRef` objects keep a specific path in a document synced over time as new
307
196
  * operations are applied to the editor. You can access their `current` property
@@ -313,118 +202,9 @@ interface PathRef {
313
202
  unref(): Path$1 | null;
314
203
  }
315
204
  interface PathRefInterface {
316
- /**
317
- * Transform the path ref's current value by an operation.
318
- */
319
205
  transform: (ref: PathRef, op: Operation) => void;
320
206
  }
321
207
  declare const PathRef: PathRefInterface;
322
- /**
323
- * `Path` arrays are a list of indexes that describe a node's exact position in
324
- * a Slate node tree. Although they are usually relative to the root `Editor`
325
- * object, they can be relative to any `Node` object.
326
- */
327
- type Path$1 = number[];
328
- interface PathAncestorsOptions {
329
- reverse?: boolean;
330
- }
331
- interface PathLevelsOptions {
332
- reverse?: boolean;
333
- }
334
- interface PathInterface {
335
- /**
336
- * Get a list of ancestor paths for a given path.
337
- *
338
- * The paths are sorted from shallowest to deepest ancestor. However, if the
339
- * `reverse: true` option is passed, they are reversed.
340
- */
341
- ancestors: (path: Path$1, options?: PathAncestorsOptions) => Path$1[];
342
- /**
343
- * Get the common ancestor path of two paths.
344
- */
345
- common: (path: Path$1, another: Path$1) => Path$1;
346
- /**
347
- * Compare a path to another, returning an integer indicating whether the path
348
- * was before, at, or after the other.
349
- *
350
- * Note: Two paths of unequal length can still receive a `0` result if one is
351
- * directly above or below the other. If you want exact matching, use
352
- * [[Path.equals]] instead.
353
- */
354
- compare: (path: Path$1, another: Path$1) => -1 | 0 | 1;
355
- /**
356
- * Check if a path ends before one of the indexes in another.
357
- */
358
- endsBefore: (path: Path$1, another: Path$1) => boolean;
359
- /**
360
- * Check if a path is exactly equal to another.
361
- */
362
- equals: (path: Path$1, another: Path$1) => boolean;
363
- /**
364
- * Check if the path of previous sibling node exists
365
- */
366
- hasPrevious: (path: Path$1) => boolean;
367
- /**
368
- * Check if a path is after another.
369
- */
370
- isAfter: (path: Path$1, another: Path$1) => boolean;
371
- /**
372
- * Check if a path is an ancestor of another.
373
- */
374
- isAncestor: (path: Path$1, another: Path$1) => boolean;
375
- /**
376
- * Check if a path is before another.
377
- */
378
- isBefore: (path: Path$1, another: Path$1) => boolean;
379
- /**
380
- * Check if a path is equal to or an ancestor of another.
381
- */
382
- isCommon: (path: Path$1, another: Path$1) => boolean;
383
- /**
384
- * Check if a path is a descendant of another.
385
- */
386
- isDescendant: (path: Path$1, another: Path$1) => boolean;
387
- /**
388
- * Check is a value implements the `Path` interface.
389
- */
390
- isPath: (value: any) => value is Path$1;
391
- /**
392
- * Check if a path is a sibling of another.
393
- */
394
- isSibling: (path: Path$1, another: Path$1) => boolean;
395
- /**
396
- * Get a list of paths at every level down to a path. Note: this is the same
397
- * as `Path.ancestors`, but including the path itself.
398
- *
399
- * The paths are sorted from shallowest to deepest. However, if the `reverse:
400
- * true` option is passed, they are reversed.
401
- */
402
- levels: (path: Path$1, options?: PathLevelsOptions) => Path$1[];
403
- /**
404
- * Given a path, get the path to the next sibling node.
405
- */
406
- next: (path: Path$1) => Path$1;
407
- /**
408
- * Returns whether this operation can affect paths or not. Used as an
409
- * optimization when updating dirty paths during normalization.
410
- */
411
- operationCanTransformPath: (operation: Operation) => operation is InsertNodeOperation | RemoveNodeOperation;
412
- /**
413
- * Given a path, return a new path referring to the parent node above it.
414
- */
415
- parent: (path: Path$1) => Path$1;
416
- /**
417
- * Given a path, get the path to the previous sibling node.
418
- */
419
- previous: (path: Path$1) => Path$1;
420
- /**
421
- * Transform a path by an operation.
422
- */
423
- transform: (path: Path$1, operation: Operation) => Path$1 | null;
424
- }
425
- declare const Path$1: PathInterface;
426
- type RangeDirection = TextDirection | 'outward' | 'inward';
427
- type TextDirection = 'forward' | 'backward';
428
208
  /**
429
209
  * `PointRef` objects keep a specific point in a document synced over time as new
430
210
  * operations are applied to the editor. You can access their `current` property
@@ -436,59 +216,9 @@ interface PointRef {
436
216
  unref(): Point | null;
437
217
  }
438
218
  interface PointRefInterface {
439
- /**
440
- * Transform the point ref's current value by an operation.
441
- */
442
219
  transform: (ref: PointRef, op: Operation) => void;
443
220
  }
444
221
  declare const PointRef: PointRefInterface;
445
- /**
446
- * `Point` objects refer to a specific location in a text node in a Slate
447
- * document. Its path refers to the location of the node in the tree, and its
448
- * offset refers to the distance into the node's string of text. Points can
449
- * only refer to `Text` nodes.
450
- */
451
- interface BasePoint {
452
- path: Path$1;
453
- offset: number;
454
- }
455
- type Point = ExtendedType<'Point', BasePoint>;
456
- interface PointTransformOptions {
457
- affinity?: TextDirection | null;
458
- }
459
- interface PointInterface {
460
- /**
461
- * Compare a point to another, returning an integer indicating whether the
462
- * point was before, at, or after the other.
463
- */
464
- compare: (point: Point, another: Point) => -1 | 0 | 1;
465
- /**
466
- * Check if a point is after another.
467
- */
468
- isAfter: (point: Point, another: Point) => boolean;
469
- /**
470
- * Check if a point is before another.
471
- */
472
- isBefore: (point: Point, another: Point) => boolean;
473
- /**
474
- * Check if a point is exactly equal to another.
475
- */
476
- equals: (point: Point, another: Point) => boolean;
477
- /**
478
- * Check if a value implements the `Point` interface.
479
- */
480
- isPoint: (value: any) => value is Point;
481
- /**
482
- * Transform a point by an operation.
483
- */
484
- transform: (point: Point, op: Operation, options?: PointTransformOptions) => Point | null;
485
- }
486
- declare const Point: PointInterface;
487
- /**
488
- * `PointEntry` objects are returned when iterating over `Point` objects that
489
- * belong to a range.
490
- */
491
- type PointEntry = [Point, 'anchor' | 'focus'];
492
222
  /**
493
223
  * `RangeRef` objects keep a specific range in a document synced over time as new
494
224
  * operations are applied to the editor. You can access their `current` property
@@ -499,140 +229,50 @@ interface RangeRef {
499
229
  affinity: 'forward' | 'backward' | 'outward' | 'inward' | null;
500
230
  unref(): Range | null;
501
231
  }
502
- interface RangeRefInterface {
503
- /**
504
- * Transform the range ref's current value by an operation.
505
- */
506
- transform: (ref: RangeRef, op: Operation) => void;
507
- }
508
- declare const RangeRef: RangeRefInterface;
509
- /**
510
- * `Range` objects are a set of points that refer to a specific span of a Slate
511
- * document. They can define a span inside a single node or a can span across
512
- * multiple nodes.
513
- */
514
- interface BaseRange {
515
- anchor: Point;
516
- focus: Point;
517
- }
518
- type Range = ExtendedType<'Range', BaseRange>;
519
- interface RangeEdgesOptions {
520
- reverse?: boolean;
521
- }
522
- interface RangeTransformOptions {
523
- affinity?: RangeDirection | null;
524
- }
525
- interface RangeInterface {
526
- /**
527
- * Get the start and end points of a range, in the order in which they appear
528
- * in the document.
529
- */
530
- edges: (range: Range, options?: RangeEdgesOptions) => [Point, Point];
531
- /**
532
- * Get the end point of a range.
533
- */
534
- end: (range: Range) => Point;
535
- /**
536
- * Check if a range is exactly equal to another.
537
- */
538
- equals: (range: Range, another: Range) => boolean;
539
- /**
540
- * Check if a range includes a path, a point or part of another range.
541
- */
542
- includes: (range: Range, target: Path$1 | Point | Range) => boolean;
543
- /**
544
- * Get the intersection of a range with another.
545
- */
546
- intersection: (range: Range, another: Range) => Range | null;
547
- /**
548
- * Check if a range is backward, meaning that its anchor point appears in the
549
- * document _after_ its focus point.
550
- */
551
- isBackward: (range: Range) => boolean;
552
- /**
553
- * Check if a range is collapsed, meaning that both its anchor and focus
554
- * points refer to the exact same position in the document.
555
- */
556
- isCollapsed: (range: Range) => boolean;
557
- /**
558
- * Check if a range is expanded.
559
- *
560
- * This is the opposite of [[Range.isCollapsed]] and is provided for legibility.
561
- */
562
- isExpanded: (range: Range) => boolean;
563
- /**
564
- * Check if a range is forward.
565
- *
566
- * This is the opposite of [[Range.isBackward]] and is provided for legibility.
567
- */
568
- isForward: (range: Range) => boolean;
569
- /**
570
- * Check if a value implements the [[Range]] interface.
571
- */
572
- isRange: (value: any) => value is Range;
573
- /**
574
- * Iterate through all of the point entries in a range.
575
- */
576
- points: (range: Range) => Generator<PointEntry, void, undefined>;
577
- /**
578
- * Get the start point of a range.
579
- */
580
- start: (range: Range) => Point;
581
- /**
582
- * Transform a range by an operation.
583
- */
584
- transform: (range: Range, op: Operation, options?: RangeTransformOptions) => Range | null;
585
- }
586
- declare const Range: RangeInterface;
587
232
  /**
588
- * `Text` objects represent the nodes that contain the actual text content of a
589
- * Slate document along with any formatting properties. They are always leaf
590
- * nodes in the document tree as they cannot contain any children.
233
+ * The `Editor` interface stores all the state of a Slate editor. It is extended
234
+ * by plugins that wish to add their own helpers and implement new behaviors.
591
235
  */
592
- interface BaseText {
593
- text: string;
594
- }
595
- type Text$1 = ExtendedType<'Text', BaseText>;
596
- interface LeafPosition {
597
- start: number;
598
- end: number;
599
- isFirst?: true;
600
- isLast?: true;
601
- }
602
- interface TextEqualsOptions {
603
- loose?: boolean;
604
- }
605
- type DecoratedRange$1 = Range & {
606
- /**
607
- * Customize how another decoration is merged into a text node. If not specified, `Object.assign` would be used.
608
- * It is useful for overlapping decorations with the same key but different values.
609
- */
610
- merge?: (leaf: Text$1, decoration: object) => void;
611
- };
612
- interface TextInterface {
613
- /**
614
- * Check if two text nodes are equal.
615
- *
616
- * When loose is set, the text is not compared. This is
617
- * used to check whether sibling text nodes can be merged.
618
- */
619
- equals: (text: Text$1, another: Text$1, options?: TextEqualsOptions) => boolean;
620
- /**
621
- * Check if a value implements the `Text` interface.
622
- */
623
- isText: (value: any, schema: EditorSchema) => value is Text$1;
624
- /**
625
- * Get the leaves for a text node given decorations.
626
- */
627
- decorations: (node: Text$1, decorations: DecoratedRange$1[]) => {
628
- leaf: Text$1;
629
- position?: LeafPosition;
630
- }[];
236
+ interface BaseEditor {
237
+ children: PortableTextBlock[];
238
+ selection: Selection$1;
239
+ operations: Operation[];
240
+ marks: EditorMarks | null;
241
+ dirtyPaths: Path$1[];
242
+ dirtyPathKeys: Set<string>;
243
+ flushing: boolean;
244
+ normalizing: boolean;
245
+ batchingDirtyPaths: boolean;
246
+ pathRefs: Set<PathRef>;
247
+ pointRefs: Set<PointRef>;
248
+ rangeRefs: Set<RangeRef>;
249
+ apply: (operation: Operation) => void;
250
+ createSpan: () => PortableTextSpan;
251
+ getDirtyPaths: (operation: Operation) => Path$1[];
252
+ isElementReadOnly: (element: PortableTextTextBlock | PortableTextObject) => boolean;
253
+ isInline: (element: PortableTextTextBlock | PortableTextObject) => boolean;
254
+ normalizeNode: (entry: [Editor$1 | Node$1, Path$1], options?: {
255
+ operation?: Operation;
256
+ }) => void;
257
+ onChange: (options?: {
258
+ operation?: Operation;
259
+ }) => void;
260
+ shouldNormalize: ({
261
+ iteration,
262
+ dirtyPaths,
263
+ operation
264
+ }: {
265
+ iteration: number;
266
+ initialDirtyPathsLength: number;
267
+ dirtyPaths: Path$1[];
268
+ operation?: Operation;
269
+ }) => boolean;
270
+ select: (target: Location) => void;
271
+ setSelection: (props: Partial<Range>) => void;
631
272
  }
632
- declare const Text$1: TextInterface;
633
- type DecoratedRange = BaseRange & {
634
- rangeDecoration: RangeDecoration;
635
- };
273
+ type Editor$1 = BaseEditor & ReactEditor & PortableTextSlateEditor;
274
+ type Selection$1 = Range | null;
275
+ type EditorMarks = Omit<PortableTextSpan, 'text'>;
636
276
  type StringDiff = {
637
277
  start: number;
638
278
  end: number;
@@ -688,11 +328,10 @@ interface DOMEditor extends BaseEditor {
688
328
  domPlaceholder: string;
689
329
  domPlaceholderElement: HTMLElement | null;
690
330
  keyToElement: WeakMap<Key, HTMLElement>;
691
- nodeToIndex: WeakMap<Node$1, number>;
692
- nodeToParent: WeakMap<Node$1, Ancestor>;
693
- elementToNode: WeakMap<HTMLElement, Node$1>;
694
- nodeToElement: WeakMap<Node$1, HTMLElement>;
695
- nodeToKey: WeakMap<Node$1, Key>;
331
+ nodeToIndex: WeakMap<Editor$1 | Node$1, number>;
332
+ nodeToParent: WeakMap<Editor$1 | Node$1, Editor$1 | Node$1>;
333
+ elementToNode: WeakMap<HTMLElement, Editor$1 | Node$1>;
334
+ nodeToKey: WeakMap<Editor$1 | Node$1, Key>;
696
335
  readOnly: boolean;
697
336
  focused: boolean;
698
337
  composing: boolean;
@@ -701,8 +340,8 @@ interface DOMEditor extends BaseEditor {
701
340
  operation?: Operation;
702
341
  }) => void) | null;
703
342
  scheduleFlush: (() => void) | null;
704
- pendingInsertionMarks: Partial<Text$1> | null;
705
- userMarks: Partial<Text$1> | null;
343
+ pendingInsertionMarks: EditorMarks | null;
344
+ userMarks: EditorMarks | null;
706
345
  pendingDiffs: TextDiff[];
707
346
  pendingAction: Action | null;
708
347
  pendingSelection: Range | null;
@@ -724,11 +363,11 @@ interface DOMEditorInterface {
724
363
  /**
725
364
  * Find a key for a Slate node.
726
365
  */
727
- findKey: (editor: Editor$1, node: Node$1) => Key;
366
+ findKey: (editor: Editor$1, node: Editor$1 | Node$1) => Key;
728
367
  /**
729
368
  * Find the path of Slate node.
730
369
  */
731
- findPath: (editor: Editor$1, node: Node$1) => Path$1;
370
+ findPath: (editor: Editor$1, node: Editor$1 | Node$1) => Path$1;
732
371
  /**
733
372
  * Focus the editor.
734
373
  */
@@ -776,7 +415,7 @@ interface DOMEditorInterface {
776
415
  /**
777
416
  * Find the native DOM element from a Slate node.
778
417
  */
779
- toDOMNode: (editor: Editor$1, node: Node$1) => HTMLElement;
418
+ toDOMNode: (editor: Editor$1, node: Editor$1 | Node$1) => HTMLElement;
780
419
  /**
781
420
  * Find a native DOM selection point from a Slate point.
782
421
  */
@@ -793,7 +432,7 @@ interface DOMEditorInterface {
793
432
  /**
794
433
  * Find a Slate node from a native DOM `element`.
795
434
  */
796
- toSlateNode: (editor: Editor$1, domNode: DOMNode) => Node$1;
435
+ toSlateNode: (editor: Editor$1, domNode: DOMNode) => Editor$1 | Node$1;
797
436
  /**
798
437
  * Find a Slate point from a DOM selection's `domNode` and `domOffset`.
799
438
  */
@@ -821,24 +460,6 @@ declare const DOMEditor: DOMEditorInterface;
821
460
  interface ReactEditor extends DOMEditor {}
822
461
  interface ReactEditorInterface extends DOMEditorInterface {}
823
462
  declare const ReactEditor: ReactEditorInterface;
824
- interface ObjectElement {
825
- _type: string;
826
- _key: string;
827
- children: Descendant[];
828
- [key: string]: unknown;
829
- }
830
- interface SlateTextBlock extends Omit<PortableTextTextBlock, 'children'> {
831
- children: Descendant[];
832
- }
833
- declare module '../slate/index' {
834
- interface CustomTypes {
835
- Editor: BaseEditor & ReactEditor & PortableTextSlateEditor;
836
- Element: SlateTextBlock | ObjectElement;
837
- ObjectNode: ObjectElement;
838
- Text: PortableTextSpan;
839
- }
840
- }
841
- //# sourceMappingURL=slate.d.ts.map
842
463
  type HistoryItem = {
843
464
  operations: Operation[];
844
465
  timestamp: Date;
@@ -856,10 +477,6 @@ type RemotePatch = {
856
477
  interface PortableTextSlateEditor extends ReactEditor {
857
478
  _key: 'editor';
858
479
  _type: 'editor';
859
- isTextBlock: (value: unknown) => value is PortableTextTextBlock;
860
- isTextSpan: (value: unknown) => value is PortableTextSpan;
861
- isListBlock: (value: unknown) => value is PortableTextListBlock;
862
- isObjectNode: (value: unknown) => boolean;
863
480
  schema: EditorSchema;
864
481
  decoratedRanges: Array<DecoratedRange>;
865
482
  decoratorState: Record<string, boolean | undefined>;
@@ -936,15 +553,11 @@ type PatchEvent = {
936
553
  type: 'patch';
937
554
  patch: Patch;
938
555
  };
939
- type SlateEditor = {
940
- instance: PortableTextSlateEditor;
941
- initialValue: Array<Descendant>;
942
- };
943
556
  type InternalEditor = Editor & {
944
557
  _internal: {
945
558
  editable: EditableAPI;
946
559
  editorActor: EditorActor;
947
- slateEditor: SlateEditor;
560
+ slateEditor: PortableTextSlateEditor;
948
561
  };
949
562
  };
950
563
  /**
@@ -1386,7 +999,7 @@ type PortableTextEditableProps = Omit<TextareaHTMLAttributes<HTMLDivElement>, 'o
1386
999
  * ```
1387
1000
  * @group Components
1388
1001
  */
1389
- declare const PortableTextEditable: react8.ForwardRefExoticComponent<Omit<PortableTextEditableProps, "ref"> & react8.RefAttributes<Omit<HTMLDivElement, "as" | "onPaste" | "onBeforeInput">>>;
1002
+ declare const PortableTextEditable: react4.ForwardRefExoticComponent<Omit<PortableTextEditableProps, "ref"> & react4.RefAttributes<Omit<HTMLDivElement, "as" | "onPaste" | "onBeforeInput">>>;
1390
1003
  /** @beta */
1391
1004
  interface EditableAPIDeleteOptions {
1392
1005
  mode?: 'blocks' | 'children' | 'selected';
@@ -2022,7 +1635,7 @@ declare const editorMachine: xstate73.StateMachine<{
2022
1635
  initialValue?: Array<PortableTextBlock>;
2023
1636
  }, xstate73.NonReducibleUnknown, InternalPatchEvent | MutationEvent | PatchesEvent | {
2024
1637
  type: "blurred";
2025
- event: react8.FocusEvent<HTMLDivElement, Element>;
1638
+ event: react4.FocusEvent<HTMLDivElement, Element>;
2026
1639
  } | {
2027
1640
  type: "done loading";
2028
1641
  } | {
@@ -2034,7 +1647,7 @@ declare const editorMachine: xstate73.StateMachine<{
2034
1647
  data: unknown;
2035
1648
  } | {
2036
1649
  type: "focused";
2037
- event: react8.FocusEvent<HTMLDivElement, Element>;
1650
+ event: react4.FocusEvent<HTMLDivElement, Element>;
2038
1651
  } | {
2039
1652
  type: "invalid value";
2040
1653
  resolution: InvalidValueResolution | null;