@makeswift/runtime 0.9.2 → 0.9.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 (197) 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 +1 -3
  6. package/dist/Button.cjs.js.map +1 -1
  7. package/dist/Button.es.js +2 -4
  8. package/dist/Button.es.js.map +1 -1
  9. package/dist/Carousel.cjs.js +1 -3
  10. package/dist/Carousel.cjs.js.map +1 -1
  11. package/dist/Carousel.es.js +2 -4
  12. package/dist/Carousel.es.js.map +1 -1
  13. package/dist/Countdown.cjs.js +1 -3
  14. package/dist/Countdown.cjs.js.map +1 -1
  15. package/dist/Countdown.es.js +2 -4
  16. package/dist/Countdown.es.js.map +1 -1
  17. package/dist/Divider.cjs.js +1 -3
  18. package/dist/Divider.cjs.js.map +1 -1
  19. package/dist/Divider.es.js +2 -4
  20. package/dist/Divider.es.js.map +1 -1
  21. package/dist/Embed.es.js +1 -1
  22. package/dist/Form.cjs.js +1 -3
  23. package/dist/Form.cjs.js.map +1 -1
  24. package/dist/Form.es.js +2 -4
  25. package/dist/Form.es.js.map +1 -1
  26. package/dist/Image.cjs.js +1 -3
  27. package/dist/Image.cjs.js.map +1 -1
  28. package/dist/Image.es.js +2 -4
  29. package/dist/Image.es.js.map +1 -1
  30. package/dist/LiveProvider.cjs.js +1 -3
  31. package/dist/LiveProvider.cjs.js.map +1 -1
  32. package/dist/LiveProvider.es.js +2 -4
  33. package/dist/LiveProvider.es.js.map +1 -1
  34. package/dist/Navigation.cjs.js +1 -3
  35. package/dist/Navigation.cjs.js.map +1 -1
  36. package/dist/Navigation.es.js +2 -4
  37. package/dist/Navigation.es.js.map +1 -1
  38. package/dist/PreviewProvider.cjs.js +3 -5
  39. package/dist/PreviewProvider.cjs.js.map +1 -1
  40. package/dist/PreviewProvider.es.js +3 -5
  41. package/dist/PreviewProvider.es.js.map +1 -1
  42. package/dist/ReadOnlyText.cjs.js +4 -7
  43. package/dist/ReadOnlyText.cjs.js.map +1 -1
  44. package/dist/ReadOnlyText.es.js +4 -7
  45. package/dist/ReadOnlyText.es.js.map +1 -1
  46. package/dist/ReadOnlyTextV2.cjs.js +11 -14
  47. package/dist/ReadOnlyTextV2.cjs.js.map +1 -1
  48. package/dist/ReadOnlyTextV2.es.js +10 -13
  49. package/dist/ReadOnlyTextV2.es.js.map +1 -1
  50. package/dist/Root.cjs.js +1 -3
  51. package/dist/Root.cjs.js.map +1 -1
  52. package/dist/Root.es.js +2 -4
  53. package/dist/Root.es.js.map +1 -1
  54. package/dist/SocialLinks.cjs.js +1 -3
  55. package/dist/SocialLinks.cjs.js.map +1 -1
  56. package/dist/SocialLinks.es.js +2 -4
  57. package/dist/SocialLinks.es.js.map +1 -1
  58. package/dist/Text.cjs.js +2 -4
  59. package/dist/Text.cjs.js.map +1 -1
  60. package/dist/Text.es.js +2 -4
  61. package/dist/Text.es.js.map +1 -1
  62. package/dist/Video.es.js +1 -1
  63. package/dist/components.cjs.js +1 -3
  64. package/dist/components.cjs.js.map +1 -1
  65. package/dist/components.es.js +1 -3
  66. package/dist/components.es.js.map +1 -1
  67. package/dist/control-serialization.es.js +1 -1
  68. package/dist/controls.cjs.js +18 -15
  69. package/dist/controls.cjs.js.map +1 -1
  70. package/dist/controls.es.js +2 -3
  71. package/dist/controls.es.js.map +1 -1
  72. package/dist/index.cjs.js +205 -57
  73. package/dist/index.cjs.js.map +1 -1
  74. package/dist/index.cjs10.js +261 -172
  75. package/dist/index.cjs10.js.map +1 -1
  76. package/dist/index.cjs5.js +99 -5
  77. package/dist/index.cjs5.js.map +1 -1
  78. package/dist/index.cjs6.js +23 -700
  79. package/dist/index.cjs6.js.map +1 -1
  80. package/dist/index.cjs7.js +13 -37
  81. package/dist/index.cjs7.js.map +1 -1
  82. package/dist/index.cjs8.js +39 -17
  83. package/dist/index.cjs8.js.map +1 -1
  84. package/dist/index.cjs9.js +269 -16
  85. package/dist/index.cjs9.js.map +1 -1
  86. package/dist/index.es.js +187 -41
  87. package/dist/index.es.js.map +1 -1
  88. package/dist/index.es10.js +262 -173
  89. package/dist/index.es10.js.map +1 -1
  90. package/dist/index.es2.js +1 -1
  91. package/dist/index.es4.js +1 -1
  92. package/dist/index.es5.js +91 -2
  93. package/dist/index.es5.js.map +1 -1
  94. package/dist/index.es6.js +23 -695
  95. package/dist/index.es6.js.map +1 -1
  96. package/dist/index.es7.js +14 -33
  97. package/dist/index.es7.js.map +1 -1
  98. package/dist/index.es8.js +37 -17
  99. package/dist/index.es8.js.map +1 -1
  100. package/dist/index.es9.js +264 -15
  101. package/dist/index.es9.js.map +1 -1
  102. package/dist/next.cjs.js +1 -3
  103. package/dist/next.cjs.js.map +1 -1
  104. package/dist/next.es.js +2 -4
  105. package/dist/next.es.js.map +1 -1
  106. package/dist/react-page.cjs.js +97 -9
  107. package/dist/react-page.cjs.js.map +1 -1
  108. package/dist/react-page.es.js +95 -9
  109. package/dist/react-page.es.js.map +1 -1
  110. package/dist/react.cjs.js +1 -3
  111. package/dist/react.cjs.js.map +1 -1
  112. package/dist/react.es.js +1 -3
  113. package/dist/react.es.js.map +1 -1
  114. package/dist/slate.cjs.js +260 -97
  115. package/dist/slate.cjs.js.map +1 -1
  116. package/dist/slate.es.js +249 -92
  117. package/dist/slate.es.js.map +1 -1
  118. package/dist/types/src/components/builtin/Button/Button.d.ts +1 -1
  119. package/dist/types/src/components/builtin/Form/components/Field/components/Checkbox/index.d.ts +1 -1
  120. package/dist/types/src/components/builtin/Text/ReadOnlyText.d.ts.map +1 -1
  121. package/dist/types/src/components/builtin/Text/components/Leaf/leaf.d.ts +0 -17
  122. package/dist/types/src/components/builtin/Text/components/Leaf/leaf.d.ts.map +1 -1
  123. package/dist/types/src/controls/control.d.ts +3 -2
  124. package/dist/types/src/controls/control.d.ts.map +1 -1
  125. package/dist/types/src/controls/icon-radio-group.d.ts +5 -2
  126. package/dist/types/src/controls/icon-radio-group.d.ts.map +1 -1
  127. package/dist/types/src/controls/index.d.ts +1 -0
  128. package/dist/types/src/controls/index.d.ts.map +1 -1
  129. package/dist/types/src/controls/list.d.ts +2 -0
  130. package/dist/types/src/controls/list.d.ts.map +1 -1
  131. package/dist/types/src/controls/shape.d.ts +2 -0
  132. package/dist/types/src/controls/shape.d.ts.map +1 -1
  133. package/dist/types/src/controls/style-v2.d.ts.map +1 -1
  134. package/dist/types/src/controls/typography.d.ts +31 -0
  135. package/dist/types/src/controls/typography.d.ts.map +1 -0
  136. package/dist/types/src/next/client.d.ts.map +1 -1
  137. package/dist/types/src/prop-controllers/descriptors.d.ts +6 -3
  138. package/dist/types/src/prop-controllers/descriptors.d.ts.map +1 -1
  139. package/dist/types/src/prop-controllers/introspection.d.ts +1 -1
  140. package/dist/types/src/prop-controllers/introspection.d.ts.map +1 -1
  141. package/dist/types/src/runtimes/react/controls/control.d.ts +3 -2
  142. package/dist/types/src/runtimes/react/controls/control.d.ts.map +1 -1
  143. package/dist/types/src/runtimes/react/controls/rich-text-v2/ReadOnlyTextV2.d.ts.map +1 -1
  144. package/dist/types/src/runtimes/react/controls/typography.d.ts +21 -0
  145. package/dist/types/src/runtimes/react/controls/typography.d.ts.map +1 -0
  146. package/dist/types/src/runtimes/react/controls.d.ts.map +1 -1
  147. package/dist/types/src/slate/InlinePlugin/getValue.d.ts +5 -0
  148. package/dist/types/src/slate/InlinePlugin/getValue.d.ts.map +1 -0
  149. package/dist/types/src/slate/InlinePlugin/index.d.ts +16 -0
  150. package/dist/types/src/slate/InlinePlugin/index.d.ts.map +1 -0
  151. package/dist/types/src/slate/InlinePlugin/onChange.d.ts +4 -0
  152. package/dist/types/src/slate/InlinePlugin/onChange.d.ts.map +1 -0
  153. package/dist/types/src/slate/InlinePlugin/types.d.ts +9 -0
  154. package/dist/types/src/slate/InlinePlugin/types.d.ts.map +1 -0
  155. package/dist/types/src/slate/LinkPlugin/getValue.d.ts +5 -0
  156. package/dist/types/src/slate/LinkPlugin/getValue.d.ts.map +1 -0
  157. package/dist/types/src/slate/LinkPlugin/index.d.ts +15 -0
  158. package/dist/types/src/slate/LinkPlugin/index.d.ts.map +1 -0
  159. package/dist/types/src/slate/LinkPlugin/onChange.d.ts +4 -0
  160. package/dist/types/src/slate/LinkPlugin/onChange.d.ts.map +1 -0
  161. package/dist/types/src/slate/LinkPlugin/types.d.ts +5 -0
  162. package/dist/types/src/slate/LinkPlugin/types.d.ts.map +1 -0
  163. package/dist/types/src/slate/TextAlignPlugin/index.d.ts +2 -0
  164. package/dist/types/src/slate/TextAlignPlugin/index.d.ts.map +1 -1
  165. package/dist/types/src/slate/TypographyPlugin/index.d.ts +9 -0
  166. package/dist/types/src/slate/TypographyPlugin/index.d.ts.map +1 -1
  167. package/dist/types/src/slate/index.d.ts +2 -0
  168. package/dist/types/src/slate/index.d.ts.map +1 -1
  169. package/dist/types.cjs2.js +753 -0
  170. package/dist/types.cjs2.js.map +1 -0
  171. package/dist/types.es2.js +736 -0
  172. package/dist/types.es2.js.map +1 -0
  173. package/dist/typography.cjs.js +56 -0
  174. package/dist/typography.cjs.js.map +1 -0
  175. package/dist/typography.es.js +41 -0
  176. package/dist/typography.es.js.map +1 -0
  177. package/package.json +1 -1
  178. package/dist/deepEqual.cjs.js +0 -40
  179. package/dist/deepEqual.cjs.js.map +0 -1
  180. package/dist/deepEqual.es.js +0 -39
  181. package/dist/deepEqual.es.js.map +0 -1
  182. package/dist/index.cjs11.js +0 -375
  183. package/dist/index.cjs11.js.map +0 -1
  184. package/dist/index.es11.js +0 -368
  185. package/dist/index.es11.js.map +0 -1
  186. package/dist/leaf.cjs.js +0 -182
  187. package/dist/leaf.cjs.js.map +0 -1
  188. package/dist/leaf.es.js +0 -179
  189. package/dist/leaf.es.js.map +0 -1
  190. package/dist/select.cjs.js +0 -21
  191. package/dist/select.cjs.js.map +0 -1
  192. package/dist/select.es.js +0 -16
  193. package/dist/select.es.js.map +0 -1
  194. package/dist/text-input.cjs.js +0 -26
  195. package/dist/text-input.cjs.js.map +0 -1
  196. package/dist/text-input.es.js +0 -18
  197. package/dist/text-input.es.js.map +0 -1
