@portabletext/editor 1.55.13 → 1.55.14

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 (74) hide show
  1. package/lib/_chunks-cjs/{selector.is-selection-expanded.cjs → selector.get-focus-span.cjs} +27 -27
  2. package/lib/_chunks-cjs/selector.get-focus-span.cjs.map +1 -0
  3. package/lib/_chunks-cjs/selector.get-text-before.cjs +3 -3
  4. package/lib/_chunks-cjs/selector.get-text-before.cjs.map +1 -1
  5. package/lib/_chunks-cjs/selector.is-selecting-entire-blocks.cjs +291 -168
  6. package/lib/_chunks-cjs/selector.is-selecting-entire-blocks.cjs.map +1 -1
  7. package/lib/_chunks-cjs/util.child-selection-point-to-block-offset.cjs +1 -1
  8. package/lib/_chunks-cjs/util.child-selection-point-to-block-offset.cjs.map +1 -1
  9. package/lib/_chunks-cjs/{util.is-equal-selection-points.cjs → util.is-selection-collapsed.cjs} +7 -3
  10. package/lib/_chunks-cjs/util.is-selection-collapsed.cjs.map +1 -0
  11. package/lib/_chunks-cjs/util.slice-blocks.cjs +2 -2
  12. package/lib/_chunks-cjs/util.slice-text-block.cjs +2 -6
  13. package/lib/_chunks-cjs/util.slice-text-block.cjs.map +1 -1
  14. package/lib/_chunks-es/{selector.is-selection-expanded.js → selector.get-focus-span.js} +27 -27
  15. package/lib/_chunks-es/selector.get-focus-span.js.map +1 -0
  16. package/lib/_chunks-es/selector.get-text-before.js +1 -1
  17. package/lib/_chunks-es/selector.is-selecting-entire-blocks.js +266 -143
  18. package/lib/_chunks-es/selector.is-selecting-entire-blocks.js.map +1 -1
  19. package/lib/_chunks-es/util.child-selection-point-to-block-offset.js +1 -1
  20. package/lib/_chunks-es/{util.is-equal-selection-points.js → util.is-selection-collapsed.js} +7 -3
  21. package/lib/_chunks-es/util.is-selection-collapsed.js.map +1 -0
  22. package/lib/_chunks-es/util.slice-blocks.js +2 -2
  23. package/lib/_chunks-es/util.slice-text-block.js +1 -5
  24. package/lib/_chunks-es/util.slice-text-block.js.map +1 -1
  25. package/lib/behaviors/index.d.cts +3 -6
  26. package/lib/behaviors/index.d.ts +3 -6
  27. package/lib/index.cjs +110 -239
  28. package/lib/index.cjs.map +1 -1
  29. package/lib/index.d.cts +11 -20
  30. package/lib/index.d.ts +11 -20
  31. package/lib/index.js +49 -178
  32. package/lib/index.js.map +1 -1
  33. package/lib/plugins/index.cjs +16 -16
  34. package/lib/plugins/index.cjs.map +1 -1
  35. package/lib/plugins/index.d.cts +3 -6
  36. package/lib/plugins/index.d.ts +3 -6
  37. package/lib/plugins/index.js +1 -1
  38. package/lib/selectors/index.cjs +14 -14
  39. package/lib/selectors/index.cjs.map +1 -1
  40. package/lib/selectors/index.d.cts +3 -6
  41. package/lib/selectors/index.d.ts +3 -6
  42. package/lib/selectors/index.js +2 -2
  43. package/lib/utils/index.cjs +9 -9
  44. package/lib/utils/index.cjs.map +1 -1
  45. package/lib/utils/index.d.cts +3 -6
  46. package/lib/utils/index.d.ts +3 -6
  47. package/lib/utils/index.js +5 -5
  48. package/package.json +3 -3
  49. package/src/behaviors/behavior.abstract.ts +2 -1
  50. package/src/editor/create-slate-editor.tsx +0 -1
  51. package/src/editor/editor-selector.ts +1 -13
  52. package/src/editor/editor-snapshot.ts +4 -19
  53. package/src/editor/plugins/createWithEditableAPI.ts +9 -5
  54. package/src/editor/plugins/createWithPortableTextMarkModel.ts +13 -4
  55. package/src/editor/plugins/with-plugins.ts +4 -8
  56. package/src/internal-utils/create-test-snapshot.ts +2 -5
  57. package/src/operations/behavior.operation.decorator.add.ts +1 -4
  58. package/src/operations/behavior.operation.insert.text.ts +34 -20
  59. package/src/selectors/selector.get-active-annotation-marks.ts +12 -0
  60. package/src/selectors/selector.get-active-annotations.ts +8 -20
  61. package/src/{editor/get-active-decorators.ts → selectors/selector.get-active-decorators.ts} +6 -11
  62. package/src/{internal-utils/mark-state.ts → selectors/selector.get-mark-state.ts} +41 -67
  63. package/src/selectors/selector.get-next-span.ts +56 -0
  64. package/src/selectors/selector.get-previous-span.ts +53 -0
  65. package/src/selectors/selector.is-active-annotation.ts +3 -1
  66. package/src/selectors/selector.is-active-decorator.ts +4 -1
  67. package/src/types/editor.ts +0 -2
  68. package/src/utils/util.is-selection-expanded.ts +13 -0
  69. package/lib/_chunks-cjs/selector.is-selection-expanded.cjs.map +0 -1
  70. package/lib/_chunks-cjs/util.is-equal-selection-points.cjs.map +0 -1
  71. package/lib/_chunks-es/selector.is-selection-expanded.js.map +0 -1
  72. package/lib/_chunks-es/util.is-equal-selection-points.js.map +0 -1
  73. package/src/editor/get-active-annotations.ts +0 -15
  74. package/src/editor/plugins/slate-plugin.update-mark-state.ts +0 -21
package/lib/index.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: !0 });
3
- var reactCompilerRuntime = require("react-compiler-runtime"), React = require("react"), useEffectEvent = require("use-effect-event"), useEditor = require("./_chunks-cjs/use-editor.cjs"), jsxRuntime = require("react/jsx-runtime"), react = require("@xstate/react"), noop = require("lodash/noop.js"), slate = require("slate"), slateReact = require("slate-react"), debug$f = require("debug"), slateDom = require("slate-dom"), util_sliceBlocks = require("./_chunks-cjs/util.slice-blocks.cjs"), util_isEqualSelectionPoints = require("./_chunks-cjs/util.is-equal-selection-points.cjs"), util_sliceTextBlock = require("./_chunks-cjs/util.slice-text-block.cjs"), isEqual = require("lodash/isEqual.js"), selector_isSelectionExpanded = require("./_chunks-cjs/selector.is-selection-expanded.cjs"), selector_isSelectingEntireBlocks = require("./_chunks-cjs/selector.is-selecting-entire-blocks.cjs"), getRandomValues = require("get-random-values-esm"), behaviors_index = require("./behaviors/index.cjs"), uniq = require("lodash/uniq.js"), rxjs = require("rxjs"), xstate = require("xstate"), blockTools = require("@portabletext/block-tools"), toHtml = require("@portabletext/to-html"), schema = require("@sanity/schema"), flatten = require("lodash/flatten.js"), omit = require("lodash/omit.js"), patches = require("@portabletext/patches"), util_childSelectionPointToBlockOffset = require("./_chunks-cjs/util.child-selection-point-to-block-offset.cjs"), get = require("lodash/get.js"), isUndefined = require("lodash/isUndefined.js"), omitBy = require("lodash/omitBy.js"), immer = require("immer"), types = require("@sanity/types"), startCase = require("lodash.startcase"), isPlainObject = require("lodash/isPlainObject.js");
3
+ var reactCompilerRuntime = require("react-compiler-runtime"), React = require("react"), useEffectEvent = require("use-effect-event"), useEditor = require("./_chunks-cjs/use-editor.cjs"), jsxRuntime = require("react/jsx-runtime"), react = require("@xstate/react"), noop = require("lodash/noop.js"), slate = require("slate"), slateReact = require("slate-react"), debug$f = require("debug"), slateDom = require("slate-dom"), util_sliceBlocks = require("./_chunks-cjs/util.slice-blocks.cjs"), util_isSelectionCollapsed = require("./_chunks-cjs/util.is-selection-collapsed.cjs"), isEqual = require("lodash/isEqual.js"), selector_isSelectingEntireBlocks = require("./_chunks-cjs/selector.is-selecting-entire-blocks.cjs"), selector_getFocusSpan = require("./_chunks-cjs/selector.get-focus-span.cjs"), getRandomValues = require("get-random-values-esm"), behaviors_index = require("./behaviors/index.cjs"), uniq = require("lodash/uniq.js"), rxjs = require("rxjs"), xstate = require("xstate"), blockTools = require("@portabletext/block-tools"), toHtml = require("@portabletext/to-html"), schema = require("@sanity/schema"), flatten = require("lodash/flatten.js"), omit = require("lodash/omit.js"), patches = require("@portabletext/patches"), util_childSelectionPointToBlockOffset = require("./_chunks-cjs/util.child-selection-point-to-block-offset.cjs"), util_sliceTextBlock = require("./_chunks-cjs/util.slice-text-block.cjs"), get = require("lodash/get.js"), isUndefined = require("lodash/isUndefined.js"), omitBy = require("lodash/omitBy.js"), immer = require("immer"), types = require("@sanity/types"), startCase = require("lodash.startcase"), isPlainObject = require("lodash/isPlainObject.js");
4
4
  function _interopDefaultCompat(e) {
5
5
  return e && typeof e == "object" && "default" in e ? e : { default: e };
6
6
  }
