@portabletext/editor 1.49.9 → 1.49.11

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 (40) hide show
  1. package/lib/behaviors/index.d.cts +160 -2885
  2. package/lib/behaviors/index.d.ts +160 -2885
  3. package/lib/index.cjs +356 -311
  4. package/lib/index.cjs.map +1 -1
  5. package/lib/index.d.cts +170 -2874
  6. package/lib/index.d.ts +170 -2874
  7. package/lib/index.js +359 -314
  8. package/lib/index.js.map +1 -1
  9. package/lib/plugins/index.cjs.map +1 -1
  10. package/lib/plugins/index.d.cts +162 -2879
  11. package/lib/plugins/index.d.ts +162 -2879
  12. package/lib/plugins/index.js.map +1 -1
  13. package/lib/selectors/index.d.cts +160 -2885
  14. package/lib/selectors/index.d.ts +160 -2885
  15. package/lib/utils/index.d.cts +160 -2885
  16. package/lib/utils/index.d.ts +160 -2885
  17. package/package.json +7 -7
  18. package/src/editor/Editable.tsx +14 -12
  19. package/src/editor/PortableTextEditor.tsx +21 -26
  20. package/src/editor/__tests__/self-solving.test.tsx +9 -9
  21. package/src/editor/create-editor.ts +91 -53
  22. package/src/editor/create-slate-editor.tsx +3 -0
  23. package/src/editor/editor-machine.ts +15 -127
  24. package/src/editor/editor-provider.tsx +20 -15
  25. package/src/editor/mutation-machine.ts +125 -7
  26. package/src/editor/plugins/createWithPatches.ts +5 -2
  27. package/src/editor/plugins/createWithPortableTextSelections.ts +4 -2
  28. package/src/editor/plugins/with-plugins.ts +8 -3
  29. package/src/editor/relay-actor-context.ts +4 -0
  30. package/src/editor/relay-machine.ts +89 -0
  31. package/src/editor/route-events-to-changes.tsx +4 -10
  32. package/src/editor/sync-machine.ts +2 -2
  33. package/src/editor-event-listener.tsx +1 -1
  34. package/src/editor.ts +2 -4
  35. package/src/index.ts +3 -6
  36. package/src/internal-utils/__tests__/operationToPatches.test.ts +3 -1
  37. package/src/internal-utils/__tests__/patchToOperations.test.ts +2 -0
  38. package/src/internal-utils/applyPatch.ts +6 -2
  39. package/src/plugins/plugin.event-listener.tsx +1 -1
  40. package/src/types/editor.ts +12 -4
package/lib/index.js CHANGED
@@ -7,7 +7,7 @@ import { useSelector, useActorRef } from "@xstate/react";
7
7
  import noop from "lodash/noop.js";
8
8
  import { Element as Element$1, Text, Range, Editor, Node, Point, Transforms, Path, Operation, deleteBackward, deleteForward, createEditor } from "slate";
9
9
  import { useSlateStatic, useSelected, withReact, ReactEditor, Slate, useSlate, Editable } from "slate-react";
10
- import debug$i from "debug";
10
+ import debug$j from "debug";
11
11
  import { getBlockEndPoint, isEmptyTextBlock, isEqualSelectionPoints } from "./_chunks-es/util.is-equal-selection-points.js";
12
12
  import { getBlockStartPoint, isKeyedSegment as isKeyedSegment$1, parseInlineObject, parseTextBlock, parseBlockObject, parseBlock, sliceBlocks, isTextBlock, parseAnnotation, blockOffsetToSpanSelectionPoint, isSpan$1 as isSpan, isListBlock, getTextBlockText, parseBlocks } from "./_chunks-es/util.slice-blocks.js";
13
13
  import { isSelectionCollapsed, getFocusTextBlock, getFocusSpan, getSelectedBlocks, isSelectionExpanded, getSelectionStartBlock as getSelectionStartBlock$1, getSelectionEndBlock as getSelectionEndBlock$1, getFocusBlock as getFocusBlock$1, getFocusBlockObject, getPreviousBlock, getNextBlock, getFirstBlock as getFirstBlock$1, getLastBlock as getLastBlock$1, getFocusListBlock } from "./_chunks-es/selector.is-selection-expanded.js";
@@ -20,10 +20,10 @@ import getRandomValues from "get-random-values-esm";
20
20
  import { defineBehavior, forward, raise } from "./behaviors/index.js";
21
21
  import uniq from "lodash/uniq.js";
22
22
  import { Subject } from "rxjs";
23
- import { Schema } from "@sanity/schema";
24
- import { setup, assign, enqueueActions, emit, assertEvent, stateIn, fromCallback, and, not, raise as raise$1, createActor } from "xstate";
23
+ import { setup, assign, enqueueActions, emit, assertEvent, stateIn, fromCallback, not, and, raise as raise$1, createActor } from "xstate";
25
24
  import { htmlToBlocks } from "@portabletext/block-tools";
26
25
  import { toHTML } from "@portabletext/to-html";
26
+ import { Schema } from "@sanity/schema";
27
27
  import { insert, unset, set, diffMatchPatch as diffMatchPatch$1, setIfMissing, applyAll } from "@portabletext/patches";
28
28
  import get from "lodash/get.js";
29
29
  import isUndefined from "lodash/isUndefined.js";
@@ -59,10 +59,10 @@ function getCompoundClientRect(nodes) {
59
59
  return new DOMRect(left, top, right - left, bottom - top);
60
60
  }
61
61
  const rootName = "sanity-pte:";
62
- debug$i(rootName);
62
+ debug$j(rootName);
63
63
  function debugWithName(name) {
64
64
  const namespace = `${rootName}${name}`;
65
- return debug$i && debug$i.enabled(namespace) ? debug$i(namespace) : debug$i(rootName);
65
+ return debug$j && debug$j.enabled(namespace) ? debug$j(namespace) : debug$j(rootName);
66
66
  }
67
67
  function getDragSelection({
68
68
  eventSelection,
@@ -1095,14 +1095,7 @@ const PortableTextEditorContext = createContext(null), usePortableTextEditor = (
1095
1095
  if (!editor)
1096
1096
  throw new Error("The `usePortableTextEditor` hook must be used inside the <PortableTextEditor> component's context.");
1097
1097
  return editor;
1098
- };
1099
- function compileType(rawType) {
1100
- return Schema.compile({
1101
- name: "blockTypeSchema",
1102
- types: [rawType]
1103
- }).get(rawType.name);
1104
- }
1105
- const forEachActor = (actorRef, callback) => {
1098
+ }, forEachActor = (actorRef, callback) => {
1106
1099
  callback(actorRef);
1107
1100
  const children = actorRef.getSnapshot().children;
1108
1101
  children && Object.values(children).forEach((child) => {
@@ -1371,11 +1364,17 @@ function escapeHtml(str) {
1371
1364
  function createCoreConverters(legacySchema) {
1372
1365
  return [converterJson, converterPortableText, createConverterTextHtml(legacySchema), createConverterTextPlain(legacySchema)];
1373
1366
  }
1374
- const debug$h = debugWithName("operationToPatches");
1367
+ function compileType(rawType) {
1368
+ return Schema.compile({
1369
+ name: "blockTypeSchema",
1370
+ types: [rawType]
1371
+ }).get(rawType.name);
1372
+ }
1373
+ const debug$i = debugWithName("operationToPatches");
1375
1374
  function createOperationToPatches(editorActor) {
1376
1375
  const textBlockName = editorActor.getSnapshot().context.schema.block.name;
1377
1376
  function insertTextPatch(editor, operation, beforeValue) {
1378
- debug$h.enabled && debug$h("Operation", JSON.stringify(operation, null, 2));
1377
+ debug$i.enabled && debug$i("Operation", JSON.stringify(operation, null, 2));
1379
1378
  const block = editor.isTextBlock(editor.children[operation.path[0]]) && editor.children[operation.path[0]];
1380
1379
  if (!block)
1381
1380
  throw new Error("Could not find block");
@@ -1468,7 +1467,7 @@ function createOperationToPatches(editorActor) {
1468
1467
  _key: block.children[operation.path[1] - 1]._key
1469
1468
  }])];
1470
1469
  }
1471
- return debug$h("Something was inserted into a void block. Not producing editor patches."), [];
1470
+ return debug$i("Something was inserted into a void block. Not producing editor patches."), [];
1472
1471
  }
1473
1472
  function splitNodePatch(editor, operation, beforeValue) {
1474
1473
  const patches = [], splitBlock = editor.children[operation.path[0]];
@@ -1526,9 +1525,9 @@ function createOperationToPatches(editorActor) {
1526
1525
  _key: block._key
1527
1526
  }, "children", {
1528
1527
  _key: spanToRemove._key
1529
- }])] : (debug$h("Span not found in editor trying to remove node"), []);
1528
+ }])] : (debug$i("Span not found in editor trying to remove node"), []);
1530
1529
  } else
1531
- return debug$h("Not creating patch inside object block"), [];
1530
+ return debug$i("Not creating patch inside object block"), [];
1532
1531
  }
1533
1532
  function mergeNodePatch(editor, operation, beforeValue) {
1534
1533
  const patches = [], block = beforeValue[operation.path[0]], updatedBlock = editor.children[operation.path[0]];
@@ -1554,7 +1553,7 @@ function createOperationToPatches(editorActor) {
1554
1553
  _key: removedSpan._key
1555
1554
  }])) : console.warn(`Multiple spans have \`_key\` ${removedSpan._key}. It's ambiguous which one to remove.`, JSON.stringify(block, null, 2)));
1556
1555
  } else
1557
- debug$h("Void nodes can't be merged, not creating any patches");
1556
+ debug$i("Void nodes can't be merged, not creating any patches");
1558
1557
  return patches;
1559
1558
  }
