@makeswift/runtime 0.9.1 → 0.9.2

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 (195) hide show
  1. package/dist/Box.cjs.js +2 -3
  2. package/dist/Box.cjs.js.map +1 -1
  3. package/dist/Box.es.js +2 -3
  4. package/dist/Box.es.js.map +1 -1
  5. package/dist/Button.cjs.js +2 -3
  6. package/dist/Button.cjs.js.map +1 -1
  7. package/dist/Button.es.js +2 -3
  8. package/dist/Button.es.js.map +1 -1
  9. package/dist/Carousel.cjs.js +2 -3
  10. package/dist/Carousel.cjs.js.map +1 -1
  11. package/dist/Carousel.es.js +2 -3
  12. package/dist/Carousel.es.js.map +1 -1
  13. package/dist/Countdown.cjs.js +1 -2
  14. package/dist/Countdown.cjs.js.map +1 -1
  15. package/dist/Countdown.es.js +1 -2
  16. package/dist/Countdown.es.js.map +1 -1
  17. package/dist/Divider.cjs.js +2 -3
  18. package/dist/Divider.cjs.js.map +1 -1
  19. package/dist/Divider.es.js +2 -3
  20. package/dist/Divider.es.js.map +1 -1
  21. package/dist/Embed.cjs.js +0 -2
  22. package/dist/Embed.cjs.js.map +1 -1
  23. package/dist/Embed.es.js +0 -2
  24. package/dist/Embed.es.js.map +1 -1
  25. package/dist/Form.cjs.js +1 -2
  26. package/dist/Form.cjs.js.map +1 -1
  27. package/dist/Form.es.js +1 -2
  28. package/dist/Form.es.js.map +1 -1
  29. package/dist/Image.cjs.js +1 -2
  30. package/dist/Image.cjs.js.map +1 -1
  31. package/dist/Image.es.js +1 -2
  32. package/dist/Image.es.js.map +1 -1
  33. package/dist/LiveProvider.cjs.js +2 -3
  34. package/dist/LiveProvider.cjs.js.map +1 -1
  35. package/dist/LiveProvider.es.js +3 -4
  36. package/dist/LiveProvider.es.js.map +1 -1
  37. package/dist/Navigation.cjs.js +1 -2
  38. package/dist/Navigation.cjs.js.map +1 -1
  39. package/dist/Navigation.es.js +1 -2
  40. package/dist/Navigation.es.js.map +1 -1
  41. package/dist/PreviewProvider.cjs.js +1 -2
  42. package/dist/PreviewProvider.cjs.js.map +1 -1
  43. package/dist/PreviewProvider.es.js +2 -3
  44. package/dist/PreviewProvider.es.js.map +1 -1
  45. package/dist/ReadOnlyText.cjs.js +2 -0
  46. package/dist/ReadOnlyText.cjs.js.map +1 -1
  47. package/dist/ReadOnlyText.es.js +3 -1
  48. package/dist/ReadOnlyText.es.js.map +1 -1
  49. package/dist/ReadOnlyTextV2.cjs.js +2 -0
  50. package/dist/ReadOnlyTextV2.cjs.js.map +1 -1
  51. package/dist/ReadOnlyTextV2.es.js +3 -1
  52. package/dist/ReadOnlyTextV2.es.js.map +1 -1
  53. package/dist/Root.cjs.js +1 -2
  54. package/dist/Root.cjs.js.map +1 -1
  55. package/dist/Root.es.js +1 -2
  56. package/dist/Root.es.js.map +1 -1
  57. package/dist/SocialLinks.cjs.js +2 -3
  58. package/dist/SocialLinks.cjs.js.map +1 -1
  59. package/dist/SocialLinks.es.js +2 -3
  60. package/dist/SocialLinks.es.js.map +1 -1
  61. package/dist/Text.cjs.js +2 -3
  62. package/dist/Text.cjs.js.map +1 -1
  63. package/dist/Text.es.js +2 -3
  64. package/dist/Text.es.js.map +1 -1
  65. package/dist/Video.cjs.js +0 -2
  66. package/dist/Video.cjs.js.map +1 -1
  67. package/dist/Video.es.js +0 -2
  68. package/dist/Video.es.js.map +1 -1
  69. package/dist/builder.cjs.js +0 -3
  70. package/dist/builder.cjs.js.map +1 -1
  71. package/dist/builder.es.js +0 -3
  72. package/dist/builder.es.js.map +1 -1
  73. package/dist/components.cjs.js +1 -2
  74. package/dist/components.cjs.js.map +1 -1
  75. package/dist/components.es.js +1 -2
  76. package/dist/components.es.js.map +1 -1
  77. package/dist/control-serialization.cjs.js +0 -3
  78. package/dist/control-serialization.cjs.js.map +1 -1
  79. package/dist/control-serialization.es.js +1 -4
  80. package/dist/control-serialization.es.js.map +1 -1
  81. package/dist/controls.cjs.js +6 -5
  82. package/dist/controls.cjs.js.map +1 -1
  83. package/dist/controls.es.js +2 -4
  84. package/dist/controls.es.js.map +1 -1
  85. package/dist/index.cjs.js +47 -14
  86. package/dist/index.cjs.js.map +1 -1
  87. package/dist/index.cjs10.js +171 -248
  88. package/dist/index.cjs10.js.map +1 -1
  89. package/dist/index.cjs11.js +375 -0
  90. package/dist/index.cjs11.js.map +1 -0
  91. package/dist/index.cjs2.js +1 -3
  92. package/dist/index.cjs2.js.map +1 -1
  93. package/dist/index.cjs6.js +700 -22
  94. package/dist/index.cjs6.js.map +1 -1
  95. package/dist/index.cjs7.js +37 -13
  96. package/dist/index.cjs7.js.map +1 -1
  97. package/dist/index.cjs8.js +17 -42
  98. package/dist/index.cjs8.js.map +1 -1
  99. package/dist/index.cjs9.js +12 -229
  100. package/dist/index.cjs9.js.map +1 -1
  101. package/dist/index.es.js +47 -14
  102. package/dist/index.es.js.map +1 -1
  103. package/dist/index.es10.js +172 -249
  104. package/dist/index.es10.js.map +1 -1
  105. package/dist/index.es11.js +368 -0
  106. package/dist/index.es11.js.map +1 -0
  107. package/dist/index.es2.js +2 -4
  108. package/dist/index.es2.js.map +1 -1
  109. package/dist/index.es6.js +695 -22
  110. package/dist/index.es6.js.map +1 -1
  111. package/dist/index.es7.js +33 -14
  112. package/dist/index.es7.js.map +1 -1
  113. package/dist/index.es8.js +17 -40
  114. package/dist/index.es8.js.map +1 -1
  115. package/dist/index.es9.js +11 -224
  116. package/dist/index.es9.js.map +1 -1
  117. package/dist/main.cjs.js +0 -3
  118. package/dist/main.cjs.js.map +1 -1
  119. package/dist/main.es.js +0 -3
  120. package/dist/main.es.js.map +1 -1
  121. package/dist/next.cjs.js +1 -2
  122. package/dist/next.cjs.js.map +1 -1
  123. package/dist/next.es.js +1 -2
  124. package/dist/next.es.js.map +1 -1
  125. package/dist/prop-controllers.cjs.js +0 -3
  126. package/dist/prop-controllers.cjs.js.map +1 -1
  127. package/dist/prop-controllers.es.js +0 -3
  128. package/dist/prop-controllers.es.js.map +1 -1
  129. package/dist/react-page.cjs.js +927 -1573
  130. package/dist/react-page.cjs.js.map +1 -1
  131. package/dist/react-page.es.js +923 -1559
  132. package/dist/react-page.es.js.map +1 -1
  133. package/dist/react.cjs.js +1 -2
  134. package/dist/react.cjs.js.map +1 -1
  135. package/dist/react.es.js +1 -2
  136. package/dist/react.es.js.map +1 -1
  137. package/dist/select.cjs.js +21 -0
  138. package/dist/select.cjs.js.map +1 -0
  139. package/dist/select.es.js +16 -0
  140. package/dist/select.es.js.map +1 -0
  141. package/dist/slate.cjs.js +172 -55
  142. package/dist/slate.cjs.js.map +1 -1
  143. package/dist/slate.es.js +172 -55
  144. package/dist/slate.es.js.map +1 -1
  145. package/dist/types/src/api/react.d.ts.map +1 -1
  146. package/dist/types/src/components/builtin/Button/Button.d.ts +1 -1
  147. package/dist/types/src/components/builtin/Form/components/Field/components/Checkbox/index.d.ts +1 -1
  148. package/dist/types/src/components/page/Page.d.ts.map +1 -1
  149. package/dist/types/src/controls/control.d.ts +3 -2
  150. package/dist/types/src/controls/control.d.ts.map +1 -1
  151. package/dist/types/src/controls/icon-radio-group.d.ts +29 -0
  152. package/dist/types/src/controls/icon-radio-group.d.ts.map +1 -0
  153. package/dist/types/src/controls/index.d.ts +1 -0
  154. package/dist/types/src/controls/index.d.ts.map +1 -1
  155. package/dist/types/src/controls/rich-text/translation.d.ts +1 -1
  156. package/dist/types/src/controls/rich-text/translation.d.ts.map +1 -1
  157. package/dist/types/src/controls/rich-text-v2/rich-text-v2.d.ts +7 -3
  158. package/dist/types/src/controls/rich-text-v2/rich-text-v2.d.ts.map +1 -1
  159. package/dist/types/src/controls/shape.d.ts +1 -2
  160. package/dist/types/src/controls/shape.d.ts.map +1 -1
  161. package/dist/types/src/controls/style-v2.d.ts +16 -7
  162. package/dist/types/src/controls/style-v2.d.ts.map +1 -1
  163. package/dist/types/src/next/client.d.ts.map +1 -1
  164. package/dist/types/src/next/document.d.ts.map +1 -1
  165. package/dist/types/src/prop-controllers/descriptors.d.ts +4 -2
  166. package/dist/types/src/prop-controllers/descriptors.d.ts.map +1 -1
  167. package/dist/types/src/prop-controllers/introspection.d.ts.map +1 -1
  168. package/dist/types/src/runtimes/react/controls/control.d.ts +3 -1
  169. package/dist/types/src/runtimes/react/controls/control.d.ts.map +1 -1
  170. package/dist/types/src/runtimes/react/controls/icon-radio-group.d.ts +4 -0
  171. package/dist/types/src/runtimes/react/controls/icon-radio-group.d.ts.map +1 -0
  172. package/dist/types/src/runtimes/react/controls/rich-text-v2/EditableTextV2/editable-text-v2.d.ts.map +1 -1
  173. package/dist/types/src/runtimes/react/controls/rich-text-v2/EditableTextV2/render-element.d.ts +10 -0
  174. package/dist/types/src/runtimes/react/controls/rich-text-v2/EditableTextV2/render-element.d.ts.map +1 -0
  175. package/dist/types/src/runtimes/react/controls/rich-text-v2/EditableTextV2/render-leaf.d.ts +10 -0
  176. package/dist/types/src/runtimes/react/controls/rich-text-v2/EditableTextV2/render-leaf.d.ts.map +1 -0
  177. package/dist/types/src/runtimes/react/controls/style-v2.d.ts +10 -1
  178. package/dist/types/src/runtimes/react/controls/style-v2.d.ts.map +1 -1
  179. package/dist/types/src/runtimes/react/controls.d.ts.map +1 -1
  180. package/dist/types/src/runtimes/react/index.d.ts.map +1 -1
  181. package/dist/types/src/slate/BlockPlugin/index.d.ts +1 -0
  182. package/dist/types/src/slate/BlockPlugin/index.d.ts.map +1 -1
  183. package/dist/types/src/slate/ColorPlugin/index.d.ts +10 -0
  184. package/dist/types/src/slate/ColorPlugin/index.d.ts.map +1 -0
  185. package/dist/types/src/slate/InlineModePlugin/index.d.ts +1 -0
  186. package/dist/types/src/slate/InlineModePlugin/index.d.ts.map +1 -1
  187. package/dist/types/src/slate/TextAlignPlugin/index.d.ts +1 -1
  188. package/dist/types/src/slate/TextAlignPlugin/index.d.ts.map +1 -1
  189. package/dist/types/src/slate/index.d.ts +1 -0
  190. package/dist/types/src/slate/index.d.ts.map +1 -1
  191. package/dist/types/src/slate/types.d.ts +21 -0
  192. package/dist/types/src/slate/types.d.ts.map +1 -1
  193. package/dist/types/src/slate/utils/responsive.d.ts +16 -0
  194. package/dist/types/src/slate/utils/responsive.d.ts.map +1 -0
  195. package/package.json +1 -1