@@ -29,35 +29,33 @@ var __objRest = (source, exclude) => {
29
29
  }
30
30
  return target;
31
31
  };
32
- import { useMemo, useState, useRef, useEffect, useCallback } from "react";
32
+ import { useCallback, useState, useEffect, forwardRef, useImperativeHandle, useMemo } from "react";
33
33
  import { Range, createEditor } from "slate";
34
- import isHotkey from "is-hotkey";
35
- import { withHistory, HistoryEditor } from "slate-history";
36
34
  import { ReactEditor, withReact, Slate, Editable } from "slate-react";
37
- import { Z as useStyle, b5 as RichTextV2Mode, bb as BlockType, bk as BuilderEditMode } from "./react-page.es.js";
38
35
  import { cx } from "@emotion/css";
36
+ import { g as getBox } from "./box-models.es.js";
37
+ import { U as useStyle, be as BlockType, bc as InlineType, b4 as richTextDTOtoDAO, b3 as richTextDTOtoSelection, bm as BuilderEditMode } from "./react-page.es.js";
39
38
  import "@emotion/serialize";
40
39
  import "@emotion/utils";
41
- import { N as ControlValue, O as useBuilderEditMode, Q as pollBoxModel } from "./index.es.js";
40
+ import { U as useEnhancedTypography, V as useTypographyClassName, n as useResponsiveStyle, u as useIsInBuilder, K as deepEqual, Q as useBuilderEditMode, T as pollBoxModel } from "./index.es.js";
41
+ import { jsx } from "react/jsx-runtime";
42
42
  import "./state/breakpoints.es.js";
