@portabletext/editor 1.48.13 → 1.48.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 (67) hide show
  1. package/lib/_chunks-cjs/editor-provider.cjs +633 -628
  2. package/lib/_chunks-cjs/editor-provider.cjs.map +1 -1
  3. package/lib/_chunks-es/editor-provider.js +634 -629
  4. package/lib/_chunks-es/editor-provider.js.map +1 -1
  5. package/lib/behaviors/index.cjs.map +1 -1
  6. package/lib/behaviors/index.d.cts +4 -2564
  7. package/lib/behaviors/index.d.ts +4 -2564
  8. package/lib/behaviors/index.js.map +1 -1
  9. package/lib/index.d.cts +5 -2564
  10. package/lib/index.d.ts +5 -2564
  11. package/lib/plugins/index.cjs +1 -7
  12. package/lib/plugins/index.cjs.map +1 -1
  13. package/lib/plugins/index.d.cts +4 -2569
  14. package/lib/plugins/index.d.ts +4 -2569
  15. package/lib/plugins/index.js +2 -8
  16. package/lib/plugins/index.js.map +1 -1
  17. package/lib/selectors/index.d.cts +3 -2563
  18. package/lib/selectors/index.d.ts +3 -2563
  19. package/lib/utils/index.d.cts +5 -2564
  20. package/lib/utils/index.d.ts +5 -2564
  21. package/package.json +1 -1
  22. package/src/behaviors/behavior.abstract.keyboard.ts +16 -0
  23. package/src/behaviors/{behavior.default.ts → behavior.abstract.ts} +3 -3
  24. package/src/behaviors/behavior.core.ts +0 -3
  25. package/src/behaviors/behavior.perform-event.ts +27 -51
  26. package/src/behaviors/behavior.types.action.ts +1 -11
  27. package/src/editor/PortableTextEditor.tsx +1 -1
  28. package/src/editor/editor-machine.ts +7 -4
  29. package/src/editor/mutation-machine.ts +6 -6
  30. package/src/editor/plugins/create-with-event-listeners.ts +25 -25
  31. package/src/editor/plugins/createWithEditableAPI.ts +3 -3
  32. package/src/editor/plugins/createWithPatches.ts +13 -5
  33. package/src/editor/plugins/createWithPortableTextMarkModel.ts +5 -5
  34. package/src/editor/plugins/createWithUndoRedo.ts +8 -8
  35. package/src/editor/with-applying-behavior-operations.ts +18 -0
  36. package/src/editor/{with-applying-behavior-actions.ts → with-undo-step.ts} +1 -19
  37. package/src/index.ts +1 -1
  38. package/src/{behavior-actions/behavior.action.annotation.add.ts → operations/behavior.operation.annotation.add.ts} +7 -7
  39. package/src/{behavior-actions/behavior.action.annotation.remove.ts → operations/behavior.operation.annotation.remove.ts} +6 -6
  40. package/src/{behavior-actions/behavior.action.block.set.ts → operations/behavior.operation.block.set.ts} +14 -14
  41. package/src/{behavior-actions/behavior.action.block.unset.ts → operations/behavior.operation.block.unset.ts} +19 -17
  42. package/src/{behavior-actions/behavior.action.decorator.add.ts → operations/behavior.operation.decorator.add.ts} +10 -10
  43. package/src/operations/behavior.operation.delete.backward.ts +8 -0
  44. package/src/operations/behavior.operation.delete.block.ts +24 -0
  45. package/src/operations/behavior.operation.delete.forward.ts +8 -0
  46. package/src/{behavior-actions/behavior.action.delete.ts → operations/behavior.operation.delete.ts} +8 -8
  47. package/src/{behavior-actions/behavior.action.insert-inline-object.ts → operations/behavior.operation.insert-inline-object.ts} +11 -11
  48. package/src/{behavior-actions/behavior.action.insert-span.ts → operations/behavior.operation.insert-span.ts} +15 -15
  49. package/src/{behavior-actions/behavior.action.insert.block.ts → operations/behavior.operation.insert.block.ts} +8 -8
  50. package/src/operations/behavior.operation.insert.text.ts +17 -0
  51. package/src/operations/behavior.operation.move.backward.ts +12 -0
  52. package/src/operations/behavior.operation.move.block.ts +16 -0
  53. package/src/operations/behavior.operation.move.forward.ts +11 -0
  54. package/src/operations/behavior.operation.select.ts +15 -0
  55. package/src/operations/behavior.operations.ts +239 -0
  56. package/src/plugins/index.ts +0 -1
  57. package/src/behavior-actions/behavior.action.delete.backward.ts +0 -7
  58. package/src/behavior-actions/behavior.action.delete.block.ts +0 -24
  59. package/src/behavior-actions/behavior.action.delete.forward.ts +0 -7
  60. package/src/behavior-actions/behavior.action.insert.text.ts +0 -17
  61. package/src/behavior-actions/behavior.action.move.backward.ts +0 -12
  62. package/src/behavior-actions/behavior.action.move.block.ts +0 -16
  63. package/src/behavior-actions/behavior.action.move.forward.ts +0 -11
  64. package/src/behavior-actions/behavior.action.select.ts +0 -15
  65. package/src/behavior-actions/behavior.actions.ts +0 -219
  66. package/src/behaviors/behavior.default.raise-soft-break.ts +0 -14
  67. package/src/plugins/plugin.core.tsx +0 -9
@@ -5,7 +5,7 @@ import { withReact, ReactEditor, Slate } from "slate-react";
5
5
  import { c } from "react-compiler-runtime";
6
6
  import debug$f from "debug";
7
7
  import isEqual from "lodash/isEqual.js";
8
- import { Element, Text, Editor, Path, Operation, Transforms, Node, Range, Point, createEditor } from "slate";
8
+ import { Element, Text, Editor, Path, Operation, Transforms, Range, Node, Point, deleteBackward, deleteForward, createEditor } from "slate";
9
9
  import { setup, stateIn, fromCallback, assign, enqueueActions, emit, assertEvent, and, not, createActor } from "xstate";
10
10
  import { unset, set, setIfMissing, insert, diffMatchPatch as diffMatchPatch$1, applyAll } from "@portabletext/patches";
11
11
  import flatten from "lodash/flatten.js";