@@ -29,34 +29,35 @@ var __objRest = (source, exclude) => {
29
29
  }
30
30
  return target;
31
31
  };
32
- import { useCallback, useState, useEffect, forwardRef, useImperativeHandle, useMemo } from "react";
32
+ import { useMemo, useState, useRef, useEffect, useCallback } from "react";
33
33
  import { Range, createEditor } from "slate";
34
+ import isHotkey from "is-hotkey";
35
+ import { withHistory, HistoryEditor } from "slate-history";
34
36
  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";
35
38
  import { cx } from "@emotion/css";
36
- import { g as getBox } from "./box-models.es.js";
37
- import { Z as useStyle, bk as BlockType, bl as InlineType, b4 as richTextDTOtoDAO, b3 as richTextDTOtoSelection, bh as withBlock, bg as onKeyDown, bt as BuilderEditMode } from "./react-page.es.js";
38
39
  import "@emotion/serialize";
39
40
  import "@emotion/utils";
40
- import { L as Leaf } from "./leaf.es.js";
41
- import { n as useResponsiveStyle, u as useIsInBuilder, N as useBuilderEditMode, O as pollBoxModel } from "./index.es.js";
41
+ import { N as ControlValue, O as useBuilderEditMode, Q as pollBoxModel } from "./index.es.js";
42
42
  import "./state/breakpoints.es.js";