43
- import "./index.es6.js";
44
- import { I as InlineModePlugin } from "./index.es7.js";
45
- import { w as withBuilder } from "./index.es8.js";
43
+ import { b as withBlock, o as onKeyDown } from "./types.es2.js";
44
+ import isHotkey from "is-hotkey";
45
+ import { L as Link } from "./index.es3.js";
46
+ import { w as withTypography } from "./index.es5.js";
47
+ import { w as withBuilder } from "./index.es7.js";
46
48
  import { u as useIsomorphicLayoutEffect } from "./useIsomorphicLayoutEffect.es.js";
47
- import { jsx } from "react/jsx-runtime";
49
+ import "css-box-model";
50
+ import "./actions.es.js";
48
51
  import "redux";
49
52
  import "redux-thunk";
50
- import "./actions.es.js";
51
53
  import "use-sync-external-store/shim/with-selector";
52
54
  import "next/dynamic";
53
- import "./text-input.es.js";
55
+ import "./typography.es.js";
54
56
  import "./combobox.es.js";
55
- import "./select.es.js";
56
57
  import "use-sync-external-store/shim";
57
58
  import "./types.es.js";
58
- import "./deepEqual.es.js";
59
- import "./box-models.es.js";
60
- import "css-box-model";
61
59
  import "color";
62
60
  import "scroll-into-view-if-needed";
63
61
  import "react-dom";
@@ -74,9 +72,211 @@ import "set-cookie-parser";
74
72
  import "./constants.es.js";
75
73
  import "uuid";
76
74
  import "corporate-ipsum";
