@makeswift/runtime 0.9.11 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Box.cjs.js +4 -1
- package/dist/Box.cjs.js.map +1 -1
- package/dist/Box.es.js +5 -2
- package/dist/Box.es.js.map +1 -1
- package/dist/Button.cjs.js +4 -3
- package/dist/Button.cjs.js.map +1 -1
- package/dist/Button.es.js +5 -4
- package/dist/Button.es.js.map +1 -1
- package/dist/Carousel.cjs.js +4 -3
- package/dist/Carousel.cjs.js.map +1 -1
- package/dist/Carousel.es.js +5 -4
- package/dist/Carousel.es.js.map +1 -1
- package/dist/Countdown.cjs.js +4 -1
- package/dist/Countdown.cjs.js.map +1 -1
- package/dist/Countdown.es.js +5 -2
- package/dist/Countdown.es.js.map +1 -1
- package/dist/Divider.cjs.js +4 -1
- package/dist/Divider.cjs.js.map +1 -1
- package/dist/Divider.es.js +5 -2
- package/dist/Divider.es.js.map +1 -1
- package/dist/Embed.cjs.js +1 -0
- package/dist/Embed.cjs.js.map +1 -1
- package/dist/Embed.es.js +2 -1
- package/dist/Embed.es.js.map +1 -1
- package/dist/Form.cjs.js +14 -13
- package/dist/Form.cjs.js.map +1 -1
- package/dist/Form.es.js +6 -5
- package/dist/Form.es.js.map +1 -1
- package/dist/Image.cjs.js +12 -11
- package/dist/Image.cjs.js.map +1 -1
- package/dist/Image.es.js +12 -11
- package/dist/Image.es.js.map +1 -1
- package/dist/LiveProvider.cjs.js +4 -1
- package/dist/LiveProvider.cjs.js.map +1 -1
- package/dist/LiveProvider.es.js +6 -3
- package/dist/LiveProvider.es.js.map +1 -1
- package/dist/Navigation.cjs.js +12 -11
- package/dist/Navigation.cjs.js.map +1 -1
- package/dist/Navigation.es.js +12 -11
- package/dist/Navigation.es.js.map +1 -1
- package/dist/PreviewProvider.cjs.js +7 -4
- package/dist/PreviewProvider.cjs.js.map +1 -1
- package/dist/PreviewProvider.es.js +6 -3
- package/dist/PreviewProvider.es.js.map +1 -1
- package/dist/ReadOnlyText.cjs.js +34 -26
- package/dist/ReadOnlyText.cjs.js.map +1 -1
- package/dist/ReadOnlyText.es.js +30 -22
- package/dist/ReadOnlyText.es.js.map +1 -1
- package/dist/ReadOnlyTextV2.cjs.js +125 -246
- package/dist/ReadOnlyTextV2.cjs.js.map +1 -1
- package/dist/ReadOnlyTextV2.es.js +126 -246
- package/dist/ReadOnlyTextV2.es.js.map +1 -1
- package/dist/Root.cjs.js +4 -1
- package/dist/Root.cjs.js.map +1 -1
- package/dist/Root.es.js +5 -2
- package/dist/Root.es.js.map +1 -1
- package/dist/SocialLinks.cjs.js +7 -6
- package/dist/SocialLinks.cjs.js.map +1 -1
- package/dist/SocialLinks.es.js +8 -7
- package/dist/SocialLinks.es.js.map +1 -1
- package/dist/Text.cjs.js +12 -71
- package/dist/Text.cjs.js.map +1 -1
- package/dist/Text.es.js +13 -64
- package/dist/Text.es.js.map +1 -1
- package/dist/Video.cjs.js +1 -0
- package/dist/Video.cjs.js.map +1 -1
- package/dist/Video.es.js +2 -1
- package/dist/Video.es.js.map +1 -1
- package/dist/builder.cjs.js +2 -0
- package/dist/builder.cjs.js.map +1 -1
- package/dist/builder.es.js +2 -0
- package/dist/builder.es.js.map +1 -1
- package/dist/components.cjs.js +4 -3
- package/dist/components.cjs.js.map +1 -1
- package/dist/components.es.js +4 -3
- package/dist/components.es.js.map +1 -1
- package/dist/control-serialization.es.js +1 -1
- package/dist/controls.cjs.js +31 -21
- package/dist/controls.cjs.js.map +1 -1
- package/dist/controls.es.js +4 -2
- package/dist/controls.es.js.map +1 -1
- package/dist/index.cjs.js +307 -243
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.cjs2.js +3 -3
- package/dist/index.cjs2.js.map +1 -1
- package/dist/index.cjs3.js +21 -107
- package/dist/index.cjs3.js.map +1 -1
- package/dist/index.cjs4.js +16 -57
- package/dist/index.cjs4.js.map +1 -1
- package/dist/index.cjs5.js +53 -243
- package/dist/index.cjs5.js.map +1 -1
- package/dist/index.cjs6.js +16 -37
- package/dist/index.cjs6.js.map +1 -1
- package/dist/index.cjs7.js +376 -14
- package/dist/index.cjs7.js.map +1 -1
- package/dist/index.cjs8.js +276 -12
- package/dist/index.cjs8.js.map +1 -1
- package/dist/index.es.js +279 -215
- package/dist/index.es.js.map +1 -1
- package/dist/index.es2.js +2 -2
- package/dist/index.es3.js +22 -103
- package/dist/index.es3.js.map +1 -1
- package/dist/index.es4.js +16 -57
- package/dist/index.es4.js.map +1 -1
- package/dist/index.es5.js +53 -241
- package/dist/index.es5.js.map +1 -1
- package/dist/index.es6.js +16 -32
- package/dist/index.es6.js.map +1 -1
- package/dist/index.es7.js +372 -16
- package/dist/index.es7.js.map +1 -1
- package/dist/index.es8.js +271 -11
- package/dist/index.es8.js.map +1 -1
- package/dist/main.cjs.js +2 -0
- package/dist/main.cjs.js.map +1 -1
- package/dist/main.es.js +2 -0
- package/dist/main.es.js.map +1 -1
- package/dist/next.cjs.js +4 -1
- package/dist/next.cjs.js.map +1 -1
- package/dist/next.es.js +5 -2
- package/dist/next.es.js.map +1 -1
- package/dist/prop-controllers.cjs.js +2 -0
- package/dist/prop-controllers.cjs.js.map +1 -1
- package/dist/prop-controllers.es.js +2 -0
- package/dist/prop-controllers.es.js.map +1 -1
- package/dist/react-page.cjs.js +1731 -183
- package/dist/react-page.cjs.js.map +1 -1
- package/dist/react-page.es.js +1694 -182
- package/dist/react-page.es.js.map +1 -1
- package/dist/react.cjs.js +4 -1
- package/dist/react.cjs.js.map +1 -1
- package/dist/react.es.js +4 -1
- package/dist/react.es.js.map +1 -1
- package/dist/slate.cjs.js +32 -377
- package/dist/slate.cjs.js.map +1 -1
- package/dist/slate.es.js +14 -363
- package/dist/slate.es.js.map +1 -1
- package/dist/text-input.cjs.js +26 -0
- package/dist/text-input.cjs.js.map +1 -0
- package/dist/text-input.es.js +18 -0
- package/dist/text-input.es.js.map +1 -0
- package/dist/types/src/components/builtin/Text/Text.d.ts +3 -4
- package/dist/types/src/components/builtin/Text/Text.d.ts.map +1 -1
- package/dist/types/src/components/builtin/Text/register.d.ts.map +1 -1
- package/dist/types/src/controls/list.d.ts +5 -2
- package/dist/types/src/controls/list.d.ts.map +1 -1
- package/dist/types/src/controls/rich-text/fixtures/v2-data-types.d.ts.map +1 -1
- package/dist/types/src/controls/rich-text/introspection.d.ts +5 -0
- package/dist/types/src/controls/rich-text/introspection.d.ts.map +1 -0
- package/dist/types/src/controls/rich-text/introspection.test.d.ts +2 -0
- package/dist/types/src/controls/rich-text/introspection.test.d.ts.map +1 -0
- package/dist/types/src/controls/rich-text/rich-text.d.ts +0 -1
- package/dist/types/src/controls/rich-text/rich-text.d.ts.map +1 -1
- package/dist/types/src/controls/rich-text/translation.d.ts.map +1 -1
- package/dist/types/src/controls/rich-text-v2/introspection.d.ts +5 -0
- package/dist/types/src/controls/rich-text-v2/introspection.d.ts.map +1 -0
- package/dist/types/src/controls/rich-text-v2/introspection.test.d.ts +2 -0
- package/dist/types/src/controls/rich-text-v2/introspection.test.d.ts.map +1 -0
- package/dist/types/src/controls/rich-text-v2/plugin.d.ts +29 -0
- package/dist/types/src/controls/rich-text-v2/plugin.d.ts.map +1 -0
- package/dist/types/src/controls/rich-text-v2/rich-text-v2.d.ts +32 -34
- package/dist/types/src/controls/rich-text-v2/rich-text-v2.d.ts.map +1 -1
- package/dist/types/src/controls/rich-text-v2/translation.d.ts +1 -1
- package/dist/types/src/controls/rich-text-v2/translation.d.ts.map +1 -1
- package/dist/types/src/controls/shape.d.ts +5 -2
- package/dist/types/src/controls/shape.d.ts.map +1 -1
- package/dist/types/src/controls/typography.d.ts +2 -0
- package/dist/types/src/controls/typography.d.ts.map +1 -1
- package/dist/types/src/next/client.d.ts.map +1 -1
- package/dist/types/src/prop-controllers/descriptors.d.ts +11 -1
- package/dist/types/src/prop-controllers/descriptors.d.ts.map +1 -1
- package/dist/types/src/prop-controllers/introspection.d.ts +0 -2
- package/dist/types/src/prop-controllers/introspection.d.ts.map +1 -1
- package/dist/types/src/runtimes/react/controls/control.d.ts +1 -1
- package/dist/types/src/runtimes/react/controls/control.d.ts.map +1 -1
- package/dist/types/src/{components/builtin/Text → runtimes/react/controls/rich-text}/EditableText/editable-text.d.ts +4 -3
- package/dist/types/src/runtimes/react/controls/rich-text/EditableText/editable-text.d.ts.map +1 -0
- package/dist/types/src/runtimes/react/controls/rich-text/EditableText/index.d.ts.map +1 -0
- package/dist/types/src/runtimes/react/controls/rich-text/EditableText/useSyncDOMSelection.d.ts.map +1 -0
- package/dist/types/src/{components/builtin/Text → runtimes/react/controls/rich-text}/EditableText/useSyncWithBuilder.d.ts +1 -1
- package/dist/types/src/runtimes/react/controls/rich-text/EditableText/useSyncWithBuilder.d.ts.map +1 -0
- package/dist/types/src/{components/builtin/Text → runtimes/react/controls/rich-text}/ReadOnlyText.d.ts +2 -2
- package/dist/types/src/runtimes/react/controls/rich-text/ReadOnlyText.d.ts.map +1 -0
- package/dist/types/src/{components/builtin/Text → runtimes/react/controls/rich-text}/components/Element/block.d.ts +1 -1
- package/dist/types/src/runtimes/react/controls/rich-text/components/Element/block.d.ts.map +1 -0
- package/dist/types/src/runtimes/react/controls/rich-text/components/Element/element.d.ts.map +1 -0
- package/dist/types/src/runtimes/react/controls/rich-text/components/Element/index.d.ts.map +1 -0
- package/dist/types/src/{components/builtin/Text → runtimes/react/controls/rich-text}/components/Element/inline.d.ts +1 -1
- package/dist/types/src/runtimes/react/controls/rich-text/components/Element/inline.d.ts.map +1 -0
- package/dist/types/src/runtimes/react/controls/rich-text/components/Leaf/index.d.ts.map +1 -0
- package/dist/types/src/runtimes/react/controls/rich-text/components/Leaf/leaf.d.ts.map +1 -0
- package/dist/types/src/runtimes/react/controls/rich-text/components/index.d.ts.map +1 -0
- package/dist/types/src/runtimes/react/controls/rich-text/index.d.ts +2 -0
- package/dist/types/src/runtimes/react/controls/rich-text/index.d.ts.map +1 -0
- package/dist/types/src/runtimes/react/controls/{rich-text.d.ts → rich-text/rich-text.d.ts} +1 -1
- package/dist/types/src/runtimes/react/controls/rich-text/rich-text.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 +3 -2
- package/dist/types/src/runtimes/react/controls/rich-text-v2/EditableTextV2/render-element.d.ts.map +1 -1
- package/dist/types/src/runtimes/react/controls/rich-text-v2/EditableTextV2/render-leaf.d.ts +2 -1
- package/dist/types/src/runtimes/react/controls/rich-text-v2/EditableTextV2/render-leaf.d.ts.map +1 -1
- package/dist/types/src/runtimes/react/controls/rich-text-v2/EditableTextV2/useRemoteChanges.d.ts +4 -0
- package/dist/types/src/runtimes/react/controls/rich-text-v2/EditableTextV2/useRemoteChanges.d.ts.map +1 -0
- package/dist/types/src/runtimes/react/controls/rich-text-v2/ReadOnlyTextV2.d.ts +8 -16
- package/dist/types/src/runtimes/react/controls/rich-text-v2/ReadOnlyTextV2.d.ts.map +1 -1
- package/dist/types/src/slate/BlockPlugin/index.d.ts +3 -3
- package/dist/types/src/slate/BlockPlugin/index.d.ts.map +1 -1
- package/dist/types/src/slate/InlineModePlugin/index.d.ts +6 -4
- package/dist/types/src/slate/InlineModePlugin/index.d.ts.map +1 -1
- package/dist/types/src/slate/InlinePlugin/index.d.ts +3 -3
- package/dist/types/src/slate/InlinePlugin/index.d.ts.map +1 -1
- package/dist/types/src/slate/InlinePlugin/types.d.ts +1 -1
- package/dist/types/src/slate/InlinePlugin/types.d.ts.map +1 -1
- package/dist/types/src/slate/LinkPlugin/index.d.ts +3 -3
- package/dist/types/src/slate/LinkPlugin/index.d.ts.map +1 -1
- package/dist/types/src/slate/LinkPlugin/linkPluginWithoutRenderElement.d.ts +16 -0
- package/dist/types/src/slate/LinkPlugin/linkPluginWithoutRenderElement.d.ts.map +1 -0
- package/dist/types/src/slate/LocalChangesPlugin/index.d.ts +16 -0
- package/dist/types/src/slate/LocalChangesPlugin/index.d.ts.map +1 -0
- package/dist/types/src/slate/TextAlignPlugin/index.d.ts +3 -3
- package/dist/types/src/slate/TextAlignPlugin/index.d.ts.map +1 -1
- package/dist/types/src/slate/TypographyPlugin/index.d.ts +3 -3
- package/dist/types/src/slate/TypographyPlugin/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 +3 -12
- package/dist/types/src/slate/types.d.ts.map +1 -1
- package/dist/types/src/slate/utils/element.d.ts.map +1 -1
- package/dist/types/src/state/modules/locales.d.ts.map +1 -1
- package/package.json +1 -2
- package/dist/index.cjs10.js +0 -390
- package/dist/index.cjs10.js.map +0 -1
- package/dist/index.cjs9.js +0 -299
- package/dist/index.cjs9.js.map +0 -1
- package/dist/index.es10.js +0 -383
- package/dist/index.es10.js.map +0 -1
- package/dist/index.es9.js +0 -292
- package/dist/index.es9.js.map +0 -1
- package/dist/types/src/components/builtin/Text/EditableText/editable-text.d.ts.map +0 -1
- package/dist/types/src/components/builtin/Text/EditableText/index.d.ts.map +0 -1
- package/dist/types/src/components/builtin/Text/EditableText/useSyncDOMSelection.d.ts.map +0 -1
- package/dist/types/src/components/builtin/Text/EditableText/useSyncWithBuilder.d.ts.map +0 -1
- package/dist/types/src/components/builtin/Text/ReadOnlyText.d.ts.map +0 -1
- package/dist/types/src/components/builtin/Text/components/Element/block.d.ts.map +0 -1
- package/dist/types/src/components/builtin/Text/components/Element/element.d.ts.map +0 -1
- package/dist/types/src/components/builtin/Text/components/Element/index.d.ts.map +0 -1
- package/dist/types/src/components/builtin/Text/components/Element/inline.d.ts.map +0 -1
- package/dist/types/src/components/builtin/Text/components/Leaf/index.d.ts.map +0 -1
- package/dist/types/src/components/builtin/Text/components/Leaf/leaf.d.ts.map +0 -1
- package/dist/types/src/components/builtin/Text/components/index.d.ts.map +0 -1
- package/dist/types/src/runtimes/react/controls/rich-text.d.ts.map +0 -1
- package/dist/types.cjs2.js +0 -746
- package/dist/types.cjs2.js.map +0 -1
- package/dist/types.es2.js +0 -729
- package/dist/types.es2.js.map +0 -1
- package/dist/typography.cjs.js +0 -56
- package/dist/typography.cjs.js.map +0 -1
- package/dist/typography.es.js +0 -41
- package/dist/typography.es.js.map +0 -1
- /package/dist/types/src/{components/builtin/Text → runtimes/react/controls/rich-text}/EditableText/index.d.ts +0 -0
- /package/dist/types/src/{components/builtin/Text → runtimes/react/controls/rich-text}/EditableText/useSyncDOMSelection.d.ts +0 -0
- /package/dist/types/src/{components/builtin/Text → runtimes/react/controls/rich-text}/components/Element/element.d.ts +0 -0
- /package/dist/types/src/{components/builtin/Text → runtimes/react/controls/rich-text}/components/Element/index.d.ts +0 -0
- /package/dist/types/src/{components/builtin/Text → runtimes/react/controls/rich-text}/components/Leaf/index.d.ts +0 -0
- /package/dist/types/src/{components/builtin/Text → runtimes/react/controls/rich-text}/components/Leaf/leaf.d.ts +0 -0
- /package/dist/types/src/{components/builtin/Text → runtimes/react/controls/rich-text}/components/index.d.ts +0 -0
package/dist/react-page.cjs.js
CHANGED
|
@@ -18,6 +18,18 @@ var __spreadValues = (a, b) => {
|
|
|
18
18
|
return a;
|
|
19
19
|
};
|
|
20
20
|
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
21
|
+
var __objRest = (source, exclude) => {
|
|
22
|
+
var target = {};
|
|
23
|
+
for (var prop in source)
|
|
24
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
25
|
+
target[prop] = source[prop];
|
|
26
|
+
if (source != null && __getOwnPropSymbols)
|
|
27
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
|
28
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
29
|
+
target[prop] = source[prop];
|
|
30
|
+
}
|
|
31
|
+
return target;
|
|
32
|
+
};
|
|
21
33
|
var __publicField = (obj, key, value) => {
|
|
22
34
|
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
23
35
|
return value;
|
|
@@ -32,11 +44,14 @@ var css = require("@emotion/css");
|
|
|
32
44
|
var serialize = require("@emotion/serialize");
|
|
33
45
|
var utils = require("@emotion/utils");
|
|
34
46
|
var slate = require("slate");
|
|
47
|
+
var jsxRuntime = require("react/jsx-runtime");
|
|
48
|
+
var isHotkey = require("is-hotkey");
|
|
35
49
|
function _interopDefaultLegacy(e) {
|
|
36
50
|
return e && typeof e === "object" && "default" in e ? e : { "default": e };
|
|
37
51
|
}
|
|
38
52
|
var thunk__default = /* @__PURE__ */ _interopDefaultLegacy(thunk);
|
|
39
53
|
var React__default = /* @__PURE__ */ _interopDefaultLegacy(React);
|
|
54
|
+
var isHotkey__default = /* @__PURE__ */ _interopDefaultLegacy(isHotkey);
|
|
40
55
|
const ComponentIcon = {
|
|
41
56
|
Billing: "billing",
|
|
42
57
|
Bolt: "bolt",
|
|
@@ -290,6 +305,12 @@ function reducer$1(state = getInitialState(), action) {
|
|
|
290
305
|
}
|
|
291
306
|
}
|
|
292
307
|
function parseLocalesInput(input) {
|
|
308
|
+
if (input.locales == null) {
|
|
309
|
+
throw new Error(`Locales cannot be null or undefined. Please provide the locales array.`);
|
|
310
|
+
}
|
|
311
|
+
if (input.locales.includes(input.defaultLocale) === false) {
|
|
312
|
+
throw new Error(`Default locale "${input.defaultLocale}" is not included in locales: ${input.locales}. Please add the default locale to the locales array.`);
|
|
313
|
+
}
|
|
293
314
|
return {
|
|
294
315
|
locales: input.locales.map((locale) => actions.localeStringSchema.parse(locale)),
|
|
295
316
|
defaultLocale: actions.localeStringSchema.parse(input.defaultLocale),
|
|
@@ -604,6 +625,21 @@ function introspectListPropControllerData(descriptor, value, func) {
|
|
|
604
625
|
return [];
|
|
605
626
|
return value.flatMap((item) => item.value ? func(descriptor.options.type, item.value) : []);
|
|
606
627
|
}
|
|
628
|
+
function getListPropControllerElementChildren(descriptor, value) {
|
|
629
|
+
return introspectListPropControllerData(descriptor, value, getElementChildren);
|
|
630
|
+
}
|
|
631
|
+
function getListPropControllerSwatchIds(descriptor, value) {
|
|
632
|
+
return introspectListPropControllerData(descriptor, value, getSwatchIds);
|
|
633
|
+
}
|
|
634
|
+
function getListPropControllerFileIds(descriptor, value) {
|
|
635
|
+
return introspectListPropControllerData(descriptor, value, getFileIds);
|
|
636
|
+
}
|
|
637
|
+
function getListPropControllerTypographyIds(descriptor, value) {
|
|
638
|
+
return introspectListPropControllerData(descriptor, value, getTypographyIds);
|
|
639
|
+
}
|
|
640
|
+
function getListPropControllerPageIds(descriptor, value) {
|
|
641
|
+
return introspectListPropControllerData(descriptor, value, getPageIds);
|
|
642
|
+
}
|
|
607
643
|
const MarginPropControllerFormat = {
|
|
608
644
|
ClassName: "makeswift::prop-controllers::margin::format::class-name",
|
|
609
645
|
ResponsiveValue: "makeswift::prop-controllers::margin::format::responsive-value"
|
|
@@ -661,7 +697,22 @@ function Shape$1(options) {
|
|
|
661
697
|
function introspectShapePropControllerData(descriptor, value, func) {
|
|
662
698
|
if (value == null)
|
|
663
699
|
return [];
|
|
664
|
-
return Object.entries(descriptor.options.type).flatMap(([key,
|
|
700
|
+
return Object.entries(descriptor.options.type).flatMap(([key, definition2]) => func(definition2, value[key]));
|
|
701
|
+
}
|
|
702
|
+
function getShapePropControllerElementChildren(descriptor, value) {
|
|
703
|
+
return introspectShapePropControllerData(descriptor, value, getElementChildren);
|
|
704
|
+
}
|
|
705
|
+
function getShapePropControllerFileIds(descriptor, value) {
|
|
706
|
+
return introspectShapePropControllerData(descriptor, value, getFileIds);
|
|
707
|
+
}
|
|
708
|
+
function getShapePropControllerTypographyIds(descriptor, value) {
|
|
709
|
+
return introspectShapePropControllerData(descriptor, value, getTypographyIds);
|
|
710
|
+
}
|
|
711
|
+
function getShapePropControllerPageIds(descriptor, value) {
|
|
712
|
+
return introspectShapePropControllerData(descriptor, value, getPageIds);
|
|
713
|
+
}
|
|
714
|
+
function getShapePropControllerSwatchIds(descriptor, value) {
|
|
715
|
+
return introspectShapePropControllerData(descriptor, value, getSwatchIds);
|
|
665
716
|
}
|
|
666
717
|
function SocialLinks(options = {}) {
|
|
667
718
|
return { type: Types.SocialLinks, options };
|
|
@@ -715,6 +766,11 @@ var descriptors = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.definePro
|
|
|
715
766
|
Link: Link$1,
|
|
716
767
|
List: List$1,
|
|
717
768
|
introspectListPropControllerData,
|
|
769
|
+
getListPropControllerElementChildren,
|
|
770
|
+
getListPropControllerSwatchIds,
|
|
771
|
+
getListPropControllerFileIds,
|
|
772
|
+
getListPropControllerTypographyIds,
|
|
773
|
+
getListPropControllerPageIds,
|
|
718
774
|
MarginPropControllerFormat,
|
|
719
775
|
Margin,
|
|
720
776
|
NavigationLinks,
|
|
@@ -732,6 +788,11 @@ var descriptors = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.definePro
|
|
|
732
788
|
Shadows,
|
|
733
789
|
Shape: Shape$1,
|
|
734
790
|
introspectShapePropControllerData,
|
|
791
|
+
getShapePropControllerElementChildren,
|
|
792
|
+
getShapePropControllerFileIds,
|
|
793
|
+
getShapePropControllerTypographyIds,
|
|
794
|
+
getShapePropControllerPageIds,
|
|
795
|
+
getShapePropControllerSwatchIds,
|
|
735
796
|
SocialLinks,
|
|
736
797
|
Table,
|
|
737
798
|
TableFormFields,
|
|
@@ -1002,17 +1063,32 @@ class ListControl extends PropController {
|
|
|
1002
1063
|
this.controls = /* @__PURE__ */ new Map();
|
|
1003
1064
|
}
|
|
1004
1065
|
}
|
|
1005
|
-
function copyListData(
|
|
1066
|
+
function copyListData(definition2, value, context) {
|
|
1006
1067
|
if (value == null)
|
|
1007
1068
|
return value;
|
|
1008
1069
|
return value && value.map((item) => __spreadProps(__spreadValues({}, item), {
|
|
1009
|
-
value: copy(
|
|
1070
|
+
value: copy(definition2.config.type, item.value, context)
|
|
1010
1071
|
}));
|
|
1011
1072
|
}
|
|
1012
|
-
function introspectListData(
|
|
1073
|
+
function introspectListData(definition2, value, func) {
|
|
1013
1074
|
if (value == null)
|
|
1014
1075
|
return [];
|
|
1015
|
-
return value.flatMap((item) => func(
|
|
1076
|
+
return value.flatMap((item) => func(definition2.config.type, item.value));
|
|
1077
|
+
}
|
|
1078
|
+
function getListElementChildren(definition2, value) {
|
|
1079
|
+
return introspectListData(definition2, value, getElementChildren);
|
|
1080
|
+
}
|
|
1081
|
+
function getListSwatchIds(definition2, value) {
|
|
1082
|
+
return introspectListData(definition2, value, getSwatchIds);
|
|
1083
|
+
}
|
|
1084
|
+
function getListFileIds(definition2, value) {
|
|
1085
|
+
return introspectListData(definition2, value, getFileIds);
|
|
1086
|
+
}
|
|
1087
|
+
function getListTypographyIds(definition2, value) {
|
|
1088
|
+
return introspectListData(definition2, value, getTypographyIds);
|
|
1089
|
+
}
|
|
1090
|
+
function getListPageIds(definition2, value) {
|
|
1091
|
+
return introspectListData(definition2, value, getPageIds);
|
|
1016
1092
|
}
|
|
1017
1093
|
const ShapeControlType = "makeswift::controls::shape";
|
|
1018
1094
|
function Shape(config) {
|
|
@@ -1057,20 +1133,35 @@ class ShapeControl extends PropController {
|
|
|
1057
1133
|
this.setControls();
|
|
1058
1134
|
}
|
|
1059
1135
|
}
|
|
1060
|
-
function copyShapeData(
|
|
1136
|
+
function copyShapeData(definition2, value, context) {
|
|
1061
1137
|
if (value == null)
|
|
1062
1138
|
return value;
|
|
1063
1139
|
const newValue = {};
|
|
1064
|
-
for (const [key, itemDefinition] of Object.entries(
|
|
1140
|
+
for (const [key, itemDefinition] of Object.entries(definition2.config.type)) {
|
|
1065
1141
|
const prop = value[key];
|
|
1066
1142
|
newValue[key] = copy(itemDefinition, prop, context);
|
|
1067
1143
|
}
|
|
1068
1144
|
return newValue;
|
|
1069
1145
|
}
|
|
1070
|
-
function introspectShapeData(
|
|
1146
|
+
function introspectShapeData(definition2, value, func) {
|
|
1071
1147
|
if (value == null)
|
|
1072
1148
|
return [];
|
|
1073
|
-
return Object.entries(
|
|
1149
|
+
return Object.entries(definition2.config.type).flatMap(([key, definition22]) => func(definition22, value[key]));
|
|
1150
|
+
}
|
|
1151
|
+
function getShapeElementChildren(definition2, data) {
|
|
1152
|
+
return introspectShapeData(definition2, data, getElementChildren);
|
|
1153
|
+
}
|
|
1154
|
+
function getShapeSwatchIds(definition2, data) {
|
|
1155
|
+
return introspectShapeData(definition2, data, getSwatchIds);
|
|
1156
|
+
}
|
|
1157
|
+
function getShapeTypographyIds(definition2, data) {
|
|
1158
|
+
return introspectShapeData(definition2, data, getTypographyIds);
|
|
1159
|
+
}
|
|
1160
|
+
function getShapePageIds(definition2, data) {
|
|
1161
|
+
return introspectShapeData(definition2, data, getPageIds);
|
|
1162
|
+
}
|
|
1163
|
+
function getShapeFileIds(definition2, data) {
|
|
1164
|
+
return introspectShapeData(definition2, data, getFileIds);
|
|
1074
1165
|
}
|
|
1075
1166
|
const SlotControlType = "makeswift::controls::slot";
|
|
1076
1167
|
function Slot() {
|
|
@@ -1868,8 +1959,8 @@ function copy$1(descriptor, value, context) {
|
|
|
1868
1959
|
function copyElementReference(value, context) {
|
|
1869
1960
|
return context.replacementContext.globalElementIds.get(value) || value;
|
|
1870
1961
|
}
|
|
1871
|
-
function copy(
|
|
1872
|
-
switch (
|
|
1962
|
+
function copy(definition2, value, context) {
|
|
1963
|
+
switch (definition2.type) {
|
|
1873
1964
|
case Types.Backgrounds:
|
|
1874
1965
|
case Types.Grid:
|
|
1875
1966
|
case Types.NavigationLinks:
|
|
@@ -1883,7 +1974,7 @@ function copy(definition, value, context) {
|
|
|
1883
1974
|
case Types.Border:
|
|
1884
1975
|
case Types.RichText:
|
|
1885
1976
|
case Types.ElementID:
|
|
1886
|
-
return copy$1(
|
|
1977
|
+
return copy$1(definition2, value, context);
|
|
1887
1978
|
case ColorControlType:
|
|
1888
1979
|
return copyColorData(value, context);
|
|
1889
1980
|
case ImageControlType:
|
|
@@ -1891,9 +1982,9 @@ function copy(definition, value, context) {
|
|
|
1891
1982
|
case LinkControlType:
|
|
1892
1983
|
return copyLinkData(value, context);
|
|
1893
1984
|
case ShapeControlType:
|
|
1894
|
-
return copyShapeData(
|
|
1985
|
+
return copyShapeData(definition2, value, context);
|
|
1895
1986
|
case ListControlType:
|
|
1896
|
-
return copyListData(
|
|
1987
|
+
return copyListData(definition2, value, context);
|
|
1897
1988
|
case StyleControlType:
|
|
1898
1989
|
return copyStyleData(value, context);
|
|
1899
1990
|
case SlotControlType:
|
|
@@ -1902,14 +1993,31 @@ function copy(definition, value, context) {
|
|
|
1902
1993
|
return value;
|
|
1903
1994
|
}
|
|
1904
1995
|
}
|
|
1905
|
-
function merge(
|
|
1906
|
-
switch (
|
|
1996
|
+
function merge(definition2, a, b = a, context) {
|
|
1997
|
+
switch (definition2.type) {
|
|
1907
1998
|
case SlotControlType:
|
|
1908
1999
|
return mergeSlotData(a, b, context);
|
|
1909
2000
|
default:
|
|
1910
2001
|
return b;
|
|
1911
2002
|
}
|
|
1912
2003
|
}
|
|
2004
|
+
const unstable_IconRadioGroupIcon = {
|
|
2005
|
+
TextAlignCenter: "TextAlignCenter",
|
|
2006
|
+
TextAlignJustify: "TextAlignJustify",
|
|
2007
|
+
TextAlignLeft: "TextAlignLeft",
|
|
2008
|
+
TextAlignRight: "TextAlignRight",
|
|
2009
|
+
Superscript: "Superscript16",
|
|
2010
|
+
Subscript: "Subscript16",
|
|
2011
|
+
Code: "Code16"
|
|
2012
|
+
};
|
|
2013
|
+
const IconRadioGroupControlType = "makeswift::controls::icon-radio-group";
|
|
2014
|
+
function unstable_IconRadioGroup(config) {
|
|
2015
|
+
return { type: IconRadioGroupControlType, config };
|
|
2016
|
+
}
|
|
2017
|
+
const SelectControlType = "makeswift::controls::select";
|
|
2018
|
+
function Select(config) {
|
|
2019
|
+
return { type: SelectControlType, config };
|
|
2020
|
+
}
|
|
1913
2021
|
const isServer = typeof window === "undefined";
|
|
1914
2022
|
const useInsertionEffectSpecifier = "useInsertionEffect";
|
|
1915
2023
|
const useInsertionEffect = (_a = React__default["default"][useInsertionEffectSpecifier]) != null ? _a : React__default["default"].useLayoutEffect;
|
|
@@ -1975,7 +2083,6 @@ const ObjectType = {
|
|
|
1975
2083
|
};
|
|
1976
2084
|
const RootBlockType = {
|
|
1977
2085
|
Default: "default",
|
|
1978
|
-
Text: "text-block",
|
|
1979
2086
|
Paragraph: "paragraph",
|
|
1980
2087
|
Heading1: "heading-one",
|
|
1981
2088
|
Heading2: "heading-two",
|
|
@@ -2147,7 +2254,6 @@ function toNodeDTO(node) {
|
|
|
2147
2254
|
case BlockType.Heading5:
|
|
2148
2255
|
case BlockType.Heading6:
|
|
2149
2256
|
case BlockType.Default:
|
|
2150
|
-
case BlockType.Text:
|
|
2151
2257
|
case BlockType.BlockQuote:
|
|
2152
2258
|
case BlockType.Paragraph:
|
|
2153
2259
|
case BlockType.OrderedList:
|
|
@@ -2201,9 +2307,6 @@ function richTextDAOToDTO(children, selection) {
|
|
|
2201
2307
|
};
|
|
2202
2308
|
}
|
|
2203
2309
|
const RichTextControlType = "makeswift::controls::rich-text";
|
|
2204
|
-
function RichText() {
|
|
2205
|
-
return { type: RichTextControlType };
|
|
2206
|
-
}
|
|
2207
2310
|
const RichTextControlMessageType = {
|
|
2208
2311
|
CHANGE_BUILDER_EDIT_MODE: "CHANGE_BUILDER_EDIT_MODE",
|
|
2209
2312
|
INITIALIZE_EDITOR: "INITIALIZE_EDITOR",
|
|
@@ -2273,30 +2376,1362 @@ class RichTextControl extends PropController {
|
|
|
2273
2376
|
function richTextV2DataToDescendents(data) {
|
|
2274
2377
|
return data.descendants;
|
|
2275
2378
|
}
|
|
2276
|
-
function richTextV2DescendentsToData(descendants) {
|
|
2379
|
+
function richTextV2DescendentsToData(descendants, key) {
|
|
2277
2380
|
return {
|
|
2278
2381
|
type: RichTextV2ControlType,
|
|
2279
2382
|
version: 2,
|
|
2280
|
-
descendants
|
|
2383
|
+
descendants,
|
|
2384
|
+
key
|
|
2281
2385
|
};
|
|
2282
2386
|
}
|
|
2283
|
-
const RichTextV2ControlType = "makeswift::controls::rich-text-v2";
|
|
2284
|
-
const RichTextV2Mode = {
|
|
2285
|
-
Inline: "makeswift::controls::rich-text-v2::mode::inline",
|
|
2286
|
-
Block: "makeswift::controls::rich-text-v2::mode::block"
|
|
2287
|
-
};
|
|
2288
2387
|
function createRichTextV2Plugin({
|
|
2289
2388
|
control,
|
|
2290
2389
|
withPlugin,
|
|
2291
|
-
onKeyDown,
|
|
2390
|
+
onKeyDown: onKeyDown2,
|
|
2292
2391
|
renderElement,
|
|
2293
2392
|
renderLeaf
|
|
2294
2393
|
}) {
|
|
2295
|
-
return { control, withPlugin, onKeyDown, renderElement, renderLeaf };
|
|
2394
|
+
return { control, withPlugin, onKeyDown: onKeyDown2, renderElement, renderLeaf };
|
|
2395
|
+
}
|
|
2396
|
+
const ElementUtils = {
|
|
2397
|
+
isRootBlock(node) {
|
|
2398
|
+
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.Default));
|
|
2399
|
+
},
|
|
2400
|
+
isBlock(node) {
|
|
2401
|
+
return slate.Element.isElement(node) && (this.isRootBlock(node) || slate.Element.isElementType(node, BlockType.ListItem) || slate.Element.isElementType(node, BlockType.ListItemChild));
|
|
2402
|
+
},
|
|
2403
|
+
isInline(node) {
|
|
2404
|
+
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);
|
|
2405
|
+
},
|
|
2406
|
+
isConvertibleToListTextNode(node) {
|
|
2407
|
+
return !this.isList(node) && !this.isListItem(node) && !this.isListItemChild(node);
|
|
2408
|
+
},
|
|
2409
|
+
isList(node) {
|
|
2410
|
+
return slate.Element.isElementType(node, BlockType.OrderedList) || slate.Element.isElementType(node, BlockType.UnorderedList);
|
|
2411
|
+
},
|
|
2412
|
+
isListItem(node) {
|
|
2413
|
+
return slate.Element.isElementType(node, BlockType.ListItem);
|
|
2414
|
+
},
|
|
2415
|
+
isListItemChild(node) {
|
|
2416
|
+
return slate.Element.isElementType(node, BlockType.ListItemChild);
|
|
2417
|
+
},
|
|
2418
|
+
createText() {
|
|
2419
|
+
return { text: "" };
|
|
2420
|
+
},
|
|
2421
|
+
createParagraph() {
|
|
2422
|
+
return {
|
|
2423
|
+
children: [this.createText()],
|
|
2424
|
+
type: BlockType.Paragraph
|
|
2425
|
+
};
|
|
2426
|
+
},
|
|
2427
|
+
createList(type = BlockType.UnorderedList) {
|
|
2428
|
+
return { children: [this.createText()], type };
|
|
2429
|
+
},
|
|
2430
|
+
createListItem() {
|
|
2431
|
+
return {
|
|
2432
|
+
children: [this.createListItemChild()],
|
|
2433
|
+
type: BlockType.ListItem
|
|
2434
|
+
};
|
|
2435
|
+
},
|
|
2436
|
+
createListItemChild() {
|
|
2437
|
+
return {
|
|
2438
|
+
children: [this.createText()],
|
|
2439
|
+
type: BlockType.ListItemChild
|
|
2440
|
+
};
|
|
2441
|
+
}
|
|
2442
|
+
};
|
|
2443
|
+
function isLinkElement(node) {
|
|
2444
|
+
return ElementUtils.isInline(node) && node.type === InlineType.Link;
|
|
2445
|
+
}
|
|
2446
|
+
function isLinkEntry(inline) {
|
|
2447
|
+
return ElementUtils.isInline(inline[0]) && inline[0].type === InlineType.Link;
|
|
2448
|
+
}
|
|
2449
|
+
function unhangRange(editor, range) {
|
|
2450
|
+
let [start, end] = slate.Range.edges(range);
|
|
2451
|
+
if (start.offset !== 0 || end.offset !== 0 || slate.Range.isCollapsed(range)) {
|
|
2452
|
+
return range;
|
|
2453
|
+
}
|
|
2454
|
+
const endBlock = slate.Editor.above(editor, {
|
|
2455
|
+
at: end,
|
|
2456
|
+
match: (n) => slate.Element.isElement(n) && slate.Editor.isBlock(editor, n)
|
|
2457
|
+
});
|
|
2458
|
+
const blockPath = endBlock ? endBlock[1] : [];
|
|
2459
|
+
const first = slate.Editor.start(editor, start);
|
|
2460
|
+
const before = { anchor: first, focus: end };
|
|
2461
|
+
let skip = true;
|
|
2462
|
+
for (const [node, path] of slate.Editor.nodes(editor, {
|
|
2463
|
+
at: before,
|
|
2464
|
+
match: slate.Text.isText,
|
|
2465
|
+
reverse: true
|
|
2466
|
+
})) {
|
|
2467
|
+
if (skip) {
|
|
2468
|
+
skip = false;
|
|
2469
|
+
continue;
|
|
2470
|
+
}
|
|
2471
|
+
if (node.text !== "" || slate.Path.isBefore(path, blockPath)) {
|
|
2472
|
+
end = { path, offset: node.text.length };
|
|
2473
|
+
break;
|
|
2474
|
+
}
|
|
2475
|
+
}
|
|
2476
|
+
return { anchor: start, focus: end };
|
|
2477
|
+
}
|
|
2478
|
+
function is(x, y) {
|
|
2479
|
+
if (x === y)
|
|
2480
|
+
return x !== 0 || y !== 0 || 1 / x === 1 / y;
|
|
2481
|
+
return x !== x && y !== y;
|
|
2482
|
+
}
|
|
2483
|
+
const { hasOwnProperty: hasOwnProperty$1 } = Object.prototype;
|
|
2484
|
+
const shallowEqual = (a, b) => {
|
|
2485
|
+
if (is(a, b))
|
|
2486
|
+
return true;
|
|
2487
|
+
if (typeof a !== "object" || a === null || typeof b !== "object" || b === null)
|
|
2488
|
+
return false;
|
|
2489
|
+
const keysA = Object.keys(a);
|
|
2490
|
+
const keysB = Object.keys(b);
|
|
2491
|
+
if (keysA.length !== keysB.length)
|
|
2492
|
+
return false;
|
|
2493
|
+
for (let i = 0; i < keysA.length; i += 1) {
|
|
2494
|
+
if (!hasOwnProperty$1.call(b, keysA[i]) || !is(a[keysA[i]], b[keysA[i]]))
|
|
2495
|
+
return false;
|
|
2496
|
+
}
|
|
2497
|
+
return true;
|
|
2498
|
+
};
|
|
2499
|
+
function isNonNullable(value) {
|
|
2500
|
+
return value != null;
|
|
2501
|
+
}
|
|
2502
|
+
const { hasOwnProperty } = Object.prototype;
|
|
2503
|
+
const deepEqual = (a, b) => {
|
|
2504
|
+
if (shallowEqual(a, b))
|
|
2505
|
+
return true;
|
|
2506
|
+
if (typeof a !== "object" || a === null || typeof b !== "object" || b === null)
|
|
2507
|
+
return false;
|
|
2508
|
+
const keysA = Object.keys(a);
|
|
2509
|
+
const keysB = Object.keys(b);
|
|
2510
|
+
if (keysA.length !== keysB.length)
|
|
2511
|
+
return false;
|
|
2512
|
+
for (let i = 0; i < keysA.length; i += 1) {
|
|
2513
|
+
if (!hasOwnProperty.call(b, keysA[i]) || !deepEqual(a[keysA[i]], b[keysA[i]]))
|
|
2514
|
+
return false;
|
|
2515
|
+
}
|
|
2516
|
+
return true;
|
|
2517
|
+
};
|
|
2518
|
+
function getSelection(editor) {
|
|
2519
|
+
if (editor.selection)
|
|
2520
|
+
return unhangRange(editor, editor.selection);
|
|
2521
|
+
return {
|
|
2522
|
+
anchor: slate.Editor.start(editor, []),
|
|
2523
|
+
focus: slate.Editor.end(editor, [])
|
|
2524
|
+
};
|
|
2525
|
+
}
|
|
2526
|
+
function getBlocksInSelection(editor) {
|
|
2527
|
+
return Array.from(slate.Editor.nodes(editor, {
|
|
2528
|
+
at: getSelection(editor),
|
|
2529
|
+
match: (node) => ElementUtils.isRootBlock(node)
|
|
2530
|
+
})).filter((entry) => ElementUtils.isRootBlock(entry[0]));
|
|
2531
|
+
}
|
|
2532
|
+
function getActiveBlockType(editor) {
|
|
2533
|
+
var _a2;
|
|
2534
|
+
const rootBlocks = getBlocksInSelection(editor).map(([node]) => node.type);
|
|
2535
|
+
return rootBlocks.reduce((a, b) => a === b ? b : null, (_a2 = rootBlocks.at(0)) != null ? _a2 : null);
|
|
2536
|
+
}
|
|
2537
|
+
function unwrapInline(editor, type) {
|
|
2538
|
+
slate.Transforms.unwrapNodes(editor, {
|
|
2539
|
+
match: (node) => ElementUtils.isInline(node) && node.type === type,
|
|
2540
|
+
at: getSelection(editor)
|
|
2541
|
+
});
|
|
2542
|
+
}
|
|
2543
|
+
function wrapInline(editor, inline) {
|
|
2544
|
+
slate.Transforms.wrapNodes(editor, inline, {
|
|
2545
|
+
at: getSelection(editor),
|
|
2546
|
+
split: true
|
|
2547
|
+
});
|
|
2548
|
+
}
|
|
2549
|
+
function filterForSubtreeRoots(entries) {
|
|
2550
|
+
return entries.filter(([, nodePath]) => !slate.Path.ancestors(nodePath).some((ancestor) => {
|
|
2551
|
+
return entries.some(([, path]) => slate.Path.equals(path, ancestor));
|
|
2552
|
+
}));
|
|
2553
|
+
}
|
|
2554
|
+
function getLinksAndTextInSelection(editor) {
|
|
2555
|
+
return Array.from(slate.Editor.nodes(editor, {
|
|
2556
|
+
at: getSelection(editor),
|
|
2557
|
+
match: (node) => ElementUtils.isInline(node) && isLinkElement(node) || slate.Text.isText(node)
|
|
2558
|
+
}));
|
|
2559
|
+
}
|
|
2560
|
+
const getValue$3 = (editor) => {
|
|
2561
|
+
var _a2;
|
|
2562
|
+
const roots = filterForSubtreeRoots(getLinksAndTextInSelection(editor));
|
|
2563
|
+
const areAllRootsLinks = roots.every(([root]) => isLinkElement(root) || slate.Text.isText(root));
|
|
2564
|
+
if (!areAllRootsLinks)
|
|
2565
|
+
return void 0;
|
|
2566
|
+
const matchingValues = roots.map(([node]) => node).filter(isLinkElement);
|
|
2567
|
+
const match = matchingValues.reduce((a, b) => deepEqual(a == null ? void 0 : a.link, b == null ? void 0 : b.link) ? b : null, (_a2 = matchingValues.at(0)) != null ? _a2 : void 0);
|
|
2568
|
+
return match == null ? match : match.link;
|
|
2569
|
+
};
|
|
2570
|
+
const onChange$1 = (editor, value) => {
|
|
2571
|
+
if (value == null)
|
|
2572
|
+
return unwrapInline(editor, InlineType.Link);
|
|
2573
|
+
const roots = filterForSubtreeRoots(getLinksAndTextInSelection(editor));
|
|
2574
|
+
const root = roots.at(0);
|
|
2575
|
+
if (roots.length === 1 && root != null && isLinkEntry(root)) {
|
|
2576
|
+
slate.Transforms.setNodes(editor, {
|
|
2577
|
+
link: value
|
|
2578
|
+
}, { at: root[1] });
|
|
2579
|
+
} else {
|
|
2580
|
+
unwrapInline(editor, InlineType.Link);
|
|
2581
|
+
wrapInline(editor, { type: InlineType.Link, link: value, children: [] });
|
|
2582
|
+
}
|
|
2583
|
+
};
|
|
2584
|
+
function LinkPlugin() {
|
|
2585
|
+
return createRichTextV2Plugin({
|
|
2586
|
+
control: {
|
|
2587
|
+
definition: Link({
|
|
2588
|
+
label: "On Click"
|
|
2589
|
+
}),
|
|
2590
|
+
onChange: onChange$1,
|
|
2591
|
+
getValue: getValue$3,
|
|
2592
|
+
getElementValue: (element) => {
|
|
2593
|
+
return ElementUtils.isInline(element) && isLinkElement(element) ? element.link : void 0;
|
|
2594
|
+
}
|
|
2595
|
+
}
|
|
2596
|
+
});
|
|
2597
|
+
}
|
|
2598
|
+
const supportedInlineOptions = [
|
|
2599
|
+
{
|
|
2600
|
+
icon: unstable_IconRadioGroupIcon.Superscript,
|
|
2601
|
+
label: "Superscript",
|
|
2602
|
+
value: "superscript"
|
|
2603
|
+
},
|
|
2604
|
+
{
|
|
2605
|
+
icon: unstable_IconRadioGroupIcon.Subscript,
|
|
2606
|
+
label: "Subscript",
|
|
2607
|
+
value: "subscript"
|
|
2608
|
+
},
|
|
2609
|
+
{
|
|
2610
|
+
icon: unstable_IconRadioGroupIcon.Code,
|
|
2611
|
+
label: "Code",
|
|
2612
|
+
value: "code"
|
|
2613
|
+
}
|
|
2614
|
+
];
|
|
2615
|
+
function isSupportedInlineType(inline) {
|
|
2616
|
+
return supportedInlineOptions.findIndex((option) => option.value === inline) !== -1;
|
|
2617
|
+
}
|
|
2618
|
+
function isSupportedInlineEntry(entry) {
|
|
2619
|
+
const node = entry[0];
|
|
2620
|
+
return ElementUtils.isInline(node) && supportedInlineOptions.findIndex((option) => option.value === node.type) !== -1;
|
|
2621
|
+
}
|
|
2622
|
+
function getSupportedInlinesAndTextInSelection(editor) {
|
|
2623
|
+
return Array.from(slate.Editor.nodes(editor, {
|
|
2624
|
+
at: getSelection(editor),
|
|
2625
|
+
match: (node) => ElementUtils.isInline(node) && isSupportedInlineType(node.type) || slate.Text.isText(node)
|
|
2626
|
+
}));
|
|
2627
|
+
}
|
|
2628
|
+
const getValue$2 = (editor) => {
|
|
2629
|
+
var _a2;
|
|
2630
|
+
const roots = filterForSubtreeRoots(getSupportedInlinesAndTextInSelection(editor));
|
|
2631
|
+
const areAllRootsSupportedInlineTypesOrText = roots.every((entry) => isSupportedInlineEntry(entry) || slate.Text.isText(entry[0]));
|
|
2632
|
+
if (!areAllRootsSupportedInlineTypesOrText)
|
|
2633
|
+
return void 0;
|
|
2634
|
+
const matchingValues = roots.filter(isSupportedInlineEntry).map(([node]) => node);
|
|
2635
|
+
const match = matchingValues.reduce((a, b) => (a == null ? void 0 : a.type) === (b == null ? void 0 : b.type) ? b : null, (_a2 = matchingValues.at(0)) != null ? _a2 : void 0);
|
|
2636
|
+
return match == null ? match : match.type;
|
|
2637
|
+
};
|
|
2638
|
+
const onChange = (editor, value) => {
|
|
2639
|
+
function unwrapAllSupportedTypes() {
|
|
2640
|
+
supportedInlineOptions.forEach(({ value: optionValue }) => unwrapInline(editor, optionValue));
|
|
2641
|
+
}
|
|
2642
|
+
function unwrapAllInlines() {
|
|
2643
|
+
slate.Transforms.unwrapNodes(editor, {
|
|
2644
|
+
match: (node) => ElementUtils.isInline(node),
|
|
2645
|
+
at: getSelection(editor)
|
|
2646
|
+
});
|
|
2647
|
+
}
|
|
2648
|
+
if (value == null)
|
|
2649
|
+
return unwrapAllSupportedTypes();
|
|
2650
|
+
if (!isSupportedInlineType(value))
|
|
2651
|
+
return;
|
|
2652
|
+
const roots = filterForSubtreeRoots(getSupportedInlinesAndTextInSelection(editor));
|
|
2653
|
+
const root = roots.at(0);
|
|
2654
|
+
if (roots.length === 1 && root != null && isSupportedInlineEntry(root) && root[0].type === value) {
|
|
2655
|
+
unwrapInline(editor, value);
|
|
2656
|
+
} else {
|
|
2657
|
+
unwrapAllInlines();
|
|
2658
|
+
wrapInline(editor, { type: value, children: [] });
|
|
2659
|
+
}
|
|
2660
|
+
};
|
|
2661
|
+
const withInline = (editor) => {
|
|
2662
|
+
const {
|
|
2663
|
+
isInline
|
|
2664
|
+
} = editor;
|
|
2665
|
+
editor.isInline = (entry) => {
|
|
2666
|
+
return ElementUtils.isInline(entry) && isInline(entry);
|
|
2667
|
+
};
|
|
2668
|
+
return editor;
|
|
2669
|
+
};
|
|
2670
|
+
function InlinePlugin() {
|
|
2671
|
+
return createRichTextV2Plugin({
|
|
2672
|
+
control: {
|
|
2673
|
+
definition: unstable_IconRadioGroup({
|
|
2674
|
+
label: "Inline",
|
|
2675
|
+
options: supportedInlineOptions
|
|
2676
|
+
}),
|
|
2677
|
+
onChange,
|
|
2678
|
+
getValue: getValue$2,
|
|
2679
|
+
getElementValue: (element) => {
|
|
2680
|
+
return ElementUtils.isInline(element) ? element.type : void 0;
|
|
2681
|
+
}
|
|
2682
|
+
},
|
|
2683
|
+
withPlugin: withInline,
|
|
2684
|
+
renderElement: (renderElement) => (props) => {
|
|
2685
|
+
return /* @__PURE__ */ jsxRuntime.jsx(InlinePluginComponent, __spreadProps(__spreadValues({}, props), {
|
|
2686
|
+
renderElement
|
|
2687
|
+
}));
|
|
2688
|
+
}
|
|
2689
|
+
});
|
|
2690
|
+
}
|
|
2691
|
+
function InlinePluginComponent(_b) {
|
|
2692
|
+
var _c = _b, {
|
|
2693
|
+
renderElement
|
|
2694
|
+
} = _c, props = __objRest(_c, [
|
|
2695
|
+
"renderElement"
|
|
2696
|
+
]);
|
|
2697
|
+
switch (props.element.type) {
|
|
2698
|
+
case InlineType.Code:
|
|
2699
|
+
return /* @__PURE__ */ jsxRuntime.jsx("code", __spreadProps(__spreadValues({}, props.attributes), {
|
|
2700
|
+
children: renderElement(props)
|
|
2701
|
+
}));
|
|
2702
|
+
case InlineType.SuperScript:
|
|
2703
|
+
return /* @__PURE__ */ jsxRuntime.jsx("sup", __spreadProps(__spreadValues({}, props.attributes), {
|
|
2704
|
+
children: renderElement(props)
|
|
2705
|
+
}));
|
|
2706
|
+
case InlineType.SubScript:
|
|
2707
|
+
return /* @__PURE__ */ jsxRuntime.jsx("sub", __spreadProps(__spreadValues({}, props.attributes), {
|
|
2708
|
+
children: renderElement(props)
|
|
2709
|
+
}));
|
|
2710
|
+
default:
|
|
2711
|
+
return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, {
|
|
2712
|
+
children: renderElement(props)
|
|
2713
|
+
});
|
|
2714
|
+
}
|
|
2715
|
+
}
|
|
2716
|
+
function setResponsiveValue(editor, key, value, options) {
|
|
2717
|
+
slate.Editor.withoutNormalizing(editor, () => {
|
|
2718
|
+
const at = getSelection(editor);
|
|
2719
|
+
if (!at)
|
|
2720
|
+
return;
|
|
2721
|
+
const atRef = slate.Editor.rangeRef(editor, at);
|
|
2722
|
+
if (atRef.current) {
|
|
2723
|
+
slate.Transforms.setNodes(editor, {
|
|
2724
|
+
slice: true
|
|
2725
|
+
}, {
|
|
2726
|
+
at: atRef.current,
|
|
2727
|
+
match: options.match,
|
|
2728
|
+
split: options.split
|
|
2729
|
+
});
|
|
2730
|
+
}
|
|
2731
|
+
if (atRef.current) {
|
|
2732
|
+
const nodesToUpdate = Array.from(slate.Editor.nodes(editor, {
|
|
2733
|
+
at: atRef.current,
|
|
2734
|
+
match: (node, path) => options.match(node, path) && node.slice === true
|
|
2735
|
+
}));
|
|
2736
|
+
for (const [, path] of nodesToUpdate) {
|
|
2737
|
+
slate.Transforms.setNodes(editor, {
|
|
2738
|
+
[key]: value
|
|
2739
|
+
}, { at: path });
|
|
2740
|
+
}
|
|
2741
|
+
}
|
|
2742
|
+
atRef.unref();
|
|
2743
|
+
});
|
|
2744
|
+
}
|
|
2745
|
+
function normalizeResponsiveValue(editor, key, options) {
|
|
2746
|
+
return (entry) => {
|
|
2747
|
+
const [node, path] = entry;
|
|
2748
|
+
if (!options.match(node, path)) {
|
|
2749
|
+
return false;
|
|
2750
|
+
}
|
|
2751
|
+
const responsiveValue = node == null ? void 0 : node[key];
|
|
2752
|
+
if (Array.isArray(responsiveValue) && responsiveValue.length === 0) {
|
|
2753
|
+
slate.Transforms.unsetNodes(editor, key, { at: path });
|
|
2754
|
+
return true;
|
|
2755
|
+
}
|
|
2756
|
+
if ((node == null ? void 0 : node.slice) != null) {
|
|
2757
|
+
slate.Transforms.unsetNodes(editor, "slice", { at: path });
|
|
2758
|
+
return true;
|
|
2759
|
+
}
|
|
2760
|
+
return false;
|
|
2761
|
+
};
|
|
2762
|
+
}
|
|
2763
|
+
function responsiveShallowEqual(a = [], b = []) {
|
|
2764
|
+
const aObject = a.reduce((acc, curr) => __spreadProps(__spreadValues({}, acc), {
|
|
2765
|
+
[curr.deviceId]: curr.value
|
|
2766
|
+
}), {});
|
|
2767
|
+
const bObject = b.reduce((acc, curr) => __spreadProps(__spreadValues({}, acc), {
|
|
2768
|
+
[curr.deviceId]: curr.value
|
|
2769
|
+
}), {});
|
|
2770
|
+
const definedDevices = /* @__PURE__ */ new Set([...a.map((a2) => a2.deviceId), ...b.map((b2) => b2.deviceId)]);
|
|
2771
|
+
return Array.from(definedDevices).map((deviceId) => {
|
|
2772
|
+
const aVal = aObject[deviceId];
|
|
2773
|
+
const bVal = bObject[deviceId];
|
|
2774
|
+
if (aVal === void 0 && bVal === void 0)
|
|
2775
|
+
return { deviceId, value: void 0 };
|
|
2776
|
+
return shallowEqual(aVal, bVal) ? { deviceId, value: aVal } : { deviceId, value: null };
|
|
2777
|
+
});
|
|
2778
|
+
}
|
|
2779
|
+
function getValue$1(editor) {
|
|
2780
|
+
const matchingValues = Array.from(slate.Editor.nodes(editor, {
|
|
2781
|
+
at: getSelection(editor),
|
|
2782
|
+
match: ElementUtils.isRootBlock
|
|
2783
|
+
})).map(([node]) => node["textAlign"]);
|
|
2784
|
+
return matchingValues.length === 0 ? void 0 : matchingValues.reduce((a, b) => {
|
|
2785
|
+
return responsiveShallowEqual(a, b);
|
|
2786
|
+
});
|
|
2787
|
+
}
|
|
2788
|
+
const TEXT_ALIGN_KEY = "textAlign";
|
|
2789
|
+
const withTextAlign = (editor) => {
|
|
2790
|
+
const {
|
|
2791
|
+
normalizeNode
|
|
2792
|
+
} = editor;
|
|
2793
|
+
editor.normalizeNode = (entry) => {
|
|
2794
|
+
if (normalizeResponsiveValue(editor, TEXT_ALIGN_KEY, {
|
|
2795
|
+
match: ElementUtils.isRootBlock
|
|
2796
|
+
})(entry)) {
|
|
2797
|
+
return;
|
|
2798
|
+
}
|
|
2799
|
+
normalizeNode(entry);
|
|
2800
|
+
};
|
|
2801
|
+
return editor;
|
|
2802
|
+
};
|
|
2803
|
+
function TextAlignPlugin() {
|
|
2804
|
+
return createRichTextV2Plugin({
|
|
2805
|
+
control: {
|
|
2806
|
+
definition: unstable_StyleV2({
|
|
2807
|
+
type: unstable_IconRadioGroup({
|
|
2808
|
+
label: "Alignment",
|
|
2809
|
+
options: [{
|
|
2810
|
+
icon: unstable_IconRadioGroupIcon.TextAlignLeft,
|
|
2811
|
+
label: "Left Align",
|
|
2812
|
+
value: "left"
|
|
2813
|
+
}, {
|
|
2814
|
+
icon: unstable_IconRadioGroupIcon.TextAlignCenter,
|
|
2815
|
+
label: "Center Align",
|
|
2816
|
+
value: "center"
|
|
2817
|
+
}, {
|
|
2818
|
+
icon: unstable_IconRadioGroupIcon.TextAlignRight,
|
|
2819
|
+
label: "Right Align",
|
|
2820
|
+
value: "right"
|
|
2821
|
+
}, {
|
|
2822
|
+
icon: unstable_IconRadioGroupIcon.TextAlignJustify,
|
|
2823
|
+
label: "Justify",
|
|
2824
|
+
value: "justify"
|
|
2825
|
+
}],
|
|
2826
|
+
defaultValue: "left"
|
|
2827
|
+
}),
|
|
2828
|
+
getStyle(textAlign) {
|
|
2829
|
+
return {
|
|
2830
|
+
textAlign
|
|
2831
|
+
};
|
|
2832
|
+
}
|
|
2833
|
+
}),
|
|
2834
|
+
onChange: (editor, value) => setResponsiveValue(editor, TEXT_ALIGN_KEY, value, {
|
|
2835
|
+
match: ElementUtils.isRootBlock,
|
|
2836
|
+
split: false
|
|
2837
|
+
}),
|
|
2838
|
+
getValue: (editor) => getValue$1(editor),
|
|
2839
|
+
getElementValue: (element) => {
|
|
2840
|
+
return ElementUtils.isRootBlock(element) ? element.textAlign : void 0;
|
|
2841
|
+
}
|
|
2842
|
+
},
|
|
2843
|
+
withPlugin: withTextAlign,
|
|
2844
|
+
renderElement: (renderElement, className) => (props) => {
|
|
2845
|
+
return renderElement(__spreadProps(__spreadValues({}, props), {
|
|
2846
|
+
element: __spreadProps(__spreadValues({}, props.element), {
|
|
2847
|
+
className
|
|
2848
|
+
})
|
|
2849
|
+
}));
|
|
2850
|
+
}
|
|
2851
|
+
});
|
|
2852
|
+
}
|
|
2853
|
+
function setBlockKeyForDevice(editor, breakpoints, deviceId, key, value, options) {
|
|
2854
|
+
var _a2, _b;
|
|
2855
|
+
const at = (_a2 = options == null ? void 0 : options.at) != null ? _a2 : editor.selection;
|
|
2856
|
+
if (!at)
|
|
2857
|
+
return;
|
|
2858
|
+
const rootElements = getBlocksInSelection(editor);
|
|
2859
|
+
for (const [node, path] of rootElements) {
|
|
2860
|
+
if (ElementUtils.isBlock(node)) {
|
|
2861
|
+
const deviceValues = (_b = node[key]) != null ? _b : [];
|
|
2862
|
+
const currentDeviceValue = state_breakpoints.findBreakpointOverride(breakpoints, deviceValues, deviceId, (v) => v);
|
|
2863
|
+
const nextDeviceValue = __spreadProps(__spreadValues({}, currentDeviceValue), {
|
|
2864
|
+
deviceId,
|
|
2865
|
+
value
|
|
2866
|
+
});
|
|
2867
|
+
slate.Transforms.setNodes(editor, {
|
|
2868
|
+
[key]: [...deviceValues.filter((v) => v.deviceId !== deviceId), nextDeviceValue]
|
|
2869
|
+
}, { at: path });
|
|
2870
|
+
}
|
|
2871
|
+
}
|
|
2872
|
+
}
|
|
2873
|
+
function clearBlockKeyForDevice(editor, deviceId, key) {
|
|
2874
|
+
var _a2;
|
|
2875
|
+
const rootElements = getBlocksInSelection(editor);
|
|
2876
|
+
for (const [node, path] of rootElements) {
|
|
2877
|
+
if (ElementUtils.isBlock(node)) {
|
|
2878
|
+
const deviceOverrides = (_a2 = node[key]) != null ? _a2 : [];
|
|
2879
|
+
slate.Transforms.setNodes(editor, {
|
|
2880
|
+
[key]: deviceOverrides.filter((v) => v.deviceId !== deviceId)
|
|
2881
|
+
}, { at: path });
|
|
2882
|
+
}
|
|
2883
|
+
}
|
|
2884
|
+
}
|
|
2885
|
+
const EditorUtils = {
|
|
2886
|
+
getFirstAncestorList(editor, path) {
|
|
2887
|
+
try {
|
|
2888
|
+
const parentList = slate.Editor.above(editor, {
|
|
2889
|
+
at: path,
|
|
2890
|
+
match: (node) => ElementUtils.isList(node)
|
|
2891
|
+
});
|
|
2892
|
+
return parentList != null ? parentList : null;
|
|
2893
|
+
} catch (e) {
|
|
2894
|
+
return null;
|
|
2895
|
+
}
|
|
2896
|
+
},
|
|
2897
|
+
getFirstAncestorListItem(editor, path) {
|
|
2898
|
+
try {
|
|
2899
|
+
const parentListItem = slate.Editor.above(editor, {
|
|
2900
|
+
at: path,
|
|
2901
|
+
match: (node) => ElementUtils.isListItem(node)
|
|
2902
|
+
});
|
|
2903
|
+
return parentListItem != null ? parentListItem : null;
|
|
2904
|
+
} catch (e) {
|
|
2905
|
+
return null;
|
|
2906
|
+
}
|
|
2907
|
+
}
|
|
2908
|
+
};
|
|
2909
|
+
const LIST_ITEM_CHILD_POSITION = 0;
|
|
2910
|
+
const LIST_ITEM_LIST_POSITION = 1;
|
|
2911
|
+
function unwrapPath(editor, listItemPath) {
|
|
2912
|
+
const parentList = EditorUtils.getFirstAncestorList(editor, listItemPath);
|
|
2913
|
+
const listItemContainingParentList = EditorUtils.getFirstAncestorListItem(editor, listItemPath);
|
|
2914
|
+
if (!parentList || listItemContainingParentList)
|
|
2915
|
+
return;
|
|
2916
|
+
slate.Editor.withoutNormalizing(editor, () => {
|
|
2917
|
+
const listItemTextPath = [...listItemPath, LIST_ITEM_CHILD_POSITION];
|
|
2918
|
+
const listItemNestedListPath = [...listItemPath, LIST_ITEM_LIST_POSITION];
|
|
2919
|
+
if (slate.Node.has(editor, listItemNestedListPath)) {
|
|
2920
|
+
slate.Transforms.setNodes(editor, { type: parentList[0].type }, { at: listItemNestedListPath });
|
|
2921
|
+
slate.Transforms.liftNodes(editor, { at: listItemNestedListPath });
|
|
2922
|
+
slate.Transforms.liftNodes(editor, { at: slate.Path.next(listItemPath) });
|
|
2923
|
+
}
|
|
2924
|
+
if (slate.Node.has(editor, listItemTextPath)) {
|
|
2925
|
+
slate.Transforms.setNodes(editor, { type: BlockType.Paragraph }, {
|
|
2926
|
+
at: listItemTextPath
|
|
2927
|
+
});
|
|
2928
|
+
slate.Transforms.liftNodes(editor, { at: listItemTextPath });
|
|
2929
|
+
slate.Transforms.liftNodes(editor, { at: listItemPath });
|
|
2930
|
+
}
|
|
2931
|
+
});
|
|
2932
|
+
}
|
|
2933
|
+
function unwrapList(editor, options) {
|
|
2934
|
+
var _a2;
|
|
2935
|
+
const at = (_a2 = options == null ? void 0 : options.at) != null ? _a2 : editor.selection;
|
|
2936
|
+
if (!at)
|
|
2937
|
+
return;
|
|
2938
|
+
const listItems = Array.from(slate.Editor.nodes(editor, {
|
|
2939
|
+
at,
|
|
2940
|
+
match: (node) => {
|
|
2941
|
+
return slate.Element.isElement(node) && ElementUtils.isListItem(node);
|
|
2942
|
+
}
|
|
2943
|
+
}));
|
|
2944
|
+
const subRoots = filterForSubtreeRoots(listItems);
|
|
2945
|
+
const refs = subRoots.map(([_, path]) => slate.Editor.pathRef(editor, path));
|
|
2946
|
+
refs.forEach((ref) => {
|
|
2947
|
+
if (ref.current) {
|
|
2948
|
+
unwrapPath(editor, ref.current);
|
|
2949
|
+
}
|
|
2950
|
+
ref.unref();
|
|
2951
|
+
});
|
|
2952
|
+
}
|
|
2953
|
+
function wrapList(editor, options = { type: BlockType.UnorderedList }) {
|
|
2954
|
+
var _a2;
|
|
2955
|
+
const at = (_a2 = options.at) != null ? _a2 : editor.selection;
|
|
2956
|
+
if (!at)
|
|
2957
|
+
return;
|
|
2958
|
+
const nonListEntries = Array.from(slate.Editor.nodes(editor, {
|
|
2959
|
+
at,
|
|
2960
|
+
match: (node) => {
|
|
2961
|
+
return slate.Element.isElement(node) && ElementUtils.isConvertibleToListTextNode(node);
|
|
2962
|
+
}
|
|
2963
|
+
}));
|
|
2964
|
+
const refs = nonListEntries.map(([_, path]) => slate.Editor.pathRef(editor, path));
|
|
2965
|
+
refs.forEach((ref) => {
|
|
2966
|
+
const path = ref.current;
|
|
2967
|
+
if (path) {
|
|
2968
|
+
slate.Editor.withoutNormalizing(editor, () => {
|
|
2969
|
+
slate.Transforms.setNodes(editor, { type: BlockType.ListItemChild }, {
|
|
2970
|
+
at: path
|
|
2971
|
+
});
|
|
2972
|
+
slate.Transforms.wrapNodes(editor, ElementUtils.createListItem(), {
|
|
2973
|
+
match: (node) => ElementUtils.isListItemChild(node),
|
|
2974
|
+
at: path
|
|
2975
|
+
});
|
|
2976
|
+
slate.Transforms.wrapNodes(editor, ElementUtils.createList(options.type), {
|
|
2977
|
+
at: path
|
|
2978
|
+
});
|
|
2979
|
+
});
|
|
2980
|
+
}
|
|
2981
|
+
ref.unref();
|
|
2982
|
+
});
|
|
2983
|
+
}
|
|
2984
|
+
const LocationUtils = {
|
|
2985
|
+
getStartPath(location) {
|
|
2986
|
+
if (slate.Range.isRange(location))
|
|
2987
|
+
return slate.Range.start(location).path;
|
|
2988
|
+
if (slate.Point.isPoint(location))
|
|
2989
|
+
return location.path;
|
|
2990
|
+
return location;
|
|
2991
|
+
}
|
|
2992
|
+
};
|
|
2993
|
+
function getSelectedListItems(editor) {
|
|
2994
|
+
var _a2, _b;
|
|
2995
|
+
if (!editor.selection)
|
|
2996
|
+
return [];
|
|
2997
|
+
const start = LocationUtils.getStartPath(editor.selection);
|
|
2998
|
+
const listItems = slate.Editor.nodes(editor, {
|
|
2999
|
+
at: editor.selection,
|
|
3000
|
+
match: (node) => ElementUtils.isListItem(node)
|
|
3001
|
+
});
|
|
3002
|
+
const firstAncestorPath = (_b = (_a2 = EditorUtils.getFirstAncestorListItem(editor, start)) == null ? void 0 : _a2[1]) != null ? _b : [];
|
|
3003
|
+
return Array.from(listItems).filter((node) => slate.Path.isDescendant(start, node[1]) ? slate.Path.equals(node[1], firstAncestorPath) : !slate.Path.isAfter(start, node[1]));
|
|
3004
|
+
}
|
|
3005
|
+
function indentPath(editor, path) {
|
|
3006
|
+
const parent = slate.Node.parent(editor, path);
|
|
3007
|
+
if (!path || !slate.Path.hasPrevious(path) || !ElementUtils.isList(parent))
|
|
3008
|
+
return;
|
|
3009
|
+
const previosPath = slate.Path.previous(path);
|
|
3010
|
+
const previousChildListPath = [...previosPath, LIST_ITEM_LIST_POSITION];
|
|
3011
|
+
const previousHasChildList = slate.Node.has(editor, previousChildListPath);
|
|
3012
|
+
slate.Editor.withoutNormalizing(editor, () => {
|
|
3013
|
+
if (!previousHasChildList) {
|
|
3014
|
+
slate.Transforms.insertNodes(editor, ElementUtils.createList(parent.type), {
|
|
3015
|
+
at: previousChildListPath
|
|
3016
|
+
});
|
|
3017
|
+
}
|
|
3018
|
+
const previousChildList = slate.Node.get(editor, previousChildListPath);
|
|
3019
|
+
if (ElementUtils.isList(previousChildList)) {
|
|
3020
|
+
const index = previousHasChildList ? previousChildList.children.length : 0;
|
|
3021
|
+
slate.Transforms.moveNodes(editor, {
|
|
3022
|
+
at: path,
|
|
3023
|
+
to: [...previousChildListPath, index]
|
|
3024
|
+
});
|
|
3025
|
+
}
|
|
3026
|
+
});
|
|
3027
|
+
}
|
|
3028
|
+
function indent(editor) {
|
|
3029
|
+
if (!editor.selection)
|
|
3030
|
+
return;
|
|
3031
|
+
const listItems = getSelectedListItems(editor);
|
|
3032
|
+
const subRoots = filterForSubtreeRoots(listItems);
|
|
3033
|
+
const refs = subRoots.map(([_, path]) => slate.Editor.pathRef(editor, path));
|
|
3034
|
+
refs.forEach((ref) => {
|
|
3035
|
+
if (ref.current) {
|
|
3036
|
+
indentPath(editor, ref.current);
|
|
3037
|
+
}
|
|
3038
|
+
ref.unref();
|
|
3039
|
+
});
|
|
3040
|
+
}
|
|
3041
|
+
function dedentPath(editor, listItemPath) {
|
|
3042
|
+
const parentList = EditorUtils.getFirstAncestorList(editor, listItemPath);
|
|
3043
|
+
const listItemContainingParentList = EditorUtils.getFirstAncestorListItem(editor, listItemPath);
|
|
3044
|
+
if (!parentList || !listItemContainingParentList)
|
|
3045
|
+
return;
|
|
3046
|
+
const [parentListNode, parentListPath] = parentList;
|
|
3047
|
+
const [_, listItemContainingParentListPath] = listItemContainingParentList;
|
|
3048
|
+
const listItemPosition = listItemPath[listItemPath.length - 1];
|
|
3049
|
+
const previousSiblings = parentListNode.children.slice(0, listItemPosition);
|
|
3050
|
+
const nextSiblings = parentListNode.children.slice(listItemPosition + 1);
|
|
3051
|
+
slate.Editor.withoutNormalizing(editor, () => {
|
|
3052
|
+
nextSiblings.forEach(() => {
|
|
3053
|
+
const nextSiblingPath = [...parentListPath, listItemPosition + 1];
|
|
3054
|
+
indentPath(editor, nextSiblingPath);
|
|
3055
|
+
});
|
|
3056
|
+
slate.Transforms.moveNodes(editor, {
|
|
3057
|
+
at: listItemPath,
|
|
3058
|
+
to: slate.Path.next(listItemContainingParentListPath)
|
|
3059
|
+
});
|
|
3060
|
+
if (previousSiblings.length === 0) {
|
|
3061
|
+
slate.Transforms.removeNodes(editor, { at: parentListPath });
|
|
3062
|
+
}
|
|
3063
|
+
});
|
|
3064
|
+
}
|
|
3065
|
+
function dedent(editor) {
|
|
3066
|
+
if (!editor.selection)
|
|
3067
|
+
return;
|
|
3068
|
+
const listItems = getSelectedListItems(editor);
|
|
3069
|
+
const subRoots = filterForSubtreeRoots(listItems);
|
|
3070
|
+
const refs = subRoots.map(([_, path]) => slate.Editor.pathRef(editor, path));
|
|
3071
|
+
refs.forEach((ref) => {
|
|
3072
|
+
if (ref.current) {
|
|
3073
|
+
dedentPath(editor, ref.current);
|
|
3074
|
+
}
|
|
3075
|
+
ref.unref();
|
|
3076
|
+
});
|
|
3077
|
+
}
|
|
3078
|
+
function toggleList(editor, options = { type: BlockType.UnorderedList }) {
|
|
3079
|
+
var _a2;
|
|
3080
|
+
const at = (_a2 = options.at) != null ? _a2 : editor.selection;
|
|
3081
|
+
if (at == null)
|
|
3082
|
+
return;
|
|
3083
|
+
const start = LocationUtils.getStartPath(at);
|
|
3084
|
+
const ancestorPath = slate.Path.ancestors(start).at(1);
|
|
3085
|
+
if (!ancestorPath || !slate.Node.has(editor, ancestorPath))
|
|
3086
|
+
return;
|
|
3087
|
+
const ancestor = slate.Node.get(editor, ancestorPath);
|
|
3088
|
+
if (!ElementUtils.isList(ancestor)) {
|
|
3089
|
+
return wrapList(editor, { type: options.type, at });
|
|
3090
|
+
}
|
|
3091
|
+
if (ancestor.type === options.type) {
|
|
3092
|
+
unwrapList(editor, { at });
|
|
3093
|
+
} else {
|
|
3094
|
+
slate.Transforms.setNodes(editor, { type: options.type }, { at: ancestorPath });
|
|
3095
|
+
}
|
|
3096
|
+
}
|
|
3097
|
+
const BlockActions = {
|
|
3098
|
+
setBlockKeyForDevice,
|
|
3099
|
+
clearBlockKeyForDevice,
|
|
3100
|
+
wrapInline,
|
|
3101
|
+
unwrapInline
|
|
3102
|
+
};
|
|
3103
|
+
const ListActions = {
|
|
3104
|
+
unwrapList,
|
|
3105
|
+
wrapList,
|
|
3106
|
+
indent,
|
|
3107
|
+
dedent,
|
|
3108
|
+
toggleList
|
|
3109
|
+
};
|
|
3110
|
+
function onKeyDown(e, editor) {
|
|
3111
|
+
if (!editor.selection || Array.from(slate.Editor.nodes(editor, {
|
|
3112
|
+
match: (node) => ElementUtils.isListItem(node)
|
|
3113
|
+
})).length === 0)
|
|
3114
|
+
return;
|
|
3115
|
+
if (isHotkey__default["default"]("shift+tab", e)) {
|
|
3116
|
+
e.preventDefault();
|
|
3117
|
+
ListActions.dedent(editor);
|
|
3118
|
+
}
|
|
3119
|
+
if (isHotkey__default["default"]("tab", e)) {
|
|
3120
|
+
e.preventDefault();
|
|
3121
|
+
ListActions.indent(editor);
|
|
3122
|
+
}
|
|
3123
|
+
if (isHotkey__default["default"]("backspace", e)) {
|
|
3124
|
+
if (!editor.selection)
|
|
3125
|
+
return;
|
|
3126
|
+
if (slate.Range.isExpanded(editor.selection))
|
|
3127
|
+
return;
|
|
3128
|
+
const listItem = EditorUtils.getFirstAncestorListItem(editor, editor.selection.anchor.path);
|
|
3129
|
+
if (editor.selection.anchor.offset === 0 && listItem) {
|
|
3130
|
+
e.preventDefault();
|
|
3131
|
+
const parentListItem = EditorUtils.getFirstAncestorListItem(editor, listItem[1]);
|
|
3132
|
+
const list = EditorUtils.getFirstAncestorList(editor, listItem[1]);
|
|
3133
|
+
if (parentListItem) {
|
|
3134
|
+
ListActions.dedent(editor);
|
|
3135
|
+
} else if (list) {
|
|
3136
|
+
ListActions.unwrapList(editor);
|
|
3137
|
+
}
|
|
3138
|
+
return;
|
|
3139
|
+
}
|
|
3140
|
+
}
|
|
3141
|
+
if (isHotkey__default["default"]("enter", e)) {
|
|
3142
|
+
e.preventDefault();
|
|
3143
|
+
if (!editor.selection)
|
|
3144
|
+
return;
|
|
3145
|
+
if (slate.Range.isExpanded(editor.selection)) {
|
|
3146
|
+
slate.Transforms.delete(editor);
|
|
3147
|
+
return;
|
|
3148
|
+
}
|
|
3149
|
+
const listItem = EditorUtils.getFirstAncestorListItem(editor, editor.selection.anchor.path);
|
|
3150
|
+
if (editor.selection.anchor.offset === 0 && listItem && slate.Editor.string(editor, listItem[1]) === "") {
|
|
3151
|
+
const parentListItem = EditorUtils.getFirstAncestorListItem(editor, listItem[1]);
|
|
3152
|
+
if (parentListItem) {
|
|
3153
|
+
ListActions.dedent(editor);
|
|
3154
|
+
} else {
|
|
3155
|
+
ListActions.unwrapList(editor);
|
|
3156
|
+
}
|
|
3157
|
+
return;
|
|
3158
|
+
}
|
|
3159
|
+
slate.Transforms.splitNodes(editor, {
|
|
3160
|
+
at: editor.selection,
|
|
3161
|
+
always: true,
|
|
3162
|
+
match: (node) => ElementUtils.isListItem(node)
|
|
3163
|
+
});
|
|
3164
|
+
}
|
|
3165
|
+
if (isHotkey__default["default"]("shift+enter", e)) {
|
|
3166
|
+
e.preventDefault();
|
|
3167
|
+
editor.insertText("\n");
|
|
3168
|
+
}
|
|
3169
|
+
}
|
|
3170
|
+
function withBlock(editor) {
|
|
3171
|
+
const {
|
|
3172
|
+
normalizeNode
|
|
3173
|
+
} = editor;
|
|
3174
|
+
editor.isInline = (entry) => {
|
|
3175
|
+
return ElementUtils.isInline(entry);
|
|
3176
|
+
};
|
|
3177
|
+
editor.normalizeNode = (entry) => {
|
|
3178
|
+
var _a2;
|
|
3179
|
+
const [normalizationNode, normalizationPath] = entry;
|
|
3180
|
+
if (ElementUtils.isBlock(normalizationNode) && ((_a2 = normalizationNode == null ? void 0 : normalizationNode.textAlign) == null ? void 0 : _a2.length) == 0) {
|
|
3181
|
+
slate.Transforms.unsetNodes(editor, "textAlign", {
|
|
3182
|
+
at: normalizationPath
|
|
3183
|
+
});
|
|
3184
|
+
return;
|
|
3185
|
+
}
|
|
3186
|
+
if (ElementUtils.isListItem(normalizationNode)) {
|
|
3187
|
+
const pathToListItemText = [...normalizationPath, LIST_ITEM_CHILD_POSITION];
|
|
3188
|
+
if (slate.Node.has(editor, pathToListItemText)) {
|
|
3189
|
+
const nodeInListItemTextPosition = slate.Node.get(editor, pathToListItemText);
|
|
3190
|
+
if (ElementUtils.isRootBlock(nodeInListItemTextPosition)) {
|
|
3191
|
+
slate.Transforms.setNodes(editor, {
|
|
3192
|
+
type: BlockType.ListItemChild
|
|
3193
|
+
}, {
|
|
3194
|
+
at: pathToListItemText
|
|
3195
|
+
});
|
|
3196
|
+
return;
|
|
3197
|
+
}
|
|
3198
|
+
} else {
|
|
3199
|
+
slate.Transforms.insertNodes(editor, ElementUtils.createListItem(), {
|
|
3200
|
+
at: pathToListItemText
|
|
3201
|
+
});
|
|
3202
|
+
return;
|
|
3203
|
+
}
|
|
3204
|
+
}
|
|
3205
|
+
if (!slate.Text.isText(normalizationNode)) {
|
|
3206
|
+
const mergeableChildren = Array.from(slate.Node.children(editor, normalizationPath)).map((child, index, children) => {
|
|
3207
|
+
const potentialNodeToBeMerged = children.at(index + 1);
|
|
3208
|
+
if (!potentialNodeToBeMerged || !ElementUtils.isList(potentialNodeToBeMerged[0]) || !ElementUtils.isList(child[0]) || potentialNodeToBeMerged[0].type !== child[0].type) {
|
|
3209
|
+
return null;
|
|
3210
|
+
}
|
|
3211
|
+
return [slate.Editor.pathRef(editor, child[1]), slate.Editor.pathRef(editor, potentialNodeToBeMerged[1])];
|
|
3212
|
+
}).filter((mergeableNodes) => Boolean(mergeableNodes));
|
|
3213
|
+
if (mergeableChildren.length !== 0) {
|
|
3214
|
+
mergeableChildren.reverse().forEach(([nodePathRef, nodeToBeMergedPathRef]) => {
|
|
3215
|
+
const nodePath = nodePathRef.current;
|
|
3216
|
+
const nodeToBeMergedPath = nodeToBeMergedPathRef.current;
|
|
3217
|
+
if (nodePath == null || nodeToBeMergedPath == null)
|
|
3218
|
+
return;
|
|
3219
|
+
const nodeChildren = Array.from(slate.Node.children(editor, nodePath));
|
|
3220
|
+
const childrenToBeMerged = Array.from(slate.Node.children(editor, nodeToBeMergedPath));
|
|
3221
|
+
slate.Editor.withoutNormalizing(editor, () => {
|
|
3222
|
+
childrenToBeMerged.reverse().forEach(([_, childPath]) => {
|
|
3223
|
+
slate.Transforms.moveNodes(editor, {
|
|
3224
|
+
at: childPath,
|
|
3225
|
+
to: [...nodePath, nodeChildren.length]
|
|
3226
|
+
});
|
|
3227
|
+
});
|
|
3228
|
+
slate.Transforms.removeNodes(editor, {
|
|
3229
|
+
at: nodeToBeMergedPath
|
|
3230
|
+
});
|
|
3231
|
+
});
|
|
3232
|
+
nodePathRef.unref();
|
|
3233
|
+
nodeToBeMergedPathRef.unref();
|
|
3234
|
+
});
|
|
3235
|
+
return;
|
|
3236
|
+
}
|
|
3237
|
+
}
|
|
3238
|
+
normalizeNode(entry);
|
|
3239
|
+
};
|
|
3240
|
+
return editor;
|
|
3241
|
+
}
|
|
3242
|
+
const definition = Select({
|
|
3243
|
+
label: "Block",
|
|
3244
|
+
labelOrientation: "horizontal",
|
|
3245
|
+
options: [{
|
|
3246
|
+
value: BlockType.Paragraph,
|
|
3247
|
+
label: "Paragraph"
|
|
3248
|
+
}, {
|
|
3249
|
+
value: BlockType.Heading1,
|
|
3250
|
+
label: "Heading 1"
|
|
3251
|
+
}, {
|
|
3252
|
+
value: BlockType.Heading2,
|
|
3253
|
+
label: "Heading 2"
|
|
3254
|
+
}, {
|
|
3255
|
+
value: BlockType.Heading3,
|
|
3256
|
+
label: "Heading 3"
|
|
3257
|
+
}, {
|
|
3258
|
+
value: BlockType.Heading4,
|
|
3259
|
+
label: "Heading 4"
|
|
3260
|
+
}, {
|
|
3261
|
+
value: BlockType.Heading5,
|
|
3262
|
+
label: "Heading 5"
|
|
3263
|
+
}, {
|
|
3264
|
+
value: BlockType.Heading6,
|
|
3265
|
+
label: "Heading 6"
|
|
3266
|
+
}, {
|
|
3267
|
+
value: BlockType.UnorderedList,
|
|
3268
|
+
label: "Bulleted list"
|
|
3269
|
+
}, {
|
|
3270
|
+
value: BlockType.OrderedList,
|
|
3271
|
+
label: "Numbered list"
|
|
3272
|
+
}, {
|
|
3273
|
+
value: BlockType.BlockQuote,
|
|
3274
|
+
label: "Quote"
|
|
3275
|
+
}],
|
|
3276
|
+
defaultValue: BlockType.Paragraph
|
|
3277
|
+
});
|
|
3278
|
+
function BlockPlugin() {
|
|
3279
|
+
return createRichTextV2Plugin({
|
|
3280
|
+
withPlugin: withBlock,
|
|
3281
|
+
onKeyDown,
|
|
3282
|
+
control: {
|
|
3283
|
+
definition,
|
|
3284
|
+
onChange: (editor, value) => {
|
|
3285
|
+
const activeBlockType = getActiveBlockType(editor);
|
|
3286
|
+
if (value === BlockType.UnorderedList || value === BlockType.OrderedList) {
|
|
3287
|
+
ListActions.toggleList(editor, {
|
|
3288
|
+
type: value,
|
|
3289
|
+
at: getSelection(editor)
|
|
3290
|
+
});
|
|
3291
|
+
} else if (activeBlockType === value) {
|
|
3292
|
+
slate.Transforms.setNodes(editor, {
|
|
3293
|
+
type: BlockType.Default
|
|
3294
|
+
}, {
|
|
3295
|
+
at: getSelection(editor)
|
|
3296
|
+
});
|
|
3297
|
+
} else {
|
|
3298
|
+
ListActions.unwrapList(editor, {
|
|
3299
|
+
at: getSelection(editor)
|
|
3300
|
+
});
|
|
3301
|
+
slate.Transforms.setNodes(editor, {
|
|
3302
|
+
type: value != null ? value : BlockType.Default
|
|
3303
|
+
}, {
|
|
3304
|
+
at: getSelection(editor)
|
|
3305
|
+
});
|
|
3306
|
+
}
|
|
3307
|
+
},
|
|
3308
|
+
getValue: (editor) => {
|
|
3309
|
+
const activeBlock = getActiveBlockType(editor);
|
|
3310
|
+
if (activeBlock === RootBlockType.Default)
|
|
3311
|
+
return void 0;
|
|
3312
|
+
return activeBlock;
|
|
3313
|
+
}
|
|
3314
|
+
},
|
|
3315
|
+
renderElement: (renderElement) => (props) => /* @__PURE__ */ jsxRuntime.jsx(BlockPluginComponent, __spreadProps(__spreadValues({}, props), {
|
|
3316
|
+
renderElement
|
|
3317
|
+
}))
|
|
3318
|
+
});
|
|
3319
|
+
}
|
|
3320
|
+
function BlockPluginComponent(_d) {
|
|
3321
|
+
var _e = _d, {
|
|
3322
|
+
renderElement
|
|
3323
|
+
} = _e, props = __objRest(_e, [
|
|
3324
|
+
"renderElement"
|
|
3325
|
+
]);
|
|
3326
|
+
const blockStyles = [useStyle({
|
|
3327
|
+
margin: 0
|
|
3328
|
+
}), props.element.className];
|
|
3329
|
+
const quoteStyles = useStyle({
|
|
3330
|
+
padding: "0.5em 10px",
|
|
3331
|
+
fontSize: "1.25em",
|
|
3332
|
+
fontWeight: "300",
|
|
3333
|
+
borderLeft: "5px solid rgba(0, 0, 0, 0.1)"
|
|
3334
|
+
});
|
|
3335
|
+
const unorderedListStyles = useStyle({
|
|
3336
|
+
listStylePosition: "inside",
|
|
3337
|
+
paddingInlineStart: "20px",
|
|
3338
|
+
listStyleType: "disc",
|
|
3339
|
+
ul: {
|
|
3340
|
+
listStyleType: "circle"
|
|
3341
|
+
},
|
|
3342
|
+
"ul ul": {
|
|
3343
|
+
listStyleType: "square"
|
|
3344
|
+
}
|
|
3345
|
+
});
|
|
3346
|
+
const orderedListStyles = useStyle({
|
|
3347
|
+
listStylePosition: "inside",
|
|
3348
|
+
paddingInlineStart: "20px",
|
|
3349
|
+
listStyleType: "decimal"
|
|
3350
|
+
});
|
|
3351
|
+
switch (props.element.type) {
|
|
3352
|
+
case BlockType.Default:
|
|
3353
|
+
case BlockType.Paragraph:
|
|
3354
|
+
return /* @__PURE__ */ jsxRuntime.jsx("p", __spreadProps(__spreadValues({}, props.attributes), {
|
|
3355
|
+
className: css.cx(...blockStyles),
|
|
3356
|
+
children: renderElement(props)
|
|
3357
|
+
}));
|
|
3358
|
+
case BlockType.Heading1:
|
|
3359
|
+
return /* @__PURE__ */ jsxRuntime.jsx("h1", __spreadProps(__spreadValues({}, props.attributes), {
|
|
3360
|
+
className: css.cx(...blockStyles),
|
|
3361
|
+
children: renderElement(props)
|
|
3362
|
+
}));
|
|
3363
|
+
case BlockType.Heading2:
|
|
3364
|
+
return /* @__PURE__ */ jsxRuntime.jsx("h2", __spreadProps(__spreadValues({}, props.attributes), {
|
|
3365
|
+
className: css.cx(...blockStyles),
|
|
3366
|
+
children: renderElement(props)
|
|
3367
|
+
}));
|
|
3368
|
+
case BlockType.Heading3:
|
|
3369
|
+
return /* @__PURE__ */ jsxRuntime.jsx("h3", __spreadProps(__spreadValues({}, props.attributes), {
|
|
3370
|
+
className: css.cx(...blockStyles),
|
|
3371
|
+
children: renderElement(props)
|
|
3372
|
+
}));
|
|
3373
|
+
case BlockType.Heading4:
|
|
3374
|
+
return /* @__PURE__ */ jsxRuntime.jsx("h4", __spreadProps(__spreadValues({}, props.attributes), {
|
|
3375
|
+
className: css.cx(...blockStyles),
|
|
3376
|
+
children: renderElement(props)
|
|
3377
|
+
}));
|
|
3378
|
+
case BlockType.Heading5:
|
|
3379
|
+
return /* @__PURE__ */ jsxRuntime.jsx("h5", __spreadProps(__spreadValues({}, props.attributes), {
|
|
3380
|
+
className: css.cx(...blockStyles),
|
|
3381
|
+
children: renderElement(props)
|
|
3382
|
+
}));
|
|
3383
|
+
case BlockType.Heading6:
|
|
3384
|
+
return /* @__PURE__ */ jsxRuntime.jsx("h6", __spreadProps(__spreadValues({}, props.attributes), {
|
|
3385
|
+
className: css.cx(...blockStyles),
|
|
3386
|
+
children: renderElement(props)
|
|
3387
|
+
}));
|
|
3388
|
+
case BlockType.BlockQuote:
|
|
3389
|
+
return /* @__PURE__ */ jsxRuntime.jsx("blockquote", __spreadProps(__spreadValues({}, props.attributes), {
|
|
3390
|
+
className: css.cx(...blockStyles, quoteStyles),
|
|
3391
|
+
children: renderElement(props)
|
|
3392
|
+
}));
|
|
3393
|
+
case BlockType.OrderedList:
|
|
3394
|
+
return /* @__PURE__ */ jsxRuntime.jsx("ol", __spreadProps(__spreadValues({}, props.attributes), {
|
|
3395
|
+
className: css.cx(...blockStyles, orderedListStyles),
|
|
3396
|
+
children: renderElement(props)
|
|
3397
|
+
}));
|
|
3398
|
+
case BlockType.UnorderedList:
|
|
3399
|
+
return /* @__PURE__ */ jsxRuntime.jsx("ul", __spreadProps(__spreadValues({}, props.attributes), {
|
|
3400
|
+
className: css.cx(...blockStyles, unorderedListStyles),
|
|
3401
|
+
children: renderElement(props)
|
|
3402
|
+
}));
|
|
3403
|
+
case BlockType.ListItem:
|
|
3404
|
+
return /* @__PURE__ */ jsxRuntime.jsx("li", __spreadProps(__spreadValues({}, props.attributes), {
|
|
3405
|
+
className: css.cx(...blockStyles),
|
|
3406
|
+
children: renderElement(props)
|
|
3407
|
+
}));
|
|
3408
|
+
case BlockType.ListItemChild:
|
|
3409
|
+
return /* @__PURE__ */ jsxRuntime.jsx("span", __spreadProps(__spreadValues({}, props.attributes), {
|
|
3410
|
+
className: css.cx(...blockStyles),
|
|
3411
|
+
children: renderElement(props)
|
|
3412
|
+
}));
|
|
3413
|
+
default:
|
|
3414
|
+
return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, {
|
|
3415
|
+
children: renderElement(props)
|
|
3416
|
+
});
|
|
3417
|
+
}
|
|
3418
|
+
}
|
|
3419
|
+
function clearActiveTypographyStyle(editor, options) {
|
|
3420
|
+
slate.Editor.withoutNormalizing(editor, () => {
|
|
3421
|
+
var _a2;
|
|
3422
|
+
const at = (_a2 = options == null ? void 0 : options.at) != null ? _a2 : editor.selection;
|
|
3423
|
+
if (!at)
|
|
3424
|
+
return;
|
|
3425
|
+
const atRef = slate.Editor.rangeRef(editor, at);
|
|
3426
|
+
if (atRef.current) {
|
|
3427
|
+
slate.Transforms.setNodes(editor, {
|
|
3428
|
+
slice: true
|
|
3429
|
+
}, {
|
|
3430
|
+
at: atRef.current,
|
|
3431
|
+
match: (node) => slate.Text.isText(node),
|
|
3432
|
+
split: slate.Range.isExpanded(atRef.current)
|
|
3433
|
+
});
|
|
3434
|
+
}
|
|
3435
|
+
if (atRef.current) {
|
|
3436
|
+
const textNodes = Array.from(slate.Editor.nodes(editor, {
|
|
3437
|
+
at: atRef.current,
|
|
3438
|
+
match: (node) => slate.Text.isText(node) && node.slice === true
|
|
3439
|
+
}));
|
|
3440
|
+
for (const [node, path] of textNodes) {
|
|
3441
|
+
if (slate.Text.isText(node)) {
|
|
3442
|
+
const typography = __spreadProps(__spreadValues({}, node.typography), {
|
|
3443
|
+
style: []
|
|
3444
|
+
});
|
|
3445
|
+
slate.Transforms.setNodes(editor, {
|
|
3446
|
+
typography
|
|
3447
|
+
}, { at: path });
|
|
3448
|
+
}
|
|
3449
|
+
}
|
|
3450
|
+
}
|
|
3451
|
+
atRef.unref();
|
|
3452
|
+
});
|
|
3453
|
+
}
|
|
3454
|
+
function clearDeviceActiveTypography(editor, currentDeviceId, options) {
|
|
3455
|
+
slate.Editor.withoutNormalizing(editor, () => {
|
|
3456
|
+
var _a2, _b, _c;
|
|
3457
|
+
const at = (_a2 = options == null ? void 0 : options.at) != null ? _a2 : editor.selection;
|
|
3458
|
+
if (!at)
|
|
3459
|
+
return;
|
|
3460
|
+
const atRef = slate.Editor.rangeRef(editor, at);
|
|
3461
|
+
if (atRef.current) {
|
|
3462
|
+
slate.Transforms.setNodes(editor, {
|
|
3463
|
+
slice: true
|
|
3464
|
+
}, {
|
|
3465
|
+
at: atRef.current,
|
|
3466
|
+
match: (node) => slate.Text.isText(node),
|
|
3467
|
+
split: slate.Range.isExpanded(atRef.current)
|
|
3468
|
+
});
|
|
3469
|
+
}
|
|
3470
|
+
if (atRef.current) {
|
|
3471
|
+
const textNodes = Array.from(slate.Editor.nodes(editor, {
|
|
3472
|
+
at: atRef.current,
|
|
3473
|
+
match: (node) => slate.Text.isText(node) && node.slice === true
|
|
3474
|
+
}));
|
|
3475
|
+
for (const [node, path] of textNodes) {
|
|
3476
|
+
if (slate.Text.isText(node)) {
|
|
3477
|
+
const typography = __spreadProps(__spreadValues({}, node.typography), {
|
|
3478
|
+
style: (_c = (_b = node == null ? void 0 : node.typography) == null ? void 0 : _b.style.filter(({ deviceId }) => deviceId !== currentDeviceId)) != null ? _c : []
|
|
3479
|
+
});
|
|
3480
|
+
slate.Transforms.setNodes(editor, {
|
|
3481
|
+
typography
|
|
3482
|
+
}, { at: path });
|
|
3483
|
+
}
|
|
3484
|
+
}
|
|
3485
|
+
}
|
|
3486
|
+
atRef.unref();
|
|
3487
|
+
});
|
|
3488
|
+
}
|
|
3489
|
+
function detachActiveTypography(editor, value, options) {
|
|
3490
|
+
slate.Editor.withoutNormalizing(editor, () => {
|
|
3491
|
+
var _a2;
|
|
3492
|
+
const at = (_a2 = options == null ? void 0 : options.at) != null ? _a2 : editor.selection;
|
|
3493
|
+
if (!at)
|
|
3494
|
+
return;
|
|
3495
|
+
const atRef = slate.Editor.rangeRef(editor, at);
|
|
3496
|
+
if (atRef.current) {
|
|
3497
|
+
slate.Transforms.setNodes(editor, {
|
|
3498
|
+
slice: true
|
|
3499
|
+
}, {
|
|
3500
|
+
at: atRef.current,
|
|
3501
|
+
match: (node) => slate.Text.isText(node),
|
|
3502
|
+
split: slate.Range.isExpanded(atRef.current)
|
|
3503
|
+
});
|
|
3504
|
+
}
|
|
3505
|
+
if (atRef.current) {
|
|
3506
|
+
const textNodes = Array.from(slate.Editor.nodes(editor, {
|
|
3507
|
+
at: atRef.current,
|
|
3508
|
+
match: (node) => slate.Text.isText(node) && node.slice === true
|
|
3509
|
+
}));
|
|
3510
|
+
for (const [node, path] of textNodes) {
|
|
3511
|
+
if (slate.Text.isText(node)) {
|
|
3512
|
+
slate.Transforms.setNodes(editor, {
|
|
3513
|
+
typography: {
|
|
3514
|
+
style: value
|
|
3515
|
+
}
|
|
3516
|
+
}, { at: path });
|
|
3517
|
+
}
|
|
3518
|
+
}
|
|
3519
|
+
}
|
|
3520
|
+
atRef.unref();
|
|
3521
|
+
});
|
|
2296
3522
|
}
|
|
2297
|
-
function
|
|
2298
|
-
|
|
3523
|
+
function setActiveTypographyId(editor, id, options) {
|
|
3524
|
+
var _a2;
|
|
3525
|
+
const at = (_a2 = options == null ? void 0 : options.at) != null ? _a2 : editor.selection;
|
|
3526
|
+
if (!at)
|
|
3527
|
+
return;
|
|
3528
|
+
slate.Transforms.setNodes(editor, {
|
|
3529
|
+
typography: {
|
|
3530
|
+
id,
|
|
3531
|
+
style: []
|
|
3532
|
+
}
|
|
3533
|
+
}, {
|
|
3534
|
+
at,
|
|
3535
|
+
match: (node) => slate.Text.isText(node),
|
|
3536
|
+
split: slate.Range.isExpanded(at)
|
|
3537
|
+
});
|
|
2299
3538
|
}
|
|
3539
|
+
function setActiveTypographyStyle(editor, breakpoints, deviceId, prop, value, options) {
|
|
3540
|
+
slate.Editor.withoutNormalizing(editor, () => {
|
|
3541
|
+
var _a2, _b, _c;
|
|
3542
|
+
const at = (_a2 = options == null ? void 0 : options.at) != null ? _a2 : editor.selection;
|
|
3543
|
+
if (!at)
|
|
3544
|
+
return;
|
|
3545
|
+
const atRef = slate.Editor.rangeRef(editor, at);
|
|
3546
|
+
if (atRef.current) {
|
|
3547
|
+
slate.Transforms.setNodes(editor, {
|
|
3548
|
+
slice: true
|
|
3549
|
+
}, {
|
|
3550
|
+
at: atRef.current,
|
|
3551
|
+
match: (node) => slate.Text.isText(node),
|
|
3552
|
+
split: slate.Range.isExpanded(atRef.current)
|
|
3553
|
+
});
|
|
3554
|
+
}
|
|
3555
|
+
if (atRef.current) {
|
|
3556
|
+
const textNodes = Array.from(slate.Editor.nodes(editor, {
|
|
3557
|
+
at: atRef.current,
|
|
3558
|
+
match: (node) => slate.Text.isText(node) && node.slice === true
|
|
3559
|
+
}));
|
|
3560
|
+
for (const [node, path] of textNodes) {
|
|
3561
|
+
if (slate.Text.isText(node)) {
|
|
3562
|
+
const deviceOverrides = (_c = (_b = node == null ? void 0 : node.typography) == null ? void 0 : _b.style) != null ? _c : [];
|
|
3563
|
+
const deviceStyle = state_breakpoints.findBreakpointOverride(breakpoints, deviceOverrides, deviceId, (v) => v) || {
|
|
3564
|
+
value: {}
|
|
3565
|
+
};
|
|
3566
|
+
const nextDeviceStyle = {
|
|
3567
|
+
deviceId,
|
|
3568
|
+
value: __spreadProps(__spreadValues({}, deviceStyle.value), { [prop]: value })
|
|
3569
|
+
};
|
|
3570
|
+
const nextTypography = __spreadProps(__spreadValues({}, node.typography), {
|
|
3571
|
+
style: [...deviceOverrides.filter((v) => v.deviceId !== deviceId), nextDeviceStyle]
|
|
3572
|
+
});
|
|
3573
|
+
slate.Transforms.setNodes(editor, {
|
|
3574
|
+
typography: nextTypography
|
|
3575
|
+
}, { at: path });
|
|
3576
|
+
}
|
|
3577
|
+
}
|
|
3578
|
+
}
|
|
3579
|
+
atRef.unref();
|
|
3580
|
+
});
|
|
3581
|
+
}
|
|
3582
|
+
function getValue(editor) {
|
|
3583
|
+
const matchingValues = Array.from(slate.Editor.nodes(editor, {
|
|
3584
|
+
at: getSelection(editor),
|
|
3585
|
+
match: slate.Text.isText
|
|
3586
|
+
})).map(([node]) => node["typography"]);
|
|
3587
|
+
return matchingValues;
|
|
3588
|
+
}
|
|
3589
|
+
const TypographyActions = {
|
|
3590
|
+
setActiveTypographyId,
|
|
3591
|
+
setActiveTypographyStyle,
|
|
3592
|
+
clearActiveTypographyStyle,
|
|
3593
|
+
clearDeviceActiveTypography,
|
|
3594
|
+
detachActiveTypography
|
|
3595
|
+
};
|
|
3596
|
+
const TYPOGRAPHY_KEY = "typography";
|
|
3597
|
+
function withTypography(editor) {
|
|
3598
|
+
const { normalizeNode } = editor;
|
|
3599
|
+
editor.normalizeNode = (entry) => {
|
|
3600
|
+
var _a2, _b;
|
|
3601
|
+
const [normalizationNode, normalizationPath] = entry;
|
|
3602
|
+
if (slate.Text.isText(normalizationNode) && ((_a2 = normalizationNode == null ? void 0 : normalizationNode.typography) == null ? void 0 : _a2.id) == null && ((_b = normalizationNode == null ? void 0 : normalizationNode.typography) == null ? void 0 : _b.style.length) === 0) {
|
|
3603
|
+
slate.Transforms.unsetNodes(editor, TYPOGRAPHY_KEY, { at: normalizationPath });
|
|
3604
|
+
return;
|
|
3605
|
+
}
|
|
3606
|
+
if (slate.Text.isText(normalizationNode) && (normalizationNode == null ? void 0 : normalizationNode.slice) != null) {
|
|
3607
|
+
slate.Transforms.unsetNodes(editor, "slice", { at: normalizationPath });
|
|
3608
|
+
return;
|
|
3609
|
+
}
|
|
3610
|
+
normalizeNode(entry);
|
|
3611
|
+
};
|
|
3612
|
+
return editor;
|
|
3613
|
+
}
|
|
3614
|
+
function TypographyPlugin() {
|
|
3615
|
+
return createRichTextV2Plugin({
|
|
3616
|
+
withPlugin: withTypography,
|
|
3617
|
+
control: {
|
|
3618
|
+
definition: unstable_Typography(),
|
|
3619
|
+
onChange: (editor, value) => {
|
|
3620
|
+
slate.Editor.withoutNormalizing(editor, () => {
|
|
3621
|
+
const at = getSelection(editor);
|
|
3622
|
+
if (!at)
|
|
3623
|
+
return;
|
|
3624
|
+
const atRef = slate.Editor.rangeRef(editor, at);
|
|
3625
|
+
if (atRef.current) {
|
|
3626
|
+
slate.Transforms.setNodes(editor, {
|
|
3627
|
+
slice: true
|
|
3628
|
+
}, {
|
|
3629
|
+
at: atRef.current,
|
|
3630
|
+
match: slate.Text.isText,
|
|
3631
|
+
split: true
|
|
3632
|
+
});
|
|
3633
|
+
}
|
|
3634
|
+
if (atRef.current) {
|
|
3635
|
+
const nodesToUpdate = Array.from(slate.Editor.nodes(editor, {
|
|
3636
|
+
at: atRef.current,
|
|
3637
|
+
match: (node) => slate.Text.isText(node) && node.slice === true
|
|
3638
|
+
}));
|
|
3639
|
+
if (nodesToUpdate.length !== (value == null ? void 0 : value.length))
|
|
3640
|
+
return console.error(`TypographyControl.onChange received the wrong number of arguments.
|
|
3641
|
+
Called with ${value == null ? void 0 : value.length} values mapping to ${nodesToUpdate.length} nodes.`);
|
|
3642
|
+
for (const [index, [, path]] of nodesToUpdate.entries()) {
|
|
3643
|
+
slate.Transforms.setNodes(editor, {
|
|
3644
|
+
typography: value == null ? void 0 : value.at(index)
|
|
3645
|
+
}, { at: path, match: slate.Text.isText });
|
|
3646
|
+
}
|
|
3647
|
+
}
|
|
3648
|
+
atRef.unref();
|
|
3649
|
+
});
|
|
3650
|
+
},
|
|
3651
|
+
getValue: (editor) => getValue(editor),
|
|
3652
|
+
getLeafValue: (text) => {
|
|
3653
|
+
return slate.Text.isText(text) ? text.typography : void 0;
|
|
3654
|
+
}
|
|
3655
|
+
},
|
|
3656
|
+
renderLeaf: (renderLeaf, className) => (props) => {
|
|
3657
|
+
return renderLeaf(__spreadProps(__spreadValues({}, props), {
|
|
3658
|
+
leaf: __spreadProps(__spreadValues({}, props.leaf), {
|
|
3659
|
+
className: `${props.leaf.className} ${className}`
|
|
3660
|
+
})
|
|
3661
|
+
}));
|
|
3662
|
+
}
|
|
3663
|
+
});
|
|
3664
|
+
}
|
|
3665
|
+
const BLOCK_ONE_PATH = [0];
|
|
3666
|
+
const BLOCK_TWO_PATH = [1];
|
|
3667
|
+
function withInlineMode(editor) {
|
|
3668
|
+
const {
|
|
3669
|
+
normalizeNode
|
|
3670
|
+
} = editor;
|
|
3671
|
+
editor.normalizeNode = (entry) => {
|
|
3672
|
+
const [normalizationNode, normalizationPath] = entry;
|
|
3673
|
+
if (slate.Path.equals(BLOCK_TWO_PATH, normalizationPath)) {
|
|
3674
|
+
slate.Transforms.mergeNodes(editor, {
|
|
3675
|
+
at: BLOCK_TWO_PATH
|
|
3676
|
+
});
|
|
3677
|
+
return;
|
|
3678
|
+
}
|
|
3679
|
+
if (slate.Path.isAncestor(BLOCK_ONE_PATH, normalizationPath) && ElementUtils.isBlock(normalizationNode)) {
|
|
3680
|
+
slate.Transforms.unwrapNodes(editor, {
|
|
3681
|
+
at: normalizationPath
|
|
3682
|
+
});
|
|
3683
|
+
return;
|
|
3684
|
+
}
|
|
3685
|
+
if (slate.Path.equals(BLOCK_ONE_PATH, normalizationPath)) {
|
|
3686
|
+
slate.Transforms.setNodes(editor, {
|
|
3687
|
+
type: BlockType.Default
|
|
3688
|
+
}, {
|
|
3689
|
+
at: normalizationPath
|
|
3690
|
+
});
|
|
3691
|
+
return;
|
|
3692
|
+
}
|
|
3693
|
+
normalizeNode(entry);
|
|
3694
|
+
};
|
|
3695
|
+
return editor;
|
|
3696
|
+
}
|
|
3697
|
+
function InlineModePlugin() {
|
|
3698
|
+
return createRichTextV2Plugin({
|
|
3699
|
+
onKeyDown: (e) => {
|
|
3700
|
+
if (isHotkey__default["default"]("enter", e))
|
|
3701
|
+
e.preventDefault();
|
|
3702
|
+
},
|
|
3703
|
+
withPlugin: withInlineMode,
|
|
3704
|
+
renderElement: (renderElement) => (props) => /* @__PURE__ */ jsxRuntime.jsx(InlineModePluginComponent, __spreadProps(__spreadValues({}, props), {
|
|
3705
|
+
renderElement
|
|
3706
|
+
}))
|
|
3707
|
+
});
|
|
3708
|
+
}
|
|
3709
|
+
function InlineModePluginComponent(_f) {
|
|
3710
|
+
var _g = _f, {
|
|
3711
|
+
renderElement
|
|
3712
|
+
} = _g, props = __objRest(_g, [
|
|
3713
|
+
"renderElement"
|
|
3714
|
+
]);
|
|
3715
|
+
return /* @__PURE__ */ jsxRuntime.jsx("span", __spreadProps(__spreadValues({}, props.attributes), {
|
|
3716
|
+
children: renderElement(props)
|
|
3717
|
+
}));
|
|
3718
|
+
}
|
|
3719
|
+
const RichTextV2ControlType = "makeswift::controls::rich-text-v2";
|
|
3720
|
+
const RichTextV2Mode = {
|
|
3721
|
+
Inline: "makeswift::controls::rich-text-v2::mode::inline",
|
|
3722
|
+
Block: "makeswift::controls::rich-text-v2::mode::block"
|
|
3723
|
+
};
|
|
3724
|
+
function RichText(config = {}) {
|
|
3725
|
+
return {
|
|
3726
|
+
type: RichTextV2ControlType,
|
|
3727
|
+
config: {
|
|
3728
|
+
mode: config.mode,
|
|
3729
|
+
defaultValue: config == null ? void 0 : config.unstable_defaultValue,
|
|
3730
|
+
plugins: (config == null ? void 0 : config.mode) === RichTextV2Mode.Inline ? [InlineModePlugin()] : [BlockPlugin(), TypographyPlugin(), TextAlignPlugin(), InlinePlugin(), LinkPlugin()]
|
|
3731
|
+
}
|
|
3732
|
+
};
|
|
3733
|
+
}
|
|
3734
|
+
RichText.Mode = RichTextV2Mode;
|
|
2300
3735
|
const RichTextV2ControlMessageType = {
|
|
2301
3736
|
RESET_VALUE: "makeswift::controls::rich-text-v2::control-message::reset-value",
|
|
2302
3737
|
FOCUS: "makeswift::controls::rich-text-v2::control-message::focus",
|
|
@@ -2306,7 +3741,9 @@ const RichTextV2ControlMessageType = {
|
|
|
2306
3741
|
ON_CHANGE: "makeswift::controls::rich-text-v2::control-message::on-change",
|
|
2307
3742
|
SELECT: "makeswift::controls::rich-text-v2::control-message::select",
|
|
2308
3743
|
SWITCH_TO_BUILD_MODE: "makeswift::controls::rich-text-v2::control-message::switch-to-build-mode",
|
|
2309
|
-
CHANGE_BOX_MODEL: "makeswift::controls::rich-text-v2::control-message::change-box-model"
|
|
3744
|
+
CHANGE_BOX_MODEL: "makeswift::controls::rich-text-v2::control-message::change-box-model",
|
|
3745
|
+
REDO: "makeswift::controls::rich-text-v2::control-message::redo",
|
|
3746
|
+
UNDO: "makeswift::controls::rich-text-v2::control-message::undo"
|
|
2310
3747
|
};
|
|
2311
3748
|
class RichTextV2Control extends PropController {
|
|
2312
3749
|
constructor(send, descriptor) {
|
|
@@ -2326,8 +3763,9 @@ class RichTextV2Control extends PropController {
|
|
|
2326
3763
|
case RichTextV2ControlMessageType.RESET_VALUE: {
|
|
2327
3764
|
if (this.defaultValue) {
|
|
2328
3765
|
this.editor.selection = null;
|
|
2329
|
-
this.editor.children = this.defaultValue
|
|
3766
|
+
this.editor.children = this.defaultValue;
|
|
2330
3767
|
this.editor.onChange();
|
|
3768
|
+
this.onLocalUserChange();
|
|
2331
3769
|
}
|
|
2332
3770
|
break;
|
|
2333
3771
|
}
|
|
@@ -2350,29 +3788,35 @@ class RichTextV2Control extends PropController {
|
|
|
2350
3788
|
return (_a3 = plugin == null ? void 0 : plugin.control) == null ? void 0 : _a3.getValue(editor);
|
|
2351
3789
|
})) != null ? _c : []
|
|
2352
3790
|
});
|
|
3791
|
+
const _onChange = editor.onChange;
|
|
3792
|
+
this.editor.onChange = (options) => {
|
|
3793
|
+
_onChange(options);
|
|
3794
|
+
this.updatePluginValues();
|
|
3795
|
+
if (this.editor == null || (options == null ? void 0 : options.operation) == null)
|
|
3796
|
+
return;
|
|
3797
|
+
this.onLocalUserChange();
|
|
3798
|
+
};
|
|
2353
3799
|
}
|
|
2354
3800
|
setDefaultValue(defaultValue) {
|
|
2355
|
-
this.defaultValue =
|
|
3801
|
+
this.defaultValue = defaultValue;
|
|
2356
3802
|
this.send({
|
|
2357
3803
|
type: RichTextV2ControlMessageType.SET_DEFAULT_VALUE,
|
|
2358
|
-
value:
|
|
3804
|
+
value: defaultValue
|
|
2359
3805
|
});
|
|
2360
3806
|
}
|
|
2361
|
-
|
|
2362
|
-
this.
|
|
2363
|
-
|
|
2364
|
-
|
|
2365
|
-
|
|
3807
|
+
onLocalUserChange() {
|
|
3808
|
+
if (this.editor == null)
|
|
3809
|
+
return;
|
|
3810
|
+
this.send({
|
|
3811
|
+
type: RichTextV2ControlMessageType.ON_CHANGE,
|
|
3812
|
+
value: richTextV2DescendentsToData(this.editor.children, this.editor.currentKey)
|
|
3813
|
+
});
|
|
2366
3814
|
}
|
|
2367
|
-
|
|
3815
|
+
updatePluginValues() {
|
|
2368
3816
|
var _a2, _b, _c;
|
|
2369
3817
|
const editor = this.editor;
|
|
2370
3818
|
if (editor == null)
|
|
2371
3819
|
return;
|
|
2372
|
-
this.send({
|
|
2373
|
-
type: RichTextV2ControlMessageType.ON_CHANGE,
|
|
2374
|
-
value: richTextV2DescendentsToData(value)
|
|
2375
|
-
});
|
|
2376
3820
|
this.send({
|
|
2377
3821
|
type: RichTextV2ControlMessageType.SET_PLUGIN_CONTROL_VALUE,
|
|
2378
3822
|
value: (_c = (_b = (_a2 = this.descriptor.config) == null ? void 0 : _a2.plugins) == null ? void 0 : _b.map((plugin) => {
|
|
@@ -2381,15 +3825,167 @@ class RichTextV2Control extends PropController {
|
|
|
2381
3825
|
})) != null ? _c : []
|
|
2382
3826
|
});
|
|
2383
3827
|
}
|
|
3828
|
+
select() {
|
|
3829
|
+
this.send({ type: RichTextV2ControlMessageType.SELECT });
|
|
3830
|
+
}
|
|
3831
|
+
switchToBuildMode() {
|
|
3832
|
+
this.send({ type: RichTextV2ControlMessageType.SWITCH_TO_BUILD_MODE });
|
|
3833
|
+
}
|
|
3834
|
+
undo() {
|
|
3835
|
+
this.send({ type: RichTextV2ControlMessageType.UNDO });
|
|
3836
|
+
}
|
|
3837
|
+
redo() {
|
|
3838
|
+
this.send({ type: RichTextV2ControlMessageType.REDO });
|
|
3839
|
+
}
|
|
2384
3840
|
changeBoxModel(boxModel) {
|
|
2385
3841
|
this.send({ type: RichTextV2ControlMessageType.CHANGE_BOX_MODEL, payload: { boxModel } });
|
|
2386
3842
|
}
|
|
2387
3843
|
}
|
|
2388
3844
|
function isRichTextV1Data(value) {
|
|
2389
|
-
return value !== void 0 && typeof value === "object" && !Array.isArray(value) && "
|
|
3845
|
+
return value !== void 0 && typeof value === "object" && !Array.isArray(value) && "document" in value;
|
|
2390
3846
|
}
|
|
2391
|
-
|
|
2392
|
-
|
|
3847
|
+
const TypographyControlType = "makeswift::controls::typography";
|
|
3848
|
+
function unstable_Typography() {
|
|
3849
|
+
return {
|
|
3850
|
+
type: TypographyControlType
|
|
3851
|
+
};
|
|
3852
|
+
}
|
|
3853
|
+
function getTypographySwatchIds(value) {
|
|
3854
|
+
var _a2;
|
|
3855
|
+
return (_a2 = value == null ? void 0 : value.style.flatMap((style) => {
|
|
3856
|
+
var _a3, _b;
|
|
3857
|
+
return (_b = (_a3 = style.value.color) == null ? void 0 : _a3.swatchId) != null ? _b : [];
|
|
3858
|
+
}).filter(isNonNullable)) != null ? _a2 : [];
|
|
3859
|
+
}
|
|
3860
|
+
function getTypographyTypographyIds(value) {
|
|
3861
|
+
return [value == null ? void 0 : value.id].filter(isNonNullable);
|
|
3862
|
+
}
|
|
3863
|
+
function getRichTextSwatchIds(value) {
|
|
3864
|
+
if (value == null || value.document == null)
|
|
3865
|
+
return [];
|
|
3866
|
+
return getNodeSwatchIds(value.document);
|
|
3867
|
+
function getNodeSwatchIds(node) {
|
|
3868
|
+
var _a2, _b, _c, _d;
|
|
3869
|
+
switch (node.object) {
|
|
3870
|
+
case "document":
|
|
3871
|
+
case "block":
|
|
3872
|
+
case "inline":
|
|
3873
|
+
return (_b = (_a2 = node.nodes) == null ? void 0 : _a2.flatMap(getNodeSwatchIds)) != null ? _b : [];
|
|
3874
|
+
case "text":
|
|
3875
|
+
return (_d = (_c = node.marks) == null ? void 0 : _c.flatMap(getMarkSwatchIds)) != null ? _d : [];
|
|
3876
|
+
default:
|
|
3877
|
+
return [];
|
|
3878
|
+
}
|
|
3879
|
+
}
|
|
3880
|
+
function getTypographyStyleSwatchIds(style) {
|
|
3881
|
+
var _a2;
|
|
3882
|
+
return (_a2 = style == null ? void 0 : style.map((override) => override.value).flatMap((typographyStyle) => {
|
|
3883
|
+
var _a3;
|
|
3884
|
+
return (_a3 = typographyStyle.color) == null ? void 0 : _a3.swatchId;
|
|
3885
|
+
}).filter(isNonNullable)) != null ? _a2 : [];
|
|
3886
|
+
}
|
|
3887
|
+
function getMarkSwatchIds(mark) {
|
|
3888
|
+
var _a2, _b;
|
|
3889
|
+
return getTypographyStyleSwatchIds((_b = (_a2 = mark.data) == null ? void 0 : _a2.value) == null ? void 0 : _b.style);
|
|
3890
|
+
}
|
|
3891
|
+
}
|
|
3892
|
+
function getRichTextTypographyIds(value) {
|
|
3893
|
+
if (value == null || value.document == null)
|
|
3894
|
+
return [];
|
|
3895
|
+
return getNodeSwatchIds(value.document);
|
|
3896
|
+
function getNodeSwatchIds(node) {
|
|
3897
|
+
var _a2, _b, _c, _d;
|
|
3898
|
+
switch (node.object) {
|
|
3899
|
+
case "document":
|
|
3900
|
+
case "block":
|
|
3901
|
+
case "inline":
|
|
3902
|
+
return (_b = (_a2 = node.nodes) == null ? void 0 : _a2.flatMap(getNodeSwatchIds)) != null ? _b : [];
|
|
3903
|
+
case "text":
|
|
3904
|
+
return (_d = (_c = node.marks) == null ? void 0 : _c.flatMap(getMarkSwatchIds)) != null ? _d : [];
|
|
3905
|
+
default:
|
|
3906
|
+
return [];
|
|
3907
|
+
}
|
|
3908
|
+
}
|
|
3909
|
+
function getMarkSwatchIds(mark) {
|
|
3910
|
+
var _a2, _b;
|
|
3911
|
+
return [(_b = (_a2 = mark.data) == null ? void 0 : _a2.value) == null ? void 0 : _b.id].filter(isNonNullable);
|
|
3912
|
+
}
|
|
3913
|
+
}
|
|
3914
|
+
function getRichTextPageIds(value) {
|
|
3915
|
+
if (value == null || value.document == null)
|
|
3916
|
+
return [];
|
|
3917
|
+
return getNodePageIds(value.document);
|
|
3918
|
+
function getNodePageIds(node) {
|
|
3919
|
+
var _a2, _b;
|
|
3920
|
+
switch (node.object) {
|
|
3921
|
+
case "document":
|
|
3922
|
+
case "block":
|
|
3923
|
+
return (_b = (_a2 = node.nodes) == null ? void 0 : _a2.flatMap(getNodePageIds)) != null ? _b : [];
|
|
3924
|
+
case "inline":
|
|
3925
|
+
return getInlinePageIds(node);
|
|
3926
|
+
default:
|
|
3927
|
+
return [];
|
|
3928
|
+
}
|
|
3929
|
+
}
|
|
3930
|
+
function getInlinePageIds(inline) {
|
|
3931
|
+
var _a2, _b, _c, _d;
|
|
3932
|
+
switch (inline.type) {
|
|
3933
|
+
case "link": {
|
|
3934
|
+
const nodePageIds = (_b = (_a2 = inline.nodes) == null ? void 0 : _a2.flatMap(getNodePageIds)) != null ? _b : [];
|
|
3935
|
+
const dataPageIds = inline.data ? getLinkDataPageIds(inline.data) : [];
|
|
3936
|
+
return [...nodePageIds, ...dataPageIds];
|
|
3937
|
+
}
|
|
3938
|
+
default:
|
|
3939
|
+
return (_d = (_c = inline.nodes) == null ? void 0 : _c.flatMap(getNodePageIds)) != null ? _d : [];
|
|
3940
|
+
}
|
|
3941
|
+
}
|
|
3942
|
+
function getLinkDataPageIds(link) {
|
|
3943
|
+
switch (link.type) {
|
|
3944
|
+
case "OPEN_PAGE":
|
|
3945
|
+
return link.payload.pageId == null ? [] : [link.payload.pageId];
|
|
3946
|
+
default:
|
|
3947
|
+
return [];
|
|
3948
|
+
}
|
|
3949
|
+
}
|
|
3950
|
+
}
|
|
3951
|
+
function introspectRichTextV2Data(definition2, data, func) {
|
|
3952
|
+
const plugins = definition2.config.plugins;
|
|
3953
|
+
return data.descendants.flatMap((d) => getDescendantTypographyIds(d));
|
|
3954
|
+
function getDescendantTypographyIds(descendant) {
|
|
3955
|
+
if (slate.Element.isElement(descendant)) {
|
|
3956
|
+
return [
|
|
3957
|
+
...getElementTypographyIds(descendant),
|
|
3958
|
+
...descendant.children.flatMap((d) => getDescendantTypographyIds(d))
|
|
3959
|
+
];
|
|
3960
|
+
}
|
|
3961
|
+
if (slate.Text.isText(descendant)) {
|
|
3962
|
+
return getTextTypographyIds(descendant);
|
|
3963
|
+
}
|
|
3964
|
+
return [];
|
|
3965
|
+
}
|
|
3966
|
+
function getElementTypographyIds(descendant) {
|
|
3967
|
+
var _a2;
|
|
3968
|
+
return (_a2 = plugins == null ? void 0 : plugins.flatMap((plugin) => {
|
|
3969
|
+
var _a3;
|
|
3970
|
+
return ((_a3 = plugin.control) == null ? void 0 : _a3.definition) && plugin.control.getElementValue ? func(plugin.control.definition, plugin.control.getElementValue(descendant)) : [];
|
|
3971
|
+
})) != null ? _a2 : [];
|
|
3972
|
+
}
|
|
3973
|
+
function getTextTypographyIds(text) {
|
|
3974
|
+
var _a2;
|
|
3975
|
+
return (_a2 = plugins == null ? void 0 : plugins.flatMap((plugin) => {
|
|
3976
|
+
var _a3;
|
|
3977
|
+
return ((_a3 = plugin.control) == null ? void 0 : _a3.definition) && plugin.control.getLeafValue ? func(plugin.control.definition, plugin.control.getLeafValue(text)) : [];
|
|
3978
|
+
})) != null ? _a2 : [];
|
|
3979
|
+
}
|
|
3980
|
+
}
|
|
3981
|
+
function getRichTextV2SwatchIds(definition2, data) {
|
|
3982
|
+
return introspectRichTextV2Data(definition2, data, getSwatchIds);
|
|
3983
|
+
}
|
|
3984
|
+
function getRichTextV2TypographyIds(definition2, data) {
|
|
3985
|
+
return introspectRichTextV2Data(definition2, data, getTypographyIds);
|
|
3986
|
+
}
|
|
3987
|
+
function getRichTextV2PageIds(definition2, data) {
|
|
3988
|
+
return introspectRichTextV2Data(definition2, data, getPageIds);
|
|
2393
3989
|
}
|
|
2394
3990
|
function getElementChildren(descriptor, prop) {
|
|
2395
3991
|
if (prop == null)
|
|
@@ -2402,16 +3998,16 @@ function getElementChildren(descriptor, prop) {
|
|
|
2402
3998
|
case ListControlType:
|
|
2403
3999
|
return prop.flatMap(({ value }) => getElementChildren(descriptor.config.type, value));
|
|
2404
4000
|
case ShapeControlType: {
|
|
2405
|
-
return
|
|
4001
|
+
return getShapeElementChildren(descriptor, prop);
|
|
2406
4002
|
}
|
|
2407
4003
|
case ListControlType: {
|
|
2408
|
-
return
|
|
4004
|
+
return getListElementChildren(descriptor, prop);
|
|
2409
4005
|
}
|
|
2410
4006
|
case Types.Shape: {
|
|
2411
|
-
return
|
|
4007
|
+
return getShapePropControllerElementChildren(descriptor, prop);
|
|
2412
4008
|
}
|
|
2413
4009
|
case Types.List: {
|
|
2414
|
-
return
|
|
4010
|
+
return getListPropControllerElementChildren(descriptor, prop);
|
|
2415
4011
|
}
|
|
2416
4012
|
default:
|
|
2417
4013
|
return [];
|
|
@@ -2464,13 +4060,6 @@ function getResponsiveColorSwatchIds(value) {
|
|
|
2464
4060
|
var _a2;
|
|
2465
4061
|
return (_a2 = value == null ? void 0 : value.map((override) => override.value).map((color) => color.swatchId)) != null ? _a2 : [];
|
|
2466
4062
|
}
|
|
2467
|
-
function getTypographyStyleSwatchIds(style) {
|
|
2468
|
-
var _a2;
|
|
2469
|
-
return (_a2 = style == null ? void 0 : style.map((override) => override.value).flatMap((typographyStyle) => {
|
|
2470
|
-
var _a3;
|
|
2471
|
-
return (_a3 = typographyStyle.color) == null ? void 0 : _a3.swatchId;
|
|
2472
|
-
}).filter(isNonNullable)) != null ? _a2 : [];
|
|
2473
|
-
}
|
|
2474
4063
|
function getSwatchIds(descriptor, prop) {
|
|
2475
4064
|
var _a2, _b;
|
|
2476
4065
|
if (prop == null)
|
|
@@ -2498,78 +4087,38 @@ function getSwatchIds(descriptor, prop) {
|
|
|
2498
4087
|
return getResponsiveColorSwatchIds(prop);
|
|
2499
4088
|
case Types.Shadows:
|
|
2500
4089
|
return getBoxShadowsSwatchIds(prop);
|
|
4090
|
+
case RichTextControlType:
|
|
2501
4091
|
case Types.RichText: {
|
|
2502
|
-
|
|
2503
|
-
var _a3, _b2, _c, _d;
|
|
2504
|
-
switch (node.object) {
|
|
2505
|
-
case "document":
|
|
2506
|
-
case "block":
|
|
2507
|
-
case "inline":
|
|
2508
|
-
return (_b2 = (_a3 = node.nodes) == null ? void 0 : _a3.flatMap(getNodeSwatchIds)) != null ? _b2 : [];
|
|
2509
|
-
case "text":
|
|
2510
|
-
return (_d = (_c = node.marks) == null ? void 0 : _c.flatMap(getMarkSwatchIds)) != null ? _d : [];
|
|
2511
|
-
default:
|
|
2512
|
-
return [];
|
|
2513
|
-
}
|
|
2514
|
-
}, getMarkSwatchIds = function(mark) {
|
|
2515
|
-
var _a3, _b2;
|
|
2516
|
-
return getTypographyStyleSwatchIds((_b2 = (_a3 = mark.data) == null ? void 0 : _a3.value) == null ? void 0 : _b2.style);
|
|
2517
|
-
};
|
|
2518
|
-
const value = prop;
|
|
2519
|
-
if (value == null || value.document == null)
|
|
2520
|
-
return [];
|
|
2521
|
-
return getNodeSwatchIds(value.document);
|
|
4092
|
+
return getRichTextSwatchIds(prop);
|
|
2522
4093
|
}
|
|
2523
4094
|
case ColorControlType: {
|
|
2524
4095
|
const value = prop;
|
|
2525
4096
|
return (value == null ? void 0 : value.swatchId) == null ? [] : [value.swatchId];
|
|
2526
4097
|
}
|
|
4098
|
+
case TypographyControlType: {
|
|
4099
|
+
return getTypographySwatchIds(prop);
|
|
4100
|
+
}
|
|
2527
4101
|
case StyleV2ControlType: {
|
|
2528
4102
|
const value = prop;
|
|
2529
4103
|
return (_b = value == null ? void 0 : value.flatMap((value2) => getSwatchIds(descriptor.config.type, value2.value))) != null ? _b : [];
|
|
2530
4104
|
}
|
|
2531
4105
|
case RichTextV2ControlType: {
|
|
2532
|
-
let getDescendantSwatchIds = function(descendant) {
|
|
2533
|
-
if (slate.Element.isElement(descendant)) {
|
|
2534
|
-
return [
|
|
2535
|
-
...getSlateElementSwatchIds(descendant),
|
|
2536
|
-
...descendant.children.flatMap((d) => getDescendantSwatchIds(d))
|
|
2537
|
-
];
|
|
2538
|
-
}
|
|
2539
|
-
if (slate.Text.isText(descendant)) {
|
|
2540
|
-
return getTextSwatchIds(descendant);
|
|
2541
|
-
}
|
|
2542
|
-
return [];
|
|
2543
|
-
}, getSlateElementSwatchIds = function(descendant) {
|
|
2544
|
-
var _a3;
|
|
2545
|
-
return (_a3 = plugins == null ? void 0 : plugins.flatMap((plugin) => {
|
|
2546
|
-
var _a4;
|
|
2547
|
-
return ((_a4 = plugin.control) == null ? void 0 : _a4.definition) && plugin.control.getElementValue ? getSwatchIds(plugin.control.definition, plugin.control.getElementValue(descendant)) : [];
|
|
2548
|
-
})) != null ? _a3 : [];
|
|
2549
|
-
}, getTextSwatchIds = function(text) {
|
|
2550
|
-
var _a3;
|
|
2551
|
-
return (_a3 = plugins == null ? void 0 : plugins.flatMap((plugin) => {
|
|
2552
|
-
var _a4;
|
|
2553
|
-
return ((_a4 = plugin.control) == null ? void 0 : _a4.definition) && plugin.control.getLeafValue ? getSwatchIds(plugin.control.definition, plugin.control.getLeafValue(text)) : [];
|
|
2554
|
-
})) != null ? _a3 : [];
|
|
2555
|
-
};
|
|
2556
4106
|
const data = prop;
|
|
2557
|
-
const plugins = descriptor.config.plugins;
|
|
2558
4107
|
if (isRichTextV1Data(data))
|
|
2559
|
-
return
|
|
2560
|
-
return
|
|
4108
|
+
return getRichTextSwatchIds(data);
|
|
4109
|
+
return getRichTextV2SwatchIds(descriptor, data);
|
|
2561
4110
|
}
|
|
2562
4111
|
case ShapeControlType: {
|
|
2563
|
-
return
|
|
4112
|
+
return getShapeSwatchIds(descriptor, prop);
|
|
2564
4113
|
}
|
|
2565
4114
|
case ListControlType: {
|
|
2566
|
-
return
|
|
4115
|
+
return getListSwatchIds(descriptor, prop);
|
|
2567
4116
|
}
|
|
2568
4117
|
case Types.Shape: {
|
|
2569
|
-
return
|
|
4118
|
+
return getShapePropControllerSwatchIds(descriptor, prop);
|
|
2570
4119
|
}
|
|
2571
4120
|
case Types.List: {
|
|
2572
|
-
return
|
|
4121
|
+
return getListPropControllerSwatchIds(descriptor, prop);
|
|
2573
4122
|
}
|
|
2574
4123
|
default:
|
|
2575
4124
|
return [];
|
|
@@ -2606,16 +4155,16 @@ function getFileIds(descriptor, prop) {
|
|
|
2606
4155
|
return value == null ? [] : [value];
|
|
2607
4156
|
}
|
|
2608
4157
|
case ShapeControlType: {
|
|
2609
|
-
return
|
|
4158
|
+
return getShapeFileIds(descriptor, prop);
|
|
2610
4159
|
}
|
|
2611
4160
|
case ListControlType: {
|
|
2612
|
-
return
|
|
4161
|
+
return getListFileIds(descriptor, prop);
|
|
2613
4162
|
}
|
|
2614
4163
|
case Types.Shape: {
|
|
2615
|
-
return
|
|
4164
|
+
return getShapePropControllerFileIds(descriptor, prop);
|
|
2616
4165
|
}
|
|
2617
4166
|
case Types.List: {
|
|
2618
|
-
return
|
|
4167
|
+
return getListPropControllerFileIds(descriptor, prop);
|
|
2619
4168
|
}
|
|
2620
4169
|
default:
|
|
2621
4170
|
return [];
|
|
@@ -2625,39 +4174,30 @@ function getTypographyIds(descriptor, prop) {
|
|
|
2625
4174
|
if (prop == null)
|
|
2626
4175
|
return [];
|
|
2627
4176
|
switch (descriptor.type) {
|
|
4177
|
+
case TypographyControlType: {
|
|
4178
|
+
return getTypographyTypographyIds(prop);
|
|
4179
|
+
}
|
|
4180
|
+
case RichTextControlType:
|
|
2628
4181
|
case Types.RichText: {
|
|
2629
|
-
|
|
2630
|
-
|
|
2631
|
-
|
|
2632
|
-
|
|
2633
|
-
|
|
2634
|
-
|
|
2635
|
-
|
|
2636
|
-
case "text":
|
|
2637
|
-
return (_d = (_c = node.marks) == null ? void 0 : _c.flatMap(getMarkTypographyIds)) != null ? _d : [];
|
|
2638
|
-
default:
|
|
2639
|
-
return [];
|
|
2640
|
-
}
|
|
2641
|
-
}, getMarkTypographyIds = function(mark) {
|
|
2642
|
-
var _a2, _b;
|
|
2643
|
-
return [(_b = (_a2 = mark.data) == null ? void 0 : _a2.value) == null ? void 0 : _b.id].filter((id) => id != null);
|
|
2644
|
-
};
|
|
2645
|
-
const value = prop;
|
|
2646
|
-
if (value == null || value.document == null)
|
|
2647
|
-
return [];
|
|
2648
|
-
return getNodeTypographyIds(value.document);
|
|
4182
|
+
return getRichTextTypographyIds(prop);
|
|
4183
|
+
}
|
|
4184
|
+
case RichTextV2ControlType: {
|
|
4185
|
+
const data = prop;
|
|
4186
|
+
if (isRichTextV1Data(data))
|
|
4187
|
+
return getRichTextTypographyIds(data);
|
|
4188
|
+
return getRichTextV2TypographyIds(descriptor, data);
|
|
2649
4189
|
}
|
|
2650
4190
|
case ShapeControlType: {
|
|
2651
|
-
return
|
|
4191
|
+
return getShapeTypographyIds(descriptor, prop);
|
|
2652
4192
|
}
|
|
2653
4193
|
case ListControlType: {
|
|
2654
|
-
return
|
|
4194
|
+
return getListTypographyIds(descriptor, prop);
|
|
2655
4195
|
}
|
|
2656
4196
|
case Types.Shape: {
|
|
2657
|
-
return
|
|
4197
|
+
return getShapePropControllerTypographyIds(descriptor, prop);
|
|
2658
4198
|
}
|
|
2659
4199
|
case Types.List: {
|
|
2660
|
-
return
|
|
4200
|
+
return getListPropControllerTypographyIds(descriptor, prop);
|
|
2661
4201
|
}
|
|
2662
4202
|
default:
|
|
2663
4203
|
return [];
|
|
@@ -2734,53 +4274,27 @@ function getPageIds(descriptor, prop) {
|
|
|
2734
4274
|
}
|
|
2735
4275
|
})) != null ? _a2 : [];
|
|
2736
4276
|
}
|
|
4277
|
+
case RichTextControlType:
|
|
2737
4278
|
case Types.RichText: {
|
|
2738
|
-
|
|
2739
|
-
|
|
2740
|
-
|
|
2741
|
-
|
|
2742
|
-
|
|
2743
|
-
|
|
2744
|
-
|
|
2745
|
-
return getInlinePageIds(node);
|
|
2746
|
-
default:
|
|
2747
|
-
return [];
|
|
2748
|
-
}
|
|
2749
|
-
}, getInlinePageIds = function(inline) {
|
|
2750
|
-
var _a3, _b, _c, _d;
|
|
2751
|
-
switch (inline.type) {
|
|
2752
|
-
case "link": {
|
|
2753
|
-
const nodePageIds = (_b = (_a3 = inline.nodes) == null ? void 0 : _a3.flatMap(getNodePageIds)) != null ? _b : [];
|
|
2754
|
-
const dataPageIds = inline.data ? getLinkDataPageIds(inline.data) : [];
|
|
2755
|
-
return [...nodePageIds, ...dataPageIds];
|
|
2756
|
-
}
|
|
2757
|
-
default:
|
|
2758
|
-
return (_d = (_c = inline.nodes) == null ? void 0 : _c.flatMap(getNodePageIds)) != null ? _d : [];
|
|
2759
|
-
}
|
|
2760
|
-
}, getLinkDataPageIds = function(link) {
|
|
2761
|
-
switch (link.type) {
|
|
2762
|
-
case "OPEN_PAGE":
|
|
2763
|
-
return link.payload.pageId == null ? [] : [link.payload.pageId];
|
|
2764
|
-
default:
|
|
2765
|
-
return [];
|
|
2766
|
-
}
|
|
2767
|
-
};
|
|
2768
|
-
const value = prop;
|
|
2769
|
-
if (value == null || value.document == null)
|
|
2770
|
-
return [];
|
|
2771
|
-
return getNodePageIds(value.document);
|
|
4279
|
+
return getRichTextPageIds(prop);
|
|
4280
|
+
}
|
|
4281
|
+
case RichTextV2ControlType: {
|
|
4282
|
+
const data = prop;
|
|
4283
|
+
if (isRichTextV1Data(data))
|
|
4284
|
+
return getRichTextPageIds(data);
|
|
4285
|
+
return getRichTextV2PageIds(descriptor, data);
|
|
2772
4286
|
}
|
|
2773
4287
|
case ShapeControlType: {
|
|
2774
|
-
return
|
|
4288
|
+
return getShapePageIds(descriptor, prop);
|
|
2775
4289
|
}
|
|
2776
4290
|
case ListControlType: {
|
|
2777
|
-
return
|
|
4291
|
+
return getListPageIds(descriptor, prop);
|
|
2778
4292
|
}
|
|
2779
4293
|
case Types.Shape: {
|
|
2780
|
-
return
|
|
4294
|
+
return getShapePropControllerPageIds(descriptor, prop);
|
|
2781
4295
|
}
|
|
2782
4296
|
case Types.List: {
|
|
2783
|
-
return
|
|
4297
|
+
return getListPropControllerPageIds(descriptor, prop);
|
|
2784
4298
|
}
|
|
2785
4299
|
default:
|
|
2786
4300
|
return [];
|
|
@@ -2794,7 +4308,6 @@ var introspection = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineP
|
|
|
2794
4308
|
getBorderSwatchIds,
|
|
2795
4309
|
getBoxShadowsSwatchIds,
|
|
2796
4310
|
getResponsiveColorSwatchIds,
|
|
2797
|
-
getTypographyStyleSwatchIds,
|
|
2798
4311
|
getSwatchIds,
|
|
2799
4312
|
getBackgroundsFileIds,
|
|
2800
4313
|
getFileIds,
|
|
@@ -2974,6 +4487,8 @@ function configureStore({
|
|
|
2974
4487
|
}), redux.applyMiddleware(thunk__default["default"]));
|
|
2975
4488
|
}
|
|
2976
4489
|
exports.Backgrounds = Backgrounds;
|
|
4490
|
+
exports.BlockActions = BlockActions;
|
|
4491
|
+
exports.BlockPlugin = BlockPlugin;
|
|
2977
4492
|
exports.BlockTextAlignment = BlockTextAlignment;
|
|
2978
4493
|
exports.BlockType = BlockType;
|
|
2979
4494
|
exports.Border = Border;
|
|
@@ -2987,20 +4502,25 @@ exports.ColorControlType = ColorControlType;
|
|
|
2987
4502
|
exports.ComponentIcon = ComponentIcon;
|
|
2988
4503
|
exports.Date = Date;
|
|
2989
4504
|
exports.ElementID = ElementID;
|
|
4505
|
+
exports.ElementUtils = ElementUtils;
|
|
2990
4506
|
exports.Font = Font;
|
|
2991
4507
|
exports.GapX = GapX;
|
|
2992
4508
|
exports.GapY = GapY;
|
|
2993
4509
|
exports.Grid = Grid;
|
|
4510
|
+
exports.IconRadioGroupControlType = IconRadioGroupControlType;
|
|
2994
4511
|
exports.Image = Image$1;
|
|
2995
4512
|
exports.Image$1 = Image;
|
|
2996
4513
|
exports.ImageControlType = ImageControlType;
|
|
2997
4514
|
exports.ImageControlValueFormat = ImageControlValueFormat;
|
|
2998
4515
|
exports.Images = Images;
|
|
4516
|
+
exports.InlineModePlugin = InlineModePlugin;
|
|
4517
|
+
exports.InlinePlugin = InlinePlugin;
|
|
2999
4518
|
exports.InlineType = InlineType;
|
|
3000
4519
|
exports.Link = Link$1;
|
|
3001
4520
|
exports.Link$1 = Link;
|
|
3002
4521
|
exports.LinkControlType = LinkControlType;
|
|
3003
4522
|
exports.List = List;
|
|
4523
|
+
exports.ListActions = ListActions;
|
|
3004
4524
|
exports.ListControl = ListControl;
|
|
3005
4525
|
exports.ListControlMessageType = ListControlMessageType;
|
|
3006
4526
|
exports.ListControlType = ListControlType;
|
|
@@ -3017,8 +4537,7 @@ exports.ResponsiveLength = ResponsiveLength;
|
|
|
3017
4537
|
exports.ResponsiveNumber = ResponsiveNumber;
|
|
3018
4538
|
exports.ResponsiveOpacity = ResponsiveOpacity;
|
|
3019
4539
|
exports.ResponsiveSelect = ResponsiveSelect;
|
|
3020
|
-
exports.RichText = RichText
|
|
3021
|
-
exports.RichText$1 = RichText;
|
|
4540
|
+
exports.RichText = RichText;
|
|
3022
4541
|
exports.RichTextControl = RichTextControl;
|
|
3023
4542
|
exports.RichTextControlMessageType = RichTextControlMessageType;
|
|
3024
4543
|
exports.RichTextControlType = RichTextControlType;
|
|
@@ -3028,6 +4547,8 @@ exports.RichTextV2ControlMessageType = RichTextV2ControlMessageType;
|
|
|
3028
4547
|
exports.RichTextV2ControlType = RichTextV2ControlType;
|
|
3029
4548
|
exports.RichTextV2Mode = RichTextV2Mode;
|
|
3030
4549
|
exports.RootBlockType = RootBlockType;
|
|
4550
|
+
exports.Select = Select;
|
|
4551
|
+
exports.SelectControlType = SelectControlType;
|
|
3031
4552
|
exports.Shadows = Shadows;
|
|
3032
4553
|
exports.ShadowsPropControllerFormat = ShadowsPropControllerFormat;
|
|
3033
4554
|
exports.Shape = Shape;
|
|
@@ -3047,13 +4568,18 @@ exports.StyleControlType = StyleControlType;
|
|
|
3047
4568
|
exports.StyleV2Control = StyleV2Control;
|
|
3048
4569
|
exports.StyleV2ControlMessageType = StyleV2ControlMessageType;
|
|
3049
4570
|
exports.StyleV2ControlType = StyleV2ControlType;
|
|
4571
|
+
exports.TYPOGRAPHY_KEY = TYPOGRAPHY_KEY;
|
|
3050
4572
|
exports.Table = Table;
|
|
3051
4573
|
exports.TableFormFields = TableFormFields;
|
|
3052
4574
|
exports.TableFormFieldsMessageType = TableFormFieldsMessageType;
|
|
4575
|
+
exports.TextAlignPlugin = TextAlignPlugin;
|
|
3053
4576
|
exports.TextArea = TextArea;
|
|
3054
4577
|
exports.TextInput = TextInput;
|
|
3055
4578
|
exports.TextStyle = TextStyle;
|
|
3056
4579
|
exports.Types = Types;
|
|
4580
|
+
exports.TypographyActions = TypographyActions;
|
|
4581
|
+
exports.TypographyControlType = TypographyControlType;
|
|
4582
|
+
exports.TypographyPlugin = TypographyPlugin;
|
|
3057
4583
|
exports.Video = Video;
|
|
3058
4584
|
exports.Width = Width;
|
|
3059
4585
|
exports.WidthPropControllerFormat = WidthPropControllerFormat;
|
|
@@ -3071,6 +4597,7 @@ exports.createDocument = createDocument;
|
|
|
3071
4597
|
exports.createDocumentReference = createDocumentReference;
|
|
3072
4598
|
exports.createPropController = createPropController;
|
|
3073
4599
|
exports.createRichTextV2Plugin = createRichTextV2Plugin;
|
|
4600
|
+
exports.deepEqual = deepEqual;
|
|
3074
4601
|
exports.descriptors = descriptors;
|
|
3075
4602
|
exports.getBackgroundsFileIds = getBackgroundsFileIds;
|
|
3076
4603
|
exports.getBackgroundsSwatchIds = getBackgroundsSwatchIds;
|
|
@@ -3094,6 +4621,11 @@ exports.getInitialState = getInitialState$7;
|
|
|
3094
4621
|
exports.getInitialState$1 = getInitialState$2;
|
|
3095
4622
|
exports.getIsInBuilder = getIsInBuilder;
|
|
3096
4623
|
exports.getIsPreview = getIsPreview;
|
|
4624
|
+
exports.getListElementChildren = getListElementChildren;
|
|
4625
|
+
exports.getListFileIds = getListFileIds;
|
|
4626
|
+
exports.getListPageIds = getListPageIds;
|
|
4627
|
+
exports.getListSwatchIds = getListSwatchIds;
|
|
4628
|
+
exports.getListTypographyIds = getListTypographyIds;
|
|
3097
4629
|
exports.getLocales = getLocales;
|
|
3098
4630
|
exports.getPageIds = getPageIds;
|
|
3099
4631
|
exports.getPropController = getPropController;
|
|
@@ -3102,18 +4634,27 @@ exports.getPropControllers = getPropControllers;
|
|
|
3102
4634
|
exports.getPropControllersHandle = getPropControllersHandle;
|
|
3103
4635
|
exports.getReactComponent = getReactComponent;
|
|
3104
4636
|
exports.getResponsiveColorSwatchIds = getResponsiveColorSwatchIds;
|
|
4637
|
+
exports.getShapeElementChildren = getShapeElementChildren;
|
|
4638
|
+
exports.getShapeFileIds = getShapeFileIds;
|
|
4639
|
+
exports.getShapePageIds = getShapePageIds;
|
|
4640
|
+
exports.getShapeSwatchIds = getShapeSwatchIds;
|
|
4641
|
+
exports.getShapeTypographyIds = getShapeTypographyIds;
|
|
3105
4642
|
exports.getSwatchIds = getSwatchIds;
|
|
3106
4643
|
exports.getTableIds = getTableIds;
|
|
3107
4644
|
exports.getTypographyIds = getTypographyIds;
|
|
3108
|
-
exports.
|
|
3109
|
-
exports.
|
|
4645
|
+
exports.getTypographySwatchIds = getTypographySwatchIds;
|
|
4646
|
+
exports.getTypographyTypographyIds = getTypographyTypographyIds;
|
|
4647
|
+
exports.getValue = getValue$3;
|
|
3110
4648
|
exports.introspection = introspection;
|
|
3111
4649
|
exports.isElementReference = isElementReference;
|
|
4650
|
+
exports.isLinkElement = isLinkElement;
|
|
3112
4651
|
exports.isNonNullable = isNonNullable;
|
|
3113
4652
|
exports.isPropControllersHandle = isPropControllersHandle;
|
|
3114
4653
|
exports.isRichTextV1Data = isRichTextV1Data;
|
|
3115
4654
|
exports.merge = merge;
|
|
3116
4655
|
exports.mergeSlotData = mergeSlotData;
|
|
4656
|
+
exports.onChange = onChange$1;
|
|
4657
|
+
exports.onKeyDown = onKeyDown;
|
|
3117
4658
|
exports.parseLocalesInput = parseLocalesInput;
|
|
3118
4659
|
exports.reducer = reducer$8;
|
|
3119
4660
|
exports.reducer$1 = reducer$7;
|
|
@@ -3130,8 +4671,15 @@ exports.richTextDTOtoSelection = richTextDTOtoSelection;
|
|
|
3130
4671
|
exports.richTextV2DataToDescendents = richTextV2DataToDescendents;
|
|
3131
4672
|
exports.richTextV2DescendentsToData = richTextV2DescendentsToData;
|
|
3132
4673
|
exports.toSelectionDTO = toSelectionDTO;
|
|
3133
|
-
exports.
|
|
4674
|
+
exports.unstable_IconRadioGroup = unstable_IconRadioGroup;
|
|
4675
|
+
exports.unstable_IconRadioGroupIcon = unstable_IconRadioGroupIcon;
|
|
3134
4676
|
exports.unstable_StyleV2 = unstable_StyleV2;
|
|
4677
|
+
exports.unstable_Typography = unstable_Typography;
|
|
3135
4678
|
exports.unstable_useStyleV2ClassName = unstable_useStyleV2ClassName;
|
|
3136
4679
|
exports.useStyle = useStyle;
|
|
4680
|
+
exports.withBlock = withBlock;
|
|
4681
|
+
exports.withInline = withInline;
|
|
4682
|
+
exports.withInlineMode = withInlineMode;
|
|
4683
|
+
exports.withTextAlign = withTextAlign;
|
|
4684
|
+
exports.withTypography = withTypography;
|
|
3137
4685
|
//# sourceMappingURL=react-page.cjs.js.map
|