@makeswift/runtime 0.5.5 → 0.6.0

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 (129) hide show
  1. package/dist/Box.cjs.js +11 -6
  2. package/dist/Box.cjs.js.map +1 -1
  3. package/dist/Box.es.js +12 -7
  4. package/dist/Box.es.js.map +1 -1
  5. package/dist/Button.cjs.js +2 -1
  6. package/dist/Button.cjs.js.map +1 -1
  7. package/dist/Button.es.js +2 -1
  8. package/dist/Button.es.js.map +1 -1
  9. package/dist/Carousel.cjs.js +2 -1
  10. package/dist/Carousel.cjs.js.map +1 -1
  11. package/dist/Carousel.es.js +2 -1
  12. package/dist/Carousel.es.js.map +1 -1
  13. package/dist/Countdown.cjs.js +2 -1
  14. package/dist/Countdown.cjs.js.map +1 -1
  15. package/dist/Countdown.es.js +2 -1
  16. package/dist/Countdown.es.js.map +1 -1
  17. package/dist/Divider.cjs.js +2 -1
  18. package/dist/Divider.cjs.js.map +1 -1
  19. package/dist/Divider.es.js +2 -1
  20. package/dist/Divider.es.js.map +1 -1
  21. package/dist/EditableText.cjs.js +359 -0
  22. package/dist/EditableText.cjs.js.map +1 -0
  23. package/dist/EditableText.es.js +352 -0
  24. package/dist/EditableText.es.js.map +1 -0
  25. package/dist/Embed.cjs.js +2 -1
  26. package/dist/Embed.cjs.js.map +1 -1
  27. package/dist/Embed.es.js +2 -1
  28. package/dist/Embed.es.js.map +1 -1
  29. package/dist/Form.cjs.js +2 -1
  30. package/dist/Form.cjs.js.map +1 -1
  31. package/dist/Form.es.js +2 -1
  32. package/dist/Form.es.js.map +1 -1
  33. package/dist/Image.cjs.js +2 -1
  34. package/dist/Image.cjs.js.map +1 -1
  35. package/dist/Image.es.js +2 -1
  36. package/dist/Image.es.js.map +1 -1
  37. package/dist/LiveProvider.cjs.js +3 -11
  38. package/dist/LiveProvider.cjs.js.map +1 -1
  39. package/dist/LiveProvider.es.js +6 -14
  40. package/dist/LiveProvider.es.js.map +1 -1
  41. package/dist/Navigation.cjs.js +2 -1
  42. package/dist/Navigation.cjs.js.map +1 -1
  43. package/dist/Navigation.es.js +2 -1
  44. package/dist/Navigation.es.js.map +1 -1
  45. package/dist/PreviewProvider.cjs.js +6 -3
  46. package/dist/PreviewProvider.cjs.js.map +1 -1
  47. package/dist/PreviewProvider.es.js +8 -5
  48. package/dist/PreviewProvider.es.js.map +1 -1
  49. package/dist/ReadOnlyText.cjs.js +206 -0
  50. package/dist/ReadOnlyText.cjs.js.map +1 -0
  51. package/dist/ReadOnlyText.es.js +204 -0
  52. package/dist/ReadOnlyText.es.js.map +1 -0
  53. package/dist/Root.cjs.js +4 -3
  54. package/dist/Root.cjs.js.map +1 -1
  55. package/dist/Root.es.js +3 -2
  56. package/dist/Root.es.js.map +1 -1
  57. package/dist/SocialLinks.cjs.js +2 -1
  58. package/dist/SocialLinks.cjs.js.map +1 -1
  59. package/dist/SocialLinks.es.js +2 -1
  60. package/dist/SocialLinks.es.js.map +1 -1
  61. package/dist/Text.cjs.js +26 -405
  62. package/dist/Text.cjs.js.map +1 -1
  63. package/dist/Text.es.js +23 -405
  64. package/dist/Text.es.js.map +1 -1
  65. package/dist/Video.cjs.js +2 -1
  66. package/dist/Video.cjs.js.map +1 -1
  67. package/dist/Video.es.js +2 -1
  68. package/dist/Video.es.js.map +1 -1
  69. package/dist/actions.cjs.js.map +1 -1
  70. package/dist/actions.es.js.map +1 -1
  71. package/dist/components.cjs.js +2 -5
  72. package/dist/components.cjs.js.map +1 -1
  73. package/dist/components.es.js +2 -5
  74. package/dist/components.es.js.map +1 -1
  75. package/dist/constants.cjs.js +45 -26
  76. package/dist/constants.cjs.js.map +1 -1
  77. package/dist/constants.es.js +36 -20
  78. package/dist/constants.es.js.map +1 -1
  79. package/dist/index.cjs.js +78 -310
  80. package/dist/index.cjs.js.map +1 -1
  81. package/dist/index.cjs2.js +20 -21
  82. package/dist/index.cjs2.js.map +1 -1
  83. package/dist/index.cjs5.js +141 -0
  84. package/dist/index.cjs5.js.map +1 -0
  85. package/dist/index.es.js +77 -308
  86. package/dist/index.es.js.map +1 -1
  87. package/dist/index.es2.js +23 -24
  88. package/dist/index.es2.js.map +1 -1
  89. package/dist/index.es3.js +1 -1
  90. package/dist/index.es5.js +139 -0
  91. package/dist/index.es5.js.map +1 -0
  92. package/dist/next.cjs.js +2 -1
  93. package/dist/next.cjs.js.map +1 -1
  94. package/dist/next.es.js +3 -2
  95. package/dist/next.es.js.map +1 -1
  96. package/dist/react.cjs.js +2 -1
  97. package/dist/react.cjs.js.map +1 -1
  98. package/dist/react.es.js +2 -1
  99. package/dist/react.es.js.map +1 -1
  100. package/dist/types/src/api/react.d.ts.map +1 -1
  101. package/dist/types/src/components/builtin/Box/Box.d.ts.map +1 -1
  102. package/dist/types/src/components/builtin/Box/animations.d.ts +1 -1
  103. package/dist/types/src/components/builtin/Box/animations.d.ts.map +1 -1
  104. package/dist/types/src/components/builtin/Form/components/Field/components/Checkbox/index.d.ts +1 -1
  105. package/dist/types/src/components/builtin/Text/EditableText.d.ts +16 -0
  106. package/dist/types/src/components/builtin/Text/EditableText.d.ts.map +1 -0
  107. package/dist/types/src/components/builtin/Text/ReadOnlyText.d.ts +11 -0
  108. package/dist/types/src/components/builtin/Text/ReadOnlyText.d.ts.map +1 -0
  109. package/dist/types/src/components/builtin/Text/Text.d.ts +3 -7
  110. package/dist/types/src/components/builtin/Text/Text.d.ts.map +1 -1
  111. package/dist/types/src/components/builtin/register.d.ts.map +1 -1
  112. package/dist/types/src/components/shared/BackgroundsContainer/index.d.ts.map +1 -1
  113. package/dist/types/src/next/document.d.ts.map +1 -1
  114. package/dist/types/src/runtimes/react/components/LiveProvider.d.ts.map +1 -1
  115. package/dist/types/src/runtimes/react/element-imperative-handle.d.ts +12 -0
  116. package/dist/types/src/runtimes/react/element-imperative-handle.d.ts.map +1 -0
  117. package/dist/types/src/runtimes/react/find-dom-node.d.ts +1 -1
  118. package/dist/types/src/runtimes/react/find-dom-node.d.ts.map +1 -1
  119. package/dist/types/src/runtimes/react/index.d.ts +4 -2
  120. package/dist/types/src/runtimes/react/index.d.ts.map +1 -1
  121. package/dist/types/src/state/actions.d.ts +4 -3
  122. package/dist/types/src/state/actions.d.ts.map +1 -1
  123. package/dist/types/src/state/modules/is-preview.d.ts +6 -0
  124. package/dist/types/src/state/modules/is-preview.d.ts.map +1 -0
  125. package/dist/types/src/state/react-builder-preview.d.ts +1 -0
  126. package/dist/types/src/state/react-builder-preview.d.ts.map +1 -1
  127. package/dist/types/src/state/react-page.d.ts +2 -0
  128. package/dist/types/src/state/react-page.d.ts.map +1 -1
  129. package/package.json +4 -1