43
- import isHotkey from "is-hotkey";
44
- import { jsx } from "react/jsx-runtime";
45
- import { L as Link } from "./index.es3.js";
46
- import { d as deepEqual } from "./deepEqual.es.js";
47
- import { w as withTypography } from "./index.es5.js";
48
- import { w as withBuilder } from "./index.es7.js";
43
+ import "./index.es6.js";
44
+ import { I as InlineModePlugin } from "./index.es7.js";
45
+ import { w as withBuilder } from "./index.es8.js";
49
46
  import { u as useIsomorphicLayoutEffect } from "./useIsomorphicLayoutEffect.es.js";
50
- import "css-box-model";
51
- import "./actions.es.js";
47
+ import { jsx } from "react/jsx-runtime";
52
48
  import "redux";
53
49
  import "redux-thunk";
50
+ import "./actions.es.js";
54
51
  import "use-sync-external-store/shim/with-selector";
55
52
  import "next/dynamic";
56
53
  import "./text-input.es.js";
57
54
  import "./combobox.es.js";
55
+ import "./select.es.js";
58
56
  import "use-sync-external-store/shim";
59
57
  import "./types.es.js";
58
+ import "./deepEqual.es.js";
59
+ import "./box-models.es.js";
60
+ import "css-box-model";
60
61
  import "color";
