@portabletext/editor 6.0.1-canary.1 → 6.0.1

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 react10 from "react";
6
- import React$1, { BaseSyntheticEvent, ClipboardEvent as ClipboardEvent$1, FocusEvent, JSX, PropsWithChildren, ReactElement, RefObject, TextareaHTMLAttributes } from "react";
6
+ import React$1, { BaseSyntheticEvent, ClipboardEvent as ClipboardEvent$1, FocusEvent, JSX, MutableRefObject, 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,121 +117,6 @@ 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;
235
120
  interface TextDeleteOptions {
236
121
  at?: Location;
237
122
  distance?: number;
@@ -276,6 +161,11 @@ interface BaseEditor {
276
161
  selection: Selection$1;
277
162
  operations: Operation[];
278
163
  marks: EditorMarks | null;
164
+ dirtyPaths: Path$1[];
165
+ dirtyPathKeys: Set<string>;
166
+ flushing: boolean;
167
+ normalizing: boolean;
168
+ batchingDirtyPaths: boolean;
279
169
  apply: (operation: Operation) => void;
280
170
  createSpan: () => Text$1;
281
171
  getDirtyPaths: (operation: Operation) => Path$1[];
@@ -300,25 +190,18 @@ interface BaseEditor {
300
190
  dirtyPaths: Path$1[];
301
191
  operation?: Operation;
302
192
  }) => boolean;
303
- addMark: OmitFirstArg<typeof Editor$1.addMark>;
304
193
  collapse: OmitFirstArg<typeof Transforms.collapse>;
305
194
  delete: OmitFirstArg<typeof Transforms.delete>;
306
- deleteBackward: (unit: TextUnit) => void;
307
- deleteForward: (unit: TextUnit) => void;
308
- deleteFragment: OmitFirstArg<typeof Editor$1.deleteFragment>;
309
195
  deselect: OmitFirstArg<typeof Transforms.deselect>;
310
196
  insertBreak: OmitFirstArg<typeof Editor$1.insertBreak>;
311
197
  insertFragment: OmitFirstArg<typeof Transforms.insertFragment>;
312
- insertNode: OmitFirstArg<typeof Editor$1.insertNode>;
313
198
  insertNodes: OmitFirstArg<typeof Transforms.insertNodes>;
314
- insertSoftBreak: OmitFirstArg<typeof Editor$1.insertSoftBreak>;
315
199
  insertText: OmitFirstArg<typeof Transforms.insertText>;
316
200
  liftNodes: OmitFirstArg<typeof Transforms.liftNodes>;
317
201
  mergeNodes: OmitFirstArg<typeof Transforms.mergeNodes>;
318
202
  move: OmitFirstArg<typeof Transforms.move>;
319
203
  moveNodes: OmitFirstArg<typeof Transforms.moveNodes>;
320
204
  normalize: OmitFirstArg<typeof Editor$1.normalize>;
321
- removeMark: OmitFirstArg<typeof Editor$1.removeMark>;
322
205
  removeNodes: OmitFirstArg<typeof Transforms.removeNodes>;
323
206
  select: OmitFirstArg<typeof Transforms.select>;
324
207
  setNodes: <T extends Node$1>(props: Partial<T>, options?: {
@@ -332,7 +215,6 @@ interface BaseEditor {
332
215
  merge?: PropsMerge;
333
216
  }) => void;
334
217
  setNormalizing: OmitFirstArg<typeof Editor$1.setNormalizing>;
335
- setPoint: OmitFirstArg<typeof Transforms.setPoint>;
336
218
  setSelection: OmitFirstArg<typeof Transforms.setSelection>;
337
219
  splitNodes: OmitFirstArg<typeof Transforms.splitNodes>;
338
220
  unsetNodes: OmitFirstArg<typeof Transforms.unsetNodes>;
@@ -342,25 +224,18 @@ interface BaseEditor {
342
224
  above: <T extends Ancestor>(options?: EditorAboveOptions<T>) => NodeEntry<T> | undefined;
343
225
  after: OmitFirstArg<typeof Editor$1.after>;
344
226
  before: OmitFirstArg<typeof Editor$1.before>;
345
- edges: OmitFirstArg<typeof Editor$1.edges>;
346
227
  elementReadOnly: OmitFirstArg<typeof Editor$1.elementReadOnly>;
347
228
  end: OmitFirstArg<typeof Editor$1.end>;
348
- first: OmitFirstArg<typeof Editor$1.first>;
349
- fragment: OmitFirstArg<typeof Editor$1.fragment>;
350
229
  getMarks: OmitFirstArg<typeof Editor$1.marks>;
351
- hasBlocks: OmitFirstArg<typeof Editor$1.hasBlocks>;
352
230
  hasInlines: OmitFirstArg<typeof Editor$1.hasInlines>;
353
231
  hasPath: OmitFirstArg<typeof Editor$1.hasPath>;
354
- hasTexts: OmitFirstArg<typeof Editor$1.hasTexts>;
355
232
  isBlock: OmitFirstArg<typeof Editor$1.isBlock>;
356
233
  isEdge: OmitFirstArg<typeof Editor$1.isEdge>;
357
- isEmpty: OmitFirstArg<typeof Editor$1.isEmpty>;
358
234
  isEnd: OmitFirstArg<typeof Editor$1.isEnd>;
359
235
  isInline: OmitFirstArg<typeof Editor$1.isInline>;
360
236
  isNormalizing: OmitFirstArg<typeof Editor$1.isNormalizing>;
361
237
  isStart: OmitFirstArg<typeof Editor$1.isStart>;
362
238
  isVoid: OmitFirstArg<typeof Editor$1.isVoid>;
363
- last: OmitFirstArg<typeof Editor$1.last>;
364
239
  leaf: OmitFirstArg<typeof Editor$1.leaf>;
365
240
  levels: <T extends Node$1>(options?: EditorLevelsOptions<T>) => Generator<NodeEntry<T>, void, undefined>;
366
241
  next: <T extends Descendant>(options?: EditorNextOptions<T>) => NodeEntry<T> | undefined;
@@ -369,15 +244,15 @@ interface BaseEditor {
369
244
  parent: OmitFirstArg<typeof Editor$1.parent>;
370
245
  path: OmitFirstArg<typeof Editor$1.path>;
371
246
  pathRef: OmitFirstArg<typeof Editor$1.pathRef>;
372
- pathRefs: OmitFirstArg<typeof Editor$1.pathRefs>;
247
+ pathRefs: Set<PathRef>;
373
248
  point: OmitFirstArg<typeof Editor$1.point>;
374
249
  pointRef: OmitFirstArg<typeof Editor$1.pointRef>;
375
- pointRefs: OmitFirstArg<typeof Editor$1.pointRefs>;
250
+ pointRefs: Set<PointRef>;
376
251
  positions: OmitFirstArg<typeof Editor$1.positions>;
377
252
  previous: <T extends Node$1>(options?: EditorPreviousOptions<T>) => NodeEntry<T> | undefined;
378
253
  range: OmitFirstArg<typeof Editor$1.range>;
379
254
  rangeRef: OmitFirstArg<typeof Editor$1.rangeRef>;
380
- rangeRefs: OmitFirstArg<typeof Editor$1.rangeRefs>;
255
+ rangeRefs: Set<RangeRef>;
381
256
  start: OmitFirstArg<typeof Editor$1.start>;
382
257
  string: OmitFirstArg<typeof Editor$1.string>;
383
258
  unhangRange: OmitFirstArg<typeof Editor$1.unhangRange>;
@@ -404,17 +279,11 @@ interface EditorBeforeOptions {
404
279
  unit?: TextUnitAdjustment;
405
280
  voids?: boolean;
406
281
  }
407
- interface EditorDirectedDeletionOptions {
408
- unit?: TextUnit;
409
- }
410
282
  interface EditorElementReadOnlyOptions {
411
283
  at?: Location;
412
284
  mode?: MaximizeMode;
413
285
  voids?: boolean;
414
286
  }
415
- interface EditorFragmentDeletionOptions {
416
- direction?: TextDirection;
417
- }
418
287
  interface EditorIsEditorOptions {
419
288
  deep?: boolean;
420
289
  }
@@ -499,13 +368,6 @@ interface EditorInterface {
499
368
  * Get the ancestor above a location in the document.
500
369
  */
501
370
  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;
509
371
  /**
510
372
  * Get the point after a location.
511
373
  */
@@ -514,22 +376,6 @@ interface EditorInterface {
514
376
  * Get the point before a location.
515
377
  */
516
378
  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];
533
379
  /**
534
380
  * Match a read-only element in the current branch of the editor.
535
381
  */
@@ -538,27 +384,11 @@ interface EditorInterface {
538
384
  * Get the end point of a location.
539
385
  */
540
386
  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;
553
387
  /**
554
388
  * Check if a node has inline and text children.
555
389
  */
556
390
  hasInlines: (editor: Editor$1, element: Element$1) => boolean;
557
391
  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;
562
392
  /**
563
393
  * Insert a block break at the current selection.
564
394
  *
@@ -570,17 +400,6 @@ interface EditorInterface {
570
400
  * at the specified location or (if not defined) the current selection or (if not defined) the end of the document.
571
401
  */
572
402
  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;
584
403
  /**
585
404
  * Insert a string of text
586
405
  * at the specified location or (if not defined) the current selection or (if not defined) the end of the document.
@@ -602,10 +421,6 @@ interface EditorInterface {
602
421
  * Check if a value is a read-only `Element` object.
603
422
  */
604
423
  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;
609
424
  /**
610
425
  * Check if a point is the end point of a location.
611
426
  */
@@ -630,10 +445,6 @@ interface EditorInterface {
630
445
  * Check if a value is a void `Element` object.
631
446
  */
632
447
  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;
637
448
  /**
638
449
  * Get the leaf text node at a location.
639
450
  */
@@ -722,14 +533,6 @@ interface EditorInterface {
722
533
  * Get the set of currently tracked range refs of the editor.
723
534
  */
724
535
  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;
733
536
  /**
734
537
  * Manually set if the editor should currently be normalizing.
735
538
  *
@@ -1513,6 +1316,121 @@ interface GeneralTransforms {
1513
1316
  transform: (editor: Editor$1, op: Operation) => void;
1514
1317
  }
1515
1318
  declare const GeneralTransforms: GeneralTransforms;
1319
+ interface NodeInsertNodesOptions<T extends Node$1> {
1320
+ at?: Location;
1321
+ match?: NodeMatch<T>;
1322
+ mode?: RangeMode;
1323
+ hanging?: boolean;
1324
+ select?: boolean;
1325
+ voids?: boolean;
1326
+ batchDirty?: boolean;
1327
+ }
1328
+ interface NodeTransforms {
1329
+ /**
1330
+ * Insert nodes in the editor
1331
+ * at the specified location or (if not defined) the current selection or (if not defined) the end of the document.
1332
+ */
1333
+ insertNodes: <T extends Node$1>(editor: Editor$1, nodes: Node$1 | Node$1[], options?: NodeInsertNodesOptions<T>) => void;
1334
+ /**
1335
+ * Lift nodes at a specific location upwards in the document tree, splitting
1336
+ * their parent in two if necessary.
1337
+ */
1338
+ liftNodes: <T extends Node$1>(editor: Editor$1, options?: {
1339
+ at?: Location;
1340
+ match?: NodeMatch<T>;
1341
+ mode?: MaximizeMode;
1342
+ voids?: boolean;
1343
+ }) => void;
1344
+ /**
1345
+ * Merge a node at a location with the previous node of the same depth,
1346
+ * removing any empty containing nodes after the merge if necessary.
1347
+ */
1348
+ mergeNodes: <T extends Node$1>(editor: Editor$1, options?: {
1349
+ at?: Location;
1350
+ match?: NodeMatch<T>;
1351
+ mode?: RangeMode;
1352
+ hanging?: boolean;
1353
+ voids?: boolean;
1354
+ }) => void;
1355
+ /**
1356
+ * Move the nodes at a location to a new location.
1357
+ */
1358
+ moveNodes: <T extends Node$1>(editor: Editor$1, options: {
1359
+ at?: Location;
1360
+ match?: NodeMatch<T>;
1361
+ mode?: MaximizeMode;
1362
+ to: Path$1;
1363
+ voids?: boolean;
1364
+ }) => void;
1365
+ /**
1366
+ * Remove the nodes at a specific location in the document.
1367
+ */
1368
+ removeNodes: <T extends Node$1>(editor: Editor$1, options?: {
1369
+ at?: Location;
1370
+ match?: NodeMatch<T>;
1371
+ mode?: RangeMode;
1372
+ hanging?: boolean;
1373
+ voids?: boolean;
1374
+ }) => void;
1375
+ /**
1376
+ * Set new properties on the nodes at a location.
1377
+ */
1378
+ setNodes: <T extends Node$1>(editor: Editor$1, props: Partial<T>, options?: {
1379
+ at?: Location;
1380
+ match?: NodeMatch<T>;
1381
+ mode?: MaximizeMode;
1382
+ hanging?: boolean;
1383
+ split?: boolean;
1384
+ voids?: boolean;
1385
+ compare?: PropsCompare;
1386
+ merge?: PropsMerge;
1387
+ }) => void;
1388
+ /**
1389
+ * Split the nodes at a specific location.
1390
+ */
1391
+ splitNodes: <T extends Node$1>(editor: Editor$1, options?: {
1392
+ at?: Location;
1393
+ match?: NodeMatch<T>;
1394
+ mode?: RangeMode;
1395
+ always?: boolean;
1396
+ height?: number;
1397
+ voids?: boolean;
1398
+ }) => void;
1399
+ /**
1400
+ * Unset properties on the nodes at a location.
1401
+ */
1402
+ unsetNodes: <T extends Node$1>(editor: Editor$1, props: string | string[], options?: {
1403
+ at?: Location;
1404
+ match?: NodeMatch<T>;
1405
+ mode?: MaximizeMode;
1406
+ hanging?: boolean;
1407
+ split?: boolean;
1408
+ voids?: boolean;
1409
+ }) => void;
1410
+ /**
1411
+ * Unwrap the nodes at a location from a parent node, splitting the parent if
1412
+ * necessary to ensure that only the content in the range is unwrapped.
1413
+ */
1414
+ unwrapNodes: <T extends Node$1>(editor: Editor$1, options?: {
1415
+ at?: Location;
1416
+ match?: NodeMatch<T>;
1417
+ mode?: MaximizeMode;
1418
+ split?: boolean;
1419
+ voids?: boolean;
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;
1516
1434
  interface SelectionCollapseOptions {
1517
1435
  edge?: SelectionEdge;
1518
1436
  }
@@ -1522,9 +1440,6 @@ interface SelectionMoveOptions {
1522
1440
  reverse?: boolean;
1523
1441
  edge?: SelectionEdge;
1524
1442
  }
1525
- interface SelectionSetPointOptions {
1526
- edge?: SelectionEdge;
1527
- }
1528
1443
  interface SelectionTransforms {
1529
1444
  /**
1530
1445
  * Collapse the selection.
@@ -1542,10 +1457,6 @@ interface SelectionTransforms {
1542
1457
  * Set the selection to a new value.
1543
1458
  */
1544
1459
  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;
1549
1460
  /**
1550
1461
  * Set new properties on the selection.
1551
1462
  */
@@ -1596,6 +1507,10 @@ declare class Key {
1596
1507
  id: string;
1597
1508
  constructor();
1598
1509
  }
1510
+ type Action = {
1511
+ at?: Point | Range;
1512
+ run: () => void;
1513
+ };
1599
1514
  /**
1600
1515
  * A DOM-specific version of the `Editor` interface.
1601
1516
  */
@@ -1609,6 +1524,32 @@ interface DOMEditor extends BaseEditor {
1609
1524
  insertTextData: (data: DataTransfer) => boolean;
1610
1525
  isTargetInsideNonReadonlyVoid: (editor: Editor$1, target: EventTarget | null) => boolean;
1611
1526
  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;
1612
1553
  }
1613
1554
  interface DOMEditorInterface {
1614
1555
  /**
@@ -1749,6 +1690,46 @@ interface DOMEditorInterface {
1749
1690
  }) => T extends true ? Range | null : Range;
1750
1691
  }
1751
1692
  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;
1752
1733
  /**
1753
1734
  * A React and DOM-specific version of the `Editor` interface.
1754
1735
  */
@@ -1759,6 +1740,7 @@ interface ReactEditor extends DOMEditor {
1759
1740
  * disabled.
1760
1741
  */
1761
1742
  getChunkSize: (node: Ancestor) => number | null;
1743
+ keyToChunkTree: WeakMap<Key, ChunkTree>;
1762
1744
  }
1763
1745
  interface ReactEditorInterface extends DOMEditorInterface {}
1764
1746
  declare const ReactEditor: ReactEditorInterface;
@@ -1794,50 +1776,6 @@ type RemotePatch = {
1794
1776
  snapshot: PortableTextBlock[] | undefined;
1795
1777
  previousSnapshot: PortableTextBlock[] | undefined;
1796
1778
  };
1797
- /**
1798
- * Context passed during a split operation to help RangeDecorator
1799
- * recompute decoration positions correctly.
1800
- */
1801
- interface SplitContext {
1802
- /** The offset in the original block where the split occurs */
1803
- splitOffset: number;
1804
- /** The child index of the span being split */
1805
- splitChildIndex: number;
1806
- /** The _key of the block being split */
1807
- originalBlockKey: string;
1808
- /** The _key of the new block created after the split */
1809
- newBlockKey: string;
1810
- /** The _key of the original span (child) being split */
1811
- originalSpanKey: string;
1812
- /** The _key of the new span in the new block (may be same or different) */
1813
- newSpanKey: string;
1814
- }
1815
- /**
1816
- * Context passed during a merge operation to help RangeDecorator
1817
- * recompute decoration positions correctly.
1818
- *
1819
- * During a forward-delete merge (Delete at end of block 1) or
1820
- * backward-delete merge (Backspace at start of block 2), the
1821
- * second block is deleted and its content is re-inserted into
1822
- * the first block. This context helps track that relationship.
1823
- */
1824
- interface MergeContext {
1825
- /** The _key of the block being deleted (block whose content is moving) */
1826
- deletedBlockKey: string;
1827
- /** The _key of the block receiving the content */
1828
- targetBlockKey: string;
1829
- /** The text length of the target block before merge (insertion offset) */
1830
- targetBlockTextLength: number;
1831
- /** The index of the deleted block at the time context was created */
1832
- deletedBlockIndex: number;
1833
- /** The index of the target block at the time context was created */
1834
- targetBlockIndex: number;
1835
- /** The number of children in the target block before merge.
1836
- * Used to compute correct insertion indices for multi-child blocks
1837
- * (e.g., blocks with bold/italic spans). Child N from the deleted block
1838
- * ends up at index targetOriginalChildCount + N in the target block. */
1839
- targetOriginalChildCount: number;
1840
- }
1841
1779
  interface PortableTextSlateEditor extends ReactEditor {
1842
1780
  _key: 'editor';
1843
1781
  _type: 'editor';
@@ -1845,18 +1783,6 @@ interface PortableTextSlateEditor extends ReactEditor {
1845
1783
  isTextSpan: (value: unknown) => value is PortableTextSpan;
1846
1784
  isListBlock: (value: unknown) => value is PortableTextListBlock;
1847
1785
  decoratedRanges: Array<DecoratedRange>;
1848
- /**
1849
- * Snapshot of decoration state taken before a remote batch starts.
1850
- * Used by the reconciliation handler to diff pre-batch vs post-batch
1851
- * and fire a single onMoved callback per changed decoration.
1852
- * Stores both the Slate Range (for change detection) and the
1853
- * EditorSelection (for previousSelection in onMoved callbacks).
1854
- * Managed by the apply interceptor in range-decorations-machine.
1855
- */
1856
- preBatchDecorationRanges: Map<RangeDecoration, {
1857
- range: Range | null;
1858
- selection: EditorSelection;
1859
- }>;
1860
1786
  decoratorState: Record<string, boolean | undefined>;
1861
1787
  blockIndexMap: Map<string, number>;
1862
1788
  history: History;
@@ -1866,28 +1792,6 @@ interface PortableTextSlateEditor extends ReactEditor {
1866
1792
  remotePatches: Array<RemotePatch>;
1867
1793
  undoStepId: string | undefined;
1868
1794
  value: Array<PortableTextBlock>;
1869
- /**
1870
- * Context for the current split operation.
1871
- * Set before delete+insert operations, cleared after.
1872
- * Used by RangeDecorator to correctly recompute decoration positions.
1873
- */
1874
- splitContext: SplitContext | null;
1875
- /**
1876
- * Context for the current merge operation.
1877
- * Set before delete+insert operations, cleared after.
1878
- * Used by RangeDecorator to correctly recompute decoration positions.
1879
- */
1880
- mergeContext: MergeContext | null;
1881
- /**
1882
- * Tracks which decoration points were on the deleted block BEFORE
1883
- * `remove_node` shifts paths. Computed during `remove_node` and consumed
1884
- * during `insert_node` to avoid stale-index collisions where a shifted
1885
- * point coincidentally lands at `deletedBlockIndex`.
1886
- */
1887
- mergeDeletedBlockFlags: Map<RangeDecoration, {
1888
- anchor: boolean;
1889
- focus: boolean;
1890
- }> | null;
1891
1795
  isDeferringMutations: boolean;
1892
1796
  isNormalizingNode: boolean;
1893
1797
  isPatching: boolean;
@@ -2631,7 +2535,6 @@ type ScrollSelectionIntoViewFunction = (editor: PortableTextEditor, domRange: gl
2631
2535
  * @alpha */
2632
2536
  interface RangeDecorationOnMovedDetails {
2633
2537
  rangeDecoration: RangeDecoration;
2634
- previousSelection: EditorSelection;
2635
2538
  newSelection: EditorSelection;
2636
2539
  origin: 'remote' | 'local';
2637
2540
  }
@@ -2660,24 +2563,9 @@ interface RangeDecoration {
2660
2563
  */
2661
2564
  selection: EditorSelection;
2662
2565
  /**
2663
- * Called when the range decoration moves due to edits.
2664
- *
2665
- * When `origin` is `'remote'`, the return value is honored: return an
2666
- * `EditorSelection` to override the auto-resolved position (e.g. re-resolve
2667
- * from a W3C annotation or other source of truth). This is useful because
2668
- * remote structural ops (split/merge) may truncate or invalidate the
2669
- * decoration, and the editor cannot reconstruct the full range without
2670
- * consumer knowledge.
2671
- *
2672
- * When `origin` is `'local'`, the return value is ignored — local transforms
2673
- * (split/merge context) already produce correct positions.
2674
- */
2675
- onMoved?: (details: RangeDecorationOnMovedDetails) => EditorSelection | void;
2676
- /**
2677
- * Stable identifier for matching to external data (e.g., annotation/comment ID).
2678
- * Set by the consumer — PTE preserves it and passes it through in onMoved details.
2566
+ * A optional callback that will be called when the range decoration potentially moves according to user edits.
2679
2567
  */
2680
- id?: string;
2568
+ onMoved?: (details: RangeDecorationOnMovedDetails) => void;
2681
2569
  /**
2682
2570
  * A custom payload that can be set on the range decoration
2683
2571
  */
@@ -3599,15 +3487,6 @@ type BehaviorAction = {
3599
3487
  * ```
3600
3488
  */
3601
3489
  send: (event: ExternalBehaviorEvent) => void;
3602
- /**
3603
- * The underlying Slate editor instance.
3604
- *
3605
- * Use this sparingly and only for setting transient state like
3606
- * `splitContext` that coordinates between behaviors and other systems.
3607
- *
3608
- * @internal
3609
- */
3610
- slateEditor: PortableTextSlateEditor;
3611
3490
  }) => void;
3612
3491
  };
3613
3492
  /**