@portabletext/editor 1.50.7 → 1.51.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.
Files changed (98) hide show
  1. package/lib/_chunks-cjs/{util.slice-blocks.cjs → selection-point.cjs} +26 -18
  2. package/lib/_chunks-cjs/selection-point.cjs.map +1 -0
  3. package/lib/_chunks-cjs/selector.get-text-before.cjs +13 -10
  4. package/lib/_chunks-cjs/selector.get-text-before.cjs.map +1 -1
  5. package/lib/_chunks-cjs/selector.is-selecting-entire-blocks.cjs +46 -46
  6. package/lib/_chunks-cjs/selector.is-selecting-entire-blocks.cjs.map +1 -1
  7. package/lib/_chunks-cjs/selector.is-selection-expanded.cjs +21 -17
  8. package/lib/_chunks-cjs/selector.is-selection-expanded.cjs.map +1 -1
  9. package/lib/_chunks-cjs/util.child-selection-point-to-block-offset.cjs +10 -10
  10. package/lib/_chunks-cjs/util.child-selection-point-to-block-offset.cjs.map +1 -1
  11. package/lib/_chunks-cjs/util.is-equal-selection-points.cjs +5 -5
  12. package/lib/_chunks-cjs/util.is-equal-selection-points.cjs.map +1 -1
  13. package/lib/_chunks-cjs/util.merge-text-blocks.cjs +3 -3
  14. package/lib/_chunks-cjs/util.merge-text-blocks.cjs.map +1 -1
  15. package/lib/_chunks-cjs/util.selection-point-to-block-offset.cjs +7 -14
  16. package/lib/_chunks-cjs/util.selection-point-to-block-offset.cjs.map +1 -1
  17. package/lib/_chunks-es/{util.slice-blocks.js → selection-point.js} +26 -18
  18. package/lib/_chunks-es/selection-point.js.map +1 -0
  19. package/lib/_chunks-es/selector.get-text-before.js +13 -10
  20. package/lib/_chunks-es/selector.get-text-before.js.map +1 -1
  21. package/lib/_chunks-es/selector.is-selecting-entire-blocks.js +21 -21
  22. package/lib/_chunks-es/selector.is-selecting-entire-blocks.js.map +1 -1
  23. package/lib/_chunks-es/selector.is-selection-expanded.js +14 -10
  24. package/lib/_chunks-es/selector.is-selection-expanded.js.map +1 -1
  25. package/lib/_chunks-es/util.child-selection-point-to-block-offset.js +2 -2
  26. package/lib/_chunks-es/util.child-selection-point-to-block-offset.js.map +1 -1
  27. package/lib/_chunks-es/util.is-equal-selection-points.js +1 -1
  28. package/lib/_chunks-es/util.merge-text-blocks.js +1 -1
  29. package/lib/_chunks-es/util.selection-point-to-block-offset.js +4 -11
  30. package/lib/_chunks-es/util.selection-point-to-block-offset.js.map +1 -1
  31. package/lib/behaviors/index.d.cts +1 -2007
  32. package/lib/behaviors/index.d.ts +1 -2007
  33. package/lib/index.cjs +130 -146
  34. package/lib/index.cjs.map +1 -1
  35. package/lib/index.d.cts +1 -3
  36. package/lib/index.d.ts +1 -3
  37. package/lib/index.js +63 -79
  38. package/lib/index.js.map +1 -1
  39. package/lib/plugins/index.cjs +11 -11
  40. package/lib/plugins/index.cjs.map +1 -1
  41. package/lib/plugins/index.d.cts +6 -1981
  42. package/lib/plugins/index.d.ts +6 -1981
  43. package/lib/plugins/index.js +1 -1
  44. package/lib/selectors/index.cjs +17 -27
  45. package/lib/selectors/index.cjs.map +1 -1
  46. package/lib/selectors/index.d.cts +5 -2645
  47. package/lib/selectors/index.d.ts +5 -2645
  48. package/lib/selectors/index.js +13 -23
  49. package/lib/selectors/index.js.map +1 -1
  50. package/lib/utils/index.cjs +25 -14
  51. package/lib/utils/index.cjs.map +1 -1
  52. package/lib/utils/index.d.cts +0 -2633
  53. package/lib/utils/index.d.ts +0 -2633
  54. package/lib/utils/index.js +14 -3
  55. package/lib/utils/index.js.map +1 -1
  56. package/package.json +18 -18
  57. package/src/behaviors/behavior.abstract.delete.ts +0 -1
  58. package/src/behaviors/behavior.abstract.insert.ts +8 -8
  59. package/src/behaviors/behavior.types.event.ts +1 -0
  60. package/src/converters/converter.portable-text.ts +1 -1
  61. package/src/converters/converter.text-plain.ts +2 -2
  62. package/src/editor/editor-machine.ts +0 -2
  63. package/src/editor/editor-selector.ts +0 -1
  64. package/src/editor/editor-snapshot.ts +0 -5
  65. package/src/editor/mutation-machine.ts +52 -63
  66. package/src/internal-utils/applyPatch.ts +2 -1
  67. package/src/internal-utils/create-test-snapshot.ts +0 -1
  68. package/src/internal-utils/event-position.ts +3 -5
  69. package/src/internal-utils/selection-block-keys.ts +7 -7
  70. package/src/internal-utils/selection-focus-text.ts +13 -9
  71. package/src/internal-utils/selection-text.ts +9 -78
  72. package/src/internal-utils/terse-pt.test.ts +108 -26
  73. package/src/internal-utils/terse-pt.ts +132 -14
  74. package/src/operations/behavior.operation.decorator.add.ts +0 -1
  75. package/src/operations/behavior.operation.delete.ts +18 -13
  76. package/src/operations/behavior.operation.insert.block.ts +5 -1
  77. package/src/selection/selection-point.ts +22 -0
  78. package/src/selectors/index.ts +1 -1
  79. package/src/selectors/selector.get-anchor-block.ts +6 -6
  80. package/src/selectors/selector.get-anchor-child.ts +6 -6
  81. package/src/selectors/selector.get-list-state.test.ts +14 -27
  82. package/src/selectors/selector.get-list-state.ts +9 -27
  83. package/src/selectors/selector.get-selected-spans.ts +16 -19
  84. package/src/selectors/selector.get-selected-text-blocks.ts +11 -19
  85. package/src/selectors/selector.get-selection-end-block.ts +30 -0
  86. package/src/selectors/selector.get-selection-start-block.ts +30 -0
  87. package/src/selectors/selector.get-text-before.ts +15 -16
  88. package/src/selectors/selector.get-trimmed-selection.ts +15 -21
  89. package/src/selectors/selector.is-point-after-selection.ts +11 -19
  90. package/src/selectors/selector.is-point-before-selection.ts +11 -19
  91. package/src/selectors/selectors.ts +23 -39
  92. package/src/utils/util.block-offset.ts +6 -7
  93. package/src/utils/util.child-selection-point-to-block-offset.ts +6 -7
  94. package/src/utils/util.selection-point-to-block-offset.ts +5 -6
  95. package/src/utils/util.slice-blocks.ts +11 -20
  96. package/lib/_chunks-cjs/util.slice-blocks.cjs.map +0 -1
  97. package/lib/_chunks-es/util.slice-blocks.js.map +0 -1
  98. package/src/internal-utils/inline-object-selection.ts +0 -115
