@makeswift/runtime 0.10.3 → 0.10.4

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 (146) hide show
  1. package/dist/Box.cjs.js +1 -3
  2. package/dist/Box.cjs.js.map +1 -1
  3. package/dist/Box.es.js +2 -4
  4. package/dist/Box.es.js.map +1 -1
  5. package/dist/Button.cjs.js +4 -4
  6. package/dist/Button.es.js +5 -5
  7. package/dist/Carousel.cjs.js +3 -3
  8. package/dist/Carousel.es.js +4 -4
  9. package/dist/Countdown.cjs.js +1 -3
  10. package/dist/Countdown.cjs.js.map +1 -1
  11. package/dist/Countdown.es.js +2 -4
  12. package/dist/Countdown.es.js.map +1 -1
  13. package/dist/Divider.cjs.js +1 -3
  14. package/dist/Divider.cjs.js.map +1 -1
  15. package/dist/Divider.es.js +2 -4
  16. package/dist/Divider.es.js.map +1 -1
  17. package/dist/Embed.cjs.js +1 -0
  18. package/dist/Embed.cjs.js.map +1 -1
  19. package/dist/Embed.es.js +2 -1
  20. package/dist/Embed.es.js.map +1 -1
  21. package/dist/Form.cjs.js +13 -13
  22. package/dist/Form.cjs.js.map +1 -1
  23. package/dist/Form.es.js +5 -5
  24. package/dist/Image.cjs.js +13 -13
  25. package/dist/Image.cjs.js.map +1 -1
  26. package/dist/Image.es.js +13 -13
  27. package/dist/LiveProvider.cjs.js +1 -3
  28. package/dist/LiveProvider.cjs.js.map +1 -1
  29. package/dist/LiveProvider.es.js +3 -5
  30. package/dist/LiveProvider.es.js.map +1 -1
  31. package/dist/Navigation.cjs.js +12 -12
  32. package/dist/Navigation.cjs.js.map +1 -1
  33. package/dist/Navigation.es.js +12 -12
  34. package/dist/PreviewProvider.cjs.js +1 -3
  35. package/dist/PreviewProvider.cjs.js.map +1 -1
  36. package/dist/PreviewProvider.es.js +3 -5
  37. package/dist/PreviewProvider.es.js.map +1 -1
  38. package/dist/ReadOnlyText.cjs.js +7 -6
  39. package/dist/ReadOnlyText.cjs.js.map +1 -1
  40. package/dist/ReadOnlyText.es.js +4 -3
  41. package/dist/ReadOnlyText.es.js.map +1 -1
  42. package/dist/ReadOnlyTextV2.cjs.js +7 -60
  43. package/dist/ReadOnlyTextV2.cjs.js.map +1 -1
  44. package/dist/ReadOnlyTextV2.es.js +9 -62
  45. package/dist/ReadOnlyTextV2.es.js.map +1 -1
  46. package/dist/Root.cjs.js +1 -3
  47. package/dist/Root.cjs.js.map +1 -1
  48. package/dist/Root.es.js +2 -4
  49. package/dist/Root.es.js.map +1 -1
  50. package/dist/SocialLinks.cjs.js +6 -6
  51. package/dist/SocialLinks.cjs.js.map +1 -1
  52. package/dist/SocialLinks.es.js +7 -7
  53. package/dist/Video.cjs.js +1 -0
  54. package/dist/Video.cjs.js.map +1 -1
  55. package/dist/Video.es.js +2 -1
  56. package/dist/Video.es.js.map +1 -1
  57. package/dist/builder.cjs.js +1 -0
  58. package/dist/builder.cjs.js.map +1 -1
  59. package/dist/builder.es.js +1 -0
  60. package/dist/builder.es.js.map +1 -1
  61. package/dist/components.cjs.js +3 -3
  62. package/dist/components.es.js +3 -3
  63. package/dist/control-serialization.es.js +1 -1
  64. package/dist/controls.cjs.js +1 -0
  65. package/dist/controls.cjs.js.map +1 -1
  66. package/dist/controls.es.js +2 -1
  67. package/dist/controls.es.js.map +1 -1
  68. package/dist/index.cjs.js +120 -256
  69. package/dist/index.cjs.js.map +1 -1
  70. package/dist/index.cjs3.js +107 -21
  71. package/dist/index.cjs3.js.map +1 -1
  72. package/dist/index.cjs4.js +57 -16
  73. package/dist/index.cjs4.js.map +1 -1
  74. package/dist/index.cjs5.js +42 -81
  75. package/dist/index.cjs5.js.map +1 -1
  76. package/dist/index.cjs6.js +82 -17
  77. package/dist/index.cjs6.js.map +1 -1
  78. package/dist/index.cjs7.js +18 -377
  79. package/dist/index.cjs7.js.map +1 -1
  80. package/dist/index.cjs8.js +258 -181
  81. package/dist/index.cjs8.js.map +1 -1
  82. package/dist/index.cjs9.js +343 -0
  83. package/dist/index.cjs9.js.map +1 -0
  84. package/dist/index.es.js +125 -260
  85. package/dist/index.es.js.map +1 -1
  86. package/dist/index.es2.js +1 -1
  87. package/dist/index.es3.js +103 -22
  88. package/dist/index.es3.js.map +1 -1
  89. package/dist/index.es4.js +57 -16
  90. package/dist/index.es4.js.map +1 -1
  91. package/dist/index.es5.js +42 -80
  92. package/dist/index.es5.js.map +1 -1
  93. package/dist/index.es6.js +81 -17
  94. package/dist/index.es6.js.map +1 -1
  95. package/dist/index.es7.js +18 -371
  96. package/dist/index.es7.js.map +1 -1
  97. package/dist/index.es8.js +259 -182
  98. package/dist/index.es8.js.map +1 -1
  99. package/dist/index.es9.js +336 -0
  100. package/dist/index.es9.js.map +1 -0
  101. package/dist/main.cjs.js +1 -0
  102. package/dist/main.cjs.js.map +1 -1
  103. package/dist/main.es.js +1 -0
  104. package/dist/main.es.js.map +1 -1
  105. package/dist/next.cjs.js +1 -3
  106. package/dist/next.cjs.js.map +1 -1
  107. package/dist/next.es.js +2 -4
  108. package/dist/next.es.js.map +1 -1
  109. package/dist/prop-controllers.cjs.js +1 -0
  110. package/dist/prop-controllers.cjs.js.map +1 -1
  111. package/dist/prop-controllers.es.js +1 -0
  112. package/dist/prop-controllers.es.js.map +1 -1
  113. package/dist/react-page.cjs.js +26 -6
  114. package/dist/react-page.cjs.js.map +1 -1
  115. package/dist/react-page.es.js +26 -7
  116. package/dist/react-page.es.js.map +1 -1
  117. package/dist/react.cjs.js +1 -3
  118. package/dist/react.cjs.js.map +1 -1
  119. package/dist/react.es.js +1 -3
  120. package/dist/react.es.js.map +1 -1
  121. package/dist/slate.cjs.js +9 -6
  122. package/dist/slate.cjs.js.map +1 -1
  123. package/dist/slate.es.js +9 -7
  124. package/dist/slate.es.js.map +1 -1
  125. package/dist/toText.cjs.js +67 -0
  126. package/dist/toText.cjs.js.map +1 -0
  127. package/dist/toText.es.js +66 -0
  128. package/dist/toText.es.js.map +1 -0
  129. package/dist/types/src/components/builtin/Text/register.d.ts.map +1 -1
  130. package/dist/types/src/controls/rich-text-v2/rich-text-v2.d.ts +2 -4
  131. package/dist/types/src/controls/rich-text-v2/rich-text-v2.d.ts.map +1 -1
  132. package/dist/types/src/runtimes/react/controls/rich-text-v2/EditableTextV2/editable-text-v2.d.ts.map +1 -1
  133. package/dist/types/src/runtimes/react/controls/rich-text-v2/EditableTextV2/render-element.d.ts.map +1 -1
  134. package/dist/types/src/runtimes/react/controls/rich-text-v2/EditableTextV2/usePresetValue.d.ts +10 -0
  135. package/dist/types/src/runtimes/react/controls/rich-text-v2/EditableTextV2/usePresetValue.d.ts.map +1 -0
  136. package/dist/types/src/runtimes/react/controls/rich-text-v2/ReadOnlyTextV2.d.ts.map +1 -1
  137. package/dist/types/src/slate/BuilderPlugin/index.d.ts +2 -1
  138. package/dist/types/src/slate/BuilderPlugin/index.d.ts.map +1 -1
  139. package/dist/types/src/slate/InlineModePlugin/index.d.ts.map +1 -1
  140. package/dist/types/src/slate/index.d.ts +1 -0
  141. package/dist/types/src/slate/index.d.ts.map +1 -1
  142. package/dist/types/src/slate/utils/index.d.ts +2 -0
  143. package/dist/types/src/slate/utils/index.d.ts.map +1 -0
  144. package/dist/types/src/slate/utils/toText.d.ts +4 -0
  145. package/dist/types/src/slate/utils/toText.d.ts.map +1 -0
  146. package/package.json +1 -1