package/dist/Text.cjs.js CHANGED
@@ -18,45 +18,29 @@ var __spreadValues = (a, b) => {
18
18
  return a;
19
19
  };
20
20
  var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
21
- var __objRest = (source, exclude) => {
22
- var target = {};
23
- for (var prop in source)
24
- if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
25
- target[prop] = source[prop];
26
- if (source != null && __getOwnPropSymbols)
27
- for (var prop of __getOwnPropSymbols(source)) {
28
- if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
29
- target[prop] = source[prop];
30
- }
31
- return target;
32
- };
33
21
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
22
+ var dynamic = require("next/dynamic");
34
23
  var React = require("react");
35
- var slate = require("slate");
36
- var Hotkeys = require("slate-hotkeys");
37
- var isHotkey = require("is-hotkey");
38
- var boxModels = require("./box-models.cjs.js");
39
- var slateReact = require("slate-react");
40
- var Lists = require("@convertkit/slate-lists");
41
24
  var next = require("./index.cjs.js");
42
- var constants = require("./constants.cjs.js");
43
- var css = require("@emotion/css");
44
25
  var jsxRuntime = require("react/jsx-runtime");
45
- var index = require("./index.cjs3.js");
46
- require("use-sync-external-store/shim");
47
- require("./slot.cjs.js");
48
- require("css-box-model");
49
- require("./actions.cjs.js");
50
26
  require("use-sync-external-store/shim/with-selector");
51
- require("next/dynamic");
52
- require("./text-input.cjs.js");
53
- require("./combobox.cjs.js");
54
- require("./control.cjs.js");
27
+ require("./constants.cjs.js");
55
28
  require("redux");
56
29
  require("redux-thunk");
30
+ require("./actions.cjs.js");
31
+ require("./slot.cjs.js");
32
+ require("./control.cjs.js");
33
+ require("@emotion/css");
34
+ require("@emotion/serialize");
35
+ require("@emotion/utils");
36
+ require("./text-input.cjs.js");
37
+ require("./combobox.cjs.js");
38
+ require("use-sync-external-store/shim");
57
39
  require("./types.cjs.js");
58
40
  require("color");
59
41
  require("scroll-into-view-if-needed");
42
+ require("./box-models.cjs.js");
43
+ require("css-box-model");
60
44
  require("react-dom");
61
45
  require("html-react-parser");
62
46
  require("next/head");
@@ -68,386 +52,23 @@ require("http-proxy");
68
52
  require("set-cookie-parser");
69
53
  require("uuid/v4");
70
54
  require("corporate-ipsum");
71
- require("next/link");
72
55
  function _interopDefaultLegacy(e) {
73
56
  return e && typeof e === "object" && "default" in e ? e : { "default": e };
74
57
  }
