@portabletext/editor 1.50.7 → 1.50.8

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.cjs CHANGED
@@ -4187,7 +4187,7 @@ function unsetPatch(editor, patch) {
4187
4187
  const newNode = patches.applyAll(child.node, [{
4188
4188
  ...patch,
4189
4189
  path: propPath
4190
- }]), removedProperties = Object.keys(child.node).filter((property) => newNode[property] === void 0);
4190
+ }]), newKeys = Object.keys(newNode), removedProperties = Object.keys(child.node).filter((property) => !newKeys.includes(property));
4191
4191
  return slate.Transforms.unsetNodes(editor, removedProperties, {
4192
4192
  at: [block.index, child.index]
4193
4193
  }), !0;
@@ -7820,6 +7820,18 @@ const debug$7 = debugWithName("mutation-machine"), mutationMachine = xstate.setu
7820
7820
  }, () => {
7821
7821
  input.slateEditor.apply = originalApply;
7822
7822
  };
7823
+ }),
7824
+ "mutation debouncer": xstate.fromCallback(({
7825
+ sendBack
7826
+ }) => {
7827
+ const interval = setInterval(() => {
7828
+ sendBack({
7829
+ type: "mutation delay passed"
7830
+ });
7831
+ }, process.env.NODE_ENV === "test" ? 250 : 0);
7832
+ return () => {
7833
+ clearInterval(interval);
7834
+ };
7823
7835
  })
7824
7836
  },
7825
7837
  guards: {
@@ -7829,15 +7841,11 @@ const debug$7 = debugWithName("mutation-machine"), mutationMachine = xstate.setu
7829
7841
  "is typing": xstate.stateIn({
7830
7842
  typing: "typing"
7831
7843
  }),
7832
- "no pending mutations": ({
7833
- context
7834
- }) => context.pendingMutations.length === 0,
7835
7844
  "slate is normalizing": ({
7836
7845
  context
7837
7846
  }) => slate.Editor.isNormalizing(context.slateEditor)
7838
7847
  },
7839
7848
  delays: {
7840
- "mutation debounce": process.env.NODE_ENV === "test" ? 250 : 0,
7841
7849
  "type debounce": process.env.NODE_ENV === "test" ? 0 : 250
7842
7850
  }
7843
7851
  }).createMachine({
@@ -7874,7 +7882,7 @@ const debug$7 = debugWithName("mutation-machine"), mutationMachine = xstate.setu
7874
7882
  debug$7("entry: typing->idle");
7875
7883
  }],
7876
7884
  exit: [() => {
7877
- debug$7("exit: typing->idle");
7885
+ debug$7("exit: typing->idle"), debug$7("entry: typing->typing");
7878
7886
  }],
7879
7887
  on: {
7880
7888
  typing: {
@@ -7883,15 +7891,12 @@ const debug$7 = debugWithName("mutation-machine"), mutationMachine = xstate.setu
7883
7891
  }
7884
7892
  },
7885
7893
  typing: {
7886
- entry: [() => {
7887
- debug$7("entry: typing->typing");
7888
- }],
7889
- exit: [() => {
7890
- debug$7("exit: typing->typing");
7891
- }],
7892
7894
  after: {
7893
7895
  "type debounce": {
7894
- target: "idle"
7896
+ target: "idle",
7897
+ actions: [() => {
7898
+ debug$7("exit: typing->typing");
7899
+ }]
7895
7900
  }
7896
7901
  },
7897
7902
  on: {
@@ -7917,56 +7922,38 @@ const debug$7 = debugWithName("mutation-machine"), mutationMachine = xstate.setu
7917
7922
  debug$7("exit: mutations->idle");
7918
7923
  }],
7919
7924
  on: {
7920
- patch: {
7921
- actions: ["emit patch", "defer mutation", "emit has pending mutations"],
7922
- target: "emitting mutations"
7923
- }
7924
- }
7925
- },
7926
- "emitting mutations": {
7927
- entry: [() => {
7928
- debug$7("entry: mutations->emitting mutations");
7929
- }],
7930
- exit: [() => {
7931
- debug$7("exit: mutations->emitting mutations");
7932
- }],
7933
- after: {
7934
- "mutation debounce": [{
7925
+ patch: [{
7935
7926
  guard: "is read-only",
7936
- target: "read-only"
7937
- }, {
7938
- guard: xstate.and([xstate.not("is typing"), "slate is normalizing"]),
7939
- target: "idle",
7940
- actions: ["emit mutations", "clear pending mutations"]
7927
+ actions: ["defer patch", "defer mutation"],
7928
+ target: "has pending mutations"
7941
7929
  }, {
7942
- target: "emitting mutations",
7943
- reenter: !0
7944
- }]
7945
- },
7946
- on: {
7947
- patch: {
7948
- target: "emitting mutations",
7949
7930
  actions: ["emit patch", "defer mutation"],
7950
- reenter: !0
7951
- }
7931
+ target: "has pending mutations"
7932
+ }]
7952
7933
  }
7953
7934
  },
7954
- "read-only": {
7935
+ "has pending mutations": {
7955
7936
  entry: [() => {
7956
- debug$7("entry: mutations->read-only");
7957
- }],
7937
+ debug$7("entry: mutations->has pending mutations");
7938
+ }, "emit has pending mutations"],
7958
7939
  exit: [() => {
7959
- debug$7("exit: mutations->read-only");
7960
- }],
7961
- always: [{
7962
- guard: xstate.not("is read-only"),
7963
- target: "emitting mutations",
7964
- actions: ["emit pending patch events", "clear pending patch events"]
7940
+ debug$7("exit: mutations->has pending mutations");
7965
7941
  }],
7942
+ invoke: {
7943
+ src: "mutation debouncer"
7944
+ },
7966
7945
  on: {
7967
- patch: {
7946
+ "mutation delay passed": {
7947
+ guard: xstate.and([xstate.not("is read-only"), xstate.not("is typing"), "slate is normalizing"]),
7948
+ target: "idle",
7949
+ actions: ["emit pending patch events", "clear pending patch events", "emit mutations", "clear pending mutations"]
7950
+ },
7951
+ patch: [{
7952
+ guard: "is read-only",
7968
7953
  actions: ["defer patch", "defer mutation"]
7969
- }
7954
+ }, {
7955
+ actions: ["emit patch", "defer mutation"]
7956
+ }]
7970
7957
  }
7971
7958
  }
7972
7959
  }