@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
@@ -0,0 +1,359 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __defProps = Object.defineProperties;
4
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
5
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
8
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
9
+ var __spreadValues = (a, b) => {
10
+ for (var prop in b || (b = {}))
11
+ if (__hasOwnProp.call(b, prop))
12
+ __defNormalProp(a, prop, b[prop]);
13
+ if (__getOwnPropSymbols)
14
+ for (var prop of __getOwnPropSymbols(b)) {
15
+ if (__propIsEnum.call(b, prop))
16
+ __defNormalProp(a, prop, b[prop]);
17
+ }
18
+ return a;
19
+ };
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
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
34
+ 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
+ var index = require("./index.cjs5.js");
42
+ var jsxRuntime = require("react/jsx-runtime");
43
+ var css = require("@emotion/css");
44
+ var next = require("./index.cjs.js");
45
+ var index$1 = 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
+ require("./constants.cjs.js");
51
+ require("redux");
52
+ require("redux-thunk");
53
+ require("./control.cjs.js");
54
+ require("use-sync-external-store/shim/with-selector");
55
+ require("next/dynamic");
56
+ require("@emotion/serialize");
57
+ require("@emotion/utils");
58
+ require("./text-input.cjs.js");
59
+ require("./combobox.cjs.js");
60
+ require("./types.cjs.js");
61
+ require("color");
62
+ require("scroll-into-view-if-needed");
63
+ require("react-dom");
64
+ require("html-react-parser");
65
+ require("next/head");
66
+ require("@emotion/server/create-instance");
67
+ require("next/document");
68
+ require("cookie");
69
+ require("cors");
70
+ require("http-proxy");
71
+ require("set-cookie-parser");
72
+ require("uuid/v4");
73
+ require("corporate-ipsum");
74
+ require("next/link");
75
+ function _interopDefaultLegacy(e) {
76
+ return e && typeof e === "object" && "default" in e ? e : { "default": e };
77
+ }
78
+ var Hotkeys__default = /* @__PURE__ */ _interopDefaultLegacy(Hotkeys);
79
+ var Lists__default = /* @__PURE__ */ _interopDefaultLegacy(Lists);
80
+ const TYPOGRAPHY_TYPE = "typography";
81
+ function DeviceOverridesMarksPlugin() {
82
+ return {
83
+ renderMark({
84
+ mark,
85
+ children
86
+ }, _editor, next2) {
87
+ if (mark.type === TYPOGRAPHY_TYPE) {
88
+ return /* @__PURE__ */ jsxRuntime.jsx(index.Mark, {
89
+ value: mark.data.get("value"),
90
+ children
91
+ });
92
+ }
93
+ return next2();
94
+ }
95
+ };
96
+ }
97
+ function DeviceOverridesBlockPlugin() {
98
+ return {
99
+ renderBlock(props, _editor, next2) {
100
+ const {
101
+ node,
102
+ attributes,
103
+ children
104
+ } = props;
105
+ const blockProps = {
106
+ textAlign: node.data.get("textAlign")
107
+ };
108
+ switch (node.type) {
109
+ case "paragraph":
110
+ return /* @__PURE__ */ jsxRuntime.jsx(index.DeviceOverrideBlock, __spreadProps(__spreadValues(__spreadValues({}, attributes), blockProps), {
111
+ as: "p",
112
+ children
113
+ }));
114
+ case "heading-one":
115
+ return /* @__PURE__ */ jsxRuntime.jsx(index.DeviceOverrideBlock, __spreadProps(__spreadValues(__spreadValues({}, attributes), blockProps), {
116
+ as: "h1",
117
+ children
118
+ }));
119
+ case "heading-two":
120
+ return /* @__PURE__ */ jsxRuntime.jsx(index.DeviceOverrideBlock, __spreadProps(__spreadValues(__spreadValues({}, attributes), blockProps), {
121
+ as: "h2",
122
+ children
123
+ }));
124
+ case "heading-three":
125
+ return /* @__PURE__ */ jsxRuntime.jsx(index.DeviceOverrideBlock, __spreadProps(__spreadValues(__spreadValues({}, attributes), blockProps), {
126
+ as: "h3",
127
+ children
128
+ }));
129
+ case "heading-four":
130
+ return /* @__PURE__ */ jsxRuntime.jsx(index.DeviceOverrideBlock, __spreadProps(__spreadValues(__spreadValues({}, attributes), blockProps), {
131
+ as: "h4",
132
+ children
133
+ }));
134
+ case "heading-five":
135
+ return /* @__PURE__ */ jsxRuntime.jsx(index.DeviceOverrideBlock, __spreadProps(__spreadValues(__spreadValues({}, attributes), blockProps), {
136
+ as: "h5",
137
+ children
138
+ }));
139
+ case "heading-six":
140
+ return /* @__PURE__ */ jsxRuntime.jsx(index.DeviceOverrideBlock, __spreadProps(__spreadValues(__spreadValues({}, attributes), blockProps), {
141
+ as: "h6",
142
+ children
143
+ }));
144
+ case "blockquote":
145
+ return /* @__PURE__ */ jsxRuntime.jsx(index.DeviceOverrideBlock, __spreadProps(__spreadValues(__spreadValues({}, attributes), blockProps), {
146
+ as: "blockquote",
147
+ children
148
+ }));
149
+ default:
150
+ return next2();
151
+ }
152
+ }
153
+ };
154
+ }
155
+ function StyledLink(_a) {
156
+ var _b = _a, {
157
+ className
158
+ } = _b, restOfProps = __objRest(_b, [
159
+ "className"
160
+ ]);
161
+ return /* @__PURE__ */ jsxRuntime.jsx(index$1.Link, __spreadProps(__spreadValues({}, restOfProps), {
162
+ className: css.cx(next.useStyle({
163
+ textDecoration: "none"
164
+ }), className)
165
+ }));
166
+ }
167
+ function LinkPlugin() {
168
+ return {
169
+ renderInline(props, _editor, next2) {
170
+ const {
171
+ attributes,
172
+ children,
173
+ node
174
+ } = props;
175
+ switch (node.type) {
176
+ case "link": {
177
+ const {
178
+ data
179
+ } = node;
180
+ return /* @__PURE__ */ jsxRuntime.jsx(StyledLink, __spreadProps(__spreadValues({}, attributes), {
181
+ link: data.toJS(),
182
+ children
183
+ }));
184
+ }
185
+ default: {
186
+ return next2();
187
+ }
188
+ }
189
+ }
190
+ };
191
+ }
192
+ function Inlines() {
193
+ return {
194
+ renderInline(props, _editor, next2) {
195
+ const {
196
+ attributes,
197
+ children,
198
+ node
199
+ } = props;
200
+ switch (node.type) {
201
+ case "code": {
202
+ return /* @__PURE__ */ jsxRuntime.jsx("code", __spreadProps(__spreadValues({}, attributes), {
203
+ children
204
+ }));
205
+ }
206
+ case "superscript": {
207
+ return /* @__PURE__ */ jsxRuntime.jsx("sup", __spreadProps(__spreadValues({}, attributes), {
208
+ children
209
+ }));
210
+ }
211
+ case "subscript": {
212
+ return /* @__PURE__ */ jsxRuntime.jsx("sub", __spreadProps(__spreadValues({}, attributes), {
213
+ children
214
+ }));
215
+ }
216
+ default: {
217
+ return next2();
218
+ }
219
+ }
220
+ }
221
+ };
222
+ }
223
+ const RichTextEditor = React.forwardRef(function RichTextEditor2(_c, ref) {
224
+ var _d = _c, {
225
+ placeholder = "Write some text...",
226
+ className
227
+ } = _d, restOfProps = __objRest(_d, [
228
+ "placeholder",
229
+ "className"
230
+ ]);
231
+ const plugins = React.useMemo(() => [Lists__default["default"](), LinkPlugin(), Inlines(), DeviceOverridesBlockPlugin(), DeviceOverridesMarksPlugin()], []);
232
+ return /* @__PURE__ */ jsxRuntime.jsx(slateReact.Editor, __spreadProps(__spreadValues({}, restOfProps), {
233
+ style: {
234
+ WebkitUserModify: void 0
235
+ },
236
+ className: css.cx(next.useStyle({
237
+ "ul, ol": {
238
+ margin: 0
239
+ }
240
+ }), className),
241
+ ref,
242
+ autoFocus: false,
243
+ plugins,
244
+ placeholder
245
+ }));
246
+ });
247
+ const defaultText = {
248
+ document: {
249
+ nodes: [{
250
+ object: "block",
251
+ type: "paragraph",
252
+ nodes: []
253
+ }]
254
+ },
255
+ data: {}
256
+ };
257
+ const COMMIT_DEBOUNCE_DELAY = 500;
258
+ const EditableText = React.forwardRef(function EditableText2({
259
+ id,
260
+ text,
261
+ width,
262
+ margin
263
+ }, ref) {
264
+ const [editor, setEditor] = React.useState(null);
265
+ const [propControllers, setPropControllers] = React.useState(null);
266
+ const controller = propControllers == null ? void 0 : propControllers.text;
267
+ React.useImperativeHandle(ref, () => ({
268
+ getBoxModel() {
269
+ const el = editor == null ? void 0 : editor.findDOMNode([]);
270
+ return el instanceof Element ? boxModels.getBox(el) : null;
271
+ },
272
+ setPropControllers
273
+ }), [editor, setPropControllers]);
274
+ React.useEffect(() => {
275
+ if (editor)
276
+ controller == null ? void 0 : controller.setSlateEditor(editor);
277
+ }, [controller, editor]);
278
+ const [value, setValue] = React.useState(() => {
279
+ const _a = text != null ? text : defaultText, {
280
+ selection
281
+ } = _a, textWithoutSelection = __objRest(_a, [
282
+ "selection"
283
+ ]);
284
+ return slate.Value.fromJSON(textWithoutSelection);
285
+ });
286
+ const [shouldCommit, setShouldCommit] = React.useState(true);
287
+ React.useEffect(() => {
288
+ if (shouldCommit) {
289
+ const nextValue = slate.Value.fromJSON(text != null ? text : defaultText);
290
+ setValue((currentValue) => currentValue.selection.isBlurred ? slate.Value.fromJSON(nextValue.toJSON({
291
+ preserveSelection: false
292
+ })) : nextValue);
293
+ }
294
+ }, [shouldCommit, text]);
295
+ React.useEffect(() => {
296
+ if (shouldCommit)
297
+ return;
298
+ const timeoutId = window.setTimeout(() => {
299
+ setShouldCommit(true);
300
+ }, COMMIT_DEBOUNCE_DELAY);
301
+ return () => {
302
+ window.clearTimeout(timeoutId);
303
+ };
304
+ }, [shouldCommit]);
305
+ function handleChange(change) {
306
+ setValue(change.value);
307
+ if (change.value !== value) {
308
+ setShouldCommit(false);
309
+ controller == null ? void 0 : controller.onChange(change);
310
+ }
311
+ }
312
+ const lastController = React.useRef(controller);
313
+ if (lastController.current !== controller)
314
+ lastController.current = controller;
315
+ const handleFocus = React.useCallback(() => {
316
+ var _a;
317
+ (_a = lastController.current) == null ? void 0 : _a.focus();
318
+ }, []);
319
+ const handleKeyDown = React.useCallback((event, _editor, next2) => {
320
+ var _a, _b, _c;
321
+ if (Hotkeys__default["default"].isUndo(event)) {
322
+ (_a = lastController.current) == null ? void 0 : _a.undo();
323
+ return true;
324
+ }
325
+ if (Hotkeys__default["default"].isRedo(event)) {
326
+ (_b = lastController.current) == null ? void 0 : _b.redo();
327
+ return true;
328
+ }
329
+ if (isHotkey.isHotkey("escape")(event)) {
330
+ (_c = lastController.current) == null ? void 0 : _c.blur();
331
+ return true;
332
+ }
333
+ return next2();
334
+ }, []);
335
+ const handleBlur = React.useCallback((event, editor2, next2) => {
336
+ const selection = editor2.value.selection;
337
+ next2();
338
+ if (event.relatedTarget == null)
339
+ editor2.select(selection);
340
+ }, []);
341
+ const isInBuilder = next.useIsInBuilder();
342
+ return /* @__PURE__ */ jsxRuntime.jsx(RichTextEditor, {
343
+ id,
344
+ ref: setEditor,
345
+ className: css.cx(next.useStyle({
346
+ "ul, ol": {
347
+ margin: 0
348
+ }
349
+ }), width, margin),
350
+ value,
351
+ onChange: handleChange,
352
+ onFocus: handleFocus,
353
+ onKeyDown: handleKeyDown,
354
+ onBlur: handleBlur,
355
+ readOnly: !isInBuilder || controller == null
356
+ });
357
+ });
358
+ exports["default"] = EditableText;
359
+ //# sourceMappingURL=EditableText.cjs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EditableText.cjs.js","sources":["../src/components/builtin/Text/components/RichTextEditor/plugins/DeviceOverridesMarks.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/EditableText.tsx"],"sourcesContent":["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 { 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 { DescriptorsPropControllers } from '../../../prop-controllers/instances'\nimport { cx } from '@emotion/css'\nimport { useStyle } from '../../../runtimes/react/use-style'\nimport { useIsInBuilder } from '../../../runtimes/react'\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 EditableText = forwardRef(function EditableText(\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(useStyle({ 'ul, ol': { margin: 0 } }), width, margin)}\n value={value}\n onChange={handleChange}\n onFocus={handleFocus}\n onKeyDown={handleKeyDown}\n onBlur={handleBlur}\n readOnly={!isInBuilder || controller == null}\n />\n )\n})\n\nexport default EditableText\n"],"names":["TYPOGRAPHY_TYPE","renderMark","mark","children","_editor","next","type","Mark","data","get","renderBlock","props","node","attributes","blockProps","textAlign","Block","className","restOfProps","Link","cx","useStyle","textDecoration","renderInline","toJS","RichTextEditor","forwardRef","ref","placeholder","plugins","useMemo","Lists","Inlines","DeviceOverridesBlocks","DeviceOverridesMarks","SlateEditor","WebkitUserModify","undefined","margin","defaultText","document","nodes","object","COMMIT_DEBOUNCE_DELAY","EditableText","id","text","width","editor","setEditor","useState","propControllers","setPropControllers","controller","useImperativeHandle","getBoxModel","el","findDOMNode","Element","getBox","useEffect","setSlateEditor","value","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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,MAAMA,kBAAkB;AAEqC,sCAAA;AACpD,SAAA;AAAA,IACLC,WAAW;AAAA,MAAEC;AAAAA,MAAMC;AAAAA,OAAYC,SAASC,OAAM;AACxCH,UAAAA,KAAKI,SAASN,iBAAiB;AACjC,8CAAQO,MAAAA,MAAD;AAAA,UAAM,OAAOL,KAAKM,KAAKC,IAAI,OAAd;AAAA,UAAyBN;AAAAA,QAAAA,CAA7C;AAAA,MACD;AAED,aAAOE,MAAP;AAAA,IACD;AAAA,EAAA;AAEJ;ACZ4D,sCAAA;AACpD,SAAA;AAAA,IACLK,YAAYC,OAAOP,SAASC,OAAmB;AACvC,YAAA;AAAA,QAAEO;AAAAA,QAAMC;AAAAA,QAAYV;AAAAA,UAAaQ;AACvC,YAAMG,aAAa;AAAA,QAAEC,WAAWH,KAAKJ,KAAKC,IAAI,WAAd;AAAA,MAAA;AAExBG,cAAAA,KAAKN;AAAAA,aACN;AAED,gDAACU,MAAAA,qBAAD,gDAAWH,aAAgBC,aAA3B;AAAA,YAAuC,IAAG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