@@ -173,18 +173,18 @@ const IS_PROCESSING_REMOTE_CHANGES = /* @__PURE__ */ new WeakMap(), KEY_TO_SLATE
173
173
  }) => {
174
174
  if (assertEvent(event, "patch"), context.pendingMutations.length === 0)
175
175
  return [{
176
- actionId: event.actionId,
176
+ operationId: event.operationId,
177
177
  value: event.value,
178
178
  patches: [event.patch]
179
179
  }];
180
180
  const lastBulk = context.pendingMutations.at(-1);
181
- return lastBulk && lastBulk.actionId === event.actionId ? context.pendingMutations.slice(0, -1).concat({
181
+ return lastBulk && lastBulk.operationId === event.operationId ? context.pendingMutations.slice(0, -1).concat({
182
182
  value: event.value,
183
- actionId: lastBulk.actionId,
183
+ operationId: lastBulk.operationId,
184
184
  patches: [...lastBulk.patches, event.patch]
185
185
  }) : context.pendingMutations.concat({
186
186
  value: event.value,
187
- actionId: event.actionId,
187
+ operationId: event.operationId,
188
188
  patches: [event.patch]
189
189
  });
190
190
  }
@@ -1325,16 +1325,6 @@ function randomKey(length) {
1325
1325
  const table = getByteHexTable();
1326
1326
  return whatwgRNG(length).reduce((str, n) => str + table[n], "").slice(0, length);
1327
1327
  }
1328
- const CURRENT_ACTION_ID = /* @__PURE__ */ new WeakMap();
1329
- function withApplyingBehaviorActions(editor, fn) {
1330
- CURRENT_ACTION_ID.set(editor, defaultKeyGenerator()), Editor.withoutNormalizing(editor, fn), CURRENT_ACTION_ID.set(editor, void 0);
1331
- }
1332
- function getCurrentActionId(editor) {
1333
- return CURRENT_ACTION_ID.get(editor);
1334
- }
1335
- function isApplyingBehaviorActions(editor) {
1336
- return getCurrentActionId(editor) !== void 0;
1337
- }
1338
1328
  const CURRENT_UNDO_STEP = /* @__PURE__ */ new WeakMap();
1339
1329
  function withUndoStep(editor, fn) {
1340
1330
  const current = CURRENT_UNDO_STEP.get(editor);
@@ -1436,10 +1426,10 @@ function createWithUndoRedo(options) {
1436
1426
  }, editor;
1437
1427
  };
1438
1428
  }
1439
- const historyUndoActionImplementation = ({
1440
- action
1429
+ const historyUndoOperationImplementation = ({
1430
+ operation
1441
1431
  }) => {
1442
- const editor = action.editor, {
1432
+ const editor = operation.editor, {
1443
1433
  undos
1444
1434
  } = editor.history, remotePatches = getRemotePatches(editor);
1445
1435
  if (undos.length > 0) {
@@ -1471,10 +1461,10 @@ const historyUndoActionImplementation = ({
1471
1461
  editor.history.redos.push(step), editor.history.undos.pop();
1472
1462
  }
1473
1463
  }
1474
- }, historyRedoActionImplementation = ({
1475
- action
1464
+ }, historyRedoOperationImplementation = ({
1465
+ operation
1476
1466
  }) => {
1477
- const editor = action.editor, {
1467
+ const editor = operation.editor, {
1478
1468
  redos
1479
1469
  } = editor.history, remotePatches = getRemotePatches(editor);
1480
1470
  if (redos.length > 0) {
@@ -2650,13 +2640,214 @@ function createOperationToPatches(editorActor) {
2650
2640
  splitNodePatch
2651
2641
  };
2652
2642
  }
2653
- const insertTextActionImplementation = ({
2654
- action
2643
+ function getFocusBlock({
2644
+ editor
2645
+ }) {
2646
+ if (!editor.selection)
2647
+ return [void 0, void 0];
2648
+ try {
2649
+ return Editor.node(editor, editor.selection.focus.path.slice(0, 1)) ?? [void 0, void 0];
2650
+ } catch {
2651
+ return [void 0, void 0];
2652
+ }
2653
+ }
2654
+ function getSelectionStartBlock({
2655
+ editor
2656
+ }) {
2657
+ if (!editor.selection)
2658
+ return [void 0, void 0];
2659
+ const selectionStartPoint = Range.start(editor.selection);
2660
+ return getPointBlock({
2661
+ editor,
2662
+ point: selectionStartPoint
2663
+ });
2664
+ }
2665
+ function getSelectionEndBlock({
2666
+ editor
2667
+ }) {
2668
+ if (!editor.selection)
2669
+ return [void 0, void 0];
2670
+ const selectionEndPoint = Range.end(editor.selection);
2671
+ return getPointBlock({
2672
+ editor,
2673
+ point: selectionEndPoint
2674
+ });
2675
+ }
2676
+ function getPointBlock({
2677
+ editor,
2678
+ point
2679
+ }) {
2680
+ try {
2681
+ const [block] = Editor.node(editor, point.path.slice(0, 1)) ?? [void 0, void 0];
2682
+ return block ? [block, point.path.slice(0, 1)] : [void 0, void 0];
2683
+ } catch {
2684
+ return [void 0, void 0];
2685
+ }
2686
+ }
2687
+ function getFocusChild({
2688
+ editor
2689
+ }) {
2690
+ const [focusBlock, focusBlockPath] = getFocusBlock({
2691
+ editor
2692
+ }), childIndex = editor.selection?.focus.path.at(1);
2693
+ if (!focusBlock || !focusBlockPath || childIndex === void 0)
2694
+ return [void 0, void 0];
2695
+ try {
2696
+ const focusChild = Node.child(focusBlock, childIndex);
2697
+ return focusChild ? [focusChild, [...focusBlockPath, childIndex]] : [void 0, void 0];
2698
+ } catch {
2699
+ return [void 0, void 0];
2700
+ }
2701
+ }
2702
+ function getPointChild({
2703
+ editor,
2704
+ point
2705
+ }) {
2706
+ const [block, blockPath] = getPointBlock({
2707
+ editor,
2708
+ point
2709
+ }), childIndex = point.path.at(1);
2710
+ if (!block || !blockPath || childIndex === void 0)
2711
+ return [void 0, void 0];
2712
+ try {
2713
+ const pointChild = Node.child(block, childIndex);
2714
+ return pointChild ? [pointChild, [...blockPath, childIndex]] : [void 0, void 0];
2715
+ } catch {
2716
+ return [void 0, void 0];
2717
+ }
2718
+ }
2719
+ function getFirstBlock({
2720
+ editor
2721
+ }) {
2722
+ const firstBlockPath = Editor.start(editor, []).path.at(0);
2723
+ try {
2724
+ return firstBlockPath !== void 0 ? Editor.node(editor, [firstBlockPath]) ?? [void 0, void 0] : [void 0, void 0];
2725
+ } catch {
2726
+ return [void 0, void 0];
2727
+ }
2728
+ }
2729
+ function getLastBlock({
2730
+ editor
2731
+ }) {
2732
+ const lastBlockPath = Editor.end(editor, []).path.at(0);
2733
+ try {
2734
+ return lastBlockPath !== void 0 ? Editor.node(editor, [lastBlockPath]) ?? [void 0, void 0] : [void 0, void 0];
2735
+ } catch {
2736
+ return [void 0, void 0];
2737
+ }
2738
+ }
2739
+ function getNodeBlock({
2740
+ editor,
2741
+ schema,
2742
+ node
2743
+ }) {
2744
+ if (Editor.isEditor(node))
2745
+ return;
2746
+ if (isBlockElement({
2747
+ editor,
2748
+ schema
2749
+ }, node))
2750
+ return elementToBlock({
2751
+ schema,
2752
+ element: node
2753
+ });
2754
+ const parent = Array.from(Editor.nodes(editor, {
2755
+ mode: "highest",
2756
+ at: [],
2757
+ match: (n) => isBlockElement({
2758
+ editor,
2759
+ schema
2760
+ }, n) && n.children.some((child) => child._key === node._key)
2761
+ })).at(0)?.at(0);
2762
+ return Element.isElement(parent) ? elementToBlock({
2763
+ schema,
2764
+ element: parent
2765
+ }) : void 0;
2766
+ }
2767
+ function elementToBlock({
2768
+ schema,
2769
+ element
2770
+ }) {
2771
+ return fromSlateValue([element], schema.block.name)?.at(0);
2772
+ }
2773
+ function isBlockElement({
2774
+ editor,
2775
+ schema
2776
+ }, node) {
2777
+ return Element.isElement(node) && !editor.isInline(node) && (schema.block.name === node._type || schema.blockObjects.some((blockObject) => blockObject.name === node._type));
2778
+ }
2779
+ function isListItemActive({
2780
+ editor,
2781
+ listItem
2782
+ }) {
2783
+ if (!editor.selection)
2784
+ return !1;
2785
+ const selectedBlocks = [...Editor.nodes(editor, {
2786
+ at: editor.selection,
2787
+ match: (node) => editor.isTextBlock(node)
2788
+ })];
2789
+ return selectedBlocks.length > 0 ? selectedBlocks.every(([node]) => editor.isListBlock(node) && node.listItem === listItem) : !1;
2790
+ }
2791
+ function isStyleActive({
2792
+ editor,
2793
+ style
2794
+ }) {
2795
+ if (!editor.selection)
2796
+ return !1;
2797
+ const selectedBlocks = [...Editor.nodes(editor, {
2798
+ at: editor.selection,
2799
+ match: (node) => editor.isTextBlock(node)
2800
+ })];
2801
+ return selectedBlocks.length > 0 ? selectedBlocks.every(([node]) => node.style === style) : !1;
2802
+ }
2803
+ function slateRangeToSelection({
2804
+ schema,
2805
+ editor,
2806
+ range
2807
+ }) {
2808
+ const [anchorBlock] = getPointBlock({
2809
+ editor,
2810
+ point: range.anchor
2811
+ }), [focusBlock] = getPointBlock({
2812
+ editor,
2813
+ point: range.focus
2814
+ });
2815
+ if (!anchorBlock || !focusBlock)
2816
+ return null;
2817
+ const [anchorChild] = anchorBlock._type === schema.block.name ? getPointChild({
2818
+ editor,
2819
+ point: range.anchor
2820
+ }) : [void 0, void 0], [focusChild] = focusBlock._type === schema.block.name ? getPointChild({
2821
+ editor,
2822
+ point: range.focus
2823
+ }) : [void 0, void 0], selection = {
2824
+ anchor: {
2825
+ path: [{
2826
+ _key: anchorBlock._key
2827
+ }],
2828
+ offset: range.anchor.offset
2829
+ },
2830
+ focus: {
2831
+ path: [{
2832
+ _key: focusBlock._key
2833
+ }],
2834
+ offset: range.focus.offset
2835
+ },
2836
+ backward: Range.isBackward(range)
2837
+ };
2838
+ return anchorChild && (selection.anchor.path.push("children"), selection.anchor.path.push({
2839
+ _key: anchorChild._key
2840
+ })), focusChild && (selection.focus.path.push("children"), selection.focus.path.push({
2841
+ _key: focusChild._key
2842
+ })), selection;
2843
+ }
2844
+ const insertTextOperationImplementation = ({
2845
+ operation
2655
2846
  }) => {
2656
- action.editor.marks ? Transforms.insertNodes(action.editor, {
2657
- text: action.text,
2658
- ...action.editor.marks
2659
- }) : Transforms.insertText(action.editor, action.text), action.editor.marks = null;
2847
+ operation.editor.marks ? Transforms.insertNodes(operation.editor, {
2848
+ text: operation.text,
2849
+ ...operation.editor.marks
2850
+ }) : Transforms.insertText(operation.editor, operation.text), operation.editor.marks = null;
2660
2851
  };
2661
2852
  function isPortableTextSpan(node) {
2662
2853
  return node._type === "span" && "text" in node && typeof node.text == "string" && (typeof node.marks > "u" || Array.isArray(node.marks) && node.marks.every((mark) => typeof mark == "string"));
@@ -3056,10 +3247,10 @@ function createWithPortableTextMarkModel(editorActor) {
3056
3247
  }, editor;
3057
3248
  };
3058
3249
  }
3059
- const removeDecoratorActionImplementation = ({
3060
- action
3250
+ const removeDecoratorOperationImplementation = ({
3251
+ operation
3061
3252
  }) => {
3062
- const editor = action.editor, mark = action.decorator, {
3253
+ const editor = operation.editor, mark = operation.decorator, {
3063
3254
  selection
3064
3255
  } = editor;
3065
3256
  if (selection) {
@@ -3130,14 +3321,14 @@ function isDecoratorActive({
3130
3321
  ...Editor.marks(editor) || {}
3131
3322
  }.marks || []).includes(decorator);
3132
3323
  }
3133
- const addAnnotationActionImplementation = ({
3324
+ const addAnnotationOperationImplementation = ({
3134
3325
  context,
3135
- action
3326
+ operation
3136
3327
  }) => {
3137
3328
  const parsedAnnotation = parseAnnotation({
3138
3329
  annotation: {
3139
- _type: action.annotation.name,
3140
- ...action.annotation.value
3330
+ _type: operation.annotation.name,
3331
+ ...operation.annotation.value
3141
3332
  },
3142
3333
  context,
3143
3334
  options: {
@@ -3145,8 +3336,8 @@ const addAnnotationActionImplementation = ({
3145
3336
  }
3146
3337
  });
3147
3338
  if (!parsedAnnotation)
3148
- throw new Error(`Failed to parse annotation ${JSON.stringify(action.annotation)}`);
3149
- const editor = action.editor;
3339
+ throw new Error(`Failed to parse annotation ${JSON.stringify(operation.annotation)}`);
3340
+ const editor = operation.editor;
3150
3341
  if (!editor.selection || Range.isCollapsed(editor.selection))
3151
3342
  return;
3152
3343
  let paths, spanPath, markDefPath;
@@ -3197,10 +3388,10 @@ const addAnnotationActionImplementation = ({
3197
3388
  markDefPaths,
3198
3389
  spanPath
3199
3390
  }), paths;
3200
- }, removeAnnotationActionImplementation = ({
3201
- action
3391
+ }, removeAnnotationOperationImplementation = ({
3392
+ operation
3202
3393
  }) => {
3203
- const editor = action.editor;
3394
+ const editor = operation.editor;
3204
3395
  if (editor.selection)
3205
3396
  if (Range.isCollapsed(editor.selection)) {
3206
3397
  const [block, blockPath] = Editor.node(editor, editor.selection, {
@@ -3208,7 +3399,7 @@ const addAnnotationActionImplementation = ({
3208
3399
  });
3209
3400
  if (!editor.isTextBlock(block))
3210
3401
  return;
3211
- const potentialAnnotations = (block.markDefs ?? []).filter((markDef) => markDef._type === action.annotation.name), [selectedChild, selectedChildPath] = Editor.node(editor, editor.selection, {
3402
+ const potentialAnnotations = (block.markDefs ?? []).filter((markDef) => markDef._type === operation.annotation.name), [selectedChild, selectedChildPath] = Editor.node(editor, editor.selection, {
3212
3403
  depth: 2
3213
3404
  });
3214
3405
  if (!editor.isTextSpan(selectedChild))
@@ -3253,7 +3444,7 @@ const addAnnotationActionImplementation = ({
3253
3444
  for (const [child, childPath] of children) {
3254
3445
  if (!editor.isTextSpan(child) || !Range.includes(editor.selection, childPath))
3255
3446
  continue;
3256
- const markDefs = block.markDefs ?? [], marks = child.marks ?? [], marksWithoutAnnotation = marks.filter((mark) => markDefs.find((markDef2) => markDef2._key === mark)?._type !== action.annotation.name);
3447
+ const markDefs = block.markDefs ?? [], marks = child.marks ?? [], marksWithoutAnnotation = marks.filter((mark) => markDefs.find((markDef2) => markDef2._key === mark)?._type !== operation.annotation.name);
3257
3448
  marksWithoutAnnotation.length !== marks.length && Transforms.setNodes(editor, {
3258
3449
  marks: marksWithoutAnnotation
3259
3450
  }, {
@@ -3305,34 +3496,34 @@ function moveRangeByOperation(range, operation) {
3305
3496
  focus
3306
3497
  };
3307
3498
  }
3308
- const blockSetBehaviorActionImplementation = ({
3499
+ const blockSetOperationImplementation = ({
3309
3500
  context,
3310
- action
3501
+ operation
3311
3502
  }) => {
3312
3503
  const location = toSlateRange({
3313
3504
  anchor: {
3314
- path: action.at,
3505
+ path: operation.at,
3315
3506
  offset: 0
3316
3507
  },
3317
3508
  focus: {
3318
- path: action.at,
3509
+ path: operation.at,
3319
3510
  offset: 0
3320
3511
  }
3321
- }, action.editor);
3512
+ }, operation.editor);
3322
3513
  if (!location)
3323
- throw new Error(`Unable to convert ${JSON.stringify(action.at)} into a Slate Range`);
3324
- const block = Editor.node(action.editor, location, {
3514
+ throw new Error(`Unable to convert ${JSON.stringify(operation.at)} into a Slate Range`);
3515
+ const block = Editor.node(operation.editor, location, {
3325
3516
  depth: 1
3326
3517
  })?.[0];
3327
3518
  if (!block)
3328
- throw new Error(`Unable to find block at ${JSON.stringify(action.at)}`);
3329
- const parsedBlock = fromSlateValue([block], context.schema.block.name, KEY_TO_VALUE_ELEMENT.get(action.editor)).at(0);
3519
+ throw new Error(`Unable to find block at ${JSON.stringify(operation.at)}`);
3520
+ const parsedBlock = fromSlateValue([block], context.schema.block.name, KEY_TO_VALUE_ELEMENT.get(operation.editor)).at(0);
3330
3521
  if (!parsedBlock)
3331
- throw new Error(`Unable to parse block at ${JSON.stringify(action.at)}`);
3522
+ throw new Error(`Unable to parse block at ${JSON.stringify(operation.at)}`);
3332
3523
  const {
3333
3524
  _type,
3334
3525
  ...filteredProps
3335
- } = action.props, updatedBlock = parseBlock({
3526
+ } = operation.props, updatedBlock = parseBlock({
3336
3527
  context,
3337
3528
  block: {
3338
3529
  ...parsedBlock,
@@ -3343,302 +3534,100 @@ const blockSetBehaviorActionImplementation = ({
3343
3534
  }
3344
3535
  });
3345
3536
  if (!updatedBlock)
3346
- throw new Error(`Unable to update block at ${JSON.stringify(action.at)}`);
3537
+ throw new Error(`Unable to update block at ${JSON.stringify(operation.at)}`);
3347
3538
  const slateBlock = toSlateValue([updatedBlock], {
3348
3539
  schemaTypes: context.schema
3349
3540
  })?.at(0);
3350
3541
  if (!slateBlock)
3351
3542
  throw new Error("Unable to convert block to Slate value");
3352
- Transforms.setNodes(action.editor, slateBlock, {
3543
+ Transforms.setNodes(operation.editor, slateBlock, {
3353
3544
  at: location
3354
3545
  });
3355
- }, blockUnsetBehaviorActionImplementation = ({
3546
+ }, blockUnsetOperationImplementation = ({
3356
3547
  context,
3357
- action
3548
+ operation
3358
3549
  }) => {
3359
- const location = toSlateRange({
3360
- anchor: {
3361
- path: action.at,
3362
- offset: 0
3363
- },
3364
- focus: {
3365
- path: action.at,
3366
- offset: 0
3367
- }
3368
- }, action.editor);
3369
- if (!location)
3370
- throw new Error(`Unable to convert ${JSON.stringify(action.at)} into a Slate Range`);
3371
- const block = Editor.node(action.editor, location, {
3372
- depth: 1
3373
- })?.[0];
3374
- if (!block)
3375
- throw new Error(`Unable to find block at ${JSON.stringify(action.at)}`);
3376
- const parsedBlock = fromSlateValue([block], context.schema.block.name, KEY_TO_VALUE_ELEMENT.get(action.editor)).at(0);
3377
- if (!parsedBlock)
3378
- throw new Error(`Unable to parse block at ${JSON.stringify(action.at)}`);
3379
- if (isTextBlock(context, parsedBlock)) {
3380
- const propsToRemove = action.props.filter((prop) => prop !== "_type"), updatedTextBlock = parseBlock({
3381
- context,
3382
- block: omit(parsedBlock, propsToRemove),
3383
- options: {
3384
- refreshKeys: !1
3385
- }
3386
- });
3387
- if (!updatedTextBlock)
3388
- throw new Error(`Unable to update block at ${JSON.stringify(action.at)}`);
3389
- const propsToSet = {};
3390
- for (const prop of propsToRemove)
3391
- prop in updatedTextBlock ? propsToSet[prop] = updatedTextBlock[prop] : propsToSet[prop] = void 0;
3392
- Transforms.setNodes(action.editor, propsToSet, {
3393
- at: location
3394
- });
3395
- return;
3396
- }
3397
- const updatedBlockObject = parseBlock({
3398
- context,
3399
- block: omit(parsedBlock, action.props.filter((prop) => prop !== "_type")),
3400
- options: {
3401
- refreshKeys: !1
3402
- }
3403
- });
3404
- if (!updatedBlockObject)
3405
- throw new Error(`Unable to update block at ${JSON.stringify(action.at)}`);
3406
- const {
3407
- _type,
3408
- _key,
3409
- ...props
3410
- } = updatedBlockObject;
3411
- Transforms.setNodes(action.editor, {
3412
- _type,
3413
- _key,
3414
- value: props
3415
- }, {
3416
- at: location
3417
- });
3418
- };
3419
- function getFocusBlock({
3420
- editor
3421
- }) {
3422
- if (!editor.selection)
3423
- return [void 0, void 0];
3424
- try {
3425
- return Editor.node(editor, editor.selection.focus.path.slice(0, 1)) ?? [void 0, void 0];
3426
- } catch {
3427
- return [void 0, void 0];
3428
- }
3429
- }
3430
- function getSelectionStartBlock({
3431
- editor
3432
- }) {
3433
- if (!editor.selection)
3434
- return [void 0, void 0];
3435
- const selectionStartPoint = Range.start(editor.selection);
3436
- return getPointBlock({
3437
- editor,
3438
- point: selectionStartPoint
3439
- });
3440
- }
3441
- function getSelectionEndBlock({
3442
- editor
3443
- }) {
3444
- if (!editor.selection)
3445
- return [void 0, void 0];
3446
- const selectionEndPoint = Range.end(editor.selection);
3447
- return getPointBlock({
3448
- editor,
3449
- point: selectionEndPoint
3450
- });
3451
- }
3452
- function getPointBlock({
3453
- editor,
3454
- point
3455
- }) {
3456
- try {
3457
- const [block] = Editor.node(editor, point.path.slice(0, 1)) ?? [void 0, void 0];
3458
- return block ? [block, point.path.slice(0, 1)] : [void 0, void 0];
3459
- } catch {
3460
- return [void 0, void 0];
3461
- }
3462
- }
3463
- function getFocusChild({
3464
- editor
3465
- }) {
3466
- const [focusBlock, focusBlockPath] = getFocusBlock({
3467
- editor
3468
- }), childIndex = editor.selection?.focus.path.at(1);
3469
- if (!focusBlock || !focusBlockPath || childIndex === void 0)
3470
- return [void 0, void 0];
3471
- try {
3472
- const focusChild = Node.child(focusBlock, childIndex);
3473
- return focusChild ? [focusChild, [...focusBlockPath, childIndex]] : [void 0, void 0];
3474
- } catch {
3475
- return [void 0, void 0];
3476
- }
3477
- }
3478
- function getPointChild({
3479
- editor,
3480
- point
3481
- }) {
3482
- const [block, blockPath] = getPointBlock({
3483
- editor,
3484
- point
3485
- }), childIndex = point.path.at(1);
3486
- if (!block || !blockPath || childIndex === void 0)
3487
- return [void 0, void 0];
3488
- try {
3489
- const pointChild = Node.child(block, childIndex);
3490
- return pointChild ? [pointChild, [...blockPath, childIndex]] : [void 0, void 0];
3491
- } catch {
3492
- return [void 0, void 0];
3493
- }
3494
- }
3495
- function getFirstBlock({
3496
- editor
3497
- }) {
3498
- const firstBlockPath = Editor.start(editor, []).path.at(0);
3499
- try {
3500
- return firstBlockPath !== void 0 ? Editor.node(editor, [firstBlockPath]) ?? [void 0, void 0] : [void 0, void 0];
3501
- } catch {
3502
- return [void 0, void 0];
3503
- }
3504
- }
3505
- function getLastBlock({
3506
- editor
3507
- }) {
3508
- const lastBlockPath = Editor.end(editor, []).path.at(0);
3509
- try {
3510
- return lastBlockPath !== void 0 ? Editor.node(editor, [lastBlockPath]) ?? [void 0, void 0] : [void 0, void 0];
3511
- } catch {
3512
- return [void 0, void 0];
3513
- }
3514
- }
3515
- function getNodeBlock({
3516
- editor,
3517
- schema,
3518
- node
3519
- }) {
3520
- if (Editor.isEditor(node))
3521
- return;
3522
- if (isBlockElement({
3523
- editor,
3524
- schema
3525
- }, node))
3526
- return elementToBlock({
3527
- schema,
3528
- element: node
3529
- });
3530
- const parent = Array.from(Editor.nodes(editor, {
3531
- mode: "highest",
3532
- at: [],
3533
- match: (n) => isBlockElement({
3534
- editor,
3535
- schema
3536
- }, n) && n.children.some((child) => child._key === node._key)
3537
- })).at(0)?.at(0);
3538
- return Element.isElement(parent) ? elementToBlock({
3539
- schema,
3540
- element: parent
3541
- }) : void 0;
3542
- }
3543
- function elementToBlock({
3544
- schema,
3545
- element
3546
- }) {
3547
- return fromSlateValue([element], schema.block.name)?.at(0);
3548
- }
3549
- function isBlockElement({
3550
- editor,
3551
- schema
3552
- }, node) {
3553
- return Element.isElement(node) && !editor.isInline(node) && (schema.block.name === node._type || schema.blockObjects.some((blockObject) => blockObject.name === node._type));
3554
- }
3555
- function isListItemActive({
3556
- editor,
3557
- listItem
3558
- }) {
3559
- if (!editor.selection)
3560
- return !1;
3561
- const selectedBlocks = [...Editor.nodes(editor, {
3562
- at: editor.selection,
3563
- match: (node) => editor.isTextBlock(node)
3564
- })];
3565
- return selectedBlocks.length > 0 ? selectedBlocks.every(([node]) => editor.isListBlock(node) && node.listItem === listItem) : !1;
3566
- }
3567
- function isStyleActive({
3568
- editor,
3569
- style
3570
- }) {
3571
- if (!editor.selection)
3572
- return !1;
3573
- const selectedBlocks = [...Editor.nodes(editor, {
3574
- at: editor.selection,
3575
- match: (node) => editor.isTextBlock(node)
3576
- })];
3577
- return selectedBlocks.length > 0 ? selectedBlocks.every(([node]) => node.style === style) : !1;
3578
- }
3579
- function slateRangeToSelection({
3580
- schema,
3581
- editor,
3582
- range
3583
- }) {
3584
- const [anchorBlock] = getPointBlock({
3585
- editor,
3586
- point: range.anchor
3587
- }), [focusBlock] = getPointBlock({
3588
- editor,
3589
- point: range.focus
3590
- });
3591
- if (!anchorBlock || !focusBlock)
3592
- return null;
3593
- const [anchorChild] = anchorBlock._type === schema.block.name ? getPointChild({
3594
- editor,
3595
- point: range.anchor
3596
- }) : [void 0, void 0], [focusChild] = focusBlock._type === schema.block.name ? getPointChild({
3597
- editor,
3598
- point: range.focus
3599
- }) : [void 0, void 0], selection = {
3600
- anchor: {
3601
- path: [{
3602
- _key: anchorBlock._key
3603
- }],
3604
- offset: range.anchor.offset
3550
+ const location = toSlateRange({
3551
+ anchor: {
3552
+ path: operation.at,
3553
+ offset: 0
3605
3554
  },
3606
3555
  focus: {
3607
- path: [{
3608
- _key: focusBlock._key
3609
- }],
3610
- offset: range.focus.offset
3611
- },
3612
- backward: Range.isBackward(range)
3613
- };
3614
- return anchorChild && (selection.anchor.path.push("children"), selection.anchor.path.push({
3615
- _key: anchorChild._key
3616
- })), focusChild && (selection.focus.path.push("children"), selection.focus.path.push({
3617
- _key: focusChild._key
3618
- })), selection;
3619
- }
3620
- const decoratorAddActionImplementation = ({
3556
+ path: operation.at,
3557
+ offset: 0
3558
+ }
3559
+ }, operation.editor);
3560
+ if (!location)
3561
+ throw new Error(`Unable to convert ${JSON.stringify(operation.at)} into a Slate Range`);
3562
+ const block = Editor.node(operation.editor, location, {
3563
+ depth: 1
3564
+ })?.[0];
3565
+ if (!block)
3566
+ throw new Error(`Unable to find block at ${JSON.stringify(operation.at)}`);
3567
+ const parsedBlock = fromSlateValue([block], context.schema.block.name, KEY_TO_VALUE_ELEMENT.get(operation.editor)).at(0);
3568
+ if (!parsedBlock)
3569
+ throw new Error(`Unable to parse block at ${JSON.stringify(operation.at)}`);
3570
+ if (isTextBlock(context, parsedBlock)) {
3571
+ const propsToRemove = operation.props.filter((prop) => prop !== "_type"), updatedTextBlock = parseBlock({
3572
+ context,
3573
+ block: omit(parsedBlock, propsToRemove),
3574
+ options: {
3575
+ refreshKeys: !1
3576
+ }
3577
+ });
3578
+ if (!updatedTextBlock)
3579
+ throw new Error(`Unable to update block at ${JSON.stringify(operation.at)}`);
3580
+ const propsToSet = {};
3581
+ for (const prop of propsToRemove)
3582
+ prop in updatedTextBlock ? propsToSet[prop] = updatedTextBlock[prop] : propsToSet[prop] = void 0;
3583
+ Transforms.setNodes(operation.editor, propsToSet, {
3584
+ at: location
3585
+ });
3586
+ return;
3587
+ }
3588
+ const updatedBlockObject = parseBlock({
3589
+ context,
3590
+ block: omit(parsedBlock, operation.props.filter((prop) => prop !== "_type")),
3591
+ options: {
3592
+ refreshKeys: !1
3593
+ }
3594
+ });
3595
+ if (!updatedBlockObject)
3596
+ throw new Error(`Unable to update block at ${JSON.stringify(operation.at)}`);
3597
+ const {
3598
+ _type,
3599
+ _key,
3600
+ ...props
3601
+ } = updatedBlockObject;
3602
+ Transforms.setNodes(operation.editor, {
3603
+ _type,
3604
+ _key,
3605
+ value: props
3606
+ }, {
3607
+ at: location
3608
+ });
3609
+ }, decoratorAddOperationImplementation = ({
3621
3610
  context,
3622
- action
3611
+ operation
3623
3612
  }) => {
3624
- const editor = action.editor, mark = action.decorator, value = fromSlateValue(editor.children, context.schema.block.name, KEY_TO_VALUE_ELEMENT.get(editor)), manualAnchor = action.at?.anchor ? blockOffsetToSpanSelectionPoint({
3613
+ const editor = operation.editor, mark = operation.decorator, value = fromSlateValue(editor.children, context.schema.block.name, KEY_TO_VALUE_ELEMENT.get(editor)), manualAnchor = operation.at?.anchor ? blockOffsetToSpanSelectionPoint({
3625
3614
  context: {
3626
3615
  ...context,
3627
3616
  value
3628
3617
  },
3629
- blockOffset: action.at.anchor,
3618
+ blockOffset: operation.at.anchor,
3630
3619
  direction: "backward"
3631
- }) : void 0, manualFocus = action.at?.focus ? blockOffsetToSpanSelectionPoint({
3620
+ }) : void 0, manualFocus = operation.at?.focus ? blockOffsetToSpanSelectionPoint({
3632
3621
  context: {
3633
3622
  ...context,
3634
3623
  value
3635
3624
  },
3636
- blockOffset: action.at.focus,
3625
+ blockOffset: operation.at.focus,
3637
3626
  direction: "forward"
3638
3627
  }) : void 0, manualSelection = manualAnchor && manualFocus ? {
3639
3628
  anchor: manualAnchor,
3640
3629
  focus: manualFocus
3641
- } : void 0, selection = manualSelection ? toSlateRange(manualSelection, action.editor) ?? editor.selection : editor.selection;
3630
+ } : void 0, selection = manualSelection ? toSlateRange(manualSelection, operation.editor) ?? editor.selection : editor.selection;
3642
3631
  if (!selection)
3643
3632
  return;
3644
3633
  const editorSelection = slateRangeToSelection({
@@ -3741,82 +3730,82 @@ const decoratorAddActionImplementation = ({
3741
3730
  ...selection2
3742
3731
  };
3743
3732
  }
3744
- }, deleteActionImplementation = ({
3733
+ }, deleteOperationImplementation = ({
3745
3734
  context,
3746
- action
3735
+ operation
3747
3736
  }) => {
3748
- const range = toSlateRange(action.at, action.editor);
3737
+ const range = toSlateRange(operation.at, operation.editor);
3749
3738
  if (!range)
3750
- throw new Error(`Failed to get Slate Range for selection ${JSON.stringify(action.at)}`);
3739
+ throw new Error(`Failed to get Slate Range for selection ${JSON.stringify(operation.at)}`);
3751
3740
  if (Range.isCollapsed(range)) {
3752
3741
  const [focusBlock] = getFocusBlock({
3753
3742
  editor: {
3754
- ...action.editor,
3743
+ ...operation.editor,
3755
3744
  selection: range
3756
3745
  }
3757
3746
  }), [focusChild] = getFocusChild({
3758
3747
  editor: {
3759
- ...action.editor,
3748
+ ...operation.editor,
3760
3749
  selection: range
3761
3750
  }
3762
3751
  });
3763
3752
  if (focusBlock && focusBlock._type === context.schema.block.name && focusChild && focusChild._type === context.schema.span.name)
3764
3753
  return;
3765
3754
  }
3766
- action.editor.delete({
3755
+ operation.editor.delete({
3767
3756
  at: range
3768
3757
  });
3769
- }, deleteBackwardActionImplementation = ({
3770
- action
3758
+ }, deleteBackwardOperationImplementation = ({
3759
+ operation
3771
3760
  }) => {
3772
- action.editor.deleteBackward(action.unit);
3773
- }, deleteBlockActionImplementation = ({
3774
- action
3761
+ deleteBackward(operation.editor, operation.unit);
3762
+ }, deleteBlockOperationImplementation = ({
3763
+ operation
3775
3764
  }) => {
3776
3765
  const range = toSlateRange({
3777
3766
  anchor: {
3778
- path: action.at,
3767
+ path: operation.at,
3779
3768
  offset: 0
3780
3769
  },
3781
3770
  focus: {
3782
- path: action.at,
3771
+ path: operation.at,
3783
3772
  offset: 0
3784
3773
  }
3785
- }, action.editor);
3774
+ }, operation.editor);
3786
3775
  if (!range) {
3787
3776
  console.error("Unable to find Slate range from selection points");
3788
3777
  return;
3789
3778
  }
3790
- Transforms.removeNodes(action.editor, {
3779
+ Transforms.removeNodes(operation.editor, {
3791
3780
  at: range
3792
3781
  });
3793
- }, deleteForwardActionImplementation = ({
3794
- action
3782
+ }, deleteForwardOperationImplementation = ({
3783
+ operation
3795
3784
  }) => {
3796
- action.editor.deleteForward(action.unit);
3797
- }, insertInlineObjectActionImplementation = ({
3785
+ deleteForward(operation.editor, operation.unit);
3786
+ }, insertInlineObjectOperationImplementation = ({
3798
3787
  context,
3799
- action
3788
+ operation
3800
3789
  }) => {
3801
3790
  const parsedInlineObject = parseInlineObject({
3802
3791
  context,
3803
3792
  inlineObject: {
3804
- _type: action.inlineObject.name,
3805
- ...action.inlineObject.value ?? {}
3793
+ _type: operation.inlineObject.name,
3794
+ ...operation.inlineObject.value ?? {}
3806
3795
  },
3807
3796
  options: {
3808
3797
  refreshKeys: !1
3809
3798
  }
3810
3799
  });
3811
3800
  if (!parsedInlineObject)
3812
- throw new Error(`Failed to parse inline object ${JSON.stringify(action.inlineObject)}`);
3813
- if (!action.editor.selection) {
3801
+ throw new Error(`Failed to parse inline object ${JSON.stringify(operation.inlineObject)}`);
3802
+ if (!operation.editor.selection) {
3814
3803
  console.error("Unable to insert inline object without selection");
3815
3804
  return;
3816
3805
  }
3817
- const [focusTextBlock] = Array.from(Editor.nodes(action.editor, {
3818
- at: action.editor.selection.focus.path,
3819
- match: (node) => action.editor.isTextBlock(node)
3806
+ const [focusTextBlock] = Array.from(Editor.nodes(operation.editor, {
3807
+ at: operation.editor.selection.focus.path,
3808
+ match: (node) => operation.editor.isTextBlock(node)
3820
3809
  })).at(0) ?? [void 0, void 0];
3821
3810
  if (!focusTextBlock) {
3822
3811
  console.error("Unable to perform action without focus text block");
@@ -3833,49 +3822,49 @@ const decoratorAddActionImplementation = ({
3833
3822
  console.error("Unable to insert inline object");
3834
3823
  return;
3835
3824
  }
3836
- Transforms.insertNodes(action.editor, child);
3837
- }, insertSpanActionImplementation = ({
3825
+ Transforms.insertNodes(operation.editor, child);
3826
+ }, insertSpanOperationImplementation = ({
3838
3827
  context,
3839
- action
3828
+ operation
3840
3829
  }) => {
3841
- if (!action.editor.selection) {
3842
- console.error("Unable to perform action without selection", action);
3830
+ if (!operation.editor.selection) {
3831
+ console.error("Unable to perform action without selection", operation);
3843
3832
  return;
3844
3833
  }
3845
- const [focusBlock, focusBlockPath] = Array.from(Editor.nodes(action.editor, {
3846
- at: action.editor.selection.focus.path,
3847
- match: (node) => action.editor.isTextBlock(node)
3834
+ const [focusBlock, focusBlockPath] = Array.from(Editor.nodes(operation.editor, {
3835
+ at: operation.editor.selection.focus.path,
3836
+ match: (node) => operation.editor.isTextBlock(node)
3848
3837
  }))[0] ?? [void 0, void 0];
3849
3838
  if (!focusBlock || !focusBlockPath) {
3850
- console.error("Unable to perform action without focus block", action);
3839
+ console.error("Unable to perform action without focus block", operation);
3851
3840
  return;
3852
3841
  }
3853
- const markDefs = focusBlock.markDefs ?? [], annotations = action.annotations ? action.annotations.map((annotation) => ({
3842
+ const markDefs = focusBlock.markDefs ?? [], annotations = operation.annotations ? operation.annotations.map((annotation) => ({
3854
3843
  _type: annotation.name,
3855
3844
  _key: context.keyGenerator(),
3856
3845
  ...annotation.value
3857
3846
  })) : void 0;
3858
- annotations && annotations.length > 0 && Transforms.setNodes(action.editor, {
3847
+ annotations && annotations.length > 0 && Transforms.setNodes(operation.editor, {
3859
3848
  markDefs: [...markDefs, ...annotations]
3860
- }), Transforms.insertNodes(action.editor, {
3849
+ }), Transforms.insertNodes(operation.editor, {
3861
3850
  _type: "span",
3862
3851
  _key: context.keyGenerator(),
3863
- text: action.text,
3864
- marks: [...annotations?.map((annotation) => annotation._key) ?? [], ...action.decorators ?? []]
3852
+ text: operation.text,
3853
+ marks: [...annotations?.map((annotation) => annotation._key) ?? [], ...operation.decorators ?? []]
3865
3854
  });
3866
- }, insertBlockActionImplementation = ({
3855
+ }, insertBlockOperationImplementation = ({
3867
3856
  context,
3868
- action
3857
+ operation
3869
3858
  }) => {
3870
3859
  const parsedBlock = parseBlock({
3871
- block: action.block,
3860
+ block: operation.block,
3872
3861
  context,
3873
3862
  options: {
3874
3863
  refreshKeys: !1
3875
3864
  }
3876
3865
  });
3877
3866
  if (!parsedBlock)
3878
- throw new Error(`Failed to parse block ${JSON.stringify(action.block)}`);
3867
+ throw new Error(`Failed to parse block ${JSON.stringify(operation.block)}`);
3879
3868
  const fragment = toSlateValue([parsedBlock], {
3880
3869
  schemaTypes: context.schema
3881
3870
  })[0];
@@ -3883,9 +3872,9 @@ const decoratorAddActionImplementation = ({
3883
3872
  throw new Error(`Failed to convert block to Slate fragment ${JSON.stringify(parsedBlock)}`);
3884
3873
  insertBlock({
3885
3874
  block: fragment,
3886
- placement: action.placement,
3887
- select: action.select ?? "start",
3888
- editor: action.editor,
3875
+ placement: operation.placement,
3876
+ select: operation.select ?? "start",
3877
+ editor: operation.editor,
3889
3878
  schema: context.schema
3890
3879
  });
3891
3880
  };
@@ -4037,218 +4026,229 @@ function insertBlock({
4037
4026
  }
4038
4027
  }
4039
4028
  }
4040
- const moveBackwardActionImplementation = ({
4041
- action
4029
+ const moveBackwardOperationImplementation = ({
4030
+ operation
4042
4031
  }) => {
4043
- Transforms.move(action.editor, {
4032
+ Transforms.move(operation.editor, {
4044
4033
  unit: "character",
4045
- distance: action.distance,
4034
+ distance: operation.distance,
4046
4035
  reverse: !0
4047
4036
  });
4048
- }, moveBlockActionImplementation = ({
4049
- action
4037
+ }, moveBlockOperationImplementation = ({
4038
+ operation
4050
4039
  }) => {
4051
- const at = [toSlatePath(action.at, action.editor)[0]], to = [toSlatePath(action.to, action.editor)[0]];
4052
- Transforms.moveNodes(action.editor, {
4040
+ const at = [toSlatePath(operation.at, operation.editor)[0]], to = [toSlatePath(operation.to, operation.editor)[0]];
4041
+ Transforms.moveNodes(operation.editor, {
4053
4042
  at,
4054
4043
  to,
4055
4044
  mode: "highest"
4056
4045
  });
4057
- }, moveForwardActionImplementation = ({
4058
- action
4046
+ }, moveForwardOperationImplementation = ({
4047
+ operation
4059
4048
  }) => {
4060
- Transforms.move(action.editor, {
4049
+ Transforms.move(operation.editor, {
4061
4050
  unit: "character",
4062
- distance: action.distance
4051
+ distance: operation.distance
4063
4052
  });
4064
- }, selectActionImplementation = ({
4065
- action
4053
+ }, selectOperationImplementation = ({
4054
+ operation
4066
4055
  }) => {
4067
- const newSelection = toSlateRange(action.at, action.editor);
4068
- newSelection ? Transforms.select(action.editor, newSelection) : Transforms.deselect(action.editor);
4069
- }, behaviorActionImplementations = {
4070
- "annotation.add": addAnnotationActionImplementation,
4071
- "annotation.remove": removeAnnotationActionImplementation,
4072
- "block.set": blockSetBehaviorActionImplementation,
4073
- "block.unset": blockUnsetBehaviorActionImplementation,
4074
- "decorator.add": decoratorAddActionImplementation,
4075
- "decorator.remove": removeDecoratorActionImplementation,
4076
- delete: deleteActionImplementation,
4077
- "delete.backward": deleteBackwardActionImplementation,
4078
- "delete.forward": deleteForwardActionImplementation,
4079
- "delete.block": deleteBlockActionImplementation,
4080
- "history.redo": historyRedoActionImplementation,
4081
- "history.undo": historyUndoActionImplementation,
4082
- "insert.block": insertBlockActionImplementation,
4083
- "insert.inline object": insertInlineObjectActionImplementation,
4084
- "insert.span": insertSpanActionImplementation,
4085
- "insert.text": insertTextActionImplementation,
4086
- "move.backward": moveBackwardActionImplementation,
4087
- "move.block": moveBlockActionImplementation,
4088
- "move.forward": moveForwardActionImplementation,
4089
- select: selectActionImplementation
4056
+ const newSelection = toSlateRange(operation.at, operation.editor);
4057
+ newSelection ? Transforms.select(operation.editor, newSelection) : Transforms.deselect(operation.editor);
4058
+ }, behaviorOperationImplementations = {
4059
+ "annotation.add": addAnnotationOperationImplementation,
4060
+ "annotation.remove": removeAnnotationOperationImplementation,
4061
+ "block.set": blockSetOperationImplementation,
4062
+ "block.unset": blockUnsetOperationImplementation,
4063
+ "decorator.add": decoratorAddOperationImplementation,
4064
+ "decorator.remove": removeDecoratorOperationImplementation,
4065
+ delete: deleteOperationImplementation,
4066
+ "delete.backward": deleteBackwardOperationImplementation,
4067
+ "delete.forward": deleteForwardOperationImplementation,
4068
+ "delete.block": deleteBlockOperationImplementation,
4069
+ "history.redo": historyRedoOperationImplementation,
4070
+ "history.undo": historyUndoOperationImplementation,
4071
+ "insert.block": insertBlockOperationImplementation,
4072
+ "insert.inline object": insertInlineObjectOperationImplementation,
4073
+ "insert.span": insertSpanOperationImplementation,
4074
+ "insert.text": insertTextOperationImplementation,
4075
+ "move.backward": moveBackwardOperationImplementation,
4076
+ "move.block": moveBlockOperationImplementation,
4077
+ "move.forward": moveForwardOperationImplementation,
4078
+ select: selectOperationImplementation
4090
4079
  };
4091
- function performAction({
4080
+ function performOperation({
4092
4081
  context,
4093
- action
4082
+ operation
4094
4083
  }) {
4095
- switch (action.type) {
4096
- case "annotation.add": {
4097
- behaviorActionImplementations["annotation.add"]({
4098
- context,
4099
- action
4100
- });
4101
- break;
4102
- }
4103
- case "annotation.remove": {
4104
- behaviorActionImplementations["annotation.remove"]({
4105
- context,
4106
- action
4107
- });
4108
- break;
4109
- }
4110
- case "block.set": {
4111
- behaviorActionImplementations["block.set"]({
4112
- context,
4113
- action
4114
- });
4115
- break;
4116
- }
4117
- case "block.unset": {
4118
- behaviorActionImplementations["block.unset"]({
4119
- context,
4120
- action
4121
- });
4122
- break;
4123
- }
4124
- case "decorator.add": {
4125
- behaviorActionImplementations["decorator.add"]({
4126
- context,
4127
- action
4128
- });
4129
- break;
4130
- }
4131
- case "decorator.remove": {
4132
- behaviorActionImplementations["decorator.remove"]({
4133
- context,
4134
- action
4135
- });
4136
- break;
4137
- }
4138
- case "delete": {
4139
- behaviorActionImplementations.delete({
4140
- context,
4141
- action
4142
- });
4143
- break;
4144
- }
4145
- case "delete.backward": {
4146
- behaviorActionImplementations["delete.backward"]({
4147
- context,
4148
- action
4149
- });
4150
- break;
4151
- }
4152
- case "delete.block": {
4153
- behaviorActionImplementations["delete.block"]({
4154
- context,
4155
- action
4156
- });
4157
- break;
4158
- }
4159
- case "delete.forward": {
4160
- behaviorActionImplementations["delete.forward"]({
4161
- context,
4162
- action
4163
- });
4164
- break;
4165
- }
4166
- case "history.redo": {
4167
- behaviorActionImplementations["history.redo"]({
4168
- context,
4169
- action
4170
- });
4171
- break;
4172
- }
4173
- case "history.undo": {
4174
- behaviorActionImplementations["history.undo"]({
4175
- context,
4176
- action
4177
- });
4178
- break;
4179
- }
4180
- case "insert.block": {
4181
- behaviorActionImplementations["insert.block"]({
4182
- context,
4183
- action
4184
- });
4185
- break;
4186
- }
4187
- case "insert.inline object": {
4188
- behaviorActionImplementations["insert.inline object"]({
4189
- context,
4190
- action
4191
- });
4192
- break;
4193
- }
4194
- case "insert.span": {
4195
- behaviorActionImplementations["insert.span"]({
4196
- context,
4197
- action
4198
- });
4199
- break;
4200
- }
4201
- case "insert.text": {
4202
- behaviorActionImplementations["insert.text"]({
4203
- context,
4204
- action
4205
- });
4206
- break;
4207
- }
4208
- case "move.backward": {
4209
- behaviorActionImplementations["move.backward"]({
4210
- context,
4211
- action
4212
- });
4213
- break;
4214
- }
4215
- case "move.block": {
4216
- behaviorActionImplementations["move.block"]({
4217
- context,
4218
- action
4219
- });
4220
- break;
4221
- }
4222
- case "move.forward": {
4223
- behaviorActionImplementations["move.forward"]({
4224
- context,
4225
- action
4226
- });
4227
- break;
4228
- }
4229
- default: {
4230
- behaviorActionImplementations.select({
4231
- context,
4232
- action
4233
- });
4234
- break;
4084
+ try {
4085
+ switch (operation.type) {
4086
+ case "annotation.add": {
4087
+ behaviorOperationImplementations["annotation.add"]({
4088
+ context,
4089
+ operation
4090
+ });
4091
+ break;
4092
+ }
4093
+ case "annotation.remove": {
4094
+ behaviorOperationImplementations["annotation.remove"]({
4095
+ context,
4096
+ operation
4097
+ });
4098
+ break;
4099
+ }
4100
+ case "block.set": {
4101
+ behaviorOperationImplementations["block.set"]({
4102
+ context,
4103
+ operation
4104
+ });
4105
+ break;
4106
+ }
4107
+ case "block.unset": {
4108
+ behaviorOperationImplementations["block.unset"]({
4109
+ context,
4110
+ operation
4111
+ });
4112
+ break;
4113
+ }
4114
+ case "decorator.add": {
4115
+ behaviorOperationImplementations["decorator.add"]({
4116
+ context,
4117
+ operation
4118
+ });
4119
+ break;
4120
+ }
4121
+ case "decorator.remove": {
4122
+ behaviorOperationImplementations["decorator.remove"]({
4123
+ context,
4124
+ operation
4125
+ });
4126
+ break;
4127
+ }
4128
+ case "delete": {
4129
+ behaviorOperationImplementations.delete({
4130
+ context,
4131
+ operation
4132
+ });
4133
+ break;
4134
+ }
4135
+ case "delete.backward": {
4136
+ behaviorOperationImplementations["delete.backward"]({
4137
+ context,
4138
+ operation
4139
+ });
4140
+ break;
4141
+ }
4142
+ case "delete.block": {
4143
+ behaviorOperationImplementations["delete.block"]({
4144
+ context,
4145
+ operation
4146
+ });
4147
+ break;
4148
+ }
4149
+ case "delete.forward": {
4150
+ behaviorOperationImplementations["delete.forward"]({
4151
+ context,
4152
+ operation
4153
+ });
4154
+ break;
4155
+ }
4156
+ case "history.redo": {
4157
+ behaviorOperationImplementations["history.redo"]({
4158
+ context,
4159
+ operation
4160
+ });
4161
+ break;
4162
+ }
4163
+ case "history.undo": {
4164
+ behaviorOperationImplementations["history.undo"]({
4165
+ context,
4166
+ operation
4167
+ });
4168
+ break;
4169
+ }
4170
+ case "insert.block": {
4171
+ behaviorOperationImplementations["insert.block"]({
4172
+ context,
4173
+ operation
4174
+ });
4175
+ break;
4176
+ }
4177
+ case "insert.inline object": {
4178
+ behaviorOperationImplementations["insert.inline object"]({
4179
+ context,
4180
+ operation
4181
+ });
4182
+ break;
4183
+ }
4184
+ case "insert.span": {
4185
+ behaviorOperationImplementations["insert.span"]({
4186
+ context,
4187
+ operation
4188
+ });
4189
+ break;
4190
+ }
4191
+ case "insert.text": {
4192
+ behaviorOperationImplementations["insert.text"]({
4193
+ context,
4194
+ operation
4195
+ });
4196
+ break;
4197
+ }
4198
+ case "move.backward": {
4199
+ behaviorOperationImplementations["move.backward"]({
4200
+ context,
4201
+ operation
4202
+ });
4203
+ break;
4204
+ }
4205
+ case "move.block": {
4206
+ behaviorOperationImplementations["move.block"]({
4207
+ context,
4208
+ operation
4209
+ });
4210
+ break;
4211
+ }
4212
+ case "move.forward": {
4213
+ behaviorOperationImplementations["move.forward"]({
4214
+ context,
4215
+ operation
4216
+ });
4217
+ break;
4218
+ }
4219
+ default: {
4220
+ behaviorOperationImplementations.select({
4221
+ context,
4222
+ operation
4223
+ });
4224
+ break;
4225
+ }
4235
4226
  }
4227
+ } catch (error) {
4228
+ console.error(new Error(`Executing "${operation.type}" failed due to: ${error.message}`));
4236
4229
  }
4237
4230
  }
4231
+ const CURRENT_OPERATION_ID = /* @__PURE__ */ new WeakMap();
4232
+ function withApplyingBehaviorOperations(editor, fn) {
4233
+ CURRENT_OPERATION_ID.set(editor, defaultKeyGenerator()), Editor.withoutNormalizing(editor, fn), CURRENT_OPERATION_ID.set(editor, void 0);
4234
+ }
4235
+ function getCurrentOperationId(editor) {
4236
+ return CURRENT_OPERATION_ID.get(editor);
4237
+ }
4238
+ function isApplyingBehaviorOperations(editor) {
4239
+ return getCurrentOperationId(editor) !== void 0;
4240
+ }
4238
4241
  function createWithEventListeners(editorActor) {
4239
4242
  return function(editor) {
4240
4243
  if (editorActor.getSnapshot().context.maxBlocks !== void 0)
4241
4244
  return editor;
4242
4245
  const {
4243
- deleteBackward,
4244
- deleteForward,
4245
- insertBreak,
4246
4246
  insertText,
4247
4247
  select
4248
4248
  } = editor;
4249
4249
  return editor.deleteBackward = (unit) => {
4250
- if (isApplyingBehaviorActions(editor)) {
4251
- deleteBackward(unit);
4250
+ if (isApplyingBehaviorOperations(editor)) {
4251
+ console.error("Unexpected call to .deleteBackward(...)");
4252
4252
  return;
4253
4253
  }
4254
4254
  editorActor.send({
@@ -4260,8 +4260,8 @@ function createWithEventListeners(editorActor) {
4260
4260
  editor
4261
4261
  });
4262
4262
  }, editor.deleteForward = (unit) => {
4263
- if (isApplyingBehaviorActions(editor)) {
4264
- deleteForward(unit);
4263
+ if (isApplyingBehaviorOperations(editor)) {
4264
+ console.error("Unexpected call to .deleteForward(...)");
4265
4265
  return;
4266
4266
  }
4267
4267
  editorActor.send({
@@ -4273,8 +4273,8 @@ function createWithEventListeners(editorActor) {
4273
4273
  editor
4274
4274
  });
4275
4275
  }, editor.insertBreak = () => {
4276
- if (isApplyingBehaviorActions(editor)) {
4277
- insertBreak();
4276
+ if (isApplyingBehaviorOperations(editor)) {
4277
+ console.error("Unexpected call to .insertBreak(...)");
4278
4278
  return;
4279
4279
  }
4280
4280
  editorActor.send({
@@ -4285,8 +4285,10 @@ function createWithEventListeners(editorActor) {
4285
4285
  editor
4286
4286
  });
4287
4287
  }, editor.insertData = (dataTransfer) => {
4288
- if (isApplyingBehaviorActions(editor))
4289
- throw new Error("Unexpected call to .insertData(...)");
4288
+ if (isApplyingBehaviorOperations(editor)) {
4289
+ console.error("Unexpected call to .insertData(...)");
4290
+ return;
4291
+ }
4290
4292
  editorActor.send({
4291
4293
  type: "behavior event",
4292
4294
  behaviorEvent: {
@@ -4298,13 +4300,13 @@ function createWithEventListeners(editorActor) {
4298
4300
  editor
4299
4301
  });
4300
4302
  }, editor.insertSoftBreak = () => {
4301
- if (isApplyingBehaviorActions(editor)) {
4302
- insertTextActionImplementation({
4303
+ if (isApplyingBehaviorOperations(editor)) {
4304
+ insertTextOperationImplementation({
4303
4305
  context: {
4304
4306
  keyGenerator: editorActor.getSnapshot().context.keyGenerator,
4305
4307
  schema: editorActor.getSnapshot().context.schema
4306
4308
  },
4307
- action: {
4309
+ operation: {
4308
4310
  text: `
4309
4311
  `,
4310
4312
  editor
@@ -4320,7 +4322,7 @@ function createWithEventListeners(editorActor) {
4320
4322
  editor
4321
4323
  });
4322
4324
  }, editor.insertText = (text, options) => {
4323
- if (isApplyingBehaviorActions(editor)) {
4325
+ if (isApplyingBehaviorOperations(editor)) {
4324
4326
  insertText(text, options);
4325
4327
  return;
4326
4328
  }
@@ -4333,13 +4335,13 @@ function createWithEventListeners(editorActor) {
4333
4335
  editor
4334
4336
  });
4335
4337
  }, editor.redo = () => {
4336
- if (isApplyingBehaviorActions(editor)) {
4337
- performAction({
4338
+ if (isApplyingBehaviorOperations(editor)) {
4339
+ performOperation({
4338
4340
  context: {
4339
4341
  keyGenerator: editorActor.getSnapshot().context.keyGenerator,
4340
4342
  schema: editorActor.getSnapshot().context.schema
4341
4343
  },
4342
- action: {
4344
+ operation: {
4343
4345
  type: "history.redo",
4344
4346
  editor
4345
4347
  }
@@ -4354,7 +4356,7 @@ function createWithEventListeners(editorActor) {
4354
4356
  editor
4355
4357
  });
4356
4358
  }, editor.select = (location) => {
4357
- if (isApplyingBehaviorActions(editor)) {
4359
+ if (isApplyingBehaviorOperations(editor)) {
4358
4360
  select(location);
4359
4361
  return;
4360
4362
  }
@@ -4372,15 +4374,15 @@ function createWithEventListeners(editorActor) {
4372
4374
  editor
4373
4375
  });
4374
4376
  }, editor.setFragmentData = () => {
4375
- console.warn("Unexpected call to .setFragmentData(...)");
4377
+ console.error("Unexpected call to .setFragmentData(...)");
4376
4378
  }, editor.undo = () => {
4377
- if (isApplyingBehaviorActions(editor)) {
4378
- performAction({
4379
+ if (isApplyingBehaviorOperations(editor)) {
4380
+ performOperation({
4379
4381
  context: {
4380
4382
  keyGenerator: editorActor.getSnapshot().context.keyGenerator,
4381
4383
  schema: editorActor.getSnapshot().context.schema
4382
4384
  },
4383
- action: {
4385
+ operation: {
4384
4386
  type: "history.undo",
4385
4387
  editor
4386
4388
  }
@@ -4784,9 +4786,14 @@ function createWithPatches({
4784
4786
  Editor.withoutNormalizing(editor, () => {
4785
4787
  withoutPatching(editor, () => {
4786
4788
  withoutSaving(editor, () => {
4787
- patches.forEach((patch) => {
4788
- debug$8.enabled && debug$8(`Handling remote patch ${JSON.stringify(patch)}`), changed = applyPatch(editor, patch);
4789
- });
4789
+ for (const patch of patches) {
4790
+ debug$8.enabled && debug$8(`Handling remote patch ${JSON.stringify(patch)}`);
4791
+ try {
4792
+ changed = applyPatch(editor, patch);
4793
+ } catch (error) {
4794
+ console.error(`Applying patch ${JSON.stringify(patch)} failed due to: ${error.message}`);
4795
+ }
4796
+ }
4790
4797
  });
4791
4798
  });
4792
4799
  }), changed && (editor.normalize(), editor.onChange());
@@ -4848,7 +4855,7 @@ function createWithPatches({
4848
4855
  ...patch,
4849
4856
  origin: "local"
4850
4857
  },
4851
- actionId: getCurrentActionId(editor),
4858
+ operationId: getCurrentOperationId(editor),
4852
4859
  value: fromSlateValue(editor.children, editorActor.getSnapshot().context.schema.block.name, KEY_TO_VALUE_ELEMENT.get(editor))
4853
4860
  });
4854
4861
  return editor;
@@ -5590,12 +5597,12 @@ function createEditableAPI(editor, editorActor) {
5590
5597
  addAnnotation: (type, value) => {
5591
5598
  let paths;
5592
5599
  return Editor.withoutNormalizing(editor, () => {
5593
- paths = addAnnotationActionImplementation({
5600
+ paths = addAnnotationOperationImplementation({
5594
5601
  context: {
5595
5602
  keyGenerator: editorActor.getSnapshot().context.keyGenerator,
5596
5603
  schema: types
5597
5604
  },
5598
- action: {
5605
+ operation: {
5599
5606
  annotation: {
5600
5607
  name: type.name,
5601
5608
  value: value ?? {}
@@ -6679,7 +6686,24 @@ const arrowDownOnLonelyBlockObject = defineBehavior({
6679
6686
  text: `
6680
6687
  `
6681
6688
  })]]
6682
- })], abstractListItemBehaviors = [defineBehavior({
6689
+ })], keyIs = {
6690
+ lineBreak: (event) => event.key === "Enter" && event.shiftKey
6691
+ }, abstractKeyboardBehaviors = [
6692
+ /**
6693
+ * On WebKit, Shift+Enter results in an `insertParagraph` input event rather
6694
+ * than an `insertLineBreak` input event. This Behavior makes sure we catch
6695
+ * that `keyboard.keydown` event beforehand and raise an `insert.soft break` manually.
6696
+ */
6697
+ defineBehavior({
6698
+ on: "keyboard.keydown",
6699
+ guard: ({
6700
+ event
6701
+ }) => keyIs.lineBreak(event.originEvent),
6702
+ actions: [() => [raise({
6703
+ type: "insert.soft break"
6704
+ })]]
6705
+ })
6706
+ ], abstractListItemBehaviors = [defineBehavior({
6683
6707
  on: "list item.add",
6684
6708
  guard: ({
6685
6709
  snapshot
@@ -7005,17 +7029,7 @@ const arrowDownOnLonelyBlockObject = defineBehavior({
7005
7029
  type: "style.add",
7006
7030
  style: event.style
7007
7031
  })]]
7008
- })], keyIs = {
7009
- lineBreak: (event) => event.key === "Enter" && event.shiftKey
7010
- }, raiseInsertSoftBreak = defineBehavior({
7011
- on: "keyboard.keydown",
7012
- guard: ({
7013
- event
7014
- }) => keyIs.lineBreak(event.originEvent),
7015
- actions: [() => [raise({
7016
- type: "insert.soft break"
7017
- })]]
7018
- }), raiseDeserializationSuccessOrFailure = defineBehavior({
7032
+ })], raiseDeserializationSuccessOrFailure = defineBehavior({
7019
7033
  on: "deserialize",
7020
7034
  guard: ({
7021
7035
  snapshot,
@@ -7075,7 +7089,7 @@ const arrowDownOnLonelyBlockObject = defineBehavior({
7075
7089
  ...serializeEvent,
7076
7090
  originEvent: event.originEvent
7077
7091
  }))]
7078
- }), defaultBehaviors = [
7092
+ }), abstractBehaviors = [
7079
7093
  defineBehavior({
7080
7094
  on: "clipboard.copy",
7081
7095
  guard: ({
@@ -7350,14 +7364,14 @@ const arrowDownOnLonelyBlockObject = defineBehavior({
7350
7364
  ...abstractDecoratorBehaviors,
7351
7365
  ...abstractDeleteBehaviors,
7352
7366
  ...abstractInsertBehaviors,
7367
+ ...abstractKeyboardBehaviors,
7353
7368
  ...abstractListItemBehaviors,
7354
7369
  ...abstractMoveBehaviors,
7355
7370
  ...abstractStyleBehaviors,
7356
7371
  ...abstractSelectBehaviors,
7357
7372
  ...abstractSplitBehaviors,
7358
7373
  raiseDeserializationSuccessOrFailure,
7359
- raiseSerializationSuccessOrFailure,
7360
- raiseInsertSoftBreak
7374
+ raiseSerializationSuccessOrFailure
7361
7375
  ];
7362
7376
  function isSyntheticBehaviorEvent(event) {
7363
7377
  return !isCustomBehaviorEvent(event) && !isNativeBehaviorEvent(event) && !isAbstractBehaviorEvent(event);
@@ -7389,28 +7403,24 @@ function performEvent({
7389
7403
  nativeEvent
7390
7404
  }) {
7391
7405
  debug$2(`(${mode}:${eventCategory(event)})`, JSON.stringify(event, null, 2));
7392
- const eventBehaviors = [...remainingEventBehaviors, ...defaultBehaviors].filter((behavior) => {
7406
+ const eventBehaviors = [...remainingEventBehaviors, ...abstractBehaviors].filter((behavior) => {
7393
7407
  if (behavior.on === "*")
7394
7408
  return !0;
7395
7409
  const [listenedNamespace] = behavior.on.includes("*") && behavior.on.includes(".") ? behavior.on.split(".") : [void 0], [eventNamespace] = event.type.includes(".") ? event.type.split(".") : [void 0];
7396
7410
  return listenedNamespace !== void 0 && eventNamespace !== void 0 && listenedNamespace === eventNamespace || listenedNamespace !== void 0 && eventNamespace === void 0 && listenedNamespace === event.type ? !0 : behavior.on === event.type;
7397
7411
  });
7398
7412
  if (eventBehaviors.length === 0 && isSyntheticBehaviorEvent(event)) {
7399
- nativeEvent?.preventDefault(), withApplyingBehaviorActions(editor, () => {
7400
- try {
7401
- debug$2(`(execute:${eventCategory(event)})`, JSON.stringify(event, null, 2)), performAction({
7402
- context: {
7403
- keyGenerator,
7404
- schema
7405
- },
7406
- action: {
7407
- ...event,
7408
- editor
7409
- }
7410
- });
7411
- } catch (error) {
7412
- console.error(new Error(`Executing "${event.type}" failed due to: ${error.message}`));
7413
- }
7413
+ nativeEvent?.preventDefault(), withApplyingBehaviorOperations(editor, () => {
7414
+ debug$2(`(execute:${eventCategory(event)})`, JSON.stringify(event, null, 2)), performOperation({
7415
+ context: {
7416
+ keyGenerator,
7417
+ schema
7418
+ },
7419
+ operation: {
7420
+ ...event,
7421
+ editor
7422
+ }
7423
+ });
7414
7424
  }), editor.onChange();
7415
7425
  return;
7416
7426
  }
@@ -7543,21 +7553,17 @@ function performEvent({
7543
7553
  break;
7544
7554
  }
7545
7555
  }
7546
- !defaultBehaviorOverwritten && isSyntheticBehaviorEvent(event) ? (nativeEvent?.preventDefault(), withApplyingBehaviorActions(editor, () => {
7547
- try {
7548
- debug$2(`(execute:${eventCategory(event)})`, JSON.stringify(event, null, 2)), performAction({
7549
- context: {
7550
- keyGenerator,
7551
- schema
7552
- },
7553
- action: {
7554
- ...event,
7555
- editor
7556
- }
7557
- });
7558
- } catch (error) {
7559
- console.error(new Error(`Executing "${event.type}" failed due to: ${error.message}`));
7560
- }
7556
+ !defaultBehaviorOverwritten && isSyntheticBehaviorEvent(event) ? (nativeEvent?.preventDefault(), withApplyingBehaviorOperations(editor, () => {
7557
+ debug$2(`(execute:${eventCategory(event)})`, JSON.stringify(event, null, 2)), performOperation({
7558
+ context: {
7559
+ keyGenerator,
7560
+ schema
7561
+ },
7562
+ operation: {
7563
+ ...event,
7564
+ editor
7565
+ }
7566
+ });
7561
7567
  }), editor.onChange()) : nativeEventPrevented && nativeEvent?.preventDefault();
7562
7568
  }
7563
7569
  function createEditorSnapshot({
@@ -7708,8 +7714,8 @@ const editorMachine = setup({
7708
7714
  try {
7709
7715
  performEvent({
7710
7716
  mode: "raise",
7711
- behaviors: [...context.behaviors.values()],
7712
- remainingEventBehaviors: [...context.behaviors.values()],
7717
+ behaviors: [...context.behaviors.values(), ...coreBehaviors],
7718
+ remainingEventBehaviors: [...context.behaviors.values(), ...coreBehaviors],
7713
7719
  event: event.behaviorEvent,
7714
7720
  editor: event.editor,
7715
7721
  keyGenerator: context.keyGenerator,
@@ -7742,7 +7748,7 @@ const editorMachine = setup({
7742
7748
  context: ({
7743
7749
  input
7744
7750
  }) => ({
7745
- behaviors: /* @__PURE__ */ new Set([...coreBehaviors]),
7751
+ behaviors: /* @__PURE__ */ new Set([]),
7746
7752
  converters: new Set(input.converters ?? []),
7747
7753
  getLegacySchema: input.getLegacySchema,
7748
7754
  keyGenerator: input.keyGenerator,
@@ -8661,7 +8667,6 @@ export {
8661
8667
  EditorProvider,
8662
8668
  KEY_TO_VALUE_ELEMENT,
8663
8669
  PortableTextEditor,
8664
- coreBehaviors,
8665
8670
  debugWithName,
8666
8671
  defaultKeyGenerator,
8667
8672
  defineSchema,