@portabletext/editor 1.4.0 → 1.4.1

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
@@ -1,10 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: !0 });
3
- var types = require("@sanity/types"), jsxRuntime = require("react/jsx-runtime"), isEqual = require("lodash/isEqual.js"), noop = require("lodash/noop.js"), require$$0 = require("react"), slate = require("slate"), slateReact = require("slate-react"), debug$m = require("debug"), reactCompilerRuntime = require("react-compiler-runtime"), styledComponents = require("styled-components"), uniq = require("lodash/uniq.js"), rxjs = require("rxjs"), xstate = require("xstate"), schema = require("@sanity/schema"), patches = require("@portabletext/patches"), get = require("lodash/get.js"), isUndefined = require("lodash/isUndefined.js"), omitBy = require("lodash/omitBy.js"), flatten = require("lodash/flatten.js"), isHotkeyEsm = require("is-hotkey-esm"), blockTools = require("@sanity/block-tools"), isPlainObject = require("lodash/isPlainObject.js"), throttle = require("lodash/throttle.js"), useEffectEvent = require("use-effect-event"), debounce = require("lodash/debounce.js"), content = require("@sanity/util/content");
3
+ var types = require("@sanity/types"), jsxRuntime = require("react/jsx-runtime"), isEqual = require("lodash/isEqual.js"), noop = require("lodash/noop.js"), react = require("react"), slate = require("slate"), slateReact = require("slate-react"), debug$m = require("debug"), reactCompilerRuntime = require("react-compiler-runtime"), styledComponents = require("styled-components"), uniq = require("lodash/uniq.js"), rxjs = require("rxjs"), xstate = require("xstate"), schema = require("@sanity/schema"), patches = require("@portabletext/patches"), get = require("lodash/get.js"), isUndefined = require("lodash/isUndefined.js"), omitBy = require("lodash/omitBy.js"), flatten = require("lodash/flatten.js"), isHotkeyEsm = require("is-hotkey-esm"), blockTools = require("@sanity/block-tools"), isPlainObject = require("lodash/isPlainObject.js"), throttle = require("lodash/throttle.js"), useEffectEvent = require("use-effect-event"), debounce = require("lodash/debounce.js"), content = require("@sanity/util/content"), react$1 = require("@xstate/react");
4
4
  function _interopDefaultCompat(e) {
5
5
  return e && typeof e == "object" && "default" in e ? e : { default: e };
6
6
  }
7
- var isEqual__default = /* @__PURE__ */ _interopDefaultCompat(isEqual), noop__default = /* @__PURE__ */ _interopDefaultCompat(noop), require$$0__default = /* @__PURE__ */ _interopDefaultCompat(require$$0), debug__default = /* @__PURE__ */ _interopDefaultCompat(debug$m), uniq__default = /* @__PURE__ */ _interopDefaultCompat(uniq), get__default = /* @__PURE__ */ _interopDefaultCompat(get), isUndefined__default = /* @__PURE__ */ _interopDefaultCompat(isUndefined), omitBy__default = /* @__PURE__ */ _interopDefaultCompat(omitBy), flatten__default = /* @__PURE__ */ _interopDefaultCompat(flatten), isPlainObject__default = /* @__PURE__ */ _interopDefaultCompat(isPlainObject), throttle__default = /* @__PURE__ */ _interopDefaultCompat(throttle), debounce__default = /* @__PURE__ */ _interopDefaultCompat(debounce);
7
+ var isEqual__default = /* @__PURE__ */ _interopDefaultCompat(isEqual), noop__default = /* @__PURE__ */ _interopDefaultCompat(noop), debug__default = /* @__PURE__ */ _interopDefaultCompat(debug$m), uniq__default = /* @__PURE__ */ _interopDefaultCompat(uniq), get__default = /* @__PURE__ */ _interopDefaultCompat(get), isUndefined__default = /* @__PURE__ */ _interopDefaultCompat(isUndefined), omitBy__default = /* @__PURE__ */ _interopDefaultCompat(omitBy), flatten__default = /* @__PURE__ */ _interopDefaultCompat(flatten), isPlainObject__default = /* @__PURE__ */ _interopDefaultCompat(isPlainObject), throttle__default = /* @__PURE__ */ _interopDefaultCompat(throttle), debounce__default = /* @__PURE__ */ _interopDefaultCompat(debounce);
8
8
  function defineBehavior(behavior) {
9
9
  return behavior;
10
10
  }
@@ -654,15 +654,15 @@ const debug$l = debugWithName("components:DraggableBlock"), DraggableBlock = (t0
654
654
  element,
655
655
  readOnly,
656
656
  blockRef
657
- } = t0, editor = slateReact.useSlateStatic(), dragGhostRef = require$$0.useRef(), [isDragOver, setIsDragOver] = require$$0.useState(!1);
657
+ } = t0, editor = slateReact.useSlateStatic(), dragGhostRef = react.useRef(), [isDragOver, setIsDragOver] = react.useState(!1);
658
658
  let t1, t2;
659
659
  $[0] !== editor || $[1] !== element ? (t2 = slate.Editor.isVoid(editor, element), $[0] = editor, $[1] = element, $[2] = t2) : t2 = $[2], t1 = t2;
660
660
  const isVoid = t1;
661
661
  let t3, t4;
662
662
  $[3] !== editor || $[4] !== element ? (t4 = slate.Editor.isInline(editor, element), $[3] = editor, $[4] = element, $[5] = t4) : t4 = $[5], t3 = t4;
663
- const isInline = t3, [blockElement, setBlockElement] = require$$0.useState(null);
663
+ const isInline = t3, [blockElement, setBlockElement] = react.useState(null);
664
664
  let t5, t6;
665
- $[6] !== blockRef || $[7] !== editor || $[8] !== element ? (t5 = () => setBlockElement(blockRef ? blockRef.current : slateReact.ReactEditor.toDOMNode(editor, element)), t6 = [editor, element, blockRef], $[6] = blockRef, $[7] = editor, $[8] = element, $[9] = t5, $[10] = t6) : (t5 = $[9], t6 = $[10]), require$$0.useEffect(t5, t6);
665
+ $[6] !== blockRef || $[7] !== editor || $[8] !== element ? (t5 = () => setBlockElement(blockRef ? blockRef.current : slateReact.ReactEditor.toDOMNode(editor, element)), t6 = [editor, element, blockRef], $[6] = blockRef, $[7] = editor, $[8] = element, $[9] = t5, $[10] = t6) : (t5 = $[9], t6 = $[10]), react.useEffect(t5, t6);
666
666
  let t7;
