@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.
- package/dist/Box.cjs.js +1 -3
- package/dist/Box.cjs.js.map +1 -1
- package/dist/Box.es.js +2 -4
- package/dist/Box.es.js.map +1 -1
- package/dist/Button.cjs.js +4 -4
- package/dist/Button.es.js +5 -5
- package/dist/Carousel.cjs.js +3 -3
- package/dist/Carousel.es.js +4 -4
- package/dist/Countdown.cjs.js +1 -3
- package/dist/Countdown.cjs.js.map +1 -1
- package/dist/Countdown.es.js +2 -4
- package/dist/Countdown.es.js.map +1 -1
- package/dist/Divider.cjs.js +1 -3
- package/dist/Divider.cjs.js.map +1 -1
- package/dist/Divider.es.js +2 -4
- package/dist/Divider.es.js.map +1 -1
- package/dist/Embed.cjs.js +1 -0
- package/dist/Embed.cjs.js.map +1 -1
- package/dist/Embed.es.js +2 -1
- package/dist/Embed.es.js.map +1 -1
- package/dist/Form.cjs.js +13 -13
- package/dist/Form.cjs.js.map +1 -1
- package/dist/Form.es.js +5 -5
- package/dist/Image.cjs.js +13 -13
- package/dist/Image.cjs.js.map +1 -1
- package/dist/Image.es.js +13 -13
- package/dist/LiveProvider.cjs.js +1 -3
- package/dist/LiveProvider.cjs.js.map +1 -1
- package/dist/LiveProvider.es.js +3 -5
- package/dist/LiveProvider.es.js.map +1 -1
- package/dist/Navigation.cjs.js +12 -12
- package/dist/Navigation.cjs.js.map +1 -1
- package/dist/Navigation.es.js +12 -12
- package/dist/PreviewProvider.cjs.js +1 -3
- package/dist/PreviewProvider.cjs.js.map +1 -1
- package/dist/PreviewProvider.es.js +3 -5
- package/dist/PreviewProvider.es.js.map +1 -1
- package/dist/ReadOnlyText.cjs.js +7 -6
- package/dist/ReadOnlyText.cjs.js.map +1 -1
- package/dist/ReadOnlyText.es.js +4 -3
- package/dist/ReadOnlyText.es.js.map +1 -1
- package/dist/ReadOnlyTextV2.cjs.js +7 -60
- package/dist/ReadOnlyTextV2.cjs.js.map +1 -1
- package/dist/ReadOnlyTextV2.es.js +9 -62
- package/dist/ReadOnlyTextV2.es.js.map +1 -1
- package/dist/Root.cjs.js +1 -3
- package/dist/Root.cjs.js.map +1 -1
- package/dist/Root.es.js +2 -4
- package/dist/Root.es.js.map +1 -1
- package/dist/SocialLinks.cjs.js +6 -6
- package/dist/SocialLinks.cjs.js.map +1 -1
- package/dist/SocialLinks.es.js +7 -7
- package/dist/Video.cjs.js +1 -0
- package/dist/Video.cjs.js.map +1 -1
- package/dist/Video.es.js +2 -1
- package/dist/Video.es.js.map +1 -1
- package/dist/builder.cjs.js +1 -0
- package/dist/builder.cjs.js.map +1 -1
- package/dist/builder.es.js +1 -0
- package/dist/builder.es.js.map +1 -1
- package/dist/components.cjs.js +3 -3
- package/dist/components.es.js +3 -3
- package/dist/control-serialization.es.js +1 -1
- package/dist/controls.cjs.js +1 -0
- package/dist/controls.cjs.js.map +1 -1
- package/dist/controls.es.js +2 -1
- package/dist/controls.es.js.map +1 -1
- package/dist/index.cjs.js +120 -256
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.cjs3.js +107 -21
- package/dist/index.cjs3.js.map +1 -1
- package/dist/index.cjs4.js +57 -16
- package/dist/index.cjs4.js.map +1 -1
- package/dist/index.cjs5.js +42 -81
- package/dist/index.cjs5.js.map +1 -1
- package/dist/index.cjs6.js +82 -17
- package/dist/index.cjs6.js.map +1 -1
- package/dist/index.cjs7.js +18 -377
- package/dist/index.cjs7.js.map +1 -1
- package/dist/index.cjs8.js +258 -181
- package/dist/index.cjs8.js.map +1 -1
- package/dist/index.cjs9.js +343 -0
- package/dist/index.cjs9.js.map +1 -0
- package/dist/index.es.js +125 -260
- package/dist/index.es.js.map +1 -1
- package/dist/index.es2.js +1 -1
- package/dist/index.es3.js +103 -22
- package/dist/index.es3.js.map +1 -1
- package/dist/index.es4.js +57 -16
- package/dist/index.es4.js.map +1 -1
- package/dist/index.es5.js +42 -80
- package/dist/index.es5.js.map +1 -1
- package/dist/index.es6.js +81 -17
- package/dist/index.es6.js.map +1 -1
- package/dist/index.es7.js +18 -371
- package/dist/index.es7.js.map +1 -1
- package/dist/index.es8.js +259 -182
- package/dist/index.es8.js.map +1 -1
- package/dist/index.es9.js +336 -0
- package/dist/index.es9.js.map +1 -0
- package/dist/main.cjs.js +1 -0
- package/dist/main.cjs.js.map +1 -1
- package/dist/main.es.js +1 -0
- package/dist/main.es.js.map +1 -1
- package/dist/next.cjs.js +1 -3
- package/dist/next.cjs.js.map +1 -1
- package/dist/next.es.js +2 -4
- package/dist/next.es.js.map +1 -1
- package/dist/prop-controllers.cjs.js +1 -0
- package/dist/prop-controllers.cjs.js.map +1 -1
- package/dist/prop-controllers.es.js +1 -0
- package/dist/prop-controllers.es.js.map +1 -1
- package/dist/react-page.cjs.js +26 -6
- package/dist/react-page.cjs.js.map +1 -1
- package/dist/react-page.es.js +26 -7
- package/dist/react-page.es.js.map +1 -1
- package/dist/react.cjs.js +1 -3
- package/dist/react.cjs.js.map +1 -1
- package/dist/react.es.js +1 -3
- package/dist/react.es.js.map +1 -1
- package/dist/slate.cjs.js +9 -6
- package/dist/slate.cjs.js.map +1 -1
- package/dist/slate.es.js +9 -7
- package/dist/slate.es.js.map +1 -1
- package/dist/toText.cjs.js +67 -0
- package/dist/toText.cjs.js.map +1 -0
- package/dist/toText.es.js +66 -0
- package/dist/toText.es.js.map +1 -0
- package/dist/types/src/components/builtin/Text/register.d.ts.map +1 -1
- package/dist/types/src/controls/rich-text-v2/rich-text-v2.d.ts +2 -4
- package/dist/types/src/controls/rich-text-v2/rich-text-v2.d.ts.map +1 -1
- package/dist/types/src/runtimes/react/controls/rich-text-v2/EditableTextV2/editable-text-v2.d.ts.map +1 -1
- package/dist/types/src/runtimes/react/controls/rich-text-v2/EditableTextV2/render-element.d.ts.map +1 -1
- package/dist/types/src/runtimes/react/controls/rich-text-v2/EditableTextV2/usePresetValue.d.ts +10 -0
- package/dist/types/src/runtimes/react/controls/rich-text-v2/EditableTextV2/usePresetValue.d.ts.map +1 -0
- package/dist/types/src/runtimes/react/controls/rich-text-v2/ReadOnlyTextV2.d.ts.map +1 -1
- package/dist/types/src/slate/BuilderPlugin/index.d.ts +2 -1
- package/dist/types/src/slate/BuilderPlugin/index.d.ts.map +1 -1
- package/dist/types/src/slate/InlineModePlugin/index.d.ts.map +1 -1
- package/dist/types/src/slate/index.d.ts +1 -0
- package/dist/types/src/slate/index.d.ts.map +1 -1
- package/dist/types/src/slate/utils/index.d.ts +2 -0
- package/dist/types/src/slate/utils/index.d.ts.map +1 -0
- package/dist/types/src/slate/utils/toText.d.ts +4 -0
- package/dist/types/src/slate/utils/toText.d.ts.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,336 @@
|
|
|
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 { useEffect, useMemo, useState, useRef, useCallback } from "react";
|
|
33
|
+
import { Range, createEditor } from "slate";
|
|
34
|
+
import isHotkey from "is-hotkey";
|
|
35
|
+
import { ReactEditor, withReact, Slate, Editable } from "slate-react";
|
|
36
|
+
import { bt as richTextV2DataToDescendents, bN as BlockType, bq as RichTextV2Mode, bJ as InlineModePlugin, bH as BlockPlugin, bC as TypographyPlugin, bL as TextAlignPlugin, bR as InlinePlugin, b$ as BuilderEditMode } from "./react-page.es.js";
|
|
37
|
+
import { T as ControlValue, u as useIsInBuilder, r as useBreakpoints, Q as pollBoxModel, O as useBuilderEditMode } from "./index.es.js";
|
|
38
|
+
import { w as withBuilder } from "./index.es5.js";
|
|
39
|
+
import { L as LinkPlugin } from "./index.es6.js";
|
|
40
|
+
import { w as withLocalChanges } from "./index.es7.js";
|
|
41
|
+
import { u as useIsomorphicLayoutEffect } from "./useIsomorphicLayoutEffect.es.js";
|
|
42
|
+
import { jsx } from "react/jsx-runtime";
|
|
43
|
+
import "./actions.es.js";
|
|
44
|
+
import { getBaseBreakpoint, DefaultBreakpointID } from "./state/breakpoints.es.js";
|
|
45
|
+
import "uuid";
|
|
46
|
+
import "./index.es3.js";
|
|
47
|
+
import "@emotion/css";
|
|
48
|
+
import "redux";
|
|
49
|
+
import "redux-thunk";
|
|
50
|
+
import "corporate-ipsum";
|
|
51
|
+
import "@emotion/serialize";
|
|
52
|
+
import "@emotion/utils";
|
|
53
|
+
import "use-sync-external-store/shim/with-selector";
|
|
54
|
+
import "next/dynamic";
|
|
55
|
+
import "./text-input.es.js";
|
|
56
|
+
import "./combobox.es.js";
|
|
57
|
+
import "use-sync-external-store/shim";
|
|
58
|
+
import "./types.es.js";
|
|
59
|
+
import "./box-models.es.js";
|
|
60
|
+
import "css-box-model";
|
|
61
|
+
import "color";
|
|
62
|
+
import "scroll-into-view-if-needed";
|
|
63
|
+
import "react-dom";
|
|
64
|
+
import "html-react-parser";
|
|
65
|
+
import "next/head";
|
|
66
|
+
import "zod";
|
|
67
|
+
import "@emotion/server/create-instance";
|
|
68
|
+
import "next/document";
|
|
69
|
+
import "cors";
|
|
70
|
+
import "path-to-regexp";
|
|
71
|
+
import "cookie";
|
|
72
|
+
import "http-proxy";
|
|
73
|
+
import "set-cookie-parser";
|
|
74
|
+
import "./constants.es.js";
|
|
75
|
+
import "next/link";
|
|
76
|
+
function useSyncDOMSelection(editor, isEnabled) {
|
|
77
|
+
useIsomorphicLayoutEffect(() => {
|
|
78
|
+
if (!isEnabled.current || editor.selection == null || ReactEditor.isFocused(editor))
|
|
79
|
+
return;
|
|
80
|
+
try {
|
|
81
|
+
const root = ReactEditor.findDocumentOrShadowRoot(editor);
|
|
82
|
+
const domSelection = root.getSelection();
|
|
83
|
+
const newDomRange = ReactEditor.toDOMRange(editor, editor.selection);
|
|
84
|
+
if (newDomRange) {
|
|
85
|
+
if (Range.isBackward(editor.selection)) {
|
|
86
|
+
domSelection == null ? void 0 : domSelection.setBaseAndExtent(newDomRange.endContainer, newDomRange.endOffset, newDomRange.startContainer, newDomRange.startOffset);
|
|
87
|
+
} else {
|
|
88
|
+
domSelection == null ? void 0 : domSelection.setBaseAndExtent(newDomRange.startContainer, newDomRange.startOffset, newDomRange.endContainer, newDomRange.endOffset);
|
|
89
|
+
}
|
|
90
|
+
} else {
|
|
91
|
+
domSelection == null ? void 0 : domSelection.removeAllRanges();
|
|
92
|
+
}
|
|
93
|
+
} catch (e) {
|
|
94
|
+
console.error(e);
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
function RichTextV2Element(_a) {
|
|
99
|
+
var _b = _a, {
|
|
100
|
+
definition,
|
|
101
|
+
plugins
|
|
102
|
+
} = _b, props = __objRest(_b, [
|
|
103
|
+
"definition",
|
|
104
|
+
"plugins"
|
|
105
|
+
]);
|
|
106
|
+
function initialRenderElement(props2) {
|
|
107
|
+
return props2.children;
|
|
108
|
+
}
|
|
109
|
+
const renderElement = plugins.reduce((renderFn, plugin) => (props2) => {
|
|
110
|
+
const {
|
|
111
|
+
control,
|
|
112
|
+
renderElement: renderElement2
|
|
113
|
+
} = plugin;
|
|
114
|
+
if (renderElement2 == null)
|
|
115
|
+
return renderFn(props2);
|
|
116
|
+
if (control == null || control.getElementValue == null)
|
|
117
|
+
return renderElement2(renderFn, void 0)(props2);
|
|
118
|
+
return /* @__PURE__ */ jsx(ControlValue, {
|
|
119
|
+
definition: control.definition,
|
|
120
|
+
data: control.getElementValue(props2.element),
|
|
121
|
+
children: (value) => renderElement2(renderFn, value)(props2)
|
|
122
|
+
});
|
|
123
|
+
}, initialRenderElement);
|
|
124
|
+
return renderElement(props);
|
|
125
|
+
}
|
|
126
|
+
function RichTextV2Leaf(_c) {
|
|
127
|
+
var _d = _c, {
|
|
128
|
+
definition,
|
|
129
|
+
plugins
|
|
130
|
+
} = _d, props = __objRest(_d, [
|
|
131
|
+
"definition",
|
|
132
|
+
"plugins"
|
|
133
|
+
]);
|
|
134
|
+
function initialRenderLeaf({
|
|
135
|
+
attributes,
|
|
136
|
+
children,
|
|
137
|
+
leaf
|
|
138
|
+
}) {
|
|
139
|
+
return /* @__PURE__ */ jsx("span", __spreadProps(__spreadValues({
|
|
140
|
+
className: leaf.className
|
|
141
|
+
}, attributes), {
|
|
142
|
+
children
|
|
143
|
+
}));
|
|
144
|
+
}
|
|
145
|
+
const renderLeaf = plugins.reduce((renderFn, plugin) => (props2) => {
|
|
146
|
+
const {
|
|
147
|
+
control,
|
|
148
|
+
renderLeaf: renderLeaf2
|
|
149
|
+
} = plugin;
|
|
150
|
+
if ((control == null ? void 0 : control.definition) == null || renderLeaf2 == null)
|
|
151
|
+
return renderFn(props2);
|
|
152
|
+
if (control.getLeafValue == null)
|
|
153
|
+
return renderLeaf2(renderFn, void 0)(props2);
|
|
154
|
+
return /* @__PURE__ */ jsx(ControlValue, {
|
|
155
|
+
definition: control.definition,
|
|
156
|
+
data: control.getLeafValue(props2.leaf),
|
|
157
|
+
children: (value) => renderLeaf2(renderFn, value)(props2)
|
|
158
|
+
});
|
|
159
|
+
}, initialRenderLeaf);
|
|
160
|
+
return renderLeaf(props);
|
|
161
|
+
}
|
|
162
|
+
function isChangeWithinPreviousSec(change) {
|
|
163
|
+
var _a;
|
|
164
|
+
return performance.now() - ((_a = change == null ? void 0 : change.time) != null ? _a : 0) < 1e3;
|
|
165
|
+
}
|
|
166
|
+
function useSyncRemoteChanges(editor, data) {
|
|
167
|
+
const isInBuilder = useIsInBuilder();
|
|
168
|
+
useEffect(() => {
|
|
169
|
+
var _a, _b, _c;
|
|
170
|
+
if (!isChangeWithinPreviousSec(editor.localChanges.get((_a = data == null ? void 0 : data.key) != null ? _a : "")) && data && isInBuilder) {
|
|
171
|
+
editor.children = richTextV2DataToDescendents(data);
|
|
172
|
+
editor.selection = (_c = (_b = editor == null ? void 0 : editor.localChanges.get(data.key)) == null ? void 0 : _b.selection) != null ? _c : null;
|
|
173
|
+
editor.onChange();
|
|
174
|
+
}
|
|
175
|
+
}, [editor, data]);
|
|
176
|
+
}
|
|
177
|
+
function usePresetValue(definition) {
|
|
178
|
+
const breakpoints = useBreakpoints();
|
|
179
|
+
return useMemo(() => {
|
|
180
|
+
var _a;
|
|
181
|
+
return [{
|
|
182
|
+
type: BlockType.Default,
|
|
183
|
+
children: [__spreadValues({
|
|
184
|
+
text: (_a = definition.config.defaultValue) != null ? _a : ""
|
|
185
|
+
}, definition.config.mode === RichTextV2Mode.Inline ? {} : {
|
|
186
|
+
typography: {
|
|
187
|
+
style: [{
|
|
188
|
+
deviceId: getBaseBreakpoint(breakpoints).id,
|
|
189
|
+
value: {
|
|
190
|
+
fontWeight: 400,
|
|
191
|
+
fontSize: {
|
|
192
|
+
value: 18,
|
|
193
|
+
unit: "px"
|
|
194
|
+
},
|
|
195
|
+
lineHeight: 1.5
|
|
196
|
+
}
|
|
197
|
+
}, ...breakpoints.some(({
|
|
198
|
+
id
|
|
199
|
+
}) => id === DefaultBreakpointID.Mobile) ? [{
|
|
200
|
+
deviceId: DefaultBreakpointID.Mobile,
|
|
201
|
+
value: {
|
|
202
|
+
fontSize: {
|
|
203
|
+
value: 16,
|
|
204
|
+
unit: "px"
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
}] : []]
|
|
208
|
+
}
|
|
209
|
+
})]
|
|
210
|
+
}];
|
|
211
|
+
}, [definition.config.mode, definition.config.defaultValue, breakpoints]);
|
|
212
|
+
}
|
|
213
|
+
const defaultValue = [{
|
|
214
|
+
type: BlockType.Default,
|
|
215
|
+
children: [{
|
|
216
|
+
text: ""
|
|
217
|
+
}]
|
|
218
|
+
}];
|
|
219
|
+
function EditableTextV2({
|
|
220
|
+
text,
|
|
221
|
+
definition,
|
|
222
|
+
control
|
|
223
|
+
}) {
|
|
224
|
+
const plugins = useMemo(() => {
|
|
225
|
+
var _a;
|
|
226
|
+
const plugins2 = [
|
|
227
|
+
...((_a = definition == null ? void 0 : definition.config) == null ? void 0 : _a.mode) === RichTextV2Mode.Inline ? [InlineModePlugin()] : [BlockPlugin(), TypographyPlugin(), TextAlignPlugin(), InlinePlugin(), LinkPlugin()]
|
|
228
|
+
];
|
|
229
|
+
return plugins2;
|
|
230
|
+
}, [definition]);
|
|
231
|
+
const [editor] = useState(() => plugins.reduceRight((editor2, plugin) => {
|
|
232
|
+
var _a, _b;
|
|
233
|
+
return (_b = (_a = plugin == null ? void 0 : plugin.withPlugin) == null ? void 0 : _a.call(plugin, editor2)) != null ? _b : editor2;
|
|
234
|
+
}, withLocalChanges(withBuilder(withReact(createEditor())))));
|
|
235
|
+
useEffect(() => {
|
|
236
|
+
if (control == null)
|
|
237
|
+
return;
|
|
238
|
+
const element = ReactEditor.toDOMNode(editor, editor);
|
|
239
|
+
return pollBoxModel({
|
|
240
|
+
element,
|
|
241
|
+
onBoxModelChange: (boxModel) => control.changeBoxModel(boxModel)
|
|
242
|
+
});
|
|
243
|
+
}, [editor, control]);
|
|
244
|
+
const isPreservingFocus = useRef(false);
|
|
245
|
+
useSyncDOMSelection(editor, isPreservingFocus);
|
|
246
|
+
const editMode = useBuilderEditMode();
|
|
247
|
+
useEffect(() => {
|
|
248
|
+
if (editMode !== BuilderEditMode.CONTENT) {
|
|
249
|
+
isPreservingFocus.current = false;
|
|
250
|
+
ReactEditor.deselect(editor);
|
|
251
|
+
}
|
|
252
|
+
}, [editMode]);
|
|
253
|
+
useSyncRemoteChanges(editor, text);
|
|
254
|
+
const presetValue = usePresetValue(definition);
|
|
255
|
+
const initialValue = useMemo(() => {
|
|
256
|
+
var _a;
|
|
257
|
+
return (_a = text && richTextV2DataToDescendents(text)) != null ? _a : presetValue;
|
|
258
|
+
}, [text, presetValue]);
|
|
259
|
+
useEffect(() => {
|
|
260
|
+
control == null ? void 0 : control.setEditor(editor);
|
|
261
|
+
control == null ? void 0 : control.setDefaultValue(defaultValue);
|
|
262
|
+
}, [control, editor]);
|
|
263
|
+
useEffect(() => {
|
|
264
|
+
if (initialValue === presetValue) {
|
|
265
|
+
control == null ? void 0 : control.onLocalUserChange();
|
|
266
|
+
}
|
|
267
|
+
}, [control, initialValue, presetValue]);
|
|
268
|
+
const renderElement = useCallback((props) => {
|
|
269
|
+
return /* @__PURE__ */ jsx(RichTextV2Element, __spreadProps(__spreadValues({}, props), {
|
|
270
|
+
definition,
|
|
271
|
+
plugins
|
|
272
|
+
}));
|
|
273
|
+
}, [plugins, definition]);
|
|
274
|
+
const renderLeaf = useCallback((props) => {
|
|
275
|
+
return /* @__PURE__ */ jsx(RichTextV2Leaf, __spreadProps(__spreadValues({}, props), {
|
|
276
|
+
definition,
|
|
277
|
+
plugins
|
|
278
|
+
}));
|
|
279
|
+
}, [plugins, definition]);
|
|
280
|
+
const handleFocus = useCallback(() => {
|
|
281
|
+
isPreservingFocus.current = true;
|
|
282
|
+
control == null ? void 0 : control.select();
|
|
283
|
+
}, [control]);
|
|
284
|
+
const handleKeyDown = useCallback((e) => {
|
|
285
|
+
if (isHotkey("mod+shift+z", e))
|
|
286
|
+
return control == null ? void 0 : control.redo();
|
|
287
|
+
if (isHotkey("mod+z", e))
|
|
288
|
+
return control == null ? void 0 : control.undo();
|
|
289
|
+
if (isHotkey("escape")(e)) {
|
|
290
|
+
isPreservingFocus.current = false;
|
|
291
|
+
ReactEditor.blur(editor);
|
|
292
|
+
control == null ? void 0 : control.switchToBuildMode();
|
|
293
|
+
}
|
|
294
|
+
if (editMode === BuilderEditMode.CONTENT) {
|
|
295
|
+
e.stopPropagation();
|
|
296
|
+
}
|
|
297
|
+
plugins.forEach((plugin) => {
|
|
298
|
+
var _a;
|
|
299
|
+
return (_a = plugin == null ? void 0 : plugin.onKeyDown) == null ? void 0 : _a.call(plugin, e, editor);
|
|
300
|
+
});
|
|
301
|
+
}, [control, plugins, editor, editMode]);
|
|
302
|
+
const handleKeyUp = useCallback((e) => {
|
|
303
|
+
if (editMode === BuilderEditMode.CONTENT) {
|
|
304
|
+
e.stopPropagation();
|
|
305
|
+
e.preventDefault();
|
|
306
|
+
}
|
|
307
|
+
}, [control, editor, editMode]);
|
|
308
|
+
const handleClick = useCallback((e) => {
|
|
309
|
+
if (editMode === BuilderEditMode.CONTENT)
|
|
310
|
+
e.stopPropagation();
|
|
311
|
+
}, [editMode]);
|
|
312
|
+
const handleBlur = useCallback((e) => {
|
|
313
|
+
var _a;
|
|
314
|
+
if (e.relatedTarget == null)
|
|
315
|
+
return;
|
|
316
|
+
if (((_a = e.relatedTarget) == null ? void 0 : _a.getAttribute("contenteditable")) === "true")
|
|
317
|
+
isPreservingFocus.current = false;
|
|
318
|
+
}, []);
|
|
319
|
+
return /* @__PURE__ */ jsx(Slate, {
|
|
320
|
+
editor,
|
|
321
|
+
value: initialValue,
|
|
322
|
+
children: /* @__PURE__ */ jsx(Editable, {
|
|
323
|
+
renderLeaf,
|
|
324
|
+
renderElement,
|
|
325
|
+
onFocus: handleFocus,
|
|
326
|
+
onKeyDown: handleKeyDown,
|
|
327
|
+
onKeyUp: handleKeyUp,
|
|
328
|
+
onClick: handleClick,
|
|
329
|
+
onBlur: handleBlur,
|
|
330
|
+
readOnly: editMode !== BuilderEditMode.CONTENT,
|
|
331
|
+
placeholder: "Write some text..."
|
|
332
|
+
})
|
|
333
|
+
});
|
|
334
|
+
}
|
|
335
|
+
export { EditableTextV2, EditableTextV2 as default };
|
|
336
|
+
//# sourceMappingURL=index.es9.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.es9.js","sources":["../src/runtimes/react/controls/rich-text-v2/EditableTextV2/useSyncDOMSelection.tsx","../src/runtimes/react/controls/rich-text-v2/EditableTextV2/render-element.tsx","../src/runtimes/react/controls/rich-text-v2/EditableTextV2/render-leaf.tsx","../src/runtimes/react/controls/rich-text-v2/EditableTextV2/useRemoteChanges.tsx","../src/runtimes/react/controls/rich-text-v2/EditableTextV2/usePresetValue.tsx","../src/runtimes/react/controls/rich-text-v2/EditableTextV2/editable-text-v2.tsx"],"sourcesContent":["import { Editor, Range as SlateRange } from 'slate'\nimport { useIsomorphicLayoutEffect } from '../../../../../components/hooks/useIsomorphicLayoutEffect'\nimport { MutableRefObject } from 'react'\nimport { ReactEditor } from 'slate-react'\n\n/**\n * Clicking outside of the host blurs our `<Editable />`.\n * `<Editable />` only updates the DOM's selection to match slate when it is focused.\n * In the case of a panel being clicked this hook updates the DOM selection to match slate.\n */\nexport function useSyncDOMSelection(editor: Editor, isEnabled: MutableRefObject<boolean>) {\n useIsomorphicLayoutEffect(() => {\n if (!isEnabled.current || editor.selection == null || ReactEditor.isFocused(editor)) return\n try {\n const root = ReactEditor.findDocumentOrShadowRoot(editor) as Document\n const domSelection = root.getSelection()\n const newDomRange: Range | null = ReactEditor.toDOMRange(editor, editor.selection)\n\n if (newDomRange) {\n if (SlateRange.isBackward(editor.selection!)) {\n domSelection?.setBaseAndExtent(\n newDomRange.endContainer,\n newDomRange.endOffset,\n newDomRange.startContainer,\n newDomRange.startOffset,\n )\n } else {\n domSelection?.setBaseAndExtent(\n newDomRange.startContainer,\n newDomRange.startOffset,\n newDomRange.endContainer,\n newDomRange.endOffset,\n )\n }\n } else {\n domSelection?.removeAllRanges()\n }\n } catch (e) {\n console.error(e)\n }\n })\n}\n","import { RenderElementProps } from 'slate-react'\nimport { RichTextV2ControlDefinition } from '../../../../../controls'\nimport { ControlValue } from '../../control'\nimport { RichTextV2Plugin } from '../../../../../controls/rich-text-v2/plugin'\n\ntype RichTextV2ElementProps = RenderElementProps & {\n definition: RichTextV2ControlDefinition\n plugins: RichTextV2Plugin[]\n}\n\nexport function RichTextV2Element({ definition, plugins, ...props }: RichTextV2ElementProps) {\n function initialRenderElement(props: RenderElementProps) {\n return props.children\n }\n\n const renderElement = plugins.reduce(\n (renderFn, plugin) => (props: RenderElementProps) => {\n const { control, renderElement } = plugin\n\n if (renderElement == null) return renderFn(props)\n\n if (control == null || control.getElementValue == null)\n return renderElement(renderFn, undefined)(props)\n\n return (\n <ControlValue definition={control.definition} data={control.getElementValue(props.element)}>\n {value => renderElement(renderFn, value)(props)}\n </ControlValue>\n )\n },\n initialRenderElement,\n )\n\n return renderElement(props)\n}\n","import { RenderLeafProps } from 'slate-react'\nimport { RichTextV2ControlDefinition } from '../../../../../controls'\nimport { ControlValue } from '../../control'\nimport { RichTextV2Plugin } from '../../../../../controls/rich-text-v2/plugin'\n\ntype RichTextV2LeafProps = RenderLeafProps & {\n definition: RichTextV2ControlDefinition\n plugins: RichTextV2Plugin[]\n}\n\nexport function RichTextV2Leaf({ definition, plugins, ...props }: RichTextV2LeafProps) {\n function initialRenderLeaf({ attributes, children, leaf }: RenderLeafProps) {\n return (\n <span className={leaf.className} {...attributes}>\n {children}\n </span>\n )\n }\n\n const renderLeaf = plugins.reduce(\n (renderFn, plugin) => (props: RenderLeafProps) => {\n const { control, renderLeaf } = plugin\n\n if (control?.definition == null || renderLeaf == null) return renderFn(props)\n\n if (control.getLeafValue == null) return renderLeaf(renderFn, undefined)(props)\n\n return (\n <ControlValue definition={control.definition} data={control.getLeafValue(props.leaf)}>\n {value => renderLeaf(renderFn, value)(props)}\n </ControlValue>\n )\n },\n initialRenderLeaf,\n )\n\n return renderLeaf(props)\n}\n","import { useEffect } from 'react'\nimport { Editor } from 'slate'\nimport { RichTextV2ControlData, richTextV2DataToDescendents } from '../../../../../controls'\nimport { LocalChange } from '../../../../../slate'\nimport { useIsInBuilder } from '../../..'\n\n// From the component point of view we can't know if the change came from an action or a undo/redo\n// So we diff the time and force updates on actions that occured over a second ago.\nfunction isChangeWithinPreviousSec(change?: LocalChange) {\n return performance.now() - (change?.time ?? 0) < 1000\n}\n\nexport function useSyncRemoteChanges(editor: Editor, data?: RichTextV2ControlData) {\n const isInBuilder = useIsInBuilder()\n\n useEffect(() => {\n if (\n !isChangeWithinPreviousSec(editor.localChanges.get(data?.key ?? '')) &&\n data &&\n isInBuilder\n ) {\n editor.children = richTextV2DataToDescendents(data)\n editor.selection = editor?.localChanges.get(data.key)?.selection ?? null\n editor.onChange()\n }\n }, [editor, data])\n}\n","import { Descendant } from 'slate'\nimport { BlockType } from '../../../../../slate'\nimport { getBaseBreakpoint, DefaultBreakpointID } from '../../../../../state/modules/breakpoints'\nimport { useBreakpoints } from '../../..'\nimport { useMemo } from 'react'\nimport { RichTextV2ControlDefinition, RichTextV2Mode } from '../../../../../controls'\n\nexport function usePresetValue(definition: RichTextV2ControlDefinition): Descendant[] {\n const breakpoints = useBreakpoints()\n return useMemo(\n () => [\n {\n type: BlockType.Default,\n children: [\n {\n text: definition.config.defaultValue ?? '',\n ...(definition.config.mode === RichTextV2Mode.Inline\n ? {}\n : {\n typography: {\n style: [\n {\n deviceId: getBaseBreakpoint(breakpoints).id,\n value: {\n fontWeight: 400,\n fontSize: { value: 18, unit: 'px' },\n lineHeight: 1.5,\n },\n },\n ...(breakpoints.some(({ id }) => id === DefaultBreakpointID.Mobile)\n ? [\n {\n deviceId: DefaultBreakpointID.Mobile,\n value: { fontSize: { value: 16, unit: 'px' } },\n },\n ]\n : []),\n ],\n },\n }),\n },\n ],\n },\n ],\n [definition.config.mode, definition.config.defaultValue, breakpoints],\n )\n}\n\nexport const defaultValue = [\n {\n type: BlockType.Default,\n children: [\n {\n text: '',\n },\n ],\n },\n]\n","import {\n FocusEvent,\n KeyboardEvent,\n MouseEvent,\n ReactNode,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from 'react'\nimport { createEditor } from 'slate'\nimport isHotkey from 'is-hotkey'\nimport {\n withReact,\n ReactEditor,\n RenderElementProps,\n RenderLeafProps,\n Slate,\n Editable,\n} from 'slate-react'\n\nimport {\n RichTextV2Control,\n RichTextV2ControlData,\n RichTextV2ControlDefinition,\n RichTextV2Mode,\n} from '../../../../../controls'\nimport { useBuilderEditMode } from '../../..'\nimport { BuilderEditMode } from '../../../../../state/modules/builder-edit-mode'\nimport { pollBoxModel } from '../../../poll-box-model'\nimport {\n BlockPlugin,\n InlineModePlugin,\n InlinePlugin,\n LinkPlugin,\n TextAlignPlugin,\n TypographyPlugin,\n withBuilder,\n withLocalChanges,\n} from '../../../../../slate'\nimport { useSyncDOMSelection } from './useSyncDOMSelection'\nimport { RichTextV2Element } from './render-element'\nimport { RichTextV2Leaf } from './render-leaf'\nimport { richTextV2DataToDescendents } from '../../../../../controls/rich-text-v2/translation'\nimport { useSyncRemoteChanges } from './useRemoteChanges'\nimport { defaultValue, usePresetValue } from './usePresetValue'\n\nexport type RichTextV2ControlValue = ReactNode\n\nexport type Descriptors = { text?: RichTextV2ControlDefinition }\n\ntype Props = {\n text?: RichTextV2ControlData\n definition: RichTextV2ControlDefinition\n control: RichTextV2Control | null\n}\n\nexport function EditableTextV2({ text, definition, control }: Props) {\n const plugins = useMemo(() => {\n const plugins = [\n /**\n * TODO: we are manually referencing our default plugins for each mode here because\n * Referencing the real LinkPlugin causes a circular dependency.\n * When circular dependencies calm down we should update the plugin definition to use real plugins,\n * and just use the plugins that are defined by our config.\n */\n // ...(definition?.config?.plugins ?? []),\n ...(definition?.config?.mode === RichTextV2Mode.Inline\n ? [InlineModePlugin()]\n : [BlockPlugin(), TypographyPlugin(), TextAlignPlugin(), InlinePlugin(), LinkPlugin()]),\n ]\n return plugins\n }, [definition])\n\n const [editor] = useState(() =>\n plugins.reduceRight(\n (editor, plugin) => plugin?.withPlugin?.(editor) ?? editor,\n withLocalChanges(withBuilder(withReact(createEditor()))),\n ),\n )\n\n useEffect(() => {\n if (control == null) return\n\n const element = ReactEditor.toDOMNode(editor, editor)\n return pollBoxModel({\n element,\n onBoxModelChange: boxModel => control.changeBoxModel(boxModel),\n })\n }, [editor, control])\n\n // ------ Preserving selection ------\n\n const isPreservingFocus = useRef(false)\n useSyncDOMSelection(editor, isPreservingFocus)\n const editMode = useBuilderEditMode()\n\n useEffect(() => {\n /**\n * This is required because clicking on the overlay has `relatedTarget` null just like the sidebar, but\n * - in the case of the overlay we switch to BUILD mode\n * - in the case of the sidebar we preserve the selection\n */\n if (editMode !== BuilderEditMode.CONTENT) {\n isPreservingFocus.current = false\n ReactEditor.deselect(editor)\n }\n }, [editMode])\n\n // ------ Syncing remote changes ------\n\n useSyncRemoteChanges(editor, text)\n\n // ------ Default value ------\n\n const presetValue = usePresetValue(definition)\n\n const initialValue = useMemo(\n () => (text && richTextV2DataToDescendents(text)) ?? presetValue,\n [text, presetValue],\n )\n\n useEffect(() => {\n control?.setEditor(editor)\n control?.setDefaultValue(defaultValue)\n }, [control, editor])\n\n /**\n * When initialValue is set to the default value we need to trigger an local change so that the sidebar updates and so the data is saved\n */\n useEffect(() => {\n if (initialValue === presetValue) {\n control?.onLocalUserChange()\n }\n }, [control, initialValue, presetValue])\n\n // ------ Rendering ------\n\n const renderElement = useCallback(\n (props: RenderElementProps) => {\n return <RichTextV2Element {...props} definition={definition} plugins={plugins} />\n },\n [plugins, definition],\n )\n\n const renderLeaf = useCallback(\n (props: RenderLeafProps) => {\n return <RichTextV2Leaf {...props} definition={definition} plugins={plugins} />\n },\n [plugins, definition],\n )\n\n // ------ Event handlers ------\n\n const handleFocus = useCallback(() => {\n isPreservingFocus.current = true\n control?.select()\n }, [control])\n\n const handleKeyDown = useCallback(\n (e: KeyboardEvent) => {\n if (isHotkey('mod+shift+z', e)) return control?.redo()\n if (isHotkey('mod+z', e)) return control?.undo()\n if (isHotkey('escape')(e)) {\n isPreservingFocus.current = false\n ReactEditor.blur(editor)\n control?.switchToBuildMode()\n }\n\n if (editMode === BuilderEditMode.CONTENT) {\n e.stopPropagation()\n }\n\n plugins.forEach(plugin => plugin?.onKeyDown?.(e, editor))\n },\n [control, plugins, editor, editMode],\n )\n\n const handleKeyUp = useCallback(\n (e: KeyboardEvent) => {\n if (editMode === BuilderEditMode.CONTENT) {\n e.stopPropagation()\n e.preventDefault()\n }\n },\n [control, editor, editMode],\n )\n\n const handleClick = useCallback(\n (e: MouseEvent) => {\n if (editMode === BuilderEditMode.CONTENT) e.stopPropagation()\n },\n [editMode],\n )\n\n const handleBlur = useCallback((e: FocusEvent) => {\n // outside of iframe (overlay, sidebar, etc)\n if (e.relatedTarget == null) return\n // another text\n if (e.relatedTarget?.getAttribute('contenteditable') === 'true')\n isPreservingFocus.current = false\n }, [])\n\n return (\n <Slate editor={editor} value={initialValue}>\n <Editable\n renderLeaf={renderLeaf}\n renderElement={renderElement}\n onFocus={handleFocus}\n onKeyDown={handleKeyDown}\n onKeyUp={handleKeyUp}\n onClick={handleClick}\n onBlur={handleBlur}\n readOnly={editMode !== BuilderEditMode.CONTENT}\n placeholder=\"Write some text...\"\n />\n </Slate>\n )\n}\n\nexport default EditableTextV2\n"],"names":["editor","isEnabled","useIsomorphicLayoutEffect","current","selection","ReactEditor","isFocused","root","findDocumentOrShadowRoot","domSelection","getSelection","newDomRange","toDOMRange","SlateRange","isBackward","setBaseAndExtent","endContainer","endOffset","startContainer","startOffset","removeAllRanges","e","console","error","definition","plugins","props","children","renderElement","reduce","renderFn","plugin","control","getElementValue","undefined","element","value","initialRenderElement","attributes","leaf","className","renderLeaf","getLeafValue","initialRenderLeaf","change","performance","now","time","data","isInBuilder","useIsInBuilder","useEffect","isChangeWithinPreviousSec","localChanges","get","key","richTextV2DataToDescendents","onChange","breakpoints","useBreakpoints","useMemo","type","BlockType","Default","text","config","defaultValue","mode","RichTextV2Mode","Inline","typography","style","deviceId","getBaseBreakpoint","id","fontWeight","fontSize","unit","lineHeight","some","DefaultBreakpointID","Mobile","InlineModePlugin","BlockPlugin","TypographyPlugin","TextAlignPlugin","InlinePlugin","LinkPlugin","useState","reduceRight","withPlugin","withLocalChanges","withBuilder","withReact","createEditor","toDOMNode","pollBoxModel","onBoxModelChange","boxModel","changeBoxModel","isPreservingFocus","useRef","useSyncDOMSelection","editMode","useBuilderEditMode","BuilderEditMode","CONTENT","deselect","useSyncRemoteChanges","presetValue","usePresetValue","initialValue","setEditor","setDefaultValue","onLocalUserChange","useCallback","handleFocus","select","handleKeyDown","isHotkey","redo","undo","blur","switchToBuildMode","stopPropagation","forEach","onKeyDown","handleKeyUp","preventDefault","handleClick","handleBlur","relatedTarget","getAttribute"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAUO,6BAA6BA,QAAgBC,WAAsC;AACxFC,4BAA0B,MAAM;AAC1B,QAAA,CAACD,UAAUE,WAAWH,OAAOI,aAAa,QAAQC,YAAYC,UAAUN,MAAtB;AAA+B;AACjF,QAAA;AACIO,YAAAA,OAAOF,YAAYG,yBAAyBR,MAArC;AACPS,YAAAA,eAAeF,KAAKG;AAC1B,YAA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AEH,GAAA,CAAChG,SAAShC,QAAQuG,QAAlB,CAP6B;AAUzB0B,QAAAA,cAAcd,YAClB,CAAC9F,MAAkB;AACbkF,QAAAA,aAAaE,gBAAgBC;AAASrF,QAAEuG,gBAAF;AAAA,EAAA,GAE5C,CAACrB,QAAD,CAJ6B;AAOzB2B,QAAAA,aAAaf,YAAY,CAAC9F,MAAkB;;AAEhD,QAAIA,EAAE8G,iBAAiB;AAAM;AAE7B,QAAI9G,SAAE8G,kBAAF9G,mBAAiB+G,aAAa,wBAAuB;AACvDhC,wBAAkBjG,UAAU;AAAA,EALF,GAM3B,CAN2B,CAAA;AAQ9B,6BACG,OAAD;AAAA,IAAO;AAAA,IAAgB,OAAO4G;AAAAA,IAA9B,8BACG,UAAD;AAAA,MACE;AAAA,MACA;AAAA,MACA,SAASK;AAAAA,MACT,WAAWE;AAAAA,MACX,SAASS;AAAAA,MACT,SAASE;AAAAA,MACT,QAAQC;AAAAA,MACR,UAAU3B,aAAaE,gBAAgBC;AAAAA,MACvC,aAAY;AAAA,IAAA,CATd;AAAA,EAAA,CAFJ;AAeD;;"}
|
package/dist/main.cjs.js
CHANGED
package/dist/main.cjs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"main.cjs.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"main.cjs.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/dist/main.es.js
CHANGED
package/dist/main.es.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"main.es.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"main.es.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;"}
|
package/dist/next.cjs.js
CHANGED
|
@@ -11,6 +11,7 @@ require("redux-thunk");
|
|
|
11
11
|
require("./actions.cjs.js");
|
|
12
12
|
require("zod");
|
|
13
13
|
require("./state/breakpoints.cjs.js");
|
|
14
|
+
require("corporate-ipsum");
|
|
14
15
|
require("slate");
|
|
15
16
|
require("uuid");
|
|
16
17
|
require("@emotion/css");
|
|
@@ -36,9 +37,6 @@ require("cookie");
|
|
|
36
37
|
require("http-proxy");
|
|
37
38
|
require("set-cookie-parser");
|
|
38
39
|
require("./constants.cjs.js");
|
|
39
|
-
require("corporate-ipsum");
|
|
40
|
-
require("slate-react");
|
|
41
|
-
require("next/link");
|
|
42
40
|
exports.Document = next.Document;
|
|
43
41
|
exports.Makeswift = next.Makeswift;
|
|
44
42
|
exports.MakeswiftApiHandler = next.MakeswiftApiHandler;
|
package/dist/next.cjs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"next.cjs.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"next.cjs.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/dist/next.es.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import "react";
|
|
2
|
-
export {
|
|
2
|
+
export { _ as Document, Y as Makeswift, $ as MakeswiftApiHandler, X as Page, Z as PreviewModeScript, a0 as forwardNextDynamicRef, W as getServerSideProps, U as getStaticPaths, V as getStaticProps } from "./index.es.js";
|
|
3
3
|
import "react/jsx-runtime";
|
|
4
4
|
import "use-sync-external-store/shim/with-selector";
|
|
5
5
|
import "next/dynamic";
|
|
@@ -9,6 +9,7 @@ import "redux-thunk";
|
|
|
9
9
|
import "./actions.es.js";
|
|
10
10
|
import "zod";
|
|
11
11
|
import "./state/breakpoints.es.js";
|
|
12
|
+
import "corporate-ipsum";
|
|
12
13
|
import "slate";
|
|
13
14
|
import "uuid";
|
|
14
15
|
import "@emotion/css";
|
|
@@ -34,7 +35,4 @@ import "cookie";
|
|
|
34
35
|
import "http-proxy";
|
|
35
36
|
import "set-cookie-parser";
|
|
36
37
|
import "./constants.es.js";
|
|
37
|
-
import "corporate-ipsum";
|
|
38
|
-
import "slate-react";
|
|
39
|
-
import "next/link";
|
|
40
38
|
//# sourceMappingURL=next.es.js.map
|
package/dist/next.es.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"next.es.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"next.es.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prop-controllers.cjs.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"prop-controllers.cjs.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prop-controllers.es.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"prop-controllers.es.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;"}
|
package/dist/react-page.cjs.js
CHANGED
|
@@ -39,6 +39,7 @@ var redux = require("redux");
|
|
|
39
39
|
var thunk = require("redux-thunk");
|
|
40
40
|
var actions = require("./actions.cjs.js");
|
|
41
41
|
var state_breakpoints = require("./state/breakpoints.cjs.js");
|
|
42
|
+
var ipsum = require("corporate-ipsum");
|
|
42
43
|
var slate = require("slate");
|
|
43
44
|
var uuid = require("uuid");
|
|
44
45
|
var React = require("react");
|
|
@@ -51,6 +52,7 @@ function _interopDefaultLegacy(e) {
|
|
|
51
52
|
return e && typeof e === "object" && "default" in e ? e : { "default": e };
|
|
52
53
|
}
|
|
53
54
|
var thunk__default = /* @__PURE__ */ _interopDefaultLegacy(thunk);
|
|
55
|
+
var ipsum__default = /* @__PURE__ */ _interopDefaultLegacy(ipsum);
|
|
54
56
|
var React__default = /* @__PURE__ */ _interopDefaultLegacy(React);
|
|
55
57
|
var isHotkey__default = /* @__PURE__ */ _interopDefaultLegacy(isHotkey);
|
|
56
58
|
const ComponentIcon = {
|
|
@@ -3705,13 +3707,31 @@ function InlineModePlugin() {
|
|
|
3705
3707
|
}))
|
|
3706
3708
|
});
|
|
3707
3709
|
}
|
|
3710
|
+
const minWidth = `${"Write some text...".length}ch`;
|
|
3708
3711
|
function InlineModePluginComponent(_f) {
|
|
3709
3712
|
var _g = _f, {
|
|
3710
3713
|
renderElement
|
|
3711
3714
|
} = _g, props = __objRest(_g, [
|
|
3712
3715
|
"renderElement"
|
|
3713
3716
|
]);
|
|
3714
|
-
|
|
3717
|
+
if (props.element.children.length === 1) {
|
|
3718
|
+
const text = props.element.children[0];
|
|
3719
|
+
if (slate.Text.isText(text) && text.text === "") {
|
|
3720
|
+
return /* @__PURE__ */ jsxRuntime.jsx("span", __spreadProps(__spreadValues({
|
|
3721
|
+
style: {
|
|
3722
|
+
display: "inline-block",
|
|
3723
|
+
minWidth
|
|
3724
|
+
}
|
|
3725
|
+
}, props.attributes), {
|
|
3726
|
+
children: renderElement(props)
|
|
3727
|
+
}));
|
|
3728
|
+
}
|
|
3729
|
+
}
|
|
3730
|
+
return /* @__PURE__ */ jsxRuntime.jsx("span", __spreadProps(__spreadValues({
|
|
3731
|
+
style: {
|
|
3732
|
+
minWidth
|
|
3733
|
+
}
|
|
3734
|
+
}, props.attributes), {
|
|
3715
3735
|
children: renderElement(props)
|
|
3716
3736
|
}));
|
|
3717
3737
|
}
|
|
@@ -3725,7 +3745,7 @@ function RichText(config = {}) {
|
|
|
3725
3745
|
type: RichTextV2ControlType,
|
|
3726
3746
|
config: {
|
|
3727
3747
|
mode: config.mode,
|
|
3728
|
-
defaultValue: config == null ? void 0 : config.
|
|
3748
|
+
defaultValue: (config == null ? void 0 : config.mode) === RichTextV2Mode.Inline ? "Edit this text" : ipsum__default["default"](3),
|
|
3729
3749
|
plugins: (config == null ? void 0 : config.mode) === RichTextV2Mode.Inline ? [InlineModePlugin()] : [BlockPlugin(), TypographyPlugin(), TextAlignPlugin(), InlinePlugin(), LinkPlugin()]
|
|
3730
3750
|
}
|
|
3731
3751
|
};
|
|
@@ -3761,10 +3781,10 @@ class RichTextV2Control extends PropController {
|
|
|
3761
3781
|
}
|
|
3762
3782
|
case RichTextV2ControlMessageType.RESET_VALUE: {
|
|
3763
3783
|
if (this.defaultValue) {
|
|
3764
|
-
this.editor.
|
|
3765
|
-
|
|
3766
|
-
|
|
3767
|
-
|
|
3784
|
+
this.editor.resetValue(this.defaultValue);
|
|
3785
|
+
setTimeout(() => {
|
|
3786
|
+
this.onLocalUserChange();
|
|
3787
|
+
});
|
|
3768
3788
|
}
|
|
3769
3789
|
break;
|
|
3770
3790
|
}
|