75
+ import "next/link";
76
+ function Leaf(_a) {
77
+ var _b = _a, {
78
+ leaf
79
+ } = _b, props = __objRest(_b, [
80
+ "leaf"
81
+ ]);
82
+ const enhancedTypography = useEnhancedTypography(leaf.typography);
83
+ const typographyClassName = useTypographyClassName(enhancedTypography);
84
+ return /* @__PURE__ */ jsx("span", __spreadProps(__spreadValues({}, props.attributes), {
85
+ className: typographyClassName,
86
+ children: props.children
87
+ }));
88
+ }
89
+ function BlockElement({
90
+ element,
91
+ attributes,
92
+ children
93
+ }) {
94
+ const blockStyles = [useStyle({
95
+ margin: 0
96
+ }), useStyle(useResponsiveStyle([element.textAlign], ([textAlign = "left"]) => ({
97
+ textAlign
98
+ })))];
99
+ const quoteStyles = useStyle({
100
+ padding: "0.5em 10px",
101
+ fontSize: "1.25em",
102
+ fontWeight: "300",
103
+ borderLeft: "5px solid rgba(0, 0, 0, 0.1)"
104
+ });
105
+ switch (element.type) {
106
+ case BlockType.Text:
107
+ return /* @__PURE__ */ jsx("span", __spreadProps(__spreadValues({}, attributes), {
108
+ className: cx(...blockStyles),
109
+ children
110
+ }));
111
+ case BlockType.Paragraph:
112
+ return /* @__PURE__ */ jsx("p", __spreadProps(__spreadValues({}, attributes), {
113
+ className: cx(...blockStyles),
114
+ children
115
+ }));
116
+ case BlockType.Heading1:
117
+ return /* @__PURE__ */ jsx("h1", __spreadProps(__spreadValues({}, attributes), {
118
+ className: cx(...blockStyles),
119
+ children
120
+ }));
121
+ case BlockType.Heading2:
122
+ return /* @__PURE__ */ jsx("h2", __spreadProps(__spreadValues({}, attributes), {
123
+ className: cx(...blockStyles),
124
+ children
125
+ }));
126
+ case BlockType.Heading3:
127
+ return /* @__PURE__ */ jsx("h3", __spreadProps(__spreadValues({}, attributes), {
128
+ className: cx(...blockStyles),
129
+ children
130
+ }));
131
+ case BlockType.Heading4:
132
+ return /* @__PURE__ */ jsx("h4", __spreadProps(__spreadValues({}, attributes), {
133
+ className: cx(...blockStyles),
134
+ children
135
+ }));
136
+ case BlockType.Heading5:
137
+ return /* @__PURE__ */ jsx("h5", __spreadProps(__spreadValues({}, attributes), {
138
+ className: cx(...blockStyles),
139
+ children
140
+ }));
141
+ case BlockType.Heading6:
142
+ return /* @__PURE__ */ jsx("h6", __spreadProps(__spreadValues({}, attributes), {
143
+ className: cx(...blockStyles),
144
+ children
145
+ }));
146
+ case BlockType.BlockQuote:
147
+ return /* @__PURE__ */ jsx("blockquote", __spreadProps(__spreadValues({}, attributes), {
148
+ className: cx(...blockStyles, quoteStyles),
149
+ children
150
+ }));
151
+ case BlockType.OrderedList:
152
+ return /* @__PURE__ */ jsx("ol", __spreadProps(__spreadValues({}, attributes), {
153
+ className: cx(...blockStyles),
154
+ style: {
155
+ listStylePosition: "inside"
156
+ },
157
+ children
158
+ }));
159
+ case BlockType.UnorderedList:
160
+ return /* @__PURE__ */ jsx("ul", __spreadProps(__spreadValues({}, attributes), {
161
+ className: cx(...blockStyles),
162
+ style: {
163
+ listStylePosition: "inside"
164
+ },
165
+ children
166
+ }));
167
+ case BlockType.ListItem:
168
+ return /* @__PURE__ */ jsx("li", __spreadProps(__spreadValues({}, attributes), {
169
+ className: cx(...blockStyles),
170
+ children
171
+ }));
172
+ case BlockType.ListItemChild:
173
+ return /* @__PURE__ */ jsx("span", __spreadProps(__spreadValues({}, attributes), {
174
+ className: cx(...blockStyles),
175
+ children
176
+ }));
177
+ default:
178
+ return null;
179
+ }
180
+ }
181
+ function StyledLink(_c) {
182
+ var _d = _c, {
183
+ className
184
+ } = _d, restOfProps = __objRest(_d, [
185
+ "className"
186
+ ]);
187
+ return /* @__PURE__ */ jsx(Link, __spreadProps(__spreadValues({}, restOfProps), {
188
+ className: cx(useStyle({
189
+ textDecoration: "none"
190
+ }), className)
191
+ }));
192
+ }
193
+ function InlineElement({
194
+ element,
195
+ attributes,
196
+ children
197
+ }) {
198
+ switch (element.type) {
199
+ case InlineType.Code:
200
+ return /* @__PURE__ */ jsx("code", __spreadProps(__spreadValues({}, attributes), {
201
+ children
202
+ }));
203
+ case InlineType.SuperScript:
204
+ return /* @__PURE__ */ jsx("sup", __spreadProps(__spreadValues({}, attributes), {
205
+ children
206
+ }));
207
+ case InlineType.SubScript:
208
+ return /* @__PURE__ */ jsx("sub", __spreadProps(__spreadValues({}, attributes), {
209
+ children
210
+ }));
211
+ case InlineType.Link:
212
+ return /* @__PURE__ */ jsx(StyledLink, __spreadProps(__spreadValues({}, attributes), {
213
+ link: element.link,
214
+ children
215
+ }));
216
+ }
217
+ }
218
+ function Element(_e) {
219
+ var _f = _e, {
220
+ element
221
+ } = _f, props = __objRest(_f, [
222
+ "element"
223
+ ]);
224
+ switch (element.type) {
225
+ case InlineType.Code:
226
+ case InlineType.SuperScript:
227
+ case InlineType.SubScript:
228
+ case InlineType.Link:
229
+ return /* @__PURE__ */ jsx(InlineElement, __spreadValues({
230
+ element
231
+ }, props));
232
+ case BlockType.Paragraph:
233
+ case BlockType.Heading1:
234
+ case BlockType.Heading2:
235
+ case BlockType.Heading3:
236
+ case BlockType.BlockQuote:
237
+ case BlockType.OrderedList:
238
+ case BlockType.UnorderedList:
239
+ case BlockType.ListItem:
240
+ case BlockType.ListItemChild:
241
+ return /* @__PURE__ */ jsx(BlockElement, __spreadValues({
242
+ element
243
+ }, props));
244
+ default:
245
+ return /* @__PURE__ */ jsx("span", __spreadProps(__spreadValues({}, props.attributes), {
246
+ children: props.children
247
+ }));
248
+ }
249
+ }
250
+ const COMMIT_DEBOUNCE_DELAY = 500;
251
+ function useSyncWithBuilder(editor, text) {
252
+ const [shouldCommit, setShouldCommit] = useState(true);
253
+ const isInBuilder = useIsInBuilder();
254
+ useEffect(() => {
255
+ if (shouldCommit && text && isInBuilder) {
256
+ const nextValue = richTextDTOtoDAO(text);
257
+ const nextSelection = richTextDTOtoSelection(text);
258
+ if (!deepEqual(editor.children, nextValue) || !deepEqual(editor.selection, nextSelection)) {
259
+ editor.children = nextValue;
260
+ editor.selection = nextSelection;
261
+ editor.onChange();
262
+ }
263
+ }
264
+ }, [editor, shouldCommit, text]);
265
+ useEffect(() => {
266
+ if (shouldCommit)
267
+ return;
268
+ const timeoutId = window.setTimeout(() => {
269
+ setShouldCommit(true);
270
+ }, COMMIT_DEBOUNCE_DELAY);
271
+ return () => {
272
+ window.clearTimeout(timeoutId);
273
+ };
274
+ }, [shouldCommit]);
275
+ return useCallback(() => setShouldCommit(false), []);
276
+ }
77
277
  function useSyncDOMSelection(editor, isEnabled) {
78
278
  useIsomorphicLayoutEffect(() => {
79
- if (!isEnabled.current || editor.selection == null || ReactEditor.isFocused(editor))
279
+ if (!isEnabled || editor.selection == null || ReactEditor.isFocused(editor))
80
280
  return;
81
281
  try {
82
282
  const root = ReactEditor.findDocumentOrShadowRoot(editor);
@@ -96,194 +296,83 @@ function useSyncDOMSelection(editor, isEnabled) {
96
296
  }
97
297
  });
98
298
  }
99
- function RichTextV2Element(_a) {
100
- var _b = _a, {
101
- definition,
102
- plugins
103
- } = _b, props = __objRest(_b, [
104
- "definition",
105
- "plugins"
106
- ]);
107
- const blockStyles = [useStyle({
108
- margin: 0
109
- })];
110
- function initialRenderElement(props2) {
111
- switch (props2.element.type) {
112
- case BlockType.Default:
113
- default:
114
- if (definition.config.mode === RichTextV2Mode.Inline) {
115
- return /* @__PURE__ */ jsx("span", __spreadProps(__spreadValues({}, props2.attributes), {
116
- className: cx(...blockStyles),
117
- children: props2.children
118
- }));
119
- }
120
- return /* @__PURE__ */ jsx("p", __spreadProps(__spreadValues({}, props2.attributes), {
121
- className: cx(...blockStyles),
122
- children: props2.children
123
- }));
124
- }
125
- }
126
- const renderElement = plugins.reduce((renderFn, plugin) => (props2) => {
127
- const {
128
- control,
129
- renderElement: renderElement2
130
- } = plugin;
131
- if ((control == null ? void 0 : control.definition) == null || renderElement2 == null)
132
- return renderFn(props2);
133
- if (control.getElementValue == null)
134
- return renderElement2(renderFn, void 0)(props2);
135
- return /* @__PURE__ */ jsx(ControlValue, {
136
- definition: control.definition,
137
- data: control.getElementValue(props2.element),
138
- children: (value) => renderElement2(renderFn, value)(props2)
139
- });
140
- }, initialRenderElement);
141
- return renderElement(props);
142
- }
143
- function RichTextV2Leaf(_c) {
144
- var _d = _c, {
145
- definition,
146
- plugins
147
- } = _d, props = __objRest(_d, [
148
- "definition",
149
- "plugins"
150
- ]);
151
- function initialRenderLeaf({
152
- attributes,
153
- children,
154
- leaf
155
- }) {
156
- return /* @__PURE__ */ jsx("span", __spreadProps(__spreadValues({
157
- className: leaf.className
158
- }, attributes), {
159
- children
160
- }));
161
- }
162
- const renderLeaf = plugins.reduce((renderFn, plugin) => (props2) => {
163
- const {
164
- control,
165
- renderLeaf: renderLeaf2
166
- } = plugin;
167
- if ((control == null ? void 0 : control.definition) == null || renderLeaf2 == null)
168
- return renderFn(props2);
169
- if (control.getLeafValue == null)
170
- return renderLeaf2(renderFn, void 0)(props2);
171
- return /* @__PURE__ */ jsx(ControlValue, {
172
- definition: control.definition,
173
- data: control.getLeafValue(props2.leaf),
174
- children: (value) => renderLeaf2(renderFn, value)(props2)
175
- });
176
- }, initialRenderLeaf);
177
- return renderLeaf(props);
178
- }
179
299
  const defaultText = [{
180
- type: BlockType.Default,
300
+ type: BlockType.Paragraph,
181
301
  children: [{
182
302
  text: ""
183
303
  }]
184
304
  }];
185
- function EditableTextV2({
305
+ const EditableText = forwardRef(function EditableText2({
306
+ id,
186
307
  text,
187
- definition,
188
- control
189
- }) {
190
- const plugins = useMemo(() => {
191
- var _a, _b, _c;
192
- const plugins2 = [...(_b = (_a = definition == null ? void 0 : definition.config) == null ? void 0 : _a.plugins) != null ? _b : [], ...((_c = definition == null ? void 0 : definition.config) == null ? void 0 : _c.mode) === RichTextV2Mode.Inline ? [InlineModePlugin] : []];
193
- return plugins2;
194
- }, [definition]);
195
- const [editor] = useState(() => plugins.reduceRight((editor2, plugin) => {
196
- var _a, _b;
197
- return (_b = (_a = plugin == null ? void 0 : plugin.withPlugin) == null ? void 0 : _a.call(plugin, editor2)) != null ? _b : editor2;
198
- }, withBuilder(withHistory(withReact(createEditor())))));
199
- const isPreservingFocus = useRef(false);
200
- useSyncDOMSelection(editor, isPreservingFocus);
308
+ width,
309
+ margin
310
+ }, ref) {
311
+ const [editor] = useState(() => withBlock(withTypography(withBuilder(withReact(createEditor())))));
312
+ const [isPreservingDOMSElection, setIsPreservingDOMSelection] = useState(false);
313
+ useSyncDOMSelection(editor, isPreservingDOMSElection);
314
+ const delaySync = useSyncWithBuilder(editor, text);
201
315
  const editMode = useBuilderEditMode();
316
+ const [propControllers, setPropControllers] = useState(null);
317
+ const controller = propControllers == null ? void 0 : propControllers.text;
202
318
  useEffect(() => {
203
- if (control == null)
319
+ if (controller == null)
204
320
  return;
205
321
  const element = ReactEditor.toDOMNode(editor, editor);
206
322
  return pollBoxModel({
207
323
  element,
208
- onBoxModelChange: (boxModel) => control.changeBoxModel(boxModel)
324
+ onBoxModelChange: (boxModel) => controller.changeBoxModel(boxModel)
209
325
  });
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(() => text != null ? text : defaultText, [text]);
224
- useEffect(() => {
225
- if (editMode !== BuilderEditMode.CONTENT) {
226
- isPreservingFocus.current = false;
227
- ReactEditor.deselect(editor);
228
- }
229
- }, [editMode]);
326
+ }, [editor, controller]);
327
+ useImperativeHandle(ref, () => ({
328
+ getDomNode() {
329
+ return ReactEditor.toDOMNode(editor, editor);
330
+ },
331
+ getBoxModel() {
332
+ return getBox(ReactEditor.toDOMNode(editor, editor));
333
+ },
334
+ setPropControllers
335
+ }), [editor, setPropControllers]);
336
+ const initialValue = useMemo(() => text ? richTextDTOtoDAO(text) : defaultText, [text]);
230
337
  useEffect(() => {
231
- control == null ? void 0 : control.setEditor(editor);
232
- control == null ? void 0 : control.setDefaultValue(defaultText);
233
- }, [control, editor, defaultText]);
338
+ controller == null ? void 0 : controller.setSlateEditor(editor);
339
+ }, [controller, editor]);
234
340
  const handleFocus = useCallback(() => {
235
- isPreservingFocus.current = true;
236
- control == null ? void 0 : control.select();
237
- }, [control]);
341
+ controller == null ? void 0 : controller.focus();
342
+ setIsPreservingDOMSelection(true);
343
+ }, [controller]);
238
344
  const handleKeyDown = useCallback((e) => {
239
345
  if (isHotkey("mod+shift+z", e))
240
- return HistoryEditor.redo(editor);
346
+ return controller == null ? void 0 : controller.redo();
241
347
  if (isHotkey("mod+z", e))
242
- return HistoryEditor.undo(editor);
243
- if (isHotkey("escape")(e)) {
244
- isPreservingFocus.current = false;
245
- ReactEditor.blur(editor);
246
- control == null ? void 0 : control.switchToBuildMode();
247
- }
248
- plugins.forEach((plugin) => {
249
- var _a;
250
- return (_a = plugin == null ? void 0 : plugin.onKeyDown) == null ? void 0 : _a.call(plugin, e, editor);
251
- });
252
- }, [control, plugins, editor]);
253
- const handleKeyUp = useCallback((e) => {
254
- if (editMode === BuilderEditMode.CONTENT)
255
- e.preventDefault();
256
- }, [control, editor, editMode]);
257
- const handleClick = useCallback((e) => {
258
- if (editMode === BuilderEditMode.CONTENT)
259
- e.stopPropagation();
260
- }, [editMode]);
348
+ return controller == null ? void 0 : controller.undo();
349
+ if (isHotkey("escape")(e))
350
+ return controller == null ? void 0 : controller.blur();
351
+ onKeyDown(e, editor);
352
+ }, [controller, editor]);
261
353
  const handleBlur = useCallback((e) => {
262
- var _a;
263
354
  if (e.relatedTarget == null)
264
355
  return;
265
- if (((_a = e.relatedTarget) == null ? void 0 : _a.getAttribute("contenteditable")) === "true")
266
- isPreservingFocus.current = false;
356
+ setIsPreservingDOMSelection(false);
357
+ ReactEditor.deselect(editor);
267
358
  }, []);
