@portabletext/editor 1.14.2 → 1.15.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.
Files changed (34) hide show
  1. package/lib/_chunks-cjs/selector.get-text-before.cjs +16 -5
  2. package/lib/_chunks-cjs/selector.get-text-before.cjs.map +1 -1
  3. package/lib/_chunks-es/selector.get-text-before.js +16 -5
  4. package/lib/_chunks-es/selector.get-text-before.js.map +1 -1
  5. package/lib/index.cjs +877 -544
  6. package/lib/index.cjs.map +1 -1
  7. package/lib/index.d.cts +15 -15
  8. package/lib/index.d.ts +15 -15
  9. package/lib/index.js +877 -544
  10. package/lib/index.js.map +1 -1
  11. package/package.json +9 -9
  12. package/src/editor/__tests__/PortableTextEditor.test.tsx +6 -6
  13. package/src/editor/__tests__/RangeDecorations.test.tsx +1 -1
  14. package/src/editor/__tests__/handleClick.test.tsx +4 -4
  15. package/src/editor/__tests__/insert-block.test.tsx +3 -3
  16. package/src/editor/__tests__/pteWarningsSelfSolving.test.tsx +6 -6
  17. package/src/editor/__tests__/self-solving.test.tsx +1 -1
  18. package/src/editor/components/DraggableBlock.tsx +1 -1
  19. package/src/editor/components/Element.tsx +8 -2
  20. package/src/editor/components/Leaf.tsx +1 -1
  21. package/src/editor/create-editor.ts +18 -29
  22. package/src/editor/hooks/useSyncValue.test.tsx +2 -2
  23. package/src/editor/hooks/useSyncValue.ts +2 -2
  24. package/src/editor/nodes/DefaultObject.tsx +1 -0
  25. package/src/editor/plugins/__tests__/withEditableAPIDelete.test.tsx +4 -4
  26. package/src/editor/plugins/__tests__/withEditableAPIGetFragment.test.tsx +2 -2
  27. package/src/editor/plugins/__tests__/withEditableAPIInsert.test.tsx +7 -7
  28. package/src/editor/plugins/__tests__/withEditableAPISelectionsOverlapping.test.tsx +4 -4
  29. package/src/editor/plugins/__tests__/withPortableTextLists.test.tsx +1 -1
  30. package/src/editor/plugins/__tests__/withPortableTextMarkModel.test.tsx +9 -9
  31. package/src/editor/plugins/__tests__/withPortableTextSelections.test.tsx +1 -1
  32. package/src/editor/plugins/__tests__/withUndoRedo.test.tsx +2 -2
  33. package/src/types/editor.ts +14 -13
  34. package/src/utils/__tests__/valueNormalization.test.tsx +1 -1
package/lib/index.cjs CHANGED
@@ -1,4 +1,15 @@
1
1
  "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty, __propIsEnum = Object.prototype.propertyIsEnumerable;
5
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: !0, configurable: !0, writable: !0, value }) : obj[key] = value, __spreadValues = (a, b) => {
6
+ for (var prop in b || (b = {}))
7
+ __hasOwnProp.call(b, prop) && __defNormalProp(a, prop, b[prop]);
8
+ if (__getOwnPropSymbols)
9
+ for (var prop of __getOwnPropSymbols(b))
10
+ __propIsEnum.call(b, prop) && __defNormalProp(a, prop, b[prop]);
11
+ return a;
12
+ };
2
13
  Object.defineProperty(exports, "__esModule", { value: !0 });
3
14
  var selector_getTextBefore = require("./_chunks-cjs/selector.get-text-before.cjs"), types = require("@sanity/types"), schema = require("@sanity/schema"), startCase = require("lodash.startcase"), jsxRuntime = require("react/jsx-runtime"), react = require("@xstate/react"), 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"), useEffectEvent = require("use-effect-event"), throttle = require("lodash/throttle.js"), debounce = require("lodash/debounce.js"), patches = require("@portabletext/patches"), flatten = require("lodash/flatten.js"), isPlainObject = require("lodash/isPlainObject.js"), xstate = require("xstate"), get = require("lodash/get.js"), isUndefined = require("lodash/isUndefined.js"), omitBy = require("lodash/omitBy.js"), getRandomValues = require("get-random-values-esm"), blockTools = require("@sanity/block-tools");
4
15
  function _interopDefaultCompat(e) {
@@ -110,12 +121,14 @@ function compareHotkey(parsedHotkey, event) {
110
121
  return (parsedHotkey.altKey == null || parsedHotkey.altKey === event.altKey) && (parsedHotkey.ctrlKey == null || parsedHotkey.ctrlKey === event.ctrlKey) && (parsedHotkey.metaKey == null || parsedHotkey.metaKey === event.metaKey) && (parsedHotkey.shiftKey == null || parsedHotkey.shiftKey === event.shiftKey) ? parsedHotkey.keyCode !== void 0 && event.keyCode !== void 0 ? parsedHotkey.keyCode === 91 && event.keyCode === 93 ? !0 : parsedHotkey.keyCode === event.keyCode : parsedHotkey.keyCode === event.keyCode || parsedHotkey.key === event.key.toLowerCase() : !1;
111
122
  }
112
123
  function toKeyCode(name) {
124
+ var _a;
113
125
  const keyName = toKeyName(name);
114
- return keyCodes[keyName] ?? keyName.toUpperCase().charCodeAt(0);
126
+ return (_a = keyCodes[keyName]) != null ? _a : keyName.toUpperCase().charCodeAt(0);
115
127
  }
116
128
  function toKeyName(name) {
129
+ var _a;
117
130
  const keyName = name.toLowerCase();
118
- return aliases[keyName] ?? keyName;
131
+ return (_a = aliases[keyName]) != null ? _a : keyName;
119
132
  }
120
133
  function defineBehavior(behavior) {
121
134
  return behavior;
@@ -127,11 +140,12 @@ function createCodeEditorBehaviors(config) {
127
140
  context,
128
141
  event
129
142
  }) => {
143
+ var _a;
130
144
  const isMoveUpShortcut = isHotkey(config.moveBlockUpShortcut, event.keyboardEvent), firstBlock = selector_getTextBefore.getFirstBlock({
131
145
  context
132
146
  }), selectedBlocks = selector_getTextBefore.getSelectedBlocks({
133
147
  context
134
- }), blocksAbove = firstBlock?.node._key !== selectedBlocks[0]?.node._key;
148
+ }), blocksAbove = (firstBlock == null ? void 0 : firstBlock.node._key) !== ((_a = selectedBlocks[0]) == null ? void 0 : _a.node._key);
135
149
  return !isMoveUpShortcut || !blocksAbove ? !1 : {
136
150
  paths: selectedBlocks.map((block) => block.path)
137
151
  };
@@ -148,11 +162,12 @@ function createCodeEditorBehaviors(config) {
148
162
  context,
149
163
  event
150
164
  }) => {
165
+ var _a;
151
166
  const isMoveDownShortcut = isHotkey(config.moveBlockDownShortcut, event.keyboardEvent), lastBlock = selector_getTextBefore.getLastBlock({
152
167
  context
153
168
  }), selectedBlocks = selector_getTextBefore.getSelectedBlocks({
154
169
  context
155
- }), blocksBelow = lastBlock?.node._key !== selectedBlocks[selectedBlocks.length - 1]?.node._key;
170
+ }), blocksBelow = (lastBlock == null ? void 0 : lastBlock.node._key) !== ((_a = selectedBlocks[selectedBlocks.length - 1]) == null ? void 0 : _a.node._key);
156
171
  return !isMoveDownShortcut || !blocksBelow ? !1 : {
157
172
  paths: selectedBlocks.map((block) => block.path).reverse()
158
173
  };
@@ -172,7 +187,10 @@ function isEmptyTextBlock(block) {
172
187
  return onlyText && blockText === "";
173
188
  }
174
189
  function getTextBlockText(block) {
175
- return block.children.map((child) => child.text ?? "").join("");
190
+ return block.children.map((child) => {
191
+ var _a;
192
+ return (_a = child.text) != null ? _a : "";
193
+ }).join("");
176
194
  }
