@portabletext/editor 1.14.2 → 1.15.0

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 (30) hide show
  1. package/lib/index.cjs +30 -21
  2. package/lib/index.cjs.map +1 -1
  3. package/lib/index.d.cts +15 -15
  4. package/lib/index.d.ts +15 -15
  5. package/lib/index.js +30 -21
  6. package/lib/index.js.map +1 -1
  7. package/package.json +7 -7
  8. package/src/editor/__tests__/PortableTextEditor.test.tsx +6 -6
  9. package/src/editor/__tests__/RangeDecorations.test.tsx +1 -1
  10. package/src/editor/__tests__/handleClick.test.tsx +4 -4
  11. package/src/editor/__tests__/insert-block.test.tsx +3 -3
  12. package/src/editor/__tests__/pteWarningsSelfSolving.test.tsx +6 -6
  13. package/src/editor/__tests__/self-solving.test.tsx +1 -1
  14. package/src/editor/components/DraggableBlock.tsx +1 -1
  15. package/src/editor/components/Element.tsx +8 -2
  16. package/src/editor/components/Leaf.tsx +1 -1
  17. package/src/editor/create-editor.ts +18 -29
  18. package/src/editor/hooks/useSyncValue.test.tsx +2 -2
  19. package/src/editor/hooks/useSyncValue.ts +2 -2
  20. package/src/editor/nodes/DefaultObject.tsx +1 -0
  21. package/src/editor/plugins/__tests__/withEditableAPIDelete.test.tsx +4 -4
  22. package/src/editor/plugins/__tests__/withEditableAPIGetFragment.test.tsx +2 -2
  23. package/src/editor/plugins/__tests__/withEditableAPIInsert.test.tsx +7 -7
  24. package/src/editor/plugins/__tests__/withEditableAPISelectionsOverlapping.test.tsx +4 -4
  25. package/src/editor/plugins/__tests__/withPortableTextLists.test.tsx +1 -1
  26. package/src/editor/plugins/__tests__/withPortableTextMarkModel.test.tsx +9 -9
  27. package/src/editor/plugins/__tests__/withPortableTextSelections.test.tsx +1 -1
  28. package/src/editor/plugins/__tests__/withUndoRedo.test.tsx +2 -2
  29. package/src/types/editor.ts +14 -13
  30. package/src/utils/__tests__/valueNormalization.test.tsx +1 -1
package/lib/index.cjs CHANGED
@@ -1462,7 +1462,7 @@ const debug$k = debugWithName("components:DraggableBlock"), DraggableBlock = (t0
1462
1462
  element,
1463
1463
  readOnly,
1464
1464
  blockRef
1465
- } = t0, editor = slateReact.useSlateStatic(), dragGhostRef = React.useRef(), [isDragOver, setIsDragOver] = React.useState(!1);
1465
+ } = t0, editor = slateReact.useSlateStatic(), dragGhostRef = React.useRef(void 0), [isDragOver, setIsDragOver] = React.useState(!1);
1466
1466
  let t1, t2;
1467
1467
  $[0] !== editor || $[1] !== element ? (t2 = slate.Editor.isVoid(editor, element), $[0] = editor, $[1] = element, $[2] = t2) : t2 = $[2], t1 = t2;
1468
1468
  const isVoid = t1;
@@ -3078,7 +3078,7 @@ function useSyncValue(props) {
3078
3078
  portableTextEditor,
3079
3079
  readOnly,
3080
3080
  slateEditor
3081
- } = props, schemaTypes = editorActor.getSnapshot().context.schema, previousValue = React.useRef(), updateValueFunctionRef = React.useRef(), updateFromCurrentValue = React.useCallback(() => {
3081
+ } = props, schemaTypes = editorActor.getSnapshot().context.schema, previousValue = React.useRef(void 0), updateValueFunctionRef = React.useRef(void 0), updateFromCurrentValue = React.useCallback(() => {
3082
3082
  const currentValue = CURRENT_VALUE.get(portableTextEditor);
3083
3083
  if (previousValue.current === currentValue) {
3084
3084
  debug$i("Value is the same object as previous, not need to sync");
@@ -6755,7 +6755,7 @@ function createEditor(config) {
6755
6755
  },
6756
6756
  on: (event, listener) => editorActor.on(
6757
6757
  event,
6758
- // @ts-ignore
6758
+ // @ts-expect-error
6759
6759
  listener
6760
6760
  ),
6761
6761
  _internal: {
@@ -6766,26 +6766,35 @@ function createEditor(config) {
6766
6766
  };
6767
6767
  }
6768
6768
  function useCreateEditor(config) {
6769
- const editorActor = react.useActorRef(editorMachine, {
6770
- input: editorConfigToMachineInput(config)
6771
- }), slateEditor = createSlateEditor({
6769
+ const $ = reactCompilerRuntime.c(18);
6770
+ let t0;
6771
+ $[0] !== config ? (t0 = editorConfigToMachineInput(config), $[0] = config, $[1] = t0) : t0 = $[1];
6772
+ let t1;
6773
+ $[2] !== t0 ? (t1 = {
6774
+ input: t0
6775
+ }, $[2] = t0, $[3] = t1) : t1 = $[3];
6776
+ const editorActor = react.useActorRef(editorMachine, t1);
6777
+ let t2, slateEditor, t3;
6778
+ $[4] !== editorActor ? (slateEditor = createSlateEditor({
6772
6779
  editorActor
6773
- }), editable = React.useMemo(() => createEditableAPI(slateEditor.instance, editorActor), [slateEditor.instance, editorActor]), send = React.useCallback((event) => {
6780
+ }), t3 = createEditableAPI(slateEditor.instance, editorActor), $[4] = editorActor, $[5] = slateEditor, $[6] = t3) : (slateEditor = $[5], t3 = $[6]);
6781
+ const editable = t3;
6782
+ let t4, t5;
6783
+ $[7] !== editorActor ? (t4 = (event) => {
6774
6784
  editorActor.send(event);
6775
- }, [editorActor]), on = React.useCallback((event_0, listener) => editorActor.on(
6776
- event_0,
6777
- // @ts-ignore
6778
- listener
6779
- ), [editorActor]);
6780
- return React.useMemo(() => ({
6781
- send,
6782
- on,
6783
- _internal: {
6784
- editable,
6785
- editorActor,
6786
- slateEditor
6787
- }
6788
- }), [send, on, editable, editorActor, slateEditor]);
6785
+ }, t5 = (event_0, listener) => editorActor.on(event_0, listener), $[7] = editorActor, $[8] = t4, $[9] = t5) : (t4 = $[8], t5 = $[9]);
6786
+ let t6;
6787
+ $[10] !== editable || $[11] !== editorActor || $[12] !== slateEditor ? (t6 = {
6788
+ editable,
6789
+ editorActor,
6790
+ slateEditor
6791
+ }, $[10] = editable, $[11] = editorActor, $[12] = slateEditor, $[13] = t6) : t6 = $[13];
6792
+ let t7;
6793
+ return $[14] !== t4 || $[15] !== t5 || $[16] !== t6 ? (t7 = {
6794
+ send: t4,
6795
+ on: t5,
6796
+ _internal: t6
6797
+ }, $[14] = t4, $[15] = t5, $[16] = t6, $[17] = t7) : t7 = $[17], t2 = t7, t2;
6789
6798
  }
6790
6799
  function editorConfigToMachineInput(config) {
6791
6800
  return {