@portabletext/editor 1.47.7 → 1.47.9

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.
package/lib/index.js CHANGED
@@ -18,7 +18,7 @@ import isEqual from "lodash/isEqual.js";
18
18
  import { isSelectingEntireBlocks } from "./_chunks-es/selector.is-selecting-entire-blocks.js";
19
19
  import { defineBehavior, isHotkey } from "./_chunks-es/behavior.core.js";
20
20
  import uniq from "lodash/uniq.js";
21
- import { setup, fromCallback, assign, assertEvent, and } from "xstate";
21
+ import { setup, fromCallback, assign, and } from "xstate";
22
22
  function EditorEventListener(props) {
23
23
  const $ = c(5), editor = useEditor(), on = useEffectEvent(props.on);
24
24
  let t0;
@@ -762,15 +762,14 @@ const slateOperationCallback = ({
762
762
  actions: {
763
763
  "update pending range decorations": assign({
764
764
  pendingRangeDecorations: ({
765
+ context,
765
766
  event
766
- }) => (assertEvent(event, "range decorations updated"), event.rangeDecorations)
767
+ }) => event.type !== "range decorations updated" ? context.pendingRangeDecorations : event.rangeDecorations
767
768
  }),
768
769
  "set up initial range decorations": assign({
769
770
  decoratedRanges: ({
770
- context,
771
- event
771
+ context
772
772
  }) => {
773
- assertEvent(event, "ready");
774
773
  const rangeDecorationState = [];
775
774
  for (const rangeDecoration of context.pendingRangeDecorations) {
776
775
  const slateRange = toSlateRange(rangeDecoration.selection, context.slateEditor);
@@ -795,7 +794,8 @@ const slateOperationCallback = ({
795
794
  context,
796
795
  event
797
796
  }) => {
798
- assertEvent(event, "range decorations updated");
797
+ if (event.type !== "range decorations updated")
798
+ return context.decoratedRanges;
799
799
  const rangeDecorationState = [];
800
800
  for (const rangeDecoration of event.rangeDecorations) {
801
801
  const slateRange = toSlateRange(rangeDecoration.selection, context.slateEditor);
@@ -820,7 +820,8 @@ const slateOperationCallback = ({
820
820
  context,
821
821
  event
822
822
  }) => {
823
- assertEvent(event, "slate operation");
823
+ if (event.type !== "slate operation")
824
+ return context.decoratedRanges;
824
825
  const rangeDecorationState = [];
825
826
  for (const decoratedRange of context.decoratedRanges) {
826
827
  const slateRange = toSlateRange(decoratedRange.rangeDecoration.selection, context.slateEditor);
@@ -862,8 +863,9 @@ const slateOperationCallback = ({
862
863
  }),
863
864
  "assign readOnly": assign({
864
865
  readOnly: ({
866
+ context,
865
867
  event
866
- }) => (assertEvent(event, "update read only"), event.readOnly)
868
+ }) => event.type !== "update read only" ? context.readOnly : event.readOnly
867
869
  }),
868
870
  "increment update count": assign({
869
871
  updateCount: ({
@@ -885,7 +887,8 @@ const slateOperationCallback = ({
885
887
  context,
886
888
  event
887
889
  }) => {
888
- assertEvent(event, "range decorations updated");
890
+ if (event.type !== "range decorations updated")
891
+ return !1;
889
892
  const existingRangeDecorations = context.decoratedRanges.map((decoratedRange) => ({
890
893
  anchor: decoratedRange.rangeDecoration.selection?.anchor,
891
894
  focus: decoratedRange.rangeDecoration.selection?.focus