@makeswift/runtime 0.10.3 → 0.10.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (146) hide show
  1. package/dist/Box.cjs.js +1 -3
  2. package/dist/Box.cjs.js.map +1 -1
  3. package/dist/Box.es.js +2 -4
  4. package/dist/Box.es.js.map +1 -1
  5. package/dist/Button.cjs.js +4 -4
  6. package/dist/Button.es.js +5 -5
  7. package/dist/Carousel.cjs.js +3 -3
  8. package/dist/Carousel.es.js +4 -4
  9. package/dist/Countdown.cjs.js +1 -3
  10. package/dist/Countdown.cjs.js.map +1 -1
  11. package/dist/Countdown.es.js +2 -4
  12. package/dist/Countdown.es.js.map +1 -1
  13. package/dist/Divider.cjs.js +1 -3
  14. package/dist/Divider.cjs.js.map +1 -1
  15. package/dist/Divider.es.js +2 -4
  16. package/dist/Divider.es.js.map +1 -1
  17. package/dist/Embed.cjs.js +1 -0
  18. package/dist/Embed.cjs.js.map +1 -1
  19. package/dist/Embed.es.js +2 -1
  20. package/dist/Embed.es.js.map +1 -1
  21. package/dist/Form.cjs.js +13 -13
  22. package/dist/Form.cjs.js.map +1 -1
  23. package/dist/Form.es.js +5 -5
  24. package/dist/Image.cjs.js +13 -13
  25. package/dist/Image.cjs.js.map +1 -1
  26. package/dist/Image.es.js +13 -13
  27. package/dist/LiveProvider.cjs.js +1 -3
  28. package/dist/LiveProvider.cjs.js.map +1 -1
  29. package/dist/LiveProvider.es.js +3 -5
  30. package/dist/LiveProvider.es.js.map +1 -1
  31. package/dist/Navigation.cjs.js +12 -12
  32. package/dist/Navigation.cjs.js.map +1 -1
  33. package/dist/Navigation.es.js +12 -12
  34. package/dist/PreviewProvider.cjs.js +1 -3
  35. package/dist/PreviewProvider.cjs.js.map +1 -1
  36. package/dist/PreviewProvider.es.js +3 -5
  37. package/dist/PreviewProvider.es.js.map +1 -1
  38. package/dist/ReadOnlyText.cjs.js +7 -6
  39. package/dist/ReadOnlyText.cjs.js.map +1 -1
  40. package/dist/ReadOnlyText.es.js +4 -3
  41. package/dist/ReadOnlyText.es.js.map +1 -1
  42. package/dist/ReadOnlyTextV2.cjs.js +7 -60
  43. package/dist/ReadOnlyTextV2.cjs.js.map +1 -1
  44. package/dist/ReadOnlyTextV2.es.js +9 -62
  45. package/dist/ReadOnlyTextV2.es.js.map +1 -1
  46. package/dist/Root.cjs.js +1 -3
  47. package/dist/Root.cjs.js.map +1 -1
  48. package/dist/Root.es.js +2 -4
  49. package/dist/Root.es.js.map +1 -1
  50. package/dist/SocialLinks.cjs.js +6 -6
  51. package/dist/SocialLinks.cjs.js.map +1 -1
  52. package/dist/SocialLinks.es.js +7 -7
  53. package/dist/Video.cjs.js +1 -0
  54. package/dist/Video.cjs.js.map +1 -1
  55. package/dist/Video.es.js +2 -1
  56. package/dist/Video.es.js.map +1 -1
  57. package/dist/builder.cjs.js +1 -0
  58. package/dist/builder.cjs.js.map +1 -1
  59. package/dist/builder.es.js +1 -0
  60. package/dist/builder.es.js.map +1 -1
  61. package/dist/components.cjs.js +3 -3
  62. package/dist/components.es.js +3 -3
  63. package/dist/control-serialization.es.js +1 -1
  64. package/dist/controls.cjs.js +1 -0
  65. package/dist/controls.cjs.js.map +1 -1
  66. package/dist/controls.es.js +2 -1
  67. package/dist/controls.es.js.map +1 -1
  68. package/dist/index.cjs.js +120 -256
  69. package/dist/index.cjs.js.map +1 -1
  70. package/dist/index.cjs3.js +107 -21
  71. package/dist/index.cjs3.js.map +1 -1
  72. package/dist/index.cjs4.js +57 -16
  73. package/dist/index.cjs4.js.map +1 -1
  74. package/dist/index.cjs5.js +42 -81
  75. package/dist/index.cjs5.js.map +1 -1
  76. package/dist/index.cjs6.js +82 -17
  77. package/dist/index.cjs6.js.map +1 -1
  78. package/dist/index.cjs7.js +18 -377
  79. package/dist/index.cjs7.js.map +1 -1
  80. package/dist/index.cjs8.js +258 -181
  81. package/dist/index.cjs8.js.map +1 -1
  82. package/dist/index.cjs9.js +343 -0
  83. package/dist/index.cjs9.js.map +1 -0
  84. package/dist/index.es.js +125 -260
  85. package/dist/index.es.js.map +1 -1
  86. package/dist/index.es2.js +1 -1
  87. package/dist/index.es3.js +103 -22
  88. package/dist/index.es3.js.map +1 -1
  89. package/dist/index.es4.js +57 -16
  90. package/dist/index.es4.js.map +1 -1
  91. package/dist/index.es5.js +42 -80
  92. package/dist/index.es5.js.map +1 -1
  93. package/dist/index.es6.js +81 -17
  94. package/dist/index.es6.js.map +1 -1
  95. package/dist/index.es7.js +18 -371
  96. package/dist/index.es7.js.map +1 -1
  97. package/dist/index.es8.js +259 -182
  98. package/dist/index.es8.js.map +1 -1
  99. package/dist/index.es9.js +336 -0
  100. package/dist/index.es9.js.map +1 -0
  101. package/dist/main.cjs.js +1 -0
  102. package/dist/main.cjs.js.map +1 -1
  103. package/dist/main.es.js +1 -0
  104. package/dist/main.es.js.map +1 -1
  105. package/dist/next.cjs.js +1 -3
  106. package/dist/next.cjs.js.map +1 -1
  107. package/dist/next.es.js +2 -4
  108. package/dist/next.es.js.map +1 -1
  109. package/dist/prop-controllers.cjs.js +1 -0
  110. package/dist/prop-controllers.cjs.js.map +1 -1
  111. package/dist/prop-controllers.es.js +1 -0
  112. package/dist/prop-controllers.es.js.map +1 -1
  113. package/dist/react-page.cjs.js +26 -6
  114. package/dist/react-page.cjs.js.map +1 -1
  115. package/dist/react-page.es.js +26 -7
  116. package/dist/react-page.es.js.map +1 -1
  117. package/dist/react.cjs.js +1 -3
  118. package/dist/react.cjs.js.map +1 -1
  119. package/dist/react.es.js +1 -3
  120. package/dist/react.es.js.map +1 -1
  121. package/dist/slate.cjs.js +9 -6
  122. package/dist/slate.cjs.js.map +1 -1
  123. package/dist/slate.es.js +9 -7
  124. package/dist/slate.es.js.map +1 -1
  125. package/dist/toText.cjs.js +67 -0
  126. package/dist/toText.cjs.js.map +1 -0
  127. package/dist/toText.es.js +66 -0
  128. package/dist/toText.es.js.map +1 -0
  129. package/dist/types/src/components/builtin/Text/register.d.ts.map +1 -1
  130. package/dist/types/src/controls/rich-text-v2/rich-text-v2.d.ts +2 -4
  131. package/dist/types/src/controls/rich-text-v2/rich-text-v2.d.ts.map +1 -1
  132. package/dist/types/src/runtimes/react/controls/rich-text-v2/EditableTextV2/editable-text-v2.d.ts.map +1 -1
  133. package/dist/types/src/runtimes/react/controls/rich-text-v2/EditableTextV2/render-element.d.ts.map +1 -1
  134. package/dist/types/src/runtimes/react/controls/rich-text-v2/EditableTextV2/usePresetValue.d.ts +10 -0
  135. package/dist/types/src/runtimes/react/controls/rich-text-v2/EditableTextV2/usePresetValue.d.ts.map +1 -0
  136. package/dist/types/src/runtimes/react/controls/rich-text-v2/ReadOnlyTextV2.d.ts.map +1 -1
  137. package/dist/types/src/slate/BuilderPlugin/index.d.ts +2 -1
  138. package/dist/types/src/slate/BuilderPlugin/index.d.ts.map +1 -1
  139. package/dist/types/src/slate/InlineModePlugin/index.d.ts.map +1 -1
  140. package/dist/types/src/slate/index.d.ts +1 -0
  141. package/dist/types/src/slate/index.d.ts.map +1 -1
  142. package/dist/types/src/slate/utils/index.d.ts +2 -0
  143. package/dist/types/src/slate/utils/index.d.ts.map +1 -0
  144. package/dist/types/src/slate/utils/toText.d.ts +4 -0
  145. package/dist/types/src/slate/utils/toText.d.ts.map +1 -0
  146. package/package.json +1 -1
