@portabletext/editor 1.3.1 → 1.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/index.js CHANGED
@@ -1,10 +1,250 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: !0 });
3
- var jsxRuntime = require("react/jsx-runtime"), isEqual = require("lodash/isEqual.js"), noop = require("lodash/noop.js"), react = require("react"), slate = require("slate"), slateReact = require("slate-react"), debug$m = require("debug"), types = require("@sanity/types"), reactCompilerRuntime = require("react-compiler-runtime"), styledComponents = require("styled-components"), uniq = require("lodash/uniq.js"), rxjs = require("rxjs"), xstate = require("xstate"), schema = require("@sanity/schema"), patches = require("@portabletext/patches"), get = require("lodash/get.js"), isUndefined = require("lodash/isUndefined.js"), omitBy = require("lodash/omitBy.js"), flatten = require("lodash/flatten.js"), isHotkeyEsm = require("is-hotkey-esm"), blockTools = require("@sanity/block-tools"), isPlainObject = require("lodash/isPlainObject.js"), throttle = require("lodash/throttle.js"), useEffectEvent = require("use-effect-event"), debounce = require("lodash/debounce.js"), content = require("@sanity/util/content");
3
+ var types = require("@sanity/types"), jsxRuntime = require("react/jsx-runtime"), isEqual = require("lodash/isEqual.js"), noop = require("lodash/noop.js"), react = require("react"), slate = require("slate"), slateReact = require("slate-react"), debug$m = require("debug"), reactCompilerRuntime = require("react-compiler-runtime"), styledComponents = require("styled-components"), uniq = require("lodash/uniq.js"), rxjs = require("rxjs"), xstate = require("xstate"), schema = require("@sanity/schema"), patches = require("@portabletext/patches"), get = require("lodash/get.js"), isUndefined = require("lodash/isUndefined.js"), omitBy = require("lodash/omitBy.js"), flatten = require("lodash/flatten.js"), isHotkeyEsm = require("is-hotkey-esm"), blockTools = require("@sanity/block-tools"), isPlainObject = require("lodash/isPlainObject.js"), throttle = require("lodash/throttle.js"), useEffectEvent = require("use-effect-event"), debounce = require("lodash/debounce.js"), content = require("@sanity/util/content"), react$1 = require("@xstate/react");
4
4
  function _interopDefaultCompat(e) {
5
5
  return e && typeof e == "object" && "default" in e ? e : { default: e };
6
6
  }
7
7
  var isEqual__default = /* @__PURE__ */ _interopDefaultCompat(isEqual), noop__default = /* @__PURE__ */ _interopDefaultCompat(noop), debug__default = /* @__PURE__ */ _interopDefaultCompat(debug$m), uniq__default = /* @__PURE__ */ _interopDefaultCompat(uniq), get__default = /* @__PURE__ */ _interopDefaultCompat(get), isUndefined__default = /* @__PURE__ */ _interopDefaultCompat(isUndefined), omitBy__default = /* @__PURE__ */ _interopDefaultCompat(omitBy), flatten__default = /* @__PURE__ */ _interopDefaultCompat(flatten), isPlainObject__default = /* @__PURE__ */ _interopDefaultCompat(isPlainObject), throttle__default = /* @__PURE__ */ _interopDefaultCompat(throttle), debounce__default = /* @__PURE__ */ _interopDefaultCompat(debounce);