@@ -402,7 +402,7 @@ function getEventPosition({
402
402
  }]
403
403
  }
404
404
  }),
405
- focus: util_isEqualSelectionPoints.getBlockEndPoint({
405
+ focus: util_isSelectionCollapsed.getBlockEndPoint({
406
406
  context: editorActor.getSnapshot().context,
407
407
  block: {
408
408
  node: eventBlock,
@@ -417,7 +417,7 @@ function getEventPosition({
417
417
  return;
418
418
  const eventSelectionFocusBlockKey = util_sliceBlocks.getBlockKeyFromSelectionPoint(eventSelection.focus);
419
419
  if (eventSelectionFocusBlockKey !== void 0)
420
- return util_sliceTextBlock.isSelectionCollapsed(eventSelection) && eventBlock && eventSelectionFocusBlockKey !== eventBlock._key ? {
420
+ return util_isSelectionCollapsed.isSelectionCollapsed(eventSelection) && eventBlock && eventSelectionFocusBlockKey !== eventBlock._key ? {
421
421
  block: eventPositionBlock,
422
422
  isEditor: !1,
423
423
  selection: {
@@ -430,7 +430,7 @@ function getEventPosition({
430
430
  }]
431
431
  }
432
432
  }),
433
- focus: util_isEqualSelectionPoints.getBlockEndPoint({
433
+ focus: util_isSelectionCollapsed.getBlockEndPoint({
434
434
  context: editorActor.getSnapshot().context,
435
435
  block: {
436
436
  node: eventBlock,
@@ -669,18 +669,18 @@ function getDragSelection({
669
669
  }
670
670
  }))
671
671
  return dragSelection;
672
- const draggingCollapsedSelection = selector_isSelectionExpanded.isSelectionCollapsed({
672
+ const draggingCollapsedSelection = selector_getFocusSpan.isSelectionCollapsed({
673
673
  context: {
674
674
  ...snapshot.context,
675
675
  selection: eventSelection
676
676
  }
677
- }), draggedTextBlock = selector_isSelectionExpanded.getFocusTextBlock({
677
+ }), draggedTextBlock = selector_getFocusSpan.getFocusTextBlock({
678
678
  ...snapshot,
679
679
  context: {
680
680
  ...snapshot.context,
681
681
  selection: eventSelection
682
682
  }
683
- }), draggedSpan = selector_isSelectionExpanded.getFocusSpan({
683
+ }), draggedSpan = selector_getFocusSpan.getFocusSpan({
684
684
  ...snapshot,
685
685
  context: {
686
686
  ...snapshot.context,
@@ -692,20 +692,20 @@ function getDragSelection({
692
692
  context: snapshot.context,
693
693
  block: draggedTextBlock
694
694
  }),
695
- focus: util_isEqualSelectionPoints.getBlockEndPoint({
695
+ focus: util_isSelectionCollapsed.getBlockEndPoint({
696
696
  context: snapshot.context,
697
697
  block: draggedTextBlock
698
698
  })
699
699
  });
700
700
  const selectedBlocks = selector_isSelectingEntireBlocks.getSelectedBlocks(snapshot);
701
- if (snapshot.context.selection && selector_isSelectionExpanded.isSelectionExpanded(snapshot) && selectedBlocks.length > 1) {
701
+ if (snapshot.context.selection && selector_getFocusSpan.isSelectionExpanded(snapshot) && selectedBlocks.length > 1) {
702
702
  const selectionStartBlock = selector_isSelectingEntireBlocks.getSelectionStartBlock(snapshot), selectionEndBlock = selector_isSelectingEntireBlocks.getSelectionEndBlock(snapshot);
703
703
  if (!selectionStartBlock || !selectionEndBlock)
704
704
  return dragSelection;
705
705
  const selectionStartPoint = util_sliceBlocks.getBlockStartPoint({
706
706
  context: snapshot.context,
707
707
  block: selectionStartBlock
708
- }), selectionEndPoint = util_isEqualSelectionPoints.getBlockEndPoint({
708
+ }), selectionEndPoint = util_isSelectionCollapsed.getBlockEndPoint({
709
709
  context: snapshot.context,
710
710
  block: selectionEndBlock
711
711
  });
@@ -765,7 +765,7 @@ function createCoreBlockElementBehaviorsConfig({
765
765
  snapshot,
766
766
  event
767
767
  }) => {
768
- const dropFocusBlock = selector_isSelectionExpanded.getFocusBlock({
768
+ const dropFocusBlock = selector_getFocusSpan.getFocusBlock({
769
769
  ...snapshot,
770
770
  context: {
771
771
  ...snapshot.context,
@@ -1092,7 +1092,7 @@ const converterJson = {
1092
1092
  originEvent: event.originEvent,
1093
1093
  reason: "No selection"
1094
1094
  };
1095
- const blocks = selector_isSelectionExpanded.getSelectedValue(snapshot);
1095
+ const blocks = selector_getFocusSpan.getSelectedValue(snapshot);
1096
1096
  return blocks.length === 0 ? {
1097
1097
  type: "serialization.failure",
1098
1098
  mimeType: "application/x-portable-text",
@@ -1152,7 +1152,7 @@ function createConverterTextHtml(legacySchema) {
1152
1152
  originEvent: event.originEvent,
1153
1153
  reason: "No selection"
1154
1154
  };
1155
- const blocks = selector_isSelectionExpanded.getSelectedValue(snapshot), html = toHtml.toHTML(blocks, {
1155
+ const blocks = selector_getFocusSpan.getSelectedValue(snapshot), html = toHtml.toHTML(blocks, {
1156
1156
  onMissingComponent: !1,
1157
1157
  components: {
1158
1158
  unknownType: ({
@@ -1210,7 +1210,7 @@ function createConverterTextPlain(legacySchema) {
1210
1210
  event
1211
1211
  }) => snapshot.context.selection ? {
1212
1212
  type: "serialization.success",
1213
- data: selector_isSelectionExpanded.getSelectedValue(snapshot).map((block) => util_sliceBlocks.isTextBlock(snapshot.context, block) ? block.children.map((child) => child._type === snapshot.context.schema.span.name ? child.text : event.originEvent === "drag.dragstart" ? `[${snapshot.context.schema.inlineObjects.find((inlineObjectType) => inlineObjectType.name === child._type)?.title ?? "Object"}]` : "").join("") : event.originEvent === "drag.dragstart" ? `[${snapshot.context.schema.blockObjects.find((blockObjectType) => blockObjectType.name === block._type)?.title ?? "Object"}]` : "").filter((block) => block !== "").join(`
1213
+ data: selector_getFocusSpan.getSelectedValue(snapshot).map((block) => util_sliceBlocks.isTextBlock(snapshot.context, block) ? block.children.map((child) => child._type === snapshot.context.schema.span.name ? child.text : event.originEvent === "drag.dragstart" ? `[${snapshot.context.schema.inlineObjects.find((inlineObjectType) => inlineObjectType.name === child._type)?.title ?? "Object"}]` : "").join("") : event.originEvent === "drag.dragstart" ? `[${snapshot.context.schema.blockObjects.find((blockObjectType) => blockObjectType.name === block._type)?.title ?? "Object"}]` : "").filter((block) => block !== "").join(`
1214
1214
 
1215
1215
  `),
1216
1216
  mimeType: "text/plain",
@@ -1343,43 +1343,34 @@ function createPlaceholderBlock(context) {
1343
1343
  }]
1344
1344
  };
1345
1345
  }
1346
- function getActiveAnnotations({
1347
- markState,
1348
- schema: schema2
1349
- }) {
1350
- return (markState?.marks ?? []).filter((mark) => !schema2.decorators.map((decorator) => decorator.name).includes(mark));
1351
- }
1352
- function getActiveDecorators({
1353
- decoratorState,
1354
- markState,
1355
- schema: schema2
1356
- }) {
1357
- const decorators = schema2.decorators.map((decorator) => decorator.name);
1358
- let activeDecorators = (markState?.marks ?? []).filter((mark) => decorators.includes(mark));
1359
- for (const decorator in decoratorState)
1360
- decoratorState[decorator] === !1 ? activeDecorators = activeDecorators.filter((activeDecorator) => activeDecorator !== decorator) : decoratorState[decorator] === !0 && (activeDecorators.includes(decorator) || activeDecorators.push(decorator));
1361
- return activeDecorators;
1362
- }
1363
1346
  const insertTextOperationImplementation = ({
1364
1347
  context,
1365
1348
  operation
1366
1349
  }) => {
1367
- const activeDecorators = getActiveDecorators({
1368
- decoratorState: operation.editor.decoratorState,
1369
- markState: operation.editor.markState,
1370
- schema: context.schema
1371
- }), activeAnnotations = getActiveAnnotations({
1372
- markState: operation.editor.markState,
1373
- schema: context.schema
1374
- }), [focusSpan] = getFocusSpan({
1350
+ const snapshot = {
1351
+ blockIndexMap: operation.editor.blockIndexMap,
1352
+ context: {
1353
+ value: operation.editor.value,
1354
+ selection: operation.editor.selection ? slateRangeToSelection({
1355
+ schema: context.schema,
1356
+ editor: operation.editor,
1357
+ range: operation.editor.selection
1358
+ }) : null,
1359
+ schema: context.schema,
1360
+ keyGenerator: context.keyGenerator,
1361
+ converters: [],
1362
+ readOnly: !1
1363
+ },
1364
+ decoratorState: operation.editor.decoratorState
1365
+ }, markState = selector_isSelectingEntireBlocks.getMarkState(snapshot), activeDecorators = selector_isSelectingEntireBlocks.getActiveDecorators(snapshot), activeAnnotations = selector_isSelectingEntireBlocks.getActiveAnnotationsMarks(snapshot), [focusSpan] = getFocusSpan({
1375
1366
  editor: operation.editor
1376
1367
  });
1377
1368
  if (!focusSpan) {
1378
1369
  slate.Transforms.insertText(operation.editor, operation.text);
1379
1370
  return;
1380
1371
  }
1381
- if (operation.editor.markState && operation.editor.markState.state === "unchanged") {
1382
- const markStateDecorators = (operation.editor.markState.marks ?? []).filter((mark) => context.schema.decorators.map((decorator) => decorator.name).includes(mark));
1372
+ if (markState && markState.state === "unchanged") {
1373
+ const markStateDecorators = (markState.marks ?? []).filter((mark) => context.schema.decorators.map((decorator) => decorator.name).includes(mark));
1383
1374
  if (markStateDecorators.length === activeDecorators.length && markStateDecorators.every((mark) => activeDecorators.includes(mark))) {
1384
1375
  slate.Transforms.insertText(operation.editor, operation.text);
1385
1376
  return;
@@ -1493,17 +1484,7 @@ function getEditorSnapshot({
1493
1484
  selection: editorActorSnapshot.context.selection,
1494
1485
  value: slateEditorInstance.value
1495
1486
  },
1496
- beta: {
1497
- activeAnnotations: getActiveAnnotations({
1498
- markState: slateEditorInstance.markState,
1499
- schema: editorActorSnapshot.context.schema
1500
- }),
1501
- activeDecorators: getActiveDecorators({
1502
- decoratorState: slateEditorInstance.decoratorState,
1503
- markState: slateEditorInstance.markState,
1504
- schema: editorActorSnapshot.context.schema
1505
- })
1506
- }
1487
+ decoratorState: slateEditorInstance.decoratorState
1507
1488
  };
1508
1489
  }
1509
1490
  const debug$e = debugWithName("plugin:withPortableTextMarkModel");
@@ -1718,11 +1699,15 @@ function createWithPortableTextMarkModel(editorActor) {
1718
1699
  }
1719
1700
  }
1720
1701
  if (op.type === "insert_text") {
1721
- if (!editor.markState) {
1702
+ const snapshot = getEditorSnapshot({
1703
+ editorActorSnapshot: editorActor.getSnapshot(),
1704
+ slateEditorInstance: editor
1705
+ }), markState = selector_isSelectingEntireBlocks.getMarkState(snapshot);
1706
+ if (!markState) {
1722
1707
  apply2(op);
1723
1708
  return;
1724
1709
  }
1725
- if (editor.markState.state === "unchanged") {
1710
+ if (markState.state === "unchanged") {
1726
1711
  apply2(op);
1727
1712
  return;
1728
1713
  }
@@ -1730,7 +1715,7 @@ function createWithPortableTextMarkModel(editorActor) {
1730
1715
  _type: "span",
1731
1716
  _key: editorActor.getSnapshot().context.keyGenerator(),
1732
1717
  text: op.text,
1733
- marks: editor.markState.marks
1718
+ marks: markState.marks
1734
1719
  });
1735
1720
  return;
1736
1721
  }
@@ -1767,7 +1752,7 @@ function createWithPortableTextMarkModel(editorActor) {
1767
1752
  });
1768
1753
  slate.Editor.withoutNormalizing(editor, () => {
1769
1754
  apply2(op), slate.Transforms.setNodes(editor, {
1770
- marks: snapshot.beta.activeDecorators
1755
+ marks: selector_isSelectingEntireBlocks.getActiveDecorators(snapshot)
1771
1756
  }, {
1772
1757
  at: op.path
1773
1758
  });
@@ -3186,10 +3171,6 @@ const addAnnotationOperationImplementation = ({
3186
3171
  backward: editorSelection?.backward
3187
3172
  }), trimmedSelection = selector_isSelectingEntireBlocks.getTrimmedSelection({
3188
3173
  blockIndexMap: editor.blockIndexMap,
3189
- beta: {
3190
- activeAnnotations: [],
3191
- activeDecorators: []
3192
- },
3193
3174
  context: {
3194
3175
  converters: [],
3195
3176
  keyGenerator: context.keyGenerator,
@@ -3197,7 +3178,8 @@ const addAnnotationOperationImplementation = ({
3197
3178
  schema: context.schema,
3198
3179
  selection: newSelection,
3199
3180
  value: newValue
3200
- }
3181
+ },
3182
+ decoratorState: editor.decoratorState
3201
3183
  });
3202
3184
  if (!trimmedSelection)
3203
3185
  throw new Error("Unable to find trimmed selection");
@@ -4348,7 +4330,7 @@ function insertTextPatch(schema2, children, operation, beforeValue) {
4348
4330
  throw new Error("Could not find block");
4349
4331
  const textChild = util_sliceBlocks.isTextBlock({
4350
4332
  schema: schema2
4351
- }, block) && util_sliceBlocks.isSpan$1({
4333
+ }, block) && util_sliceBlocks.isSpan({
4352
4334
  schema: schema2
4353
4335
  }, block.children[operation.path[1]]) && block.children[operation.path[1]];
4354
4336
  if (!textChild)
@@ -4359,7 +4341,7 @@ function insertTextPatch(schema2, children, operation, beforeValue) {
4359
4341
  _key: textChild._key
4360
4342
  }, "text"], prevBlock = beforeValue[operation.path[0]], prevChild = util_sliceBlocks.isTextBlock({
4361
4343
  schema: schema2
4362
- }, prevBlock) && prevBlock.children[operation.path[1]], prevText = util_sliceBlocks.isSpan$1({
4344
+ }, prevBlock) && prevBlock.children[operation.path[1]], prevText = util_sliceBlocks.isSpan({
4363
4345
  schema: schema2
4364
4346
  }, prevChild) ? prevChild.text : "", patch = patches.diffMatchPatch(prevText, textChild.text, path);
4365
4347
  return patch.value.length ? [patch] : [];
@@ -4370,7 +4352,7 @@ function removeTextPatch(schema2, children, operation, beforeValue) {
4370
4352
  throw new Error("Could not find block");
4371
4353
  const child = util_sliceBlocks.isTextBlock({
4372
4354
  schema: schema2
4373
- }, block) && block.children[operation.path[1]] || void 0, textChild = util_sliceBlocks.isSpan$1({
4355
+ }, block) && block.children[operation.path[1]] || void 0, textChild = util_sliceBlocks.isSpan({
4374
4356
  schema: schema2
4375
4357
  }, child) ? child : void 0;
4376
4358
  if (child && !textChild)
@@ -4383,7 +4365,7 @@ function removeTextPatch(schema2, children, operation, beforeValue) {
4383
4365
  _key: textChild._key
4384
4366
  }, "text"], beforeBlock = beforeValue[operation.path[0]], prevTextChild = util_sliceBlocks.isTextBlock({
4385
4367
  schema: schema2
4386
- }, beforeBlock) && beforeBlock.children[operation.path[1]], prevText = util_sliceBlocks.isSpan$1({
4368
+ }, beforeBlock) && beforeBlock.children[operation.path[1]], prevText = util_sliceBlocks.isSpan({
4387
4369
  schema: schema2
4388
4370
  }, prevTextChild) && prevTextChild.text, patch = patches.diffMatchPatch(prevText || "", textChild.text, path);
4389
4371
  return patch.value ? [patch] : [];
@@ -4484,7 +4466,7 @@ function splitNodePatch(schema2, children, operation, beforeValue) {
4484
4466
  }
4485
4467
  if (operation.path.length === 2) {
4486
4468
  const splitSpan = splitBlock.children[operation.path[1]];
4487
- if (util_sliceBlocks.isSpan$1({
4469
+ if (util_sliceBlocks.isSpan({
4488
4470
  schema: schema2
4489
4471
  }, splitSpan)) {
4490
4472
  const targetSpans = fromSlateValue([{
@@ -4542,9 +4524,9 @@ function mergeNodePatch(schema2, children, operation, beforeValue) {
4542
4524
  }, block) && util_sliceBlocks.isTextBlock({
4543
4525
  schema: schema2
4544
4526
  }, updatedBlock) && operation.path.length === 2) {
4545
- const updatedSpan = updatedBlock.children[operation.path[1] - 1] && util_sliceBlocks.isSpan$1({
4527
+ const updatedSpan = updatedBlock.children[operation.path[1] - 1] && util_sliceBlocks.isSpan({
4546
4528
  schema: schema2
4547
- }, updatedBlock.children[operation.path[1] - 1]) ? updatedBlock.children[operation.path[1] - 1] : void 0, removedSpan = block.children[operation.path[1]] && util_sliceBlocks.isSpan$1({
4529
+ }, updatedBlock.children[operation.path[1] - 1]) ? updatedBlock.children[operation.path[1] - 1] : void 0, removedSpan = block.children[operation.path[1]] && util_sliceBlocks.isSpan({
4548
4530
  schema: schema2
4549
4531
  }, block.children[operation.path[1]]) ? block.children[operation.path[1]] : void 0;
4550
4532
  updatedSpan && (block.children.filter((span) => span._key === updatedSpan._key).length === 1 ? patches$1.push(patches.set(updatedSpan.text, [{
@@ -4732,7 +4714,7 @@ function createWithSchemaTypes({
4732
4714
  editorActor
4733
4715
  }) {
4734
4716
  return function(editor) {
4735
- editor.isTextBlock = (value) => slate.Editor.isEditor(value) ? !1 : util_sliceBlocks.isTextBlock(editorActor.getSnapshot().context, value), editor.isTextSpan = (value) => slate.Editor.isEditor(value) ? !1 : util_sliceBlocks.isSpan$1(editorActor.getSnapshot().context, value), editor.isListBlock = (value) => slate.Editor.isEditor(value) ? !1 : util_sliceBlocks.isListBlock(editorActor.getSnapshot().context, value), editor.isVoid = (element) => slate.Editor.isEditor(element) ? !1 : editorActor.getSnapshot().context.schema.block.name !== element._type && (editorActor.getSnapshot().context.schema.blockObjects.map((obj) => obj.name).includes(element._type) || editorActor.getSnapshot().context.schema.inlineObjects.map((obj) => obj.name).includes(element._type)), editor.isInline = (element) => slate.Editor.isEditor(element) ? !1 : editorActor.getSnapshot().context.schema.inlineObjects.map((obj) => obj.name).includes(element._type) && "__inline" in element && element.__inline === !0;
4717
+ editor.isTextBlock = (value) => slate.Editor.isEditor(value) ? !1 : util_sliceBlocks.isTextBlock(editorActor.getSnapshot().context, value), editor.isTextSpan = (value) => slate.Editor.isEditor(value) ? !1 : util_sliceBlocks.isSpan(editorActor.getSnapshot().context, value), editor.isListBlock = (value) => slate.Editor.isEditor(value) ? !1 : util_sliceBlocks.isListBlock(editorActor.getSnapshot().context, value), editor.isVoid = (element) => slate.Editor.isEditor(element) ? !1 : editorActor.getSnapshot().context.schema.block.name !== element._type && (editorActor.getSnapshot().context.schema.blockObjects.map((obj) => obj.name).includes(element._type) || editorActor.getSnapshot().context.schema.inlineObjects.map((obj) => obj.name).includes(element._type)), editor.isInline = (element) => slate.Editor.isEditor(element) ? !1 : editorActor.getSnapshot().context.schema.inlineObjects.map((obj) => obj.name).includes(element._type) && "__inline" in element && element.__inline === !0;
4736
4718
  const {
4737
4719
  normalizeNode
4738
4720
  } = editor;
@@ -4800,110 +4782,6 @@ function createWithUtils({
4800
4782
  })[0], editor;
4801
4783
  };
4802
4784
  }
4803
- function getMarkState({
4804
- schema: schema2,
4805
- editor
4806
- }) {
4807
- if (!editor.selection)
4808
- return;
4809
- const [block, blockPath] = getFocusBlock({
4810
- editor
4811
- }), [span, spanPath] = getFocusSpan({
4812
- editor
4813
- });
4814
- if (!block || !editor.isTextBlock(block) || !span)
4815
- return;
4816
- if (slate.Range.isExpanded(editor.selection)) {
4817
- const selection = editor.selection ? slateRangeToSelection({
4818
- schema: schema2,
4819
- editor,
4820
- range: editor.selection
4821
- }) : null, selectedSpans = selector_isSelectingEntireBlocks.getSelectedSpans({
4822
- blockIndexMap: editor.blockIndexMap,
4823
- context: {
4824
- value: editor.value,
4825
- selection,
4826
- schema: schema2,
4827
- converters: [],
4828
- keyGenerator: () => "",
4829
- readOnly: !1
4830
- }
4831
- });
4832
- let index = 0, marks2 = [];
4833
- for (const span2 of selectedSpans)
4834
- index === 0 ? marks2 = span2.node.marks ?? [] : (span2.node.marks?.length === 0 || (span2.node.marks ?? [])?.some((mark) => !marks2.includes(mark))) && (marks2 = []), index++;
4835
- return {
4836
- state: "unchanged",
4837
- marks: marks2
4838
- };
4839
- }
4840
- const decorators = schema2.decorators.map((decorator) => decorator.name), marks = span.marks ?? [], marksWithoutAnnotations = marks.filter((mark) => decorators.includes(mark)), spanHasAnnotations = marks.length > marksWithoutAnnotations.length, spanIsEmpty = span.text.length === 0, atTheBeginningOfSpan = editor.selection.anchor.offset === 0, atTheEndOfSpan = editor.selection.anchor.offset === span.text.length, previousSpan = getPreviousSpan({
4841
- editor,
4842
- blockPath,
4843
- spanPath
4844
- }), nextSpan = getNextSpan({
4845
- editor,
4846
- blockPath,
4847
- spanPath
4848
- }), nextSpanAnnotations = nextSpan?.marks?.filter((mark) => !decorators.includes(mark)) ?? [], spanAnnotations = marks.filter((mark) => !decorators.includes(mark)), previousSpanHasAnnotations = previousSpan ? previousSpan.marks?.some((mark) => !decorators.includes(mark)) : !1, previousSpanHasSameAnnotations = previousSpan ? previousSpan.marks?.filter((mark) => !decorators.includes(mark)).every((mark) => marks.includes(mark)) : !1, previousSpanHasSameAnnotation = previousSpan ? previousSpan.marks?.some((mark) => !decorators.includes(mark) && marks.includes(mark)) : !1, previousSpanHasSameMarks = previousSpan ? previousSpan.marks?.every((mark) => marks.includes(mark)) : !1, nextSpanSharesSomeAnnotations = spanAnnotations.some((mark) => nextSpanAnnotations?.includes(mark));
4849
- if (spanHasAnnotations && !spanIsEmpty) {
4850
- if (atTheBeginningOfSpan) {
4851
- if (previousSpanHasSameMarks)
4852
- return {
4853
- state: "changed",
4854
- marks: previousSpan?.marks ?? []
4855
- };
4856
- if (previousSpanHasSameAnnotations)
4857
- return {
4858
- state: "changed",
4859
- marks: previousSpan?.marks ?? []
4860
- };
4861
- if (previousSpanHasSameAnnotation)
4862
- return {
4863
- state: "unchanged",
4864
- marks: span.marks ?? []
4865
- };
4866
- if (!previousSpan)
4867
- return {
4868
- state: "changed",
4869
- marks: []
4870
- };
4871
- }
4872
- if (atTheEndOfSpan) {
4873
- if (nextSpan && nextSpanSharesSomeAnnotations && nextSpanAnnotations.length < spanAnnotations.length || !nextSpanSharesSomeAnnotations)
4874
- return {
4875
- state: "changed",
4876
- marks: nextSpan?.marks ?? []
4877
- };
4878
- if (!nextSpan)
4879
- return {
4880
- state: "changed",
4881
- marks: []
4882
- };
4883
- }
4884
- }
4885
- return atTheBeginningOfSpan && !spanIsEmpty && previousSpan ? previousSpanHasAnnotations ? {
4886
- state: "changed",
4887
- marks: []
4888
- } : {
4889
- state: "changed",
4890
- marks: (previousSpan?.marks ?? []).filter((mark) => decorators.includes(mark))
4891
- } : {
4892
- state: "unchanged",
4893
- marks: span.marks ?? []
4894
- };
4895
- }
4896
- function pluginUpdateMarkState(context, editor) {
4897
- const {
4898
- apply: apply2
4899
- } = editor;
4900
- return editor.apply = (operation) => {
4901
- apply2(operation), editor.markState = getMarkState({
4902
- editor,
4903
- schema: context.schema
4904
- });
4905
- }, editor;
4906
- }
4907
4785
  function pluginUpdateSelection({
4908
4786
  editor,
4909
4787
  editorActor
@@ -5247,10 +5125,10 @@ const withPlugins = (editor, options) => {
5247
5125
  }), withPortableTextMarkModel = createWithPortableTextMarkModel(editorActor), withPlaceholderBlock = createWithPlaceholderBlock(editorActor), withUtils = createWithUtils({
5248
5126
  editorActor
5249
5127
  });
5250
- return createWithEventListeners(editorActor)(withSchemaTypes(withObjectKeys(withPortableTextMarkModel(withPlaceholderBlock(withUtils(withMaxBlocks(withUndoRedo(withPatches(pluginUpdateValue(editorActor.getSnapshot().context, pluginUpdateMarkState(editorActor.getSnapshot().context, pluginUpdateSelection({
5128
+ return createWithEventListeners(editorActor)(withSchemaTypes(withObjectKeys(withPortableTextMarkModel(withPlaceholderBlock(withUtils(withMaxBlocks(withUndoRedo(withPatches(pluginUpdateValue(editorActor.getSnapshot().context, pluginUpdateSelection({
5251
5129
  editorActor,
5252
5130
  editor: e
5253
- }))))))))))));
5131
+ })))))))))));
5254
5132
  }, debug$9 = debugWithName("setup");
5255
5133
  function createSlateEditor(config) {
5256
5134
  debug$9("Creating new Slate editor instance");
@@ -5259,7 +5137,7 @@ function createSlateEditor(config) {
5259
5137
  relayActor: config.relayActor,
5260
5138
  subscriptions: config.subscriptions
5261
5139
  });
5262
- KEY_TO_VALUE_ELEMENT.set(instance, {}), KEY_TO_SLATE_ELEMENT.set(instance, {}), instance.decoratedRanges = [], instance.decoratorState = {}, instance.markState = void 0;
5140
+ KEY_TO_VALUE_ELEMENT.set(instance, {}), KEY_TO_SLATE_ELEMENT.set(instance, {}), instance.decoratedRanges = [], instance.decoratorState = {};
5263
5141
  const placeholderBlock = createPlaceholderBlock(config.editorActor.getSnapshot().context);
5264
5142
  instance.value = [placeholderBlock], instance.blockIndexMap = /* @__PURE__ */ new Map(), instance.listIndexMap = /* @__PURE__ */ new Map(), buildIndexMaps({
5265
5143
  schema: config.editorActor.getSnapshot().context.schema,
@@ -5337,10 +5215,10 @@ const addAnnotationOnCollapsedSelection = behaviors_index.defineBehavior({
5337
5215
  guard: ({
5338
5216
  snapshot
5339
5217
  }) => {
5340
- if (!selector_isSelectionExpanded.isSelectionCollapsed(snapshot))
5218
+ if (!selector_getFocusSpan.isSelectionCollapsed(snapshot))
5341
5219
  return !1;
5342
5220
  const caretWordSelection = selector_isSelectingEntireBlocks.getCaretWordSelection(snapshot);
5343
- return !caretWordSelection || !selector_isSelectionExpanded.isSelectionExpanded({
5221
+ return !caretWordSelection || !selector_getFocusSpan.isSelectionExpanded({
5344
5222
  context: {
5345
5223
  ...snapshot.context,
5346
5224
  selection: caretWordSelection
@@ -5566,7 +5444,7 @@ const defaultKeyboardShortcuts = {
5566
5444
  snapshot,
5567
5445
  event
5568
5446
  }) => {
5569
- if (!defaultKeyboardShortcuts.arrowDown.guard(event.originEvent) || !selector_isSelectionExpanded.isSelectionCollapsed(snapshot))
5447
+ if (!defaultKeyboardShortcuts.arrowDown.guard(event.originEvent) || !selector_getFocusSpan.isSelectionCollapsed(snapshot))
5570
5448
  return !1;
5571
5449
  const focusBlockObject = selector_isSelectingEntireBlocks.getFocusBlockObject(snapshot), nextBlock = selector_isSelectingEntireBlocks.getNextBlock(snapshot);
5572
5450
  return focusBlockObject && !nextBlock;
@@ -5586,7 +5464,7 @@ const defaultKeyboardShortcuts = {
5586
5464
  snapshot,
5587
5465
  event
5588
5466
  }) => {
5589
- if (!defaultKeyboardShortcuts.arrowUp.guard(event.originEvent) || !selector_isSelectionExpanded.isSelectionCollapsed(snapshot))
5467
+ if (!defaultKeyboardShortcuts.arrowUp.guard(event.originEvent) || !selector_getFocusSpan.isSelectionCollapsed(snapshot))
5590
5468
  return !1;
5591
5469
  const focusBlockObject = selector_isSelectingEntireBlocks.getFocusBlockObject(snapshot), previousBlock = selector_isSelectingEntireBlocks.getPreviousBlock(snapshot);
5592
5470
  return focusBlockObject && !previousBlock;
@@ -5606,7 +5484,7 @@ const defaultKeyboardShortcuts = {
5606
5484
  snapshot
5607
5485
  }) => {
5608
5486
  const focusBlockObject = selector_isSelectingEntireBlocks.getFocusBlockObject(snapshot);
5609
- return selector_isSelectionExpanded.isSelectionCollapsed(snapshot) && focusBlockObject !== void 0;
5487
+ return selector_getFocusSpan.isSelectionCollapsed(snapshot) && focusBlockObject !== void 0;
5610
5488
  },
5611
5489
  actions: [({
5612
5490
  snapshot
@@ -5623,7 +5501,7 @@ const defaultKeyboardShortcuts = {
5623
5501
  snapshot,
5624
5502
  event
5625
5503
  }) => {
5626
- if (snapshot.context.readOnly || snapshot.context.selection && !selector_isSelectionExpanded.isSelectionCollapsed(snapshot))
5504
+ if (snapshot.context.readOnly || snapshot.context.selection && !selector_getFocusSpan.isSelectionCollapsed(snapshot))
5627
5505
  return !1;
5628
5506
  const focusBlockObject = selector_isSelectingEntireBlocks.getFocusBlockObject({
5629
5507
  ...snapshot,
@@ -5660,7 +5538,7 @@ const defaultKeyboardShortcuts = {
5660
5538
  snapshot,
5661
5539
  event
5662
5540
  }) => {
5663
- if (snapshot.context.readOnly || snapshot.context.selection && !selector_isSelectionExpanded.isSelectionCollapsed(snapshot))
5541
+ if (snapshot.context.readOnly || snapshot.context.selection && !selector_getFocusSpan.isSelectionCollapsed(snapshot))
5664
5542
  return !1;
5665
5543
  const focusBlockObject = selector_isSelectingEntireBlocks.getFocusBlockObject({
5666
5544
  ...snapshot,
@@ -5696,8 +5574,8 @@ const defaultKeyboardShortcuts = {
5696
5574
  guard: ({
5697
5575
  snapshot
5698
5576
  }) => {
5699
- const focusTextBlock = selector_isSelectionExpanded.getFocusTextBlock(snapshot), selectionCollapsed = selector_isSelectionExpanded.isSelectionCollapsed(snapshot), previousBlock = selector_isSelectingEntireBlocks.getPreviousBlock(snapshot);
5700
- return !focusTextBlock || !selectionCollapsed || !previousBlock ? !1 : util_isEqualSelectionPoints.isEmptyTextBlock(snapshot.context, focusTextBlock.node) && !util_sliceBlocks.isTextBlock(snapshot.context, previousBlock.node) ? {
5577
+ const focusTextBlock = selector_getFocusSpan.getFocusTextBlock(snapshot), selectionCollapsed = selector_getFocusSpan.isSelectionCollapsed(snapshot), previousBlock = selector_isSelectingEntireBlocks.getPreviousBlock(snapshot);
5578
+ return !focusTextBlock || !selectionCollapsed || !previousBlock ? !1 : util_isSelectionCollapsed.isEmptyTextBlock(snapshot.context, focusTextBlock.node) && !util_sliceBlocks.isTextBlock(snapshot.context, previousBlock.node) ? {
5701
5579
  focusTextBlock,
5702
5580
  previousBlock
5703
5581
  } : !1;
@@ -5726,8 +5604,8 @@ const defaultKeyboardShortcuts = {
5726
5604
  guard: ({
5727
5605
  snapshot
5728
5606
  }) => {
5729
- const focusTextBlock = selector_isSelectionExpanded.getFocusTextBlock(snapshot), selectionCollapsed = selector_isSelectionExpanded.isSelectionCollapsed(snapshot), nextBlock = selector_isSelectingEntireBlocks.getNextBlock(snapshot);
5730
- return !focusTextBlock || !selectionCollapsed || !nextBlock ? !1 : util_isEqualSelectionPoints.isEmptyTextBlock(snapshot.context, focusTextBlock.node) && !util_sliceBlocks.isTextBlock(snapshot.context, nextBlock.node) ? {
5607
+ const focusTextBlock = selector_getFocusSpan.getFocusTextBlock(snapshot), selectionCollapsed = selector_getFocusSpan.isSelectionCollapsed(snapshot), nextBlock = selector_isSelectingEntireBlocks.getNextBlock(snapshot);
5608
+ return !focusTextBlock || !selectionCollapsed || !nextBlock ? !1 : util_isSelectionCollapsed.isEmptyTextBlock(snapshot.context, focusTextBlock.node) && !util_sliceBlocks.isTextBlock(snapshot.context, nextBlock.node) ? {
5731
5609
  focusTextBlock,
5732
5610
  nextBlock
5733
5611
  } : !1;
@@ -6073,7 +5951,7 @@ const coreDndBehaviors = [
6073
5951
  guard: ({
6074
5952
  snapshot
6075
5953
  }) => {
6076
- const focusTextBlock = selector_isSelectionExpanded.getFocusTextBlock(snapshot), selectionCollapsed = selector_isSelectionExpanded.isSelectionCollapsed(snapshot);
5954
+ const focusTextBlock = selector_getFocusSpan.getFocusTextBlock(snapshot), selectionCollapsed = selector_getFocusSpan.isSelectionCollapsed(snapshot);
6077
5955
  if (!snapshot.context.selection || !focusTextBlock || !selectionCollapsed)
6078
5956
  return !1;
6079
5957
  const atTheEndOfBlock = selector_isSelectingEntireBlocks.isAtTheEndOfBlock(focusTextBlock)(snapshot), focusListItem = focusTextBlock.node.listItem, focusLevel = focusTextBlock.node.level;
@@ -6108,10 +5986,10 @@ const coreDndBehaviors = [
6108
5986
  guard: ({
6109
5987
  snapshot
6110
5988
  }) => {
6111
- const focusTextBlock = selector_isSelectionExpanded.getFocusTextBlock(snapshot), selectionCollapsed = selector_isSelectionExpanded.isSelectionCollapsed(snapshot);
5989
+ const focusTextBlock = selector_getFocusSpan.getFocusTextBlock(snapshot), selectionCollapsed = selector_getFocusSpan.isSelectionCollapsed(snapshot);
6112
5990
  if (!snapshot.context.selection || !focusTextBlock || !selectionCollapsed)
6113
5991
  return !1;
6114
- const focusSpan = selector_isSelectionExpanded.getFocusSpan(snapshot), focusDecorators = focusSpan?.node.marks?.filter((mark) => snapshot.context.schema.decorators.some((decorator) => decorator.name === mark) ?? []), focusAnnotations = focusSpan?.node.marks?.filter((mark) => !snapshot.context.schema.decorators.some((decorator) => decorator.name === mark)) ?? [], focusListItem = focusTextBlock.node.listItem, focusLevel = focusTextBlock.node.level;
5992
+ const focusSpan = selector_getFocusSpan.getFocusSpan(snapshot), focusDecorators = focusSpan?.node.marks?.filter((mark) => snapshot.context.schema.decorators.some((decorator) => decorator.name === mark) ?? []), focusAnnotations = focusSpan?.node.marks?.filter((mark) => !snapshot.context.schema.decorators.some((decorator) => decorator.name === mark)) ?? [], focusListItem = focusTextBlock.node.listItem, focusLevel = focusTextBlock.node.level;
6115
5993
  return selector_isSelectingEntireBlocks.isAtTheStartOfBlock(focusTextBlock)(snapshot) ? {
6116
5994
  focusAnnotations,
6117
5995
  focusDecorators,
@@ -6147,7 +6025,7 @@ const coreDndBehaviors = [
6147
6025
  guard: ({
6148
6026
  snapshot
6149
6027
  }) => {
6150
- if (!snapshot.context.selection || !selector_isSelectionExpanded.isSelectionExpanded(snapshot))
6028
+ if (!snapshot.context.selection || !selector_getFocusSpan.isSelectionExpanded(snapshot))
6151
6029
  return !1;
6152
6030
  const firstBlock = selector_isSelectingEntireBlocks.getFirstBlock(snapshot), lastBlock = selector_isSelectingEntireBlocks.getLastBlock(snapshot);
6153
6031
  if (!firstBlock || !lastBlock)
@@ -6155,11 +6033,11 @@ const coreDndBehaviors = [
6155
6033
  const firstBlockStartPoint = util_sliceBlocks.getBlockStartPoint({
6156
6034
  context: snapshot.context,
6157
6035
  block: firstBlock
6158
- }), selectionStartPoint = util_sliceBlocks.getSelectionStartPoint(snapshot.context.selection), lastBlockEndPoint = util_isEqualSelectionPoints.getBlockEndPoint({
6036
+ }), selectionStartPoint = util_sliceBlocks.getSelectionStartPoint(snapshot.context.selection), lastBlockEndPoint = util_isSelectionCollapsed.getBlockEndPoint({
6159
6037
  context: snapshot.context,
6160
6038
  block: lastBlock
6161
6039
  }), selectionEndPoint = util_sliceBlocks.getSelectionEndPoint(snapshot.context.selection);
6162
- return util_isEqualSelectionPoints.isEqualSelectionPoints(firstBlockStartPoint, selectionStartPoint) && util_isEqualSelectionPoints.isEqualSelectionPoints(lastBlockEndPoint, selectionEndPoint) ? {
6040
+ return util_isSelectionCollapsed.isEqualSelectionPoints(firstBlockStartPoint, selectionStartPoint) && util_isSelectionCollapsed.isEqualSelectionPoints(lastBlockEndPoint, selectionEndPoint) ? {
6163
6041
  selection: snapshot.context.selection
6164
6042
  } : !1;
6165
6043
  },
@@ -6174,7 +6052,7 @@ const coreDndBehaviors = [
6174
6052
  guard: ({
6175
6053
  snapshot
6176
6054
  }) => {
6177
- if (!snapshot.context.selection || !selector_isSelectionExpanded.isSelectionExpanded(snapshot))
6055
+ if (!snapshot.context.selection || !selector_getFocusSpan.isSelectionExpanded(snapshot))
6178
6056
  return !1;
6179
6057
  const selectedBlocks = selector_isSelectingEntireBlocks.getSelectedBlocks(snapshot), selectionStartBlock = selector_isSelectingEntireBlocks.getSelectionStartBlock(snapshot), selectionEndBlock = selector_isSelectingEntireBlocks.getSelectionEndBlock(snapshot);
6180
6058
  if (!selectionStartBlock || !selectionEndBlock)
@@ -6182,11 +6060,11 @@ const coreDndBehaviors = [
6182
6060
  const startBlockStartPoint = util_sliceBlocks.getBlockStartPoint({
6183
6061
  context: snapshot.context,
6184
6062
  block: selectionStartBlock
6185
- }), selectionStartPoint = util_sliceBlocks.getSelectionStartPoint(snapshot.context.selection), endBlockEndPoint = util_isEqualSelectionPoints.getBlockEndPoint({
6063
+ }), selectionStartPoint = util_sliceBlocks.getSelectionStartPoint(snapshot.context.selection), endBlockEndPoint = util_isSelectionCollapsed.getBlockEndPoint({
6186
6064
  context: snapshot.context,
6187
6065
  block: selectionEndBlock
6188
6066
  }), selectionEndPoint = util_sliceBlocks.getSelectionEndPoint(snapshot.context.selection);
6189
- return util_isEqualSelectionPoints.isEqualSelectionPoints(selectionStartPoint, startBlockStartPoint) && util_isEqualSelectionPoints.isEqualSelectionPoints(selectionEndPoint, endBlockEndPoint) ? {
6067
+ return util_isSelectionCollapsed.isEqualSelectionPoints(selectionStartPoint, startBlockStartPoint) && util_isSelectionCollapsed.isEqualSelectionPoints(selectionEndPoint, endBlockEndPoint) ? {
6190
6068
  selectedBlocks
6191
6069
  } : !1;
6192
6070
  },
@@ -6215,7 +6093,7 @@ const coreDndBehaviors = [
6215
6093
  guard: ({
6216
6094
  snapshot
6217
6095
  }) => {
6218
- const selectionCollapsed = selector_isSelectionExpanded.isSelectionCollapsed(snapshot), focusInlineObject = selector_isSelectingEntireBlocks.getFocusInlineObject(snapshot);
6096
+ const selectionCollapsed = selector_getFocusSpan.isSelectionCollapsed(snapshot), focusInlineObject = selector_isSelectingEntireBlocks.getFocusInlineObject(snapshot);
6219
6097
  return selectionCollapsed && focusInlineObject;
6220
6098
  },
6221
6099
  actions: [() => [behaviors_index.raise({
@@ -6235,7 +6113,7 @@ const coreDndBehaviors = [
6235
6113
  guard: ({
6236
6114
  snapshot
6237
6115
  }) => {
6238
- const selectionCollapsed = selector_isSelectionExpanded.isSelectionCollapsed(snapshot), focusTextBlock = selector_isSelectionExpanded.getFocusTextBlock(snapshot), focusSpan = selector_isSelectionExpanded.getFocusSpan(snapshot);
6116
+ const selectionCollapsed = selector_getFocusSpan.isSelectionCollapsed(snapshot), focusTextBlock = selector_getFocusSpan.getFocusTextBlock(snapshot), focusSpan = selector_getFocusSpan.getFocusSpan(snapshot);
6239
6117
  return !selectionCollapsed || !focusTextBlock || !focusSpan ? !1 : focusTextBlock.node.children[0]._key === focusSpan.node._key && snapshot.context.selection?.focus.offset === 0 && focusTextBlock.node.level === 1 ? {
6240
6118
  focusTextBlock
6241
6119
  } : !1;
@@ -6252,7 +6130,7 @@ const coreDndBehaviors = [
6252
6130
  guard: ({
6253
6131
  snapshot
6254
6132
  }) => {
6255
- const selectionCollapsed = selector_isSelectionExpanded.isSelectionCollapsed(snapshot), focusTextBlock = selector_isSelectionExpanded.getFocusTextBlock(snapshot), focusSpan = selector_isSelectionExpanded.getFocusSpan(snapshot);
6133
+ const selectionCollapsed = selector_getFocusSpan.isSelectionCollapsed(snapshot), focusTextBlock = selector_getFocusSpan.getFocusTextBlock(snapshot), focusSpan = selector_getFocusSpan.getFocusSpan(snapshot);
6256
6134
  return !selectionCollapsed || !focusTextBlock || !focusSpan ? !1 : focusTextBlock.node.children[0]._key === focusSpan.node._key && snapshot.context.selection?.focus.offset === 0 && focusTextBlock.node.level !== void 0 && focusTextBlock.node.level > 1 ? {
6257
6135
  focusTextBlock,
6258
6136
  level: focusTextBlock.node.level - 1
@@ -6273,8 +6151,8 @@ const coreDndBehaviors = [
6273
6151
  guard: ({
6274
6152
  snapshot
6275
6153
  }) => {
6276
- const selectionCollapsed = selector_isSelectionExpanded.isSelectionCollapsed(snapshot), focusListBlock = selector_isSelectingEntireBlocks.getFocusListBlock(snapshot);
6277
- return !selectionCollapsed || !focusListBlock || !util_isEqualSelectionPoints.isEmptyTextBlock(snapshot.context, focusListBlock.node) ? !1 : {
6154
+ const selectionCollapsed = selector_getFocusSpan.isSelectionCollapsed(snapshot), focusListBlock = selector_isSelectingEntireBlocks.getFocusListBlock(snapshot);
6155
+ return !selectionCollapsed || !focusListBlock || !util_isSelectionCollapsed.isEmptyTextBlock(snapshot.context, focusListBlock.node) ? !1 : {
6278
6156
  focusListBlock
6279
6157
  };
6280
6158
  },
@@ -6350,7 +6228,7 @@ const coreDndBehaviors = [
6350
6228
  snapshot,
6351
6229
  event
6352
6230
  }) => {
6353
- const blockKey = event.at[0]._key, markDefKey = event.at[2]._key, block = selector_isSelectionExpanded.getFocusTextBlock({
6231
+ const blockKey = event.at[0]._key, markDefKey = event.at[2]._key, block = selector_getFocusSpan.getFocusTextBlock({
6354
6232
  ...snapshot,
6355
6233
  context: {
6356
6234
  ...snapshot.context,
@@ -6510,7 +6388,7 @@ const coreDndBehaviors = [
6510
6388
  snapshot,
6511
6389
  event
6512
6390
  }) => {
6513
- const focusChild = selector_isSelectionExpanded.getFocusChild({
6391
+ const focusChild = selector_getFocusSpan.getFocusChild({
6514
6392
  ...snapshot,
6515
6393
  context: {
6516
6394
  ...snapshot.context,
@@ -6526,7 +6404,7 @@ const coreDndBehaviors = [
6526
6404
  }
6527
6405
  }
6528
6406
  });
6529
- return focusChild ? util_sliceBlocks.isSpan$1(snapshot.context, focusChild.node) ? {
6407
+ return focusChild ? util_sliceBlocks.isSpan(snapshot.context, focusChild.node) ? {
6530
6408
  selection: {
6531
6409
  anchor: {
6532
6410
  path: event.at,
@@ -6620,7 +6498,7 @@ const coreDndBehaviors = [
6620
6498
  }) => {
6621
6499
  if (event.placement !== "auto")
6622
6500
  return !1;
6623
- const focusTextBlock = selector_isSelectionExpanded.getFocusTextBlock(snapshot);
6501
+ const focusTextBlock = selector_getFocusSpan.getFocusTextBlock(snapshot);
6624
6502
  return focusTextBlock ? {
6625
6503
  focusTextBlock
6626
6504
  } : !1;
@@ -6635,7 +6513,7 @@ const coreDndBehaviors = [
6635
6513
  block: event.blocks[0],
6636
6514
  placement: "auto",
6637
6515
  select: event.select ?? "end"
6638
- })] : util_isEqualSelectionPoints.isEmptyTextBlock(snapshot.context, focusTextBlock.node) ? event.blocks.map((block, index) => behaviors_index.raise({
6516
+ })] : util_isSelectionCollapsed.isEmptyTextBlock(snapshot.context, focusTextBlock.node) ? event.blocks.map((block, index) => behaviors_index.raise({
6639
6517
  type: "insert.block",
6640
6518
  block,
6641
6519
  placement: index === 0 ? "auto" : "after",
@@ -6699,7 +6577,7 @@ const coreDndBehaviors = [
6699
6577
  guard: ({
6700
6578
  snapshot,
6701
6579
  event
6702
- }) => defaultKeyboardShortcuts.break.guard(event.originEvent) && selector_isSelectionExpanded.isSelectionCollapsed(snapshot) && selector_isSelectingEntireBlocks.getFocusInlineObject(snapshot),
6580
+ }) => defaultKeyboardShortcuts.break.guard(event.originEvent) && selector_getFocusSpan.isSelectionCollapsed(snapshot) && selector_isSelectingEntireBlocks.getFocusInlineObject(snapshot),
6703
6581
  actions: [() => [behaviors_index.raise({
6704
6582
  type: "insert.break"
6705
6583
  })]]
@@ -6878,7 +6756,7 @@ const coreDndBehaviors = [
6878
6756
  const previousBlock = selector_isSelectingEntireBlocks.getPreviousBlock(snapshot);
6879
6757
  if (!previousBlock)
6880
6758
  return !1;
6881
- const point = event.select === "end" ? util_isEqualSelectionPoints.getBlockEndPoint({
6759
+ const point = event.select === "end" ? util_isSelectionCollapsed.getBlockEndPoint({
6882
6760
  context: snapshot.context,
6883
6761
  block: previousBlock
6884
6762
  }) : util_sliceBlocks.getBlockStartPoint({
@@ -6907,7 +6785,7 @@ const coreDndBehaviors = [
6907
6785
  const nextBlock = selector_isSelectingEntireBlocks.getNextBlock(snapshot);
6908
6786
  if (!nextBlock)
6909
6787
  return !1;
6910
- const point = event.select === "end" ? util_isEqualSelectionPoints.getBlockEndPoint({
6788
+ const point = event.select === "end" ? util_isSelectionCollapsed.getBlockEndPoint({
6911
6789
  context: snapshot.context,
6912
6790
  block: nextBlock
6913
6791
  }) : util_sliceBlocks.getBlockStartPoint({
@@ -6935,7 +6813,7 @@ const coreDndBehaviors = [
6935
6813
  on: "split",
6936
6814
  guard: ({
6937
6815
  snapshot
6938
- }) => selector_isSelectionExpanded.isSelectionCollapsed(snapshot) && selector_isSelectingEntireBlocks.getFocusInlineObject(snapshot),
6816
+ }) => selector_getFocusSpan.isSelectionCollapsed(snapshot) && selector_isSelectingEntireBlocks.getFocusInlineObject(snapshot),
6939
6817
  actions: []
6940
6818
  }),
6941
6819
  /**
@@ -6945,7 +6823,7 @@ const coreDndBehaviors = [
6945
6823
  on: "split",
6946
6824
  guard: ({
6947
6825
  snapshot
6948
- }) => selector_isSelectionExpanded.isSelectionCollapsed(snapshot) && selector_isSelectingEntireBlocks.getFocusBlockObject(snapshot),
6826
+ }) => selector_getFocusSpan.isSelectionCollapsed(snapshot) && selector_isSelectingEntireBlocks.getFocusBlockObject(snapshot),
6949
6827
  actions: []
6950
6828
  }),
6951
6829
  behaviors_index.defineBehavior({
@@ -6954,7 +6832,7 @@ const coreDndBehaviors = [
6954
6832
  snapshot
6955
6833
  }) => {
6956
6834
  const selection = snapshot.context.selection;
6957
- if (!selection || util_sliceTextBlock.isSelectionCollapsed(selection))
6835
+ if (!selection || util_isSelectionCollapsed.isSelectionCollapsed(selection))
6958
6836
  return !1;
6959
6837
  const selectionStartBlock = selector_isSelectingEntireBlocks.getSelectionStartBlock(snapshot), selectionEndBlock = selector_isSelectingEntireBlocks.getSelectionEndBlock(snapshot);
6960
6838
  return !selectionStartBlock || !selectionEndBlock ? !1 : !util_sliceBlocks.isTextBlock(snapshot.context, selectionStartBlock.node) && util_sliceBlocks.isTextBlock(snapshot.context, selectionEndBlock.node) ? {
@@ -6974,7 +6852,7 @@ const coreDndBehaviors = [
6974
6852
  snapshot
6975
6853
  }) => {
6976
6854
  const selection = snapshot.context.selection;
6977
- return !selection || util_sliceTextBlock.isSelectionCollapsed(selection) ? !1 : {
6855
+ return !selection || util_isSelectionCollapsed.isSelectionCollapsed(selection) ? !1 : {
6978
6856
  selection
6979
6857
  };
6980
6858
  },
@@ -6993,12 +6871,12 @@ const coreDndBehaviors = [
6993
6871
  snapshot
6994
6872
  }) => {
6995
6873
  const selection = snapshot.context.selection;
6996
- if (!selection || !util_sliceTextBlock.isSelectionCollapsed(selection))
6874
+ if (!selection || !util_isSelectionCollapsed.isSelectionCollapsed(selection))
6997
6875
  return !1;
6998
- const selectionStartPoint = util_sliceBlocks.getSelectionStartPoint(selection), focusTextBlock = selector_isSelectionExpanded.getFocusTextBlock(snapshot);
6876
+ const selectionStartPoint = util_sliceBlocks.getSelectionStartPoint(selection), focusTextBlock = selector_getFocusSpan.getFocusTextBlock(snapshot);
6999
6877
  if (!focusTextBlock)
7000
6878
  return !1;
7001
- const blockEndPoint = util_isEqualSelectionPoints.getBlockEndPoint({
6879
+ const blockEndPoint = util_isSelectionCollapsed.getBlockEndPoint({
7002
6880
  context: snapshot.context,
7003
6881
  block: focusTextBlock
7004
6882
  }), newTextBlockSelection = {
@@ -7026,7 +6904,7 @@ const coreDndBehaviors = [
7026
6904
  actions: [(_, {
7027
6905
  newTextBlock,
7028
6906
  newTextBlockSelection
7029
- }) => util_sliceTextBlock.isSelectionCollapsed(newTextBlockSelection) ? [behaviors_index.raise({
6907
+ }) => util_isSelectionCollapsed.isSelectionCollapsed(newTextBlockSelection) ? [behaviors_index.raise({
7030
6908
  type: "insert.block",
7031
6909
  block: newTextBlock,
7032
6910
  placement: "after",
@@ -7163,7 +7041,7 @@ const coreDndBehaviors = [
7163
7041
  guard: ({
7164
7042
  snapshot
7165
7043
  }) => {
7166
- const focusSpan = selector_isSelectionExpanded.getFocusSpan(snapshot), selectionCollapsed = selector_isSelectionExpanded.isSelectionCollapsed(snapshot);
7044
+ const focusSpan = selector_getFocusSpan.getFocusSpan(snapshot), selectionCollapsed = selector_getFocusSpan.isSelectionCollapsed(snapshot);
7167
7045
  return focusSpan && selectionCollapsed;
7168
7046
  },
7169
7047
  actions: []
@@ -7182,7 +7060,7 @@ const coreDndBehaviors = [
7182
7060
  guard: ({
7183
7061
  snapshot
7184
7062
  }) => {
7185
- const focusSpan = selector_isSelectionExpanded.getFocusSpan(snapshot), selectionCollapsed = selector_isSelectionExpanded.isSelectionCollapsed(snapshot);
7063
+ const focusSpan = selector_getFocusSpan.getFocusSpan(snapshot), selectionCollapsed = selector_getFocusSpan.isSelectionCollapsed(snapshot);
7186
7064
  return focusSpan && selectionCollapsed;
7187
7065
  },
7188
7066
  actions: []
@@ -7248,8 +7126,8 @@ const coreDndBehaviors = [
7248
7126
  snapshot,
7249
7127
  event
7250
7128
  }) => {
7251
- if (selector_isSelectionExpanded.getFocusTextBlock(snapshot) && event.mimeType === "text/plain" && event.originEvent.type === "clipboard.paste") {
7252
- const activeDecorators = snapshot.beta.activeDecorators;
7129
+ if (selector_getFocusSpan.getFocusTextBlock(snapshot) && event.mimeType === "text/plain" && event.originEvent.type === "clipboard.paste") {
7130
+ const activeDecorators = selector_isSelectingEntireBlocks.getActiveDecorators(snapshot);
7253
7131
  return {
7254
7132
  activeAnnotations: selector_isSelectingEntireBlocks.getActiveAnnotations(snapshot),
7255
7133
  activeDecorators,
@@ -7315,7 +7193,7 @@ const coreDndBehaviors = [
7315
7193
  on: "clipboard.paste",
7316
7194
  guard: ({
7317
7195
  snapshot
7318
- }) => snapshot.context.selection && selector_isSelectionExpanded.isSelectionExpanded(snapshot) ? {
7196
+ }) => snapshot.context.selection && selector_getFocusSpan.isSelectionExpanded(snapshot) ? {
7319
7197
  selection: snapshot.context.selection
7320
7198
  } : !1,
7321
7199
  actions: [({
@@ -7625,17 +7503,7 @@ function createEditorSnapshot({
7625
7503
  return {
7626
7504
  blockIndexMap: editor.blockIndexMap,
7627
7505
  context,
7628
- beta: {
7629
- activeAnnotations: getActiveAnnotations({
7630
- markState: editor.markState,
7631
- schema: schema2
7632
- }),
7633
- activeDecorators: getActiveDecorators({
7634
- decoratorState: editor.decoratorState,
7635
- markState: editor.markState,
7636
- schema: schema2
7637
- })
7638
- }
7506
+ decoratorState: editor.decoratorState
7639
7507
  };
7640
7508
  }
7641
7509
  const debug$7 = debugWithName("editor machine"), editorMachine = xstate.setup({
@@ -8601,16 +8469,19 @@ function createEditableAPI(editor, editorActor) {
8601
8469
  editor
8602
8470
  });
8603
8471
  },
8604
- isMarkActive: (mark) => getEditorSnapshot({
8605
- editorActorSnapshot: editorActor.getSnapshot(),
8606
- slateEditorInstance: editor
8607
- }).beta.activeDecorators.includes(mark),
8608
- marks: () => {
8472
+ isMarkActive: (mark) => {
8609
8473
  const snapshot = getEditorSnapshot({
8610
8474
  editorActorSnapshot: editorActor.getSnapshot(),
8611
8475
  slateEditorInstance: editor
8612
8476
  });
8613
- return [...snapshot.beta.activeAnnotations, ...snapshot.beta.activeDecorators];
8477
+ return selector_isSelectingEntireBlocks.getActiveDecorators(snapshot).includes(mark);
8478
+ },
8479
+ marks: () => {
8480
+ const snapshot = getEditorSnapshot({
8481
+ editorActorSnapshot: editorActor.getSnapshot(),
8482
+ slateEditorInstance: editor
8483
+ }), activeAnnotations = selector_isSelectingEntireBlocks.getActiveAnnotationsMarks(snapshot), activeDecorators = selector_isSelectingEntireBlocks.getActiveDecorators(snapshot);
8484
+ return [...activeAnnotations, ...activeDecorators];
8614
8485
  },
8615
8486
  undo: () => {
8616
8487
  editorActor.send({