75
- var Hotkeys__default = /* @__PURE__ */ _interopDefaultLegacy(Hotkeys);
76
- var Lists__default = /* @__PURE__ */ _interopDefaultLegacy(Lists);
77
- const getDeviceId = ({ deviceId }) => deviceId;
78
- const withColor = (swatches) => (_a) => {
79
- var _b = _a, {
80
- value: _c
81
- } = _b, _d = _c, { color } = _d, restOfValue = __objRest(_d, ["color"]), rest = __objRest(_b, [
82
- "value"
83
- ]);
84
- return __spreadProps(__spreadValues({}, rest), {
85
- value: __spreadValues(__spreadValues({}, restOfValue), color ? {
86
- color: {
87
- swatch: swatches.find((s) => s && s.id === color.swatchId),
88
- alpha: color.alpha
89
- }
90
- } : {})
91
- });
92
- };
93
- const overrideTypographyStyle = (source, override) => {
94
- const devices = [...new Set(source.map(getDeviceId).concat(override.map(getDeviceId)))];
95
- return devices.map((deviceId) => ({
96
- deviceId,
97
- value: __spreadValues(__spreadValues({}, (next.findDeviceOverride(source, deviceId) || { value: {} }).value), (next.findDeviceOverride(override, deviceId, (v) => v) || { value: {} }).value)
58
+ var dynamic__default = /* @__PURE__ */ _interopDefaultLegacy(dynamic);
59
+ const EditableText = next.forwardNextDynamicRef((patch) => dynamic__default["default"](() => patch(Promise.resolve().then(function() {
60
+ return require("./EditableText.cjs.js");
61
+ }))));
62
+ const ReadOnlyText = next.forwardNextDynamicRef((patch) => dynamic__default["default"](() => patch(Promise.resolve().then(function() {
63
+ return require("./ReadOnlyText.cjs.js");
64
+ }))));
65
+ const Text = React.forwardRef(function Text2(props, ref) {
66
+ const isPreview = next.useIsPreview();
67
+ return isPreview ? /* @__PURE__ */ jsxRuntime.jsx(EditableText, __spreadProps(__spreadValues({}, props), {
68
+ ref
69
+ })) : /* @__PURE__ */ jsxRuntime.jsx(ReadOnlyText, __spreadProps(__spreadValues({}, props), {
70
+ ref
98
71
  }));
99
- };
100
- function useTypographyMark(value) {
101
- var _a, _b, _c;
102
- const typography = next.useTypography((_a = value == null ? void 0 : value.id) != null ? _a : null);
103
- const swatchIds = [
104
- ...constants.getTypographyStyleSwatchIds(value == null ? void 0 : value.style),
105
- ...constants.getTypographyStyleSwatchIds(typography == null ? void 0 : typography.style)
106
- ];
107
- const swatches = next.useSwatches(swatchIds);
108
- return overrideTypographyStyle((_b = typography == null ? void 0 : typography.style.map(withColor(swatches.filter(constants.isNonNullable)))) != null ? _b : [], (_c = value == null ? void 0 : value.style.map(withColor(swatches.filter(constants.isNonNullable)))) != null ? _c : []);
109
- }
110
- function Mark(_a) {
111
- var _b = _a, {
112
- value,
113
- className
114
- } = _b, restOfProps = __objRest(_b, [
115
- "value",
116
- "className"
117
- ]);
118
- const typographyStyle = useTypographyMark(value);
119
- const typographyClassName = next.useStyle(next.responsiveStyle([typographyStyle], ([{
120
- color,
121
- fontFamily,
122
- fontSize,
123
- fontWeight,
124
- lineHeight,
125
- letterSpacing,
126
- uppercase,
127
- underline,
128
- strikethrough,
129
- italic
130
- } = {}]) => __spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues({}, color == null ? {} : {
131
- color: next.colorToString(color)
132
- }), fontFamily == null ? {} : {
133
- fontFamily
134
- }), fontSize == null || fontSize.value == null || fontSize.unit == null ? {} : {
135
- fontSize: `${fontSize.value}${fontSize.unit}`
136
- }), fontWeight == null ? {} : {
137
- fontWeight
138
- }), lineHeight == null ? {} : {
139
- lineHeight
140
- }), letterSpacing == null ? {} : {
141
- letterSpacing: `${letterSpacing / 10}em`
142
- }), uppercase == null ? {} : {
143
- textTransform: uppercase === true ? "uppercase" : "initial"
144
- }), underline == null && strikethrough == null ? {} : {
145
- textDecoration: [Boolean(underline) && "underline", Boolean(strikethrough) && "line-through"].filter(Boolean).join(" ")
146
- }), italic == null ? {} : {
147
- fontStyle: italic === true ? "italic" : "initial"
148
- }), next.shallowMergeFallbacks));
149
- return /* @__PURE__ */ jsxRuntime.jsx("span", __spreadProps(__spreadValues({}, restOfProps), {
150
- className: css.cx(typographyClassName, className)
151
- }));
152
- }
153
- const TYPOGRAPHY_TYPE = "typography";
154
- function DeviceOverridesMarksPlugin() {
155
- return {
156
- renderMark({
157
- mark,
158
- children
159
- }, _editor, next2) {
160
- if (mark.type === TYPOGRAPHY_TYPE) {
161
- return /* @__PURE__ */ jsxRuntime.jsx(Mark, {
162
- value: mark.data.get("value"),
163
- children
164
- });
165
- }
166
- return next2();
167
- }
168
- };
169
- }
170
- var Block = React.forwardRef(function Block2(_c, ref) {
171
- var _d = _c, {
172
- textAlign,
173
- className,
174
- as
175
- } = _d, restOfProps = __objRest(_d, [
176
- "textAlign",
177
- "className",
178
- "as"
179
- ]);
180
- const Component = as != null ? as : "div";
181
- return /* @__PURE__ */ jsxRuntime.jsx(Component, __spreadProps(__spreadValues({}, restOfProps), {
182
- ref,
183
- className: css.cx(next.useStyle({
184
- margin: 0
185
- }), next.useStyle(next.responsiveStyle([textAlign], ([textAlign2 = "left"]) => ({
186
- textAlign: textAlign2
187
- }))), next.useStyle(as === "blockquote" ? {
188
- padding: "0.5em 10px",
189
- fontSize: "1.25em",
190
- fontWeight: "300",
191
- borderLeft: "5px solid rgba(0, 0, 0, 0.1)"
192
- } : {}), className)
193
- }));
194
- });
195
- function DeviceOverridesBlockPlugin() {
196
- return {
197
- renderBlock(props, _editor, next2) {
198
- const {
199
- node,
200
- attributes,
201
- children
202
- } = props;
203
- const blockProps = {
204
- textAlign: node.data.get("textAlign")
205
- };
206
- switch (node.type) {
207
- case "paragraph":
208
- return /* @__PURE__ */ jsxRuntime.jsx(Block, __spreadProps(__spreadValues(__spreadValues({}, attributes), blockProps), {
209
- as: "p",
210
- children
211
- }));
212
- case "heading-one":
213
- return /* @__PURE__ */ jsxRuntime.jsx(Block, __spreadProps(__spreadValues(__spreadValues({}, attributes), blockProps), {
214
- as: "h1",
215
- children
216
- }));
217
- case "heading-two":
218
- return /* @__PURE__ */ jsxRuntime.jsx(Block, __spreadProps(__spreadValues(__spreadValues({}, attributes), blockProps), {
219
- as: "h2",
220
- children
221
- }));
222
- case "heading-three":
223
- return /* @__PURE__ */ jsxRuntime.jsx(Block, __spreadProps(__spreadValues(__spreadValues({}, attributes), blockProps), {
224
- as: "h3",
225
- children
226
- }));
227
- case "heading-four":
228
- return /* @__PURE__ */ jsxRuntime.jsx(Block, __spreadProps(__spreadValues(__spreadValues({}, attributes), blockProps), {
229
- as: "h4",
230
- children
231
- }));
232
- case "heading-five":
233
- return /* @__PURE__ */ jsxRuntime.jsx(Block, __spreadProps(__spreadValues(__spreadValues({}, attributes), blockProps), {
234
- as: "h5",
235
- children
236
- }));
237
- case "heading-six":
238
- return /* @__PURE__ */ jsxRuntime.jsx(Block, __spreadProps(__spreadValues(__spreadValues({}, attributes), blockProps), {
239
- as: "h6",
240
- children
241
- }));
242
- case "blockquote":
243
- return /* @__PURE__ */ jsxRuntime.jsx(Block, __spreadProps(__spreadValues(__spreadValues({}, attributes), blockProps), {
244
- as: "blockquote",
245
- children
246
- }));
247
- default:
248
- return next2();
249
- }
250
- }
251
- };
252
- }
253
- function StyledLink(_e) {
254
- var _f = _e, {
255
- className
256
- } = _f, restOfProps = __objRest(_f, [
257
- "className"
258
- ]);
259
- return /* @__PURE__ */ jsxRuntime.jsx(index.Link, __spreadProps(__spreadValues({}, restOfProps), {
260
- className: css.cx(next.useStyle({
261
- textDecoration: "none"
262
- }), className)
263
- }));
264
- }
265
- function LinkPlugin() {
266
- return {
267
- renderInline(props, _editor, next2) {
268
- const {
269
- attributes,
270
- children,
271
- node
272
- } = props;
273
- switch (node.type) {
274
- case "link": {
275
- const {
276
- data
277
- } = node;
278
- return /* @__PURE__ */ jsxRuntime.jsx(StyledLink, __spreadProps(__spreadValues({}, attributes), {
279
- link: data.toJS(),
280
- children
281
- }));
282
- }
283
- default: {
284
- return next2();
285
- }
286
- }
287
- }
288
- };
289
- }
290
- function Inlines() {
291
- return {
292
- renderInline(props, _editor, next2) {
293
- const {
294
- attributes,
295
- children,
296
- node
297
- } = props;
298
- switch (node.type) {
299
- case "code": {
300
- return /* @__PURE__ */ jsxRuntime.jsx("code", __spreadProps(__spreadValues({}, attributes), {
301
- children
302
- }));
303
- }
304
- case "superscript": {
305
- return /* @__PURE__ */ jsxRuntime.jsx("sup", __spreadProps(__spreadValues({}, attributes), {
306
- children
307
- }));
308
- }
309
- case "subscript": {
310
- return /* @__PURE__ */ jsxRuntime.jsx("sub", __spreadProps(__spreadValues({}, attributes), {
311
- children
312
- }));
313
- }
314
- default: {
315
- return next2();
316
- }
317
- }
318
- }
319
- };
320
- }
321
- const RichTextEditor = React.forwardRef(function RichTextEditor2(_g, ref) {
322
- var _h = _g, {
323
- placeholder = "Write some text...",
324
- className
325
- } = _h, restOfProps = __objRest(_h, [
326
- "placeholder",
327
- "className"
328
- ]);
329
- const plugins = React.useMemo(() => [Lists__default["default"](), LinkPlugin(), Inlines(), DeviceOverridesBlockPlugin(), DeviceOverridesMarksPlugin()], []);
330
- return /* @__PURE__ */ jsxRuntime.jsx(slateReact.Editor, __spreadProps(__spreadValues({}, restOfProps), {
331
- style: {
332
- WebkitUserModify: void 0
333
- },
334
- className: css.cx(next.useStyle({
335
- "ul, ol": {
336
- margin: 0
337
- }
338
- }), className),
339
- ref,
340
- autoFocus: false,
341
- plugins,
342
- placeholder
343
- }));
344
- });
345
- const defaultText = {
346
- document: {
347
- nodes: [{
348
- object: "block",
349
- type: "paragraph",
350
- nodes: []
351
- }]
352
- },
353
- data: {}
354
- };
355
- const COMMIT_DEBOUNCE_DELAY = 500;
356
- const Text = React.forwardRef(function Text2({
357
- id,
358
- text,
359
- width,
360
- margin
361
- }, ref) {
362
- const [editor, setEditor] = React.useState(null);
363
- const [propControllers, setPropControllers] = React.useState(null);
364
- const controller = propControllers == null ? void 0 : propControllers.text;
365
- React.useImperativeHandle(ref, () => ({
366
- getBoxModel() {
367
- const el = editor == null ? void 0 : editor.findDOMNode([]);
368
- return el instanceof Element ? boxModels.getBox(el) : null;
369
- },
370
- setPropControllers
371
- }), [editor, setPropControllers]);
372
- React.useEffect(() => {
373
- if (editor)
374
- controller == null ? void 0 : controller.setSlateEditor(editor);
375
- }, [controller, editor]);
376
- const [value, setValue] = React.useState(() => {
377
- const _a = text != null ? text : defaultText, {
378
- selection
379
- } = _a, textWithoutSelection = __objRest(_a, [
380
- "selection"
381
- ]);
382
- return slate.Value.fromJSON(textWithoutSelection);
383
- });
384
- const [shouldCommit, setShouldCommit] = React.useState(true);
385
- React.useEffect(() => {
386
- if (shouldCommit) {
387
- const nextValue = slate.Value.fromJSON(text != null ? text : defaultText);
388
- setValue((currentValue) => currentValue.selection.isBlurred ? slate.Value.fromJSON(nextValue.toJSON({
389
- preserveSelection: false
390
- })) : nextValue);
391
- }
392
- }, [shouldCommit, text]);
393
- React.useEffect(() => {
394
- if (shouldCommit)
395
- return;
396
- const timeoutId = window.setTimeout(() => {
397
- setShouldCommit(true);
398
- }, COMMIT_DEBOUNCE_DELAY);
399
- return () => {
400
- window.clearTimeout(timeoutId);
401
- };
402
- }, [shouldCommit]);
403
- function handleChange(change) {
404
- setValue(change.value);
405
- if (change.value !== value) {
406
- setShouldCommit(false);
407
- controller == null ? void 0 : controller.onChange(change);
408
- }
409
- }
410
- const lastController = React.useRef(controller);
411
- if (lastController.current !== controller)
412
- lastController.current = controller;
413
- const handleFocus = React.useCallback(() => {
414
- var _a;
415
- (_a = lastController.current) == null ? void 0 : _a.focus();
416
- }, []);
417
- const handleKeyDown = React.useCallback((event, _editor, next2) => {
418
- var _a, _b, _c;
419
- if (Hotkeys__default["default"].isUndo(event)) {
420
- (_a = lastController.current) == null ? void 0 : _a.undo();
421
- return true;
422
- }
423
- if (Hotkeys__default["default"].isRedo(event)) {
424
- (_b = lastController.current) == null ? void 0 : _b.redo();
425
- return true;
426
- }
427
- if (isHotkey.isHotkey("escape")(event)) {
428
- (_c = lastController.current) == null ? void 0 : _c.blur();
429
- return true;
430
- }
431
- return next2();
432
- }, []);
433
- const handleBlur = React.useCallback((event, editor2, next2) => {
434
- const selection = editor2.value.selection;
435
- next2();
436
- if (event.relatedTarget == null)
437
- editor2.select(selection);
438
- }, []);
439
- const isInBuilder = next.useIsInBuilder();
440
- return /* @__PURE__ */ jsxRuntime.jsx(RichTextEditor, {
441
- id,
442
- ref: setEditor,
443
- className: css.cx(width, margin),
444
- readOnly: !isInBuilder || controller == null,
445
- value,
446
- onChange: handleChange,
447
- onFocus: handleFocus,
448
- onKeyDown: handleKeyDown,
449
- onBlur: handleBlur
450
- });
451
72
  });