8
+ function defineBehavior(behavior) {
9
+ return behavior;
10
+ }
11
+ function selectionIsCollapsed(context) {
12
+ return context.selection?.anchor.path.join() === context.selection?.focus.path.join() && context.selection?.anchor.offset === context.selection?.focus.offset;
13
+ }
14
+ function getFocusBlock(context) {
15
+ const key = context.selection && types.isKeySegment(context.selection.focus.path[0]) ? context.selection.focus.path[0]._key : void 0, node = key ? context.value.find((block) => block._key === key) : void 0;
16
+ return node && key ? {
17
+ node,
18
+ path: [{
19
+ _key: key
20
+ }]
21
+ } : void 0;
22
+ }
23
+ function getFocusTextBlock(context) {
24
+ const focusBlock = getFocusBlock(context);
25
+ return focusBlock && types.isPortableTextTextBlock(focusBlock.node) ? {
26
+ node: focusBlock.node,
27
+ path: focusBlock.path
28
+ } : void 0;
29
+ }
30
+ function getFocusBlockObject(context) {
31
+ const focusBlock = getFocusBlock(context);
32
+ return focusBlock && !types.isPortableTextTextBlock(focusBlock.node) ? {
33
+ node: focusBlock.node,
34
+ path: focusBlock.path
35
+ } : void 0;
36
+ }
37
+ function getFocusChild(context) {
38
+ const focusBlock = getFocusTextBlock(context);
39
+ if (!focusBlock)
40
+ return;
41
+ const key = context.selection && types.isKeySegment(context.selection.focus.path[2]) ? context.selection.focus.path[2]._key : void 0, node = key ? focusBlock.node.children.find((span) => span._key === key) : void 0;
42
+ return node && key ? {
43
+ node,
44
+ path: [...focusBlock.path, "children", {
45
+ _key: key
46
+ }]
47
+ } : void 0;
48
+ }
49
+ function getFocusSpan(context) {
50
+ const focusChild = getFocusChild(context);
51
+ return focusChild && types.isPortableTextSpan(focusChild.node) ? {
52
+ node: focusChild.node,
53
+ path: focusChild.path
54
+ } : void 0;
55
+ }
56
+ function getSelectionStartBlock(context) {
57
+ const key = context.selection.backward ? types.isKeySegment(context.selection.focus.path[0]) ? context.selection.focus.path[0]._key : void 0 : types.isKeySegment(context.selection.anchor.path[0]) ? context.selection.anchor.path[0]._key : void 0, node = key ? context.value.find((block) => block._key === key) : void 0;
58
+ return node && key ? {
59
+ node,
60
+ path: [{
61
+ _key: key
62
+ }]
63
+ } : void 0;
64
+ }
65
+ function getSelectionEndBlock(context) {
66
+ const key = context.selection.backward ? types.isKeySegment(context.selection.anchor.path[0]) ? context.selection.anchor.path[0]._key : void 0 : types.isKeySegment(context.selection.focus.path[0]) ? context.selection.focus.path[0]._key : void 0, node = key ? context.value.find((block) => block._key === key) : void 0;
67
+ return node && key ? {
68
+ node,
69
+ path: [{
70
+ _key: key
71
+ }]
72
+ } : void 0;
73
+ }
74
+ function getPreviousBlock(context) {
75
+ let previousBlock;
76
+ const selectionStartBlock = getSelectionStartBlock(context);
77
+ if (!selectionStartBlock)
78
+ return;
79
+ let foundSelectionStartBlock = !1;
80
+ for (const block of context.value) {
81
+ if (block._key === selectionStartBlock.node._key) {
82
+ foundSelectionStartBlock = !0;
83
+ break;
84
+ }
85
+ previousBlock = {
86
+ node: block,
87
+ path: [{
88
+ _key: block._key
89
+ }]
90
+ };
91
+ }
92
+ if (foundSelectionStartBlock && previousBlock)
93
+ return previousBlock;
94
+ }
95
+ function getNextBlock(context) {
96
+ let nextBlock;
97
+ const selectionEndBlock = getSelectionEndBlock(context);
98
+ if (!selectionEndBlock)
99
+ return;
100
+ let foundSelectionEndBlock = !1;
101
+ for (const block of context.value) {
102
+ if (block._key === selectionEndBlock.node._key) {
103
+ foundSelectionEndBlock = !0;
104
+ continue;
105
+ }
106
+ if (foundSelectionEndBlock) {
107
+ nextBlock = {
108
+ node: block,
109
+ path: [{
110
+ _key: block._key
111
+ }]
112
+ };
113
+ break;
114
+ }
115
+ }
116
+ if (foundSelectionEndBlock && nextBlock)
117
+ return nextBlock;
118
+ }
119
+ function isEmptyTextBlock(block) {
120
+ return block.children.length === 1 && block.children[0].text === "";
121
+ }
122
+ function createMarkdownBehaviors(config) {
123
+ const automaticStyleOnSpace = {
124
+ on: "insert text",
125
+ guard: ({
126
+ context,
127
+ event
128
+ }) => {
129
+ if (event.text !== " ")
130
+ return !1;
131
+ const selectionCollapsed = selectionIsCollapsed(context), focusTextBlock = getFocusTextBlock(context), focusSpan = getFocusSpan(context);
132
+ if (!selectionCollapsed || !focusTextBlock || !focusSpan)
133
+ return !1;
134
+ const looksLikeMarkdownHeading = /^#+/.test(focusSpan.node.text), headingStyle = config.mapHeadingStyle(context.schema, focusSpan.node.text.length), looksLikeMarkdownQuote = /^>/.test(focusSpan.node.text), blockquoteStyle = config.mapBlockquoteStyle(context.schema);
135
+ return looksLikeMarkdownHeading && headingStyle !== void 0 ? {
136
+ focusTextBlock,
137
+ focusSpan,
138
+ style: headingStyle
139
+ } : looksLikeMarkdownQuote && blockquoteStyle !== void 0 ? {
140
+ focusTextBlock,
141
+ focusSpan,
142
+ style: blockquoteStyle
143
+ } : !1;
144
+ },
145
+ actions: [() => [{
146
+ type: "insert text",
147
+ text: " "
148
+ }], (_, {
149
+ focusTextBlock,
150
+ focusSpan,
151
+ style
152
+ }) => [{
153
+ type: "set block",
154
+ style,
155
+ paths: [focusTextBlock.path]
156
+ }, {
157
+ type: "delete",
158
+ selection: {
159
+ anchor: {
160
+ path: focusSpan.path,
161
+ offset: 0
162
+ },
163
+ focus: {
164
+ path: focusSpan.path,
165
+ offset: focusSpan.node.text.length + 1
166
+ }
167
+ }
168
+ }]]
169
+ }, clearStyleOnBackspace = {
170
+ on: "delete backward",
171
+ guard: ({
172
+ context
173
+ }) => {
174
+ const selectionCollapsed = selectionIsCollapsed(context), focusTextBlock = getFocusTextBlock(context), focusSpan = getFocusSpan(context);
175
+ if (!selectionCollapsed || !focusTextBlock || !focusSpan)
176
+ return !1;
177
+ const defaultStyle = config.mapDefaultStyle(context.schema);
178
+ return defaultStyle && focusTextBlock.node.children.length === 1 && focusTextBlock.node.style !== config.mapDefaultStyle(context.schema) && focusSpan.node.text === "" ? {
179
+ defaultStyle,
180
+ focusTextBlock
181
+ } : !1;
182
+ },
183
+ actions: [(_, {
184
+ defaultStyle,
185
+ focusTextBlock
186
+ }) => [{
187
+ type: "set block",
188
+ style: defaultStyle,
189
+ paths: [focusTextBlock.path]
190
+ }]]
191
+ }, automaticListOnSpace = {
192
+ on: "insert text",
193
+ guard: ({
194
+ context,
195
+ event
196
+ }) => {
197
+ if (event.text !== " ")
198
+ return !1;
199
+ const selectionCollapsed = selectionIsCollapsed(context), focusTextBlock = getFocusTextBlock(context), focusSpan = getFocusSpan(context);
200
+ if (!selectionCollapsed || !focusTextBlock || !focusSpan)
201
+ return !1;
202
+ const looksLikeUnorderedList = /^-/.test(focusSpan.node.text), unorderedListStyle = config.mapUnorderedListStyle(context.schema);
203
+ if (looksLikeUnorderedList && unorderedListStyle !== void 0)
204
+ return {
205
+ focusTextBlock,
206
+ focusSpan,
207
+ listItem: unorderedListStyle
208
+ };
209
+ const looksLikeOrderedList = /^1./.test(focusSpan.node.text), orderedListStyle = config.mapOrderedListStyle(context.schema);
210
+ return looksLikeOrderedList && orderedListStyle !== void 0 ? {
211
+ focusTextBlock,
212
+ focusSpan,
213
+ listItem: orderedListStyle
214
+ } : !1;
215
+ },
216
+ actions: [() => [{
217
+ type: "insert text",
218
+ text: " "
219
+ }], (_, {
220
+ focusTextBlock,
221
+ focusSpan,
222
+ listItem
223
+ }) => [{
224
+ type: "unset block",
225
+ props: ["style"],
226
+ paths: [focusTextBlock.path]
227
+ }, {
228
+ type: "set block",
229
+ listItem,
230
+ level: 1,
231
+ paths: [focusTextBlock.path]
232
+ }, {
233
+ type: "delete",
234
+ selection: {
235
+ anchor: {
236
+ path: focusSpan.path,
237
+ offset: 0
238
+ },
239
+ focus: {
240
+ path: focusSpan.path,
241
+ offset: focusSpan.node.text.length + 1
242
+ }
243
+ }
244
+ }]]
245
+ };
246
+ return [automaticStyleOnSpace, clearStyleOnBackspace, automaticListOnSpace];
247
+ }
8
248
  const rootName = "sanity-pte:";
