@makeswift/runtime 0.9.1 → 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 +2 -3
- package/dist/Box.cjs.js.map +1 -1
- package/dist/Box.es.js +2 -3
- package/dist/Box.es.js.map +1 -1
- package/dist/Button.cjs.js +2 -3
- package/dist/Button.cjs.js.map +1 -1
- package/dist/Button.es.js +2 -3
- package/dist/Button.es.js.map +1 -1
- package/dist/Carousel.cjs.js +2 -3
- package/dist/Carousel.cjs.js.map +1 -1
- package/dist/Carousel.es.js +2 -3
- package/dist/Carousel.es.js.map +1 -1
- package/dist/Countdown.cjs.js +1 -2
- package/dist/Countdown.cjs.js.map +1 -1
- package/dist/Countdown.es.js +1 -2
- package/dist/Countdown.es.js.map +1 -1
- package/dist/Divider.cjs.js +2 -3
- package/dist/Divider.cjs.js.map +1 -1
- package/dist/Divider.es.js +2 -3
- package/dist/Divider.es.js.map +1 -1
- package/dist/Embed.cjs.js +0 -2
- package/dist/Embed.cjs.js.map +1 -1
- package/dist/Embed.es.js +0 -2
- package/dist/Embed.es.js.map +1 -1
- package/dist/Form.cjs.js +1 -2
- package/dist/Form.cjs.js.map +1 -1
- package/dist/Form.es.js +1 -2
- package/dist/Form.es.js.map +1 -1
- package/dist/Image.cjs.js +1 -2
- package/dist/Image.cjs.js.map +1 -1
- package/dist/Image.es.js +1 -2
- package/dist/Image.es.js.map +1 -1
- package/dist/LiveProvider.cjs.js +2 -3
- package/dist/LiveProvider.cjs.js.map +1 -1
- package/dist/LiveProvider.es.js +3 -4
- package/dist/LiveProvider.es.js.map +1 -1
- package/dist/Navigation.cjs.js +1 -2
- package/dist/Navigation.cjs.js.map +1 -1
- package/dist/Navigation.es.js +1 -2
- package/dist/Navigation.es.js.map +1 -1
- package/dist/PreviewProvider.cjs.js +1 -2
- package/dist/PreviewProvider.cjs.js.map +1 -1
- package/dist/PreviewProvider.es.js +2 -3
- package/dist/PreviewProvider.es.js.map +1 -1
- package/dist/ReadOnlyText.cjs.js +2 -0
- package/dist/ReadOnlyText.cjs.js.map +1 -1
- package/dist/ReadOnlyText.es.js +3 -1
- package/dist/ReadOnlyText.es.js.map +1 -1
- package/dist/ReadOnlyTextV2.cjs.js +2 -0
- package/dist/ReadOnlyTextV2.cjs.js.map +1 -1
- package/dist/ReadOnlyTextV2.es.js +3 -1
- package/dist/ReadOnlyTextV2.es.js.map +1 -1
- package/dist/Root.cjs.js +1 -2
- package/dist/Root.cjs.js.map +1 -1
- package/dist/Root.es.js +1 -2
- package/dist/Root.es.js.map +1 -1
- package/dist/SocialLinks.cjs.js +2 -3
- package/dist/SocialLinks.cjs.js.map +1 -1
- package/dist/SocialLinks.es.js +2 -3
- package/dist/SocialLinks.es.js.map +1 -1
- package/dist/Text.cjs.js +2 -3
- package/dist/Text.cjs.js.map +1 -1
- package/dist/Text.es.js +2 -3
- package/dist/Text.es.js.map +1 -1
- package/dist/Video.cjs.js +0 -2
- package/dist/Video.cjs.js.map +1 -1
- package/dist/Video.es.js +0 -2
- package/dist/Video.es.js.map +1 -1
- package/dist/builder.cjs.js +0 -3
- package/dist/builder.cjs.js.map +1 -1
- package/dist/builder.es.js +0 -3
- package/dist/builder.es.js.map +1 -1
- package/dist/components.cjs.js +1 -2
- package/dist/components.cjs.js.map +1 -1
- package/dist/components.es.js +1 -2
- package/dist/components.es.js.map +1 -1
- package/dist/control-serialization.cjs.js +0 -3
- package/dist/control-serialization.cjs.js.map +1 -1
- package/dist/control-serialization.es.js +1 -4
- package/dist/control-serialization.es.js.map +1 -1
- package/dist/controls.cjs.js +6 -5
- package/dist/controls.cjs.js.map +1 -1
- package/dist/controls.es.js +2 -4
- package/dist/controls.es.js.map +1 -1
- package/dist/index.cjs.js +47 -14
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.cjs10.js +171 -248
- 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 +1 -3
- package/dist/index.cjs2.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 -42
- package/dist/index.cjs8.js.map +1 -1
- package/dist/index.cjs9.js +12 -229
- package/dist/index.cjs9.js.map +1 -1
- package/dist/index.es.js +47 -14
- package/dist/index.es.js.map +1 -1
- package/dist/index.es10.js +172 -249
- 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 +2 -4
- package/dist/index.es2.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 -40
- package/dist/index.es8.js.map +1 -1
- package/dist/index.es9.js +11 -224
- package/dist/index.es9.js.map +1 -1
- package/dist/main.cjs.js +0 -3
- package/dist/main.cjs.js.map +1 -1
- package/dist/main.es.js +0 -3
- package/dist/main.es.js.map +1 -1
- package/dist/next.cjs.js +1 -2
- package/dist/next.cjs.js.map +1 -1
- package/dist/next.es.js +1 -2
- package/dist/next.es.js.map +1 -1
- package/dist/prop-controllers.cjs.js +0 -3
- package/dist/prop-controllers.cjs.js.map +1 -1
- package/dist/prop-controllers.es.js +0 -3
- package/dist/prop-controllers.es.js.map +1 -1
- package/dist/react-page.cjs.js +927 -1573
- package/dist/react-page.cjs.js.map +1 -1
- package/dist/react-page.es.js +923 -1559
- package/dist/react-page.es.js.map +1 -1
- package/dist/react.cjs.js +1 -2
- package/dist/react.cjs.js.map +1 -1
- package/dist/react.es.js +1 -2
- package/dist/react.es.js.map +1 -1
- 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 +172 -55
- package/dist/slate.cjs.js.map +1 -1
- package/dist/slate.es.js +172 -55
- package/dist/slate.es.js.map +1 -1
- package/dist/types/src/api/react.d.ts.map +1 -1
- 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/page/Page.d.ts.map +1 -1
- package/dist/types/src/controls/control.d.ts +3 -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 +1 -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 +7 -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 +16 -7
- package/dist/types/src/controls/style-v2.d.ts.map +1 -1
- 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 +4 -2
- package/dist/types/src/prop-controllers/descriptors.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 +3 -1
- 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.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/style-v2.d.ts +10 -1
- package/dist/types/src/runtimes/react/controls/style-v2.d.ts.map +1 -1
- 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 +1 -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 +1 -0
- package/dist/types/src/slate/InlineModePlugin/index.d.ts.map +1 -1
- package/dist/types/src/slate/TextAlignPlugin/index.d.ts +1 -1
- package/dist/types/src/slate/TextAlignPlugin/index.d.ts.map +1 -1
- package/dist/types/src/slate/index.d.ts +1 -0
- package/dist/types/src/slate/index.d.ts.map +1 -1
- package/dist/types/src/slate/types.d.ts +21 -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/package.json +1 -1
package/dist/react-page.cjs.js
CHANGED
|
@@ -32,9 +32,6 @@ var css = require("@emotion/css");
|
|
|
32
32
|
var serialize = require("@emotion/serialize");
|
|
33
33
|
var utils = require("@emotion/utils");
|
|
34
34
|
var slate = require("slate");
|
|
35
|
-
var isHotkey = require("is-hotkey");
|
|
36
|
-
require("slate-react");
|
|
37
|
-
var jsxRuntime = require("react/jsx-runtime");
|
|
38
35
|
function _interopDefaultLegacy(e) {
|
|
39
36
|
return e && typeof e === "object" && "default" in e ? e : { "default": e };
|
|
40
37
|
}
|
|
@@ -60,7 +57,6 @@ function _interopNamespace(e) {
|
|
|
60
57
|
}
|
|
61
58
|
var thunk__default = /* @__PURE__ */ _interopDefaultLegacy(thunk);
|
|
62
59
|
var React__namespace = /* @__PURE__ */ _interopNamespace(React);
|
|
63
|
-
var isHotkey__default = /* @__PURE__ */ _interopDefaultLegacy(isHotkey);
|
|
64
60
|
const ComponentIcon = {
|
|
65
61
|
Billing: "billing",
|
|
66
62
|
Bolt: "bolt",
|
|
@@ -325,92 +321,199 @@ function copyColorData(value, context) {
|
|
|
325
321
|
swatchId: (_a2 = context.replacementContext.swatchIds.get(value.swatchId)) != null ? _a2 : value.swatchId
|
|
326
322
|
});
|
|
327
323
|
}
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
}
|
|
333
|
-
function Image$1(config = {}) {
|
|
334
|
-
return { type: ImageControlType, config };
|
|
324
|
+
class PropController {
|
|
325
|
+
constructor(send) {
|
|
326
|
+
__publicField(this, "send");
|
|
327
|
+
this.send = send;
|
|
328
|
+
}
|
|
335
329
|
}
|
|
336
|
-
|
|
337
|
-
|
|
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) {
|
|
338
352
|
var _a2;
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
}
|
|
343
|
-
if (void 0) {
|
|
344
|
-
const { describe, test, expect } = void 0;
|
|
345
|
-
describe.concurrent("image copy", () => {
|
|
346
|
-
test("image is replaced by a one in replacement context", () => {
|
|
347
|
-
const data = "file-id";
|
|
348
|
-
const expected = "testing";
|
|
349
|
-
const replacementContext = {
|
|
350
|
-
elementHtmlIds: /* @__PURE__ */ new Set(),
|
|
351
|
-
elementKeys: /* @__PURE__ */ new Map(),
|
|
352
|
-
swatchIds: /* @__PURE__ */ new Map(),
|
|
353
|
-
fileIds: /* @__PURE__ */ new Map([["file-id", "testing"]]),
|
|
354
|
-
typographyIds: /* @__PURE__ */ new Map(),
|
|
355
|
-
tableIds: /* @__PURE__ */ new Map(),
|
|
356
|
-
tableColumnIds: /* @__PURE__ */ new Map(),
|
|
357
|
-
pageIds: /* @__PURE__ */ new Map(),
|
|
358
|
-
globalElementIds: /* @__PURE__ */ new Map(),
|
|
359
|
-
globalElementData: /* @__PURE__ */ new Map()
|
|
360
|
-
};
|
|
361
|
-
const result = copyImageData(data, {
|
|
362
|
-
replacementContext,
|
|
363
|
-
copyElement: (node) => node
|
|
364
|
-
});
|
|
365
|
-
expect(result).toMatchObject(expected);
|
|
366
|
-
});
|
|
367
|
-
});
|
|
353
|
+
return {
|
|
354
|
+
type: StyleControlType,
|
|
355
|
+
config: { properties: (_a2 = params == null ? void 0 : params.properties) != null ? _a2 : StyleControlDefaultProperties }
|
|
356
|
+
};
|
|
368
357
|
}
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
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
|
+
}
|
|
372
378
|
}
|
|
373
|
-
function
|
|
374
|
-
var _a2;
|
|
379
|
+
function copyStyleData(value, context) {
|
|
375
380
|
if (value == null)
|
|
376
381
|
return value;
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
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)
|
|
384
397
|
});
|
|
385
398
|
}
|
|
399
|
+
return {
|
|
400
|
+
borderTop: copyBorderSide(border.borderTop),
|
|
401
|
+
borderBottom: copyBorderSide(border.borderBottom),
|
|
402
|
+
borderRight: copyBorderSide(border.borderRight),
|
|
403
|
+
borderLeft: copyBorderSide(border.borderLeft)
|
|
404
|
+
};
|
|
386
405
|
}
|
|
387
|
-
return value;
|
|
406
|
+
return __spreadProps(__spreadValues({}, value), { border: copyResponsiveBorder(value.border) });
|
|
388
407
|
}
|
|
389
408
|
if (void 0) {
|
|
390
409
|
const { describe, test, expect } = void 0;
|
|
391
|
-
describe.concurrent("
|
|
392
|
-
test("
|
|
393
|
-
const
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
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
|
+
]
|
|
399
500
|
};
|
|
400
|
-
const expected = JSON.parse(JSON.stringify(
|
|
501
|
+
const expected = JSON.parse(JSON.stringify(value).replaceAll("U3dhdGNoOmJjMDkwZWJjLTZkZDUtNDY1NS1hMDY0LTg3ZDAxM2U4YTFhNA==", "testing"));
|
|
401
502
|
const replacementContext = {
|
|
402
503
|
elementHtmlIds: /* @__PURE__ */ new Set(),
|
|
403
504
|
elementKeys: /* @__PURE__ */ new Map(),
|
|
404
|
-
swatchIds: /* @__PURE__ */ new Map(
|
|
405
|
-
|
|
505
|
+
swatchIds: /* @__PURE__ */ new Map([
|
|
506
|
+
["U3dhdGNoOmJjMDkwZWJjLTZkZDUtNDY1NS1hMDY0LTg3ZDAxM2U4YTFhNA==", "testing"]
|
|
507
|
+
]),
|
|
508
|
+
fileIds: /* @__PURE__ */ new Map(),
|
|
406
509
|
typographyIds: /* @__PURE__ */ new Map(),
|
|
407
510
|
tableIds: /* @__PURE__ */ new Map(),
|
|
408
511
|
tableColumnIds: /* @__PURE__ */ new Map(),
|
|
409
|
-
|
|
512
|
+
pageIds: /* @__PURE__ */ new Map(),
|
|
410
513
|
globalElementIds: /* @__PURE__ */ new Map(),
|
|
411
514
|
globalElementData: /* @__PURE__ */ new Map()
|
|
412
515
|
};
|
|
413
|
-
const result =
|
|
516
|
+
const result = copyStyleData(value, {
|
|
414
517
|
replacementContext,
|
|
415
518
|
copyElement: (node) => node
|
|
416
519
|
});
|
|
@@ -418,30 +521,340 @@ if (void 0) {
|
|
|
418
521
|
});
|
|
419
522
|
});
|
|
420
523
|
}
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
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
|
+
}
|
|
856
|
+
}
|
|
857
|
+
class RichTextPropController extends PropController {
|
|
445
858
|
constructor() {
|
|
446
859
|
super(...arguments);
|
|
447
860
|
__publicField(this, "editor", null);
|
|
@@ -533,13 +946,13 @@ function createPropController(descriptor, send) {
|
|
|
533
946
|
case StyleControlType:
|
|
534
947
|
return new StyleControl(send);
|
|
535
948
|
case StyleV2ControlType:
|
|
536
|
-
return new StyleV2Control(send);
|
|
949
|
+
return new StyleV2Control(send, descriptor);
|
|
537
950
|
default:
|
|
538
951
|
return new DefaultPropController(send);
|
|
539
952
|
}
|
|
540
953
|
}
|
|
541
954
|
const ListControlType = "makeswift::controls::list";
|
|
542
|
-
function List
|
|
955
|
+
function List(config) {
|
|
543
956
|
return { type: ListControlType, config };
|
|
544
957
|
}
|
|
545
958
|
const ListControlMessageType = {
|
|
@@ -590,259 +1003,65 @@ class ListControl extends PropController {
|
|
|
590
1003
|
this.controls = /* @__PURE__ */ new Map();
|
|
591
1004
|
}
|
|
592
1005
|
}
|
|
593
|
-
function copyListData(
|
|
1006
|
+
function copyListData(definition, value, context) {
|
|
594
1007
|
if (value == null)
|
|
595
1008
|
return value;
|
|
596
1009
|
return value && value.map((item) => __spreadProps(__spreadValues({}, item), {
|
|
597
|
-
value: copy(
|
|
1010
|
+
value: copy(definition.config.type, item.value, context)
|
|
598
1011
|
}));
|
|
599
1012
|
}
|
|
600
|
-
const ShapeControlType = "makeswift::controls::shape";
|
|
601
|
-
function Shape
|
|
602
|
-
return { type: ShapeControlType, config };
|
|
603
|
-
}
|
|
604
|
-
const ShapeControlMessageType = {
|
|
605
|
-
SHAPE_CONTROL_CHILD_CONTROL_MESSAGE: "makeswift::controls::shape::message::child-control-message"
|
|
606
|
-
};
|
|
607
|
-
class ShapeControl extends PropController {
|
|
608
|
-
constructor(send, descriptor) {
|
|
609
|
-
super(send);
|
|
610
|
-
__publicField(this, "controls");
|
|
611
|
-
__publicField(this, "descriptor");
|
|
612
|
-
__publicField(this, "send");
|
|
613
|
-
__publicField(this, "setControls", () => {
|
|
614
|
-
const controls = /* @__PURE__ */ new Map();
|
|
615
|
-
const children = this.descriptor.config.type;
|
|
616
|
-
Object.keys(children).forEach((key) => {
|
|
617
|
-
const control = createPropController(children[key], (message) => this.send({
|
|
618
|
-
type: ShapeControlMessageType.SHAPE_CONTROL_CHILD_CONTROL_MESSAGE,
|
|
619
|
-
payload: { message, key }
|
|
620
|
-
}));
|
|
621
|
-
controls.set(key, control);
|
|
622
|
-
});
|
|
623
|
-
this.controls = controls;
|
|
624
|
-
return this.controls;
|
|
625
|
-
});
|
|
626
|
-
__publicField(this, "recv", (message) => {
|
|
627
|
-
switch (message.type) {
|
|
628
|
-
case ShapeControlMessageType.SHAPE_CONTROL_CHILD_CONTROL_MESSAGE: {
|
|
629
|
-
const control = this.controls.get(message.payload.key);
|
|
630
|
-
if (control == null)
|
|
631
|
-
return;
|
|
632
|
-
const recv = control.recv;
|
|
633
|
-
recv(message.payload.message);
|
|
634
|
-
}
|
|
635
|
-
}
|
|
636
|
-
});
|
|
637
|
-
this.descriptor = descriptor;
|
|
638
|
-
this.send = send;
|
|
639
|
-
this.controls = /* @__PURE__ */ new Map();
|
|
640
|
-
this.setControls();
|
|
641
|
-
}
|
|
642
|
-
}
|
|
643
|
-
function copyShapeData(definition2, value, context) {
|
|
644
|
-
if (value == null)
|
|
645
|
-
return value;
|
|
646
|
-
const newValue = {};
|
|
647
|
-
for (const [key, itemDefinition] of Object.entries(definition2.config.type)) {
|
|
648
|
-
const prop = value[key];
|
|
649
|
-
newValue[key] = copy(itemDefinition, prop, context);
|
|
650
|
-
}
|
|
651
|
-
return newValue;
|
|
652
|
-
}
|
|
653
|
-
const StyleControlType = "makeswift::controls::style";
|
|
654
|
-
const StyleControlProperty = {
|
|
655
|
-
Width: "makeswift::controls::style::property::width",
|
|
656
|
-
Margin: "makeswift::controls::style::property::margin",
|
|
657
|
-
Padding: "makeswift::controls::style::property::padding",
|
|
658
|
-
Border: "makeswift::controls::style::property::border",
|
|
659
|
-
BorderRadius: "makeswift::controls::style::property::border-radius",
|
|
660
|
-
TextStyle: "makeswift::controls::style::property::text-style"
|
|
661
|
-
};
|
|
662
|
-
const StyleControlDefaultProperties = [
|
|
663
|
-
StyleControlProperty.Width,
|
|
664
|
-
StyleControlProperty.Margin
|
|
665
|
-
];
|
|
666
|
-
const AllStyleControlProperties = [
|
|
667
|
-
StyleControlProperty.Width,
|
|
668
|
-
StyleControlProperty.Margin,
|
|
669
|
-
StyleControlProperty.Padding,
|
|
670
|
-
StyleControlProperty.Border,
|
|
671
|
-
StyleControlProperty.BorderRadius,
|
|
672
|
-
StyleControlProperty.TextStyle
|
|
673
|
-
];
|
|
674
|
-
function Style(params) {
|
|
675
|
-
var _a2;
|
|
676
|
-
return {
|
|
677
|
-
type: StyleControlType,
|
|
678
|
-
config: { properties: (_a2 = params == null ? void 0 : params.properties) != null ? _a2 : StyleControlDefaultProperties }
|
|
679
|
-
};
|
|
680
|
-
}
|
|
681
|
-
Style.Default = StyleControlDefaultProperties;
|
|
682
|
-
Style.All = AllStyleControlProperties;
|
|
683
|
-
Style.Width = StyleControlProperty.Width;
|
|
684
|
-
Style.Margin = StyleControlProperty.Margin;
|
|
685
|
-
Style.Padding = StyleControlProperty.Padding;
|
|
686
|
-
Style.Border = StyleControlProperty.Border;
|
|
687
|
-
Style.BorderRadius = StyleControlProperty.BorderRadius;
|
|
688
|
-
Style.TextStyle = StyleControlProperty.TextStyle;
|
|
689
|
-
const StyleControlMessageType = {
|
|
690
|
-
CHANGE_BOX_MODEL: "makeswift::controls::style::message::change-box-model"
|
|
691
|
-
};
|
|
692
|
-
class StyleControl extends PropController {
|
|
693
|
-
constructor(send) {
|
|
694
|
-
super(send);
|
|
695
|
-
}
|
|
696
|
-
changeBoxModel(boxModel) {
|
|
697
|
-
this.send({ type: StyleControlMessageType.CHANGE_BOX_MODEL, payload: { boxModel } });
|
|
698
|
-
}
|
|
699
|
-
recv() {
|
|
700
|
-
}
|
|
701
|
-
}
|
|
702
|
-
function copyStyleData(value, context) {
|
|
703
|
-
if (value == null)
|
|
704
|
-
return value;
|
|
705
|
-
function copyResponsiveBorder(responsiveBorder) {
|
|
706
|
-
if (responsiveBorder == null)
|
|
707
|
-
return void 0;
|
|
708
|
-
return responsiveBorder.map((deviceBorder) => __spreadProps(__spreadValues({}, deviceBorder), {
|
|
709
|
-
value: copyBorder(deviceBorder.value)
|
|
710
|
-
}));
|
|
711
|
-
}
|
|
712
|
-
function copyBorder(border) {
|
|
713
|
-
function copyBorderSide(side) {
|
|
714
|
-
if (side == null)
|
|
715
|
-
return null;
|
|
716
|
-
if (side.color == null)
|
|
717
|
-
return side;
|
|
718
|
-
return __spreadProps(__spreadValues({}, side), {
|
|
719
|
-
color: copyColorData(side.color, context)
|
|
720
|
-
});
|
|
721
|
-
}
|
|
722
|
-
return {
|
|
723
|
-
borderTop: copyBorderSide(border.borderTop),
|
|
724
|
-
borderBottom: copyBorderSide(border.borderBottom),
|
|
725
|
-
borderRight: copyBorderSide(border.borderRight),
|
|
726
|
-
borderLeft: copyBorderSide(border.borderLeft)
|
|
727
|
-
};
|
|
728
|
-
}
|
|
729
|
-
return __spreadProps(__spreadValues({}, value), { border: copyResponsiveBorder(value.border) });
|
|
730
|
-
}
|
|
731
|
-
if (void 0) {
|
|
732
|
-
const { describe, test, expect } = void 0;
|
|
733
|
-
describe.concurrent("style copy", () => {
|
|
734
|
-
test("colors are replaced", () => {
|
|
735
|
-
const value = {
|
|
736
|
-
width: [
|
|
737
|
-
{
|
|
738
|
-
value: {
|
|
739
|
-
unit: "px",
|
|
740
|
-
value: 100
|
|
741
|
-
},
|
|
742
|
-
deviceId: "desktop"
|
|
743
|
-
}
|
|
744
|
-
],
|
|
745
|
-
border: [
|
|
746
|
-
{
|
|
747
|
-
value: {
|
|
748
|
-
borderTop: {
|
|
749
|
-
color: {
|
|
750
|
-
alpha: 1,
|
|
751
|
-
swatchId: "U3dhdGNoOmJjMDkwZWJjLTZkZDUtNDY1NS1hMDY0LTg3ZDAxM2U4YTFhNA=="
|
|
752
|
-
},
|
|
753
|
-
style: "solid",
|
|
754
|
-
width: 9
|
|
755
|
-
},
|
|
756
|
-
borderLeft: {
|
|
757
|
-
color: {
|
|
758
|
-
alpha: 1,
|
|
759
|
-
swatchId: "U3dhdGNoOmJjMDkwZWJjLTZkZDUtNDY1NS1hMDY0LTg3ZDAxM2U4YTFhNA=="
|
|
760
|
-
},
|
|
761
|
-
style: "solid",
|
|
762
|
-
width: 9
|
|
763
|
-
},
|
|
764
|
-
borderRight: {
|
|
765
|
-
color: {
|
|
766
|
-
alpha: 1,
|
|
767
|
-
swatchId: "U3dhdGNoOmJjMDkwZWJjLTZkZDUtNDY1NS1hMDY0LTg3ZDAxM2U4YTFhNA=="
|
|
768
|
-
},
|
|
769
|
-
style: "solid",
|
|
770
|
-
width: 9
|
|
771
|
-
},
|
|
772
|
-
borderBottom: {
|
|
773
|
-
color: {
|
|
774
|
-
alpha: 1,
|
|
775
|
-
swatchId: "U3dhdGNoOmJjMDkwZWJjLTZkZDUtNDY1NS1hMDY0LTg3ZDAxM2U4YTFhNA=="
|
|
776
|
-
},
|
|
777
|
-
style: "solid",
|
|
778
|
-
width: 9
|
|
779
|
-
}
|
|
780
|
-
},
|
|
781
|
-
deviceId: "desktop"
|
|
782
|
-
}
|
|
783
|
-
],
|
|
784
|
-
textStyle: [
|
|
785
|
-
{
|
|
786
|
-
value: {
|
|
787
|
-
fontSize: {
|
|
788
|
-
unit: "px",
|
|
789
|
-
value: 46
|
|
790
|
-
},
|
|
791
|
-
fontStyle: [],
|
|
792
|
-
fontFamily: "Oswald",
|
|
793
|
-
fontWeight: 400,
|
|
794
|
-
letterSpacing: 5.2,
|
|
795
|
-
textTransform: []
|
|
796
|
-
},
|
|
797
|
-
deviceId: "desktop"
|
|
798
|
-
}
|
|
799
|
-
],
|
|
800
|
-
borderRadius: [
|
|
801
|
-
{
|
|
802
|
-
value: {
|
|
803
|
-
borderTopLeftRadius: {
|
|
804
|
-
unit: "px",
|
|
805
|
-
value: 4
|
|
806
|
-
},
|
|
807
|
-
borderTopRightRadius: {
|
|
808
|
-
unit: "px",
|
|
809
|
-
value: 4
|
|
810
|
-
},
|
|
811
|
-
borderBottomLeftRadius: {
|
|
812
|
-
unit: "px",
|
|
813
|
-
value: 4
|
|
814
|
-
},
|
|
815
|
-
borderBottomRightRadius: {
|
|
816
|
-
unit: "px",
|
|
817
|
-
value: 4
|
|
818
|
-
}
|
|
819
|
-
},
|
|
820
|
-
deviceId: "desktop"
|
|
821
|
-
}
|
|
822
|
-
]
|
|
823
|
-
};
|
|
824
|
-
const expected = JSON.parse(JSON.stringify(value).replaceAll("U3dhdGNoOmJjMDkwZWJjLTZkZDUtNDY1NS1hMDY0LTg3ZDAxM2U4YTFhNA==", "testing"));
|
|
825
|
-
const replacementContext = {
|
|
826
|
-
elementHtmlIds: /* @__PURE__ */ new Set(),
|
|
827
|
-
elementKeys: /* @__PURE__ */ new Map(),
|
|
828
|
-
swatchIds: /* @__PURE__ */ new Map([
|
|
829
|
-
["U3dhdGNoOmJjMDkwZWJjLTZkZDUtNDY1NS1hMDY0LTg3ZDAxM2U4YTFhNA==", "testing"]
|
|
830
|
-
]),
|
|
831
|
-
fileIds: /* @__PURE__ */ new Map(),
|
|
832
|
-
typographyIds: /* @__PURE__ */ new Map(),
|
|
833
|
-
tableIds: /* @__PURE__ */ new Map(),
|
|
834
|
-
tableColumnIds: /* @__PURE__ */ new Map(),
|
|
835
|
-
pageIds: /* @__PURE__ */ new Map(),
|
|
836
|
-
globalElementIds: /* @__PURE__ */ new Map(),
|
|
837
|
-
globalElementData: /* @__PURE__ */ new Map()
|
|
838
|
-
};
|
|
839
|
-
const result = copyStyleData(value, {
|
|
840
|
-
replacementContext,
|
|
841
|
-
copyElement: (node) => node
|
|
1013
|
+
const ShapeControlType = "makeswift::controls::shape";
|
|
1014
|
+
function Shape(config) {
|
|
1015
|
+
return { type: ShapeControlType, config };
|
|
1016
|
+
}
|
|
1017
|
+
const ShapeControlMessageType = {
|
|
1018
|
+
SHAPE_CONTROL_CHILD_CONTROL_MESSAGE: "makeswift::controls::shape::message::child-control-message"
|
|
1019
|
+
};
|
|
1020
|
+
class ShapeControl extends PropController {
|
|
1021
|
+
constructor(send, descriptor) {
|
|
1022
|
+
super(send);
|
|
1023
|
+
__publicField(this, "controls");
|
|
1024
|
+
__publicField(this, "descriptor");
|
|
1025
|
+
__publicField(this, "send");
|
|
1026
|
+
__publicField(this, "setControls", () => {
|
|
1027
|
+
const controls = /* @__PURE__ */ new Map();
|
|
1028
|
+
const children = this.descriptor.config.type;
|
|
1029
|
+
Object.keys(children).forEach((key) => {
|
|
1030
|
+
const control = createPropController(children[key], (message) => this.send({
|
|
1031
|
+
type: ShapeControlMessageType.SHAPE_CONTROL_CHILD_CONTROL_MESSAGE,
|
|
1032
|
+
payload: { message, key }
|
|
1033
|
+
}));
|
|
1034
|
+
controls.set(key, control);
|
|
842
1035
|
});
|
|
843
|
-
|
|
1036
|
+
this.controls = controls;
|
|
1037
|
+
return this.controls;
|
|
844
1038
|
});
|
|
845
|
-
|
|
1039
|
+
__publicField(this, "recv", (message) => {
|
|
1040
|
+
switch (message.type) {
|
|
1041
|
+
case ShapeControlMessageType.SHAPE_CONTROL_CHILD_CONTROL_MESSAGE: {
|
|
1042
|
+
const control = this.controls.get(message.payload.key);
|
|
1043
|
+
if (control == null)
|
|
1044
|
+
return;
|
|
1045
|
+
const recv = control.recv;
|
|
1046
|
+
recv(message.payload.message);
|
|
1047
|
+
}
|
|
1048
|
+
}
|
|
1049
|
+
});
|
|
1050
|
+
this.descriptor = descriptor;
|
|
1051
|
+
this.send = send;
|
|
1052
|
+
this.controls = /* @__PURE__ */ new Map();
|
|
1053
|
+
this.setControls();
|
|
1054
|
+
}
|
|
1055
|
+
}
|
|
1056
|
+
function copyShapeData(definition, value, context) {
|
|
1057
|
+
if (value == null)
|
|
1058
|
+
return value;
|
|
1059
|
+
const newValue = {};
|
|
1060
|
+
for (const [key, itemDefinition] of Object.entries(definition.config.type)) {
|
|
1061
|
+
const prop = value[key];
|
|
1062
|
+
newValue[key] = copy(itemDefinition, prop, context);
|
|
1063
|
+
}
|
|
1064
|
+
return newValue;
|
|
846
1065
|
}
|
|
847
1066
|
const SlotControlType = "makeswift::controls::slot";
|
|
848
1067
|
function Slot() {
|
|
@@ -1627,923 +1846,155 @@ function copy$1(descriptor, value, context) {
|
|
|
1627
1846
|
return copy$6(value, context);
|
|
1628
1847
|
case "Table":
|
|
1629
1848
|
return copy$5(value, context);
|
|
1630
|
-
case "Border":
|
|
1631
|
-
return copy$4(value, context);
|
|
1632
|
-
case "RichText":
|
|
1633
|
-
return copy$3(value, context);
|
|
1634
|
-
case "ElementID":
|
|
1635
|
-
return copy$2(value, context);
|
|
1636
|
-
default:
|
|
1637
|
-
return value;
|
|
1638
|
-
}
|
|
1639
|
-
}
|
|
1640
|
-
function copyElementReference(value, context) {
|
|
1641
|
-
return context.replacementContext.globalElementIds.get(value) || value;
|
|
1642
|
-
}
|
|
1643
|
-
function copy(definition2, value, context) {
|
|
1644
|
-
switch (definition2.type) {
|
|
1645
|
-
case Types.Backgrounds:
|
|
1646
|
-
case Types.Grid:
|
|
1647
|
-
case Types.NavigationLinks:
|
|
1648
|
-
case Types.Link:
|
|
1649
|
-
case Types.Shadows:
|
|
1650
|
-
case Types.Image:
|
|
1651
|
-
case Types.Images:
|
|
1652
|
-
case Types.ResponsiveColor:
|
|
1653
|
-
case Types.TableFormFields:
|
|
1654
|
-
case Types.Table:
|
|
1655
|
-
case Types.Border:
|
|
1656
|
-
case Types.RichText:
|
|
1657
|
-
case Types.ElementID:
|
|
1658
|
-
return copy$1(definition2, value, context);
|
|
1659
|
-
case ColorControlType:
|
|
1660
|
-
return copyColorData(value, context);
|
|
1661
|
-
case ImageControlType:
|
|
1662
|
-
return copyImageData(value, context);
|
|
1663
|
-
case LinkControlType:
|
|
1664
|
-
return copyLinkData(value, context);
|
|
1665
|
-
case ShapeControlType:
|
|
1666
|
-
return copyShapeData(definition2, value, context);
|
|
1667
|
-
case ListControlType:
|
|
1668
|
-
return copyListData(definition2, value, context);
|
|
1669
|
-
case StyleControlType:
|
|
1670
|
-
return copyStyleData(value, context);
|
|
1671
|
-
case SlotControlType:
|
|
1672
|
-
return copySlotData(value, context);
|
|
1673
|
-
default:
|
|
1674
|
-
return value;
|
|
1675
|
-
}
|
|
1676
|
-
}
|
|
1677
|
-
function merge(definition2, a, b = a, context) {
|
|
1678
|
-
switch (definition2.type) {
|
|
1679
|
-
case SlotControlType:
|
|
1680
|
-
return mergeSlotData(a, b, context);
|
|
1681
|
-
default:
|
|
1682
|
-
return b;
|
|
1683
|
-
}
|
|
1684
|
-
}
|
|
1685
|
-
const SelectControlType = "makeswift::controls::select";
|
|
1686
|
-
function Select(config) {
|
|
1687
|
-
return { type: SelectControlType, config };
|
|
1688
|
-
}
|
|
1689
|
-
const isServer = typeof window === "undefined";
|
|
1690
|
-
const useInsertionEffectSpecifier = "useInsertionEffect";
|
|
1691
|
-
const useInsertionEffect = (_a = React__namespace[useInsertionEffectSpecifier]) != null ? _a : React__namespace.useLayoutEffect;
|
|
1692
|
-
function useStyle(style) {
|
|
1693
|
-
const serialized = serialize.serializeStyles([style], css.cache.registered);
|
|
1694
|
-
utils.registerStyles(css.cache, serialized, false);
|
|
1695
|
-
useInsertionEffect(() => {
|
|
1696
|
-
utils.insertStyles(css.cache, serialized, false);
|
|
1697
|
-
});
|
|
1698
|
-
if (isServer)
|
|
1699
|
-
utils.insertStyles(css.cache, serialized, false);
|
|
1700
|
-
return `${css.cache.key}-${serialized.name}`;
|
|
1701
|
-
}
|
|
1702
|
-
const StyleV2ControlType = "makeswift::controls::style-v2";
|
|
1703
|
-
const unstable_useStyleV2ClassName = useStyle;
|
|
1704
|
-
function unstable_StyleV2(config) {
|
|
1705
|
-
return { type: StyleV2ControlType, config };
|
|
1706
|
-
}
|
|
1707
|
-
const StyleV2ControlMessageType = {
|
|
1708
|
-
CHANGE_BOX_MODEL: "makeswift::controls::style::message::change-box-model"
|
|
1709
|
-
};
|
|
1710
|
-
class StyleV2Control extends PropController {
|
|
1711
|
-
constructor(send) {
|
|
1712
|
-
super(send);
|
|
1713
|
-
}
|
|
1714
|
-
changeBoxModel(boxModel) {
|
|
1715
|
-
this.send({ type: StyleV2ControlMessageType.CHANGE_BOX_MODEL, payload: { boxModel } });
|
|
1716
|
-
}
|
|
1717
|
-
recv() {
|
|
1718
|
-
}
|
|
1719
|
-
}
|
|
1720
|
-
const ObjectType = {
|
|
1721
|
-
Value: "value",
|
|
1722
|
-
Text: "text",
|
|
1723
|
-
Inline: "inline",
|
|
1724
|
-
Block: "block",
|
|
1725
|
-
Document: "document",
|
|
1726
|
-
Leaf: "leaf",
|
|
1727
|
-
Selection: "selection",
|
|
1728
|
-
Mark: "mark",
|
|
1729
|
-
Range: "range",
|
|
1730
|
-
Decoration: "decoration",
|
|
1731
|
-
Annotation: "annotation",
|
|
1732
|
-
Point: "point",
|
|
1733
|
-
Operation: "operation"
|
|
1734
|
-
};
|
|
1735
|
-
const RootBlockType = {
|
|
1736
|
-
Default: "default",
|
|
1737
|
-
Text: "text-block",
|
|
1738
|
-
Paragraph: "paragraph",
|
|
1739
|
-
Heading1: "heading-one",
|
|
1740
|
-
Heading2: "heading-two",
|
|
1741
|
-
Heading3: "heading-three",
|
|
1742
|
-
Heading4: "heading-four",
|
|
1743
|
-
Heading5: "heading-five",
|
|
1744
|
-
Heading6: "heading-six",
|
|
1745
|
-
BlockQuote: "blockquote",
|
|
1746
|
-
UnorderedList: "unordered-list",
|
|
1747
|
-
OrderedList: "ordered-list"
|
|
1748
|
-
};
|
|
1749
|
-
const BlockType = __spreadProps(__spreadValues({}, RootBlockType), {
|
|
1750
|
-
ListItem: "list-item",
|
|
1751
|
-
ListItemChild: "list-item-child"
|
|
1752
|
-
});
|
|
1753
|
-
const InlineType = {
|
|
1754
|
-
Code: "code",
|
|
1755
|
-
SuperScript: "superscript",
|
|
1756
|
-
SubScript: "subscript",
|
|
1757
|
-
Link: "link"
|
|
1758
|
-
};
|
|
1759
|
-
const BlockTextAlignment = {
|
|
1760
|
-
Left: "left",
|
|
1761
|
-
Center: "center",
|
|
1762
|
-
Right: "right",
|
|
1763
|
-
Justify: "justify"
|
|
1764
|
-
};
|
|
1765
|
-
const ElementUtils = {
|
|
1766
|
-
isRootBlock(node) {
|
|
1767
|
-
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));
|
|
1768
|
-
},
|
|
1769
|
-
isBlock(node) {
|
|
1770
|
-
return slate.Element.isElement(node) && (this.isRootBlock(node) || slate.Element.isElementType(node, BlockType.ListItem) || slate.Element.isElementType(node, BlockType.ListItemChild));
|
|
1771
|
-
},
|
|
1772
|
-
isInline(node) {
|
|
1773
|
-
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);
|
|
1774
|
-
},
|
|
1775
|
-
isConvertibleToListTextNode(node) {
|
|
1776
|
-
return !this.isList(node) && !this.isListItem(node) && !this.isListItemChild(node);
|
|
1777
|
-
},
|
|
1778
|
-
isList(node) {
|
|
1779
|
-
return slate.Element.isElementType(node, BlockType.OrderedList) || slate.Element.isElementType(node, BlockType.UnorderedList);
|
|
1780
|
-
},
|
|
1781
|
-
isListItem(node) {
|
|
1782
|
-
return slate.Element.isElementType(node, BlockType.ListItem);
|
|
1783
|
-
},
|
|
1784
|
-
isListItemChild(node) {
|
|
1785
|
-
return slate.Element.isElementType(node, BlockType.ListItemChild);
|
|
1786
|
-
},
|
|
1787
|
-
createText() {
|
|
1788
|
-
return { text: "" };
|
|
1789
|
-
},
|
|
1790
|
-
createParagraph() {
|
|
1791
|
-
return {
|
|
1792
|
-
children: [this.createText()],
|
|
1793
|
-
type: BlockType.Paragraph
|
|
1794
|
-
};
|
|
1795
|
-
},
|
|
1796
|
-
createList(type = BlockType.UnorderedList) {
|
|
1797
|
-
return { children: [this.createText()], type };
|
|
1798
|
-
},
|
|
1799
|
-
createListItem() {
|
|
1800
|
-
return {
|
|
1801
|
-
children: [this.createListItemChild()],
|
|
1802
|
-
type: BlockType.ListItem
|
|
1803
|
-
};
|
|
1804
|
-
},
|
|
1805
|
-
createListItemChild() {
|
|
1806
|
-
return {
|
|
1807
|
-
children: [this.createText()],
|
|
1808
|
-
type: BlockType.ListItemChild
|
|
1809
|
-
};
|
|
1810
|
-
}
|
|
1811
|
-
};
|
|
1812
|
-
function unhangRange(editor, range) {
|
|
1813
|
-
let [start, end] = slate.Range.edges(range);
|
|
1814
|
-
if (start.offset !== 0 || end.offset !== 0 || slate.Range.isCollapsed(range)) {
|
|
1815
|
-
return range;
|
|
1816
|
-
}
|
|
1817
|
-
const endBlock = slate.Editor.above(editor, {
|
|
1818
|
-
at: end,
|
|
1819
|
-
match: (n) => slate.Element.isElement(n) && slate.Editor.isBlock(editor, n)
|
|
1820
|
-
});
|
|
1821
|
-
const blockPath = endBlock ? endBlock[1] : [];
|
|
1822
|
-
const first = slate.Editor.start(editor, start);
|
|
1823
|
-
const before = { anchor: first, focus: end };
|
|
1824
|
-
let skip = true;
|
|
1825
|
-
for (const [node, path] of slate.Editor.nodes(editor, {
|
|
1826
|
-
at: before,
|
|
1827
|
-
match: slate.Text.isText,
|
|
1828
|
-
reverse: true
|
|
1829
|
-
})) {
|
|
1830
|
-
if (skip) {
|
|
1831
|
-
skip = false;
|
|
1832
|
-
continue;
|
|
1833
|
-
}
|
|
1834
|
-
if (node.text !== "" || slate.Path.isBefore(path, blockPath)) {
|
|
1835
|
-
end = { path, offset: node.text.length };
|
|
1836
|
-
break;
|
|
1837
|
-
}
|
|
1838
|
-
}
|
|
1839
|
-
return { anchor: start, focus: end };
|
|
1840
|
-
}
|
|
1841
|
-
function getSelection(editor) {
|
|
1842
|
-
if (editor.selection)
|
|
1843
|
-
return unhangRange(editor, editor.selection);
|
|
1844
|
-
return {
|
|
1845
|
-
anchor: slate.Editor.start(editor, []),
|
|
1846
|
-
focus: slate.Editor.end(editor, [])
|
|
1847
|
-
};
|
|
1848
|
-
}
|
|
1849
|
-
function getBlocksInSelection(editor) {
|
|
1850
|
-
return Array.from(slate.Editor.nodes(editor, {
|
|
1851
|
-
at: getSelection(editor),
|
|
1852
|
-
match: (node) => ElementUtils.isRootBlock(node)
|
|
1853
|
-
})).filter((entry) => ElementUtils.isRootBlock(entry[0]));
|
|
1854
|
-
}
|
|
1855
|
-
function getActiveBlockType(editor) {
|
|
1856
|
-
var _a2;
|
|
1857
|
-
const rootBlocks = getBlocksInSelection(editor).map(([node]) => node.type);
|
|
1858
|
-
return rootBlocks.reduce((a, b) => a === b ? b : null, (_a2 = rootBlocks.at(0)) != null ? _a2 : null);
|
|
1859
|
-
}
|
|
1860
|
-
function setBlockKeyForDevice(editor, breakpoints, deviceId, key, value, options) {
|
|
1861
|
-
var _a2, _b;
|
|
1862
|
-
const at = (_a2 = options == null ? void 0 : options.at) != null ? _a2 : editor.selection;
|
|
1863
|
-
if (!at)
|
|
1864
|
-
return;
|
|
1865
|
-
const rootElements = getBlocksInSelection(editor);
|
|
1866
|
-
for (const [node, path] of rootElements) {
|
|
1867
|
-
if (ElementUtils.isBlock(node)) {
|
|
1868
|
-
const deviceValues = (_b = node[key]) != null ? _b : [];
|
|
1869
|
-
const currentDeviceValue = state_breakpoints.findBreakpointOverride(breakpoints, deviceValues, deviceId, (v) => v);
|
|
1870
|
-
const nextDeviceValue = __spreadProps(__spreadValues({}, currentDeviceValue), {
|
|
1871
|
-
deviceId,
|
|
1872
|
-
value
|
|
1873
|
-
});
|
|
1874
|
-
slate.Transforms.setNodes(editor, {
|
|
1875
|
-
[key]: [...deviceValues.filter((v) => v.deviceId !== deviceId), nextDeviceValue]
|
|
1876
|
-
}, { at: path });
|
|
1877
|
-
}
|
|
1878
|
-
}
|
|
1879
|
-
}
|
|
1880
|
-
function clearBlockKeyForDevice(editor, deviceId, key) {
|
|
1881
|
-
var _a2;
|
|
1882
|
-
const rootElements = getBlocksInSelection(editor);
|
|
1883
|
-
for (const [node, path] of rootElements) {
|
|
1884
|
-
if (ElementUtils.isBlock(node)) {
|
|
1885
|
-
const deviceOverrides = (_a2 = node[key]) != null ? _a2 : [];
|
|
1886
|
-
slate.Transforms.setNodes(editor, {
|
|
1887
|
-
[key]: deviceOverrides.filter((v) => v.deviceId !== deviceId)
|
|
1888
|
-
}, { at: path });
|
|
1889
|
-
}
|
|
1890
|
-
}
|
|
1891
|
-
}
|
|
1892
|
-
function wrapInline(editor, inline) {
|
|
1893
|
-
slate.Transforms.wrapNodes(editor, inline, {
|
|
1894
|
-
at: getSelection(editor),
|
|
1895
|
-
split: true
|
|
1896
|
-
});
|
|
1897
|
-
}
|
|
1898
|
-
function unwrapInline(editor, type) {
|
|
1899
|
-
slate.Transforms.unwrapNodes(editor, {
|
|
1900
|
-
match: (node) => ElementUtils.isInline(node) && node.type === type,
|
|
1901
|
-
at: getSelection(editor)
|
|
1902
|
-
});
|
|
1903
|
-
}
|
|
1904
|
-
const EditorUtils = {
|
|
1905
|
-
getFirstAncestorList(editor, path) {
|
|
1906
|
-
try {
|
|
1907
|
-
const parentList = slate.Editor.above(editor, {
|
|
1908
|
-
at: path,
|
|
1909
|
-
match: (node) => ElementUtils.isList(node)
|
|
1910
|
-
});
|
|
1911
|
-
return parentList != null ? parentList : null;
|
|
1912
|
-
} catch (e) {
|
|
1913
|
-
return null;
|
|
1914
|
-
}
|
|
1915
|
-
},
|
|
1916
|
-
getFirstAncestorListItem(editor, path) {
|
|
1917
|
-
try {
|
|
1918
|
-
const parentListItem = slate.Editor.above(editor, {
|
|
1919
|
-
at: path,
|
|
1920
|
-
match: (node) => ElementUtils.isListItem(node)
|
|
1921
|
-
});
|
|
1922
|
-
return parentListItem != null ? parentListItem : null;
|
|
1923
|
-
} catch (e) {
|
|
1924
|
-
return null;
|
|
1925
|
-
}
|
|
1926
|
-
}
|
|
1927
|
-
};
|
|
1928
|
-
const LIST_ITEM_CHILD_POSITION = 0;
|
|
1929
|
-
const LIST_ITEM_LIST_POSITION = 1;
|
|
1930
|
-
function filterForSubtreeRoots(entries) {
|
|
1931
|
-
return entries.filter(([, nodePath]) => !slate.Path.ancestors(nodePath).some((ancestor) => {
|
|
1932
|
-
return entries.some(([, path]) => slate.Path.equals(path, ancestor));
|
|
1933
|
-
}));
|
|
1934
|
-
}
|
|
1935
|
-
function unwrapPath(editor, listItemPath) {
|
|
1936
|
-
const parentList = EditorUtils.getFirstAncestorList(editor, listItemPath);
|
|
1937
|
-
const listItemContainingParentList = EditorUtils.getFirstAncestorListItem(editor, listItemPath);
|
|
1938
|
-
if (!parentList || listItemContainingParentList)
|
|
1939
|
-
return;
|
|
1940
|
-
slate.Editor.withoutNormalizing(editor, () => {
|
|
1941
|
-
const listItemTextPath = [...listItemPath, LIST_ITEM_CHILD_POSITION];
|
|
1942
|
-
const listItemNestedListPath = [...listItemPath, LIST_ITEM_LIST_POSITION];
|
|
1943
|
-
if (slate.Node.has(editor, listItemNestedListPath)) {
|
|
1944
|
-
slate.Transforms.setNodes(editor, { type: parentList[0].type }, { at: listItemNestedListPath });
|
|
1945
|
-
slate.Transforms.liftNodes(editor, { at: listItemNestedListPath });
|
|
1946
|
-
slate.Transforms.liftNodes(editor, { at: slate.Path.next(listItemPath) });
|
|
1947
|
-
}
|
|
1948
|
-
if (slate.Node.has(editor, listItemTextPath)) {
|
|
1949
|
-
slate.Transforms.setNodes(editor, { type: BlockType.Paragraph }, {
|
|
1950
|
-
at: listItemTextPath
|
|
1951
|
-
});
|
|
1952
|
-
slate.Transforms.liftNodes(editor, { at: listItemTextPath });
|
|
1953
|
-
slate.Transforms.liftNodes(editor, { at: listItemPath });
|
|
1954
|
-
}
|
|
1955
|
-
});
|
|
1956
|
-
}
|
|
1957
|
-
function unwrapList(editor, options) {
|
|
1958
|
-
var _a2;
|
|
1959
|
-
const at = (_a2 = options == null ? void 0 : options.at) != null ? _a2 : editor.selection;
|
|
1960
|
-
if (!at)
|
|
1961
|
-
return;
|
|
1962
|
-
const listItems = Array.from(slate.Editor.nodes(editor, {
|
|
1963
|
-
at,
|
|
1964
|
-
match: (node) => {
|
|
1965
|
-
return slate.Element.isElement(node) && ElementUtils.isListItem(node);
|
|
1966
|
-
}
|
|
1967
|
-
}));
|
|
1968
|
-
const subRoots = filterForSubtreeRoots(listItems);
|
|
1969
|
-
const refs = subRoots.map(([_, path]) => slate.Editor.pathRef(editor, path));
|
|
1970
|
-
refs.forEach((ref) => {
|
|
1971
|
-
if (ref.current) {
|
|
1972
|
-
unwrapPath(editor, ref.current);
|
|
1973
|
-
}
|
|
1974
|
-
ref.unref();
|
|
1975
|
-
});
|
|
1976
|
-
}
|
|
1977
|
-
function wrapList(editor, options = { type: BlockType.UnorderedList }) {
|
|
1978
|
-
var _a2;
|
|
1979
|
-
const at = (_a2 = options.at) != null ? _a2 : editor.selection;
|
|
1980
|
-
if (!at)
|
|
1981
|
-
return;
|
|
1982
|
-
const nonListEntries = Array.from(slate.Editor.nodes(editor, {
|
|
1983
|
-
at,
|
|
1984
|
-
match: (node) => {
|
|
1985
|
-
return slate.Element.isElement(node) && ElementUtils.isConvertibleToListTextNode(node);
|
|
1986
|
-
}
|
|
1987
|
-
}));
|
|
1988
|
-
const refs = nonListEntries.map(([_, path]) => slate.Editor.pathRef(editor, path));
|
|
1989
|
-
refs.forEach((ref) => {
|
|
1990
|
-
const path = ref.current;
|
|
1991
|
-
if (path) {
|
|
1992
|
-
slate.Editor.withoutNormalizing(editor, () => {
|
|
1993
|
-
slate.Transforms.setNodes(editor, { type: BlockType.ListItemChild }, {
|
|
1994
|
-
at: path
|
|
1995
|
-
});
|
|
1996
|
-
slate.Transforms.wrapNodes(editor, ElementUtils.createListItem(), {
|
|
1997
|
-
match: (node) => ElementUtils.isListItemChild(node),
|
|
1998
|
-
at: path
|
|
1999
|
-
});
|
|
2000
|
-
slate.Transforms.wrapNodes(editor, ElementUtils.createList(options.type), {
|
|
2001
|
-
at: path
|
|
2002
|
-
});
|
|
2003
|
-
});
|
|
2004
|
-
}
|
|
2005
|
-
ref.unref();
|
|
2006
|
-
});
|
|
2007
|
-
}
|
|
2008
|
-
const LocationUtils = {
|
|
2009
|
-
getStartPath(location) {
|
|
2010
|
-
if (slate.Range.isRange(location))
|
|
2011
|
-
return slate.Range.start(location).path;
|
|
2012
|
-
if (slate.Point.isPoint(location))
|
|
2013
|
-
return location.path;
|
|
2014
|
-
return location;
|
|
2015
|
-
}
|
|
2016
|
-
};
|
|
2017
|
-
function getSelectedListItems(editor) {
|
|
2018
|
-
var _a2, _b;
|
|
2019
|
-
if (!editor.selection)
|
|
2020
|
-
return [];
|
|
2021
|
-
const start = LocationUtils.getStartPath(editor.selection);
|
|
2022
|
-
const listItems = slate.Editor.nodes(editor, {
|
|
2023
|
-
at: editor.selection,
|
|
2024
|
-
match: (node) => ElementUtils.isListItem(node)
|
|
2025
|
-
});
|
|
2026
|
-
const firstAncestorPath = (_b = (_a2 = EditorUtils.getFirstAncestorListItem(editor, start)) == null ? void 0 : _a2[1]) != null ? _b : [];
|
|
2027
|
-
return Array.from(listItems).filter((node) => slate.Path.isDescendant(start, node[1]) ? slate.Path.equals(node[1], firstAncestorPath) : !slate.Path.isAfter(start, node[1]));
|
|
2028
|
-
}
|
|
2029
|
-
function indentPath(editor, path) {
|
|
2030
|
-
const parent = slate.Node.parent(editor, path);
|
|
2031
|
-
if (!path || !slate.Path.hasPrevious(path) || !ElementUtils.isList(parent))
|
|
2032
|
-
return;
|
|
2033
|
-
const previosPath = slate.Path.previous(path);
|
|
2034
|
-
const previousChildListPath = [...previosPath, LIST_ITEM_LIST_POSITION];
|
|
2035
|
-
const previousHasChildList = slate.Node.has(editor, previousChildListPath);
|
|
2036
|
-
slate.Editor.withoutNormalizing(editor, () => {
|
|
2037
|
-
if (!previousHasChildList) {
|
|
2038
|
-
slate.Transforms.insertNodes(editor, ElementUtils.createList(parent.type), {
|
|
2039
|
-
at: previousChildListPath
|
|
2040
|
-
});
|
|
2041
|
-
}
|
|
2042
|
-
const previousChildList = slate.Node.get(editor, previousChildListPath);
|
|
2043
|
-
if (ElementUtils.isList(previousChildList)) {
|
|
2044
|
-
const index = previousHasChildList ? previousChildList.children.length : 0;
|
|
2045
|
-
slate.Transforms.moveNodes(editor, {
|
|
2046
|
-
at: path,
|
|
2047
|
-
to: [...previousChildListPath, index]
|
|
2048
|
-
});
|
|
2049
|
-
}
|
|
2050
|
-
});
|
|
2051
|
-
}
|
|
2052
|
-
function indent(editor) {
|
|
2053
|
-
if (!editor.selection)
|
|
2054
|
-
return;
|
|
2055
|
-
const listItems = getSelectedListItems(editor);
|
|
2056
|
-
const subRoots = filterForSubtreeRoots(listItems);
|
|
2057
|
-
const refs = subRoots.map(([_, path]) => slate.Editor.pathRef(editor, path));
|
|
2058
|
-
refs.forEach((ref) => {
|
|
2059
|
-
if (ref.current) {
|
|
2060
|
-
indentPath(editor, ref.current);
|
|
2061
|
-
}
|
|
2062
|
-
ref.unref();
|
|
2063
|
-
});
|
|
2064
|
-
}
|
|
2065
|
-
function dedentPath(editor, listItemPath) {
|
|
2066
|
-
const parentList = EditorUtils.getFirstAncestorList(editor, listItemPath);
|
|
2067
|
-
const listItemContainingParentList = EditorUtils.getFirstAncestorListItem(editor, listItemPath);
|
|
2068
|
-
if (!parentList || !listItemContainingParentList)
|
|
2069
|
-
return;
|
|
2070
|
-
const [parentListNode, parentListPath] = parentList;
|
|
2071
|
-
const [_, listItemContainingParentListPath] = listItemContainingParentList;
|
|
2072
|
-
const listItemPosition = listItemPath[listItemPath.length - 1];
|
|
2073
|
-
const previousSiblings = parentListNode.children.slice(0, listItemPosition);
|
|
2074
|
-
const nextSiblings = parentListNode.children.slice(listItemPosition + 1);
|
|
2075
|
-
slate.Editor.withoutNormalizing(editor, () => {
|
|
2076
|
-
nextSiblings.forEach(() => {
|
|
2077
|
-
const nextSiblingPath = [...parentListPath, listItemPosition + 1];
|
|
2078
|
-
indentPath(editor, nextSiblingPath);
|
|
2079
|
-
});
|
|
2080
|
-
slate.Transforms.moveNodes(editor, {
|
|
2081
|
-
at: listItemPath,
|
|
2082
|
-
to: slate.Path.next(listItemContainingParentListPath)
|
|
2083
|
-
});
|
|
2084
|
-
if (previousSiblings.length === 0) {
|
|
2085
|
-
slate.Transforms.removeNodes(editor, { at: parentListPath });
|
|
2086
|
-
}
|
|
2087
|
-
});
|
|
1849
|
+
case "Border":
|
|
1850
|
+
return copy$4(value, context);
|
|
1851
|
+
case "RichText":
|
|
1852
|
+
return copy$3(value, context);
|
|
1853
|
+
case "ElementID":
|
|
1854
|
+
return copy$2(value, context);
|
|
1855
|
+
default:
|
|
1856
|
+
return value;
|
|
1857
|
+
}
|
|
2088
1858
|
}
|
|
2089
|
-
function
|
|
2090
|
-
|
|
2091
|
-
return;
|
|
2092
|
-
const listItems = getSelectedListItems(editor);
|
|
2093
|
-
const subRoots = filterForSubtreeRoots(listItems);
|
|
2094
|
-
const refs = subRoots.map(([_, path]) => slate.Editor.pathRef(editor, path));
|
|
2095
|
-
refs.forEach((ref) => {
|
|
2096
|
-
if (ref.current) {
|
|
2097
|
-
dedentPath(editor, ref.current);
|
|
2098
|
-
}
|
|
2099
|
-
ref.unref();
|
|
2100
|
-
});
|
|
1859
|
+
function copyElementReference(value, context) {
|
|
1860
|
+
return context.replacementContext.globalElementIds.get(value) || value;
|
|
2101
1861
|
}
|
|
2102
|
-
function
|
|
2103
|
-
|
|
2104
|
-
|
|
2105
|
-
|
|
2106
|
-
|
|
2107
|
-
|
|
2108
|
-
|
|
2109
|
-
|
|
2110
|
-
|
|
2111
|
-
|
|
2112
|
-
|
|
2113
|
-
|
|
2114
|
-
|
|
2115
|
-
|
|
2116
|
-
|
|
2117
|
-
|
|
2118
|
-
|
|
2119
|
-
|
|
2120
|
-
|
|
2121
|
-
|
|
2122
|
-
|
|
2123
|
-
|
|
2124
|
-
|
|
2125
|
-
|
|
2126
|
-
|
|
2127
|
-
|
|
2128
|
-
|
|
2129
|
-
|
|
2130
|
-
|
|
2131
|
-
|
|
2132
|
-
|
|
2133
|
-
|
|
2134
|
-
function onKeyDown(e, editor) {
|
|
2135
|
-
if (!editor.selection || Array.from(slate.Editor.nodes(editor, {
|
|
2136
|
-
match: (node) => ElementUtils.isListItem(node)
|
|
2137
|
-
})).length === 0)
|
|
2138
|
-
return;
|
|
2139
|
-
if (isHotkey__default["default"]("shift+tab", e)) {
|
|
2140
|
-
e.preventDefault();
|
|
2141
|
-
ListActions.dedent(editor);
|
|
2142
|
-
}
|
|
2143
|
-
if (isHotkey__default["default"]("tab", e)) {
|
|
2144
|
-
e.preventDefault();
|
|
2145
|
-
ListActions.indent(editor);
|
|
2146
|
-
}
|
|
2147
|
-
if (isHotkey__default["default"]("backspace", e)) {
|
|
2148
|
-
if (!editor.selection)
|
|
2149
|
-
return;
|
|
2150
|
-
if (slate.Range.isExpanded(editor.selection))
|
|
2151
|
-
return;
|
|
2152
|
-
const listItem = EditorUtils.getFirstAncestorListItem(editor, editor.selection.anchor.path);
|
|
2153
|
-
if (editor.selection.anchor.offset === 0 && listItem) {
|
|
2154
|
-
e.preventDefault();
|
|
2155
|
-
const parentListItem = EditorUtils.getFirstAncestorListItem(editor, listItem[1]);
|
|
2156
|
-
const list = EditorUtils.getFirstAncestorList(editor, listItem[1]);
|
|
2157
|
-
if (parentListItem) {
|
|
2158
|
-
ListActions.dedent(editor);
|
|
2159
|
-
} else if (list) {
|
|
2160
|
-
ListActions.unwrapList(editor);
|
|
2161
|
-
}
|
|
2162
|
-
return;
|
|
2163
|
-
}
|
|
2164
|
-
}
|
|
2165
|
-
if (isHotkey__default["default"]("enter", e)) {
|
|
2166
|
-
e.preventDefault();
|
|
2167
|
-
if (!editor.selection)
|
|
2168
|
-
return;
|
|
2169
|
-
if (slate.Range.isExpanded(editor.selection)) {
|
|
2170
|
-
slate.Transforms.delete(editor);
|
|
2171
|
-
return;
|
|
2172
|
-
}
|
|
2173
|
-
const listItem = EditorUtils.getFirstAncestorListItem(editor, editor.selection.anchor.path);
|
|
2174
|
-
if (editor.selection.anchor.offset === 0 && listItem && slate.Editor.string(editor, listItem[1]) === "") {
|
|
2175
|
-
const parentListItem = EditorUtils.getFirstAncestorListItem(editor, listItem[1]);
|
|
2176
|
-
if (parentListItem) {
|
|
2177
|
-
ListActions.dedent(editor);
|
|
2178
|
-
} else {
|
|
2179
|
-
ListActions.unwrapList(editor);
|
|
2180
|
-
}
|
|
2181
|
-
return;
|
|
2182
|
-
}
|
|
2183
|
-
slate.Transforms.splitNodes(editor, {
|
|
2184
|
-
at: editor.selection,
|
|
2185
|
-
always: true,
|
|
2186
|
-
match: (node) => ElementUtils.isListItem(node)
|
|
2187
|
-
});
|
|
2188
|
-
}
|
|
2189
|
-
if (isHotkey__default["default"]("shift+enter", e)) {
|
|
2190
|
-
e.preventDefault();
|
|
2191
|
-
editor.insertText("\n");
|
|
1862
|
+
function copy(definition, value, context) {
|
|
1863
|
+
switch (definition.type) {
|
|
1864
|
+
case Types.Backgrounds:
|
|
1865
|
+
case Types.Grid:
|
|
1866
|
+
case Types.NavigationLinks:
|
|
1867
|
+
case Types.Link:
|
|
1868
|
+
case Types.Shadows:
|
|
1869
|
+
case Types.Image:
|
|
1870
|
+
case Types.Images:
|
|
1871
|
+
case Types.ResponsiveColor:
|
|
1872
|
+
case Types.TableFormFields:
|
|
1873
|
+
case Types.Table:
|
|
1874
|
+
case Types.Border:
|
|
1875
|
+
case Types.RichText:
|
|
1876
|
+
case Types.ElementID:
|
|
1877
|
+
return copy$1(definition, value, context);
|
|
1878
|
+
case ColorControlType:
|
|
1879
|
+
return copyColorData(value, context);
|
|
1880
|
+
case ImageControlType:
|
|
1881
|
+
return copyImageData(value, context);
|
|
1882
|
+
case LinkControlType:
|
|
1883
|
+
return copyLinkData(value, context);
|
|
1884
|
+
case ShapeControlType:
|
|
1885
|
+
return copyShapeData(definition, value, context);
|
|
1886
|
+
case ListControlType:
|
|
1887
|
+
return copyListData(definition, value, context);
|
|
1888
|
+
case StyleControlType:
|
|
1889
|
+
return copyStyleData(value, context);
|
|
1890
|
+
case SlotControlType:
|
|
1891
|
+
return copySlotData(value, context);
|
|
1892
|
+
default:
|
|
1893
|
+
return value;
|
|
2192
1894
|
}
|
|
2193
1895
|
}
|
|
2194
|
-
function
|
|
2195
|
-
|
|
2196
|
-
|
|
2197
|
-
|
|
2198
|
-
editor.isInline = (entry) => {
|
|
2199
|
-
return ElementUtils.isInline(entry);
|
|
2200
|
-
};
|
|
2201
|
-
editor.normalizeNode = (entry) => {
|
|
2202
|
-
var _a2;
|
|
2203
|
-
const [normalizationNode, normalizationPath] = entry;
|
|
2204
|
-
if (ElementUtils.isBlock(normalizationNode) && ((_a2 = normalizationNode == null ? void 0 : normalizationNode.textAlign) == null ? void 0 : _a2.length) == 0) {
|
|
2205
|
-
slate.Transforms.unsetNodes(editor, "textAlign", {
|
|
2206
|
-
at: normalizationPath
|
|
2207
|
-
});
|
|
2208
|
-
return;
|
|
2209
|
-
}
|
|
2210
|
-
if (ElementUtils.isListItem(normalizationNode)) {
|
|
2211
|
-
const pathToListItemText = [...normalizationPath, LIST_ITEM_CHILD_POSITION];
|
|
2212
|
-
if (slate.Node.has(editor, pathToListItemText)) {
|
|
2213
|
-
const nodeInListItemTextPosition = slate.Node.get(editor, pathToListItemText);
|
|
2214
|
-
if (ElementUtils.isRootBlock(nodeInListItemTextPosition)) {
|
|
2215
|
-
slate.Transforms.setNodes(editor, {
|
|
2216
|
-
type: BlockType.ListItemChild
|
|
2217
|
-
}, {
|
|
2218
|
-
at: pathToListItemText
|
|
2219
|
-
});
|
|
2220
|
-
return;
|
|
2221
|
-
}
|
|
2222
|
-
} else {
|
|
2223
|
-
slate.Transforms.insertNodes(editor, ElementUtils.createListItem(), {
|
|
2224
|
-
at: pathToListItemText
|
|
2225
|
-
});
|
|
2226
|
-
return;
|
|
2227
|
-
}
|
|
2228
|
-
}
|
|
2229
|
-
if (!slate.Text.isText(normalizationNode)) {
|
|
2230
|
-
const mergeableChildren = Array.from(slate.Node.children(editor, normalizationPath)).map((child, index, children) => {
|
|
2231
|
-
const potentialNodeToBeMerged = children.at(index + 1);
|
|
2232
|
-
if (!potentialNodeToBeMerged || !ElementUtils.isList(potentialNodeToBeMerged[0]) || !ElementUtils.isList(child[0]) || potentialNodeToBeMerged[0].type !== child[0].type) {
|
|
2233
|
-
return null;
|
|
2234
|
-
}
|
|
2235
|
-
return [slate.Editor.pathRef(editor, child[1]), slate.Editor.pathRef(editor, potentialNodeToBeMerged[1])];
|
|
2236
|
-
}).filter((mergeableNodes) => Boolean(mergeableNodes));
|
|
2237
|
-
if (mergeableChildren.length !== 0) {
|
|
2238
|
-
mergeableChildren.reverse().forEach(([nodePathRef, nodeToBeMergedPathRef]) => {
|
|
2239
|
-
const nodePath = nodePathRef.current;
|
|
2240
|
-
const nodeToBeMergedPath = nodeToBeMergedPathRef.current;
|
|
2241
|
-
if (nodePath == null || nodeToBeMergedPath == null)
|
|
2242
|
-
return;
|
|
2243
|
-
const nodeChildren = Array.from(slate.Node.children(editor, nodePath));
|
|
2244
|
-
const childrenToBeMerged = Array.from(slate.Node.children(editor, nodeToBeMergedPath));
|
|
2245
|
-
slate.Editor.withoutNormalizing(editor, () => {
|
|
2246
|
-
childrenToBeMerged.reverse().forEach(([_, childPath]) => {
|
|
2247
|
-
slate.Transforms.moveNodes(editor, {
|
|
2248
|
-
at: childPath,
|
|
2249
|
-
to: [...nodePath, nodeChildren.length]
|
|
2250
|
-
});
|
|
2251
|
-
});
|
|
2252
|
-
slate.Transforms.removeNodes(editor, {
|
|
2253
|
-
at: nodeToBeMergedPath
|
|
2254
|
-
});
|
|
2255
|
-
});
|
|
2256
|
-
nodePathRef.unref();
|
|
2257
|
-
nodeToBeMergedPathRef.unref();
|
|
2258
|
-
});
|
|
2259
|
-
return;
|
|
2260
|
-
}
|
|
2261
|
-
}
|
|
2262
|
-
normalizeNode(entry);
|
|
2263
|
-
};
|
|
2264
|
-
return editor;
|
|
2265
|
-
}
|
|
2266
|
-
const definition = Select({
|
|
2267
|
-
label: "Block",
|
|
2268
|
-
labelOrientation: "horizontal",
|
|
2269
|
-
options: [{
|
|
2270
|
-
value: BlockType.Paragraph,
|
|
2271
|
-
label: "Paragraph"
|
|
2272
|
-
}, {
|
|
2273
|
-
value: BlockType.Heading1,
|
|
2274
|
-
label: "Heading 1"
|
|
2275
|
-
}, {
|
|
2276
|
-
value: BlockType.Heading2,
|
|
2277
|
-
label: "Heading 2"
|
|
2278
|
-
}, {
|
|
2279
|
-
value: BlockType.Heading3,
|
|
2280
|
-
label: "Heading 3"
|
|
2281
|
-
}, {
|
|
2282
|
-
value: BlockType.Heading4,
|
|
2283
|
-
label: "Heading 4"
|
|
2284
|
-
}, {
|
|
2285
|
-
value: BlockType.Heading5,
|
|
2286
|
-
label: "Heading 5"
|
|
2287
|
-
}, {
|
|
2288
|
-
value: BlockType.Heading6,
|
|
2289
|
-
label: "Heading 6"
|
|
2290
|
-
}, {
|
|
2291
|
-
value: BlockType.UnorderedList,
|
|
2292
|
-
label: "Bulleted list"
|
|
2293
|
-
}, {
|
|
2294
|
-
value: BlockType.OrderedList,
|
|
2295
|
-
label: "Numbered list"
|
|
2296
|
-
}, {
|
|
2297
|
-
value: BlockType.BlockQuote,
|
|
2298
|
-
label: "Quote"
|
|
2299
|
-
}],
|
|
2300
|
-
defaultValue: BlockType.Paragraph
|
|
2301
|
-
});
|
|
2302
|
-
function BlockPlugin() {
|
|
2303
|
-
return createRichTextV2Plugin({
|
|
2304
|
-
withPlugin: withBlock,
|
|
2305
|
-
onKeyDown,
|
|
2306
|
-
control: {
|
|
2307
|
-
definition,
|
|
2308
|
-
onChange: (editor, value) => {
|
|
2309
|
-
const activeBlockType = getActiveBlockType(editor);
|
|
2310
|
-
if (value === BlockType.UnorderedList || value === BlockType.OrderedList) {
|
|
2311
|
-
ListActions.toggleList(editor, {
|
|
2312
|
-
type: value,
|
|
2313
|
-
at: getSelection(editor)
|
|
2314
|
-
});
|
|
2315
|
-
} else if (activeBlockType === value) {
|
|
2316
|
-
slate.Transforms.setNodes(editor, {
|
|
2317
|
-
type: BlockType.Default
|
|
2318
|
-
}, {
|
|
2319
|
-
at: getSelection(editor)
|
|
2320
|
-
});
|
|
2321
|
-
} else {
|
|
2322
|
-
ListActions.unwrapList(editor, {
|
|
2323
|
-
at: getSelection(editor)
|
|
2324
|
-
});
|
|
2325
|
-
slate.Transforms.setNodes(editor, {
|
|
2326
|
-
type: value != null ? value : BlockType.Default
|
|
2327
|
-
}, {
|
|
2328
|
-
at: getSelection(editor)
|
|
2329
|
-
});
|
|
2330
|
-
}
|
|
2331
|
-
},
|
|
2332
|
-
getValue: (editor) => {
|
|
2333
|
-
const activeBlock = getActiveBlockType(editor);
|
|
2334
|
-
if (activeBlock === RootBlockType.Text || activeBlock === RootBlockType.Default)
|
|
2335
|
-
return void 0;
|
|
2336
|
-
return activeBlock;
|
|
2337
|
-
}
|
|
2338
|
-
},
|
|
2339
|
-
renderElement: (renderElement) => (props) => /* @__PURE__ */ jsxRuntime.jsx(BlockPluginComponent, __spreadProps(__spreadValues({}, props), {
|
|
2340
|
-
renderElement
|
|
2341
|
-
}))
|
|
2342
|
-
});
|
|
2343
|
-
}
|
|
2344
|
-
function BlockPluginComponent({
|
|
2345
|
-
element,
|
|
2346
|
-
attributes,
|
|
2347
|
-
children,
|
|
2348
|
-
renderElement
|
|
2349
|
-
}) {
|
|
2350
|
-
const blockStyles = [useStyle({
|
|
2351
|
-
margin: 0
|
|
2352
|
-
}), element.className];
|
|
2353
|
-
const quoteStyles = useStyle({
|
|
2354
|
-
padding: "0.5em 10px",
|
|
2355
|
-
fontSize: "1.25em",
|
|
2356
|
-
fontWeight: "300",
|
|
2357
|
-
borderLeft: "5px solid rgba(0, 0, 0, 0.1)"
|
|
2358
|
-
});
|
|
2359
|
-
switch (element.type) {
|
|
2360
|
-
case BlockType.Text:
|
|
2361
|
-
return /* @__PURE__ */ jsxRuntime.jsx("span", __spreadProps(__spreadValues({}, attributes), {
|
|
2362
|
-
className: css.cx(...blockStyles),
|
|
2363
|
-
children
|
|
2364
|
-
}));
|
|
2365
|
-
case BlockType.Paragraph:
|
|
2366
|
-
return /* @__PURE__ */ jsxRuntime.jsx("p", __spreadProps(__spreadValues({}, attributes), {
|
|
2367
|
-
className: css.cx(...blockStyles),
|
|
2368
|
-
children
|
|
2369
|
-
}));
|
|
2370
|
-
case BlockType.Heading1:
|
|
2371
|
-
return /* @__PURE__ */ jsxRuntime.jsx("h1", __spreadProps(__spreadValues({}, attributes), {
|
|
2372
|
-
className: css.cx(...blockStyles),
|
|
2373
|
-
children
|
|
2374
|
-
}));
|
|
2375
|
-
case BlockType.Heading2:
|
|
2376
|
-
return /* @__PURE__ */ jsxRuntime.jsx("h2", __spreadProps(__spreadValues({}, attributes), {
|
|
2377
|
-
className: css.cx(...blockStyles),
|
|
2378
|
-
children
|
|
2379
|
-
}));
|
|
2380
|
-
case BlockType.Heading3:
|
|
2381
|
-
return /* @__PURE__ */ jsxRuntime.jsx("h3", __spreadProps(__spreadValues({}, attributes), {
|
|
2382
|
-
className: css.cx(...blockStyles),
|
|
2383
|
-
children
|
|
2384
|
-
}));
|
|
2385
|
-
case BlockType.Heading4:
|
|
2386
|
-
return /* @__PURE__ */ jsxRuntime.jsx("h4", __spreadProps(__spreadValues({}, attributes), {
|
|
2387
|
-
className: css.cx(...blockStyles),
|
|
2388
|
-
children
|
|
2389
|
-
}));
|
|
2390
|
-
case BlockType.Heading5:
|
|
2391
|
-
return /* @__PURE__ */ jsxRuntime.jsx("h5", __spreadProps(__spreadValues({}, attributes), {
|
|
2392
|
-
className: css.cx(...blockStyles),
|
|
2393
|
-
children
|
|
2394
|
-
}));
|
|
2395
|
-
case BlockType.Heading6:
|
|
2396
|
-
return /* @__PURE__ */ jsxRuntime.jsx("h6", __spreadProps(__spreadValues({}, attributes), {
|
|
2397
|
-
className: css.cx(...blockStyles),
|
|
2398
|
-
children
|
|
2399
|
-
}));
|
|
2400
|
-
case BlockType.BlockQuote:
|
|
2401
|
-
return /* @__PURE__ */ jsxRuntime.jsx("blockquote", __spreadProps(__spreadValues({}, attributes), {
|
|
2402
|
-
className: css.cx(...blockStyles, quoteStyles),
|
|
2403
|
-
children
|
|
2404
|
-
}));
|
|
2405
|
-
case BlockType.OrderedList:
|
|
2406
|
-
return /* @__PURE__ */ jsxRuntime.jsx("ol", __spreadProps(__spreadValues({}, attributes), {
|
|
2407
|
-
className: css.cx(...blockStyles),
|
|
2408
|
-
style: {
|
|
2409
|
-
listStylePosition: "inside"
|
|
2410
|
-
},
|
|
2411
|
-
children
|
|
2412
|
-
}));
|
|
2413
|
-
case BlockType.UnorderedList:
|
|
2414
|
-
return /* @__PURE__ */ jsxRuntime.jsx("ul", __spreadProps(__spreadValues({}, attributes), {
|
|
2415
|
-
className: css.cx(...blockStyles),
|
|
2416
|
-
style: {
|
|
2417
|
-
listStylePosition: "inside"
|
|
2418
|
-
},
|
|
2419
|
-
children
|
|
2420
|
-
}));
|
|
2421
|
-
case BlockType.ListItem:
|
|
2422
|
-
return /* @__PURE__ */ jsxRuntime.jsx("li", __spreadProps(__spreadValues({}, attributes), {
|
|
2423
|
-
className: css.cx(...blockStyles),
|
|
2424
|
-
children
|
|
2425
|
-
}));
|
|
2426
|
-
case BlockType.ListItemChild:
|
|
2427
|
-
return /* @__PURE__ */ jsxRuntime.jsx("span", __spreadProps(__spreadValues({}, attributes), {
|
|
2428
|
-
className: css.cx(...blockStyles),
|
|
2429
|
-
children
|
|
2430
|
-
}));
|
|
2431
|
-
case BlockType.Default:
|
|
2432
|
-
return /* @__PURE__ */ jsxRuntime.jsx("p", __spreadProps(__spreadValues({}, attributes), {
|
|
2433
|
-
className: css.cx(...blockStyles),
|
|
2434
|
-
children
|
|
2435
|
-
}));
|
|
1896
|
+
function merge(definition, a, b = a, context) {
|
|
1897
|
+
switch (definition.type) {
|
|
1898
|
+
case SlotControlType:
|
|
1899
|
+
return mergeSlotData(a, b, context);
|
|
2436
1900
|
default:
|
|
2437
|
-
return
|
|
2438
|
-
children: renderElement({
|
|
2439
|
-
element,
|
|
2440
|
-
attributes,
|
|
2441
|
-
children
|
|
2442
|
-
})
|
|
2443
|
-
});
|
|
1901
|
+
return b;
|
|
2444
1902
|
}
|
|
2445
1903
|
}
|
|
2446
|
-
const
|
|
2447
|
-
const
|
|
2448
|
-
|
|
2449
|
-
|
|
2450
|
-
|
|
2451
|
-
|
|
2452
|
-
|
|
2453
|
-
|
|
2454
|
-
|
|
2455
|
-
|
|
2456
|
-
|
|
2457
|
-
return {
|
|
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}`;
|
|
2458
1916
|
}
|
|
2459
|
-
|
|
2460
|
-
|
|
1917
|
+
const StyleV2ControlType = "makeswift::controls::style-v2";
|
|
1918
|
+
const unstable_useStyleV2ClassName = useStyle;
|
|
1919
|
+
function unstable_StyleV2(config) {
|
|
1920
|
+
return { type: StyleV2ControlType, config };
|
|
2461
1921
|
}
|
|
2462
|
-
const
|
|
2463
|
-
|
|
2464
|
-
|
|
2465
|
-
RUN_PLUGIN_CONTROL_ACTION: "RUN_PLUGIN_CONTROL_ACTION",
|
|
2466
|
-
SET_DEFAULT_VALUE: "SET_DEFAULT_VALUE",
|
|
2467
|
-
SET_PLUGIN_CONTROL_VALUE: "SET_PLUGIN_CONTROL_VALUE",
|
|
2468
|
-
ON_CHANGE: "ON_CHANGE",
|
|
2469
|
-
SELECT: "SELECT",
|
|
2470
|
-
SWITCH_TO_BUILD_MODE: "SWITCH_TO_BUILD_MODE",
|
|
2471
|
-
CHANGE_BOX_MODEL: "CHANGE_BOX_MODEL"
|
|
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"
|
|
2472
1925
|
};
|
|
2473
|
-
class
|
|
1926
|
+
class StyleV2Control extends PropController {
|
|
2474
1927
|
constructor(send, descriptor) {
|
|
2475
1928
|
super(send);
|
|
2476
|
-
__publicField(this, "
|
|
2477
|
-
|
|
2478
|
-
|
|
2479
|
-
|
|
2480
|
-
|
|
2481
|
-
|
|
2482
|
-
|
|
2483
|
-
switch (message.type) {
|
|
2484
|
-
case RichTextV2ControlMessageType.FOCUS: {
|
|
2485
|
-
this.editor.focusAndSelectAll();
|
|
2486
|
-
break;
|
|
2487
|
-
}
|
|
2488
|
-
case RichTextV2ControlMessageType.RESET_VALUE: {
|
|
2489
|
-
if (this.defaultValue) {
|
|
2490
|
-
this.editor.selection = null;
|
|
2491
|
-
this.editor.children = this.defaultValue;
|
|
2492
|
-
this.editor.onChange();
|
|
2493
|
-
}
|
|
2494
|
-
break;
|
|
2495
|
-
}
|
|
2496
|
-
case RichTextV2ControlMessageType.RUN_PLUGIN_CONTROL_ACTION: {
|
|
2497
|
-
(_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);
|
|
2498
|
-
break;
|
|
2499
|
-
}
|
|
2500
|
-
}
|
|
2501
|
-
});
|
|
2502
|
-
this.descriptor = descriptor;
|
|
2503
|
-
this.send = send;
|
|
2504
|
-
}
|
|
2505
|
-
setEditor(editor) {
|
|
2506
|
-
var _a2, _b, _c;
|
|
2507
|
-
this.editor = editor;
|
|
2508
|
-
this.send({
|
|
2509
|
-
type: RichTextV2ControlMessageType.SET_PLUGIN_CONTROL_VALUE,
|
|
2510
|
-
value: (_c = (_b = (_a2 = this.descriptor.config) == null ? void 0 : _a2.plugins) == null ? void 0 : _b.map((plugin) => {
|
|
2511
|
-
var _a3;
|
|
2512
|
-
return (_a3 = plugin == null ? void 0 : plugin.control) == null ? void 0 : _a3.getValue(editor);
|
|
2513
|
-
})) != null ? _c : []
|
|
2514
|
-
});
|
|
2515
|
-
}
|
|
2516
|
-
setDefaultValue(defaultValue) {
|
|
2517
|
-
this.defaultValue = defaultValue;
|
|
2518
|
-
this.send({ type: RichTextV2ControlMessageType.SET_DEFAULT_VALUE, value: defaultValue });
|
|
2519
|
-
}
|
|
2520
|
-
select() {
|
|
2521
|
-
this.send({ type: RichTextV2ControlMessageType.SELECT });
|
|
2522
|
-
}
|
|
2523
|
-
switchToBuildMode() {
|
|
2524
|
-
this.send({ type: RichTextV2ControlMessageType.SWITCH_TO_BUILD_MODE });
|
|
2525
|
-
}
|
|
2526
|
-
onChange(value) {
|
|
2527
|
-
var _a2, _b, _c;
|
|
2528
|
-
const editor = this.editor;
|
|
2529
|
-
if (editor == null)
|
|
2530
|
-
return;
|
|
2531
|
-
this.send({
|
|
2532
|
-
type: RichTextV2ControlMessageType.ON_CHANGE,
|
|
2533
|
-
value
|
|
2534
|
-
});
|
|
2535
|
-
this.send({
|
|
2536
|
-
type: RichTextV2ControlMessageType.SET_PLUGIN_CONTROL_VALUE,
|
|
2537
|
-
value: (_c = (_b = (_a2 = this.descriptor.config) == null ? void 0 : _a2.plugins) == null ? void 0 : _b.map((plugin) => {
|
|
2538
|
-
var _a3;
|
|
2539
|
-
return (_a3 = plugin == null ? void 0 : plugin.control) == null ? void 0 : _a3.getValue(editor);
|
|
2540
|
-
})) != null ? _c : []
|
|
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
|
+
});
|
|
2541
1936
|
});
|
|
2542
1937
|
}
|
|
2543
1938
|
changeBoxModel(boxModel) {
|
|
2544
|
-
this.send({ type:
|
|
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
|
+
}
|
|
2545
1951
|
}
|
|
2546
1952
|
}
|
|
1953
|
+
const ObjectType = {
|
|
1954
|
+
Value: "value",
|
|
1955
|
+
Text: "text",
|
|
1956
|
+
Inline: "inline",
|
|
1957
|
+
Block: "block",
|
|
1958
|
+
Document: "document",
|
|
1959
|
+
Leaf: "leaf",
|
|
1960
|
+
Selection: "selection",
|
|
1961
|
+
Mark: "mark",
|
|
1962
|
+
Range: "range",
|
|
1963
|
+
Decoration: "decoration",
|
|
1964
|
+
Annotation: "annotation",
|
|
1965
|
+
Point: "point",
|
|
1966
|
+
Operation: "operation"
|
|
1967
|
+
};
|
|
1968
|
+
const RootBlockType = {
|
|
1969
|
+
Default: "default",
|
|
1970
|
+
Text: "text-block",
|
|
1971
|
+
Paragraph: "paragraph",
|
|
1972
|
+
Heading1: "heading-one",
|
|
1973
|
+
Heading2: "heading-two",
|
|
1974
|
+
Heading3: "heading-three",
|
|
1975
|
+
Heading4: "heading-four",
|
|
1976
|
+
Heading5: "heading-five",
|
|
1977
|
+
Heading6: "heading-six",
|
|
1978
|
+
BlockQuote: "blockquote",
|
|
1979
|
+
UnorderedList: "unordered-list",
|
|
1980
|
+
OrderedList: "ordered-list"
|
|
1981
|
+
};
|
|
1982
|
+
const BlockType = __spreadProps(__spreadValues({}, RootBlockType), {
|
|
1983
|
+
ListItem: "list-item",
|
|
1984
|
+
ListItemChild: "list-item-child"
|
|
1985
|
+
});
|
|
1986
|
+
const InlineType = {
|
|
1987
|
+
Code: "code",
|
|
1988
|
+
SuperScript: "superscript",
|
|
1989
|
+
SubScript: "subscript",
|
|
1990
|
+
Link: "link"
|
|
1991
|
+
};
|
|
1992
|
+
const BlockTextAlignment = {
|
|
1993
|
+
Left: "left",
|
|
1994
|
+
Center: "center",
|
|
1995
|
+
Right: "right",
|
|
1996
|
+
Justify: "justify"
|
|
1997
|
+
};
|
|
2547
1998
|
function isText(node) {
|
|
2548
1999
|
if (typeof node === "object" && "text" in node)
|
|
2549
2000
|
return true;
|
|
@@ -2705,330 +2156,209 @@ function toNodeDTO(node) {
|
|
|
2705
2156
|
}
|
|
2706
2157
|
}
|
|
2707
2158
|
function toSelectionDTO(selection) {
|
|
2708
|
-
if (selection == null)
|
|
2709
|
-
return void 0;
|
|
2710
|
-
return {
|
|
2711
|
-
isFocused: false,
|
|
2712
|
-
marks: void 0,
|
|
2713
|
-
object: "selection",
|
|
2714
|
-
anchor: {
|
|
2715
|
-
offset: selection.anchor.offset,
|
|
2716
|
-
path: selection.anchor.path,
|
|
2717
|
-
object: "point"
|
|
2718
|
-
},
|
|
2719
|
-
focus: {
|
|
2720
|
-
offset: selection.focus.offset,
|
|
2721
|
-
path: selection.focus.path,
|
|
2722
|
-
object: "point"
|
|
2723
|
-
}
|
|
2724
|
-
};
|
|
2725
|
-
}
|
|
2726
|
-
function richTextDAOToDTO(children, selection) {
|
|
2727
|
-
return {
|
|
2728
|
-
document: {
|
|
2729
|
-
data: void 0,
|
|
2730
|
-
nodes: children.flatMap(toNodeDTO),
|
|
2731
|
-
object: "document"
|
|
2732
|
-
},
|
|
2733
|
-
object: "value",
|
|
2734
|
-
selection: toSelectionDTO(selection),
|
|
2735
|
-
annotations: void 0,
|
|
2736
|
-
data: void 0
|
|
2737
|
-
};
|
|
2738
|
-
}
|
|
2739
|
-
const RichTextControlType = "makeswift::controls::rich-text";
|
|
2740
|
-
function RichText$1() {
|
|
2741
|
-
return { type: RichTextControlType };
|
|
2742
|
-
}
|
|
2743
|
-
const RichTextControlMessageType = {
|
|
2744
|
-
CHANGE_BUILDER_EDIT_MODE: "CHANGE_BUILDER_EDIT_MODE",
|
|
2745
|
-
INITIALIZE_EDITOR: "INITIALIZE_EDITOR",
|
|
2746
|
-
CHANGE_EDITOR_VALUE: "CHANGE_EDITOR_VALUE",
|
|
2747
|
-
FOCUS: "FOCUS",
|
|
2748
|
-
BLUR: "BLUR",
|
|
2749
|
-
UNDO: "UNDO",
|
|
2750
|
-
REDO: "REDO",
|
|
2751
|
-
CHANGE_BOX_MODEL: "CHANGE_BOX_MODEL"
|
|
2752
|
-
};
|
|
2753
|
-
class RichTextControl extends PropController {
|
|
2754
|
-
constructor() {
|
|
2755
|
-
super(...arguments);
|
|
2756
|
-
__publicField(this, "editor", null);
|
|
2757
|
-
__publicField(this, "recv", (message) => {
|
|
2758
|
-
if (!this.editor)
|
|
2759
|
-
return;
|
|
2760
|
-
switch (message.type) {
|
|
2761
|
-
case RichTextControlMessageType.CHANGE_BUILDER_EDIT_MODE: {
|
|
2762
|
-
switch (message.editMode) {
|
|
2763
|
-
case BuilderEditMode.BUILD:
|
|
2764
|
-
case BuilderEditMode.INTERACT:
|
|
2765
|
-
this.editor.deselectAndBlur();
|
|
2766
|
-
}
|
|
2767
|
-
break;
|
|
2768
|
-
}
|
|
2769
|
-
case RichTextControlMessageType.FOCUS: {
|
|
2770
|
-
this.editor.focusAndSelectAll();
|
|
2771
|
-
break;
|
|
2772
|
-
}
|
|
2773
|
-
}
|
|
2774
|
-
});
|
|
2775
|
-
}
|
|
2776
|
-
setSlateEditor(editor) {
|
|
2777
|
-
this.editor = editor;
|
|
2778
|
-
this.send({
|
|
2779
|
-
type: RichTextControlMessageType.INITIALIZE_EDITOR,
|
|
2780
|
-
value: richTextDAOToDTO(editor.children, editor.selection)
|
|
2781
|
-
});
|
|
2782
|
-
const _onChange = editor.onChange;
|
|
2783
|
-
this.editor.onChange = (options) => {
|
|
2784
|
-
_onChange(options);
|
|
2785
|
-
if ((options == null ? void 0 : options.operation) != null) {
|
|
2786
|
-
this.send({
|
|
2787
|
-
type: RichTextControlMessageType.CHANGE_EDITOR_VALUE,
|
|
2788
|
-
value: richTextDAOToDTO(editor.children, editor.selection)
|
|
2789
|
-
});
|
|
2790
|
-
}
|
|
2791
|
-
};
|
|
2792
|
-
}
|
|
2793
|
-
focus() {
|
|
2794
|
-
this.send({ type: RichTextControlMessageType.FOCUS });
|
|
2795
|
-
}
|
|
2796
|
-
blur() {
|
|
2797
|
-
this.send({ type: RichTextControlMessageType.BLUR });
|
|
2798
|
-
}
|
|
2799
|
-
undo() {
|
|
2800
|
-
this.send({ type: RichTextControlMessageType.UNDO });
|
|
2801
|
-
}
|
|
2802
|
-
redo() {
|
|
2803
|
-
this.send({ type: RichTextControlMessageType.REDO });
|
|
2804
|
-
}
|
|
2805
|
-
changeBoxModel(boxModel) {
|
|
2806
|
-
this.send({ type: RichTextControlMessageType.CHANGE_BOX_MODEL, payload: { boxModel } });
|
|
2807
|
-
}
|
|
2808
|
-
}
|
|
2809
|
-
const Types = {
|
|
2810
|
-
Backgrounds: "Backgrounds",
|
|
2811
|
-
Border: "Border",
|
|
2812
|
-
BorderRadius: "BorderRadius",
|
|
2813
|
-
Checkbox: "Checkbox",
|
|
2814
|
-
Date: "Date",
|
|
2815
|
-
ElementID: "ElementID",
|
|
2816
|
-
Font: "Font",
|
|
2817
|
-
GapX: "GapX",
|
|
2818
|
-
GapY: "GapY",
|
|
2819
|
-
Grid: "Grid",
|
|
2820
|
-
Image: "Image",
|
|
2821
|
-
Images: "Images",
|
|
2822
|
-
Link: "Link",
|
|
2823
|
-
List: "List",
|
|
2824
|
-
Margin: "Margin",
|
|
2825
|
-
NavigationLinks: "NavigationLinks",
|
|
2826
|
-
Number: "Number",
|
|
2827
|
-
Padding: "Padding",
|
|
2828
|
-
ResponsiveColor: "ResponsiveColor",
|
|
2829
|
-
ResponsiveIconRadioGroup: "ResponsiveIconRadioGroup",
|
|
2830
|
-
ResponsiveLength: "ResponsiveLength",
|
|
2831
|
-
ResponsiveNumber: "ResponsiveNumber",
|
|
2832
|
-
ResponsiveOpacity: "ResponsiveOpacity",
|
|
2833
|
-
ResponsiveSelect: "ResponsiveSelect",
|
|
2834
|
-
RichText: "RichText",
|
|
2835
|
-
Shadows: "Shadows",
|
|
2836
|
-
Shape: "Shape",
|
|
2837
|
-
SocialLinks: "SocialLinks",
|
|
2838
|
-
Table: "Table",
|
|
2839
|
-
TableFormFields: "TableFormFields",
|
|
2840
|
-
Typeahead: "Typeahead",
|
|
2841
|
-
TextArea: "TextArea",
|
|
2842
|
-
TextInput: "TextInput",
|
|
2843
|
-
TextStyle: "TextStyle",
|
|
2844
|
-
Video: "Video",
|
|
2845
|
-
Width: "Width",
|
|
2846
|
-
Style: StyleControlType
|
|
2847
|
-
};
|
|
2848
|
-
function Backgrounds(options = {}) {
|
|
2849
|
-
return { type: Types.Backgrounds, options };
|
|
2850
|
-
}
|
|
2851
|
-
const BorderPropControllerFormat = {
|
|
2852
|
-
ClassName: "makeswift::prop-controllers::border::format::class-name",
|
|
2853
|
-
ResponsiveValue: "makeswift::prop-controllers:border::format::responsive-value"
|
|
2854
|
-
};
|
|
2855
|
-
function Border(options = {}) {
|
|
2856
|
-
return { type: Types.Border, options };
|
|
2857
|
-
}
|
|
2858
|
-
Border.Format = BorderPropControllerFormat;
|
|
2859
|
-
const BorderRadiusPropControllerFormat = {
|
|
2860
|
-
ClassName: "makeswift::prop-controllers::border-radius::format::class-name",
|
|
2861
|
-
ResponsiveValue: "makeswift::prop-controllers::border-radius::format::responsive-value"
|
|
2862
|
-
};
|
|
2863
|
-
function BorderRadius(options = {}) {
|
|
2864
|
-
return { type: Types.BorderRadius, options };
|
|
2865
|
-
}
|
|
2866
|
-
BorderRadius.Format = BorderRadiusPropControllerFormat;
|
|
2867
|
-
function Checkbox(options) {
|
|
2868
|
-
return { type: Types.Checkbox, options };
|
|
2869
|
-
}
|
|
2870
|
-
function Date(options = {}) {
|
|
2871
|
-
return { type: Types.Date, options };
|
|
2872
|
-
}
|
|
2873
|
-
function ElementID(options = {}) {
|
|
2874
|
-
return { type: Types.ElementID, options };
|
|
2875
|
-
}
|
|
2876
|
-
function Font(options = {}) {
|
|
2877
|
-
return { type: Types.Font, options };
|
|
2878
|
-
}
|
|
2879
|
-
function GapX(options = {}) {
|
|
2880
|
-
return { type: Types.GapX, options };
|
|
2881
|
-
}
|
|
2882
|
-
function GapY(options = {}) {
|
|
2883
|
-
return { type: Types.GapY, options };
|
|
2884
|
-
}
|
|
2885
|
-
function Grid(options = {}) {
|
|
2886
|
-
return { type: Types.Grid, options };
|
|
2887
|
-
}
|
|
2888
|
-
function Image(options = {}) {
|
|
2889
|
-
return { type: Types.Image, options };
|
|
2890
|
-
}
|
|
2891
|
-
function Images(options = {}) {
|
|
2892
|
-
return { type: Types.Images, options };
|
|
2893
|
-
}
|
|
2894
|
-
function Link(options = {}) {
|
|
2895
|
-
return { type: Types.Link, options };
|
|
2896
|
-
}
|
|
2897
|
-
function List(options) {
|
|
2898
|
-
return { type: Types.List, options };
|
|
2899
|
-
}
|
|
2900
|
-
const MarginPropControllerFormat = {
|
|
2901
|
-
ClassName: "makeswift::prop-controllers::margin::format::class-name",
|
|
2902
|
-
ResponsiveValue: "makeswift::prop-controllers::margin::format::responsive-value"
|
|
2903
|
-
};
|
|
2904
|
-
function Margin(options = {}) {
|
|
2905
|
-
return { type: Types.Margin, options };
|
|
2906
|
-
}
|
|
2907
|
-
Margin.Format = MarginPropControllerFormat;
|
|
2908
|
-
function NavigationLinks(options = {}) {
|
|
2909
|
-
return { type: Types.NavigationLinks, options };
|
|
2910
|
-
}
|
|
2911
|
-
function Number(options = {}) {
|
|
2912
|
-
return { type: Types.Number, options };
|
|
2913
|
-
}
|
|
2914
|
-
const PaddingPropControllerFormat = {
|
|
2915
|
-
ClassName: "makeswift::prop-controllers::padding::format::class-name",
|
|
2916
|
-
ResponsiveValue: "makeswift::prop-controllers::padding::format::responsive-value"
|
|
2917
|
-
};
|
|
2918
|
-
function Padding(options = {}) {
|
|
2919
|
-
return { type: Types.Padding, options };
|
|
2920
|
-
}
|
|
2921
|
-
Padding.Format = PaddingPropControllerFormat;
|
|
2922
|
-
function ResponsiveColor(options = {}) {
|
|
2923
|
-
return { type: Types.ResponsiveColor, options };
|
|
2924
|
-
}
|
|
2925
|
-
function ResponsiveIconRadioGroup(options) {
|
|
2926
|
-
return { type: Types.ResponsiveIconRadioGroup, options };
|
|
2927
|
-
}
|
|
2928
|
-
function ResponsiveLength(options = {}) {
|
|
2929
|
-
return { type: Types.ResponsiveLength, options };
|
|
2930
|
-
}
|
|
2931
|
-
function ResponsiveNumber(options = {}) {
|
|
2932
|
-
return { type: Types.ResponsiveNumber, options };
|
|
2933
|
-
}
|
|
2934
|
-
function ResponsiveOpacity(options = {}) {
|
|
2935
|
-
return { type: Types.ResponsiveOpacity, options };
|
|
2936
|
-
}
|
|
2937
|
-
function ResponsiveSelect(options) {
|
|
2938
|
-
return { type: Types.ResponsiveSelect, options };
|
|
2939
|
-
}
|
|
2940
|
-
function RichText(options = {}) {
|
|
2941
|
-
return { type: Types.RichText, options };
|
|
2942
|
-
}
|
|
2943
|
-
const ShadowsPropControllerFormat = {
|
|
2944
|
-
ClassName: "makeswift::prop-controllers::shadows::format::class-name",
|
|
2945
|
-
ResponsiveValue: "makeswift::prop-controllers::shadows::format::responsive-value"
|
|
2946
|
-
};
|
|
2947
|
-
function Shadows(options = {}) {
|
|
2948
|
-
return { type: Types.Shadows, options };
|
|
2949
|
-
}
|
|
2950
|
-
Shadows.Format = ShadowsPropControllerFormat;
|
|
2951
|
-
function Shape(options) {
|
|
2952
|
-
return { type: Types.Shape, options };
|
|
2953
|
-
}
|
|
2954
|
-
function SocialLinks(options = {}) {
|
|
2955
|
-
return { type: Types.SocialLinks, options };
|
|
2956
|
-
}
|
|
2957
|
-
function Table(options = {}) {
|
|
2958
|
-
return { type: Types.Table, options };
|
|
2959
|
-
}
|
|
2960
|
-
function TableFormFields(options = {}) {
|
|
2961
|
-
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
|
+
};
|
|
2962
2176
|
}
|
|
2963
|
-
function
|
|
2964
|
-
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
|
+
};
|
|
2965
2189
|
}
|
|
2966
|
-
|
|
2967
|
-
|
|
2190
|
+
const RichTextControlType = "makeswift::controls::rich-text";
|
|
2191
|
+
function RichText() {
|
|
2192
|
+
return { type: RichTextControlType };
|
|
2968
2193
|
}
|
|
2969
|
-
|
|
2970
|
-
|
|
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
|
+
}
|
|
2971
2259
|
}
|
|
2972
|
-
|
|
2973
|
-
|
|
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 };
|
|
2974
2273
|
}
|
|
2975
|
-
function
|
|
2976
|
-
return { type:
|
|
2274
|
+
function unstable_RichTextV2(config = {}) {
|
|
2275
|
+
return { type: RichTextV2ControlType, config };
|
|
2977
2276
|
}
|
|
2978
|
-
const
|
|
2979
|
-
|
|
2980
|
-
|
|
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"
|
|
2981
2287
|
};
|
|
2982
|
-
|
|
2983
|
-
|
|
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
|
+
}
|
|
2984
2361
|
}
|
|
2985
|
-
Width.Format = WidthPropControllerFormat;
|
|
2986
|
-
var descriptors = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
2987
|
-
__proto__: null,
|
|
2988
|
-
Types,
|
|
2989
|
-
Backgrounds,
|
|
2990
|
-
BorderPropControllerFormat,
|
|
2991
|
-
Border,
|
|
2992
|
-
BorderRadiusPropControllerFormat,
|
|
2993
|
-
BorderRadius,
|
|
2994
|
-
Checkbox,
|
|
2995
|
-
Date,
|
|
2996
|
-
ElementID,
|
|
2997
|
-
Font,
|
|
2998
|
-
GapX,
|
|
2999
|
-
GapY,
|
|
3000
|
-
Grid,
|
|
3001
|
-
Image,
|
|
3002
|
-
Images,
|
|
3003
|
-
Link,
|
|
3004
|
-
List,
|
|
3005
|
-
MarginPropControllerFormat,
|
|
3006
|
-
Margin,
|
|
3007
|
-
NavigationLinks,
|
|
3008
|
-
Number,
|
|
3009
|
-
PaddingPropControllerFormat,
|
|
3010
|
-
Padding,
|
|
3011
|
-
ResponsiveColor,
|
|
3012
|
-
ResponsiveIconRadioGroup,
|
|
3013
|
-
ResponsiveLength,
|
|
3014
|
-
ResponsiveNumber,
|
|
3015
|
-
ResponsiveOpacity,
|
|
3016
|
-
ResponsiveSelect,
|
|
3017
|
-
RichText,
|
|
3018
|
-
ShadowsPropControllerFormat,
|
|
3019
|
-
Shadows,
|
|
3020
|
-
Shape,
|
|
3021
|
-
SocialLinks,
|
|
3022
|
-
Table,
|
|
3023
|
-
TableFormFields,
|
|
3024
|
-
Typeahead,
|
|
3025
|
-
TextArea,
|
|
3026
|
-
TextInput,
|
|
3027
|
-
TextStyle,
|
|
3028
|
-
Video,
|
|
3029
|
-
WidthPropControllerFormat,
|
|
3030
|
-
Width
|
|
3031
|
-
}, Symbol.toStringTag, { value: "Module" }));
|
|
3032
2362
|
function isNonNullable(value) {
|
|
3033
2363
|
return value != null;
|
|
3034
2364
|
}
|
|
@@ -3157,6 +2487,39 @@ function getElementSwatchIds(descriptor, prop) {
|
|
|
3157
2487
|
const value = prop;
|
|
3158
2488
|
return (value == null ? void 0 : value.swatchId) == null ? [] : [value.swatchId];
|
|
3159
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
|
+
}
|
|
3160
2523
|
default:
|
|
3161
2524
|
return [];
|
|
3162
2525
|
}
|
|
@@ -3510,8 +2873,6 @@ function configureStore({
|
|
|
3510
2873
|
}), redux.applyMiddleware(thunk__default["default"]));
|
|
3511
2874
|
}
|
|
3512
2875
|
exports.Backgrounds = Backgrounds;
|
|
3513
|
-
exports.BlockActions = BlockActions;
|
|
3514
|
-
exports.BlockPlugin = BlockPlugin;
|
|
3515
2876
|
exports.BlockTextAlignment = BlockTextAlignment;
|
|
3516
2877
|
exports.BlockType = BlockType;
|
|
3517
2878
|
exports.Border = Border;
|
|
@@ -3525,22 +2886,20 @@ exports.ColorControlType = ColorControlType;
|
|
|
3525
2886
|
exports.ComponentIcon = ComponentIcon;
|
|
3526
2887
|
exports.Date = Date;
|
|
3527
2888
|
exports.ElementID = ElementID;
|
|
3528
|
-
exports.ElementUtils = ElementUtils;
|
|
3529
2889
|
exports.Font = Font;
|
|
3530
2890
|
exports.GapX = GapX;
|
|
3531
2891
|
exports.GapY = GapY;
|
|
3532
2892
|
exports.Grid = Grid;
|
|
3533
|
-
exports.Image = Image;
|
|
3534
|
-
exports.Image$1 = Image
|
|
2893
|
+
exports.Image = Image$1;
|
|
2894
|
+
exports.Image$1 = Image;
|
|
3535
2895
|
exports.ImageControlType = ImageControlType;
|
|
3536
2896
|
exports.ImageControlValueFormat = ImageControlValueFormat;
|
|
3537
2897
|
exports.Images = Images;
|
|
3538
2898
|
exports.InlineType = InlineType;
|
|
3539
|
-
exports.Link = Link;
|
|
3540
|
-
exports.Link$1 = Link
|
|
2899
|
+
exports.Link = Link$1;
|
|
2900
|
+
exports.Link$1 = Link;
|
|
3541
2901
|
exports.LinkControlType = LinkControlType;
|
|
3542
|
-
exports.List = List
|
|
3543
|
-
exports.ListActions = ListActions;
|
|
2902
|
+
exports.List = List;
|
|
3544
2903
|
exports.ListControl = ListControl;
|
|
3545
2904
|
exports.ListControlMessageType = ListControlMessageType;
|
|
3546
2905
|
exports.ListControlType = ListControlType;
|
|
@@ -3557,8 +2916,8 @@ exports.ResponsiveLength = ResponsiveLength;
|
|
|
3557
2916
|
exports.ResponsiveNumber = ResponsiveNumber;
|
|
3558
2917
|
exports.ResponsiveOpacity = ResponsiveOpacity;
|
|
3559
2918
|
exports.ResponsiveSelect = ResponsiveSelect;
|
|
3560
|
-
exports.RichText = RichText;
|
|
3561
|
-
exports.RichText$1 = RichText
|
|
2919
|
+
exports.RichText = RichText$1;
|
|
2920
|
+
exports.RichText$1 = RichText;
|
|
3562
2921
|
exports.RichTextControl = RichTextControl;
|
|
3563
2922
|
exports.RichTextControlMessageType = RichTextControlMessageType;
|
|
3564
2923
|
exports.RichTextControlType = RichTextControlType;
|
|
@@ -3568,11 +2927,9 @@ exports.RichTextV2ControlMessageType = RichTextV2ControlMessageType;
|
|
|
3568
2927
|
exports.RichTextV2ControlType = RichTextV2ControlType;
|
|
3569
2928
|
exports.RichTextV2Mode = RichTextV2Mode;
|
|
3570
2929
|
exports.RootBlockType = RootBlockType;
|
|
3571
|
-
exports.Select = Select;
|
|
3572
|
-
exports.SelectControlType = SelectControlType;
|
|
3573
2930
|
exports.Shadows = Shadows;
|
|
3574
2931
|
exports.ShadowsPropControllerFormat = ShadowsPropControllerFormat;
|
|
3575
|
-
exports.Shape = Shape
|
|
2932
|
+
exports.Shape = Shape;
|
|
3576
2933
|
exports.ShapeControl = ShapeControl;
|
|
3577
2934
|
exports.ShapeControlMessageType = ShapeControlMessageType;
|
|
3578
2935
|
exports.ShapeControlType = ShapeControlType;
|
|
@@ -3616,7 +2973,6 @@ exports.createRichTextV2Plugin = createRichTextV2Plugin;
|
|
|
3616
2973
|
exports.descriptors = descriptors;
|
|
3617
2974
|
exports.getBackgroundsFileIds = getBackgroundsFileIds;
|
|
3618
2975
|
exports.getBackgroundsSwatchIds = getBackgroundsSwatchIds;
|
|
3619
|
-
exports.getBlocksInSelection = getBlocksInSelection;
|
|
3620
2976
|
exports.getBorderSwatchIds = getBorderSwatchIds;
|
|
3621
2977
|
exports.getBoxShadowsSwatchIds = getBoxShadowsSwatchIds;
|
|
3622
2978
|
exports.getBreakpoints = getBreakpoints;
|
|
@@ -3653,7 +3009,6 @@ exports.isNonNullable = isNonNullable;
|
|
|
3653
3009
|
exports.isPropControllersHandle = isPropControllersHandle;
|
|
3654
3010
|
exports.merge = merge;
|
|
3655
3011
|
exports.mergeSlotData = mergeSlotData;
|
|
3656
|
-
exports.onKeyDown = onKeyDown;
|
|
3657
3012
|
exports.reducer = reducer$8;
|
|
3658
3013
|
exports.reducer$1 = reducer$7;
|
|
3659
3014
|
exports.reducer$2 = reducer$9;
|
|
@@ -3671,5 +3026,4 @@ exports.unstable_RichTextV2 = unstable_RichTextV2;
|
|
|
3671
3026
|
exports.unstable_StyleV2 = unstable_StyleV2;
|
|
3672
3027
|
exports.unstable_useStyleV2ClassName = unstable_useStyleV2ClassName;
|
|
3673
3028
|
exports.useStyle = useStyle;
|
|
3674
|
-
exports.withBlock = withBlock;
|
|
3675
3029
|
//# sourceMappingURL=react-page.cjs.js.map
|