package/lib/index.d.cts CHANGED
@@ -171,6 +171,7 @@ declare type AbstractBehaviorEvent =
171
171
  type: StrictExtract<SyntheticBehaviorEventType, 'insert.blocks'>
172
172
  blocks: Array<BlockWithOptionalKey>
173
173
  placement: InsertPlacement
174
+ select?: 'start' | 'end' | 'none'
174
175
  }
175
176
  | {
176
177
  type: StrictExtract<SyntheticBehaviorEventType, 'insert.break'>
@@ -2786,7 +2787,6 @@ export declare type EditorSnapshot = {
2786
2787
  beta: {
2787
2788
  activeAnnotations: Array<string>
2788
2789
  activeDecorators: Array<string>
2789
- hasTag: HasTag
2790
2790
  internalDrag:
2791
2791
  | {
2792
2792
  origin: Pick<EventPosition, 'selection'>
@@ -2887,8 +2887,6 @@ export declare type FocusChange = {
2887
2887
  event: FocusEvent_2<HTMLDivElement, Element>
2888
2888
  }
2889
2889
 
2890
- declare type HasTag = ReturnType<EditorActor['getSnapshot']>['hasTag']
2891
-
2892
2890
  declare interface History_2 {
2893
2891
  redos: HistoryItem[]
2894
2892
  undos: HistoryItem[]
package/lib/index.d.ts CHANGED
@@ -171,6 +171,7 @@ declare type AbstractBehaviorEvent =
171
171
  type: StrictExtract<SyntheticBehaviorEventType, 'insert.blocks'>
172
172
  blocks: Array<BlockWithOptionalKey>
173
173
  placement: InsertPlacement
174
+ select?: 'start' | 'end' | 'none'
174
175
  }
175
176
  | {
176
177
  type: StrictExtract<SyntheticBehaviorEventType, 'insert.break'>
@@ -2786,7 +2787,6 @@ export declare type EditorSnapshot = {
2786
2787
  beta: {
2787
2788
  activeAnnotations: Array<string>
2788
2789
  activeDecorators: Array<string>
2789
- hasTag: HasTag
2790
2790
  internalDrag:
2791
2791
  | {
2792
2792
  origin: Pick<EventPosition, 'selection'>
@@ -2887,8 +2887,6 @@ export declare type FocusChange = {
2887
2887
  event: FocusEvent_2<HTMLDivElement, Element>
2888
2888
  }
2889
2889
 
2890
- declare type HasTag = ReturnType<EditorActor['getSnapshot']>['hasTag']
2891
-
2892
2890
  declare interface History_2 {
2893
2891
  redos: HistoryItem[]
2894
2892
  undos: HistoryItem[]
package/lib/index.js CHANGED
@@ -9,18 +9,18 @@ import { Element as Element$1, Text, Range, Editor, Node, Point, Transforms, Pat
9
9
  import { useSlateStatic, useSelected, withReact, ReactEditor, Slate, useSlate, Editable } from "slate-react";
10
10
  import debug$h from "debug";
11
11
  import { getBlockEndPoint, isEmptyTextBlock, isEqualSelectionPoints } from "./_chunks-es/util.is-equal-selection-points.js";
12
- import { getBlockStartPoint, isKeyedSegment, parseInlineObject, parseTextBlock, parseBlockObject, parseBlock, sliceBlocks, isTextBlock, parseAnnotation, blockOffsetToSpanSelectionPoint, isSpan$1 as isSpan, isListBlock, isTypedObject, getTextBlockText, parseBlocks } from "./_chunks-es/util.slice-blocks.js";
12
+ import { getBlockStartPoint, getBlockKeyFromSelectionPoint, parseInlineObject, parseTextBlock, parseBlockObject, parseBlock, sliceBlocks, isTextBlock, parseAnnotation, blockOffsetToSpanSelectionPoint, isKeyedSegment, isSpan$1 as isSpan, isListBlock, isTypedObject, getSelectionStartPoint, getSelectionEndPoint, getTextBlockText, parseBlocks } from "./_chunks-es/selection-point.js";
13
13
  import { isSelectionCollapsed, getFocusTextBlock, getFocusSpan as getFocusSpan$1, getSelectedBlocks, isSelectionExpanded, getSelectionStartBlock as getSelectionStartBlock$1, getSelectionEndBlock as getSelectionEndBlock$1, getFocusBlock as getFocusBlock$1, getFocusBlockObject, getPreviousBlock, getNextBlock, getFirstBlock as getFirstBlock$1, getLastBlock as getLastBlock$1, getFocusListBlock } from "./_chunks-es/selector.is-selection-expanded.js";
14
14
  import { getFocusInlineObject, isOverlappingSelection, isSelectingEntireBlocks, getTrimmedSelection, getCaretWordSelection, isAtTheEndOfBlock, isAtTheStartOfBlock, isActiveAnnotation, isActiveDecorator, getSelectedTextBlocks, isActiveListItem, isActiveStyle, getActiveAnnotations as getActiveAnnotations$1 } from "./_chunks-es/selector.is-selecting-entire-blocks.js";
15
15
  import { DOMEditor, isDOMNode } from "slate-dom";
16
- import { isSelectionCollapsed as isSelectionCollapsed$1, selectionPointToBlockOffset, getSelectionStartPoint, getSelectionEndPoint } from "./_chunks-es/util.selection-point-to-block-offset.js";
16
+ import { isSelectionCollapsed as isSelectionCollapsed$1, selectionPointToBlockOffset } from "./_chunks-es/util.selection-point-to-block-offset.js";
17
17
  import isEqual from "lodash/isEqual.js";
18
18
  import { isKeySegment, defineType, defineField, isPortableTextSpan as isPortableTextSpan$1 } from "@sanity/types";
19
19
  import getRandomValues from "get-random-values-esm";
20
20
  import { defineBehavior, forward, raise } from "./behaviors/index.js";
21
21
  import uniq from "lodash/uniq.js";
22
22
  import { Subject } from "rxjs";
23
- import { setup, assign, enqueueActions, emit, assertEvent, stateIn, fromCallback, not, and, raise as raise$1, createActor } from "xstate";
23
+ import { setup, assign, enqueueActions, emit, assertEvent, stateIn, fromCallback, and, not, raise as raise$1, createActor } from "xstate";
24
24
  import { htmlToBlocks } from "@portabletext/block-tools";
25
25
  import { toHTML } from "@portabletext/to-html";
26
26
  import { Schema } from "@sanity/schema";
@@ -537,8 +537,8 @@ function getEventPosition({
537
537
  };
538
538
  if (!positionBlock || !selection)
539
539
  return;
540
- const focusBlockPath = selection.focus.path.at(0), focusBlockKey = isKeyedSegment(focusBlockPath) ? focusBlockPath._key : void 0;
541
- if (focusBlockKey)
540
+ const focusBlockKey = getBlockKeyFromSelectionPoint(selection.focus);
541
+ if (focusBlockKey !== void 0)
542
542
  return isSelectionCollapsed$1(selection) && block && focusBlockKey !== block._key ? {
543
543
  block: positionBlock,
544
544
  isEditor: !1,
@@ -1253,7 +1253,7 @@ const converterJson = {
1253
1253
  * If we are dragging internally then we would like to keep the
1254
1254
  * dropped portable text as is.
1255
1255
  */
1256
- refreshKeys: !snapshot.beta.hasTag?.("dragging internally"),
1256
+ refreshKeys: !snapshot.beta.internalDrag,
1257
1257
  validateFields: !1
1258
1258
  }
1259
1259
  });
@@ -1357,7 +1357,7 @@ function createConverterTextPlain(legacySchema) {
1357
1357
  schema: snapshot.context.schema
1358
1358
  },
1359
1359
  blocks: snapshot.context.value
1360
- }).map((block) => isTextBlock(snapshot.context, block) ? block.children.map((child) => child._type === snapshot.context.schema.span.name ? child.text : snapshot.beta.hasTag("dragging internally") ? `[${snapshot.context.schema.inlineObjects.find((inlineObjectType) => inlineObjectType.name === child._type)?.title ?? "Object"}]` : "").join("") : snapshot.beta.hasTag("dragging internally") ? `[${snapshot.context.schema.blockObjects.find((blockObjectType) => blockObjectType.name === block._type)?.title ?? "Object"}]` : "").filter((block) => block !== "").join(`
1360
+ }).map((block) => isTextBlock(snapshot.context, block) ? block.children.map((child) => child._type === snapshot.context.schema.span.name ? child.text : snapshot.beta.internalDrag ? `[${snapshot.context.schema.inlineObjects.find((inlineObjectType) => inlineObjectType.name === child._type)?.title ?? "Object"}]` : "").join("") : snapshot.beta.internalDrag ? `[${snapshot.context.schema.blockObjects.find((blockObjectType) => blockObjectType.name === block._type)?.title ?? "Object"}]` : "").filter((block) => block !== "").join(`
1361
1361
 
1362
1362
  `),
1363
1363
  mimeType: "text/plain",
@@ -1593,7 +1593,6 @@ function getEditorSnapshot({
1593
1593
  markState: slateEditorInstance.markState,
1594
1594
  schema: editorActorSnapshot.context.schema
1595
1595
  }),
1596
- hasTag: (tag) => editorActorSnapshot.hasTag(tag),
1597
1596
  internalDrag: editorActorSnapshot.context.internalDrag
1598
1597
  }
1599
1598
  };
@@ -3209,12 +3208,12 @@ const addAnnotationOperationImplementation = ({
3209
3208
  }, deleteOperationImplementation = ({
3210
3209
  operation
3211
3210
  }) => {
3212
- const anchorBlockPath = isKeyedSegment(operation.at.anchor.path[0]) ? getBlockPath({
3211
+ const anchorBlockKey = getBlockKeyFromSelectionPoint(operation.at.anchor), focusBlockKey = getBlockKeyFromSelectionPoint(operation.at.focus), anchorBlockPath = anchorBlockKey !== void 0 ? getBlockPath({
3213
3212
  editor: operation.editor,
3214
- _key: operation.at.anchor.path[0]._key
3215
- }) : void 0, focusBlockPath = isKeyedSegment(operation.at.focus.path[0]) ? getBlockPath({
3213
+ _key: anchorBlockKey
3214
+ }) : void 0, focusBlockPath = focusBlockKey !== void 0 ? getBlockPath({
3216
3215
  editor: operation.editor,
3217
- _key: operation.at.focus.path[0]._key
3216
+ _key: focusBlockKey
3218
3217
  }) : void 0;
3219
3218
  if (operation.at.anchor.path.length === 1 && operation.at.focus.path.length === 1 && anchorBlockPath && focusBlockPath && anchorBlockPath[0] === focusBlockPath[0]) {
3220
3219
  Transforms.removeNodes(operation.editor, {
@@ -3351,8 +3350,7 @@ function insertBlock({
3351
3350
  else if (placement === "after") {
3352
3351
  const nextPath = lastBlockPath ? [lastBlockPath[0] + 1] : [0];
3353
3352
  Transforms.insertNodes(editor, [block], {
3354
- at: nextPath,
3355
- select: !1
3353
+ at: nextPath
3356
3354
  }), select === "start" ? Transforms.select(editor, Editor.start(editor, nextPath)) : select === "end" && Transforms.select(editor, Editor.end(editor, nextPath));
3357
3355
  } else {
3358
3356
  if (lastBlock && isEqualToEmptyEditor([lastBlock], schema)) {
@@ -3465,7 +3463,9 @@ function insertBlock({
3465
3463
  editor
3466
3464
  });
3467
3465
  if (focusChild && editor.isTextSpan(focusChild))
3468
- Transforms.insertFragment(editor, [block], {
3466
+ Transforms.splitNodes(editor, {
3467
+ at: currentSelection2
3468
+ }), Transforms.insertFragment(editor, [block], {
3469
3469
  at: currentSelection2
3470
3470
  }), select === "start" || select === "end" ? Transforms.select(editor, [endBlockPath[0] + 1]) : Transforms.select(editor, currentSelection2);
3471
3471
  else {
@@ -4216,7 +4216,7 @@ function unsetPatch(editor, patch) {
4216
4216
  const newNode = applyAll(child.node, [{
4217
4217
  ...patch,
4218
4218
  path: propPath
4219
- }]), removedProperties = Object.keys(child.node).filter((property) => newNode[property] === void 0);
4219
+ }]), newKeys = Object.keys(newNode), removedProperties = Object.keys(child.node).filter((property) => !newKeys.includes(property));
4220
4220
  return Transforms.unsetNodes(editor, removedProperties, {
4221
4221
  at: [block.index, child.index]
4222
4222
  }), !0;
@@ -6017,7 +6017,7 @@ const arrowDownOnLonelyBlockObject = defineBehavior({
6017
6017
  type: "insert.block",
6018
6018
  block,
6019
6019
  placement: index === 0 ? "before" : "after",
6020
- select: "end"
6020
+ select: event.select ?? "end"
6021
6021
  }))]
6022
6022
  }), defineBehavior({
6023
6023
  on: "insert.blocks",
@@ -6030,7 +6030,7 @@ const arrowDownOnLonelyBlockObject = defineBehavior({
6030
6030
  type: "insert.block",
6031
6031
  block,
6032
6032
  placement: "after",
6033
- select: "end"
6033
+ select: event.select ?? "end"
6034
6034
  }))]
6035
6035
  }), defineBehavior({
6036
6036
  on: "insert.blocks",
@@ -6054,12 +6054,12 @@ const arrowDownOnLonelyBlockObject = defineBehavior({
6054
6054
  type: "insert.block",
6055
6055
  block: event.blocks[0],
6056
6056
  placement: "auto",
6057
- select: "end"
6057
+ select: event.select ?? "end"
6058
6058
  })] : isEmptyTextBlock(snapshot.context, focusTextBlock.node) ? event.blocks.map((block, index) => raise({
6059
6059
  type: "insert.block",
6060
6060
  block,
6061
6061
  placement: index === 0 ? "auto" : "after",
6062
- select: "end"
6062
+ select: event.select ?? "end"
6063
6063
  })) : event.blocks.flatMap((block, index) => index === 0 ? [raise({
6064
6064
  type: "split"
6065
6065
  }), raise({
@@ -6069,7 +6069,7 @@ const arrowDownOnLonelyBlockObject = defineBehavior({
6069
6069
  type: "insert.block",
6070
6070
  block,
6071
6071
  placement: "auto",
6072
- select: "end"
6072
+ select: event.select ?? "end"
6073
6073
  })] : index === event.blocks.length - 1 ? [raise({
6074
6074
  type: "select.next block",
6075
6075
  select: "start"
@@ -6077,12 +6077,12 @@ const arrowDownOnLonelyBlockObject = defineBehavior({
6077
6077
  type: "insert.block",
6078
6078
  block,
6079
6079
  placement: "auto",
6080
- select: "end"
6080
+ select: event.select ?? "end"
6081
6081
  })] : [raise({
6082
6082
  type: "insert.block",
6083
6083
  block,
6084
6084
  placement: "after",
6085
- select: "end"
6085
+ select: event.select ?? "end"
6086
6086
  })])]
6087
6087
  }), defineBehavior({
6088
6088
  on: "insert.blocks",
@@ -6095,7 +6095,7 @@ const arrowDownOnLonelyBlockObject = defineBehavior({
6095
6095
  type: "insert.block",
6096
6096
  block,
6097
6097
  placement: index === 0 ? "auto" : "after",
6098
- select: "end"
6098
+ select: event.select ?? "end"
6099
6099
  }))]
6100
6100
  }), defineBehavior({
6101
6101
  on: "insert.break",
@@ -7045,7 +7045,6 @@ function createEditorSnapshot({
7045
7045
  keyGenerator,
7046
7046
  readOnly,
7047
7047
  schema,
7048
- hasTag,
7049
7048
  internalDrag
7050
7049
  }) {
7051
7050
  const selection = editor.selection ? slateRangeToSelection({
@@ -7072,7 +7071,6 @@ function createEditorSnapshot({
7072
7071
  markState: editor.markState,
7073
7072
  schema
7074
7073
  }),
7075
- hasTag,
7076
7074
  internalDrag
7077
7075
  }
7078
7076
  };
@@ -7196,7 +7194,6 @@ const debug$8 = debugWithName("editor machine"), editorMachine = setup({
7196
7194
  "edit mode": "read only"
7197
7195
  }),
7198
7196
  schema: context.schema,
7199
- hasTag: (tag) => self.getSnapshot().hasTag(tag),
7200
7197
  internalDrag: context.internalDrag
7201
7198
  }),
7202
7199
  nativeEvent: event.nativeEvent
@@ -7849,6 +7846,18 @@ const debug$7 = debugWithName("mutation-machine"), mutationMachine = setup({
7849
7846
  }, () => {
7850
7847
  input.slateEditor.apply = originalApply;
7851
7848
  };
7849
+ }),
7850
+ "mutation debouncer": fromCallback(({
7851
+ sendBack
7852
+ }) => {
7853
+ const interval = setInterval(() => {
7854
+ sendBack({
7855
+ type: "mutation delay passed"
7856
+ });
7857
+ }, process.env.NODE_ENV === "test" ? 250 : 0);
7858
+ return () => {
7859
+ clearInterval(interval);
7860
+ };
7852
7861
  })
7853
7862
  },
7854
7863
  guards: {
@@ -7858,15 +7867,11 @@ const debug$7 = debugWithName("mutation-machine"), mutationMachine = setup({
7858
7867
  "is typing": stateIn({
7859
7868
  typing: "typing"
7860
7869
  }),
7861
- "no pending mutations": ({
7862
- context
7863
- }) => context.pendingMutations.length === 0,
7864
7870
  "slate is normalizing": ({
7865
7871
  context
7866
7872
  }) => Editor.isNormalizing(context.slateEditor)
7867
7873
  },
7868
7874
  delays: {
7869
- "mutation debounce": process.env.NODE_ENV === "test" ? 250 : 0,
7870
7875
  "type debounce": process.env.NODE_ENV === "test" ? 0 : 250
7871
7876
  }
7872
7877
  }).createMachine({
@@ -7903,7 +7908,7 @@ const debug$7 = debugWithName("mutation-machine"), mutationMachine = setup({
7903
7908
  debug$7("entry: typing->idle");
7904
7909
  }],
7905
7910
  exit: [() => {
7906
- debug$7("exit: typing->idle");
7911
+ debug$7("exit: typing->idle"), debug$7("entry: typing->typing");
7907
7912
  }],
7908
7913
  on: {
7909
7914
  typing: {
@@ -7912,15 +7917,12 @@ const debug$7 = debugWithName("mutation-machine"), mutationMachine = setup({
7912
7917
  }
7913
7918
  },
7914
7919
  typing: {
7915
- entry: [() => {
7916
- debug$7("entry: typing->typing");
7917
- }],
7918
- exit: [() => {
7919
- debug$7("exit: typing->typing");
7920
- }],
7921
7920
  after: {
7922
7921
  "type debounce": {
7923
- target: "idle"
7922
+ target: "idle",
7923
+ actions: [() => {
7924
+ debug$7("exit: typing->typing");
7925
+ }]
7924
7926
  }
7925
7927
  },
7926
7928
  on: {
@@ -7946,56 +7948,38 @@ const debug$7 = debugWithName("mutation-machine"), mutationMachine = setup({
7946
7948
  debug$7("exit: mutations->idle");
7947
7949
  }],
7948
7950
  on: {
7949
- patch: {
7950
- actions: ["emit patch", "defer mutation", "emit has pending mutations"],
7951
- target: "emitting mutations"
7952
- }
7953
- }
7954
- },
7955
- "emitting mutations": {
7956
- entry: [() => {
7957
- debug$7("entry: mutations->emitting mutations");
7958
- }],
7959
- exit: [() => {
7960
- debug$7("exit: mutations->emitting mutations");
7961
- }],
7962
- after: {
7963
- "mutation debounce": [{
7951
+ patch: [{
7964
7952
  guard: "is read-only",
7965
- target: "read-only"
7953
+ actions: ["defer patch", "defer mutation"],
7954
+ target: "has pending mutations"
7966
7955
  }, {
7967
- guard: and([not("is typing"), "slate is normalizing"]),
7968
- target: "idle",
7969
- actions: ["emit mutations", "clear pending mutations"]
7970
- }, {
7971
- target: "emitting mutations",
7972
- reenter: !0
7973
- }]
7974
- },
7975
- on: {
7976
- patch: {
7977
- target: "emitting mutations",
7978
7956
  actions: ["emit patch", "defer mutation"],
7979
- reenter: !0
7980
- }
7957
+ target: "has pending mutations"
7958
+ }]
7981
7959
  }
7982
7960
  },
7983
- "read-only": {
7961
+ "has pending mutations": {
7984
7962
  entry: [() => {
7985
- debug$7("entry: mutations->read-only");
7986
- }],
7963
+ debug$7("entry: mutations->has pending mutations");
7964
+ }, "emit has pending mutations"],
7987
7965
  exit: [() => {
7988
- debug$7("exit: mutations->read-only");
7989
- }],
7990
- always: [{
7991
- guard: not("is read-only"),
7992
- target: "emitting mutations",
7993
- actions: ["emit pending patch events", "clear pending patch events"]
7966
+ debug$7("exit: mutations->has pending mutations");
7994
7967
  }],
7968
+ invoke: {
7969
+ src: "mutation debouncer"
7970
+ },
7995
7971
  on: {
7996
- patch: {
7972
+ "mutation delay passed": {
7973
+ guard: and([not("is read-only"), not("is typing"), "slate is normalizing"]),
7974
+ target: "idle",
7975
+ actions: ["emit pending patch events", "clear pending patch events", "emit mutations", "clear pending mutations"]
7976
+ },
7977
+ patch: [{
7978
+ guard: "is read-only",
7997
7979
  actions: ["defer patch", "defer mutation"]
7998
- }
7980
+ }, {
7981
+ actions: ["emit patch", "defer mutation"]
7982
+ }]
7999
7983
  }
8000
7984
  }
8001
7985
  }