9
249
  debug__default.default(rootName);
10
250
  function debugWithName(name) {
@@ -641,360 +881,119 @@ const EMPTY_ANNOTATIONS = [], inlineBlockStyle = {
641
881
  get() {
642
882
  return console.warn("Property 'type' is deprecated, use 'schemaType' instead."), schemaTypes.block;
643
883
  }
644
- }), propsOrDefaultRendered = renderBlock ? renderBlock(renderProps) : children;
645
- 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);
646
- }
647
- const schemaType_0 = schemaTypes.blockObjects.find((_type_0) => _type_0.name === element._type);
648
- if (!schemaType_0)
649
- throw new Error(`Could not find schema type for block element of _type ${element._type}`);
650
- className = "pt-block pt-object-block";
651
- const block_0 = fromSlateValue([element], schemaTypes.block.name, KEY_TO_VALUE_ELEMENT.get(editor))[0];
652
- let renderedBlockFromProps;
653
- if (renderBlock) {
654
- const _props = Object.defineProperty({
655
- children: /* @__PURE__ */ jsxRuntime.jsx(DefaultObject, { value }),
656
- editorElementRef: blockRef,
657
- focused,
658
- path: blockPath,
659
- schemaType: schemaType_0,
660
- selected,
661
- value: block_0
662
- }, "type", {
663
- enumerable: !1,
664
- get() {
665
- return console.warn("Property 'type' is deprecated, use 'schemaType' instead."), schemaType_0;
666
- }
667
- });
668
- renderedBlockFromProps = renderBlock(_props);
669
- }
670
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { ...attributes, className, children: [
671
- children,
672
- /* @__PURE__ */ jsxRuntime.jsxs(DraggableBlock, { element, readOnly, blockRef, children: [
673
- renderedBlockFromProps && /* @__PURE__ */ jsxRuntime.jsx("div", { ref: blockRef, contentEditable: !1, children: renderedBlockFromProps }),
674
- !renderedBlockFromProps && /* @__PURE__ */ jsxRuntime.jsx(DefaultBlockObject, { selected, children: /* @__PURE__ */ jsxRuntime.jsx(DefaultObject, { value }) })
675
- ] })
676
- ] }, element._key);
677
- };
678
- Element.displayName = "Element";
679
- const PortableTextEditorContext = react.createContext(null), usePortableTextEditor = () => {
680
- const editor = react.useContext(PortableTextEditorContext);
681
- if (!editor)
682
- throw new Error("The `usePortableTextEditor` hook must be used inside the <PortableTextEditor> component's context.");
683
- return editor;
684
- };
685
- function DefaultAnnotation(props) {
686
- const $ = reactCompilerRuntime.c(6);
687
- let t0;
688
- $[0] !== props.annotation ? (t0 = () => alert(JSON.stringify(props.annotation)), $[0] = props.annotation, $[1] = t0) : t0 = $[1];
689
- const handleClick = t0;
690
- let t1;
691
- $[2] === Symbol.for("react.memo_cache_sentinel") ? (t1 = {
692
- color: "blue"
693
- }, $[2] = t1) : t1 = $[2];
694
- let t2;
695
- return $[3] !== handleClick || $[4] !== props.children ? (t2 = /* @__PURE__ */ jsxRuntime.jsx("span", { style: t1, onClick: handleClick, children: props.children }), $[3] = handleClick, $[4] = props.children, $[5] = t2) : t2 = $[5], t2;
696
- }
697
- DefaultAnnotation.displayName = "DefaultAnnotation";
698
- function getPortableTextMemberSchemaTypes(portableTextType) {
699
- if (!portableTextType)
700
- throw new Error("Parameter 'portabletextType' missing (required)");
701
- const blockType = portableTextType.of?.find(findBlockType);
702
- if (!blockType)
703
- throw new Error("Block type is not defined in this schema (required)");
704
- const childrenField = blockType.fields?.find((field) => field.name === "children");
705
- if (!childrenField)
706
- throw new Error("Children field for block type found in schema (required)");
707
- const ofType = childrenField.type.of;
708
- if (!ofType)
709
- throw new Error("Valid types for block children not found in schema (required)");
710
- const spanType = ofType.find((memberType) => memberType.name === "span");
711
- if (!spanType)
712
- throw new Error("Span type not found in schema (required)");
713
- const inlineObjectTypes = ofType.filter((memberType) => memberType.name !== "span") || [], blockObjectTypes = portableTextType.of?.filter((field) => field.name !== blockType.name) || [];
714
- return {
715
- styles: resolveEnabledStyles(blockType),
716
- decorators: resolveEnabledDecorators(spanType),
717
- lists: resolveEnabledListItems(blockType),
718
- block: blockType,
719
- span: spanType,
720
- portableText: portableTextType,
721
- inlineObjects: inlineObjectTypes,
722
- blockObjects: blockObjectTypes,
723
- annotations: spanType.annotations
724
- };
725
- }
726
- function resolveEnabledStyles(blockType) {
727
- const styleField = blockType.fields?.find((btField) => btField.name === "style");
728
- if (!styleField)
729
- throw new Error("A field with name 'style' is not defined in the block type (required).");
730
- const textStyles = styleField.type.options?.list && styleField.type.options.list?.filter((style) => style.value);
731
- if (!textStyles || textStyles.length === 0)
732
- throw new Error("The style fields need at least one style defined. I.e: {title: 'Normal', value: 'normal'}.");
733
- return textStyles;
734
- }
735
- function resolveEnabledDecorators(spanType) {
736
- return spanType.decorators;
737
- }
738
- function resolveEnabledListItems(blockType) {
739
- const listField = blockType.fields?.find((btField) => btField.name === "listItem");
740
- if (!listField)
741
- throw new Error("A field with name 'listItem' is not defined in the block type (required).");
742
- const listItems = listField.type.options?.list && listField.type.options.list.filter((list) => list.value);
743
- if (!listItems)
744
- throw new Error("The list field need at least to be an empty array");
745
- return listItems;
746
- }
747
- function findBlockType(type) {
748
- return type.type ? findBlockType(type.type) : type.name === "block" ? type : null;
749
- }
750
- function compileType(rawType) {
751
- return schema.Schema.compile({
752
- name: "blockTypeSchema",
753
- types: [rawType]
754
- }).get(rawType.name);
755
- }
756
- function selectionIsCollapsed(context) {
757
- return context.selection?.anchor.path.join() === context.selection?.focus.path.join() && context.selection?.anchor.offset === context.selection?.focus.offset;
758
- }
759
- function getFocusBlock(context) {
760
- const key = context.selection && types.isKeySegment(context.selection.focus.path[0]) ? context.selection.focus.path[0]._key : void 0, node = key ? context.value.find((block) => block._key === key) : void 0;
761
- return node && key ? {
762
- node,
763
- path: [{
764
- _key: key
765
- }]
766
- } : void 0;
767
- }
768
- function getFocusTextBlock(context) {
769
- const focusBlock = getFocusBlock(context);
770
- return focusBlock && types.isPortableTextTextBlock(focusBlock.node) ? {
771
- node: focusBlock.node,
772
- path: focusBlock.path
773
- } : void 0;
774
- }
775
- function getFocusBlockObject(context) {
776
- const focusBlock = getFocusBlock(context);
777
- return focusBlock && !types.isPortableTextTextBlock(focusBlock.node) ? {
778
- node: focusBlock.node,
779
- path: focusBlock.path
780
- } : void 0;
781
- }
782
- function getFocusChild(context) {
783
- const focusBlock = getFocusTextBlock(context);
784
- if (!focusBlock)
785
- return;
786
- const key = context.selection && types.isKeySegment(context.selection.focus.path[2]) ? context.selection.focus.path[2]._key : void 0, node = key ? focusBlock.node.children.find((span) => span._key === key) : void 0;
787
- return node && key ? {
788
- node,
789
- path: [...focusBlock.path, "children", {
790
- _key: key
791
- }]
792
- } : void 0;
793
- }
794
- function getFocusSpan(context) {
795
- const focusChild = getFocusChild(context);
796
- return focusChild && types.isPortableTextSpan(focusChild.node) ? {
797
- node: focusChild.node,
798
- path: focusChild.path
799
- } : void 0;
800
- }
801
- function getSelectionStartBlock(context) {
802
- const key = context.selection.backward ? types.isKeySegment(context.selection.focus.path[0]) ? context.selection.focus.path[0]._key : void 0 : types.isKeySegment(context.selection.anchor.path[0]) ? context.selection.anchor.path[0]._key : void 0, node = key ? context.value.find((block) => block._key === key) : void 0;
803
- return node && key ? {
804
- node,
805
- path: [{
806
- _key: key
807
- }]
808
- } : void 0;
809
- }
810
- function getSelectionEndBlock(context) {
811
- const key = context.selection.backward ? types.isKeySegment(context.selection.anchor.path[0]) ? context.selection.anchor.path[0]._key : void 0 : types.isKeySegment(context.selection.focus.path[0]) ? context.selection.focus.path[0]._key : void 0, node = key ? context.value.find((block) => block._key === key) : void 0;
812
- return node && key ? {
813
- node,
814
- path: [{
815
- _key: key
816
- }]
817
- } : void 0;
818
- }
819
- function getPreviousBlock(context) {
820
- let previousBlock;
821
- const selectionStartBlock = getSelectionStartBlock(context);
822
- if (!selectionStartBlock)
823
- return;
824
- let foundSelectionStartBlock = !1;
825
- for (const block of context.value) {
826
- if (block._key === selectionStartBlock.node._key) {
827
- foundSelectionStartBlock = !0;
828
- break;
829
- }
830
- previousBlock = {
831
- node: block,
832
- path: [{
833
- _key: block._key
834
- }]
835
- };
836
- }
837
- if (foundSelectionStartBlock && previousBlock)
838
- return previousBlock;
839
- }
840
- function getNextBlock(context) {
841
- let nextBlock;
842
- const selectionEndBlock = getSelectionEndBlock(context);
843
- if (!selectionEndBlock)
844
- return;
845
- let foundSelectionEndBlock = !1;
846
- for (const block of context.value) {
847
- if (block._key === selectionEndBlock.node._key) {
848
- foundSelectionEndBlock = !0;
849
- continue;
850
- }
851
- if (foundSelectionEndBlock) {
852
- nextBlock = {
853
- node: block,
854
- path: [{
855
- _key: block._key
856
- }]
857
- };
858
- break;
859
- }
860
- }
861
- if (foundSelectionEndBlock && nextBlock)
862
- return nextBlock;
863
- }
864
- function isEmptyTextBlock(block) {
865
- return block.children.length === 1 && block.children[0].text === "";
866
- }
867
- const breakingVoidBlock = {
868
- on: "insert break",
869
- guard: ({
870
- context
871
- }) => !!getFocusBlockObject(context),
872
- actions: [() => [{
873
- type: "insert text block",
874
- decorators: []
875
- }]]
876
- }, deletingEmptyTextBlockAfterBlockObject = {
877
- on: "delete backward",
878
- guard: ({
879
- context
880
- }) => {
881
- const focusTextBlock = getFocusTextBlock(context), selectionCollapsed = selectionIsCollapsed(context), previousBlock = getPreviousBlock(context);
882
- return !focusTextBlock || !selectionCollapsed || !previousBlock ? !1 : isEmptyTextBlock(focusTextBlock.node) && !types.isPortableTextTextBlock(previousBlock.node) ? {
883
- focusTextBlock,
884
- previousBlock
885
- } : !1;
886
- },
887
- actions: [(_, {
888
- focusTextBlock,
889
- previousBlock
890
- }) => [{
891
- type: "delete",
892
- selection: {
893
- anchor: {
894
- path: focusTextBlock.path,
895
- offset: 0
896
- },
897
- focus: {
898
- path: focusTextBlock.path,
899
- offset: 0
900
- }
901
- }
902
- }, {
903
- type: "select",
904
- selection: {
905
- anchor: {
906
- path: previousBlock.path,
907
- offset: 0
908
- },
909
- focus: {
910
- path: previousBlock.path,
911
- offset: 0
912
- }
913
- }
914
- }]]
915
- }, deletingEmptyTextBlockBeforeBlockObject = {
916
- on: "delete forward",
917
- guard: ({
918
- context
919
- }) => {
920
- const focusTextBlock = getFocusTextBlock(context), selectionCollapsed = selectionIsCollapsed(context), nextBlock = getNextBlock(context);
921
- return !focusTextBlock || !selectionCollapsed || !nextBlock ? !1 : isEmptyTextBlock(focusTextBlock.node) && !types.isPortableTextTextBlock(nextBlock.node) ? {
922
- focusTextBlock,
923
- nextBlock
924
- } : !1;
925
- },
926
- actions: [(_, {
927
- focusTextBlock,
928
- nextBlock
929
- }) => [{
930
- type: "delete",
931
- selection: {
932
- anchor: {
933
- path: focusTextBlock.path,
934
- offset: 0
935
- },
936
- focus: {
937
- path: focusTextBlock.path,
938
- offset: 0
939
- }
940
- }
941
- }, {
942
- type: "select",
943
- selection: {
944
- anchor: {
945
- path: nextBlock.path,
946
- offset: 0
947
- },
948
- focus: {
949
- path: nextBlock.path,
950
- offset: 0
951
- }
952
- }
953
- }]]
954
- }, coreBlockObjectBehaviors = [breakingVoidBlock, deletingEmptyTextBlockAfterBlockObject, deletingEmptyTextBlockBeforeBlockObject], clearListOnBackspace = {
955
- on: "delete backward",
956
- guard: ({
957
- context
958
- }) => {
959
- const selectionCollapsed = selectionIsCollapsed(context), focusTextBlock = getFocusTextBlock(context), focusSpan = getFocusSpan(context);
960
- return !selectionCollapsed || !focusTextBlock || !focusSpan ? !1 : focusTextBlock.node.children[0]._key === focusSpan.node._key && context.selection.focus.offset === 0 && focusTextBlock.node.level === 1 ? {
961
- focusTextBlock
962
- } : !1;
963
- },
964
- actions: [(_, {
965
- focusTextBlock
966
- }) => [{
967
- type: "unset block",
968
- props: ["listItem", "level"],
969
- paths: [focusTextBlock.path]
970
- }]]
971
- }, unindentListOnBackspace = {
972
- on: "delete backward",
973
- guard: ({
974
- context
975
- }) => {
976
- const selectionCollapsed = selectionIsCollapsed(context), focusTextBlock = getFocusTextBlock(context), focusSpan = getFocusSpan(context);
977
- return !selectionCollapsed || !focusTextBlock || !focusSpan ? !1 : focusTextBlock.node.children[0]._key === focusSpan.node._key && context.selection.focus.offset === 0 && focusTextBlock.node.level !== void 0 && focusTextBlock.node.level > 1 ? {
978
- focusTextBlock,
979
- level: focusTextBlock.node.level - 1
980
- } : !1;
981
- },
982
- actions: [(_, {
983
- focusTextBlock,
984
- level
985
- }) => [{
986
- type: "set block",
987
- level,
988
- paths: [focusTextBlock.path]
989
- }]]
990
- }, coreListBehaviors = [clearListOnBackspace, unindentListOnBackspace], softReturn = {
991
- on: "insert soft break",
992
- actions: [() => [{
993
- type: "insert text",
994
- text: `
995
- `
996
- }]]
997
- }, coreBehaviors = [softReturn, ...coreBlockObjectBehaviors, ...coreListBehaviors], debug$k = debugWithName("operationToPatches");
884
+ }), propsOrDefaultRendered = renderBlock ? renderBlock(renderProps) : children;
885
+ 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);
886
+ }
887
+ const schemaType_0 = schemaTypes.blockObjects.find((_type_0) => _type_0.name === element._type);
888
+ if (!schemaType_0)
889
+ throw new Error(`Could not find schema type for block element of _type ${element._type}`);
890
+ className = "pt-block pt-object-block";
891
+ const block_0 = fromSlateValue([element], schemaTypes.block.name, KEY_TO_VALUE_ELEMENT.get(editor))[0];
892
+ let renderedBlockFromProps;
893
+ if (renderBlock) {
894
+ const _props = Object.defineProperty({
895
+ children: /* @__PURE__ */ jsxRuntime.jsx(DefaultObject, { value }),
896
+ editorElementRef: blockRef,
897
+ focused,
898
+ path: blockPath,
899
+ schemaType: schemaType_0,
900
+ selected,
901
+ value: block_0
902
+ }, "type", {
903
+ enumerable: !1,
904
+ get() {
905
+ return console.warn("Property 'type' is deprecated, use 'schemaType' instead."), schemaType_0;
906
+ }
907
+ });
908
+ renderedBlockFromProps = renderBlock(_props);
909
+ }
910
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { ...attributes, className, children: [
911
+ children,
912
+ /* @__PURE__ */ jsxRuntime.jsxs(DraggableBlock, { element, readOnly, blockRef, children: [
913
+ renderedBlockFromProps && /* @__PURE__ */ jsxRuntime.jsx("div", { ref: blockRef, contentEditable: !1, children: renderedBlockFromProps }),
914
+ !renderedBlockFromProps && /* @__PURE__ */ jsxRuntime.jsx(DefaultBlockObject, { selected, children: /* @__PURE__ */ jsxRuntime.jsx(DefaultObject, { value }) })
915
+ ] })
916
+ ] }, element._key);
917
+ };
918
+ Element.displayName = "Element";
919
+ const PortableTextEditorContext = react.createContext(null), usePortableTextEditor = () => {
920
+ const editor = react.useContext(PortableTextEditorContext);
921
+ if (!editor)
922
+ throw new Error("The `usePortableTextEditor` hook must be used inside the <PortableTextEditor> component's context.");
923
+ return editor;
924
+ };
925
+ function DefaultAnnotation(props) {
926
+ const $ = reactCompilerRuntime.c(6);
927
+ let t0;
928
+ $[0] !== props.annotation ? (t0 = () => alert(JSON.stringify(props.annotation)), $[0] = props.annotation, $[1] = t0) : t0 = $[1];
929
+ const handleClick = t0;
930
+ let t1;
931
+ $[2] === Symbol.for("react.memo_cache_sentinel") ? (t1 = {
932
+ color: "blue"
933
+ }, $[2] = t1) : t1 = $[2];
934
+ let t2;
935
+ return $[3] !== handleClick || $[4] !== props.children ? (t2 = /* @__PURE__ */ jsxRuntime.jsx("span", { style: t1, onClick: handleClick, children: props.children }), $[3] = handleClick, $[4] = props.children, $[5] = t2) : t2 = $[5], t2;
936
+ }
937
+ DefaultAnnotation.displayName = "DefaultAnnotation";
938
+ function getPortableTextMemberSchemaTypes(portableTextType) {
939
+ if (!portableTextType)
940
+ throw new Error("Parameter 'portabletextType' missing (required)");
941
+ const blockType = portableTextType.of?.find(findBlockType);
942
+ if (!blockType)
943
+ throw new Error("Block type is not defined in this schema (required)");
944
+ const childrenField = blockType.fields?.find((field) => field.name === "children");
945
+ if (!childrenField)
946
+ throw new Error("Children field for block type found in schema (required)");
947
+ const ofType = childrenField.type.of;
948
+ if (!ofType)
949
+ throw new Error("Valid types for block children not found in schema (required)");
950
+ const spanType = ofType.find((memberType) => memberType.name === "span");
951
+ if (!spanType)
952
+ throw new Error("Span type not found in schema (required)");
953
+ const inlineObjectTypes = ofType.filter((memberType) => memberType.name !== "span") || [], blockObjectTypes = portableTextType.of?.filter((field) => field.name !== blockType.name) || [];
954
+ return {
955
+ styles: resolveEnabledStyles(blockType),
956
+ decorators: resolveEnabledDecorators(spanType),
957
+ lists: resolveEnabledListItems(blockType),
958
+ block: blockType,
959
+ span: spanType,
960
+ portableText: portableTextType,
961
+ inlineObjects: inlineObjectTypes,
962
+ blockObjects: blockObjectTypes,
963
+ annotations: spanType.annotations
964
+ };
965
+ }
966
+ function resolveEnabledStyles(blockType) {
967
+ const styleField = blockType.fields?.find((btField) => btField.name === "style");
968
+ if (!styleField)
969
+ throw new Error("A field with name 'style' is not defined in the block type (required).");
970
+ const textStyles = styleField.type.options?.list && styleField.type.options.list?.filter((style) => style.value);
971
+ if (!textStyles || textStyles.length === 0)
972
+ throw new Error("The style fields need at least one style defined. I.e: {title: 'Normal', value: 'normal'}.");
973
+ return textStyles;
974
+ }
975
+ function resolveEnabledDecorators(spanType) {
976
+ return spanType.decorators;
977
+ }
978
+ function resolveEnabledListItems(blockType) {
979
+ const listField = blockType.fields?.find((btField) => btField.name === "listItem");
980
+ if (!listField)
981
+ throw new Error("A field with name 'listItem' is not defined in the block type (required).");
982
+ const listItems = listField.type.options?.list && listField.type.options.list.filter((list) => list.value);
983
+ if (!listItems)
984
+ throw new Error("The list field need at least to be an empty array");
985
+ return listItems;
986
+ }
987
+ function findBlockType(type) {
988
+ return type.type ? findBlockType(type.type) : type.name === "block" ? type : null;
989
+ }
990
+ function compileType(rawType) {
991
+ return schema.Schema.compile({
992
+ name: "blockTypeSchema",
993
+ types: [rawType]
994
+ }).get(rawType.name);
995
+ }
996
+ const debug$k = debugWithName("operationToPatches");
998
997
  function createOperationToPatches(types2) {
999
998
  const textBlockName = types2.block.name;
1000
999
  function insertTextPatch(editor, operation, beforeValue) {
@@ -5263,7 +5262,137 @@ function performDefaultAction({
5263
5262
  });
5264
5263
  }
5265
5264
  }