package/dist/index.es8.js CHANGED
@@ -29,39 +29,36 @@ var __objRest = (source, exclude) => {
29
29
  }
30
30
  return target;
31
31
  };
32
- import { useEffect, useMemo, useState, useRef, useCallback } from "react";
33
- import { Range, createEditor } from "slate";
32
+ import { cx } from "@emotion/css";
33
+ import { getBox } from "css-box-model";
34
34
  import isHotkey from "is-hotkey";
35
+ import { useCallback, useState, useEffect, forwardRef, useImperativeHandle, useMemo } from "react";
36
+ import { Range, createEditor } from "slate";
35
37
  import { ReactEditor, withReact, Slate, Editable } from "slate-react";
36
- import { bu as richTextV2DataToDescendents, Y as BlockType, br as RichTextV2Mode, bK as InlineModePlugin, bI as BlockPlugin, bD as TypographyPlugin, bM as TextAlignPlugin, bR as InlinePlugin, b$ as BuilderEditMode } from "./react-page.es.js";
37
- import { Q as ControlValue, u as useIsInBuilder, N as useBuilderEditMode, O as pollBoxModel } from "./index.es.js";
38
- import { w as withBuilder } from "./index.es4.js";
39
- import { L as LinkPlugin } from "./index.es5.js";
40
- import { w as withLocalChanges } from "./index.es6.js";
41
- import { u as useIsomorphicLayoutEffect } from "./useIsomorphicLayoutEffect.es.js";
38
+ import { n as useResponsiveStyle, L as useEnhancedTypography, N as useTypographyClassName, u as useIsInBuilder, O as useBuilderEditMode, Q as pollBoxModel } from "./index.es.js";
39
+ import { Z as useStyle, bN as BlockType, bO as InlineType, bn as richTextDTOtoDAO, bm as richTextDTOtoSelection, a as deepEqual, bG as withBlock, bB as withTypography, bF as onKeyDown, b$ as BuilderEditMode } from "./react-page.es.js";
40
+ import "uuid";
42
41
  import { jsx } from "react/jsx-runtime";
43
- import "./actions.es.js";
44
- import "redux";
45
- import "redux-thunk";
42
+ import { w as withBuilder } from "./index.es5.js";
46
43
  import "./state/breakpoints.es.js";
47
- import "zod";
48
- import "uuid";
49
- import "@emotion/css";
50
- import "@emotion/serialize";
51
- import "@emotion/utils";
44
+ import { L as Link } from "./index.es3.js";
45
+ import "./actions.es.js";
46
+ import { u as useIsomorphicLayoutEffect } from "./useIsomorphicLayoutEffect.es.js";
52
47
  import "use-sync-external-store/shim/with-selector";
53
48
  import "next/dynamic";
54
49
  import "./text-input.es.js";
55
50
  import "./combobox.es.js";
56
51
  import "use-sync-external-store/shim";
52
+ import "redux";
53
+ import "redux-thunk";
57
54
  import "./types.es.js";
58
55
  import "./box-models.es.js";
59
- import "css-box-model";
60
56
  import "color";
61
57
  import "scroll-into-view-if-needed";
62
58
  import "react-dom";
63
59
  import "html-react-parser";
64
60
  import "next/head";
61
+ import "zod";
65
62
  import "@emotion/server/create-instance";
66
63
  import "next/document";
67
64
  import "cors";
@@ -71,10 +68,185 @@ import "http-proxy";
71
68
  import "set-cookie-parser";
72
69
  import "./constants.es.js";
73
70
  import "corporate-ipsum";
71
+ import "@emotion/serialize";
72
+ import "@emotion/utils";
74
73
  import "next/link";