package/dist/index.es7.js CHANGED
@@ -1,374 +1,21 @@
1
- var __defProp = Object.defineProperty;
2
- var __defProps = Object.defineProperties;
3
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
4
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
7
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
- var __spreadValues = (a, b) => {
9
- for (var prop in b || (b = {}))
10
- if (__hasOwnProp.call(b, prop))
11
- __defNormalProp(a, prop, b[prop]);
12
- if (__getOwnPropSymbols)
13
- for (var prop of __getOwnPropSymbols(b)) {
14
- if (__propIsEnum.call(b, prop))
15
- __defNormalProp(a, prop, b[prop]);
16
- }
17
- return a;
18
- };
19
- var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
- var __objRest = (source, exclude) => {
21
- var target = {};
22
- for (var prop in source)
23
- if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
24
- target[prop] = source[prop];
25
- if (source != null && __getOwnPropSymbols)
26
- for (var prop of __getOwnPropSymbols(source)) {
27
- if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
28
- target[prop] = source[prop];
29
- }
30
- return target;
31
- };
32
- import { cx } from "@emotion/css";
33
- import { getBox } from "css-box-model";
34
- import isHotkey from "is-hotkey";
35
- import { useCallback, useState, useEffect, forwardRef, useImperativeHandle, useMemo } from "react";
36
- import { Range, createEditor } from "slate";
37
- import { ReactEditor, withReact, Slate, Editable } from "slate-react";
38
- import { n as useResponsiveStyle, L as Link, J as useEnhancedTypography, K as useTypographyClassName, u as useIsInBuilder, N as useBuilderEditMode, O as pollBoxModel } from "./index.es.js";
39
- import { _ as useStyle, Y as BlockType, bO as InlineType, bo as richTextDTOtoDAO, bn as richTextDTOtoSelection, a as deepEqual, bH as withBlock, bC as withTypography, bG as onKeyDown, b$ as BuilderEditMode } from "./react-page.es.js";
40
- import "uuid";
41
- import { jsx } from "react/jsx-runtime";
42
- import { w as withBuilder } from "./index.es4.js";
43
- import "./state/breakpoints.es.js";
44
- import "./actions.es.js";
45
- import { u as useIsomorphicLayoutEffect } from "./useIsomorphicLayoutEffect.es.js";
46
- import "use-sync-external-store/shim/with-selector";
47
- import "next/dynamic";
48
- import "./text-input.es.js";
49
- import "./combobox.es.js";
50
- import "use-sync-external-store/shim";
51
- import "redux";
52
- import "redux-thunk";
53
- import "./types.es.js";
54
- import "./box-models.es.js";
55
- import "color";
56
- import "scroll-into-view-if-needed";
57
- import "react-dom";
58
- import "html-react-parser";
59
- import "next/head";
60
- import "zod";
61
- import "@emotion/server/create-instance";
62
- import "next/document";
63
- import "cors";
64
- import "path-to-regexp";
65
- import "cookie";
66
- import "http-proxy";
67
- import "set-cookie-parser";
68
- import "./constants.es.js";
69
- import "corporate-ipsum";
70
- import "next/link";
71
- import "@emotion/serialize";
72
- import "@emotion/utils";
73
- function BlockElement({
74
- element,
75
- attributes,
76
- children
77
- }) {
78
- const blockStyles = [useStyle({
79
- margin: 0
80
- }), useStyle(useResponsiveStyle([element.textAlign], ([textAlign = "left"]) => ({
81
- textAlign
82
- })))];
83
- const quoteStyles = useStyle({
84
- padding: "0.5em 10px",
85
- fontSize: "1.25em",
86
- fontWeight: "300",
87
- borderLeft: "5px solid rgba(0, 0, 0, 0.1)"
88
- });
89
- switch (element.type) {
90
- case BlockType.Default:
91
- case BlockType.Paragraph:
92
- return /* @__PURE__ */ jsx("p", __spreadProps(__spreadValues({}, attributes), {
93
- className: cx(...blockStyles),
94
- children
95
- }));
96
- case BlockType.Heading1:
97
- return /* @__PURE__ */ jsx("h1", __spreadProps(__spreadValues({}, attributes), {
98
- className: cx(...blockStyles),
99
- children
100
- }));
101
- case BlockType.Heading2:
102
- return /* @__PURE__ */ jsx("h2", __spreadProps(__spreadValues({}, attributes), {
103
- className: cx(...blockStyles),
104
- children
105
- }));
106
- case BlockType.Heading3:
107
- return /* @__PURE__ */ jsx("h3", __spreadProps(__spreadValues({}, attributes), {
108
- className: cx(...blockStyles),
109
- children
110
- }));
111
- case BlockType.Heading4:
112
- return /* @__PURE__ */ jsx("h4", __spreadProps(__spreadValues({}, attributes), {
113
- className: cx(...blockStyles),
114
- children
115
- }));
116
- case BlockType.Heading5:
117
- return /* @__PURE__ */ jsx("h5", __spreadProps(__spreadValues({}, attributes), {
118
- className: cx(...blockStyles),
119
- children
120
- }));
121
- case BlockType.Heading6:
122
- return /* @__PURE__ */ jsx("h6", __spreadProps(__spreadValues({}, attributes), {
123
- className: cx(...blockStyles),
124
- children
125
- }));
126
- case BlockType.BlockQuote:
127
- return /* @__PURE__ */ jsx("blockquote", __spreadProps(__spreadValues({}, attributes), {
128
- className: cx(...blockStyles, quoteStyles),
129
- children
130
- }));
131
- case BlockType.OrderedList:
132
- return /* @__PURE__ */ jsx("ol", __spreadProps(__spreadValues({}, attributes), {
133
- className: cx(...blockStyles),
134
- style: {
135
- listStylePosition: "inside"
136
- },
137
- children
138
- }));
139
- case BlockType.UnorderedList:
140
- return /* @__PURE__ */ jsx("ul", __spreadProps(__spreadValues({}, attributes), {
141
- className: cx(...blockStyles),
142
- style: {
143
- listStylePosition: "inside"
144
- },
145
- children
146
- }));
147
- case BlockType.ListItem:
148
- return /* @__PURE__ */ jsx("li", __spreadProps(__spreadValues({}, attributes), {
149
- className: cx(...blockStyles),
150
- children
151
- }));
152
- case BlockType.ListItemChild:
153
- return /* @__PURE__ */ jsx("span", __spreadProps(__spreadValues({}, attributes), {
154
- className: cx(...blockStyles),
155
- children
156
- }));
157
- }
158
- }
159
- function StyledLink(_a) {
160
- var _b = _a, {
161
- className
162
- } = _b, restOfProps = __objRest(_b, [
163
- "className"
164
- ]);
165
- return /* @__PURE__ */ jsx(Link, __spreadProps(__spreadValues({}, restOfProps), {
166
- className: cx(useStyle({
167
- textDecoration: "none"
168
- }), className)
169
- }));
170
- }
171
- function InlineElement({
172
- element,
173
- attributes,
174
- children
175
- }) {
176
- var _a;
177
- switch (element.type) {
178
- case InlineType.Code:
179
- return /* @__PURE__ */ jsx("code", __spreadProps(__spreadValues({}, attributes), {
180
- children
181
- }));
182
- case InlineType.SuperScript:
183
- return /* @__PURE__ */ jsx("sup", __spreadProps(__spreadValues({}, attributes), {
184
- children
185
- }));
186
- case InlineType.SubScript:
187
- return /* @__PURE__ */ jsx("sub", __spreadProps(__spreadValues({}, attributes), {
188
- children
189
- }));
190
- case InlineType.Link:
191
- return /* @__PURE__ */ jsx(StyledLink, __spreadProps(__spreadValues({}, attributes), {
192
- link: (_a = element.link) != null ? _a : void 0,
193
- children
194
- }));
195
- }
196
- }
197
- function Element(_c) {
198
- var _d = _c, {
199
- element
200
- } = _d, props = __objRest(_d, [
201
- "element"
202
- ]);
203
- switch (element.type) {
204
- case InlineType.Code:
205
- case InlineType.SuperScript:
206
- case InlineType.SubScript:
207
- case InlineType.Link:
208
- return /* @__PURE__ */ jsx(InlineElement, __spreadValues({
209
- element
210
- }, props));
211
- case BlockType.Default:
212
- case BlockType.Paragraph:
213
- case BlockType.Heading1:
214
- case BlockType.Heading2:
215
- case BlockType.Heading3:
216
- case BlockType.Heading4:
217
- case BlockType.Heading5:
218
- case BlockType.Heading6:
219
- case BlockType.BlockQuote:
220
- case BlockType.OrderedList:
221
- case BlockType.UnorderedList:
222
- case BlockType.ListItem:
223
- case BlockType.ListItemChild:
224
- return /* @__PURE__ */ jsx(BlockElement, __spreadValues({
225
- element
226
- }, props));
227
- default:
228
- return /* @__PURE__ */ jsx("span", __spreadProps(__spreadValues({}, props.attributes), {
229
- children: props.children
230
- }));
231
- }
232
- }
233
- function Leaf(_e) {
234
- var _f = _e, {
235
- leaf
236
- } = _f, props = __objRest(_f, [
237
- "leaf"
238
- ]);
239
- const enhancedTypography = useEnhancedTypography(leaf.typography);
240
- const typographyClassName = useTypographyClassName(enhancedTypography);
241
- return /* @__PURE__ */ jsx("span", __spreadProps(__spreadValues({}, props.attributes), {
242
- className: typographyClassName,
243
- children: props.children
244
- }));
245
- }
246
- function useSyncDOMSelection(editor, isEnabled) {
247
- useIsomorphicLayoutEffect(() => {
248
- if (!isEnabled || editor.selection == null || ReactEditor.isFocused(editor))
1
+ import { v4 } from "uuid";
2
+ function withLocalChanges(editor) {
3
+ editor.localChanges = /* @__PURE__ */ new Map();
4
+ editor.recentLocalChanges = [];
5
+ editor.currentKey = "";
6
+ const _onChange = editor.onChange;
7
+ editor.onChange = (options) => {
8
+ _onChange(options);
9
+ if (editor == null || (options == null ? void 0 : options.operation) == null)
249
10
  return;
250
- try {
251
- const root = ReactEditor.findDocumentOrShadowRoot(editor);
252
- const domSelection = root.getSelection();
253
- const newDomRange = ReactEditor.toDOMRange(editor, editor.selection);
254
- if (newDomRange) {
255
- if (Range.isBackward(editor.selection)) {
256
- domSelection == null ? void 0 : domSelection.setBaseAndExtent(newDomRange.endContainer, newDomRange.endOffset, newDomRange.startContainer, newDomRange.startOffset);
257
- } else {
258
- domSelection == null ? void 0 : domSelection.setBaseAndExtent(newDomRange.startContainer, newDomRange.startOffset, newDomRange.endContainer, newDomRange.endOffset);
259
- }
260
- } else {
261
- domSelection == null ? void 0 : domSelection.removeAllRanges();
262
- }
263
- } catch (e) {
264
- console.error(e);
265
- }
266
- });
267
- }
268
- const COMMIT_DEBOUNCE_DELAY = 500;
269
- function useSyncWithBuilder(editor, text) {
270
- const [shouldCommit, setShouldCommit] = useState(true);
271
- const isInBuilder = useIsInBuilder();
272
- useEffect(() => {
273
- if (shouldCommit && text && isInBuilder) {
274
- const nextValue = richTextDTOtoDAO(text);
275
- const nextSelection = richTextDTOtoSelection(text);
276
- if (!deepEqual(editor.children, nextValue) || !deepEqual(editor.selection, nextSelection)) {
277
- editor.children = nextValue;
278
- editor.selection = nextSelection;
279
- editor.onChange();
280
- }
281
- }
282
- }, [editor, shouldCommit, text]);
283
- useEffect(() => {
284
- if (shouldCommit)
285
- return;
286
- const timeoutId = window.setTimeout(() => {
287
- setShouldCommit(true);
288
- }, COMMIT_DEBOUNCE_DELAY);
289
- return () => {
290
- window.clearTimeout(timeoutId);
291
- };
292
- }, [shouldCommit]);
293
- return useCallback(() => setShouldCommit(false), []);
294
- }
295
- const defaultText = [{
296
- type: BlockType.Paragraph,
297
- children: [{
298
- text: ""
299
- }]
300
- }];
301
- const EditableText = forwardRef(function EditableText2({
302
- id,
303
- text,
304
- width,
305
- margin
306
- }, ref) {
307
- const [editor] = useState(() => withBlock(withTypography(withBuilder(withReact(createEditor())))));
308
- const [isPreservingDOMSElection, setIsPreservingDOMSelection] = useState(false);
309
- useSyncDOMSelection(editor, isPreservingDOMSElection);
310
- const delaySync = useSyncWithBuilder(editor, text);
311
- const editMode = useBuilderEditMode();
312
- const [propControllers, setPropControllers] = useState(null);
313
- const controller = propControllers == null ? void 0 : propControllers.text;
314
- useEffect(() => {
315
- if (controller == null)
316
- return;
317
- const element = ReactEditor.toDOMNode(editor, editor);
318
- return pollBoxModel({
319
- element,
320
- onBoxModelChange: (boxModel) => controller.changeBoxModel(boxModel)
11
+ const key = v4();
12
+ editor.localChanges.set(key, {
13
+ selection: editor.selection,
14
+ time: performance.now()
321
15
  });
322
- }, [editor, controller]);
323
- useImperativeHandle(ref, () => ({
324
- getDomNode() {
325
- return ReactEditor.toDOMNode(editor, editor);
326
- },
327
- getBoxModel() {
328
- return getBox(ReactEditor.toDOMNode(editor, editor));
329
- },
330
- setPropControllers
331
- }), [editor, setPropControllers]);
332
- const initialValue = useMemo(() => text ? richTextDTOtoDAO(text) : defaultText, [text]);
333
- useEffect(() => {
334
- controller == null ? void 0 : controller.setSlateEditor(editor);
335
- }, [controller, editor]);
336
- const handleFocus = useCallback(() => {
337
- controller == null ? void 0 : controller.focus();
338
- setIsPreservingDOMSelection(true);
339
- }, [controller]);
340
- const handleKeyDown = useCallback((e) => {
341
- if (isHotkey("mod+shift+z", e))
342
- return controller == null ? void 0 : controller.redo();
343
- if (isHotkey("mod+z", e))
344
- return controller == null ? void 0 : controller.undo();
345
- if (isHotkey("escape")(e))
346
- return controller == null ? void 0 : controller.blur();
347
- onKeyDown(e, editor);
348
- }, [controller, editor]);
349
- const handleBlur = useCallback((e) => {
350
- if (e.relatedTarget == null)
351
- return;
352
- setIsPreservingDOMSelection(false);
353
- ReactEditor.deselect(editor);
354
- }, []);
355
- return /* @__PURE__ */ jsx(Slate, {
356
- editor,
357
- value: initialValue,
358
- onChange: delaySync,
359
- children: /* @__PURE__ */ jsx(Editable, {
360
- id,
361
- renderLeaf: Leaf,
362
- renderElement: Element,
363
- onFocus: handleFocus,
364
- onKeyDown: handleKeyDown,
365
- onBlur: handleBlur,
366
- className: cx(width, margin),
367
- readOnly: editMode !== BuilderEditMode.CONTENT,
368
- placeholder: "Write some text..."
369
- })
370
- });
371
- });
372
- var EditableText$1 = EditableText;
373
- export { EditableText, EditableText$1 as default };
16
+ editor.currentKey = key;
17
+ };
18
+ return editor;
19
+ }
20
+ export { withLocalChanges as w };
374
21
  //# sourceMappingURL=index.es7.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.es7.js","sources":["../src/runtimes/react/controls/rich-text/components/Element/block.tsx","../src/runtimes/react/controls/rich-text/components/Element/inline.tsx","../src/runtimes/react/controls/rich-text/components/Element/element.tsx","../src/runtimes/react/controls/rich-text/components/Leaf/leaf.tsx","../src/runtimes/react/controls/rich-text/EditableText/useSyncDOMSelection.tsx","../src/runtimes/react/controls/rich-text/EditableText/useSyncWithBuilder.tsx","../src/runtimes/react/controls/rich-text/EditableText/editable-text.tsx"],"sourcesContent":["import { cx } from '@emotion/css'\nimport { RenderElementProps } from 'slate-react'\nimport { useResponsiveStyle } from '../../../../../../components/utils/responsive-style'\nimport { Block, BlockType } from '../../../../../../slate'\nimport { useStyle } from '../../../../use-style'\n\nexport interface InlineRenderElementProps extends RenderElementProps {\n element: Block\n}\n\nexport function BlockElement({ element, attributes, children }: InlineRenderElementProps) {\n const blockStyles = [\n useStyle({ margin: 0 }),\n useStyle(useResponsiveStyle([element.textAlign], ([textAlign = 'left']) => ({ textAlign }))),\n ]\n\n const quoteStyles = useStyle({\n padding: '0.5em 10px',\n fontSize: '1.25em',\n fontWeight: '300',\n borderLeft: '5px solid rgba(0, 0, 0, 0.1)',\n })\n\n switch (element.type) {\n case BlockType.Default:\n case BlockType.Paragraph:\n return (\n <p {...attributes} className={cx(...blockStyles)}>\n {children}\n </p>\n )\n case BlockType.Heading1:\n return (\n <h1 {...attributes} className={cx(...blockStyles)}>\n {children}\n </h1>\n )\n case BlockType.Heading2:\n return (\n <h2 {...attributes} className={cx(...blockStyles)}>\n {children}\n </h2>\n )\n case BlockType.Heading3:\n return (\n <h3 {...attributes} className={cx(...blockStyles)}>\n {children}\n </h3>\n )\n case BlockType.Heading4:\n return (\n <h4 {...attributes} className={cx(...blockStyles)}>\n {children}\n </h4>\n )\n case BlockType.Heading5:\n return (\n <h5 {...attributes} className={cx(...blockStyles)}>\n {children}\n </h5>\n )\n case BlockType.Heading6:\n return (\n <h6 {...attributes} className={cx(...blockStyles)}>\n {children}\n </h6>\n )\n case BlockType.BlockQuote:\n return (\n <blockquote {...attributes} className={cx(...blockStyles, quoteStyles)}>\n {children}\n </blockquote>\n )\n case BlockType.OrderedList:\n return (\n <ol {...attributes} className={cx(...blockStyles)} style={{ listStylePosition: 'inside' }}>\n {children}\n </ol>\n )\n case BlockType.UnorderedList:\n return (\n <ul {...attributes} className={cx(...blockStyles)} style={{ listStylePosition: 'inside' }}>\n {children}\n </ul>\n )\n case BlockType.ListItem:\n return (\n <li {...attributes} className={cx(...blockStyles)}>\n {children}\n </li>\n )\n case BlockType.ListItemChild:\n return (\n <span {...attributes} className={cx(...blockStyles)}>\n {children}\n </span>\n )\n }\n}\n","import { cx } from '@emotion/css'\nimport { ComponentPropsWithoutRef } from 'react'\nimport { RenderElementProps } from 'slate-react'\nimport { Inline, InlineType } from '../../../../../../slate/types'\nimport { useStyle } from '../../../../use-style'\nimport { Link } from '../../../../../../components/shared/Link'\n\nfunction StyledLink({ className, ...restOfProps }: ComponentPropsWithoutRef<typeof Link>) {\n return <Link {...restOfProps} className={cx(useStyle({ textDecoration: 'none' }), className)} />\n}\n\nexport interface InlineRenderElementProps extends RenderElementProps {\n element: Inline\n}\n\nexport function InlineElement({ element, attributes, children }: InlineRenderElementProps) {\n switch (element.type) {\n case InlineType.Code:\n return <code {...attributes}>{children}</code>\n case InlineType.SuperScript:\n return <sup {...attributes}>{children}</sup>\n case InlineType.SubScript:\n return <sub {...attributes}>{children}</sub>\n case InlineType.Link:\n return (\n <StyledLink {...attributes} link={element.link ?? undefined}>\n {children}\n </StyledLink>\n )\n }\n}\n","import { RenderElementProps } from 'slate-react'\nimport { BlockElement } from './block'\nimport { InlineElement } from './inline'\nimport { BlockType, InlineType } from '../../../../../../slate/types'\n\nexport function Element({ element, ...props }: RenderElementProps) {\n switch (element.type) {\n case InlineType.Code:\n case InlineType.SuperScript:\n case InlineType.SubScript:\n case InlineType.Link:\n return <InlineElement element={element} {...props} />\n case BlockType.Default:\n case BlockType.Paragraph:\n case BlockType.Heading1:\n case BlockType.Heading2:\n case BlockType.Heading3:\n case BlockType.Heading4:\n case BlockType.Heading5:\n case BlockType.Heading6:\n case BlockType.BlockQuote:\n case BlockType.OrderedList:\n case BlockType.UnorderedList:\n case BlockType.ListItem:\n case BlockType.ListItemChild:\n return <BlockElement element={element} {...props} />\n default:\n return <span {...props.attributes}>{props.children}</span>\n }\n}\n","import { RenderLeafProps } from 'slate-react'\nimport useEnhancedTypography, { useTypographyClassName } from '../../../typography'\n\nexport function Leaf({ leaf, ...props }: RenderLeafProps) {\n // for each breakpoint fetch related resources and merge its value with its override\n const enhancedTypography = useEnhancedTypography(leaf.typography)\n\n // for each breakpoint shallow merge back up through the breakpoints and create a className\n const typographyClassName = useTypographyClassName(enhancedTypography)\n\n return (\n <span {...props.attributes} className={typographyClassName}>\n {props.children}\n </span>\n )\n}\n","import { ReactEditor } from 'slate-react'\nimport { Editor, Range as SlateRange } from 'slate'\nimport { useIsomorphicLayoutEffect } from '../../../../../components/hooks/useIsomorphicLayoutEffect'\n\n/**\n * Clicking outside of the host blurs our `<Editable />`.\n * `<Editable />` only updates the DOM's selection to match slate when it is focused.\n * In the case of a panel being clicked this hook updates the DOM selection to match slate.\n */\nexport function useSyncDOMSelection(editor: Editor, isEnabled: boolean) {\n useIsomorphicLayoutEffect(() => {\n if (!isEnabled || editor.selection == null || ReactEditor.isFocused(editor)) return\n try {\n const root = ReactEditor.findDocumentOrShadowRoot(editor) as Document\n const domSelection = root.getSelection()\n const newDomRange: Range | null = ReactEditor.toDOMRange(editor, editor.selection)\n\n if (newDomRange) {\n if (SlateRange.isBackward(editor.selection!)) {\n domSelection?.setBaseAndExtent(\n newDomRange.endContainer,\n newDomRange.endOffset,\n newDomRange.startContainer,\n newDomRange.startOffset,\n )\n } else {\n domSelection?.setBaseAndExtent(\n newDomRange.startContainer,\n newDomRange.startOffset,\n newDomRange.endContainer,\n newDomRange.endOffset,\n )\n }\n } else {\n domSelection?.removeAllRanges()\n }\n } catch (e) {\n console.error(e)\n }\n })\n}\n","import { useState, useEffect, useCallback } from 'react'\nimport { Editor } from 'slate'\nimport { useIsInBuilder } from '../../../../../react'\nimport { richTextDTOtoDAO, richTextDTOtoSelection } from '../../../../../controls'\nimport { RichTextValue } from '../../../../../prop-controllers'\nimport deepEqual from '../../../../../utils/deepEqual'\n\nconst COMMIT_DEBOUNCE_DELAY = 500\n\n/**\n * Compare new prop value with current editor and update editor\n * if the values are not equal.\n */\nexport function useSyncWithBuilder(editor: Editor, text?: RichTextValue) {\n const [shouldCommit, setShouldCommit] = useState(true)\n const isInBuilder = useIsInBuilder()\n\n useEffect(() => {\n if (shouldCommit && text && isInBuilder) {\n const nextValue = richTextDTOtoDAO(text)\n const nextSelection = richTextDTOtoSelection(text)\n if (!deepEqual(editor.children, nextValue) || !deepEqual(editor.selection, nextSelection)) {\n editor.children = nextValue\n editor.selection = nextSelection\n editor.onChange()\n }\n }\n }, [editor, shouldCommit, text])\n\n useEffect(() => {\n if (shouldCommit) return\n\n const timeoutId = window.setTimeout(() => {\n setShouldCommit(true)\n }, COMMIT_DEBOUNCE_DELAY)\n\n return () => {\n window.clearTimeout(timeoutId)\n }\n }, [shouldCommit])\n\n return useCallback(() => setShouldCommit(false), [])\n}\n","import { cx } from '@emotion/css'\nimport { getBox } from 'css-box-model'\nimport isHotkey from 'is-hotkey'\nimport {\n FocusEvent,\n forwardRef,\n KeyboardEvent,\n Ref,\n useCallback,\n useEffect,\n useImperativeHandle,\n useMemo,\n useState,\n} from 'react'\n\nimport { createEditor } from 'slate'\nimport { Slate, Editable, withReact, ReactEditor } from 'slate-react'\nimport { useBuilderEditMode } from '../../..'\nimport { richTextDTOtoDAO } from '../../../../../controls'\nimport { RichTextValue } from '../../../../../prop-controllers'\nimport { ElementIDValue } from '../../../../../prop-controllers/descriptors'\nimport { DescriptorsPropControllers } from '../../../../../prop-controllers/instances'\nimport {\n RichTextDAO,\n BlockType,\n withBlock,\n withTypography,\n withBuilder,\n onKeyDown,\n} from '../../../../../slate'\nimport { BuilderEditMode } from '../../../../../state/modules/builder-edit-mode'\nimport { PropControllersHandle } from '../../../../../state/modules/prop-controller-handles'\nimport { pollBoxModel } from '../../../poll-box-model'\nimport { Element, Leaf } from '../components'\nimport { Descriptors } from '../rich-text'\nimport { useSyncDOMSelection } from './useSyncDOMSelection'\nimport { useSyncWithBuilder } from './useSyncWithBuilder'\n\ntype Props = {\n id?: ElementIDValue\n text?: RichTextValue\n width?: string\n margin?: string\n}\n\nconst defaultText: RichTextDAO = [{ type: BlockType.Paragraph, children: [{ text: '' }] }]\n\nexport const EditableText = forwardRef(function EditableText(\n { id, text, width, margin }: Props,\n ref: Ref<PropControllersHandle<Descriptors>>,\n) {\n const [editor] = useState(() => withBlock(withTypography(withBuilder(withReact(createEditor())))))\n const [isPreservingDOMSElection, setIsPreservingDOMSelection] = useState(false)\n useSyncDOMSelection(editor, isPreservingDOMSElection)\n const delaySync = useSyncWithBuilder(editor, text)\n const editMode = useBuilderEditMode()\n\n const [propControllers, setPropControllers] =\n useState<DescriptorsPropControllers<Descriptors> | null>(null)\n const controller = propControllers?.text\n\n useEffect(() => {\n if (controller == null) return\n\n const element = ReactEditor.toDOMNode(editor, editor)\n\n return pollBoxModel({\n element,\n onBoxModelChange: boxModel => controller.changeBoxModel(boxModel),\n })\n }, [editor, controller])\n\n useImperativeHandle(\n ref,\n () => ({\n getDomNode() {\n return ReactEditor.toDOMNode(editor, editor)\n },\n getBoxModel() {\n return getBox(ReactEditor.toDOMNode(editor, editor))\n },\n setPropControllers,\n }),\n [editor, setPropControllers],\n )\n\n const initialValue = useMemo(() => (text ? richTextDTOtoDAO(text) : defaultText), [text])\n\n useEffect(() => {\n controller?.setSlateEditor(editor)\n }, [controller, editor])\n\n const handleFocus = useCallback(() => {\n controller?.focus()\n setIsPreservingDOMSelection(true)\n }, [controller])\n\n const handleKeyDown = useCallback(\n (e: KeyboardEvent) => {\n if (isHotkey('mod+shift+z', e)) return controller?.redo()\n if (isHotkey('mod+z', e)) return controller?.undo()\n if (isHotkey('escape')(e)) return controller?.blur()\n onKeyDown(e, editor)\n },\n [controller, editor],\n )\n\n const handleBlur = useCallback((e: FocusEvent) => {\n // When clicking outside of the iframe (`relatedTarget` is null) we want to preserve the DOM selection.\n if (e.relatedTarget == null) return\n // Otherwise we want to deselect on blur and stop preserving selection.\n setIsPreservingDOMSelection(false)\n ReactEditor.deselect(editor)\n }, [])\n\n return (\n <Slate editor={editor} value={initialValue} onChange={delaySync}>\n <Editable\n id={id}\n renderLeaf={Leaf}\n renderElement={Element}\n onFocus={handleFocus}\n onKeyDown={handleKeyDown}\n onBlur={handleBlur}\n className={cx(width, margin)}\n readOnly={editMode !== BuilderEditMode.CONTENT}\n placeholder=\"Write some text...\"\n />\n </Slate>\n )\n})\n\nexport default EditableText\n"],"names":["element","attributes","children","blockStyles","useStyle","margin","useResponsiveStyle","textAlign","quoteStyles","padding","fontSize","fontWeight","borderLeft","type","BlockType","Default","Paragraph","cx","Heading1","Heading2","Heading3","Heading4","Heading5","Heading6","BlockQuote","OrderedList","listStylePosition","UnorderedList","ListItem","ListItemChild","className","restOfProps","textDecoration","InlineType","Code","SuperScript","SubScript","Link","link","undefined","props","leaf","enhancedTypography","useEnhancedTypography","typography","typographyClassName","useTypographyClassName","editor","isEnabled","useIsomorphicLayoutEffect","selection","ReactEditor","isFocused","root","findDocumentOrShadowRoot","domSelection","getSelection","newDomRange","toDOMRange","SlateRange","isBackward","setBaseAndExtent","endContainer","endOffset","startContainer","startOffset","removeAllRanges","e","console","error","COMMIT_DEBOUNCE_DELAY","text","shouldCommit","setShouldCommit","useState","isInBuilder","useIsInBuilder","useEffect","nextValue","richTextDTOtoDAO","nextSelection","richTextDTOtoSelection","deepEqual","onChange","timeoutId","window","setTimeout","clearTimeout","useCallback","defaultText","EditableText","forwardRef","id","width","ref","withBlock","withTypography","withBuilder","withReact","createEditor","isPreservingDOMSElection","setIsPreservingDOMSelection","useSyncDOMSelection","delaySync","useSyncWithBuilder","editMode","useBuilderEditMode","propControllers","setPropControllers","controller","toDOMNode","pollBoxModel","onBoxModelChange","boxModel","changeBoxModel","useImperativeHandle","getDomNode","getBoxModel","getBox","initialValue","useMemo","setSlateEditor","handleFocus","focus","handleKeyDown","isHotkey","redo","undo","blur","onKeyDown","handleBlur","relatedTarget","deselect","Leaf","Element","BuilderEditMode","CONTENT"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAU6B,sBAAA;AAAA,EAAEA;AAAAA,EAASC;AAAAA,EAAYC;AAAAA,GAAsC;AAClFC,QAAAA,cAAc,CAClBC,SAAS;AAAA,IAAEC,QAAQ;AAAA,EAAA,CAAX,GACRD,SAASE,mBAAmB,CAACN,QAAQO,SAAT,GAAqB,CAAC,CAACA,YAAY,YAAa;AAAA,IAAEA;AAAAA,EAAAA,EAAnD,CAAnB,CAFU;AAKdC,QAAAA,cAAcJ,SAAS;AAAA,IAC3BK,SAAS;AAAA,IACTC,UAAU;AAAA,IACVC,YAAY;AAAA,IACZC,YAAY;AAAA,EAAA,CAJc;AAOpBZ,UAAAA,QAAQa;AAAAA,SACTC,UAAUC;AAAAA,SACVD,UAAUE;AACb,uEACSf;QAAY,WAAWgB,GAAG,GAAGd,WAAJ;AAAA,QAC7BD;AAAAA,MAAAA,EAFL;AAAA,SAKGY,UAAUI;AACb,wEACUjB;QAAY,WAAWgB,GAAG,GAAGd,WAAJ;AAAA,QAC9BD;AAAAA,MAAAA,EAFL;AAAA,SAKGY,UAAUK;AACb,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,EAL4B,GAM3B,CAN2B,CAAA;AAQ9B,6BACG,OAAD;AAAA,IAAO;AAAA,IAAgB,OAAOwE;AAAAA,IAAc,UAAUhB;AAAAA,IAAtD,8BACG,UAAD;AAAA,MACE;AAAA,MACA,YAAY8B;AAAAA,MACZ,eAAeC;AAAAA,MACf,SAASZ;AAAAA,MACT,WAAWE;AAAAA,MACX,QAAQM;AAAAA,MACR,WAAWjH,GAAG4E,OAAOxF,MAAR;AAAA,MACb,UAAUoG,aAAa8B,gBAAgBC;AAAAA,MACvC,aAAY;AAAA,IAAA,CATd;AAAA,EAAA,CAFJ;AAeD,CAnFqC;AAqFtC,IAAA,iBAAe9C;;"}
1
+ {"version":3,"file":"index.es7.js","sources":["../src/slate/LocalChangesPlugin/index.tsx"],"sourcesContent":["import { BaseEditor, Editor, Selection } from 'slate'\nimport { v4 as uuid } from 'uuid'\n\nexport type LocalChange = { selection: Selection; time: number }\n\nexport interface LocalChangesEditor extends BaseEditor {\n localChanges: Map<string, LocalChange>\n recentKeys: Map<string, number>\n recentLocalChanges: { time: number; key: string }[]\n currentKey: string\n}\n\nexport function withLocalChanges(editor: Editor): Editor {\n editor.localChanges = new Map<string, LocalChange>()\n editor.recentLocalChanges = []\n editor.currentKey = ''\n\n const _onChange = editor.onChange\n editor.onChange = options => {\n _onChange(options)\n if (editor == null || options?.operation == null) return\n\n const key = uuid()\n editor.localChanges.set(key, { selection: editor.selection, time: performance.now() })\n editor.currentKey = key\n }\n\n return editor\n}\n"],"names":["editor","localChanges","Map","recentLocalChanges","currentKey","_onChange","onChange","options","operation","key","uuid","set","selection","time","performance","now"],"mappings":";AAYO,0BAA0BA,QAAwB;AAChDC,SAAAA,mCAAmBC;AAC1BF,SAAOG,qBAAqB;AAC5BH,SAAOI,aAAa;AAEpB,QAAMC,YAAYL,OAAOM;AACzBN,SAAOM,WAAWC,CAAW,YAAA;AAC3BF,cAAUE,OAAD;AACLP,QAAAA,UAAU,QAAQO,oCAASC,cAAa;AAAM;AAE5CC,UAAAA,MAAMC;AACLT,WAAAA,aAAaU,IAAIF,KAAK;AAAA,MAAEG,WAAWZ,OAAOY;AAAAA,MAAWC,MAAMC,YAAYC,IAAZ;AAAA,IAAA,CAAlE;AACAf,WAAOI,aAAaK;AAAAA,EAAAA;AAGfT,SAAAA;AACR;;"}