@makeswift/runtime 0.9.0 → 0.9.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Box.cjs.js +15 -15
- package/dist/Box.cjs.js.map +1 -1
- package/dist/Box.es.js +10 -10
- package/dist/Button.cjs.js +12 -12
- package/dist/Button.cjs.js.map +1 -1
- package/dist/Button.es.js +10 -10
- package/dist/Carousel.cjs.js +28 -28
- package/dist/Carousel.cjs.js.map +1 -1
- package/dist/Carousel.es.js +7 -7
- package/dist/Countdown.cjs.js +15 -15
- package/dist/Countdown.cjs.js.map +1 -1
- package/dist/Countdown.es.js +7 -7
- package/dist/Divider.cjs.js +12 -12
- package/dist/Divider.cjs.js.map +1 -1
- package/dist/Divider.es.js +10 -10
- package/dist/Embed.cjs.js +3 -30
- package/dist/Embed.cjs.js.map +1 -1
- package/dist/Embed.es.js +2 -29
- package/dist/Embed.es.js.map +1 -1
- package/dist/Form.cjs.js +51 -51
- package/dist/Form.cjs.js.map +1 -1
- package/dist/Form.es.js +7 -7
- package/dist/Image.cjs.js +8 -8
- package/dist/Image.cjs.js.map +1 -1
- package/dist/Image.es.js +7 -7
- package/dist/LiveProvider.cjs.js +6 -6
- package/dist/LiveProvider.es.js +8 -8
- package/dist/Navigation.cjs.js +27 -27
- package/dist/Navigation.cjs.js.map +1 -1
- package/dist/Navigation.es.js +6 -6
- package/dist/PreviewProvider.cjs.js +7 -7
- package/dist/PreviewProvider.cjs.js.map +1 -1
- package/dist/PreviewProvider.es.js +7 -7
- package/dist/ReadOnlyText.cjs.js +16 -13
- package/dist/ReadOnlyText.cjs.js.map +1 -1
- package/dist/ReadOnlyText.es.js +11 -8
- package/dist/ReadOnlyText.es.js.map +1 -1
- package/dist/ReadOnlyTextV2.cjs.js +13 -10
- package/dist/ReadOnlyTextV2.cjs.js.map +1 -1
- package/dist/ReadOnlyTextV2.es.js +9 -6
- package/dist/ReadOnlyTextV2.es.js.map +1 -1
- package/dist/Root.cjs.js +8 -8
- package/dist/Root.cjs.js.map +1 -1
- package/dist/Root.es.js +6 -6
- package/dist/SocialLinks.cjs.js +14 -14
- package/dist/SocialLinks.cjs.js.map +1 -1
- package/dist/SocialLinks.es.js +10 -10
- package/dist/Text.cjs.js +4 -4
- package/dist/Text.es.js +5 -5
- package/dist/Video.cjs.js +3 -30
- package/dist/Video.cjs.js.map +1 -1
- package/dist/Video.es.js +2 -29
- package/dist/Video.es.js.map +1 -1
- package/dist/builder.cjs.js +4 -2
- package/dist/builder.cjs.js.map +1 -1
- package/dist/builder.es.js +4 -2
- package/dist/builder.es.js.map +1 -1
- package/dist/components.cjs.js +9 -9
- package/dist/components.es.js +9 -9
- package/dist/control-serialization.cjs.js +88 -12
- package/dist/control-serialization.cjs.js.map +1 -1
- package/dist/control-serialization.es.js +89 -13
- package/dist/control-serialization.es.js.map +1 -1
- package/dist/controls.cjs.js +15 -4
- package/dist/controls.cjs.js.map +1 -1
- package/dist/controls.es.js +6 -3
- package/dist/controls.es.js.map +1 -1
- package/dist/deepEqual.cjs.js +40 -0
- package/dist/deepEqual.cjs.js.map +1 -0
- package/dist/deepEqual.es.js +39 -0
- package/dist/deepEqual.es.js.map +1 -0
- package/dist/index.cjs.js +102 -98
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.cjs10.js +173 -249
- package/dist/index.cjs10.js.map +1 -1
- package/dist/index.cjs11.js +375 -0
- package/dist/index.cjs11.js.map +1 -0
- package/dist/index.cjs2.js +14 -16
- package/dist/index.cjs2.js.map +1 -1
- package/dist/index.cjs4.js +2 -1
- package/dist/index.cjs4.js.map +1 -1
- package/dist/index.cjs6.js +700 -22
- package/dist/index.cjs6.js.map +1 -1
- package/dist/index.cjs7.js +37 -13
- package/dist/index.cjs7.js.map +1 -1
- package/dist/index.cjs8.js +17 -41
- package/dist/index.cjs8.js.map +1 -1
- package/dist/index.cjs9.js +13 -266
- package/dist/index.cjs9.js.map +1 -1
- package/dist/index.es.js +85 -80
- package/dist/index.es.js.map +1 -1
- package/dist/index.es10.js +174 -250
- package/dist/index.es10.js.map +1 -1
- package/dist/index.es11.js +368 -0
- package/dist/index.es11.js.map +1 -0
- package/dist/index.es2.js +3 -5
- package/dist/index.es2.js.map +1 -1
- package/dist/index.es3.js +1 -1
- package/dist/index.es4.js +2 -1
- package/dist/index.es4.js.map +1 -1
- package/dist/index.es6.js +695 -22
- package/dist/index.es6.js.map +1 -1
- package/dist/index.es7.js +33 -14
- package/dist/index.es7.js.map +1 -1
- package/dist/index.es8.js +17 -39
- package/dist/index.es8.js.map +1 -1
- package/dist/index.es9.js +12 -261
- package/dist/index.es9.js.map +1 -1
- package/dist/leaf.cjs.js +1 -1
- package/dist/leaf.cjs.js.map +1 -1
- package/dist/leaf.es.js +2 -2
- package/dist/main.cjs.js +4 -2
- package/dist/main.cjs.js.map +1 -1
- package/dist/main.es.js +4 -2
- package/dist/main.es.js.map +1 -1
- package/dist/next.cjs.js +3 -3
- package/dist/next.es.js +4 -4
- package/dist/prop-controllers.cjs.js +4 -2
- package/dist/prop-controllers.cjs.js.map +1 -1
- package/dist/prop-controllers.es.js +4 -2
- package/dist/prop-controllers.es.js.map +1 -1
- package/dist/react-page.cjs.js +958 -1431
- package/dist/react-page.cjs.js.map +1 -1
- package/dist/react-page.es.js +852 -1343
- package/dist/react-page.es.js.map +1 -1
- package/dist/react.cjs.js +3 -3
- package/dist/react.es.js +3 -3
- package/dist/select.cjs.js +21 -0
- package/dist/select.cjs.js.map +1 -0
- package/dist/select.es.js +16 -0
- package/dist/select.es.js.map +1 -0
- package/dist/slate.cjs.js +213 -12
- package/dist/slate.cjs.js.map +1 -1
- package/dist/slate.es.js +207 -6
- package/dist/slate.es.js.map +1 -1
- package/dist/types/src/api/react.d.ts.map +1 -1
- package/dist/types/src/builder/serialization/control-serialization.d.ts +3 -3
- package/dist/types/src/builder/serialization/control-serialization.d.ts.map +1 -1
- package/dist/types/src/builder/serialization/controls/rich-text-v2.d.ts +2 -2
- package/dist/types/src/builder/serialization/controls/rich-text-v2.d.ts.map +1 -1
- package/dist/types/src/builder/serialization/controls/style-v2.d.ts +5 -0
- package/dist/types/src/builder/serialization/controls/style-v2.d.ts.map +1 -0
- package/dist/types/src/components/builtin/Button/Button.d.ts +1 -1
- package/dist/types/src/components/builtin/Form/components/Field/components/Checkbox/index.d.ts +1 -1
- package/dist/types/src/components/hooks/useIsomorphicLayoutEffect.d.ts +2 -2
- package/dist/types/src/components/hooks/useIsomorphicLayoutEffect.d.ts.map +1 -1
- package/dist/types/src/components/page/Page.d.ts.map +1 -1
- package/dist/types/src/controls/control.d.ts +4 -2
- package/dist/types/src/controls/control.d.ts.map +1 -1
- package/dist/types/src/controls/icon-radio-group.d.ts +29 -0
- package/dist/types/src/controls/icon-radio-group.d.ts.map +1 -0
- package/dist/types/src/controls/index.d.ts +2 -0
- package/dist/types/src/controls/index.d.ts.map +1 -1
- package/dist/types/src/controls/rich-text/translation.d.ts +1 -1
- package/dist/types/src/controls/rich-text/translation.d.ts.map +1 -1
- package/dist/types/src/controls/rich-text-v2/rich-text-v2.d.ts +12 -3
- package/dist/types/src/controls/rich-text-v2/rich-text-v2.d.ts.map +1 -1
- package/dist/types/src/controls/shape.d.ts +1 -2
- package/dist/types/src/controls/shape.d.ts.map +1 -1
- package/dist/types/src/controls/style-v2.d.ts +64 -0
- package/dist/types/src/controls/style-v2.d.ts.map +1 -0
- package/dist/types/src/next/client.d.ts.map +1 -1
- package/dist/types/src/next/document.d.ts.map +1 -1
- package/dist/types/src/prop-controllers/descriptors.d.ts +6 -3
- package/dist/types/src/prop-controllers/descriptors.d.ts.map +1 -1
- package/dist/types/src/prop-controllers/instances.d.ts +2 -2
- package/dist/types/src/prop-controllers/instances.d.ts.map +1 -1
- package/dist/types/src/prop-controllers/introspection.d.ts.map +1 -1
- package/dist/types/src/runtimes/react/controls/control.d.ts +5 -2
- package/dist/types/src/runtimes/react/controls/control.d.ts.map +1 -1
- package/dist/types/src/runtimes/react/controls/icon-radio-group.d.ts +4 -0
- package/dist/types/src/runtimes/react/controls/icon-radio-group.d.ts.map +1 -0
- package/dist/types/src/runtimes/react/controls/rich-text-v2/EditableTextV2/editable-text-v2.d.ts +2 -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 +10 -0
- package/dist/types/src/runtimes/react/controls/rich-text-v2/EditableTextV2/render-element.d.ts.map +1 -0
- package/dist/types/src/runtimes/react/controls/rich-text-v2/EditableTextV2/render-leaf.d.ts +10 -0
- package/dist/types/src/runtimes/react/controls/rich-text-v2/EditableTextV2/render-leaf.d.ts.map +1 -0
- package/dist/types/src/runtimes/react/controls/rich-text-v2/rich-text-v2.d.ts +1 -1
- package/dist/types/src/runtimes/react/controls/rich-text-v2/rich-text-v2.d.ts.map +1 -1
- package/dist/types/src/runtimes/react/controls/style-v2.d.ts +13 -0
- package/dist/types/src/runtimes/react/controls/style-v2.d.ts.map +1 -0
- package/dist/types/src/runtimes/react/controls.d.ts.map +1 -1
- package/dist/types/src/runtimes/react/index.d.ts.map +1 -1
- package/dist/types/src/slate/BlockPlugin/index.d.ts +4 -0
- package/dist/types/src/slate/BlockPlugin/index.d.ts.map +1 -1
- package/dist/types/src/slate/ColorPlugin/index.d.ts +10 -0
- package/dist/types/src/slate/ColorPlugin/index.d.ts.map +1 -0
- package/dist/types/src/slate/InlineModePlugin/index.d.ts +2 -0
- package/dist/types/src/slate/InlineModePlugin/index.d.ts.map +1 -1
- package/dist/types/src/slate/TextAlignPlugin/index.d.ts +9 -0
- package/dist/types/src/slate/TextAlignPlugin/index.d.ts.map +1 -0
- package/dist/types/src/slate/index.d.ts +2 -0
- package/dist/types/src/slate/index.d.ts.map +1 -1
- package/dist/types/src/slate/types.d.ts +39 -0
- package/dist/types/src/slate/types.d.ts.map +1 -1
- package/dist/types/src/slate/utils/responsive.d.ts +16 -0
- package/dist/types/src/slate/utils/responsive.d.ts.map +1 -0
- package/dist/useMediaQuery.es.js +1 -1
- package/package.json +1 -1
package/dist/react-page.cjs.js
CHANGED
|
@@ -22,18 +22,41 @@ var __publicField = (obj, key, value) => {
|
|
|
22
22
|
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
23
23
|
return value;
|
|
24
24
|
};
|
|
25
|
+
var _a;
|
|
25
26
|
var redux = require("redux");
|
|
26
27
|
var thunk = require("redux-thunk");
|
|
27
28
|
var actions = require("./actions.cjs.js");
|
|
28
29
|
var state_breakpoints = require("./state/breakpoints.cjs.js");
|
|
30
|
+
var React = require("react");
|
|
31
|
+
var css = require("@emotion/css");
|
|
32
|
+
var serialize = require("@emotion/serialize");
|
|
33
|
+
var utils = require("@emotion/utils");
|
|
29
34
|
var slate = require("slate");
|
|
30
|
-
var isHotkey = require("is-hotkey");
|
|
31
|
-
require("slate-react");
|
|
32
35
|
function _interopDefaultLegacy(e) {
|
|
33
36
|
return e && typeof e === "object" && "default" in e ? e : { "default": e };
|
|
34
37
|
}
|
|
38
|
+
function _interopNamespace(e) {
|
|
39
|
+
if (e && e.__esModule)
|
|
40
|
+
return e;
|
|
41
|
+
var n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
|
|
42
|
+
if (e) {
|
|
43
|
+
Object.keys(e).forEach(function(k) {
|
|
44
|
+
if (k !== "default") {
|
|
45
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
46
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
47
|
+
enumerable: true,
|
|
48
|
+
get: function() {
|
|
49
|
+
return e[k];
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
n["default"] = e;
|
|
56
|
+
return Object.freeze(n);
|
|
57
|
+
}
|
|
35
58
|
var thunk__default = /* @__PURE__ */ _interopDefaultLegacy(thunk);
|
|
36
|
-
var
|
|
59
|
+
var React__namespace = /* @__PURE__ */ _interopNamespace(React);
|
|
37
60
|
const ComponentIcon = {
|
|
38
61
|
Billing: "billing",
|
|
39
62
|
Bolt: "bolt",
|
|
@@ -101,8 +124,8 @@ function getDocuments(state) {
|
|
|
101
124
|
return state;
|
|
102
125
|
}
|
|
103
126
|
function getDocument$1(state, documentKey) {
|
|
104
|
-
var
|
|
105
|
-
return (
|
|
127
|
+
var _a2;
|
|
128
|
+
return (_a2 = getDocuments(state).get(documentKey)) != null ? _a2 : null;
|
|
106
129
|
}
|
|
107
130
|
function reducer$8(state = getInitialState$7(), action) {
|
|
108
131
|
switch (action.type) {
|
|
@@ -126,8 +149,8 @@ function getReactComponents(state) {
|
|
|
126
149
|
return state;
|
|
127
150
|
}
|
|
128
151
|
function getReactComponent$1(state, type) {
|
|
129
|
-
var
|
|
130
|
-
return (
|
|
152
|
+
var _a2;
|
|
153
|
+
return (_a2 = getReactComponents(state).get(type)) != null ? _a2 : null;
|
|
131
154
|
}
|
|
132
155
|
function reducer$7(state = getInitialState$6(), action) {
|
|
133
156
|
switch (action.type) {
|
|
@@ -151,8 +174,8 @@ function getPropControllerDescriptors$1(state) {
|
|
|
151
174
|
return state;
|
|
152
175
|
}
|
|
153
176
|
function getComponentPropControllerDescriptors$1(state, componentType) {
|
|
154
|
-
var
|
|
155
|
-
return (
|
|
177
|
+
var _a2;
|
|
178
|
+
return (_a2 = getPropControllerDescriptors$1(state).get(componentType)) != null ? _a2 : null;
|
|
156
179
|
}
|
|
157
180
|
function reducer$6(state = getInitialState$5(), action) {
|
|
158
181
|
switch (action.type) {
|
|
@@ -177,24 +200,24 @@ function getInitialState$4() {
|
|
|
177
200
|
return { handles: /* @__PURE__ */ new Map(), instances: /* @__PURE__ */ new Map() };
|
|
178
201
|
}
|
|
179
202
|
function getPropControllersHandle(state, documentKey, elementKey) {
|
|
180
|
-
var
|
|
181
|
-
return (_b = (
|
|
203
|
+
var _a2, _b;
|
|
204
|
+
return (_b = (_a2 = state.handles.get(documentKey)) == null ? void 0 : _a2.get(elementKey)) != null ? _b : null;
|
|
182
205
|
}
|
|
183
206
|
function getPropControllers$1(state, documentKey, elementKey) {
|
|
184
|
-
var
|
|
185
|
-
return (_b = (
|
|
207
|
+
var _a2, _b;
|
|
208
|
+
return (_b = (_a2 = state.instances.get(documentKey)) == null ? void 0 : _a2.get(elementKey)) != null ? _b : null;
|
|
186
209
|
}
|
|
187
210
|
function getPropController(state, documentKey, elementKey, propName) {
|
|
188
|
-
var
|
|
189
|
-
return (_b = (
|
|
211
|
+
var _a2, _b;
|
|
212
|
+
return (_b = (_a2 = getPropControllers$1(state, documentKey, elementKey)) == null ? void 0 : _a2[propName]) != null ? _b : null;
|
|
190
213
|
}
|
|
191
214
|
function reducer$5(state = getInitialState$4(), action) {
|
|
192
|
-
var
|
|
215
|
+
var _a2, _b, _c, _d;
|
|
193
216
|
switch (action.type) {
|
|
194
217
|
case actions.ActionTypes.REGISTER_PROP_CONTROLLERS_HANDLE: {
|
|
195
218
|
const { documentKey, elementKey, handle } = action.payload;
|
|
196
219
|
return __spreadProps(__spreadValues({}, state), {
|
|
197
|
-
handles: new Map(state.handles).set(documentKey, new Map((
|
|
220
|
+
handles: new Map(state.handles).set(documentKey, new Map((_a2 = state.handles.get(documentKey)) != null ? _a2 : []).set(elementKey, handle))
|
|
198
221
|
});
|
|
199
222
|
}
|
|
200
223
|
case actions.ActionTypes.UNREGISTER_PROP_CONTROLLERS_HANDLE: {
|
|
@@ -259,9 +282,9 @@ function reducer$2(state = getInitialState$1(), action) {
|
|
|
259
282
|
}
|
|
260
283
|
}
|
|
261
284
|
function getInitialState(initialState) {
|
|
262
|
-
var
|
|
285
|
+
var _a2, _b, _c;
|
|
263
286
|
return {
|
|
264
|
-
locales: (
|
|
287
|
+
locales: (_a2 = initialState == null ? void 0 : initialState.locales) != null ? _a2 : [],
|
|
265
288
|
locale: (_b = initialState == null ? void 0 : initialState.locale) != null ? _b : null,
|
|
266
289
|
defaultLocale: (_c = initialState == null ? void 0 : initialState.defaultLocale) != null ? _c : null
|
|
267
290
|
};
|
|
@@ -291,99 +314,206 @@ function Color(config = {}) {
|
|
|
291
314
|
return { type: ColorControlType, config };
|
|
292
315
|
}
|
|
293
316
|
function copyColorData(value, context) {
|
|
294
|
-
var
|
|
317
|
+
var _a2;
|
|
295
318
|
if (value == null)
|
|
296
319
|
return value;
|
|
297
320
|
return __spreadProps(__spreadValues({}, value), {
|
|
298
|
-
swatchId: (
|
|
321
|
+
swatchId: (_a2 = context.replacementContext.swatchIds.get(value.swatchId)) != null ? _a2 : value.swatchId
|
|
299
322
|
});
|
|
300
323
|
}
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
}
|
|
306
|
-
function Image$1(config = {}) {
|
|
307
|
-
return { type: ImageControlType, config };
|
|
308
|
-
}
|
|
309
|
-
Image$1.Format = ImageControlValueFormat;
|
|
310
|
-
function copyImageData(value, context) {
|
|
311
|
-
var _a;
|
|
312
|
-
if (value == null)
|
|
313
|
-
return value;
|
|
314
|
-
return (_a = context.replacementContext.fileIds.get(value)) != null ? _a : value;
|
|
324
|
+
class PropController {
|
|
325
|
+
constructor(send) {
|
|
326
|
+
__publicField(this, "send");
|
|
327
|
+
this.send = send;
|
|
328
|
+
}
|
|
315
329
|
}
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
330
|
+
const StyleControlType = "makeswift::controls::style";
|
|
331
|
+
const StyleControlProperty = {
|
|
332
|
+
Width: "makeswift::controls::style::property::width",
|
|
333
|
+
Margin: "makeswift::controls::style::property::margin",
|
|
334
|
+
Padding: "makeswift::controls::style::property::padding",
|
|
335
|
+
Border: "makeswift::controls::style::property::border",
|
|
336
|
+
BorderRadius: "makeswift::controls::style::property::border-radius",
|
|
337
|
+
TextStyle: "makeswift::controls::style::property::text-style"
|
|
338
|
+
};
|
|
339
|
+
const StyleControlDefaultProperties = [
|
|
340
|
+
StyleControlProperty.Width,
|
|
341
|
+
StyleControlProperty.Margin
|
|
342
|
+
];
|
|
343
|
+
const AllStyleControlProperties = [
|
|
344
|
+
StyleControlProperty.Width,
|
|
345
|
+
StyleControlProperty.Margin,
|
|
346
|
+
StyleControlProperty.Padding,
|
|
347
|
+
StyleControlProperty.Border,
|
|
348
|
+
StyleControlProperty.BorderRadius,
|
|
349
|
+
StyleControlProperty.TextStyle
|
|
350
|
+
];
|
|
351
|
+
function Style(params) {
|
|
352
|
+
var _a2;
|
|
353
|
+
return {
|
|
354
|
+
type: StyleControlType,
|
|
355
|
+
config: { properties: (_a2 = params == null ? void 0 : params.properties) != null ? _a2 : StyleControlDefaultProperties }
|
|
356
|
+
};
|
|
341
357
|
}
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
358
|
+
Style.Default = StyleControlDefaultProperties;
|
|
359
|
+
Style.All = AllStyleControlProperties;
|
|
360
|
+
Style.Width = StyleControlProperty.Width;
|
|
361
|
+
Style.Margin = StyleControlProperty.Margin;
|
|
362
|
+
Style.Padding = StyleControlProperty.Padding;
|
|
363
|
+
Style.Border = StyleControlProperty.Border;
|
|
364
|
+
Style.BorderRadius = StyleControlProperty.BorderRadius;
|
|
365
|
+
Style.TextStyle = StyleControlProperty.TextStyle;
|
|
366
|
+
const StyleControlMessageType = {
|
|
367
|
+
CHANGE_BOX_MODEL: "makeswift::controls::style::message::change-box-model"
|
|
368
|
+
};
|
|
369
|
+
class StyleControl extends PropController {
|
|
370
|
+
constructor(send) {
|
|
371
|
+
super(send);
|
|
372
|
+
}
|
|
373
|
+
changeBoxModel(boxModel) {
|
|
374
|
+
this.send({ type: StyleControlMessageType.CHANGE_BOX_MODEL, payload: { boxModel } });
|
|
375
|
+
}
|
|
376
|
+
recv() {
|
|
377
|
+
}
|
|
345
378
|
}
|
|
346
|
-
function
|
|
347
|
-
var _a;
|
|
379
|
+
function copyStyleData(value, context) {
|
|
348
380
|
if (value == null)
|
|
349
381
|
return value;
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
382
|
+
function copyResponsiveBorder(responsiveBorder) {
|
|
383
|
+
if (responsiveBorder == null)
|
|
384
|
+
return void 0;
|
|
385
|
+
return responsiveBorder.map((deviceBorder) => __spreadProps(__spreadValues({}, deviceBorder), {
|
|
386
|
+
value: copyBorder(deviceBorder.value)
|
|
387
|
+
}));
|
|
388
|
+
}
|
|
389
|
+
function copyBorder(border) {
|
|
390
|
+
function copyBorderSide(side) {
|
|
391
|
+
if (side == null)
|
|
392
|
+
return null;
|
|
393
|
+
if (side.color == null)
|
|
394
|
+
return side;
|
|
395
|
+
return __spreadProps(__spreadValues({}, side), {
|
|
396
|
+
color: copyColorData(side.color, context)
|
|
357
397
|
});
|
|
358
398
|
}
|
|
399
|
+
return {
|
|
400
|
+
borderTop: copyBorderSide(border.borderTop),
|
|
401
|
+
borderBottom: copyBorderSide(border.borderBottom),
|
|
402
|
+
borderRight: copyBorderSide(border.borderRight),
|
|
403
|
+
borderLeft: copyBorderSide(border.borderLeft)
|
|
404
|
+
};
|
|
359
405
|
}
|
|
360
|
-
return value;
|
|
406
|
+
return __spreadProps(__spreadValues({}, value), { border: copyResponsiveBorder(value.border) });
|
|
361
407
|
}
|
|
362
408
|
if (void 0) {
|
|
363
409
|
const { describe, test, expect } = void 0;
|
|
364
|
-
describe.concurrent("
|
|
365
|
-
test("
|
|
366
|
-
const
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
410
|
+
describe.concurrent("style copy", () => {
|
|
411
|
+
test("colors are replaced", () => {
|
|
412
|
+
const value = {
|
|
413
|
+
width: [
|
|
414
|
+
{
|
|
415
|
+
value: {
|
|
416
|
+
unit: "px",
|
|
417
|
+
value: 100
|
|
418
|
+
},
|
|
419
|
+
deviceId: "desktop"
|
|
420
|
+
}
|
|
421
|
+
],
|
|
422
|
+
border: [
|
|
423
|
+
{
|
|
424
|
+
value: {
|
|
425
|
+
borderTop: {
|
|
426
|
+
color: {
|
|
427
|
+
alpha: 1,
|
|
428
|
+
swatchId: "U3dhdGNoOmJjMDkwZWJjLTZkZDUtNDY1NS1hMDY0LTg3ZDAxM2U4YTFhNA=="
|
|
429
|
+
},
|
|
430
|
+
style: "solid",
|
|
431
|
+
width: 9
|
|
432
|
+
},
|
|
433
|
+
borderLeft: {
|
|
434
|
+
color: {
|
|
435
|
+
alpha: 1,
|
|
436
|
+
swatchId: "U3dhdGNoOmJjMDkwZWJjLTZkZDUtNDY1NS1hMDY0LTg3ZDAxM2U4YTFhNA=="
|
|
437
|
+
},
|
|
438
|
+
style: "solid",
|
|
439
|
+
width: 9
|
|
440
|
+
},
|
|
441
|
+
borderRight: {
|
|
442
|
+
color: {
|
|
443
|
+
alpha: 1,
|
|
444
|
+
swatchId: "U3dhdGNoOmJjMDkwZWJjLTZkZDUtNDY1NS1hMDY0LTg3ZDAxM2U4YTFhNA=="
|
|
445
|
+
},
|
|
446
|
+
style: "solid",
|
|
447
|
+
width: 9
|
|
448
|
+
},
|
|
449
|
+
borderBottom: {
|
|
450
|
+
color: {
|
|
451
|
+
alpha: 1,
|
|
452
|
+
swatchId: "U3dhdGNoOmJjMDkwZWJjLTZkZDUtNDY1NS1hMDY0LTg3ZDAxM2U4YTFhNA=="
|
|
453
|
+
},
|
|
454
|
+
style: "solid",
|
|
455
|
+
width: 9
|
|
456
|
+
}
|
|
457
|
+
},
|
|
458
|
+
deviceId: "desktop"
|
|
459
|
+
}
|
|
460
|
+
],
|
|
461
|
+
textStyle: [
|
|
462
|
+
{
|
|
463
|
+
value: {
|
|
464
|
+
fontSize: {
|
|
465
|
+
unit: "px",
|
|
466
|
+
value: 46
|
|
467
|
+
},
|
|
468
|
+
fontStyle: [],
|
|
469
|
+
fontFamily: "Oswald",
|
|
470
|
+
fontWeight: 400,
|
|
471
|
+
letterSpacing: 5.2,
|
|
472
|
+
textTransform: []
|
|
473
|
+
},
|
|
474
|
+
deviceId: "desktop"
|
|
475
|
+
}
|
|
476
|
+
],
|
|
477
|
+
borderRadius: [
|
|
478
|
+
{
|
|
479
|
+
value: {
|
|
480
|
+
borderTopLeftRadius: {
|
|
481
|
+
unit: "px",
|
|
482
|
+
value: 4
|
|
483
|
+
},
|
|
484
|
+
borderTopRightRadius: {
|
|
485
|
+
unit: "px",
|
|
486
|
+
value: 4
|
|
487
|
+
},
|
|
488
|
+
borderBottomLeftRadius: {
|
|
489
|
+
unit: "px",
|
|
490
|
+
value: 4
|
|
491
|
+
},
|
|
492
|
+
borderBottomRightRadius: {
|
|
493
|
+
unit: "px",
|
|
494
|
+
value: 4
|
|
495
|
+
}
|
|
496
|
+
},
|
|
497
|
+
deviceId: "desktop"
|
|
498
|
+
}
|
|
499
|
+
]
|
|
372
500
|
};
|
|
373
|
-
const expected = JSON.parse(JSON.stringify(
|
|
501
|
+
const expected = JSON.parse(JSON.stringify(value).replaceAll("U3dhdGNoOmJjMDkwZWJjLTZkZDUtNDY1NS1hMDY0LTg3ZDAxM2U4YTFhNA==", "testing"));
|
|
374
502
|
const replacementContext = {
|
|
375
503
|
elementHtmlIds: /* @__PURE__ */ new Set(),
|
|
376
504
|
elementKeys: /* @__PURE__ */ new Map(),
|
|
377
|
-
swatchIds: /* @__PURE__ */ new Map(
|
|
378
|
-
|
|
505
|
+
swatchIds: /* @__PURE__ */ new Map([
|
|
506
|
+
["U3dhdGNoOmJjMDkwZWJjLTZkZDUtNDY1NS1hMDY0LTg3ZDAxM2U4YTFhNA==", "testing"]
|
|
507
|
+
]),
|
|
508
|
+
fileIds: /* @__PURE__ */ new Map(),
|
|
379
509
|
typographyIds: /* @__PURE__ */ new Map(),
|
|
380
510
|
tableIds: /* @__PURE__ */ new Map(),
|
|
381
511
|
tableColumnIds: /* @__PURE__ */ new Map(),
|
|
382
|
-
|
|
512
|
+
pageIds: /* @__PURE__ */ new Map(),
|
|
383
513
|
globalElementIds: /* @__PURE__ */ new Map(),
|
|
384
514
|
globalElementData: /* @__PURE__ */ new Map()
|
|
385
515
|
};
|
|
386
|
-
const result =
|
|
516
|
+
const result = copyStyleData(value, {
|
|
387
517
|
replacementContext,
|
|
388
518
|
copyElement: (node) => node
|
|
389
519
|
});
|
|
@@ -391,28 +521,338 @@ if (void 0) {
|
|
|
391
521
|
});
|
|
392
522
|
});
|
|
393
523
|
}
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
524
|
+
const Types = {
|
|
525
|
+
Backgrounds: "Backgrounds",
|
|
526
|
+
Border: "Border",
|
|
527
|
+
BorderRadius: "BorderRadius",
|
|
528
|
+
Checkbox: "Checkbox",
|
|
529
|
+
Date: "Date",
|
|
530
|
+
ElementID: "ElementID",
|
|
531
|
+
Font: "Font",
|
|
532
|
+
GapX: "GapX",
|
|
533
|
+
GapY: "GapY",
|
|
534
|
+
Grid: "Grid",
|
|
535
|
+
Image: "Image",
|
|
536
|
+
Images: "Images",
|
|
537
|
+
Link: "Link",
|
|
538
|
+
List: "List",
|
|
539
|
+
Margin: "Margin",
|
|
540
|
+
NavigationLinks: "NavigationLinks",
|
|
541
|
+
Number: "Number",
|
|
542
|
+
Padding: "Padding",
|
|
543
|
+
ResponsiveColor: "ResponsiveColor",
|
|
544
|
+
ResponsiveIconRadioGroup: "ResponsiveIconRadioGroup",
|
|
545
|
+
ResponsiveLength: "ResponsiveLength",
|
|
546
|
+
ResponsiveNumber: "ResponsiveNumber",
|
|
547
|
+
ResponsiveOpacity: "ResponsiveOpacity",
|
|
548
|
+
ResponsiveSelect: "ResponsiveSelect",
|
|
549
|
+
RichText: "RichText",
|
|
550
|
+
Shadows: "Shadows",
|
|
551
|
+
Shape: "Shape",
|
|
552
|
+
SocialLinks: "SocialLinks",
|
|
553
|
+
Table: "Table",
|
|
554
|
+
TableFormFields: "TableFormFields",
|
|
555
|
+
Typeahead: "Typeahead",
|
|
556
|
+
TextArea: "TextArea",
|
|
557
|
+
TextInput: "TextInput",
|
|
558
|
+
TextStyle: "TextStyle",
|
|
559
|
+
Video: "Video",
|
|
560
|
+
Width: "Width",
|
|
561
|
+
Style: StyleControlType
|
|
562
|
+
};
|
|
563
|
+
function Backgrounds(options = {}) {
|
|
564
|
+
return { type: Types.Backgrounds, options };
|
|
565
|
+
}
|
|
566
|
+
const BorderPropControllerFormat = {
|
|
567
|
+
ClassName: "makeswift::prop-controllers::border::format::class-name",
|
|
568
|
+
ResponsiveValue: "makeswift::prop-controllers:border::format::responsive-value"
|
|
569
|
+
};
|
|
570
|
+
function Border(options = {}) {
|
|
571
|
+
return { type: Types.Border, options };
|
|
572
|
+
}
|
|
573
|
+
Border.Format = BorderPropControllerFormat;
|
|
574
|
+
const BorderRadiusPropControllerFormat = {
|
|
575
|
+
ClassName: "makeswift::prop-controllers::border-radius::format::class-name",
|
|
576
|
+
ResponsiveValue: "makeswift::prop-controllers::border-radius::format::responsive-value"
|
|
577
|
+
};
|
|
578
|
+
function BorderRadius(options = {}) {
|
|
579
|
+
return { type: Types.BorderRadius, options };
|
|
580
|
+
}
|
|
581
|
+
BorderRadius.Format = BorderRadiusPropControllerFormat;
|
|
582
|
+
function Checkbox(options) {
|
|
583
|
+
return { type: Types.Checkbox, options };
|
|
584
|
+
}
|
|
585
|
+
function Date(options = {}) {
|
|
586
|
+
return { type: Types.Date, options };
|
|
587
|
+
}
|
|
588
|
+
function ElementID(options = {}) {
|
|
589
|
+
return { type: Types.ElementID, options };
|
|
590
|
+
}
|
|
591
|
+
function Font(options = {}) {
|
|
592
|
+
return { type: Types.Font, options };
|
|
593
|
+
}
|
|
594
|
+
function GapX(options = {}) {
|
|
595
|
+
return { type: Types.GapX, options };
|
|
596
|
+
}
|
|
597
|
+
function GapY(options = {}) {
|
|
598
|
+
return { type: Types.GapY, options };
|
|
599
|
+
}
|
|
600
|
+
function Grid(options = {}) {
|
|
601
|
+
return { type: Types.Grid, options };
|
|
602
|
+
}
|
|
603
|
+
function Image$1(options = {}) {
|
|
604
|
+
return { type: Types.Image, options };
|
|
605
|
+
}
|
|
606
|
+
function Images(options = {}) {
|
|
607
|
+
return { type: Types.Images, options };
|
|
608
|
+
}
|
|
609
|
+
function Link$1(options = {}) {
|
|
610
|
+
return { type: Types.Link, options };
|
|
611
|
+
}
|
|
612
|
+
function List$1(options) {
|
|
613
|
+
return { type: Types.List, options };
|
|
614
|
+
}
|
|
615
|
+
const MarginPropControllerFormat = {
|
|
616
|
+
ClassName: "makeswift::prop-controllers::margin::format::class-name",
|
|
617
|
+
ResponsiveValue: "makeswift::prop-controllers::margin::format::responsive-value"
|
|
618
|
+
};
|
|
619
|
+
function Margin(options = {}) {
|
|
620
|
+
return { type: Types.Margin, options };
|
|
621
|
+
}
|
|
622
|
+
Margin.Format = MarginPropControllerFormat;
|
|
623
|
+
function NavigationLinks(options = {}) {
|
|
624
|
+
return { type: Types.NavigationLinks, options };
|
|
625
|
+
}
|
|
626
|
+
function Number(options = {}) {
|
|
627
|
+
return { type: Types.Number, options };
|
|
628
|
+
}
|
|
629
|
+
const PaddingPropControllerFormat = {
|
|
630
|
+
ClassName: "makeswift::prop-controllers::padding::format::class-name",
|
|
631
|
+
ResponsiveValue: "makeswift::prop-controllers::padding::format::responsive-value"
|
|
632
|
+
};
|
|
633
|
+
function Padding(options = {}) {
|
|
634
|
+
return { type: Types.Padding, options };
|
|
635
|
+
}
|
|
636
|
+
Padding.Format = PaddingPropControllerFormat;
|
|
637
|
+
function ResponsiveColor(options = {}) {
|
|
638
|
+
return { type: Types.ResponsiveColor, options };
|
|
639
|
+
}
|
|
640
|
+
function ResponsiveIconRadioGroup(options) {
|
|
641
|
+
return { type: Types.ResponsiveIconRadioGroup, options };
|
|
642
|
+
}
|
|
643
|
+
function ResponsiveLength(options = {}) {
|
|
644
|
+
return { type: Types.ResponsiveLength, options };
|
|
645
|
+
}
|
|
646
|
+
function ResponsiveNumber(options = {}) {
|
|
647
|
+
return { type: Types.ResponsiveNumber, options };
|
|
648
|
+
}
|
|
649
|
+
function ResponsiveOpacity(options = {}) {
|
|
650
|
+
return { type: Types.ResponsiveOpacity, options };
|
|
651
|
+
}
|
|
652
|
+
function ResponsiveSelect(options) {
|
|
653
|
+
return { type: Types.ResponsiveSelect, options };
|
|
654
|
+
}
|
|
655
|
+
function RichText$1(options = {}) {
|
|
656
|
+
return { type: Types.RichText, options };
|
|
657
|
+
}
|
|
658
|
+
const ShadowsPropControllerFormat = {
|
|
659
|
+
ClassName: "makeswift::prop-controllers::shadows::format::class-name",
|
|
660
|
+
ResponsiveValue: "makeswift::prop-controllers::shadows::format::responsive-value"
|
|
661
|
+
};
|
|
662
|
+
function Shadows(options = {}) {
|
|
663
|
+
return { type: Types.Shadows, options };
|
|
664
|
+
}
|
|
665
|
+
Shadows.Format = ShadowsPropControllerFormat;
|
|
666
|
+
function Shape$1(options) {
|
|
667
|
+
return { type: Types.Shape, options };
|
|
668
|
+
}
|
|
669
|
+
function SocialLinks(options = {}) {
|
|
670
|
+
return { type: Types.SocialLinks, options };
|
|
671
|
+
}
|
|
672
|
+
function Table(options = {}) {
|
|
673
|
+
return { type: Types.Table, options };
|
|
674
|
+
}
|
|
675
|
+
function TableFormFields(options = {}) {
|
|
676
|
+
return { type: Types.TableFormFields, options };
|
|
677
|
+
}
|
|
678
|
+
function Typeahead(options) {
|
|
679
|
+
return { type: Types.Typeahead, options };
|
|
680
|
+
}
|
|
681
|
+
function TextArea(options = {}) {
|
|
682
|
+
return { type: Types.TextArea, options };
|
|
683
|
+
}
|
|
684
|
+
function TextInput(options = {}) {
|
|
685
|
+
return { type: Types.TextInput, options };
|
|
686
|
+
}
|
|
687
|
+
function TextStyle(options = {}) {
|
|
688
|
+
return { type: Types.TextStyle, options };
|
|
689
|
+
}
|
|
690
|
+
function Video(options = {}) {
|
|
691
|
+
return { type: Types.Video, options };
|
|
692
|
+
}
|
|
693
|
+
const WidthPropControllerFormat = {
|
|
694
|
+
ClassName: "makeswift::prop-controllers::width::format::class-name",
|
|
695
|
+
ResponsiveValue: "makeswift::prop-controllers::width::format::responsive-value"
|
|
696
|
+
};
|
|
697
|
+
function Width(options = {}) {
|
|
698
|
+
return { type: Types.Width, options };
|
|
699
|
+
}
|
|
700
|
+
Width.Format = WidthPropControllerFormat;
|
|
701
|
+
var descriptors = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
702
|
+
__proto__: null,
|
|
703
|
+
Types,
|
|
704
|
+
Backgrounds,
|
|
705
|
+
BorderPropControllerFormat,
|
|
706
|
+
Border,
|
|
707
|
+
BorderRadiusPropControllerFormat,
|
|
708
|
+
BorderRadius,
|
|
709
|
+
Checkbox,
|
|
710
|
+
Date,
|
|
711
|
+
ElementID,
|
|
712
|
+
Font,
|
|
713
|
+
GapX,
|
|
714
|
+
GapY,
|
|
715
|
+
Grid,
|
|
716
|
+
Image: Image$1,
|
|
717
|
+
Images,
|
|
718
|
+
Link: Link$1,
|
|
719
|
+
List: List$1,
|
|
720
|
+
MarginPropControllerFormat,
|
|
721
|
+
Margin,
|
|
722
|
+
NavigationLinks,
|
|
723
|
+
Number,
|
|
724
|
+
PaddingPropControllerFormat,
|
|
725
|
+
Padding,
|
|
726
|
+
ResponsiveColor,
|
|
727
|
+
ResponsiveIconRadioGroup,
|
|
728
|
+
ResponsiveLength,
|
|
729
|
+
ResponsiveNumber,
|
|
730
|
+
ResponsiveOpacity,
|
|
731
|
+
ResponsiveSelect,
|
|
732
|
+
RichText: RichText$1,
|
|
733
|
+
ShadowsPropControllerFormat,
|
|
734
|
+
Shadows,
|
|
735
|
+
Shape: Shape$1,
|
|
736
|
+
SocialLinks,
|
|
737
|
+
Table,
|
|
738
|
+
TableFormFields,
|
|
739
|
+
Typeahead,
|
|
740
|
+
TextArea,
|
|
741
|
+
TextInput,
|
|
742
|
+
TextStyle,
|
|
743
|
+
Video,
|
|
744
|
+
WidthPropControllerFormat,
|
|
745
|
+
Width
|
|
746
|
+
}, Symbol.toStringTag, { value: "Module" }));
|
|
747
|
+
const ImageControlType = "makeswift::controls::image";
|
|
748
|
+
const ImageControlValueFormat = {
|
|
749
|
+
URL: "makeswift::controls::image::format::url",
|
|
750
|
+
WithDimensions: "makeswift::controls::image::format::with-dimensions"
|
|
751
|
+
};
|
|
752
|
+
function Image(config = {}) {
|
|
753
|
+
return { type: ImageControlType, config };
|
|
754
|
+
}
|
|
755
|
+
Image.Format = ImageControlValueFormat;
|
|
756
|
+
function copyImageData(value, context) {
|
|
757
|
+
var _a2;
|
|
758
|
+
if (value == null)
|
|
759
|
+
return value;
|
|
760
|
+
return (_a2 = context.replacementContext.fileIds.get(value)) != null ? _a2 : value;
|
|
761
|
+
}
|
|
762
|
+
if (void 0) {
|
|
763
|
+
const { describe, test, expect } = void 0;
|
|
764
|
+
describe.concurrent("image copy", () => {
|
|
765
|
+
test("image is replaced by a one in replacement context", () => {
|
|
766
|
+
const data = "file-id";
|
|
767
|
+
const expected = "testing";
|
|
768
|
+
const replacementContext = {
|
|
769
|
+
elementHtmlIds: /* @__PURE__ */ new Set(),
|
|
770
|
+
elementKeys: /* @__PURE__ */ new Map(),
|
|
771
|
+
swatchIds: /* @__PURE__ */ new Map(),
|
|
772
|
+
fileIds: /* @__PURE__ */ new Map([["file-id", "testing"]]),
|
|
773
|
+
typographyIds: /* @__PURE__ */ new Map(),
|
|
774
|
+
tableIds: /* @__PURE__ */ new Map(),
|
|
775
|
+
tableColumnIds: /* @__PURE__ */ new Map(),
|
|
776
|
+
pageIds: /* @__PURE__ */ new Map(),
|
|
777
|
+
globalElementIds: /* @__PURE__ */ new Map(),
|
|
778
|
+
globalElementData: /* @__PURE__ */ new Map()
|
|
779
|
+
};
|
|
780
|
+
const result = copyImageData(data, {
|
|
781
|
+
replacementContext,
|
|
782
|
+
copyElement: (node) => node
|
|
783
|
+
});
|
|
784
|
+
expect(result).toMatchObject(expected);
|
|
785
|
+
});
|
|
786
|
+
});
|
|
787
|
+
}
|
|
788
|
+
const LinkControlType = "makeswift::controls::link";
|
|
789
|
+
function Link(config = {}) {
|
|
790
|
+
return { type: LinkControlType, config };
|
|
791
|
+
}
|
|
792
|
+
function copyLinkData(value, context) {
|
|
793
|
+
var _a2;
|
|
794
|
+
if (value == null)
|
|
795
|
+
return value;
|
|
796
|
+
if (value.type === "OPEN_PAGE") {
|
|
797
|
+
const pageId = value.payload.pageId;
|
|
798
|
+
if (pageId != null) {
|
|
799
|
+
return __spreadProps(__spreadValues({}, value), {
|
|
800
|
+
payload: __spreadProps(__spreadValues({}, value.payload), {
|
|
801
|
+
pageId: (_a2 = context.replacementContext.pageIds.get(pageId)) != null ? _a2 : pageId
|
|
802
|
+
})
|
|
803
|
+
});
|
|
804
|
+
}
|
|
805
|
+
}
|
|
806
|
+
return value;
|
|
807
|
+
}
|
|
808
|
+
if (void 0) {
|
|
809
|
+
const { describe, test, expect } = void 0;
|
|
810
|
+
describe.concurrent("link", () => {
|
|
811
|
+
test("page id is replaced by one in replacement context", () => {
|
|
812
|
+
const data = {
|
|
813
|
+
type: "OPEN_PAGE",
|
|
814
|
+
payload: {
|
|
815
|
+
pageId: "UGFnZTpmNTdmMjQ2MS0wMGY3LTQzZWUtYmIwOS03ODdiNTUyYzUyYWQ=",
|
|
816
|
+
openInNewTab: false
|
|
817
|
+
}
|
|
818
|
+
};
|
|
819
|
+
const expected = JSON.parse(JSON.stringify(data).replace("UGFnZTpmNTdmMjQ2MS0wMGY3LTQzZWUtYmIwOS03ODdiNTUyYzUyYWQ=", "testing"));
|
|
820
|
+
const replacementContext = {
|
|
821
|
+
elementHtmlIds: /* @__PURE__ */ new Set(),
|
|
822
|
+
elementKeys: /* @__PURE__ */ new Map(),
|
|
823
|
+
swatchIds: /* @__PURE__ */ new Map(),
|
|
824
|
+
pageIds: /* @__PURE__ */ new Map([["UGFnZTpmNTdmMjQ2MS0wMGY3LTQzZWUtYmIwOS03ODdiNTUyYzUyYWQ=", "testing"]]),
|
|
825
|
+
typographyIds: /* @__PURE__ */ new Map(),
|
|
826
|
+
tableIds: /* @__PURE__ */ new Map(),
|
|
827
|
+
tableColumnIds: /* @__PURE__ */ new Map(),
|
|
828
|
+
fileIds: /* @__PURE__ */ new Map(),
|
|
829
|
+
globalElementIds: /* @__PURE__ */ new Map(),
|
|
830
|
+
globalElementData: /* @__PURE__ */ new Map()
|
|
831
|
+
};
|
|
832
|
+
const result = copyLinkData(data, {
|
|
833
|
+
replacementContext,
|
|
834
|
+
copyElement: (node) => node
|
|
835
|
+
});
|
|
836
|
+
expect(result).toMatchObject(expected);
|
|
837
|
+
});
|
|
838
|
+
});
|
|
839
|
+
}
|
|
840
|
+
const RichTextPropControllerMessageType = {
|
|
841
|
+
CHANGE_BUILDER_EDIT_MODE: "CHANGE_BUILDER_EDIT_MODE",
|
|
842
|
+
INITIALIZE_EDITOR: "INITIALIZE_EDITOR",
|
|
843
|
+
CHANGE_EDITOR_VALUE: "CHANGE_EDITOR_VALUE",
|
|
844
|
+
FOCUS: "FOCUS",
|
|
845
|
+
BLUR: "BLUR",
|
|
846
|
+
UNDO: "UNDO",
|
|
847
|
+
REDO: "REDO",
|
|
848
|
+
CHANGE_BOX_MODEL: "CHANGE_BOX_MODEL"
|
|
849
|
+
};
|
|
850
|
+
class DefaultPropController extends PropController {
|
|
851
|
+
constructor() {
|
|
852
|
+
super(...arguments);
|
|
853
|
+
__publicField(this, "recv", (_message) => {
|
|
854
|
+
});
|
|
855
|
+
}
|
|
416
856
|
}
|
|
417
857
|
class RichTextPropController extends PropController {
|
|
418
858
|
constructor() {
|
|
@@ -505,12 +945,14 @@ function createPropController(descriptor, send) {
|
|
|
505
945
|
return new ShapeControl(send, descriptor);
|
|
506
946
|
case StyleControlType:
|
|
507
947
|
return new StyleControl(send);
|
|
948
|
+
case StyleV2ControlType:
|
|
949
|
+
return new StyleV2Control(send, descriptor);
|
|
508
950
|
default:
|
|
509
951
|
return new DefaultPropController(send);
|
|
510
952
|
}
|
|
511
953
|
}
|
|
512
954
|
const ListControlType = "makeswift::controls::list";
|
|
513
|
-
function List
|
|
955
|
+
function List(config) {
|
|
514
956
|
return { type: ListControlType, config };
|
|
515
957
|
}
|
|
516
958
|
const ListControlMessageType = {
|
|
@@ -561,15 +1003,15 @@ class ListControl extends PropController {
|
|
|
561
1003
|
this.controls = /* @__PURE__ */ new Map();
|
|
562
1004
|
}
|
|
563
1005
|
}
|
|
564
|
-
function copyListData(
|
|
1006
|
+
function copyListData(definition, value, context) {
|
|
565
1007
|
if (value == null)
|
|
566
1008
|
return value;
|
|
567
1009
|
return value && value.map((item) => __spreadProps(__spreadValues({}, item), {
|
|
568
|
-
value: copy(
|
|
1010
|
+
value: copy(definition.config.type, item.value, context)
|
|
569
1011
|
}));
|
|
570
1012
|
}
|
|
571
1013
|
const ShapeControlType = "makeswift::controls::shape";
|
|
572
|
-
function Shape
|
|
1014
|
+
function Shape(config) {
|
|
573
1015
|
return { type: ShapeControlType, config };
|
|
574
1016
|
}
|
|
575
1017
|
const ShapeControlMessageType = {
|
|
@@ -611,210 +1053,16 @@ class ShapeControl extends PropController {
|
|
|
611
1053
|
this.setControls();
|
|
612
1054
|
}
|
|
613
1055
|
}
|
|
614
|
-
function copyShapeData(
|
|
1056
|
+
function copyShapeData(definition, value, context) {
|
|
615
1057
|
if (value == null)
|
|
616
1058
|
return value;
|
|
617
1059
|
const newValue = {};
|
|
618
|
-
for (const [key, itemDefinition] of Object.entries(
|
|
1060
|
+
for (const [key, itemDefinition] of Object.entries(definition.config.type)) {
|
|
619
1061
|
const prop = value[key];
|
|
620
1062
|
newValue[key] = copy(itemDefinition, prop, context);
|
|
621
1063
|
}
|
|
622
1064
|
return newValue;
|
|
623
1065
|
}
|
|
624
|
-
const StyleControlType = "makeswift::controls::style";
|
|
625
|
-
const StyleControlProperty = {
|
|
626
|
-
Width: "makeswift::controls::style::property::width",
|
|
627
|
-
Margin: "makeswift::controls::style::property::margin",
|
|
628
|
-
Padding: "makeswift::controls::style::property::padding",
|
|
629
|
-
Border: "makeswift::controls::style::property::border",
|
|
630
|
-
BorderRadius: "makeswift::controls::style::property::border-radius",
|
|
631
|
-
TextStyle: "makeswift::controls::style::property::text-style"
|
|
632
|
-
};
|
|
633
|
-
const StyleControlDefaultProperties = [
|
|
634
|
-
StyleControlProperty.Width,
|
|
635
|
-
StyleControlProperty.Margin
|
|
636
|
-
];
|
|
637
|
-
const AllStyleControlProperties = [
|
|
638
|
-
StyleControlProperty.Width,
|
|
639
|
-
StyleControlProperty.Margin,
|
|
640
|
-
StyleControlProperty.Padding,
|
|
641
|
-
StyleControlProperty.Border,
|
|
642
|
-
StyleControlProperty.BorderRadius,
|
|
643
|
-
StyleControlProperty.TextStyle
|
|
644
|
-
];
|
|
645
|
-
function Style(params) {
|
|
646
|
-
var _a;
|
|
647
|
-
return {
|
|
648
|
-
type: StyleControlType,
|
|
649
|
-
config: { properties: (_a = params == null ? void 0 : params.properties) != null ? _a : StyleControlDefaultProperties }
|
|
650
|
-
};
|
|
651
|
-
}
|
|
652
|
-
Style.Default = StyleControlDefaultProperties;
|
|
653
|
-
Style.All = AllStyleControlProperties;
|
|
654
|
-
Style.Width = StyleControlProperty.Width;
|
|
655
|
-
Style.Margin = StyleControlProperty.Margin;
|
|
656
|
-
Style.Padding = StyleControlProperty.Padding;
|
|
657
|
-
Style.Border = StyleControlProperty.Border;
|
|
658
|
-
Style.BorderRadius = StyleControlProperty.BorderRadius;
|
|
659
|
-
Style.TextStyle = StyleControlProperty.TextStyle;
|
|
660
|
-
const StyleControlMessageType = {
|
|
661
|
-
CHANGE_BOX_MODEL: "makeswift::controls::style::message::change-box-model"
|
|
662
|
-
};
|
|
663
|
-
class StyleControl extends PropController {
|
|
664
|
-
constructor(send) {
|
|
665
|
-
super(send);
|
|
666
|
-
}
|
|
667
|
-
changeBoxModel(boxModel) {
|
|
668
|
-
this.send({ type: StyleControlMessageType.CHANGE_BOX_MODEL, payload: { boxModel } });
|
|
669
|
-
}
|
|
670
|
-
recv() {
|
|
671
|
-
}
|
|
672
|
-
}
|
|
673
|
-
function copyStyleData(value, context) {
|
|
674
|
-
if (value == null)
|
|
675
|
-
return value;
|
|
676
|
-
function copyResponsiveBorder(responsiveBorder) {
|
|
677
|
-
if (responsiveBorder == null)
|
|
678
|
-
return void 0;
|
|
679
|
-
return responsiveBorder.map((deviceBorder) => __spreadProps(__spreadValues({}, deviceBorder), {
|
|
680
|
-
value: copyBorder(deviceBorder.value)
|
|
681
|
-
}));
|
|
682
|
-
}
|
|
683
|
-
function copyBorder(border) {
|
|
684
|
-
function copyBorderSide(side) {
|
|
685
|
-
if (side == null)
|
|
686
|
-
return null;
|
|
687
|
-
if (side.color == null)
|
|
688
|
-
return side;
|
|
689
|
-
return __spreadProps(__spreadValues({}, side), {
|
|
690
|
-
color: copyColorData(side.color, context)
|
|
691
|
-
});
|
|
692
|
-
}
|
|
693
|
-
return {
|
|
694
|
-
borderTop: copyBorderSide(border.borderTop),
|
|
695
|
-
borderBottom: copyBorderSide(border.borderBottom),
|
|
696
|
-
borderRight: copyBorderSide(border.borderRight),
|
|
697
|
-
borderLeft: copyBorderSide(border.borderLeft)
|
|
698
|
-
};
|
|
699
|
-
}
|
|
700
|
-
return __spreadProps(__spreadValues({}, value), { border: copyResponsiveBorder(value.border) });
|
|
701
|
-
}
|
|
702
|
-
if (void 0) {
|
|
703
|
-
const { describe, test, expect } = void 0;
|
|
704
|
-
describe.concurrent("style copy", () => {
|
|
705
|
-
test("colors are replaced", () => {
|
|
706
|
-
const value = {
|
|
707
|
-
width: [
|
|
708
|
-
{
|
|
709
|
-
value: {
|
|
710
|
-
unit: "px",
|
|
711
|
-
value: 100
|
|
712
|
-
},
|
|
713
|
-
deviceId: "desktop"
|
|
714
|
-
}
|
|
715
|
-
],
|
|
716
|
-
border: [
|
|
717
|
-
{
|
|
718
|
-
value: {
|
|
719
|
-
borderTop: {
|
|
720
|
-
color: {
|
|
721
|
-
alpha: 1,
|
|
722
|
-
swatchId: "U3dhdGNoOmJjMDkwZWJjLTZkZDUtNDY1NS1hMDY0LTg3ZDAxM2U4YTFhNA=="
|
|
723
|
-
},
|
|
724
|
-
style: "solid",
|
|
725
|
-
width: 9
|
|
726
|
-
},
|
|
727
|
-
borderLeft: {
|
|
728
|
-
color: {
|
|
729
|
-
alpha: 1,
|
|
730
|
-
swatchId: "U3dhdGNoOmJjMDkwZWJjLTZkZDUtNDY1NS1hMDY0LTg3ZDAxM2U4YTFhNA=="
|
|
731
|
-
},
|
|
732
|
-
style: "solid",
|
|
733
|
-
width: 9
|
|
734
|
-
},
|
|
735
|
-
borderRight: {
|
|
736
|
-
color: {
|
|
737
|
-
alpha: 1,
|
|
738
|
-
swatchId: "U3dhdGNoOmJjMDkwZWJjLTZkZDUtNDY1NS1hMDY0LTg3ZDAxM2U4YTFhNA=="
|
|
739
|
-
},
|
|
740
|
-
style: "solid",
|
|
741
|
-
width: 9
|
|
742
|
-
},
|
|
743
|
-
borderBottom: {
|
|
744
|
-
color: {
|
|
745
|
-
alpha: 1,
|
|
746
|
-
swatchId: "U3dhdGNoOmJjMDkwZWJjLTZkZDUtNDY1NS1hMDY0LTg3ZDAxM2U4YTFhNA=="
|
|
747
|
-
},
|
|
748
|
-
style: "solid",
|
|
749
|
-
width: 9
|
|
750
|
-
}
|
|
751
|
-
},
|
|
752
|
-
deviceId: "desktop"
|
|
753
|
-
}
|
|
754
|
-
],
|
|
755
|
-
textStyle: [
|
|
756
|
-
{
|
|
757
|
-
value: {
|
|
758
|
-
fontSize: {
|
|
759
|
-
unit: "px",
|
|
760
|
-
value: 46
|
|
761
|
-
},
|
|
762
|
-
fontStyle: [],
|
|
763
|
-
fontFamily: "Oswald",
|
|
764
|
-
fontWeight: 400,
|
|
765
|
-
letterSpacing: 5.2,
|
|
766
|
-
textTransform: []
|
|
767
|
-
},
|
|
768
|
-
deviceId: "desktop"
|
|
769
|
-
}
|
|
770
|
-
],
|
|
771
|
-
borderRadius: [
|
|
772
|
-
{
|
|
773
|
-
value: {
|
|
774
|
-
borderTopLeftRadius: {
|
|
775
|
-
unit: "px",
|
|
776
|
-
value: 4
|
|
777
|
-
},
|
|
778
|
-
borderTopRightRadius: {
|
|
779
|
-
unit: "px",
|
|
780
|
-
value: 4
|
|
781
|
-
},
|
|
782
|
-
borderBottomLeftRadius: {
|
|
783
|
-
unit: "px",
|
|
784
|
-
value: 4
|
|
785
|
-
},
|
|
786
|
-
borderBottomRightRadius: {
|
|
787
|
-
unit: "px",
|
|
788
|
-
value: 4
|
|
789
|
-
}
|
|
790
|
-
},
|
|
791
|
-
deviceId: "desktop"
|
|
792
|
-
}
|
|
793
|
-
]
|
|
794
|
-
};
|
|
795
|
-
const expected = JSON.parse(JSON.stringify(value).replaceAll("U3dhdGNoOmJjMDkwZWJjLTZkZDUtNDY1NS1hMDY0LTg3ZDAxM2U4YTFhNA==", "testing"));
|
|
796
|
-
const replacementContext = {
|
|
797
|
-
elementHtmlIds: /* @__PURE__ */ new Set(),
|
|
798
|
-
elementKeys: /* @__PURE__ */ new Map(),
|
|
799
|
-
swatchIds: /* @__PURE__ */ new Map([
|
|
800
|
-
["U3dhdGNoOmJjMDkwZWJjLTZkZDUtNDY1NS1hMDY0LTg3ZDAxM2U4YTFhNA==", "testing"]
|
|
801
|
-
]),
|
|
802
|
-
fileIds: /* @__PURE__ */ new Map(),
|
|
803
|
-
typographyIds: /* @__PURE__ */ new Map(),
|
|
804
|
-
tableIds: /* @__PURE__ */ new Map(),
|
|
805
|
-
tableColumnIds: /* @__PURE__ */ new Map(),
|
|
806
|
-
pageIds: /* @__PURE__ */ new Map(),
|
|
807
|
-
globalElementIds: /* @__PURE__ */ new Map(),
|
|
808
|
-
globalElementData: /* @__PURE__ */ new Map()
|
|
809
|
-
};
|
|
810
|
-
const result = copyStyleData(value, {
|
|
811
|
-
replacementContext,
|
|
812
|
-
copyElement: (node) => node
|
|
813
|
-
});
|
|
814
|
-
expect(result).toMatchObject(expected);
|
|
815
|
-
});
|
|
816
|
-
});
|
|
817
|
-
}
|
|
818
1066
|
const SlotControlType = "makeswift::controls::slot";
|
|
819
1067
|
function Slot() {
|
|
820
1068
|
return { type: SlotControlType };
|
|
@@ -864,22 +1112,22 @@ function copy$e(value, context) {
|
|
|
864
1112
|
return value;
|
|
865
1113
|
return value.map((override) => __spreadProps(__spreadValues({}, override), {
|
|
866
1114
|
value: override.value.map((backgroundItem) => {
|
|
867
|
-
var
|
|
1115
|
+
var _a2, _b;
|
|
868
1116
|
switch (backgroundItem.type) {
|
|
869
1117
|
case "color":
|
|
870
1118
|
return __spreadProps(__spreadValues({}, backgroundItem), {
|
|
871
1119
|
payload: backgroundItem.payload === null ? null : __spreadProps(__spreadValues({}, backgroundItem.payload), {
|
|
872
|
-
swatchId: (
|
|
1120
|
+
swatchId: (_a2 = context.replacementContext.swatchIds.get(backgroundItem.payload.swatchId)) != null ? _a2 : backgroundItem.payload.swatchId
|
|
873
1121
|
})
|
|
874
1122
|
});
|
|
875
1123
|
case "gradient":
|
|
876
1124
|
return __spreadProps(__spreadValues({}, backgroundItem), {
|
|
877
1125
|
payload: __spreadProps(__spreadValues({}, backgroundItem.payload), {
|
|
878
1126
|
stops: backgroundItem.payload.stops.map((stop) => {
|
|
879
|
-
var
|
|
1127
|
+
var _a3;
|
|
880
1128
|
return __spreadProps(__spreadValues({}, stop), {
|
|
881
1129
|
color: stop.color == null ? null : __spreadProps(__spreadValues({}, stop.color), {
|
|
882
|
-
swatchId: (
|
|
1130
|
+
swatchId: (_a3 = context.replacementContext.swatchIds.get(stop.color.swatchId)) != null ? _a3 : stop.color.swatchId
|
|
883
1131
|
})
|
|
884
1132
|
});
|
|
885
1133
|
})
|
|
@@ -905,7 +1153,7 @@ function copy$d(value, context) {
|
|
|
905
1153
|
});
|
|
906
1154
|
}
|
|
907
1155
|
function copy$c(value, context) {
|
|
908
|
-
var
|
|
1156
|
+
var _a2, _b;
|
|
909
1157
|
if (value == null)
|
|
910
1158
|
return value;
|
|
911
1159
|
switch (value.type) {
|
|
@@ -915,7 +1163,7 @@ function copy$c(value, context) {
|
|
|
915
1163
|
return value;
|
|
916
1164
|
return __spreadProps(__spreadValues({}, value), {
|
|
917
1165
|
payload: __spreadProps(__spreadValues({}, value.payload), {
|
|
918
|
-
pageId: (
|
|
1166
|
+
pageId: (_a2 = context.replacementContext.pageIds.get(pageId)) != null ? _a2 : pageId
|
|
919
1167
|
})
|
|
920
1168
|
});
|
|
921
1169
|
}
|
|
@@ -948,10 +1196,10 @@ function copy$b(value, context) {
|
|
|
948
1196
|
payload: __spreadProps(__spreadValues({}, item.payload), {
|
|
949
1197
|
link: link != null ? copy$c(link, context) : void 0,
|
|
950
1198
|
color: color != null ? color.map((override) => {
|
|
951
|
-
var
|
|
1199
|
+
var _a2;
|
|
952
1200
|
return __spreadProps(__spreadValues({}, override), {
|
|
953
1201
|
value: __spreadProps(__spreadValues({}, override.value), {
|
|
954
|
-
swatchId: (
|
|
1202
|
+
swatchId: (_a2 = context.replacementContext.swatchIds.get(override.value.swatchId)) != null ? _a2 : override.value.swatchId
|
|
955
1203
|
})
|
|
956
1204
|
});
|
|
957
1205
|
}) : void 0
|
|
@@ -1009,14 +1257,14 @@ function copy$a(value, context) {
|
|
|
1009
1257
|
return value;
|
|
1010
1258
|
return value.map((override) => __spreadProps(__spreadValues({}, override), { value: override.value.map(copyShadowItem) }));
|
|
1011
1259
|
function copyShadowItem(item) {
|
|
1012
|
-
var
|
|
1260
|
+
var _a2;
|
|
1013
1261
|
const { color } = item.payload;
|
|
1014
1262
|
if (color == null)
|
|
1015
1263
|
return item;
|
|
1016
1264
|
return __spreadProps(__spreadValues({}, item), {
|
|
1017
1265
|
payload: __spreadProps(__spreadValues({}, item.payload), {
|
|
1018
1266
|
color: __spreadProps(__spreadValues({}, color), {
|
|
1019
|
-
swatchId: (
|
|
1267
|
+
swatchId: (_a2 = context.replacementContext.swatchIds.get(color.swatchId)) != null ? _a2 : color.swatchId
|
|
1020
1268
|
})
|
|
1021
1269
|
})
|
|
1022
1270
|
});
|
|
@@ -1070,10 +1318,10 @@ if (void 0) {
|
|
|
1070
1318
|
});
|
|
1071
1319
|
}
|
|
1072
1320
|
function copy$9(value, context) {
|
|
1073
|
-
var
|
|
1321
|
+
var _a2;
|
|
1074
1322
|
if (value == null)
|
|
1075
1323
|
return value;
|
|
1076
|
-
return (
|
|
1324
|
+
return (_a2 = context.replacementContext.fileIds.get(value)) != null ? _a2 : value;
|
|
1077
1325
|
}
|
|
1078
1326
|
if (void 0) {
|
|
1079
1327
|
const { describe, test, expect } = void 0;
|
|
@@ -1106,13 +1354,13 @@ function copy$8(value, context) {
|
|
|
1106
1354
|
return value;
|
|
1107
1355
|
return value.map(copyImagesPanelItem);
|
|
1108
1356
|
function copyImagesPanelItem(imagesPanelItem) {
|
|
1109
|
-
var
|
|
1357
|
+
var _a2;
|
|
1110
1358
|
const { file } = imagesPanelItem.props;
|
|
1111
1359
|
if (file == null)
|
|
1112
1360
|
return imagesPanelItem;
|
|
1113
1361
|
return __spreadProps(__spreadValues({}, imagesPanelItem), {
|
|
1114
1362
|
props: __spreadProps(__spreadValues({}, imagesPanelItem.props), {
|
|
1115
|
-
file: (
|
|
1363
|
+
file: (_a2 = context.replacementContext.fileIds.get(file)) != null ? _a2 : file
|
|
1116
1364
|
})
|
|
1117
1365
|
});
|
|
1118
1366
|
}
|
|
@@ -1161,9 +1409,9 @@ function copy$7(value, context) {
|
|
|
1161
1409
|
return value;
|
|
1162
1410
|
return value.map((override) => __spreadProps(__spreadValues({}, override), { value: copyColorValue(override.value) }));
|
|
1163
1411
|
function copyColorValue(colorValue) {
|
|
1164
|
-
var
|
|
1412
|
+
var _a2;
|
|
1165
1413
|
return __spreadProps(__spreadValues({}, colorValue), {
|
|
1166
|
-
swatchId: (
|
|
1414
|
+
swatchId: (_a2 = context.replacementContext.swatchIds.get(colorValue.swatchId)) != null ? _a2 : colorValue.swatchId
|
|
1167
1415
|
});
|
|
1168
1416
|
}
|
|
1169
1417
|
}
|
|
@@ -1172,9 +1420,9 @@ function copy$6(value, context) {
|
|
|
1172
1420
|
return value;
|
|
1173
1421
|
return __spreadProps(__spreadValues({}, value), { fields: value.fields.map(copyFormFieldsPanelItem) });
|
|
1174
1422
|
function copyFormFieldsPanelItem(item) {
|
|
1175
|
-
var
|
|
1423
|
+
var _a2;
|
|
1176
1424
|
return __spreadProps(__spreadValues({}, item), {
|
|
1177
|
-
tableColumnId: (
|
|
1425
|
+
tableColumnId: (_a2 = context.replacementContext.tableColumnIds.get(item.tableColumnId)) != null ? _a2 : item.tableColumnId
|
|
1178
1426
|
});
|
|
1179
1427
|
}
|
|
1180
1428
|
}
|
|
@@ -1228,10 +1476,10 @@ if (void 0) {
|
|
|
1228
1476
|
});
|
|
1229
1477
|
}
|
|
1230
1478
|
function copy$5(value, context) {
|
|
1231
|
-
var
|
|
1479
|
+
var _a2;
|
|
1232
1480
|
if (value == null)
|
|
1233
1481
|
return value;
|
|
1234
|
-
return (
|
|
1482
|
+
return (_a2 = context.replacementContext.tableIds.get(value)) != null ? _a2 : value;
|
|
1235
1483
|
}
|
|
1236
1484
|
if (void 0) {
|
|
1237
1485
|
const { describe, test, expect } = void 0;
|
|
@@ -1273,13 +1521,13 @@ function copy$4(value, context) {
|
|
|
1273
1521
|
};
|
|
1274
1522
|
}
|
|
1275
1523
|
function copyBorderSide(borderSide) {
|
|
1276
|
-
var
|
|
1524
|
+
var _a2;
|
|
1277
1525
|
const { color } = borderSide;
|
|
1278
1526
|
if (color == null)
|
|
1279
1527
|
return borderSide;
|
|
1280
1528
|
return __spreadProps(__spreadValues({}, borderSide), {
|
|
1281
1529
|
color: __spreadProps(__spreadValues({}, color), {
|
|
1282
|
-
swatchId: (
|
|
1530
|
+
swatchId: (_a2 = context.replacementContext.swatchIds.get(color.swatchId)) != null ? _a2 : color.swatchId
|
|
1283
1531
|
})
|
|
1284
1532
|
});
|
|
1285
1533
|
}
|
|
@@ -1393,24 +1641,24 @@ function copy$3(value, context) {
|
|
|
1393
1641
|
return value;
|
|
1394
1642
|
return __spreadProps(__spreadValues({}, value), { document: value.document ? copyNode(value.document) : value.document });
|
|
1395
1643
|
function copyNode(node) {
|
|
1396
|
-
var
|
|
1644
|
+
var _a2;
|
|
1397
1645
|
switch (node.object) {
|
|
1398
1646
|
case "document":
|
|
1399
1647
|
case "block":
|
|
1400
1648
|
case "inline":
|
|
1401
1649
|
return copyInline(node);
|
|
1402
1650
|
case "text":
|
|
1403
|
-
return __spreadProps(__spreadValues({}, node), { marks: (
|
|
1651
|
+
return __spreadProps(__spreadValues({}, node), { marks: (_a2 = node.marks) == null ? void 0 : _a2.map(copyMark) });
|
|
1404
1652
|
default:
|
|
1405
1653
|
return node;
|
|
1406
1654
|
}
|
|
1407
1655
|
}
|
|
1408
1656
|
function copyInline(inline) {
|
|
1409
|
-
var
|
|
1657
|
+
var _a2, _b;
|
|
1410
1658
|
switch (inline.type) {
|
|
1411
1659
|
case "link":
|
|
1412
1660
|
return __spreadProps(__spreadValues({}, inline), {
|
|
1413
|
-
nodes: (
|
|
1661
|
+
nodes: (_a2 = inline.nodes) == null ? void 0 : _a2.map(copyNode),
|
|
1414
1662
|
data: inline.data ? copyLinkData2(inline.data) : inline.data
|
|
1415
1663
|
});
|
|
1416
1664
|
default:
|
|
@@ -1418,7 +1666,7 @@ function copy$3(value, context) {
|
|
|
1418
1666
|
}
|
|
1419
1667
|
}
|
|
1420
1668
|
function copyLinkData2(data) {
|
|
1421
|
-
var
|
|
1669
|
+
var _a2, _b;
|
|
1422
1670
|
switch (data.type) {
|
|
1423
1671
|
case "OPEN_PAGE": {
|
|
1424
1672
|
const pageId = data.payload.pageId;
|
|
@@ -1426,7 +1674,7 @@ function copy$3(value, context) {
|
|
|
1426
1674
|
return data;
|
|
1427
1675
|
return __spreadProps(__spreadValues({}, data), {
|
|
1428
1676
|
payload: __spreadProps(__spreadValues({}, data.payload), {
|
|
1429
|
-
pageId: (
|
|
1677
|
+
pageId: (_a2 = context.replacementContext.pageIds.get(pageId)) != null ? _a2 : data.payload.pageId
|
|
1430
1678
|
})
|
|
1431
1679
|
});
|
|
1432
1680
|
}
|
|
@@ -1447,20 +1695,20 @@ function copy$3(value, context) {
|
|
|
1447
1695
|
}
|
|
1448
1696
|
}
|
|
1449
1697
|
function copyMark(mark) {
|
|
1450
|
-
var
|
|
1698
|
+
var _a2, _b, _c, _d;
|
|
1451
1699
|
switch (mark.type) {
|
|
1452
1700
|
case "typography": {
|
|
1453
|
-
const typographyId = (
|
|
1701
|
+
const typographyId = (_a2 = mark.data) == null ? void 0 : _a2.value.id;
|
|
1454
1702
|
return __spreadProps(__spreadValues({}, mark), {
|
|
1455
1703
|
data: __spreadProps(__spreadValues({}, mark.data), {
|
|
1456
1704
|
value: __spreadProps(__spreadValues({}, (_b = mark.data) == null ? void 0 : _b.value), {
|
|
1457
1705
|
id: (_c = context.replacementContext.typographyIds.get(typographyId)) != null ? _c : typographyId,
|
|
1458
1706
|
style: (_d = mark.data) == null ? void 0 : _d.value.style.map((override) => {
|
|
1459
|
-
var
|
|
1707
|
+
var _a3, _b2, _c2;
|
|
1460
1708
|
return __spreadProps(__spreadValues({}, override), {
|
|
1461
1709
|
value: __spreadProps(__spreadValues({}, override.value), {
|
|
1462
1710
|
color: override.value.color == null ? override.value.color : __spreadProps(__spreadValues({}, override.value.color), {
|
|
1463
|
-
swatchId: (_c2 = context.replacementContext.swatchIds.get((
|
|
1711
|
+
swatchId: (_c2 = context.replacementContext.swatchIds.get((_a3 = override.value.color) == null ? void 0 : _a3.swatchId)) != null ? _c2 : (_b2 = override.value.color) == null ? void 0 : _b2.swatchId
|
|
1464
1712
|
})
|
|
1465
1713
|
})
|
|
1466
1714
|
});
|
|
@@ -1611,8 +1859,8 @@ function copy$1(descriptor, value, context) {
|
|
|
1611
1859
|
function copyElementReference(value, context) {
|
|
1612
1860
|
return context.replacementContext.globalElementIds.get(value) || value;
|
|
1613
1861
|
}
|
|
1614
|
-
function copy(
|
|
1615
|
-
switch (
|
|
1862
|
+
function copy(definition, value, context) {
|
|
1863
|
+
switch (definition.type) {
|
|
1616
1864
|
case Types.Backgrounds:
|
|
1617
1865
|
case Types.Grid:
|
|
1618
1866
|
case Types.NavigationLinks:
|
|
@@ -1626,7 +1874,7 @@ function copy(definition2, value, context) {
|
|
|
1626
1874
|
case Types.Border:
|
|
1627
1875
|
case Types.RichText:
|
|
1628
1876
|
case Types.ElementID:
|
|
1629
|
-
return copy$1(
|
|
1877
|
+
return copy$1(definition, value, context);
|
|
1630
1878
|
case ColorControlType:
|
|
1631
1879
|
return copyColorData(value, context);
|
|
1632
1880
|
case ImageControlType:
|
|
@@ -1634,9 +1882,9 @@ function copy(definition2, value, context) {
|
|
|
1634
1882
|
case LinkControlType:
|
|
1635
1883
|
return copyLinkData(value, context);
|
|
1636
1884
|
case ShapeControlType:
|
|
1637
|
-
return copyShapeData(
|
|
1885
|
+
return copyShapeData(definition, value, context);
|
|
1638
1886
|
case ListControlType:
|
|
1639
|
-
return copyListData(
|
|
1887
|
+
return copyListData(definition, value, context);
|
|
1640
1888
|
case StyleControlType:
|
|
1641
1889
|
return copyStyleData(value, context);
|
|
1642
1890
|
case SlotControlType:
|
|
@@ -1645,17 +1893,62 @@ function copy(definition2, value, context) {
|
|
|
1645
1893
|
return value;
|
|
1646
1894
|
}
|
|
1647
1895
|
}
|
|
1648
|
-
function merge(
|
|
1649
|
-
switch (
|
|
1896
|
+
function merge(definition, a, b = a, context) {
|
|
1897
|
+
switch (definition.type) {
|
|
1650
1898
|
case SlotControlType:
|
|
1651
1899
|
return mergeSlotData(a, b, context);
|
|
1652
1900
|
default:
|
|
1653
1901
|
return b;
|
|
1654
1902
|
}
|
|
1655
1903
|
}
|
|
1656
|
-
const
|
|
1657
|
-
|
|
1658
|
-
|
|
1904
|
+
const isServer = typeof window === "undefined";
|
|
1905
|
+
const useInsertionEffectSpecifier = "useInsertionEffect";
|
|
1906
|
+
const useInsertionEffect = (_a = React__namespace[useInsertionEffectSpecifier]) != null ? _a : React__namespace.useLayoutEffect;
|
|
1907
|
+
function useStyle(style) {
|
|
1908
|
+
const serialized = serialize.serializeStyles([style], css.cache.registered);
|
|
1909
|
+
utils.registerStyles(css.cache, serialized, false);
|
|
1910
|
+
useInsertionEffect(() => {
|
|
1911
|
+
utils.insertStyles(css.cache, serialized, false);
|
|
1912
|
+
});
|
|
1913
|
+
if (isServer)
|
|
1914
|
+
utils.insertStyles(css.cache, serialized, false);
|
|
1915
|
+
return `${css.cache.key}-${serialized.name}`;
|
|
1916
|
+
}
|
|
1917
|
+
const StyleV2ControlType = "makeswift::controls::style-v2";
|
|
1918
|
+
const unstable_useStyleV2ClassName = useStyle;
|
|
1919
|
+
function unstable_StyleV2(config) {
|
|
1920
|
+
return { type: StyleV2ControlType, config };
|
|
1921
|
+
}
|
|
1922
|
+
const StyleV2ControlMessageType = {
|
|
1923
|
+
CHANGE_BOX_MODEL: "makeswift::controls::style::message::change-box-model",
|
|
1924
|
+
STYLE_V2_CONTROL_CHILD_CONTROL_MESSAGE: "makeswift::controls::style-v2::message::child-control-message"
|
|
1925
|
+
};
|
|
1926
|
+
class StyleV2Control extends PropController {
|
|
1927
|
+
constructor(send, descriptor) {
|
|
1928
|
+
super(send);
|
|
1929
|
+
__publicField(this, "control");
|
|
1930
|
+
this.control = createPropController(descriptor.config.type, (message) => {
|
|
1931
|
+
console.log("message you are supposed to be sending in styleV2 control", { message });
|
|
1932
|
+
this.send({
|
|
1933
|
+
type: StyleV2ControlMessageType.STYLE_V2_CONTROL_CHILD_CONTROL_MESSAGE,
|
|
1934
|
+
payload: { message }
|
|
1935
|
+
});
|
|
1936
|
+
});
|
|
1937
|
+
}
|
|
1938
|
+
changeBoxModel(boxModel) {
|
|
1939
|
+
this.send({ type: StyleV2ControlMessageType.CHANGE_BOX_MODEL, payload: { boxModel } });
|
|
1940
|
+
}
|
|
1941
|
+
recv(message) {
|
|
1942
|
+
switch (message.type) {
|
|
1943
|
+
case StyleV2ControlMessageType.STYLE_V2_CONTROL_CHILD_CONTROL_MESSAGE: {
|
|
1944
|
+
const control = this.control;
|
|
1945
|
+
if (control == null)
|
|
1946
|
+
return;
|
|
1947
|
+
const recv = control.recv;
|
|
1948
|
+
recv(message.payload.message);
|
|
1949
|
+
}
|
|
1950
|
+
}
|
|
1951
|
+
}
|
|
1659
1952
|
}
|
|
1660
1953
|
const ObjectType = {
|
|
1661
1954
|
Value: "value",
|
|
@@ -1694,698 +1987,22 @@ const InlineType = {
|
|
|
1694
1987
|
Code: "code",
|
|
1695
1988
|
SuperScript: "superscript",
|
|
1696
1989
|
SubScript: "subscript",
|
|
1697
|
-
Link: "link"
|
|
1698
|
-
};
|
|
1699
|
-
const BlockTextAlignment = {
|
|
1700
|
-
Left: "left",
|
|
1701
|
-
Center: "center",
|
|
1702
|
-
Right: "right",
|
|
1703
|
-
Justify: "justify"
|
|
1704
|
-
};
|
|
1705
|
-
const ElementUtils = {
|
|
1706
|
-
isRootBlock(node) {
|
|
1707
|
-
return slate.Element.isElement(node) && (slate.Element.isElementType(node, BlockType.Paragraph) || slate.Element.isElementType(node, BlockType.Heading1) || slate.Element.isElementType(node, BlockType.Heading2) || slate.Element.isElementType(node, BlockType.Heading3) || slate.Element.isElementType(node, BlockType.Heading3) || slate.Element.isElementType(node, BlockType.Heading4) || slate.Element.isElementType(node, BlockType.Heading5) || slate.Element.isElementType(node, BlockType.Heading6) || slate.Element.isElementType(node, BlockType.BlockQuote) || slate.Element.isElementType(node, BlockType.UnorderedList) || slate.Element.isElementType(node, BlockType.OrderedList) || slate.Element.isElementType(node, BlockType.Text) || slate.Element.isElementType(node, BlockType.Default));
|
|
1708
|
-
},
|
|
1709
|
-
isBlock(node) {
|
|
1710
|
-
return slate.Element.isElement(node) && (this.isRootBlock(node) || slate.Element.isElementType(node, BlockType.ListItem) || slate.Element.isElementType(node, BlockType.ListItemChild));
|
|
1711
|
-
},
|
|
1712
|
-
isInline(node) {
|
|
1713
|
-
return slate.Element.isElementType(node, InlineType.Code) || slate.Element.isElementType(node, InlineType.Link) || slate.Element.isElementType(node, InlineType.SubScript) || slate.Element.isElementType(node, InlineType.SuperScript);
|
|
1714
|
-
},
|
|
1715
|
-
isConvertibleToListTextNode(node) {
|
|
1716
|
-
return !this.isList(node) && !this.isListItem(node) && !this.isListItemChild(node);
|
|
1717
|
-
},
|
|
1718
|
-
isList(node) {
|
|
1719
|
-
return slate.Element.isElementType(node, BlockType.OrderedList) || slate.Element.isElementType(node, BlockType.UnorderedList);
|
|
1720
|
-
},
|
|
1721
|
-
isListItem(node) {
|
|
1722
|
-
return slate.Element.isElementType(node, BlockType.ListItem);
|
|
1723
|
-
},
|
|
1724
|
-
isListItemChild(node) {
|
|
1725
|
-
return slate.Element.isElementType(node, BlockType.ListItemChild);
|
|
1726
|
-
},
|
|
1727
|
-
createText() {
|
|
1728
|
-
return { text: "" };
|
|
1729
|
-
},
|
|
1730
|
-
createParagraph() {
|
|
1731
|
-
return {
|
|
1732
|
-
children: [this.createText()],
|
|
1733
|
-
type: BlockType.Paragraph
|
|
1734
|
-
};
|
|
1735
|
-
},
|
|
1736
|
-
createList(type = BlockType.UnorderedList) {
|
|
1737
|
-
return { children: [this.createText()], type };
|
|
1738
|
-
},
|
|
1739
|
-
createListItem() {
|
|
1740
|
-
return {
|
|
1741
|
-
children: [this.createListItemChild()],
|
|
1742
|
-
type: BlockType.ListItem
|
|
1743
|
-
};
|
|
1744
|
-
},
|
|
1745
|
-
createListItemChild() {
|
|
1746
|
-
return {
|
|
1747
|
-
children: [this.createText()],
|
|
1748
|
-
type: BlockType.ListItemChild
|
|
1749
|
-
};
|
|
1750
|
-
}
|
|
1751
|
-
};
|
|
1752
|
-
function unhangRange(editor, range) {
|
|
1753
|
-
let [start, end] = slate.Range.edges(range);
|
|
1754
|
-
if (start.offset !== 0 || end.offset !== 0 || slate.Range.isCollapsed(range)) {
|
|
1755
|
-
return range;
|
|
1756
|
-
}
|
|
1757
|
-
const endBlock = slate.Editor.above(editor, {
|
|
1758
|
-
at: end,
|
|
1759
|
-
match: (n) => slate.Element.isElement(n) && slate.Editor.isBlock(editor, n)
|
|
1760
|
-
});
|
|
1761
|
-
const blockPath = endBlock ? endBlock[1] : [];
|
|
1762
|
-
const first = slate.Editor.start(editor, start);
|
|
1763
|
-
const before = { anchor: first, focus: end };
|
|
1764
|
-
let skip = true;
|
|
1765
|
-
for (const [node, path] of slate.Editor.nodes(editor, {
|
|
1766
|
-
at: before,
|
|
1767
|
-
match: slate.Text.isText,
|
|
1768
|
-
reverse: true
|
|
1769
|
-
})) {
|
|
1770
|
-
if (skip) {
|
|
1771
|
-
skip = false;
|
|
1772
|
-
continue;
|
|
1773
|
-
}
|
|
1774
|
-
if (node.text !== "" || slate.Path.isBefore(path, blockPath)) {
|
|
1775
|
-
end = { path, offset: node.text.length };
|
|
1776
|
-
break;
|
|
1777
|
-
}
|
|
1778
|
-
}
|
|
1779
|
-
return { anchor: start, focus: end };
|
|
1780
|
-
}
|
|
1781
|
-
function getSelection(editor) {
|
|
1782
|
-
if (editor.selection)
|
|
1783
|
-
return unhangRange(editor, editor.selection);
|
|
1784
|
-
return {
|
|
1785
|
-
anchor: slate.Editor.start(editor, []),
|
|
1786
|
-
focus: slate.Editor.end(editor, [])
|
|
1787
|
-
};
|
|
1788
|
-
}
|
|
1789
|
-
function getBlocksInSelection(editor) {
|
|
1790
|
-
return Array.from(slate.Editor.nodes(editor, {
|
|
1791
|
-
at: getSelection(editor),
|
|
1792
|
-
match: (node) => ElementUtils.isRootBlock(node)
|
|
1793
|
-
})).filter((entry) => ElementUtils.isRootBlock(entry[0]));
|
|
1794
|
-
}
|
|
1795
|
-
function getActiveBlockType(editor) {
|
|
1796
|
-
var _a;
|
|
1797
|
-
const rootBlocks = getBlocksInSelection(editor).map(([node]) => node.type);
|
|
1798
|
-
return rootBlocks.reduce((a, b) => a === b ? b : null, (_a = rootBlocks.at(0)) != null ? _a : null);
|
|
1799
|
-
}
|
|
1800
|
-
function setBlockKeyForDevice(editor, breakpoints, deviceId, key, value, options) {
|
|
1801
|
-
var _a, _b;
|
|
1802
|
-
const at = (_a = options == null ? void 0 : options.at) != null ? _a : editor.selection;
|
|
1803
|
-
if (!at)
|
|
1804
|
-
return;
|
|
1805
|
-
const rootElements = getBlocksInSelection(editor);
|
|
1806
|
-
for (const [node, path] of rootElements) {
|
|
1807
|
-
if (ElementUtils.isBlock(node)) {
|
|
1808
|
-
const deviceValues = (_b = node[key]) != null ? _b : [];
|
|
1809
|
-
const currentDeviceValue = state_breakpoints.findBreakpointOverride(breakpoints, deviceValues, deviceId, (v) => v);
|
|
1810
|
-
const nextDeviceValue = __spreadProps(__spreadValues({}, currentDeviceValue), {
|
|
1811
|
-
deviceId,
|
|
1812
|
-
value
|
|
1813
|
-
});
|
|
1814
|
-
slate.Transforms.setNodes(editor, {
|
|
1815
|
-
[key]: [...deviceValues.filter((v) => v.deviceId !== deviceId), nextDeviceValue]
|
|
1816
|
-
}, { at: path });
|
|
1817
|
-
}
|
|
1818
|
-
}
|
|
1819
|
-
}
|
|
1820
|
-
function clearBlockKeyForDevice(editor, deviceId, key) {
|
|
1821
|
-
var _a;
|
|
1822
|
-
const rootElements = getBlocksInSelection(editor);
|
|
1823
|
-
for (const [node, path] of rootElements) {
|
|
1824
|
-
if (ElementUtils.isBlock(node)) {
|
|
1825
|
-
const deviceOverrides = (_a = node[key]) != null ? _a : [];
|
|
1826
|
-
slate.Transforms.setNodes(editor, {
|
|
1827
|
-
[key]: deviceOverrides.filter((v) => v.deviceId !== deviceId)
|
|
1828
|
-
}, { at: path });
|
|
1829
|
-
}
|
|
1830
|
-
}
|
|
1831
|
-
}
|
|
1832
|
-
function wrapInline(editor, inline) {
|
|
1833
|
-
slate.Transforms.wrapNodes(editor, inline, {
|
|
1834
|
-
at: getSelection(editor),
|
|
1835
|
-
split: true
|
|
1836
|
-
});
|
|
1837
|
-
}
|
|
1838
|
-
function unwrapInline(editor, type) {
|
|
1839
|
-
slate.Transforms.unwrapNodes(editor, {
|
|
1840
|
-
match: (node) => ElementUtils.isInline(node) && node.type === type,
|
|
1841
|
-
at: getSelection(editor)
|
|
1842
|
-
});
|
|
1843
|
-
}
|
|
1844
|
-
const EditorUtils = {
|
|
1845
|
-
getFirstAncestorList(editor, path) {
|
|
1846
|
-
try {
|
|
1847
|
-
const parentList = slate.Editor.above(editor, {
|
|
1848
|
-
at: path,
|
|
1849
|
-
match: (node) => ElementUtils.isList(node)
|
|
1850
|
-
});
|
|
1851
|
-
return parentList != null ? parentList : null;
|
|
1852
|
-
} catch (e) {
|
|
1853
|
-
return null;
|
|
1854
|
-
}
|
|
1855
|
-
},
|
|
1856
|
-
getFirstAncestorListItem(editor, path) {
|
|
1857
|
-
try {
|
|
1858
|
-
const parentListItem = slate.Editor.above(editor, {
|
|
1859
|
-
at: path,
|
|
1860
|
-
match: (node) => ElementUtils.isListItem(node)
|
|
1861
|
-
});
|
|
1862
|
-
return parentListItem != null ? parentListItem : null;
|
|
1863
|
-
} catch (e) {
|
|
1864
|
-
return null;
|
|
1865
|
-
}
|
|
1866
|
-
}
|
|
1867
|
-
};
|
|
1868
|
-
const LIST_ITEM_CHILD_POSITION = 0;
|
|
1869
|
-
const LIST_ITEM_LIST_POSITION = 1;
|
|
1870
|
-
function filterForSubtreeRoots(entries) {
|
|
1871
|
-
return entries.filter(([, nodePath]) => !slate.Path.ancestors(nodePath).some((ancestor) => {
|
|
1872
|
-
return entries.some(([, path]) => slate.Path.equals(path, ancestor));
|
|
1873
|
-
}));
|
|
1874
|
-
}
|
|
1875
|
-
function unwrapPath(editor, listItemPath) {
|
|
1876
|
-
const parentList = EditorUtils.getFirstAncestorList(editor, listItemPath);
|
|
1877
|
-
const listItemContainingParentList = EditorUtils.getFirstAncestorListItem(editor, listItemPath);
|
|
1878
|
-
if (!parentList || listItemContainingParentList)
|
|
1879
|
-
return;
|
|
1880
|
-
slate.Editor.withoutNormalizing(editor, () => {
|
|
1881
|
-
const listItemTextPath = [...listItemPath, LIST_ITEM_CHILD_POSITION];
|
|
1882
|
-
const listItemNestedListPath = [...listItemPath, LIST_ITEM_LIST_POSITION];
|
|
1883
|
-
if (slate.Node.has(editor, listItemNestedListPath)) {
|
|
1884
|
-
slate.Transforms.setNodes(editor, { type: parentList[0].type }, { at: listItemNestedListPath });
|
|
1885
|
-
slate.Transforms.liftNodes(editor, { at: listItemNestedListPath });
|
|
1886
|
-
slate.Transforms.liftNodes(editor, { at: slate.Path.next(listItemPath) });
|
|
1887
|
-
}
|
|
1888
|
-
if (slate.Node.has(editor, listItemTextPath)) {
|
|
1889
|
-
slate.Transforms.setNodes(editor, { type: BlockType.Paragraph }, {
|
|
1890
|
-
at: listItemTextPath
|
|
1891
|
-
});
|
|
1892
|
-
slate.Transforms.liftNodes(editor, { at: listItemTextPath });
|
|
1893
|
-
slate.Transforms.liftNodes(editor, { at: listItemPath });
|
|
1894
|
-
}
|
|
1895
|
-
});
|
|
1896
|
-
}
|
|
1897
|
-
function unwrapList(editor, options) {
|
|
1898
|
-
var _a;
|
|
1899
|
-
const at = (_a = options == null ? void 0 : options.at) != null ? _a : editor.selection;
|
|
1900
|
-
if (!at)
|
|
1901
|
-
return;
|
|
1902
|
-
const listItems = Array.from(slate.Editor.nodes(editor, {
|
|
1903
|
-
at,
|
|
1904
|
-
match: (node) => {
|
|
1905
|
-
return slate.Element.isElement(node) && ElementUtils.isListItem(node);
|
|
1906
|
-
}
|
|
1907
|
-
}));
|
|
1908
|
-
const subRoots = filterForSubtreeRoots(listItems);
|
|
1909
|
-
const refs = subRoots.map(([_, path]) => slate.Editor.pathRef(editor, path));
|
|
1910
|
-
refs.forEach((ref) => {
|
|
1911
|
-
if (ref.current) {
|
|
1912
|
-
unwrapPath(editor, ref.current);
|
|
1913
|
-
}
|
|
1914
|
-
ref.unref();
|
|
1915
|
-
});
|
|
1916
|
-
}
|
|
1917
|
-
function wrapList(editor, options = { type: BlockType.UnorderedList }) {
|
|
1918
|
-
var _a;
|
|
1919
|
-
const at = (_a = options.at) != null ? _a : editor.selection;
|
|
1920
|
-
if (!at)
|
|
1921
|
-
return;
|
|
1922
|
-
const nonListEntries = Array.from(slate.Editor.nodes(editor, {
|
|
1923
|
-
at,
|
|
1924
|
-
match: (node) => {
|
|
1925
|
-
return slate.Element.isElement(node) && ElementUtils.isConvertibleToListTextNode(node);
|
|
1926
|
-
}
|
|
1927
|
-
}));
|
|
1928
|
-
const refs = nonListEntries.map(([_, path]) => slate.Editor.pathRef(editor, path));
|
|
1929
|
-
refs.forEach((ref) => {
|
|
1930
|
-
const path = ref.current;
|
|
1931
|
-
if (path) {
|
|
1932
|
-
slate.Editor.withoutNormalizing(editor, () => {
|
|
1933
|
-
slate.Transforms.setNodes(editor, { type: BlockType.ListItemChild }, {
|
|
1934
|
-
at: path
|
|
1935
|
-
});
|
|
1936
|
-
slate.Transforms.wrapNodes(editor, ElementUtils.createListItem(), {
|
|
1937
|
-
match: (node) => ElementUtils.isListItemChild(node),
|
|
1938
|
-
at: path
|
|
1939
|
-
});
|
|
1940
|
-
slate.Transforms.wrapNodes(editor, ElementUtils.createList(options.type), {
|
|
1941
|
-
at: path
|
|
1942
|
-
});
|
|
1943
|
-
});
|
|
1944
|
-
}
|
|
1945
|
-
ref.unref();
|
|
1946
|
-
});
|
|
1947
|
-
}
|
|
1948
|
-
const LocationUtils = {
|
|
1949
|
-
getStartPath(location) {
|
|
1950
|
-
if (slate.Range.isRange(location))
|
|
1951
|
-
return slate.Range.start(location).path;
|
|
1952
|
-
if (slate.Point.isPoint(location))
|
|
1953
|
-
return location.path;
|
|
1954
|
-
return location;
|
|
1955
|
-
}
|
|
1956
|
-
};
|
|
1957
|
-
function getSelectedListItems(editor) {
|
|
1958
|
-
var _a, _b;
|
|
1959
|
-
if (!editor.selection)
|
|
1960
|
-
return [];
|
|
1961
|
-
const start = LocationUtils.getStartPath(editor.selection);
|
|
1962
|
-
const listItems = slate.Editor.nodes(editor, {
|
|
1963
|
-
at: editor.selection,
|
|
1964
|
-
match: (node) => ElementUtils.isListItem(node)
|
|
1965
|
-
});
|
|
1966
|
-
const firstAncestorPath = (_b = (_a = EditorUtils.getFirstAncestorListItem(editor, start)) == null ? void 0 : _a[1]) != null ? _b : [];
|
|
1967
|
-
return Array.from(listItems).filter((node) => slate.Path.isDescendant(start, node[1]) ? slate.Path.equals(node[1], firstAncestorPath) : !slate.Path.isAfter(start, node[1]));
|
|
1968
|
-
}
|
|
1969
|
-
function indentPath(editor, path) {
|
|
1970
|
-
const parent = slate.Node.parent(editor, path);
|
|
1971
|
-
if (!path || !slate.Path.hasPrevious(path) || !ElementUtils.isList(parent))
|
|
1972
|
-
return;
|
|
1973
|
-
const previosPath = slate.Path.previous(path);
|
|
1974
|
-
const previousChildListPath = [...previosPath, LIST_ITEM_LIST_POSITION];
|
|
1975
|
-
const previousHasChildList = slate.Node.has(editor, previousChildListPath);
|
|
1976
|
-
slate.Editor.withoutNormalizing(editor, () => {
|
|
1977
|
-
if (!previousHasChildList) {
|
|
1978
|
-
slate.Transforms.insertNodes(editor, ElementUtils.createList(parent.type), {
|
|
1979
|
-
at: previousChildListPath
|
|
1980
|
-
});
|
|
1981
|
-
}
|
|
1982
|
-
const previousChildList = slate.Node.get(editor, previousChildListPath);
|
|
1983
|
-
if (ElementUtils.isList(previousChildList)) {
|
|
1984
|
-
const index = previousHasChildList ? previousChildList.children.length : 0;
|
|
1985
|
-
slate.Transforms.moveNodes(editor, {
|
|
1986
|
-
at: path,
|
|
1987
|
-
to: [...previousChildListPath, index]
|
|
1988
|
-
});
|
|
1989
|
-
}
|
|
1990
|
-
});
|
|
1991
|
-
}
|
|
1992
|
-
function indent(editor) {
|
|
1993
|
-
if (!editor.selection)
|
|
1994
|
-
return;
|
|
1995
|
-
const listItems = getSelectedListItems(editor);
|
|
1996
|
-
const subRoots = filterForSubtreeRoots(listItems);
|
|
1997
|
-
const refs = subRoots.map(([_, path]) => slate.Editor.pathRef(editor, path));
|
|
1998
|
-
refs.forEach((ref) => {
|
|
1999
|
-
if (ref.current) {
|
|
2000
|
-
indentPath(editor, ref.current);
|
|
2001
|
-
}
|
|
2002
|
-
ref.unref();
|
|
2003
|
-
});
|
|
2004
|
-
}
|
|
2005
|
-
function dedentPath(editor, listItemPath) {
|
|
2006
|
-
const parentList = EditorUtils.getFirstAncestorList(editor, listItemPath);
|
|
2007
|
-
const listItemContainingParentList = EditorUtils.getFirstAncestorListItem(editor, listItemPath);
|
|
2008
|
-
if (!parentList || !listItemContainingParentList)
|
|
2009
|
-
return;
|
|
2010
|
-
const [parentListNode, parentListPath] = parentList;
|
|
2011
|
-
const [_, listItemContainingParentListPath] = listItemContainingParentList;
|
|
2012
|
-
const listItemPosition = listItemPath[listItemPath.length - 1];
|
|
2013
|
-
const previousSiblings = parentListNode.children.slice(0, listItemPosition);
|
|
2014
|
-
const nextSiblings = parentListNode.children.slice(listItemPosition + 1);
|
|
2015
|
-
slate.Editor.withoutNormalizing(editor, () => {
|
|
2016
|
-
nextSiblings.forEach(() => {
|
|
2017
|
-
const nextSiblingPath = [...parentListPath, listItemPosition + 1];
|
|
2018
|
-
indentPath(editor, nextSiblingPath);
|
|
2019
|
-
});
|
|
2020
|
-
slate.Transforms.moveNodes(editor, {
|
|
2021
|
-
at: listItemPath,
|
|
2022
|
-
to: slate.Path.next(listItemContainingParentListPath)
|
|
2023
|
-
});
|
|
2024
|
-
if (previousSiblings.length === 0) {
|
|
2025
|
-
slate.Transforms.removeNodes(editor, { at: parentListPath });
|
|
2026
|
-
}
|
|
2027
|
-
});
|
|
2028
|
-
}
|
|
2029
|
-
function dedent(editor) {
|
|
2030
|
-
if (!editor.selection)
|
|
2031
|
-
return;
|
|
2032
|
-
const listItems = getSelectedListItems(editor);
|
|
2033
|
-
const subRoots = filterForSubtreeRoots(listItems);
|
|
2034
|
-
const refs = subRoots.map(([_, path]) => slate.Editor.pathRef(editor, path));
|
|
2035
|
-
refs.forEach((ref) => {
|
|
2036
|
-
if (ref.current) {
|
|
2037
|
-
dedentPath(editor, ref.current);
|
|
2038
|
-
}
|
|
2039
|
-
ref.unref();
|
|
2040
|
-
});
|
|
2041
|
-
}
|
|
2042
|
-
function toggleList(editor, options = { type: BlockType.UnorderedList }) {
|
|
2043
|
-
var _a;
|
|
2044
|
-
const at = (_a = options.at) != null ? _a : editor.selection;
|
|
2045
|
-
if (at == null)
|
|
2046
|
-
return;
|
|
2047
|
-
const start = LocationUtils.getStartPath(at);
|
|
2048
|
-
const ancestorPath = slate.Path.ancestors(start).at(1);
|
|
2049
|
-
if (!ancestorPath || !slate.Node.has(editor, ancestorPath))
|
|
2050
|
-
return;
|
|
2051
|
-
const ancestor = slate.Node.get(editor, ancestorPath);
|
|
2052
|
-
if (!ElementUtils.isList(ancestor)) {
|
|
2053
|
-
return wrapList(editor, { type: options.type, at });
|
|
2054
|
-
}
|
|
2055
|
-
if (ancestor.type === options.type) {
|
|
2056
|
-
unwrapList(editor, { at });
|
|
2057
|
-
} else {
|
|
2058
|
-
slate.Transforms.setNodes(editor, { type: options.type }, { at: ancestorPath });
|
|
2059
|
-
}
|
|
2060
|
-
}
|
|
2061
|
-
const BlockActions = {
|
|
2062
|
-
setBlockKeyForDevice,
|
|
2063
|
-
clearBlockKeyForDevice,
|
|
2064
|
-
wrapInline,
|
|
2065
|
-
unwrapInline
|
|
2066
|
-
};
|
|
2067
|
-
const ListActions = {
|
|
2068
|
-
unwrapList,
|
|
2069
|
-
wrapList,
|
|
2070
|
-
indent,
|
|
2071
|
-
dedent,
|
|
2072
|
-
toggleList
|
|
2073
|
-
};
|
|
2074
|
-
function onKeyDown(e, editor) {
|
|
2075
|
-
if (!editor.selection || Array.from(slate.Editor.nodes(editor, { match: (node) => ElementUtils.isListItem(node) })).length === 0)
|
|
2076
|
-
return;
|
|
2077
|
-
if (isHotkey__default["default"]("shift+tab", e)) {
|
|
2078
|
-
e.preventDefault();
|
|
2079
|
-
ListActions.dedent(editor);
|
|
2080
|
-
}
|
|
2081
|
-
if (isHotkey__default["default"]("tab", e)) {
|
|
2082
|
-
e.preventDefault();
|
|
2083
|
-
ListActions.indent(editor);
|
|
2084
|
-
}
|
|
2085
|
-
if (isHotkey__default["default"]("backspace", e)) {
|
|
2086
|
-
if (!editor.selection)
|
|
2087
|
-
return;
|
|
2088
|
-
if (slate.Range.isExpanded(editor.selection))
|
|
2089
|
-
return;
|
|
2090
|
-
const listItem = EditorUtils.getFirstAncestorListItem(editor, editor.selection.anchor.path);
|
|
2091
|
-
if (editor.selection.anchor.offset === 0 && listItem) {
|
|
2092
|
-
e.preventDefault();
|
|
2093
|
-
const parentListItem = EditorUtils.getFirstAncestorListItem(editor, listItem[1]);
|
|
2094
|
-
const list = EditorUtils.getFirstAncestorList(editor, listItem[1]);
|
|
2095
|
-
if (parentListItem) {
|
|
2096
|
-
ListActions.dedent(editor);
|
|
2097
|
-
} else if (list) {
|
|
2098
|
-
ListActions.unwrapList(editor);
|
|
2099
|
-
}
|
|
2100
|
-
return;
|
|
2101
|
-
}
|
|
2102
|
-
}
|
|
2103
|
-
if (isHotkey__default["default"]("enter", e)) {
|
|
2104
|
-
e.preventDefault();
|
|
2105
|
-
if (!editor.selection)
|
|
2106
|
-
return;
|
|
2107
|
-
if (slate.Range.isExpanded(editor.selection)) {
|
|
2108
|
-
slate.Transforms.delete(editor);
|
|
2109
|
-
return;
|
|
2110
|
-
}
|
|
2111
|
-
const listItem = EditorUtils.getFirstAncestorListItem(editor, editor.selection.anchor.path);
|
|
2112
|
-
if (editor.selection.anchor.offset === 0 && listItem && slate.Editor.string(editor, listItem[1]) === "") {
|
|
2113
|
-
const parentListItem = EditorUtils.getFirstAncestorListItem(editor, listItem[1]);
|
|
2114
|
-
if (parentListItem) {
|
|
2115
|
-
ListActions.dedent(editor);
|
|
2116
|
-
} else {
|
|
2117
|
-
ListActions.unwrapList(editor);
|
|
2118
|
-
}
|
|
2119
|
-
return;
|
|
2120
|
-
}
|
|
2121
|
-
slate.Transforms.splitNodes(editor, {
|
|
2122
|
-
at: editor.selection,
|
|
2123
|
-
always: true,
|
|
2124
|
-
match: (node) => ElementUtils.isListItem(node)
|
|
2125
|
-
});
|
|
2126
|
-
}
|
|
2127
|
-
if (isHotkey__default["default"]("shift+enter", e)) {
|
|
2128
|
-
e.preventDefault();
|
|
2129
|
-
editor.insertText("\n");
|
|
2130
|
-
}
|
|
2131
|
-
}
|
|
2132
|
-
function withBlock(editor) {
|
|
2133
|
-
const { normalizeNode } = editor;
|
|
2134
|
-
editor.isInline = (entry) => {
|
|
2135
|
-
return ElementUtils.isInline(entry);
|
|
2136
|
-
};
|
|
2137
|
-
editor.normalizeNode = (entry) => {
|
|
2138
|
-
var _a;
|
|
2139
|
-
const [normalizationNode, normalizationPath] = entry;
|
|
2140
|
-
if (ElementUtils.isBlock(normalizationNode) && ((_a = normalizationNode == null ? void 0 : normalizationNode.textAlign) == null ? void 0 : _a.length) == 0) {
|
|
2141
|
-
slate.Transforms.unsetNodes(editor, "textAlign", { at: normalizationPath });
|
|
2142
|
-
return;
|
|
2143
|
-
}
|
|
2144
|
-
if (ElementUtils.isListItem(normalizationNode)) {
|
|
2145
|
-
const pathToListItemText = [...normalizationPath, LIST_ITEM_CHILD_POSITION];
|
|
2146
|
-
if (slate.Node.has(editor, pathToListItemText)) {
|
|
2147
|
-
const nodeInListItemTextPosition = slate.Node.get(editor, pathToListItemText);
|
|
2148
|
-
if (ElementUtils.isRootBlock(nodeInListItemTextPosition)) {
|
|
2149
|
-
slate.Transforms.setNodes(editor, { type: BlockType.ListItemChild }, {
|
|
2150
|
-
at: pathToListItemText
|
|
2151
|
-
});
|
|
2152
|
-
return;
|
|
2153
|
-
}
|
|
2154
|
-
} else {
|
|
2155
|
-
slate.Transforms.insertNodes(editor, ElementUtils.createListItem(), {
|
|
2156
|
-
at: pathToListItemText
|
|
2157
|
-
});
|
|
2158
|
-
return;
|
|
2159
|
-
}
|
|
2160
|
-
}
|
|
2161
|
-
if (!slate.Text.isText(normalizationNode)) {
|
|
2162
|
-
const mergeableChildren = Array.from(slate.Node.children(editor, normalizationPath)).map((child, index, children) => {
|
|
2163
|
-
const potentialNodeToBeMerged = children.at(index + 1);
|
|
2164
|
-
if (!potentialNodeToBeMerged || !ElementUtils.isList(potentialNodeToBeMerged[0]) || !ElementUtils.isList(child[0]) || potentialNodeToBeMerged[0].type !== child[0].type) {
|
|
2165
|
-
return null;
|
|
2166
|
-
}
|
|
2167
|
-
return [
|
|
2168
|
-
slate.Editor.pathRef(editor, child[1]),
|
|
2169
|
-
slate.Editor.pathRef(editor, potentialNodeToBeMerged[1])
|
|
2170
|
-
];
|
|
2171
|
-
}).filter((mergeableNodes) => Boolean(mergeableNodes));
|
|
2172
|
-
if (mergeableChildren.length !== 0) {
|
|
2173
|
-
mergeableChildren.reverse().forEach(([nodePathRef, nodeToBeMergedPathRef]) => {
|
|
2174
|
-
const nodePath = nodePathRef.current;
|
|
2175
|
-
const nodeToBeMergedPath = nodeToBeMergedPathRef.current;
|
|
2176
|
-
if (nodePath == null || nodeToBeMergedPath == null)
|
|
2177
|
-
return;
|
|
2178
|
-
const nodeChildren = Array.from(slate.Node.children(editor, nodePath));
|
|
2179
|
-
const childrenToBeMerged = Array.from(slate.Node.children(editor, nodeToBeMergedPath));
|
|
2180
|
-
slate.Editor.withoutNormalizing(editor, () => {
|
|
2181
|
-
childrenToBeMerged.reverse().forEach(([_, childPath]) => {
|
|
2182
|
-
slate.Transforms.moveNodes(editor, {
|
|
2183
|
-
at: childPath,
|
|
2184
|
-
to: [...nodePath, nodeChildren.length]
|
|
2185
|
-
});
|
|
2186
|
-
});
|
|
2187
|
-
slate.Transforms.removeNodes(editor, { at: nodeToBeMergedPath });
|
|
2188
|
-
});
|
|
2189
|
-
nodePathRef.unref();
|
|
2190
|
-
nodeToBeMergedPathRef.unref();
|
|
2191
|
-
});
|
|
2192
|
-
return;
|
|
2193
|
-
}
|
|
2194
|
-
}
|
|
2195
|
-
normalizeNode(entry);
|
|
2196
|
-
};
|
|
2197
|
-
return editor;
|
|
2198
|
-
}
|
|
2199
|
-
const definition = Select({
|
|
2200
|
-
label: "Block",
|
|
2201
|
-
labelOrientation: "horizontal",
|
|
2202
|
-
options: [
|
|
2203
|
-
{
|
|
2204
|
-
value: BlockType.Paragraph,
|
|
2205
|
-
label: "Paragraph"
|
|
2206
|
-
},
|
|
2207
|
-
{
|
|
2208
|
-
value: BlockType.Heading1,
|
|
2209
|
-
label: "Heading 1"
|
|
2210
|
-
},
|
|
2211
|
-
{
|
|
2212
|
-
value: BlockType.Heading2,
|
|
2213
|
-
label: "Heading 2"
|
|
2214
|
-
},
|
|
2215
|
-
{
|
|
2216
|
-
value: BlockType.Heading3,
|
|
2217
|
-
label: "Heading 3"
|
|
2218
|
-
},
|
|
2219
|
-
{
|
|
2220
|
-
value: BlockType.Heading4,
|
|
2221
|
-
label: "Heading 4"
|
|
2222
|
-
},
|
|
2223
|
-
{
|
|
2224
|
-
value: BlockType.Heading5,
|
|
2225
|
-
label: "Heading 5"
|
|
2226
|
-
},
|
|
2227
|
-
{
|
|
2228
|
-
value: BlockType.Heading6,
|
|
2229
|
-
label: "Heading 6"
|
|
2230
|
-
},
|
|
2231
|
-
{
|
|
2232
|
-
value: BlockType.UnorderedList,
|
|
2233
|
-
label: "Bulleted list"
|
|
2234
|
-
},
|
|
2235
|
-
{
|
|
2236
|
-
value: BlockType.OrderedList,
|
|
2237
|
-
label: "Numbered list"
|
|
2238
|
-
},
|
|
2239
|
-
{
|
|
2240
|
-
value: BlockType.BlockQuote,
|
|
2241
|
-
label: "Quote"
|
|
2242
|
-
}
|
|
2243
|
-
],
|
|
2244
|
-
defaultValue: BlockType.Paragraph
|
|
2245
|
-
});
|
|
2246
|
-
function BlockPlugin() {
|
|
2247
|
-
return createRichTextV2Plugin({
|
|
2248
|
-
withPlugin: withBlock,
|
|
2249
|
-
onKeyDown,
|
|
2250
|
-
control: {
|
|
2251
|
-
definition,
|
|
2252
|
-
onChange: (editor, value) => {
|
|
2253
|
-
const activeBlockType = getActiveBlockType(editor);
|
|
2254
|
-
if (value === BlockType.UnorderedList || value === BlockType.OrderedList) {
|
|
2255
|
-
ListActions.toggleList(editor, {
|
|
2256
|
-
type: value,
|
|
2257
|
-
at: getSelection(editor)
|
|
2258
|
-
});
|
|
2259
|
-
} else if (activeBlockType === value) {
|
|
2260
|
-
slate.Transforms.setNodes(editor, {
|
|
2261
|
-
type: BlockType.Default
|
|
2262
|
-
}, { at: getSelection(editor) });
|
|
2263
|
-
} else {
|
|
2264
|
-
ListActions.unwrapList(editor, {
|
|
2265
|
-
at: getSelection(editor)
|
|
2266
|
-
});
|
|
2267
|
-
slate.Transforms.setNodes(editor, {
|
|
2268
|
-
type: value != null ? value : BlockType.Default
|
|
2269
|
-
}, { at: getSelection(editor) });
|
|
2270
|
-
}
|
|
2271
|
-
},
|
|
2272
|
-
getValue: (editor) => {
|
|
2273
|
-
const activeBlock = getActiveBlockType(editor);
|
|
2274
|
-
if (activeBlock === RootBlockType.Text || activeBlock === RootBlockType.Default)
|
|
2275
|
-
return void 0;
|
|
2276
|
-
return activeBlock;
|
|
2277
|
-
}
|
|
2278
|
-
}
|
|
2279
|
-
});
|
|
2280
|
-
}
|
|
2281
|
-
const RichTextV2ControlType = "makeswift::controls::rich-text-v2";
|
|
2282
|
-
const RichTextV2Mode = {
|
|
2283
|
-
Inline: "makeswift::controls::rich-text-v2::mode::inline",
|
|
2284
|
-
Block: "makeswift::controls::rich-text-v2::mode::block"
|
|
2285
|
-
};
|
|
2286
|
-
function createRichTextV2Plugin({
|
|
2287
|
-
control,
|
|
2288
|
-
withPlugin,
|
|
2289
|
-
onKeyDown: onKeyDown2
|
|
2290
|
-
}) {
|
|
2291
|
-
return { control, withPlugin, onKeyDown: onKeyDown2 };
|
|
2292
|
-
}
|
|
2293
|
-
function unstable_RichTextV2(config = {}) {
|
|
2294
|
-
return { type: RichTextV2ControlType, config };
|
|
2295
|
-
}
|
|
2296
|
-
const RichTextV2ControlMessageType = {
|
|
2297
|
-
RESET_VALUE: "RESET_VALUE",
|
|
2298
|
-
FOCUS: "FOCUS",
|
|
2299
|
-
RUN_PLUGIN_CONTROL_ACTION: "RUN_PLUGIN_CONTROL_ACTION",
|
|
2300
|
-
SET_DEFAULT_VALUE: "SET_DEFAULT_VALUE",
|
|
2301
|
-
SET_PLUGIN_CONTROL_VALUE: "SET_PLUGIN_CONTROL_VALUE",
|
|
2302
|
-
ON_CHANGE: "ON_CHANGE",
|
|
2303
|
-
SELECT: "SELECT",
|
|
2304
|
-
SWITCH_TO_BUILD_MODE: "SWITCH_TO_BUILD_MODE",
|
|
2305
|
-
CHANGE_BOX_MODEL: "CHANGE_BOX_MODEL"
|
|
2306
|
-
};
|
|
2307
|
-
class RichTextV2Control extends PropController {
|
|
2308
|
-
constructor(send, descriptor) {
|
|
2309
|
-
super(send);
|
|
2310
|
-
__publicField(this, "editor", null);
|
|
2311
|
-
__publicField(this, "defaultValue", null);
|
|
2312
|
-
__publicField(this, "descriptor");
|
|
2313
|
-
__publicField(this, "recv", (message) => {
|
|
2314
|
-
var _a, _b, _c;
|
|
2315
|
-
if (!this.editor)
|
|
2316
|
-
return;
|
|
2317
|
-
switch (message.type) {
|
|
2318
|
-
case RichTextV2ControlMessageType.FOCUS: {
|
|
2319
|
-
this.editor.focusAndSelectAll();
|
|
2320
|
-
break;
|
|
2321
|
-
}
|
|
2322
|
-
case RichTextV2ControlMessageType.RESET_VALUE: {
|
|
2323
|
-
if (this.defaultValue) {
|
|
2324
|
-
this.editor.selection = null;
|
|
2325
|
-
this.editor.children = this.defaultValue;
|
|
2326
|
-
this.editor.onChange();
|
|
2327
|
-
}
|
|
2328
|
-
break;
|
|
2329
|
-
}
|
|
2330
|
-
case RichTextV2ControlMessageType.RUN_PLUGIN_CONTROL_ACTION: {
|
|
2331
|
-
(_c = (_b = (_a = this.descriptor.config.plugins) == null ? void 0 : _a.at(message.pluginIndex)) == null ? void 0 : _b.control) == null ? void 0 : _c.onChange(this.editor, message.value);
|
|
2332
|
-
break;
|
|
2333
|
-
}
|
|
2334
|
-
}
|
|
2335
|
-
});
|
|
2336
|
-
this.descriptor = descriptor;
|
|
2337
|
-
this.send = send;
|
|
2338
|
-
}
|
|
2339
|
-
setEditor(editor) {
|
|
2340
|
-
var _a, _b, _c;
|
|
2341
|
-
this.editor = editor;
|
|
2342
|
-
this.send({
|
|
2343
|
-
type: RichTextV2ControlMessageType.SET_PLUGIN_CONTROL_VALUE,
|
|
2344
|
-
value: (_c = (_b = (_a = this.descriptor.config) == null ? void 0 : _a.plugins) == null ? void 0 : _b.map((plugin) => {
|
|
2345
|
-
var _a2;
|
|
2346
|
-
return (_a2 = plugin == null ? void 0 : plugin.control) == null ? void 0 : _a2.getValue(editor);
|
|
2347
|
-
})) != null ? _c : []
|
|
2348
|
-
});
|
|
2349
|
-
}
|
|
2350
|
-
setDefaultValue(defaultValue) {
|
|
2351
|
-
this.defaultValue = defaultValue;
|
|
2352
|
-
this.send({ type: RichTextV2ControlMessageType.SET_DEFAULT_VALUE, value: defaultValue });
|
|
2353
|
-
}
|
|
2354
|
-
select() {
|
|
2355
|
-
this.send({ type: RichTextV2ControlMessageType.SELECT });
|
|
2356
|
-
}
|
|
2357
|
-
switchToBuildMode() {
|
|
2358
|
-
this.send({ type: RichTextV2ControlMessageType.SWITCH_TO_BUILD_MODE });
|
|
2359
|
-
}
|
|
2360
|
-
onChange(value) {
|
|
2361
|
-
var _a, _b, _c;
|
|
2362
|
-
const editor = this.editor;
|
|
2363
|
-
if (editor == null)
|
|
2364
|
-
return;
|
|
2365
|
-
this.send({
|
|
2366
|
-
type: RichTextV2ControlMessageType.ON_CHANGE,
|
|
2367
|
-
value
|
|
2368
|
-
});
|
|
2369
|
-
this.send({
|
|
2370
|
-
type: RichTextV2ControlMessageType.SET_PLUGIN_CONTROL_VALUE,
|
|
2371
|
-
value: (_c = (_b = (_a = this.descriptor.config) == null ? void 0 : _a.plugins) == null ? void 0 : _b.map((plugin) => {
|
|
2372
|
-
var _a2;
|
|
2373
|
-
return (_a2 = plugin == null ? void 0 : plugin.control) == null ? void 0 : _a2.getValue(editor);
|
|
2374
|
-
})) != null ? _c : []
|
|
2375
|
-
});
|
|
2376
|
-
}
|
|
2377
|
-
changeBoxModel(boxModel) {
|
|
2378
|
-
this.send({ type: RichTextV2ControlMessageType.CHANGE_BOX_MODEL, payload: { boxModel } });
|
|
2379
|
-
}
|
|
2380
|
-
}
|
|
1990
|
+
Link: "link"
|
|
1991
|
+
};
|
|
1992
|
+
const BlockTextAlignment = {
|
|
1993
|
+
Left: "left",
|
|
1994
|
+
Center: "center",
|
|
1995
|
+
Right: "right",
|
|
1996
|
+
Justify: "justify"
|
|
1997
|
+
};
|
|
2381
1998
|
function isText(node) {
|
|
2382
1999
|
if (typeof node === "object" && "text" in node)
|
|
2383
2000
|
return true;
|
|
2384
2001
|
return false;
|
|
2385
2002
|
}
|
|
2386
2003
|
function toTextDAO(node) {
|
|
2387
|
-
var
|
|
2388
|
-
const typographyMark = (
|
|
2004
|
+
var _a2, _b, _c, _d;
|
|
2005
|
+
const typographyMark = (_a2 = node.marks) == null ? void 0 : _a2.find((mark) => mark.type === "typography");
|
|
2389
2006
|
return [
|
|
2390
2007
|
{
|
|
2391
2008
|
text: (_b = node.text) != null ? _b : "",
|
|
@@ -2394,12 +2011,12 @@ function toTextDAO(node) {
|
|
|
2394
2011
|
];
|
|
2395
2012
|
}
|
|
2396
2013
|
function toInlineDAO(node) {
|
|
2397
|
-
var
|
|
2014
|
+
var _a2, _b, _c, _d;
|
|
2398
2015
|
switch (node.type) {
|
|
2399
2016
|
case InlineType.Link:
|
|
2400
2017
|
return [
|
|
2401
2018
|
{
|
|
2402
|
-
children: (_b = (
|
|
2019
|
+
children: (_b = (_a2 = node.nodes) == null ? void 0 : _a2.flatMap(toInlineOrTextDAO)) != null ? _b : [],
|
|
2403
2020
|
[node.type]: node.data,
|
|
2404
2021
|
type: node.type
|
|
2405
2022
|
}
|
|
@@ -2428,7 +2045,7 @@ function toInlineOrTextDAO(node) {
|
|
|
2428
2045
|
}
|
|
2429
2046
|
}
|
|
2430
2047
|
function toNodeDAO(node) {
|
|
2431
|
-
var
|
|
2048
|
+
var _a2, _b;
|
|
2432
2049
|
switch (node.object) {
|
|
2433
2050
|
case ObjectType.Inline:
|
|
2434
2051
|
case ObjectType.Text:
|
|
@@ -2438,7 +2055,7 @@ function toNodeDAO(node) {
|
|
|
2438
2055
|
{
|
|
2439
2056
|
type: node.type,
|
|
2440
2057
|
textAlign: (node == null ? void 0 : node.data) && "textAlign" in node.data ? node == null ? void 0 : node.data.textAlign : void 0,
|
|
2441
|
-
children: (_b = (
|
|
2058
|
+
children: (_b = (_a2 = node.nodes) == null ? void 0 : _a2.flatMap(toNodeDAO)) != null ? _b : []
|
|
2442
2059
|
}
|
|
2443
2060
|
];
|
|
2444
2061
|
default:
|
|
@@ -2446,8 +2063,8 @@ function toNodeDAO(node) {
|
|
|
2446
2063
|
}
|
|
2447
2064
|
}
|
|
2448
2065
|
function richTextDTOtoSelection(data) {
|
|
2449
|
-
var
|
|
2450
|
-
if (((_b = (
|
|
2066
|
+
var _a2, _b, _c, _d;
|
|
2067
|
+
if (((_b = (_a2 = data.selection) == null ? void 0 : _a2.anchor) == null ? void 0 : _b.offset) != null && data.selection.anchor.path != null && ((_d = (_c = data.selection) == null ? void 0 : _c.focus) == null ? void 0 : _d.offset) != null && data.selection.focus.path != null)
|
|
2451
2068
|
return {
|
|
2452
2069
|
anchor: {
|
|
2453
2070
|
offset: data.selection.anchor.offset,
|
|
@@ -2461,8 +2078,8 @@ function richTextDTOtoSelection(data) {
|
|
|
2461
2078
|
return null;
|
|
2462
2079
|
}
|
|
2463
2080
|
function richTextDTOtoDAO(data) {
|
|
2464
|
-
var
|
|
2465
|
-
return (_c = (_b = (
|
|
2081
|
+
var _a2, _b, _c;
|
|
2082
|
+
return (_c = (_b = (_a2 = data.document) == null ? void 0 : _a2.nodes) == null ? void 0 : _b.flatMap(toNodeDAO)) != null ? _c : [];
|
|
2466
2083
|
}
|
|
2467
2084
|
function toInlineOrTextDTO(node) {
|
|
2468
2085
|
if (isText(node)) {
|
|
@@ -2506,7 +2123,7 @@ function toInlineOrTextDTO(node) {
|
|
|
2506
2123
|
}
|
|
2507
2124
|
}
|
|
2508
2125
|
function toNodeDTO(node) {
|
|
2509
|
-
var
|
|
2126
|
+
var _a2, _b;
|
|
2510
2127
|
if (isText(node))
|
|
2511
2128
|
return toInlineOrTextDTO(node);
|
|
2512
2129
|
switch (node.type) {
|
|
@@ -2531,7 +2148,7 @@ function toNodeDTO(node) {
|
|
|
2531
2148
|
textAlign: node.textAlign
|
|
2532
2149
|
} : {},
|
|
2533
2150
|
object: "block",
|
|
2534
|
-
nodes: (_b = (
|
|
2151
|
+
nodes: (_b = (_a2 = node.children) == null ? void 0 : _a2.flatMap(toNodeDTO)) != null ? _b : []
|
|
2535
2152
|
}
|
|
2536
2153
|
];
|
|
2537
2154
|
default:
|
|
@@ -2539,330 +2156,209 @@ function toNodeDTO(node) {
|
|
|
2539
2156
|
}
|
|
2540
2157
|
}
|
|
2541
2158
|
function toSelectionDTO(selection) {
|
|
2542
|
-
if (selection == null)
|
|
2543
|
-
return void 0;
|
|
2544
|
-
return {
|
|
2545
|
-
isFocused: false,
|
|
2546
|
-
marks: void 0,
|
|
2547
|
-
object: "selection",
|
|
2548
|
-
anchor: {
|
|
2549
|
-
offset: selection.anchor.offset,
|
|
2550
|
-
path: selection.anchor.path,
|
|
2551
|
-
object: "point"
|
|
2552
|
-
},
|
|
2553
|
-
focus: {
|
|
2554
|
-
offset: selection.focus.offset,
|
|
2555
|
-
path: selection.focus.path,
|
|
2556
|
-
object: "point"
|
|
2557
|
-
}
|
|
2558
|
-
};
|
|
2559
|
-
}
|
|
2560
|
-
function richTextDAOToDTO(children, selection) {
|
|
2561
|
-
return {
|
|
2562
|
-
document: {
|
|
2563
|
-
data: void 0,
|
|
2564
|
-
nodes: children.flatMap(toNodeDTO),
|
|
2565
|
-
object: "document"
|
|
2566
|
-
},
|
|
2567
|
-
object: "value",
|
|
2568
|
-
selection: toSelectionDTO(selection),
|
|
2569
|
-
annotations: void 0,
|
|
2570
|
-
data: void 0
|
|
2571
|
-
};
|
|
2572
|
-
}
|
|
2573
|
-
const RichTextControlType = "makeswift::controls::rich-text";
|
|
2574
|
-
function RichText$1() {
|
|
2575
|
-
return { type: RichTextControlType };
|
|
2576
|
-
}
|
|
2577
|
-
const RichTextControlMessageType = {
|
|
2578
|
-
CHANGE_BUILDER_EDIT_MODE: "CHANGE_BUILDER_EDIT_MODE",
|
|
2579
|
-
INITIALIZE_EDITOR: "INITIALIZE_EDITOR",
|
|
2580
|
-
CHANGE_EDITOR_VALUE: "CHANGE_EDITOR_VALUE",
|
|
2581
|
-
FOCUS: "FOCUS",
|
|
2582
|
-
BLUR: "BLUR",
|
|
2583
|
-
UNDO: "UNDO",
|
|
2584
|
-
REDO: "REDO",
|
|
2585
|
-
CHANGE_BOX_MODEL: "CHANGE_BOX_MODEL"
|
|
2586
|
-
};
|
|
2587
|
-
class RichTextControl extends PropController {
|
|
2588
|
-
constructor() {
|
|
2589
|
-
super(...arguments);
|
|
2590
|
-
__publicField(this, "editor", null);
|
|
2591
|
-
__publicField(this, "recv", (message) => {
|
|
2592
|
-
if (!this.editor)
|
|
2593
|
-
return;
|
|
2594
|
-
switch (message.type) {
|
|
2595
|
-
case RichTextControlMessageType.CHANGE_BUILDER_EDIT_MODE: {
|
|
2596
|
-
switch (message.editMode) {
|
|
2597
|
-
case BuilderEditMode.BUILD:
|
|
2598
|
-
case BuilderEditMode.INTERACT:
|
|
2599
|
-
this.editor.deselectAndBlur();
|
|
2600
|
-
}
|
|
2601
|
-
break;
|
|
2602
|
-
}
|
|
2603
|
-
case RichTextControlMessageType.FOCUS: {
|
|
2604
|
-
this.editor.focusAndSelectAll();
|
|
2605
|
-
break;
|
|
2606
|
-
}
|
|
2607
|
-
}
|
|
2608
|
-
});
|
|
2609
|
-
}
|
|
2610
|
-
setSlateEditor(editor) {
|
|
2611
|
-
this.editor = editor;
|
|
2612
|
-
this.send({
|
|
2613
|
-
type: RichTextControlMessageType.INITIALIZE_EDITOR,
|
|
2614
|
-
value: richTextDAOToDTO(editor.children, editor.selection)
|
|
2615
|
-
});
|
|
2616
|
-
const _onChange = editor.onChange;
|
|
2617
|
-
this.editor.onChange = (options) => {
|
|
2618
|
-
_onChange(options);
|
|
2619
|
-
if ((options == null ? void 0 : options.operation) != null) {
|
|
2620
|
-
this.send({
|
|
2621
|
-
type: RichTextControlMessageType.CHANGE_EDITOR_VALUE,
|
|
2622
|
-
value: richTextDAOToDTO(editor.children, editor.selection)
|
|
2623
|
-
});
|
|
2624
|
-
}
|
|
2625
|
-
};
|
|
2626
|
-
}
|
|
2627
|
-
focus() {
|
|
2628
|
-
this.send({ type: RichTextControlMessageType.FOCUS });
|
|
2629
|
-
}
|
|
2630
|
-
blur() {
|
|
2631
|
-
this.send({ type: RichTextControlMessageType.BLUR });
|
|
2632
|
-
}
|
|
2633
|
-
undo() {
|
|
2634
|
-
this.send({ type: RichTextControlMessageType.UNDO });
|
|
2635
|
-
}
|
|
2636
|
-
redo() {
|
|
2637
|
-
this.send({ type: RichTextControlMessageType.REDO });
|
|
2638
|
-
}
|
|
2639
|
-
changeBoxModel(boxModel) {
|
|
2640
|
-
this.send({ type: RichTextControlMessageType.CHANGE_BOX_MODEL, payload: { boxModel } });
|
|
2641
|
-
}
|
|
2642
|
-
}
|
|
2643
|
-
const Types = {
|
|
2644
|
-
Backgrounds: "Backgrounds",
|
|
2645
|
-
Border: "Border",
|
|
2646
|
-
BorderRadius: "BorderRadius",
|
|
2647
|
-
Checkbox: "Checkbox",
|
|
2648
|
-
Date: "Date",
|
|
2649
|
-
ElementID: "ElementID",
|
|
2650
|
-
Font: "Font",
|
|
2651
|
-
GapX: "GapX",
|
|
2652
|
-
GapY: "GapY",
|
|
2653
|
-
Grid: "Grid",
|
|
2654
|
-
Image: "Image",
|
|
2655
|
-
Images: "Images",
|
|
2656
|
-
Link: "Link",
|
|
2657
|
-
List: "List",
|
|
2658
|
-
Margin: "Margin",
|
|
2659
|
-
NavigationLinks: "NavigationLinks",
|
|
2660
|
-
Number: "Number",
|
|
2661
|
-
Padding: "Padding",
|
|
2662
|
-
ResponsiveColor: "ResponsiveColor",
|
|
2663
|
-
ResponsiveIconRadioGroup: "ResponsiveIconRadioGroup",
|
|
2664
|
-
ResponsiveLength: "ResponsiveLength",
|
|
2665
|
-
ResponsiveNumber: "ResponsiveNumber",
|
|
2666
|
-
ResponsiveOpacity: "ResponsiveOpacity",
|
|
2667
|
-
ResponsiveSelect: "ResponsiveSelect",
|
|
2668
|
-
RichText: "RichText",
|
|
2669
|
-
Shadows: "Shadows",
|
|
2670
|
-
Shape: "Shape",
|
|
2671
|
-
SocialLinks: "SocialLinks",
|
|
2672
|
-
Table: "Table",
|
|
2673
|
-
TableFormFields: "TableFormFields",
|
|
2674
|
-
Typeahead: "Typeahead",
|
|
2675
|
-
TextArea: "TextArea",
|
|
2676
|
-
TextInput: "TextInput",
|
|
2677
|
-
TextStyle: "TextStyle",
|
|
2678
|
-
Video: "Video",
|
|
2679
|
-
Width: "Width",
|
|
2680
|
-
Style: StyleControlType
|
|
2681
|
-
};
|
|
2682
|
-
function Backgrounds(options = {}) {
|
|
2683
|
-
return { type: Types.Backgrounds, options };
|
|
2684
|
-
}
|
|
2685
|
-
const BorderPropControllerFormat = {
|
|
2686
|
-
ClassName: "makeswift::prop-controllers::border::format::class-name",
|
|
2687
|
-
ResponsiveValue: "makeswift::prop-controllers:border::format::responsive-value"
|
|
2688
|
-
};
|
|
2689
|
-
function Border(options = {}) {
|
|
2690
|
-
return { type: Types.Border, options };
|
|
2691
|
-
}
|
|
2692
|
-
Border.Format = BorderPropControllerFormat;
|
|
2693
|
-
const BorderRadiusPropControllerFormat = {
|
|
2694
|
-
ClassName: "makeswift::prop-controllers::border-radius::format::class-name",
|
|
2695
|
-
ResponsiveValue: "makeswift::prop-controllers::border-radius::format::responsive-value"
|
|
2696
|
-
};
|
|
2697
|
-
function BorderRadius(options = {}) {
|
|
2698
|
-
return { type: Types.BorderRadius, options };
|
|
2699
|
-
}
|
|
2700
|
-
BorderRadius.Format = BorderRadiusPropControllerFormat;
|
|
2701
|
-
function Checkbox(options) {
|
|
2702
|
-
return { type: Types.Checkbox, options };
|
|
2703
|
-
}
|
|
2704
|
-
function Date(options = {}) {
|
|
2705
|
-
return { type: Types.Date, options };
|
|
2706
|
-
}
|
|
2707
|
-
function ElementID(options = {}) {
|
|
2708
|
-
return { type: Types.ElementID, options };
|
|
2709
|
-
}
|
|
2710
|
-
function Font(options = {}) {
|
|
2711
|
-
return { type: Types.Font, options };
|
|
2712
|
-
}
|
|
2713
|
-
function GapX(options = {}) {
|
|
2714
|
-
return { type: Types.GapX, options };
|
|
2715
|
-
}
|
|
2716
|
-
function GapY(options = {}) {
|
|
2717
|
-
return { type: Types.GapY, options };
|
|
2718
|
-
}
|
|
2719
|
-
function Grid(options = {}) {
|
|
2720
|
-
return { type: Types.Grid, options };
|
|
2721
|
-
}
|
|
2722
|
-
function Image(options = {}) {
|
|
2723
|
-
return { type: Types.Image, options };
|
|
2724
|
-
}
|
|
2725
|
-
function Images(options = {}) {
|
|
2726
|
-
return { type: Types.Images, options };
|
|
2727
|
-
}
|
|
2728
|
-
function Link(options = {}) {
|
|
2729
|
-
return { type: Types.Link, options };
|
|
2730
|
-
}
|
|
2731
|
-
function List(options) {
|
|
2732
|
-
return { type: Types.List, options };
|
|
2733
|
-
}
|
|
2734
|
-
const MarginPropControllerFormat = {
|
|
2735
|
-
ClassName: "makeswift::prop-controllers::margin::format::class-name",
|
|
2736
|
-
ResponsiveValue: "makeswift::prop-controllers::margin::format::responsive-value"
|
|
2737
|
-
};
|
|
2738
|
-
function Margin(options = {}) {
|
|
2739
|
-
return { type: Types.Margin, options };
|
|
2740
|
-
}
|
|
2741
|
-
Margin.Format = MarginPropControllerFormat;
|
|
2742
|
-
function NavigationLinks(options = {}) {
|
|
2743
|
-
return { type: Types.NavigationLinks, options };
|
|
2744
|
-
}
|
|
2745
|
-
function Number(options = {}) {
|
|
2746
|
-
return { type: Types.Number, options };
|
|
2747
|
-
}
|
|
2748
|
-
const PaddingPropControllerFormat = {
|
|
2749
|
-
ClassName: "makeswift::prop-controllers::padding::format::class-name",
|
|
2750
|
-
ResponsiveValue: "makeswift::prop-controllers::padding::format::responsive-value"
|
|
2751
|
-
};
|
|
2752
|
-
function Padding(options = {}) {
|
|
2753
|
-
return { type: Types.Padding, options };
|
|
2754
|
-
}
|
|
2755
|
-
Padding.Format = PaddingPropControllerFormat;
|
|
2756
|
-
function ResponsiveColor(options = {}) {
|
|
2757
|
-
return { type: Types.ResponsiveColor, options };
|
|
2758
|
-
}
|
|
2759
|
-
function ResponsiveIconRadioGroup(options) {
|
|
2760
|
-
return { type: Types.ResponsiveIconRadioGroup, options };
|
|
2761
|
-
}
|
|
2762
|
-
function ResponsiveLength(options = {}) {
|
|
2763
|
-
return { type: Types.ResponsiveLength, options };
|
|
2764
|
-
}
|
|
2765
|
-
function ResponsiveNumber(options = {}) {
|
|
2766
|
-
return { type: Types.ResponsiveNumber, options };
|
|
2767
|
-
}
|
|
2768
|
-
function ResponsiveOpacity(options = {}) {
|
|
2769
|
-
return { type: Types.ResponsiveOpacity, options };
|
|
2770
|
-
}
|
|
2771
|
-
function ResponsiveSelect(options) {
|
|
2772
|
-
return { type: Types.ResponsiveSelect, options };
|
|
2773
|
-
}
|
|
2774
|
-
function RichText(options = {}) {
|
|
2775
|
-
return { type: Types.RichText, options };
|
|
2776
|
-
}
|
|
2777
|
-
const ShadowsPropControllerFormat = {
|
|
2778
|
-
ClassName: "makeswift::prop-controllers::shadows::format::class-name",
|
|
2779
|
-
ResponsiveValue: "makeswift::prop-controllers::shadows::format::responsive-value"
|
|
2780
|
-
};
|
|
2781
|
-
function Shadows(options = {}) {
|
|
2782
|
-
return { type: Types.Shadows, options };
|
|
2783
|
-
}
|
|
2784
|
-
Shadows.Format = ShadowsPropControllerFormat;
|
|
2785
|
-
function Shape(options) {
|
|
2786
|
-
return { type: Types.Shape, options };
|
|
2787
|
-
}
|
|
2788
|
-
function SocialLinks(options = {}) {
|
|
2789
|
-
return { type: Types.SocialLinks, options };
|
|
2790
|
-
}
|
|
2791
|
-
function Table(options = {}) {
|
|
2792
|
-
return { type: Types.Table, options };
|
|
2793
|
-
}
|
|
2794
|
-
function TableFormFields(options = {}) {
|
|
2795
|
-
return { type: Types.TableFormFields, options };
|
|
2159
|
+
if (selection == null)
|
|
2160
|
+
return void 0;
|
|
2161
|
+
return {
|
|
2162
|
+
isFocused: false,
|
|
2163
|
+
marks: void 0,
|
|
2164
|
+
object: "selection",
|
|
2165
|
+
anchor: {
|
|
2166
|
+
offset: selection.anchor.offset,
|
|
2167
|
+
path: selection.anchor.path,
|
|
2168
|
+
object: "point"
|
|
2169
|
+
},
|
|
2170
|
+
focus: {
|
|
2171
|
+
offset: selection.focus.offset,
|
|
2172
|
+
path: selection.focus.path,
|
|
2173
|
+
object: "point"
|
|
2174
|
+
}
|
|
2175
|
+
};
|
|
2796
2176
|
}
|
|
2797
|
-
function
|
|
2798
|
-
return {
|
|
2177
|
+
function richTextDAOToDTO(children, selection) {
|
|
2178
|
+
return {
|
|
2179
|
+
document: {
|
|
2180
|
+
data: void 0,
|
|
2181
|
+
nodes: children.flatMap(toNodeDTO),
|
|
2182
|
+
object: "document"
|
|
2183
|
+
},
|
|
2184
|
+
object: "value",
|
|
2185
|
+
selection: toSelectionDTO(selection),
|
|
2186
|
+
annotations: void 0,
|
|
2187
|
+
data: void 0
|
|
2188
|
+
};
|
|
2799
2189
|
}
|
|
2800
|
-
|
|
2801
|
-
|
|
2190
|
+
const RichTextControlType = "makeswift::controls::rich-text";
|
|
2191
|
+
function RichText() {
|
|
2192
|
+
return { type: RichTextControlType };
|
|
2802
2193
|
}
|
|
2803
|
-
|
|
2804
|
-
|
|
2194
|
+
const RichTextControlMessageType = {
|
|
2195
|
+
CHANGE_BUILDER_EDIT_MODE: "CHANGE_BUILDER_EDIT_MODE",
|
|
2196
|
+
INITIALIZE_EDITOR: "INITIALIZE_EDITOR",
|
|
2197
|
+
CHANGE_EDITOR_VALUE: "CHANGE_EDITOR_VALUE",
|
|
2198
|
+
FOCUS: "FOCUS",
|
|
2199
|
+
BLUR: "BLUR",
|
|
2200
|
+
UNDO: "UNDO",
|
|
2201
|
+
REDO: "REDO",
|
|
2202
|
+
CHANGE_BOX_MODEL: "CHANGE_BOX_MODEL"
|
|
2203
|
+
};
|
|
2204
|
+
class RichTextControl extends PropController {
|
|
2205
|
+
constructor() {
|
|
2206
|
+
super(...arguments);
|
|
2207
|
+
__publicField(this, "editor", null);
|
|
2208
|
+
__publicField(this, "recv", (message) => {
|
|
2209
|
+
if (!this.editor)
|
|
2210
|
+
return;
|
|
2211
|
+
switch (message.type) {
|
|
2212
|
+
case RichTextControlMessageType.CHANGE_BUILDER_EDIT_MODE: {
|
|
2213
|
+
switch (message.editMode) {
|
|
2214
|
+
case BuilderEditMode.BUILD:
|
|
2215
|
+
case BuilderEditMode.INTERACT:
|
|
2216
|
+
this.editor.deselectAndBlur();
|
|
2217
|
+
}
|
|
2218
|
+
break;
|
|
2219
|
+
}
|
|
2220
|
+
case RichTextControlMessageType.FOCUS: {
|
|
2221
|
+
this.editor.focusAndSelectAll();
|
|
2222
|
+
break;
|
|
2223
|
+
}
|
|
2224
|
+
}
|
|
2225
|
+
});
|
|
2226
|
+
}
|
|
2227
|
+
setSlateEditor(editor) {
|
|
2228
|
+
this.editor = editor;
|
|
2229
|
+
this.send({
|
|
2230
|
+
type: RichTextControlMessageType.INITIALIZE_EDITOR,
|
|
2231
|
+
value: richTextDAOToDTO(editor.children, editor.selection)
|
|
2232
|
+
});
|
|
2233
|
+
const _onChange = editor.onChange;
|
|
2234
|
+
this.editor.onChange = (options) => {
|
|
2235
|
+
_onChange(options);
|
|
2236
|
+
if ((options == null ? void 0 : options.operation) != null) {
|
|
2237
|
+
this.send({
|
|
2238
|
+
type: RichTextControlMessageType.CHANGE_EDITOR_VALUE,
|
|
2239
|
+
value: richTextDAOToDTO(editor.children, editor.selection)
|
|
2240
|
+
});
|
|
2241
|
+
}
|
|
2242
|
+
};
|
|
2243
|
+
}
|
|
2244
|
+
focus() {
|
|
2245
|
+
this.send({ type: RichTextControlMessageType.FOCUS });
|
|
2246
|
+
}
|
|
2247
|
+
blur() {
|
|
2248
|
+
this.send({ type: RichTextControlMessageType.BLUR });
|
|
2249
|
+
}
|
|
2250
|
+
undo() {
|
|
2251
|
+
this.send({ type: RichTextControlMessageType.UNDO });
|
|
2252
|
+
}
|
|
2253
|
+
redo() {
|
|
2254
|
+
this.send({ type: RichTextControlMessageType.REDO });
|
|
2255
|
+
}
|
|
2256
|
+
changeBoxModel(boxModel) {
|
|
2257
|
+
this.send({ type: RichTextControlMessageType.CHANGE_BOX_MODEL, payload: { boxModel } });
|
|
2258
|
+
}
|
|
2805
2259
|
}
|
|
2806
|
-
|
|
2807
|
-
|
|
2260
|
+
const RichTextV2ControlType = "makeswift::controls::rich-text-v2";
|
|
2261
|
+
const RichTextV2Mode = {
|
|
2262
|
+
Inline: "makeswift::controls::rich-text-v2::mode::inline",
|
|
2263
|
+
Block: "makeswift::controls::rich-text-v2::mode::block"
|
|
2264
|
+
};
|
|
2265
|
+
function createRichTextV2Plugin({
|
|
2266
|
+
control,
|
|
2267
|
+
withPlugin,
|
|
2268
|
+
onKeyDown,
|
|
2269
|
+
renderElement,
|
|
2270
|
+
renderLeaf
|
|
2271
|
+
}) {
|
|
2272
|
+
return { control, withPlugin, onKeyDown, renderElement, renderLeaf };
|
|
2808
2273
|
}
|
|
2809
|
-
function
|
|
2810
|
-
return { type:
|
|
2274
|
+
function unstable_RichTextV2(config = {}) {
|
|
2275
|
+
return { type: RichTextV2ControlType, config };
|
|
2811
2276
|
}
|
|
2812
|
-
const
|
|
2813
|
-
|
|
2814
|
-
|
|
2277
|
+
const RichTextV2ControlMessageType = {
|
|
2278
|
+
RESET_VALUE: "RESET_VALUE",
|
|
2279
|
+
FOCUS: "FOCUS",
|
|
2280
|
+
RUN_PLUGIN_CONTROL_ACTION: "RUN_PLUGIN_CONTROL_ACTION",
|
|
2281
|
+
SET_DEFAULT_VALUE: "SET_DEFAULT_VALUE",
|
|
2282
|
+
SET_PLUGIN_CONTROL_VALUE: "SET_PLUGIN_CONTROL_VALUE",
|
|
2283
|
+
ON_CHANGE: "ON_CHANGE",
|
|
2284
|
+
SELECT: "SELECT",
|
|
2285
|
+
SWITCH_TO_BUILD_MODE: "SWITCH_TO_BUILD_MODE",
|
|
2286
|
+
CHANGE_BOX_MODEL: "CHANGE_BOX_MODEL"
|
|
2815
2287
|
};
|
|
2816
|
-
|
|
2817
|
-
|
|
2288
|
+
class RichTextV2Control extends PropController {
|
|
2289
|
+
constructor(send, descriptor) {
|
|
2290
|
+
super(send);
|
|
2291
|
+
__publicField(this, "editor", null);
|
|
2292
|
+
__publicField(this, "defaultValue", null);
|
|
2293
|
+
__publicField(this, "descriptor");
|
|
2294
|
+
__publicField(this, "recv", (message) => {
|
|
2295
|
+
var _a2, _b, _c;
|
|
2296
|
+
if (!this.editor)
|
|
2297
|
+
return;
|
|
2298
|
+
switch (message.type) {
|
|
2299
|
+
case RichTextV2ControlMessageType.FOCUS: {
|
|
2300
|
+
this.editor.focusAndSelectAll();
|
|
2301
|
+
break;
|
|
2302
|
+
}
|
|
2303
|
+
case RichTextV2ControlMessageType.RESET_VALUE: {
|
|
2304
|
+
if (this.defaultValue) {
|
|
2305
|
+
this.editor.selection = null;
|
|
2306
|
+
this.editor.children = this.defaultValue;
|
|
2307
|
+
this.editor.onChange();
|
|
2308
|
+
}
|
|
2309
|
+
break;
|
|
2310
|
+
}
|
|
2311
|
+
case RichTextV2ControlMessageType.RUN_PLUGIN_CONTROL_ACTION: {
|
|
2312
|
+
(_c = (_b = (_a2 = this.descriptor.config.plugins) == null ? void 0 : _a2.at(message.pluginIndex)) == null ? void 0 : _b.control) == null ? void 0 : _c.onChange(this.editor, message.value);
|
|
2313
|
+
break;
|
|
2314
|
+
}
|
|
2315
|
+
}
|
|
2316
|
+
});
|
|
2317
|
+
this.descriptor = descriptor;
|
|
2318
|
+
this.send = send;
|
|
2319
|
+
}
|
|
2320
|
+
setEditor(editor) {
|
|
2321
|
+
var _a2, _b, _c;
|
|
2322
|
+
this.editor = editor;
|
|
2323
|
+
this.send({
|
|
2324
|
+
type: RichTextV2ControlMessageType.SET_PLUGIN_CONTROL_VALUE,
|
|
2325
|
+
value: (_c = (_b = (_a2 = this.descriptor.config) == null ? void 0 : _a2.plugins) == null ? void 0 : _b.map((plugin) => {
|
|
2326
|
+
var _a3;
|
|
2327
|
+
return (_a3 = plugin == null ? void 0 : plugin.control) == null ? void 0 : _a3.getValue(editor);
|
|
2328
|
+
})) != null ? _c : []
|
|
2329
|
+
});
|
|
2330
|
+
}
|
|
2331
|
+
setDefaultValue(defaultValue) {
|
|
2332
|
+
this.defaultValue = defaultValue;
|
|
2333
|
+
this.send({ type: RichTextV2ControlMessageType.SET_DEFAULT_VALUE, value: defaultValue });
|
|
2334
|
+
}
|
|
2335
|
+
select() {
|
|
2336
|
+
this.send({ type: RichTextV2ControlMessageType.SELECT });
|
|
2337
|
+
}
|
|
2338
|
+
switchToBuildMode() {
|
|
2339
|
+
this.send({ type: RichTextV2ControlMessageType.SWITCH_TO_BUILD_MODE });
|
|
2340
|
+
}
|
|
2341
|
+
onChange(value) {
|
|
2342
|
+
var _a2, _b, _c;
|
|
2343
|
+
const editor = this.editor;
|
|
2344
|
+
if (editor == null)
|
|
2345
|
+
return;
|
|
2346
|
+
this.send({
|
|
2347
|
+
type: RichTextV2ControlMessageType.ON_CHANGE,
|
|
2348
|
+
value
|
|
2349
|
+
});
|
|
2350
|
+
this.send({
|
|
2351
|
+
type: RichTextV2ControlMessageType.SET_PLUGIN_CONTROL_VALUE,
|
|
2352
|
+
value: (_c = (_b = (_a2 = this.descriptor.config) == null ? void 0 : _a2.plugins) == null ? void 0 : _b.map((plugin) => {
|
|
2353
|
+
var _a3;
|
|
2354
|
+
return (_a3 = plugin == null ? void 0 : plugin.control) == null ? void 0 : _a3.getValue(editor);
|
|
2355
|
+
})) != null ? _c : []
|
|
2356
|
+
});
|
|
2357
|
+
}
|
|
2358
|
+
changeBoxModel(boxModel) {
|
|
2359
|
+
this.send({ type: RichTextV2ControlMessageType.CHANGE_BOX_MODEL, payload: { boxModel } });
|
|
2360
|
+
}
|
|
2818
2361
|
}
|
|
2819
|
-
Width.Format = WidthPropControllerFormat;
|
|
2820
|
-
var descriptors = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
2821
|
-
__proto__: null,
|
|
2822
|
-
Types,
|
|
2823
|
-
Backgrounds,
|
|
2824
|
-
BorderPropControllerFormat,
|
|
2825
|
-
Border,
|
|
2826
|
-
BorderRadiusPropControllerFormat,
|
|
2827
|
-
BorderRadius,
|
|
2828
|
-
Checkbox,
|
|
2829
|
-
Date,
|
|
2830
|
-
ElementID,
|
|
2831
|
-
Font,
|
|
2832
|
-
GapX,
|
|
2833
|
-
GapY,
|
|
2834
|
-
Grid,
|
|
2835
|
-
Image,
|
|
2836
|
-
Images,
|
|
2837
|
-
Link,
|
|
2838
|
-
List,
|
|
2839
|
-
MarginPropControllerFormat,
|
|
2840
|
-
Margin,
|
|
2841
|
-
NavigationLinks,
|
|
2842
|
-
Number,
|
|
2843
|
-
PaddingPropControllerFormat,
|
|
2844
|
-
Padding,
|
|
2845
|
-
ResponsiveColor,
|
|
2846
|
-
ResponsiveIconRadioGroup,
|
|
2847
|
-
ResponsiveLength,
|
|
2848
|
-
ResponsiveNumber,
|
|
2849
|
-
ResponsiveOpacity,
|
|
2850
|
-
ResponsiveSelect,
|
|
2851
|
-
RichText,
|
|
2852
|
-
ShadowsPropControllerFormat,
|
|
2853
|
-
Shadows,
|
|
2854
|
-
Shape,
|
|
2855
|
-
SocialLinks,
|
|
2856
|
-
Table,
|
|
2857
|
-
TableFormFields,
|
|
2858
|
-
Typeahead,
|
|
2859
|
-
TextArea,
|
|
2860
|
-
TextInput,
|
|
2861
|
-
TextStyle,
|
|
2862
|
-
Video,
|
|
2863
|
-
WidthPropControllerFormat,
|
|
2864
|
-
Width
|
|
2865
|
-
}, Symbol.toStringTag, { value: "Module" }));
|
|
2866
2362
|
function isNonNullable(value) {
|
|
2867
2363
|
return value != null;
|
|
2868
2364
|
}
|
|
@@ -2895,51 +2391,51 @@ function getElementId$1(descriptor, prop) {
|
|
|
2895
2391
|
}
|
|
2896
2392
|
}
|
|
2897
2393
|
function getBackgroundsSwatchIds(value) {
|
|
2898
|
-
var
|
|
2899
|
-
return (
|
|
2900
|
-
var
|
|
2394
|
+
var _a2;
|
|
2395
|
+
return (_a2 = value == null ? void 0 : value.flatMap((override) => override.value).flatMap((backgroundItem) => {
|
|
2396
|
+
var _a3;
|
|
2901
2397
|
switch (backgroundItem.type) {
|
|
2902
2398
|
case "color":
|
|
2903
|
-
return ((
|
|
2399
|
+
return ((_a3 = backgroundItem.payload) == null ? void 0 : _a3.swatchId) == null ? [] : [backgroundItem.payload.swatchId];
|
|
2904
2400
|
case "gradient":
|
|
2905
2401
|
return backgroundItem.payload.stops.flatMap((stop) => stop.color == null ? [] : stop.color.swatchId);
|
|
2906
2402
|
default:
|
|
2907
2403
|
return [];
|
|
2908
2404
|
}
|
|
2909
|
-
})) != null ?
|
|
2405
|
+
})) != null ? _a2 : [];
|
|
2910
2406
|
}
|
|
2911
2407
|
function getBorderSwatchIds(value) {
|
|
2912
|
-
var
|
|
2913
|
-
return (
|
|
2914
|
-
var
|
|
2408
|
+
var _a2;
|
|
2409
|
+
return (_a2 = value == null ? void 0 : value.flatMap((override) => override.value).flatMap((borderValue) => {
|
|
2410
|
+
var _a3, _b, _c, _d, _e, _f, _g, _h;
|
|
2915
2411
|
return [
|
|
2916
|
-
(_b = (
|
|
2412
|
+
(_b = (_a3 = borderValue.borderTop) == null ? void 0 : _a3.color) == null ? void 0 : _b.swatchId,
|
|
2917
2413
|
(_d = (_c = borderValue.borderRight) == null ? void 0 : _c.color) == null ? void 0 : _d.swatchId,
|
|
2918
2414
|
(_f = (_e = borderValue.borderBottom) == null ? void 0 : _e.color) == null ? void 0 : _f.swatchId,
|
|
2919
2415
|
(_h = (_g = borderValue.borderLeft) == null ? void 0 : _g.color) == null ? void 0 : _h.swatchId
|
|
2920
2416
|
].filter((swatchId) => swatchId != null);
|
|
2921
|
-
})) != null ?
|
|
2417
|
+
})) != null ? _a2 : [];
|
|
2922
2418
|
}
|
|
2923
2419
|
function getBoxShadowsSwatchIds(value) {
|
|
2924
|
-
var
|
|
2925
|
-
return (
|
|
2926
|
-
var
|
|
2927
|
-
return (
|
|
2928
|
-
}).filter((swatchId) => swatchId != null)) != null ?
|
|
2420
|
+
var _a2;
|
|
2421
|
+
return (_a2 = value == null ? void 0 : value.flatMap((override) => override.value).map((item) => {
|
|
2422
|
+
var _a3;
|
|
2423
|
+
return (_a3 = item.payload.color) == null ? void 0 : _a3.swatchId;
|
|
2424
|
+
}).filter((swatchId) => swatchId != null)) != null ? _a2 : [];
|
|
2929
2425
|
}
|
|
2930
2426
|
function getResponsiveColorSwatchIds(value) {
|
|
2931
|
-
var
|
|
2932
|
-
return (
|
|
2427
|
+
var _a2;
|
|
2428
|
+
return (_a2 = value == null ? void 0 : value.map((override) => override.value).map((color) => color.swatchId)) != null ? _a2 : [];
|
|
2933
2429
|
}
|
|
2934
2430
|
function getTypographyStyleSwatchIds(style) {
|
|
2935
|
-
var
|
|
2936
|
-
return (
|
|
2937
|
-
var
|
|
2938
|
-
return (
|
|
2939
|
-
}).filter(isNonNullable)) != null ?
|
|
2431
|
+
var _a2;
|
|
2432
|
+
return (_a2 = style == null ? void 0 : style.map((override) => override.value).flatMap((typographyStyle) => {
|
|
2433
|
+
var _a3;
|
|
2434
|
+
return (_a3 = typographyStyle.color) == null ? void 0 : _a3.swatchId;
|
|
2435
|
+
}).filter(isNonNullable)) != null ? _a2 : [];
|
|
2940
2436
|
}
|
|
2941
2437
|
function getElementSwatchIds(descriptor, prop) {
|
|
2942
|
-
var
|
|
2438
|
+
var _a2;
|
|
2943
2439
|
if (prop == null)
|
|
2944
2440
|
return [];
|
|
2945
2441
|
switch (descriptor.type) {
|
|
@@ -2949,17 +2445,17 @@ function getElementSwatchIds(descriptor, prop) {
|
|
|
2949
2445
|
return getBorderSwatchIds(prop);
|
|
2950
2446
|
case Types.NavigationLinks: {
|
|
2951
2447
|
const value = prop;
|
|
2952
|
-
return (
|
|
2953
|
-
var
|
|
2448
|
+
return (_a2 = value == null ? void 0 : value.flatMap((item) => {
|
|
2449
|
+
var _a3, _b, _c, _d;
|
|
2954
2450
|
switch (item.type) {
|
|
2955
2451
|
case "button":
|
|
2956
2452
|
case "dropdown":
|
|
2957
2453
|
return [
|
|
2958
|
-
...(_b = (
|
|
2454
|
+
...(_b = (_a3 = item.payload.color) == null ? void 0 : _a3.map((override) => override.value).map((color) => color.swatchId)) != null ? _b : [],
|
|
2959
2455
|
...(_d = (_c = item.payload.textColor) == null ? void 0 : _c.map((override) => override.value).map((color) => color.swatchId)) != null ? _d : []
|
|
2960
2456
|
];
|
|
2961
2457
|
}
|
|
2962
|
-
})) != null ?
|
|
2458
|
+
})) != null ? _a2 : [];
|
|
2963
2459
|
}
|
|
2964
2460
|
case Types.ResponsiveColor:
|
|
2965
2461
|
return getResponsiveColorSwatchIds(prop);
|
|
@@ -2967,20 +2463,20 @@ function getElementSwatchIds(descriptor, prop) {
|
|
|
2967
2463
|
return getBoxShadowsSwatchIds(prop);
|
|
2968
2464
|
case Types.RichText: {
|
|
2969
2465
|
let getNodeSwatchIds = function(node) {
|
|
2970
|
-
var
|
|
2466
|
+
var _a3, _b, _c, _d;
|
|
2971
2467
|
switch (node.object) {
|
|
2972
2468
|
case "document":
|
|
2973
2469
|
case "block":
|
|
2974
2470
|
case "inline":
|
|
2975
|
-
return (_b = (
|
|
2471
|
+
return (_b = (_a3 = node.nodes) == null ? void 0 : _a3.flatMap(getNodeSwatchIds)) != null ? _b : [];
|
|
2976
2472
|
case "text":
|
|
2977
2473
|
return (_d = (_c = node.marks) == null ? void 0 : _c.flatMap(getMarkSwatchIds)) != null ? _d : [];
|
|
2978
2474
|
default:
|
|
2979
2475
|
return [];
|
|
2980
2476
|
}
|
|
2981
2477
|
}, getMarkSwatchIds = function(mark) {
|
|
2982
|
-
var
|
|
2983
|
-
return getTypographyStyleSwatchIds((_b = (
|
|
2478
|
+
var _a3, _b;
|
|
2479
|
+
return getTypographyStyleSwatchIds((_b = (_a3 = mark.data) == null ? void 0 : _a3.value) == null ? void 0 : _b.style);
|
|
2984
2480
|
};
|
|
2985
2481
|
const value = prop;
|
|
2986
2482
|
if (value == null || value.document == null)
|
|
@@ -2991,23 +2487,56 @@ function getElementSwatchIds(descriptor, prop) {
|
|
|
2991
2487
|
const value = prop;
|
|
2992
2488
|
return (value == null ? void 0 : value.swatchId) == null ? [] : [value.swatchId];
|
|
2993
2489
|
}
|
|
2490
|
+
case StyleV2ControlType: {
|
|
2491
|
+
const value = prop;
|
|
2492
|
+
return value.flatMap((value2) => getElementSwatchIds(descriptor.config.type, value2.value));
|
|
2493
|
+
}
|
|
2494
|
+
case RichTextV2ControlType: {
|
|
2495
|
+
let getDescendantSwatchIds = function(descendant) {
|
|
2496
|
+
if (slate.Element.isElement(descendant)) {
|
|
2497
|
+
return [
|
|
2498
|
+
...getSlateElementSwatchIds(descendant),
|
|
2499
|
+
...descendant.children.flatMap((d) => getDescendantSwatchIds(d))
|
|
2500
|
+
];
|
|
2501
|
+
}
|
|
2502
|
+
if (slate.Text.isText(descendant)) {
|
|
2503
|
+
return getTextSwatchIds(descendant);
|
|
2504
|
+
}
|
|
2505
|
+
return [];
|
|
2506
|
+
}, getSlateElementSwatchIds = function(descendant) {
|
|
2507
|
+
var _a3;
|
|
2508
|
+
return (_a3 = plugins == null ? void 0 : plugins.flatMap((plugin) => {
|
|
2509
|
+
var _a4;
|
|
2510
|
+
return ((_a4 = plugin.control) == null ? void 0 : _a4.definition) && plugin.control.getElementValue ? getElementSwatchIds(plugin.control.definition, plugin.control.getElementValue(descendant)) : [];
|
|
2511
|
+
})) != null ? _a3 : [];
|
|
2512
|
+
}, getTextSwatchIds = function(text) {
|
|
2513
|
+
var _a3;
|
|
2514
|
+
return (_a3 = plugins == null ? void 0 : plugins.flatMap((plugin) => {
|
|
2515
|
+
var _a4;
|
|
2516
|
+
return ((_a4 = plugin.control) == null ? void 0 : _a4.definition) && plugin.control.getLeafValue ? getElementSwatchIds(plugin.control.definition, plugin.control.getLeafValue(text)) : [];
|
|
2517
|
+
})) != null ? _a3 : [];
|
|
2518
|
+
};
|
|
2519
|
+
const descendants = prop;
|
|
2520
|
+
const plugins = descriptor.config.plugins;
|
|
2521
|
+
return descendants.flatMap((d) => getDescendantSwatchIds(d));
|
|
2522
|
+
}
|
|
2994
2523
|
default:
|
|
2995
2524
|
return [];
|
|
2996
2525
|
}
|
|
2997
2526
|
}
|
|
2998
2527
|
function getBackgroundsFileIds(value) {
|
|
2999
|
-
var
|
|
3000
|
-
return (
|
|
2528
|
+
var _a2;
|
|
2529
|
+
return (_a2 = value == null ? void 0 : value.flatMap((override) => override.value).flatMap((backgroundItem) => {
|
|
3001
2530
|
switch (backgroundItem.type) {
|
|
3002
2531
|
case "image":
|
|
3003
2532
|
return [backgroundItem.payload.imageId];
|
|
3004
2533
|
default:
|
|
3005
2534
|
return [];
|
|
3006
2535
|
}
|
|
3007
|
-
})) != null ?
|
|
2536
|
+
})) != null ? _a2 : [];
|
|
3008
2537
|
}
|
|
3009
2538
|
function getFileIds(descriptor, prop) {
|
|
3010
|
-
var
|
|
2539
|
+
var _a2;
|
|
3011
2540
|
if (prop == null)
|
|
3012
2541
|
return [];
|
|
3013
2542
|
switch (descriptor.type) {
|
|
@@ -3019,7 +2548,7 @@ function getFileIds(descriptor, prop) {
|
|
|
3019
2548
|
}
|
|
3020
2549
|
case Types.Images: {
|
|
3021
2550
|
const value = prop;
|
|
3022
|
-
return (
|
|
2551
|
+
return (_a2 = value == null ? void 0 : value.flatMap((item) => item.props.file == null ? [] : [item.props.file])) != null ? _a2 : [];
|
|
3023
2552
|
}
|
|
3024
2553
|
case ImageControlType: {
|
|
3025
2554
|
const value = prop;
|
|
@@ -3035,20 +2564,20 @@ function getTypographyIds(descriptor, prop) {
|
|
|
3035
2564
|
switch (descriptor.type) {
|
|
3036
2565
|
case Types.RichText: {
|
|
3037
2566
|
let getNodeTypographyIds = function(node) {
|
|
3038
|
-
var
|
|
2567
|
+
var _a2, _b, _c, _d;
|
|
3039
2568
|
switch (node.object) {
|
|
3040
2569
|
case "document":
|
|
3041
2570
|
case "block":
|
|
3042
2571
|
case "inline":
|
|
3043
|
-
return (_b = (
|
|
2572
|
+
return (_b = (_a2 = node.nodes) == null ? void 0 : _a2.flatMap(getNodeTypographyIds)) != null ? _b : [];
|
|
3044
2573
|
case "text":
|
|
3045
2574
|
return (_d = (_c = node.marks) == null ? void 0 : _c.flatMap(getMarkTypographyIds)) != null ? _d : [];
|
|
3046
2575
|
default:
|
|
3047
2576
|
return [];
|
|
3048
2577
|
}
|
|
3049
2578
|
}, getMarkTypographyIds = function(mark) {
|
|
3050
|
-
var
|
|
3051
|
-
return [(_b = (
|
|
2579
|
+
var _a2, _b;
|
|
2580
|
+
return [(_b = (_a2 = mark.data) == null ? void 0 : _a2.value) == null ? void 0 : _b.id].filter((id) => id != null);
|
|
3052
2581
|
};
|
|
3053
2582
|
const value = prop;
|
|
3054
2583
|
if (value == null || value.document == null)
|
|
@@ -3072,7 +2601,7 @@ function getTableIds(descriptor, prop) {
|
|
|
3072
2601
|
}
|
|
3073
2602
|
}
|
|
3074
2603
|
function getPageIds(descriptor, prop) {
|
|
3075
|
-
var
|
|
2604
|
+
var _a2;
|
|
3076
2605
|
if (prop == null)
|
|
3077
2606
|
return [];
|
|
3078
2607
|
switch (descriptor.type) {
|
|
@@ -3091,8 +2620,8 @@ function getPageIds(descriptor, prop) {
|
|
|
3091
2620
|
const value = prop;
|
|
3092
2621
|
if (value == null)
|
|
3093
2622
|
return [];
|
|
3094
|
-
return (
|
|
3095
|
-
var
|
|
2623
|
+
return (_a2 = value == null ? void 0 : value.flatMap((item) => {
|
|
2624
|
+
var _a3, _b;
|
|
3096
2625
|
switch (item.type) {
|
|
3097
2626
|
case "button": {
|
|
3098
2627
|
if (item.payload.link == null)
|
|
@@ -3105,7 +2634,7 @@ function getPageIds(descriptor, prop) {
|
|
|
3105
2634
|
}
|
|
3106
2635
|
}
|
|
3107
2636
|
case "dropdown": {
|
|
3108
|
-
return (_b = (
|
|
2637
|
+
return (_b = (_a3 = item.payload.links) == null ? void 0 : _a3.flatMap((link) => {
|
|
3109
2638
|
if (link.payload.link == null)
|
|
3110
2639
|
return [];
|
|
3111
2640
|
switch (link.payload.link.type) {
|
|
@@ -3117,25 +2646,25 @@ function getPageIds(descriptor, prop) {
|
|
|
3117
2646
|
})) != null ? _b : [];
|
|
3118
2647
|
}
|
|
3119
2648
|
}
|
|
3120
|
-
})) != null ?
|
|
2649
|
+
})) != null ? _a2 : [];
|
|
3121
2650
|
}
|
|
3122
2651
|
case Types.RichText: {
|
|
3123
2652
|
let getNodePageIds = function(node) {
|
|
3124
|
-
var
|
|
2653
|
+
var _a3, _b;
|
|
3125
2654
|
switch (node.object) {
|
|
3126
2655
|
case "document":
|
|
3127
2656
|
case "block":
|
|
3128
|
-
return (_b = (
|
|
2657
|
+
return (_b = (_a3 = node.nodes) == null ? void 0 : _a3.flatMap(getNodePageIds)) != null ? _b : [];
|
|
3129
2658
|
case "inline":
|
|
3130
2659
|
return getInlinePageIds(node);
|
|
3131
2660
|
default:
|
|
3132
2661
|
return [];
|
|
3133
2662
|
}
|
|
3134
2663
|
}, getInlinePageIds = function(inline) {
|
|
3135
|
-
var
|
|
2664
|
+
var _a3, _b, _c, _d;
|
|
3136
2665
|
switch (inline.type) {
|
|
3137
2666
|
case "link": {
|
|
3138
|
-
const nodePageIds = (_b = (
|
|
2667
|
+
const nodePageIds = (_b = (_a3 = inline.nodes) == null ? void 0 : _a3.flatMap(getNodePageIds)) != null ? _b : [];
|
|
3139
2668
|
const dataPageIds = inline.data ? getLinkDataPageIds(inline.data) : [];
|
|
3140
2669
|
return [...nodePageIds, ...dataPageIds];
|
|
3141
2670
|
}
|
|
@@ -3250,14 +2779,14 @@ function getDocumentKeysSortedByDepth(state) {
|
|
|
3250
2779
|
elements.set(key, getDocumentElements(state, key));
|
|
3251
2780
|
});
|
|
3252
2781
|
keys.sort((a, b) => {
|
|
3253
|
-
var
|
|
3254
|
-
return ((
|
|
2782
|
+
var _a2;
|
|
2783
|
+
return ((_a2 = elements.get(a)) == null ? void 0 : _a2.has(b)) ? -1 : 1;
|
|
3255
2784
|
});
|
|
3256
2785
|
return keys;
|
|
3257
2786
|
}
|
|
3258
2787
|
function getElement(state, documentKey, elementKey) {
|
|
3259
|
-
var
|
|
3260
|
-
return (
|
|
2788
|
+
var _a2;
|
|
2789
|
+
return (_a2 = getDocumentElements(state, documentKey).get(elementKey)) != null ? _a2 : null;
|
|
3261
2790
|
}
|
|
3262
2791
|
function getElementPropControllerDescriptors(state, documentKey, elementKey) {
|
|
3263
2792
|
const element = getElement(state, documentKey, elementKey);
|
|
@@ -3344,8 +2873,6 @@ function configureStore({
|
|
|
3344
2873
|
}), redux.applyMiddleware(thunk__default["default"]));
|
|
3345
2874
|
}
|
|
3346
2875
|
exports.Backgrounds = Backgrounds;
|
|
3347
|
-
exports.BlockActions = BlockActions;
|
|
3348
|
-
exports.BlockPlugin = BlockPlugin;
|
|
3349
2876
|
exports.BlockTextAlignment = BlockTextAlignment;
|
|
3350
2877
|
exports.BlockType = BlockType;
|
|
3351
2878
|
exports.Border = Border;
|
|
@@ -3359,22 +2886,20 @@ exports.ColorControlType = ColorControlType;
|
|
|
3359
2886
|
exports.ComponentIcon = ComponentIcon;
|
|
3360
2887
|
exports.Date = Date;
|
|
3361
2888
|
exports.ElementID = ElementID;
|
|
3362
|
-
exports.ElementUtils = ElementUtils;
|
|
3363
2889
|
exports.Font = Font;
|
|
3364
2890
|
exports.GapX = GapX;
|
|
3365
2891
|
exports.GapY = GapY;
|
|
3366
2892
|
exports.Grid = Grid;
|
|
3367
|
-
exports.Image = Image;
|
|
3368
|
-
exports.Image$1 = Image
|
|
2893
|
+
exports.Image = Image$1;
|
|
2894
|
+
exports.Image$1 = Image;
|
|
3369
2895
|
exports.ImageControlType = ImageControlType;
|
|
3370
2896
|
exports.ImageControlValueFormat = ImageControlValueFormat;
|
|
3371
2897
|
exports.Images = Images;
|
|
3372
2898
|
exports.InlineType = InlineType;
|
|
3373
|
-
exports.Link = Link;
|
|
3374
|
-
exports.Link$1 = Link
|
|
2899
|
+
exports.Link = Link$1;
|
|
2900
|
+
exports.Link$1 = Link;
|
|
3375
2901
|
exports.LinkControlType = LinkControlType;
|
|
3376
|
-
exports.List = List
|
|
3377
|
-
exports.ListActions = ListActions;
|
|
2902
|
+
exports.List = List;
|
|
3378
2903
|
exports.ListControl = ListControl;
|
|
3379
2904
|
exports.ListControlMessageType = ListControlMessageType;
|
|
3380
2905
|
exports.ListControlType = ListControlType;
|
|
@@ -3391,8 +2916,8 @@ exports.ResponsiveLength = ResponsiveLength;
|
|
|
3391
2916
|
exports.ResponsiveNumber = ResponsiveNumber;
|
|
3392
2917
|
exports.ResponsiveOpacity = ResponsiveOpacity;
|
|
3393
2918
|
exports.ResponsiveSelect = ResponsiveSelect;
|
|
3394
|
-
exports.RichText = RichText;
|
|
3395
|
-
exports.RichText$1 = RichText
|
|
2919
|
+
exports.RichText = RichText$1;
|
|
2920
|
+
exports.RichText$1 = RichText;
|
|
3396
2921
|
exports.RichTextControl = RichTextControl;
|
|
3397
2922
|
exports.RichTextControlMessageType = RichTextControlMessageType;
|
|
3398
2923
|
exports.RichTextControlType = RichTextControlType;
|
|
@@ -3402,11 +2927,9 @@ exports.RichTextV2ControlMessageType = RichTextV2ControlMessageType;
|
|
|
3402
2927
|
exports.RichTextV2ControlType = RichTextV2ControlType;
|
|
3403
2928
|
exports.RichTextV2Mode = RichTextV2Mode;
|
|
3404
2929
|
exports.RootBlockType = RootBlockType;
|
|
3405
|
-
exports.Select = Select;
|
|
3406
|
-
exports.SelectControlType = SelectControlType;
|
|
3407
2930
|
exports.Shadows = Shadows;
|
|
3408
2931
|
exports.ShadowsPropControllerFormat = ShadowsPropControllerFormat;
|
|
3409
|
-
exports.Shape = Shape
|
|
2932
|
+
exports.Shape = Shape;
|
|
3410
2933
|
exports.ShapeControl = ShapeControl;
|
|
3411
2934
|
exports.ShapeControlMessageType = ShapeControlMessageType;
|
|
3412
2935
|
exports.ShapeControlType = ShapeControlType;
|
|
@@ -3420,6 +2943,9 @@ exports.StyleControl = StyleControl;
|
|
|
3420
2943
|
exports.StyleControlMessageType = StyleControlMessageType;
|
|
3421
2944
|
exports.StyleControlProperty = StyleControlProperty;
|
|
3422
2945
|
exports.StyleControlType = StyleControlType;
|
|
2946
|
+
exports.StyleV2Control = StyleV2Control;
|
|
2947
|
+
exports.StyleV2ControlMessageType = StyleV2ControlMessageType;
|
|
2948
|
+
exports.StyleV2ControlType = StyleV2ControlType;
|
|
3423
2949
|
exports.Table = Table;
|
|
3424
2950
|
exports.TableFormFields = TableFormFields;
|
|
3425
2951
|
exports.TableFormFieldsMessageType = TableFormFieldsMessageType;
|
|
@@ -3483,7 +3009,6 @@ exports.isNonNullable = isNonNullable;
|
|
|
3483
3009
|
exports.isPropControllersHandle = isPropControllersHandle;
|
|
3484
3010
|
exports.merge = merge;
|
|
3485
3011
|
exports.mergeSlotData = mergeSlotData;
|
|
3486
|
-
exports.onKeyDown = onKeyDown;
|
|
3487
3012
|
exports.reducer = reducer$8;
|
|
3488
3013
|
exports.reducer$1 = reducer$7;
|
|
3489
3014
|
exports.reducer$2 = reducer$9;
|
|
@@ -3498,5 +3023,7 @@ exports.richTextDTOtoDAO = richTextDTOtoDAO;
|
|
|
3498
3023
|
exports.richTextDTOtoSelection = richTextDTOtoSelection;
|
|
3499
3024
|
exports.toSelectionDTO = toSelectionDTO;
|
|
3500
3025
|
exports.unstable_RichTextV2 = unstable_RichTextV2;
|
|
3501
|
-
exports.
|
|
3026
|
+
exports.unstable_StyleV2 = unstable_StyleV2;
|
|
3027
|
+
exports.unstable_useStyleV2ClassName = unstable_useStyleV2ClassName;
|
|
3028
|
+
exports.useStyle = useStyle;
|
|
3502
3029
|
//# sourceMappingURL=react-page.cjs.js.map
|