452
73
  exports["default"] = Text;
453
74
  //# sourceMappingURL=Text.cjs.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Text.cjs.js","sources":["../src/components/builtin/Text/components/RichTextEditor/components/Mark/hooks/useTypographyMark.ts","../src/components/builtin/Text/components/RichTextEditor/components/Mark/index.tsx","../src/components/builtin/Text/components/RichTextEditor/plugins/DeviceOverridesMarks.tsx","../src/components/builtin/Text/components/RichTextEditor/components/Block/index.tsx","../src/components/builtin/Text/components/RichTextEditor/plugins/DeviceOverridesBlocks.tsx","../src/components/builtin/Text/components/RichTextEditor/plugins/Link.tsx","../src/components/builtin/Text/components/RichTextEditor/plugins/Inlines.tsx","../src/components/builtin/Text/components/RichTextEditor/index.tsx","../src/components/builtin/Text/Text.tsx"],"sourcesContent":["import { Length as LengthValue } from '../../../../../../../../prop-controllers'\nimport { ColorValue as Color } from '../../../../../../../utils/types'\nimport { findDeviceOverride } from '../../../../../../../utils/devices'\nimport type { DeviceOverride } from '../../../../../../../../prop-controllers'\nimport {\n useSwatches,\n useTypography,\n} from '../../../../../../../../runtimes/react/hooks/makeswift-api'\nimport { Swatch, Typography } from '../../../../../../../../api'\nimport { getTypographyStyleSwatchIds } from '../../../../../../../../prop-controllers/introspection'\nimport { isNonNullable } from '../../../../../../../utils/isNonNullable'\n\nexport type TypographyMarkDataValue = {\n fontWeight?: number\n fontSize?: LengthValue\n fontFamily?: string\n color?: Color\n textAlign?: string\n lineHeight?: number\n letterSpacing?: number\n uppercase?: boolean\n italic?: boolean\n underline?: boolean\n strikethrough?: boolean\n}\n\nexport type TypographyMarkValue = {\n id: string | null | undefined\n style: Typography['style']\n}\n\nexport type TypographyMarkData = Array<DeviceOverride<TypographyMarkDataValue>>\n\nconst getDeviceId = ({ deviceId }: DeviceOverride<unknown>) => deviceId\n\nconst withColor =\n (swatches: Swatch[]) =>\n ({\n value: { color, ...restOfValue },\n ...rest\n }: Typography['style'][number]): DeviceOverride<TypographyMarkDataValue> =>\n ({\n ...rest,\n value: {\n ...restOfValue,\n ...(color\n ? {\n color: {\n swatch: swatches.find(s => s && s.id === color.swatchId),\n alpha: color.alpha,\n },\n }\n : {}),\n } as TypographyMarkDataValue,\n } as DeviceOverride<TypographyMarkDataValue>)\n\nexport const overrideTypographyStyle = <A>(\n source: Array<DeviceOverride<A>>,\n override: Array<DeviceOverride<A>>,\n): Array<DeviceOverride<A>> => {\n const devices = [...new Set(source.map(getDeviceId).concat(override.map(getDeviceId)))]\n\n return devices.map(deviceId => ({\n deviceId,\n value: {\n ...(findDeviceOverride(source, deviceId) || { value: {} }).value,\n ...(findDeviceOverride(override, deviceId, v => v) || { value: {} }).value,\n },\n })) as DeviceOverride<A>[]\n}\n\nexport default function useTypographyMark(\n value: TypographyMarkValue | null | undefined,\n): TypographyMarkData | null | undefined {\n const typography = useTypography(value?.id ?? null)\n const swatchIds = [\n ...getTypographyStyleSwatchIds(value?.style),\n ...getTypographyStyleSwatchIds(typography?.style),\n ]\n const swatches = useSwatches(swatchIds)\n\n return overrideTypographyStyle(\n typography?.style.map(withColor(swatches.filter(isNonNullable))) ?? [],\n value?.style.map(withColor(swatches.filter(isNonNullable))) ?? [],\n )\n}\n","import { ComponentPropsWithoutRef } from 'react'\n\nimport useTypographyMark, {\n TypographyMarkValue,\n overrideTypographyStyle,\n TypographyMarkDataValue,\n} from './hooks/useTypographyMark'\nimport { colorToString } from '../../../../../../utils/colorToString'\nimport { shallowMergeFallbacks } from '../../../../../../utils/devices'\nimport { cx } from '@emotion/css'\nimport { useStyle } from '../../../../../../../runtimes/react/use-style'\nimport { responsiveStyle } from '../../../../../../utils/responsive-style'\nimport { ResponsiveValue } from '../../../../../../../prop-controllers/descriptors'\n\nexport type { TypographyMarkValue }\nexport { overrideTypographyStyle }\n\ntype BaseProps = { value: TypographyMarkValue }\n\ntype Props = BaseProps & Omit<ComponentPropsWithoutRef<'span'>, keyof BaseProps>\n\nexport default function Mark({ value, className, ...restOfProps }: Props): JSX.Element {\n const typographyStyle = useTypographyMark(value)\n const typographyClassName = useStyle(\n responsiveStyle<\n TypographyMarkDataValue,\n [ResponsiveValue<TypographyMarkDataValue> | null | undefined]\n >(\n [typographyStyle],\n ([\n {\n color,\n fontFamily,\n fontSize,\n fontWeight,\n lineHeight,\n letterSpacing,\n uppercase,\n underline,\n strikethrough,\n italic,\n } = {} as TypographyMarkDataValue,\n ]) => ({\n ...(color == null ? {} : { color: colorToString(color) }),\n ...(fontFamily == null ? {} : { fontFamily }),\n ...(fontSize == null || fontSize.value == null || fontSize.unit == null\n ? {}\n : { fontSize: `${fontSize.value}${fontSize.unit}` }),\n ...(fontWeight == null ? {} : { fontWeight }),\n ...(lineHeight == null ? {} : { lineHeight }),\n ...(letterSpacing == null ? {} : { letterSpacing: `${letterSpacing / 10}em` }),\n ...(uppercase == null\n ? {}\n : { textTransform: uppercase === true ? 'uppercase' : 'initial' }),\n ...(underline == null && strikethrough == null\n ? {}\n : {\n textDecoration: [\n Boolean(underline) && 'underline',\n Boolean(strikethrough) && 'line-through',\n ]\n .filter(Boolean)\n .join(' '),\n }),\n ...(italic == null ? {} : { fontStyle: italic === true ? 'italic' : 'initial' }),\n }),\n shallowMergeFallbacks,\n ),\n )\n\n return <span {...restOfProps} className={cx(typographyClassName, className)} />\n}\n","import type { Plugin } from 'slate-react'\n\nimport Mark from '../components/Mark'\n\nconst TYPOGRAPHY_TYPE = 'typography'\n\nexport default function DeviceOverridesMarksPlugin(): Plugin {\n return {\n renderMark({ mark, children }, _editor, next) {\n if (mark.type === TYPOGRAPHY_TYPE) {\n return <Mark value={mark.data.get('value')}>{children}</Mark>\n }\n\n return next()\n },\n }\n}\n","import { cx } from '@emotion/css'\nimport { forwardRef, ComponentPropsWithoutRef, ForwardedRef, ElementRef, ElementType } from 'react'\n\nimport type { ResponsiveValue } from '../../../../../../../prop-controllers'\nimport { useStyle } from '../../../../../../../runtimes/react/use-style'\nimport { responsiveStyle } from '../../../../../../utils/responsive-style'\n\ntype BaseProps<T extends ElementType> = {\n as?: T\n textAlign?: ResponsiveValue<'left' | 'center' | 'right' | 'justify'>\n}\n\ntype Props<T extends ElementType> = BaseProps<T> &\n Omit<ComponentPropsWithoutRef<T>, keyof BaseProps<T>>\n\nexport default forwardRef(function Block<T extends ElementType>(\n { textAlign, className, as, ...restOfProps }: Props<T>,\n ref: ForwardedRef<ElementRef<T>>,\n) {\n const Component = as ?? 'div'\n\n return (\n // @ts-ignore: `ref` types don't match.\n <Component\n {...restOfProps}\n ref={ref}\n className={cx(\n useStyle({ margin: 0 }),\n useStyle(responsiveStyle([textAlign], ([textAlign = 'left']) => ({ textAlign }))),\n useStyle(\n as === 'blockquote'\n ? {\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 ),\n className,\n )}\n />\n )\n})\n","import { Plugin } from 'slate-react'\n\nimport Block from '../components/Block'\n\nexport default function DeviceOverridesBlockPlugin(): Plugin {\n return {\n renderBlock(props, _editor, next): JSX.Element {\n const { node, attributes, children } = props\n const blockProps = { textAlign: node.data.get('textAlign') }\n\n switch (node.type) {\n case 'paragraph':\n return (\n <Block {...attributes} {...blockProps} as=\"p\">\n {children}\n </Block>\n )\n\n case 'heading-one':\n return (\n <Block {...attributes} {...blockProps} as=\"h1\">\n {children}\n </Block>\n )\n\n case 'heading-two':\n return (\n <Block {...attributes} {...blockProps} as=\"h2\">\n {children}\n </Block>\n )\n\n case 'heading-three':\n return (\n <Block {...attributes} {...blockProps} as=\"h3\">\n {children}\n </Block>\n )\n\n case 'heading-four':\n return (\n <Block {...attributes} {...blockProps} as=\"h4\">\n {children}\n </Block>\n )\n\n case 'heading-five':\n return (\n <Block {...attributes} {...blockProps} as=\"h5\">\n {children}\n </Block>\n )\n\n case 'heading-six':\n return (\n <Block {...attributes} {...blockProps} as=\"h6\">\n {children}\n </Block>\n )\n\n case 'blockquote':\n return (\n <Block {...attributes} {...blockProps} as=\"blockquote\">\n {children}\n </Block>\n )\n\n default:\n return next()\n }\n },\n }\n}\n","import { cx } from '@emotion/css'\nimport { ComponentPropsWithoutRef } from 'react'\nimport { Plugin } from 'slate-react'\nimport { useStyle } from '../../../../../../runtimes/react/use-style'\n\nimport { Link } from '../../../../../shared/Link'\n\nfunction StyledLink({ className, ...restOfProps }: ComponentPropsWithoutRef<typeof Link>) {\n return <Link {...restOfProps} className={cx(useStyle({ textDecoration: 'none' }), className)} />\n}\n\nexport default function LinkPlugin(): Plugin {\n return {\n renderInline(props, _editor, next) {\n const { attributes, children, node } = props\n\n switch (node.type) {\n case 'link': {\n const { data } = node\n\n return (\n <StyledLink {...attributes} link={data.toJS()}>\n {children}\n </StyledLink>\n )\n }\n\n default: {\n return next()\n }\n }\n },\n }\n}\n","import { Plugin } from 'slate-react'\n\nexport default function Inlines(): Plugin {\n return {\n renderInline(props, _editor, next) {\n const { attributes, children, node } = props\n\n switch (node.type) {\n case 'code': {\n return <code {...attributes}>{children}</code>\n }\n\n case 'superscript': {\n return <sup {...attributes}>{children}</sup>\n }\n\n case 'subscript': {\n return <sub {...attributes}>{children}</sub>\n }\n\n default: {\n return next()\n }\n }\n },\n }\n}\n","import { ComponentPropsWithoutRef, forwardRef, useMemo } from 'react'\n\nimport { Editor as SlateEditor } from 'slate-react'\n\n// @ts-expect-error: no types for '@convertkit/slate-lists'\nimport Lists from '@convertkit/slate-lists'\n\nimport DeviceOverridesMarks from './plugins/DeviceOverridesMarks'\nimport DeviceOverridesBlocks from './plugins/DeviceOverridesBlocks'\nimport Link from './plugins/Link'\nimport Inlines from './plugins/Inlines'\nimport { useStyle } from '../../../../../runtimes/react/use-style'\nimport { cx } from '@emotion/css'\n\nexport { overrideTypographyStyle } from './components/Mark'\n\ntype Props = ComponentPropsWithoutRef<typeof SlateEditor>\n\nexport const RichTextEditor = forwardRef<SlateEditor, Props>(function RichTextEditor(\n { placeholder = 'Write some text...', className, ...restOfProps }: Props,\n ref,\n) {\n const plugins = useMemo(\n () => [Lists(), Link(), Inlines(), DeviceOverridesBlocks(), DeviceOverridesMarks()],\n [],\n )\n\n return (\n <SlateEditor\n {...restOfProps}\n // Workaround because our Slate editor is broken on Chrome 105\n // Problem: https://linear.app/makeswift/issue/PRD-434/our-rich-text-component-breaks-in-the-latest-version-of-chrome\n // Workaround: https://github.com/ianstormtaylor/slate/issues/5110#issuecomment-1234951122\n style={{ WebkitUserModify: undefined }}\n className={cx(useStyle({ 'ul, ol': { margin: 0 } }), className)}\n ref={ref}\n autoFocus={false}\n plugins={plugins}\n placeholder={placeholder}\n />\n )\n})\n","import {\n useState,\n Ref,\n useImperativeHandle,\n forwardRef,\n useEffect,\n useCallback,\n useRef,\n KeyboardEvent as ReactKeyboardEvent,\n FocusEvent as ReactFocusEvent,\n} from 'react'\nimport { Editor, OnChangeParam } from 'slate-react'\nimport { Value, ValueJSON } from 'slate'\n// @ts-expect-error: no types for 'slate-hotkeys'\nimport Hotkeys from 'slate-hotkeys'\nimport { isHotkey } from 'is-hotkey'\n\nimport {\n ElementIDValue,\n RichTextDescriptor,\n RichTextValue,\n} from '../../../prop-controllers/descriptors'\nimport { BoxModelHandle, getBox } from '../../../box-model'\nimport { PropControllersHandle } from '../../../state/modules/prop-controller-handles'\nimport { RichTextEditor } from './components/RichTextEditor'\nimport { useIsInBuilder } from '../../../runtimes/react'\nimport { DescriptorsPropControllers } from '../../../prop-controllers/instances'\nimport { cx } from '@emotion/css'\n\ntype Props = {\n id?: ElementIDValue\n text?: RichTextValue\n width?: string\n margin?: string\n}\n\nconst defaultText: ValueJSON = {\n document: { nodes: [{ object: 'block' as const, type: 'paragraph' as const, nodes: [] }] },\n data: {},\n}\n\nconst COMMIT_DEBOUNCE_DELAY = 500\n\ntype Descriptors = { text?: RichTextDescriptor }\n\nconst Text = forwardRef(function Text(\n { id, text, width, margin }: Props,\n ref: Ref<BoxModelHandle & PropControllersHandle<Descriptors>>,\n) {\n const [editor, setEditor] = useState<Editor | null>(null)\n const [propControllers, setPropControllers] =\n useState<DescriptorsPropControllers<Descriptors> | null>(null)\n const controller = propControllers?.text\n\n useImperativeHandle(\n ref,\n () => ({\n getBoxModel() {\n const el = editor?.findDOMNode([])\n\n return el instanceof Element ? getBox(el) : null\n },\n setPropControllers,\n }),\n [editor, setPropControllers],\n )\n\n useEffect(() => {\n if (editor) controller?.setSlateEditor(editor)\n }, [controller, editor])\n\n /**\n * We must keep local state so that we can reflect the user's typed changes immediately. At the\n * same time, though, the source of truth for the data is the prop data. This presents a\n * challenge: how do we keep local state in sync with the prop data without mangling user input as\n * data comes in?\n *\n * Consider, for example, that the user types \"Hello\". If at a later time, when the user is trying\n * to type \", world\" the component re-renders with prop data \"H\", \"He\", \"Hel\", \"Hell\", \"Hello\", it\n * will disrupt the user's typing. This could also happen as a result of the prop data changing\n * for other reasons, like collaborators changing the prop data concurrently. We want to avoid to\n * disrupt the user's typing, while at the same time display the \"true\" value as quickly as\n * possible.\n *\n * The approach we take here is to commit the prop data at an opportune time: as the user is\n * typing we avoid to commit prop data. But once they've stopped typing, we commit it as soon as\n * possible. This is known as a debounce.\n */\n const [value, setValue] = useState(() => {\n const { selection, ...textWithoutSelection } = text ?? defaultText\n\n return Value.fromJSON(textWithoutSelection)\n })\n const [shouldCommit, setShouldCommit] = useState(true)\n\n useEffect(() => {\n if (shouldCommit) {\n const nextValue = Value.fromJSON(text ?? defaultText)\n\n setValue(currentValue =>\n currentValue.selection.isBlurred\n ? Value.fromJSON(nextValue.toJSON({ preserveSelection: false }))\n : nextValue,\n )\n }\n }, [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 function handleChange(change: OnChangeParam) {\n setValue(change.value as Value)\n\n if (change.value !== value) {\n setShouldCommit(false)\n\n controller?.onChange(change)\n }\n }\n\n // HACK: Slate holds on to the very first DOM event handlers passed in and doesn't update them\n // even if they change. Since `controller` is first `undefined` then we must use a ref.\n const lastController = useRef(controller)\n if (lastController.current !== controller) lastController.current = controller\n const handleFocus = useCallback(() => {\n lastController.current?.focus()\n }, [])\n const handleKeyDown = useCallback(\n (event: ReactKeyboardEvent, _editor: Editor, next: () => any) => {\n if (Hotkeys.isUndo(event)) {\n lastController.current?.undo()\n\n return true\n }\n\n if (Hotkeys.isRedo(event)) {\n lastController.current?.redo()\n\n return true\n }\n\n if (isHotkey('escape')(event)) {\n lastController.current?.blur()\n\n return true\n }\n\n return next()\n },\n [],\n )\n const handleBlur = useCallback((event: ReactFocusEvent, editor: Editor, next: () => any) => {\n const selection = editor.value.selection\n\n next()\n\n // Normally, after a user highlight a text, clicking on the panel will remove the text selection.\n // This line is a workaround for that. Because the panel is not in the iframe, relatedTarget\n // would be null, and we select the previous text selection to maintain the text highlight.\n // Inspiration: https://github.com/ianstormtaylor/slate/issues/3412#issuecomment-663906003\n if (event.relatedTarget == null) editor.select(selection)\n }, [])\n\n const isInBuilder = useIsInBuilder()\n\n return (\n <RichTextEditor\n // @ts-expect-error: types don't allow for 'id' prop even though it's used.\n id={id}\n ref={setEditor}\n className={cx(width, margin)}\n readOnly={!isInBuilder || controller == null}\n value={value}\n onChange={handleChange}\n onFocus={handleFocus}\n onKeyDown={handleKeyDown}\n onBlur={handleBlur}\n />\n )\n})\n\nexport default Text\n"],"names":["findDeviceOverride","useTypography","getTypographyStyleSwatchIds","useSwatches","isNonNullable","value","className","restOfProps","typographyStyle","useTypographyMark","typographyClassName","useStyle","responsiveStyle","color","fontFamily","fontSize","fontWeight","lineHeight","letterSpacing","uppercase","underline","strikethrough","italic","colorToString","unit","textTransform","textDecoration","Boolean","filter","join","fontStyle","shallowMergeFallbacks","cx","TYPOGRAPHY_TYPE","renderMark","mark","children","_editor","next","type","data","get","forwardRef","ref","textAlign","as","Component","margin","padding","borderLeft","renderBlock","props","node","attributes","blockProps","Link","renderInline","toJS","RichTextEditor","placeholder","plugins","useMemo","Lists","Inlines","DeviceOverridesBlocks","DeviceOverridesMarks","SlateEditor","WebkitUserModify","undefined","defaultText","document","nodes","object","COMMIT_DEBOUNCE_DELAY","Text","id","text","width","editor","setEditor","useState","propControllers","setPropControllers","controller","useImperativeHandle","getBoxModel","el","findDOMNode","Element","getBox","useEffect","setSlateEditor","setValue","selection","textWithoutSelection","Value","fromJSON","shouldCommit","setShouldCommit","nextValue","currentValue","isBlurred","toJSON","preserveSelection","timeoutId","window","setTimeout","clearTimeout","change","onChange","lastController","useRef","current","handleFocus","useCallback","focus","handleKeyDown","event","Hotkeys","isUndo","undo","isRedo","redo","isHotkey","blur","handleBlur","relatedTarget","select","isInBuilder","useIsInBuilder","handleChange"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiCA,MAAM,cAAc,CAAC,EAAE,eAAwC;AAE/D,MAAM,YACJ,CAAC,aACD,CAAC,OAIE;AAJF,eACQ;AAAA,IAAP,OAAO;AAAA,MADR,IACQ,SAAE,YAAF,IAAY,wBAAZ,IAAY,CAAV,WACN,iBAFJ,IAEI;AAAA,IADH;AAAA;AAGC,0CACI,OADJ;AAAA,IAEC,OAAO,kCACF,cACC,QACA;AAAA,MACE,OAAO;AAAA,QACL,QAAQ,SAAS,KAAK,CAAA,MAAK,KAAK,EAAE,OAAO,MAAM,QAAQ;AAAA,QACvD,OAAO,MAAM;AAAA,MACf;AAAA,IAAA,IAEF,CAAC;AAAA,EAET;AAAA;AAES,MAAA,0BAA0B,CACrC,QACA,aAC6B;AAC7B,QAAM,UAAU,CAAC,GAAG,IAAI,IAAI,OAAO,IAAI,WAAW,EAAE,OAAO,SAAS,IAAI,WAAW,CAAC,CAAC,CAAC;AAE/E,SAAA,QAAQ,IAAI,CAAa,aAAA;AAAA,IAC9B;AAAA,IACA,OAAO,kCACDA,MAAA,mBAAmB,QAAQ,QAAQ,KAAK,EAAE,OAAO,MAAM,QACvDA,MAAA,mBAAmB,UAAU,UAAU,CAAK,MAAA,CAAC,KAAK,EAAE,OAAO,CAAC,EAAA,GAAK;AAAA,EAEvE,EAAA;AACJ;AAEA,2BACE,OACuC;;AACvC,QAAM,aAAaC,KAAA,cAAc,qCAAO,OAAP,YAAa,IAAI;AAClD,QAAM,YAAY;AAAA,IAChB,GAAGC,UAA4B,4BAAA,+BAAO,KAAK;AAAA,IAC3C,GAAGA,UAA4B,4BAAA,yCAAY,KAAK;AAAA,EAAA;AAE5C,QAAA,WAAWC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AA,YACpB,CAACG,OAA2BhF,SAAiBC,UAAoB;;AAC3DgF,QAAAA,iBAAAA,WAAQC,OAAOF,KAAf,GAAuB;AACzBP,2BAAeE,YAAfF,mBAAwBU;AAEjB,aAAA;AAAA,IACR;AAEGF,QAAAA,iBAAAA,WAAQG,OAAOJ,KAAf,GAAuB;AACzBP,2BAAeE,YAAfF,mBAAwBY;AAEjB,aAAA;AAAA,IACR;AAED,QAAIC,kBAAS,QAAD,EAAWN,KAAnB,GAA2B;AAC7BP,2BAAeE,YAAfF,mBAAwBc;AAEjB,aAAA;AAAA,IACR;AAED,WAAOtF,MAAP;AAAA,EApB6B,GAsB/B,CAtB+B,CAAA;AAwBjC,QAAMuF,aAAaX,MAAAA,YAAY,CAACG,OAAwBvC,SAAgBxC,UAAoB;AACpFuD,UAAAA,YAAYf,QAAOzE,MAAMwF;;AAQ3BwB,QAAAA,MAAMS,iBAAiB;AAAMhD,cAAOiD,OAAOlC,SAAd;AAAA,EATL,GAU3B,CAV2B,CAAA;AAYxBmC,QAAAA,cAAcC,KAAAA;AAGlB,wCAAC,gBAAD;AAAA,IAEE;AAAA,IACA,KAAKlD;AAAAA,IACL,WAAW/C,IAAAA,GAAG6C,OAAO9B,MAAR;AAAA,IACb,UAAU,CAACiF,eAAe7C,cAAc;AAAA,IACxC;AAAA,IACA,UAAU+C;AAAAA,IACV,SAASjB;AAAAA,IACT,WAAWG;AAAAA,IACX,QAAQS;AAAAA,EAAAA,CAXZ;AAcD,CA/IsB;;"}