74
+ function BlockElement({
75
+ element,
76
+ attributes,
77
+ children
78
+ }) {
79
+ const blockStyles = [useStyle({
80
+ margin: 0
81
+ }), useStyle(useResponsiveStyle([element.textAlign], ([textAlign = "left"]) => ({
82
+ textAlign
83
+ })))];
84
+ const quoteStyles = useStyle({
85
+ padding: "0.5em 10px",
86
+ fontSize: "1.25em",
87
+ fontWeight: "300",
88
+ borderLeft: "5px solid rgba(0, 0, 0, 0.1)"
89
+ });
90
+ switch (element.type) {
91
+ case BlockType.Default:
92
+ case BlockType.Paragraph:
93
+ return /* @__PURE__ */ jsx("p", __spreadProps(__spreadValues({}, attributes), {
94
+ className: cx(...blockStyles),
95
+ children
96
+ }));
97
+ case BlockType.Heading1:
98
+ return /* @__PURE__ */ jsx("h1", __spreadProps(__spreadValues({}, attributes), {
99
+ className: cx(...blockStyles),
100
+ children
101
+ }));
102
+ case BlockType.Heading2:
103
+ return /* @__PURE__ */ jsx("h2", __spreadProps(__spreadValues({}, attributes), {
104
+ className: cx(...blockStyles),
105
+ children
106
+ }));
107
+ case BlockType.Heading3:
108
+ return /* @__PURE__ */ jsx("h3", __spreadProps(__spreadValues({}, attributes), {
109
+ className: cx(...blockStyles),
110
+ children
111
+ }));
112
+ case BlockType.Heading4:
113
+ return /* @__PURE__ */ jsx("h4", __spreadProps(__spreadValues({}, attributes), {
114
+ className: cx(...blockStyles),
115
+ children
116
+ }));
117
+ case BlockType.Heading5:
118
+ return /* @__PURE__ */ jsx("h5", __spreadProps(__spreadValues({}, attributes), {
119
+ className: cx(...blockStyles),
120
+ children
121
+ }));
122
+ case BlockType.Heading6:
123
+ return /* @__PURE__ */ jsx("h6", __spreadProps(__spreadValues({}, attributes), {
124
+ className: cx(...blockStyles),
125
+ children
126
+ }));
127
+ case BlockType.BlockQuote:
128
+ return /* @__PURE__ */ jsx("blockquote", __spreadProps(__spreadValues({}, attributes), {
129
+ className: cx(...blockStyles, quoteStyles),
130
+ children
131
+ }));
132
+ case BlockType.OrderedList:
133
+ return /* @__PURE__ */ jsx("ol", __spreadProps(__spreadValues({}, attributes), {
134
+ className: cx(...blockStyles),
135
+ style: {
136
+ listStylePosition: "inside"
137
+ },
138
+ children
139
+ }));
140
+ case BlockType.UnorderedList:
141
+ return /* @__PURE__ */ jsx("ul", __spreadProps(__spreadValues({}, attributes), {
142
+ className: cx(...blockStyles),
143
+ style: {
144
+ listStylePosition: "inside"
145
+ },
146
+ children
147
+ }));
148
+ case BlockType.ListItem:
149
+ return /* @__PURE__ */ jsx("li", __spreadProps(__spreadValues({}, attributes), {
150
+ className: cx(...blockStyles),
151
+ children
152
+ }));
153
+ case BlockType.ListItemChild:
154
+ return /* @__PURE__ */ jsx("span", __spreadProps(__spreadValues({}, attributes), {
155
+ className: cx(...blockStyles),
156
+ children
157
+ }));
158
+ }
159
+ }
160
+ function StyledLink(_a) {
161
+ var _b = _a, {
162
+ className
163
+ } = _b, restOfProps = __objRest(_b, [
164
+ "className"
165
+ ]);
166
+ return /* @__PURE__ */ jsx(Link, __spreadProps(__spreadValues({}, restOfProps), {
167
+ className: cx(useStyle({
168
+ textDecoration: "none"
169
+ }), className)
170
+ }));
171
+ }
172
+ function InlineElement({
173
+ element,
174
+ attributes,
175
+ children
176
+ }) {
177
+ var _a;
178
+ switch (element.type) {
179
+ case InlineType.Code:
180
+ return /* @__PURE__ */ jsx("code", __spreadProps(__spreadValues({}, attributes), {
181
+ children
182
+ }));
183
+ case InlineType.SuperScript:
184
+ return /* @__PURE__ */ jsx("sup", __spreadProps(__spreadValues({}, attributes), {
185
+ children
186
+ }));
187
+ case InlineType.SubScript:
188
+ return /* @__PURE__ */ jsx("sub", __spreadProps(__spreadValues({}, attributes), {
189
+ children
190
+ }));
191
+ case InlineType.Link:
192
+ return /* @__PURE__ */ jsx(StyledLink, __spreadProps(__spreadValues({}, attributes), {
193
+ link: (_a = element.link) != null ? _a : void 0,
194
+ children
195
+ }));
196
+ }
197
+ }
198
+ function Element(_c) {
199
+ var _d = _c, {
200
+ element
201
+ } = _d, props = __objRest(_d, [
202
+ "element"
203
+ ]);
204
+ switch (element.type) {
205
+ case InlineType.Code:
206
+ case InlineType.SuperScript:
207
+ case InlineType.SubScript:
208
+ case InlineType.Link:
209
+ return /* @__PURE__ */ jsx(InlineElement, __spreadValues({
210
+ element
211
+ }, props));
212
+ case BlockType.Default:
213
+ case BlockType.Paragraph:
214
+ case BlockType.Heading1:
215
+ case BlockType.Heading2:
216
+ case BlockType.Heading3:
217
+ case BlockType.Heading4:
218
+ case BlockType.Heading5:
219
+ case BlockType.Heading6:
220
+ case BlockType.BlockQuote:
221
+ case BlockType.OrderedList:
222
+ case BlockType.UnorderedList:
223
+ case BlockType.ListItem:
224
+ case BlockType.ListItemChild:
225
+ return /* @__PURE__ */ jsx(BlockElement, __spreadValues({
226
+ element
227
+ }, props));
228
+ default:
229
+ return /* @__PURE__ */ jsx("span", __spreadProps(__spreadValues({}, props.attributes), {
230
+ children: props.children
231
+ }));
232
+ }
233
+ }
234
+ function Leaf(_e) {
235
+ var _f = _e, {
236
+ leaf
237
+ } = _f, props = __objRest(_f, [
238
+ "leaf"
239
+ ]);
240
+ const enhancedTypography = useEnhancedTypography(leaf.typography);
241
+ const typographyClassName = useTypographyClassName(enhancedTypography);
242
+ return /* @__PURE__ */ jsx("span", __spreadProps(__spreadValues({}, props.attributes), {
243
+ className: typographyClassName,
244
+ children: props.children
245
+ }));
246
+ }
75
247
  function useSyncDOMSelection(editor, isEnabled) {
76
248
  useIsomorphicLayoutEffect(() => {
77
- if (!isEnabled.current || editor.selection == null || ReactEditor.isFocused(editor))
249
+ if (!isEnabled || editor.selection == null || ReactEditor.isFocused(editor))
78
250
  return;
79
251
  try {
80
252
  const root = ReactEditor.findDocumentOrShadowRoot(editor);
@@ -94,205 +266,110 @@ function useSyncDOMSelection(editor, isEnabled) {
94
266
  }
95
267
  });
96
268
  }
97
- function RichTextV2Element(_a) {
98
- var _b = _a, {
99
- definition,
100
- plugins
101
- } = _b, props = __objRest(_b, [
102
- "definition",
103
- "plugins"
104
- ]);
105
- function initialRenderElement(props2) {
106
- return props2.children;
107
- }
108
- const renderElement = plugins.reduce((renderFn, plugin) => (props2) => {
109
- const {
110
- control,
111
- renderElement: renderElement2
112
- } = plugin;
113
- if ((control == null ? void 0 : control.definition) == null || renderElement2 == null)
114
- return renderFn(props2);
115
- if (control.getElementValue == null)
116
- return renderElement2(renderFn, void 0)(props2);
117
- return /* @__PURE__ */ jsx(ControlValue, {
118
- definition: control.definition,
119
- data: control.getElementValue(props2.element),
120
- children: (value) => renderElement2(renderFn, value)(props2)
121
- });
122
- }, initialRenderElement);
123
- return renderElement(props);
124
- }
125
- function RichTextV2Leaf(_c) {
126
- var _d = _c, {
127
- definition,
128
- plugins
129
- } = _d, props = __objRest(_d, [
130
- "definition",
131
- "plugins"
132
- ]);
133
- function initialRenderLeaf({
134
- attributes,
135
- children,
136
- leaf
137
- }) {
138
- return /* @__PURE__ */ jsx("span", __spreadProps(__spreadValues({
139
- className: leaf.className
140
- }, attributes), {
141
- children
142
- }));
143
- }
144
- const renderLeaf = plugins.reduce((renderFn, plugin) => (props2) => {
145
- const {
146
- control,
147
- renderLeaf: renderLeaf2
148
- } = plugin;
149
- if ((control == null ? void 0 : control.definition) == null || renderLeaf2 == null)
150
- return renderFn(props2);
151
- if (control.getLeafValue == null)
152
- return renderLeaf2(renderFn, void 0)(props2);
153
- return /* @__PURE__ */ jsx(ControlValue, {
154
- definition: control.definition,
155
- data: control.getLeafValue(props2.leaf),
156
- children: (value) => renderLeaf2(renderFn, value)(props2)
157
- });
158
- }, initialRenderLeaf);
159
- return renderLeaf(props);
160
- }
161
- function isChangeWithinPreviousSec(change) {
162
- var _a;
163
- return performance.now() - ((_a = change == null ? void 0 : change.time) != null ? _a : 0) < 1e3;
164
- }
165
- function useSyncRemoteChanges(editor, data) {
269
+ const COMMIT_DEBOUNCE_DELAY = 500;
270
+ function useSyncWithBuilder(editor, text) {
271
+ const [shouldCommit, setShouldCommit] = useState(true);
166
272
  const isInBuilder = useIsInBuilder();
167
273
  useEffect(() => {
168
- var _a, _b, _c;
169
- if (!isChangeWithinPreviousSec(editor.localChanges.get((_a = data == null ? void 0 : data.key) != null ? _a : "")) && data && isInBuilder) {
170
- editor.children = richTextV2DataToDescendents(data);
171
- editor.selection = (_c = (_b = editor == null ? void 0 : editor.localChanges.get(data.key)) == null ? void 0 : _b.selection) != null ? _c : null;
172
- editor.onChange();
274
+ if (shouldCommit && text && isInBuilder) {
275
+ const nextValue = richTextDTOtoDAO(text);
276
+ const nextSelection = richTextDTOtoSelection(text);
277
+ if (!deepEqual(editor.children, nextValue) || !deepEqual(editor.selection, nextSelection)) {
278
+ editor.children = nextValue;
279
+ editor.selection = nextSelection;
280
+ editor.onChange();
281
+ }
173
282
  }
174
- }, [editor, data]);
283
+ }, [editor, shouldCommit, text]);
284
+ useEffect(() => {
285
+ if (shouldCommit)
286
+ return;
287
+ const timeoutId = window.setTimeout(() => {
288
+ setShouldCommit(true);
289
+ }, COMMIT_DEBOUNCE_DELAY);
290
+ return () => {
291
+ window.clearTimeout(timeoutId);
292
+ };
293
+ }, [shouldCommit]);
294
+ return useCallback(() => setShouldCommit(false), []);
175
295
  }
176
296
  const defaultText = [{
177
- type: BlockType.Default,
297
+ type: BlockType.Paragraph,
178
298
  children: [{
179
299
  text: ""
180
300
  }]
181
301
  }];
182
- function EditableTextV2({
302
+ const EditableText = forwardRef(function EditableText2({
303
+ id,
183
304
  text,
184
- definition,
185
- control
186
- }) {
187
- const plugins = useMemo(() => {
188
- var _a;
189
- const plugins2 = [
190
- ...((_a = definition == null ? void 0 : definition.config) == null ? void 0 : _a.mode) === RichTextV2Mode.Inline ? [InlineModePlugin()] : [BlockPlugin(), TypographyPlugin(), TextAlignPlugin(), InlinePlugin(), LinkPlugin()]
191
- ];
192
- return plugins2;
193
- }, [definition]);
194
- const [editor] = useState(() => plugins.reduceRight((editor2, plugin) => {
195
- var _a, _b;
196
- return (_b = (_a = plugin == null ? void 0 : plugin.withPlugin) == null ? void 0 : _a.call(plugin, editor2)) != null ? _b : editor2;
197
- }, withLocalChanges(withBuilder(withReact(createEditor())))));
198
- const isPreservingFocus = useRef(false);
199
- useSyncDOMSelection(editor, isPreservingFocus);
305
+ width,
306
+ margin
307
+ }, ref) {
308
+ const [editor] = useState(() => withBlock(withTypography(withBuilder(withReact(createEditor())))));
309
+ const [isPreservingDOMSElection, setIsPreservingDOMSelection] = useState(false);
310
+ useSyncDOMSelection(editor, isPreservingDOMSElection);
311
+ const delaySync = useSyncWithBuilder(editor, text);
200
312
  const editMode = useBuilderEditMode();
201
- useSyncRemoteChanges(editor, text);
313
+ const [propControllers, setPropControllers] = useState(null);
314
+ const controller = propControllers == null ? void 0 : propControllers.text;
202
315
  useEffect(() => {
203
- if (control == null)
316
+ if (controller == null)
204
317
  return;
205
318
  const element = ReactEditor.toDOMNode(editor, editor);
206
319
  return pollBoxModel({
207
320
  element,
208
- onBoxModelChange: (boxModel) => control.changeBoxModel(boxModel)
321
+ onBoxModelChange: (boxModel) => controller.changeBoxModel(boxModel)
209
322
  });
210
- }, [editor, control]);
211
- const renderElement = useCallback((props) => {
212
- return /* @__PURE__ */ jsx(RichTextV2Element, __spreadProps(__spreadValues({}, props), {
213
- definition,
214
- plugins
215
- }));
216
- }, [plugins, definition]);
217
- const renderLeaf = useCallback((props) => {
218
- return /* @__PURE__ */ jsx(RichTextV2Leaf, __spreadProps(__spreadValues({}, props), {
219
- definition,
220
- plugins
221
- }));
222
- }, [plugins, definition]);
223
- const initialValue = useMemo(() => {
224
- var _a, _b;
225
- return (_b = (_a = text && richTextV2DataToDescendents(text)) != null ? _a : definition.config.defaultValue) != null ? _b : defaultText;
226
- }, [text, definition]);
323
+ }, [editor, controller]);
324
+ useImperativeHandle(ref, () => ({
325
+ getDomNode() {
326
+ return ReactEditor.toDOMNode(editor, editor);
327
+ },
328
+ getBoxModel() {
329
+ return getBox(ReactEditor.toDOMNode(editor, editor));
330
+ },
331
+ setPropControllers
332
+ }), [editor, setPropControllers]);
333
+ const initialValue = useMemo(() => text ? richTextDTOtoDAO(text) : defaultText, [text]);
227
334
  useEffect(() => {
228
- if (editMode !== BuilderEditMode.CONTENT) {
229
- isPreservingFocus.current = false;
230
- ReactEditor.deselect(editor);
231
- }
232
- }, [editMode]);
233
- useEffect(() => {
234
- var _a;
235
- const defaultValue = (_a = definition.config.defaultValue) != null ? _a : defaultText;
236
- control == null ? void 0 : control.setEditor(editor);
237
- control == null ? void 0 : control.setDefaultValue(defaultValue);
238
- if (initialValue === defaultValue) {
239
- control == null ? void 0 : control.onLocalUserChange();
240
- }
241
- }, [control, definition, editor]);
335
+ controller == null ? void 0 : controller.setSlateEditor(editor);
336
+ }, [controller, editor]);
242
337
  const handleFocus = useCallback(() => {
243
- isPreservingFocus.current = true;
244
- control == null ? void 0 : control.select();
245
- }, [control]);
338
+ controller == null ? void 0 : controller.focus();
339
+ setIsPreservingDOMSelection(true);
340
+ }, [controller]);
246
341
  const handleKeyDown = useCallback((e) => {
247
342
  if (isHotkey("mod+shift+z", e))
248
- return control == null ? void 0 : control.redo();
343
+ return controller == null ? void 0 : controller.redo();
249
344
  if (isHotkey("mod+z", e))
250
- return control == null ? void 0 : control.undo();
251
- if (isHotkey("escape")(e)) {
252
- isPreservingFocus.current = false;
253
- ReactEditor.blur(editor);
254
- control == null ? void 0 : control.switchToBuildMode();
255
- }
256
- if (editMode === BuilderEditMode.CONTENT) {
257
- e.stopPropagation();
258
- }
259
- plugins.forEach((plugin) => {
260
- var _a;
261
- return (_a = plugin == null ? void 0 : plugin.onKeyDown) == null ? void 0 : _a.call(plugin, e, editor);
262
- });
263
- }, [control, plugins, editor, editMode]);
264
- const handleKeyUp = useCallback((e) => {
265
- if (editMode === BuilderEditMode.CONTENT) {
266
- e.stopPropagation();
267
- e.preventDefault();
268
- }
269
- }, [control, editor, editMode]);
270
- const handleClick = useCallback((e) => {
271
- if (editMode === BuilderEditMode.CONTENT)
272
- e.stopPropagation();
273
- }, [editMode]);
345
+ return controller == null ? void 0 : controller.undo();
346
+ if (isHotkey("escape")(e))
347
+ return controller == null ? void 0 : controller.blur();
348
+ onKeyDown(e, editor);
349
+ }, [controller, editor]);
274
350
  const handleBlur = useCallback((e) => {
275
- var _a;
276
351
  if (e.relatedTarget == null)
277
352
  return;
278
- if (((_a = e.relatedTarget) == null ? void 0 : _a.getAttribute("contenteditable")) === "true")
279
- isPreservingFocus.current = false;
353
+ setIsPreservingDOMSelection(false);
354
+ ReactEditor.deselect(editor);
280
355
  }, []);