5266
- const networkLogic = xstate.fromCallback(({
5265
+ const breakingVoidBlock = {
5266
+ on: "insert break",
5267
+ guard: ({
5268
+ context
5269
+ }) => !!getFocusBlockObject(context),
5270
+ actions: [() => [{
5271
+ type: "insert text block",
5272
+ decorators: []
5273
+ }]]
5274
+ }, deletingEmptyTextBlockAfterBlockObject = {
5275
+ on: "delete backward",
5276
+ guard: ({
5277
+ context
5278
+ }) => {
5279
+ const focusTextBlock = getFocusTextBlock(context), selectionCollapsed = selectionIsCollapsed(context), previousBlock = getPreviousBlock(context);
5280
+ return !focusTextBlock || !selectionCollapsed || !previousBlock ? !1 : isEmptyTextBlock(focusTextBlock.node) && !types.isPortableTextTextBlock(previousBlock.node) ? {
5281
+ focusTextBlock,
5282
+ previousBlock
5283
+ } : !1;
5284
+ },
5285
+ actions: [(_, {
5286
+ focusTextBlock,
5287
+ previousBlock
5288
+ }) => [{
5289
+ type: "delete",
5290
+ selection: {
5291
+ anchor: {
5292
+ path: focusTextBlock.path,
5293
+ offset: 0
5294
+ },
5295
+ focus: {
5296
+ path: focusTextBlock.path,
5297
+ offset: 0
5298
+ }
5299
+ }
5300
+ }, {
5301
+ type: "select",
5302
+ selection: {
5303
+ anchor: {
5304
+ path: previousBlock.path,
5305
+ offset: 0
5306
+ },
5307
+ focus: {
5308
+ path: previousBlock.path,
5309
+ offset: 0
5310
+ }
5311
+ }
5312
+ }]]
5313
+ }, deletingEmptyTextBlockBeforeBlockObject = {
5314
+ on: "delete forward",
5315
+ guard: ({
5316
+ context
5317
+ }) => {
5318
+ const focusTextBlock = getFocusTextBlock(context), selectionCollapsed = selectionIsCollapsed(context), nextBlock = getNextBlock(context);
5319
+ return !focusTextBlock || !selectionCollapsed || !nextBlock ? !1 : isEmptyTextBlock(focusTextBlock.node) && !types.isPortableTextTextBlock(nextBlock.node) ? {
5320
+ focusTextBlock,
5321
+ nextBlock
5322
+ } : !1;
5323
+ },
5324
+ actions: [(_, {
5325
+ focusTextBlock,
5326
+ nextBlock
5327
+ }) => [{
5328
+ type: "delete",
5329
+ selection: {
5330
+ anchor: {
5331
+ path: focusTextBlock.path,
5332
+ offset: 0
5333
+ },
5334
+ focus: {
5335
+ path: focusTextBlock.path,
5336
+ offset: 0
5337
+ }
5338
+ }
5339
+ }, {
5340
+ type: "select",
5341
+ selection: {
5342
+ anchor: {
5343
+ path: nextBlock.path,
5344
+ offset: 0
5345
+ },
5346
+ focus: {
5347
+ path: nextBlock.path,
5348
+ offset: 0
5349
+ }
5350
+ }
5351
+ }]]
5352
+ }, coreBlockObjectBehaviors = [breakingVoidBlock, deletingEmptyTextBlockAfterBlockObject, deletingEmptyTextBlockBeforeBlockObject], clearListOnBackspace = {
5353
+ on: "delete backward",
5354
+ guard: ({
5355
+ context
5356
+ }) => {
5357
+ const selectionCollapsed = selectionIsCollapsed(context), focusTextBlock = getFocusTextBlock(context), focusSpan = getFocusSpan(context);
5358
+ return !selectionCollapsed || !focusTextBlock || !focusSpan ? !1 : focusTextBlock.node.children[0]._key === focusSpan.node._key && context.selection.focus.offset === 0 && focusTextBlock.node.level === 1 ? {
5359
+ focusTextBlock
5360
+ } : !1;
5361
+ },
5362
+ actions: [(_, {
5363
+ focusTextBlock
5364
+ }) => [{
5365
+ type: "unset block",
5366
+ props: ["listItem", "level"],
5367
+ paths: [focusTextBlock.path]
5368
+ }]]
5369
+ }, unindentListOnBackspace = {
5370
+ on: "delete backward",
5371
+ guard: ({
5372
+ context
5373
+ }) => {
5374
+ const selectionCollapsed = selectionIsCollapsed(context), focusTextBlock = getFocusTextBlock(context), focusSpan = getFocusSpan(context);
5375
+ return !selectionCollapsed || !focusTextBlock || !focusSpan ? !1 : focusTextBlock.node.children[0]._key === focusSpan.node._key && context.selection.focus.offset === 0 && focusTextBlock.node.level !== void 0 && focusTextBlock.node.level > 1 ? {
5376
+ focusTextBlock,
5377
+ level: focusTextBlock.node.level - 1
5378
+ } : !1;
5379
+ },
5380
+ actions: [(_, {
5381
+ focusTextBlock,
5382
+ level
5383
+ }) => [{
5384
+ type: "set block",
5385
+ level,
5386
+ paths: [focusTextBlock.path]
5387
+ }]]
5388
+ }, coreListBehaviors = [clearListOnBackspace, unindentListOnBackspace], softReturn = {
5389
+ on: "insert soft break",
5390
+ actions: [() => [{
5391
+ type: "insert text",
5392
+ text: `
5393
+ `
5394
+ }]]
5395
+ }, coreBehaviors = [softReturn, ...coreBlockObjectBehaviors, ...coreListBehaviors], networkLogic = xstate.fromCallback(({
5267
5396
  sendBack
5268
5397
  }) => {
5269
5398
  const onlineHandler = () => {
@@ -5286,6 +5415,11 @@ const networkLogic = xstate.fromCallback(({
5286
5415
  input: {}
5287
5416
  },
5288
5417
  actions: {
5418
+ "assign behaviors": xstate.assign({
5419
+ behaviors: ({
5420
+ event
5421
+ }) => (xstate.assertEvent(event, "update behaviors"), [...coreBehaviors, ...event.behaviors])
5422
+ }),
5289
5423
  "assign schema": xstate.assign({
5290
5424
  schema: ({
5291
5425
  event
@@ -5378,7 +5512,7 @@ const networkLogic = xstate.fromCallback(({
5378
5512
  context: ({
5379
5513
  input
5380
5514
  }) => ({
5381
- behaviors: input.behaviors,
5515
+ behaviors: input.behaviors ? [...coreBehaviors, ...input.behaviors] : coreBehaviors,
5382
5516
  keyGenerator: input.keyGenerator,
5383
5517
  pendingEvents: [],
5384
5518
  schema: input.schema
@@ -5453,6 +5587,9 @@ const networkLogic = xstate.fromCallback(({
5453
5587
  type: "done loading"
5454
5588
  })
5455
5589
  },
5590
+ "update behaviors": {
5591
+ actions: "assign behaviors"
5592
+ },
5456
5593
  "update schema": {
5457
5594
  actions: "assign schema"
5458
5595
  },
@@ -5563,18 +5700,21 @@ class PortableTextEditor extends react.Component {
5563
5700
  * The editor API (currently implemented with Slate).
5564
5701
  */
5565
5702
  constructor(props) {
5566
- if (super(props), !props.schemaType)
5567
- throw new Error('PortableTextEditor: missing "schemaType" property');
5568
- props.incomingPatches$ && console.warn("The prop 'incomingPatches$' is deprecated and renamed to 'patches$'"), this.schemaTypes = getPortableTextMemberSchemaTypes(props.schemaType.hasOwnProperty("jsonType") ? props.schemaType : compileType(props.schemaType)), this.editorActor = xstate.createActor(editorMachine, {
5569
- input: {
5570
- behaviors: coreBehaviors,
5571
- keyGenerator: props.keyGenerator || defaultKeyGenerator,
5572
- schema: this.schemaTypes
5573
- }
5574
- }), this.editorActor.start();
5703
+ if (super(props), props.editor)
5704
+ this.editorActor = props.editor, this.editorActor.start(), this.schemaTypes = this.editorActor.getSnapshot().context.schema;
5705
+ else {
5706
+ if (!props.schemaType)
5707
+ throw new Error('PortableTextEditor: missing "schemaType" property');
5708
+ props.incomingPatches$ && console.warn("The prop 'incomingPatches$' is deprecated and renamed to 'patches$'"), this.schemaTypes = getPortableTextMemberSchemaTypes(props.schemaType.hasOwnProperty("jsonType") ? props.schemaType : compileType(props.schemaType)), this.editorActor = props.editor ?? xstate.createActor(editorMachine, {
5709
+ input: {
5710
+ keyGenerator: props.keyGenerator || defaultKeyGenerator,
5711
+ schema: this.schemaTypes
5712
+ }
5713
+ }), this.editorActor.start();
5714
+ }
5575
5715
  }
5576
5716
  componentDidUpdate(prevProps) {
5577
- this.props.schemaType !== prevProps.schemaType && (this.schemaTypes = getPortableTextMemberSchemaTypes(this.props.schemaType.hasOwnProperty("jsonType") ? this.props.schemaType : compileType(this.props.schemaType)), this.editorActor.send({
5717
+ !this.props.editor && !prevProps.editor && this.props.schemaType !== prevProps.schemaType && (this.schemaTypes = getPortableTextMemberSchemaTypes(this.props.schemaType.hasOwnProperty("jsonType") ? this.props.schemaType : compileType(this.props.schemaType)), this.editorActor.send({
5578
5718
  type: "update schema",
5579
5719
  schema: this.schemaTypes
5580
5720
  })), this.props.editorRef !== prevProps.editorRef && this.props.editorRef && (this.props.editorRef.current = this);
@@ -5590,19 +5730,14 @@ class PortableTextEditor extends react.Component {
5590
5730
  return this.editable.getValue();
5591
5731
  };
5592
5732
  render() {
5593
- const {
5594
- value,
5595
- children,
5596
- patches$,
5597
- incomingPatches$
5598
- } = this.props, _patches$ = incomingPatches$ || patches$, maxBlocks = typeof this.props.maxBlocks > "u" ? void 0 : Number.parseInt(this.props.maxBlocks.toString(), 10) || void 0, readOnly = !!this.props.readOnly;
5733
+ const maxBlocks = this.props.editor || typeof this.props.maxBlocks > "u" ? void 0 : Number.parseInt(this.props.maxBlocks.toString(), 10) || void 0, readOnly = !!this.props.readOnly, legacyPatches = this.props.editor ? void 0 : this.props.incomingPatches$ ?? this.props.patches$;
5599
5734
  return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
5600
- _patches$ ? /* @__PURE__ */ jsxRuntime.jsx(RoutePatchesObservableToEditorActor, { editorActor: this.editorActor, patches$: _patches$ }) : null,
5735
+ legacyPatches ? /* @__PURE__ */ jsxRuntime.jsx(RoutePatchesObservableToEditorActor, { editorActor: this.editorActor, patches$: legacyPatches }) : null,
5601
5736
  /* @__PURE__ */ jsxRuntime.jsx(EditorActorContext.Provider, { value: this.editorActor, children: /* @__PURE__ */ jsxRuntime.jsx(SlateContainer, { editorActor: this.editorActor, maxBlocks, portableTextEditor: this, readOnly, children: /* @__PURE__ */ jsxRuntime.jsx(PortableTextEditorContext.Provider, { value: this, children: /* @__PURE__ */ jsxRuntime.jsx(PortableTextEditorReadOnlyContext.Provider, { value: readOnly, children: /* @__PURE__ */ jsxRuntime.jsxs(PortableTextEditorSelectionProvider, { editorActor: this.editorActor, children: [
5602
5737
  /* @__PURE__ */ jsxRuntime.jsx(Synchronizer, { editorActor: this.editorActor, getValue: this.getValue, onChange: (change) => {
5603
- this.props.onChange(change), this.change$.next(change);
5604
- }, value }),
5605
- children
5738
+ this.props.editor || this.props.onChange(change), this.change$.next(change);
5739
+ }, value: this.props.value }),
5740
+ this.props.children
5606
5741
  ] }) }) }) }) })
5607
5742
  ] });
5608
5743
  }
@@ -6060,10 +6195,29 @@ const debug = debugWithName("component:Editable"), PLACEHOLDER_STYLE = {
6060
6195
  ) : null;
6061
6196
  });
6062
6197
  PortableTextEditable.displayName = "ForwardRef(PortableTextEditable)";
6198
+ function useEditor(config) {
6199
+ const $ = reactCompilerRuntime.c(8);
6200
+ let t0;
6201
+ $[0] !== config.schema ? (t0 = config.schema.hasOwnProperty("jsonType") ? config.schema : compileType(config.schema), $[0] = config.schema, $[1] = t0) : t0 = $[1];
6202
+ let t1;
6203
+ $[2] !== t0 ? (t1 = getPortableTextMemberSchemaTypes(t0), $[2] = t0, $[3] = t1) : t1 = $[3];
6204
+ const schema2 = t1, t2 = config.keyGenerator ?? defaultKeyGenerator;
6205
+ let t3;
6206
+ return $[4] !== config.behaviors || $[5] !== t2 || $[6] !== schema2 ? (t3 = {
6207
+ input: {
6208
+ behaviors: config.behaviors,
6209
+ keyGenerator: t2,
6210
+ schema: schema2
6211
+ }
6212
+ }, $[4] = config.behaviors, $[5] = t2, $[6] = schema2, $[7] = t3) : t3 = $[7], react$1.useActorRef(editorMachine, t3);
6213
+ }
6063
6214
  exports.PortableTextEditable = PortableTextEditable;
6064
6215
  exports.PortableTextEditor = PortableTextEditor;
6216
+ exports.createMarkdownBehaviors = createMarkdownBehaviors;
6217
+ exports.defineBehavior = defineBehavior;
6065
6218
  exports.editorMachine = editorMachine;
6066
6219
  exports.keyGenerator = defaultKeyGenerator;
6220
+ exports.useEditor = useEditor;
6067
6221
  exports.usePortableTextEditor = usePortableTextEditor;
6068
6222
  exports.usePortableTextEditorSelection = usePortableTextEditorSelection;
6069
6223
  //# sourceMappingURL=index.js.map