268
- const handleOnChange = useCallback((value) => {
269
- control == null ? void 0 : control.onChange(value);
270
- }, [control]);
271
359
  return /* @__PURE__ */ jsx(Slate, {
272
360
  editor,
273
- onChange: handleOnChange,
274
361
  value: initialValue,
362
+ onChange: delaySync,
275
363
  children: /* @__PURE__ */ jsx(Editable, {
276
- renderLeaf,
277
- renderElement,
364
+ id,
365
+ renderLeaf: Leaf,
366
+ renderElement: Element,
278
367
  onFocus: handleFocus,
279
368
  onKeyDown: handleKeyDown,
280
- onKeyUp: handleKeyUp,
281
- onClick: handleClick,
282
369
  onBlur: handleBlur,
370
+ className: cx(width, margin),
283
371
  readOnly: editMode !== BuilderEditMode.CONTENT,
284
372
  placeholder: "Write some text..."
285
373
  })
286
374
  });
287
- }
288
- export { EditableTextV2, EditableTextV2 as default };
375
+ });
376
+ var EditableText$1 = EditableText;
377
+ export { EditableText, EditableText$1 as default };
289
378
  //# sourceMappingURL=index.es10.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.es10.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/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 { cx } from '@emotion/css'\nimport { RenderElementProps } from 'slate-react'\nimport {\n RichTextV2ControlDefinition,\n RichTextV2Plugin,\n RichTextV2Mode,\n} from '../../../../../controls'\nimport { BlockType } from '../../../../../slate'\nimport { useStyle } from '../../../use-style'\nimport { ControlValue } from '../../control'\n\ntype RichTextV2ElementProps = RenderElementProps & {\n definition: RichTextV2ControlDefinition\n plugins: RichTextV2Plugin[]\n}\n\nexport function RichTextV2Element({ definition, plugins, ...props }: RichTextV2ElementProps) {\n const blockStyles = [useStyle({ margin: 0 })]\n\n function initialRenderElement(props: RenderElementProps) {\n switch (props.element.type) {\n case BlockType.Default:\n default:\n if (definition.config.mode === RichTextV2Mode.Inline) {\n return (\n <span {...props.attributes} className={cx(...blockStyles)}>\n {props.children}\n </span>\n )\n }\n\n return (\n <p {...props.attributes} className={cx(...blockStyles)}>\n {props.children}\n </p>\n )\n }\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, RichTextV2Plugin } from '../../../../../controls'\nimport { ControlValue } from '../../control'\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 {\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 { withHistory, HistoryEditor } from 'slate-history'\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 { InlineModePlugin, withBuilder } from '../../../../../slate'\nimport { useSyncDOMSelection } from './useSyncDOMSelection'\nimport { BlockType } from '../../../../../slate'\nimport { RichTextV2Element } from './render-element'\nimport { RichTextV2Leaf } from './render-leaf'\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 ...(definition?.config?.plugins ?? []),\n ...(definition?.config?.mode === RichTextV2Mode.Inline ? [InlineModePlugin] : []),\n ]\n return plugins\n }, [definition])\n\n const [editor] = useState(() =>\n plugins.reduceRight(\n (editor, plugin) => plugin?.withPlugin?.(editor) ?? editor,\n withBuilder(withHistory(withReact(createEditor()))),\n ),\n )\n\n const isPreservingFocus = useRef(false)\n useSyncDOMSelection(editor, isPreservingFocus)\n\n const editMode = useBuilderEditMode()\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(() => text ?? defaultText, [text])\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 control?.setEditor(editor)\n control?.setDefaultValue(defaultText)\n }, [control, editor, defaultText])\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 HistoryEditor.redo(editor)\n if (isHotkey('mod+z', e)) return HistoryEditor.undo(editor)\n if (isHotkey('escape')(e)) {\n isPreservingFocus.current = false\n ReactEditor.blur(editor)\n control?.switchToBuildMode()\n }\n\n plugins.forEach(plugin => plugin?.onKeyDown?.(e, editor))\n },\n [control, plugins, editor],\n )\n\n const handleKeyUp = useCallback(\n (e: KeyboardEvent) => {\n if (editMode === BuilderEditMode.CONTENT) e.preventDefault()\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 const handleOnChange = useCallback(\n (value: Descendant[]) => {\n control?.onChange(value)\n },\n [control],\n )\n\n return (\n <Slate editor={editor} onChange={handleOnChange} 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","blockStyles","useStyle","margin","element","type","BlockType","Default","config","mode","RichTextV2Mode","Inline","attributes","cx","children","renderElement","reduce","renderFn","plugin","control","getElementValue","undefined","value","initialRenderElement","leaf","className","renderLeaf","getLeafValue","initialRenderLeaf","defaultText","text","useMemo","InlineModePlugin","useState","reduceRight","withPlugin","withBuilder","withHistory","withReact","createEditor","isPreservingFocus","useRef","useSyncDOMSelection","editMode","useBuilderEditMode","useEffect","toDOMNode","pollBoxModel","onBoxModelChange","boxModel","changeBoxModel","useCallback","initialValue","BuilderEditMode","CONTENT","deselect","setEditor","setDefaultValue","handleFocus","select","handleKeyDown","isHotkey","HistoryEditor","redo","undo","blur","switchToBuildMode","forEach","onKeyDown","handleKeyUp","preventDefault","handleClick","stopPropagation","handleBlur","relatedTarget","getAttribute","handleOnChange","onChange"],"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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AF/E,mBAAiBgF,aAAa,wBAAuB;AACvDnC,wBAAkB/D,UAAU;AAAA,EALF,GAM3B,CAN2B,CAAA;AAQxBmG,QAAAA,iBAAiBzB,YACrB,CAAC7B,UAAwB;AACvBH,uCAAS0D,SAASvD;AAAAA,EAAlB,GAEF,CAACH,OAAD,CAJgC;AAOlC,6BACG,OAAD;AAAA,IAAO;AAAA,IAAgB,UAAUyD;AAAAA,IAAgB,OAAOxB;AAAAA,IAAxD,8BACG,UAAD;AAAA,MACE;AAAA,MACA;AAAA,MACA,SAASM;AAAAA,MACT,WAAWE;AAAAA,MACX,SAASS;AAAAA,MACT,SAASE;AAAAA,MACT,QAAQE;AAAAA,MACR,UAAU9B,aAAaU,gBAAgBC;AAAAA,MACvC,aAAY;AAAA,IAAA,CATd;AAAA,EAAA,CAFJ;AAeD;;"}