61
62
  import "scroll-into-view-if-needed";
62
63
  import "react-dom";
@@ -73,198 +74,9 @@ import "set-cookie-parser";
73
74
  import "./constants.es.js";
74
75
  import "uuid";
75
76
  import "corporate-ipsum";
76
- import "next/link";
77
- function BlockElement({
78
- element,
79
- attributes,
80
- children
81
- }) {
82
- const blockStyles = [useStyle({
83
- margin: 0
84
- }), useStyle(useResponsiveStyle([element.textAlign], ([textAlign = "left"]) => ({
85
- textAlign
86
- })))];
87
- const quoteStyles = useStyle({
88
- padding: "0.5em 10px",
89
- fontSize: "1.25em",
90
- fontWeight: "300",
91
- borderLeft: "5px solid rgba(0, 0, 0, 0.1)"
92
- });
93
- switch (element.type) {
94
- case BlockType.Text:
95
- return /* @__PURE__ */ jsx("span", __spreadProps(__spreadValues({}, attributes), {
96
- className: cx(...blockStyles),
97
- children
98
- }));
99
- case BlockType.Paragraph:
100
- return /* @__PURE__ */ jsx("p", __spreadProps(__spreadValues({}, attributes), {
101
- className: cx(...blockStyles),
102
- children
103
- }));
104
- case BlockType.Heading1:
105
- return /* @__PURE__ */ jsx("h1", __spreadProps(__spreadValues({}, attributes), {
106
- className: cx(...blockStyles),
107
- children
108
- }));
109
- case BlockType.Heading2:
110
- return /* @__PURE__ */ jsx("h2", __spreadProps(__spreadValues({}, attributes), {
111
- className: cx(...blockStyles),
112
- children
113
- }));
114
- case BlockType.Heading3:
115
- return /* @__PURE__ */ jsx("h3", __spreadProps(__spreadValues({}, attributes), {
116
- className: cx(...blockStyles),
117
- children
118
- }));
119
- case BlockType.Heading4:
120
- return /* @__PURE__ */ jsx("h4", __spreadProps(__spreadValues({}, attributes), {
121
- className: cx(...blockStyles),
122
- children
123
- }));
124
- case BlockType.Heading5:
125
- return /* @__PURE__ */ jsx("h5", __spreadProps(__spreadValues({}, attributes), {
126
- className: cx(...blockStyles),
127
- children
128
- }));
129
- case BlockType.Heading6:
130
- return /* @__PURE__ */ jsx("h6", __spreadProps(__spreadValues({}, attributes), {
131
- className: cx(...blockStyles),
132
- children
133
- }));
134
- case BlockType.BlockQuote:
135
- return /* @__PURE__ */ jsx("blockquote", __spreadProps(__spreadValues({}, attributes), {
136
- className: cx(...blockStyles, quoteStyles),
137
- children
138
- }));
139
- case BlockType.OrderedList:
140
- return /* @__PURE__ */ jsx("ol", __spreadProps(__spreadValues({}, attributes), {
141
- className: cx(...blockStyles),
142
- style: {
143
- listStylePosition: "inside"
144
- },
145
- children
146
- }));
147
- case BlockType.UnorderedList:
148
- return /* @__PURE__ */ jsx("ul", __spreadProps(__spreadValues({}, attributes), {
149
- className: cx(...blockStyles),
150
- style: {
151
- listStylePosition: "inside"
152
- },
153
- children
154
- }));
155
- case BlockType.ListItem:
156
- return /* @__PURE__ */ jsx("li", __spreadProps(__spreadValues({}, attributes), {
157
- className: cx(...blockStyles),
158
- children
159
- }));
160
- case BlockType.ListItemChild:
161
- return /* @__PURE__ */ jsx("span", __spreadProps(__spreadValues({}, attributes), {
162
- className: cx(...blockStyles),
163
- children
164
- }));
165
- default:
166
- return null;
167
- }
168
- }
169
- function StyledLink(_a) {
170
- var _b = _a, {
171
- className
172
- } = _b, restOfProps = __objRest(_b, [
173
- "className"
174
- ]);
175
- return /* @__PURE__ */ jsx(Link, __spreadProps(__spreadValues({}, restOfProps), {
176
- className: cx(useStyle({
177
- textDecoration: "none"
178
- }), className)
179
- }));
180
- }
181
- function InlineElement({
182
- element,
183
- attributes,
184
- children
185
- }) {
186
- switch (element.type) {
187
- case InlineType.Code:
188
- return /* @__PURE__ */ jsx("code", __spreadProps(__spreadValues({}, attributes), {
189
- children
190
- }));
191
- case InlineType.SuperScript:
192
- return /* @__PURE__ */ jsx("sup", __spreadProps(__spreadValues({}, attributes), {
193
- children
194
- }));
195
- case InlineType.SubScript:
196
- return /* @__PURE__ */ jsx("sub", __spreadProps(__spreadValues({}, attributes), {
197
- children
198
- }));
199
- case InlineType.Link:
200
- return /* @__PURE__ */ jsx(StyledLink, __spreadProps(__spreadValues({}, attributes), {
201
- link: element.link,
202
- children
203
- }));
204
- }
205
- }
206
- function Element(_c) {
207
- var _d = _c, {
208
- element
209
- } = _d, props = __objRest(_d, [
210
- "element"
211
- ]);
212
- switch (element.type) {
213
- case InlineType.Code:
214
- case InlineType.SuperScript:
215
- case InlineType.SubScript:
216
- case InlineType.Link:
217
- return /* @__PURE__ */ jsx(InlineElement, __spreadValues({
218
- element
219
- }, props));
220
- case BlockType.Paragraph:
221
- case BlockType.Heading1:
222
- case BlockType.Heading2:
223
- case BlockType.Heading3:
224
- case BlockType.BlockQuote:
225
- case BlockType.OrderedList:
226
- case BlockType.UnorderedList:
227
- case BlockType.ListItem:
228
- case BlockType.ListItemChild:
229
- return /* @__PURE__ */ jsx(BlockElement, __spreadValues({
230
- element
231
- }, props));
232
- default:
233
- return /* @__PURE__ */ jsx("span", __spreadProps(__spreadValues({}, props.attributes), {
234
- children: props.children
235
- }));
236
- }
237
- }
238
- const COMMIT_DEBOUNCE_DELAY = 500;
239
- function useSyncWithBuilder(editor, text) {
240
- const [shouldCommit, setShouldCommit] = useState(true);
241
- const isInBuilder = useIsInBuilder();
242
- useEffect(() => {
243
- if (shouldCommit && text && isInBuilder) {
244
- const nextValue = richTextDTOtoDAO(text);
245
- const nextSelection = richTextDTOtoSelection(text);
246
- if (!deepEqual(editor.children, nextValue) || !deepEqual(editor.selection, nextSelection)) {
247
- editor.children = nextValue;
248
- editor.selection = nextSelection;
249
- editor.onChange();
250
- }
251
- }
252
- }, [editor, shouldCommit, text]);
253
- useEffect(() => {
254
- if (shouldCommit)
255
- return;
256
- const timeoutId = window.setTimeout(() => {
257
- setShouldCommit(true);
258
- }, COMMIT_DEBOUNCE_DELAY);
259
- return () => {
260
- window.clearTimeout(timeoutId);
261
- };
262
- }, [shouldCommit]);
263
- return useCallback(() => setShouldCommit(false), []);
264
- }
265
77
  function useSyncDOMSelection(editor, isEnabled) {
266
78
  useIsomorphicLayoutEffect(() => {
267
- if (!isEnabled || editor.selection == null || ReactEditor.isFocused(editor))
79
+ if (!isEnabled.current || editor.selection == null || ReactEditor.isFocused(editor))
268
80
  return;
269
81
  try {
270
82
  const root = ReactEditor.findDocumentOrShadowRoot(editor);
@@ -284,83 +96,194 @@ function useSyncDOMSelection(editor, isEnabled) {
284
96
  }
285
97
  });
286
98
  }
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
+ }
287
179
  const defaultText = [{
288
- type: BlockType.Paragraph,
180
+ type: BlockType.Default,
289
181
  children: [{
290
182
  text: ""
291
183
  }]
292
184
  }];