281
356
  return /* @__PURE__ */ jsx(Slate, {
282
357
  editor,
283
358
  value: initialValue,
359
+ onChange: delaySync,
284
360
  children: /* @__PURE__ */ jsx(Editable, {
285
- renderLeaf,
286
- renderElement,
361
+ id,
362
+ renderLeaf: Leaf,
363
+ renderElement: Element,
287
364
  onFocus: handleFocus,
288
365
  onKeyDown: handleKeyDown,
289
- onKeyUp: handleKeyUp,
290
- onClick: handleClick,
291
366
  onBlur: handleBlur,
367
+ className: cx(width, margin),
292
368
  readOnly: editMode !== BuilderEditMode.CONTENT,
293
369
  placeholder: "Write some text..."
294
370
  })
295
371
  });
296
- }
297
- export { EditableTextV2, EditableTextV2 as default };
372
+ });
373
+ var EditableText$1 = EditableText;
374
+ export { EditableText, EditableText$1 as default };
298
375
  //# sourceMappingURL=index.es8.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.es8.js","sources":["../src/runtimes/react/controls/rich-text-v2/EditableTextV2/useSyncDOMSelection.tsx","../src/runtimes/react/controls/rich-text-v2/EditableTextV2/render-element.tsx","../src/runtimes/react/controls/rich-text-v2/EditableTextV2/render-leaf.tsx","../src/runtimes/react/controls/rich-text-v2/EditableTextV2/useRemoteChanges.tsx","../src/runtimes/react/controls/rich-text-v2/EditableTextV2/editable-text-v2.tsx"],"sourcesContent":["import { Editor, Range as SlateRange } from 'slate'\nimport { useIsomorphicLayoutEffect } from '../../../../../components/hooks/useIsomorphicLayoutEffect'\nimport { MutableRefObject } from 'react'\nimport { ReactEditor } from 'slate-react'\n\n/**\n * Clicking outside of the host blurs our `<Editable />`.\n * `<Editable />` only updates the DOM's selection to match slate when it is focused.\n * In the case of a panel being clicked this hook updates the DOM selection to match slate.\n */\nexport function useSyncDOMSelection(editor: Editor, isEnabled: MutableRefObject<boolean>) {\n useIsomorphicLayoutEffect(() => {\n if (!isEnabled.current || editor.selection == null || ReactEditor.isFocused(editor)) return\n try {\n const root = ReactEditor.findDocumentOrShadowRoot(editor) as Document\n const domSelection = root.getSelection()\n const newDomRange: Range | null = ReactEditor.toDOMRange(editor, editor.selection)\n\n if (newDomRange) {\n if (SlateRange.isBackward(editor.selection!)) {\n domSelection?.setBaseAndExtent(\n newDomRange.endContainer,\n newDomRange.endOffset,\n newDomRange.startContainer,\n newDomRange.startOffset,\n )\n } else {\n domSelection?.setBaseAndExtent(\n newDomRange.startContainer,\n newDomRange.startOffset,\n newDomRange.endContainer,\n newDomRange.endOffset,\n )\n }\n } else {\n domSelection?.removeAllRanges()\n }\n } catch (e) {\n console.error(e)\n }\n })\n}\n","import { RenderElementProps } from 'slate-react'\nimport { RichTextV2ControlDefinition } from '../../../../../controls'\nimport { ControlValue } from '../../control'\nimport { RichTextV2Plugin } from '../../../../../controls/rich-text-v2/plugin'\n\ntype RichTextV2ElementProps = RenderElementProps & {\n definition: RichTextV2ControlDefinition\n plugins: RichTextV2Plugin[]\n}\n\nexport function RichTextV2Element({ definition, plugins, ...props }: RichTextV2ElementProps) {\n function initialRenderElement(props: RenderElementProps) {\n return props.children\n }\n\n const renderElement = plugins.reduce(\n (renderFn, plugin) => (props: RenderElementProps) => {\n const { control, renderElement } = plugin\n\n if (control?.definition == null || renderElement == null) return renderFn(props)\n\n if (control.getElementValue == null) return renderElement(renderFn, undefined)(props)\n\n return (\n <ControlValue definition={control.definition} data={control.getElementValue(props.element)}>\n {value => renderElement(renderFn, value)(props)}\n </ControlValue>\n )\n },\n initialRenderElement,\n )\n\n return renderElement(props)\n}\n","import { RenderLeafProps } from 'slate-react'\nimport { RichTextV2ControlDefinition } from '../../../../../controls'\nimport { ControlValue } from '../../control'\nimport { RichTextV2Plugin } from '../../../../../controls/rich-text-v2/plugin'\n\ntype RichTextV2LeafProps = RenderLeafProps & {\n definition: RichTextV2ControlDefinition\n plugins: RichTextV2Plugin[]\n}\n\nexport function RichTextV2Leaf({ definition, plugins, ...props }: RichTextV2LeafProps) {\n function initialRenderLeaf({ attributes, children, leaf }: RenderLeafProps) {\n return (\n <span className={leaf.className} {...attributes}>\n {children}\n </span>\n )\n }\n\n const renderLeaf = plugins.reduce(\n (renderFn, plugin) => (props: RenderLeafProps) => {\n const { control, renderLeaf } = plugin\n\n if (control?.definition == null || renderLeaf == null) return renderFn(props)\n\n if (control.getLeafValue == null) return renderLeaf(renderFn, undefined)(props)\n\n return (\n <ControlValue definition={control.definition} data={control.getLeafValue(props.leaf)}>\n {value => renderLeaf(renderFn, value)(props)}\n </ControlValue>\n )\n },\n initialRenderLeaf,\n )\n\n return renderLeaf(props)\n}\n","import { useEffect } from 'react'\nimport { Editor } from 'slate'\nimport { RichTextV2ControlData, richTextV2DataToDescendents } from '../../../../../controls'\nimport { LocalChange } from '../../../../../slate'\nimport { useIsInBuilder } from '../../..'\n\n// From the component point of view we can't know if the change came from an action or a undo/redo\n// So we diff the time and force updates on actions that occured over a second ago.\nfunction isChangeWithinPreviousSec(change?: LocalChange) {\n return performance.now() - (change?.time ?? 0) < 1000\n}\n\nexport function useSyncRemoteChanges(editor: Editor, data?: RichTextV2ControlData) {\n const isInBuilder = useIsInBuilder()\n\n useEffect(() => {\n if (\n !isChangeWithinPreviousSec(editor.localChanges.get(data?.key ?? '')) &&\n data &&\n isInBuilder\n ) {\n editor.children = richTextV2DataToDescendents(data)\n editor.selection = editor?.localChanges.get(data.key)?.selection ?? null\n editor.onChange()\n }\n }, [editor, data])\n}\n","import {\n FocusEvent,\n KeyboardEvent,\n MouseEvent,\n ReactNode,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from 'react'\nimport { Descendant, createEditor } from 'slate'\nimport isHotkey from 'is-hotkey'\nimport {\n withReact,\n ReactEditor,\n RenderElementProps,\n RenderLeafProps,\n Slate,\n Editable,\n} from 'slate-react'\n\nimport {\n RichTextV2Control,\n RichTextV2ControlData,\n RichTextV2ControlDefinition,\n RichTextV2Mode,\n} from '../../../../../controls'\nimport { useBuilderEditMode } from '../../..'\nimport { BuilderEditMode } from '../../../../../state/modules/builder-edit-mode'\nimport { pollBoxModel } from '../../../poll-box-model'\nimport {\n BlockPlugin,\n InlineModePlugin,\n InlinePlugin,\n LinkPlugin,\n TextAlignPlugin,\n TypographyPlugin,\n withBuilder,\n withLocalChanges,\n} from '../../../../../slate'\nimport { useSyncDOMSelection } from './useSyncDOMSelection'\nimport { BlockType } from '../../../../../slate'\nimport { RichTextV2Element } from './render-element'\nimport { RichTextV2Leaf } from './render-leaf'\nimport { richTextV2DataToDescendents } from '../../../../../controls/rich-text-v2/translation'\nimport { useSyncRemoteChanges } from './useRemoteChanges'\n\nexport type RichTextV2ControlValue = ReactNode\n\nexport type Descriptors = { text?: RichTextV2ControlDefinition }\n\nconst defaultText: Descendant[] = [{ type: BlockType.Default, children: [{ text: '' }] }]\n\ntype Props = {\n text?: RichTextV2ControlData\n definition: RichTextV2ControlDefinition\n control: RichTextV2Control | null\n}\n\nexport function EditableTextV2({ text, definition, control }: Props) {\n const plugins = useMemo(() => {\n const plugins = [\n /**\n * TODO: we are manually referencing our default plugins for each mode here because\n * Referencing the real LinkPlugin causes a circular dependency.\n * When circular dependencies calm down we should update the plugin definition to use real plugins,\n * and just use the plugins that are defined by our config.\n */\n // ...(definition?.config?.plugins ?? []),\n ...(definition?.config?.mode === RichTextV2Mode.Inline\n ? [InlineModePlugin()]\n : [BlockPlugin(), TypographyPlugin(), TextAlignPlugin(), InlinePlugin(), LinkPlugin()]),\n ]\n return plugins\n }, [definition])\n\n const [editor] = useState(() =>\n plugins.reduceRight(\n (editor, plugin) => plugin?.withPlugin?.(editor) ?? editor,\n withLocalChanges(withBuilder(withReact(createEditor()))),\n ),\n )\n\n const isPreservingFocus = useRef(false)\n useSyncDOMSelection(editor, isPreservingFocus)\n\n const editMode = useBuilderEditMode()\n\n useSyncRemoteChanges(editor, text)\n\n useEffect(() => {\n if (control == null) return\n\n const element = ReactEditor.toDOMNode(editor, editor)\n return pollBoxModel({\n element,\n onBoxModelChange: boxModel => control.changeBoxModel(boxModel),\n })\n }, [editor, control])\n\n const renderElement = useCallback(\n (props: RenderElementProps) => {\n return <RichTextV2Element {...props} definition={definition} plugins={plugins} />\n },\n [plugins, definition],\n )\n\n const renderLeaf = useCallback(\n (props: RenderLeafProps) => {\n return <RichTextV2Leaf {...props} definition={definition} plugins={plugins} />\n },\n [plugins, definition],\n )\n\n const initialValue = useMemo(\n () =>\n (text && richTextV2DataToDescendents(text)) ?? definition.config.defaultValue ?? defaultText,\n [text, definition],\n )\n\n useEffect(() => {\n /**\n * This is required because clicking on the overlay has `relatedTarget` null just like the sidebar, but\n * - in the case of the overlay we switch to BUILD mode\n * - in the case of the sidebar we preserve the selection\n */\n if (editMode !== BuilderEditMode.CONTENT) {\n isPreservingFocus.current = false\n ReactEditor.deselect(editor)\n }\n }, [editMode])\n\n useEffect(() => {\n const defaultValue = definition.config.defaultValue ?? defaultText\n\n control?.setEditor(editor)\n control?.setDefaultValue(defaultValue)\n\n /**\n * When initialValue is set to the default value we need to trigger an local change so that the sidebar updates and so the data is saved\n */\n if (initialValue === defaultValue) {\n control?.onLocalUserChange()\n }\n }, [control, definition, editor])\n\n const handleFocus = useCallback(() => {\n isPreservingFocus.current = true\n control?.select()\n }, [control])\n\n const handleKeyDown = useCallback(\n (e: KeyboardEvent) => {\n if (isHotkey('mod+shift+z', e)) return control?.redo()\n if (isHotkey('mod+z', e)) return control?.undo()\n if (isHotkey('escape')(e)) {\n isPreservingFocus.current = false\n ReactEditor.blur(editor)\n control?.switchToBuildMode()\n }\n\n if (editMode === BuilderEditMode.CONTENT) {\n e.stopPropagation()\n }\n\n plugins.forEach(plugin => plugin?.onKeyDown?.(e, editor))\n },\n [control, plugins, editor, editMode],\n )\n\n const handleKeyUp = useCallback(\n (e: KeyboardEvent) => {\n if (editMode === BuilderEditMode.CONTENT) {\n e.stopPropagation()\n e.preventDefault()\n }\n },\n [control, editor, editMode],\n )\n\n const handleClick = useCallback(\n (e: MouseEvent) => {\n if (editMode === BuilderEditMode.CONTENT) e.stopPropagation()\n },\n [editMode],\n )\n\n const handleBlur = useCallback((e: FocusEvent) => {\n // outside of iframe (overlay, sidebar, etc)\n if (e.relatedTarget == null) return\n // another text\n if (e.relatedTarget?.getAttribute('contenteditable') === 'true')\n isPreservingFocus.current = false\n }, [])\n\n return (\n <Slate editor={editor} value={initialValue}>\n <Editable\n renderLeaf={renderLeaf}\n renderElement={renderElement}\n onFocus={handleFocus}\n onKeyDown={handleKeyDown}\n onKeyUp={handleKeyUp}\n onClick={handleClick}\n onBlur={handleBlur}\n readOnly={editMode !== BuilderEditMode.CONTENT}\n placeholder=\"Write some text...\"\n />\n </Slate>\n )\n}\n\nexport default EditableTextV2\n"],"names":["editor","isEnabled","useIsomorphicLayoutEffect","current","selection","ReactEditor","isFocused","root","findDocumentOrShadowRoot","domSelection","getSelection","newDomRange","toDOMRange","SlateRange","isBackward","setBaseAndExtent","endContainer","endOffset","startContainer","startOffset","removeAllRanges","e","console","error","definition","plugins","props","children","renderElement","reduce","renderFn","plugin","control","getElementValue","undefined","element","value","initialRenderElement","attributes","leaf","className","renderLeaf","getLeafValue","initialRenderLeaf","change","performance","now","time","data","isInBuilder","useIsInBuilder","useEffect","isChangeWithinPreviousSec","localChanges","get","key","richTextV2DataToDescendents","onChange","defaultText","type","BlockType","Default","text","useMemo","config","mode","RichTextV2Mode","Inline","InlineModePlugin","BlockPlugin","TypographyPlugin","TextAlignPlugin","InlinePlugin","LinkPlugin","useState","reduceRight","withPlugin","withLocalChanges","withBuilder","withReact","createEditor","isPreservingFocus","useRef","useSyncDOMSelection","editMode","useBuilderEditMode","useSyncRemoteChanges","toDOMNode","pollBoxModel","onBoxModelChange","boxModel","changeBoxModel","useCallback","initialValue","defaultValue","BuilderEditMode","CONTENT","deselect","setEditor","setDefaultValue","onLocalUserChange","handleFocus","select","handleKeyDown","isHotkey","redo","undo","blur","switchToBuildMode","stopPropagation","forEach","onKeyDown","handleKeyUp","preventDefault","handleClick","handleBlur","relatedTarget","getAttribute"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAUO,6BAA6BA,QAAgBC,WAAsC;AACxFC,4BAA0B,MAAM;AAC1B,QAAA,CAACD,UAAUE,WAAWH,OAAOI,aAAa,QAAQC,YAAYC,UAAUN,MAAtB;AAA+B;AACjF,QAAA;AACIO,YAAAA,OAAOF,YAAYG,yBAAyBR,MAArC;AACPS,YAAAA,eAAeF,KAAKG;AAC1B,YAAMC,cAA4BN,YAAYO,WAAWZ,QAAQA,OAAOI,SAAtC;AAElC,UAAIO,aAAa;AACXE,YAAAA,MAAWC,WAAWd,OAAOI,SAA7B,GAA0C;AAC9BW,uDAAAA,iBACZJ,YAAYK,cACZL,YAAYM,WACZN,YAAYO,gBACZP,YAAYQ;AAAAA,QAJd,OAMK;AACSJ,uDAAAA,iBACZJ,YAAYO,gBACZP,YAAYQ,aACZR,YAAYK,cACZL,YAAYM;AAAAA,QAEf;AAAA,MAAA,OACI;AACLR,qDAAcW;AAAAA,MACf;AAAA,aACMC;AACPC,cAAQC,MAAMF,CAAd;AAAA,IACD;AAAA,EAAA,CA5BsB;AA8B1B;AC/BiC,2BAAA,IAA2D;AAA3D,eAAEG;AAAAA;AAAAA,IAAYC;AAAAA,MAAd,IAA0BC,kBAA1B,IAA0BA;AAAAA,IAAxBF;AAAAA,IAAYC;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AkB;;AAEhD,QAAIA,EAAE+F,iBAAiB;AAAM;AAE7B,QAAI/F,SAAE+F,kBAAF/F,mBAAiBgG,aAAa,wBAAuB;AACvDpC,wBAAkB9E,UAAU;AAAA,EALF,GAM3B,CAN2B,CAAA;AAQ9B,6BACG,OAAD;AAAA,IAAO;AAAA,IAAgB,OAAO0F;AAAAA,IAA9B,8BACG,UAAD;AAAA,MACE;AAAA,MACA;AAAA,MACA,SAASQ;AAAAA,MACT,WAAWE;AAAAA,MACX,SAASS;AAAAA,MACT,SAASE;AAAAA,MACT,QAAQC;AAAAA,MACR,UAAU/B,aAAaW,gBAAgBC;AAAAA,MACvC,aAAY;AAAA,IAAA,CATd;AAAA,EAAA,CAFJ;AAeD;;"}
