@makeswift/runtime 0.9.12 → 0.10.1
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 +3 -0
- package/dist/Box.cjs.js.map +1 -1
- package/dist/Box.es.js +4 -1
- package/dist/Box.es.js.map +1 -1
- package/dist/Button.cjs.js +3 -2
- package/dist/Button.cjs.js.map +1 -1
- package/dist/Button.es.js +4 -3
- package/dist/Button.es.js.map +1 -1
- package/dist/Carousel.cjs.js +3 -2
- package/dist/Carousel.cjs.js.map +1 -1
- package/dist/Carousel.es.js +4 -3
- package/dist/Carousel.es.js.map +1 -1
- package/dist/Countdown.cjs.js +3 -0
- package/dist/Countdown.cjs.js.map +1 -1
- package/dist/Countdown.es.js +4 -1
- package/dist/Countdown.es.js.map +1 -1
- package/dist/Divider.cjs.js +3 -0
- package/dist/Divider.cjs.js.map +1 -1
- package/dist/Divider.es.js +4 -1
- package/dist/Divider.es.js.map +1 -1
- package/dist/Embed.cjs.js +1 -0
- package/dist/Embed.cjs.js.map +1 -1
- package/dist/Embed.es.js +2 -1
- package/dist/Embed.es.js.map +1 -1
- package/dist/Form.cjs.js +13 -12
- package/dist/Form.cjs.js.map +1 -1
- package/dist/Form.es.js +5 -4
- package/dist/Form.es.js.map +1 -1
- package/dist/Image.cjs.js +11 -10
- package/dist/Image.cjs.js.map +1 -1
- package/dist/Image.es.js +11 -10
- package/dist/Image.es.js.map +1 -1
- package/dist/LiveProvider.cjs.js +3 -0
- package/dist/LiveProvider.cjs.js.map +1 -1
- package/dist/LiveProvider.es.js +5 -2
- package/dist/LiveProvider.es.js.map +1 -1
- package/dist/Navigation.cjs.js +11 -10
- package/dist/Navigation.cjs.js.map +1 -1
- package/dist/Navigation.es.js +11 -10
- package/dist/Navigation.es.js.map +1 -1
- package/dist/PreviewProvider.cjs.js +10 -6
- package/dist/PreviewProvider.cjs.js.map +1 -1
- package/dist/PreviewProvider.es.js +9 -5
- package/dist/PreviewProvider.es.js.map +1 -1
- package/dist/ReadOnlyText.cjs.js +19 -26
- package/dist/ReadOnlyText.cjs.js.map +1 -1
- package/dist/ReadOnlyText.es.js +15 -22
- package/dist/ReadOnlyText.es.js.map +1 -1
- package/dist/ReadOnlyTextV2.cjs.js +29 -26
- package/dist/ReadOnlyTextV2.cjs.js.map +1 -1
- package/dist/ReadOnlyTextV2.es.js +28 -25
- package/dist/ReadOnlyTextV2.es.js.map +1 -1
- package/dist/Root.cjs.js +3 -0
- package/dist/Root.cjs.js.map +1 -1
- package/dist/Root.es.js +4 -1
- package/dist/Root.es.js.map +1 -1
- package/dist/SocialLinks.cjs.js +6 -5
- package/dist/SocialLinks.cjs.js.map +1 -1
- package/dist/SocialLinks.es.js +7 -6
- 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/actions.cjs.js +2 -2
- package/dist/actions.cjs.js.map +1 -1
- package/dist/actions.es.js +2 -2
- package/dist/actions.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 +3 -2
- package/dist/components.cjs.js.map +1 -1
- package/dist/components.es.js +3 -2
- package/dist/components.es.js.map +1 -1
- package/dist/control-serialization.es.js +1 -1
- package/dist/controls.cjs.js +8 -8
- package/dist/controls.es.js +4 -2
- package/dist/controls.es.js.map +1 -1
- package/dist/index.cjs.js +280 -216
- package/dist/index.cjs.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 -242
- package/dist/index.cjs5.js.map +1 -1
- package/dist/index.cjs6.js +0 -41
- 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 +275 -11
- package/dist/index.cjs8.js.map +1 -1
- package/dist/index.es.js +274 -209
- 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 -240
- package/dist/index.es5.js.map +1 -1
- package/dist/index.es6.js +1 -36
- 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 +270 -10
- 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 +3 -0
- package/dist/next.cjs.js.map +1 -1
- package/dist/next.es.js +4 -1
- 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 +1450 -65
- package/dist/react-page.cjs.js.map +1 -1
- package/dist/react-page.es.js +1427 -66
- package/dist/react-page.es.js.map +1 -1
- package/dist/react.cjs.js +3 -0
- package/dist/react.cjs.js.map +1 -1
- package/dist/react.es.js +3 -0
- package/dist/react.es.js.map +1 -1
- package/dist/slate.cjs.js +33 -391
- package/dist/slate.cjs.js.map +1 -1
- package/dist/slate.es.js +15 -376
- package/dist/slate.es.js.map +1 -1
- package/dist/text-input.cjs.js +0 -22
- package/dist/text-input.cjs.js.map +1 -1
- package/dist/text-input.es.js +1 -18
- package/dist/text-input.es.js.map +1 -1
- 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/rich-text/fixtures/v2-data-types.d.ts.map +1 -1
- 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/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 +17 -31
- package/dist/types/src/controls/rich-text-v2/rich-text-v2.d.ts.map +1 -1
- package/dist/types/src/next/api-handler/index.d.ts.map +1 -1
- package/dist/types/src/next/client.d.ts.map +1 -1
- package/dist/types/src/next/index.d.ts.map +1 -1
- package/dist/types/src/prop-controllers/descriptors.d.ts +1 -1
- package/dist/types/src/prop-controllers/descriptors.d.ts.map +1 -1
- package/dist/types/src/prop-controllers/introspection.d.ts.map +1 -1
- package/dist/types/src/runtimes/react/controls/control.d.ts +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 +2 -1
- package/dist/types/src/runtimes/react/controls/rich-text-v2/EditableTextV2/render-element.d.ts.map +1 -1
- package/dist/types/src/runtimes/react/controls/rich-text-v2/EditableTextV2/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.map +1 -1
- package/dist/types/src/runtimes/react/controls/rich-text-v2/ReadOnlyTextV2.d.ts +2 -1
- 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/TextAlignPlugin/index.d.ts +3 -3
- 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/types.d.ts +1 -10
- 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/actions.d.ts +2 -1
- package/dist/types/src/state/actions.d.ts.map +1 -1
- package/dist/types/src/state/modules/locales.d.ts.map +1 -1
- package/dist/types/src/state/react-builder-preview.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/index.cjs10.js +0 -390
- package/dist/index.cjs10.js.map +0 -1
- package/dist/index.cjs9.js +0 -295
- 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 -288
- 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 -765
- package/dist/types.cjs2.js.map +0 -1
- package/dist/types.es2.js +0 -748
- package/dist/types.es2.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.es.js
CHANGED
|
@@ -17,6 +17,18 @@ var __spreadValues = (a, b) => {
|
|
|
17
17
|
return a;
|
|
18
18
|
};
|
|
19
19
|
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
+
var __objRest = (source, exclude) => {
|
|
21
|
+
var target = {};
|
|
22
|
+
for (var prop in source)
|
|
23
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
24
|
+
target[prop] = source[prop];
|
|
25
|
+
if (source != null && __getOwnPropSymbols)
|
|
26
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
|
27
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
28
|
+
target[prop] = source[prop];
|
|
29
|
+
}
|
|
30
|
+
return target;
|
|
31
|
+
};
|
|
20
32
|
var __publicField = (obj, key, value) => {
|
|
21
33
|
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
22
34
|
return value;
|
|
@@ -26,12 +38,14 @@ var _a;
|
|
|
26
38
|
import { combineReducers, createStore, applyMiddleware } from "redux";
|
|
27
39
|
import thunk from "redux-thunk";
|
|
28
40
|
import { A as ActionTypes, n as localeStringSchema } from "./actions.es.js";
|
|
29
|
-
import { reducer as reducer$a, getInitialState as getInitialState$9 } from "./state/breakpoints.es.js";
|
|
41
|
+
import { findBreakpointOverride, reducer as reducer$a, getInitialState as getInitialState$9 } from "./state/breakpoints.es.js";
|
|
30
42
|
import React__default from "react";
|
|
31
|
-
import { cache } from "@emotion/css";
|
|
43
|
+
import { cache, cx } from "@emotion/css";
|
|
32
44
|
import { serializeStyles } from "@emotion/serialize";
|
|
33
45
|
import { registerStyles, insertStyles } from "@emotion/utils";
|
|
34
|
-
import { Element, Text } from "slate";
|
|
46
|
+
import { Element, Range, Editor, Text, Path, Transforms, Node, Point } from "slate";
|
|
47
|
+
import { jsx, Fragment } from "react/jsx-runtime";
|
|
48
|
+
import isHotkey from "is-hotkey";
|
|
35
49
|
const ComponentIcon = {
|
|
36
50
|
Billing: "billing",
|
|
37
51
|
Bolt: "bolt",
|
|
@@ -285,6 +299,12 @@ function reducer$1(state = getInitialState(), action) {
|
|
|
285
299
|
}
|
|
286
300
|
}
|
|
287
301
|
function parseLocalesInput(input) {
|
|
302
|
+
if (input.locales == null) {
|
|
303
|
+
throw new Error(`Locales cannot be null or undefined. Please provide the locales array.`);
|
|
304
|
+
}
|
|
305
|
+
if (input.locales.includes(input.defaultLocale) === false) {
|
|
306
|
+
throw new Error(`Default locale "${input.defaultLocale}" is not included in locales: ${input.locales}. Please add the default locale to the locales array.`);
|
|
307
|
+
}
|
|
288
308
|
return {
|
|
289
309
|
locales: input.locales.map((locale) => localeStringSchema.parse(locale)),
|
|
290
310
|
defaultLocale: localeStringSchema.parse(input.defaultLocale),
|
|
@@ -671,7 +691,7 @@ function Shape$1(options) {
|
|
|
671
691
|
function introspectShapePropControllerData(descriptor, value, func) {
|
|
672
692
|
if (value == null)
|
|
673
693
|
return [];
|
|
674
|
-
return Object.entries(descriptor.options.type).flatMap(([key,
|
|
694
|
+
return Object.entries(descriptor.options.type).flatMap(([key, definition2]) => func(definition2, value[key]));
|
|
675
695
|
}
|
|
676
696
|
function getShapePropControllerElementChildren(descriptor, value) {
|
|
677
697
|
return introspectShapePropControllerData(descriptor, value, getElementChildren);
|
|
@@ -1037,32 +1057,32 @@ class ListControl extends PropController {
|
|
|
1037
1057
|
this.controls = /* @__PURE__ */ new Map();
|
|
1038
1058
|
}
|
|
1039
1059
|
}
|
|
1040
|
-
function copyListData(
|
|
1060
|
+
function copyListData(definition2, value, context) {
|
|
1041
1061
|
if (value == null)
|
|
1042
1062
|
return value;
|
|
1043
1063
|
return value && value.map((item) => __spreadProps(__spreadValues({}, item), {
|
|
1044
|
-
value: copy(
|
|
1064
|
+
value: copy(definition2.config.type, item.value, context)
|
|
1045
1065
|
}));
|
|
1046
1066
|
}
|
|
1047
|
-
function introspectListData(
|
|
1067
|
+
function introspectListData(definition2, value, func) {
|
|
1048
1068
|
if (value == null)
|
|
1049
1069
|
return [];
|
|
1050
|
-
return value.flatMap((item) => func(
|
|
1070
|
+
return value.flatMap((item) => func(definition2.config.type, item.value));
|
|
1051
1071
|
}
|
|
1052
|
-
function getListElementChildren(
|
|
1053
|
-
return introspectListData(
|
|
1072
|
+
function getListElementChildren(definition2, value) {
|
|
1073
|
+
return introspectListData(definition2, value, getElementChildren);
|
|
1054
1074
|
}
|
|
1055
|
-
function getListSwatchIds(
|
|
1056
|
-
return introspectListData(
|
|
1075
|
+
function getListSwatchIds(definition2, value) {
|
|
1076
|
+
return introspectListData(definition2, value, getSwatchIds);
|
|
1057
1077
|
}
|
|
1058
|
-
function getListFileIds(
|
|
1059
|
-
return introspectListData(
|
|
1078
|
+
function getListFileIds(definition2, value) {
|
|
1079
|
+
return introspectListData(definition2, value, getFileIds);
|
|
1060
1080
|
}
|
|
1061
|
-
function getListTypographyIds(
|
|
1062
|
-
return introspectListData(
|
|
1081
|
+
function getListTypographyIds(definition2, value) {
|
|
1082
|
+
return introspectListData(definition2, value, getTypographyIds);
|
|
1063
1083
|
}
|
|
1064
|
-
function getListPageIds(
|
|
1065
|
-
return introspectListData(
|
|
1084
|
+
function getListPageIds(definition2, value) {
|
|
1085
|
+
return introspectListData(definition2, value, getPageIds);
|
|
1066
1086
|
}
|
|
1067
1087
|
const ShapeControlType = "makeswift::controls::shape";
|
|
1068
1088
|
function Shape(config) {
|
|
@@ -1107,35 +1127,35 @@ class ShapeControl extends PropController {
|
|
|
1107
1127
|
this.setControls();
|
|
1108
1128
|
}
|
|
1109
1129
|
}
|
|
1110
|
-
function copyShapeData(
|
|
1130
|
+
function copyShapeData(definition2, value, context) {
|
|
1111
1131
|
if (value == null)
|
|
1112
1132
|
return value;
|
|
1113
1133
|
const newValue = {};
|
|
1114
|
-
for (const [key, itemDefinition] of Object.entries(
|
|
1134
|
+
for (const [key, itemDefinition] of Object.entries(definition2.config.type)) {
|
|
1115
1135
|
const prop = value[key];
|
|
1116
1136
|
newValue[key] = copy(itemDefinition, prop, context);
|
|
1117
1137
|
}
|
|
1118
1138
|
return newValue;
|
|
1119
1139
|
}
|
|
1120
|
-
function introspectShapeData(
|
|
1140
|
+
function introspectShapeData(definition2, value, func) {
|
|
1121
1141
|
if (value == null)
|
|
1122
1142
|
return [];
|
|
1123
|
-
return Object.entries(
|
|
1143
|
+
return Object.entries(definition2.config.type).flatMap(([key, definition22]) => func(definition22, value[key]));
|
|
1124
1144
|
}
|
|
1125
|
-
function getShapeElementChildren(
|
|
1126
|
-
return introspectShapeData(
|
|
1145
|
+
function getShapeElementChildren(definition2, data) {
|
|
1146
|
+
return introspectShapeData(definition2, data, getElementChildren);
|
|
1127
1147
|
}
|
|
1128
|
-
function getShapeSwatchIds(
|
|
1129
|
-
return introspectShapeData(
|
|
1148
|
+
function getShapeSwatchIds(definition2, data) {
|
|
1149
|
+
return introspectShapeData(definition2, data, getSwatchIds);
|
|
1130
1150
|
}
|
|
1131
|
-
function getShapeTypographyIds(
|
|
1132
|
-
return introspectShapeData(
|
|
1151
|
+
function getShapeTypographyIds(definition2, data) {
|
|
1152
|
+
return introspectShapeData(definition2, data, getTypographyIds);
|
|
1133
1153
|
}
|
|
1134
|
-
function getShapePageIds(
|
|
1135
|
-
return introspectShapeData(
|
|
1154
|
+
function getShapePageIds(definition2, data) {
|
|
1155
|
+
return introspectShapeData(definition2, data, getPageIds);
|
|
1136
1156
|
}
|
|
1137
|
-
function getShapeFileIds(
|
|
1138
|
-
return introspectShapeData(
|
|
1157
|
+
function getShapeFileIds(definition2, data) {
|
|
1158
|
+
return introspectShapeData(definition2, data, getFileIds);
|
|
1139
1159
|
}
|
|
1140
1160
|
const SlotControlType = "makeswift::controls::slot";
|
|
1141
1161
|
function Slot() {
|
|
@@ -1933,8 +1953,8 @@ function copy$1(descriptor, value, context) {
|
|
|
1933
1953
|
function copyElementReference(value, context) {
|
|
1934
1954
|
return context.replacementContext.globalElementIds.get(value) || value;
|
|
1935
1955
|
}
|
|
1936
|
-
function copy(
|
|
1937
|
-
switch (
|
|
1956
|
+
function copy(definition2, value, context) {
|
|
1957
|
+
switch (definition2.type) {
|
|
1938
1958
|
case Types.Backgrounds:
|
|
1939
1959
|
case Types.Grid:
|
|
1940
1960
|
case Types.NavigationLinks:
|
|
@@ -1948,7 +1968,7 @@ function copy(definition, value, context) {
|
|
|
1948
1968
|
case Types.Border:
|
|
1949
1969
|
case Types.RichText:
|
|
1950
1970
|
case Types.ElementID:
|
|
1951
|
-
return copy$1(
|
|
1971
|
+
return copy$1(definition2, value, context);
|
|
1952
1972
|
case ColorControlType:
|
|
1953
1973
|
return copyColorData(value, context);
|
|
1954
1974
|
case ImageControlType:
|
|
@@ -1956,9 +1976,9 @@ function copy(definition, value, context) {
|
|
|
1956
1976
|
case LinkControlType:
|
|
1957
1977
|
return copyLinkData(value, context);
|
|
1958
1978
|
case ShapeControlType:
|
|
1959
|
-
return copyShapeData(
|
|
1979
|
+
return copyShapeData(definition2, value, context);
|
|
1960
1980
|
case ListControlType:
|
|
1961
|
-
return copyListData(
|
|
1981
|
+
return copyListData(definition2, value, context);
|
|
1962
1982
|
case StyleControlType:
|
|
1963
1983
|
return copyStyleData(value, context);
|
|
1964
1984
|
case SlotControlType:
|
|
@@ -1967,14 +1987,31 @@ function copy(definition, value, context) {
|
|
|
1967
1987
|
return value;
|
|
1968
1988
|
}
|
|
1969
1989
|
}
|
|
1970
|
-
function merge(
|
|
1971
|
-
switch (
|
|
1990
|
+
function merge(definition2, a, b = a, context) {
|
|
1991
|
+
switch (definition2.type) {
|
|
1972
1992
|
case SlotControlType:
|
|
1973
1993
|
return mergeSlotData(a, b, context);
|
|
1974
1994
|
default:
|
|
1975
1995
|
return b;
|
|
1976
1996
|
}
|
|
1977
1997
|
}
|
|
1998
|
+
const unstable_IconRadioGroupIcon = {
|
|
1999
|
+
TextAlignCenter: "TextAlignCenter",
|
|
2000
|
+
TextAlignJustify: "TextAlignJustify",
|
|
2001
|
+
TextAlignLeft: "TextAlignLeft",
|
|
2002
|
+
TextAlignRight: "TextAlignRight",
|
|
2003
|
+
Superscript: "Superscript16",
|
|
2004
|
+
Subscript: "Subscript16",
|
|
2005
|
+
Code: "Code16"
|
|
2006
|
+
};
|
|
2007
|
+
const IconRadioGroupControlType = "makeswift::controls::icon-radio-group";
|
|
2008
|
+
function unstable_IconRadioGroup(config) {
|
|
2009
|
+
return { type: IconRadioGroupControlType, config };
|
|
2010
|
+
}
|
|
2011
|
+
const SelectControlType = "makeswift::controls::select";
|
|
2012
|
+
function Select(config) {
|
|
2013
|
+
return { type: SelectControlType, config };
|
|
2014
|
+
}
|
|
1978
2015
|
const isServer = typeof window === "undefined";
|
|
1979
2016
|
const useInsertionEffectSpecifier = "useInsertionEffect";
|
|
1980
2017
|
const useInsertionEffect = (_a = React__default[useInsertionEffectSpecifier]) != null ? _a : React__default.useLayoutEffect;
|
|
@@ -2040,7 +2077,6 @@ const ObjectType = {
|
|
|
2040
2077
|
};
|
|
2041
2078
|
const RootBlockType = {
|
|
2042
2079
|
Default: "default",
|
|
2043
|
-
Text: "text-block",
|
|
2044
2080
|
Paragraph: "paragraph",
|
|
2045
2081
|
Heading1: "heading-one",
|
|
2046
2082
|
Heading2: "heading-two",
|
|
@@ -2212,7 +2248,6 @@ function toNodeDTO(node) {
|
|
|
2212
2248
|
case BlockType.Heading5:
|
|
2213
2249
|
case BlockType.Heading6:
|
|
2214
2250
|
case BlockType.Default:
|
|
2215
|
-
case BlockType.Text:
|
|
2216
2251
|
case BlockType.BlockQuote:
|
|
2217
2252
|
case BlockType.Paragraph:
|
|
2218
2253
|
case BlockType.OrderedList:
|
|
@@ -2266,9 +2301,6 @@ function richTextDAOToDTO(children, selection) {
|
|
|
2266
2301
|
};
|
|
2267
2302
|
}
|
|
2268
2303
|
const RichTextControlType = "makeswift::controls::rich-text";
|
|
2269
|
-
function RichText() {
|
|
2270
|
-
return { type: RichTextControlType };
|
|
2271
|
-
}
|
|
2272
2304
|
const RichTextControlMessageType = {
|
|
2273
2305
|
CHANGE_BUILDER_EDIT_MODE: "CHANGE_BUILDER_EDIT_MODE",
|
|
2274
2306
|
INITIALIZE_EDITOR: "INITIALIZE_EDITOR",
|
|
@@ -2346,23 +2378,1354 @@ function richTextV2DescendentsToData(descendants, key) {
|
|
|
2346
2378
|
key
|
|
2347
2379
|
};
|
|
2348
2380
|
}
|
|
2349
|
-
const RichTextV2ControlType = "makeswift::controls::rich-text-v2";
|
|
2350
|
-
const RichTextV2Mode = {
|
|
2351
|
-
Inline: "makeswift::controls::rich-text-v2::mode::inline",
|
|
2352
|
-
Block: "makeswift::controls::rich-text-v2::mode::block"
|
|
2353
|
-
};
|
|
2354
2381
|
function createRichTextV2Plugin({
|
|
2355
2382
|
control,
|
|
2356
2383
|
withPlugin,
|
|
2357
|
-
onKeyDown,
|
|
2384
|
+
onKeyDown: onKeyDown2,
|
|
2358
2385
|
renderElement,
|
|
2359
2386
|
renderLeaf
|
|
2360
2387
|
}) {
|
|
2361
|
-
return { control, withPlugin, onKeyDown, renderElement, renderLeaf };
|
|
2388
|
+
return { control, withPlugin, onKeyDown: onKeyDown2, renderElement, renderLeaf };
|
|
2389
|
+
}
|
|
2390
|
+
const ElementUtils = {
|
|
2391
|
+
isRootBlock(node) {
|
|
2392
|
+
return Element.isElement(node) && (Element.isElementType(node, BlockType.Paragraph) || Element.isElementType(node, BlockType.Heading1) || Element.isElementType(node, BlockType.Heading2) || Element.isElementType(node, BlockType.Heading3) || Element.isElementType(node, BlockType.Heading3) || Element.isElementType(node, BlockType.Heading4) || Element.isElementType(node, BlockType.Heading5) || Element.isElementType(node, BlockType.Heading6) || Element.isElementType(node, BlockType.BlockQuote) || Element.isElementType(node, BlockType.UnorderedList) || Element.isElementType(node, BlockType.OrderedList) || Element.isElementType(node, BlockType.Default));
|
|
2393
|
+
},
|
|
2394
|
+
isBlock(node) {
|
|
2395
|
+
return Element.isElement(node) && (this.isRootBlock(node) || Element.isElementType(node, BlockType.ListItem) || Element.isElementType(node, BlockType.ListItemChild));
|
|
2396
|
+
},
|
|
2397
|
+
isInline(node) {
|
|
2398
|
+
return Element.isElementType(node, InlineType.Code) || Element.isElementType(node, InlineType.Link) || Element.isElementType(node, InlineType.SubScript) || Element.isElementType(node, InlineType.SuperScript);
|
|
2399
|
+
},
|
|
2400
|
+
isConvertibleToListTextNode(node) {
|
|
2401
|
+
return !this.isList(node) && !this.isListItem(node) && !this.isListItemChild(node);
|
|
2402
|
+
},
|
|
2403
|
+
isList(node) {
|
|
2404
|
+
return Element.isElementType(node, BlockType.OrderedList) || Element.isElementType(node, BlockType.UnorderedList);
|
|
2405
|
+
},
|
|
2406
|
+
isListItem(node) {
|
|
2407
|
+
return Element.isElementType(node, BlockType.ListItem);
|
|
2408
|
+
},
|
|
2409
|
+
isListItemChild(node) {
|
|
2410
|
+
return Element.isElementType(node, BlockType.ListItemChild);
|
|
2411
|
+
},
|
|
2412
|
+
createText() {
|
|
2413
|
+
return { text: "" };
|
|
2414
|
+
},
|
|
2415
|
+
createParagraph() {
|
|
2416
|
+
return {
|
|
2417
|
+
children: [this.createText()],
|
|
2418
|
+
type: BlockType.Paragraph
|
|
2419
|
+
};
|
|
2420
|
+
},
|
|
2421
|
+
createList(type = BlockType.UnorderedList) {
|
|
2422
|
+
return { children: [this.createText()], type };
|
|
2423
|
+
},
|
|
2424
|
+
createListItem() {
|
|
2425
|
+
return {
|
|
2426
|
+
children: [this.createListItemChild()],
|
|
2427
|
+
type: BlockType.ListItem
|
|
2428
|
+
};
|
|
2429
|
+
},
|
|
2430
|
+
createListItemChild() {
|
|
2431
|
+
return {
|
|
2432
|
+
children: [this.createText()],
|
|
2433
|
+
type: BlockType.ListItemChild
|
|
2434
|
+
};
|
|
2435
|
+
}
|
|
2436
|
+
};
|
|
2437
|
+
function isLinkElement(node) {
|
|
2438
|
+
return ElementUtils.isInline(node) && node.type === InlineType.Link;
|
|
2439
|
+
}
|
|
2440
|
+
function isLinkEntry(inline) {
|
|
2441
|
+
return ElementUtils.isInline(inline[0]) && inline[0].type === InlineType.Link;
|
|
2442
|
+
}
|
|
2443
|
+
function unhangRange(editor, range) {
|
|
2444
|
+
let [start, end] = Range.edges(range);
|
|
2445
|
+
if (start.offset !== 0 || end.offset !== 0 || Range.isCollapsed(range)) {
|
|
2446
|
+
return range;
|
|
2447
|
+
}
|
|
2448
|
+
const endBlock = Editor.above(editor, {
|
|
2449
|
+
at: end,
|
|
2450
|
+
match: (n) => Element.isElement(n) && Editor.isBlock(editor, n)
|
|
2451
|
+
});
|
|
2452
|
+
const blockPath = endBlock ? endBlock[1] : [];
|
|
2453
|
+
const first = Editor.start(editor, start);
|
|
2454
|
+
const before = { anchor: first, focus: end };
|
|
2455
|
+
let skip = true;
|
|
2456
|
+
for (const [node, path] of Editor.nodes(editor, {
|
|
2457
|
+
at: before,
|
|
2458
|
+
match: Text.isText,
|
|
2459
|
+
reverse: true
|
|
2460
|
+
})) {
|
|
2461
|
+
if (skip) {
|
|
2462
|
+
skip = false;
|
|
2463
|
+
continue;
|
|
2464
|
+
}
|
|
2465
|
+
if (node.text !== "" || Path.isBefore(path, blockPath)) {
|
|
2466
|
+
end = { path, offset: node.text.length };
|
|
2467
|
+
break;
|
|
2468
|
+
}
|
|
2469
|
+
}
|
|
2470
|
+
return { anchor: start, focus: end };
|
|
2471
|
+
}
|
|
2472
|
+
function is(x, y) {
|
|
2473
|
+
if (x === y)
|
|
2474
|
+
return x !== 0 || y !== 0 || 1 / x === 1 / y;
|
|
2475
|
+
return x !== x && y !== y;
|
|
2476
|
+
}
|
|
2477
|
+
const { hasOwnProperty: hasOwnProperty$1 } = Object.prototype;
|
|
2478
|
+
const shallowEqual = (a, b) => {
|
|
2479
|
+
if (is(a, b))
|
|
2480
|
+
return true;
|
|
2481
|
+
if (typeof a !== "object" || a === null || typeof b !== "object" || b === null)
|
|
2482
|
+
return false;
|
|
2483
|
+
const keysA = Object.keys(a);
|
|
2484
|
+
const keysB = Object.keys(b);
|
|
2485
|
+
if (keysA.length !== keysB.length)
|
|
2486
|
+
return false;
|
|
2487
|
+
for (let i = 0; i < keysA.length; i += 1) {
|
|
2488
|
+
if (!hasOwnProperty$1.call(b, keysA[i]) || !is(a[keysA[i]], b[keysA[i]]))
|
|
2489
|
+
return false;
|
|
2490
|
+
}
|
|
2491
|
+
return true;
|
|
2492
|
+
};
|
|
2493
|
+
function isNonNullable(value) {
|
|
2494
|
+
return value != null;
|
|
2495
|
+
}
|
|
2496
|
+
const { hasOwnProperty } = Object.prototype;
|
|
2497
|
+
const deepEqual = (a, b) => {
|
|
2498
|
+
if (shallowEqual(a, b))
|
|
2499
|
+
return true;
|
|
2500
|
+
if (typeof a !== "object" || a === null || typeof b !== "object" || b === null)
|
|
2501
|
+
return false;
|
|
2502
|
+
const keysA = Object.keys(a);
|
|
2503
|
+
const keysB = Object.keys(b);
|
|
2504
|
+
if (keysA.length !== keysB.length)
|
|
2505
|
+
return false;
|
|
2506
|
+
for (let i = 0; i < keysA.length; i += 1) {
|
|
2507
|
+
if (!hasOwnProperty.call(b, keysA[i]) || !deepEqual(a[keysA[i]], b[keysA[i]]))
|
|
2508
|
+
return false;
|
|
2509
|
+
}
|
|
2510
|
+
return true;
|
|
2511
|
+
};
|
|
2512
|
+
function getSelection(editor) {
|
|
2513
|
+
if (editor.selection)
|
|
2514
|
+
return unhangRange(editor, editor.selection);
|
|
2515
|
+
return {
|
|
2516
|
+
anchor: Editor.start(editor, []),
|
|
2517
|
+
focus: Editor.end(editor, [])
|
|
2518
|
+
};
|
|
2519
|
+
}
|
|
2520
|
+
function getBlocksInSelection(editor) {
|
|
2521
|
+
return Array.from(Editor.nodes(editor, {
|
|
2522
|
+
at: getSelection(editor),
|
|
2523
|
+
match: (node) => ElementUtils.isRootBlock(node)
|
|
2524
|
+
})).filter((entry) => ElementUtils.isRootBlock(entry[0]));
|
|
2525
|
+
}
|
|
2526
|
+
function getActiveBlockType(editor) {
|
|
2527
|
+
var _a2;
|
|
2528
|
+
const rootBlocks = getBlocksInSelection(editor).map(([node]) => node.type);
|
|
2529
|
+
return rootBlocks.reduce((a, b) => a === b ? b : null, (_a2 = rootBlocks.at(0)) != null ? _a2 : null);
|
|
2530
|
+
}
|
|
2531
|
+
function unwrapInline(editor, type) {
|
|
2532
|
+
Transforms.unwrapNodes(editor, {
|
|
2533
|
+
match: (node) => ElementUtils.isInline(node) && node.type === type,
|
|
2534
|
+
at: getSelection(editor)
|
|
2535
|
+
});
|
|
2536
|
+
}
|
|
2537
|
+
function wrapInline(editor, inline) {
|
|
2538
|
+
Transforms.wrapNodes(editor, inline, {
|
|
2539
|
+
at: getSelection(editor),
|
|
2540
|
+
split: true
|
|
2541
|
+
});
|
|
2542
|
+
}
|
|
2543
|
+
function filterForSubtreeRoots(entries) {
|
|
2544
|
+
return entries.filter(([, nodePath]) => !Path.ancestors(nodePath).some((ancestor) => {
|
|
2545
|
+
return entries.some(([, path]) => Path.equals(path, ancestor));
|
|
2546
|
+
}));
|
|
2547
|
+
}
|
|
2548
|
+
function getLinksAndTextInSelection(editor) {
|
|
2549
|
+
return Array.from(Editor.nodes(editor, {
|
|
2550
|
+
at: getSelection(editor),
|
|
2551
|
+
match: (node) => ElementUtils.isInline(node) && isLinkElement(node) || Text.isText(node)
|
|
2552
|
+
}));
|
|
2553
|
+
}
|
|
2554
|
+
const getValue$3 = (editor) => {
|
|
2555
|
+
var _a2;
|
|
2556
|
+
const roots = filterForSubtreeRoots(getLinksAndTextInSelection(editor));
|
|
2557
|
+
const areAllRootsLinks = roots.every(([root]) => isLinkElement(root) || Text.isText(root));
|
|
2558
|
+
if (!areAllRootsLinks)
|
|
2559
|
+
return void 0;
|
|
2560
|
+
const matchingValues = roots.map(([node]) => node).filter(isLinkElement);
|
|
2561
|
+
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);
|
|
2562
|
+
return match == null ? match : match.link;
|
|
2563
|
+
};
|
|
2564
|
+
const onChange$1 = (editor, value) => {
|
|
2565
|
+
if (value == null)
|
|
2566
|
+
return unwrapInline(editor, InlineType.Link);
|
|
2567
|
+
const roots = filterForSubtreeRoots(getLinksAndTextInSelection(editor));
|
|
2568
|
+
const root = roots.at(0);
|
|
2569
|
+
if (roots.length === 1 && root != null && isLinkEntry(root)) {
|
|
2570
|
+
Transforms.setNodes(editor, {
|
|
2571
|
+
link: value
|
|
2572
|
+
}, { at: root[1] });
|
|
2573
|
+
} else {
|
|
2574
|
+
unwrapInline(editor, InlineType.Link);
|
|
2575
|
+
wrapInline(editor, { type: InlineType.Link, link: value, children: [] });
|
|
2576
|
+
}
|
|
2577
|
+
};
|
|
2578
|
+
function LinkPlugin() {
|
|
2579
|
+
return createRichTextV2Plugin({
|
|
2580
|
+
control: {
|
|
2581
|
+
definition: Link({
|
|
2582
|
+
label: "On Click"
|
|
2583
|
+
}),
|
|
2584
|
+
onChange: onChange$1,
|
|
2585
|
+
getValue: getValue$3,
|
|
2586
|
+
getElementValue: (element) => {
|
|
2587
|
+
return ElementUtils.isInline(element) && isLinkElement(element) ? element.link : void 0;
|
|
2588
|
+
}
|
|
2589
|
+
}
|
|
2590
|
+
});
|
|
2591
|
+
}
|
|
2592
|
+
const supportedInlineOptions = [
|
|
2593
|
+
{
|
|
2594
|
+
icon: unstable_IconRadioGroupIcon.Superscript,
|
|
2595
|
+
label: "Superscript",
|
|
2596
|
+
value: "superscript"
|
|
2597
|
+
},
|
|
2598
|
+
{
|
|
2599
|
+
icon: unstable_IconRadioGroupIcon.Subscript,
|
|
2600
|
+
label: "Subscript",
|
|
2601
|
+
value: "subscript"
|
|
2602
|
+
},
|
|
2603
|
+
{
|
|
2604
|
+
icon: unstable_IconRadioGroupIcon.Code,
|
|
2605
|
+
label: "Code",
|
|
2606
|
+
value: "code"
|
|
2607
|
+
}
|
|
2608
|
+
];
|
|
2609
|
+
function isSupportedInlineType(inline) {
|
|
2610
|
+
return supportedInlineOptions.findIndex((option) => option.value === inline) !== -1;
|
|
2611
|
+
}
|
|
2612
|
+
function isSupportedInlineEntry(entry) {
|
|
2613
|
+
const node = entry[0];
|
|
2614
|
+
return ElementUtils.isInline(node) && supportedInlineOptions.findIndex((option) => option.value === node.type) !== -1;
|
|
2615
|
+
}
|
|
2616
|
+
function getSupportedInlinesAndTextInSelection(editor) {
|
|
2617
|
+
return Array.from(Editor.nodes(editor, {
|
|
2618
|
+
at: getSelection(editor),
|
|
2619
|
+
match: (node) => ElementUtils.isInline(node) && isSupportedInlineType(node.type) || Text.isText(node)
|
|
2620
|
+
}));
|
|
2621
|
+
}
|
|
2622
|
+
const getValue$2 = (editor) => {
|
|
2623
|
+
var _a2;
|
|
2624
|
+
const roots = filterForSubtreeRoots(getSupportedInlinesAndTextInSelection(editor));
|
|
2625
|
+
const areAllRootsSupportedInlineTypesOrText = roots.every((entry) => isSupportedInlineEntry(entry) || Text.isText(entry[0]));
|
|
2626
|
+
if (!areAllRootsSupportedInlineTypesOrText)
|
|
2627
|
+
return void 0;
|
|
2628
|
+
const matchingValues = roots.filter(isSupportedInlineEntry).map(([node]) => node);
|
|
2629
|
+
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);
|
|
2630
|
+
return match == null ? match : match.type;
|
|
2631
|
+
};
|
|
2632
|
+
const onChange = (editor, value) => {
|
|
2633
|
+
function unwrapAllSupportedTypes() {
|
|
2634
|
+
supportedInlineOptions.forEach(({ value: optionValue }) => unwrapInline(editor, optionValue));
|
|
2635
|
+
}
|
|
2636
|
+
function unwrapAllInlines() {
|
|
2637
|
+
Transforms.unwrapNodes(editor, {
|
|
2638
|
+
match: (node) => ElementUtils.isInline(node),
|
|
2639
|
+
at: getSelection(editor)
|
|
2640
|
+
});
|
|
2641
|
+
}
|
|
2642
|
+
if (value == null)
|
|
2643
|
+
return unwrapAllSupportedTypes();
|
|
2644
|
+
if (!isSupportedInlineType(value))
|
|
2645
|
+
return;
|
|
2646
|
+
const roots = filterForSubtreeRoots(getSupportedInlinesAndTextInSelection(editor));
|
|
2647
|
+
const root = roots.at(0);
|
|
2648
|
+
if (roots.length === 1 && root != null && isSupportedInlineEntry(root) && root[0].type === value) {
|
|
2649
|
+
unwrapInline(editor, value);
|
|
2650
|
+
} else {
|
|
2651
|
+
unwrapAllInlines();
|
|
2652
|
+
wrapInline(editor, { type: value, children: [] });
|
|
2653
|
+
}
|
|
2654
|
+
};
|
|
2655
|
+
const withInline = (editor) => {
|
|
2656
|
+
const {
|
|
2657
|
+
isInline
|
|
2658
|
+
} = editor;
|
|
2659
|
+
editor.isInline = (entry) => {
|
|
2660
|
+
return ElementUtils.isInline(entry) && isInline(entry);
|
|
2661
|
+
};
|
|
2662
|
+
return editor;
|
|
2663
|
+
};
|
|
2664
|
+
function InlinePlugin() {
|
|
2665
|
+
return createRichTextV2Plugin({
|
|
2666
|
+
control: {
|
|
2667
|
+
definition: unstable_IconRadioGroup({
|
|
2668
|
+
label: "Inline",
|
|
2669
|
+
options: supportedInlineOptions
|
|
2670
|
+
}),
|
|
2671
|
+
onChange,
|
|
2672
|
+
getValue: getValue$2,
|
|
2673
|
+
getElementValue: (element) => {
|
|
2674
|
+
return ElementUtils.isInline(element) ? element.type : void 0;
|
|
2675
|
+
}
|
|
2676
|
+
},
|
|
2677
|
+
withPlugin: withInline,
|
|
2678
|
+
renderElement: (renderElement) => (props) => {
|
|
2679
|
+
return /* @__PURE__ */ jsx(InlinePluginComponent, __spreadProps(__spreadValues({}, props), {
|
|
2680
|
+
renderElement
|
|
2681
|
+
}));
|
|
2682
|
+
}
|
|
2683
|
+
});
|
|
2684
|
+
}
|
|
2685
|
+
function InlinePluginComponent(_b) {
|
|
2686
|
+
var _c = _b, {
|
|
2687
|
+
renderElement
|
|
2688
|
+
} = _c, props = __objRest(_c, [
|
|
2689
|
+
"renderElement"
|
|
2690
|
+
]);
|
|
2691
|
+
switch (props.element.type) {
|
|
2692
|
+
case InlineType.Code:
|
|
2693
|
+
return /* @__PURE__ */ jsx("code", __spreadProps(__spreadValues({}, props.attributes), {
|
|
2694
|
+
children: renderElement(props)
|
|
2695
|
+
}));
|
|
2696
|
+
case InlineType.SuperScript:
|
|
2697
|
+
return /* @__PURE__ */ jsx("sup", __spreadProps(__spreadValues({}, props.attributes), {
|
|
2698
|
+
children: renderElement(props)
|
|
2699
|
+
}));
|
|
2700
|
+
case InlineType.SubScript:
|
|
2701
|
+
return /* @__PURE__ */ jsx("sub", __spreadProps(__spreadValues({}, props.attributes), {
|
|
2702
|
+
children: renderElement(props)
|
|
2703
|
+
}));
|
|
2704
|
+
default:
|
|
2705
|
+
return /* @__PURE__ */ jsx(Fragment, {
|
|
2706
|
+
children: renderElement(props)
|
|
2707
|
+
});
|
|
2708
|
+
}
|
|
2709
|
+
}
|
|
2710
|
+
function setResponsiveValue(editor, key, value, options) {
|
|
2711
|
+
Editor.withoutNormalizing(editor, () => {
|
|
2712
|
+
const at = getSelection(editor);
|
|
2713
|
+
if (!at)
|
|
2714
|
+
return;
|
|
2715
|
+
const atRef = Editor.rangeRef(editor, at);
|
|
2716
|
+
if (atRef.current) {
|
|
2717
|
+
Transforms.setNodes(editor, {
|
|
2718
|
+
slice: true
|
|
2719
|
+
}, {
|
|
2720
|
+
at: atRef.current,
|
|
2721
|
+
match: options.match,
|
|
2722
|
+
split: options.split
|
|
2723
|
+
});
|
|
2724
|
+
}
|
|
2725
|
+
if (atRef.current) {
|
|
2726
|
+
const nodesToUpdate = Array.from(Editor.nodes(editor, {
|
|
2727
|
+
at: atRef.current,
|
|
2728
|
+
match: (node, path) => options.match(node, path) && node.slice === true
|
|
2729
|
+
}));
|
|
2730
|
+
for (const [, path] of nodesToUpdate) {
|
|
2731
|
+
Transforms.setNodes(editor, {
|
|
2732
|
+
[key]: value
|
|
2733
|
+
}, { at: path });
|
|
2734
|
+
}
|
|
2735
|
+
}
|
|
2736
|
+
atRef.unref();
|
|
2737
|
+
});
|
|
2738
|
+
}
|
|
2739
|
+
function normalizeResponsiveValue(editor, key, options) {
|
|
2740
|
+
return (entry) => {
|
|
2741
|
+
const [node, path] = entry;
|
|
2742
|
+
if (!options.match(node, path)) {
|
|
2743
|
+
return false;
|
|
2744
|
+
}
|
|
2745
|
+
const responsiveValue = node == null ? void 0 : node[key];
|
|
2746
|
+
if (Array.isArray(responsiveValue) && responsiveValue.length === 0) {
|
|
2747
|
+
Transforms.unsetNodes(editor, key, { at: path });
|
|
2748
|
+
return true;
|
|
2749
|
+
}
|
|
2750
|
+
if ((node == null ? void 0 : node.slice) != null) {
|
|
2751
|
+
Transforms.unsetNodes(editor, "slice", { at: path });
|
|
2752
|
+
return true;
|
|
2753
|
+
}
|
|
2754
|
+
return false;
|
|
2755
|
+
};
|
|
2756
|
+
}
|
|
2757
|
+
function responsiveShallowEqual(a = [], b = []) {
|
|
2758
|
+
const aObject = a.reduce((acc, curr) => __spreadProps(__spreadValues({}, acc), {
|
|
2759
|
+
[curr.deviceId]: curr.value
|
|
2760
|
+
}), {});
|
|
2761
|
+
const bObject = b.reduce((acc, curr) => __spreadProps(__spreadValues({}, acc), {
|
|
2762
|
+
[curr.deviceId]: curr.value
|
|
2763
|
+
}), {});
|
|
2764
|
+
const definedDevices = /* @__PURE__ */ new Set([...a.map((a2) => a2.deviceId), ...b.map((b2) => b2.deviceId)]);
|
|
2765
|
+
return Array.from(definedDevices).map((deviceId) => {
|
|
2766
|
+
const aVal = aObject[deviceId];
|
|
2767
|
+
const bVal = bObject[deviceId];
|
|
2768
|
+
if (aVal === void 0 && bVal === void 0)
|
|
2769
|
+
return { deviceId, value: void 0 };
|
|
2770
|
+
return shallowEqual(aVal, bVal) ? { deviceId, value: aVal } : { deviceId, value: null };
|
|
2771
|
+
});
|
|
2772
|
+
}
|
|
2773
|
+
function getValue$1(editor) {
|
|
2774
|
+
const matchingValues = Array.from(Editor.nodes(editor, {
|
|
2775
|
+
at: getSelection(editor),
|
|
2776
|
+
match: ElementUtils.isRootBlock
|
|
2777
|
+
})).map(([node]) => node["textAlign"]);
|
|
2778
|
+
return matchingValues.length === 0 ? void 0 : matchingValues.reduce((a, b) => {
|
|
2779
|
+
return responsiveShallowEqual(a, b);
|
|
2780
|
+
});
|
|
2781
|
+
}
|
|
2782
|
+
const TEXT_ALIGN_KEY = "textAlign";
|
|
2783
|
+
const withTextAlign = (editor) => {
|
|
2784
|
+
const {
|
|
2785
|
+
normalizeNode
|
|
2786
|
+
} = editor;
|
|
2787
|
+
editor.normalizeNode = (entry) => {
|
|
2788
|
+
if (normalizeResponsiveValue(editor, TEXT_ALIGN_KEY, {
|
|
2789
|
+
match: ElementUtils.isRootBlock
|
|
2790
|
+
})(entry)) {
|
|
2791
|
+
return;
|
|
2792
|
+
}
|
|
2793
|
+
normalizeNode(entry);
|
|
2794
|
+
};
|
|
2795
|
+
return editor;
|
|
2796
|
+
};
|
|
2797
|
+
function TextAlignPlugin() {
|
|
2798
|
+
return createRichTextV2Plugin({
|
|
2799
|
+
control: {
|
|
2800
|
+
definition: unstable_StyleV2({
|
|
2801
|
+
type: unstable_IconRadioGroup({
|
|
2802
|
+
label: "Alignment",
|
|
2803
|
+
options: [{
|
|
2804
|
+
icon: unstable_IconRadioGroupIcon.TextAlignLeft,
|
|
2805
|
+
label: "Left Align",
|
|
2806
|
+
value: "left"
|
|
2807
|
+
}, {
|
|
2808
|
+
icon: unstable_IconRadioGroupIcon.TextAlignCenter,
|
|
2809
|
+
label: "Center Align",
|
|
2810
|
+
value: "center"
|
|
2811
|
+
}, {
|
|
2812
|
+
icon: unstable_IconRadioGroupIcon.TextAlignRight,
|
|
2813
|
+
label: "Right Align",
|
|
2814
|
+
value: "right"
|
|
2815
|
+
}, {
|
|
2816
|
+
icon: unstable_IconRadioGroupIcon.TextAlignJustify,
|
|
2817
|
+
label: "Justify",
|
|
2818
|
+
value: "justify"
|
|
2819
|
+
}],
|
|
2820
|
+
defaultValue: "left"
|
|
2821
|
+
}),
|
|
2822
|
+
getStyle(textAlign) {
|
|
2823
|
+
return {
|
|
2824
|
+
textAlign
|
|
2825
|
+
};
|
|
2826
|
+
}
|
|
2827
|
+
}),
|
|
2828
|
+
onChange: (editor, value) => setResponsiveValue(editor, TEXT_ALIGN_KEY, value, {
|
|
2829
|
+
match: ElementUtils.isRootBlock,
|
|
2830
|
+
split: false
|
|
2831
|
+
}),
|
|
2832
|
+
getValue: (editor) => getValue$1(editor),
|
|
2833
|
+
getElementValue: (element) => {
|
|
2834
|
+
return ElementUtils.isRootBlock(element) ? element.textAlign : void 0;
|
|
2835
|
+
}
|
|
2836
|
+
},
|
|
2837
|
+
withPlugin: withTextAlign,
|
|
2838
|
+
renderElement: (renderElement, className) => (props) => {
|
|
2839
|
+
return renderElement(__spreadProps(__spreadValues({}, props), {
|
|
2840
|
+
element: __spreadProps(__spreadValues({}, props.element), {
|
|
2841
|
+
className
|
|
2842
|
+
})
|
|
2843
|
+
}));
|
|
2844
|
+
}
|
|
2845
|
+
});
|
|
2846
|
+
}
|
|
2847
|
+
function setBlockKeyForDevice(editor, breakpoints, deviceId, key, value, options) {
|
|
2848
|
+
var _a2, _b;
|
|
2849
|
+
const at = (_a2 = options == null ? void 0 : options.at) != null ? _a2 : editor.selection;
|
|
2850
|
+
if (!at)
|
|
2851
|
+
return;
|
|
2852
|
+
const rootElements = getBlocksInSelection(editor);
|
|
2853
|
+
for (const [node, path] of rootElements) {
|
|
2854
|
+
if (ElementUtils.isBlock(node)) {
|
|
2855
|
+
const deviceValues = (_b = node[key]) != null ? _b : [];
|
|
2856
|
+
const currentDeviceValue = findBreakpointOverride(breakpoints, deviceValues, deviceId, (v) => v);
|
|
2857
|
+
const nextDeviceValue = __spreadProps(__spreadValues({}, currentDeviceValue), {
|
|
2858
|
+
deviceId,
|
|
2859
|
+
value
|
|
2860
|
+
});
|
|
2861
|
+
Transforms.setNodes(editor, {
|
|
2862
|
+
[key]: [...deviceValues.filter((v) => v.deviceId !== deviceId), nextDeviceValue]
|
|
2863
|
+
}, { at: path });
|
|
2864
|
+
}
|
|
2865
|
+
}
|
|
2866
|
+
}
|
|
2867
|
+
function clearBlockKeyForDevice(editor, deviceId, key) {
|
|
2868
|
+
var _a2;
|
|
2869
|
+
const rootElements = getBlocksInSelection(editor);
|
|
2870
|
+
for (const [node, path] of rootElements) {
|
|
2871
|
+
if (ElementUtils.isBlock(node)) {
|
|
2872
|
+
const deviceOverrides = (_a2 = node[key]) != null ? _a2 : [];
|
|
2873
|
+
Transforms.setNodes(editor, {
|
|
2874
|
+
[key]: deviceOverrides.filter((v) => v.deviceId !== deviceId)
|
|
2875
|
+
}, { at: path });
|
|
2876
|
+
}
|
|
2877
|
+
}
|
|
2878
|
+
}
|
|
2879
|
+
const EditorUtils = {
|
|
2880
|
+
getFirstAncestorList(editor, path) {
|
|
2881
|
+
try {
|
|
2882
|
+
const parentList = Editor.above(editor, {
|
|
2883
|
+
at: path,
|
|
2884
|
+
match: (node) => ElementUtils.isList(node)
|
|
2885
|
+
});
|
|
2886
|
+
return parentList != null ? parentList : null;
|
|
2887
|
+
} catch (e) {
|
|
2888
|
+
return null;
|
|
2889
|
+
}
|
|
2890
|
+
},
|
|
2891
|
+
getFirstAncestorListItem(editor, path) {
|
|
2892
|
+
try {
|
|
2893
|
+
const parentListItem = Editor.above(editor, {
|
|
2894
|
+
at: path,
|
|
2895
|
+
match: (node) => ElementUtils.isListItem(node)
|
|
2896
|
+
});
|
|
2897
|
+
return parentListItem != null ? parentListItem : null;
|
|
2898
|
+
} catch (e) {
|
|
2899
|
+
return null;
|
|
2900
|
+
}
|
|
2901
|
+
}
|
|
2902
|
+
};
|
|
2903
|
+
const LIST_ITEM_CHILD_POSITION = 0;
|
|
2904
|
+
const LIST_ITEM_LIST_POSITION = 1;
|
|
2905
|
+
function unwrapPath(editor, listItemPath) {
|
|
2906
|
+
const parentList = EditorUtils.getFirstAncestorList(editor, listItemPath);
|
|
2907
|
+
const listItemContainingParentList = EditorUtils.getFirstAncestorListItem(editor, listItemPath);
|
|
2908
|
+
if (!parentList || listItemContainingParentList)
|
|
2909
|
+
return;
|
|
2910
|
+
Editor.withoutNormalizing(editor, () => {
|
|
2911
|
+
const listItemTextPath = [...listItemPath, LIST_ITEM_CHILD_POSITION];
|
|
2912
|
+
const listItemNestedListPath = [...listItemPath, LIST_ITEM_LIST_POSITION];
|
|
2913
|
+
if (Node.has(editor, listItemNestedListPath)) {
|
|
2914
|
+
Transforms.setNodes(editor, { type: parentList[0].type }, { at: listItemNestedListPath });
|
|
2915
|
+
Transforms.liftNodes(editor, { at: listItemNestedListPath });
|
|
2916
|
+
Transforms.liftNodes(editor, { at: Path.next(listItemPath) });
|
|
2917
|
+
}
|
|
2918
|
+
if (Node.has(editor, listItemTextPath)) {
|
|
2919
|
+
Transforms.setNodes(editor, { type: BlockType.Paragraph }, {
|
|
2920
|
+
at: listItemTextPath
|
|
2921
|
+
});
|
|
2922
|
+
Transforms.liftNodes(editor, { at: listItemTextPath });
|
|
2923
|
+
Transforms.liftNodes(editor, { at: listItemPath });
|
|
2924
|
+
}
|
|
2925
|
+
});
|
|
2926
|
+
}
|
|
2927
|
+
function unwrapList(editor, options) {
|
|
2928
|
+
var _a2;
|
|
2929
|
+
const at = (_a2 = options == null ? void 0 : options.at) != null ? _a2 : editor.selection;
|
|
2930
|
+
if (!at)
|
|
2931
|
+
return;
|
|
2932
|
+
const listItems = Array.from(Editor.nodes(editor, {
|
|
2933
|
+
at,
|
|
2934
|
+
match: (node) => {
|
|
2935
|
+
return Element.isElement(node) && ElementUtils.isListItem(node);
|
|
2936
|
+
}
|
|
2937
|
+
}));
|
|
2938
|
+
const subRoots = filterForSubtreeRoots(listItems);
|
|
2939
|
+
const refs = subRoots.map(([_, path]) => Editor.pathRef(editor, path));
|
|
2940
|
+
refs.forEach((ref) => {
|
|
2941
|
+
if (ref.current) {
|
|
2942
|
+
unwrapPath(editor, ref.current);
|
|
2943
|
+
}
|
|
2944
|
+
ref.unref();
|
|
2945
|
+
});
|
|
2946
|
+
}
|
|
2947
|
+
function wrapList(editor, options = { type: BlockType.UnorderedList }) {
|
|
2948
|
+
var _a2;
|
|
2949
|
+
const at = (_a2 = options.at) != null ? _a2 : editor.selection;
|
|
2950
|
+
if (!at)
|
|
2951
|
+
return;
|
|
2952
|
+
const nonListEntries = Array.from(Editor.nodes(editor, {
|
|
2953
|
+
at,
|
|
2954
|
+
match: (node) => {
|
|
2955
|
+
return Element.isElement(node) && ElementUtils.isConvertibleToListTextNode(node);
|
|
2956
|
+
}
|
|
2957
|
+
}));
|
|
2958
|
+
const refs = nonListEntries.map(([_, path]) => Editor.pathRef(editor, path));
|
|
2959
|
+
refs.forEach((ref) => {
|
|
2960
|
+
const path = ref.current;
|
|
2961
|
+
if (path) {
|
|
2962
|
+
Editor.withoutNormalizing(editor, () => {
|
|
2963
|
+
Transforms.setNodes(editor, { type: BlockType.ListItemChild }, {
|
|
2964
|
+
at: path
|
|
2965
|
+
});
|
|
2966
|
+
Transforms.wrapNodes(editor, ElementUtils.createListItem(), {
|
|
2967
|
+
match: (node) => ElementUtils.isListItemChild(node),
|
|
2968
|
+
at: path
|
|
2969
|
+
});
|
|
2970
|
+
Transforms.wrapNodes(editor, ElementUtils.createList(options.type), {
|
|
2971
|
+
at: path
|
|
2972
|
+
});
|
|
2973
|
+
});
|
|
2974
|
+
}
|
|
2975
|
+
ref.unref();
|
|
2976
|
+
});
|
|
2977
|
+
}
|
|
2978
|
+
const LocationUtils = {
|
|
2979
|
+
getStartPath(location) {
|
|
2980
|
+
if (Range.isRange(location))
|
|
2981
|
+
return Range.start(location).path;
|
|
2982
|
+
if (Point.isPoint(location))
|
|
2983
|
+
return location.path;
|
|
2984
|
+
return location;
|
|
2985
|
+
}
|
|
2986
|
+
};
|
|
2987
|
+
function getSelectedListItems(editor) {
|
|
2988
|
+
var _a2, _b;
|
|
2989
|
+
if (!editor.selection)
|
|
2990
|
+
return [];
|
|
2991
|
+
const start = LocationUtils.getStartPath(editor.selection);
|
|
2992
|
+
const listItems = Editor.nodes(editor, {
|
|
2993
|
+
at: editor.selection,
|
|
2994
|
+
match: (node) => ElementUtils.isListItem(node)
|
|
2995
|
+
});
|
|
2996
|
+
const firstAncestorPath = (_b = (_a2 = EditorUtils.getFirstAncestorListItem(editor, start)) == null ? void 0 : _a2[1]) != null ? _b : [];
|
|
2997
|
+
return Array.from(listItems).filter((node) => Path.isDescendant(start, node[1]) ? Path.equals(node[1], firstAncestorPath) : !Path.isAfter(start, node[1]));
|
|
2998
|
+
}
|
|
2999
|
+
function indentPath(editor, path) {
|
|
3000
|
+
const parent = Node.parent(editor, path);
|
|
3001
|
+
if (!path || !Path.hasPrevious(path) || !ElementUtils.isList(parent))
|
|
3002
|
+
return;
|
|
3003
|
+
const previosPath = Path.previous(path);
|
|
3004
|
+
const previousChildListPath = [...previosPath, LIST_ITEM_LIST_POSITION];
|
|
3005
|
+
const previousHasChildList = Node.has(editor, previousChildListPath);
|
|
3006
|
+
Editor.withoutNormalizing(editor, () => {
|
|
3007
|
+
if (!previousHasChildList) {
|
|
3008
|
+
Transforms.insertNodes(editor, ElementUtils.createList(parent.type), {
|
|
3009
|
+
at: previousChildListPath
|
|
3010
|
+
});
|
|
3011
|
+
}
|
|
3012
|
+
const previousChildList = Node.get(editor, previousChildListPath);
|
|
3013
|
+
if (ElementUtils.isList(previousChildList)) {
|
|
3014
|
+
const index = previousHasChildList ? previousChildList.children.length : 0;
|
|
3015
|
+
Transforms.moveNodes(editor, {
|
|
3016
|
+
at: path,
|
|
3017
|
+
to: [...previousChildListPath, index]
|
|
3018
|
+
});
|
|
3019
|
+
}
|
|
3020
|
+
});
|
|
3021
|
+
}
|
|
3022
|
+
function indent(editor) {
|
|
3023
|
+
if (!editor.selection)
|
|
3024
|
+
return;
|
|
3025
|
+
const listItems = getSelectedListItems(editor);
|
|
3026
|
+
const subRoots = filterForSubtreeRoots(listItems);
|
|
3027
|
+
const refs = subRoots.map(([_, path]) => Editor.pathRef(editor, path));
|
|
3028
|
+
refs.forEach((ref) => {
|
|
3029
|
+
if (ref.current) {
|
|
3030
|
+
indentPath(editor, ref.current);
|
|
3031
|
+
}
|
|
3032
|
+
ref.unref();
|
|
3033
|
+
});
|
|
3034
|
+
}
|
|
3035
|
+
function dedentPath(editor, listItemPath) {
|
|
3036
|
+
const parentList = EditorUtils.getFirstAncestorList(editor, listItemPath);
|
|
3037
|
+
const listItemContainingParentList = EditorUtils.getFirstAncestorListItem(editor, listItemPath);
|
|
3038
|
+
if (!parentList || !listItemContainingParentList)
|
|
3039
|
+
return;
|
|
3040
|
+
const [parentListNode, parentListPath] = parentList;
|
|
3041
|
+
const [_, listItemContainingParentListPath] = listItemContainingParentList;
|
|
3042
|
+
const listItemPosition = listItemPath[listItemPath.length - 1];
|
|
3043
|
+
const previousSiblings = parentListNode.children.slice(0, listItemPosition);
|
|
3044
|
+
const nextSiblings = parentListNode.children.slice(listItemPosition + 1);
|
|
3045
|
+
Editor.withoutNormalizing(editor, () => {
|
|
3046
|
+
nextSiblings.forEach(() => {
|
|
3047
|
+
const nextSiblingPath = [...parentListPath, listItemPosition + 1];
|
|
3048
|
+
indentPath(editor, nextSiblingPath);
|
|
3049
|
+
});
|
|
3050
|
+
Transforms.moveNodes(editor, {
|
|
3051
|
+
at: listItemPath,
|
|
3052
|
+
to: Path.next(listItemContainingParentListPath)
|
|
3053
|
+
});
|
|
3054
|
+
if (previousSiblings.length === 0) {
|
|
3055
|
+
Transforms.removeNodes(editor, { at: parentListPath });
|
|
3056
|
+
}
|
|
3057
|
+
});
|
|
3058
|
+
}
|
|
3059
|
+
function dedent(editor) {
|
|
3060
|
+
if (!editor.selection)
|
|
3061
|
+
return;
|
|
3062
|
+
const listItems = getSelectedListItems(editor);
|
|
3063
|
+
const subRoots = filterForSubtreeRoots(listItems);
|
|
3064
|
+
const refs = subRoots.map(([_, path]) => Editor.pathRef(editor, path));
|
|
3065
|
+
refs.forEach((ref) => {
|
|
3066
|
+
if (ref.current) {
|
|
3067
|
+
dedentPath(editor, ref.current);
|
|
3068
|
+
}
|
|
3069
|
+
ref.unref();
|
|
3070
|
+
});
|
|
3071
|
+
}
|
|
3072
|
+
function toggleList(editor, options = { type: BlockType.UnorderedList }) {
|
|
3073
|
+
var _a2;
|
|
3074
|
+
const at = (_a2 = options.at) != null ? _a2 : editor.selection;
|
|
3075
|
+
if (at == null)
|
|
3076
|
+
return;
|
|
3077
|
+
const start = LocationUtils.getStartPath(at);
|
|
3078
|
+
const ancestorPath = Path.ancestors(start).at(1);
|
|
3079
|
+
if (!ancestorPath || !Node.has(editor, ancestorPath))
|
|
3080
|
+
return;
|
|
3081
|
+
const ancestor = Node.get(editor, ancestorPath);
|
|
3082
|
+
if (!ElementUtils.isList(ancestor)) {
|
|
3083
|
+
return wrapList(editor, { type: options.type, at });
|
|
3084
|
+
}
|
|
3085
|
+
if (ancestor.type === options.type) {
|
|
3086
|
+
unwrapList(editor, { at });
|
|
3087
|
+
} else {
|
|
3088
|
+
Transforms.setNodes(editor, { type: options.type }, { at: ancestorPath });
|
|
3089
|
+
}
|
|
3090
|
+
}
|
|
3091
|
+
const BlockActions = {
|
|
3092
|
+
setBlockKeyForDevice,
|
|
3093
|
+
clearBlockKeyForDevice,
|
|
3094
|
+
wrapInline,
|
|
3095
|
+
unwrapInline
|
|
3096
|
+
};
|
|
3097
|
+
const ListActions = {
|
|
3098
|
+
unwrapList,
|
|
3099
|
+
wrapList,
|
|
3100
|
+
indent,
|
|
3101
|
+
dedent,
|
|
3102
|
+
toggleList
|
|
3103
|
+
};
|
|
3104
|
+
function onKeyDown(e, editor) {
|
|
3105
|
+
if (!editor.selection || Array.from(Editor.nodes(editor, {
|
|
3106
|
+
match: (node) => ElementUtils.isListItem(node)
|
|
3107
|
+
})).length === 0)
|
|
3108
|
+
return;
|
|
3109
|
+
if (isHotkey("shift+tab", e)) {
|
|
3110
|
+
e.preventDefault();
|
|
3111
|
+
ListActions.dedent(editor);
|
|
3112
|
+
}
|
|
3113
|
+
if (isHotkey("tab", e)) {
|
|
3114
|
+
e.preventDefault();
|
|
3115
|
+
ListActions.indent(editor);
|
|
3116
|
+
}
|
|
3117
|
+
if (isHotkey("backspace", e)) {
|
|
3118
|
+
if (!editor.selection)
|
|
3119
|
+
return;
|
|
3120
|
+
if (Range.isExpanded(editor.selection))
|
|
3121
|
+
return;
|
|
3122
|
+
const listItem = EditorUtils.getFirstAncestorListItem(editor, editor.selection.anchor.path);
|
|
3123
|
+
if (editor.selection.anchor.offset === 0 && listItem) {
|
|
3124
|
+
e.preventDefault();
|
|
3125
|
+
const parentListItem = EditorUtils.getFirstAncestorListItem(editor, listItem[1]);
|
|
3126
|
+
const list = EditorUtils.getFirstAncestorList(editor, listItem[1]);
|
|
3127
|
+
if (parentListItem) {
|
|
3128
|
+
ListActions.dedent(editor);
|
|
3129
|
+
} else if (list) {
|
|
3130
|
+
ListActions.unwrapList(editor);
|
|
3131
|
+
}
|
|
3132
|
+
return;
|
|
3133
|
+
}
|
|
3134
|
+
}
|
|
3135
|
+
if (isHotkey("enter", e)) {
|
|
3136
|
+
e.preventDefault();
|
|
3137
|
+
if (!editor.selection)
|
|
3138
|
+
return;
|
|
3139
|
+
if (Range.isExpanded(editor.selection)) {
|
|
3140
|
+
Transforms.delete(editor);
|
|
3141
|
+
return;
|
|
3142
|
+
}
|
|
3143
|
+
const listItem = EditorUtils.getFirstAncestorListItem(editor, editor.selection.anchor.path);
|
|
3144
|
+
if (editor.selection.anchor.offset === 0 && listItem && Editor.string(editor, listItem[1]) === "") {
|
|
3145
|
+
const parentListItem = EditorUtils.getFirstAncestorListItem(editor, listItem[1]);
|
|
3146
|
+
if (parentListItem) {
|
|
3147
|
+
ListActions.dedent(editor);
|
|
3148
|
+
} else {
|
|
3149
|
+
ListActions.unwrapList(editor);
|
|
3150
|
+
}
|
|
3151
|
+
return;
|
|
3152
|
+
}
|
|
3153
|
+
Transforms.splitNodes(editor, {
|
|
3154
|
+
at: editor.selection,
|
|
3155
|
+
always: true,
|
|
3156
|
+
match: (node) => ElementUtils.isListItem(node)
|
|
3157
|
+
});
|
|
3158
|
+
}
|
|
3159
|
+
if (isHotkey("shift+enter", e)) {
|
|
3160
|
+
e.preventDefault();
|
|
3161
|
+
editor.insertText("\n");
|
|
3162
|
+
}
|
|
3163
|
+
}
|
|
3164
|
+
function withBlock(editor) {
|
|
3165
|
+
const {
|
|
3166
|
+
normalizeNode
|
|
3167
|
+
} = editor;
|
|
3168
|
+
editor.isInline = (entry) => {
|
|
3169
|
+
return ElementUtils.isInline(entry);
|
|
3170
|
+
};
|
|
3171
|
+
editor.normalizeNode = (entry) => {
|
|
3172
|
+
var _a2;
|
|
3173
|
+
const [normalizationNode, normalizationPath] = entry;
|
|
3174
|
+
if (ElementUtils.isBlock(normalizationNode) && ((_a2 = normalizationNode == null ? void 0 : normalizationNode.textAlign) == null ? void 0 : _a2.length) == 0) {
|
|
3175
|
+
Transforms.unsetNodes(editor, "textAlign", {
|
|
3176
|
+
at: normalizationPath
|
|
3177
|
+
});
|
|
3178
|
+
return;
|
|
3179
|
+
}
|
|
3180
|
+
if (ElementUtils.isListItem(normalizationNode)) {
|
|
3181
|
+
const pathToListItemText = [...normalizationPath, LIST_ITEM_CHILD_POSITION];
|
|
3182
|
+
if (Node.has(editor, pathToListItemText)) {
|
|
3183
|
+
const nodeInListItemTextPosition = Node.get(editor, pathToListItemText);
|
|
3184
|
+
if (ElementUtils.isRootBlock(nodeInListItemTextPosition)) {
|
|
3185
|
+
Transforms.setNodes(editor, {
|
|
3186
|
+
type: BlockType.ListItemChild
|
|
3187
|
+
}, {
|
|
3188
|
+
at: pathToListItemText
|
|
3189
|
+
});
|
|
3190
|
+
return;
|
|
3191
|
+
}
|
|
3192
|
+
} else {
|
|
3193
|
+
Transforms.insertNodes(editor, ElementUtils.createListItem(), {
|
|
3194
|
+
at: pathToListItemText
|
|
3195
|
+
});
|
|
3196
|
+
return;
|
|
3197
|
+
}
|
|
3198
|
+
}
|
|
3199
|
+
if (!Text.isText(normalizationNode)) {
|
|
3200
|
+
const mergeableChildren = Array.from(Node.children(editor, normalizationPath)).map((child, index, children) => {
|
|
3201
|
+
const potentialNodeToBeMerged = children.at(index + 1);
|
|
3202
|
+
if (!potentialNodeToBeMerged || !ElementUtils.isList(potentialNodeToBeMerged[0]) || !ElementUtils.isList(child[0]) || potentialNodeToBeMerged[0].type !== child[0].type) {
|
|
3203
|
+
return null;
|
|
3204
|
+
}
|
|
3205
|
+
return [Editor.pathRef(editor, child[1]), Editor.pathRef(editor, potentialNodeToBeMerged[1])];
|
|
3206
|
+
}).filter((mergeableNodes) => Boolean(mergeableNodes));
|
|
3207
|
+
if (mergeableChildren.length !== 0) {
|
|
3208
|
+
mergeableChildren.reverse().forEach(([nodePathRef, nodeToBeMergedPathRef]) => {
|
|
3209
|
+
const nodePath = nodePathRef.current;
|
|
3210
|
+
const nodeToBeMergedPath = nodeToBeMergedPathRef.current;
|
|
3211
|
+
if (nodePath == null || nodeToBeMergedPath == null)
|
|
3212
|
+
return;
|
|
3213
|
+
const nodeChildren = Array.from(Node.children(editor, nodePath));
|
|
3214
|
+
const childrenToBeMerged = Array.from(Node.children(editor, nodeToBeMergedPath));
|
|
3215
|
+
Editor.withoutNormalizing(editor, () => {
|
|
3216
|
+
childrenToBeMerged.reverse().forEach(([_, childPath]) => {
|
|
3217
|
+
Transforms.moveNodes(editor, {
|
|
3218
|
+
at: childPath,
|
|
3219
|
+
to: [...nodePath, nodeChildren.length]
|
|
3220
|
+
});
|
|
3221
|
+
});
|
|
3222
|
+
Transforms.removeNodes(editor, {
|
|
3223
|
+
at: nodeToBeMergedPath
|
|
3224
|
+
});
|
|
3225
|
+
});
|
|
3226
|
+
nodePathRef.unref();
|
|
3227
|
+
nodeToBeMergedPathRef.unref();
|
|
3228
|
+
});
|
|
3229
|
+
return;
|
|
3230
|
+
}
|
|
3231
|
+
}
|
|
3232
|
+
normalizeNode(entry);
|
|
3233
|
+
};
|
|
3234
|
+
return editor;
|
|
3235
|
+
}
|
|
3236
|
+
const definition = Select({
|
|
3237
|
+
label: "Block",
|
|
3238
|
+
labelOrientation: "horizontal",
|
|
3239
|
+
options: [{
|
|
3240
|
+
value: BlockType.Paragraph,
|
|
3241
|
+
label: "Paragraph"
|
|
3242
|
+
}, {
|
|
3243
|
+
value: BlockType.Heading1,
|
|
3244
|
+
label: "Heading 1"
|
|
3245
|
+
}, {
|
|
3246
|
+
value: BlockType.Heading2,
|
|
3247
|
+
label: "Heading 2"
|
|
3248
|
+
}, {
|
|
3249
|
+
value: BlockType.Heading3,
|
|
3250
|
+
label: "Heading 3"
|
|
3251
|
+
}, {
|
|
3252
|
+
value: BlockType.Heading4,
|
|
3253
|
+
label: "Heading 4"
|
|
3254
|
+
}, {
|
|
3255
|
+
value: BlockType.Heading5,
|
|
3256
|
+
label: "Heading 5"
|
|
3257
|
+
}, {
|
|
3258
|
+
value: BlockType.Heading6,
|
|
3259
|
+
label: "Heading 6"
|
|
3260
|
+
}, {
|
|
3261
|
+
value: BlockType.UnorderedList,
|
|
3262
|
+
label: "Bulleted list"
|
|
3263
|
+
}, {
|
|
3264
|
+
value: BlockType.OrderedList,
|
|
3265
|
+
label: "Numbered list"
|
|
3266
|
+
}, {
|
|
3267
|
+
value: BlockType.BlockQuote,
|
|
3268
|
+
label: "Quote"
|
|
3269
|
+
}],
|
|
3270
|
+
defaultValue: BlockType.Paragraph
|
|
3271
|
+
});
|
|
3272
|
+
function BlockPlugin() {
|
|
3273
|
+
return createRichTextV2Plugin({
|
|
3274
|
+
withPlugin: withBlock,
|
|
3275
|
+
onKeyDown,
|
|
3276
|
+
control: {
|
|
3277
|
+
definition,
|
|
3278
|
+
onChange: (editor, value) => {
|
|
3279
|
+
const activeBlockType = getActiveBlockType(editor);
|
|
3280
|
+
if (value === BlockType.UnorderedList || value === BlockType.OrderedList) {
|
|
3281
|
+
ListActions.toggleList(editor, {
|
|
3282
|
+
type: value,
|
|
3283
|
+
at: getSelection(editor)
|
|
3284
|
+
});
|
|
3285
|
+
} else if (activeBlockType === value) {
|
|
3286
|
+
Transforms.setNodes(editor, {
|
|
3287
|
+
type: BlockType.Default
|
|
3288
|
+
}, {
|
|
3289
|
+
at: getSelection(editor)
|
|
3290
|
+
});
|
|
3291
|
+
} else {
|
|
3292
|
+
ListActions.unwrapList(editor, {
|
|
3293
|
+
at: getSelection(editor)
|
|
3294
|
+
});
|
|
3295
|
+
Transforms.setNodes(editor, {
|
|
3296
|
+
type: value != null ? value : BlockType.Default
|
|
3297
|
+
}, {
|
|
3298
|
+
at: getSelection(editor)
|
|
3299
|
+
});
|
|
3300
|
+
}
|
|
3301
|
+
},
|
|
3302
|
+
getValue: (editor) => {
|
|
3303
|
+
const activeBlock = getActiveBlockType(editor);
|
|
3304
|
+
if (activeBlock === RootBlockType.Default)
|
|
3305
|
+
return void 0;
|
|
3306
|
+
return activeBlock;
|
|
3307
|
+
}
|
|
3308
|
+
},
|
|
3309
|
+
renderElement: (renderElement) => (props) => /* @__PURE__ */ jsx(BlockPluginComponent, __spreadProps(__spreadValues({}, props), {
|
|
3310
|
+
renderElement
|
|
3311
|
+
}))
|
|
3312
|
+
});
|
|
3313
|
+
}
|
|
3314
|
+
function BlockPluginComponent(_d) {
|
|
3315
|
+
var _e = _d, {
|
|
3316
|
+
renderElement
|
|
3317
|
+
} = _e, props = __objRest(_e, [
|
|
3318
|
+
"renderElement"
|
|
3319
|
+
]);
|
|
3320
|
+
const blockStyles = [useStyle({
|
|
3321
|
+
margin: 0
|
|
3322
|
+
}), props.element.className];
|
|
3323
|
+
const quoteStyles = useStyle({
|
|
3324
|
+
padding: "0.5em 10px",
|
|
3325
|
+
fontSize: "1.25em",
|
|
3326
|
+
fontWeight: "300",
|
|
3327
|
+
borderLeft: "5px solid rgba(0, 0, 0, 0.1)"
|
|
3328
|
+
});
|
|
3329
|
+
const unorderedListStyles = useStyle({
|
|
3330
|
+
listStylePosition: "inside",
|
|
3331
|
+
paddingInlineStart: "20px",
|
|
3332
|
+
listStyleType: "disc",
|
|
3333
|
+
ul: {
|
|
3334
|
+
listStyleType: "circle"
|
|
3335
|
+
},
|
|
3336
|
+
"ul ul": {
|
|
3337
|
+
listStyleType: "square"
|
|
3338
|
+
}
|
|
3339
|
+
});
|
|
3340
|
+
const orderedListStyles = useStyle({
|
|
3341
|
+
listStylePosition: "inside",
|
|
3342
|
+
paddingInlineStart: "20px",
|
|
3343
|
+
listStyleType: "decimal"
|
|
3344
|
+
});
|
|
3345
|
+
switch (props.element.type) {
|
|
3346
|
+
case BlockType.Default:
|
|
3347
|
+
case BlockType.Paragraph:
|
|
3348
|
+
return /* @__PURE__ */ jsx("p", __spreadProps(__spreadValues({}, props.attributes), {
|
|
3349
|
+
className: cx(...blockStyles),
|
|
3350
|
+
children: renderElement(props)
|
|
3351
|
+
}));
|
|
3352
|
+
case BlockType.Heading1:
|
|
3353
|
+
return /* @__PURE__ */ jsx("h1", __spreadProps(__spreadValues({}, props.attributes), {
|
|
3354
|
+
className: cx(...blockStyles),
|
|
3355
|
+
children: renderElement(props)
|
|
3356
|
+
}));
|
|
3357
|
+
case BlockType.Heading2:
|
|
3358
|
+
return /* @__PURE__ */ jsx("h2", __spreadProps(__spreadValues({}, props.attributes), {
|
|
3359
|
+
className: cx(...blockStyles),
|
|
3360
|
+
children: renderElement(props)
|
|
3361
|
+
}));
|
|
3362
|
+
case BlockType.Heading3:
|
|
3363
|
+
return /* @__PURE__ */ jsx("h3", __spreadProps(__spreadValues({}, props.attributes), {
|
|
3364
|
+
className: cx(...blockStyles),
|
|
3365
|
+
children: renderElement(props)
|
|
3366
|
+
}));
|
|
3367
|
+
case BlockType.Heading4:
|
|
3368
|
+
return /* @__PURE__ */ jsx("h4", __spreadProps(__spreadValues({}, props.attributes), {
|
|
3369
|
+
className: cx(...blockStyles),
|
|
3370
|
+
children: renderElement(props)
|
|
3371
|
+
}));
|
|
3372
|
+
case BlockType.Heading5:
|
|
3373
|
+
return /* @__PURE__ */ jsx("h5", __spreadProps(__spreadValues({}, props.attributes), {
|
|
3374
|
+
className: cx(...blockStyles),
|
|
3375
|
+
children: renderElement(props)
|
|
3376
|
+
}));
|
|
3377
|
+
case BlockType.Heading6:
|
|
3378
|
+
return /* @__PURE__ */ jsx("h6", __spreadProps(__spreadValues({}, props.attributes), {
|
|
3379
|
+
className: cx(...blockStyles),
|
|
3380
|
+
children: renderElement(props)
|
|
3381
|
+
}));
|
|
3382
|
+
case BlockType.BlockQuote:
|
|
3383
|
+
return /* @__PURE__ */ jsx("blockquote", __spreadProps(__spreadValues({}, props.attributes), {
|
|
3384
|
+
className: cx(...blockStyles, quoteStyles),
|
|
3385
|
+
children: renderElement(props)
|
|
3386
|
+
}));
|
|
3387
|
+
case BlockType.OrderedList:
|
|
3388
|
+
return /* @__PURE__ */ jsx("ol", __spreadProps(__spreadValues({}, props.attributes), {
|
|
3389
|
+
className: cx(...blockStyles, orderedListStyles),
|
|
3390
|
+
children: renderElement(props)
|
|
3391
|
+
}));
|
|
3392
|
+
case BlockType.UnorderedList:
|
|
3393
|
+
return /* @__PURE__ */ jsx("ul", __spreadProps(__spreadValues({}, props.attributes), {
|
|
3394
|
+
className: cx(...blockStyles, unorderedListStyles),
|
|
3395
|
+
children: renderElement(props)
|
|
3396
|
+
}));
|
|
3397
|
+
case BlockType.ListItem:
|
|
3398
|
+
return /* @__PURE__ */ jsx("li", __spreadProps(__spreadValues({}, props.attributes), {
|
|
3399
|
+
className: cx(...blockStyles),
|
|
3400
|
+
children: renderElement(props)
|
|
3401
|
+
}));
|
|
3402
|
+
case BlockType.ListItemChild:
|
|
3403
|
+
return /* @__PURE__ */ jsx("span", __spreadProps(__spreadValues({}, props.attributes), {
|
|
3404
|
+
className: cx(...blockStyles),
|
|
3405
|
+
children: renderElement(props)
|
|
3406
|
+
}));
|
|
3407
|
+
default:
|
|
3408
|
+
return /* @__PURE__ */ jsx(Fragment, {
|
|
3409
|
+
children: renderElement(props)
|
|
3410
|
+
});
|
|
3411
|
+
}
|
|
3412
|
+
}
|
|
3413
|
+
function clearActiveTypographyStyle(editor, options) {
|
|
3414
|
+
Editor.withoutNormalizing(editor, () => {
|
|
3415
|
+
var _a2;
|
|
3416
|
+
const at = (_a2 = options == null ? void 0 : options.at) != null ? _a2 : editor.selection;
|
|
3417
|
+
if (!at)
|
|
3418
|
+
return;
|
|
3419
|
+
const atRef = Editor.rangeRef(editor, at);
|
|
3420
|
+
if (atRef.current) {
|
|
3421
|
+
Transforms.setNodes(editor, {
|
|
3422
|
+
slice: true
|
|
3423
|
+
}, {
|
|
3424
|
+
at: atRef.current,
|
|
3425
|
+
match: (node) => Text.isText(node),
|
|
3426
|
+
split: Range.isExpanded(atRef.current)
|
|
3427
|
+
});
|
|
3428
|
+
}
|
|
3429
|
+
if (atRef.current) {
|
|
3430
|
+
const textNodes = Array.from(Editor.nodes(editor, {
|
|
3431
|
+
at: atRef.current,
|
|
3432
|
+
match: (node) => Text.isText(node) && node.slice === true
|
|
3433
|
+
}));
|
|
3434
|
+
for (const [node, path] of textNodes) {
|
|
3435
|
+
if (Text.isText(node)) {
|
|
3436
|
+
const typography = __spreadProps(__spreadValues({}, node.typography), {
|
|
3437
|
+
style: []
|
|
3438
|
+
});
|
|
3439
|
+
Transforms.setNodes(editor, {
|
|
3440
|
+
typography
|
|
3441
|
+
}, { at: path });
|
|
3442
|
+
}
|
|
3443
|
+
}
|
|
3444
|
+
}
|
|
3445
|
+
atRef.unref();
|
|
3446
|
+
});
|
|
3447
|
+
}
|
|
3448
|
+
function clearDeviceActiveTypography(editor, currentDeviceId, options) {
|
|
3449
|
+
Editor.withoutNormalizing(editor, () => {
|
|
3450
|
+
var _a2, _b, _c;
|
|
3451
|
+
const at = (_a2 = options == null ? void 0 : options.at) != null ? _a2 : editor.selection;
|
|
3452
|
+
if (!at)
|
|
3453
|
+
return;
|
|
3454
|
+
const atRef = Editor.rangeRef(editor, at);
|
|
3455
|
+
if (atRef.current) {
|
|
3456
|
+
Transforms.setNodes(editor, {
|
|
3457
|
+
slice: true
|
|
3458
|
+
}, {
|
|
3459
|
+
at: atRef.current,
|
|
3460
|
+
match: (node) => Text.isText(node),
|
|
3461
|
+
split: Range.isExpanded(atRef.current)
|
|
3462
|
+
});
|
|
3463
|
+
}
|
|
3464
|
+
if (atRef.current) {
|
|
3465
|
+
const textNodes = Array.from(Editor.nodes(editor, {
|
|
3466
|
+
at: atRef.current,
|
|
3467
|
+
match: (node) => Text.isText(node) && node.slice === true
|
|
3468
|
+
}));
|
|
3469
|
+
for (const [node, path] of textNodes) {
|
|
3470
|
+
if (Text.isText(node)) {
|
|
3471
|
+
const typography = __spreadProps(__spreadValues({}, node.typography), {
|
|
3472
|
+
style: (_c = (_b = node == null ? void 0 : node.typography) == null ? void 0 : _b.style.filter(({ deviceId }) => deviceId !== currentDeviceId)) != null ? _c : []
|
|
3473
|
+
});
|
|
3474
|
+
Transforms.setNodes(editor, {
|
|
3475
|
+
typography
|
|
3476
|
+
}, { at: path });
|
|
3477
|
+
}
|
|
3478
|
+
}
|
|
3479
|
+
}
|
|
3480
|
+
atRef.unref();
|
|
3481
|
+
});
|
|
3482
|
+
}
|
|
3483
|
+
function detachActiveTypography(editor, value, options) {
|
|
3484
|
+
Editor.withoutNormalizing(editor, () => {
|
|
3485
|
+
var _a2;
|
|
3486
|
+
const at = (_a2 = options == null ? void 0 : options.at) != null ? _a2 : editor.selection;
|
|
3487
|
+
if (!at)
|
|
3488
|
+
return;
|
|
3489
|
+
const atRef = Editor.rangeRef(editor, at);
|
|
3490
|
+
if (atRef.current) {
|
|
3491
|
+
Transforms.setNodes(editor, {
|
|
3492
|
+
slice: true
|
|
3493
|
+
}, {
|
|
3494
|
+
at: atRef.current,
|
|
3495
|
+
match: (node) => Text.isText(node),
|
|
3496
|
+
split: Range.isExpanded(atRef.current)
|
|
3497
|
+
});
|
|
3498
|
+
}
|
|
3499
|
+
if (atRef.current) {
|
|
3500
|
+
const textNodes = Array.from(Editor.nodes(editor, {
|
|
3501
|
+
at: atRef.current,
|
|
3502
|
+
match: (node) => Text.isText(node) && node.slice === true
|
|
3503
|
+
}));
|
|
3504
|
+
for (const [node, path] of textNodes) {
|
|
3505
|
+
if (Text.isText(node)) {
|
|
3506
|
+
Transforms.setNodes(editor, {
|
|
3507
|
+
typography: {
|
|
3508
|
+
style: value
|
|
3509
|
+
}
|
|
3510
|
+
}, { at: path });
|
|
3511
|
+
}
|
|
3512
|
+
}
|
|
3513
|
+
}
|
|
3514
|
+
atRef.unref();
|
|
3515
|
+
});
|
|
2362
3516
|
}
|
|
2363
|
-
function
|
|
2364
|
-
|
|
3517
|
+
function setActiveTypographyId(editor, id, options) {
|
|
3518
|
+
var _a2;
|
|
3519
|
+
const at = (_a2 = options == null ? void 0 : options.at) != null ? _a2 : editor.selection;
|
|
3520
|
+
if (!at)
|
|
3521
|
+
return;
|
|
3522
|
+
Transforms.setNodes(editor, {
|
|
3523
|
+
typography: {
|
|
3524
|
+
id,
|
|
3525
|
+
style: []
|
|
3526
|
+
}
|
|
3527
|
+
}, {
|
|
3528
|
+
at,
|
|
3529
|
+
match: (node) => Text.isText(node),
|
|
3530
|
+
split: Range.isExpanded(at)
|
|
3531
|
+
});
|
|
3532
|
+
}
|
|
3533
|
+
function setActiveTypographyStyle(editor, breakpoints, deviceId, prop, value, options) {
|
|
3534
|
+
Editor.withoutNormalizing(editor, () => {
|
|
3535
|
+
var _a2, _b, _c;
|
|
3536
|
+
const at = (_a2 = options == null ? void 0 : options.at) != null ? _a2 : editor.selection;
|
|
3537
|
+
if (!at)
|
|
3538
|
+
return;
|
|
3539
|
+
const atRef = Editor.rangeRef(editor, at);
|
|
3540
|
+
if (atRef.current) {
|
|
3541
|
+
Transforms.setNodes(editor, {
|
|
3542
|
+
slice: true
|
|
3543
|
+
}, {
|
|
3544
|
+
at: atRef.current,
|
|
3545
|
+
match: (node) => Text.isText(node),
|
|
3546
|
+
split: Range.isExpanded(atRef.current)
|
|
3547
|
+
});
|
|
3548
|
+
}
|
|
3549
|
+
if (atRef.current) {
|
|
3550
|
+
const textNodes = Array.from(Editor.nodes(editor, {
|
|
3551
|
+
at: atRef.current,
|
|
3552
|
+
match: (node) => Text.isText(node) && node.slice === true
|
|
3553
|
+
}));
|
|
3554
|
+
for (const [node, path] of textNodes) {
|
|
3555
|
+
if (Text.isText(node)) {
|
|
3556
|
+
const deviceOverrides = (_c = (_b = node == null ? void 0 : node.typography) == null ? void 0 : _b.style) != null ? _c : [];
|
|
3557
|
+
const deviceStyle = findBreakpointOverride(breakpoints, deviceOverrides, deviceId, (v) => v) || {
|
|
3558
|
+
value: {}
|
|
3559
|
+
};
|
|
3560
|
+
const nextDeviceStyle = {
|
|
3561
|
+
deviceId,
|
|
3562
|
+
value: __spreadProps(__spreadValues({}, deviceStyle.value), { [prop]: value })
|
|
3563
|
+
};
|
|
3564
|
+
const nextTypography = __spreadProps(__spreadValues({}, node.typography), {
|
|
3565
|
+
style: [...deviceOverrides.filter((v) => v.deviceId !== deviceId), nextDeviceStyle]
|
|
3566
|
+
});
|
|
3567
|
+
Transforms.setNodes(editor, {
|
|
3568
|
+
typography: nextTypography
|
|
3569
|
+
}, { at: path });
|
|
3570
|
+
}
|
|
3571
|
+
}
|
|
3572
|
+
}
|
|
3573
|
+
atRef.unref();
|
|
3574
|
+
});
|
|
2365
3575
|
}
|
|
3576
|
+
function getValue(editor) {
|
|
3577
|
+
const matchingValues = Array.from(Editor.nodes(editor, {
|
|
3578
|
+
at: getSelection(editor),
|
|
3579
|
+
match: Text.isText
|
|
3580
|
+
})).map(([node]) => node["typography"]);
|
|
3581
|
+
return matchingValues;
|
|
3582
|
+
}
|
|
3583
|
+
const TypographyActions = {
|
|
3584
|
+
setActiveTypographyId,
|
|
3585
|
+
setActiveTypographyStyle,
|
|
3586
|
+
clearActiveTypographyStyle,
|
|
3587
|
+
clearDeviceActiveTypography,
|
|
3588
|
+
detachActiveTypography
|
|
3589
|
+
};
|
|
3590
|
+
const TYPOGRAPHY_KEY = "typography";
|
|
3591
|
+
function withTypography(editor) {
|
|
3592
|
+
const { normalizeNode } = editor;
|
|
3593
|
+
editor.normalizeNode = (entry) => {
|
|
3594
|
+
var _a2, _b;
|
|
3595
|
+
const [normalizationNode, normalizationPath] = entry;
|
|
3596
|
+
if (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) {
|
|
3597
|
+
Transforms.unsetNodes(editor, TYPOGRAPHY_KEY, { at: normalizationPath });
|
|
3598
|
+
return;
|
|
3599
|
+
}
|
|
3600
|
+
if (Text.isText(normalizationNode) && (normalizationNode == null ? void 0 : normalizationNode.slice) != null) {
|
|
3601
|
+
Transforms.unsetNodes(editor, "slice", { at: normalizationPath });
|
|
3602
|
+
return;
|
|
3603
|
+
}
|
|
3604
|
+
normalizeNode(entry);
|
|
3605
|
+
};
|
|
3606
|
+
return editor;
|
|
3607
|
+
}
|
|
3608
|
+
function TypographyPlugin() {
|
|
3609
|
+
return createRichTextV2Plugin({
|
|
3610
|
+
withPlugin: withTypography,
|
|
3611
|
+
control: {
|
|
3612
|
+
definition: unstable_Typography(),
|
|
3613
|
+
onChange: (editor, value) => {
|
|
3614
|
+
Editor.withoutNormalizing(editor, () => {
|
|
3615
|
+
const at = getSelection(editor);
|
|
3616
|
+
if (!at)
|
|
3617
|
+
return;
|
|
3618
|
+
const atRef = Editor.rangeRef(editor, at);
|
|
3619
|
+
if (atRef.current) {
|
|
3620
|
+
Transforms.setNodes(editor, {
|
|
3621
|
+
slice: true
|
|
3622
|
+
}, {
|
|
3623
|
+
at: atRef.current,
|
|
3624
|
+
match: Text.isText,
|
|
3625
|
+
split: true
|
|
3626
|
+
});
|
|
3627
|
+
}
|
|
3628
|
+
if (atRef.current) {
|
|
3629
|
+
const nodesToUpdate = Array.from(Editor.nodes(editor, {
|
|
3630
|
+
at: atRef.current,
|
|
3631
|
+
match: (node) => Text.isText(node) && node.slice === true
|
|
3632
|
+
}));
|
|
3633
|
+
if (nodesToUpdate.length !== (value == null ? void 0 : value.length))
|
|
3634
|
+
return console.error(`TypographyControl.onChange received the wrong number of arguments.
|
|
3635
|
+
Called with ${value == null ? void 0 : value.length} values mapping to ${nodesToUpdate.length} nodes.`);
|
|
3636
|
+
for (const [index, [, path]] of nodesToUpdate.entries()) {
|
|
3637
|
+
Transforms.setNodes(editor, {
|
|
3638
|
+
typography: value == null ? void 0 : value.at(index)
|
|
3639
|
+
}, { at: path, match: Text.isText });
|
|
3640
|
+
}
|
|
3641
|
+
}
|
|
3642
|
+
atRef.unref();
|
|
3643
|
+
});
|
|
3644
|
+
},
|
|
3645
|
+
getValue: (editor) => getValue(editor),
|
|
3646
|
+
getLeafValue: (text) => {
|
|
3647
|
+
return Text.isText(text) ? text.typography : void 0;
|
|
3648
|
+
}
|
|
3649
|
+
},
|
|
3650
|
+
renderLeaf: (renderLeaf, className) => (props) => {
|
|
3651
|
+
return renderLeaf(__spreadProps(__spreadValues({}, props), {
|
|
3652
|
+
leaf: __spreadProps(__spreadValues({}, props.leaf), {
|
|
3653
|
+
className: `${props.leaf.className} ${className}`
|
|
3654
|
+
})
|
|
3655
|
+
}));
|
|
3656
|
+
}
|
|
3657
|
+
});
|
|
3658
|
+
}
|
|
3659
|
+
const BLOCK_ONE_PATH = [0];
|
|
3660
|
+
const BLOCK_TWO_PATH = [1];
|
|
3661
|
+
function withInlineMode(editor) {
|
|
3662
|
+
const {
|
|
3663
|
+
normalizeNode
|
|
3664
|
+
} = editor;
|
|
3665
|
+
editor.normalizeNode = (entry) => {
|
|
3666
|
+
const [normalizationNode, normalizationPath] = entry;
|
|
3667
|
+
if (Path.equals(BLOCK_TWO_PATH, normalizationPath)) {
|
|
3668
|
+
Transforms.mergeNodes(editor, {
|
|
3669
|
+
at: BLOCK_TWO_PATH
|
|
3670
|
+
});
|
|
3671
|
+
return;
|
|
3672
|
+
}
|
|
3673
|
+
if (Path.isAncestor(BLOCK_ONE_PATH, normalizationPath) && ElementUtils.isBlock(normalizationNode)) {
|
|
3674
|
+
Transforms.unwrapNodes(editor, {
|
|
3675
|
+
at: normalizationPath
|
|
3676
|
+
});
|
|
3677
|
+
return;
|
|
3678
|
+
}
|
|
3679
|
+
if (Path.equals(BLOCK_ONE_PATH, normalizationPath)) {
|
|
3680
|
+
Transforms.setNodes(editor, {
|
|
3681
|
+
type: BlockType.Default
|
|
3682
|
+
}, {
|
|
3683
|
+
at: normalizationPath
|
|
3684
|
+
});
|
|
3685
|
+
return;
|
|
3686
|
+
}
|
|
3687
|
+
normalizeNode(entry);
|
|
3688
|
+
};
|
|
3689
|
+
return editor;
|
|
3690
|
+
}
|
|
3691
|
+
function InlineModePlugin() {
|
|
3692
|
+
return createRichTextV2Plugin({
|
|
3693
|
+
onKeyDown: (e) => {
|
|
3694
|
+
if (isHotkey("enter", e))
|
|
3695
|
+
e.preventDefault();
|
|
3696
|
+
},
|
|
3697
|
+
withPlugin: withInlineMode,
|
|
3698
|
+
renderElement: (renderElement) => (props) => /* @__PURE__ */ jsx(InlineModePluginComponent, __spreadProps(__spreadValues({}, props), {
|
|
3699
|
+
renderElement
|
|
3700
|
+
}))
|
|
3701
|
+
});
|
|
3702
|
+
}
|
|
3703
|
+
function InlineModePluginComponent(_f) {
|
|
3704
|
+
var _g = _f, {
|
|
3705
|
+
renderElement
|
|
3706
|
+
} = _g, props = __objRest(_g, [
|
|
3707
|
+
"renderElement"
|
|
3708
|
+
]);
|
|
3709
|
+
return /* @__PURE__ */ jsx("span", __spreadProps(__spreadValues({}, props.attributes), {
|
|
3710
|
+
children: renderElement(props)
|
|
3711
|
+
}));
|
|
3712
|
+
}
|
|
3713
|
+
const RichTextV2ControlType = "makeswift::controls::rich-text-v2";
|
|
3714
|
+
const RichTextV2Mode = {
|
|
3715
|
+
Inline: "makeswift::controls::rich-text-v2::mode::inline",
|
|
3716
|
+
Block: "makeswift::controls::rich-text-v2::mode::block"
|
|
3717
|
+
};
|
|
3718
|
+
function RichText(config = {}) {
|
|
3719
|
+
return {
|
|
3720
|
+
type: RichTextV2ControlType,
|
|
3721
|
+
config: {
|
|
3722
|
+
mode: config.mode,
|
|
3723
|
+
defaultValue: config == null ? void 0 : config.unstable_defaultValue,
|
|
3724
|
+
plugins: (config == null ? void 0 : config.mode) === RichTextV2Mode.Inline ? [InlineModePlugin()] : [BlockPlugin(), TypographyPlugin(), TextAlignPlugin(), InlinePlugin(), LinkPlugin()]
|
|
3725
|
+
}
|
|
3726
|
+
};
|
|
3727
|
+
}
|
|
3728
|
+
RichText.Mode = RichTextV2Mode;
|
|
2366
3729
|
const RichTextV2ControlMessageType = {
|
|
2367
3730
|
RESET_VALUE: "makeswift::controls::rich-text-v2::control-message::reset-value",
|
|
2368
3731
|
FOCUS: "makeswift::controls::rich-text-v2::control-message::focus",
|
|
@@ -2396,6 +3759,7 @@ class RichTextV2Control extends PropController {
|
|
|
2396
3759
|
this.editor.selection = null;
|
|
2397
3760
|
this.editor.children = this.defaultValue;
|
|
2398
3761
|
this.editor.onChange();
|
|
3762
|
+
this.onLocalUserChange();
|
|
2399
3763
|
}
|
|
2400
3764
|
break;
|
|
2401
3765
|
}
|
|
@@ -2472,10 +3836,7 @@ class RichTextV2Control extends PropController {
|
|
|
2472
3836
|
}
|
|
2473
3837
|
}
|
|
2474
3838
|
function isRichTextV1Data(value) {
|
|
2475
|
-
return value !== void 0 && typeof value === "object" && !Array.isArray(value) && "
|
|
2476
|
-
}
|
|
2477
|
-
function isNonNullable(value) {
|
|
2478
|
-
return value != null;
|
|
3839
|
+
return value !== void 0 && typeof value === "object" && !Array.isArray(value) && "document" in value;
|
|
2479
3840
|
}
|
|
2480
3841
|
const TypographyControlType = "makeswift::controls::typography";
|
|
2481
3842
|
function unstable_Typography() {
|
|
@@ -2581,8 +3942,8 @@ function getRichTextPageIds(value) {
|
|
|
2581
3942
|
}
|
|
2582
3943
|
}
|
|
2583
3944
|
}
|
|
2584
|
-
function introspectRichTextV2Data(
|
|
2585
|
-
const plugins =
|
|
3945
|
+
function introspectRichTextV2Data(definition2, data, func) {
|
|
3946
|
+
const plugins = definition2.config.plugins;
|
|
2586
3947
|
return data.descendants.flatMap((d) => getDescendantTypographyIds(d));
|
|
2587
3948
|
function getDescendantTypographyIds(descendant) {
|
|
2588
3949
|
if (Element.isElement(descendant)) {
|
|
@@ -2611,14 +3972,14 @@ function introspectRichTextV2Data(definition, data, func) {
|
|
|
2611
3972
|
})) != null ? _a2 : [];
|
|
2612
3973
|
}
|
|
2613
3974
|
}
|
|
2614
|
-
function getRichTextV2SwatchIds(
|
|
2615
|
-
return introspectRichTextV2Data(
|
|
3975
|
+
function getRichTextV2SwatchIds(definition2, data) {
|
|
3976
|
+
return introspectRichTextV2Data(definition2, data, getSwatchIds);
|
|
2616
3977
|
}
|
|
2617
|
-
function getRichTextV2TypographyIds(
|
|
2618
|
-
return introspectRichTextV2Data(
|
|
3978
|
+
function getRichTextV2TypographyIds(definition2, data) {
|
|
3979
|
+
return introspectRichTextV2Data(definition2, data, getTypographyIds);
|
|
2619
3980
|
}
|
|
2620
|
-
function getRichTextV2PageIds(
|
|
2621
|
-
return introspectRichTextV2Data(
|
|
3981
|
+
function getRichTextV2PageIds(definition2, data) {
|
|
3982
|
+
return introspectRichTextV2Data(definition2, data, getPageIds);
|
|
2622
3983
|
}
|
|
2623
3984
|
function getElementChildren(descriptor, prop) {
|
|
2624
3985
|
if (prop == null)
|
|
@@ -3119,5 +4480,5 @@ function configureStore({
|
|
|
3119
4480
|
locales: getInitialState(locales != null ? locales : preloadedState == null ? void 0 : preloadedState.locales)
|
|
3120
4481
|
}), applyMiddleware(thunk));
|
|
3121
4482
|
}
|
|
3122
|
-
export {
|
|
4483
|
+
export { getBorderSwatchIds as $, ResponsiveLength as A, Backgrounds as B, ComponentIcon as C, Date as D, ElementID as E, Font as F, GapY as G, TextArea as H, Images as I, Table as J, TableFormFields as K, Link$1 as L, Margin as M, Number as N, Image$1 as O, Padding as P, ResponsiveOpacity as Q, RichTextPropControllerMessageType as R, Shadows as S, TableFormFieldsMessageType as T, NavigationLinks as U, SocialLinks as V, Width as W, RichText as X, BlockType as Y, Video as Z, useStyle as _, deepEqual as a, ShapeControl as a$, getBoxShadowsSwatchIds as a0, getResponsiveColorSwatchIds as a1, StyleControlProperty as a2, ImageControlValueFormat as a3, isPropControllersHandle as a4, isRichTextV1Data as a5, isNonNullable as a6, TypographyControlType as a7, StyleControlType as a8, RichTextV2ControlType as a9, getIsInBuilder as aA, getBuilderEditMode as aB, getIsPreview as aC, getBackgroundsFileIds as aD, getBackgroundsSwatchIds as aE, Color as aF, copyColorData as aG, copy as aH, merge as aI, unstable_IconRadioGroupIcon as aJ, unstable_IconRadioGroup as aK, Image as aL, copyImageData as aM, Link as aN, copyLinkData as aO, List as aP, ListControlMessageType as aQ, ListControl as aR, copyListData as aS, getListElementChildren as aT, getListSwatchIds as aU, getListFileIds as aV, getListTypographyIds as aW, getListPageIds as aX, Select as aY, Shape as aZ, ShapeControlMessageType as a_, RichTextControlType as aa, SlotControlType as ab, StyleV2ControlType as ac, ListControlType as ad, ShapeControlType as ae, LinkControlType as af, ImageControlType as ag, IconRadioGroupControlType as ah, ColorControlType as ai, SelectControlType as aj, getComponentPropControllerDescriptors as ak, getPropControllers as al, Types as am, BorderPropControllerFormat as an, ShadowsPropControllerFormat as ao, BorderRadiusPropControllerFormat as ap, MarginPropControllerFormat as aq, PaddingPropControllerFormat as ar, WidthPropControllerFormat as as, configureStore as at, copyElementTree as au, getBreakpoints as av, parseLocalesInput as aw, getElementId as ax, getReactComponent as ay, getDocument as az, createDocumentReference as b, getDocumentKeysSortedByDepth as b$, copyShapeData as b0, getShapeElementChildren as b1, getShapeSwatchIds as b2, getShapeTypographyIds as b3, getShapePageIds as b4, getShapeFileIds as b5, Slot as b6, SlotControlMessageType as b7, SlotControl as b8, copySlotData as b9, withTypography as bA, TypographyPlugin as bB, BlockActions as bC, ListActions as bD, onKeyDown as bE, withBlock as bF, BlockPlugin as bG, withInlineMode as bH, InlineModePlugin as bI, withTextAlign as bJ, TextAlignPlugin as bK, RootBlockType as bL, InlineType as bM, BlockTextAlignment as bN, withInline as bO, InlinePlugin as bP, ElementUtils as bQ, createRichTextV2Plugin as bR, onChange$1 as bS, getValue$3 as bT, isLinkElement as bU, getInitialState$7 as bV, reducer$8 as bW, getDocument$1 as bX, getComponentsMeta as bY, getComponentPropControllerDescriptors$1 as bZ, BuilderEditMode as b_, mergeSlotData as ba, Style as bb, StyleControlMessageType as bc, StyleControl as bd, copyStyleData as be, unstable_useStyleV2ClassName as bf, unstable_StyleV2 as bg, StyleV2ControlMessageType as bh, StyleV2Control as bi, ObjectType as bj, RichTextControlMessageType as bk, RichTextControl as bl, richTextDTOtoSelection as bm, richTextDTOtoDAO as bn, toSelectionDTO as bo, richTextDAOToDTO as bp, RichTextV2Mode as bq, RichTextV2ControlMessageType as br, RichTextV2Control as bs, richTextV2DataToDescendents as bt, richTextV2DescendentsToData as bu, unstable_Typography as bv, getTypographySwatchIds as bw, getTypographyTypographyIds as bx, TypographyActions as by, TYPOGRAPHY_KEY as bz, createDocument as c, getPropController as c0, getPropControllersHandle as c1, getElement as c2, getElementPropControllerDescriptors as c3, createPropController as c4, reducer$7 as c5, reducer$9 as c6, reducer$6 as c7, reducer$5 as c8, reducer$4 as c9, reducer$3 as ca, reducer$2 as cb, reducer$1 as cc, getInitialState$2 as cd, descriptors as d, isElementReference as e, getDefaultLocale as f, getPropControllerDescriptors as g, getLocales as h, introspection as i, getSwatchIds as j, getFileIds as k, getTypographyIds as l, getTableIds as m, getPageIds as n, getElementChildren as o, ResponsiveIconRadioGroup as p, Border as q, BorderRadius as r, GapX as s, ResponsiveSelect as t, ResponsiveNumber as u, Checkbox as v, Grid as w, TextInput as x, ResponsiveColor as y, TextStyle as z };
|
|
3123
4484
|
//# sourceMappingURL=react-page.es.js.map
|