@portabletext/editor 1.44.9 → 1.44.10

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
@@ -867,7 +867,10 @@ const slateOperationCallback = ({
867
867
  },
868
868
  "not read only": ({
869
869
  context
870
- }) => !context.readOnly
870
+ }) => !context.readOnly,
871
+ "should skip setup": ({
872
+ context
873
+ }) => context.skipSetup
871
874
  }
872
875
  }).createMachine({
873
876
  id: "range decorations",
@@ -877,6 +880,7 @@ const slateOperationCallback = ({
877
880
  readOnly: input.readOnly,
878
881
  pendingRangeDecorations: input.rangeDecorations,
879
882
  decoratedRanges: [],
883
+ skipSetup: input.skipSetup,
880
884
  schema: input.schema,
881
885
  slateEditor: input.slateEditor,
882
886
  updateCount: 0
@@ -894,9 +898,17 @@ const slateOperationCallback = ({
894
898
  actions: ["assign readOnly"]
895
899
  }
896
900
  },
897
- initial: "idle",
901
+ initial: "setting up",
898
902
  states: {
899
- idle: {
903
+ "setting up": {
904
+ always: [{
905
+ guard: xstate.and(["should skip setup", "has pending range decorations"]),
906
+ target: "ready",
907
+ actions: ["set up initial range decorations", "increment update count"]
908
+ }, {
909
+ guard: "should skip setup",
910
+ target: "ready"
911
+ }],
900
912
  on: {
901
913
  "range decorations updated": {
902
914
  actions: ["update pending range decorations"]
@@ -1010,10 +1022,13 @@ const debug = editorProvider.debugWithName("component:Editable"), PLACEHOLDER_ST
1010
1022
  "edit mode": "read only"
1011
1023
  })), schemaTypes = react.useSelector(editorActor, (s_0) => s_0.context.schema), slateEditor = slateReact.useSlate(), rangeDecorationsActor = react.useActorRef(rangeDecorationsMachine, {
1012
1024
  input: {
1025
+ rangeDecorations: rangeDecorations ?? [],
1013
1026
  readOnly,
1014
- slateEditor,
1015
1027
  schema: schemaTypes,
1016
- rangeDecorations: rangeDecorations ?? []
1028
+ slateEditor,
1029
+ skipSetup: !editorActor.getSnapshot().matches({
1030
+ setup: "setting up"
1031
+ })
1017
1032
  }
1018
1033
  });
1019
1034
  react.useSelector(rangeDecorationsActor, (s_1) => s_1.context.updateCount);