@portabletext/editor 6.0.1-canary.2 → 6.0.1-canary.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/_chunks-dts/behavior.types.action.d.ts +360 -220
- package/lib/_chunks-dts/behavior.types.action.d.ts.map +1 -1
- package/lib/behaviors/index.js.map +1 -1
- package/lib/index.js +1429 -1271
- package/lib/index.js.map +1 -1
- package/package.json +2 -2
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
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
|
-
import * as
|
|
3
|
+
import * as xstate77 from "xstate";
|
|
4
4
|
import { ActorRef, ActorRefFrom, EventObject, Snapshot } from "xstate";
|
|
5
5
|
import * as react13 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
|
/**
|
|
@@ -117,6 +117,121 @@ type TextDirection = 'forward' | 'backward';
|
|
|
117
117
|
type TextUnit = 'character' | 'word' | 'line' | 'block';
|
|
118
118
|
type TextUnitAdjustment = TextUnit | 'offset';
|
|
119
119
|
type OmitFirstArg<F> = F extends ((x: any, ...args: infer P) => infer R) ? (...args: P) => R : never;
|
|
120
|
+
interface NodeInsertNodesOptions<T extends Node$1> {
|
|
121
|
+
at?: Location;
|
|
122
|
+
match?: NodeMatch<T>;
|
|
123
|
+
mode?: RangeMode;
|
|
124
|
+
hanging?: boolean;
|
|
125
|
+
select?: boolean;
|
|
126
|
+
voids?: boolean;
|
|
127
|
+
batchDirty?: boolean;
|
|
128
|
+
}
|
|
129
|
+
interface NodeTransforms {
|
|
130
|
+
/**
|
|
131
|
+
* Insert nodes in the editor
|
|
132
|
+
* at the specified location or (if not defined) the current selection or (if not defined) the end of the document.
|
|
133
|
+
*/
|
|
134
|
+
insertNodes: <T extends Node$1>(editor: Editor$1, nodes: Node$1 | Node$1[], options?: NodeInsertNodesOptions<T>) => void;
|
|
135
|
+
/**
|
|
136
|
+
* Lift nodes at a specific location upwards in the document tree, splitting
|
|
137
|
+
* their parent in two if necessary.
|
|
138
|
+
*/
|
|
139
|
+
liftNodes: <T extends Node$1>(editor: Editor$1, options?: {
|
|
140
|
+
at?: Location;
|
|
141
|
+
match?: NodeMatch<T>;
|
|
142
|
+
mode?: MaximizeMode;
|
|
143
|
+
voids?: boolean;
|
|
144
|
+
}) => void;
|
|
145
|
+
/**
|
|
146
|
+
* Merge a node at a location with the previous node of the same depth,
|
|
147
|
+
* removing any empty containing nodes after the merge if necessary.
|
|
148
|
+
*/
|
|
149
|
+
mergeNodes: <T extends Node$1>(editor: Editor$1, options?: {
|
|
150
|
+
at?: Location;
|
|
151
|
+
match?: NodeMatch<T>;
|
|
152
|
+
mode?: RangeMode;
|
|
153
|
+
hanging?: boolean;
|
|
154
|
+
voids?: boolean;
|
|
155
|
+
}) => void;
|
|
156
|
+
/**
|
|
157
|
+
* Move the nodes at a location to a new location.
|
|
158
|
+
*/
|
|
159
|
+
moveNodes: <T extends Node$1>(editor: Editor$1, options: {
|
|
160
|
+
at?: Location;
|
|
161
|
+
match?: NodeMatch<T>;
|
|
162
|
+
mode?: MaximizeMode;
|
|
163
|
+
to: Path$1;
|
|
164
|
+
voids?: boolean;
|
|
165
|
+
}) => void;
|
|
166
|
+
/**
|
|
167
|
+
* Remove the nodes at a specific location in the document.
|
|
168
|
+
*/
|
|
169
|
+
removeNodes: <T extends Node$1>(editor: Editor$1, options?: {
|
|
170
|
+
at?: Location;
|
|
171
|
+
match?: NodeMatch<T>;
|
|
172
|
+
mode?: RangeMode;
|
|
173
|
+
hanging?: boolean;
|
|
174
|
+
voids?: boolean;
|
|
175
|
+
}) => void;
|
|
176
|
+
/**
|
|
177
|
+
* Set new properties on the nodes at a location.
|
|
178
|
+
*/
|
|
179
|
+
setNodes: <T extends Node$1>(editor: Editor$1, props: Partial<T>, options?: {
|
|
180
|
+
at?: Location;
|
|
181
|
+
match?: NodeMatch<T>;
|
|
182
|
+
mode?: MaximizeMode;
|
|
183
|
+
hanging?: boolean;
|
|
184
|
+
split?: boolean;
|
|
185
|
+
voids?: boolean;
|
|
186
|
+
compare?: PropsCompare;
|
|
187
|
+
merge?: PropsMerge;
|
|
188
|
+
}) => void;
|
|
189
|
+
/**
|
|
190
|
+
* Split the nodes at a specific location.
|
|
191
|
+
*/
|
|
192
|
+
splitNodes: <T extends Node$1>(editor: Editor$1, options?: {
|
|
193
|
+
at?: Location;
|
|
194
|
+
match?: NodeMatch<T>;
|
|
195
|
+
mode?: RangeMode;
|
|
196
|
+
always?: boolean;
|
|
197
|
+
height?: number;
|
|
198
|
+
voids?: boolean;
|
|
199
|
+
}) => void;
|
|
200
|
+
/**
|
|
201
|
+
* Unset properties on the nodes at a location.
|
|
202
|
+
*/
|
|
203
|
+
unsetNodes: <T extends Node$1>(editor: Editor$1, props: string | string[], options?: {
|
|
204
|
+
at?: Location;
|
|
205
|
+
match?: NodeMatch<T>;
|
|
206
|
+
mode?: MaximizeMode;
|
|
207
|
+
hanging?: boolean;
|
|
208
|
+
split?: boolean;
|
|
209
|
+
voids?: boolean;
|
|
210
|
+
}) => void;
|
|
211
|
+
/**
|
|
212
|
+
* Unwrap the nodes at a location from a parent node, splitting the parent if
|
|
213
|
+
* necessary to ensure that only the content in the range is unwrapped.
|
|
214
|
+
*/
|
|
215
|
+
unwrapNodes: <T extends Node$1>(editor: Editor$1, options?: {
|
|
216
|
+
at?: Location;
|
|
217
|
+
match?: NodeMatch<T>;
|
|
218
|
+
mode?: MaximizeMode;
|
|
219
|
+
split?: boolean;
|
|
220
|
+
voids?: boolean;
|
|
221
|
+
}) => void;
|
|
222
|
+
/**
|
|
223
|
+
* Wrap the nodes at a location in a new container node, splitting the edges
|
|
224
|
+
* of the range first to ensure that only the content in the range is wrapped.
|
|
225
|
+
*/
|
|
226
|
+
wrapNodes: <T extends Node$1>(editor: Editor$1, element: Element$1, options?: {
|
|
227
|
+
at?: Location;
|
|
228
|
+
match?: NodeMatch<T>;
|
|
229
|
+
mode?: MaximizeMode;
|
|
230
|
+
split?: boolean;
|
|
231
|
+
voids?: boolean;
|
|
232
|
+
}) => void;
|
|
233
|
+
}
|
|
234
|
+
declare const NodeTransforms: NodeTransforms;
|
|
120
235
|
interface TextDeleteOptions {
|
|
121
236
|
at?: Location;
|
|
122
237
|
distance?: number;
|
|
@@ -161,11 +276,6 @@ interface BaseEditor {
|
|
|
161
276
|
selection: Selection$1;
|
|
162
277
|
operations: Operation[];
|
|
163
278
|
marks: EditorMarks | null;
|
|
164
|
-
dirtyPaths: Path$1[];
|
|
165
|
-
dirtyPathKeys: Set<string>;
|
|
166
|
-
flushing: boolean;
|
|
167
|
-
normalizing: boolean;
|
|
168
|
-
batchingDirtyPaths: boolean;
|
|
169
279
|
apply: (operation: Operation) => void;
|
|
170
280
|
createSpan: () => Text$1;
|
|
171
281
|
getDirtyPaths: (operation: Operation) => Path$1[];
|
|
@@ -190,18 +300,25 @@ interface BaseEditor {
|
|
|
190
300
|
dirtyPaths: Path$1[];
|
|
191
301
|
operation?: Operation;
|
|
192
302
|
}) => boolean;
|
|
303
|
+
addMark: OmitFirstArg<typeof Editor$1.addMark>;
|
|
193
304
|
collapse: OmitFirstArg<typeof Transforms.collapse>;
|
|
194
305
|
delete: OmitFirstArg<typeof Transforms.delete>;
|
|
306
|
+
deleteBackward: (unit: TextUnit) => void;
|
|
307
|
+
deleteForward: (unit: TextUnit) => void;
|
|
308
|
+
deleteFragment: OmitFirstArg<typeof Editor$1.deleteFragment>;
|
|
195
309
|
deselect: OmitFirstArg<typeof Transforms.deselect>;
|
|
196
310
|
insertBreak: OmitFirstArg<typeof Editor$1.insertBreak>;
|
|
197
311
|
insertFragment: OmitFirstArg<typeof Transforms.insertFragment>;
|
|
312
|
+
insertNode: OmitFirstArg<typeof Editor$1.insertNode>;
|
|
198
313
|
insertNodes: OmitFirstArg<typeof Transforms.insertNodes>;
|
|
314
|
+
insertSoftBreak: OmitFirstArg<typeof Editor$1.insertSoftBreak>;
|
|
199
315
|
insertText: OmitFirstArg<typeof Transforms.insertText>;
|
|
200
316
|
liftNodes: OmitFirstArg<typeof Transforms.liftNodes>;
|
|
201
317
|
mergeNodes: OmitFirstArg<typeof Transforms.mergeNodes>;
|
|
202
318
|
move: OmitFirstArg<typeof Transforms.move>;
|
|
203
319
|
moveNodes: OmitFirstArg<typeof Transforms.moveNodes>;
|
|
204
320
|
normalize: OmitFirstArg<typeof Editor$1.normalize>;
|
|
321
|
+
removeMark: OmitFirstArg<typeof Editor$1.removeMark>;
|
|
205
322
|
removeNodes: OmitFirstArg<typeof Transforms.removeNodes>;
|
|
206
323
|
select: OmitFirstArg<typeof Transforms.select>;
|
|
207
324
|
setNodes: <T extends Node$1>(props: Partial<T>, options?: {
|
|
@@ -215,6 +332,7 @@ interface BaseEditor {
|
|
|
215
332
|
merge?: PropsMerge;
|
|
216
333
|
}) => void;
|
|
217
334
|
setNormalizing: OmitFirstArg<typeof Editor$1.setNormalizing>;
|
|
335
|
+
setPoint: OmitFirstArg<typeof Transforms.setPoint>;
|
|
218
336
|
setSelection: OmitFirstArg<typeof Transforms.setSelection>;
|
|
219
337
|
splitNodes: OmitFirstArg<typeof Transforms.splitNodes>;
|
|
220
338
|
unsetNodes: OmitFirstArg<typeof Transforms.unsetNodes>;
|
|
@@ -224,18 +342,25 @@ interface BaseEditor {
|
|
|
224
342
|
above: <T extends Ancestor>(options?: EditorAboveOptions<T>) => NodeEntry<T> | undefined;
|
|
225
343
|
after: OmitFirstArg<typeof Editor$1.after>;
|
|
226
344
|
before: OmitFirstArg<typeof Editor$1.before>;
|
|
345
|
+
edges: OmitFirstArg<typeof Editor$1.edges>;
|
|
227
346
|
elementReadOnly: OmitFirstArg<typeof Editor$1.elementReadOnly>;
|
|
228
347
|
end: OmitFirstArg<typeof Editor$1.end>;
|
|
348
|
+
first: OmitFirstArg<typeof Editor$1.first>;
|
|
349
|
+
fragment: OmitFirstArg<typeof Editor$1.fragment>;
|
|
229
350
|
getMarks: OmitFirstArg<typeof Editor$1.marks>;
|
|
351
|
+
hasBlocks: OmitFirstArg<typeof Editor$1.hasBlocks>;
|
|
230
352
|
hasInlines: OmitFirstArg<typeof Editor$1.hasInlines>;
|
|
231
353
|
hasPath: OmitFirstArg<typeof Editor$1.hasPath>;
|
|
354
|
+
hasTexts: OmitFirstArg<typeof Editor$1.hasTexts>;
|
|
232
355
|
isBlock: OmitFirstArg<typeof Editor$1.isBlock>;
|
|
233
356
|
isEdge: OmitFirstArg<typeof Editor$1.isEdge>;
|
|
357
|
+
isEmpty: OmitFirstArg<typeof Editor$1.isEmpty>;
|
|
234
358
|
isEnd: OmitFirstArg<typeof Editor$1.isEnd>;
|
|
235
359
|
isInline: OmitFirstArg<typeof Editor$1.isInline>;
|
|
236
360
|
isNormalizing: OmitFirstArg<typeof Editor$1.isNormalizing>;
|
|
237
361
|
isStart: OmitFirstArg<typeof Editor$1.isStart>;
|
|
238
362
|
isVoid: OmitFirstArg<typeof Editor$1.isVoid>;
|
|
363
|
+
last: OmitFirstArg<typeof Editor$1.last>;
|
|
239
364
|
leaf: OmitFirstArg<typeof Editor$1.leaf>;
|
|
240
365
|
levels: <T extends Node$1>(options?: EditorLevelsOptions<T>) => Generator<NodeEntry<T>, void, undefined>;
|
|
241
366
|
next: <T extends Descendant>(options?: EditorNextOptions<T>) => NodeEntry<T> | undefined;
|
|
@@ -244,15 +369,15 @@ interface BaseEditor {
|
|
|
244
369
|
parent: OmitFirstArg<typeof Editor$1.parent>;
|
|
245
370
|
path: OmitFirstArg<typeof Editor$1.path>;
|
|
246
371
|
pathRef: OmitFirstArg<typeof Editor$1.pathRef>;
|
|
247
|
-
pathRefs:
|
|
372
|
+
pathRefs: OmitFirstArg<typeof Editor$1.pathRefs>;
|
|
248
373
|
point: OmitFirstArg<typeof Editor$1.point>;
|
|
249
374
|
pointRef: OmitFirstArg<typeof Editor$1.pointRef>;
|
|
250
|
-
pointRefs:
|
|
375
|
+
pointRefs: OmitFirstArg<typeof Editor$1.pointRefs>;
|
|
251
376
|
positions: OmitFirstArg<typeof Editor$1.positions>;
|
|
252
377
|
previous: <T extends Node$1>(options?: EditorPreviousOptions<T>) => NodeEntry<T> | undefined;
|
|
253
378
|
range: OmitFirstArg<typeof Editor$1.range>;
|
|
254
379
|
rangeRef: OmitFirstArg<typeof Editor$1.rangeRef>;
|
|
255
|
-
rangeRefs:
|
|
380
|
+
rangeRefs: OmitFirstArg<typeof Editor$1.rangeRefs>;
|
|
256
381
|
start: OmitFirstArg<typeof Editor$1.start>;
|
|
257
382
|
string: OmitFirstArg<typeof Editor$1.string>;
|
|
258
383
|
unhangRange: OmitFirstArg<typeof Editor$1.unhangRange>;
|
|
@@ -279,11 +404,17 @@ interface EditorBeforeOptions {
|
|
|
279
404
|
unit?: TextUnitAdjustment;
|
|
280
405
|
voids?: boolean;
|
|
281
406
|
}
|
|
407
|
+
interface EditorDirectedDeletionOptions {
|
|
408
|
+
unit?: TextUnit;
|
|
409
|
+
}
|
|
282
410
|
interface EditorElementReadOnlyOptions {
|
|
283
411
|
at?: Location;
|
|
284
412
|
mode?: MaximizeMode;
|
|
285
413
|
voids?: boolean;
|
|
286
414
|
}
|
|
415
|
+
interface EditorFragmentDeletionOptions {
|
|
416
|
+
direction?: TextDirection;
|
|
417
|
+
}
|
|
287
418
|
interface EditorIsEditorOptions {
|
|
288
419
|
deep?: boolean;
|
|
289
420
|
}
|
|
@@ -368,6 +499,13 @@ interface EditorInterface {
|
|
|
368
499
|
* Get the ancestor above a location in the document.
|
|
369
500
|
*/
|
|
370
501
|
above: <T extends Ancestor>(editor: Editor$1, options?: EditorAboveOptions<T>) => NodeEntry<T> | undefined;
|
|
502
|
+
/**
|
|
503
|
+
* Add a custom property to the leaf text nodes in the current selection.
|
|
504
|
+
*
|
|
505
|
+
* If the selection is currently collapsed, the marks will be added to the
|
|
506
|
+
* `editor.marks` property instead, and applied when text is inserted next.
|
|
507
|
+
*/
|
|
508
|
+
addMark: (editor: Editor$1, key: string, value: any) => void;
|
|
371
509
|
/**
|
|
372
510
|
* Get the point after a location.
|
|
373
511
|
*/
|
|
@@ -376,6 +514,22 @@ interface EditorInterface {
|
|
|
376
514
|
* Get the point before a location.
|
|
377
515
|
*/
|
|
378
516
|
before: (editor: Editor$1, at: Location, options?: EditorBeforeOptions) => Point | undefined;
|
|
517
|
+
/**
|
|
518
|
+
* Delete content in the editor backward from the current selection.
|
|
519
|
+
*/
|
|
520
|
+
deleteBackward: (editor: Editor$1, options?: EditorDirectedDeletionOptions) => void;
|
|
521
|
+
/**
|
|
522
|
+
* Delete content in the editor forward from the current selection.
|
|
523
|
+
*/
|
|
524
|
+
deleteForward: (editor: Editor$1, options?: EditorDirectedDeletionOptions) => void;
|
|
525
|
+
/**
|
|
526
|
+
* Delete the content in the current selection.
|
|
527
|
+
*/
|
|
528
|
+
deleteFragment: (editor: Editor$1, options?: EditorFragmentDeletionOptions) => void;
|
|
529
|
+
/**
|
|
530
|
+
* Get the start and end points of a location.
|
|
531
|
+
*/
|
|
532
|
+
edges: (editor: Editor$1, at: Location) => [Point, Point];
|
|
379
533
|
/**
|
|
380
534
|
* Match a read-only element in the current branch of the editor.
|
|
381
535
|
*/
|
|
@@ -384,11 +538,27 @@ interface EditorInterface {
|
|
|
384
538
|
* Get the end point of a location.
|
|
385
539
|
*/
|
|
386
540
|
end: (editor: Editor$1, at: Location) => Point;
|
|
541
|
+
/**
|
|
542
|
+
* Get the first node at a location.
|
|
543
|
+
*/
|
|
544
|
+
first: (editor: Editor$1, at: Location) => NodeEntry;
|
|
545
|
+
/**
|
|
546
|
+
* Get the fragment at a location.
|
|
547
|
+
*/
|
|
548
|
+
fragment: (editor: Editor$1, at: Location) => Descendant[];
|
|
549
|
+
/**
|
|
550
|
+
* Check if a node has block children.
|
|
551
|
+
*/
|
|
552
|
+
hasBlocks: (editor: Editor$1, element: Element$1) => boolean;
|
|
387
553
|
/**
|
|
388
554
|
* Check if a node has inline and text children.
|
|
389
555
|
*/
|
|
390
556
|
hasInlines: (editor: Editor$1, element: Element$1) => boolean;
|
|
391
557
|
hasPath: (editor: Editor$1, path: Path$1) => boolean;
|
|
558
|
+
/**
|
|
559
|
+
* Check if a node has text children.
|
|
560
|
+
*/
|
|
561
|
+
hasTexts: (editor: Editor$1, element: Element$1) => boolean;
|
|
392
562
|
/**
|
|
393
563
|
* Insert a block break at the current selection.
|
|
394
564
|
*
|
|
@@ -400,6 +570,17 @@ interface EditorInterface {
|
|
|
400
570
|
* at the specified location or (if not defined) the current selection or (if not defined) the end of the document.
|
|
401
571
|
*/
|
|
402
572
|
insertFragment: (editor: Editor$1, fragment: Node$1[], options?: TextInsertFragmentOptions) => void;
|
|
573
|
+
/**
|
|
574
|
+
* Atomically inserts `nodes`
|
|
575
|
+
* at the specified location or (if not defined) the current selection or (if not defined) the end of the document.
|
|
576
|
+
*/
|
|
577
|
+
insertNode: <T extends Node$1>(editor: Editor$1, node: Node$1, options?: NodeInsertNodesOptions<T>) => void;
|
|
578
|
+
/**
|
|
579
|
+
* Insert a soft break at the current selection.
|
|
580
|
+
*
|
|
581
|
+
* If the selection is currently expanded, it will be deleted first.
|
|
582
|
+
*/
|
|
583
|
+
insertSoftBreak: (editor: Editor$1) => void;
|
|
403
584
|
/**
|
|
404
585
|
* Insert a string of text
|
|
405
586
|
* at the specified location or (if not defined) the current selection or (if not defined) the end of the document.
|
|
@@ -421,6 +602,10 @@ interface EditorInterface {
|
|
|
421
602
|
* Check if a value is a read-only `Element` object.
|
|
422
603
|
*/
|
|
423
604
|
isElementReadOnly: (editor: Editor$1, element: Element$1) => boolean;
|
|
605
|
+
/**
|
|
606
|
+
* Check if an element is empty, accounting for void nodes.
|
|
607
|
+
*/
|
|
608
|
+
isEmpty: (editor: Editor$1, element: Element$1) => boolean;
|
|
424
609
|
/**
|
|
425
610
|
* Check if a point is the end point of a location.
|
|
426
611
|
*/
|
|
@@ -445,6 +630,10 @@ interface EditorInterface {
|
|
|
445
630
|
* Check if a value is a void `Element` object.
|
|
446
631
|
*/
|
|
447
632
|
isVoid: (editor: Editor$1, value: Element$1) => boolean;
|
|
633
|
+
/**
|
|
634
|
+
* Get the last node at a location.
|
|
635
|
+
*/
|
|
636
|
+
last: (editor: Editor$1, at: Location) => NodeEntry;
|
|
448
637
|
/**
|
|
449
638
|
* Get the leaf text node at a location.
|
|
450
639
|
*/
|
|
@@ -533,6 +722,14 @@ interface EditorInterface {
|
|
|
533
722
|
* Get the set of currently tracked range refs of the editor.
|
|
534
723
|
*/
|
|
535
724
|
rangeRefs: (editor: Editor$1) => Set<RangeRef>;
|
|
725
|
+
/**
|
|
726
|
+
* Remove a custom property from all of the leaf text nodes in the current
|
|
727
|
+
* selection.
|
|
728
|
+
*
|
|
729
|
+
* If the selection is currently collapsed, the removal will be stored on
|
|
730
|
+
* `editor.marks` and applied to the text inserted next.
|
|
731
|
+
*/
|
|
732
|
+
removeMark: (editor: Editor$1, key: string) => void;
|
|
536
733
|
/**
|
|
537
734
|
* Manually set if the editor should currently be normalizing.
|
|
538
735
|
*
|
|
@@ -1316,121 +1513,6 @@ interface GeneralTransforms {
|
|
|
1316
1513
|
transform: (editor: Editor$1, op: Operation) => void;
|
|
1317
1514
|
}
|
|
1318
1515
|
declare const GeneralTransforms: GeneralTransforms;
|
|
1319
|
-
interface NodeInsertNodesOptions<T extends Node$1> {
|
|
1320
|
-
at?: Location;
|
|
1321
|
-
match?: NodeMatch<T>;
|
|
1322
|
-
mode?: RangeMode;
|
|
1323
|
-
hanging?: boolean;
|
|
1324
|
-
select?: boolean;
|
|
1325
|
-
voids?: boolean;
|
|
1326
|
-
batchDirty?: boolean;
|
|
1327
|
-
}
|
|
1328
|
-
interface NodeTransforms {
|
|
1329
|
-
/**
|
|
1330
|
-
* Insert nodes in the editor
|
|
1331
|
-
* at the specified location or (if not defined) the current selection or (if not defined) the end of the document.
|
|
1332
|
-
*/
|
|
1333
|
-
insertNodes: <T extends Node$1>(editor: Editor$1, nodes: Node$1 | Node$1[], options?: NodeInsertNodesOptions<T>) => void;
|
|
1334
|
-
/**
|
|
1335
|
-
* Lift nodes at a specific location upwards in the document tree, splitting
|
|
1336
|
-
* their parent in two if necessary.
|
|
1337
|
-
*/
|
|
1338
|
-
liftNodes: <T extends Node$1>(editor: Editor$1, options?: {
|
|
1339
|
-
at?: Location;
|
|
1340
|
-
match?: NodeMatch<T>;
|
|
1341
|
-
mode?: MaximizeMode;
|
|
1342
|
-
voids?: boolean;
|
|
1343
|
-
}) => void;
|
|
1344
|
-
/**
|
|
1345
|
-
* Merge a node at a location with the previous node of the same depth,
|
|
1346
|
-
* removing any empty containing nodes after the merge if necessary.
|
|
1347
|
-
*/
|
|
1348
|
-
mergeNodes: <T extends Node$1>(editor: Editor$1, options?: {
|
|
1349
|
-
at?: Location;
|
|
1350
|
-
match?: NodeMatch<T>;
|
|
1351
|
-
mode?: RangeMode;
|
|
1352
|
-
hanging?: boolean;
|
|
1353
|
-
voids?: boolean;
|
|
1354
|
-
}) => void;
|
|
1355
|
-
/**
|
|
1356
|
-
* Move the nodes at a location to a new location.
|
|
1357
|
-
*/
|
|
1358
|
-
moveNodes: <T extends Node$1>(editor: Editor$1, options: {
|
|
1359
|
-
at?: Location;
|
|
1360
|
-
match?: NodeMatch<T>;
|
|
1361
|
-
mode?: MaximizeMode;
|
|
1362
|
-
to: Path$1;
|
|
1363
|
-
voids?: boolean;
|
|
1364
|
-
}) => void;
|
|
1365
|
-
/**
|
|
1366
|
-
* Remove the nodes at a specific location in the document.
|
|
1367
|
-
*/
|
|
1368
|
-
removeNodes: <T extends Node$1>(editor: Editor$1, options?: {
|
|
1369
|
-
at?: Location;
|
|
1370
|
-
match?: NodeMatch<T>;
|
|
1371
|
-
mode?: RangeMode;
|
|
1372
|
-
hanging?: boolean;
|
|
1373
|
-
voids?: boolean;
|
|
1374
|
-
}) => void;
|
|
1375
|
-
/**
|
|
1376
|
-
* Set new properties on the nodes at a location.
|
|
1377
|
-
*/
|
|
1378
|
-
setNodes: <T extends Node$1>(editor: Editor$1, props: Partial<T>, options?: {
|
|
1379
|
-
at?: Location;
|
|
1380
|
-
match?: NodeMatch<T>;
|
|
1381
|
-
mode?: MaximizeMode;
|
|
1382
|
-
hanging?: boolean;
|
|
1383
|
-
split?: boolean;
|
|
1384
|
-
voids?: boolean;
|
|
1385
|
-
compare?: PropsCompare;
|
|
1386
|
-
merge?: PropsMerge;
|
|
1387
|
-
}) => void;
|
|
1388
|
-
/**
|
|
1389
|
-
* Split the nodes at a specific location.
|
|
1390
|
-
*/
|
|
1391
|
-
splitNodes: <T extends Node$1>(editor: Editor$1, options?: {
|
|
1392
|
-
at?: Location;
|
|
1393
|
-
match?: NodeMatch<T>;
|
|
1394
|
-
mode?: RangeMode;
|
|
1395
|
-
always?: boolean;
|
|
1396
|
-
height?: number;
|
|
1397
|
-
voids?: boolean;
|
|
1398
|
-
}) => void;
|
|
1399
|
-
/**
|
|
1400
|
-
* Unset properties on the nodes at a location.
|
|
1401
|
-
*/
|
|
1402
|
-
unsetNodes: <T extends Node$1>(editor: Editor$1, props: string | string[], options?: {
|
|
1403
|
-
at?: Location;
|
|
1404
|
-
match?: NodeMatch<T>;
|
|
1405
|
-
mode?: MaximizeMode;
|
|
1406
|
-
hanging?: boolean;
|
|
1407
|
-
split?: boolean;
|
|
1408
|
-
voids?: boolean;
|
|
1409
|
-
}) => void;
|
|
1410
|
-
/**
|
|
1411
|
-
* Unwrap the nodes at a location from a parent node, splitting the parent if
|
|
1412
|
-
* necessary to ensure that only the content in the range is unwrapped.
|
|
1413
|
-
*/
|
|
1414
|
-
unwrapNodes: <T extends Node$1>(editor: Editor$1, options?: {
|
|
1415
|
-
at?: Location;
|
|
1416
|
-
match?: NodeMatch<T>;
|
|
1417
|
-
mode?: MaximizeMode;
|
|
1418
|
-
split?: boolean;
|
|
1419
|
-
voids?: boolean;
|
|
1420
|
-
}) => void;
|
|
1421
|
-
/**
|
|
1422
|
-
* Wrap the nodes at a location in a new container node, splitting the edges
|
|
1423
|
-
* of the range first to ensure that only the content in the range is wrapped.
|
|
1424
|
-
*/
|
|
1425
|
-
wrapNodes: <T extends Node$1>(editor: Editor$1, element: Element$1, options?: {
|
|
1426
|
-
at?: Location;
|
|
1427
|
-
match?: NodeMatch<T>;
|
|
1428
|
-
mode?: MaximizeMode;
|
|
1429
|
-
split?: boolean;
|
|
1430
|
-
voids?: boolean;
|
|
1431
|
-
}) => void;
|
|
1432
|
-
}
|
|
1433
|
-
declare const NodeTransforms: NodeTransforms;
|
|
1434
1516
|
interface SelectionCollapseOptions {
|
|
1435
1517
|
edge?: SelectionEdge;
|
|
1436
1518
|
}
|
|
@@ -1440,6 +1522,9 @@ interface SelectionMoveOptions {
|
|
|
1440
1522
|
reverse?: boolean;
|
|
1441
1523
|
edge?: SelectionEdge;
|
|
1442
1524
|
}
|
|
1525
|
+
interface SelectionSetPointOptions {
|
|
1526
|
+
edge?: SelectionEdge;
|
|
1527
|
+
}
|
|
1443
1528
|
interface SelectionTransforms {
|
|
1444
1529
|
/**
|
|
1445
1530
|
* Collapse the selection.
|
|
@@ -1457,6 +1542,10 @@ interface SelectionTransforms {
|
|
|
1457
1542
|
* Set the selection to a new value.
|
|
1458
1543
|
*/
|
|
1459
1544
|
select: (editor: Editor$1, target: Location) => void;
|
|
1545
|
+
/**
|
|
1546
|
+
* Set new properties on one of the selection's points.
|
|
1547
|
+
*/
|
|
1548
|
+
setPoint: (editor: Editor$1, props: Partial<Point>, options?: SelectionSetPointOptions) => void;
|
|
1460
1549
|
/**
|
|
1461
1550
|
* Set new properties on the selection.
|
|
1462
1551
|
*/
|
|
@@ -1470,6 +1559,7 @@ declare const Transforms: GeneralTransforms & NodeTransforms & SelectionTransfor
|
|
|
1470
1559
|
type EditorSchema = Schema;
|
|
1471
1560
|
type DecoratedRange = BaseRange & {
|
|
1472
1561
|
rangeDecoration: RangeDecoration;
|
|
1562
|
+
merge: (leaf: Record<string, unknown>, decoration: Record<string, unknown>) => void;
|
|
1473
1563
|
};
|
|
1474
1564
|
type StringDiff = {
|
|
1475
1565
|
start: number;
|
|
@@ -1507,10 +1597,6 @@ declare class Key {
|
|
|
1507
1597
|
id: string;
|
|
1508
1598
|
constructor();
|
|
1509
1599
|
}
|
|
1510
|
-
type Action = {
|
|
1511
|
-
at?: Point | Range;
|
|
1512
|
-
run: () => void;
|
|
1513
|
-
};
|
|
1514
1600
|
/**
|
|
1515
1601
|
* A DOM-specific version of the `Editor` interface.
|
|
1516
1602
|
*/
|
|
@@ -1524,32 +1610,6 @@ interface DOMEditor extends BaseEditor {
|
|
|
1524
1610
|
insertTextData: (data: DataTransfer) => boolean;
|
|
1525
1611
|
isTargetInsideNonReadonlyVoid: (editor: Editor$1, target: EventTarget | null) => boolean;
|
|
1526
1612
|
setFragmentData: (data: DataTransfer, originEvent?: 'drag' | 'copy' | 'cut') => void;
|
|
1527
|
-
isNodeMapDirty: boolean;
|
|
1528
|
-
domWindow: Window | null;
|
|
1529
|
-
domElement: HTMLElement | null;
|
|
1530
|
-
domPlaceholder: string;
|
|
1531
|
-
domPlaceholderElement: HTMLElement | null;
|
|
1532
|
-
keyToElement: WeakMap<Key, HTMLElement>;
|
|
1533
|
-
nodeToIndex: WeakMap<Node$1, number>;
|
|
1534
|
-
nodeToParent: WeakMap<Node$1, Ancestor>;
|
|
1535
|
-
elementToNode: WeakMap<HTMLElement, Node$1>;
|
|
1536
|
-
nodeToElement: WeakMap<Node$1, HTMLElement>;
|
|
1537
|
-
nodeToKey: WeakMap<Node$1, Key>;
|
|
1538
|
-
changeVersion: MutableRefObject<number>;
|
|
1539
|
-
readOnly: boolean;
|
|
1540
|
-
focused: boolean;
|
|
1541
|
-
composing: boolean;
|
|
1542
|
-
userSelection: RangeRef | null;
|
|
1543
|
-
onContextChange: ((options?: {
|
|
1544
|
-
operation?: Operation;
|
|
1545
|
-
}) => void) | null;
|
|
1546
|
-
scheduleFlush: (() => void) | null;
|
|
1547
|
-
pendingInsertionMarks: Partial<Text$1> | null;
|
|
1548
|
-
userMarks: Partial<Text$1> | null;
|
|
1549
|
-
pendingDiffs: TextDiff[];
|
|
1550
|
-
pendingAction: Action | null;
|
|
1551
|
-
pendingSelection: Range | null;
|
|
1552
|
-
forceRender: (() => void) | null;
|
|
1553
1613
|
}
|
|
1554
1614
|
interface DOMEditorInterface {
|
|
1555
1615
|
/**
|
|
@@ -1690,46 +1750,6 @@ interface DOMEditorInterface {
|
|
|
1690
1750
|
}) => T extends true ? Range | null : Range;
|
|
1691
1751
|
}
|
|
1692
1752
|
declare const DOMEditor: DOMEditorInterface;
|
|
1693
|
-
interface ChunkTree {
|
|
1694
|
-
type: 'root';
|
|
1695
|
-
children: ChunkDescendant[];
|
|
1696
|
-
/**
|
|
1697
|
-
* The keys of any Slate nodes that have been moved using move_node since the
|
|
1698
|
-
* last render
|
|
1699
|
-
*
|
|
1700
|
-
* Detecting when a node has been moved to a different position in the
|
|
1701
|
-
* children array is impossible to do efficiently while reconciling the chunk
|
|
1702
|
-
* tree. This interferes with the reconciliation logic since it is treated as
|
|
1703
|
-
* if the intermediate nodes were inserted and removed, causing them to be
|
|
1704
|
-
* re-chunked unnecessarily.
|
|
1705
|
-
*
|
|
1706
|
-
* This set is used to detect when a node has been moved so that this case
|
|
1707
|
-
* can be handled correctly and efficiently.
|
|
1708
|
-
*/
|
|
1709
|
-
movedNodeKeys: Set<Key>;
|
|
1710
|
-
/**
|
|
1711
|
-
* The chunks whose descendants have been modified during the most recent
|
|
1712
|
-
* reconciliation
|
|
1713
|
-
*
|
|
1714
|
-
* Used to determine when the otherwise memoized React components for each
|
|
1715
|
-
* chunk should be re-rendered.
|
|
1716
|
-
*/
|
|
1717
|
-
modifiedChunks: Set<Chunk>;
|
|
1718
|
-
}
|
|
1719
|
-
interface Chunk {
|
|
1720
|
-
type: 'chunk';
|
|
1721
|
-
key: Key;
|
|
1722
|
-
parent: ChunkAncestor;
|
|
1723
|
-
children: ChunkDescendant[];
|
|
1724
|
-
}
|
|
1725
|
-
interface ChunkLeaf {
|
|
1726
|
-
type: 'leaf';
|
|
1727
|
-
key: Key;
|
|
1728
|
-
node: Descendant;
|
|
1729
|
-
index: number;
|
|
1730
|
-
}
|
|
1731
|
-
type ChunkAncestor = ChunkTree | Chunk;
|
|
1732
|
-
type ChunkDescendant = Chunk | ChunkLeaf;
|
|
1733
1753
|
/**
|
|
1734
1754
|
* A React and DOM-specific version of the `Editor` interface.
|
|
1735
1755
|
*/
|
|
@@ -1740,7 +1760,6 @@ interface ReactEditor extends DOMEditor {
|
|
|
1740
1760
|
* disabled.
|
|
1741
1761
|
*/
|
|
1742
1762
|
getChunkSize: (node: Ancestor) => number | null;
|
|
1743
|
-
keyToChunkTree: WeakMap<Key, ChunkTree>;
|
|
1744
1763
|
}
|
|
1745
1764
|
interface ReactEditorInterface extends DOMEditorInterface {}
|
|
1746
1765
|
declare const ReactEditor: ReactEditorInterface;
|
|
@@ -1776,6 +1795,50 @@ type RemotePatch = {
|
|
|
1776
1795
|
snapshot: PortableTextBlock[] | undefined;
|
|
1777
1796
|
previousSnapshot: PortableTextBlock[] | undefined;
|
|
1778
1797
|
};
|
|
1798
|
+
/**
|
|
1799
|
+
* Context passed during a split operation to help RangeDecorator
|
|
1800
|
+
* recompute decoration positions correctly.
|
|
1801
|
+
*/
|
|
1802
|
+
interface SplitContext {
|
|
1803
|
+
/** The offset in the original block where the split occurs */
|
|
1804
|
+
splitOffset: number;
|
|
1805
|
+
/** The child index of the span being split */
|
|
1806
|
+
splitChildIndex: number;
|
|
1807
|
+
/** The _key of the block being split */
|
|
1808
|
+
originalBlockKey: string;
|
|
1809
|
+
/** The _key of the new block created after the split */
|
|
1810
|
+
newBlockKey: string;
|
|
1811
|
+
/** The _key of the original span (child) being split */
|
|
1812
|
+
originalSpanKey: string;
|
|
1813
|
+
/** The _key of the new span in the new block (may be same or different) */
|
|
1814
|
+
newSpanKey: string;
|
|
1815
|
+
}
|
|
1816
|
+
/**
|
|
1817
|
+
* Context passed during a merge operation to help RangeDecorator
|
|
1818
|
+
* recompute decoration positions correctly.
|
|
1819
|
+
*
|
|
1820
|
+
* During a forward-delete merge (Delete at end of block 1) or
|
|
1821
|
+
* backward-delete merge (Backspace at start of block 2), the
|
|
1822
|
+
* second block is deleted and its content is re-inserted into
|
|
1823
|
+
* the first block. This context helps track that relationship.
|
|
1824
|
+
*/
|
|
1825
|
+
interface MergeContext {
|
|
1826
|
+
/** The _key of the block being deleted (block whose content is moving) */
|
|
1827
|
+
deletedBlockKey: string;
|
|
1828
|
+
/** The _key of the block receiving the content */
|
|
1829
|
+
targetBlockKey: string;
|
|
1830
|
+
/** The text length of the target block before merge (insertion offset) */
|
|
1831
|
+
targetBlockTextLength: number;
|
|
1832
|
+
/** The index of the deleted block at the time context was created */
|
|
1833
|
+
deletedBlockIndex: number;
|
|
1834
|
+
/** The index of the target block at the time context was created */
|
|
1835
|
+
targetBlockIndex: number;
|
|
1836
|
+
/** The number of children in the target block before merge.
|
|
1837
|
+
* Used to compute correct insertion indices for multi-child blocks
|
|
1838
|
+
* (e.g., blocks with bold/italic spans). Child N from the deleted block
|
|
1839
|
+
* ends up at index targetOriginalChildCount + N in the target block. */
|
|
1840
|
+
targetOriginalChildCount: number;
|
|
1841
|
+
}
|
|
1779
1842
|
interface PortableTextSlateEditor extends ReactEditor {
|
|
1780
1843
|
_key: 'editor';
|
|
1781
1844
|
_type: 'editor';
|
|
@@ -1783,6 +1846,24 @@ interface PortableTextSlateEditor extends ReactEditor {
|
|
|
1783
1846
|
isTextSpan: (value: unknown) => value is PortableTextSpan;
|
|
1784
1847
|
isListBlock: (value: unknown) => value is PortableTextListBlock;
|
|
1785
1848
|
decoratedRanges: Array<DecoratedRange>;
|
|
1849
|
+
/**
|
|
1850
|
+
* Snapshot of decoration state taken before a remote batch starts.
|
|
1851
|
+
* Used by the reconciliation handler to diff pre-batch vs post-batch
|
|
1852
|
+
* and fire a single onMoved callback per changed decoration.
|
|
1853
|
+
* Stores both the Slate Range (for change detection) and the
|
|
1854
|
+
* EditorSelection (for previousSelection in onMoved callbacks).
|
|
1855
|
+
* Managed by the apply interceptor in range-decorations-machine.
|
|
1856
|
+
*/
|
|
1857
|
+
preBatchDecorationRanges: Map<RangeDecoration, {
|
|
1858
|
+
range: Range | null;
|
|
1859
|
+
selection: EditorSelection;
|
|
1860
|
+
}>;
|
|
1861
|
+
/**
|
|
1862
|
+
* Tracks decorations whose interior content was modified during a remote
|
|
1863
|
+
* batch. Populated by the `move range decorations` action when callbacks
|
|
1864
|
+
* are suppressed; consumed and cleared by `reconcile range decorations`.
|
|
1865
|
+
*/
|
|
1866
|
+
batchContentChangedDecorations: Set<RangeDecoration>;
|
|
1786
1867
|
decoratorState: Record<string, boolean | undefined>;
|
|
1787
1868
|
blockIndexMap: Map<string, number>;
|
|
1788
1869
|
history: History;
|
|
@@ -1792,6 +1873,28 @@ interface PortableTextSlateEditor extends ReactEditor {
|
|
|
1792
1873
|
remotePatches: Array<RemotePatch>;
|
|
1793
1874
|
undoStepId: string | undefined;
|
|
1794
1875
|
value: Array<PortableTextBlock>;
|
|
1876
|
+
/**
|
|
1877
|
+
* Context for the current split operation.
|
|
1878
|
+
* Set before delete+insert operations, cleared after.
|
|
1879
|
+
* Used by RangeDecorator to correctly recompute decoration positions.
|
|
1880
|
+
*/
|
|
1881
|
+
splitContext: SplitContext | null;
|
|
1882
|
+
/**
|
|
1883
|
+
* Context for the current merge operation.
|
|
1884
|
+
* Set before delete+insert operations, cleared after.
|
|
1885
|
+
* Used by RangeDecorator to correctly recompute decoration positions.
|
|
1886
|
+
*/
|
|
1887
|
+
mergeContext: MergeContext | null;
|
|
1888
|
+
/**
|
|
1889
|
+
* Tracks which decoration points were on the deleted block BEFORE
|
|
1890
|
+
* `remove_node` shifts paths. Computed during `remove_node` and consumed
|
|
1891
|
+
* during `insert_node` to avoid stale-index collisions where a shifted
|
|
1892
|
+
* point coincidentally lands at `deletedBlockIndex`.
|
|
1893
|
+
*/
|
|
1894
|
+
mergeDeletedBlockFlags: Map<RangeDecoration, {
|
|
1895
|
+
anchor: boolean;
|
|
1896
|
+
focus: boolean;
|
|
1897
|
+
}> | null;
|
|
1795
1898
|
isDeferringMutations: boolean;
|
|
1796
1899
|
isNormalizingNode: boolean;
|
|
1797
1900
|
isPatching: boolean;
|
|
@@ -2535,8 +2638,21 @@ type ScrollSelectionIntoViewFunction = (editor: PortableTextEditor, domRange: gl
|
|
|
2535
2638
|
* @alpha */
|
|
2536
2639
|
interface RangeDecorationOnMovedDetails {
|
|
2537
2640
|
rangeDecoration: RangeDecoration;
|
|
2641
|
+
previousSelection: EditorSelection;
|
|
2538
2642
|
newSelection: EditorSelection;
|
|
2539
2643
|
origin: 'remote' | 'local';
|
|
2644
|
+
/**
|
|
2645
|
+
* Why the callback fired.
|
|
2646
|
+
*
|
|
2647
|
+
* - `'moved'` — the range's boundary points (anchor/focus) shifted due to
|
|
2648
|
+
* an editing operation, or the range was invalidated (`newSelection` is
|
|
2649
|
+
* `null`).
|
|
2650
|
+
* - `'contentChanged'` — the boundary points are unchanged, but content
|
|
2651
|
+
* inside the range was modified (text edits, node changes, etc.).
|
|
2652
|
+
* `previousSelection` and `newSelection` will be identical.
|
|
2653
|
+
* The return value is ignored for this reason.
|
|
2654
|
+
*/
|
|
2655
|
+
reason: 'moved' | 'contentChanged';
|
|
2540
2656
|
}
|
|
2541
2657
|
/**
|
|
2542
2658
|
* A range decoration is a UI affordance that wraps a given selection range in the editor
|
|
@@ -2563,9 +2679,24 @@ interface RangeDecoration {
|
|
|
2563
2679
|
*/
|
|
2564
2680
|
selection: EditorSelection;
|
|
2565
2681
|
/**
|
|
2566
|
-
*
|
|
2682
|
+
* Called when the range decoration moves due to edits.
|
|
2683
|
+
*
|
|
2684
|
+
* When `origin` is `'remote'`, the return value is honored: return an
|
|
2685
|
+
* `EditorSelection` to override the auto-resolved position (e.g. re-resolve
|
|
2686
|
+
* from a W3C annotation or other source of truth). This is useful because
|
|
2687
|
+
* remote structural ops (split/merge) may truncate or invalidate the
|
|
2688
|
+
* decoration, and the editor cannot reconstruct the full range without
|
|
2689
|
+
* consumer knowledge.
|
|
2690
|
+
*
|
|
2691
|
+
* When `origin` is `'local'`, the return value is ignored — local transforms
|
|
2692
|
+
* (split/merge context) already produce correct positions.
|
|
2567
2693
|
*/
|
|
2568
|
-
onMoved?: (details: RangeDecorationOnMovedDetails) => void;
|
|
2694
|
+
onMoved?: (details: RangeDecorationOnMovedDetails) => EditorSelection | void;
|
|
2695
|
+
/**
|
|
2696
|
+
* Stable identifier for matching to external data (e.g., annotation/comment ID).
|
|
2697
|
+
* Set by the consumer — PTE preserves it and passes it through in onMoved details.
|
|
2698
|
+
*/
|
|
2699
|
+
id?: string;
|
|
2569
2700
|
/**
|
|
2570
2701
|
* A custom payload that can be set on the range decoration
|
|
2571
2702
|
*/
|
|
@@ -2803,7 +2934,7 @@ type EditorActor = ActorRefFrom<typeof editorMachine>;
|
|
|
2803
2934
|
/**
|
|
2804
2935
|
* @internal
|
|
2805
2936
|
*/
|
|
2806
|
-
declare const editorMachine:
|
|
2937
|
+
declare const editorMachine: xstate77.StateMachine<{
|
|
2807
2938
|
behaviors: Set<BehaviorConfig>;
|
|
2808
2939
|
behaviorsSorted: boolean;
|
|
2809
2940
|
converters: Set<Converter>;
|
|
@@ -2819,7 +2950,7 @@ declare const editorMachine: xstate73.StateMachine<{
|
|
|
2819
2950
|
};
|
|
2820
2951
|
dragGhost?: HTMLElement;
|
|
2821
2952
|
slateEditor?: PortableTextSlateEditor;
|
|
2822
|
-
},
|
|
2953
|
+
}, MutationEvent | InternalPatchEvent | PatchesEvent | {
|
|
2823
2954
|
type: "update readOnly";
|
|
2824
2955
|
readOnly: boolean;
|
|
2825
2956
|
} | {
|
|
@@ -2864,52 +2995,52 @@ declare const editorMachine: xstate73.StateMachine<{
|
|
|
2864
2995
|
editor: PortableTextSlateEditor;
|
|
2865
2996
|
}, {}, never, {
|
|
2866
2997
|
type: "add behavior to context";
|
|
2867
|
-
params:
|
|
2998
|
+
params: xstate77.NonReducibleUnknown;
|
|
2868
2999
|
} | {
|
|
2869
3000
|
type: "remove behavior from context";
|
|
2870
|
-
params:
|
|
3001
|
+
params: xstate77.NonReducibleUnknown;
|
|
2871
3002
|
} | {
|
|
2872
3003
|
type: "add slate editor to context";
|
|
2873
|
-
params:
|
|
3004
|
+
params: xstate77.NonReducibleUnknown;
|
|
2874
3005
|
} | {
|
|
2875
3006
|
type: "emit patch event";
|
|
2876
|
-
params:
|
|
3007
|
+
params: xstate77.NonReducibleUnknown;
|
|
2877
3008
|
} | {
|
|
2878
3009
|
type: "emit mutation event";
|
|
2879
|
-
params:
|
|
3010
|
+
params: xstate77.NonReducibleUnknown;
|
|
2880
3011
|
} | {
|
|
2881
3012
|
type: "emit read only";
|
|
2882
|
-
params:
|
|
3013
|
+
params: xstate77.NonReducibleUnknown;
|
|
2883
3014
|
} | {
|
|
2884
3015
|
type: "emit editable";
|
|
2885
|
-
params:
|
|
3016
|
+
params: xstate77.NonReducibleUnknown;
|
|
2886
3017
|
} | {
|
|
2887
3018
|
type: "defer event";
|
|
2888
|
-
params:
|
|
3019
|
+
params: xstate77.NonReducibleUnknown;
|
|
2889
3020
|
} | {
|
|
2890
3021
|
type: "emit pending events";
|
|
2891
|
-
params:
|
|
3022
|
+
params: xstate77.NonReducibleUnknown;
|
|
2892
3023
|
} | {
|
|
2893
3024
|
type: "emit ready";
|
|
2894
|
-
params:
|
|
3025
|
+
params: xstate77.NonReducibleUnknown;
|
|
2895
3026
|
} | {
|
|
2896
3027
|
type: "clear pending events";
|
|
2897
|
-
params:
|
|
3028
|
+
params: xstate77.NonReducibleUnknown;
|
|
2898
3029
|
} | {
|
|
2899
3030
|
type: "discard conflicting pending patches";
|
|
2900
|
-
params:
|
|
3031
|
+
params: xstate77.NonReducibleUnknown;
|
|
2901
3032
|
} | {
|
|
2902
3033
|
type: "discard all pending events";
|
|
2903
|
-
params:
|
|
3034
|
+
params: xstate77.NonReducibleUnknown;
|
|
2904
3035
|
} | {
|
|
2905
3036
|
type: "defer incoming patches";
|
|
2906
|
-
params:
|
|
3037
|
+
params: xstate77.NonReducibleUnknown;
|
|
2907
3038
|
} | {
|
|
2908
3039
|
type: "emit pending incoming patches";
|
|
2909
|
-
params:
|
|
3040
|
+
params: xstate77.NonReducibleUnknown;
|
|
2910
3041
|
} | {
|
|
2911
3042
|
type: "clear pending incoming patches";
|
|
2912
|
-
params:
|
|
3043
|
+
params: xstate77.NonReducibleUnknown;
|
|
2913
3044
|
} | {
|
|
2914
3045
|
type: "handle blur";
|
|
2915
3046
|
params: unknown;
|
|
@@ -2921,7 +3052,7 @@ declare const editorMachine: xstate73.StateMachine<{
|
|
|
2921
3052
|
params: unknown;
|
|
2922
3053
|
} | {
|
|
2923
3054
|
type: "sort behaviors";
|
|
2924
|
-
params:
|
|
3055
|
+
params: xstate77.NonReducibleUnknown;
|
|
2925
3056
|
}, {
|
|
2926
3057
|
type: "slate is busy";
|
|
2927
3058
|
params: unknown;
|
|
@@ -2950,7 +3081,7 @@ declare const editorMachine: xstate73.StateMachine<{
|
|
|
2950
3081
|
readOnly?: boolean;
|
|
2951
3082
|
schema: EditorSchema;
|
|
2952
3083
|
initialValue?: Array<PortableTextBlock>;
|
|
2953
|
-
},
|
|
3084
|
+
}, xstate77.NonReducibleUnknown, {
|
|
2954
3085
|
type: "blurred";
|
|
2955
3086
|
event: react13.FocusEvent<HTMLDivElement, Element>;
|
|
2956
3087
|
} | {
|
|
@@ -2971,7 +3102,7 @@ declare const editorMachine: xstate73.StateMachine<{
|
|
|
2971
3102
|
value: Array<PortableTextBlock> | undefined;
|
|
2972
3103
|
} | {
|
|
2973
3104
|
type: "loading";
|
|
2974
|
-
} | {
|
|
3105
|
+
} | MutationEvent | {
|
|
2975
3106
|
type: "read only";
|
|
2976
3107
|
} | {
|
|
2977
3108
|
type: "ready";
|
|
@@ -2981,7 +3112,7 @@ declare const editorMachine: xstate73.StateMachine<{
|
|
|
2981
3112
|
} | {
|
|
2982
3113
|
type: "value changed";
|
|
2983
3114
|
value: Array<PortableTextBlock> | undefined;
|
|
2984
|
-
},
|
|
3115
|
+
} | InternalPatchEvent | PatchesEvent, xstate77.MetaObject, {
|
|
2985
3116
|
id: "editor";
|
|
2986
3117
|
states: {
|
|
2987
3118
|
readonly 'edit mode': {
|
|
@@ -3487,6 +3618,15 @@ type BehaviorAction = {
|
|
|
3487
3618
|
* ```
|
|
3488
3619
|
*/
|
|
3489
3620
|
send: (event: ExternalBehaviorEvent) => void;
|
|
3621
|
+
/**
|
|
3622
|
+
* The underlying Slate editor instance.
|
|
3623
|
+
*
|
|
3624
|
+
* Use this sparingly and only for setting transient state like
|
|
3625
|
+
* `splitContext` that coordinates between behaviors and other systems.
|
|
3626
|
+
*
|
|
3627
|
+
* @internal
|
|
3628
|
+
*/
|
|
3629
|
+
slateEditor: PortableTextSlateEditor;
|
|
3490
3630
|
}) => void;
|
|
3491
3631
|
};
|
|
3492
3632
|
/**
|