1
+ {"version":3,"file":"index.es10.js","sources":["../src/components/builtin/Text/components/Leaf/leaf.tsx","../src/components/builtin/Text/components/Element/block.tsx","../src/components/builtin/Text/components/Element/inline.tsx","../src/components/builtin/Text/components/Element/element.tsx","../src/components/builtin/Text/EditableText/useSyncWithBuilder.tsx","../src/components/builtin/Text/EditableText/useSyncDOMSelection.tsx","../src/components/builtin/Text/EditableText/editable-text.tsx"],"sourcesContent":["import { RenderLeafProps } from 'slate-react'\nimport useEnhancedTypography, {\n useTypographyClassName,\n} from '../../../../../runtimes/react/controls/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 { cx } from '@emotion/css'\nimport { RenderElementProps } from 'slate-react'\nimport { useStyle } from '../../../../../runtimes/react/use-style'\nimport { useResponsiveStyle } from '../../../../utils/responsive-style'\nimport { Block, BlockType } from '../../../../../slate'\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.Text:\n return (\n <span {...attributes} className={cx(...blockStyles)}>\n {children}\n </span>\n )\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 default:\n return null\n }\n}\n","import { cx } from '@emotion/css'\nimport { ComponentPropsWithoutRef } from 'react'\nimport { RenderElementProps } from 'slate-react'\nimport { useStyle } from '../../../../../runtimes/react/use-style'\nimport { Link } from '../../../../shared/Link'\nimport { Inline, InlineType } from '../../../../../slate'\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}>\n {children}\n </StyledLink>\n )\n }\n}\n","import { RenderElementProps } from 'slate-react'\nimport { BlockElement } from './block'\nimport { InlineElement } from './inline'\nimport { InlineType, BlockType } from '../../../../../slate'\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.Paragraph:\n case BlockType.Heading1:\n case BlockType.Heading2:\n case BlockType.Heading3:\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 { useState, useEffect, useCallback } from 'react'\nimport { Editor } from 'slate'\nimport { richTextDTOtoDAO, richTextDTOtoSelection } from '../../../../controls'\nimport { RichTextValue } from '../../../../prop-controllers'\nimport deepEqual from '../../../../utils/deepEqual'\nimport { useIsInBuilder } from '../../../../runtimes/react'\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 { ReactEditor } from 'slate-react'\nimport { useIsomorphicLayoutEffect } from '../../../hooks/useIsomorphicLayoutEffect'\nimport { Editor, Range as SlateRange } from 'slate'\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 {\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'\n\nimport { ElementIDValue, RichTextValue } from '../../../../prop-controllers/descriptors'\nimport { cx } from '@emotion/css'\nimport { DescriptorsPropControllers } from '../../../../prop-controllers/instances'\nimport { Descriptors } from '../../../../runtimes/react/controls/rich-text'\nimport { getBox } from '../../../../box-model'\nimport { PropControllersHandle } from '../../../../state/modules/prop-controller-handles'\nimport { richTextDTOtoDAO } from '../../../../controls'\nimport { Leaf } from '../components/Leaf'\nimport { Element } from '../components/Element'\nimport { useSyncWithBuilder } from './useSyncWithBuilder'\nimport isHotkey from 'is-hotkey'\nimport { useBuilderEditMode } from '../../../../runtimes/react'\nimport { BuilderEditMode } from '../../../../state/modules/builder-edit-mode'\nimport { onKeyDown, withBlock, withTypography, withBuilder } from '../../../../slate'\nimport { pollBoxModel } from '../../../../runtimes/react/poll-box-model'\nimport { useSyncDOMSelection } from './useSyncDOMSelection'\nimport { RichTextDAO, BlockType } from '../../../../slate'\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":["leaf","props","enhancedTypography","useEnhancedTypography","typography","typographyClassName","useTypographyClassName","attributes","children","element","blockStyles","useStyle","margin","useResponsiveStyle","textAlign","quoteStyles","padding","fontSize","fontWeight","borderLeft","type","BlockType","Text","cx","Paragraph","Heading1","Heading2","Heading3","Heading4","Heading5","Heading6","BlockQuote","OrderedList","listStylePosition","UnorderedList","ListItem","ListItemChild","className","restOfProps","textDecoration","InlineType","Code","SuperScript","SubScript","Link","link","COMMIT_DEBOUNCE_DELAY","editor","text","shouldCommit","setShouldCommit","useState","isInBuilder","useIsInBuilder","useEffect","nextValue","richTextDTOtoDAO","nextSelection","richTextDTOtoSelection","deepEqual","selection","onChange","timeoutId","window","setTimeout","clearTimeout","useCallback","isEnabled","useIsomorphicLayoutEffect","ReactEditor","isFocused","root","findDocumentOrShadowRoot","domSelection","getSelection","newDomRange","toDOMRange","SlateRange","isBackward","setBaseAndExtent","endContainer","endOffset","startContainer","startOffset","removeAllRanges","e","console","error","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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAKqB,cAAA,IAAqC;AAArC,eAAEA;AAAAA;AAAAA,MAAF,IAAWC,kBAAX,IAAWA;AAAAA,IAATD;AAAAA;AAEfE,QAAAA,qBAAqBC,sBAAsBH,KAAKI,UAAN;AAG1CC,QAAAA,sBAAsBC,uBAAuBJ,kBAAD;AAGhD,6BAAA,QAAA,iCAAUD,MAAMM,aAAhB;AAAA,IAA4B,WAAWF;AAAAA,IAAvC,UACGJ,MAAMO;AAAAA,EAAAA,EAFX;AAKD;ACP4B,sBAAA;AAAA,EAAEC;AAAAA,EAASF;AAAAA,EAAYC;AAAAA,GAAsC;AAClFE,QAAAA,cAAc,CA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AuB,aAAOuB,yCAAYmB;AAC9CC,cAAU3C,GAAGtC,MAAJ;AAAA,EAAA,GAEX,CAAC6D,YAAY7D,MAAb,CAP+B;AAU3BkF,QAAAA,aAAa/D,YAAY,CAACmB,MAAkB;AAEhD,QAAIA,EAAE6C,iBAAiB;AAAM;AAE7B9B,gCAA4B,KAAD;AAC3B/B,gBAAY8D,SAASpF,MAArB;AAAA,EAL4B,GAM3B,CAN2B,CAAA;AAQ9B,6BACG,OAAD;AAAA,IAAO;AAAA,IAAgB,OAAOuE;AAAAA,IAAc,UAAUhB;AAAAA,IAAtD,8BACG,UAAD;AAAA,MACE;AAAA,MACA,YAAY8B;AAAAA,MACZ,eAAeC;AAAAA,MACf,SAASZ;AAAAA,MACT,WAAWE;AAAAA,MACX,QAAQM;AAAAA,MACR,WAAW1G,GAAGqE,OAAOhF,MAAR;AAAA,MACb,UAAU4F,aAAa8B,gBAAgBC;AAAAA,MACvC,aAAY;AAAA,IAAA,CATd;AAAA,EAAA,CAFJ;AAeD,CAnFqC;AAqFtC,IAAA,iBAAe9C;;"}
package/dist/index.es2.js CHANGED
@@ -30,7 +30,7 @@ var __objRest = (source, exclude) => {
30
30
  return target;
31
31
  };
32
32
  import { useMemo, useState, useEffect, useCallback, useRef, forwardRef, createElement, Children } from "react";
33
- import { $ as isNonNullable, au as getBackgroundsFileIds, av as getBackgroundsSwatchIds, Z as useStyle } from "./react-page.es.js";
33
+ import { Y as isNonNullable, au as getBackgroundsFileIds, av as getBackgroundsSwatchIds, U as useStyle } from "./react-page.es.js";
34
34
  import "use-sync-external-store/shim";
35
35
  import { G as useFiles, H as useSwatches, v as useResponsiveGridItem, c as DEFAULT_BOX_ANIMATE_TYPE, f as DEFAULT_ITEM_ANIMATE_TYPE, e as DEFAULT_BOX_ANIMATE_DURATION, d as DEFAULT_BOX_ANIMATE_DELAY, i as DEFAULT_ITEM_STAGGER_DURATION, n as useResponsiveStyle, q as colorToString } from "./index.es.js";
36
36
  import "slate";
package/dist/index.es4.js CHANGED
@@ -30,7 +30,7 @@ var __objRest = (source, exclude) => {
30
30
  return target;
31
31
  };
32
32
  import { cx } from "@emotion/css";
33
- import { Z as useStyle } from "./react-page.es.js";
33
+ import { U as useStyle } from "./react-page.es.js";
34
34
  import { n as useResponsiveStyle } from "./index.es.js";
35
35
  import { jsx } from "react/jsx-runtime";
36
36
  function GutterContainer(_a) {