@portabletext/editor 1.44.9 → 1.44.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 (26) hide show
  1. package/lib/_chunks-cjs/editor-provider.cjs +1 -1
  2. package/lib/_chunks-cjs/editor-provider.cjs.map +1 -1
  3. package/lib/_chunks-es/editor-provider.js +1 -1
  4. package/lib/_chunks-es/editor-provider.js.map +1 -1
  5. package/lib/index.cjs +20 -5
  6. package/lib/index.cjs.map +1 -1
  7. package/lib/index.js +20 -5
  8. package/lib/index.js.map +1 -1
  9. package/package.json +1 -1
  10. package/src/editor/Editable.tsx +3 -2
  11. package/src/editor/__tests__/PortableTextEditor.test.tsx +10 -0
  12. package/src/editor/__tests__/PortableTextEditorTester.tsx +3 -17
  13. package/src/editor/__tests__/RangeDecorations.test.tsx +6 -0
  14. package/src/editor/__tests__/pteWarningsSelfSolving.test.tsx +12 -5
  15. package/src/editor/__tests__/sync-value.test.tsx +5 -0
  16. package/src/editor/plugins/__tests__/withEditableAPIDelete.test.tsx +8 -3
  17. package/src/editor/plugins/__tests__/withEditableAPIGetFragment.test.tsx +3 -0
  18. package/src/editor/plugins/__tests__/withEditableAPIInsert.test.tsx +20 -12
  19. package/src/editor/plugins/__tests__/withEditableAPISelectionsOverlapping.test.tsx +5 -0
  20. package/src/editor/plugins/__tests__/withPortableTextLists.test.tsx +2 -0
  21. package/src/editor/plugins/__tests__/withPortableTextMarkModel.test.tsx +10 -289
  22. package/src/editor/plugins/__tests__/withPortableTextSelections.test.tsx +2 -0
  23. package/src/editor/plugins/__tests__/withUndoRedo.test.tsx +3 -0
  24. package/src/editor/range-decorations-machine.ts +21 -3
  25. package/src/editor/sync-machine.ts +8 -6
  26. package/src/internal-utils/__tests__/valueNormalization.test.tsx +2 -0
package/lib/index.js CHANGED
@@ -881,7 +881,10 @@ const slateOperationCallback = ({
881
881
  },
882
882
  "not read only": ({
883
883
  context
884
- }) => !context.readOnly
884
+ }) => !context.readOnly,
885
+ "should skip setup": ({
886
+ context
887
+ }) => context.skipSetup
885
888
  }
886
889
  }).createMachine({
887
890
  id: "range decorations",
@@ -891,6 +894,7 @@ const slateOperationCallback = ({
891
894
  readOnly: input.readOnly,
892
895
  pendingRangeDecorations: input.rangeDecorations,
893
896
  decoratedRanges: [],
897
+ skipSetup: input.skipSetup,
894
898
  schema: input.schema,
895
899
  slateEditor: input.slateEditor,
896
900
  updateCount: 0
@@ -908,9 +912,17 @@ const slateOperationCallback = ({
908
912
  actions: ["assign readOnly"]
909
913
  }
910
914
  },
911
- initial: "idle",
915
+ initial: "setting up",
912
916
  states: {
913
- idle: {
917
+ "setting up": {
918
+ always: [{
919
+ guard: and(["should skip setup", "has pending range decorations"]),
920
+ target: "ready",
921
+ actions: ["set up initial range decorations", "increment update count"]
922
+ }, {
923
+ guard: "should skip setup",
924
+ target: "ready"
925
+ }],
914
926
  on: {
915
927
  "range decorations updated": {
916
928
  actions: ["update pending range decorations"]
@@ -1024,10 +1036,13 @@ const debug = debugWithName("component:Editable"), PLACEHOLDER_STYLE = {
1024
1036
  "edit mode": "read only"
1025
1037
  })), schemaTypes = useSelector(editorActor, (s_0) => s_0.context.schema), slateEditor = useSlate(), rangeDecorationsActor = useActorRef(rangeDecorationsMachine, {
1026
1038
  input: {
1039
+ rangeDecorations: rangeDecorations ?? [],
1027
1040
  readOnly,
1028
- slateEditor,
1029
1041
  schema: schemaTypes,
1030
- rangeDecorations: rangeDecorations ?? []
1042
+ slateEditor,
1043
+ skipSetup: !editorActor.getSnapshot().matches({
1044
+ setup: "setting up"
1045
+ })
1031
1046
  }
1032
1047
  });
1033
1048
  useSelector(rangeDecorationsActor, (s_1) => s_1.context.updateCount);