293
- const EditableText = forwardRef(function EditableText2({
294
- id,
185
+ function EditableTextV2({
295
186
  text,
296
- width,
297
- margin
298
- }, ref) {
299
- const [editor] = useState(() => withBlock(withTypography(withBuilder(withReact(createEditor())))));
300
- const [isPreservingDOMSElection, setIsPreservingDOMSelection] = useState(false);
301
- useSyncDOMSelection(editor, isPreservingDOMSElection);
302
- const delaySync = useSyncWithBuilder(editor, 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);
303
201
  const editMode = useBuilderEditMode();
304
- const [propControllers, setPropControllers] = useState(null);
305
- const controller = propControllers == null ? void 0 : propControllers.text;
306
202
  useEffect(() => {
307
- if (controller == null)
203
+ if (control == null)
308
204
  return;
309
205
  const element = ReactEditor.toDOMNode(editor, editor);
310
206
  return pollBoxModel({
311
207
  element,
312
- onBoxModelChange: (boxModel) => controller.changeBoxModel(boxModel)
208
+ onBoxModelChange: (boxModel) => control.changeBoxModel(boxModel)
313
209
  });
314
- }, [editor, controller]);
315
- useImperativeHandle(ref, () => ({
316
- getDomNode() {
317
- return ReactEditor.toDOMNode(editor, editor);
318
- },
319
- getBoxModel() {
320
- return getBox(ReactEditor.toDOMNode(editor, editor));
321
- },
322
- setPropControllers
323
- }), [editor, setPropControllers]);
324
- const initialValue = useMemo(() => text ? richTextDTOtoDAO(text) : defaultText, [text]);
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]);
325
230
  useEffect(() => {
326
- controller == null ? void 0 : controller.setSlateEditor(editor);
327
- }, [controller, editor]);
231
+ control == null ? void 0 : control.setEditor(editor);
232
+ control == null ? void 0 : control.setDefaultValue(defaultText);
233
+ }, [control, editor, defaultText]);
328
234
  const handleFocus = useCallback(() => {
329
- controller == null ? void 0 : controller.focus();
330
- setIsPreservingDOMSelection(true);
331
- }, [controller]);
235
+ isPreservingFocus.current = true;
236
+ control == null ? void 0 : control.select();
237
+ }, [control]);
332
238
  const handleKeyDown = useCallback((e) => {
333
239
  if (isHotkey("mod+shift+z", e))
334
- return controller == null ? void 0 : controller.redo();
240
+ return HistoryEditor.redo(editor);
335
241
  if (isHotkey("mod+z", e))
336
- return controller == null ? void 0 : controller.undo();
337
- if (isHotkey("escape")(e))
338
- return controller == null ? void 0 : controller.blur();
339
- onKeyDown(e, editor);
340
- }, [controller, editor]);
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]);
341
261
  const handleBlur = useCallback((e) => {
262
+ var _a;
342
263
  if (e.relatedTarget == null)
343
264
  return;
344
- setIsPreservingDOMSelection(false);
345
- ReactEditor.deselect(editor);
265
+ if (((_a = e.relatedTarget) == null ? void 0 : _a.getAttribute("contenteditable")) === "true")
266
+ isPreservingFocus.current = false;
346
267
  }, []);