1
+ {"version":3,"file":"index.es8.js","sources":["../src/runtimes/react/controls/rich-text/components/Element/block.tsx","../src/runtimes/react/controls/rich-text/components/Element/inline.tsx","../src/runtimes/react/controls/rich-text/components/Element/element.tsx","../src/runtimes/react/controls/rich-text/components/Leaf/leaf.tsx","../src/runtimes/react/controls/rich-text/EditableText/useSyncDOMSelection.tsx","../src/runtimes/react/controls/rich-text/EditableText/useSyncWithBuilder.tsx","../src/runtimes/react/controls/rich-text/EditableText/editable-text.tsx"],"sourcesContent":["import { cx } from '@emotion/css'\nimport { RenderElementProps } from 'slate-react'\nimport { useResponsiveStyle } from '../../../../../../components/utils/responsive-style'\nimport { Block, BlockType } from '../../../../../../slate'\nimport { useStyle } from '../../../../use-style'\n\nexport interface InlineRenderElementProps extends RenderElementProps {\n element: Block\n}\n\nexport function BlockElement({ element, attributes, children }: InlineRenderElementProps) {\n const blockStyles = [\n useStyle({ margin: 0 }),\n useStyle(useResponsiveStyle([element.textAlign], ([textAlign = 'left']) => ({ textAlign }))),\n ]\n\n const quoteStyles = useStyle({\n padding: '0.5em 10px',\n fontSize: '1.25em',\n fontWeight: '300',\n borderLeft: '5px solid rgba(0, 0, 0, 0.1)',\n })\n\n switch (element.type) {\n case BlockType.Default:\n case BlockType.Paragraph:\n return (\n <p {...attributes} className={cx(...blockStyles)}>\n {children}\n </p>\n )\n case BlockType.Heading1:\n return (\n <h1 {...attributes} className={cx(...blockStyles)}>\n {children}\n </h1>\n )\n case BlockType.Heading2:\n return (\n <h2 {...attributes} className={cx(...blockStyles)}>\n {children}\n </h2>\n )\n case BlockType.Heading3:\n return (\n <h3 {...attributes} className={cx(...blockStyles)}>\n {children}\n </h3>\n )\n case BlockType.Heading4:\n return (\n <h4 {...attributes} className={cx(...blockStyles)}>\n {children}\n </h4>\n )\n case BlockType.Heading5:\n return (\n <h5 {...attributes} className={cx(...blockStyles)}>\n {children}\n </h5>\n )\n case BlockType.Heading6:\n return (\n <h6 {...attributes} className={cx(...blockStyles)}>\n {children}\n </h6>\n )\n case BlockType.BlockQuote:\n return (\n <blockquote {...attributes} className={cx(...blockStyles, quoteStyles)}>\n {children}\n </blockquote>\n )\n case BlockType.OrderedList:\n return (\n <ol {...attributes} className={cx(...blockStyles)} style={{ listStylePosition: 'inside' }}>\n {children}\n </ol>\n )\n case BlockType.UnorderedList:\n return (\n <ul {...attributes} className={cx(...blockStyles)} style={{ listStylePosition: 'inside' }}>\n {children}\n </ul>\n )\n case BlockType.ListItem:\n return (\n <li {...attributes} className={cx(...blockStyles)}>\n {children}\n </li>\n )\n case BlockType.ListItemChild:\n return (\n <span {...attributes} className={cx(...blockStyles)}>\n {children}\n </span>\n )\n }\n}\n","import { cx } from '@emotion/css'\nimport { ComponentPropsWithoutRef } from 'react'\nimport { RenderElementProps } from 'slate-react'\nimport { Inline, InlineType } from '../../../../../../slate/types'\nimport { useStyle } from '../../../../use-style'\nimport { Link } from '../../../../../../components/shared/Link'\n\nfunction StyledLink({ className, ...restOfProps }: ComponentPropsWithoutRef<typeof Link>) {\n return <Link {...restOfProps} className={cx(useStyle({ textDecoration: 'none' }), className)} />\n}\n\nexport interface InlineRenderElementProps extends RenderElementProps {\n element: Inline\n}\n\nexport function InlineElement({ element, attributes, children }: InlineRenderElementProps) {\n switch (element.type) {\n case InlineType.Code:\n return <code {...attributes}>{children}</code>\n case InlineType.SuperScript:\n return <sup {...attributes}>{children}</sup>\n case InlineType.SubScript:\n return <sub {...attributes}>{children}</sub>\n case InlineType.Link:\n return (\n <StyledLink {...attributes} link={element.link ?? undefined}>\n {children}\n </StyledLink>\n )\n }\n}\n","import { RenderElementProps } from 'slate-react'\nimport { BlockElement } from './block'\nimport { InlineElement } from './inline'\nimport { BlockType, InlineType } from '../../../../../../slate/types'\n\nexport function Element({ element, ...props }: RenderElementProps) {\n switch (element.type) {\n case InlineType.Code:\n case InlineType.SuperScript:\n case InlineType.SubScript:\n case InlineType.Link:\n return <InlineElement element={element} {...props} />\n case BlockType.Default:\n case BlockType.Paragraph:\n case BlockType.Heading1:\n case BlockType.Heading2:\n case BlockType.Heading3:\n case BlockType.Heading4:\n case BlockType.Heading5:\n case BlockType.Heading6:\n case BlockType.BlockQuote:\n case BlockType.OrderedList:\n case BlockType.UnorderedList:\n case BlockType.ListItem:\n case BlockType.ListItemChild:\n return <BlockElement element={element} {...props} />\n default:\n return <span {...props.attributes}>{props.children}</span>\n }\n}\n","import { RenderLeafProps } from 'slate-react'\nimport useEnhancedTypography, { useTypographyClassName } from '../../../typography'\n\nexport function Leaf({ leaf, ...props }: RenderLeafProps) {\n // for each breakpoint fetch related resources and merge its value with its override\n const enhancedTypography = useEnhancedTypography(leaf.typography)\n\n // for each breakpoint shallow merge back up through the breakpoints and create a className\n const typographyClassName = useTypographyClassName(enhancedTypography)\n\n return (\n <span {...props.attributes} className={typographyClassName}>\n {props.children}\n </span>\n )\n}\n","import { ReactEditor } from 'slate-react'\nimport { Editor, Range as SlateRange } from 'slate'\nimport { useIsomorphicLayoutEffect } from '../../../../../components/hooks/useIsomorphicLayoutEffect'\n\n/**\n * Clicking outside of the host blurs our `<Editable />`.\n * `<Editable />` only updates the DOM's selection to match slate when it is focused.\n * In the case of a panel being clicked this hook updates the DOM selection to match slate.\n */\nexport function useSyncDOMSelection(editor: Editor, isEnabled: boolean) {\n useIsomorphicLayoutEffect(() => {\n if (!isEnabled || editor.selection == null || ReactEditor.isFocused(editor)) return\n try {\n const root = ReactEditor.findDocumentOrShadowRoot(editor) as Document\n const domSelection = root.getSelection()\n const newDomRange: Range | null = ReactEditor.toDOMRange(editor, editor.selection)\n\n if (newDomRange) {\n if (SlateRange.isBackward(editor.selection!)) {\n domSelection?.setBaseAndExtent(\n newDomRange.endContainer,\n newDomRange.endOffset,\n newDomRange.startContainer,\n newDomRange.startOffset,\n )\n } else {\n domSelection?.setBaseAndExtent(\n newDomRange.startContainer,\n newDomRange.startOffset,\n newDomRange.endContainer,\n newDomRange.endOffset,\n )\n }\n } else {\n domSelection?.removeAllRanges()\n }\n } catch (e) {\n console.error(e)\n }\n })\n}\n","import { useState, useEffect, useCallback } from 'react'\nimport { Editor } from 'slate'\nimport { useIsInBuilder } from '../../../../../react'\nimport { richTextDTOtoDAO, richTextDTOtoSelection } from '../../../../../controls'\nimport { RichTextValue } from '../../../../../prop-controllers'\nimport deepEqual from '../../../../../utils/deepEqual'\n\nconst COMMIT_DEBOUNCE_DELAY = 500\n\n/**\n * Compare new prop value with current editor and update editor\n * if the values are not equal.\n */\nexport function useSyncWithBuilder(editor: Editor, text?: RichTextValue) {\n const [shouldCommit, setShouldCommit] = useState(true)\n const isInBuilder = useIsInBuilder()\n\n useEffect(() => {\n if (shouldCommit && text && isInBuilder) {\n const nextValue = richTextDTOtoDAO(text)\n const nextSelection = richTextDTOtoSelection(text)\n if (!deepEqual(editor.children, nextValue) || !deepEqual(editor.selection, nextSelection)) {\n editor.children = nextValue\n editor.selection = nextSelection\n editor.onChange()\n }\n }\n }, [editor, shouldCommit, text])\n\n useEffect(() => {\n if (shouldCommit) return\n\n const timeoutId = window.setTimeout(() => {\n setShouldCommit(true)\n }, COMMIT_DEBOUNCE_DELAY)\n\n return () => {\n window.clearTimeout(timeoutId)\n }\n }, [shouldCommit])\n\n return useCallback(() => setShouldCommit(false), [])\n}\n","import { cx } from '@emotion/css'\nimport { getBox } from 'css-box-model'\nimport isHotkey from 'is-hotkey'\nimport {\n FocusEvent,\n forwardRef,\n KeyboardEvent,\n Ref,\n useCallback,\n useEffect,\n useImperativeHandle,\n useMemo,\n useState,\n} from 'react'\n\nimport { createEditor } from 'slate'\nimport { Slate, Editable, withReact, ReactEditor } from 'slate-react'\nimport { useBuilderEditMode } from '../../..'\nimport { richTextDTOtoDAO } from '../../../../../controls'\nimport { RichTextValue } from '../../../../../prop-controllers'\nimport { ElementIDValue } from '../../../../../prop-controllers/descriptors'\nimport { DescriptorsPropControllers } from '../../../../../prop-controllers/instances'\nimport {\n RichTextDAO,\n BlockType,\n withBlock,\n withTypography,\n withBuilder,\n onKeyDown,\n} from '../../../../../slate'\nimport { BuilderEditMode } from '../../../../../state/modules/builder-edit-mode'\nimport { PropControllersHandle } from '../../../../../state/modules/prop-controller-handles'\nimport { pollBoxModel } from '../../../poll-box-model'\nimport { Element, Leaf } from '../components'\nimport { Descriptors } from '../rich-text'\nimport { useSyncDOMSelection } from './useSyncDOMSelection'\nimport { useSyncWithBuilder } from './useSyncWithBuilder'\n\ntype Props = {\n id?: ElementIDValue\n text?: RichTextValue\n width?: string\n margin?: string\n}\n\nconst defaultText: RichTextDAO = [{ type: BlockType.Paragraph, children: [{ text: '' }] }]\n\nexport const EditableText = forwardRef(function EditableText(\n { id, text, width, margin }: Props,\n ref: Ref<PropControllersHandle<Descriptors>>,\n) {\n const [editor] = useState(() => withBlock(withTypography(withBuilder(withReact(createEditor())))))\n const [isPreservingDOMSElection, setIsPreservingDOMSelection] = useState(false)\n useSyncDOMSelection(editor, isPreservingDOMSElection)\n const delaySync = useSyncWithBuilder(editor, text)\n const editMode = useBuilderEditMode()\n\n const [propControllers, setPropControllers] =\n useState<DescriptorsPropControllers<Descriptors> | null>(null)\n const controller = propControllers?.text\n\n useEffect(() => {\n if (controller == null) return\n\n const element = ReactEditor.toDOMNode(editor, editor)\n\n return pollBoxModel({\n element,\n onBoxModelChange: boxModel => controller.changeBoxModel(boxModel),\n })\n }, [editor, controller])\n\n useImperativeHandle(\n ref,\n () => ({\n getDomNode() {\n return ReactEditor.toDOMNode(editor, editor)\n },\n getBoxModel() {\n return getBox(ReactEditor.toDOMNode(editor, editor))\n },\n setPropControllers,\n }),\n [editor, setPropControllers],\n )\n\n const initialValue = useMemo(() => (text ? richTextDTOtoDAO(text) : defaultText), [text])\n\n useEffect(() => {\n controller?.setSlateEditor(editor)\n }, [controller, editor])\n\n const handleFocus = useCallback(() => {\n controller?.focus()\n setIsPreservingDOMSelection(true)\n }, [controller])\n\n const handleKeyDown = useCallback(\n (e: KeyboardEvent) => {\n if (isHotkey('mod+shift+z', e)) return controller?.redo()\n if (isHotkey('mod+z', e)) return controller?.undo()\n if (isHotkey('escape')(e)) return controller?.blur()\n onKeyDown(e, editor)\n },\n [controller, editor],\n )\n\n const handleBlur = useCallback((e: FocusEvent) => {\n // When clicking outside of the iframe (`relatedTarget` is null) we want to preserve the DOM selection.\n if (e.relatedTarget == null) return\n // Otherwise we want to deselect on blur and stop preserving selection.\n setIsPreservingDOMSelection(false)\n ReactEditor.deselect(editor)\n }, [])\n\n return (\n <Slate editor={editor} value={initialValue} onChange={delaySync}>\n <Editable\n id={id}\n renderLeaf={Leaf}\n renderElement={Element}\n onFocus={handleFocus}\n onKeyDown={handleKeyDown}\n onBlur={handleBlur}\n className={cx(width, margin)}\n readOnly={editMode !== BuilderEditMode.CONTENT}\n placeholder=\"Write some text...\"\n />\n </Slate>\n )\n})\n\nexport default EditableText\n"],"names":["element","attributes","children","blockStyles","useStyle","margin","useResponsiveStyle","textAlign","quoteStyles","padding","fontSize","fontWeight","borderLeft","type","BlockType","Default","Paragraph","cx","Heading1","Heading2","Heading3","Heading4","Heading5","Heading6","BlockQuote","OrderedList","listStylePosition","UnorderedList","ListItem","ListItemChild","className","restOfProps","textDecoration","InlineType","Code","SuperScript","SubScript","Link","link","undefined","props","leaf","enhancedTypography","useEnhancedTypography","typography","typographyClassName","useTypographyClassName","editor","isEnabled","useIsomorphicLayoutEffect","selection","ReactEditor","isFocused","root","findDocumentOrShadowRoot","domSelection","getSelection","newDomRange","toDOMRange","SlateRange","isBackward","setBaseAndExtent","endContainer","endOffset","startContainer","startOffset","removeAllRanges","e","console","error","COMMIT_DEBOUNCE_DELAY","text","shouldCommit","setShouldCommit","useState","isInBuilder","useIsInBuilder","useEffect","nextValue","richTextDTOtoDAO","nextSelection","richTextDTOtoSelection","deepEqual","onChange","timeoutId","window","setTimeout","clearTimeout","useCallback","defaultText","EditableText","forwardRef","id","width","ref","withBlock","withTypography","withBuilder","withReact","createEditor","isPreservingDOMSElection","setIsPreservingDOMSelection","useSyncDOMSelection","delaySync","useSyncWithBuilder","editMode","useBuilderEditMode","propControllers","setPropControllers","controller","toDOMNode","pollBoxModel","onBoxModelChange","boxModel","changeBoxModel","useImperativeHandle","getDomNode","getBoxModel","getBox","initialValue","useMemo","setSlateEditor","handleFocus","focus","handleKeyDown","isHotkey","redo","undo","blur","onKeyDown","handleBlur","relatedTarget","deselect","Leaf","Element","BuilderEditMode","CONTENT"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAU6B,sBAAA;AAAA,EAAEA;AAAAA,EAASC;AAAAA,EAAYC;AAAAA,GAAsC;AAClFC,QAAAA,cAAc,CAClBC,SAAS;AAAA,IAAEC,QAAQ;AAAA,EAAA,CAAX,GACRD,SAASE,mBAAmB,CAACN,QAAQO,SAAT,GAAqB,CAAC,CAACA,YAAY,YAAa;AAAA,IAAEA;AAAAA,EAAAA,EAAnD,CAAnB,CAFU;AAKdC,QAAAA,cAAcJ,SAAS;AAAA,IAC3BK,SAAS;AAAA,IACTC,UAAU;AAAA,IACVC,YAAY;AAAA,IACZC,YAAY;AAAA,EAAA,CAJc;AAOpBZ,UAAAA,QAAQa;AAAAA,SACTC,UAAUC;AAAAA,SACVD,UAAUE;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