667
667
  $[11] !== editor || $[12] !== blockElement || $[13] !== element ? (t7 = (event) => {
668
668
  const isMyDragOver = IS_DRAGGING_BLOCK_ELEMENT.get(editor);
@@ -793,9 +793,9 @@ const EMPTY_ANNOTATIONS = [], inlineBlockStyle = {
793
793
  renderStyle,
794
794
  spellCheck
795
795
  }) => {
796
- const editor = slateReact.useSlateStatic(), selected = slateReact.useSelected(), blockRef = require$$0.useRef(null), inlineBlockObjectRef = require$$0.useRef(null), focused = selected && editor.selection && slate.Range.isCollapsed(editor.selection) || !1, value = require$$0.useMemo(() => fromSlateValue([element], schemaTypes.block.name, KEY_TO_VALUE_ELEMENT.get(editor))[0], [editor, element, schemaTypes.block.name]);
796
+ const editor = slateReact.useSlateStatic(), selected = slateReact.useSelected(), blockRef = react.useRef(null), inlineBlockObjectRef = react.useRef(null), focused = selected && editor.selection && slate.Range.isCollapsed(editor.selection) || !1, value = react.useMemo(() => fromSlateValue([element], schemaTypes.block.name, KEY_TO_VALUE_ELEMENT.get(editor))[0], [editor, element, schemaTypes.block.name]);
797
797
  let renderedBlock = children, className;
798
- const blockPath = require$$0.useMemo(() => [{
798
+ const blockPath = react.useMemo(() => [{
799
799
  _key: element._key
800
800
  }], [element]);
801
801
  if (typeof element._type != "string")
@@ -916,8 +916,8 @@ const EMPTY_ANNOTATIONS = [], inlineBlockStyle = {
916
916
  ] }, element._key);
917
917
  };
918
918
  Element.displayName = "Element";
919
- const PortableTextEditorContext = require$$0.createContext(null), usePortableTextEditor = () => {
920
- const editor = require$$0.useContext(PortableTextEditorContext);
919
+ const PortableTextEditorContext = react.createContext(null), usePortableTextEditor = () => {
920
+ const editor = react.useContext(PortableTextEditorContext);
921
921
  if (!editor)
922
922
  throw new Error("The `usePortableTextEditor` hook must be used inside the <PortableTextEditor> component's context.");
923
923
  return editor;
@@ -2680,9 +2680,9 @@ function debugState(editor, stateName) {
2680
2680
  }
2681
2681
  function findBlockFromPath(editor, path) {
2682
2682
  let blockIndex = -1;
2683
- const block = editor.children.find((node, index2) => {
2684
- const isMatch = isKeyedSegment(path[0]) ? node._key === path[0]._key : index2 === path[0];
2685
- return isMatch && (blockIndex = index2), isMatch;
2683
+ const block = editor.children.find((node, index) => {
2684
+ const isMatch = isKeyedSegment(path[0]) ? node._key === path[0]._key : index === path[0];
2685
+ return isMatch && (blockIndex = index), isMatch;
2686
2686
  });
2687
2687
  return block ? {
2688
2688
  block,
@@ -2702,9 +2702,9 @@ function findBlockAndChildFromPath(editor, path) {
2702
2702
  childPath: void 0
2703
2703
  };
2704
2704
  let childIndex = -1;
2705
- const child = block.children.find((node, index2) => {
2706
- const isMatch = isKeyedSegment(path[2]) ? node._key === path[2]._key : index2 === path[2];
2707
- return isMatch && (childIndex = index2), isMatch;
2705
+ const child = block.children.find((node, index) => {
2706
+ const isMatch = isKeyedSegment(path[2]) ? node._key === path[2]._key : index === path[2];
2707
+ return isMatch && (childIndex = index), isMatch;
2708
2708
  });
2709
2709
  return child ? {
2710
2710
  block,
@@ -2901,9 +2901,9 @@ function transformOperation(editor, patch, operation, snapshot, previousSnapshot
2901
2901
  const {
2902
2902
  diffs
2903
2903
  } = diffPatch;
2904
- if (diffs.forEach((diff2, index2) => {
2904
+ if (diffs.forEach((diff2, index) => {
2905
2905
  const [diffType, text] = diff2;
2906
- diffType === DIFF_INSERT ? (adjustOffsetBy += text.length, changedOffset += text.length) : diffType === DIFF_DELETE ? (adjustOffsetBy -= text.length, changedOffset -= text.length) : diffType === DIFF_EQUAL && (diffs.slice(index2).every(([dType]) => dType === DIFF_EQUAL) || (changedOffset += text.length));
2906
+ diffType === DIFF_INSERT ? (adjustOffsetBy += text.length, changedOffset += text.length) : diffType === DIFF_DELETE ? (adjustOffsetBy -= text.length, changedOffset -= text.length) : diffType === DIFF_EQUAL && (diffs.slice(index).every(([dType]) => dType === DIFF_EQUAL) || (changedOffset += text.length));
2907
2907
  }), transformedOperation.type === "insert_text" && changedOffset < transformedOperation.offset && (transformedOperation.offset += adjustOffsetBy), transformedOperation.type === "remove_text" && changedOffset <= transformedOperation.offset - transformedOperation.text.length && (transformedOperation.offset += adjustOffsetBy), transformedOperation.type === "set_selection") {
2908
2908
  const currentFocus = transformedOperation.properties?.focus ? {
2909
2909
  ...transformedOperation.properties.focus
@@ -3997,10 +3997,10 @@ function validateValue(value, types$1, keyGenerator) {
3997
3997
  }
3998
3998
  },
3999
3999
  value
4000
- } : (value.some((blk, index2) => {
4000
+ } : (value.some((blk, index) => {
4001
4001
  if (!isPlainObject__default.default(blk))
4002
4002
  return resolution = {
4003
- patches: [patches.unset([index2])],
4003
+ patches: [patches.unset([index])],
4004
4004
  description: `Block must be an object, got ${String(blk)}`,
4005
4005
  action: "Unset invalid item",
4006
4006
  item: blk,
@@ -4008,7 +4008,7 @@ function validateValue(value, types$1, keyGenerator) {
4008
4008
  description: "inputs.portable-text.invalid-value.not-an-object.description",
4009
4009
  action: "inputs.portable-text.invalid-value.not-an-object.action",
4010
4010
  values: {
4011
- index: index2
4011
+ index
4012
4012
  }
4013
4013
  }
4014
4014
  }, !0;
@@ -4017,15 +4017,15 @@ function validateValue(value, types$1, keyGenerator) {
4017
4017
  patches: [patches.set({
4018
4018
  ...blk,
4019
4019
  _key: keyGenerator()
4020
- }, [index2])],
4021
- description: `Block at index ${index2} is missing required _key.`,
4020
+ }, [index])],
4021
+ description: `Block at index ${index} is missing required _key.`,
4022
4022
  action: "Set the block with a random _key value",
4023
4023
  item: blk,
4024
4024
  i18n: {
4025
4025
  description: "inputs.portable-text.invalid-value.missing-key.description",
4026
4026
  action: "inputs.portable-text.invalid-value.missing-key.action",
4027
4027
  values: {
4028
- index: index2
4028
+ index
4029
4029
  }
4030
4030
  }
4031
4031
  }, !0;
@@ -4582,14 +4582,14 @@ function SlateContainer(props) {
4582
4582
  });
4583
4583
  return KEY_TO_VALUE_ELEMENT.set(editor, {}), KEY_TO_SLATE_ELEMENT.set(editor, {}), [editor, _sub];
4584
4584
  }, $[0] = editorActor, $[1] = maxBlocks, $[2] = portableTextEditor, $[3] = readOnly, $[4] = t0) : t0 = $[4];
4585
- const [t1] = require$$0.useState(t0), [slateEditor, subscribe] = t1;
4585
+ const [t1] = react.useState(t0), [slateEditor, subscribe] = t1;
4586
4586
  let t2, t3;
4587
4587
  $[5] !== subscribe ? (t2 = () => {
4588
4588
  const unsubscribe = subscribe();
4589
4589
  return () => {
4590
4590
  unsubscribe();
4591
4591
  };
4592
- }, t3 = [subscribe], $[5] = subscribe, $[6] = t2, $[7] = t3) : (t2 = $[6], t3 = $[7]), require$$0.useEffect(t2, t3);
4592
+ }, t3 = [subscribe], $[5] = subscribe, $[6] = t2, $[7] = t3) : (t2 = $[6], t3 = $[7]), react.useEffect(t2, t3);
4593
4593
  let t4, t5;
4594
4594
  $[8] !== slateEditor || $[9] !== editorActor || $[10] !== maxBlocks || $[11] !== portableTextEditor || $[12] !== readOnly ? (t4 = () => {
4595
4595
  debug$6("Re-initializing plugin chain"), withPlugins(slateEditor, {
@@ -4598,7 +4598,7 @@ function SlateContainer(props) {
4598
4598
  portableTextEditor,
4599
4599
  readOnly
4600
4600
  });
4601
- }, t5 = [editorActor, portableTextEditor, maxBlocks, readOnly, slateEditor], $[8] = slateEditor, $[9] = editorActor, $[10] = maxBlocks, $[11] = portableTextEditor, $[12] = readOnly, $[13] = t4, $[14] = t5) : (t4 = $[13], t5 = $[14]), require$$0.useEffect(t4, t5);
4601
+ }, t5 = [editorActor, portableTextEditor, maxBlocks, readOnly, slateEditor], $[8] = slateEditor, $[9] = editorActor, $[10] = maxBlocks, $[11] = portableTextEditor, $[12] = readOnly, $[13] = t4, $[14] = t5) : (t4 = $[13], t5 = $[14]), react.useEffect(t4, t5);
4602
4602
  let t6, t7;
4603
4603
  $[15] !== slateEditor ? (t7 = slateEditor.pteCreateTextBlock({
4604
4604
  decorators: []
@@ -4609,13 +4609,13 @@ function SlateContainer(props) {
4609
4609
  let t9, t10;
4610
4610
  $[19] !== slateEditor ? (t9 = () => () => {
4611
4611
  debug$6("Destroying Slate editor"), slateEditor.destroy();
4612
- }, t10 = [slateEditor], $[19] = slateEditor, $[20] = t9, $[21] = t10) : (t9 = $[20], t10 = $[21]), require$$0.useEffect(t9, t10);
4612
+ }, t10 = [slateEditor], $[19] = slateEditor, $[20] = t9, $[21] = t10) : (t9 = $[20], t10 = $[21]), react.useEffect(t9, t10);
4613
4613
  let t11;
4614
4614
  return $[22] !== slateEditor || $[23] !== initialValue || $[24] !== props.children ? (t11 = /* @__PURE__ */ jsxRuntime.jsx(slateReact.Slate, { editor: slateEditor, initialValue, children: props.children }), $[22] = slateEditor, $[23] = initialValue, $[24] = props.children, $[25] = t11) : t11 = $[25], t11;
4615
4615
  }
4616
4616
  SlateContainer.displayName = "SlateContainer";
4617
- const PortableTextEditorReadOnlyContext = require$$0.createContext(!1), usePortableTextEditorReadOnlyStatus = () => {
4618
- const readOnly = require$$0.useContext(PortableTextEditorReadOnlyContext);
4617
+ const PortableTextEditorReadOnlyContext = react.createContext(!1), usePortableTextEditorReadOnlyStatus = () => {
4618
+ const readOnly = react.useContext(PortableTextEditorReadOnlyContext);
4619
4619
  if (readOnly === void 0)
4620
4620
  throw new Error("The `usePortableTextEditorReadOnly` hook must be used inside the <PortableTextEditor> component's context.");
4621
4621
  return readOnly;
@@ -4625,18 +4625,18 @@ function useSyncValue(props) {
4625
4625
  editorActor,
4626
4626
  portableTextEditor,
4627
4627
  readOnly
4628
- } = props, schemaTypes = editorActor.getSnapshot().context.schema, previousValue = require$$0.useRef(), slateEditor = slateReact.useSlate(), updateValueFunctionRef = require$$0.useRef(), updateFromCurrentValue = require$$0.useCallback(() => {
4628
+ } = props, schemaTypes = editorActor.getSnapshot().context.schema, previousValue = react.useRef(), slateEditor = slateReact.useSlate(), updateValueFunctionRef = react.useRef(), updateFromCurrentValue = react.useCallback(() => {
4629
4629
  const currentValue = CURRENT_VALUE.get(portableTextEditor);
4630
4630
  if (previousValue.current === currentValue) {
4631
4631
  debug$5("Value is the same object as previous, not need to sync");
4632
4632
  return;
4633
4633
  }
4634
4634
  updateValueFunctionRef.current && currentValue && (debug$5("Updating the value debounced"), updateValueFunctionRef.current(currentValue));
4635
- }, [portableTextEditor]), updateValueDebounced = require$$0.useMemo(() => debounce__default.default(updateFromCurrentValue, 1e3, {
4635
+ }, [portableTextEditor]), updateValueDebounced = react.useMemo(() => debounce__default.default(updateFromCurrentValue, 1e3, {
4636
4636
  trailing: !0,
4637
4637
  leading: !1
4638
4638
  }), [updateFromCurrentValue]);
4639
- return require$$0.useMemo(() => {
4639
+ return react.useMemo(() => {
4640
4640
  const updateFunction = (value) => {
4641
4641
  CURRENT_VALUE.set(portableTextEditor, value);
4642
4642
  const isProcessingLocalChanges = isChangingLocally(slateEditor), isProcessingRemoteChanges = isChangingRemotely(slateEditor);
@@ -4657,9 +4657,9 @@ function useSyncValue(props) {
4657
4657
  withoutPatching(slateEditor, () => {
4658
4658
  hadSelection && slate.Transforms.deselect(slateEditor);
4659
4659
  const childrenLength = slateEditor.children.length;
4660
- slateEditor.children.forEach((_, index2) => {
4660
+ slateEditor.children.forEach((_, index) => {
4661
4661
  slate.Transforms.removeNodes(slateEditor, {
4662
- at: [childrenLength - 1 - index2]
4662
+ at: [childrenLength - 1 - index]
4663
4663
  });
4664
4664
  }), slate.Transforms.insertNodes(slateEditor, slateEditor.pteCreateTextBlock({
4665
4665
  decorators: []
@@ -4764,8 +4764,8 @@ function _updateBlock(slateEditor, currentBlock, oldBlock, currentBlockIndex) {
4764
4764
  at: [currentBlockIndex]
4765
4765
  }), slateEditor.isTextBlock(currentBlock) && slateEditor.isTextBlock(oldBlock)) {
4766
4766
  const oldBlockChildrenLength = oldBlock.children.length;
4767
- currentBlock.children.length < oldBlockChildrenLength && Array.from(Array(oldBlockChildrenLength - currentBlock.children.length)).forEach((_, index2) => {
4768
- const childIndex = oldBlockChildrenLength - 1 - index2;
4767
+ currentBlock.children.length < oldBlockChildrenLength && Array.from(Array(oldBlockChildrenLength - currentBlock.children.length)).forEach((_, index) => {
4768
+ const childIndex = oldBlockChildrenLength - 1 - index;
4769
4769
  childIndex > 0 && (debug$5("Removing child"), slate.Transforms.removeNodes(slateEditor, {
4770
4770
  at: [currentBlockIndex, childIndex]
4771
4771
  }));
@@ -4816,7 +4816,7 @@ function Synchronizer(props) {
4816
4816
  } = props;
4817
4817
  let t0;
4818
4818
  $[0] === Symbol.for("react.memo_cache_sentinel") ? (t0 = [], $[0] = t0) : t0 = $[0];
4819
- const pendingPatches = require$$0.useRef(t0);
4819
+ const pendingPatches = react.useRef(t0);
4820
4820
  let t1;
4821
4821
  $[1] !== editorActor || $[2] !== portableTextEditor || $[3] !== readOnly ? (t1 = {
4822
4822
  editorActor,
@@ -4827,7 +4827,7 @@ function Synchronizer(props) {
4827
4827
  let t2, t3;
4828
4828
  $[5] !== slateEditor ? (t2 = () => {
4829
4829
  IS_PROCESSING_LOCAL_CHANGES.set(slateEditor, !1);
4830
- }, t3 = [slateEditor], $[5] = slateEditor, $[6] = t2, $[7] = t3) : (t2 = $[6], t3 = $[7]), require$$0.useEffect(t2, t3);
4830
+ }, t3 = [slateEditor], $[5] = slateEditor, $[6] = t2, $[7] = t3) : (t2 = $[6], t3 = $[7]), react.useEffect(t2, t3);
4831
4831
  let t4;
4832
4832
  $[8] !== getValue || $[9] !== editorActor || $[10] !== slateEditor ? (t4 = () => {
4833
4833
  if (pendingPatches.current.length > 0) {
@@ -4846,7 +4846,7 @@ ${JSON.stringify(pendingPatches.current, null, 2)}`);
4846
4846
  let t5, t6;
4847
4847
  $[12] !== onFlushPendingPatches ? (t5 = () => () => {
4848
4848
  onFlushPendingPatches();
4849
- }, t6 = [onFlushPendingPatches], $[12] = onFlushPendingPatches, $[13] = t5, $[14] = t6) : (t5 = $[13], t6 = $[14]), require$$0.useEffect(t5, t6);
4849
+ }, t6 = [onFlushPendingPatches], $[12] = onFlushPendingPatches, $[13] = t5, $[14] = t6) : (t5 = $[13], t6 = $[14]), react.useEffect(t5, t6);
4850
4850
  let t7;
4851
4851
  $[15] !== onChange ? (t7 = (change) => onChange(change), $[15] = onChange, $[16] = t7) : t7 = $[16];
4852
4852
  const handleChange = useEffectEvent.useEffectEvent(t7);
@@ -4928,7 +4928,7 @@ ${JSON.stringify(pendingPatches.current, null, 2)}`);
4928
4928
  return () => {
4929
4929
  debug$4("Unsubscribing to changes"), sub.unsubscribe();
4930
4930
  };
4931
- }, t9 = [editorActor, handleChange, onFlushPendingPatches, slateEditor], $[17] = slateEditor, $[18] = onFlushPendingPatches, $[19] = editorActor, $[20] = handleChange, $[21] = t8, $[22] = t9) : (t8 = $[21], t9 = $[22]), require$$0.useEffect(t8, t9);
4931
+ }, t9 = [editorActor, handleChange, onFlushPendingPatches, slateEditor], $[17] = slateEditor, $[18] = onFlushPendingPatches, $[19] = editorActor, $[20] = handleChange, $[21] = t8, $[22] = t9) : (t8 = $[21], t9 = $[22]), react.useEffect(t8, t9);
4932
4932
  let t10;
4933
4933
  $[23] !== syncValue || $[24] !== value ? (t10 = () => {
4934
4934
  debug$4("Editor is online, syncing from props.value"), syncValue(value);
@@ -4940,17 +4940,17 @@ ${JSON.stringify(pendingPatches.current, null, 2)}`);
4940
4940
  return () => {
4941
4941
  subscription.unsubscribe();
4942
4942
  };
4943
- }, t12 = [handleOnline, editorActor], $[26] = editorActor, $[27] = handleOnline, $[28] = t11, $[29] = t12) : (t11 = $[28], t12 = $[29]), require$$0.useEffect(t11, t12);
4944
- const isInitialValueFromProps = require$$0.useRef(!0);
4943
+ }, t12 = [handleOnline, editorActor], $[26] = editorActor, $[27] = handleOnline, $[28] = t11, $[29] = t12) : (t11 = $[28], t12 = $[29]), react.useEffect(t11, t12);
4944
+ const isInitialValueFromProps = react.useRef(!0);
4945
4945
  let t13, t14;
4946
4946
  return $[30] !== syncValue || $[31] !== value || $[32] !== editorActor ? (t13 = () => {
4947
4947
  debug$4("Value from props changed, syncing new value"), syncValue(value), isInitialValueFromProps.current && (editorActor.send({
4948
4948
  type: "ready"
4949
4949
  }), isInitialValueFromProps.current = !1);
4950
- }, t14 = [editorActor, syncValue, value], $[30] = syncValue, $[31] = value, $[32] = editorActor, $[33] = t13, $[34] = t14) : (t13 = $[33], t14 = $[34]), require$$0.useEffect(t13, t14), null;
4950
+ }, t14 = [editorActor, syncValue, value], $[30] = syncValue, $[31] = value, $[32] = editorActor, $[33] = t13, $[34] = t14) : (t13 = $[33], t14 = $[34]), react.useEffect(t13, t14), null;
4951
4951
  }
4952
4952
  Synchronizer.displayName = "Synchronizer";
4953
- const EditorActorContext = require$$0.createContext({}), insertBreakActionImplementation = ({
4953
+ const EditorActorContext = react.createContext({}), insertBreakActionImplementation = ({
4954
4954
  context,
4955
4955
  action
4956
4956
  }) => {
@@ -5663,31 +5663,31 @@ const breakingVoidBlock = {
5663
5663
  }
5664
5664
  }
5665
5665
  }
5666
- }), PortableTextEditorSelectionContext = require$$0.createContext(null), usePortableTextEditorSelection = () => {
5667
- const selection = require$$0.useContext(PortableTextEditorSelectionContext);
5666
+ }), PortableTextEditorSelectionContext = react.createContext(null), usePortableTextEditorSelection = () => {
5667
+ const selection = react.useContext(PortableTextEditorSelectionContext);
5668
5668
  if (selection === void 0)
5669
5669
  throw new Error("The `usePortableTextEditorSelection` hook must be used inside the <PortableTextEditor> component's context.");
5670
5670
  return selection;
5671
5671
  }, debug$3 = debugWithName("component:PortableTextEditor:SelectionProvider"), debugVerbose = debug$3.enabled && !1;
5672
5672
  function PortableTextEditorSelectionProvider(props) {
5673
- const $ = reactCompilerRuntime.c(6), [selection, setSelection] = require$$0.useState(null);
5673
+ const $ = reactCompilerRuntime.c(6), [selection, setSelection] = react.useState(null);
5674
5674
  let t0, t1;
5675
5675
  $[0] !== props.editorActor ? (t0 = () => {
5676
5676
  debug$3("Subscribing to selection changes");
5677
5677
  const subscription = props.editorActor.on("selection", (event) => {
5678
- require$$0.startTransition(() => {
5678
+ react.startTransition(() => {
5679
5679
  debugVerbose && debug$3("Setting selection"), setSelection(event.selection);
5680
5680
  });
5681
5681
  });
5682
5682
  return () => {
5683
5683
  debug$3("Unsubscribing to selection changes"), subscription.unsubscribe();
5684
5684
  };
5685
- }, t1 = [props.editorActor], $[0] = props.editorActor, $[1] = t0, $[2] = t1) : (t0 = $[1], t1 = $[2]), require$$0.useEffect(t0, t1);
5685
+ }, t1 = [props.editorActor], $[0] = props.editorActor, $[1] = t0, $[2] = t1) : (t0 = $[1], t1 = $[2]), react.useEffect(t0, t1);
5686
5686
  let t2;
5687
5687
  return $[3] !== selection || $[4] !== props.children ? (t2 = /* @__PURE__ */ jsxRuntime.jsx(PortableTextEditorSelectionContext.Provider, { value: selection, children: props.children }), $[3] = selection, $[4] = props.children, $[5] = t2) : t2 = $[5], t2;
5688
5688
  }
5689
5689
  const defaultKeyGenerator = () => content.randomKey(12), debug$2 = debugWithName("component:PortableTextEditor");
5690
- class PortableTextEditor extends require$$0.Component {
5690
+ class PortableTextEditor extends react.Component {
5691
5691
  static displayName = "PortableTextEditor";
5692
5692
  /**
5693
5693
  * An observable of all the editor changes.
@@ -5804,7 +5804,7 @@ function RoutePatchesObservableToEditorActor(props) {
5804
5804
  return () => {
5805
5805
  subscription.unsubscribe();
5806
5806
  };
5807
- }, t1 = [props.editorActor, props.patches$], $[0] = props.patches$, $[1] = props.editorActor, $[2] = t0, $[3] = t1) : (t0 = $[2], t1 = $[3]), require$$0.useEffect(t0, t1), null;
5807
+ }, t1 = [props.editorActor, props.patches$], $[0] = props.patches$, $[1] = props.editorActor, $[2] = t0, $[3] = t1) : (t0 = $[2], t1 = $[3]), react.useEffect(t0, t1), null;
5808
5808
  }
5809
5809
  const debug$1 = debugWithName("components:Leaf"), EMPTY_MARKS = [], Leaf = (props) => {
5810
5810
  const {
@@ -5816,22 +5816,22 @@ const debug$1 = debugWithName("components:Leaf"), EMPTY_MARKS = [], Leaf = (prop
5816
5816
  renderChild,
5817
5817
  renderDecorator,
5818
5818
  renderAnnotation
5819
- } = props, spanRef = require$$0.useRef(null), portableTextEditor = usePortableTextEditor(), blockSelected = slateReact.useSelected(), [focused, setFocused] = require$$0.useState(!1), [selected, setSelected] = require$$0.useState(!1), block = children.props.parent, path = require$$0.useMemo(() => block ? [{
5819
+ } = props, spanRef = react.useRef(null), portableTextEditor = usePortableTextEditor(), blockSelected = slateReact.useSelected(), [focused, setFocused] = react.useState(!1), [selected, setSelected] = react.useState(!1), block = children.props.parent, path = react.useMemo(() => block ? [{
5820
5820
  _key: block?._key
5821
5821
  }, "children", {
5822
5822
  _key: leaf._key
5823
- }] : [], [block, leaf._key]), decoratorValues = require$$0.useMemo(() => schemaTypes.decorators.map((dec) => dec.value), [schemaTypes.decorators]), marks = require$$0.useMemo(() => uniq__default.default((leaf.marks || EMPTY_MARKS).filter((mark) => decoratorValues.includes(mark))), [decoratorValues, leaf.marks]), annotationMarks = Array.isArray(leaf.marks) ? leaf.marks : EMPTY_MARKS, annotations = require$$0.useMemo(() => annotationMarks.map((mark_0) => !decoratorValues.includes(mark_0) && block?.markDefs?.find((def) => def._key === mark_0)).filter(Boolean), [annotationMarks, block, decoratorValues]), shouldTrackSelectionAndFocus = annotations.length > 0 && blockSelected;
5824
- require$$0.useEffect(() => {
5823
+ }] : [], [block, leaf._key]), decoratorValues = react.useMemo(() => schemaTypes.decorators.map((dec) => dec.value), [schemaTypes.decorators]), marks = react.useMemo(() => uniq__default.default((leaf.marks || EMPTY_MARKS).filter((mark) => decoratorValues.includes(mark))), [decoratorValues, leaf.marks]), annotationMarks = Array.isArray(leaf.marks) ? leaf.marks : EMPTY_MARKS, annotations = react.useMemo(() => annotationMarks.map((mark_0) => !decoratorValues.includes(mark_0) && block?.markDefs?.find((def) => def._key === mark_0)).filter(Boolean), [annotationMarks, block, decoratorValues]), shouldTrackSelectionAndFocus = annotations.length > 0 && blockSelected;
5824
+ react.useEffect(() => {
5825
5825
  if (!shouldTrackSelectionAndFocus) {
5826
5826
  setFocused(!1);
5827
5827
  return;
5828
5828
  }
5829
5829
  const sel = PortableTextEditor.getSelection(portableTextEditor);
5830
- sel && isEqual__default.default(sel.focus.path, path) && PortableTextEditor.isCollapsedSelection(portableTextEditor) && require$$0.startTransition(() => {
5830
+ sel && isEqual__default.default(sel.focus.path, path) && PortableTextEditor.isCollapsedSelection(portableTextEditor) && react.startTransition(() => {
5831
5831
  setFocused(!0);
5832
5832
  });
5833
5833
  }, [shouldTrackSelectionAndFocus, path, portableTextEditor]);
5834
- const setSelectedFromRange = require$$0.useCallback(() => {
5834
+ const setSelectedFromRange = react.useCallback(() => {
5835
5835
  if (!shouldTrackSelectionAndFocus)
5836
5836
  return;
5837
5837
  debug$1("Setting selection and focus from range");
@@ -5846,7 +5846,7 @@ const debug$1 = debugWithName("components:Leaf"), EMPTY_MARKS = [], Leaf = (prop
5846
5846
  } else
5847
5847
  setSelected(!1);
5848
5848
  }, [shouldTrackSelectionAndFocus]);
5849
- require$$0.useEffect(() => {
5849
+ react.useEffect(() => {
5850
5850
  if (!shouldTrackSelectionAndFocus)
5851
5851
  return;
5852
5852
  const onBlur = editorActor.on("blur", () => {
@@ -5860,8 +5860,8 @@ const debug$1 = debugWithName("components:Leaf"), EMPTY_MARKS = [], Leaf = (prop
5860
5860
  return () => {
5861
5861
  onBlur.unsubscribe(), onFocus.unsubscribe(), onSelection.unsubscribe();
5862
5862
  };
5863
- }, [editorActor, path, portableTextEditor, setSelectedFromRange, shouldTrackSelectionAndFocus]), require$$0.useEffect(() => setSelectedFromRange(), [setSelectedFromRange]);
5864
- const content2 = require$$0.useMemo(() => {
5863
+ }, [editorActor, path, portableTextEditor, setSelectedFromRange, shouldTrackSelectionAndFocus]), react.useEffect(() => setSelectedFromRange(), [setSelectedFromRange]);
5864
+ const content2 = react.useMemo(() => {
5865
5865
  let returnedChildren = children;
5866
5866
  if (slate.Text.isText(leaf) && leaf._type === schemaTypes.span.name && (marks.forEach((mark_1) => {
5867
5867
  const schemaType = schemaTypes.decorators.find((dec_0) => dec_0.value === mark_1);
@@ -5927,7 +5927,7 @@ const debug$1 = debugWithName("components:Leaf"), EMPTY_MARKS = [], Leaf = (prop
5927
5927
  }
5928
5928
  return returnedChildren;
5929
5929
  }, [annotations, block, children, focused, leaf, marks, path, renderAnnotation, renderChild, renderDecorator, schemaTypes.annotations, schemaTypes.decorators, schemaTypes.span, selected]);
5930
- return require$$0.useMemo(() => /* @__PURE__ */ jsxRuntime.jsx("span", { ...attributes, ref: spanRef, children: content2 }, leaf._key), [leaf, attributes, content2]);
5930
+ return react.useMemo(() => /* @__PURE__ */ jsxRuntime.jsx("span", { ...attributes, ref: spanRef, children: content2 }, leaf._key), [leaf, attributes, content2]);
5931
5931
  };
5932
5932
  Leaf.displayName = "Leaf";
5933
5933
  const debug = debugWithName("component:Editable"), PLACEHOLDER_STYLE = {
@@ -5936,7 +5936,7 @@ const debug = debugWithName("component:Editable"), PLACEHOLDER_STYLE = {
5936
5936
  pointerEvents: "none",
5937
5937
  left: 0,
5938
5938
  right: 0
5939
- }, PortableTextEditable = require$$0.forwardRef(function(props, forwardedRef) {
5939
+ }, PortableTextEditable = react.forwardRef(function(props, forwardedRef) {
5940
5940
  const {
5941
5941
  hotkeys,
5942
5942
  onBlur,
@@ -5957,13 +5957,13 @@ const debug = debugWithName("component:Editable"), PLACEHOLDER_STYLE = {
5957
5957
  scrollSelectionIntoView,
5958
5958
  spellCheck,
5959
5959
  ...restProps
5960
- } = props, portableTextEditor = usePortableTextEditor(), readOnly = usePortableTextEditorReadOnlyStatus(), ref = require$$0.useRef(null), [editableElement, setEditableElement] = require$$0.useState(null), [hasInvalidValue, setHasInvalidValue] = require$$0.useState(!1), [rangeDecorationState, setRangeDecorationsState] = require$$0.useState([]);
5961
- require$$0.useImperativeHandle(forwardedRef, () => ref.current);
5962
- const rangeDecorationsRef = require$$0.useRef(rangeDecorations), editorActor = require$$0.useContext(EditorActorContext), {
5960
+ } = props, portableTextEditor = usePortableTextEditor(), readOnly = usePortableTextEditorReadOnlyStatus(), ref = react.useRef(null), [editableElement, setEditableElement] = react.useState(null), [hasInvalidValue, setHasInvalidValue] = react.useState(!1), [rangeDecorationState, setRangeDecorationsState] = react.useState([]);
5961
+ react.useImperativeHandle(forwardedRef, () => ref.current);
5962
+ const rangeDecorationsRef = react.useRef(rangeDecorations), editorActor = react.useContext(EditorActorContext), {
5963
5963
  schemaTypes
5964
- } = portableTextEditor, slateEditor = slateReact.useSlate(), blockTypeName = schemaTypes.block.name, withInsertData = require$$0.useMemo(() => createWithInsertData(editorActor, schemaTypes), [editorActor, schemaTypes]), withHotKeys = require$$0.useMemo(() => createWithHotkeys(portableTextEditor, hotkeys), [hotkeys, portableTextEditor]);
5965
- require$$0.useMemo(() => readOnly ? (debug("Editable is in read only mode"), withInsertData(slateEditor)) : (debug("Editable is in edit mode"), withInsertData(withHotKeys(slateEditor))), [readOnly, slateEditor, withHotKeys, withInsertData]);
5966
- const renderElement = require$$0.useCallback((eProps) => /* @__PURE__ */ jsxRuntime.jsx(Element, { ...eProps, readOnly, renderBlock, renderChild, renderListItem, renderStyle, schemaTypes, spellCheck }), [schemaTypes, spellCheck, readOnly, renderBlock, renderChild, renderListItem, renderStyle]), renderLeaf = require$$0.useCallback((lProps) => {
5964
+ } = portableTextEditor, slateEditor = slateReact.useSlate(), blockTypeName = schemaTypes.block.name, withInsertData = react.useMemo(() => createWithInsertData(editorActor, schemaTypes), [editorActor, schemaTypes]), withHotKeys = react.useMemo(() => createWithHotkeys(portableTextEditor, hotkeys), [hotkeys, portableTextEditor]);
5965
+ react.useMemo(() => readOnly ? (debug("Editable is in read only mode"), withInsertData(slateEditor)) : (debug("Editable is in edit mode"), withInsertData(withHotKeys(slateEditor))), [readOnly, slateEditor, withHotKeys, withInsertData]);
5966
+ const renderElement = react.useCallback((eProps) => /* @__PURE__ */ jsxRuntime.jsx(Element, { ...eProps, readOnly, renderBlock, renderChild, renderListItem, renderStyle, schemaTypes, spellCheck }), [schemaTypes, spellCheck, readOnly, renderBlock, renderChild, renderListItem, renderStyle]), renderLeaf = react.useCallback((lProps) => {
5967
5967
  if (lProps.leaf._type === "span") {
5968
5968
  let rendered = /* @__PURE__ */ jsxRuntime.jsx(Leaf, { ...lProps, editorActor, schemaTypes, renderAnnotation, renderChild, renderDecorator, readOnly });
5969
5969
  if (renderPlaceholder && lProps.leaf.placeholder && lProps.text.text === "")
@@ -5977,7 +5977,7 @@ const debug = debugWithName("component:Editable"), PLACEHOLDER_STYLE = {
5977
5977
  })), rendered;
5978
5978
  }
5979
5979
  return lProps.children;
5980
- }, [editorActor, readOnly, renderAnnotation, renderChild, renderDecorator, renderPlaceholder, schemaTypes]), restoreSelectionFromProps = require$$0.useCallback(() => {
5980
+ }, [editorActor, readOnly, renderAnnotation, renderChild, renderDecorator, renderPlaceholder, schemaTypes]), restoreSelectionFromProps = react.useCallback(() => {
5981
5981
  if (propsSelection) {
5982
5982
  debug(`Selection from props ${JSON.stringify(propsSelection)}`);
5983
5983
  const normalizedSelection = normalizeSelection(propsSelection, fromSlateValue(slateEditor.children, blockTypeName));
@@ -5990,7 +5990,7 @@ const debug = debugWithName("component:Editable"), PLACEHOLDER_STYLE = {
5990
5990
  }), slateEditor.onChange());
5991
5991
  }
5992
5992
  }
5993
- }, [blockTypeName, editorActor, propsSelection, slateEditor]), syncRangeDecorations = require$$0.useCallback((operation) => {
5993
+ }, [blockTypeName, editorActor, propsSelection, slateEditor]), syncRangeDecorations = react.useCallback((operation) => {
5994
5994
  if (rangeDecorations && rangeDecorations.length > 0) {
5995
5995
  const newSlateRanges = [];
5996
5996
  if (rangeDecorations.forEach((rangeDecorationItem) => {
@@ -6023,7 +6023,7 @@ const debug = debugWithName("component:Editable"), PLACEHOLDER_STYLE = {
6023
6023
  }
6024
6024
  setRangeDecorationsState((rangeDecorationState_0) => rangeDecorationState_0.length > 0 ? [] : rangeDecorationState_0);
6025
6025
  }, [portableTextEditor, rangeDecorations, schemaTypes, slateEditor]);
6026
- require$$0.useEffect(() => {
6026
+ react.useEffect(() => {
6027
6027
  const onReady = editorActor.on("ready", () => {
6028
6028
  restoreSelectionFromProps();
6029
6029
  }), onInvalidValue = editorActor.on("invalid value", () => {
@@ -6034,22 +6034,22 @@ const debug = debugWithName("component:Editable"), PLACEHOLDER_STYLE = {
6034
6034
  return () => {
6035
6035
  onReady.unsubscribe(), onInvalidValue.unsubscribe(), onValueChanged.unsubscribe();
6036
6036
  };
6037
- }, [editorActor, restoreSelectionFromProps]), require$$0.useEffect(() => {
6037
+ }, [editorActor, restoreSelectionFromProps]), react.useEffect(() => {
6038
6038
  propsSelection && !hasInvalidValue && restoreSelectionFromProps();
6039
6039
  }, [hasInvalidValue, propsSelection, restoreSelectionFromProps]);
6040
- const originalApply = require$$0.useMemo(() => slateEditor.apply, [slateEditor]), [syncedRangeDecorations, setSyncedRangeDecorations] = require$$0.useState(!1);
6041
- require$$0.useEffect(() => {
6040
+ const originalApply = react.useMemo(() => slateEditor.apply, [slateEditor]), [syncedRangeDecorations, setSyncedRangeDecorations] = react.useState(!1);
6041
+ react.useEffect(() => {
6042
6042
  syncedRangeDecorations || (setSyncedRangeDecorations(!0), syncRangeDecorations());
6043
- }, [syncRangeDecorations, syncedRangeDecorations]), require$$0.useEffect(() => {
6043
+ }, [syncRangeDecorations, syncedRangeDecorations]), react.useEffect(() => {
6044
6044
  isEqual__default.default(rangeDecorations, rangeDecorationsRef.current) || syncRangeDecorations(), rangeDecorationsRef.current = rangeDecorations;
6045
- }, [rangeDecorations, syncRangeDecorations]), require$$0.useEffect(() => (slateEditor.apply = (op) => {
6045
+ }, [rangeDecorations, syncRangeDecorations]), react.useEffect(() => (slateEditor.apply = (op) => {
6046
6046
  originalApply(op), op.type !== "set_selection" && syncRangeDecorations(op);
6047
6047
  }, () => {
6048
6048
  slateEditor.apply = originalApply;
6049
6049
  }), [originalApply, slateEditor, syncRangeDecorations]);
6050
- const handleCopy = require$$0.useCallback((event) => {
6050
+ const handleCopy = react.useCallback((event) => {
6051
6051
  onCopy && onCopy(event) !== void 0 && event.preventDefault();
6052
- }, [onCopy]), handlePaste = require$$0.useCallback((event_0) => {
6052
+ }, [onCopy]), handlePaste = react.useCallback((event_0) => {
6053
6053
  if (event_0.preventDefault(), !slateEditor.selection)
6054
6054
  return;
6055
6055
  if (!onPaste) {
@@ -6073,7 +6073,7 @@ const debug = debugWithName("component:Editable"), PLACEHOLDER_STYLE = {
6073
6073
  type: "done loading"
6074
6074
  });
6075
6075
  }));
6076
- }, [editorActor, onPaste, portableTextEditor, schemaTypes, slateEditor]), handleOnFocus = require$$0.useCallback((event_1) => {
6076
+ }, [editorActor, onPaste, portableTextEditor, schemaTypes, slateEditor]), handleOnFocus = react.useCallback((event_1) => {
6077
6077
  if (onFocus && onFocus(event_1), !event_1.isDefaultPrevented()) {
6078
6078
  const selection = PortableTextEditor.getSelection(portableTextEditor);
6079
6079
  selection === null && (slate.Transforms.select(slateEditor, slate.Editor.start(slateEditor, [])), slateEditor.onChange()), editorActor.send({
@@ -6086,7 +6086,7 @@ const debug = debugWithName("component:Editable"), PLACEHOLDER_STYLE = {
6086
6086
  selection
6087
6087
  });
6088
6088
  }
6089
- }, [editorActor, onFocus, portableTextEditor, slateEditor]), handleClick = require$$0.useCallback((event_2) => {
6089
+ }, [editorActor, onFocus, portableTextEditor, slateEditor]), handleClick = react.useCallback((event_2) => {
6090
6090
  if (onClick && onClick(event_2), slateEditor.selection && event_2.target === event_2.currentTarget) {
6091
6091
  const [lastBlock, path_0] = slate.Node.last(slateEditor, []), focusPath = slateEditor.selection.focus.path.slice(0, 1), lastPath = path_0.slice(0, 1);
6092
6092
  if (slate.Path.equals(focusPath, lastPath)) {
@@ -6096,14 +6096,14 @@ const debug = debugWithName("component:Editable"), PLACEHOLDER_STYLE = {
6096
6096
  })), slateEditor.onChange());
6097
6097
  }
6098
6098
  }
6099
- }, [onClick, slateEditor]), handleOnBlur = require$$0.useCallback((event_3) => {
6099
+ }, [onClick, slateEditor]), handleOnBlur = react.useCallback((event_3) => {
6100
6100
  onBlur && onBlur(event_3), event_3.isPropagationStopped() || editorActor.send({
6101
6101
  type: "blur",
6102
6102
  event: event_3
6103
6103
  });
6104
- }, [editorActor, onBlur]), handleOnBeforeInput = require$$0.useCallback((event_4) => {
6104
+ }, [editorActor, onBlur]), handleOnBeforeInput = react.useCallback((event_4) => {
6105
6105
  onBeforeInput && onBeforeInput(event_4);
6106
- }, [onBeforeInput]), validateSelection = require$$0.useCallback(() => {
6106
+ }, [onBeforeInput]), validateSelection = react.useCallback(() => {
6107
6107
  if (!slateEditor.selection)
6108
6108
  return;
6109
6109
  const root = slateReact.ReactEditor.findDocumentOrShadowRoot(slateEditor), {
@@ -6122,7 +6122,7 @@ const debug = debugWithName("component:Editable"), PLACEHOLDER_STYLE = {
6122
6122
  debug("Could not resolve selection, selecting top document"), slate.Transforms.deselect(slateEditor), slateEditor.children.length > 0 && slate.Transforms.select(slateEditor, [0, 0]), slateEditor.onChange();
6123
6123
  }
6124
6124
  }, [ref, slateEditor]);
6125
- require$$0.useEffect(() => {
6125
+ react.useEffect(() => {
6126
6126
  if (editableElement) {
6127
6127
  const mutationObserver = new MutationObserver(validateSelection);
6128
6128
  return mutationObserver.observe(editableElement, {
@@ -6136,14 +6136,14 @@ const debug = debugWithName("component:Editable"), PLACEHOLDER_STYLE = {
6136
6136
  };
6137
6137
  }
6138
6138
  }, [validateSelection, editableElement]);
6139
- const handleKeyDown = require$$0.useCallback((event_5) => {
6139
+ const handleKeyDown = react.useCallback((event_5) => {
6140
6140
  props.onKeyDown && props.onKeyDown(event_5), event_5.isDefaultPrevented() || slateEditor.pteWithHotKeys(event_5);
6141
- }, [props, slateEditor]), scrollSelectionIntoViewToSlate = require$$0.useMemo(() => {
6141
+ }, [props, slateEditor]), scrollSelectionIntoViewToSlate = react.useMemo(() => {
6142
6142
  if (scrollSelectionIntoView !== void 0)
6143
6143
  return scrollSelectionIntoView === null ? noop__default.default : (_editor, domRange) => {
6144
6144
  scrollSelectionIntoView(portableTextEditor, domRange);
6145
6145
  };
6146
- }, [portableTextEditor, scrollSelectionIntoView]), decorate = require$$0.useCallback(([, path_1]) => {
6146
+ }, [portableTextEditor, scrollSelectionIntoView]), decorate = react.useCallback(([, path_1]) => {
6147
6147
  if (isEqualToEmptyEditor(slateEditor.children, schemaTypes))
6148
6148
  return [{
6149
6149
  anchor: {
@@ -6170,7 +6170,7 @@ const debug = debugWithName("component:Editable"), PLACEHOLDER_STYLE = {
6170
6170
  }) || slate.Range.includes(item, path_1));
6171
6171
  return result_1.length > 0 ? result_1 : [];
6172
6172
  }, [slateEditor, schemaTypes, rangeDecorationState]);
6173
- return require$$0.useEffect(() => {
6173
+ return react.useEffect(() => {
6174
6174
  ref.current = slateReact.ReactEditor.toDOMNode(slateEditor, slateEditor), setEditableElement(ref.current);
6175
6175
  }, [slateEditor, ref]), portableTextEditor ? hasInvalidValue ? null : /* @__PURE__ */ jsxRuntime.jsx(
6176
6176
  slateReact.Editable,
@@ -6195,310 +6195,6 @@ const debug = debugWithName("component:Editable"), PLACEHOLDER_STYLE = {
6195
6195
  ) : null;
6196
6196
  });
6197
6197
  PortableTextEditable.displayName = "ForwardRef(PortableTextEditable)";
6198
- var index = typeof document < "u" ? require$$0.useLayoutEffect : require$$0.useEffect, withSelector = { exports: {} }, withSelector_production_min = {}, shim = { exports: {} }, useSyncExternalStoreShim_production_min = {};
6199
- /**
6200
- * @license React
6201
- * use-sync-external-store-shim.production.min.js
6202
- *
6203
- * Copyright (c) Facebook, Inc. and its affiliates.
6204
- *
6205
- * This source code is licensed under the MIT license found in the
6206
- * LICENSE file in the root directory of this source tree.
6207
- */
6208
- var hasRequiredUseSyncExternalStoreShim_production_min;
6209
- function requireUseSyncExternalStoreShim_production_min() {
6210
- if (hasRequiredUseSyncExternalStoreShim_production_min) return useSyncExternalStoreShim_production_min;
6211
- hasRequiredUseSyncExternalStoreShim_production_min = 1;
6212
- var e = require$$0__default.default;
6213
- function h(a, b) {
6214
- return a === b && (a !== 0 || 1 / a === 1 / b) || a !== a && b !== b;
6215
- }
6216
- var k = typeof Object.is == "function" ? Object.is : h, l = e.useState, m = e.useEffect, n = e.useLayoutEffect, p = e.useDebugValue;
6217
- function q(a, b) {
6218
- var d = b(), f = l({
6219
- inst: {
6220
- value: d,
6221
- getSnapshot: b
6222
- }
6223
- }), c = f[0].inst, g = f[1];
6224
- return n(function() {
6225
- c.value = d, c.getSnapshot = b, r(c) && g({
6226
- inst: c
6227
- });
6228
- }, [a, d, b]), m(function() {
6229
- return r(c) && g({
6230
- inst: c
6231
- }), a(function() {
6232
- r(c) && g({
6233
- inst: c
6234
- });
6235
- });
6236
- }, [a]), p(d), d;
6237
- }
6238
- function r(a) {
6239
- var b = a.getSnapshot;
6240
- a = a.value;
6241
- try {
6242
- var d = b();
6243
- return !k(a, d);
6244
- } catch {
6245
- return !0;
6246
- }
6247
- }
6248
- function t(a, b) {
6249
- return b();
6250
- }
6251
- var u = typeof window > "u" || typeof window.document > "u" || typeof window.document.createElement > "u" ? t : q;
6252
- return useSyncExternalStoreShim_production_min.useSyncExternalStore = e.useSyncExternalStore !== void 0 ? e.useSyncExternalStore : u, useSyncExternalStoreShim_production_min;
6253
- }
6254
- var useSyncExternalStoreShim_development = {};
6255
- /**
6256
- * @license React
6257
- * use-sync-external-store-shim.development.js
6258
- *
6259
- * Copyright (c) Facebook, Inc. and its affiliates.
6260
- *
6261
- * This source code is licensed under the MIT license found in the
6262
- * LICENSE file in the root directory of this source tree.
6263
- */
6264
- var hasRequiredUseSyncExternalStoreShim_development;
6265
- function requireUseSyncExternalStoreShim_development() {
6266
- return hasRequiredUseSyncExternalStoreShim_development || (hasRequiredUseSyncExternalStoreShim_development = 1, process.env.NODE_ENV !== "production" && function() {
6267
- typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ < "u" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart == "function" && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error());
6268
- var React = require$$0__default.default, ReactSharedInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
6269
- function error(format) {
6270
- {
6271
- for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++)
6272
- args[_key2 - 1] = arguments[_key2];
6273
- printWarning("error", format, args);
6274
- }
6275
- }
6276
- function printWarning(level, format, args) {
6277
- {
6278
- var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame, stack = ReactDebugCurrentFrame.getStackAddendum();
6279
- stack !== "" && (format += "%s", args = args.concat([stack]));
6280
- var argsWithFormat = args.map(function(item) {
6281
- return String(item);
6282
- });
6283
- argsWithFormat.unshift("Warning: " + format), Function.prototype.apply.call(console[level], console, argsWithFormat);
6284
- }
6285
- }
6286
- function is(x, y) {
6287
- return x === y && (x !== 0 || 1 / x === 1 / y) || x !== x && y !== y;
6288
- }
6289
- var objectIs = typeof Object.is == "function" ? Object.is : is, useState = React.useState, useEffect = React.useEffect, useLayoutEffect = React.useLayoutEffect, useDebugValue = React.useDebugValue, didWarnOld18Alpha = !1, didWarnUncachedGetSnapshot = !1;
6290
- function useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot) {
6291
- didWarnOld18Alpha || React.startTransition !== void 0 && (didWarnOld18Alpha = !0, error("You are using an outdated, pre-release alpha of React 18 that does not support useSyncExternalStore. The use-sync-external-store shim will not work correctly. Upgrade to a newer pre-release."));
6292
- var value = getSnapshot();
6293
- if (!didWarnUncachedGetSnapshot) {
6294
- var cachedValue = getSnapshot();
6295
- objectIs(value, cachedValue) || (error("The result of getSnapshot should be cached to avoid an infinite loop"), didWarnUncachedGetSnapshot = !0);
6296
- }
6297
- var _useState = useState({
6298
- inst: {
6299
- value,
6300
- getSnapshot
6301
- }
6302
- }), inst = _useState[0].inst, forceUpdate = _useState[1];
6303
- return useLayoutEffect(function() {
6304
- inst.value = value, inst.getSnapshot = getSnapshot, checkIfSnapshotChanged(inst) && forceUpdate({
6305
- inst
6306
- });
6307
- }, [subscribe, value, getSnapshot]), useEffect(function() {
6308
- checkIfSnapshotChanged(inst) && forceUpdate({
6309
- inst
6310
- });
6311
- var handleStoreChange = function() {
6312
- checkIfSnapshotChanged(inst) && forceUpdate({
6313
- inst
6314
- });
6315
- };
6316
- return subscribe(handleStoreChange);
6317
- }, [subscribe]), useDebugValue(value), value;
6318
- }
6319
- function checkIfSnapshotChanged(inst) {
6320
- var latestGetSnapshot = inst.getSnapshot, prevValue = inst.value;
6321
- try {
6322
- var nextValue = latestGetSnapshot();
6323
- return !objectIs(prevValue, nextValue);
6324
- } catch {
6325
- return !0;
6326
- }
6327
- }
6328
- function useSyncExternalStore$1(subscribe, getSnapshot, getServerSnapshot) {
6329
- return getSnapshot();
6330
- }
6331
- var canUseDOM = typeof window < "u" && typeof window.document < "u" && typeof window.document.createElement < "u", isServerEnvironment = !canUseDOM, shim2 = isServerEnvironment ? useSyncExternalStore$1 : useSyncExternalStore, useSyncExternalStore$2 = React.useSyncExternalStore !== void 0 ? React.useSyncExternalStore : shim2;
6332
- useSyncExternalStoreShim_development.useSyncExternalStore = useSyncExternalStore$2, typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ < "u" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop == "function" && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error());
6333
- }()), useSyncExternalStoreShim_development;
6334
- }
6335
- var hasRequiredShim;
6336
- function requireShim() {
6337
- return hasRequiredShim || (hasRequiredShim = 1, process.env.NODE_ENV === "production" ? shim.exports = requireUseSyncExternalStoreShim_production_min() : shim.exports = requireUseSyncExternalStoreShim_development()), shim.exports;
6338
- }
6339
- /**
6340
- * @license React
6341
- * use-sync-external-store-shim/with-selector.production.min.js
6342
- *
6343
- * Copyright (c) Facebook, Inc. and its affiliates.
6344
- *
6345
- * This source code is licensed under the MIT license found in the
6346
- * LICENSE file in the root directory of this source tree.
6347
- */
6348
- var hasRequiredWithSelector_production_min;
6349
- function requireWithSelector_production_min() {
6350
- if (hasRequiredWithSelector_production_min) return withSelector_production_min;
6351
- hasRequiredWithSelector_production_min = 1;
6352
- var h = require$$0__default.default, n = requireShim();
6353
- function p(a, b) {
6354
- return a === b && (a !== 0 || 1 / a === 1 / b) || a !== a && b !== b;
6355
- }
6356
- var q = typeof Object.is == "function" ? Object.is : p, r = n.useSyncExternalStore, t = h.useRef, u = h.useEffect, v = h.useMemo, w = h.useDebugValue;
6357
- return withSelector_production_min.useSyncExternalStoreWithSelector = function(a, b, e, l, g) {
6358
- var c = t(null);
6359
- if (c.current === null) {
6360
- var f = {
6361
- hasValue: !1,
6362
- value: null
6363
- };
6364
- c.current = f;
6365
- } else f = c.current;
6366
- c = v(function() {
6367
- function a2(a3) {
6368
- if (!c2) {
6369
- if (c2 = !0, d2 = a3, a3 = l(a3), g !== void 0 && f.hasValue) {
6370
- var b2 = f.value;
6371
- if (g(b2, a3)) return k = b2;
6372
- }
6373
- return k = a3;
6374
- }
6375
- if (b2 = k, q(d2, a3)) return b2;
6376
- var e2 = l(a3);
6377
- return g !== void 0 && g(b2, e2) ? b2 : (d2 = a3, k = e2);
6378
- }
6379
- var c2 = !1, d2, k, m = e === void 0 ? null : e;
6380
- return [function() {
6381
- return a2(b());
6382
- }, m === null ? void 0 : function() {
6383
- return a2(m());
6384
- }];
6385
- }, [b, e, l, g]);
6386
- var d = r(a, c[0], c[1]);
6387
- return u(function() {
6388
- f.hasValue = !0, f.value = d;
6389
- }, [d]), w(d), d;
6390
- }, withSelector_production_min;
6391
- }
6392
- var withSelector_development = {};
6393
- /**
6394
- * @license React
6395
- * use-sync-external-store-shim/with-selector.development.js
6396
- *
6397
- * Copyright (c) Facebook, Inc. and its affiliates.
6398
- *
6399
- * This source code is licensed under the MIT license found in the
6400
- * LICENSE file in the root directory of this source tree.
6401
- */
6402
- var hasRequiredWithSelector_development;
6403
- function requireWithSelector_development() {
6404
- return hasRequiredWithSelector_development || (hasRequiredWithSelector_development = 1, process.env.NODE_ENV !== "production" && function() {
6405
- typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ < "u" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart == "function" && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error());
6406
- var React = require$$0__default.default, shim2 = requireShim();
6407
- function is(x, y) {
6408
- return x === y && (x !== 0 || 1 / x === 1 / y) || x !== x && y !== y;
6409
- }
6410
- var objectIs = typeof Object.is == "function" ? Object.is : is, useSyncExternalStore = shim2.useSyncExternalStore, useRef = React.useRef, useEffect = React.useEffect, useMemo = React.useMemo, useDebugValue = React.useDebugValue;
6411
- function useSyncExternalStoreWithSelector(subscribe, getSnapshot, getServerSnapshot, selector, isEqual2) {
6412
- var instRef = useRef(null), inst;
6413
- instRef.current === null ? (inst = {
6414
- hasValue: !1,
6415
- value: null
6416
- }, instRef.current = inst) : inst = instRef.current;
6417
- var _useMemo = useMemo(function() {
6418
- var hasMemo = !1, memoizedSnapshot, memoizedSelection, memoizedSelector = function(nextSnapshot) {
6419
- if (!hasMemo) {
6420
- hasMemo = !0, memoizedSnapshot = nextSnapshot;
6421
- var _nextSelection = selector(nextSnapshot);
6422
- if (isEqual2 !== void 0 && inst.hasValue) {
6423
- var currentSelection = inst.value;
6424
- if (isEqual2(currentSelection, _nextSelection))
6425
- return memoizedSelection = currentSelection, currentSelection;
6426
- }
6427
- return memoizedSelection = _nextSelection, _nextSelection;
6428
- }
6429
- var prevSnapshot = memoizedSnapshot, prevSelection = memoizedSelection;
6430
- if (objectIs(prevSnapshot, nextSnapshot))
6431
- return prevSelection;
6432
- var nextSelection = selector(nextSnapshot);
6433
- return isEqual2 !== void 0 && isEqual2(prevSelection, nextSelection) ? prevSelection : (memoizedSnapshot = nextSnapshot, memoizedSelection = nextSelection, nextSelection);
6434
- }, maybeGetServerSnapshot = getServerSnapshot === void 0 ? null : getServerSnapshot, getSnapshotWithSelector = function() {
6435
- return memoizedSelector(getSnapshot());
6436
- }, getServerSnapshotWithSelector = maybeGetServerSnapshot === null ? void 0 : function() {
6437
- return memoizedSelector(maybeGetServerSnapshot());
6438
- };
6439
- return [getSnapshotWithSelector, getServerSnapshotWithSelector];
6440
- }, [getSnapshot, getServerSnapshot, selector, isEqual2]), getSelection = _useMemo[0], getServerSelection = _useMemo[1], value = useSyncExternalStore(subscribe, getSelection, getServerSelection);
6441
- return useEffect(function() {
6442
- inst.hasValue = !0, inst.value = value;
6443
- }, [value]), useDebugValue(value), value;
6444
- }
6445
- withSelector_development.useSyncExternalStoreWithSelector = useSyncExternalStoreWithSelector, typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ < "u" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop == "function" && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error());
6446
- }()), withSelector_development;
6447
- }
6448
- var hasRequiredWithSelector;
6449
- function requireWithSelector() {
6450
- return hasRequiredWithSelector || (hasRequiredWithSelector = 1, process.env.NODE_ENV === "production" ? withSelector.exports = requireWithSelector_production_min() : withSelector.exports = requireWithSelector_development()), withSelector.exports;
6451
- }
6452
- requireWithSelector();
6453
- requireShim();
6454
- const forEachActor = (actorRef, callback) => {
6455
- callback(actorRef);
6456
- const children = actorRef.getSnapshot().children;
6457
- children && Object.values(children).forEach((child) => {
6458
- forEachActor(child, callback);
6459
- });
6460
- };
6461
- function stopRootWithRehydration(actorRef) {
6462
- const persistedSnapshots = [];
6463
- forEachActor(actorRef, (ref) => {
6464
- persistedSnapshots.push([ref, ref.getSnapshot()]), ref.observers = /* @__PURE__ */ new Set();
6465
- });
6466
- const systemSnapshot = actorRef.system.getSnapshot?.();
6467
- actorRef.stop(), actorRef.system._snapshot = systemSnapshot, persistedSnapshots.forEach(([ref, snapshot]) => {
6468
- ref._processingStatus = 0, ref._snapshot = snapshot;
6469
- });
6470
- }
6471
- function useIdleActorRef(logic, ...[options]) {
6472
- let [[currentConfig, actorRef], setCurrent] = require$$0.useState(() => {
6473
- const actorRef2 = xstate.createActor(logic, options);
6474
- return [logic.config, actorRef2];
6475
- });
6476
- if (logic.config !== currentConfig) {
6477
- const newActorRef = xstate.createActor(logic, {
6478
- ...options,
6479
- snapshot: actorRef.getPersistedSnapshot({
6480
- __unsafeAllowInlineActors: !0
6481
- })
6482
- });
6483
- setCurrent([logic.config, newActorRef]), actorRef = newActorRef;
6484
- }
6485
- return index(() => {
6486
- actorRef.logic.implementations = logic.implementations;
6487
- }), actorRef;
6488
- }
6489
- function useActorRef(machine, ...[options, observerOrListener]) {
6490
- const actorRef = useIdleActorRef(machine, options);
6491
- return require$$0.useEffect(() => {
6492
- if (!observerOrListener)
6493
- return;
6494
- let sub = actorRef.subscribe(xstate.toObserver(observerOrListener));
6495
- return () => {
6496
- sub.unsubscribe();
6497
- };
6498
- }, [observerOrListener]), require$$0.useEffect(() => (actorRef.start(), () => {
6499
- stopRootWithRehydration(actorRef);
6500
- }), [actorRef]), actorRef;
6501
- }
6502
6198
  function useEditor(config) {
6503
6199
  const $ = reactCompilerRuntime.c(8);
6504
6200
  let t0;
@@ -6513,7 +6209,7 @@ function useEditor(config) {
6513
6209
  keyGenerator: t2,
6514
6210
  schema: schema2
6515
6211
  }
6516
- }, $[4] = config.behaviors, $[5] = t2, $[6] = schema2, $[7] = t3) : t3 = $[7], useActorRef(editorMachine, t3);
6212
+ }, $[4] = config.behaviors, $[5] = t2, $[6] = schema2, $[7] = t3) : t3 = $[7], react$1.useActorRef(editorMachine, t3);
6517
6213
  }
6518
6214
  exports.PortableTextEditable = PortableTextEditable;
6519
6215
  exports.PortableTextEditor = PortableTextEditor;