268
+ const handleOnChange = useCallback((value) => {
269
+ control == null ? void 0 : control.onChange(value);
270
+ }, [control]);
347
271
  return /* @__PURE__ */ jsx(Slate, {
348
272
  editor,
273
+ onChange: handleOnChange,
349
274
  value: initialValue,
350
- onChange: delaySync,
351
275
  children: /* @__PURE__ */ jsx(Editable, {
352
- id,
353
- renderLeaf: Leaf,
354
- renderElement: Element,
276
+ renderLeaf,
277
+ renderElement,
355
278
  onFocus: handleFocus,
356
279
  onKeyDown: handleKeyDown,
280
+ onKeyUp: handleKeyUp,
281
+ onClick: handleClick,
357
282
  onBlur: handleBlur,
358
- className: cx(width, margin),
359
283
  readOnly: editMode !== BuilderEditMode.CONTENT,
360
284
  placeholder: "Write some text..."
361
285
  })
362
286
  });
363
- });
364
- var EditableText$1 = EditableText;
365
- export { EditableText, EditableText$1 as default };
287
+ }
288
+ export { EditableTextV2, EditableTextV2 as default };
366
289
  //# sourceMappingURL=index.es10.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.es10.js","sources":["../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 { 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":["element","attributes","children","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","props","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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;AACb,0EACYd;QAAY,WAAWe,GAAG,GAAGb,WAAJ;AAAA,QAChCD;AAAAA,MAAAA,EAFL;AAAA,SAKGY,UAAUG;AACb,uEACShB;QAAY,WAAWe,GAAG,GAAGb,WAAJ;AAAA,QAC7BD;AAAAA,MAAAA,EAFL;AAAA,SAKGY,UAAUI;AACb,wEACUjB;QAAY,WAAWe,GAAG,GAAGb,WAAJ;AAAA,QAC9BD;AAAAA,MAAA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AeD,CAnFqC;AAqFtC,IAAA,iBAAe9C;;"}
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,yBAAy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