@portabletext/editor 6.1.1 → 6.2.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.
|
@@ -3,7 +3,7 @@ import { AnnotationDefinition, AnnotationSchemaType, AnnotationSchemaType as Ann
|
|
|
3
3
|
import * as xstate73 from "xstate";
|
|
4
4
|
import { ActorRef, ActorRefFrom, EventObject, Snapshot } from "xstate";
|
|
5
5
|
import * as react8 from "react";
|
|
6
|
-
import React$1, { BaseSyntheticEvent, ClipboardEvent as ClipboardEvent$1, FocusEvent, JSX,
|
|
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
|
/**
|
|
@@ -183,22 +183,18 @@ interface BaseEditor {
|
|
|
183
183
|
insertBreak: OmitFirstArg<typeof Editor$1.insertBreak>;
|
|
184
184
|
insertNodes: OmitFirstArg<typeof Transforms.insertNodes>;
|
|
185
185
|
insertText: OmitFirstArg<typeof Transforms.insertText>;
|
|
186
|
-
mergeNodes: OmitFirstArg<typeof Transforms.mergeNodes>;
|
|
187
186
|
move: OmitFirstArg<typeof Transforms.move>;
|
|
188
|
-
moveNodes: OmitFirstArg<typeof Transforms.moveNodes>;
|
|
189
187
|
normalize: OmitFirstArg<typeof Editor$1.normalize>;
|
|
190
188
|
removeNodes: OmitFirstArg<typeof Transforms.removeNodes>;
|
|
191
189
|
select: OmitFirstArg<typeof Transforms.select>;
|
|
192
190
|
setNormalizing: OmitFirstArg<typeof Editor$1.setNormalizing>;
|
|
193
191
|
setSelection: OmitFirstArg<typeof Transforms.setSelection>;
|
|
194
|
-
splitNodes: OmitFirstArg<typeof Transforms.splitNodes>;
|
|
195
192
|
withoutNormalizing: OmitFirstArg<typeof Editor$1.withoutNormalizing>;
|
|
196
193
|
above: <T extends Ancestor>(options?: EditorAboveOptions<T>) => NodeEntry<T> | undefined;
|
|
197
194
|
after: OmitFirstArg<typeof Editor$1.after>;
|
|
198
195
|
before: OmitFirstArg<typeof Editor$1.before>;
|
|
199
196
|
elementReadOnly: OmitFirstArg<typeof Editor$1.elementReadOnly>;
|
|
200
197
|
end: OmitFirstArg<typeof Editor$1.end>;
|
|
201
|
-
getMarks: OmitFirstArg<typeof Editor$1.marks>;
|
|
202
198
|
hasInlines: OmitFirstArg<typeof Editor$1.hasInlines>;
|
|
203
199
|
hasPath: OmitFirstArg<typeof Editor$1.hasPath>;
|
|
204
200
|
isBlock: OmitFirstArg<typeof Editor$1.isBlock>;
|
|
@@ -412,10 +408,6 @@ interface EditorInterface {
|
|
|
412
408
|
* Iterate through all of the levels at a location.
|
|
413
409
|
*/
|
|
414
410
|
levels: <T extends Node$1>(editor: Editor$1, options?: EditorLevelsOptions<T>) => Generator<NodeEntry<T>, void, undefined>;
|
|
415
|
-
/**
|
|
416
|
-
* Get the marks that would be added to text at the current selection.
|
|
417
|
-
*/
|
|
418
|
-
marks: (editor: Editor$1) => Omit<Text$1, 'text'> | null;
|
|
419
411
|
/**
|
|
420
412
|
* Get the matching node in the branch of the document after a location.
|
|
421
413
|
*/
|
|
@@ -554,28 +546,8 @@ interface ElementInterface {
|
|
|
554
546
|
* Check if a value implements the `Element` interface.
|
|
555
547
|
*/
|
|
556
548
|
isElement: (value: any, schema: EditorSchema) => value is Element$1;
|
|
557
|
-
/**
|
|
558
|
-
* Check if a value is an array of `Element` objects.
|
|
559
|
-
*/
|
|
560
|
-
isElementList: (value: any, schema: EditorSchema) => value is Element$1[];
|
|
561
|
-
/**
|
|
562
|
-
* Check if a set of props is a partial of Element.
|
|
563
|
-
*/
|
|
564
|
-
isElementProps: (props: any) => props is Partial<Element$1>;
|
|
565
|
-
/**
|
|
566
|
-
* Check if an element matches set of properties.
|
|
567
|
-
*
|
|
568
|
-
* Note: this checks custom properties, and it does not ensure that any
|
|
569
|
-
* children are equivalent.
|
|
570
|
-
*/
|
|
571
|
-
matches: (element: Element$1, props: Partial<Element$1>) => boolean;
|
|
572
549
|
}
|
|
573
550
|
declare const Element$1: ElementInterface;
|
|
574
|
-
/**
|
|
575
|
-
* `ElementEntry` objects refer to an `Element` and the `Path` where it can be
|
|
576
|
-
* found inside a root node.
|
|
577
|
-
*/
|
|
578
|
-
type ElementEntry = [Element$1, Path$1];
|
|
579
551
|
/**
|
|
580
552
|
* The `Location` interface is a union of the ways to refer to a specific
|
|
581
553
|
* location in a Slate document: paths, points or ranges.
|
|
@@ -585,13 +557,6 @@ type ElementEntry = [Element$1, Path$1];
|
|
|
585
557
|
* converting between the different interfaces in their own code base.
|
|
586
558
|
*/
|
|
587
559
|
type Location = Path$1 | Point | Range;
|
|
588
|
-
interface LocationInterface {
|
|
589
|
-
/**
|
|
590
|
-
* Check if a value implements the `Location` interface.
|
|
591
|
-
*/
|
|
592
|
-
isLocation: (value: any) => value is Location;
|
|
593
|
-
}
|
|
594
|
-
declare const Location: LocationInterface;
|
|
595
560
|
/**
|
|
596
561
|
* The `Span` interface is a low-level way to refer to locations in nodes
|
|
597
562
|
* without using `Point` which requires leaf text nodes to be present.
|
|
@@ -623,24 +588,9 @@ interface BaseObjectNode {
|
|
|
623
588
|
}
|
|
624
589
|
type ObjectNode = ExtendedType<'ObjectNode', BaseObjectNode>;
|
|
625
590
|
type Node$1 = Editor$1 | Element$1 | ObjectNode | Text$1;
|
|
626
|
-
interface NodeAncestorsOptions {
|
|
627
|
-
reverse?: boolean;
|
|
628
|
-
}
|
|
629
591
|
interface NodeChildrenOptions {
|
|
630
592
|
reverse?: boolean;
|
|
631
593
|
}
|
|
632
|
-
interface NodeDescendantsOptions {
|
|
633
|
-
from?: Path$1;
|
|
634
|
-
to?: Path$1;
|
|
635
|
-
reverse?: boolean;
|
|
636
|
-
pass?: (node: NodeEntry) => boolean;
|
|
637
|
-
}
|
|
638
|
-
interface NodeElementsOptions {
|
|
639
|
-
from?: Path$1;
|
|
640
|
-
to?: Path$1;
|
|
641
|
-
reverse?: boolean;
|
|
642
|
-
pass?: (node: NodeEntry) => boolean;
|
|
643
|
-
}
|
|
644
594
|
interface NodeLevelsOptions {
|
|
645
595
|
reverse?: boolean;
|
|
646
596
|
}
|
|
@@ -661,13 +611,6 @@ interface NodeInterface {
|
|
|
661
611
|
* Get the node at a specific path, asserting that it's an ancestor node.
|
|
662
612
|
*/
|
|
663
613
|
ancestor: (root: Node$1, path: Path$1, schema: EditorSchema) => Ancestor;
|
|
664
|
-
/**
|
|
665
|
-
* Return a generator of all the ancestor nodes above a specific path.
|
|
666
|
-
*
|
|
667
|
-
* By default the order is top-down, from highest to lowest ancestor in
|
|
668
|
-
* the tree, but you can pass the `reverse: true` option to go bottom-up.
|
|
669
|
-
*/
|
|
670
|
-
ancestors: (root: Node$1, path: Path$1, schema: EditorSchema, options?: NodeAncestorsOptions) => Generator<NodeEntry<Ancestor>, void, undefined>;
|
|
671
614
|
/**
|
|
672
615
|
* Get the child of a node at a specific index.
|
|
673
616
|
*/
|
|
@@ -676,24 +619,6 @@ interface NodeInterface {
|
|
|
676
619
|
* Iterate over the children of a node at a specific path.
|
|
677
620
|
*/
|
|
678
621
|
children: (root: Node$1, path: Path$1, schema: EditorSchema, options?: NodeChildrenOptions) => Generator<NodeEntry<Descendant>, void, undefined>;
|
|
679
|
-
/**
|
|
680
|
-
* Get an entry for the common ancesetor node of two paths.
|
|
681
|
-
*/
|
|
682
|
-
common: (root: Node$1, path: Path$1, another: Path$1, schema: EditorSchema) => NodeEntry;
|
|
683
|
-
/**
|
|
684
|
-
* Get the node at a specific path, asserting that it's a descendant node.
|
|
685
|
-
*/
|
|
686
|
-
descendant: (root: Node$1, path: Path$1, schema: EditorSchema) => Descendant;
|
|
687
|
-
/**
|
|
688
|
-
* Return a generator of all the descendant node entries inside a root node.
|
|
689
|
-
*/
|
|
690
|
-
descendants: (root: Node$1, schema: EditorSchema, options?: NodeDescendantsOptions) => Generator<NodeEntry<Descendant>, void, undefined>;
|
|
691
|
-
/**
|
|
692
|
-
* Return a generator of all the element nodes inside a root node. Each iteration
|
|
693
|
-
* will return an `ElementEntry` tuple consisting of `[Element, Path]`. If the
|
|
694
|
-
* root node is an element it will be included in the iteration as well.
|
|
695
|
-
*/
|
|
696
|
-
elements: (root: Node$1, schema: EditorSchema, options?: NodeElementsOptions) => Generator<ElementEntry, void, undefined>;
|
|
697
622
|
/**
|
|
698
623
|
* Extract props from a Node.
|
|
699
624
|
*/
|
|
@@ -753,10 +678,6 @@ interface NodeInterface {
|
|
|
753
678
|
* but you can pass the `reverse: true` option to go bottom-up.
|
|
754
679
|
*/
|
|
755
680
|
levels: (root: Node$1, path: Path$1, schema: EditorSchema, options?: NodeLevelsOptions) => Generator<NodeEntry, void, undefined>;
|
|
756
|
-
/**
|
|
757
|
-
* Check if a node matches a set of props.
|
|
758
|
-
*/
|
|
759
|
-
matches: (node: Node$1, props: Partial<Node$1>, schema: EditorSchema) => boolean;
|
|
760
681
|
/**
|
|
761
682
|
* Return a generator of all the node entries of a root node. Each entry is
|
|
762
683
|
* returned as a `[Node, Path]` tuple, with the path referring to the node's
|
|
@@ -882,10 +803,6 @@ type TextOperation = InsertTextOperation | RemoveTextOperation;
|
|
|
882
803
|
type BaseOperation = NodeOperation | SelectionOperation | TextOperation;
|
|
883
804
|
type Operation = ExtendedType<'Operation', BaseOperation>;
|
|
884
805
|
interface OperationInterface {
|
|
885
|
-
/**
|
|
886
|
-
* Check if a value is a `NodeOperation` object.
|
|
887
|
-
*/
|
|
888
|
-
isNodeOperation: (value: any) => value is NodeOperation;
|
|
889
806
|
/**
|
|
890
807
|
* Check if a value is an `Operation` object.
|
|
891
808
|
*/
|
|
@@ -894,14 +811,6 @@ interface OperationInterface {
|
|
|
894
811
|
* Check if a value is a list of `Operation` objects.
|
|
895
812
|
*/
|
|
896
813
|
isOperationList: (value: any) => value is Operation[];
|
|
897
|
-
/**
|
|
898
|
-
* Check if a value is a `SelectionOperation` object.
|
|
899
|
-
*/
|
|
900
|
-
isSelectionOperation: (value: any) => value is SelectionOperation;
|
|
901
|
-
/**
|
|
902
|
-
* Check if a value is a `TextOperation` object.
|
|
903
|
-
*/
|
|
904
|
-
isTextOperation: (value: any) => value is TextOperation;
|
|
905
814
|
/**
|
|
906
815
|
* Invert an operation, returning a new operation that will exactly undo the
|
|
907
816
|
* original when applied.
|
|
@@ -962,14 +871,6 @@ interface PathInterface {
|
|
|
962
871
|
* [[Path.equals]] instead.
|
|
963
872
|
*/
|
|
964
873
|
compare: (path: Path$1, another: Path$1) => -1 | 0 | 1;
|
|
965
|
-
/**
|
|
966
|
-
* Check if a path ends after one of the indexes in another.
|
|
967
|
-
*/
|
|
968
|
-
endsAfter: (path: Path$1, another: Path$1) => boolean;
|
|
969
|
-
/**
|
|
970
|
-
* Check if a path ends at one of the indexes in another.
|
|
971
|
-
*/
|
|
972
|
-
endsAt: (path: Path$1, another: Path$1) => boolean;
|
|
973
874
|
/**
|
|
974
875
|
* Check if a path ends before one of the indexes in another.
|
|
975
876
|
*/
|
|
@@ -994,10 +895,6 @@ interface PathInterface {
|
|
|
994
895
|
* Check if a path is before another.
|
|
995
896
|
*/
|
|
996
897
|
isBefore: (path: Path$1, another: Path$1) => boolean;
|
|
997
|
-
/**
|
|
998
|
-
* Check if a path is a child of another.
|
|
999
|
-
*/
|
|
1000
|
-
isChild: (path: Path$1, another: Path$1) => boolean;
|
|
1001
898
|
/**
|
|
1002
899
|
* Check if a path is equal to or an ancestor of another.
|
|
1003
900
|
*/
|
|
@@ -1006,10 +903,6 @@ interface PathInterface {
|
|
|
1006
903
|
* Check if a path is a descendant of another.
|
|
1007
904
|
*/
|
|
1008
905
|
isDescendant: (path: Path$1, another: Path$1) => boolean;
|
|
1009
|
-
/**
|
|
1010
|
-
* Check if a path is the parent of another.
|
|
1011
|
-
*/
|
|
1012
|
-
isParent: (path: Path$1, another: Path$1) => boolean;
|
|
1013
906
|
/**
|
|
1014
907
|
* Check is a value implements the `Path` interface.
|
|
1015
908
|
*/
|
|
@@ -1046,10 +939,6 @@ interface PathInterface {
|
|
|
1046
939
|
* Given a path, get the path to the previous sibling node.
|
|
1047
940
|
*/
|
|
1048
941
|
previous: (path: Path$1) => Path$1;
|
|
1049
|
-
/**
|
|
1050
|
-
* Get a path relative to an ancestor.
|
|
1051
|
-
*/
|
|
1052
|
-
relative: (path: Path$1, ancestor: Path$1) => Path$1;
|
|
1053
942
|
/**
|
|
1054
943
|
* Transform a path by an operation.
|
|
1055
944
|
*/
|
|
@@ -1171,10 +1060,6 @@ interface RangeInterface {
|
|
|
1171
1060
|
* Check if a range includes a path, a point or part of another range.
|
|
1172
1061
|
*/
|
|
1173
1062
|
includes: (range: Range, target: Path$1 | Point | Range) => boolean;
|
|
1174
|
-
/**
|
|
1175
|
-
* Check if a range includes another range.
|
|
1176
|
-
*/
|
|
1177
|
-
surrounds: (range: Range, target: Range) => boolean;
|
|
1178
1063
|
/**
|
|
1179
1064
|
* Get the intersection of a range with another.
|
|
1180
1065
|
*/
|
|
@@ -1256,21 +1141,6 @@ interface TextInterface {
|
|
|
1256
1141
|
* Check if a value implements the `Text` interface.
|
|
1257
1142
|
*/
|
|
1258
1143
|
isText: (value: any, schema: EditorSchema) => value is Text$1;
|
|
1259
|
-
/**
|
|
1260
|
-
* Check if a value is a list of `Text` objects.
|
|
1261
|
-
*/
|
|
1262
|
-
isTextList: (value: any, schema: EditorSchema) => value is Text$1[];
|
|
1263
|
-
/**
|
|
1264
|
-
* Check if some props are a partial of Text.
|
|
1265
|
-
*/
|
|
1266
|
-
isTextProps: (props: any) => props is Partial<Text$1>;
|
|
1267
|
-
/**
|
|
1268
|
-
* Check if an text matches set of properties.
|
|
1269
|
-
*
|
|
1270
|
-
* Note: this is for matching custom properties, and it does not ensure that
|
|
1271
|
-
* the `text` property are two nodes equal.
|
|
1272
|
-
*/
|
|
1273
|
-
matches: (text: Text$1, props: Partial<Text$1>) => boolean;
|
|
1274
1144
|
/**
|
|
1275
1145
|
* Get the leaves for a text node given decorations.
|
|
1276
1146
|
*/
|
|
@@ -1302,27 +1172,6 @@ interface NodeTransforms {
|
|
|
1302
1172
|
* at the specified location or (if not defined) the current selection or (if not defined) the end of the document.
|
|
1303
1173
|
*/
|
|
1304
1174
|
insertNodes: <T extends Node$1>(editor: Editor$1, nodes: Node$1 | Node$1[], options?: NodeInsertNodesOptions<T>) => void;
|
|
1305
|
-
/**
|
|
1306
|
-
* Merge a node at a location with the previous node of the same depth,
|
|
1307
|
-
* removing any empty containing nodes after the merge if necessary.
|
|
1308
|
-
*/
|
|
1309
|
-
mergeNodes: <T extends Node$1>(editor: Editor$1, options?: {
|
|
1310
|
-
at?: Location;
|
|
1311
|
-
match?: NodeMatch<T>;
|
|
1312
|
-
mode?: RangeMode;
|
|
1313
|
-
hanging?: boolean;
|
|
1314
|
-
voids?: boolean;
|
|
1315
|
-
}) => void;
|
|
1316
|
-
/**
|
|
1317
|
-
* Move the nodes at a location to a new location.
|
|
1318
|
-
*/
|
|
1319
|
-
moveNodes: <T extends Node$1>(editor: Editor$1, options: {
|
|
1320
|
-
at?: Location;
|
|
1321
|
-
match?: NodeMatch<T>;
|
|
1322
|
-
mode?: MaximizeMode;
|
|
1323
|
-
to: Path$1;
|
|
1324
|
-
voids?: boolean;
|
|
1325
|
-
}) => void;
|
|
1326
1175
|
/**
|
|
1327
1176
|
* Remove the nodes at a specific location in the document.
|
|
1328
1177
|
*/
|
|
@@ -1333,17 +1182,6 @@ interface NodeTransforms {
|
|
|
1333
1182
|
hanging?: boolean;
|
|
1334
1183
|
voids?: boolean;
|
|
1335
1184
|
}) => void;
|
|
1336
|
-
/**
|
|
1337
|
-
* Split the nodes at a specific location.
|
|
1338
|
-
*/
|
|
1339
|
-
splitNodes: <T extends Node$1>(editor: Editor$1, options?: {
|
|
1340
|
-
at?: Location;
|
|
1341
|
-
match?: NodeMatch<T>;
|
|
1342
|
-
mode?: RangeMode;
|
|
1343
|
-
always?: boolean;
|
|
1344
|
-
height?: number;
|
|
1345
|
-
voids?: boolean;
|
|
1346
|
-
}) => void;
|
|
1347
1185
|
}
|
|
1348
1186
|
declare const NodeTransforms: NodeTransforms;
|
|
1349
1187
|
interface SelectionCollapseOptions {
|
|
@@ -1445,7 +1283,6 @@ interface DOMEditor extends BaseEditor {
|
|
|
1445
1283
|
elementToNode: WeakMap<HTMLElement, Node$1>;
|
|
1446
1284
|
nodeToElement: WeakMap<Node$1, HTMLElement>;
|
|
1447
1285
|
nodeToKey: WeakMap<Node$1, Key>;
|
|
1448
|
-
changeVersion: MutableRefObject<number>;
|
|
1449
1286
|
readOnly: boolean;
|
|
1450
1287
|
focused: boolean;
|
|
1451
1288
|
composing: boolean;
|
|
@@ -1462,22 +1299,10 @@ interface DOMEditor extends BaseEditor {
|
|
|
1462
1299
|
forceRender: (() => void) | null;
|
|
1463
1300
|
}
|
|
1464
1301
|
interface DOMEditorInterface {
|
|
1465
|
-
/**
|
|
1466
|
-
* Experimental and android specific: Get pending diffs
|
|
1467
|
-
*/
|
|
1468
|
-
androidPendingDiffs: (editor: Editor$1) => TextDiff[] | undefined;
|
|
1469
|
-
/**
|
|
1470
|
-
* Experimental and android specific: Flush all pending diffs and cancel composition at the next possible time.
|
|
1471
|
-
*/
|
|
1472
|
-
androidScheduleFlush: (editor: Editor$1) => void;
|
|
1473
1302
|
/**
|
|
1474
1303
|
* Blur the editor.
|
|
1475
1304
|
*/
|
|
1476
1305
|
blur: (editor: Editor$1) => void;
|
|
1477
|
-
/**
|
|
1478
|
-
* Deselect the editor.
|
|
1479
|
-
*/
|
|
1480
|
-
deselect: (editor: Editor$1) => void;
|
|
1481
1306
|
/**
|
|
1482
1307
|
* Find the DOM node that implements DocumentOrShadowRoot for the editor.
|
|
1483
1308
|
*/
|
|
@@ -1534,10 +1359,6 @@ interface DOMEditorInterface {
|
|
|
1534
1359
|
* Check if the editor is focused.
|
|
1535
1360
|
*/
|
|
1536
1361
|
isFocused: (editor: Editor$1) => boolean;
|
|
1537
|
-
/**
|
|
1538
|
-
* Check if the editor is in read-only mode.
|
|
1539
|
-
*/
|
|
1540
|
-
isReadOnly: (editor: Editor$1) => boolean;
|
|
1541
1362
|
/**
|
|
1542
1363
|
* Check if the target is inside void and in an non-readonly editor.
|
|
1543
1364
|
*/
|
|
@@ -1591,20 +1412,6 @@ declare const DOMEditor: DOMEditorInterface;
|
|
|
1591
1412
|
interface ChunkTree {
|
|
1592
1413
|
type: 'root';
|
|
1593
1414
|
children: ChunkDescendant[];
|
|
1594
|
-
/**
|
|
1595
|
-
* The keys of any Slate nodes that have been moved using move_node since the
|
|
1596
|
-
* last render
|
|
1597
|
-
*
|
|
1598
|
-
* Detecting when a node has been moved to a different position in the
|
|
1599
|
-
* children array is impossible to do efficiently while reconciling the chunk
|
|
1600
|
-
* tree. This interferes with the reconciliation logic since it is treated as
|
|
1601
|
-
* if the intermediate nodes were inserted and removed, causing them to be
|
|
1602
|
-
* re-chunked unnecessarily.
|
|
1603
|
-
*
|
|
1604
|
-
* This set is used to detect when a node has been moved so that this case
|
|
1605
|
-
* can be handled correctly and efficiently.
|
|
1606
|
-
*/
|
|
1607
|
-
movedNodeKeys: Set<Key>;
|
|
1608
1415
|
/**
|
|
1609
1416
|
* The chunks whose descendants have been modified during the most recent
|
|
1610
1417
|
* reconciliation
|