1560
1559
  function moveNodePatch(editor, operation, beforeValue) {
@@ -1672,7 +1671,7 @@ function isRedoing(editor) {
1672
1671
  function setIsRedoing(editor, isRedoing2) {
1673
1672
  IS_REDOING.set(editor, isRedoing2);
1674
1673
  }
1675
- const debug$g = debugWithName("plugin:withPortableTextMarkModel");
1674
+ const debug$h = debugWithName("plugin:withPortableTextMarkModel");
1676
1675
  function createWithPortableTextMarkModel(editorActor) {
1677
1676
  return function(editor) {
1678
1677
  const {
@@ -1686,7 +1685,7 @@ function createWithPortableTextMarkModel(editorActor) {
1686
1685
  for (const [child, childPath] of children) {
1687
1686
  const nextNode = node.children[childPath[1] + 1];
1688
1687
  if (editor.isTextSpan(child) && editor.isTextSpan(nextNode) && child.marks?.every((mark) => nextNode.marks?.includes(mark)) && nextNode.marks?.every((mark) => child.marks?.includes(mark))) {
1689
- debug$g("Merging spans", JSON.stringify(child, null, 2), JSON.stringify(nextNode, null, 2)), editorActor.send({
1688
+ debug$h("Merging spans", JSON.stringify(child, null, 2), JSON.stringify(nextNode, null, 2)), editorActor.send({
1690
1689
  type: "normalizing"
1691
1690
  }), Transforms.mergeNodes(editor, {
1692
1691
  at: [childPath[0], childPath[1] + 1],
@@ -1699,7 +1698,7 @@ function createWithPortableTextMarkModel(editorActor) {
1699
1698
  }
1700
1699
  }
1701
1700
  if (editor.isTextBlock(node) && !Array.isArray(node.markDefs)) {
1702
- debug$g("Adding .markDefs to block node"), editorActor.send({
1701
+ debug$h("Adding .markDefs to block node"), editorActor.send({
1703
1702
  type: "normalizing"
1704
1703
  }), Transforms.setNodes(editor, {
1705
1704
  markDefs: []
@@ -1711,7 +1710,7 @@ function createWithPortableTextMarkModel(editorActor) {
1711
1710
  return;
1712
1711
  }
1713
1712
  if (editor.isTextSpan(node) && !Array.isArray(node.marks)) {
1714
- debug$g("Adding .marks to span node"), editorActor.send({
1713
+ debug$h("Adding .marks to span node"), editorActor.send({
1715
1714
  type: "normalizing"
1716
1715
  }), Transforms.setNodes(editor, {
1717
1716
  marks: []
@@ -1725,7 +1724,7 @@ function createWithPortableTextMarkModel(editorActor) {
1725
1724
  if (editor.isTextSpan(node)) {
1726
1725
  const blockPath = Path.parent(path), [block] = Editor.node(editor, blockPath), decorators2 = editorActor.getSnapshot().context.schema.decorators.map((decorator) => decorator.name), annotations = node.marks?.filter((mark) => !decorators2.includes(mark));
1727
1726
  if (editor.isTextBlock(block) && node.text === "" && annotations && annotations.length > 0) {
1728
- debug$g("Removing annotations from empty span node"), editorActor.send({
1727
+ debug$h("Removing annotations from empty span node"), editorActor.send({
1729
1728
  type: "normalizing"
1730
1729
  }), Transforms.setNodes(editor, {
1731
1730
  marks: node.marks?.filter((mark) => decorators2.includes(mark))
@@ -1743,7 +1742,7 @@ function createWithPortableTextMarkModel(editorActor) {
1743
1742
  if (editor.isTextSpan(child)) {
1744
1743
  const marks = child.marks ?? [], orphanedAnnotations = marks.filter((mark) => !decorators2.includes(mark) && !node.markDefs?.find((def) => def._key === mark));
1745
1744
  if (orphanedAnnotations.length > 0) {
1746
- debug$g("Removing orphaned annotations from span node"), editorActor.send({
1745
+ debug$h("Removing orphaned annotations from span node"), editorActor.send({
1747
1746
  type: "normalizing"
1748
1747
  }), Transforms.setNodes(editor, {
1749
1748
  marks: marks.filter((mark) => !orphanedAnnotations.includes(mark))
@@ -1761,7 +1760,7 @@ function createWithPortableTextMarkModel(editorActor) {
1761
1760
  if (editor.isTextBlock(block)) {
1762
1761
  const decorators2 = editorActor.getSnapshot().context.schema.decorators.map((decorator) => decorator.name), marks = node.marks ?? [], orphanedAnnotations = marks.filter((mark) => !decorators2.includes(mark) && !block.markDefs?.find((def) => def._key === mark));
1763
1762
  if (orphanedAnnotations.length > 0) {
1764
- debug$g("Removing orphaned annotations from span node"), editorActor.send({
1763
+ debug$h("Removing orphaned annotations from span node"), editorActor.send({
1765
1764
  type: "normalizing"
1766
1765
  }), Transforms.setNodes(editor, {
1767
1766
  marks: marks.filter((mark) => !orphanedAnnotations.includes(mark))
@@ -1779,7 +1778,7 @@ function createWithPortableTextMarkModel(editorActor) {
1779
1778
  for (const markDef of markDefs)
1780
1779
  markDefKeys.has(markDef._key) || (markDefKeys.add(markDef._key), newMarkDefs.push(markDef));
1781
1780
  if (markDefs.length !== newMarkDefs.length) {
1782
- debug$g("Removing duplicate markDefs"), editorActor.send({
1781
+ debug$h("Removing duplicate markDefs"), editorActor.send({
1783
1782
  type: "normalizing"
1784
1783
  }), Transforms.setNodes(editor, {
1785
1784
  markDefs: newMarkDefs
@@ -1794,7 +1793,7 @@ function createWithPortableTextMarkModel(editorActor) {
1794
1793
  if (editor.isTextBlock(node) && !editor.operations.some((op) => op.type === "merge_node" && "markDefs" in op.properties && op.path.length === 1)) {
1795
1794
  const newMarkDefs = (node.markDefs || []).filter((def) => node.children.find((child) => Text.isText(child) && Array.isArray(child.marks) && child.marks.includes(def._key)));
1796
1795
  if (node.markDefs && !isEqual(newMarkDefs, node.markDefs)) {
1797
- debug$g("Removing markDef not in use"), editorActor.send({
1796
+ debug$h("Removing markDef not in use"), editorActor.send({
1798
1797
  type: "normalizing"
1799
1798
  }), Transforms.setNodes(editor, {
1800
1799
  markDefs: newMarkDefs
@@ -2014,7 +2013,7 @@ function createWithPortableTextMarkModel(editorActor) {
2014
2013
  const [targetBlock, targetPath] = Editor.node(editor, [op.path[0] - 1]);
2015
2014
  if (editor.isTextBlock(targetBlock)) {
2016
2015
  const oldDefs = Array.isArray(targetBlock.markDefs) && targetBlock.markDefs || [], newMarkDefs = uniq([...oldDefs, ...op.properties.markDefs]);
2017
- debug$g("Copying markDefs over to merged block", op), Transforms.setNodes(editor, {
2016
+ debug$h("Copying markDefs over to merged block", op), Transforms.setNodes(editor, {
2018
2017
  markDefs: newMarkDefs
2019
2018
  }, {
2020
2019
  at: targetPath,
@@ -2751,7 +2750,7 @@ function withUndoStep(editor, fn) {
2751
2750
  function getCurrentUndoStepId(editor) {
2752
2751
  return CURRENT_UNDO_STEP.get(editor)?.undoStepId;
2753
2752
  }
2754
- const debug$f = debugWithName("plugin:withUndoRedo"), SAVING = /* @__PURE__ */ new WeakMap(), REMOTE_PATCHES = /* @__PURE__ */ new WeakMap(), UNDO_STEP_LIMIT = 1e3, isSaving = (editor) => {
2753
+ const debug$g = debugWithName("plugin:withUndoRedo"), SAVING = /* @__PURE__ */ new WeakMap(), REMOTE_PATCHES = /* @__PURE__ */ new WeakMap(), UNDO_STEP_LIMIT = 1e3, isSaving = (editor) => {
2755
2754
  const state = SAVING.get(editor);
2756
2755
  return state === void 0 ? !0 : state;
2757
2756
  }, getRemotePatches = (editor) => (REMOTE_PATCHES.get(editor) || REMOTE_PATCHES.set(editor, []), REMOTE_PATCHES.get(editor) || []);
@@ -2764,7 +2763,7 @@ function createWithUndoRedo(options) {
2764
2763
  const remotePatches = getRemotePatches(editor);
2765
2764
  let previousUndoStepId = getCurrentUndoStepId(editor);
2766
2765
  options.subscriptions.push(() => {
2767
- debug$f("Subscribing to patches");
2766
+ debug$g("Subscribing to patches");
2768
2767
  const sub = editorActor.on("patches", ({
2769
2768
  patches,
2770
2769
  snapshot
@@ -2773,7 +2772,7 @@ function createWithUndoRedo(options) {
2773
2772
  patches.forEach((patch) => {
2774
2773
  if (!reset && patch.origin !== "local" && remotePatches) {
2775
2774
  if (patch.type === "unset" && patch.path.length === 0) {
2776
- debug$f("Someone else cleared the content, resetting undo/redo history"), editor.history = {
2775
+ debug$g("Someone else cleared the content, resetting undo/redo history"), editor.history = {
2777
2776
  undos: [],
2778
2777
  redos: []
2779
2778
  }, remotePatches.splice(0, remotePatches.length), SAVING.set(editor, !0), reset = !0;
@@ -2789,7 +2788,7 @@ function createWithUndoRedo(options) {
2789
2788
  }), previousSnapshot = snapshot;
2790
2789
  });
2791
2790
  return () => {
2792
- debug$f("Unsubscribing to patches"), sub.unsubscribe();
2791
+ debug$g("Unsubscribing to patches"), sub.unsubscribe();
2793
2792
  };
2794
2793
  }), editor.history = {
2795
2794
  undos: [],
@@ -2828,7 +2827,7 @@ function createWithUndoRedo(options) {
2828
2827
  operations: [...editor.selection === null ? [] : [createSelectOperation(editor)], op],
2829
2828
  timestamp: /* @__PURE__ */ new Date()
2830
2829
  };
2831
- undos.push(newStep), debug$f("Created new undo step", step);
2830
+ undos.push(newStep), debug$g("Created new undo step", step);
2832
2831
  }
2833
2832
  for (; undos.length > UNDO_STEP_LIMIT; )
2834
2833
  undos.shift();
@@ -2846,7 +2845,7 @@ const historyUndoOperationImplementation = ({
2846
2845
  } = editor.history, remotePatches = getRemotePatches(editor);
2847
2846
  if (undos.length > 0) {
2848
2847
  const step = undos[undos.length - 1];
2849
- if (debug$f("Undoing", step), step.operations.length > 0) {
2848
+ if (debug$g("Undoing", step), step.operations.length > 0) {
2850
2849
  const otherPatches = remotePatches.filter((item) => item.time >= step.timestamp);
2851
2850
  let transformedOperations = step.operations;
2852
2851
  otherPatches.forEach((item) => {
@@ -2864,7 +2863,7 @@ const historyUndoOperationImplementation = ({
2864
2863
  });
2865
2864
  });
2866
2865
  } catch (err) {
2867
- debug$f("Could not perform undo step", err), remotePatches.splice(0, remotePatches.length), Transforms.deselect(editor), editor.history = {
2866
+ debug$g("Could not perform undo step", err), remotePatches.splice(0, remotePatches.length), Transforms.deselect(editor), editor.history = {
2868
2867
  undos: [],
2869
2868
  redos: []
2870
2869
  }, SAVING.set(editor, !0), setIsUndoing(editor, !1), editor.onChange();
@@ -2881,7 +2880,7 @@ const historyUndoOperationImplementation = ({
2881
2880
  } = editor.history, remotePatches = getRemotePatches(editor);
2882
2881
  if (redos.length > 0) {
2883
2882
  const step = redos[redos.length - 1];
2884
- if (debug$f("Redoing", step), step.operations.length > 0) {
2883
+ if (debug$g("Redoing", step), step.operations.length > 0) {
2885
2884
  const otherPatches = remotePatches.filter((item) => item.time >= step.timestamp);
2886
2885
  let transformedOperations = step.operations;
2887
2886
  otherPatches.forEach((item) => {
@@ -2898,7 +2897,7 @@ const historyUndoOperationImplementation = ({
2898
2897
  });
2899
2898
  });
2900
2899
  } catch (err) {
2901
- debug$f("Could not perform redo step", err), remotePatches.splice(0, remotePatches.length), Transforms.deselect(editor), editor.history = {
2900
+ debug$g("Could not perform redo step", err), remotePatches.splice(0, remotePatches.length), Transforms.deselect(editor), editor.history = {
2902
2901
  undos: [],
2903
2902
  redos: []
2904
2903
  }, SAVING.set(editor, !0), setIsRedoing(editor, !1), editor.onChange();
@@ -2916,16 +2915,16 @@ function transformOperation(editor, patch, operation, snapshot, previousSnapshot
2916
2915
  const insertBlockIndex = (snapshot || []).findIndex((blk) => isEqual({
2917
2916
  _key: blk._key
2918
2917
  }, patch.path[0]));
2919
- return debug$f(`Adjusting block path (+${patch.items.length}) for '${transformedOperation.type}' operation and patch '${patch.type}'`), [adjustBlockPath(transformedOperation, patch.items.length, insertBlockIndex)];
2918
+ return debug$g(`Adjusting block path (+${patch.items.length}) for '${transformedOperation.type}' operation and patch '${patch.type}'`), [adjustBlockPath(transformedOperation, patch.items.length, insertBlockIndex)];
2920
2919
  }
2921
2920
  if (patch.type === "unset" && patch.path.length === 1) {
2922
2921
  const unsetBlockIndex = (previousSnapshot || []).findIndex((blk) => isEqual({
2923
2922
  _key: blk._key
2924
2923
  }, patch.path[0]));
2925
- return "path" in transformedOperation && Array.isArray(transformedOperation.path) && transformedOperation.path[0] === unsetBlockIndex ? (debug$f("Skipping transformation that targeted removed block"), []) : [adjustBlockPath(transformedOperation, -1, unsetBlockIndex)];
2924
+ return "path" in transformedOperation && Array.isArray(transformedOperation.path) && transformedOperation.path[0] === unsetBlockIndex ? (debug$g("Skipping transformation that targeted removed block"), []) : [adjustBlockPath(transformedOperation, -1, unsetBlockIndex)];
2926
2925
  }
2927
2926
  if (patch.type === "unset" && patch.path.length === 0)
2928
- return debug$f(`Adjusting selection for unset everything patch and ${operation.type} operation`), [];
2927
+ return debug$g(`Adjusting selection for unset everything patch and ${operation.type} operation`), [];
2929
2928
  if (patch.type === "diffMatchPatch") {
2930
2929
  const operationTargetBlock = findOperationTargetBlock(editor, transformedOperation);
2931
2930
  return !operationTargetBlock || !isEqual({
@@ -4149,13 +4148,13 @@ function createWithObjectKeys(editorActor) {
4149
4148
  }, editor;
4150
4149
  };
4151
4150
  }
4152
- const debug$e = debugWithName("applyPatches"), debugVerbose = debug$e.enabled && !0;
4151
+ const debug$f = debugWithName("applyPatches"), debugVerbose = debug$f.enabled && !0;
4153
4152
  function createApplyPatch(schema) {
4154
4153
  return (editor, patch) => {
4155
4154
  let changed = !1;
4156
- debugVerbose && (debug$e(`
4155
+ debugVerbose && (debug$f(`
4157
4156
 
4158
- NEW PATCH =============================================================`), debug$e(JSON.stringify(patch, null, 2)));
4157
+ NEW PATCH =============================================================`), debug$f(JSON.stringify(patch, null, 2)));
4159
4158
  try {
4160
4159
  switch (patch.type) {
4161
4160
  case "insert":
@@ -4171,7 +4170,7 @@ NEW PATCH =============================================================`), debug
4171
4170
  changed = diffMatchPatch(editor, patch);
4172
4171
  break;
4173
4172
  default:
4174
- debug$e("Unhandled patch", patch.type);
4173
+ debug$f("Unhandled patch", patch.type);
4175
4174
  }
4176
4175
  } catch (err) {
4177
4176
  console.error(err);
@@ -4186,9 +4185,9 @@ function diffMatchPatch(editor, patch) {
4186
4185
  childPath
4187
4186
  } = findBlockAndChildFromPath(editor, patch.path);
4188
4187
  if (!block)
4189
- return debug$e("Block not found"), !1;
4188
+ return debug$f("Block not found"), !1;
4190
4189
  if (!child || !childPath)
4191
- return debug$e("Child not found"), !1;
4190
+ return debug$f("Child not found"), !1;
4192
4191
  if (!(block && editor.isTextBlock(block) && patch.path.length === 4 && patch.path[1] === "children" && patch.path[3] === "text") || !Text.isText(child))
4193
4192
  return !1;
4194
4193
  const patches = parse(patch.value), [newValue] = apply(patches, child.text, {
@@ -4218,9 +4217,9 @@ function insertPatch(editor, patch, schema) {
4218
4217
  childPath: targetChildPath
4219
4218
  } = findBlockAndChildFromPath(editor, patch.path);
4220
4219
  if (!targetBlock || !targetBlockPath)
4221
- return debug$e("Block not found"), !1;
4220
+ return debug$f("Block not found"), !1;
4222
4221
  if (patch.path.length > 1 && patch.path[1] !== "children")
4223
- return debug$e("Ignoring patch targeting void value"), !1;
4222
+ return debug$f("Ignoring patch targeting void value"), !1;
4224
4223
  if (patch.path.length === 1) {
4225
4224
  const {
4226
4225
  items: items2,
@@ -4228,12 +4227,12 @@ function insertPatch(editor, patch, schema) {
4228
4227
  } = patch, blocksToInsert = toSlateValue(items2, {
4229
4228
  schemaTypes: schema
4230
4229
  }, KEY_TO_SLATE_ELEMENT.get(editor)), targetBlockIndex = targetBlockPath[0], normalizedIdx2 = position2 === "after" ? targetBlockIndex + 1 : targetBlockIndex;
4231
- debug$e(`Inserting blocks at path [${normalizedIdx2}]`), debugState(editor, "before");
4230
+ debug$f(`Inserting blocks at path [${normalizedIdx2}]`), debugState(editor, "before");
4232
4231
  const editorWasEmptyBefore = isEqualToEmptyEditor(editor.children, schema);
4233
4232
  return Transforms.insertNodes(editor, blocksToInsert, {
4234
4233
  at: [normalizedIdx2]
4235
- }), editorWasEmptyBefore && Transforms.removeNodes(editor, {
4236
- at: [position2 === "after" ? targetBlockIndex + 1 : targetBlockIndex]
4234
+ }), editorWasEmptyBefore && typeof patch.path[0] == "number" && patch.path[0] === 0 && Transforms.removeNodes(editor, {
4235
+ at: [position2 === "before" ? targetBlockIndex + 1 : targetBlockIndex]
4237
4236
  }), debugState(editor, "after"), !0;
4238
4237
  }
4239
4238
  const {
@@ -4241,14 +4240,14 @@ function insertPatch(editor, patch, schema) {
4241
4240
  position
4242
4241
  } = patch;
4243
4242
  if (!targetChild || !targetChildPath)
4244
- return debug$e("Child not found"), !1;
4243
+ return debug$f("Child not found"), !1;
4245
4244
  const childrenToInsert = targetBlock && toSlateValue([{
4246
4245
  ...targetBlock,
4247
4246
  children: items
4248
4247
  }], {
4249
4248
  schemaTypes: schema
4250
4249
  }, KEY_TO_SLATE_ELEMENT.get(editor)), targetChildIndex = targetChildPath[1], normalizedIdx = position === "after" ? targetChildIndex + 1 : targetChildIndex, childInsertPath = [targetChildPath[0], normalizedIdx];
4251
- return debug$e(`Inserting children at path ${childInsertPath}`), debugState(editor, "before"), childrenToInsert && Element$1.isElement(childrenToInsert[0]) && Transforms.insertNodes(editor, childrenToInsert[0].children, {
4250
+ return debug$f(`Inserting children at path ${childInsertPath}`), debugState(editor, "before"), childrenToInsert && Element$1.isElement(childrenToInsert[0]) && Transforms.insertNodes(editor, childrenToInsert[0].children, {
4252
4251
  at: childInsertPath
4253
4252
  }), debugState(editor, "after"), !0;
4254
4253
  }
@@ -4262,14 +4261,14 @@ function setPatch(editor, patch) {
4262
4261
  childPath
4263
4262
  } = findBlockAndChildFromPath(editor, patch.path);
4264
4263
  if (!block)
4265
- return debug$e("Block not found"), !1;
4264
+ return debug$f("Block not found"), !1;
4266
4265
  const isTextBlock2 = editor.isTextBlock(block);
4267
4266
  if (isTextBlock2 && patch.path.length > 1 && patch.path[1] !== "children")
4268
- return debug$e("Ignoring setting void value"), !1;
4267
+ return debug$f("Ignoring setting void value"), !1;
4269
4268
  if (debugState(editor, "before"), isTextBlock2 && child && childPath) {
4270
4269
  if (Text.isText(value) && Text.isText(child)) {
4271
4270
  const newText = child.text;
4272
- value.text !== newText && (debug$e("Setting text property"), editor.apply({
4271
+ value.text !== newText && (debug$f("Setting text property"), editor.apply({
4273
4272
  type: "remove_text",
4274
4273
  path: childPath,
4275
4274
  offset: 0,
@@ -4281,7 +4280,7 @@ function setPatch(editor, patch) {
4281
4280
  text: value.text
4282
4281
  }), editor.onChange());
4283
4282
  } else
4284
- debug$e("Setting non-text property"), editor.apply({
4283
+ debug$f("Setting non-text property"), editor.apply({
4285
4284
  type: "set_node",
4286
4285
  path: childPath,
4287
4286
  properties: {},
@@ -4289,7 +4288,7 @@ function setPatch(editor, patch) {
4289
4288
  });
4290
4289
  return !0;
4291
4290
  } else if (Element$1.isElement(block) && patch.path.length === 1 && blockPath) {
4292
- debug$e("Setting block property");
4291
+ debug$f("Setting block property");
4293
4292
  const {
4294
4293
  children,
4295
4294
  ...nextRest
@@ -4306,7 +4305,7 @@ function setPatch(editor, patch) {
4306
4305
  ...prevRest
4307
4306
  },
4308
4307
  newProperties: nextRest
4309
- }), debug$e("Setting children"), block.children.forEach((c2, cIndex) => {
4308
+ }), debug$f("Setting children"), block.children.forEach((c2, cIndex) => {
4310
4309
  editor.apply({
4311
4310
  type: "remove_node",
4312
4311
  path: blockPath.concat(block.children.length - 1 - cIndex),
@@ -4337,7 +4336,7 @@ function setPatch(editor, patch) {
4337
4336
  }
4338
4337
  function unsetPatch(editor, patch) {
4339
4338
  if (patch.path.length === 0) {
4340
- debug$e("Removing everything"), debugState(editor, "before");
4339
+ debug$f("Removing everything"), debugState(editor, "before");
4341
4340
  const previousSelection = editor.selection;
4342
4341
  Transforms.deselect(editor);
4343
4342
  const children = Node.children(editor, [], {
@@ -4368,13 +4367,13 @@ function unsetPatch(editor, patch) {
4368
4367
  } = findBlockAndChildFromPath(editor, patch.path);
4369
4368
  if (patch.path.length === 1) {
4370
4369
  if (!block || !blockPath)
4371
- return debug$e("Block not found"), !1;
4370
+ return debug$f("Block not found"), !1;
4372
4371
  const blockIndex = blockPath[0];
4373
- return debug$e(`Removing block at path [${blockIndex}]`), debugState(editor, "before"), Transforms.removeNodes(editor, {
4372
+ return debug$f(`Removing block at path [${blockIndex}]`), debugState(editor, "before"), Transforms.removeNodes(editor, {
4374
4373
  at: [blockIndex]
4375
4374
  }), debugState(editor, "after"), !0;
4376
4375
  }
4377
- return editor.isTextBlock(block) && patch.path[1] === "children" && patch.path.length === 3 ? !child || !childPath ? (debug$e("Child not found"), !1) : (debug$e(`Unsetting child at path ${JSON.stringify(childPath)}`), debugState(editor, "before"), debugVerbose && debug$e(`Removing child at path ${JSON.stringify(childPath)}`), Transforms.removeNodes(editor, {
4376
+ return editor.isTextBlock(block) && patch.path[1] === "children" && patch.path.length === 3 ? !child || !childPath ? (debug$f("Child not found"), !1) : (debug$f(`Unsetting child at path ${JSON.stringify(childPath)}`), debugState(editor, "before"), debugVerbose && debug$f(`Removing child at path ${JSON.stringify(childPath)}`), Transforms.removeNodes(editor, {
4378
4377
  at: childPath
4379
4378
  }), debugState(editor, "after"), !0) : !1;
4380
4379
  }
@@ -4382,7 +4381,7 @@ function isKeyedSegment(segment) {
4382
4381
  return typeof segment == "object" && "_key" in segment;
4383
4382
  }
4384
4383
  function debugState(editor, stateName) {
4385
- debugVerbose && (debug$e(`Children ${stateName}:`, JSON.stringify(editor.children, null, 2)), debug$e(`Selection ${stateName}: `, JSON.stringify(editor.selection, null, 2)));
4384
+ debugVerbose && (debug$f(`Children ${stateName}:`, JSON.stringify(editor.children, null, 2)), debug$f(`Selection ${stateName}: `, JSON.stringify(editor.selection, null, 2)));
4386
4385
  }
4387
4386
  function findBlockFromPath(editor, path) {
4388
4387
  let blockIndex = -1;
@@ -4432,9 +4431,10 @@ function withoutPatching(editor, fn) {
4432
4431
  function isPatching(editor) {
4433
4432
  return PATCHING.get(editor);
4434
4433
  }
4435
- const debug$d = debugWithName("plugin:withPatches");
4434
+ const debug$e = debugWithName("plugin:withPatches");
4436
4435
  function createWithPatches({
4437
4436
  editorActor,
4437
+ relayActor,
4438
4438
  patchFunctions,
4439
4439
  subscriptions
4440
4440
  }) {
@@ -4457,7 +4457,7 @@ function createWithPatches({
4457
4457
  withoutPatching(editor, () => {
4458
4458
  withoutSaving(editor, () => {
4459
4459
  for (const patch of patches) {
4460
- debug$d.enabled && debug$d(`Handling remote patch ${JSON.stringify(patch)}`);
4460
+ debug$e.enabled && debug$e(`Handling remote patch ${JSON.stringify(patch)}`);
4461
4461
  try {
4462
4462
  changed = applyPatch(editor, patch);
4463
4463
  } catch (error) {
@@ -4475,10 +4475,10 @@ function createWithPatches({
4475
4475
  remotePatches.length !== 0 && (bufferedPatches = bufferedPatches.concat(remotePatches), handleBufferedRemotePatches());
4476
4476
  };
4477
4477
  return subscriptions.push(() => {
4478
- debug$d("Subscribing to remote patches");
4478
+ debug$e("Subscribing to remote patches");
4479
4479
  const sub = editorActor.on("patches", handlePatches);
4480
4480
  return () => {
4481
- debug$d("Unsubscribing to remote patches"), sub.unsubscribe();
4481
+ debug$e("Unsubscribing to remote patches"), sub.unsubscribe();
4482
4482
  };
4483
4483
  }), editor.apply = (operation) => {
4484
4484
  let patches = [];
@@ -4514,8 +4514,8 @@ function createWithPatches({
4514
4514
  patches = [...patches, ...patchFunctions.moveNodePatch(editor, operation, previousChildren)];
4515
4515
  break;
4516
4516
  }
4517
- if (!editorWasEmpty && editorIsEmpty && ["merge_node", "set_node", "remove_text", "remove_node"].includes(operation.type) && (patches = [...patches, unset([])], editorActor.send({
4518
- type: "notify.unset",
4517
+ if (!editorWasEmpty && editorIsEmpty && ["merge_node", "set_node", "remove_text", "remove_node"].includes(operation.type) && (patches = [...patches, unset([])], relayActor.send({
4518
+ type: "unset",
4519
4519
  previousValue: fromSlateValue(previousChildren, editorActor.getSnapshot().context.schema.block.name, KEY_TO_VALUE_ELEMENT.get(editor))
4520
4520
  })), editorWasEmpty && patches.length > 0 && (patches = [setIfMissing([], []), ...patches]), patches.length > 0)
4521
4521
  for (const patch of patches)
@@ -4532,7 +4532,7 @@ function createWithPatches({
4532
4532
  }, editor;
4533
4533
  };
4534
4534
  }
4535
- const debug$c = debugWithName("plugin:withPlaceholderBlock");
4535
+ const debug$d = debugWithName("plugin:withPlaceholderBlock");
4536
4536
  function createWithPlaceholderBlock(editorActor) {
4537
4537
  return function(editor) {
4538
4538
  const {
@@ -4557,7 +4557,7 @@ function createWithPlaceholderBlock(editorActor) {
4557
4557
  const node = op.node;
4558
4558
  if (op.path[0] === 0 && Editor.isVoid(editor, node)) {
4559
4559
  const nextPath = Path.next(op.path);
4560
- editor.children[nextPath[0]] || (debug$c("Adding placeholder block"), Editor.insertNode(editor, editor.pteCreateTextBlock({
4560
+ editor.children[nextPath[0]] || (debug$d("Adding placeholder block"), Editor.insertNode(editor, editor.pteCreateTextBlock({
4561
4561
  decorators: []
4562
4562
  })));
4563
4563
  }
@@ -4566,7 +4566,7 @@ function createWithPlaceholderBlock(editorActor) {
4566
4566
  }, editor;
4567
4567
  };
4568
4568
  }
4569
- const debug$b = debugWithName("plugin:withPortableTextBlockStyle");
4569
+ const debug$c = debugWithName("plugin:withPortableTextBlockStyle");
4570
4570
  function createWithPortableTextBlockStyle(editorActor) {
4571
4571
  const defaultStyle = editorActor.getSnapshot().context.schema.styles[0].name;
4572
4572
  return function(editor) {
@@ -4579,7 +4579,7 @@ function createWithPortableTextBlockStyle(editorActor) {
4579
4579
  if (op.type === "split_node" && op.path.length === 1 && editor.isTextBlock(op.properties) && op.properties.style !== defaultStyle && op.path[0] === path[0] && !Path.equals(path, op.path)) {
4580
4580
  const [child] = Editor.node(editor, [op.path[0] + 1, 0]);
4581
4581
  if (Text.isText(child) && child.text === "") {
4582
- debug$b(`Normalizing split node to ${defaultStyle} style`, op), editorActor.send({
4582
+ debug$c(`Normalizing split node to ${defaultStyle} style`, op), editorActor.send({
4583
4583
  type: "normalizing"
4584
4584
  }), Transforms.setNodes(editor, {
4585
4585
  style: defaultStyle
@@ -4597,7 +4597,7 @@ function createWithPortableTextBlockStyle(editorActor) {
4597
4597
  };
4598
4598
  }
4599
4599
  debugWithName("plugin:withPortableTextSelections");
4600
- function createWithPortableTextSelections(editorActor) {
4600
+ function createWithPortableTextSelections(editorActor, relayActor) {
4601
4601
  let prevSelection = null;
4602
4602
  return function(editor) {
4603
4603
  const emitPortableTextSelection = () => {
@@ -4611,11 +4611,11 @@ function createWithPortableTextSelections(editorActor) {
4611
4611
  range: editor.selection
4612
4612
  }), SLATE_TO_PORTABLE_TEXT_RANGE.set(editor.selection, ptRange));
4613
4613
  }
4614
- ptRange ? editorActor.send({
4615
- type: "notify.selection",
4614
+ ptRange ? relayActor.send({
4615
+ type: "selection",
4616
4616
  selection: ptRange
4617
- }) : editorActor.send({
4618
- type: "notify.selection",
4617
+ }) : relayActor.send({
4618
+ type: "selection",
4619
4619
  selection: null
4620
4620
  });
4621
4621
  }
@@ -4630,7 +4630,7 @@ function createWithPortableTextSelections(editorActor) {
4630
4630
  }, editor;
4631
4631
  };
4632
4632
  }
4633
- const debug$a = debugWithName("plugin:withSchemaTypes");
4633
+ const debug$b = debugWithName("plugin:withSchemaTypes");
4634
4634
  function createWithSchemaTypes({
4635
4635
  editorActor
4636
4636
  }) {
@@ -4642,7 +4642,7 @@ function createWithSchemaTypes({
4642
4642
  return editor.normalizeNode = (entry) => {
4643
4643
  const [node, path] = entry;
4644
4644
  if (node._type === void 0 && path.length === 2) {
4645
- debug$a("Setting span type on text node without a type");
4645
+ debug$b("Setting span type on text node without a type");
4646
4646
  const span = node, key = span._key || editorActor.getSnapshot().context.keyGenerator();
4647
4647
  editorActor.send({
4648
4648
  type: "normalizing"
@@ -4658,7 +4658,7 @@ function createWithSchemaTypes({
4658
4658
  return;
4659
4659
  }
4660
4660
  if (node._key === void 0 && (path.length === 1 || path.length === 2)) {
4661
- debug$a("Setting missing key on child node without a key");
4661
+ debug$b("Setting missing key on child node without a key");
4662
4662
  const key = editorActor.getSnapshot().context.keyGenerator();
4663
4663
  editorActor.send({
4664
4664
  type: "normalizing"
@@ -4705,11 +4705,13 @@ function createWithUtils({
4705
4705
  }
4706
4706
  const withPlugins = (editor, options) => {
4707
4707
  const e = editor, {
4708
- editorActor
4708
+ editorActor,
4709
+ relayActor
4709
4710
  } = options, operationToPatches = createOperationToPatches(editorActor), withObjectKeys = createWithObjectKeys(editorActor), withSchemaTypes = createWithSchemaTypes({
4710
4711
  editorActor
4711
4712
  }), withPatches = createWithPatches({
4712
4713
  editorActor,
4714
+ relayActor,
4713
4715
  patchFunctions: operationToPatches,
4714
4716
  subscriptions: options.subscriptions
4715
4717
  }), withMaxBlocks = createWithMaxBlocks(editorActor), withUndoRedo = createWithUndoRedo({
@@ -4717,13 +4719,14 @@ const withPlugins = (editor, options) => {
4717
4719
  subscriptions: options.subscriptions
4718
4720
  }), withPortableTextMarkModel = createWithPortableTextMarkModel(editorActor), withPortableTextBlockStyle = createWithPortableTextBlockStyle(editorActor), withPlaceholderBlock = createWithPlaceholderBlock(editorActor), withUtils = createWithUtils({
4719
4721
  editorActor
4720
- }), withPortableTextSelections = createWithPortableTextSelections(editorActor);
4722
+ }), withPortableTextSelections = createWithPortableTextSelections(editorActor, relayActor);
4721
4723
  return createWithEventListeners(editorActor)(withSchemaTypes(withObjectKeys(withPortableTextMarkModel(withPortableTextBlockStyle(withPlaceholderBlock(withUtils(withMaxBlocks(withUndoRedo(withPatches(withPortableTextSelections(e)))))))))));
4722
- }, debug$9 = debugWithName("setup");
4724
+ }, debug$a = debugWithName("setup");
4723
4725
  function createSlateEditor(config) {
4724
- debug$9("Creating new Slate editor instance");
4726
+ debug$a("Creating new Slate editor instance");
4725
4727
  const instance = withPlugins(withReact(createEditor()), {
4726
4728
  editorActor: config.editorActor,
4729
+ relayActor: config.relayActor,
4727
4730
  subscriptions: config.subscriptions
4728
4731
  });
4729
4732
  KEY_TO_VALUE_ELEMENT.set(instance, {}), KEY_TO_SLATE_ELEMENT.set(instance, {});
@@ -6299,7 +6302,7 @@ function isNativeBehaviorEvent(event) {
6299
6302
  function isCustomBehaviorEvent(event) {
6300
6303
  return event.type.startsWith("custom.");
6301
6304
  }
6302
- const debug$8 = debugWithName("behaviors:event");
6305
+ const debug$9 = debugWithName("behaviors:event");
6303
6306
  function eventCategory(event) {
6304
6307
  return isNativeBehaviorEvent(event) ? "native" : isAbstractBehaviorEvent(event) ? "synthetic" : isCustomBehaviorEvent(event) ? "custom" : "synthetic";
6305
6308
  }
@@ -6314,7 +6317,7 @@ function performEvent({
6314
6317
  getSnapshot,
6315
6318
  nativeEvent
6316
6319
  }) {
6317
- debug$8(`(${mode}:${eventCategory(event)})`, JSON.stringify(event, null, 2));
6320
+ debug$9(`(${mode}:${eventCategory(event)})`, JSON.stringify(event, null, 2));
6318
6321
  const eventBehaviors = [...remainingEventBehaviors, ...abstractBehaviors].filter((behavior) => {
6319
6322
  if (behavior.on === "*")
6320
6323
  return !0;
@@ -6323,7 +6326,7 @@ function performEvent({
6323
6326
  });
6324
6327
  if (eventBehaviors.length === 0 && isSyntheticBehaviorEvent(event)) {
6325
6328
  nativeEvent?.preventDefault(), withApplyingBehaviorOperations(editor, () => {
6326
- debug$8(`(execute:${eventCategory(event)})`, JSON.stringify(event, null, 2)), performOperation({
6329
+ debug$9(`(execute:${eventCategory(event)})`, JSON.stringify(event, null, 2)), performOperation({
6327
6330
  context: {
6328
6331
  keyGenerator,
6329
6332
  schema
@@ -6466,7 +6469,7 @@ function performEvent({
6466
6469
  }
6467
6470
  }
6468
6471
  !defaultBehaviorOverwritten && isSyntheticBehaviorEvent(event) ? (nativeEvent?.preventDefault(), withApplyingBehaviorOperations(editor, () => {
6469
- debug$8(`(execute:${eventCategory(event)})`, JSON.stringify(event, null, 2)), performOperation({
6472
+ debug$9(`(execute:${eventCategory(event)})`, JSON.stringify(event, null, 2)), performOperation({
6470
6473
  context: {
6471
6474
  keyGenerator,
6472
6475
  schema
@@ -6591,7 +6594,7 @@ function createEditorSnapshot({
6591
6594
  }
6592
6595
  };
6593
6596
  }
6594
- const debug$7 = debugWithName("editor machine"), editorMachine = setup({
6597
+ const debug$8 = debugWithName("editor machine"), editorMachine = setup({
6595
6598
  types: {
6596
6599
  context: {},
6597
6600
  events: {},
@@ -6612,19 +6615,11 @@ const debug$7 = debugWithName("editor machine"), editorMachine = setup({
6612
6615
  event
6613
6616
  }) => (assertEvent(event, "remove behavior"), context.behaviors.delete(event.behaviorConfig), /* @__PURE__ */ new Set([...context.behaviors]))
6614
6617
  }),
6615
- "assign schema": assign({
6616
- schema: ({
6617
- event
6618
- }) => (assertEvent(event, "update schema"), event.schema)
6619
- }),
6620
6618
  "emit patch event": enqueueActions(({
6621
6619
  event,
6622
6620
  enqueue
6623
6621
  }) => {
6624
- assertEvent(event, "internal.patch"), enqueue.emit(event), enqueue.emit({
6625
- type: "patch",
6626
- patch: event.patch
6627
- });
6622
+ assertEvent(event, "internal.patch"), enqueue.emit(event);
6628
6623
  }),
6629
6624
  "emit mutation event": emit(({
6630
6625
  event
@@ -6646,10 +6641,7 @@ const debug$7 = debugWithName("editor machine"), editorMachine = setup({
6646
6641
  enqueue
6647
6642
  }) => {
6648
6643
  for (const event of context.pendingEvents)
6649
- event.type === "internal.patch" ? (enqueue.emit(event), enqueue.emit({
6650
- type: "patch",
6651
- patch: event.patch
6652
- })) : enqueue.emit(event);
6644
+ enqueue.emit(event);
6653
6645
  }),
6654
6646
  "emit ready": emit({
6655
6647
  type: "ready"
@@ -6754,98 +6746,25 @@ const debug$7 = debugWithName("editor machine"), editorMachine = setup({
6754
6746
  initialValue: input.initialValue
6755
6747
  }),
6756
6748
  on: {
6757
- "notify.blurred": {
6758
- actions: emit(({
6759
- event
6760
- }) => ({
6761
- ...event,
6762
- type: "blurred"
6763
- }))
6764
- },
6765
- "notify.done loading": {
6766
- actions: emit({
6767
- type: "done loading"
6768
- })
6769
- },
6770
- "notify.error": {
6771
- actions: emit(({
6772
- event
6773
- }) => ({
6774
- ...event,
6775
- type: "error"
6776
- }))
6777
- },
6778
- "notify.invalid value": {
6779
- actions: emit(({
6780
- event
6781
- }) => ({
6782
- ...event,
6783
- type: "invalid value"
6784
- }))
6785
- },
6786
- "notify.focused": {
6787
- actions: emit(({
6788
- event
6789
- }) => ({
6790
- ...event,
6791
- type: "focused"
6792
- }))
6793
- },
6794
- "notify.selection": {
6795
- actions: [assign({
6796
- selection: ({
6797
- event
6798
- }) => event.selection
6799
- }), emit(({
6800
- event
6801
- }) => ({
6802
- ...event,
6803
- type: "selection"
6804
- }))]
6805
- },
6806
- "notify.unset": {
6807
- actions: emit(({
6808
- event
6809
- }) => ({
6810
- ...event,
6811
- type: "unset"
6812
- }))
6813
- },
6814
- "notify.loading": {
6815
- actions: emit({
6816
- type: "loading"
6817
- })
6818
- },
6819
- "notify.value changed": {
6820
- actions: emit(({
6821
- event
6822
- }) => ({
6823
- ...event,
6824
- type: "value changed"
6825
- }))
6826
- },
6827
6749
  "add behavior": {
6828
6750
  actions: "add behavior to context"
6829
6751
  },
6830
6752
  "remove behavior": {
6831
6753
  actions: "remove behavior from context"
6832
6754
  },
6833
- "update key generator": {
6834
- actions: assign({
6835
- keyGenerator: ({
6836
- event
6837
- }) => event.keyGenerator
6838
- })
6839
- },
6840
- "update schema": {
6841
- actions: "assign schema"
6842
- },
6843
6755
  "update maxBlocks": {
6844
6756
  actions: assign({
6845
6757
  maxBlocks: ({
6846
6758
  event
6847
6759
  }) => event.maxBlocks
6848
6760
  })
6761
+ },
6762
+ "update selection": {
6763
+ actions: [assign({
6764
+ selection: ({
6765
+ event
6766
+ }) => event.selection
6767
+ })]
6849
6768
  }
6850
6769
  },
6851
6770
  type: "parallel",
@@ -6866,10 +6785,10 @@ const debug$7 = debugWithName("editor machine"), editorMachine = setup({
6866
6785
  states: {
6867
6786
  "determine initial edit mode": {
6868
6787
  entry: [() => {
6869
- debug$7("entry: edit mode->read only->determine initial edit mode");
6788
+ debug$8("entry: edit mode->read only->determine initial edit mode");
6870
6789
  }],
6871
6790
  exit: [() => {
6872
- debug$7("exit: edit mode->read only->determine initial edit mode");
6791
+ debug$8("exit: edit mode->read only->determine initial edit mode");
6873
6792
  }],
6874
6793
  on: {
6875
6794
  "done syncing value": [{
@@ -6884,10 +6803,10 @@ const debug$7 = debugWithName("editor machine"), editorMachine = setup({
6884
6803
  },
6885
6804
  "read only": {
6886
6805
  entry: [() => {
6887
- debug$7("entry: edit mode->read only->read only");
6806
+ debug$8("entry: edit mode->read only->read only");
6888
6807
  }],
6889
6808
  exit: [() => {
6890
- debug$7("exit: edit mode->read only->read only");
6809
+ debug$8("exit: edit mode->read only->read only");
6891
6810
  }],
6892
6811
  on: {
6893
6812
  "update readOnly": {
@@ -6929,10 +6848,10 @@ const debug$7 = debugWithName("editor machine"), editorMachine = setup({
6929
6848
  states: {
6930
6849
  idle: {
6931
6850
  entry: [() => {
6932
- debug$7("entry: edit mode->editable->idle");
6851
+ debug$8("entry: edit mode->editable->idle");
6933
6852
  }],
6934
6853
  exit: [() => {
6935
- debug$7("exit: edit mode->editable-idle");
6854
+ debug$8("exit: edit mode->editable-idle");
6936
6855
  }],
6937
6856
  on: {
6938
6857
  dragstart: {
@@ -6953,10 +6872,10 @@ const debug$7 = debugWithName("editor machine"), editorMachine = setup({
6953
6872
  states: {
6954
6873
  "checking if busy": {
6955
6874
  entry: [() => {
6956
- debug$7("entry: edit mode->editable->focusing->checking if busy");
6875
+ debug$8("entry: edit mode->editable->focusing->checking if busy");
6957
6876
  }],
6958
6877
  exit: [() => {
6959
- debug$7("exit: edit mode->editable->focusing->checking if busy");
6878
+ debug$8("exit: edit mode->editable->focusing->checking if busy");
6960
6879
  }],
6961
6880
  always: [{
6962
6881
  guard: "slate is busy",
@@ -6968,10 +6887,10 @@ const debug$7 = debugWithName("editor machine"), editorMachine = setup({
6968
6887
  },
6969
6888
  busy: {
6970
6889
  entry: [() => {
6971
- debug$7("entry: edit mode->editable->focusing-busy");
6890
+ debug$8("entry: edit mode->editable->focusing-busy");
6972
6891
  }],
6973
6892
  exit: [() => {
6974
- debug$7("exit: edit mode->editable->focusing->busy");
6893
+ debug$8("exit: edit mode->editable->focusing->busy");
6975
6894
  }],
6976
6895
  after: {
6977
6896
  10: {
@@ -6983,10 +6902,10 @@ const debug$7 = debugWithName("editor machine"), editorMachine = setup({
6983
6902
  },
6984
6903
  "dragging internally": {
6985
6904
  entry: [() => {
6986
- debug$7("entry: edit mode->editable->dragging internally");
6905
+ debug$8("entry: edit mode->editable->dragging internally");
6987
6906
  }],
6988
6907
  exit: [() => {
6989
- debug$7("exit: edit mode->editable->dragging internally");
6908
+ debug$8("exit: edit mode->editable->dragging internally");
6990
6909
  }, ({
6991
6910
  context
6992
6911
  }) => {
@@ -7018,10 +6937,10 @@ const debug$7 = debugWithName("editor machine"), editorMachine = setup({
7018
6937
  states: {
7019
6938
  "setting up": {
7020
6939
  entry: [() => {
7021
- debug$7("entry: setup->setting up");
6940
+ debug$8("entry: setup->setting up");
7022
6941
  }],
7023
6942
  exit: [() => {
7024
- debug$7("exit: setup->setting up");
6943
+ debug$8("exit: setup->setting up");
7025
6944
  }, "emit ready", "emit pending incoming patches", "clear pending incoming patches"],
7026
6945
  on: {
7027
6946
  "internal.patch": {
@@ -7046,10 +6965,10 @@ const debug$7 = debugWithName("editor machine"), editorMachine = setup({
7046
6965
  states: {
7047
6966
  idle: {
7048
6967
  entry: [() => {
7049
- debug$7("entry: setup->set up->value sync->idle");
6968
+ debug$8("entry: setup->set up->value sync->idle");
7050
6969
  }],
7051
6970
  exit: [() => {
7052
- debug$7("exit: setup->set up->value sync->idle");
6971
+ debug$8("exit: setup->set up->value sync->idle");
7053
6972
  }],
7054
6973
  on: {
7055
6974
  patches: {
@@ -7064,10 +6983,10 @@ const debug$7 = debugWithName("editor machine"), editorMachine = setup({
7064
6983
  },
7065
6984
  "syncing value": {
7066
6985
  entry: [() => {
7067
- debug$7("entry: setup->set up->value sync->syncing value");
6986
+ debug$8("entry: setup->set up->value sync->syncing value");
7068
6987
  }],
7069
6988
  exit: [() => {
7070
- debug$7("exit: setup->set up->value sync->syncing value");
6989
+ debug$8("exit: setup->set up->value sync->syncing value");
7071
6990
  }, "emit pending incoming patches", "clear pending incoming patches"],
7072
6991
  on: {
7073
6992
  patches: {
@@ -7088,10 +7007,10 @@ const debug$7 = debugWithName("editor machine"), editorMachine = setup({
7088
7007
  states: {
7089
7008
  idle: {
7090
7009
  entry: [() => {
7091
- debug$7("entry: setup->set up->writing->pristine->idle");
7010
+ debug$8("entry: setup->set up->writing->pristine->idle");
7092
7011
  }],
7093
7012
  exit: [() => {
7094
- debug$7("exit: setup->set up->writing->pristine->idle");
7013
+ debug$8("exit: setup->set up->writing->pristine->idle");
7095
7014
  }],
7096
7015
  on: {
7097
7016
  normalizing: {
@@ -7109,10 +7028,10 @@ const debug$7 = debugWithName("editor machine"), editorMachine = setup({
7109
7028
  },
7110
7029
  normalizing: {
7111
7030
  entry: [() => {
7112
- debug$7("entry: setup->set up->writing->pristine->normalizing");
7031
+ debug$8("entry: setup->set up->writing->pristine->normalizing");
7113
7032
  }],
7114
7033
  exit: [() => {
7115
- debug$7("exit: setup->set up->writing->pristine->normalizing");
7034
+ debug$8("exit: setup->set up->writing->pristine->normalizing");
7116
7035
  }],
7117
7036
  on: {
7118
7037
  "done normalizing": {
@@ -7130,10 +7049,10 @@ const debug$7 = debugWithName("editor machine"), editorMachine = setup({
7130
7049
  },
7131
7050
  dirty: {
7132
7051
  entry: [() => {
7133
- debug$7("entry: setup->set up->writing->dirty");
7052
+ debug$8("entry: setup->set up->writing->dirty");
7134
7053
  }, "emit pending events", "clear pending events"],
7135
7054
  exit: [() => {
7136
- debug$7("exit: setup->set up->writing->dirty");
7055
+ debug$8("exit: setup->set up->writing->dirty");
7137
7056
  }],
7138
7057
  on: {
7139
7058
  "internal.patch": {
@@ -7386,7 +7305,7 @@ function getEditorSnapshot({
7386
7305
  }
7387
7306
  };
7388
7307
  }
7389
- const mutationMachine = setup({
7308
+ const debug$7 = debugWithName("mutation-machine"), mutationMachine = setup({
7390
7309
  types: {
7391
7310
  context: {},
7392
7311
  events: {},
@@ -7394,8 +7313,23 @@ const mutationMachine = setup({
7394
7313
  emitted: {}
7395
7314
  },
7396
7315
  actions: {
7397
- "emit has pending patches": emit({
7398
- type: "has pending patches"
7316
+ "assign readOnly": assign({
7317
+ readOnly: ({
7318
+ context,
7319
+ event
7320
+ }) => event.type === "update readOnly" ? event.readOnly : context.readOnly
7321
+ }),
7322
+ "emit patch": enqueueActions(({
7323
+ event,
7324
+ enqueue
7325
+ }) => {
7326
+ event.type === "patch" && enqueue.emit({
7327
+ type: "patch",
7328
+ patch: event.patch
7329
+ });
7330
+ }),
7331
+ "emit has pending mutations": emit({
7332
+ type: "has pending mutations"
7399
7333
  }),
7400
7334
  "emit mutations": enqueueActions(({
7401
7335
  context,
@@ -7411,7 +7345,7 @@ const mutationMachine = setup({
7411
7345
  "clear pending mutations": assign({
7412
7346
  pendingMutations: []
7413
7347
  }),
7414
- "defer patch": assign({
7348
+ "defer mutation": assign({
7415
7349
  pendingMutations: ({
7416
7350
  context,
7417
7351
  event
@@ -7433,6 +7367,22 @@ const mutationMachine = setup({
7433
7367
  patches: [event.patch]
7434
7368
  });
7435
7369
  }
7370
+ }),
7371
+ "clear pending patch events": assign({
7372
+ pendingPatchEvents: []
7373
+ }),
7374
+ "defer patch": assign({
7375
+ pendingPatchEvents: ({
7376
+ context,
7377
+ event
7378
+ }) => event.type === "patch" ? [...context.pendingPatchEvents, event] : context.pendingPatchEvents
7379
+ }),
7380
+ "emit pending patch events": enqueueActions(({
7381
+ context,
7382
+ enqueue
7383
+ }) => {
7384
+ for (const event of context.pendingPatchEvents)
7385
+ enqueue.emit(event);
7436
7386
  })
7437
7387
  },
7438
7388
  actors: {
@@ -7453,6 +7403,9 @@ const mutationMachine = setup({
7453
7403
  })
7454
7404
  },
7455
7405
  guards: {
7406
+ "is read-only": ({
7407
+ context
7408
+ }) => context.readOnly,
7456
7409
  "is typing": stateIn({
7457
7410
  typing: "typing"
7458
7411
  }),
@@ -7473,9 +7426,16 @@ const mutationMachine = setup({
7473
7426
  input
7474
7427
  }) => ({
7475
7428
  pendingMutations: [],
7429
+ pendingPatchEvents: [],
7430
+ readOnly: input.readOnly,
7476
7431
  schema: input.schema,
7477
7432
  slateEditor: input.slateEditor
7478
7433
  }),
7434
+ on: {
7435
+ "update readOnly": {
7436
+ actions: ["assign readOnly"]
7437
+ }
7438
+ },
7479
7439
  type: "parallel",
7480
7440
  states: {
7481
7441
  typing: {
@@ -7490,6 +7450,12 @@ const mutationMachine = setup({
7490
7450
  },
7491
7451
  states: {
7492
7452
  idle: {
7453
+ entry: [() => {
7454
+ debug$7("entry: typing->idle");
7455
+ }],
7456
+ exit: [() => {
7457
+ debug$7("exit: typing->idle");
7458
+ }],
7493
7459
  on: {
7494
7460
  typing: {
7495
7461
  target: "typing"
@@ -7497,6 +7463,12 @@ const mutationMachine = setup({
7497
7463
  }
7498
7464
  },
7499
7465
  typing: {
7466
+ entry: [() => {
7467
+ debug$7("entry: typing->typing");
7468
+ }],
7469
+ exit: [() => {
7470
+ debug$7("exit: typing->typing");
7471
+ }],
7500
7472
  after: {
7501
7473
  "type debounce": {
7502
7474
  target: "idle"
@@ -7518,16 +7490,31 @@ const mutationMachine = setup({
7518
7490
  initial: "idle",
7519
7491
  states: {
7520
7492
  idle: {
7493
+ entry: [() => {
7494
+ debug$7("entry: mutations->idle");
7495
+ }],
7496
+ exit: [() => {
7497
+ debug$7("exit: mutations->idle");
7498
+ }],
7521
7499
  on: {
7522
7500
  patch: {
7523
- actions: ["defer patch", "emit has pending patches"],
7501
+ actions: ["emit patch", "defer mutation", "emit has pending mutations"],
7524
7502
  target: "emitting mutations"
7525
7503
  }
7526
7504
  }
7527
7505
  },
7528
7506
  "emitting mutations": {
7507
+ entry: [() => {
7508
+ debug$7("entry: mutations->emitting mutations");
7509
+ }],
7510
+ exit: [() => {
7511
+ debug$7("exit: mutations->emitting mutations");
7512
+ }],
7529
7513
  after: {
7530
7514
  "mutation debounce": [{
7515
+ guard: "is read-only",
7516
+ target: "read-only"
7517
+ }, {
7531
7518
  guard: and([not("is typing"), "slate is normalizing"]),
7532
7519
  target: "idle",
7533
7520
  actions: ["emit mutations", "clear pending mutations"]
@@ -7539,10 +7526,28 @@ const mutationMachine = setup({
7539
7526
  on: {
7540
7527
  patch: {
7541
7528
  target: "emitting mutations",
7542
- actions: ["defer patch"],
7529
+ actions: ["emit patch", "defer mutation"],
7543
7530
  reenter: !0
7544
7531
  }
7545
7532
  }
7533
+ },
7534
+ "read-only": {
7535
+ entry: [() => {
7536
+ debug$7("entry: mutations->read-only");
7537
+ }],
7538
+ exit: [() => {
7539
+ debug$7("exit: mutations->read-only");
7540
+ }],
7541
+ always: [{
7542
+ guard: not("is read-only"),
7543
+ target: "emitting mutations",
7544
+ actions: ["emit pending patch events", "clear pending patch events"]
7545
+ }],
7546
+ on: {
7547
+ patch: {
7548
+ actions: ["defer patch", "defer mutation"]
7549
+ }
7550
+ }
7546
7551
  }
7547
7552
  }
7548
7553
  }
@@ -7909,6 +7914,21 @@ function isAnnotationActive({
7909
7914
  return !1;
7910
7915
  }
7911
7916
  }
7917
+ const relayMachine = setup({
7918
+ types: {
7919
+ events: {},
7920
+ emitted: {}
7921
+ }
7922
+ }).createMachine({
7923
+ id: "relay",
7924
+ on: {
7925
+ "*": {
7926
+ actions: emit(({
7927
+ event
7928
+ }) => event)
7929
+ }
7930
+ }
7931
+ });
7912
7932
  function validateValue(value, types, keyGenerator) {
7913
7933
  let resolution = null, valid = !0;
7914
7934
  const validChildTypes = [types.span.name, ...types.inlineObjects.map((t) => t.name)], validBlockTypes = [types.block.name, ...types.blockObjects.map((t) => t.name)];
@@ -8345,7 +8365,7 @@ const debug$5 = debugWithName("sync machine"), syncValueCallback = ({
8345
8365
  value: context.initialValue
8346
8366
  }))],
8347
8367
  on: {
8348
- "has pending patches": {
8368
+ "has pending mutations": {
8349
8369
  actions: assign({
8350
8370
  isProcessingLocalChanges: !0
8351
8371
  })
@@ -8736,40 +8756,20 @@ function _updateBlock(slateEditor, currentBlock, oldBlock, currentBlockIndex) {
8736
8756
  }
8737
8757
  }
8738
8758
  const debug$4 = debugWithName("setup");
8739
- function compileSchemasFromEditorConfig(config) {
8740
- const legacySchema = config.schemaDefinition ? compileSchemaDefinitionToLegacySchema(config.schemaDefinition) : createLegacySchema(config.schema.hasOwnProperty("jsonType") ? config.schema : compileType(config.schema)), schema = legacySchemaToEditorSchema(legacySchema);
8741
- return {
8742
- legacySchema,
8743
- schema
8744
- };
8745
- }
8746
- function editorConfigToMachineInput(config) {
8747
- const {
8748
- legacySchema,
8749
- schema
8750
- } = compileSchemasFromEditorConfig(config);
8751
- return {
8752
- converters: createCoreConverters(legacySchema),
8753
- getLegacySchema: () => legacySchema,
8754
- keyGenerator: config.keyGenerator ?? defaultKeyGenerator,
8755
- maxBlocks: config.maxBlocks,
8756
- readOnly: config.readOnly,
8757
- schema,
8758
- initialValue: config.initialValue
8759
- };
8760
- }
8761
8759
  function createInternalEditor(config) {
8762
8760
  debug$4("Creating new Editor instance");
8763
8761
  const subscriptions = [], editorActor = createActor(editorMachine, {
8764
8762
  input: editorConfigToMachineInput(config)
8765
- }), slateEditor = createSlateEditor({
8763
+ }), relayActor = createActor(relayMachine), slateEditor = createSlateEditor({
8766
8764
  editorActor,
8765
+ relayActor,
8767
8766
  subscriptions
8768
8767
  }), editable = createEditableAPI(slateEditor.instance, editorActor), {
8769
8768
  mutationActor,
8770
8769
  syncActor
8771
8770
  } = createActors({
8772
8771
  editorActor,
8772
+ relayActor,
8773
8773
  slateEditor: slateEditor.instance,
8774
8774
  subscriptions
8775
8775
  });
@@ -8777,6 +8777,7 @@ function createInternalEditor(config) {
8777
8777
  actors: {
8778
8778
  editorActor,
8779
8779
  mutationActor,
8780
+ relayActor,
8780
8781
  syncActor
8781
8782
  },
8782
8783
  editor: {
@@ -8810,10 +8811,8 @@ function createInternalEditor(config) {
8810
8811
  case "update value":
8811
8812
  syncActor.send(event);
8812
8813
  break;
8813
- case "update key generator":
8814
8814
  case "update readOnly":
8815
8815
  case "patches":
8816
- case "update schema":
8817
8816
  case "update maxBlocks":
8818
8817
  editorActor.send(event);
8819
8818
  break;
@@ -8851,12 +8850,11 @@ function createInternalEditor(config) {
8851
8850
  });
8852
8851
  }
8853
8852
  },
8854
- on: (event, listener) => editorActor.on(event, (event2) => {
8853
+ on: (event, listener) => relayActor.on(event, (event2) => {
8855
8854
  switch (event2.type) {
8856
8855
  case "blurred":
8857
8856
  case "done loading":
8858
8857
  case "editable":
8859
- case "error":
8860
8858
  case "focused":
8861
8859
  case "invalid value":
8862
8860
  case "loading":
@@ -8879,10 +8877,35 @@ function createInternalEditor(config) {
8879
8877
  subscriptions
8880
8878
  };
8881
8879
  }
8880
+ function editorConfigToMachineInput(config) {
8881
+ const {
8882
+ legacySchema,
8883
+ schema
8884
+ } = compileSchemasFromEditorConfig(config);
8885
+ return {
8886
+ converters: createCoreConverters(legacySchema),
8887
+ getLegacySchema: () => legacySchema,
8888
+ keyGenerator: config.keyGenerator ?? defaultKeyGenerator,
8889
+ maxBlocks: config.maxBlocks,
8890
+ readOnly: config.readOnly,
8891
+ schema,
8892
+ initialValue: config.initialValue
8893
+ };
8894
+ }
8895
+ function compileSchemasFromEditorConfig(config) {
8896
+ const legacySchema = config.schemaDefinition ? compileSchemaDefinitionToLegacySchema(config.schemaDefinition) : createLegacySchema(config.schema.hasOwnProperty("jsonType") ? config.schema : compileType(config.schema)), schema = legacySchemaToEditorSchema(legacySchema);
8897
+ return {
8898
+ legacySchema,
8899
+ schema
8900
+ };
8901
+ }
8882
8902
  function createActors(config) {
8883
8903
  debug$4("Creating new Actors");
8884
8904
  const mutationActor = createActor(mutationMachine, {
8885
8905
  input: {
8906
+ readOnly: config.editorActor.getSnapshot().matches({
8907
+ "edit mode": "read only"
8908
+ }),
8886
8909
  schema: config.editorActor.getSnapshot().context.schema,
8887
8910
  slateEditor: config.slateEditor
8888
8911
  }
@@ -8899,8 +8922,8 @@ function createActors(config) {
8899
8922
  });
8900
8923
  return config.subscriptions.push(() => {
8901
8924
  const subscription = mutationActor.on("*", (event) => {
8902
- event.type === "has pending patches" && syncActor.send({
8903
- type: "has pending patches"
8925
+ event.type === "has pending mutations" && syncActor.send({
8926
+ type: "has pending mutations"
8904
8927
  }), event.type === "mutation" && (syncActor.send({
8905
8928
  type: "mutation"
8906
8929
  }), config.editorActor.send({
@@ -8908,7 +8931,17 @@ function createActors(config) {
8908
8931
  patches: event.patches,
8909
8932
  snapshot: event.snapshot,
8910
8933
  value: event.snapshot
8911
- }));
8934
+ })), event.type === "patch" && config.relayActor.send(event);
8935
+ });
8936
+ return () => {
8937
+ subscription.unsubscribe();
8938
+ };
8939
+ }), config.subscriptions.push(() => {
8940
+ const subscription = config.relayActor.on("*", (event) => {
8941
+ event.type === "selection" && config.editorActor.send({
8942
+ type: "update selection",
8943
+ selection: event.selection
8944
+ });
8912
8945
  });
8913
8946
  return () => {
8914
8947
  subscription.unsubscribe();
@@ -8917,16 +8950,10 @@ function createActors(config) {
8917
8950
  const subscription = syncActor.on("*", (event) => {
8918
8951
  switch (event.type) {
8919
8952
  case "invalid value":
8920
- config.editorActor.send({
8921
- ...event,
8922
- type: "notify.invalid value"
8923
- });
8953
+ config.relayActor.send(event);
8924
8954
  break;
8925
8955
  case "value changed":
8926
- config.editorActor.send({
8927
- ...event,
8928
- type: "notify.value changed"
8929
- });
8956
+ config.relayActor.send(event);
8930
8957
  break;
8931
8958
  case "patch":
8932
8959
  config.editorActor.send({
@@ -8943,26 +8970,49 @@ function createActors(config) {
8943
8970
  subscription.unsubscribe();
8944
8971
  };
8945
8972
  }), config.subscriptions.push(() => {
8946
- const subscription = config.editorActor.on("*", (event) => {
8947
- config.editorActor.getSnapshot().matches({
8973
+ const subscription = config.editorActor.subscribe((snapshot) => {
8974
+ snapshot.matches({
8948
8975
  "edit mode": "read only"
8949
- }) ? syncActor.send({
8976
+ }) ? (mutationActor.send({
8977
+ type: "update readOnly",
8978
+ readOnly: !0
8979
+ }), syncActor.send({
8950
8980
  type: "update readOnly",
8951
8981
  readOnly: !0
8952
- }) : syncActor.send({
8982
+ })) : (mutationActor.send({
8953
8983
  type: "update readOnly",
8954
8984
  readOnly: !1
8955
- }), event.type === "internal.patch" && mutationActor.send({
8956
- ...event,
8957
- type: "patch"
8958
- });
8985
+ }), syncActor.send({
8986
+ type: "update readOnly",
8987
+ readOnly: !1
8988
+ }));
8989
+ });
8990
+ return () => {
8991
+ subscription.unsubscribe();
8992
+ };
8993
+ }), config.subscriptions.push(() => {
8994
+ const subscription = config.editorActor.on("*", (event) => {
8995
+ switch (event.type) {
8996
+ case "editable":
8997
+ case "mutation":
8998
+ case "ready":
8999
+ case "read only":
9000
+ config.relayActor.send(event);
9001
+ break;
9002
+ case "internal.patch":
9003
+ mutationActor.send({
9004
+ ...event,
9005
+ type: "patch"
9006
+ });
9007
+ break;
9008
+ }
8959
9009
  });
8960
9010
  return () => {
8961
9011
  subscription.unsubscribe();
8962
9012
  };
8963
9013
  }), {
8964
- syncActor,
8965
- mutationActor
9014
+ mutationActor,
9015
+ syncActor
8966
9016
  };
8967
9017
  }
8968
9018
  const PortableTextEditorSelectionContext = createContext(null), usePortableTextEditorSelection = () => {
@@ -8988,23 +9038,24 @@ function PortableTextEditorSelectionProvider(props) {
8988
9038
  let t2;
8989
9039
  return $[3] !== props.children || $[4] !== selection ? (t2 = /* @__PURE__ */ jsx(PortableTextEditorSelectionContext.Provider, { value: selection, children: props.children }), $[3] = props.children, $[4] = selection, $[5] = t2) : t2 = $[5], t2;
8990
9040
  }
9041
+ const RelayActorContext = createContext({});
8991
9042
  function RouteEventsToChanges(props) {
8992
9043
  const $ = c(7);
8993
9044
  let t0;
8994
9045
  $[0] !== props ? (t0 = (change) => props.onChange(change), $[0] = props, $[1] = t0) : t0 = $[1];
8995
9046
  const handleChange = useEffectEvent(t0);
8996
9047
  let t1;
8997
- $[2] !== handleChange || $[3] !== props.editorActor ? (t1 = () => {
8998
- const sub = props.editorActor.on("*", (event) => {
9048
+ $[2] !== handleChange || $[3] !== props.relayActor ? (t1 = () => {
9049
+ const sub = props.relayActor.on("*", (event) => {
8999
9050
  const change_0 = eventToChange(event);
9000
9051
  change_0 && handleChange(change_0);
9001
9052
  });
9002
9053
  return () => {
9003
9054
  sub.unsubscribe();
9004
9055
  };
9005
- }, $[2] = handleChange, $[3] = props.editorActor, $[4] = t1) : t1 = $[4];
9056
+ }, $[2] = handleChange, $[3] = props.relayActor, $[4] = t1) : t1 = $[4];
9006
9057
  let t2;
9007
- return $[5] !== props.editorActor ? (t2 = [props.editorActor], $[5] = props.editorActor, $[6] = t2) : t2 = $[6], useEffect(t1, t2), null;
9058
+ return $[5] !== props.relayActor ? (t2 = [props.relayActor], $[5] = props.relayActor, $[6] = t2) : t2 = $[6], useEffect(t1, t2), null;
9008
9059
  }
9009
9060
  function eventToChange(event) {
9010
9061
  switch (event.type) {
@@ -9041,11 +9092,6 @@ function eventToChange(event) {
9041
9092
  resolution: event.resolution,
9042
9093
  value: event.value
9043
9094
  };
9044
- case "error":
9045
- return {
9046
- ...event,
9047
- level: "warning"
9048
- };
9049
9095
  case "mutation":
9050
9096
  return event;
9051
9097
  case "ready":
@@ -9089,7 +9135,7 @@ class PortableTextEditor extends Component {
9089
9135
  schema: props.schemaType
9090
9136
  });
9091
9137
  this.unsubscribers.push((() => {
9092
- const subscription = actors.editorActor.on("*", (event) => {
9138
+ const subscription = actors.relayActor.on("*", (event) => {
9093
9139
  const change = eventToChange(event);
9094
9140
  change && (props.onChange(change), this.change$.next(change));
9095
9141
  });
@@ -9104,13 +9150,10 @@ class PortableTextEditor extends Component {
9104
9150
  this.editable = this.editor._internal.editable;
9105
9151
  }
9106
9152
  componentDidMount() {
9107
- this.actors && (this.actors.editorActor.start(), this.actors.mutationActor.start(), this.actors.syncActor.start());
9153
+ this.actors && (this.actors.editorActor.start(), this.actors.mutationActor.start(), this.actors.relayActor.start(), this.actors.syncActor.start());
9108
9154
  }
9109
9155
  componentDidUpdate(prevProps) {
9110
- !this.props.editor && !prevProps.editor && this.props.schemaType !== prevProps.schemaType && (this.schemaTypes = createLegacySchema(this.props.schemaType.hasOwnProperty("jsonType") ? this.props.schemaType : compileType(this.props.schemaType)), this.editor._internal.editorActor.send({
9111
- type: "update schema",
9112
- schema: legacySchemaToEditorSchema(this.schemaTypes)
9113
- })), !this.props.editor && !prevProps.editor && (this.props.readOnly !== prevProps.readOnly && this.editor._internal.editorActor.send({
9156
+ !this.props.editor && !prevProps.editor && this.props.schemaType !== prevProps.schemaType && console.warn("Updating schema type is no longer supported"), !this.props.editor && !prevProps.editor && (this.props.readOnly !== prevProps.readOnly && this.editor._internal.editorActor.send({
9114
9157
  type: "update readOnly",
9115
9158
  readOnly: this.props.readOnly ?? !1
9116
9159
  }), this.props.maxBlocks !== prevProps.maxBlocks && this.editor._internal.editorActor.send({
@@ -9124,7 +9167,7 @@ class PortableTextEditor extends Component {
9124
9167
  componentWillUnmount() {
9125
9168
  for (const unsubscribe of this.unsubscribers)
9126
9169
  unsubscribe();
9127
- this.actors && (stopActor(this.actors.editorActor), stopActor(this.actors.mutationActor), stopActor(this.actors.syncActor));
9170
+ this.actors && (stopActor(this.actors.editorActor), stopActor(this.actors.mutationActor), stopActor(this.actors.relayActor), stopActor(this.actors.syncActor));
9128
9171
  }
9129
9172
  setEditable = (editable) => {
9130
9173
  this.editor._internal.editable = {
@@ -9136,7 +9179,7 @@ class PortableTextEditor extends Component {
9136
9179
  const legacyPatches = this.props.editor ? void 0 : this.props.incomingPatches$ ?? this.props.patches$;
9137
9180
  return /* @__PURE__ */ jsxs(Fragment, { children: [
9138
9181
  legacyPatches ? /* @__PURE__ */ jsx(RoutePatchesObservableToEditorActor, { editorActor: this.editor._internal.editorActor, patches$: legacyPatches }) : null,
9139
- /* @__PURE__ */ jsx(EditorActorContext.Provider, { value: this.editor._internal.editorActor, children: /* @__PURE__ */ jsx(Slate, { editor: this.editor._internal.slateEditor.instance, initialValue: this.editor._internal.slateEditor.initialValue, children: /* @__PURE__ */ jsx(PortableTextEditorContext.Provider, { value: this, children: /* @__PURE__ */ jsx(PortableTextEditorSelectionProvider, { editorActor: this.editor._internal.editorActor, children: this.props.children }) }) }) })
9182
+ /* @__PURE__ */ jsx(EditorActorContext.Provider, { value: this.editor._internal.editorActor, children: /* @__PURE__ */ jsx(RelayActorContext.Provider, { value: this.actors.relayActor, children: /* @__PURE__ */ jsx(Slate, { editor: this.editor._internal.slateEditor.instance, initialValue: this.editor._internal.slateEditor.initialValue, children: /* @__PURE__ */ jsx(PortableTextEditorContext.Provider, { value: this, children: /* @__PURE__ */ jsx(PortableTextEditorSelectionProvider, { editorActor: this.editor._internal.editorActor, children: this.props.children }) }) }) }) })
9140
9183
  ] });
9141
9184
  }
9142
9185
  /**
@@ -9985,7 +10028,7 @@ const debug = debugWithName("component:Editable"), PortableTextEditable = forwar
9985
10028
  ...restProps
9986
10029
  } = props, portableTextEditor = usePortableTextEditor(), ref = useRef(null), [editableElement, setEditableElement] = useState(null), [hasInvalidValue, setHasInvalidValue] = useState(!1);
9987
10030
  useImperativeHandle(forwardedRef, () => ref.current);
9988
- const editorActor = useContext(EditorActorContext), readOnly = useSelector(editorActor, (s) => s.matches({
10031
+ const editorActor = useContext(EditorActorContext), relayActor = useContext(RelayActorContext), readOnly = useSelector(editorActor, (s) => s.matches({
9989
10032
  "edit mode": "read only"
9990
10033
  })), slateEditor = useSlate(), rangeDecorationsActor = useActorRef(rangeDecorationsMachine, {
9991
10034
  input: {
@@ -10018,13 +10061,13 @@ const debug = debugWithName("component:Editable"), PortableTextEditable = forwar
10018
10061
  if (normalizedSelection !== null) {
10019
10062
  debug(`Normalized selection from props ${JSON.stringify(normalizedSelection)}`);
10020
10063
  const slateRange = toSlateRange(normalizedSelection, slateEditor);
10021
- slateRange && (Transforms.select(slateEditor, slateRange), slateEditor.operations.some((o) => o.type === "set_selection") || editorActor.send({
10022
- type: "notify.selection",
10064
+ slateRange && (Transforms.select(slateEditor, slateRange), slateEditor.operations.some((o) => o.type === "set_selection") || relayActor.send({
10065
+ type: "selection",
10023
10066
  selection: normalizedSelection
10024
10067
  }), slateEditor.onChange());
10025
10068
  }
10026
10069
  }
10027
- }, [editorActor, propsSelection, slateEditor]);
10070
+ }, [editorActor, propsSelection, relayActor, slateEditor]);
10028
10071
  useEffect(() => {
10029
10072
  const onReady = editorActor.on("ready", () => {
10030
10073
  rangeDecorationsActor.send({
@@ -10107,8 +10150,8 @@ const debug = debugWithName("component:Editable"), PortableTextEditable = forwar
10107
10150
  schemaTypes: portableTextEditor.schemaTypes
10108
10151
  });
10109
10152
  if (onPasteResult || !slateEditor.selection)
10110
- event_1.preventDefault(), editorActor.send({
10111
- type: "notify.loading"
10153
+ event_1.preventDefault(), relayActor.send({
10154
+ type: "loading"
10112
10155
  }), Promise.resolve(onPasteResult).then((result_1) => {
10113
10156
  if (debug("Custom paste function from client resolved", result_1), !result_1 || !result_1.insert) {
10114
10157
  debug("No result from custom paste handler, pasting normally");
@@ -10151,8 +10194,8 @@ const debug = debugWithName("component:Editable"), PortableTextEditable = forwar
10151
10194
  editor: slateEditor
10152
10195
  }) : console.warn("Your onPaste function returned something unexpected:", result_1);
10153
10196
  }).catch((error) => (console.warn(error), error)).finally(() => {
10154
- editorActor.send({
10155
- type: "notify.done loading"
10197
+ relayActor.send({
10198
+ type: "done loading"
10156
10199
  });
10157
10200
  });
10158
10201
  else if (event_1.nativeEvent.clipboardData) {
@@ -10178,20 +10221,20 @@ const debug = debugWithName("component:Editable"), PortableTextEditable = forwar
10178
10221
  });
10179
10222
  }
10180
10223
  debug("No result from custom paste handler, pasting normally");
10181
- }, [editorActor, onPaste, portableTextEditor, slateEditor]), handleOnFocus = useCallback((event_2) => {
10224
+ }, [editorActor, onPaste, portableTextEditor, relayActor, slateEditor]), handleOnFocus = useCallback((event_2) => {
10182
10225
  if (onFocus && onFocus(event_2), !event_2.isDefaultPrevented()) {
10183
10226
  const selection_3 = PortableTextEditor.getSelection(portableTextEditor);
10184
- selection_3 === null && (Transforms.select(slateEditor, Editor.start(slateEditor, [])), slateEditor.onChange()), editorActor.send({
10185
- type: "notify.focused",
10227
+ selection_3 === null && (Transforms.select(slateEditor, Editor.start(slateEditor, [])), slateEditor.onChange()), relayActor.send({
10228
+ type: "focused",
10186
10229
  event: event_2
10187
10230
  });
10188
10231
  const newSelection = PortableTextEditor.getSelection(portableTextEditor);
10189
- selection_3 === newSelection && editorActor.send({
10190
- type: "notify.selection",
10232
+ selection_3 === newSelection && relayActor.send({
10233
+ type: "selection",
10191
10234
  selection: selection_3
10192
10235
  });
10193
10236
  }
10194
- }, [editorActor, onFocus, slateEditor, portableTextEditor]), handleClick = useCallback((event_3) => {
10237
+ }, [onFocus, slateEditor, portableTextEditor, relayActor]), handleClick = useCallback((event_3) => {
10195
10238
  if (onClick && onClick(event_3), event_3.isDefaultPrevented() || event_3.isPropagationStopped())
10196
10239
  return;
10197
10240
  const position_3 = getEventPosition({
@@ -10209,11 +10252,11 @@ const debug = debugWithName("component:Editable"), PortableTextEditable = forwar
10209
10252
  nativeEvent: event_3
10210
10253
  });
10211
10254
  }, [onClick, editorActor, slateEditor]), handleOnBlur = useCallback((event_4) => {
10212
- onBlur && onBlur(event_4), event_4.isPropagationStopped() || editorActor.send({
10213
- type: "notify.blurred",
10255
+ onBlur && onBlur(event_4), event_4.isPropagationStopped() || relayActor.send({
10256
+ type: "blurred",
10214
10257
  event: event_4
10215
10258
  });
10216
- }, [editorActor, onBlur]), handleOnBeforeInput = useCallback((event_5) => {
10259
+ }, [relayActor, onBlur]), handleOnBeforeInput = useCallback((event_5) => {
10217
10260
  onBeforeInput && onBeforeInput(event_5);
10218
10261
  }, [onBeforeInput]), validateSelection = useCallback(() => {
10219
10262
  if (!slateEditor.selection)
@@ -10537,7 +10580,7 @@ function useConstant(factory) {
10537
10580
  }), ref.current.constant;
10538
10581
  }
10539
10582
  function EditorProvider(props) {
10540
- const $ = c(31);
10583
+ const $ = c(35);
10541
10584
  let t0;
10542
10585
  $[0] !== props.initialConfig ? (t0 = () => {
10543
10586
  const internalEditor = createInternalEditor(props.initialConfig), portableTextEditor = new PortableTextEditor({
@@ -10553,37 +10596,39 @@ function EditorProvider(props) {
10553
10596
  portableTextEditor: portableTextEditor_0
10554
10597
  } = useConstant(t0);
10555
10598
  let t1;
10556
- $[2] !== internalEditor_0.actors.editorActor || $[3] !== internalEditor_0.actors.mutationActor || $[4] !== internalEditor_0.actors.syncActor || $[5] !== internalEditor_0.subscriptions ? (t1 = () => {
10599
+ $[2] !== internalEditor_0.actors.editorActor || $[3] !== internalEditor_0.actors.mutationActor || $[4] !== internalEditor_0.actors.relayActor || $[5] !== internalEditor_0.actors.syncActor || $[6] !== internalEditor_0.subscriptions ? (t1 = () => {
10557
10600
  const unsubscribers = [];
10558
10601
  for (const subscription of internalEditor_0.subscriptions)
10559
10602
  unsubscribers.push(subscription());
10560
- return internalEditor_0.actors.editorActor.start(), internalEditor_0.actors.mutationActor.start(), internalEditor_0.actors.syncActor.start(), () => {
10603
+ return internalEditor_0.actors.editorActor.start(), internalEditor_0.actors.mutationActor.start(), internalEditor_0.actors.relayActor.start(), internalEditor_0.actors.syncActor.start(), () => {
10561
10604
  for (const unsubscribe of unsubscribers)
10562
10605
  unsubscribe();
10563
- stopActor(internalEditor_0.actors.editorActor), stopActor(internalEditor_0.actors.mutationActor), stopActor(internalEditor_0.actors.syncActor);
10606
+ stopActor(internalEditor_0.actors.editorActor), stopActor(internalEditor_0.actors.mutationActor), stopActor(internalEditor_0.actors.relayActor), stopActor(internalEditor_0.actors.syncActor);
10564
10607
  };
10565
- }, $[2] = internalEditor_0.actors.editorActor, $[3] = internalEditor_0.actors.mutationActor, $[4] = internalEditor_0.actors.syncActor, $[5] = internalEditor_0.subscriptions, $[6] = t1) : t1 = $[6];
10608
+ }, $[2] = internalEditor_0.actors.editorActor, $[3] = internalEditor_0.actors.mutationActor, $[4] = internalEditor_0.actors.relayActor, $[5] = internalEditor_0.actors.syncActor, $[6] = internalEditor_0.subscriptions, $[7] = t1) : t1 = $[7];
10566
10609
  let t2;
10567
- $[7] !== internalEditor_0 ? (t2 = [internalEditor_0], $[7] = internalEditor_0, $[8] = t2) : t2 = $[8], useEffect(t1, t2);
10610
+ $[8] !== internalEditor_0 ? (t2 = [internalEditor_0], $[8] = internalEditor_0, $[9] = t2) : t2 = $[9], useEffect(t1, t2);
10568
10611
  let t3;
10569
- $[9] !== portableTextEditor_0.change$ ? (t3 = (change) => {
10612
+ $[10] !== portableTextEditor_0.change$ ? (t3 = (change) => {
10570
10613
  portableTextEditor_0.change$.next(change);
10571
- }, $[9] = portableTextEditor_0.change$, $[10] = t3) : t3 = $[10];
10614
+ }, $[10] = portableTextEditor_0.change$, $[11] = t3) : t3 = $[11];
10572
10615
  let t4;
10573
- $[11] !== internalEditor_0.actors.editorActor || $[12] !== t3 ? (t4 = /* @__PURE__ */ jsx(RouteEventsToChanges, { editorActor: internalEditor_0.actors.editorActor, onChange: t3 }), $[11] = internalEditor_0.actors.editorActor, $[12] = t3, $[13] = t4) : t4 = $[13];
10616
+ $[12] !== internalEditor_0.actors.relayActor || $[13] !== t3 ? (t4 = /* @__PURE__ */ jsx(RouteEventsToChanges, { relayActor: internalEditor_0.actors.relayActor, onChange: t3 }), $[12] = internalEditor_0.actors.relayActor, $[13] = t3, $[14] = t4) : t4 = $[14];
10574
10617
  let t5;
10575
- $[14] !== internalEditor_0.actors.editorActor || $[15] !== props.children ? (t5 = /* @__PURE__ */ jsx(PortableTextEditorSelectionProvider, { editorActor: internalEditor_0.actors.editorActor, children: props.children }), $[14] = internalEditor_0.actors.editorActor, $[15] = props.children, $[16] = t5) : t5 = $[16];
10618
+ $[15] !== internalEditor_0.actors.editorActor || $[16] !== props.children ? (t5 = /* @__PURE__ */ jsx(PortableTextEditorSelectionProvider, { editorActor: internalEditor_0.actors.editorActor, children: props.children }), $[15] = internalEditor_0.actors.editorActor, $[16] = props.children, $[17] = t5) : t5 = $[17];
10576
10619
  let t6;
10577
- $[17] !== portableTextEditor_0 || $[18] !== t5 ? (t6 = /* @__PURE__ */ jsx(PortableTextEditorContext.Provider, { value: portableTextEditor_0, children: t5 }), $[17] = portableTextEditor_0, $[18] = t5, $[19] = t6) : t6 = $[19];
10620
+ $[18] !== portableTextEditor_0 || $[19] !== t5 ? (t6 = /* @__PURE__ */ jsx(PortableTextEditorContext.Provider, { value: portableTextEditor_0, children: t5 }), $[18] = portableTextEditor_0, $[19] = t5, $[20] = t6) : t6 = $[20];
10578
10621
  let t7;
10579
- $[20] !== internalEditor_0.editor._internal.slateEditor.initialValue || $[21] !== internalEditor_0.editor._internal.slateEditor.instance || $[22] !== t6 ? (t7 = /* @__PURE__ */ jsx(Slate, { editor: internalEditor_0.editor._internal.slateEditor.instance, initialValue: internalEditor_0.editor._internal.slateEditor.initialValue, children: t6 }), $[20] = internalEditor_0.editor._internal.slateEditor.initialValue, $[21] = internalEditor_0.editor._internal.slateEditor.instance, $[22] = t6, $[23] = t7) : t7 = $[23];
10622
+ $[21] !== internalEditor_0.editor._internal.slateEditor.initialValue || $[22] !== internalEditor_0.editor._internal.slateEditor.instance || $[23] !== t6 ? (t7 = /* @__PURE__ */ jsx(Slate, { editor: internalEditor_0.editor._internal.slateEditor.instance, initialValue: internalEditor_0.editor._internal.slateEditor.initialValue, children: t6 }), $[21] = internalEditor_0.editor._internal.slateEditor.initialValue, $[22] = internalEditor_0.editor._internal.slateEditor.instance, $[23] = t6, $[24] = t7) : t7 = $[24];
10580
10623
  let t8;
10581
- $[24] !== internalEditor_0.actors.editorActor || $[25] !== t7 ? (t8 = /* @__PURE__ */ jsx(EditorActorContext.Provider, { value: internalEditor_0.actors.editorActor, children: t7 }), $[24] = internalEditor_0.actors.editorActor, $[25] = t7, $[26] = t8) : t8 = $[26];
10624
+ $[25] !== internalEditor_0.actors.relayActor || $[26] !== t7 ? (t8 = /* @__PURE__ */ jsx(RelayActorContext.Provider, { value: internalEditor_0.actors.relayActor, children: t7 }), $[25] = internalEditor_0.actors.relayActor, $[26] = t7, $[27] = t8) : t8 = $[27];
10582
10625
  let t9;
10583
- return $[27] !== internalEditor_0.editor || $[28] !== t4 || $[29] !== t8 ? (t9 = /* @__PURE__ */ jsxs(EditorContext.Provider, { value: internalEditor_0.editor, children: [
10626
+ $[28] !== internalEditor_0.actors.editorActor || $[29] !== t8 ? (t9 = /* @__PURE__ */ jsx(EditorActorContext.Provider, { value: internalEditor_0.actors.editorActor, children: t8 }), $[28] = internalEditor_0.actors.editorActor, $[29] = t8, $[30] = t9) : t9 = $[30];
10627
+ let t10;
10628
+ return $[31] !== internalEditor_0.editor || $[32] !== t4 || $[33] !== t9 ? (t10 = /* @__PURE__ */ jsxs(EditorContext.Provider, { value: internalEditor_0.editor, children: [
10584
10629
  t4,
10585
- t8
10586
- ] }), $[27] = internalEditor_0.editor, $[28] = t4, $[29] = t8, $[30] = t9) : t9 = $[30], t9;
10630
+ t9
10631
+ ] }), $[31] = internalEditor_0.editor, $[32] = t4, $[33] = t9, $[34] = t10) : t10 = $[34], t10;
10587
10632
  }
10588
10633
  export {
10589
10634
  EditorEventListener,