177
195
  const arrowDownOnLonelyBlockObject = {
178
196
  on: "key.down",
@@ -498,9 +516,10 @@ function createLinkBehaviors(config) {
498
516
  context,
499
517
  event
500
518
  }) => {
519
+ var _a;
501
520
  const selectionCollapsed = selector_getTextBefore.selectionIsCollapsed({
502
521
  context
503
- }), text = event.data.getData("text/plain"), url = looksLikeUrl(text) ? text : void 0, annotation = url !== void 0 ? config.linkAnnotation?.({
522
+ }), text = event.data.getData("text/plain"), url = looksLikeUrl(text) ? text : void 0, annotation = url !== void 0 ? (_a = config.linkAnnotation) == null ? void 0 : _a.call(config, {
504
523
  url,
505
524
  schema: context.schema
506
525
  }) : void 0;
@@ -520,6 +539,7 @@ function createLinkBehaviors(config) {
520
539
  context,
521
540
  event
522
541
  }) => {
542
+ var _a;
523
543
  const focusSpan = selector_getTextBefore.getFocusSpan({
524
544
  context
525
545
  }), selectionCollapsed = selector_getTextBefore.selectionIsCollapsed({
@@ -527,7 +547,7 @@ function createLinkBehaviors(config) {
527
547
  });
528
548
  if (!focusSpan || !selectionCollapsed)
529
549
  return !1;
530
- const text = event.data.getData("text/plain"), url = looksLikeUrl(text) ? text : void 0, annotation = url !== void 0 ? config.linkAnnotation?.({
550
+ const text = event.data.getData("text/plain"), url = looksLikeUrl(text) ? text : void 0, annotation = url !== void 0 ? (_a = config.linkAnnotation) == null ? void 0 : _a.call(config, {
531
551
  url,
532
552
  schema: context.schema
533
553
  }) : void 0;
@@ -552,7 +572,7 @@ function looksLikeUrl(text) {
552
572
  let looksLikeUrl2 = !1;
553
573
  try {
554
574
  new URL(text), looksLikeUrl2 = !0;
555
- } catch {
575
+ } catch (e) {
556
576
  }
557
577
  return looksLikeUrl2;
558
578
  }
@@ -608,6 +628,14 @@ function spanSelectionPointToBlockOffset({
608
628
  }
609
629
  }
610
630
  }
631
+ var __defProp$q = Object.defineProperty, __getOwnPropSymbols$q = Object.getOwnPropertySymbols, __hasOwnProp$q = Object.prototype.hasOwnProperty, __propIsEnum$q = Object.prototype.propertyIsEnumerable, __defNormalProp$q = (obj, key, value) => key in obj ? __defProp$q(obj, key, { enumerable: !0, configurable: !0, writable: !0, value }) : obj[key] = value, __spreadValues$q = (a, b) => {
632
+ for (var prop in b || (b = {}))
633
+ __hasOwnProp$q.call(b, prop) && __defNormalProp$q(a, prop, b[prop]);
634
+ if (__getOwnPropSymbols$q)
635
+ for (var prop of __getOwnPropSymbols$q(b))
636
+ __propIsEnum$q.call(b, prop) && __defNormalProp$q(a, prop, b[prop]);
637
+ return a;
638
+ };
611
639
  function createMarkdownBehaviors(config) {
612
640
  const automaticBlockquoteOnSpace = {
613
641
  on: "insert.text",
@@ -615,6 +643,7 @@ function createMarkdownBehaviors(config) {
615
643
  context,
616
644
  event
617
645
  }) => {
646
+ var _a;
618
647
  if (event.text !== " ")
619
648
  return !1;
620
649
  const selectionCollapsed = selector_getTextBefore.selectionIsCollapsed({
@@ -639,7 +668,7 @@ function createMarkdownBehaviors(config) {
639
668
  });
640
669
  if (!blockOffset)
641
670
  return !1;
642
- const blockText = getTextBlockText(focusTextBlock.node), caretAtTheEndOfQuote = blockOffset.offset === 1, looksLikeMarkdownQuote = /^>/.test(blockText), blockquoteStyle = config.blockquoteStyle?.(context);
671
+ const blockText = getTextBlockText(focusTextBlock.node), caretAtTheEndOfQuote = blockOffset.offset === 1, looksLikeMarkdownQuote = /^>/.test(blockText), blockquoteStyle = (_a = config.blockquoteStyle) == null ? void 0 : _a.call(config, context);
643
672
  return caretAtTheEndOfQuote && looksLikeMarkdownQuote && blockquoteStyle !== void 0 ? {
644
673
  focusTextBlock,
645
674
  style: blockquoteStyle
@@ -676,10 +705,11 @@ function createMarkdownBehaviors(config) {
676
705
  context,
677
706
  event
678
707
  }) => {
708
+ var _a;
679
709
  const hrCharacter = event.text === "-" ? "-" : event.text === "*" ? "*" : event.text === "_" ? "_" : void 0;
680
710
  if (hrCharacter === void 0)
681
711
  return !1;
682
- const hrObject = config.horizontalRuleObject?.(context), focusBlock = selector_getTextBefore.getFocusTextBlock({
712
+ const hrObject = (_a = config.horizontalRuleObject) == null ? void 0 : _a.call(config, context), focusBlock = selector_getTextBefore.getFocusTextBlock({
683
713
  context
684
714
  }), selectionCollapsed = selector_getTextBefore.selectionIsCollapsed({
685
715
  context
@@ -717,17 +747,17 @@ function createMarkdownBehaviors(config) {
717
747
  type: "insert.block object",
718
748
  placement: "before",
719
749
  blockObject: hrObject
720
- }, {
721
- type: "delete.text",
722
- ...hrBlockOffsets
723
- }]]
750
+ }, __spreadValues$q({
751
+ type: "delete.text"
752
+ }, hrBlockOffsets)]]
724
753
  }, automaticHrOnPaste = {
725
754
  on: "paste",
726
755
  guard: ({
727
756
  context,
728
757
  event
729
758
  }) => {
730
- const text = event.data.getData("text/plain"), hrRegExp = /^(---)$|(___)$|(\*\*\*)$/gm, hrCharacters = text.match(hrRegExp)?.[0], hrObject = config.horizontalRuleObject?.(context), focusBlock = selector_getTextBefore.getFocusBlock({
759
+ var _a, _b;
760
+ const text = event.data.getData("text/plain"), hrRegExp = /^(---)$|(___)$|(\*\*\*)$/gm, hrCharacters = (_a = text.match(hrRegExp)) == null ? void 0 : _a[0], hrObject = (_b = config.horizontalRuleObject) == null ? void 0 : _b.call(config, context), focusBlock = selector_getTextBefore.getFocusBlock({
731
761
  context
732
762
  });
733
763
  return !hrCharacters || !hrObject || !focusBlock ? !1 : {
@@ -768,6 +798,7 @@ function createMarkdownBehaviors(config) {
768
798
  context,
769
799
  event
770
800
  }) => {
801
+ var _a;
771
802
  if (event.text !== " ")
772
803
  return !1;
773
804
  const selectionCollapsed = selector_getTextBefore.selectionIsCollapsed({
@@ -795,7 +826,7 @@ function createMarkdownBehaviors(config) {
795
826
  const blockText = getTextBlockText(focusTextBlock.node), markdownHeadingSearch = /^#+/.exec(blockText), level = markdownHeadingSearch ? markdownHeadingSearch[0].length : void 0;
796
827
  if (blockOffset.offset !== level)
797
828
  return !1;
798
- const style = level !== void 0 ? config.headingStyle?.({
829
+ const style = level !== void 0 ? (_a = config.headingStyle) == null ? void 0 : _a.call(config, {
799
830
  schema: context.schema,
800
831
  level
801
832
  }) : void 0;
@@ -836,6 +867,7 @@ function createMarkdownBehaviors(config) {
836
867
  guard: ({
837
868
  context
838
869
  }) => {
870
+ var _a;
839
871
  const selectionCollapsed = selector_getTextBefore.selectionIsCollapsed({
840
872
  context
841
873
  }), focusTextBlock = selector_getTextBefore.getFocusTextBlock({
@@ -845,7 +877,7 @@ function createMarkdownBehaviors(config) {
845
877
  });
846
878
  if (!selectionCollapsed || !focusTextBlock || !focusSpan)
847
879
  return !1;
848
- const atTheBeginningOfBLock = focusTextBlock.node.children[0]._key === focusSpan.node._key && context.selection.focus.offset === 0, defaultStyle = config.defaultStyle?.(context);
880
+ const atTheBeginningOfBLock = focusTextBlock.node.children[0]._key === focusSpan.node._key && context.selection.focus.offset === 0, defaultStyle = (_a = config.defaultStyle) == null ? void 0 : _a.call(config, context);
849
881
  return atTheBeginningOfBLock && defaultStyle && focusTextBlock.node.style !== defaultStyle ? {
850
882
  defaultStyle,
851
883
  focusTextBlock
@@ -865,6 +897,7 @@ function createMarkdownBehaviors(config) {
865
897
  context,
866
898
  event
867
899
  }) => {
900
+ var _a, _b, _c;
868
901
  if (event.text !== " ")
869
902
  return !1;
870
903
  const selectionCollapsed = selector_getTextBefore.selectionIsCollapsed({
@@ -889,7 +922,7 @@ function createMarkdownBehaviors(config) {
889
922
  });
890
923
  if (!blockOffset)
891
924
  return !1;
892
- const blockText = getTextBlockText(focusTextBlock.node), defaultStyle = config.defaultStyle?.(context), looksLikeUnorderedList = /^(-|\*)/.test(blockText), unorderedListStyle = config.unorderedListStyle?.(context), caretAtTheEndOfUnorderedList = blockOffset.offset === 1;
925
+ const blockText = getTextBlockText(focusTextBlock.node), defaultStyle = (_a = config.defaultStyle) == null ? void 0 : _a.call(config, context), looksLikeUnorderedList = /^(-|\*)/.test(blockText), unorderedListStyle = (_b = config.unorderedListStyle) == null ? void 0 : _b.call(config, context), caretAtTheEndOfUnorderedList = blockOffset.offset === 1;
893
926
  if (defaultStyle && caretAtTheEndOfUnorderedList && looksLikeUnorderedList && unorderedListStyle !== void 0)
894
927
  return {
895
928
  focusTextBlock,
@@ -897,7 +930,7 @@ function createMarkdownBehaviors(config) {
897
930
  listItemLength: 1,
898
931
  style: defaultStyle
899
932
  };
900
- const looksLikeOrderedList = /^1\./.test(blockText), orderedListStyle = config.orderedListStyle?.(context), caretAtTheEndOfOrderedList = blockOffset.offset === 2;
933
+ const looksLikeOrderedList = /^1\./.test(blockText), orderedListStyle = (_c = config.orderedListStyle) == null ? void 0 : _c.call(config, context), caretAtTheEndOfOrderedList = blockOffset.offset === 2;
901
934
  return defaultStyle && caretAtTheEndOfOrderedList && looksLikeOrderedList && orderedListStyle !== void 0 ? {
902
935
  focusTextBlock,
903
936
  listItem: orderedListStyle,
@@ -934,12 +967,13 @@ function createMarkdownBehaviors(config) {
934
967
  return [automaticBlockquoteOnSpace, automaticHeadingOnSpace, automaticHr, automaticHrOnPaste, clearStyleOnBackspace, automaticListOnSpace];
935
968
  }
936
969
  function getPortableTextMemberSchemaTypes(portableTextType) {
970
+ var _a, _b, _c;
937
971
  if (!portableTextType)
938
972
  throw new Error("Parameter 'portabletextType' missing (required)");
939
- const blockType = portableTextType.of?.find(findBlockType);
973
+ const blockType = (_a = portableTextType.of) == null ? void 0 : _a.find(findBlockType);
940
974
  if (!blockType)
941
975
  throw new Error("Block type is not defined in this schema (required)");
942
- const childrenField = blockType.fields?.find((field) => field.name === "children");
976
+ const childrenField = (_b = blockType.fields) == null ? void 0 : _b.find((field) => field.name === "children");
943
977
  if (!childrenField)
944
978
  throw new Error("Children field for block type found in schema (required)");
945
979
  const ofType = childrenField.type.of;
@@ -948,7 +982,7 @@ function getPortableTextMemberSchemaTypes(portableTextType) {
948
982
  const spanType = ofType.find((memberType) => memberType.name === "span");
949
983
  if (!spanType)
950
984
  throw new Error("Span type not found in schema (required)");
951
- const inlineObjectTypes = ofType.filter((memberType) => memberType.name !== "span") || [], blockObjectTypes = portableTextType.of?.filter((field) => field.name !== blockType.name) || [];
985
+ const inlineObjectTypes = ofType.filter((memberType) => memberType.name !== "span") || [], blockObjectTypes = ((_c = portableTextType.of) == null ? void 0 : _c.filter((field) => field.name !== blockType.name)) || [];
952
986
  return {
953
987
  styles: resolveEnabledStyles(blockType),
954
988
  decorators: resolveEnabledDecorators(spanType),
@@ -962,10 +996,11 @@ function getPortableTextMemberSchemaTypes(portableTextType) {
962
996
  };
963
997
  }
964
998
  function resolveEnabledStyles(blockType) {
965
- const styleField = blockType.fields?.find((btField) => btField.name === "style");
999
+ var _a, _b, _c;
1000
+ const styleField = (_a = blockType.fields) == null ? void 0 : _a.find((btField) => btField.name === "style");
966
1001
  if (!styleField)
967
1002
  throw new Error("A field with name 'style' is not defined in the block type (required).");
968
- const textStyles = styleField.type.options?.list && styleField.type.options.list?.filter((style) => style.value);
1003
+ const textStyles = ((_b = styleField.type.options) == null ? void 0 : _b.list) && ((_c = styleField.type.options.list) == null ? void 0 : _c.filter((style) => style.value));
969
1004
  if (!textStyles || textStyles.length === 0)
970
1005
  throw new Error("The style fields need at least one style defined. I.e: {title: 'Normal', value: 'normal'}.");
971
1006
  return textStyles;
@@ -974,10 +1009,11 @@ function resolveEnabledDecorators(spanType) {
974
1009
  return spanType.decorators;
975
1010
  }
976
1011
  function resolveEnabledListItems(blockType) {
977
- const listField = blockType.fields?.find((btField) => btField.name === "listItem");
1012
+ var _a, _b;
1013
+ const listField = (_a = blockType.fields) == null ? void 0 : _a.find((btField) => btField.name === "listItem");
978
1014
  if (!listField)
979
1015
  throw new Error("A field with name 'listItem' is not defined in the block type (required).");
980
- const listItems = listField.type.options?.list && listField.type.options.list.filter((list) => list.value);
1016
+ const listItems = ((_b = listField.type.options) == null ? void 0 : _b.list) && listField.type.options.list.filter((list) => list.value);
981
1017
  if (!listItems)
982
1018
  throw new Error("The list field need at least to be an empty array");
983
1019
  return listItems;
@@ -985,11 +1021,20 @@ function resolveEnabledListItems(blockType) {
985
1021
  function findBlockType(type) {
986
1022
  return type.type ? findBlockType(type.type) : type.name === "block" ? type : null;
987
1023
  }
1024
+ var __defProp$p = Object.defineProperty, __defProps$j = Object.defineProperties, __getOwnPropDescs$j = Object.getOwnPropertyDescriptors, __getOwnPropSymbols$p = Object.getOwnPropertySymbols, __hasOwnProp$p = Object.prototype.hasOwnProperty, __propIsEnum$p = Object.prototype.propertyIsEnumerable, __defNormalProp$p = (obj, key, value) => key in obj ? __defProp$p(obj, key, { enumerable: !0, configurable: !0, writable: !0, value }) : obj[key] = value, __spreadValues$p = (a, b) => {
1025
+ for (var prop in b || (b = {}))
1026
+ __hasOwnProp$p.call(b, prop) && __defNormalProp$p(a, prop, b[prop]);
1027
+ if (__getOwnPropSymbols$p)
1028
+ for (var prop of __getOwnPropSymbols$p(b))
1029
+ __propIsEnum$p.call(b, prop) && __defNormalProp$p(a, prop, b[prop]);
1030
+ return a;
1031
+ }, __spreadProps$j = (a, b) => __defProps$j(a, __getOwnPropDescs$j(b));
988
1032
  function defineSchema(definition) {
989
1033
  return definition;
990
1034
  }
991
1035
  function compileSchemaDefinition(definition) {
992
- const blockObjects = definition?.blockObjects?.map((blockObject) => types.defineType({
1036
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
1037
+ const blockObjects = (_b = (_a = definition == null ? void 0 : definition.blockObjects) == null ? void 0 : _a.map((blockObject) => types.defineType({
993
1038
  type: "object",
994
1039
  // Very naive way to work around `SanitySchema.compile` adding default
995
1040
  // fields to objects with the name `image`
@@ -997,13 +1042,13 @@ function compileSchemaDefinition(definition) {
997
1042
  title: blockObject.title,
998
1043
  icon: blockObject.icon,
999
1044
  fields: []
1000
- })) ?? [], inlineObjects = definition?.inlineObjects?.map((inlineObject) => types.defineType({
1045
+ }))) != null ? _b : [], inlineObjects = (_d = (_c = definition == null ? void 0 : definition.inlineObjects) == null ? void 0 : _c.map((inlineObject) => types.defineType({
1001
1046
  type: "object",
1002
1047
  name: inlineObject.name,
1003
1048
  title: inlineObject.title,
1004
1049
  icon: inlineObject.icon,
1005
1050
  fields: []
1006
- })) ?? [], portableTextSchema = types.defineField({
1051
+ }))) != null ? _d : [], portableTextSchema = types.defineField({
1007
1052
  type: "array",
1008
1053
  name: "portable-text",
1009
1054
  of: [...blockObjects.map((blockObject) => ({
@@ -1015,43 +1060,49 @@ function compileSchemaDefinition(definition) {
1015
1060
  type: inlineObject.name
1016
1061
  })),
1017
1062
  marks: {
1018
- decorators: definition?.decorators?.map((decorator) => ({
1019
- title: decorator.title ?? startCase__default.default(decorator.name),
1020
- value: decorator.name,
1021
- icon: decorator.icon
1022
- })) ?? [],
1023
- annotations: definition?.annotations?.map((annotation) => ({
1063
+ decorators: (_f = (_e = definition == null ? void 0 : definition.decorators) == null ? void 0 : _e.map((decorator) => {
1064
+ var _a2;
1065
+ return {
1066
+ title: (_a2 = decorator.title) != null ? _a2 : startCase__default.default(decorator.name),
1067
+ value: decorator.name,
1068
+ icon: decorator.icon
1069
+ };
1070
+ })) != null ? _f : [],
1071
+ annotations: (_h = (_g = definition == null ? void 0 : definition.annotations) == null ? void 0 : _g.map((annotation) => ({
1024
1072
  name: annotation.name,
1025
1073
  type: "object",
1026
1074
  title: annotation.title,
1027
1075
  icon: annotation.icon
1028
- })) ?? []
1076
+ }))) != null ? _h : []
1029
1077
  },
1030
- lists: definition?.lists?.map((list) => ({
1031
- value: list.name,
1032
- title: list.title ?? startCase__default.default(list.name),
1033
- icon: list.icon
1034
- })) ?? [],
1035
- styles: definition?.styles?.map((style) => ({
1036
- value: style.name,
1037
- title: style.title ?? startCase__default.default(style.name),
1038
- icon: style.icon
1039
- })) ?? []
1078
+ lists: (_j = (_i = definition == null ? void 0 : definition.lists) == null ? void 0 : _i.map((list) => {
1079
+ var _a2;
1080
+ return {
1081
+ value: list.name,
1082
+ title: (_a2 = list.title) != null ? _a2 : startCase__default.default(list.name),
1083
+ icon: list.icon
1084
+ };
1085
+ })) != null ? _j : [],
1086
+ styles: (_l = (_k = definition == null ? void 0 : definition.styles) == null ? void 0 : _k.map((style) => {
1087
+ var _a2;
1088
+ return {
1089
+ value: style.name,
1090
+ title: (_a2 = style.title) != null ? _a2 : startCase__default.default(style.name),
1091
+ icon: style.icon
1092
+ };
1093
+ })) != null ? _l : []
1040
1094
  }]
1041
1095
  }), schema$1 = schema.Schema.compile({
1042
1096
  types: [portableTextSchema, ...blockObjects, ...inlineObjects]
1043
1097
  }).get("portable-text"), pteSchema = getPortableTextMemberSchemaTypes(schema$1);
1044
- return {
1045
- ...pteSchema,
1046
- blockObjects: pteSchema.blockObjects.map((blockObject) => blockObject.name === "tmp-image" ? {
1047
- ...blockObject,
1098
+ return __spreadProps$j(__spreadValues$p({}, pteSchema), {
1099
+ blockObjects: pteSchema.blockObjects.map((blockObject) => blockObject.name === "tmp-image" ? __spreadProps$j(__spreadValues$p({}, blockObject), {
1048
1100
  name: "image",
1049
- type: {
1050
- ...blockObject.type,
1101
+ type: __spreadProps$j(__spreadValues$p({}, blockObject.type), {
1051
1102
  name: "image"
1052
- }
1053
- } : blockObject)
1054
- };
1103
+ })
1104
+ }) : blockObject)
1105
+ });
1055
1106
  }
1056
1107
  const rootName = "sanity-pte:";
1057
1108
  var debug$l = debug__default.default(rootName);
@@ -1186,6 +1237,22 @@ function normalizeSelection(selection, value) {
1186
1237
  backward: selection.backward
1187
1238
  } : null;
1188
1239
  }
1240
+ var __defProp$o = Object.defineProperty, __defProps$i = Object.defineProperties, __getOwnPropDescs$i = Object.getOwnPropertyDescriptors, __getOwnPropSymbols$o = Object.getOwnPropertySymbols, __hasOwnProp$o = Object.prototype.hasOwnProperty, __propIsEnum$o = Object.prototype.propertyIsEnumerable, __defNormalProp$o = (obj, key, value) => key in obj ? __defProp$o(obj, key, { enumerable: !0, configurable: !0, writable: !0, value }) : obj[key] = value, __spreadValues$o = (a, b) => {
1241
+ for (var prop in b || (b = {}))
1242
+ __hasOwnProp$o.call(b, prop) && __defNormalProp$o(a, prop, b[prop]);
1243
+ if (__getOwnPropSymbols$o)
1244
+ for (var prop of __getOwnPropSymbols$o(b))
1245
+ __propIsEnum$o.call(b, prop) && __defNormalProp$o(a, prop, b[prop]);
1246
+ return a;
1247
+ }, __spreadProps$i = (a, b) => __defProps$i(a, __getOwnPropDescs$i(b)), __objRest$3 = (source, exclude) => {
1248
+ var target = {};
1249
+ for (var prop in source)
1250
+ __hasOwnProp$o.call(source, prop) && exclude.indexOf(prop) < 0 && (target[prop] = source[prop]);
1251
+ if (source != null && __getOwnPropSymbols$o)
1252
+ for (var prop of __getOwnPropSymbols$o(source))
1253
+ exclude.indexOf(prop) < 0 && __propIsEnum$o.call(source, prop) && (target[prop] = source[prop]);
1254
+ return target;
1255
+ };
1189
1256
  const VOID_CHILD_KEY = "void-child";
1190
1257
  function keepObjectEquality(object, keyMap) {
1191
1258
  const value = keyMap[object._key];
@@ -1195,11 +1262,13 @@ function toSlateValue(value, {
1195
1262
  schemaTypes
1196
1263
  }, keyMap = {}) {
1197
1264
  return value && Array.isArray(value) ? value.map((block) => {
1198
- const {
1265
+ const _a = block, {
1199
1266
  _type,
1200
- _key,
1201
- ...rest
1202
- } = block, voidChildren = [{
1267
+ _key
1268
+ } = _a, rest = __objRest$3(_a, [
1269
+ "_type",
1270
+ "_key"
1271
+ ]), voidChildren = [{
1203
1272
  _key: VOID_CHILD_KEY,
1204
1273
  _type: "span",
1205
1274
  text: "",
@@ -1209,11 +1278,13 @@ function toSlateValue(value, {
1209
1278
  const textBlock = block;
1210
1279
  let hasInlines = !1;
1211
1280
  const hasMissingStyle = typeof textBlock.style > "u", hasMissingMarkDefs = typeof textBlock.markDefs > "u", hasMissingChildren = typeof textBlock.children > "u", children = (textBlock.children || []).map((child) => {
1212
- const {
1281
+ const _a2 = child, {
1213
1282
  _type: cType,
1214
- _key: cKey,
1215
- ...cRest
1216
- } = child;
1283
+ _key: cKey
1284
+ } = _a2, cRest = __objRest$3(_a2, [
1285
+ "_type",
1286
+ "_key"
1287
+ ]);
1217
1288
  return cType !== "span" ? (hasInlines = !0, keepObjectEquality({
1218
1289
  _type: cType,
1219
1290
  _key: cKey,
@@ -1222,12 +1293,12 @@ function toSlateValue(value, {
1222
1293
  __inline: !0
1223
1294
  }, keyMap)) : child;
1224
1295
  });
1225
- return !hasMissingStyle && !hasMissingMarkDefs && !hasMissingChildren && !hasInlines && slate.Element.isElement(block) ? block : (hasMissingStyle && (rest.style = schemaTypes.styles[0].value), keepObjectEquality({
1296
+ return !hasMissingStyle && !hasMissingMarkDefs && !hasMissingChildren && !hasInlines && slate.Element.isElement(block) ? block : (hasMissingStyle && (rest.style = schemaTypes.styles[0].value), keepObjectEquality(__spreadProps$i(__spreadValues$o({
1226
1297
  _type,
1227
- _key,
1228
- ...rest,
1298
+ _key
1299
+ }, rest), {
1229
1300
  children
1230
- }, keyMap));
1301
+ }), keyMap));
1231
1302
  }
1232
1303
  return keepObjectEquality({
1233
1304
  _type,
@@ -1253,40 +1324,42 @@ function fromSlateValue(value, textBlockType, keyMap = {}) {
1253
1324
  } = child;
1254
1325
  if ("value" in child && _cType !== "span") {
1255
1326
  hasInlines = !0;
1256
- const {
1327
+ const _a = child, {
1257
1328
  value: v,
1258
1329
  _key: k,
1259
1330
  _type: t,
1260
1331
  __inline: _i,
1261
- children: _c,
1262
- ...rest
1263
- } = child;
1264
- return keepObjectEquality({
1265
- ...rest,
1266
- ...v,
1332
+ children: _c
1333
+ } = _a, rest = __objRest$3(_a, [
1334
+ "value",
1335
+ "_key",
1336
+ "_type",
1337
+ "__inline",
1338
+ "children"
1339
+ ]);
1340
+ return keepObjectEquality(__spreadProps$i(__spreadValues$o(__spreadValues$o({}, rest), v), {
1267
1341
  _key: k,
1268
1342
  _type: t
1269
- }, keyMap);
1343
+ }), keyMap);
1270
1344
  }
1271
1345
  return child;
1272
1346
  });
1273
- return hasInlines ? keepObjectEquality({
1274
- ...block,
1347
+ return hasInlines ? keepObjectEquality(__spreadProps$i(__spreadValues$o({}, block), {
1275
1348
  children,
1276
1349
  _key,
1277
1350
  _type
1278
- }, keyMap) : block;
1351
+ }), keyMap) : block;
1279
1352
  }
1280
1353
  const blockValue = "value" in block && block.value;
1281
- return keepObjectEquality({
1354
+ return keepObjectEquality(__spreadValues$o({
1282
1355
  _key,
1283
- _type,
1284
- ...typeof blockValue == "object" ? blockValue : {}
1285
- }, keyMap);
1356
+ _type
1357
+ }, typeof blockValue == "object" ? blockValue : {}), keyMap);
1286
1358
  });
1287
1359
  }
1288
1360
  function isEqualToEmptyEditor(children, schemaTypes) {
1289
- return children === void 0 || children && Array.isArray(children) && children.length === 0 || children && Array.isArray(children) && children.length === 1 && slate.Element.isElement(children[0]) && children[0]._type === schemaTypes.block.name && "style" in children[0] && children[0].style === schemaTypes.styles[0].value && !("listItem" in children[0]) && Array.isArray(children[0].children) && children[0].children.length === 1 && slate.Text.isText(children[0].children[0]) && children[0].children[0]._type === "span" && !children[0].children[0].marks?.join("") && children[0].children[0].text === "";
1361
+ var _a;
1362
+ return children === void 0 || children && Array.isArray(children) && children.length === 0 || children && Array.isArray(children) && children.length === 1 && slate.Element.isElement(children[0]) && children[0]._type === schemaTypes.block.name && "style" in children[0] && children[0].style === schemaTypes.styles[0].value && !("listItem" in children[0]) && Array.isArray(children[0].children) && children[0].children.length === 1 && slate.Text.isText(children[0].children[0]) && children[0].children[0]._type === "span" && !((_a = children[0].children[0].marks) != null && _a.join("")) && children[0].children[0].text === "";
1290
1363
  }
1291
1364
  const IS_PROCESSING_REMOTE_CHANGES = /* @__PURE__ */ new WeakMap(), IS_PROCESSING_LOCAL_CHANGES = /* @__PURE__ */ new WeakMap(), IS_DRAGGING = /* @__PURE__ */ new WeakMap(), IS_DRAGGING_BLOCK_ELEMENT = /* @__PURE__ */ new WeakMap(), IS_DRAGGING_ELEMENT_TARGET = /* @__PURE__ */ new WeakMap(), IS_DRAGGING_BLOCK_TARGET_POSITION = /* @__PURE__ */ new WeakMap(), KEY_TO_SLATE_ELEMENT = /* @__PURE__ */ new WeakMap(), KEY_TO_VALUE_ELEMENT = /* @__PURE__ */ new WeakMap(), SLATE_TO_PORTABLE_TEXT_RANGE = /* @__PURE__ */ new WeakMap(), DefaultObject = (props) => {
1292
1365
  const $ = reactCompilerRuntime.c(4);
@@ -1462,7 +1535,7 @@ const debug$k = debugWithName("components:DraggableBlock"), DraggableBlock = (t0
1462
1535
  element,
1463
1536
  readOnly,
1464
1537
  blockRef
1465
- } = t0, editor = slateReact.useSlateStatic(), dragGhostRef = React.useRef(), [isDragOver, setIsDragOver] = React.useState(!1);
1538
+ } = t0, editor = slateReact.useSlateStatic(), dragGhostRef = React.useRef(void 0), [isDragOver, setIsDragOver] = React.useState(!1);
1466
1539
  let t1, t2;
1467
1540
  $[0] !== editor || $[1] !== element ? (t2 = slate.Editor.isVoid(editor, element), $[0] = editor, $[1] = element, $[2] = t2) : t2 = $[2], t1 = t2;
1468
1541
  const isVoid = t1;
@@ -1586,6 +1659,14 @@ const debug$k = debugWithName("components:DraggableBlock"), DraggableBlock = (t0
1586
1659
  ] }), $[41] = children, $[42] = handleDrag, $[43] = handleDragEnd, $[44] = handleDragOver, $[45] = handleDragStart, $[46] = handleDrop, $[47] = isVoid, $[48] = t17, $[49] = t18, $[50] = t19) : t19 = $[50], t19;
1587
1660
  };
1588
1661
  DraggableBlock.displayName = "DraggableBlock";
1662
+ var __defProp$n = Object.defineProperty, __defProps$h = Object.defineProperties, __getOwnPropDescs$h = Object.getOwnPropertyDescriptors, __getOwnPropSymbols$n = Object.getOwnPropertySymbols, __hasOwnProp$n = Object.prototype.hasOwnProperty, __propIsEnum$n = Object.prototype.propertyIsEnumerable, __defNormalProp$n = (obj, key, value) => key in obj ? __defProp$n(obj, key, { enumerable: !0, configurable: !0, writable: !0, value }) : obj[key] = value, __spreadValues$n = (a, b) => {
1663
+ for (var prop in b || (b = {}))
1664
+ __hasOwnProp$n.call(b, prop) && __defNormalProp$n(a, prop, b[prop]);
1665
+ if (__getOwnPropSymbols$n)
1666
+ for (var prop of __getOwnPropSymbols$n(b))
1667
+ __propIsEnum$n.call(b, prop) && __defNormalProp$n(a, prop, b[prop]);
1668
+ return a;
1669
+ }, __spreadProps$h = (a, b) => __defProps$h(a, __getOwnPropDescs$h(b));
1589
1670
  debugWithName("components:Element");
1590
1671
  const EMPTY_ANNOTATIONS = [], inlineBlockStyle = {
1591
1672
  display: "inline-block"
@@ -1622,7 +1703,7 @@ const EMPTY_ANNOTATIONS = [], inlineBlockStyle = {
1622
1703
  }, "children", {
1623
1704
  _key: element._key
1624
1705
  }];
1625
- return /* @__PURE__ */ jsxRuntime.jsxs("span", { ...attributes, children: [
1706
+ return /* @__PURE__ */ jsxRuntime.jsxs("span", __spreadProps$h(__spreadValues$n({}, attributes), { children: [
1626
1707
  children,
1627
1708
  /* @__PURE__ */ jsxRuntime.jsxs("span", { draggable: !readOnly, className: "pt-inline-object", "data-testid": "pt-inline-object", ref: inlineBlockObjectRef, style: inlineBlockStyle, contentEditable: !1, children: [
1628
1709
  renderChild && renderChild({
@@ -1639,7 +1720,7 @@ const EMPTY_ANNOTATIONS = [], inlineBlockStyle = {
1639
1720
  }),
1640
1721
  !renderChild && /* @__PURE__ */ jsxRuntime.jsx(DefaultObject, { value })
1641
1722
  ] }, element._key)
1642
- ] });
1723
+ ] }));
1643
1724
  }
1644
1725
  throw new Error("Block not found!");
1645
1726
  }
@@ -1690,7 +1771,7 @@ const EMPTY_ANNOTATIONS = [], inlineBlockStyle = {
1690
1771
  return console.warn("Property 'type' is deprecated, use 'schemaType' instead."), schemaTypes.block;
1691
1772
  }
1692
1773
  }), propsOrDefaultRendered = renderBlock ? renderBlock(renderProps) : children;
1693
- return /* @__PURE__ */ jsxRuntime.jsx("div", { ...attributes, className, spellCheck, children: /* @__PURE__ */ jsxRuntime.jsx(DraggableBlock, { element, readOnly, blockRef, children: /* @__PURE__ */ jsxRuntime.jsx("div", { ref: blockRef, children: propsOrDefaultRendered }) }) }, element._key);
1774
+ return /* @__PURE__ */ jsxRuntime.jsx("div", __spreadProps$h(__spreadValues$n({}, attributes), { className, spellCheck, children: /* @__PURE__ */ jsxRuntime.jsx(DraggableBlock, { element, readOnly, blockRef, children: /* @__PURE__ */ jsxRuntime.jsx("div", { ref: blockRef, children: propsOrDefaultRendered }) }) }), element._key);
1694
1775
  }
1695
1776
  const schemaType_0 = schemaTypes.blockObjects.find((_type_0) => _type_0.name === element._type);
1696
1777
  if (!schemaType_0)
@@ -1715,13 +1796,13 @@ const EMPTY_ANNOTATIONS = [], inlineBlockStyle = {
1715
1796
  });
1716
1797
  renderedBlockFromProps = renderBlock(_props);
1717
1798
  }
1718
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { ...attributes, className, children: [
1799
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", __spreadProps$h(__spreadValues$n({}, attributes), { className, children: [
1719
1800
  children,
1720
1801
  /* @__PURE__ */ jsxRuntime.jsxs(DraggableBlock, { element, readOnly, blockRef, children: [
1721
1802
  renderedBlockFromProps && /* @__PURE__ */ jsxRuntime.jsx("div", { ref: blockRef, contentEditable: !1, children: renderedBlockFromProps }),
1722
1803
  !renderedBlockFromProps && /* @__PURE__ */ jsxRuntime.jsx(DefaultBlockObject, { selected, children: /* @__PURE__ */ jsxRuntime.jsx(DefaultObject, { value }) })
1723
1804
  ] })
1724
- ] }, element._key);
1805
+ ] }), element._key);
1725
1806
  };
1726
1807
  Element.displayName = "Element";
1727
1808
  const PortableTextEditorContext = React.createContext(null), usePortableTextEditor = () => {
@@ -1749,6 +1830,14 @@ function compileType(rawType) {
1749
1830
  types: [rawType]
1750
1831
  }).get(rawType.name);
1751
1832
  }
1833
+ var __defProp$m = Object.defineProperty, __defProps$g = Object.defineProperties, __getOwnPropDescs$g = Object.getOwnPropertyDescriptors, __getOwnPropSymbols$m = Object.getOwnPropertySymbols, __hasOwnProp$m = Object.prototype.hasOwnProperty, __propIsEnum$m = Object.prototype.propertyIsEnumerable, __defNormalProp$m = (obj, key, value) => key in obj ? __defProp$m(obj, key, { enumerable: !0, configurable: !0, writable: !0, value }) : obj[key] = value, __spreadValues$m = (a, b) => {
1834
+ for (var prop in b || (b = {}))
1835
+ __hasOwnProp$m.call(b, prop) && __defNormalProp$m(a, prop, b[prop]);
1836
+ if (__getOwnPropSymbols$m)
1837
+ for (var prop of __getOwnPropSymbols$m(b))
1838
+ __propIsEnum$m.call(b, prop) && __defNormalProp$m(a, prop, b[prop]);
1839
+ return a;
1840
+ }, __spreadProps$g = (a, b) => __defProps$g(a, __getOwnPropDescs$g(b));
1752
1841
  function validateValue(value, types$1, keyGenerator) {
1753
1842
  let resolution = null, valid = !0;
1754
1843
  const validChildTypes = [types$1.span.name, ...types$1.inlineObjects.map((t) => t.name)], validBlockTypes = [types$1.block.name, ...types$1.blockObjects.map((t) => t.name)];
@@ -1786,10 +1875,9 @@ function validateValue(value, types$1, keyGenerator) {
1786
1875
  }, !0;
1787
1876
  if (!blk._key || typeof blk._key != "string")
1788
1877
  return resolution = {
1789
- patches: [patches.set({
1790
- ...blk,
1878
+ patches: [patches.set(__spreadProps$g(__spreadValues$m({}, blk), {
1791
1879
  _key: keyGenerator()
1792
- }, [index])],
1880
+ }), [index])],
1793
1881
  description: `Block at index ${index} is missing required _key.`,
1794
1882
  action: "Set the block with a random _key value",
1795
1883
  item: blk,
@@ -1805,10 +1893,9 @@ function validateValue(value, types$1, keyGenerator) {
1805
1893
  if (blk._type === "block") {
1806
1894
  const currentBlockTypeName = types$1.block.name;
1807
1895
  return resolution = {
1808
- patches: [patches.set({
1809
- ...blk,
1896
+ patches: [patches.set(__spreadProps$g(__spreadValues$m({}, blk), {
1810
1897
  _type: currentBlockTypeName
1811
- }, [{
1898
+ }), [{
1812
1899
  _key: blk._key
1813
1900
  }])],
1814
1901
  description: `Block with _key '${blk._key}' has invalid type name '${blk._type}'. According to the schema, the block type name is '${currentBlockTypeName}'`,
@@ -1824,14 +1911,12 @@ function validateValue(value, types$1, keyGenerator) {
1824
1911
  }
1825
1912
  }, !0;
1826
1913
  }
1827
- return !blk._type && types.isPortableTextTextBlock({
1828
- ...blk,
1914
+ return !blk._type && types.isPortableTextTextBlock(__spreadProps$g(__spreadValues$m({}, blk), {
1829
1915
  _type: types$1.block.name
1830
- }) ? (resolution = {
1831
- patches: [patches.set({
1832
- ...blk,
1916
+ })) ? (resolution = {
1917
+ patches: [patches.set(__spreadProps$g(__spreadValues$m({}, blk), {
1833
1918
  _type: types$1.block.name
1834
- }, [{
1919
+ }), [{
1835
1920
  _key: blk._key
1836
1921
  }])],
1837
1922
  description: `Block with _key '${blk._key}' is missing a type name. According to the schema, the block type name is '${types$1.block.name}'`,
@@ -1991,10 +2076,9 @@ function validateValue(value, types$1, keyGenerator) {
1991
2076
  }
1992
2077
  }, !0;
1993
2078
  if (!child._key || typeof child._key != "string") {
1994
- const newChild = {
1995
- ...child,
2079
+ const newChild = __spreadProps$g(__spreadValues$m({}, child), {
1996
2080
  _key: keyGenerator()
1997
- };
2081
+ });
1998
2082
  return resolution = {
1999
2083
  autoResolve: !0,
2000
2084
  patches: [patches.set(newChild, [{
@@ -2014,10 +2098,9 @@ function validateValue(value, types$1, keyGenerator) {
2014
2098
  }, !0;
2015
2099
  }
2016
2100
  return child._type ? validChildTypes.includes(child._type) ? child._type === types$1.span.name && typeof child.text != "string" ? (resolution = {
2017
- patches: [patches.set({
2018
- ...child,
2101
+ patches: [patches.set(__spreadProps$g(__spreadValues$m({}, child), {
2019
2102
  text: ""
2020
- }, [{
2103
+ }), [{
2021
2104
  _key: blk._key
2022
2105
  }, "children", {
2023
2106
  _key: child._key
@@ -2428,11 +2511,10 @@ function createDeadLine(timeout) {
2428
2511
  return typeof timeout < "u" && (t = timeout <= 0 ? Number.MAX_VALUE : timeout), Date.now() + t * 1e3;
2429
2512
  }
2430
2513
  function createInternalOpts(opts) {
2431
- return {
2514
+ return __spreadValues({
2432
2515
  checkLines: !0,
2433
- deadline: createDeadLine(opts.timeout || 1),
2434
- ...opts
2435
- };
2516
+ deadline: createDeadLine(opts.timeout || 1)
2517
+ }, opts);
2436
2518
  }
2437
2519
  function combineChar(data, char, dir) {
2438
2520
  return dir === 1 ? data + char : char + data;
@@ -2496,10 +2578,7 @@ const DEFAULT_OPTIONS = {
2496
2578
  distance: 1e3
2497
2579
  };
2498
2580
  function applyDefaults(options) {
2499
- return {
2500
- ...DEFAULT_OPTIONS,
2501
- ...options
2502
- };
2581
+ return __spreadValues(__spreadValues({}, DEFAULT_OPTIONS), options);
2503
2582
  }
2504
2583
  const MAX_BITS$1 = 32;
2505
2584
  function bitap(text, pattern, loc) {
@@ -2771,7 +2850,7 @@ function parse(textline) {
2771
2850
  let line;
2772
2851
  try {
2773
2852
  line = decodeURI(currentLine.slice(1));
2774
- } catch {
2853
+ } catch (ex) {
2775
2854
  throw new Error("Illegal escape in parse: ".concat(currentLine));
2776
2855
  }
2777
2856
  const utf8Diff = countUtf8Bytes(line) - line.length;
@@ -2797,7 +2876,8 @@ function withUndoing(editor, fn) {
2797
2876
  IS_UDOING.set(editor, !0), fn(), IS_UDOING.set(editor, prev);
2798
2877
  }
2799
2878
  function isUndoing(editor) {
2800
- return IS_UDOING.get(editor) ?? !1;
2879
+ var _a;
2880
+ return (_a = IS_UDOING.get(editor)) != null ? _a : !1;
2801
2881
  }
2802
2882
  function setIsUndoing(editor, isUndoing2) {
2803
2883
  IS_UDOING.set(editor, isUndoing2);
@@ -2807,11 +2887,20 @@ function withRedoing(editor, fn) {
2807
2887
  IS_REDOING.set(editor, !0), fn(), IS_REDOING.set(editor, prev);
2808
2888
  }
2809
2889
  function isRedoing(editor) {
2810
- return IS_REDOING.get(editor) ?? !1;
2890
+ var _a;
2891
+ return (_a = IS_REDOING.get(editor)) != null ? _a : !1;
2811
2892
  }
2812
2893
  function setIsRedoing(editor, isRedoing2) {
2813
2894
  IS_REDOING.set(editor, isRedoing2);
2814
2895
  }
2896
+ var __defProp$l = Object.defineProperty, __getOwnPropSymbols$l = Object.getOwnPropertySymbols, __hasOwnProp$l = Object.prototype.hasOwnProperty, __propIsEnum$l = Object.prototype.propertyIsEnumerable, __defNormalProp$l = (obj, key, value) => key in obj ? __defProp$l(obj, key, { enumerable: !0, configurable: !0, writable: !0, value }) : obj[key] = value, __spreadValues$l = (a, b) => {
2897
+ for (var prop in b || (b = {}))
2898
+ __hasOwnProp$l.call(b, prop) && __defNormalProp$l(a, prop, b[prop]);
2899
+ if (__getOwnPropSymbols$l)
2900
+ for (var prop of __getOwnPropSymbols$l(b))
2901
+ __propIsEnum$l.call(b, prop) && __defNormalProp$l(a, prop, b[prop]);
2902
+ return a;
2903
+ };
2815
2904
  const debug$j = debugWithName("plugin:withUndoRedo"), debugVerbose$4 = debug$j.enabled && !1, SAVING = /* @__PURE__ */ new WeakMap(), REMOTE_PATCHES = /* @__PURE__ */ new WeakMap(), UNDO_STEP_LIMIT = 1e3, isSaving = (editor) => {
2816
2905
  const state = SAVING.get(editor);
2817
2906
  return state === void 0 ? !0 : state;
@@ -2968,9 +3057,7 @@ function createWithUndoRedo(options) {
2968
3057
  }
2969
3058
  function transformOperation(editor, patch, operation, snapshot, previousSnapshot) {
2970
3059
  debugVerbose$4 && (debug$j(`Adjusting '${operation.type}' operation paths for '${patch.type}' patch`), debug$j(`Operation ${JSON.stringify(operation)}`), debug$j(`Patch ${JSON.stringify(patch)}`));
2971
- const transformedOperation = {
2972
- ...operation
2973
- };
3060
+ const transformedOperation = __spreadValues$l({}, operation);
2974
3061
  if (patch.type === "insert" && patch.path.length === 1) {
2975
3062
  const insertBlockIndex = (snapshot || []).findIndex((blk) => isEqual__default.default({
2976
3063
  _key: blk._key
@@ -2990,6 +3077,7 @@ function transformOperation(editor, patch, operation, snapshot, previousSnapshot
2990
3077
  return !operationTargetBlock || !isEqual__default.default({
2991
3078
  _key: operationTargetBlock._key
2992
3079
  }, patch.path[0]) ? [transformedOperation] : (parse(patch.value).forEach((diffPatch) => {
3080
+ var _a, _b, _c, _d;
2993
3081
  let adjustOffsetBy = 0, changedOffset = diffPatch.utf8Start1;
2994
3082
  const {
2995
3083
  diffs
@@ -2998,15 +3086,7 @@ function transformOperation(editor, patch, operation, snapshot, previousSnapshot
2998
3086
  const [diffType, text] = diff2;
2999
3087
  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));
3000
3088
  }), 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") {
3001
- const currentFocus = transformedOperation.properties?.focus ? {
3002
- ...transformedOperation.properties.focus
3003
- } : void 0, currentAnchor = transformedOperation?.properties?.anchor ? {
3004
- ...transformedOperation.properties.anchor
3005
- } : void 0, newFocus = transformedOperation?.newProperties?.focus ? {
3006
- ...transformedOperation.newProperties.focus
3007
- } : void 0, newAnchor = transformedOperation?.newProperties?.anchor ? {
3008
- ...transformedOperation.newProperties.anchor
3009
- } : void 0;
3089
+ const currentFocus = (_a = transformedOperation.properties) != null && _a.focus ? __spreadValues$l({}, transformedOperation.properties.focus) : void 0, currentAnchor = (_b = transformedOperation == null ? void 0 : transformedOperation.properties) != null && _b.anchor ? __spreadValues$l({}, transformedOperation.properties.anchor) : void 0, newFocus = (_c = transformedOperation == null ? void 0 : transformedOperation.newProperties) != null && _c.focus ? __spreadValues$l({}, transformedOperation.newProperties.focus) : void 0, newAnchor = (_d = transformedOperation == null ? void 0 : transformedOperation.newProperties) != null && _d.anchor ? __spreadValues$l({}, transformedOperation.newProperties.anchor) : void 0;
3010
3090
  (currentFocus && currentAnchor || newFocus && newAnchor) && ([currentFocus, currentAnchor, newFocus, newAnchor].forEach((point) => {
3011
3091
  point && changedOffset < point.offset && (point.offset += adjustOffsetBy);
3012
3092
  }), currentFocus && currentAnchor && (transformedOperation.properties = {
@@ -3022,23 +3102,14 @@ function transformOperation(editor, patch, operation, snapshot, previousSnapshot
3022
3102
  return [transformedOperation];
3023
3103
  }
3024
3104
  function adjustBlockPath(operation, level, blockIndex) {
3025
- const transformedOperation = {
3026
- ...operation
3027
- };
3105
+ var _a, _b, _c, _d;
3106
+ const transformedOperation = __spreadValues$l({}, operation);
3028
3107
  if (blockIndex >= 0 && transformedOperation.type !== "set_selection" && Array.isArray(transformedOperation.path) && transformedOperation.path[0] >= blockIndex + level && transformedOperation.path[0] + level > -1) {
3029
3108
  const newPath = [transformedOperation.path[0] + level, ...transformedOperation.path.slice(1)];
3030
3109
  transformedOperation.path = newPath;
3031
3110
  }
3032
3111
  if (transformedOperation.type === "set_selection") {
3033
- const currentFocus = transformedOperation.properties?.focus ? {
3034
- ...transformedOperation.properties.focus
3035
- } : void 0, currentAnchor = transformedOperation?.properties?.anchor ? {
3036
- ...transformedOperation.properties.anchor
3037
- } : void 0, newFocus = transformedOperation?.newProperties?.focus ? {
3038
- ...transformedOperation.newProperties.focus
3039
- } : void 0, newAnchor = transformedOperation?.newProperties?.anchor ? {
3040
- ...transformedOperation.newProperties.anchor
3041
- } : void 0;
3112
+ const currentFocus = (_a = transformedOperation.properties) != null && _a.focus ? __spreadValues$l({}, transformedOperation.properties.focus) : void 0, currentAnchor = (_b = transformedOperation == null ? void 0 : transformedOperation.properties) != null && _b.anchor ? __spreadValues$l({}, transformedOperation.properties.anchor) : void 0, newFocus = (_c = transformedOperation == null ? void 0 : transformedOperation.newProperties) != null && _c.focus ? __spreadValues$l({}, transformedOperation.newProperties.focus) : void 0, newAnchor = (_d = transformedOperation == null ? void 0 : transformedOperation.newProperties) != null && _d.anchor ? __spreadValues$l({}, transformedOperation.newProperties.anchor) : void 0;
3042
3113
  (currentFocus && currentAnchor || newFocus && newAnchor) && ([currentFocus, currentAnchor, newFocus, newAnchor].forEach((point) => {
3043
3114
  point && point.path[0] >= blockIndex + level && point.path[0] + level > -1 && (point.path = [point.path[0] + level, ...point.path.slice(1)]);
3044
3115
  }), currentFocus && currentAnchor && (transformedOperation.properties = {
@@ -3059,12 +3130,8 @@ function withoutSaving(editor, fn) {
3059
3130
  function createSelectOperation(editor) {
3060
3131
  return {
3061
3132
  type: "set_selection",
3062
- properties: {
3063
- ...editor.selection
3064
- },
3065
- newProperties: {
3066
- ...editor.selection
3067
- }
3133
+ properties: __spreadValues$l({}, editor.selection),
3134
+ newProperties: __spreadValues$l({}, editor.selection)
3068
3135
  };
3069
3136
  }
3070
3137
  function findOperationTargetBlock(editor, operation) {
@@ -3078,7 +3145,7 @@ function useSyncValue(props) {
3078
3145
  portableTextEditor,
3079
3146
  readOnly,
3080
3147
  slateEditor
3081
- } = props, schemaTypes = editorActor.getSnapshot().context.schema, previousValue = React.useRef(), updateValueFunctionRef = React.useRef(), updateFromCurrentValue = React.useCallback(() => {
3148
+ } = props, schemaTypes = editorActor.getSnapshot().context.schema, previousValue = React.useRef(void 0), updateValueFunctionRef = React.useRef(void 0), updateFromCurrentValue = React.useCallback(() => {
3082
3149
  const currentValue = CURRENT_VALUE.get(portableTextEditor);
3083
3150
  if (previousValue.current === currentValue) {
3084
3151
  debug$i("Value is the same object as previous, not need to sync");
@@ -3138,15 +3205,16 @@ function useSyncValue(props) {
3138
3205
  isChanged = !0;
3139
3206
  }
3140
3207
  slateValueFromProps.forEach((currentBlock, currentBlockIndex) => {
3208
+ var _a, _b, _c, _d, _e;
3141
3209
  const oldBlock = slateEditor.children[currentBlockIndex];
3142
3210
  if (oldBlock && !isEqual__default.default(currentBlock, oldBlock) && isValid) {
3143
3211
  const validationValue = [value[currentBlockIndex]], validation = validateValue(validationValue, schemaTypes, editorActor.getSnapshot().context.keyGenerator);
3144
- !validation.valid && validation.resolution?.autoResolve && validation.resolution?.patches.length > 0 && !readOnly && previousValue.current && previousValue.current !== value && (console.warn(`${validation.resolution.action} for block with _key '${validationValue[0]._key}'. ${validation.resolution?.description}`), validation.resolution.patches.forEach((patch) => {
3212
+ !validation.valid && (_a = validation.resolution) != null && _a.autoResolve && ((_b = validation.resolution) == null ? void 0 : _b.patches.length) > 0 && !readOnly && previousValue.current && previousValue.current !== value && (console.warn(`${validation.resolution.action} for block with _key '${validationValue[0]._key}'. ${(_c = validation.resolution) == null ? void 0 : _c.description}`), validation.resolution.patches.forEach((patch) => {
3145
3213
  editorActor.send({
3146
3214
  type: "patch",
3147
3215
  patch
3148
3216
  });
3149
- })), validation.valid || validation.resolution?.autoResolve ? (oldBlock._key === currentBlock._key ? (debug$i.enabled && debug$i("Updating block", oldBlock, currentBlock), _updateBlock(slateEditor, currentBlock, oldBlock, currentBlockIndex)) : (debug$i.enabled && debug$i("Replacing block", oldBlock, currentBlock), _replaceBlock(slateEditor, currentBlock, currentBlockIndex)), isChanged = !0) : (editorActor.send({
3217
+ })), validation.valid || (_d = validation.resolution) != null && _d.autoResolve ? (oldBlock._key === currentBlock._key ? (debug$i.enabled && debug$i("Updating block", oldBlock, currentBlock), _updateBlock(slateEditor, currentBlock, oldBlock, currentBlockIndex)) : (debug$i.enabled && debug$i("Replacing block", oldBlock, currentBlock), _replaceBlock(slateEditor, currentBlock, currentBlockIndex)), isChanged = !0) : (editorActor.send({
3150
3218
  type: "invalid value",
3151
3219
  resolution: validation.resolution,
3152
3220
  value
@@ -3154,7 +3222,7 @@ function useSyncValue(props) {
3154
3222
  }
3155
3223
  if (!oldBlock && isValid) {
3156
3224
  const validationValue_0 = [value[currentBlockIndex]], validation_0 = validateValue(validationValue_0, schemaTypes, editorActor.getSnapshot().context.keyGenerator);
3157
- debug$i.enabled && debug$i("Validating and inserting new block in the end of the value", currentBlock), validation_0.valid || validation_0.resolution?.autoResolve ? slate.Transforms.insertNodes(slateEditor, currentBlock, {
3225
+ debug$i.enabled && debug$i("Validating and inserting new block in the end of the value", currentBlock), validation_0.valid || (_e = validation_0.resolution) != null && _e.autoResolve ? slate.Transforms.insertNodes(slateEditor, currentBlock, {
3158
3226
  at: [currentBlockIndex]
3159
3227
  }) : (debug$i("Invalid", validation_0), editorActor.send({
3160
3228
  type: "invalid value",
@@ -3223,9 +3291,9 @@ function _updateBlock(slateEditor, currentBlock, oldBlock, currentBlockIndex) {
3223
3291
  at: [currentBlockIndex, childIndex]
3224
3292
  }));
3225
3293
  }), currentBlock.children.forEach((currentBlockChild, currentBlockChildIndex) => {
3226
- const oldBlockChild = oldBlock.children[currentBlockChildIndex], isChildChanged = !isEqual__default.default(currentBlockChild, oldBlockChild), isTextChanged = !isEqual__default.default(currentBlockChild.text, oldBlockChild?.text), path = [currentBlockIndex, currentBlockChildIndex];
3294
+ const oldBlockChild = oldBlock.children[currentBlockChildIndex], isChildChanged = !isEqual__default.default(currentBlockChild, oldBlockChild), isTextChanged = !isEqual__default.default(currentBlockChild.text, oldBlockChild == null ? void 0 : oldBlockChild.text), path = [currentBlockIndex, currentBlockChildIndex];
3227
3295
  if (isChildChanged)
3228
- if (currentBlockChild._key === oldBlockChild?._key) {
3296
+ if (currentBlockChild._key === (oldBlockChild == null ? void 0 : oldBlockChild._key)) {
3229
3297
  debug$i("Updating changed child", currentBlockChild, oldBlockChild), slate.Transforms.setNodes(slateEditor, currentBlockChild, {
3230
3298
  at: path
3231
3299
  });
@@ -3336,6 +3404,14 @@ function _temp(s) {
3336
3404
  return s.context.readOnly;
3337
3405
  }
3338
3406
  Synchronizer.displayName = "Synchronizer";
3407
+ var __defProp$k = Object.defineProperty, __defProps$f = Object.defineProperties, __getOwnPropDescs$f = Object.getOwnPropertyDescriptors, __getOwnPropSymbols$k = Object.getOwnPropertySymbols, __hasOwnProp$k = Object.prototype.hasOwnProperty, __propIsEnum$k = Object.prototype.propertyIsEnumerable, __defNormalProp$k = (obj, key, value) => key in obj ? __defProp$k(obj, key, { enumerable: !0, configurable: !0, writable: !0, value }) : obj[key] = value, __spreadValues$k = (a, b) => {
3408
+ for (var prop in b || (b = {}))
3409
+ __hasOwnProp$k.call(b, prop) && __defNormalProp$k(a, prop, b[prop]);
3410
+ if (__getOwnPropSymbols$k)
3411
+ for (var prop of __getOwnPropSymbols$k(b))
3412
+ __propIsEnum$k.call(b, prop) && __defNormalProp$k(a, prop, b[prop]);
3413
+ return a;
3414
+ }, __spreadProps$f = (a, b) => __defProps$f(a, __getOwnPropDescs$f(b));
3339
3415
  const debug$g = debugWithName("operationToPatches");
3340
3416
  function createOperationToPatches(types2) {
3341
3417
  const textBlockName = types2.block.name;
@@ -3375,10 +3451,7 @@ function createOperationToPatches(types2) {
3375
3451
  const block = editor.children[operation.path[0]];
3376
3452
  if (typeof block._key != "string")
3377
3453
  throw new Error("Expected block to have a _key");
3378
- const setNode = omitBy__default.default({
3379
- ...editor.children[operation.path[0]],
3380
- ...operation.newProperties
3381
- }, isUndefined__default.default);
3454
+ const setNode = omitBy__default.default(__spreadValues$k(__spreadValues$k({}, editor.children[operation.path[0]]), operation.newProperties), isUndefined__default.default);
3382
3455
  return [patches.set(fromSlateValue([setNode], textBlockName)[0], [{
3383
3456
  _key: block._key
3384
3457
  }])];
@@ -3413,14 +3486,12 @@ function createOperationToPatches(types2) {
3413
3486
  function insertNodePatch(editor, operation, beforeValue) {
3414
3487
  const block = beforeValue[operation.path[0]], isTextBlock = editor.isTextBlock(block);
3415
3488
  if (operation.path.length === 1) {
3416
- const position = operation.path[0] === 0 ? "before" : "after", beforeBlock = beforeValue[operation.path[0] - 1], targetKey = operation.path[0] === 0 ? block?._key : beforeBlock?._key;
3489
+ const position = operation.path[0] === 0 ? "before" : "after", beforeBlock = beforeValue[operation.path[0] - 1], targetKey = operation.path[0] === 0 ? block == null ? void 0 : block._key : beforeBlock == null ? void 0 : beforeBlock._key;
3417
3490
  return targetKey ? [patches.insert([fromSlateValue([operation.node], textBlockName)[0]], position, [{
3418
3491
  _key: targetKey
3419
3492
  }])] : [patches.setIfMissing(beforeValue, []), patches.insert([fromSlateValue([operation.node], textBlockName)[0]], "before", [operation.path[0]])];
3420
3493
  } else if (isTextBlock && operation.path.length === 2 && editor.children[operation.path[0]]) {
3421
- const position = block.children.length === 0 || !block.children[operation.path[1] - 1] ? "before" : "after", node = {
3422
- ...operation.node
3423
- };
3494
+ const position = block.children.length === 0 || !block.children[operation.path[1] - 1] ? "before" : "after", node = __spreadValues$k({}, operation.node);
3424
3495
  !node._type && slate.Text.isText(node) && (node._type = "span", node.marks = []);
3425
3496
  const child = fromSlateValue([{
3426
3497
  _key: "bogus",
@@ -3459,10 +3530,9 @@ function createOperationToPatches(types2) {
3459
3530
  if (operation.path.length === 2) {
3460
3531
  const splitSpan = splitBlock.children[operation.path[1]];
3461
3532
  if (editor.isTextSpan(splitSpan)) {
3462
- const targetSpans = fromSlateValue([{
3463
- ...splitBlock,
3533
+ const targetSpans = fromSlateValue([__spreadProps$f(__spreadValues$k({}, splitBlock), {
3464
3534
  children: splitBlock.children.slice(operation.path[1] + 1, operation.path[1] + 2)
3465
- }], textBlockName)[0].children;
3535
+ })], textBlockName)[0].children;
3466
3536
  patches$1.push(patches.insert(targetSpans, "after", [{
3467
3537
  _key: splitBlock._key
3468
3538
  }, "children", {
@@ -3498,7 +3568,7 @@ function createOperationToPatches(types2) {
3498
3568
  function mergeNodePatch(editor, operation, beforeValue) {
3499
3569
  const patches$1 = [], block = beforeValue[operation.path[0]], updatedBlock = editor.children[operation.path[0]];
3500
3570
  if (operation.path.length === 1)
3501
- if (block?._key) {
3571
+ if (block != null && block._key) {
3502
3572
  const newBlock = fromSlateValue([editor.children[operation.path[0] - 1]], textBlockName)[0];
3503
3573
  patches$1.push(patches.set(newBlock, [{
3504
3574
  _key: newBlock._key
@@ -3770,6 +3840,7 @@ function createWithMaxBlocks(editorActor) {
3770
3840
  apply: apply2
3771
3841
  } = editor;
3772
3842
  return editor.apply = (operation) => {
3843
+ var _a;
3773
3844
  if (editorActor.getSnapshot().context.readOnly) {
3774
3845
  apply2(operation);
3775
3846
  return;
@@ -3782,11 +3853,19 @@ function createWithMaxBlocks(editorActor) {
3782
3853
  apply2(operation);
3783
3854
  return;
3784
3855
  }
3785
- const rows = editorActor.getSnapshot().context.maxBlocks ?? -1;
3856
+ const rows = (_a = editorActor.getSnapshot().context.maxBlocks) != null ? _a : -1;
3786
3857
  rows > 0 && editor.children.length >= rows && (operation.type === "insert_node" || operation.type === "split_node") && operation.path.length === 1 || apply2(operation);
3787
3858
  }, editor;
3788
3859
  };
3789
3860
  }
3861
+ var __defProp$j = Object.defineProperty, __defProps$e = Object.defineProperties, __getOwnPropDescs$e = Object.getOwnPropertyDescriptors, __getOwnPropSymbols$j = Object.getOwnPropertySymbols, __hasOwnProp$j = Object.prototype.hasOwnProperty, __propIsEnum$j = Object.prototype.propertyIsEnumerable, __defNormalProp$j = (obj, key, value) => key in obj ? __defProp$j(obj, key, { enumerable: !0, configurable: !0, writable: !0, value }) : obj[key] = value, __spreadValues$j = (a, b) => {
3862
+ for (var prop in b || (b = {}))
3863
+ __hasOwnProp$j.call(b, prop) && __defNormalProp$j(a, prop, b[prop]);
3864
+ if (__getOwnPropSymbols$j)
3865
+ for (var prop of __getOwnPropSymbols$j(b))
3866
+ __propIsEnum$j.call(b, prop) && __defNormalProp$j(a, prop, b[prop]);
3867
+ return a;
3868
+ }, __spreadProps$e = (a, b) => __defProps$e(a, __getOwnPropDescs$e(b));
3790
3869
  function createWithObjectKeys(editorActor, schemaTypes) {
3791
3870
  return function(editor) {
3792
3871
  const {
@@ -3803,23 +3882,19 @@ function createWithObjectKeys(editorActor, schemaTypes) {
3803
3882
  return;
3804
3883
  }
3805
3884
  if (operation.type === "split_node") {
3806
- apply2({
3807
- ...operation,
3808
- properties: {
3809
- ...operation.properties,
3885
+ apply2(__spreadProps$e(__spreadValues$j({}, operation), {
3886
+ properties: __spreadProps$e(__spreadValues$j({}, operation.properties), {
3810
3887
  _key: editorActor.getSnapshot().context.keyGenerator()
3811
- }
3812
- });
3888
+ })
3889
+ }));
3813
3890
  return;
3814
3891
  }
3815
3892
  if (operation.type === "insert_node" && !slate.Editor.isEditor(operation.node)) {
3816
- apply2({
3817
- ...operation,
3818
- node: {
3819
- ...operation.node,
3893
+ apply2(__spreadProps$e(__spreadValues$j({}, operation), {
3894
+ node: __spreadProps$e(__spreadValues$j({}, operation.node), {
3820
3895
  _key: editorActor.getSnapshot().context.keyGenerator()
3821
- }
3822
- });
3896
+ })
3897
+ }));
3823
3898
  return;
3824
3899
  }
3825
3900
  apply2(operation);
@@ -3856,6 +3931,22 @@ function createWithObjectKeys(editorActor, schemaTypes) {
3856
3931
  }, editor;
3857
3932
  };
3858
3933
  }
3934
+ var __defProp$i = Object.defineProperty, __defProps$d = Object.defineProperties, __getOwnPropDescs$d = Object.getOwnPropertyDescriptors, __getOwnPropSymbols$i = Object.getOwnPropertySymbols, __hasOwnProp$i = Object.prototype.hasOwnProperty, __propIsEnum$i = Object.prototype.propertyIsEnumerable, __defNormalProp$i = (obj, key, value) => key in obj ? __defProp$i(obj, key, { enumerable: !0, configurable: !0, writable: !0, value }) : obj[key] = value, __spreadValues$i = (a, b) => {
3935
+ for (var prop in b || (b = {}))
3936
+ __hasOwnProp$i.call(b, prop) && __defNormalProp$i(a, prop, b[prop]);
3937
+ if (__getOwnPropSymbols$i)
3938
+ for (var prop of __getOwnPropSymbols$i(b))
3939
+ __propIsEnum$i.call(b, prop) && __defNormalProp$i(a, prop, b[prop]);
3940
+ return a;
3941
+ }, __spreadProps$d = (a, b) => __defProps$d(a, __getOwnPropDescs$d(b)), __objRest$2 = (source, exclude) => {
3942
+ var target = {};
3943
+ for (var prop in source)
3944
+ __hasOwnProp$i.call(source, prop) && exclude.indexOf(prop) < 0 && (target[prop] = source[prop]);
3945
+ if (source != null && __getOwnPropSymbols$i)
3946
+ for (var prop of __getOwnPropSymbols$i(source))
3947
+ exclude.indexOf(prop) < 0 && __propIsEnum$i.call(source, prop) && (target[prop] = source[prop]);
3948
+ return target;
3949
+ };
3859
3950
  const debug$f = debugWithName("applyPatches"), debugVerbose$2 = debug$f.enabled && !0;
3860
3951
  function createApplyPatch(schemaTypes) {
3861
3952
  return (editor, patch) => {
@@ -3945,10 +4036,9 @@ function insertPatch(editor, patch, schemaTypes) {
3945
4036
  } = patch;
3946
4037
  if (!targetChild || !targetChildPath)
3947
4038
  return debug$f("Child not found"), !1;
3948
- const childrenToInsert = targetBlock && toSlateValue([{
3949
- ...targetBlock,
4039
+ const childrenToInsert = targetBlock && toSlateValue([__spreadProps$d(__spreadValues$i({}, targetBlock), {
3950
4040
  children: items
3951
- }], {
4041
+ })], {
3952
4042
  schemaTypes
3953
4043
  }, KEY_TO_SLATE_ELEMENT.get(editor)), targetChildIndex = targetChildPath[1], normalizedIdx = position === "after" ? targetChildIndex + 1 : targetChildIndex, childInsertPath = [targetChildPath[0], normalizedIdx];
3954
4044
  return debug$f(`Inserting children at path ${childInsertPath}`), debugState(editor, "before"), childrenToInsert && slate.Element.isElement(childrenToInsert[0]) && slate.Transforms.insertNodes(editor, childrenToInsert[0].children, {
@@ -3993,21 +4083,19 @@ function setPatch(editor, patch) {
3993
4083
  return !0;
3994
4084
  } else if (slate.Element.isElement(block) && patch.path.length === 1 && blockPath) {
3995
4085
  debug$f("Setting block property");
3996
- const {
3997
- children,
3998
- ...nextRest
3999
- } = value, {
4000
- children: prevChildren,
4001
- ...prevRest
4002
- } = block || {
4086
+ const _a = value, {
4087
+ children
4088
+ } = _a, nextRest = __objRest$2(_a, [
4089
+ "children"
4090
+ ]), _b = block || {
4003
4091
  children: void 0
4004
- };
4092
+ }, prevRest = __objRest$2(_b, [
4093
+ "children"
4094
+ ]);
4005
4095
  editor.apply({
4006
4096
  type: "set_node",
4007
4097
  path: blockPath,
4008
- properties: {
4009
- ...prevRest
4010
- },
4098
+ properties: __spreadValues$i({}, prevRest),
4011
4099
  newProperties: nextRest
4012
4100
  }), debug$f("Setting children"), block.children.forEach((c, cIndex) => {
4013
4101
  editor.apply({
@@ -4024,10 +4112,9 @@ function setPatch(editor, patch) {
4024
4112
  });
4025
4113
  } else if (block && "value" in block) {
4026
4114
  const newVal = patches.applyAll([block.value], [patch])[0];
4027
- return slate.Transforms.setNodes(editor, {
4028
- ...block,
4115
+ return slate.Transforms.setNodes(editor, __spreadProps$d(__spreadValues$i({}, block), {
4029
4116
  value: newVal
4030
- }, {
4117
+ }), {
4031
4118
  at: blockPath
4032
4119
  }), !0;
4033
4120
  }
@@ -4110,7 +4197,7 @@ function findBlockAndChildFromPath(editor, path) {
4110
4197
  block,
4111
4198
  child,
4112
4199
  blockPath,
4113
- childPath: blockPath?.concat(childIndex)
4200
+ childPath: blockPath == null ? void 0 : blockPath.concat(childIndex)
4114
4201
  } : {
4115
4202
  block,
4116
4203
  blockPath,
@@ -4118,6 +4205,14 @@ function findBlockAndChildFromPath(editor, path) {
4118
4205
  childPath: void 0
4119
4206
  };
4120
4207
  }
4208
+ var __defProp$h = Object.defineProperty, __defProps$c = Object.defineProperties, __getOwnPropDescs$c = Object.getOwnPropertyDescriptors, __getOwnPropSymbols$h = Object.getOwnPropertySymbols, __hasOwnProp$h = Object.prototype.hasOwnProperty, __propIsEnum$h = Object.prototype.propertyIsEnumerable, __defNormalProp$h = (obj, key, value) => key in obj ? __defProp$h(obj, key, { enumerable: !0, configurable: !0, writable: !0, value }) : obj[key] = value, __spreadValues$h = (a, b) => {
4209
+ for (var prop in b || (b = {}))
4210
+ __hasOwnProp$h.call(b, prop) && __defNormalProp$h(a, prop, b[prop]);
4211
+ if (__getOwnPropSymbols$h)
4212
+ for (var prop of __getOwnPropSymbols$h(b))
4213
+ __propIsEnum$h.call(b, prop) && __defNormalProp$h(a, prop, b[prop]);
4214
+ return a;
4215
+ }, __spreadProps$c = (a, b) => __defProps$c(a, __getOwnPropDescs$c(b));
4121
4216
  const debug$e = debugWithName("plugin:withPatches");
4122
4217
  function createWithPatches({
4123
4218
  editorActor,
@@ -4204,10 +4299,9 @@ function createWithPatches({
4204
4299
  })), editorWasEmpty && patches$1.length > 0 && (patches$1 = [patches.setIfMissing([], []), ...patches$1]), patches$1.length > 0 && patches$1.forEach((patch) => {
4205
4300
  editorActor.send({
4206
4301
  type: "patch",
4207
- patch: {
4208
- ...patch,
4302
+ patch: __spreadProps$c(__spreadValues$h({}, patch), {
4209
4303
  origin: "local"
4210
- }
4304
+ })
4211
4305
  });
4212
4306
  }), editor;
4213
4307
  }, editor;
@@ -4318,6 +4412,14 @@ function getNextSpan({
4318
4412
  }
4319
4413
  return nextSpan;
4320
4414
  }
4415
+ var __defProp$g = Object.defineProperty, __defProps$b = Object.defineProperties, __getOwnPropDescs$b = Object.getOwnPropertyDescriptors, __getOwnPropSymbols$g = Object.getOwnPropertySymbols, __hasOwnProp$g = Object.prototype.hasOwnProperty, __propIsEnum$g = Object.prototype.propertyIsEnumerable, __defNormalProp$g = (obj, key, value) => key in obj ? __defProp$g(obj, key, { enumerable: !0, configurable: !0, writable: !0, value }) : obj[key] = value, __spreadValues$g = (a, b) => {
4416
+ for (var prop in b || (b = {}))
4417
+ __hasOwnProp$g.call(b, prop) && __defNormalProp$g(a, prop, b[prop]);
4418
+ if (__getOwnPropSymbols$g)
4419
+ for (var prop of __getOwnPropSymbols$g(b))
4420
+ __propIsEnum$g.call(b, prop) && __defNormalProp$g(a, prop, b[prop]);
4421
+ return a;
4422
+ }, __spreadProps$b = (a, b) => __defProps$b(a, __getOwnPropDescs$b(b));
4321
4423
  const debug$b = debugWithName("plugin:withPortableTextMarkModel");
4322
4424
  function createWithPortableTextMarkModel(editorActor, types2) {
4323
4425
  return function(editor) {
@@ -4326,12 +4428,19 @@ function createWithPortableTextMarkModel(editorActor, types2) {
4326
4428
  normalizeNode
4327
4429
  } = editor, decorators = types2.decorators.map((t) => t.value);
4328
4430
  return editor.normalizeNode = (nodeEntry) => {
4431
+ var _a, _b, _c, _d, _e, _f, _g;
4329
4432
  const [node, path] = nodeEntry;
4330
4433
  if (editor.isTextBlock(node)) {
4331
4434
  const children = slate.Node.children(editor, path);
4332
4435
  for (const [child, childPath] of children) {
4333
4436
  const nextNode = node.children[childPath[1] + 1];
4334
- if (editor.isTextSpan(child) && editor.isTextSpan(nextNode) && child.marks?.every((mark) => nextNode.marks?.includes(mark)) && nextNode.marks?.every((mark) => child.marks?.includes(mark))) {
4437
+ if (editor.isTextSpan(child) && editor.isTextSpan(nextNode) && (_a = child.marks) != null && _a.every((mark) => {
4438
+ var _a2;
4439
+ return (_a2 = nextNode.marks) == null ? void 0 : _a2.includes(mark);
4440
+ }) && (_b = nextNode.marks) != null && _b.every((mark) => {
4441
+ var _a2;
4442
+ return (_a2 = child.marks) == null ? void 0 : _a2.includes(mark);
4443
+ })) {
4335
4444
  debug$b("Merging spans", JSON.stringify(child, null, 2), JSON.stringify(nextNode, null, 2)), editorActor.send({
4336
4445
  type: "normalizing"
4337
4446
  }), slate.Transforms.mergeNodes(editor, {
@@ -4369,12 +4478,12 @@ function createWithPortableTextMarkModel(editorActor, types2) {
4369
4478
  return;
4370
4479
  }
4371
4480
  if (editor.isTextSpan(node)) {
4372
- const blockPath = slate.Path.parent(path), [block] = slate.Editor.node(editor, blockPath), decorators2 = types2.decorators.map((decorator) => decorator.value), annotations = node.marks?.filter((mark) => !decorators2.includes(mark));
4481
+ const blockPath = slate.Path.parent(path), [block] = slate.Editor.node(editor, blockPath), decorators2 = types2.decorators.map((decorator) => decorator.value), annotations = (_c = node.marks) == null ? void 0 : _c.filter((mark) => !decorators2.includes(mark));
4373
4482
  if (editor.isTextBlock(block) && node.text === "" && annotations && annotations.length > 0) {
4374
4483
  debug$b("Removing annotations from empty span node"), editorActor.send({
4375
4484
  type: "normalizing"
4376
4485
  }), slate.Transforms.setNodes(editor, {
4377
- marks: node.marks?.filter((mark) => decorators2.includes(mark))
4486
+ marks: (_d = node.marks) == null ? void 0 : _d.filter((mark) => decorators2.includes(mark))
4378
4487
  }, {
4379
4488
  at: path
4380
4489
  }), editorActor.send({
@@ -4387,7 +4496,10 @@ function createWithPortableTextMarkModel(editorActor, types2) {
4387
4496
  const decorators2 = types2.decorators.map((decorator) => decorator.value);
4388
4497
  for (const [child, childPath] of slate.Node.children(editor, path))
4389
4498
  if (editor.isTextSpan(child)) {
4390
- const marks = child.marks ?? [], orphanedAnnotations = marks.filter((mark) => !decorators2.includes(mark) && !node.markDefs?.find((def) => def._key === mark));
4499
+ const marks = (_e = child.marks) != null ? _e : [], orphanedAnnotations = marks.filter((mark) => {
4500
+ var _a2;
4501
+ return !decorators2.includes(mark) && !((_a2 = node.markDefs) != null && _a2.find((def) => def._key === mark));
4502
+ });
4391
4503
  if (orphanedAnnotations.length > 0) {
4392
4504
  debug$b("Removing orphaned annotations from span node"), editorActor.send({
4393
4505
  type: "normalizing"
@@ -4405,7 +4517,10 @@ function createWithPortableTextMarkModel(editorActor, types2) {
4405
4517
  if (editor.isTextSpan(node)) {
4406
4518
  const blockPath = slate.Path.parent(path), [block] = slate.Editor.node(editor, blockPath);
4407
4519
  if (editor.isTextBlock(block)) {
4408
- const decorators2 = types2.decorators.map((decorator) => decorator.value), marks = node.marks ?? [], orphanedAnnotations = marks.filter((mark) => !decorators2.includes(mark) && !block.markDefs?.find((def) => def._key === mark));
4520
+ const decorators2 = types2.decorators.map((decorator) => decorator.value), marks = (_f = node.marks) != null ? _f : [], orphanedAnnotations = marks.filter((mark) => {
4521
+ var _a2;
4522
+ return !decorators2.includes(mark) && !((_a2 = block.markDefs) != null && _a2.find((def) => def._key === mark));
4523
+ });
4409
4524
  if (orphanedAnnotations.length > 0) {
4410
4525
  debug$b("Removing orphaned annotations from span node"), editorActor.send({
4411
4526
  type: "normalizing"
@@ -4421,7 +4536,7 @@ function createWithPortableTextMarkModel(editorActor, types2) {
4421
4536
  }
4422
4537
  }
4423
4538
  if (editor.isTextBlock(node)) {
4424
- const markDefs = node.markDefs ?? [], markDefKeys = /* @__PURE__ */ new Set(), newMarkDefs = [];
4539
+ const markDefs = (_g = node.markDefs) != null ? _g : [], markDefKeys = /* @__PURE__ */ new Set(), newMarkDefs = [];
4425
4540
  for (const markDef of markDefs)
4426
4541
  markDefKeys.has(markDef._key) || (markDefKeys.add(markDef._key), newMarkDefs.push(markDef));
4427
4542
  if (markDefs.length !== newMarkDefs.length) {
@@ -4454,6 +4569,7 @@ function createWithPortableTextMarkModel(editorActor, types2) {
4454
4569
  }
4455
4570
  normalizeNode(nodeEntry);
4456
4571
  }, editor.apply = (op) => {
4572
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F;
4457
4573
  if (isChangingRemotely(editor)) {
4458
4574
  apply2(op);
4459
4575
  return;
@@ -4471,17 +4587,17 @@ function createWithPortableTextMarkModel(editorActor, types2) {
4471
4587
  focus: op.newProperties.focus
4472
4588
  });
4473
4589
  if (previousSelectionIsCollapsed && newSelectionIsCollapsed) {
4474
- const focusSpan = Array.from(slate.Editor.nodes(editor, {
4590
+ const focusSpan = (_a = Array.from(slate.Editor.nodes(editor, {
4475
4591
  mode: "lowest",
4476
4592
  at: op.properties.focus,
4477
4593
  match: (n) => editor.isTextSpan(n),
4478
4594
  voids: !1
4479
- }))[0]?.[0], newFocusSpan = Array.from(slate.Editor.nodes(editor, {
4595
+ }))[0]) == null ? void 0 : _a[0], newFocusSpan = (_b = Array.from(slate.Editor.nodes(editor, {
4480
4596
  mode: "lowest",
4481
4597
  at: op.newProperties.focus,
4482
4598
  match: (n) => editor.isTextSpan(n),
4483
4599
  voids: !1
4484
- }))[0]?.[0], movedToNextSpan = focusSpan && newFocusSpan && op.newProperties.focus.path[0] === op.properties.focus.path[0] && op.newProperties.focus.path[1] === op.properties.focus.path[1] + 1 && focusSpan.text.length === op.properties.focus.offset && op.newProperties.focus.offset === 0, movedToPreviousSpan = focusSpan && newFocusSpan && op.newProperties.focus.path[0] === op.properties.focus.path[0] && op.newProperties.focus.path[1] === op.properties.focus.path[1] - 1 && op.properties.focus.offset === 0 && newFocusSpan.text.length === op.newProperties.focus.offset;
4600
+ }))[0]) == null ? void 0 : _b[0], movedToNextSpan = focusSpan && newFocusSpan && op.newProperties.focus.path[0] === op.properties.focus.path[0] && op.newProperties.focus.path[1] === op.properties.focus.path[1] + 1 && focusSpan.text.length === op.properties.focus.offset && op.newProperties.focus.offset === 0, movedToPreviousSpan = focusSpan && newFocusSpan && op.newProperties.focus.path[0] === op.properties.focus.path[0] && op.newProperties.focus.path[1] === op.properties.focus.path[1] - 1 && op.properties.focus.offset === 0 && newFocusSpan.text.length === op.newProperties.focus.offset;
4485
4601
  if (movedToNextSpan || movedToPreviousSpan)
4486
4602
  return;
4487
4603
  }
@@ -4497,32 +4613,29 @@ function createWithPortableTextMarkModel(editorActor, types2) {
4497
4613
  editor,
4498
4614
  blockPath,
4499
4615
  spanPath: op.path
4500
- }), previousSpanAnnotations = previousSpan ? previousSpan.marks?.filter((mark) => !decorators.includes(mark)) : [], nextSpan = getNextSpan({
4616
+ }), previousSpanAnnotations = previousSpan ? (_c = previousSpan.marks) == null ? void 0 : _c.filter((mark) => !decorators.includes(mark)) : [], nextSpan = getNextSpan({
4501
4617
  editor,
4502
4618
  blockPath,
4503
4619
  spanPath: [op.path[0], op.path[1] - 1]
4504
- }), nextSpanAnnotations = nextSpan ? nextSpan.marks?.filter((mark) => !decorators.includes(mark)) : [], annotationsEnding = previousSpanAnnotations?.filter((annotation) => !nextSpanAnnotations?.includes(annotation)) ?? [], atTheEndOfAnnotation = annotationsEnding.length > 0;
4505
- if (atTheEndOfAnnotation && isPortableTextSpan(op.node) && op.node.marks?.some((mark) => annotationsEnding.includes(mark))) {
4506
- slate.Transforms.insertNodes(editor, {
4507
- ...op.node,
4508
- marks: op.node.marks?.filter((mark) => !annotationsEnding.includes(mark)) ?? []
4509
- });
4620
+ }), nextSpanAnnotations = nextSpan ? (_d = nextSpan.marks) == null ? void 0 : _d.filter((mark) => !decorators.includes(mark)) : [], annotationsEnding = (_e = previousSpanAnnotations == null ? void 0 : previousSpanAnnotations.filter((annotation) => !(nextSpanAnnotations != null && nextSpanAnnotations.includes(annotation)))) != null ? _e : [], atTheEndOfAnnotation = annotationsEnding.length > 0;
4621
+ if (atTheEndOfAnnotation && isPortableTextSpan(op.node) && (_f = op.node.marks) != null && _f.some((mark) => annotationsEnding.includes(mark))) {
4622
+ slate.Transforms.insertNodes(editor, __spreadProps$b(__spreadValues$g({}, op.node), {
4623
+ marks: (_h = (_g = op.node.marks) == null ? void 0 : _g.filter((mark) => !annotationsEnding.includes(mark))) != null ? _h : []
4624
+ }));
4510
4625
  return;
4511
4626
  }
4512
- const annotationsStarting = nextSpanAnnotations?.filter((annotation) => !previousSpanAnnotations?.includes(annotation)) ?? [], atTheStartOfAnnotation = annotationsStarting.length > 0;
4513
- if (atTheStartOfAnnotation && isPortableTextSpan(op.node) && op.node.marks?.some((mark) => annotationsStarting.includes(mark))) {
4514
- slate.Transforms.insertNodes(editor, {
4515
- ...op.node,
4516
- marks: op.node.marks?.filter((mark) => !annotationsStarting.includes(mark)) ?? []
4517
- });
4627
+ const annotationsStarting = (_i = nextSpanAnnotations == null ? void 0 : nextSpanAnnotations.filter((annotation) => !(previousSpanAnnotations != null && previousSpanAnnotations.includes(annotation)))) != null ? _i : [], atTheStartOfAnnotation = annotationsStarting.length > 0;
4628
+ if (atTheStartOfAnnotation && isPortableTextSpan(op.node) && (_j = op.node.marks) != null && _j.some((mark) => annotationsStarting.includes(mark))) {
4629
+ slate.Transforms.insertNodes(editor, __spreadProps$b(__spreadValues$g({}, op.node), {
4630
+ marks: (_l = (_k = op.node.marks) == null ? void 0 : _k.filter((mark) => !annotationsStarting.includes(mark))) != null ? _l : []
4631
+ }));
4518
4632
  return;
4519
4633
  }
4520
- const nextSpanDecorators = nextSpan?.marks?.filter((mark) => decorators.includes(mark)) ?? [];
4521
- if (nextSpanDecorators.length > 0 && atTheEndOfAnnotation && !atTheStartOfAnnotation && isPortableTextSpan(op.node) && op.node.marks?.length === 0) {
4522
- slate.Transforms.insertNodes(editor, {
4523
- ...op.node,
4634
+ const nextSpanDecorators = (_n = (_m = nextSpan == null ? void 0 : nextSpan.marks) == null ? void 0 : _m.filter((mark) => decorators.includes(mark))) != null ? _n : [];
4635
+ if (nextSpanDecorators.length > 0 && atTheEndOfAnnotation && !atTheStartOfAnnotation && isPortableTextSpan(op.node) && ((_o = op.node.marks) == null ? void 0 : _o.length) === 0) {
4636
+ slate.Transforms.insertNodes(editor, __spreadProps$b(__spreadValues$g({}, op.node), {
4524
4637
  marks: nextSpanDecorators
4525
- });
4638
+ }));
4526
4639
  return;
4527
4640
  }
4528
4641
  }
@@ -4534,12 +4647,12 @@ function createWithPortableTextMarkModel(editorActor, types2) {
4534
4647
  if (selection && collapsedSelection) {
4535
4648
  const [_block, blockPath] = slate.Editor.node(editor, selection, {
4536
4649
  depth: 1
4537
- }), [span, spanPath] = Array.from(slate.Editor.nodes(editor, {
4650
+ }), [span, spanPath] = (_p = Array.from(slate.Editor.nodes(editor, {
4538
4651
  mode: "lowest",
4539
4652
  at: selection.focus,
4540
4653
  match: (n) => editor.isTextSpan(n),
4541
4654
  voids: !1
4542
- }))[0] ?? [void 0, void 0], marks = span.marks ?? [], marksWithoutAnnotations = marks.filter((mark) => decorators.includes(mark)), spanHasAnnotations = marks.length > marksWithoutAnnotations.length, spanIsEmpty = span.text.length === 0, atTheBeginningOfSpan = selection.anchor.offset === 0, atTheEndOfSpan = selection.anchor.offset === span.text.length, previousSpan = getPreviousSpan({
4655
+ }))[0]) != null ? _p : [void 0, void 0], marks = (_q = span.marks) != null ? _q : [], marksWithoutAnnotations = marks.filter((mark) => decorators.includes(mark)), spanHasAnnotations = marks.length > marksWithoutAnnotations.length, spanIsEmpty = span.text.length === 0, atTheBeginningOfSpan = selection.anchor.offset === 0, atTheEndOfSpan = selection.anchor.offset === span.text.length, previousSpan = getPreviousSpan({
4543
4656
  editor,
4544
4657
  blockPath,
4545
4658
  spanPath
@@ -4547,7 +4660,7 @@ function createWithPortableTextMarkModel(editorActor, types2) {
4547
4660
  editor,
4548
4661
  blockPath,
4549
4662
  spanPath
4550
- }), nextSpanAnnotations = nextSpan?.marks?.filter((mark) => !decorators.includes(mark)) ?? [], spanAnnotations = marks.filter((mark) => !decorators.includes(mark)), previousSpanHasAnnotations = previousSpan ? previousSpan.marks?.some((mark) => !decorators.includes(mark)) : !1, previousSpanHasSameAnnotations = previousSpan ? previousSpan.marks?.filter((mark) => !decorators.includes(mark)).every((mark) => marks.includes(mark)) : !1, previousSpanHasSameAnnotation = previousSpan ? previousSpan.marks?.some((mark) => !decorators.includes(mark) && marks.includes(mark)) : !1, previousSpanHasSameMarks = previousSpan ? previousSpan.marks?.every((mark) => marks.includes(mark)) : !1, nextSpanSharesSomeAnnotations = spanAnnotations.some((mark) => nextSpanAnnotations?.includes(mark));
4663
+ }), nextSpanAnnotations = (_s = (_r = nextSpan == null ? void 0 : nextSpan.marks) == null ? void 0 : _r.filter((mark) => !decorators.includes(mark))) != null ? _s : [], spanAnnotations = marks.filter((mark) => !decorators.includes(mark)), previousSpanHasAnnotations = previousSpan ? (_t = previousSpan.marks) == null ? void 0 : _t.some((mark) => !decorators.includes(mark)) : !1, previousSpanHasSameAnnotations = previousSpan ? (_u = previousSpan.marks) == null ? void 0 : _u.filter((mark) => !decorators.includes(mark)).every((mark) => marks.includes(mark)) : !1, previousSpanHasSameAnnotation = previousSpan ? (_v = previousSpan.marks) == null ? void 0 : _v.some((mark) => !decorators.includes(mark) && marks.includes(mark)) : !1, previousSpanHasSameMarks = previousSpan ? (_w = previousSpan.marks) == null ? void 0 : _w.every((mark) => marks.includes(mark)) : !1, nextSpanSharesSomeAnnotations = spanAnnotations.some((mark) => nextSpanAnnotations == null ? void 0 : nextSpanAnnotations.includes(mark));
4551
4664
  if (spanHasAnnotations && !spanIsEmpty) {
4552
4665
  if (atTheBeginningOfSpan) {
4553
4666
  if (previousSpanHasSameMarks) {
@@ -4555,7 +4668,7 @@ function createWithPortableTextMarkModel(editorActor, types2) {
4555
4668
  _type: "span",
4556
4669
  _key: editorActor.getSnapshot().context.keyGenerator(),
4557
4670
  text: op.text,
4558
- marks: previousSpan?.marks ?? []
4671
+ marks: (_x = previousSpan == null ? void 0 : previousSpan.marks) != null ? _x : []
4559
4672
  });
4560
4673
  return;
4561
4674
  } else if (previousSpanHasSameAnnotations) {
@@ -4563,7 +4676,7 @@ function createWithPortableTextMarkModel(editorActor, types2) {
4563
4676
  _type: "span",
4564
4677
  _key: editorActor.getSnapshot().context.keyGenerator(),
4565
4678
  text: op.text,
4566
- marks: previousSpan?.marks ?? []
4679
+ marks: (_y = previousSpan == null ? void 0 : previousSpan.marks) != null ? _y : []
4567
4680
  });
4568
4681
  return;
4569
4682
  } else if (previousSpanHasSameAnnotation) {
@@ -4585,7 +4698,7 @@ function createWithPortableTextMarkModel(editorActor, types2) {
4585
4698
  _type: "span",
4586
4699
  _key: editorActor.getSnapshot().context.keyGenerator(),
4587
4700
  text: op.text,
4588
- marks: nextSpan?.marks ?? []
4701
+ marks: (_z = nextSpan == null ? void 0 : nextSpan.marks) != null ? _z : []
4589
4702
  });
4590
4703
  return;
4591
4704
  }
@@ -4605,7 +4718,7 @@ function createWithPortableTextMarkModel(editorActor, types2) {
4605
4718
  _type: "span",
4606
4719
  _key: editorActor.getSnapshot().context.keyGenerator(),
4607
4720
  text: op.text,
4608
- marks: previousSpanHasAnnotations ? [] : (previousSpan.marks ?? []).filter((mark) => decorators.includes(mark))
4721
+ marks: previousSpanHasAnnotations ? [] : ((_A = previousSpan.marks) != null ? _A : []).filter((mark) => decorators.includes(mark))
4609
4722
  });
4610
4723
  return;
4611
4724
  }
@@ -4618,7 +4731,7 @@ function createWithPortableTextMarkModel(editorActor, types2) {
4618
4731
  if (selection && slate.Range.isExpanded(selection)) {
4619
4732
  const [block, blockPath] = slate.Editor.node(editor, selection, {
4620
4733
  depth: 1
4621
- }), [span, spanPath] = Array.from(slate.Editor.nodes(editor, {
4734
+ }), [span, spanPath] = (_B = Array.from(slate.Editor.nodes(editor, {
4622
4735
  mode: "lowest",
4623
4736
  at: {
4624
4737
  path: op.path,
@@ -4626,9 +4739,9 @@ function createWithPortableTextMarkModel(editorActor, types2) {
4626
4739
  },
4627
4740
  match: (n) => editor.isTextSpan(n),
4628
4741
  voids: !1
4629
- }))[0] ?? [void 0, void 0];
4742
+ }))[0]) != null ? _B : [void 0, void 0];
4630
4743
  if (span && block && isPortableTextBlock(block)) {
4631
- const markDefs = block.markDefs ?? [], marks = span.marks ?? [], spanHasAnnotations = marks.some((mark) => markDefs.find((markDef) => markDef._key === mark)), deletingFromTheEnd = op.offset + op.text.length === span.text.length, deletingAllText = op.offset === 0 && deletingFromTheEnd, previousSpan = getPreviousSpan({
4744
+ const markDefs = (_C = block.markDefs) != null ? _C : [], marks = (_D = span.marks) != null ? _D : [], spanHasAnnotations = marks.some((mark) => markDefs.find((markDef) => markDef._key === mark)), deletingFromTheEnd = op.offset + op.text.length === span.text.length, deletingAllText = op.offset === 0 && deletingFromTheEnd, previousSpan = getPreviousSpan({
4632
4745
  editor,
4633
4746
  blockPath,
4634
4747
  spanPath
@@ -4636,11 +4749,9 @@ function createWithPortableTextMarkModel(editorActor, types2) {
4636
4749
  editor,
4637
4750
  blockPath,
4638
4751
  spanPath
4639
- }), previousSpanHasSameAnnotation = previousSpan ? previousSpan.marks?.some((mark) => !decorators.includes(mark) && marks.includes(mark)) : !1, nextSpanHasSameAnnotation = nextSpan ? nextSpan.marks?.some((mark) => !decorators.includes(mark) && marks.includes(mark)) : !1;
4752
+ }), previousSpanHasSameAnnotation = previousSpan ? (_E = previousSpan.marks) == null ? void 0 : _E.some((mark) => !decorators.includes(mark) && marks.includes(mark)) : !1, nextSpanHasSameAnnotation = nextSpan ? (_F = nextSpan.marks) == null ? void 0 : _F.some((mark) => !decorators.includes(mark) && marks.includes(mark)) : !1;
4640
4753
  if (spanHasAnnotations && deletingAllText && !previousSpanHasSameAnnotation && !nextSpanHasSameAnnotation) {
4641
- const marksWithoutAnnotationMarks = ({
4642
- ...slate.Editor.marks(editor) || {}
4643
- }.marks || []).filter((mark) => decorators.includes(mark));
4754
+ const marksWithoutAnnotationMarks = (__spreadValues$g({}, slate.Editor.marks(editor) || {}).marks || []).filter((mark) => decorators.includes(mark));
4644
4755
  slate.Editor.withoutNormalizing(editor, () => {
4645
4756
  apply2(op), slate.Transforms.setNodes(editor, {
4646
4757
  marks: marksWithoutAnnotationMarks
@@ -4673,6 +4784,7 @@ function createWithPortableTextMarkModel(editorActor, types2) {
4673
4784
  const addDecoratorActionImplementation = ({
4674
4785
  action
4675
4786
  }) => {
4787
+ var _a;
4676
4788
  const editor = action.editor, mark = action.decorator;
4677
4789
  if (editor.selection) {
4678
4790
  if (slate.Range.isExpanded(editor.selection)) {
@@ -4685,7 +4797,10 @@ const addDecoratorActionImplementation = ({
4685
4797
  at: editor.selection,
4686
4798
  match: slate.Text.isText
4687
4799
  })] : [];
4688
- splitTextNodes.length > 1 && splitTextNodes.every((node) => node[0].marks?.includes(mark)) ? editor.removeMark(mark) : splitTextNodes.forEach(([node, path]) => {
4800
+ splitTextNodes.length > 1 && splitTextNodes.every((node) => {
4801
+ var _a2;
4802
+ return (_a2 = node[0].marks) == null ? void 0 : _a2.includes(mark);
4803
+ }) ? editor.removeMark(mark) : splitTextNodes.forEach(([node, path]) => {
4689
4804
  const marks = [...(Array.isArray(node.marks) ? node.marks : []).filter((eMark) => eMark !== mark), mark];
4690
4805
  slate.Transforms.setNodes(editor, {
4691
4806
  marks
@@ -4701,7 +4816,7 @@ const addDecoratorActionImplementation = ({
4701
4816
  depth: 1
4702
4817
  }), lonelyEmptySpan = editor.isTextBlock(block) && block.children.length === 1 && editor.isTextSpan(block.children[0]) && block.children[0].text === "" ? block.children[0] : void 0;
4703
4818
  if (lonelyEmptySpan) {
4704
- const existingMarks = lonelyEmptySpan.marks ?? [], existingMarksWithoutDecorator = existingMarks.filter((existingMark) => existingMark !== mark);
4819
+ const existingMarks = (_a = lonelyEmptySpan.marks) != null ? _a : [], existingMarksWithoutDecorator = existingMarks.filter((existingMark) => existingMark !== mark);
4705
4820
  slate.Transforms.setNodes(editor, {
4706
4821
  marks: existingMarks.length === existingMarksWithoutDecorator.length ? [...existingMarks, mark] : existingMarksWithoutDecorator
4707
4822
  }, {
@@ -4709,12 +4824,9 @@ const addDecoratorActionImplementation = ({
4709
4824
  match: (node) => editor.isTextSpan(node)
4710
4825
  });
4711
4826
  } else {
4712
- const existingMarks = {
4713
- ...slate.Editor.marks(editor) || {}
4714
- }.marks || [], marks = {
4715
- ...slate.Editor.marks(editor) || {},
4827
+ const existingMarks = __spreadValues$g({}, slate.Editor.marks(editor) || {}).marks || [], marks = __spreadProps$b(__spreadValues$g({}, slate.Editor.marks(editor) || {}), {
4716
4828
  marks: [...existingMarks, mark]
4717
- };
4829
+ });
4718
4830
  editor.marks = marks;
4719
4831
  }
4720
4832
  }
@@ -4723,6 +4835,7 @@ const addDecoratorActionImplementation = ({
4723
4835
  }, removeDecoratorActionImplementation = ({
4724
4836
  action
4725
4837
  }) => {
4838
+ var _a;
4726
4839
  const editor = action.editor, mark = action.decorator, {
4727
4840
  selection
4728
4841
  } = editor;
@@ -4749,7 +4862,7 @@ const addDecoratorActionImplementation = ({
4749
4862
  depth: 1
4750
4863
  }), lonelyEmptySpan = editor.isTextBlock(block) && block.children.length === 1 && editor.isTextSpan(block.children[0]) && block.children[0].text === "" ? block.children[0] : void 0;
4751
4864
  if (lonelyEmptySpan) {
4752
- const existingMarksWithoutDecorator = (lonelyEmptySpan.marks ?? []).filter((existingMark) => existingMark !== mark);
4865
+ const existingMarksWithoutDecorator = ((_a = lonelyEmptySpan.marks) != null ? _a : []).filter((existingMark) => existingMark !== mark);
4753
4866
  slate.Transforms.setNodes(editor, {
4754
4867
  marks: existingMarksWithoutDecorator
4755
4868
  }, {
@@ -4757,12 +4870,9 @@ const addDecoratorActionImplementation = ({
4757
4870
  match: (node) => editor.isTextSpan(node)
4758
4871
  });
4759
4872
  } else {
4760
- const existingMarks = {
4761
- ...slate.Editor.marks(editor) || {}
4762
- }.marks || [], marks = {
4763
- ...slate.Editor.marks(editor) || {},
4873
+ const existingMarks = __spreadValues$g({}, slate.Editor.marks(editor) || {}).marks || [], marks = __spreadProps$b(__spreadValues$g({}, slate.Editor.marks(editor) || {}), {
4764
4874
  marks: existingMarks.filter((eMark) => eMark !== mark)
4765
- };
4875
+ });
4766
4876
  editor.marks = {
4767
4877
  marks: marks.marks,
4768
4878
  _type: "span"
@@ -4781,11 +4891,10 @@ function isDecoratorActive({
4781
4891
  at: editor.selection
4782
4892
  }));
4783
4893
  return selectedTextNodes.length === 0 ? !1 : slate.Range.isExpanded(editor.selection) ? selectedTextNodes.every((n) => {
4894
+ var _a;
4784
4895
  const [node] = n;
4785
- return node.marks?.includes(decorator);
4786
- }) : ({
4787
- ...slate.Editor.marks(editor) || {}
4788
- }.marks || []).includes(decorator);
4896
+ return (_a = node.marks) == null ? void 0 : _a.includes(decorator);
4897
+ }) : (__spreadValues$g({}, slate.Editor.marks(editor) || {}).marks || []).includes(decorator);
4789
4898
  }
4790
4899
  const toggleDecoratorActionImplementation = ({
4791
4900
  context,
@@ -4843,6 +4952,14 @@ function createWithPortableTextSelections(editorActor, types2) {
4843
4952
  }, editor;
4844
4953
  };
4845
4954
  }
4955
+ var __defProp$f = Object.defineProperty, __defProps$a = Object.defineProperties, __getOwnPropDescs$a = Object.getOwnPropertyDescriptors, __getOwnPropSymbols$f = Object.getOwnPropertySymbols, __hasOwnProp$f = Object.prototype.hasOwnProperty, __propIsEnum$f = Object.prototype.propertyIsEnumerable, __defNormalProp$f = (obj, key, value) => key in obj ? __defProp$f(obj, key, { enumerable: !0, configurable: !0, writable: !0, value }) : obj[key] = value, __spreadValues$f = (a, b) => {
4956
+ for (var prop in b || (b = {}))
4957
+ __hasOwnProp$f.call(b, prop) && __defNormalProp$f(a, prop, b[prop]);
4958
+ if (__getOwnPropSymbols$f)
4959
+ for (var prop of __getOwnPropSymbols$f(b))
4960
+ __propIsEnum$f.call(b, prop) && __defNormalProp$f(a, prop, b[prop]);
4961
+ return a;
4962
+ }, __spreadProps$a = (a, b) => __defProps$a(a, __getOwnPropDescs$a(b));
4846
4963
  const debug$9 = debugWithName("plugin:withSchemaTypes");
4847
4964
  function createWithSchemaTypes({
4848
4965
  editorActor,
@@ -4860,11 +4977,10 @@ function createWithSchemaTypes({
4860
4977
  const span = node, key = span._key || editorActor.getSnapshot().context.keyGenerator();
4861
4978
  editorActor.send({
4862
4979
  type: "normalizing"
4863
- }), slate.Transforms.setNodes(editor, {
4864
- ...span,
4980
+ }), slate.Transforms.setNodes(editor, __spreadProps$a(__spreadValues$f({}, span), {
4865
4981
  _type: schemaTypes.span.name,
4866
4982
  _key: key
4867
- }, {
4983
+ }), {
4868
4984
  at: path
4869
4985
  }), editorActor.send({
4870
4986
  type: "done normalizing"
@@ -4889,6 +5005,14 @@ function createWithSchemaTypes({
4889
5005
  }, editor;
4890
5006
  };
4891
5007
  }
5008
+ var __defProp$e = Object.defineProperty, __defProps$9 = Object.defineProperties, __getOwnPropDescs$9 = Object.getOwnPropertyDescriptors, __getOwnPropSymbols$e = Object.getOwnPropertySymbols, __hasOwnProp$e = Object.prototype.hasOwnProperty, __propIsEnum$e = Object.prototype.propertyIsEnumerable, __defNormalProp$e = (obj, key, value) => key in obj ? __defProp$e(obj, key, { enumerable: !0, configurable: !0, writable: !0, value }) : obj[key] = value, __spreadValues$e = (a, b) => {
5009
+ for (var prop in b || (b = {}))
5010
+ __hasOwnProp$e.call(b, prop) && __defNormalProp$e(a, prop, b[prop]);
5011
+ if (__getOwnPropSymbols$e)
5012
+ for (var prop of __getOwnPropSymbols$e(b))
5013
+ __propIsEnum$e.call(b, prop) && __defNormalProp$e(a, prop, b[prop]);
5014
+ return a;
5015
+ }, __spreadProps$9 = (a, b) => __defProps$9(a, __getOwnPropDescs$9(b));
4892
5016
  const debug$8 = debugWithName("plugin:withUtils");
4893
5017
  function createWithUtils({
4894
5018
  editorActor,
@@ -4912,29 +5036,26 @@ function createWithUtils({
4912
5036
  } = selection, focusOffset = focus.offset, charsBefore = textNode.text.slice(0, focusOffset), charsAfter = textNode.text.slice(focusOffset, -1), isEmpty = (str) => str.match(/\s/g), whiteSpaceBeforeIndex = charsBefore.split("").reverse().findIndex((str) => isEmpty(str)), newStartOffset = whiteSpaceBeforeIndex > -1 ? charsBefore.length - whiteSpaceBeforeIndex : 0, whiteSpaceAfterIndex = charsAfter.split("").findIndex((obj) => isEmpty(obj)), newEndOffset = charsBefore.length + (whiteSpaceAfterIndex > -1 ? whiteSpaceAfterIndex : charsAfter.length + 1);
4913
5037
  if (!(newStartOffset === newEndOffset || Number.isNaN(newStartOffset) || Number.isNaN(newEndOffset))) {
4914
5038
  debug$8("pteExpandToWord: Expanding to focused word"), slate.Transforms.setSelection(editor, {
4915
- anchor: {
4916
- ...selection.anchor,
5039
+ anchor: __spreadProps$9(__spreadValues$e({}, selection.anchor), {
4917
5040
  offset: newStartOffset
4918
- },
4919
- focus: {
4920
- ...selection.focus,
5041
+ }),
5042
+ focus: __spreadProps$9(__spreadValues$e({}, selection.focus), {
4921
5043
  offset: newEndOffset
4922
- }
5044
+ })
4923
5045
  });
4924
5046
  return;
4925
5047
  }
4926
5048
  debug$8("pteExpandToWord: Can't expand to word here");
4927
5049
  }
4928
- }, editor.pteCreateTextBlock = (options) => toSlateValue([{
5050
+ }, editor.pteCreateTextBlock = (options) => toSlateValue([__spreadProps$9(__spreadValues$e(__spreadValues$e({
4929
5051
  _type: schemaTypes.block.name,
4930
5052
  _key: editorActor.getSnapshot().context.keyGenerator(),
4931
- style: schemaTypes.styles[0].value || "normal",
4932
- ...options.listItem ? {
4933
- listItem: options.listItem
4934
- } : {},
4935
- ...options.level ? {
4936
- level: options.level
4937
- } : {},
5053
+ style: schemaTypes.styles[0].value || "normal"
5054
+ }, options.listItem ? {
5055
+ listItem: options.listItem
5056
+ } : {}), options.level ? {
5057
+ level: options.level
5058
+ } : {}), {
4938
5059
  markDefs: [],
4939
5060
  children: [{
4940
5061
  _type: "span",
@@ -4944,7 +5065,7 @@ function createWithUtils({
4944
5065
  value
4945
5066
  }) => value === decorator))
4946
5067
  }]
4947
- }], {
5068
+ })], {
4948
5069
  schemaTypes
4949
5070
  })[0], editor;
4950
5071
  };
@@ -4990,6 +5111,14 @@ function createSlateEditor(config) {
4990
5111
  };
4991
5112
  return slateEditors.set(config.editorActor, slateEditor), slateEditor;
4992
5113
  }
5114
+ var __defProp$d = Object.defineProperty, __defProps$8 = Object.defineProperties, __getOwnPropDescs$8 = Object.getOwnPropertyDescriptors, __getOwnPropSymbols$d = Object.getOwnPropertySymbols, __hasOwnProp$d = Object.prototype.hasOwnProperty, __propIsEnum$d = Object.prototype.propertyIsEnumerable, __defNormalProp$d = (obj, key, value) => key in obj ? __defProp$d(obj, key, { enumerable: !0, configurable: !0, writable: !0, value }) : obj[key] = value, __spreadValues$d = (a, b) => {
5115
+ for (var prop in b || (b = {}))
5116
+ __hasOwnProp$d.call(b, prop) && __defNormalProp$d(a, prop, b[prop]);
5117
+ if (__getOwnPropSymbols$d)
5118
+ for (var prop of __getOwnPropSymbols$d(b))
5119
+ __propIsEnum$d.call(b, prop) && __defNormalProp$d(a, prop, b[prop]);
5120
+ return a;
5121
+ }, __spreadProps$8 = (a, b) => __defProps$8(a, __getOwnPropDescs$8(b));
4993
5122
  const toggleListItemActionImplementation = ({
4994
5123
  context,
4995
5124
  action
@@ -4999,16 +5128,14 @@ const toggleListItemActionImplementation = ({
4999
5128
  listItem: action.listItem
5000
5129
  }) ? removeListItemActionImplementation({
5001
5130
  context,
5002
- action: {
5003
- ...action,
5131
+ action: __spreadProps$8(__spreadValues$d({}, action), {
5004
5132
  type: "list item.remove"
5005
- }
5133
+ })
5006
5134
  }) : addListItemActionImplementation({
5007
5135
  context,
5008
- action: {
5009
- ...action,
5136
+ action: __spreadProps$8(__spreadValues$d({}, action), {
5010
5137
  type: "list item.add"
5011
- }
5138
+ })
5012
5139
  });
5013
5140
  }, removeListItemActionImplementation = ({
5014
5141
  context,
@@ -5054,6 +5181,14 @@ function isListItemActive({
5054
5181
  })];
5055
5182
  return selectedBlocks.length > 0 ? selectedBlocks.every(([node]) => editor.isListBlock(node) && node.listItem === listItem) : !1;
5056
5183
  }
5184
+ var __defProp$c = Object.defineProperty, __defProps$7 = Object.defineProperties, __getOwnPropDescs$7 = Object.getOwnPropertyDescriptors, __getOwnPropSymbols$c = Object.getOwnPropertySymbols, __hasOwnProp$c = Object.prototype.hasOwnProperty, __propIsEnum$c = Object.prototype.propertyIsEnumerable, __defNormalProp$c = (obj, key, value) => key in obj ? __defProp$c(obj, key, { enumerable: !0, configurable: !0, writable: !0, value }) : obj[key] = value, __spreadValues$c = (a, b) => {
5185
+ for (var prop in b || (b = {}))
5186
+ __hasOwnProp$c.call(b, prop) && __defNormalProp$c(a, prop, b[prop]);
5187
+ if (__getOwnPropSymbols$c)
5188
+ for (var prop of __getOwnPropSymbols$c(b))
5189
+ __propIsEnum$c.call(b, prop) && __defNormalProp$c(a, prop, b[prop]);
5190
+ return a;
5191
+ }, __spreadProps$7 = (a, b) => __defProps$7(a, __getOwnPropDescs$7(b));
5057
5192
  const toggleStyleActionImplementation = ({
5058
5193
  context,
5059
5194
  action
@@ -5063,16 +5198,14 @@ const toggleStyleActionImplementation = ({
5063
5198
  style: action.style
5064
5199
  }) ? removeStyleActionImplementation({
5065
5200
  context,
5066
- action: {
5067
- ...action,
5201
+ action: __spreadProps$7(__spreadValues$c({}, action), {
5068
5202
  type: "style.remove"
5069
- }
5203
+ })
5070
5204
  }) : addStyleActionImplementation({
5071
5205
  context,
5072
- action: {
5073
- ...action,
5206
+ action: __spreadProps$7(__spreadValues$c({}, action), {
5074
5207
  type: "style.add"
5075
- }
5208
+ })
5076
5209
  });
5077
5210
  }, removeStyleActionImplementation = ({
5078
5211
  context,
@@ -5119,6 +5252,14 @@ function isStyleActive({
5119
5252
  })];
5120
5253
  return selectedBlocks.length > 0 ? selectedBlocks.every(([node]) => node.style === style) : !1;
5121
5254
  }
5255
+ var __defProp$b = Object.defineProperty, __getOwnPropSymbols$b = Object.getOwnPropertySymbols, __hasOwnProp$b = Object.prototype.hasOwnProperty, __propIsEnum$b = Object.prototype.propertyIsEnumerable, __defNormalProp$b = (obj, key, value) => key in obj ? __defProp$b(obj, key, { enumerable: !0, configurable: !0, writable: !0, value }) : obj[key] = value, __spreadValues$b = (a, b) => {
5256
+ for (var prop in b || (b = {}))
5257
+ __hasOwnProp$b.call(b, prop) && __defNormalProp$b(a, prop, b[prop]);
5258
+ if (__getOwnPropSymbols$b)
5259
+ for (var prop of __getOwnPropSymbols$b(b))
5260
+ __propIsEnum$b.call(b, prop) && __defNormalProp$b(a, prop, b[prop]);
5261
+ return a;
5262
+ };
5122
5263
  const debug$6 = debugWithName("API:editable");
5123
5264
  function createEditableAPI(editor, editorActor) {
5124
5265
  const types2 = editorActor.getSnapshot().context.schema;
@@ -5181,9 +5322,7 @@ function createEditableAPI(editor, editorActor) {
5181
5322
  return console.warn(err), !1;
5182
5323
  }
5183
5324
  },
5184
- marks: () => ({
5185
- ...slate.Editor.marks(editor) || {}
5186
- }).marks || [],
5325
+ marks: () => __spreadValues$b({}, slate.Editor.marks(editor) || {}).marks || [],
5187
5326
  undo: () => editor.undo(),
5188
5327
  redo: () => editor.redo(),
5189
5328
  select: (selection) => {
@@ -5205,6 +5344,7 @@ function createEditableAPI(editor, editorActor) {
5205
5344
  }
5206
5345
  },
5207
5346
  insertChild: (type, value) => {
5347
+ var _a, _b, _c;
5208
5348
  if (type.name !== types2.span.name)
5209
5349
  return editorActor.send({
5210
5350
  type: "behavior event",
@@ -5216,7 +5356,7 @@ function createEditableAPI(editor, editorActor) {
5216
5356
  }
5217
5357
  },
5218
5358
  editor
5219
- }), toPortableTextRange(fromSlateValue(editor.children, types2.block.name, KEY_TO_VALUE_ELEMENT.get(editor)), editor.selection, types2)?.focus.path ?? [];
5359
+ }), (_b = (_a = toPortableTextRange(fromSlateValue(editor.children, types2.block.name, KEY_TO_VALUE_ELEMENT.get(editor)), editor.selection, types2)) == null ? void 0 : _a.focus.path) != null ? _b : [];
5220
5360
  if (!editor.selection)
5221
5361
  throw new Error("The editor has no selection");
5222
5362
  const [focusBlock] = Array.from(slate.Editor.nodes(editor, {
@@ -5230,11 +5370,10 @@ function createEditableAPI(editor, editorActor) {
5230
5370
  const child = toSlateValue([{
5231
5371
  _key: editorActor.getSnapshot().context.keyGenerator(),
5232
5372
  _type: types2.block.name,
5233
- children: [{
5373
+ children: [__spreadValues$b({
5234
5374
  _key: editorActor.getSnapshot().context.keyGenerator(),
5235
- _type: type.name,
5236
- ...value || {}
5237
- }]
5375
+ _type: type.name
5376
+ }, value || {})]
5238
5377
  }], {
5239
5378
  schemaTypes: editorActor.getSnapshot().context.schema
5240
5379
  })[0].children[0], focusChildPath = editor.selection.focus.path.slice(0, 2), isSpanNode = child._type === types2.span.name, focusNode = slate.Node.get(editor, focusChildPath);
@@ -5244,27 +5383,30 @@ function createEditableAPI(editor, editorActor) {
5244
5383
  })), slate.Transforms.insertNodes(editor, child, {
5245
5384
  select: !0,
5246
5385
  at: editor.selection
5247
- }), editor.onChange(), toPortableTextRange(fromSlateValue(editor.children, types2.block.name, KEY_TO_VALUE_ELEMENT.get(editor)), editor.selection, types2)?.focus.path || [];
5386
+ }), editor.onChange(), ((_c = toPortableTextRange(fromSlateValue(editor.children, types2.block.name, KEY_TO_VALUE_ELEMENT.get(editor)), editor.selection, types2)) == null ? void 0 : _c.focus.path) || [];
5248
5387
  },
5249
- insertBlock: (type, value) => (editorActor.send({
5250
- type: "behavior event",
5251
- behaviorEvent: {
5252
- type: "insert.block object",
5253
- blockObject: {
5254
- name: type.name,
5255
- value
5388
+ insertBlock: (type, value) => {
5389
+ var _a, _b;
5390
+ return editorActor.send({
5391
+ type: "behavior event",
5392
+ behaviorEvent: {
5393
+ type: "insert.block object",
5394
+ blockObject: {
5395
+ name: type.name,
5396
+ value
5397
+ },
5398
+ placement: "auto"
5256
5399
  },
5257
- placement: "auto"
5258
- },
5259
- editor
5260
- }), toPortableTextRange(fromSlateValue(editor.children, types2.block.name, KEY_TO_VALUE_ELEMENT.get(editor)), editor.selection, types2)?.focus.path ?? []),
5400
+ editor
5401
+ }), (_b = (_a = toPortableTextRange(fromSlateValue(editor.children, types2.block.name, KEY_TO_VALUE_ELEMENT.get(editor)), editor.selection, types2)) == null ? void 0 : _a.focus.path) != null ? _b : [];
5402
+ },
5261
5403
  hasBlockStyle: (style) => {
5262
5404
  try {
5263
5405
  return isStyleActive({
5264
5406
  editor,
5265
5407
  style
5266
5408
  });
5267
- } catch {
5409
+ } catch (e) {
5268
5410
  return !1;
5269
5411
  }
5270
5412
  },
@@ -5274,7 +5416,7 @@ function createEditableAPI(editor, editorActor) {
5274
5416
  editor,
5275
5417
  listItem
5276
5418
  });
5277
- } catch {
5419
+ } catch (e) {
5278
5420
  return !1;
5279
5421
  }
5280
5422
  },
@@ -5319,11 +5461,12 @@ function createEditableAPI(editor, editorActor) {
5319
5461
  match: (n) => n._key === element._key
5320
5462
  }) || [])[0] || [void 0];
5321
5463
  node = slateReact.ReactEditor.toDOMNode(editor, item);
5322
- } catch {
5464
+ } catch (e) {
5323
5465
  }
5324
5466
  return node;
5325
5467
  },
5326
5468
  activeAnnotations: () => {
5469
+ var _a;
5327
5470
  if (!editor.selection || editor.selection.focus.path.length < 2)
5328
5471
  return [];
5329
5472
  try {
@@ -5335,12 +5478,12 @@ function createEditableAPI(editor, editorActor) {
5335
5478
  const [block] = slate.Editor.node(editor, path, {
5336
5479
  depth: 1
5337
5480
  });
5338
- editor.isTextBlock(block) && block.markDefs?.forEach((def) => {
5481
+ editor.isTextBlock(block) && ((_a = block.markDefs) == null || _a.forEach((def) => {
5339
5482
  slate.Text.isText(span) && span.marks && Array.isArray(span.marks) && span.marks.includes(def._key) && activeAnnotations.push(def);
5340
- });
5483
+ }));
5341
5484
  }
5342
5485
  return activeAnnotations;
5343
- } catch {
5486
+ } catch (e) {
5344
5487
  return [];
5345
5488
  }
5346
5489
  },
@@ -5362,7 +5505,7 @@ function createEditableAPI(editor, editorActor) {
5362
5505
  type: "annotation.add",
5363
5506
  annotation: {
5364
5507
  name: type.name,
5365
- value: value ?? {}
5508
+ value: value != null ? value : {}
5366
5509
  },
5367
5510
  editor
5368
5511
  }
@@ -5375,7 +5518,7 @@ function createEditableAPI(editor, editorActor) {
5375
5518
  if (!(range && range.anchor.path.length > 0 && range.focus.path.length > 0))
5376
5519
  throw new Error("Invalid range");
5377
5520
  if (range) {
5378
- if (!options?.mode || options?.mode === "selected") {
5521
+ if (!(options != null && options.mode) || (options == null ? void 0 : options.mode) === "selected") {
5379
5522
  debug$6("Deleting content in selection"), slate.Transforms.delete(editor, {
5380
5523
  at: range,
5381
5524
  hanging: !0,
@@ -5383,11 +5526,11 @@ function createEditableAPI(editor, editorActor) {
5383
5526
  }), editor.onChange();
5384
5527
  return;
5385
5528
  }
5386
- options?.mode === "blocks" && (debug$6("Deleting blocks touched by selection"), slate.Transforms.removeNodes(editor, {
5529
+ (options == null ? void 0 : options.mode) === "blocks" && (debug$6("Deleting blocks touched by selection"), slate.Transforms.removeNodes(editor, {
5387
5530
  at: range,
5388
5531
  voids: !0,
5389
5532
  match: (node) => editor.isTextBlock(node) || !editor.isTextBlock(node) && slate.Element.isElement(node)
5390
- })), options?.mode === "children" && (debug$6("Deleting children touched by selection"), slate.Transforms.removeNodes(editor, {
5533
+ })), (options == null ? void 0 : options.mode) === "children" && (debug$6("Deleting children touched by selection"), slate.Transforms.removeNodes(editor, {
5391
5534
  at: range,
5392
5535
  voids: !0,
5393
5536
  match: (node) => node._type === types2.span.name || // Text children
@@ -5444,15 +5587,26 @@ function isAnnotationActive({
5444
5587
  at: editor.selection,
5445
5588
  match: (node) => slate.Text.isText(node)
5446
5589
  })];
5447
- if (spans.length === 0 || spans.some(([span]) => !types.isPortableTextSpan(span) || !span.marks || span.marks?.length === 0)) return !1;
5590
+ if (spans.length === 0 || spans.some(([span]) => {
5591
+ var _a;
5592
+ return !types.isPortableTextSpan(span) || !span.marks || ((_a = span.marks) == null ? void 0 : _a.length) === 0;
5593
+ })) return !1;
5448
5594
  const selectionMarkDefs = spans.reduce((accMarkDefs, [, path]) => {
5449
5595
  const [block] = slate.Editor.node(editor, path, {
5450
5596
  depth: 1
5451
5597
  });
5452
5598
  return editor.isTextBlock(block) && block.markDefs ? [...accMarkDefs, ...block.markDefs] : accMarkDefs;
5453
5599
  }, []);
5454
- return spans.every(([span]) => types.isPortableTextSpan(span) ? span.marks?.map((markKey) => selectionMarkDefs.find((def) => def?._key === markKey)?._type)?.includes(annotation.name) : !1);
5455
- } catch {
5600
+ return spans.every(([span]) => {
5601
+ var _a;
5602
+ if (!types.isPortableTextSpan(span)) return !1;
5603
+ const spanMarkDefs = (_a = span.marks) == null ? void 0 : _a.map((markKey) => {
5604
+ var _a2;
5605
+ return (_a2 = selectionMarkDefs.find((def) => (def == null ? void 0 : def._key) === markKey)) == null ? void 0 : _a2._type;
5606
+ });
5607
+ return spanMarkDefs == null ? void 0 : spanMarkDefs.includes(annotation.name);
5608
+ });
5609
+ } catch (e) {
5456
5610
  return !1;
5457
5611
  }
5458
5612
  }
@@ -5460,6 +5614,7 @@ const addAnnotationActionImplementation = ({
5460
5614
  context,
5461
5615
  action
5462
5616
  }) => {
5617
+ var _a, _b;
5463
5618
  const editor = action.editor, {
5464
5619
  selection: originalSelection
5465
5620
  } = editor;
@@ -5477,13 +5632,12 @@ const addAnnotationActionImplementation = ({
5477
5632
  for (const [block, blockPath] of selectedBlocks) {
5478
5633
  if (block.children.length === 0 || block.children.length === 1 && block.children[0].text === "")
5479
5634
  continue;
5480
- const annotationKey = context.keyGenerator(), markDefs = block.markDefs ?? [];
5635
+ const annotationKey = context.keyGenerator(), markDefs = (_a = block.markDefs) != null ? _a : [];
5481
5636
  markDefs.find((markDef) => markDef._type === action.annotation.name && markDef._key === annotationKey) === void 0 && (slate.Transforms.setNodes(editor, {
5482
- markDefs: [...markDefs, {
5637
+ markDefs: [...markDefs, __spreadValues$b({
5483
5638
  _type: action.annotation.name,
5484
- _key: annotationKey,
5485
- ...action.annotation.value
5486
- }]
5639
+ _key: annotationKey
5640
+ }, action.annotation.value)]
5487
5641
  }, {
5488
5642
  at: blockPath
5489
5643
  }), markDefPath = [{
@@ -5498,7 +5652,7 @@ const addAnnotationActionImplementation = ({
5498
5652
  for (const [span, path] of children) {
5499
5653
  if (!editor.isTextSpan(span) || !slate.Range.includes(editor.selection, path))
5500
5654
  continue;
5501
- const marks = span.marks ?? [], existingSameTypeAnnotations = marks.filter((mark) => markDefs.some((markDef) => markDef._key === mark && markDef._type === action.annotation.name));
5655
+ const marks = (_b = span.marks) != null ? _b : [], existingSameTypeAnnotations = marks.filter((mark) => markDefs.some((markDef) => markDef._key === mark && markDef._type === action.annotation.name));
5502
5656
  slate.Transforms.setNodes(editor, {
5503
5657
  marks: [...marks.filter((mark) => !existingSameTypeAnnotations.includes(mark)), annotationKey]
5504
5658
  }, {
@@ -5520,6 +5674,7 @@ const addAnnotationActionImplementation = ({
5520
5674
  }, removeAnnotationActionImplementation = ({
5521
5675
  action
5522
5676
  }) => {
5677
+ var _a, _b, _c, _d, _e, _f, _g;
5523
5678
  const editor = action.editor;
5524
5679
  if (debug$6("Removing annotation", action.annotation.name), !!editor.selection)
5525
5680
  if (slate.Range.isCollapsed(editor.selection)) {
@@ -5528,12 +5683,12 @@ const addAnnotationActionImplementation = ({
5528
5683
  });
5529
5684
  if (!editor.isTextBlock(block))
5530
5685
  return;
5531
- const potentialAnnotations = (block.markDefs ?? []).filter((markDef) => markDef._type === action.annotation.name), [selectedChild, selectedChildPath] = slate.Editor.node(editor, editor.selection, {
5686
+ const potentialAnnotations = ((_a = block.markDefs) != null ? _a : []).filter((markDef) => markDef._type === action.annotation.name), [selectedChild, selectedChildPath] = slate.Editor.node(editor, editor.selection, {
5532
5687
  depth: 2
5533
5688
  });
5534
5689
  if (!editor.isTextSpan(selectedChild))
5535
5690
  return;
5536
- const annotationToRemove = selectedChild.marks?.find((mark) => potentialAnnotations.some((markDef) => markDef._key === mark));
5691
+ const annotationToRemove = (_b = selectedChild.marks) == null ? void 0 : _b.find((mark) => potentialAnnotations.some((markDef) => markDef._key === mark));
5537
5692
  if (!annotationToRemove)
5538
5693
  return;
5539
5694
  const previousSpansWithSameAnnotation = [];
@@ -5541,20 +5696,20 @@ const addAnnotationActionImplementation = ({
5541
5696
  reverse: !0
5542
5697
  }))
5543
5698
  if (editor.isTextSpan(child) && slate.Path.isBefore(childPath, selectedChildPath))
5544
- if (child.marks?.includes(annotationToRemove))
5699
+ if ((_c = child.marks) != null && _c.includes(annotationToRemove))
5545
5700
  previousSpansWithSameAnnotation.push([child, childPath]);
5546
5701
  else
5547
5702
  break;
5548
5703
  const nextSpansWithSameAnnotation = [];
5549
5704
  for (const [child, childPath] of slate.Node.children(editor, blockPath))
5550
5705
  if (editor.isTextSpan(child) && slate.Path.isAfter(childPath, selectedChildPath))
5551
- if (child.marks?.includes(annotationToRemove))
5706
+ if ((_d = child.marks) != null && _d.includes(annotationToRemove))
5552
5707
  nextSpansWithSameAnnotation.push([child, childPath]);
5553
5708
  else
5554
5709
  break;
5555
5710
  for (const [child, childPath] of [...previousSpansWithSameAnnotation, [selectedChild, selectedChildPath], ...nextSpansWithSameAnnotation])
5556
5711
  slate.Transforms.setNodes(editor, {
5557
- marks: child.marks?.filter((mark) => mark !== annotationToRemove)
5712
+ marks: (_e = child.marks) == null ? void 0 : _e.filter((mark) => mark !== annotationToRemove)
5558
5713
  }, {
5559
5714
  at: childPath
5560
5715
  });
@@ -5573,7 +5728,10 @@ const addAnnotationActionImplementation = ({
5573
5728
  for (const [child, childPath] of children) {
5574
5729
  if (!editor.isTextSpan(child) || !slate.Range.includes(editor.selection, childPath))
5575
5730
  continue;
5576
- const markDefs = block.markDefs ?? [], marks = child.marks ?? [], marksWithoutAnnotation = marks.filter((mark) => markDefs.find((markDef2) => markDef2._key === mark)?._type !== action.annotation.name);
5731
+ const markDefs = (_f = block.markDefs) != null ? _f : [], marks = (_g = child.marks) != null ? _g : [], marksWithoutAnnotation = marks.filter((mark) => {
5732
+ const markDef = markDefs.find((markDef2) => markDef2._key === mark);
5733
+ return (markDef == null ? void 0 : markDef._type) !== action.annotation.name;
5734
+ });
5577
5735
  marksWithoutAnnotation.length !== marks.length && slate.Transforms.setNodes(editor, {
5578
5736
  marks: marksWithoutAnnotation
5579
5737
  }, {
@@ -5616,11 +5774,12 @@ function insertBlock({
5616
5774
  editor,
5617
5775
  schema: schema2
5618
5776
  }) {
5777
+ var _a;
5619
5778
  if (editor.selection) {
5620
- const [focusBlock, focusBlockPath] = Array.from(slate.Editor.nodes(editor, {
5779
+ const [focusBlock, focusBlockPath] = (_a = Array.from(slate.Editor.nodes(editor, {
5621
5780
  at: editor.selection.focus.path.slice(0, 1),
5622
5781
  match: (n) => !slate.Editor.isEditor(n)
5623
- }))[0] ?? [void 0, void 0];
5782
+ }))[0]) != null ? _a : [void 0, void 0];
5624
5783
  if (placement === "after") {
5625
5784
  const nextPath = [focusBlockPath[0] + 1];
5626
5785
  slate.Transforms.insertNodes(editor, block, {
@@ -5652,15 +5811,22 @@ function insertBlock({
5652
5811
  });
5653
5812
  }
5654
5813
  }
5814
+ var __defProp$a = Object.defineProperty, __getOwnPropSymbols$a = Object.getOwnPropertySymbols, __hasOwnProp$a = Object.prototype.hasOwnProperty, __propIsEnum$a = Object.prototype.propertyIsEnumerable, __defNormalProp$a = (obj, key, value) => key in obj ? __defProp$a(obj, key, { enumerable: !0, configurable: !0, writable: !0, value }) : obj[key] = value, __spreadValues$a = (a, b) => {
5815
+ for (var prop in b || (b = {}))
5816
+ __hasOwnProp$a.call(b, prop) && __defNormalProp$a(a, prop, b[prop]);
5817
+ if (__getOwnPropSymbols$a)
5818
+ for (var prop of __getOwnPropSymbols$a(b))
5819
+ __propIsEnum$a.call(b, prop) && __defNormalProp$a(a, prop, b[prop]);
5820
+ return a;
5821
+ };
5655
5822
  const insertBlockObjectActionImplementation = ({
5656
5823
  context,
5657
5824
  action
5658
5825
  }) => {
5659
- const block = toSlateValue([{
5826
+ const block = toSlateValue([__spreadValues$a({
5660
5827
  _key: context.keyGenerator(),
5661
- _type: action.blockObject.name,
5662
- ...action.blockObject.value ? action.blockObject.value : {}
5663
- }], {
5828
+ _type: action.blockObject.name
5829
+ }, action.blockObject.value ? action.blockObject.value : {})], {
5664
5830
  schemaTypes: context.schema
5665
5831
  })[0];
5666
5832
  insertBlock({
@@ -5669,19 +5835,29 @@ const insertBlockObjectActionImplementation = ({
5669
5835
  editor: action.editor,
5670
5836
  schema: context.schema
5671
5837
  });
5672
- }, insertBreakActionImplementation = ({
5838
+ };
5839
+ var __defProp$9 = Object.defineProperty, __defProps$6 = Object.defineProperties, __getOwnPropDescs$6 = Object.getOwnPropertyDescriptors, __getOwnPropSymbols$9 = Object.getOwnPropertySymbols, __hasOwnProp$9 = Object.prototype.hasOwnProperty, __propIsEnum$9 = Object.prototype.propertyIsEnumerable, __defNormalProp$9 = (obj, key, value) => key in obj ? __defProp$9(obj, key, { enumerable: !0, configurable: !0, writable: !0, value }) : obj[key] = value, __spreadValues$9 = (a, b) => {
5840
+ for (var prop in b || (b = {}))
5841
+ __hasOwnProp$9.call(b, prop) && __defNormalProp$9(a, prop, b[prop]);
5842
+ if (__getOwnPropSymbols$9)
5843
+ for (var prop of __getOwnPropSymbols$9(b))
5844
+ __propIsEnum$9.call(b, prop) && __defNormalProp$9(a, prop, b[prop]);
5845
+ return a;
5846
+ }, __spreadProps$6 = (a, b) => __defProps$6(a, __getOwnPropDescs$6(b));
5847
+ const insertBreakActionImplementation = ({
5673
5848
  context,
5674
5849
  action
5675
5850
  }) => {
5851
+ var _a, _b, _c, _d, _e;
5676
5852
  const keyGenerator = context.keyGenerator, schema2 = context.schema, editor = action.editor;
5677
5853
  if (!editor.selection)
5678
5854
  return;
5679
- const [focusSpan] = Array.from(slate.Editor.nodes(editor, {
5855
+ const [focusSpan] = (_a = Array.from(slate.Editor.nodes(editor, {
5680
5856
  mode: "lowest",
5681
5857
  at: editor.selection.focus,
5682
5858
  match: (n) => editor.isTextSpan(n),
5683
5859
  voids: !1
5684
- }))[0] ?? [void 0], focusDecorators = focusSpan?.marks?.filter((mark) => schema2.decorators.some((decorator) => decorator.value === mark)) ?? [], focusAnnotations = focusSpan?.marks?.filter((mark) => !schema2.decorators.some((decorator) => decorator.value === mark)) ?? [], anchorBlockPath = editor.selection.anchor.path.slice(0, 1), focusBlockPath = editor.selection.focus.path.slice(0, 1), focusBlock = slate.Node.descendant(editor, focusBlockPath);
5860
+ }))[0]) != null ? _a : [void 0], focusDecorators = (_c = (_b = focusSpan == null ? void 0 : focusSpan.marks) == null ? void 0 : _b.filter((mark) => schema2.decorators.some((decorator) => decorator.value === mark))) != null ? _c : [], focusAnnotations = (_e = (_d = focusSpan == null ? void 0 : focusSpan.marks) == null ? void 0 : _d.filter((mark) => !schema2.decorators.some((decorator) => decorator.value === mark))) != null ? _e : [], anchorBlockPath = editor.selection.anchor.path.slice(0, 1), focusBlockPath = editor.selection.focus.path.slice(0, 1), focusBlock = slate.Node.descendant(editor, focusBlockPath);
5685
5861
  if (editor.isTextBlock(focusBlock)) {
5686
5862
  const [start, end] = slate.Range.edges(editor.selection), lastFocusBlockChild = focusBlock.children[focusBlock.children.length - 1], atTheEndOfBlock = isEqual__default.default(start, {
5687
5863
  path: [...focusBlockPath, focusBlock.children.length - 1],
@@ -5720,6 +5896,7 @@ const insertBlockObjectActionImplementation = ({
5720
5896
  const selectionAcrossBlocks = anchorBlockPath[0] !== focusBlockPath[0];
5721
5897
  if (!atTheStartOfBlock && !atTheEndOfBlock && !selectionAcrossBlocks) {
5722
5898
  slate.Editor.withoutNormalizing(editor, () => {
5899
+ var _a2;
5723
5900
  if (!editor.selection)
5724
5901
  return;
5725
5902
  slate.Transforms.splitNodes(editor, {
@@ -5742,20 +5919,28 @@ const insertBlockObjectActionImplementation = ({
5742
5919
  for (const [child, childPath] of children) {
5743
5920
  if (!editor.isTextSpan(child))
5744
5921
  continue;
5745
- const marks = child.marks ?? [];
5922
+ const marks = (_a2 = child.marks) != null ? _a2 : [];
5746
5923
  for (const mark of marks)
5747
- schema2.decorators.some((decorator) => decorator.value === mark) || prevNodeSpans.some((prevNodeSpan) => prevNodeSpan.marks?.includes(mark)) && !newMarkDefKeys.has(mark) && newMarkDefKeys.set(mark, keyGenerator());
5748
- const newMarks = marks.map((mark) => newMarkDefKeys.get(mark) ?? mark);
5924
+ schema2.decorators.some((decorator) => decorator.value === mark) || prevNodeSpans.some((prevNodeSpan) => {
5925
+ var _a3;
5926
+ return (_a3 = prevNodeSpan.marks) == null ? void 0 : _a3.includes(mark);
5927
+ }) && !newMarkDefKeys.has(mark) && newMarkDefKeys.set(mark, keyGenerator());
5928
+ const newMarks = marks.map((mark) => {
5929
+ var _a3;
5930
+ return (_a3 = newMarkDefKeys.get(mark)) != null ? _a3 : mark;
5931
+ });
5749
5932
  isEqual__default.default(marks, newMarks) || slate.Transforms.setNodes(editor, {
5750
5933
  marks: newMarks
5751
5934
  }, {
5752
5935
  at: childPath
5753
5936
  });
5754
5937
  }
5755
- const newMarkDefs = nextNode.markDefs.map((markDef) => ({
5756
- ...markDef,
5757
- _key: newMarkDefKeys.get(markDef._key) ?? markDef._key
5758
- }));
5938
+ const newMarkDefs = nextNode.markDefs.map((markDef) => {
5939
+ var _a3;
5940
+ return __spreadProps$6(__spreadValues$9({}, markDef), {
5941
+ _key: (_a3 = newMarkDefKeys.get(markDef._key)) != null ? _a3 : markDef._key
5942
+ });
5943
+ });
5759
5944
  isEqual__default.default(nextNode.markDefs, newMarkDefs) || slate.Transforms.setNodes(editor, {
5760
5945
  markDefs: newMarkDefs
5761
5946
  }, {
@@ -5776,15 +5961,24 @@ const insertBlockObjectActionImplementation = ({
5776
5961
  }) => {
5777
5962
  insertBreakActionImplementation({
5778
5963
  context,
5779
- action: {
5780
- ...action,
5964
+ action: __spreadProps$6(__spreadValues$9({}, action), {
5781
5965
  type: "insert.break"
5782
- }
5966
+ })
5783
5967
  });
5784
- }, insertInlineObjectActionImplementation = ({
5968
+ };
5969
+ var __defProp$8 = Object.defineProperty, __getOwnPropSymbols$8 = Object.getOwnPropertySymbols, __hasOwnProp$8 = Object.prototype.hasOwnProperty, __propIsEnum$8 = Object.prototype.propertyIsEnumerable, __defNormalProp$8 = (obj, key, value) => key in obj ? __defProp$8(obj, key, { enumerable: !0, configurable: !0, writable: !0, value }) : obj[key] = value, __spreadValues$8 = (a, b) => {
5970
+ for (var prop in b || (b = {}))
5971
+ __hasOwnProp$8.call(b, prop) && __defNormalProp$8(a, prop, b[prop]);
5972
+ if (__getOwnPropSymbols$8)
5973
+ for (var prop of __getOwnPropSymbols$8(b))
5974
+ __propIsEnum$8.call(b, prop) && __defNormalProp$8(a, prop, b[prop]);
5975
+ return a;
5976
+ };
5977
+ const insertInlineObjectActionImplementation = ({
5785
5978
  context,
5786
5979
  action
5787
5980
  }) => {
5981
+ var _a, _b;
5788
5982
  if (!context.schema.inlineObjects.some((inlineObject) => inlineObject.name === action.inlineObject.name)) {
5789
5983
  console.error("Unable to insert unknown inline object");
5790
5984
  return;
@@ -5793,60 +5987,77 @@ const insertBlockObjectActionImplementation = ({
5793
5987
  console.error("Unable to insert inline object without selection");
5794
5988
  return;
5795
5989
  }
5796
- const [focusTextBlock] = Array.from(slate.Editor.nodes(action.editor, {
5990
+ const [focusTextBlock] = (_a = Array.from(slate.Editor.nodes(action.editor, {
5797
5991
  at: action.editor.selection.focus.path,
5798
5992
  match: (node) => action.editor.isTextBlock(node)
5799
- })).at(0) ?? [void 0, void 0];
5993
+ })).at(0)) != null ? _a : [void 0, void 0];
5800
5994
  if (!focusTextBlock) {
5801
5995
  console.error("Unable to perform action without focus text block");
5802
5996
  return;
5803
5997
  }
5804
- const child = toSlateValue([{
5998
+ const block = toSlateValue([{
5805
5999
  _type: context.schema.block.name,
5806
6000
  _key: context.keyGenerator(),
5807
- children: [{
6001
+ children: [__spreadValues$8({
5808
6002
  _type: action.inlineObject.name,
5809
- _key: context.keyGenerator(),
5810
- ...action.inlineObject.value ?? {}
5811
- }]
6003
+ _key: context.keyGenerator()
6004
+ }, (_b = action.inlineObject.value) != null ? _b : {})]
5812
6005
  }], {
5813
6006
  schemaTypes: context.schema
5814
- }).at(0)?.children.at(0);
6007
+ }).at(0), child = block == null ? void 0 : block.children.at(0);
5815
6008
  if (!child) {
5816
6009
  console.error("Unable to insert inline object");
5817
6010
  return;
5818
6011
  }
5819
6012
  slate.Transforms.insertNodes(action.editor, child);
5820
- }, insertSpanActionImplementation = ({
6013
+ };
6014
+ var __defProp$7 = Object.defineProperty, __getOwnPropSymbols$7 = Object.getOwnPropertySymbols, __hasOwnProp$7 = Object.prototype.hasOwnProperty, __propIsEnum$7 = Object.prototype.propertyIsEnumerable, __defNormalProp$7 = (obj, key, value) => key in obj ? __defProp$7(obj, key, { enumerable: !0, configurable: !0, writable: !0, value }) : obj[key] = value, __spreadValues$7 = (a, b) => {
6015
+ for (var prop in b || (b = {}))
6016
+ __hasOwnProp$7.call(b, prop) && __defNormalProp$7(a, prop, b[prop]);
6017
+ if (__getOwnPropSymbols$7)
6018
+ for (var prop of __getOwnPropSymbols$7(b))
6019
+ __propIsEnum$7.call(b, prop) && __defNormalProp$7(a, prop, b[prop]);
6020
+ return a;
6021
+ };
6022
+ const insertSpanActionImplementation = ({
5821
6023
  context,
5822
6024
  action
5823
6025
  }) => {
6026
+ var _a, _b, _c, _d;
5824
6027
  if (!action.editor.selection) {
5825
6028
  console.error("Unable to perform action without selection", action);
5826
6029
  return;
5827
6030
  }
5828
- const [focusBlock, focusBlockPath] = Array.from(slate.Editor.nodes(action.editor, {
6031
+ const [focusBlock, focusBlockPath] = (_a = Array.from(slate.Editor.nodes(action.editor, {
5829
6032
  at: action.editor.selection.focus.path,
5830
6033
  match: (node) => action.editor.isTextBlock(node)
5831
- }))[0] ?? [void 0, void 0];
6034
+ }))[0]) != null ? _a : [void 0, void 0];
5832
6035
  if (!focusBlock || !focusBlockPath) {
5833
6036
  console.error("Unable to perform action without focus block", action);
5834
6037
  return;
5835
6038
  }
5836
- const markDefs = focusBlock.markDefs ?? [], annotations = action.annotations ? action.annotations.map((annotation) => ({
6039
+ const markDefs = (_b = focusBlock.markDefs) != null ? _b : [], annotations = action.annotations ? action.annotations.map((annotation) => __spreadValues$7({
5837
6040
  _type: annotation.name,
5838
- _key: context.keyGenerator(),
5839
- ...annotation.value
5840
- })) : void 0;
6041
+ _key: context.keyGenerator()
6042
+ }, annotation.value)) : void 0;
5841
6043
  annotations && annotations.length > 0 && slate.Transforms.setNodes(action.editor, {
5842
6044
  markDefs: [...markDefs, ...annotations]
5843
6045
  }), slate.Transforms.insertNodes(action.editor, {
5844
6046
  _type: "span",
5845
6047
  _key: context.keyGenerator(),
5846
6048
  text: action.text,
5847
- marks: [...annotations?.map((annotation) => annotation._key) ?? [], ...action.decorators ?? []]
6049
+ marks: [...(_c = annotations == null ? void 0 : annotations.map((annotation) => annotation._key)) != null ? _c : [], ...(_d = action.decorators) != null ? _d : []]
5848
6050
  });
5849
- }, textBlockSetActionImplementation = ({
6051
+ };
6052
+ var __defProp$6 = Object.defineProperty, __getOwnPropSymbols$6 = Object.getOwnPropertySymbols, __hasOwnProp$6 = Object.prototype.hasOwnProperty, __propIsEnum$6 = Object.prototype.propertyIsEnumerable, __defNormalProp$6 = (obj, key, value) => key in obj ? __defProp$6(obj, key, { enumerable: !0, configurable: !0, writable: !0, value }) : obj[key] = value, __spreadValues$6 = (a, b) => {
6053
+ for (var prop in b || (b = {}))
6054
+ __hasOwnProp$6.call(b, prop) && __defNormalProp$6(a, prop, b[prop]);
6055
+ if (__getOwnPropSymbols$6)
6056
+ for (var prop of __getOwnPropSymbols$6(b))
6057
+ __propIsEnum$6.call(b, prop) && __defNormalProp$6(a, prop, b[prop]);
6058
+ return a;
6059
+ };
6060
+ const textBlockSetActionImplementation = ({
5850
6061
  action
5851
6062
  }) => {
5852
6063
  const at = toSlateRange({
@@ -5859,17 +6070,13 @@ const insertBlockObjectActionImplementation = ({
5859
6070
  offset: 0
5860
6071
  }
5861
6072
  }, action.editor);
5862
- slate.Transforms.setNodes(action.editor, {
5863
- ...action.style ? {
5864
- style: action.style
5865
- } : {},
5866
- ...action.listItem ? {
5867
- listItem: action.listItem
5868
- } : {},
5869
- ...action.level ? {
5870
- level: action.level
5871
- } : {}
5872
- }, {
6073
+ slate.Transforms.setNodes(action.editor, __spreadValues$6(__spreadValues$6(__spreadValues$6({}, action.style ? {
6074
+ style: action.style
6075
+ } : {}), action.listItem ? {
6076
+ listItem: action.listItem
6077
+ } : {}), action.level ? {
6078
+ level: action.level
6079
+ } : {}), {
5873
6080
  at
5874
6081
  });
5875
6082
  }, textBlockUnsetActionImplementation = ({
@@ -5888,7 +6095,16 @@ const insertBlockObjectActionImplementation = ({
5888
6095
  slate.Transforms.unsetNodes(action.editor, action.props, {
5889
6096
  at
5890
6097
  });
5891
- }, behaviorActionImplementations = {
6098
+ };
6099
+ var __defProp$5 = Object.defineProperty, __defProps$5 = Object.defineProperties, __getOwnPropDescs$5 = Object.getOwnPropertyDescriptors, __getOwnPropSymbols$5 = Object.getOwnPropertySymbols, __hasOwnProp$5 = Object.prototype.hasOwnProperty, __propIsEnum$5 = Object.prototype.propertyIsEnumerable, __defNormalProp$5 = (obj, key, value) => key in obj ? __defProp$5(obj, key, { enumerable: !0, configurable: !0, writable: !0, value }) : obj[key] = value, __spreadValues$5 = (a, b) => {
6100
+ for (var prop in b || (b = {}))
6101
+ __hasOwnProp$5.call(b, prop) && __defNormalProp$5(a, prop, b[prop]);
6102
+ if (__getOwnPropSymbols$5)
6103
+ for (var prop of __getOwnPropSymbols$5(b))
6104
+ __propIsEnum$5.call(b, prop) && __defNormalProp$5(a, prop, b[prop]);
6105
+ return a;
6106
+ }, __spreadProps$5 = (a, b) => __defProps$5(a, __getOwnPropDescs$5(b));
6107
+ const behaviorActionImplementations = {
5892
6108
  "annotation.add": addAnnotationActionImplementation,
5893
6109
  "annotation.remove": removeAnnotationActionImplementation,
5894
6110
  "annotation.toggle": toggleAnnotationActionImplementation,
@@ -5977,15 +6193,15 @@ const insertBlockObjectActionImplementation = ({
5977
6193
  context,
5978
6194
  action
5979
6195
  }) => {
6196
+ var _a, _b, _c, _d;
5980
6197
  const block = toSlateValue([{
5981
6198
  _key: context.keyGenerator(),
5982
6199
  _type: context.schema.block.name,
5983
- style: context.schema.styles[0].value ?? "normal",
6200
+ style: (_a = context.schema.styles[0].value) != null ? _a : "normal",
5984
6201
  markDefs: [],
5985
- children: action.textBlock?.children?.map((child) => ({
5986
- ...child,
6202
+ children: (_d = (_c = (_b = action.textBlock) == null ? void 0 : _b.children) == null ? void 0 : _c.map((child) => __spreadProps$5(__spreadValues$5({}, child), {
5987
6203
  _key: context.keyGenerator()
5988
- })) ?? [{
6204
+ }))) != null ? _d : [{
5989
6205
  _type: context.schema.span.name,
5990
6206
  _key: context.keyGenerator(),
5991
6207
  text: ""
@@ -6078,11 +6294,7 @@ const insertBlockObjectActionImplementation = ({
6078
6294
  action
6079
6295
  }) => {
6080
6296
  const selection = action.editor.selection;
6081
- selection && (slate.Transforms.select(action.editor, {
6082
- ...selection
6083
- }), action.editor.selection = {
6084
- ...selection
6085
- });
6297
+ selection && (slate.Transforms.select(action.editor, __spreadValues$5({}, selection)), action.editor.selection = __spreadValues$5({}, selection));
6086
6298
  },
6087
6299
  "style.toggle": toggleStyleActionImplementation,
6088
6300
  "style.add": addStyleActionImplementation,
@@ -6354,6 +6566,14 @@ function performDefaultAction({
6354
6566
  });
6355
6567
  }
6356
6568
  }
6569
+ var __defProp$4 = Object.defineProperty, __defProps$4 = Object.defineProperties, __getOwnPropDescs$4 = Object.getOwnPropertyDescriptors, __getOwnPropSymbols$4 = Object.getOwnPropertySymbols, __hasOwnProp$4 = Object.prototype.hasOwnProperty, __propIsEnum$4 = Object.prototype.propertyIsEnumerable, __defNormalProp$4 = (obj, key, value) => key in obj ? __defProp$4(obj, key, { enumerable: !0, configurable: !0, writable: !0, value }) : obj[key] = value, __spreadValues$4 = (a, b) => {
6570
+ for (var prop in b || (b = {}))
6571
+ __hasOwnProp$4.call(b, prop) && __defNormalProp$4(a, prop, b[prop]);
6572
+ if (__getOwnPropSymbols$4)
6573
+ for (var prop of __getOwnPropSymbols$4(b))
6574
+ __propIsEnum$4.call(b, prop) && __defNormalProp$4(a, prop, b[prop]);
6575
+ return a;
6576
+ }, __spreadProps$4 = (a, b) => __defProps$4(a, __getOwnPropDescs$4(b));
6357
6577
  const editorMachine = xstate.setup({
6358
6578
  types: {
6359
6579
  context: {},
@@ -6399,11 +6619,11 @@ const editorMachine = xstate.setup({
6399
6619
  event,
6400
6620
  enqueue
6401
6621
  }) => {
6622
+ var _a;
6402
6623
  xstate.assertEvent(event, ["behavior event"]), debug$l("Behavior event", event);
6403
- const defaultAction = event.behaviorEvent.type === "copy" || event.behaviorEvent.type === "key.down" || event.behaviorEvent.type === "key.up" || event.behaviorEvent.type === "paste" ? void 0 : {
6404
- ...event.behaviorEvent,
6624
+ const defaultAction = event.behaviorEvent.type === "copy" || event.behaviorEvent.type === "key.down" || event.behaviorEvent.type === "key.up" || event.behaviorEvent.type === "paste" ? void 0 : __spreadProps$4(__spreadValues$4({}, event.behaviorEvent), {
6405
6625
  editor: event.editor
6406
- }, eventBehaviors = context.behaviors.filter((behavior) => behavior.on === event.behaviorEvent.type);
6626
+ }), eventBehaviors = context.behaviors.filter((behavior) => behavior.on === event.behaviorEvent.type);
6407
6627
  if (eventBehaviors.length === 0) {
6408
6628
  if (!defaultAction)
6409
6629
  return;
@@ -6447,7 +6667,7 @@ const editorMachine = xstate.setup({
6447
6667
  actionIntends
6448
6668
  });
6449
6669
  if (behaviorOverwritten) {
6450
- event.nativeEvent?.preventDefault();
6670
+ (_a = event.nativeEvent) == null || _a.preventDefault();
6451
6671
  break;
6452
6672
  }
6453
6673
  }
@@ -6466,16 +6686,19 @@ const editorMachine = xstate.setup({
6466
6686
  id: "editor",
6467
6687
  context: ({
6468
6688
  input
6469
- }) => ({
6470
- behaviors: input.behaviors ?? coreBehaviors,
6471
- keyGenerator: input.keyGenerator,
6472
- pendingEvents: [],
6473
- schema: input.schema,
6474
- selection: void 0,
6475
- readOnly: input.readOnly ?? !1,
6476
- maxBlocks: input.maxBlocks,
6477
- value: input.value
6478
- }),
6689
+ }) => {
6690
+ var _a, _b;
6691
+ return {
6692
+ behaviors: (_a = input.behaviors) != null ? _a : coreBehaviors,
6693
+ keyGenerator: input.keyGenerator,
6694
+ pendingEvents: [],
6695
+ schema: input.schema,
6696
+ selection: void 0,
6697
+ readOnly: (_b = input.readOnly) != null ? _b : !1,
6698
+ maxBlocks: input.maxBlocks,
6699
+ value: input.value
6700
+ };
6701
+ },
6479
6702
  on: {
6480
6703
  "annotation.add": {
6481
6704
  actions: xstate.emit(({
@@ -6578,7 +6801,10 @@ const editorMachine = xstate.setup({
6578
6801
  actions: [xstate.assign({
6579
6802
  selection: ({
6580
6803
  event
6581
- }) => event.selection ?? void 0
6804
+ }) => {
6805
+ var _a;
6806
+ return (_a = event.selection) != null ? _a : void 0;
6807
+ }
6582
6808
  }), xstate.emit(({
6583
6809
  event
6584
6810
  }) => event)]
@@ -6653,10 +6879,9 @@ const editorMachine = xstate.setup({
6653
6879
  }) => {
6654
6880
  slate.Editor.withoutNormalizing(event.editor, () => {
6655
6881
  for (const actionIntend of event.actionIntends) {
6656
- const action = {
6657
- ...actionIntend,
6882
+ const action = __spreadProps$4(__spreadValues$4({}, actionIntend), {
6658
6883
  editor: event.editor
6659
- };
6884
+ });
6660
6885
  performAction({
6661
6886
  context,
6662
6887
  action
@@ -6755,7 +6980,7 @@ function createEditor(config) {
6755
6980
  },
6756
6981
  on: (event, listener) => editorActor.on(
6757
6982
  event,
6758
- // @ts-ignore
6983
+ // @ts-expect-error
6759
6984
  listener
6760
6985
  ),
6761
6986
  _internal: {
@@ -6766,31 +6991,41 @@ function createEditor(config) {
6766
6991
  };
6767
6992
  }
6768
6993
  function useCreateEditor(config) {
6769
- const editorActor = react.useActorRef(editorMachine, {
6770
- input: editorConfigToMachineInput(config)
6771
- }), slateEditor = createSlateEditor({
6994
+ const $ = reactCompilerRuntime.c(18);
6995
+ let t0;
6996
+ $[0] !== config ? (t0 = editorConfigToMachineInput(config), $[0] = config, $[1] = t0) : t0 = $[1];
6997
+ let t1;
6998
+ $[2] !== t0 ? (t1 = {
6999
+ input: t0
7000
+ }, $[2] = t0, $[3] = t1) : t1 = $[3];
7001
+ const editorActor = react.useActorRef(editorMachine, t1);
7002
+ let t2, slateEditor, t3;
7003
+ $[4] !== editorActor ? (slateEditor = createSlateEditor({
6772
7004
  editorActor
6773
- }), editable = React.useMemo(() => createEditableAPI(slateEditor.instance, editorActor), [slateEditor.instance, editorActor]), send = React.useCallback((event) => {
7005
+ }), t3 = createEditableAPI(slateEditor.instance, editorActor), $[4] = editorActor, $[5] = slateEditor, $[6] = t3) : (slateEditor = $[5], t3 = $[6]);
7006
+ const editable = t3;
7007
+ let t4, t5;
7008
+ $[7] !== editorActor ? (t4 = (event) => {
6774
7009
  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]);
7010
+ }, t5 = (event_0, listener) => editorActor.on(event_0, listener), $[7] = editorActor, $[8] = t4, $[9] = t5) : (t4 = $[8], t5 = $[9]);
7011
+ let t6;
7012
+ $[10] !== editable || $[11] !== editorActor || $[12] !== slateEditor ? (t6 = {
7013
+ editable,
7014
+ editorActor,
7015
+ slateEditor
7016
+ }, $[10] = editable, $[11] = editorActor, $[12] = slateEditor, $[13] = t6) : t6 = $[13];
7017
+ let t7;
7018
+ return $[14] !== t4 || $[15] !== t5 || $[16] !== t6 ? (t7 = {
7019
+ send: t4,
7020
+ on: t5,
7021
+ _internal: t6
7022
+ }, $[14] = t4, $[15] = t5, $[16] = t6, $[17] = t7) : t7 = $[17], t2 = t7, t2;
6789
7023
  }
6790
7024
  function editorConfigToMachineInput(config) {
7025
+ var _a;
6791
7026
  return {
6792
7027
  behaviors: config.behaviors,
6793
- keyGenerator: config.keyGenerator ?? defaultKeyGenerator,
7028
+ keyGenerator: (_a = config.keyGenerator) != null ? _a : defaultKeyGenerator,
6794
7029
  maxBlocks: config.maxBlocks,
6795
7030
  readOnly: config.readOnly,
6796
7031
  schema: config.schemaDefinition ? compileSchemaDefinition(config.schemaDefinition) : getPortableTextMemberSchemaTypes(config.schema.hasOwnProperty("jsonType") ? config.schema : compileType(config.schema)),
@@ -6820,13 +7055,16 @@ function PortableTextEditorSelectionProvider(props) {
6820
7055
  let t2;
6821
7056
  return $[3] !== props.children || $[4] !== selection ? (t2 = /* @__PURE__ */ jsxRuntime.jsx(PortableTextEditorSelectionContext.Provider, { value: selection, children: props.children }), $[3] = props.children, $[4] = selection, $[5] = t2) : t2 = $[5], t2;
6822
7057
  }
7058
+ var __defProp$3 = Object.defineProperty, __defProps$3 = Object.defineProperties, __getOwnPropDescs$3 = Object.getOwnPropertyDescriptors, __getOwnPropSymbols$3 = Object.getOwnPropertySymbols, __hasOwnProp$3 = Object.prototype.hasOwnProperty, __propIsEnum$3 = Object.prototype.propertyIsEnumerable, __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: !0, configurable: !0, writable: !0, value }) : obj[key] = value, __spreadValues$3 = (a, b) => {
7059
+ for (var prop in b || (b = {}))
7060
+ __hasOwnProp$3.call(b, prop) && __defNormalProp$3(a, prop, b[prop]);
7061
+ if (__getOwnPropSymbols$3)
7062
+ for (var prop of __getOwnPropSymbols$3(b))
7063
+ __propIsEnum$3.call(b, prop) && __defNormalProp$3(a, prop, b[prop]);
7064
+ return a;
7065
+ }, __spreadProps$3 = (a, b) => __defProps$3(a, __getOwnPropDescs$3(b)), __publicField = (obj, key, value) => __defNormalProp$3(obj, typeof key != "symbol" ? key + "" : key, value);
6823
7066
  const debug$4 = debugWithName("component:PortableTextEditor");
6824
7067
  class PortableTextEditor extends React.Component {
6825
- static displayName = "PortableTextEditor";
6826
- /**
6827
- * An observable of all the editor changes.
6828
- */
6829
- change$ = new rxjs.Subject();
6830
7068
  /**
6831
7069
  * A lookup table for all the relevant schema types for this portable text type.
6832
7070
  */
@@ -6837,8 +7075,11 @@ class PortableTextEditor extends React.Component {
6837
7075
  * The editor API (currently implemented with Slate).
6838
7076
  */
6839
7077
  constructor(props) {
6840
- super(props), props.editor ? this.editor = props.editor : this.editor = createEditor({
6841
- keyGenerator: props.keyGenerator ?? defaultKeyGenerator,
7078
+ var _a;
7079
+ super(props), __publicField(this, "change$", new rxjs.Subject()), __publicField(this, "setEditable", (editable) => {
7080
+ this.editor._internal.editable = __spreadValues$3(__spreadValues$3({}, this.editor._internal.editable), editable);
7081
+ }), props.editor ? this.editor = props.editor : this.editor = createEditor({
7082
+ keyGenerator: (_a = props.keyGenerator) != null ? _a : defaultKeyGenerator,
6842
7083
  schema: props.schemaType,
6843
7084
  initialValue: props.value,
6844
7085
  maxBlocks: props.maxBlocks === void 0 ? void 0 : Number.parseInt(props.maxBlocks.toString(), 10),
@@ -6859,14 +7100,9 @@ class PortableTextEditor extends React.Component {
6859
7100
  value: this.props.value
6860
7101
  }), this.props.editorRef !== prevProps.editorRef && this.props.editorRef && (this.props.editorRef.current = this));
6861
7102
  }
6862
- setEditable = (editable) => {
6863
- this.editor._internal.editable = {
6864
- ...this.editor._internal.editable,
6865
- ...editable
6866
- };
6867
- };
6868
7103
  render() {
6869
- const legacyPatches = this.props.editor ? void 0 : this.props.incomingPatches$ ?? this.props.patches$;
7104
+ var _a;
7105
+ const legacyPatches = this.props.editor ? void 0 : (_a = this.props.incomingPatches$) != null ? _a : this.props.patches$;
6870
7106
  return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
6871
7107
  legacyPatches ? /* @__PURE__ */ jsxRuntime.jsx(RoutePatchesObservableToEditorActor, { editorActor: this.editor._internal.editorActor, patches$: legacyPatches }) : null,
6872
7108
  /* @__PURE__ */ jsxRuntime.jsx(RouteEventsToChanges, { editorActor: this.editor._internal.editorActor, onChange: (change) => {
@@ -6876,65 +7112,105 @@ class PortableTextEditor extends React.Component {
6876
7112
  /* @__PURE__ */ jsxRuntime.jsx(EditorActorContext.Provider, { value: this.editor._internal.editorActor, children: /* @__PURE__ */ jsxRuntime.jsx(slateReact.Slate, { editor: this.editor._internal.slateEditor.instance, initialValue: this.editor._internal.slateEditor.initialValue, children: /* @__PURE__ */ jsxRuntime.jsx(PortableTextEditorContext.Provider, { value: this, children: /* @__PURE__ */ jsxRuntime.jsx(PortableTextEditorSelectionProvider, { editorActor: this.editor._internal.editorActor, children: this.props.children }) }) }) })
6877
7113
  ] });
6878
7114
  }
6879
- // Static API methods
6880
- static activeAnnotations = (editor) => editor && editor.editable ? editor.editable.activeAnnotations() : [];
6881
- static isAnnotationActive = (editor, annotationType) => editor && editor.editable ? editor.editable.isAnnotationActive(annotationType) : !1;
6882
- static addAnnotation = (editor, type, value) => editor.editable?.addAnnotation(type, value);
6883
- static blur = (editor) => {
6884
- debug$4("Host blurred"), editor.editable?.blur();
6885
- };
6886
- static delete = (editor, selection, options) => editor.editable?.delete(selection, options);
6887
- static findDOMNode = (editor, element) => editor.editable?.findDOMNode(element);
6888
- static findByPath = (editor, path) => editor.editable?.findByPath(path) || [];
6889
- static focus = (editor) => {
6890
- debug$4("Host requesting focus"), editor.editable?.focus();
6891
- };
6892
- static focusBlock = (editor) => editor.editable?.focusBlock();
6893
- static focusChild = (editor) => editor.editable?.focusChild();
6894
- static getSelection = (editor) => editor.editable ? editor.editable.getSelection() : null;
6895
- static getValue = (editor) => editor.editable?.getValue();
6896
- static hasBlockStyle = (editor, blockStyle) => editor.editable?.hasBlockStyle(blockStyle);
6897
- static hasListStyle = (editor, listStyle) => editor.editable?.hasListStyle(listStyle);
6898
- static isCollapsedSelection = (editor) => editor.editable?.isCollapsedSelection();
6899
- static isExpandedSelection = (editor) => editor.editable?.isExpandedSelection();
6900
- static isMarkActive = (editor, mark) => editor.editable?.isMarkActive(mark);
6901
- static insertChild = (editor, type, value) => (debug$4("Host inserting child"), editor.editable?.insertChild(type, value));
6902
- static insertBlock = (editor, type, value) => editor.editable?.insertBlock(type, value);
6903
- static insertBreak = (editor) => editor.editable?.insertBreak();
6904
- static isVoid = (editor, element) => editor.editable?.isVoid(element);
6905
- static isObjectPath = (_editor, path) => {
6906
- if (!path || !Array.isArray(path)) return !1;
6907
- const isChildObjectEditPath = path.length > 3 && path[1] === "children";
6908
- return path.length > 1 && path[1] !== "children" || isChildObjectEditPath;
6909
- };
6910
- static marks = (editor) => editor.editable?.marks();
6911
- static select = (editor, selection) => {
6912
- debug$4("Host setting selection", selection), editor.editable?.select(selection);
6913
- };
6914
- static removeAnnotation = (editor, type) => editor.editable?.removeAnnotation(type);
6915
- static toggleBlockStyle = (editor, blockStyle) => (debug$4("Host is toggling block style"), editor.editable?.toggleBlockStyle(blockStyle));
6916
- static toggleList = (editor, listStyle) => editor.editable?.toggleList(listStyle);
6917
- static toggleMark = (editor, mark) => {
6918
- debug$4("Host toggling mark", mark), editor.editable?.toggleMark(mark);
6919
- };
6920
- static getFragment = (editor) => (debug$4("Host getting fragment"), editor.editable?.getFragment());
6921
- static undo = (editor) => {
6922
- debug$4("Host undoing"), editor.editable?.undo();
6923
- };
6924
- static redo = (editor) => {
6925
- debug$4("Host redoing"), editor.editable?.redo();
6926
- };
6927
- static isSelectionsOverlapping = (editor, selectionA, selectionB) => editor.editable?.isSelectionsOverlapping(selectionA, selectionB);
6928
7115
  }
7116
+ __publicField(PortableTextEditor, "displayName", "PortableTextEditor"), // Static API methods
7117
+ __publicField(PortableTextEditor, "activeAnnotations", (editor) => editor && editor.editable ? editor.editable.activeAnnotations() : []), __publicField(PortableTextEditor, "isAnnotationActive", (editor, annotationType) => editor && editor.editable ? editor.editable.isAnnotationActive(annotationType) : !1), __publicField(PortableTextEditor, "addAnnotation", (editor, type, value) => {
7118
+ var _a;
7119
+ return (_a = editor.editable) == null ? void 0 : _a.addAnnotation(type, value);
7120
+ }), __publicField(PortableTextEditor, "blur", (editor) => {
7121
+ var _a;
7122
+ debug$4("Host blurred"), (_a = editor.editable) == null || _a.blur();
7123
+ }), __publicField(PortableTextEditor, "delete", (editor, selection, options) => {
7124
+ var _a;
7125
+ return (_a = editor.editable) == null ? void 0 : _a.delete(selection, options);
7126
+ }), __publicField(PortableTextEditor, "findDOMNode", (editor, element) => {
7127
+ var _a;
7128
+ return (_a = editor.editable) == null ? void 0 : _a.findDOMNode(element);
7129
+ }), __publicField(PortableTextEditor, "findByPath", (editor, path) => {
7130
+ var _a;
7131
+ return ((_a = editor.editable) == null ? void 0 : _a.findByPath(path)) || [];
7132
+ }), __publicField(PortableTextEditor, "focus", (editor) => {
7133
+ var _a;
7134
+ debug$4("Host requesting focus"), (_a = editor.editable) == null || _a.focus();
7135
+ }), __publicField(PortableTextEditor, "focusBlock", (editor) => {
7136
+ var _a;
7137
+ return (_a = editor.editable) == null ? void 0 : _a.focusBlock();
7138
+ }), __publicField(PortableTextEditor, "focusChild", (editor) => {
7139
+ var _a;
7140
+ return (_a = editor.editable) == null ? void 0 : _a.focusChild();
7141
+ }), __publicField(PortableTextEditor, "getSelection", (editor) => editor.editable ? editor.editable.getSelection() : null), __publicField(PortableTextEditor, "getValue", (editor) => {
7142
+ var _a;
7143
+ return (_a = editor.editable) == null ? void 0 : _a.getValue();
7144
+ }), __publicField(PortableTextEditor, "hasBlockStyle", (editor, blockStyle) => {
7145
+ var _a;
7146
+ return (_a = editor.editable) == null ? void 0 : _a.hasBlockStyle(blockStyle);
7147
+ }), __publicField(PortableTextEditor, "hasListStyle", (editor, listStyle) => {
7148
+ var _a;
7149
+ return (_a = editor.editable) == null ? void 0 : _a.hasListStyle(listStyle);
7150
+ }), __publicField(PortableTextEditor, "isCollapsedSelection", (editor) => {
7151
+ var _a;
7152
+ return (_a = editor.editable) == null ? void 0 : _a.isCollapsedSelection();
7153
+ }), __publicField(PortableTextEditor, "isExpandedSelection", (editor) => {
7154
+ var _a;
7155
+ return (_a = editor.editable) == null ? void 0 : _a.isExpandedSelection();
7156
+ }), __publicField(PortableTextEditor, "isMarkActive", (editor, mark) => {
7157
+ var _a;
7158
+ return (_a = editor.editable) == null ? void 0 : _a.isMarkActive(mark);
7159
+ }), __publicField(PortableTextEditor, "insertChild", (editor, type, value) => {
7160
+ var _a;
7161
+ return debug$4("Host inserting child"), (_a = editor.editable) == null ? void 0 : _a.insertChild(type, value);
7162
+ }), __publicField(PortableTextEditor, "insertBlock", (editor, type, value) => {
7163
+ var _a;
7164
+ return (_a = editor.editable) == null ? void 0 : _a.insertBlock(type, value);
7165
+ }), __publicField(PortableTextEditor, "insertBreak", (editor) => {
7166
+ var _a;
7167
+ return (_a = editor.editable) == null ? void 0 : _a.insertBreak();
7168
+ }), __publicField(PortableTextEditor, "isVoid", (editor, element) => {
7169
+ var _a;
7170
+ return (_a = editor.editable) == null ? void 0 : _a.isVoid(element);
7171
+ }), __publicField(PortableTextEditor, "isObjectPath", (_editor, path) => {
7172
+ if (!path || !Array.isArray(path)) return !1;
7173
+ const isChildObjectEditPath = path.length > 3 && path[1] === "children";
7174
+ return path.length > 1 && path[1] !== "children" || isChildObjectEditPath;
7175
+ }), __publicField(PortableTextEditor, "marks", (editor) => {
7176
+ var _a;
7177
+ return (_a = editor.editable) == null ? void 0 : _a.marks();
7178
+ }), __publicField(PortableTextEditor, "select", (editor, selection) => {
7179
+ var _a;
7180
+ debug$4("Host setting selection", selection), (_a = editor.editable) == null || _a.select(selection);
7181
+ }), __publicField(PortableTextEditor, "removeAnnotation", (editor, type) => {
7182
+ var _a;
7183
+ return (_a = editor.editable) == null ? void 0 : _a.removeAnnotation(type);
7184
+ }), __publicField(PortableTextEditor, "toggleBlockStyle", (editor, blockStyle) => {
7185
+ var _a;
7186
+ return debug$4("Host is toggling block style"), (_a = editor.editable) == null ? void 0 : _a.toggleBlockStyle(blockStyle);
7187
+ }), __publicField(PortableTextEditor, "toggleList", (editor, listStyle) => {
7188
+ var _a;
7189
+ return (_a = editor.editable) == null ? void 0 : _a.toggleList(listStyle);
7190
+ }), __publicField(PortableTextEditor, "toggleMark", (editor, mark) => {
7191
+ var _a;
7192
+ debug$4("Host toggling mark", mark), (_a = editor.editable) == null || _a.toggleMark(mark);
7193
+ }), __publicField(PortableTextEditor, "getFragment", (editor) => {
7194
+ var _a;
7195
+ return debug$4("Host getting fragment"), (_a = editor.editable) == null ? void 0 : _a.getFragment();
7196
+ }), __publicField(PortableTextEditor, "undo", (editor) => {
7197
+ var _a;
7198
+ debug$4("Host undoing"), (_a = editor.editable) == null || _a.undo();
7199
+ }), __publicField(PortableTextEditor, "redo", (editor) => {
7200
+ var _a;
7201
+ debug$4("Host redoing"), (_a = editor.editable) == null || _a.redo();
7202
+ }), __publicField(PortableTextEditor, "isSelectionsOverlapping", (editor, selectionA, selectionB) => {
7203
+ var _a;
7204
+ return (_a = editor.editable) == null ? void 0 : _a.isSelectionsOverlapping(selectionA, selectionB);
7205
+ });
6929
7206
  function RoutePatchesObservableToEditorActor(props) {
6930
7207
  const $ = reactCompilerRuntime.c(4);
6931
7208
  let t0, t1;
6932
7209
  return $[0] !== props.editorActor || $[1] !== props.patches$ ? (t0 = () => {
6933
7210
  const subscription = props.patches$.subscribe((payload) => {
6934
- props.editorActor.send({
6935
- type: "patches",
6936
- ...payload
6937
- });
7211
+ props.editorActor.send(__spreadValues$3({
7212
+ type: "patches"
7213
+ }, payload));
6938
7214
  });
6939
7215
  return () => {
6940
7216
  subscription.unsubscribe();
@@ -6999,10 +7275,9 @@ function RouteEventsToChanges(props) {
6999
7275
  break bb5;
7000
7276
  }
7001
7277
  case "error": {
7002
- handleChange({
7003
- ...event,
7278
+ handleChange(__spreadProps$3(__spreadValues$3({}, event), {
7004
7279
  level: "warning"
7005
- });
7280
+ }));
7006
7281
  break bb5;
7007
7282
  }
7008
7283
  case "annotation.add":
@@ -7029,6 +7304,14 @@ function RouteEventsToChanges(props) {
7029
7304
  };
7030
7305
  }, t2 = [props.editorActor, handleChange], $[2] = handleChange, $[3] = props.editorActor, $[4] = t1, $[5] = t2) : (t1 = $[4], t2 = $[5]), React.useEffect(t1, t2), null;
7031
7306
  }
7307
+ var __defProp$2 = Object.defineProperty, __defProps$2 = Object.defineProperties, __getOwnPropDescs$2 = Object.getOwnPropertyDescriptors, __getOwnPropSymbols$2 = Object.getOwnPropertySymbols, __hasOwnProp$2 = Object.prototype.hasOwnProperty, __propIsEnum$2 = Object.prototype.propertyIsEnumerable, __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: !0, configurable: !0, writable: !0, value }) : obj[key] = value, __spreadValues$2 = (a, b) => {
7308
+ for (var prop in b || (b = {}))
7309
+ __hasOwnProp$2.call(b, prop) && __defNormalProp$2(a, prop, b[prop]);
7310
+ if (__getOwnPropSymbols$2)
7311
+ for (var prop of __getOwnPropSymbols$2(b))
7312
+ __propIsEnum$2.call(b, prop) && __defNormalProp$2(a, prop, b[prop]);
7313
+ return a;
7314
+ }, __spreadProps$2 = (a, b) => __defProps$2(a, __getOwnPropDescs$2(b));
7032
7315
  const debug$3 = debugWithName("components:Leaf"), EMPTY_MARKS = [], Leaf = (props) => {
7033
7316
  const {
7034
7317
  editorActor,
@@ -7040,10 +7323,13 @@ const debug$3 = debugWithName("components:Leaf"), EMPTY_MARKS = [], Leaf = (prop
7040
7323
  renderDecorator,
7041
7324
  renderAnnotation
7042
7325
  } = 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 ? [{
7043
- _key: block?._key
7326
+ _key: block == null ? void 0 : block._key
7044
7327
  }, "children", {
7045
7328
  _key: leaf._key
7046
- }] : [], [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;
7329
+ }] : [], [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) => {
7330
+ var _a;
7331
+ return !decoratorValues.includes(mark_0) && ((_a = block == null ? void 0 : block.markDefs) == null ? void 0 : _a.find((def) => def._key === mark_0));
7332
+ }).filter(Boolean), [annotationMarks, block, decoratorValues]), shouldTrackSelectionAndFocus = annotations.length > 0 && blockSelected;
7047
7333
  React.useEffect(() => {
7048
7334
  if (!shouldTrackSelectionAndFocus) {
7049
7335
  setFocused(!1);
@@ -7150,7 +7436,7 @@ const debug$3 = debugWithName("components:Leaf"), EMPTY_MARKS = [], Leaf = (prop
7150
7436
  }
7151
7437
  return returnedChildren;
7152
7438
  }, [annotations, block, children, focused, leaf, marks, path, renderAnnotation, renderChild, renderDecorator, schemaTypes.annotations, schemaTypes.decorators, schemaTypes.span, selected]);
7153
- return React.useMemo(() => /* @__PURE__ */ jsxRuntime.jsx("span", { ...attributes, ref: spanRef, children: content }, leaf._key), [leaf, attributes, content]);
7439
+ return React.useMemo(() => /* @__PURE__ */ jsxRuntime.jsx("span", __spreadProps$2(__spreadValues$2({}, attributes), { ref: spanRef, children: content }), leaf._key), [leaf, attributes, content]);
7154
7440
  };
7155
7441
  Leaf.displayName = "Leaf";
7156
7442
  const debug$2 = debugWithName("plugin:withHotKeys"), DEFAULT_HOTKEYS = {
@@ -7203,10 +7489,32 @@ function createWithHotkeys(editorActor, portableTextEditor, hotkeysFromOptions)
7203
7489
  }, editor;
7204
7490
  };
7205
7491
  }
7492
+ var __defProp$1 = Object.defineProperty, __defProps$1 = Object.defineProperties, __getOwnPropDescs$1 = Object.getOwnPropertyDescriptors, __getOwnPropSymbols$1 = Object.getOwnPropertySymbols, __hasOwnProp$1 = Object.prototype.hasOwnProperty, __propIsEnum$1 = Object.prototype.propertyIsEnumerable, __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: !0, configurable: !0, writable: !0, value }) : obj[key] = value, __spreadValues$1 = (a, b) => {
7493
+ for (var prop in b || (b = {}))
7494
+ __hasOwnProp$1.call(b, prop) && __defNormalProp$1(a, prop, b[prop]);
7495
+ if (__getOwnPropSymbols$1)
7496
+ for (var prop of __getOwnPropSymbols$1(b))
7497
+ __propIsEnum$1.call(b, prop) && __defNormalProp$1(a, prop, b[prop]);
7498
+ return a;
7499
+ }, __spreadProps$1 = (a, b) => __defProps$1(a, __getOwnPropDescs$1(b)), __objRest$1 = (source, exclude) => {
7500
+ var target = {};
7501
+ for (var prop in source)
7502
+ __hasOwnProp$1.call(source, prop) && exclude.indexOf(prop) < 0 && (target[prop] = source[prop]);
7503
+ if (source != null && __getOwnPropSymbols$1)
7504
+ for (var prop of __getOwnPropSymbols$1(source))
7505
+ exclude.indexOf(prop) < 0 && __propIsEnum$1.call(source, prop) && (target[prop] = source[prop]);
7506
+ return target;
7507
+ };
7206
7508
  const debug$1 = debugWithName("plugin:withInsertData");
7207
7509
  function createWithInsertData(editorActor, schemaTypes) {
7208
7510
  return function(editor) {
7209
- const blockTypeName = schemaTypes.block.name, spanTypeName = schemaTypes.span.name, whitespaceOnPasteMode = schemaTypes.block.options.unstable_whitespaceOnPasteMode, toPlainText = (blocks) => blocks.map((block) => editor.isTextBlock(block) ? block.children.map((child) => child._type === spanTypeName ? child.text : `[${schemaTypes.inlineObjects.find((t) => t.name === child._type)?.title || "Object"}]`).join("") : `[${schemaTypes.blockObjects.find((t) => t.name === block._type)?.title || "Object"}]`).join(`
7511
+ const blockTypeName = schemaTypes.block.name, spanTypeName = schemaTypes.span.name, whitespaceOnPasteMode = schemaTypes.block.options.unstable_whitespaceOnPasteMode, toPlainText = (blocks) => blocks.map((block) => {
7512
+ var _a;
7513
+ return editor.isTextBlock(block) ? block.children.map((child) => {
7514
+ var _a2;
7515
+ return child._type === spanTypeName ? child.text : `[${((_a2 = schemaTypes.inlineObjects.find((t) => t.name === child._type)) == null ? void 0 : _a2.title) || "Object"}]`;
7516
+ }).join("") : `[${((_a = schemaTypes.blockObjects.find((t) => t.name === block._type)) == null ? void 0 : _a.title) || "Object"}]`;
7517
+ }).join(`
7210
7518
 
7211
7519
  `);
7212
7520
  return editor.setFragmentData = (data, originEvent) => {
@@ -7244,6 +7552,7 @@ function createWithInsertData(editorActor, schemaTypes) {
7244
7552
  const fragment = editor.getFragment(), portableText = fromSlateValue(fragment, blockTypeName), asJSON = JSON.stringify(portableText), asPlainText = toPlainText(portableText);
7245
7553
  data.clearData(), data.setData("text/plain", asPlainText), data.setData("text/html", asHTML), data.setData("application/json", asJSON), data.setData("application/x-portable-text", asJSON), debug$1("text", asPlainText), data.setData("application/x-portable-text-event-origin", originEvent || "external"), debug$1("Set fragment data", asJSON, asHTML);
7246
7554
  }, editor.insertPortableTextData = (data) => {
7555
+ var _a, _b;
7247
7556
  if (!editor.selection)
7248
7557
  return !1;
7249
7558
  const pText = data.getData("application/x-portable-text"), origin = data.getData("application/x-portable-text-event-origin");
@@ -7253,8 +7562,8 @@ function createWithInsertData(editorActor, schemaTypes) {
7253
7562
  const slateValue = _regenerateKeys(editor, toSlateValue(parsed, {
7254
7563
  schemaTypes
7255
7564
  }), editorActor.getSnapshot().context.keyGenerator, spanTypeName, schemaTypes), validation = validateValue(parsed, schemaTypes, editorActor.getSnapshot().context.keyGenerator);
7256
- if (!validation.valid && !validation.resolution?.autoResolve) {
7257
- const errorDescription = `${validation.resolution?.description}`;
7565
+ if (!validation.valid && !((_a = validation.resolution) != null && _a.autoResolve)) {
7566
+ const errorDescription = `${(_b = validation.resolution) == null ? void 0 : _b.description}`;
7258
7567
  return editorActor.send({
7259
7568
  type: "error",
7260
7569
  name: "pasteError",
@@ -7267,6 +7576,7 @@ function createWithInsertData(editorActor, schemaTypes) {
7267
7576
  }
7268
7577
  return !1;
7269
7578
  }, editor.insertTextOrHTMLData = (data) => {
7579
+ var _a;
7270
7580
  if (!editor.selection)
7271
7581
  return debug$1("No selection, not inserting"), !1;
7272
7582
  const html = data.getData("text/html"), text = data.getData("text/plain");
@@ -7293,7 +7603,7 @@ function createWithInsertData(editorActor, schemaTypes) {
7293
7603
  const validation = validateValue(portableText, schemaTypes, editorActor.getSnapshot().context.keyGenerator);
7294
7604
  if (!validation.valid) {
7295
7605
  const errorDescription = `Could not validate the resulting portable text to insert.
7296
- ${validation.resolution?.description}
7606
+ ${(_a = validation.resolution) == null ? void 0 : _a.description}
7297
7607
  Try to insert as plain text (shift-paste) instead.`;
7298
7608
  return editorActor.send({
7299
7609
  type: "error",
@@ -7332,46 +7642,37 @@ function escapeHtml(str) {
7332
7642
  }
7333
7643
  function _regenerateKeys(editor, fragment, keyGenerator, spanTypeName, editorTypes) {
7334
7644
  return fragment.map((node) => {
7335
- const newNode = {
7336
- ...node
7337
- };
7645
+ const newNode = __spreadValues$1({}, node);
7338
7646
  if (editor.isTextBlock(newNode)) {
7339
7647
  const annotations = editorTypes.annotations.map((t) => t.name);
7340
7648
  if (annotations.length === 0) {
7341
- const {
7342
- markDefs,
7343
- ...NewNodeNoDefs
7344
- } = newNode;
7345
- return {
7346
- ...NewNodeNoDefs,
7649
+ const _a = newNode, NewNodeNoDefs = __objRest$1(_a, [
7650
+ "markDefs"
7651
+ ]);
7652
+ return __spreadProps$1(__spreadValues$1({}, NewNodeNoDefs), {
7347
7653
  _key: keyGenerator()
7348
- };
7654
+ });
7349
7655
  }
7350
7656
  if ((newNode.markDefs || []).some((def) => !annotations.includes(def._type))) {
7351
7657
  const allowedAnnotations = (newNode.markDefs || []).filter((def) => annotations.includes(def._type));
7352
- return {
7353
- ...newNode,
7658
+ return __spreadProps$1(__spreadValues$1({}, newNode), {
7354
7659
  markDefs: allowedAnnotations,
7355
7660
  _key: keyGenerator()
7356
- };
7661
+ });
7357
7662
  }
7358
7663
  newNode.markDefs = (newNode.markDefs || []).map((def) => {
7359
7664
  const oldKey = def._key, newKey = keyGenerator();
7360
- return newNode.children = newNode.children.map((child) => child._type === spanTypeName && editor.isTextSpan(child) ? {
7361
- ...child,
7665
+ return newNode.children = newNode.children.map((child) => child._type === spanTypeName && editor.isTextSpan(child) ? __spreadProps$1(__spreadValues$1({}, child), {
7362
7666
  marks: child.marks && child.marks.includes(oldKey) ? [...child.marks].filter((mark) => mark !== oldKey).concat(newKey) : child.marks
7363
- } : child), {
7364
- ...def,
7667
+ }) : child), __spreadProps$1(__spreadValues$1({}, def), {
7365
7668
  _key: newKey
7366
- };
7669
+ });
7367
7670
  });
7368
7671
  }
7369
- const nodeWithNewKeys = {
7370
- ...newNode,
7672
+ const nodeWithNewKeys = __spreadProps$1(__spreadValues$1({}, newNode), {
7371
7673
  _key: keyGenerator()
7372
- };
7373
- return editor.isTextBlock(nodeWithNewKeys) && (nodeWithNewKeys.children = nodeWithNewKeys.children.map((child) => ({
7374
- ...child,
7674
+ });
7675
+ return editor.isTextBlock(nodeWithNewKeys) && (nodeWithNewKeys.children = nodeWithNewKeys.children.map((child) => __spreadProps$1(__spreadValues$1({}, child), {
7375
7676
  _key: keyGenerator()
7376
7677
  }))), nodeWithNewKeys;
7377
7678
  });
@@ -7410,6 +7711,22 @@ function withSyncRangeDecorations(slateEditor, syncRangeDecorations) {
7410
7711
  slateEditor.apply = originalApply;
7411
7712
  };
7412
7713
  }
7714
+ var __defProp2 = Object.defineProperty, __defProps = Object.defineProperties, __getOwnPropDescs = Object.getOwnPropertyDescriptors, __getOwnPropSymbols2 = Object.getOwnPropertySymbols, __hasOwnProp2 = Object.prototype.hasOwnProperty, __propIsEnum2 = Object.prototype.propertyIsEnumerable, __defNormalProp2 = (obj, key, value) => key in obj ? __defProp2(obj, key, { enumerable: !0, configurable: !0, writable: !0, value }) : obj[key] = value, __spreadValues2 = (a, b) => {
7715
+ for (var prop in b || (b = {}))
7716
+ __hasOwnProp2.call(b, prop) && __defNormalProp2(a, prop, b[prop]);
7717
+ if (__getOwnPropSymbols2)
7718
+ for (var prop of __getOwnPropSymbols2(b))
7719
+ __propIsEnum2.call(b, prop) && __defNormalProp2(a, prop, b[prop]);
7720
+ return a;
7721
+ }, __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b)), __objRest = (source, exclude) => {
7722
+ var target = {};
7723
+ for (var prop in source)
7724
+ __hasOwnProp2.call(source, prop) && exclude.indexOf(prop) < 0 && (target[prop] = source[prop]);
7725
+ if (source != null && __getOwnPropSymbols2)
7726
+ for (var prop of __getOwnPropSymbols2(source))
7727
+ exclude.indexOf(prop) < 0 && __propIsEnum2.call(source, prop) && (target[prop] = source[prop]);
7728
+ return target;
7729
+ };
7413
7730
  const debug = debugWithName("component:Editable"), PLACEHOLDER_STYLE = {
7414
7731
  position: "absolute",
7415
7732
  userSelect: "none",
@@ -7417,7 +7734,7 @@ const debug = debugWithName("component:Editable"), PLACEHOLDER_STYLE = {
7417
7734
  left: 0,
7418
7735
  right: 0
7419
7736
  }, PortableTextEditable = React.forwardRef(function(props, forwardedRef) {
7420
- const {
7737
+ const _a = props, {
7421
7738
  hotkeys,
7422
7739
  onBlur,
7423
7740
  onFocus,
@@ -7435,9 +7752,27 @@ const debug = debugWithName("component:Editable"), PLACEHOLDER_STYLE = {
7435
7752
  renderStyle,
7436
7753
  selection: propsSelection,
7437
7754
  scrollSelectionIntoView,
7438
- spellCheck,
7439
- ...restProps
7440
- } = props, portableTextEditor = usePortableTextEditor(), ref = React.useRef(null), [editableElement, setEditableElement] = React.useState(null), [hasInvalidValue, setHasInvalidValue] = React.useState(!1), [rangeDecorationState, setRangeDecorationsState] = React.useState([]);
7755
+ spellCheck
7756
+ } = _a, restProps = __objRest(_a, [
7757
+ "hotkeys",
7758
+ "onBlur",
7759
+ "onFocus",
7760
+ "onBeforeInput",
7761
+ "onPaste",
7762
+ "onCopy",
7763
+ "onClick",
7764
+ "rangeDecorations",
7765
+ "renderAnnotation",
7766
+ "renderBlock",
7767
+ "renderChild",
7768
+ "renderDecorator",
7769
+ "renderListItem",
7770
+ "renderPlaceholder",
7771
+ "renderStyle",
7772
+ "selection",
7773
+ "scrollSelectionIntoView",
7774
+ "spellCheck"
7775
+ ]), portableTextEditor = usePortableTextEditor(), ref = React.useRef(null), [editableElement, setEditableElement] = React.useState(null), [hasInvalidValue, setHasInvalidValue] = React.useState(!1), [rangeDecorationState, setRangeDecorationsState] = React.useState([]);
7441
7776
  React.useImperativeHandle(forwardedRef, () => ref.current);
7442
7777
  const rangeDecorationsRef = React.useRef(rangeDecorations), editorActor = React.useContext(EditorActorContext), readOnly = react.useSelector(editorActor, (s) => s.context.readOnly), schemaTypes = react.useSelector(editorActor, (s_0) => s_0.context.schema), slateEditor = slateReact.useSlate(), blockTypeName = schemaTypes.block.name;
7443
7778
  React.useMemo(() => {
@@ -7447,9 +7782,9 @@ const debug = debugWithName("component:Editable"), PLACEHOLDER_STYLE = {
7447
7782
  const withHotKeys = createWithHotkeys(editorActor, portableTextEditor, hotkeys);
7448
7783
  return debug("Editable is in edit mode"), withInsertData(withHotKeys(slateEditor));
7449
7784
  }, [editorActor, hotkeys, portableTextEditor, readOnly, schemaTypes, slateEditor]);
7450
- 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) => {
7785
+ const renderElement = React.useCallback((eProps) => /* @__PURE__ */ jsxRuntime.jsx(Element, __spreadProps(__spreadValues2({}, eProps), { readOnly, renderBlock, renderChild, renderListItem, renderStyle, schemaTypes, spellCheck })), [schemaTypes, spellCheck, readOnly, renderBlock, renderChild, renderListItem, renderStyle]), renderLeaf = React.useCallback((lProps) => {
7451
7786
  if (lProps.leaf._type === "span") {
7452
- let rendered = /* @__PURE__ */ jsxRuntime.jsx(Leaf, { ...lProps, editorActor, schemaTypes, renderAnnotation, renderChild, renderDecorator, readOnly });
7787
+ let rendered = /* @__PURE__ */ jsxRuntime.jsx(Leaf, __spreadProps(__spreadValues2({}, lProps), { editorActor, schemaTypes, renderAnnotation, renderChild, renderDecorator, readOnly }));
7453
7788
  if (renderPlaceholder && lProps.leaf.placeholder && lProps.text.text === "")
7454
7789
  return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
7455
7790
  /* @__PURE__ */ jsxRuntime.jsx("span", { style: PLACEHOLDER_STYLE, contentEditable: !1, children: renderPlaceholder() }),
@@ -7496,10 +7831,9 @@ const debug = debugWithName("component:Editable"), PLACEHOLDER_STYLE = {
7496
7831
  origin: "local"
7497
7832
  });
7498
7833
  }
7499
- newRange !== null && newSlateRanges.push({
7500
- ...newRange || slateRange_0,
7834
+ newRange !== null && newSlateRanges.push(__spreadProps(__spreadValues2({}, newRange || slateRange_0), {
7501
7835
  rangeDecoration: rangeDecorationItem
7502
- });
7836
+ }));
7503
7837
  }), newSlateRanges.length > 0) {
7504
7838
  setRangeDecorationsState(newSlateRanges);
7505
7839
  return;
@@ -7541,7 +7875,7 @@ const debug = debugWithName("component:Editable"), PLACEHOLDER_STYLE = {
7541
7875
  nativeEvent: event
7542
7876
  });
7543
7877
  }, [onCopy, editorActor, slateEditor]), handlePaste = React.useCallback((event_0) => {
7544
- const value_0 = PortableTextEditor.getValue(portableTextEditor), path = toPortableTextRange(value_0, slateEditor.selection, schemaTypes)?.focus.path || [], onPasteResult = onPaste?.({
7878
+ const value_0 = PortableTextEditor.getValue(portableTextEditor), ptRange = toPortableTextRange(value_0, slateEditor.selection, schemaTypes), path = (ptRange == null ? void 0 : ptRange.focus.path) || [], onPasteResult = onPaste == null ? void 0 : onPaste({
7545
7879
  event: event_0,
7546
7880
  value: value_0,
7547
7881
  path,
@@ -7606,8 +7940,8 @@ const debug = debugWithName("component:Editable"), PLACEHOLDER_STYLE = {
7606
7940
  const existingDOMRange = domSelection.getRangeAt(0);
7607
7941
  try {
7608
7942
  const newDOMRange = slateReact.ReactEditor.toDOMRange(slateEditor, slateEditor.selection);
7609
- (newDOMRange.startOffset !== existingDOMRange.startOffset || newDOMRange.endOffset !== existingDOMRange.endOffset) && (debug("DOM range out of sync, validating selection"), domSelection?.removeAllRanges(), domSelection.addRange(newDOMRange));
7610
- } catch {
7943
+ (newDOMRange.startOffset !== existingDOMRange.startOffset || newDOMRange.endOffset !== existingDOMRange.endOffset) && (debug("DOM range out of sync, validating selection"), domSelection == null || domSelection.removeAllRanges(), domSelection.addRange(newDOMRange));
7944
+ } catch (e) {
7611
7945
  debug("Could not resolve selection, selecting top document"), slate.Transforms.deselect(slateEditor), slateEditor.children.length > 0 && slate.Transforms.select(slateEditor, [0, 0]), slateEditor.onChange();
7612
7946
  }
7613
7947
  }, [ref, slateEditor]);
@@ -7695,8 +8029,7 @@ const debug = debugWithName("component:Editable"), PLACEHOLDER_STYLE = {
7695
8029
  ref.current = slateReact.ReactEditor.toDOMNode(slateEditor, slateEditor), setEditableElement(ref.current);
7696
8030
  }, [slateEditor, ref]), portableTextEditor ? hasInvalidValue ? null : /* @__PURE__ */ jsxRuntime.jsx(
7697
8031
  slateReact.Editable,
7698
- {
7699
- ...restProps,
8032
+ __spreadProps(__spreadValues2({}, restProps), {
7700
8033
  autoFocus: !1,
7701
8034
  className: restProps.className || "pt-editable",
7702
8035
  decorate,
@@ -7713,7 +8046,7 @@ const debug = debugWithName("component:Editable"), PLACEHOLDER_STYLE = {
7713
8046
  renderElement,
7714
8047
  renderLeaf,
7715
8048
  scrollSelectionIntoView: scrollSelectionIntoViewToSlate
7716
- }
8049
+ })
7717
8050
  ) : null;
7718
8051
  });
7719
8052
  PortableTextEditable.displayName = "ForwardRef(PortableTextEditable)";