1
+ {"version":3,"file":"Text.cjs.js","sources":["../src/components/builtin/Text/Text.tsx"],"sourcesContent":["import dynamic from 'next/dynamic'\nimport { ForwardedRef, forwardRef } from 'react'\nimport { forwardNextDynamicRef } from '../../../next'\nimport { RichTextValue } from '../../../prop-controllers'\nimport { ElementIDValue } from '../../../prop-controllers/descriptors'\n\nimport { useIsPreview } from '../../../runtimes/react'\n\nconst EditableText = forwardNextDynamicRef(patch => dynamic(() => patch(import('./EditableText'))))\nconst ReadOnlyText = forwardNextDynamicRef(patch => dynamic(() => patch(import('./ReadOnlyText'))))\n\ntype Props = {\n id?: ElementIDValue\n text?: RichTextValue\n width?: string\n margin?: string\n}\n\nconst Text = forwardRef(function Text(props: Props, ref: ForwardedRef<unknown>) {\n const isPreview = useIsPreview()\n\n return isPreview ? <EditableText {...props} ref={ref} /> : <ReadOnlyText {...props} ref={ref} />\n})\n\nexport default Text\n"],"names":["EditableText","forwardNextDynamicRef","patch","dynamic","ReadOnlyText","Text","forwardRef","props","ref","isPreview","useIsPreview","_jsx"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAQA,MAAMA,eAAeC,KAAAA,sBAAsBC,CAASC,UAAAA,iBAAAA,WAAQ,MAAMD,MAAM,QAAO,QAAA,EAAA,KAAA,WAAA;AAAA,SAAA,QAAA,uBAAR;EAAA,CAAZ,CAAjB;AAC1C,MAAME,eAAeH,KAAAA,sBAAsBC,CAASC,UAAAA,iBAAAA,WAAQ,MAAMD,MAAM,QAAO,QAAA,EAAA,KAAA,WAAA;AAAA,SAAA,QAAA,uBAAR;EAAA,CAAZ,CAAjB;AAS1C,MAAMG,OAAOC,MAAAA,WAAW,eAAcC,OAAcC,KAA4B;AACxEC,QAAAA,YAAYC,KAAAA;AAEXD,SAAAA,2CAAa,+CAAiBF;IAAO;AAAA,EAAA,EAAzB,IAAwCI,2BAAA,IAAC,cAAD,iCAAkBJ,QAAlB;AAAA,IAAyB;AAAA,EAAA,EAApF;AACD,CAJsB;;"}