@makeswift/runtime 0.7.7 → 0.7.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Box.cjs.js +2 -0
- package/dist/Box.cjs.js.map +1 -1
- package/dist/Box.es.js +2 -0
- package/dist/Box.es.js.map +1 -1
- package/dist/Button.cjs.js +2 -0
- package/dist/Button.cjs.js.map +1 -1
- package/dist/Button.es.js +2 -0
- package/dist/Button.es.js.map +1 -1
- package/dist/Carousel.cjs.js +2 -0
- package/dist/Carousel.cjs.js.map +1 -1
- package/dist/Carousel.es.js +2 -0
- package/dist/Carousel.es.js.map +1 -1
- package/dist/Countdown.cjs.js +2 -0
- package/dist/Countdown.cjs.js.map +1 -1
- package/dist/Countdown.es.js +2 -0
- package/dist/Countdown.es.js.map +1 -1
- package/dist/Divider.cjs.js +2 -0
- package/dist/Divider.cjs.js.map +1 -1
- package/dist/Divider.es.js +2 -0
- package/dist/Divider.es.js.map +1 -1
- package/dist/Embed.cjs.js +2 -0
- package/dist/Embed.cjs.js.map +1 -1
- package/dist/Embed.es.js +2 -0
- package/dist/Embed.es.js.map +1 -1
- package/dist/Form.cjs.js +3 -1
- package/dist/Form.cjs.js.map +1 -1
- package/dist/Form.es.js +3 -1
- package/dist/Form.es.js.map +1 -1
- package/dist/Image.cjs.js +2 -0
- package/dist/Image.cjs.js.map +1 -1
- package/dist/Image.es.js +2 -0
- package/dist/Image.es.js.map +1 -1
- package/dist/LiveProvider.cjs.js +2 -0
- package/dist/LiveProvider.cjs.js.map +1 -1
- package/dist/LiveProvider.es.js +3 -1
- package/dist/LiveProvider.es.js.map +1 -1
- package/dist/Navigation.cjs.js +2 -0
- package/dist/Navigation.cjs.js.map +1 -1
- package/dist/Navigation.es.js +2 -0
- package/dist/Navigation.es.js.map +1 -1
- package/dist/PreviewProvider.cjs.js +29 -23
- package/dist/PreviewProvider.cjs.js.map +1 -1
- package/dist/PreviewProvider.es.js +33 -25
- package/dist/PreviewProvider.es.js.map +1 -1
- package/dist/ReadOnlyText.cjs.js +185 -153
- package/dist/ReadOnlyText.cjs.js.map +1 -1
- package/dist/ReadOnlyText.es.js +182 -153
- package/dist/ReadOnlyText.es.js.map +1 -1
- package/dist/Root.cjs.js +2 -0
- package/dist/Root.cjs.js.map +1 -1
- package/dist/Root.es.js +2 -0
- package/dist/Root.es.js.map +1 -1
- package/dist/SocialLinks.cjs.js +2 -0
- package/dist/SocialLinks.cjs.js.map +1 -1
- package/dist/SocialLinks.es.js +2 -0
- package/dist/SocialLinks.es.js.map +1 -1
- package/dist/Text.cjs.js +3 -1
- package/dist/Text.cjs.js.map +1 -1
- package/dist/Text.es.js +3 -1
- package/dist/Text.es.js.map +1 -1
- package/dist/Video.cjs.js +2 -0
- package/dist/Video.cjs.js.map +1 -1
- package/dist/Video.es.js +2 -0
- package/dist/Video.es.js.map +1 -1
- package/dist/actions.cjs.js +1 -0
- package/dist/actions.cjs.js.map +1 -1
- package/dist/actions.es.js +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/compare.cjs.js +126 -0
- package/dist/compare.cjs.js.map +1 -0
- package/dist/compare.es.js +124 -0
- package/dist/compare.es.js.map +1 -0
- package/dist/components.cjs.js +2 -0
- package/dist/components.cjs.js.map +1 -1
- package/dist/components.es.js +2 -0
- package/dist/components.es.js.map +1 -1
- package/dist/constants.cjs.js +2 -0
- package/dist/constants.cjs.js.map +1 -1
- package/dist/constants.es.js +2 -0
- package/dist/constants.es.js.map +1 -1
- package/dist/control-serialization.cjs.js +29 -0
- package/dist/control-serialization.cjs.js.map +1 -1
- package/dist/control-serialization.es.js +30 -0
- package/dist/control-serialization.es.js.map +1 -1
- package/dist/controls.cjs.js +13 -0
- package/dist/controls.cjs.js.map +1 -1
- package/dist/controls.es.js +4 -1
- package/dist/controls.es.js.map +1 -1
- package/dist/index.cjs.js +6 -4
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.cjs2.js +2 -0
- package/dist/index.cjs2.js.map +1 -1
- package/dist/index.cjs5.js +2 -0
- package/dist/index.cjs5.js.map +1 -1
- package/dist/index.cjs6.js +663 -96
- package/dist/index.cjs6.js.map +1 -1
- package/dist/index.es.js +6 -4
- package/dist/index.es.js.map +1 -1
- package/dist/index.es2.js +2 -0
- package/dist/index.es2.js.map +1 -1
- package/dist/index.es5.js +2 -0
- package/dist/index.es5.js.map +1 -1
- package/dist/index.es6.js +657 -95
- package/dist/index.es6.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 +2 -0
- package/dist/next.cjs.js.map +1 -1
- package/dist/next.es.js +2 -0
- 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.cjs.js +2 -0
- package/dist/react.cjs.js.map +1 -1
- package/dist/react.es.js +2 -0
- package/dist/react.es.js.map +1 -1
- package/dist/rich-text.cjs.js +894 -22
- package/dist/rich-text.cjs.js.map +1 -1
- package/dist/rich-text.es.js +888 -23
- package/dist/rich-text.es.js.map +1 -1
- package/dist/types/src/components/builtin/Button/Button.d.ts +1 -1
- package/dist/types/src/components/builtin/Form/components/Field/components/Checkbox/index.d.ts +1 -1
- package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/ListPlugin.d.ts +13 -0
- package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/ListPlugin.d.ts.map +1 -0
- package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/constants.d.ts +3 -0
- package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/constants.d.ts.map +1 -0
- package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/index.d.ts +2 -0
- package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/index.d.ts.map +1 -0
- package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/lib/dedent.d.ts +3 -0
- package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/lib/dedent.d.ts.map +1 -0
- package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/lib/indent.d.ts +4 -0
- package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/lib/indent.d.ts.map +1 -0
- package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/lib/index.d.ts +6 -0
- package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/lib/index.d.ts.map +1 -0
- package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/lib/toggleList.d.ts +8 -0
- package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/lib/toggleList.d.ts.map +1 -0
- package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/lib/unwrapList.d.ts +4 -0
- package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/lib/unwrapList.d.ts.map +1 -0
- package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/lib/utils/editor.d.ts +7 -0
- package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/lib/utils/editor.d.ts.map +1 -0
- package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/lib/utils/element.d.ts +26 -0
- package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/lib/utils/element.d.ts.map +1 -0
- package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/lib/utils/filterForSubtreeRoots.d.ts +3 -0
- package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/lib/utils/filterForSubtreeRoots.d.ts.map +1 -0
- package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/lib/utils/getSelectedListItems.d.ts +5 -0
- package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/lib/utils/getSelectedListItems.d.ts.map +1 -0
- package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/lib/utils/location.d.ts +5 -0
- package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/lib/utils/location.d.ts.map +1 -0
- package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/lib/wrapList.d.ts +8 -0
- package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/lib/wrapList.d.ts.map +1 -0
- package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/test/dedent.test.d.ts +3 -0
- package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/test/dedent.test.d.ts.map +1 -0
- package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/test/indent.test.d.ts +3 -0
- package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/test/indent.test.d.ts.map +1 -0
- package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/test/normalization.test.d.ts +3 -0
- package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/test/normalization.test.d.ts.map +1 -0
- package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/test/slate-test-helper.d.ts +48 -0
- package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/test/slate-test-helper.d.ts.map +1 -0
- package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/test/toggleList.test.d.ts +3 -0
- package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/test/toggleList.test.d.ts.map +1 -0
- package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/test/types.d.ts +21 -0
- package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/test/types.d.ts.map +1 -0
- package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/test/unwrapList.test.d.ts +3 -0
- package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/test/unwrapList.test.d.ts.map +1 -0
- package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/test/utils/filterForSubtreeRoots.test.d.ts +2 -0
- package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/test/utils/filterForSubtreeRoots.test.d.ts.map +1 -0
- package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/test/utils/getSelectedListItems.test.d.ts +3 -0
- package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/test/utils/getSelectedListItems.test.d.ts.map +1 -0
- package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/test/wrapList.test.d.ts +3 -0
- package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/test/wrapList.test.d.ts.map +1 -0
- package/dist/types/src/components/builtin/Text/EditableText/editable-text.d.ts +13 -0
- package/dist/types/src/components/builtin/Text/EditableText/editable-text.d.ts.map +1 -0
- package/dist/types/src/components/builtin/Text/EditableText/index.d.ts +4 -0
- package/dist/types/src/components/builtin/Text/EditableText/index.d.ts.map +1 -0
- package/dist/types/src/components/builtin/Text/EditableText/useSyncWithBuilder.d.ts +8 -0
- package/dist/types/src/components/builtin/Text/EditableText/useSyncWithBuilder.d.ts.map +1 -0
- package/dist/types/src/components/builtin/Text/ReadOnlyText.d.ts +16 -0
- package/dist/types/src/components/builtin/Text/ReadOnlyText.d.ts.map +1 -1
- package/dist/types/src/components/builtin/Text/Text.d.ts +1 -1
- package/dist/types/src/components/builtin/Text/Text.d.ts.map +1 -1
- package/dist/types/src/components/builtin/Text/components/Element/block.d.ts +8 -0
- package/dist/types/src/components/builtin/Text/components/Element/block.d.ts.map +1 -0
- package/dist/types/src/components/builtin/Text/components/Element/element.d.ts +4 -0
- package/dist/types/src/components/builtin/Text/components/Element/element.d.ts.map +1 -0
- package/dist/types/src/components/builtin/Text/components/Element/index.d.ts +2 -0
- package/dist/types/src/components/builtin/Text/components/Element/index.d.ts.map +1 -0
- package/dist/types/src/components/builtin/Text/components/Element/inline.d.ts +8 -0
- package/dist/types/src/components/builtin/Text/components/Element/inline.d.ts.map +1 -0
- package/dist/types/src/components/builtin/Text/components/Leaf/index.d.ts +3 -0
- package/dist/types/src/components/builtin/Text/components/Leaf/index.d.ts.map +1 -0
- package/dist/types/src/components/builtin/Text/components/Leaf/leaf.d.ts +4 -0
- package/dist/types/src/components/builtin/Text/components/Leaf/leaf.d.ts.map +1 -0
- package/dist/types/src/components/builtin/Text/components/Leaf/typography.d.ts +27 -0
- package/dist/types/src/components/builtin/Text/components/Leaf/typography.d.ts.map +1 -0
- package/dist/types/src/components/builtin/Text/components/index.d.ts +3 -0
- package/dist/types/src/components/builtin/Text/components/index.d.ts.map +1 -0
- package/dist/types/src/components/utils/types.d.ts +1 -1
- package/dist/types/src/components/utils/types.d.ts.map +1 -1
- package/dist/types/src/controls/rich-text/compare.d.ts +5 -0
- package/dist/types/src/controls/rich-text/compare.d.ts.map +1 -0
- package/dist/types/src/controls/rich-text/compare.test.d.ts +2 -0
- package/dist/types/src/controls/rich-text/compare.test.d.ts.map +1 -0
- package/dist/types/src/controls/rich-text/dto-types.d.ts +131 -0
- package/dist/types/src/controls/rich-text/dto-types.d.ts.map +1 -0
- package/dist/types/src/controls/rich-text/fixtures/blockquote.d.ts +3 -0
- package/dist/types/src/controls/rich-text/fixtures/blockquote.d.ts.map +1 -0
- package/dist/types/src/controls/rich-text/fixtures/index.d.ts +4 -0
- package/dist/types/src/controls/rich-text/fixtures/index.d.ts.map +1 -0
- package/dist/types/src/controls/rich-text/fixtures/list.d.ts +3 -0
- package/dist/types/src/controls/rich-text/fixtures/list.d.ts.map +1 -0
- package/dist/types/src/controls/rich-text/fixtures/typography.d.ts +3 -0
- package/dist/types/src/controls/rich-text/fixtures/typography.d.ts.map +1 -0
- package/dist/types/src/controls/rich-text/index.d.ts +6 -0
- package/dist/types/src/controls/rich-text/index.d.ts.map +1 -0
- package/dist/types/src/controls/{rich-text.d.ts → rich-text/rich-text.d.ts} +8 -10
- package/dist/types/src/controls/rich-text/rich-text.d.ts.map +1 -0
- package/dist/types/src/controls/rich-text/translation.d.ts +8 -0
- package/dist/types/src/controls/rich-text/translation.d.ts.map +1 -0
- package/dist/types/src/controls/rich-text/translation.test.d.ts +2 -0
- package/dist/types/src/controls/rich-text/translation.test.d.ts.map +1 -0
- package/dist/types/src/controls/rich-text/types.d.ts +134 -0
- package/dist/types/src/controls/rich-text/types.d.ts.map +1 -0
- package/dist/types/src/prop-controllers/descriptors.d.ts +2 -3
- package/dist/types/src/prop-controllers/descriptors.d.ts.map +1 -1
- package/dist/types/src/prop-controllers/instances.d.ts +4 -7
- package/dist/types/src/prop-controllers/instances.d.ts.map +1 -1
- package/dist/types/src/prop-controllers/introspection.d.ts.map +1 -1
- package/dist/types/src/runtimes/react/element-imperative-handle.d.ts.map +1 -1
- package/dist/types/src/state/react-builder-preview.d.ts.map +1 -1
- package/dist/typography.cjs.js +146 -0
- package/dist/typography.cjs.js.map +1 -0
- package/dist/typography.es.js +143 -0
- package/dist/typography.es.js.map +1 -0
- package/package.json +7 -10
- package/dist/EditableText.cjs.js +0 -380
- package/dist/EditableText.cjs.js.map +0 -1
- package/dist/EditableText.es.js +0 -373
- package/dist/EditableText.es.js.map +0 -1
- package/dist/types/src/components/builtin/Text/EditableText.d.ts +0 -16
- package/dist/types/src/components/builtin/Text/EditableText.d.ts.map +0 -1
- package/dist/types/src/components/builtin/Text/components/RichTextEditor/components/Block/index.d.ts +0 -10
- package/dist/types/src/components/builtin/Text/components/RichTextEditor/components/Block/index.d.ts.map +0 -1
- package/dist/types/src/components/builtin/Text/components/RichTextEditor/components/Mark/hooks/useTypographyMark.d.ts +0 -25
- package/dist/types/src/components/builtin/Text/components/RichTextEditor/components/Mark/hooks/useTypographyMark.d.ts.map +0 -1
- package/dist/types/src/components/builtin/Text/components/RichTextEditor/components/Mark/index.d.ts +0 -10
- package/dist/types/src/components/builtin/Text/components/RichTextEditor/components/Mark/index.d.ts.map +0 -1
- package/dist/types/src/components/builtin/Text/components/RichTextEditor/index.d.ts +0 -5
- package/dist/types/src/components/builtin/Text/components/RichTextEditor/index.d.ts.map +0 -1
- package/dist/types/src/components/builtin/Text/components/RichTextEditor/plugins/DeviceOverridesBlocks.d.ts +0 -3
- package/dist/types/src/components/builtin/Text/components/RichTextEditor/plugins/DeviceOverridesBlocks.d.ts.map +0 -1
- package/dist/types/src/components/builtin/Text/components/RichTextEditor/plugins/DeviceOverridesMarks.d.ts +0 -3
- package/dist/types/src/components/builtin/Text/components/RichTextEditor/plugins/DeviceOverridesMarks.d.ts.map +0 -1
- package/dist/types/src/components/builtin/Text/components/RichTextEditor/plugins/Inlines.d.ts +0 -3
- package/dist/types/src/components/builtin/Text/components/RichTextEditor/plugins/Inlines.d.ts.map +0 -1
- package/dist/types/src/components/builtin/Text/components/RichTextEditor/plugins/Link.d.ts +0 -3
- package/dist/types/src/components/builtin/Text/components/RichTextEditor/plugins/Link.d.ts.map +0 -1
- package/dist/types/src/controls/rich-text.d.ts.map +0 -1
package/dist/rich-text.es.js
CHANGED
|
@@ -21,7 +21,10 @@ var __publicField = (obj, key, value) => {
|
|
|
21
21
|
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
22
22
|
return value;
|
|
23
23
|
};
|
|
24
|
+
const import_meta = {};
|
|
24
25
|
import { A as ActionTypes } from "./actions.es.js";
|
|
26
|
+
import { Transforms, Editor } from "slate";
|
|
27
|
+
import { ReactEditor } from "slate-react";
|
|
25
28
|
const BuilderEditMode = {
|
|
26
29
|
BUILD: "build",
|
|
27
30
|
CONTENT: "content",
|
|
@@ -115,6 +118,122 @@ function copyStyleData(value, context) {
|
|
|
115
118
|
}
|
|
116
119
|
return __spreadProps(__spreadValues({}, value), { border: copyResponsiveBorder(value.border) });
|
|
117
120
|
}
|
|
121
|
+
if (import_meta.vitest) {
|
|
122
|
+
const { describe, test, expect } = import_meta.vitest;
|
|
123
|
+
describe.concurrent("style copy", () => {
|
|
124
|
+
test("colors are replaced", () => {
|
|
125
|
+
const value = {
|
|
126
|
+
width: [
|
|
127
|
+
{
|
|
128
|
+
value: {
|
|
129
|
+
unit: "px",
|
|
130
|
+
value: 100
|
|
131
|
+
},
|
|
132
|
+
deviceId: "desktop"
|
|
133
|
+
}
|
|
134
|
+
],
|
|
135
|
+
border: [
|
|
136
|
+
{
|
|
137
|
+
value: {
|
|
138
|
+
borderTop: {
|
|
139
|
+
color: {
|
|
140
|
+
alpha: 1,
|
|
141
|
+
swatchId: "U3dhdGNoOmJjMDkwZWJjLTZkZDUtNDY1NS1hMDY0LTg3ZDAxM2U4YTFhNA=="
|
|
142
|
+
},
|
|
143
|
+
style: "solid",
|
|
144
|
+
width: 9
|
|
145
|
+
},
|
|
146
|
+
borderLeft: {
|
|
147
|
+
color: {
|
|
148
|
+
alpha: 1,
|
|
149
|
+
swatchId: "U3dhdGNoOmJjMDkwZWJjLTZkZDUtNDY1NS1hMDY0LTg3ZDAxM2U4YTFhNA=="
|
|
150
|
+
},
|
|
151
|
+
style: "solid",
|
|
152
|
+
width: 9
|
|
153
|
+
},
|
|
154
|
+
borderRight: {
|
|
155
|
+
color: {
|
|
156
|
+
alpha: 1,
|
|
157
|
+
swatchId: "U3dhdGNoOmJjMDkwZWJjLTZkZDUtNDY1NS1hMDY0LTg3ZDAxM2U4YTFhNA=="
|
|
158
|
+
},
|
|
159
|
+
style: "solid",
|
|
160
|
+
width: 9
|
|
161
|
+
},
|
|
162
|
+
borderBottom: {
|
|
163
|
+
color: {
|
|
164
|
+
alpha: 1,
|
|
165
|
+
swatchId: "U3dhdGNoOmJjMDkwZWJjLTZkZDUtNDY1NS1hMDY0LTg3ZDAxM2U4YTFhNA=="
|
|
166
|
+
},
|
|
167
|
+
style: "solid",
|
|
168
|
+
width: 9
|
|
169
|
+
}
|
|
170
|
+
},
|
|
171
|
+
deviceId: "desktop"
|
|
172
|
+
}
|
|
173
|
+
],
|
|
174
|
+
textStyle: [
|
|
175
|
+
{
|
|
176
|
+
value: {
|
|
177
|
+
fontSize: {
|
|
178
|
+
unit: "px",
|
|
179
|
+
value: 46
|
|
180
|
+
},
|
|
181
|
+
fontStyle: [],
|
|
182
|
+
fontFamily: "Oswald",
|
|
183
|
+
fontWeight: 400,
|
|
184
|
+
letterSpacing: 5.2,
|
|
185
|
+
textTransform: []
|
|
186
|
+
},
|
|
187
|
+
deviceId: "desktop"
|
|
188
|
+
}
|
|
189
|
+
],
|
|
190
|
+
borderRadius: [
|
|
191
|
+
{
|
|
192
|
+
value: {
|
|
193
|
+
borderTopLeftRadius: {
|
|
194
|
+
unit: "px",
|
|
195
|
+
value: 4
|
|
196
|
+
},
|
|
197
|
+
borderTopRightRadius: {
|
|
198
|
+
unit: "px",
|
|
199
|
+
value: 4
|
|
200
|
+
},
|
|
201
|
+
borderBottomLeftRadius: {
|
|
202
|
+
unit: "px",
|
|
203
|
+
value: 4
|
|
204
|
+
},
|
|
205
|
+
borderBottomRightRadius: {
|
|
206
|
+
unit: "px",
|
|
207
|
+
value: 4
|
|
208
|
+
}
|
|
209
|
+
},
|
|
210
|
+
deviceId: "desktop"
|
|
211
|
+
}
|
|
212
|
+
]
|
|
213
|
+
};
|
|
214
|
+
const expected = JSON.parse(JSON.stringify(value).replaceAll("U3dhdGNoOmJjMDkwZWJjLTZkZDUtNDY1NS1hMDY0LTg3ZDAxM2U4YTFhNA==", "testing"));
|
|
215
|
+
const replacementContext = {
|
|
216
|
+
elementHtmlIds: /* @__PURE__ */ new Set(),
|
|
217
|
+
elementKeys: /* @__PURE__ */ new Map(),
|
|
218
|
+
swatchIds: /* @__PURE__ */ new Map([
|
|
219
|
+
["U3dhdGNoOmJjMDkwZWJjLTZkZDUtNDY1NS1hMDY0LTg3ZDAxM2U4YTFhNA==", "testing"]
|
|
220
|
+
]),
|
|
221
|
+
fileIds: /* @__PURE__ */ new Map(),
|
|
222
|
+
typographyIds: /* @__PURE__ */ new Map(),
|
|
223
|
+
tableIds: /* @__PURE__ */ new Map(),
|
|
224
|
+
tableColumnIds: /* @__PURE__ */ new Map(),
|
|
225
|
+
pageIds: /* @__PURE__ */ new Map(),
|
|
226
|
+
globalElementIds: /* @__PURE__ */ new Map(),
|
|
227
|
+
globalElementData: /* @__PURE__ */ new Map()
|
|
228
|
+
};
|
|
229
|
+
const result = copyStyleData(value, {
|
|
230
|
+
replacementContext,
|
|
231
|
+
copyElement: (node) => node
|
|
232
|
+
});
|
|
233
|
+
expect(result).toMatchObject(expected);
|
|
234
|
+
});
|
|
235
|
+
});
|
|
236
|
+
}
|
|
118
237
|
const Types = {
|
|
119
238
|
Backgrounds: "Backgrounds",
|
|
120
239
|
Border: "Border",
|
|
@@ -353,6 +472,32 @@ function copyImageData(value, context) {
|
|
|
353
472
|
return value;
|
|
354
473
|
return (_a = context.replacementContext.fileIds.get(value)) != null ? _a : value;
|
|
355
474
|
}
|
|
475
|
+
if (import_meta.vitest) {
|
|
476
|
+
const { describe, test, expect } = import_meta.vitest;
|
|
477
|
+
describe.concurrent("image copy", () => {
|
|
478
|
+
test("image is replaced by a one in replacement context", () => {
|
|
479
|
+
const data = "file-id";
|
|
480
|
+
const expected = "testing";
|
|
481
|
+
const replacementContext = {
|
|
482
|
+
elementHtmlIds: /* @__PURE__ */ new Set(),
|
|
483
|
+
elementKeys: /* @__PURE__ */ new Map(),
|
|
484
|
+
swatchIds: /* @__PURE__ */ new Map(),
|
|
485
|
+
fileIds: /* @__PURE__ */ new Map([["file-id", "testing"]]),
|
|
486
|
+
typographyIds: /* @__PURE__ */ new Map(),
|
|
487
|
+
tableIds: /* @__PURE__ */ new Map(),
|
|
488
|
+
tableColumnIds: /* @__PURE__ */ new Map(),
|
|
489
|
+
pageIds: /* @__PURE__ */ new Map(),
|
|
490
|
+
globalElementIds: /* @__PURE__ */ new Map(),
|
|
491
|
+
globalElementData: /* @__PURE__ */ new Map()
|
|
492
|
+
};
|
|
493
|
+
const result = copyImageData(data, {
|
|
494
|
+
replacementContext,
|
|
495
|
+
copyElement: (node) => node
|
|
496
|
+
});
|
|
497
|
+
expect(result).toMatchObject(expected);
|
|
498
|
+
});
|
|
499
|
+
});
|
|
500
|
+
}
|
|
356
501
|
const LinkControlType = "makeswift::controls::link";
|
|
357
502
|
function Link(config = {}) {
|
|
358
503
|
return { type: LinkControlType, config };
|
|
@@ -373,6 +518,38 @@ function copyLinkData(value, context) {
|
|
|
373
518
|
}
|
|
374
519
|
return value;
|
|
375
520
|
}
|
|
521
|
+
if (import_meta.vitest) {
|
|
522
|
+
const { describe, test, expect } = import_meta.vitest;
|
|
523
|
+
describe.concurrent("link", () => {
|
|
524
|
+
test("page id is replaced by one in replacement context", () => {
|
|
525
|
+
const data = {
|
|
526
|
+
type: "OPEN_PAGE",
|
|
527
|
+
payload: {
|
|
528
|
+
pageId: "UGFnZTpmNTdmMjQ2MS0wMGY3LTQzZWUtYmIwOS03ODdiNTUyYzUyYWQ=",
|
|
529
|
+
openInNewTab: false
|
|
530
|
+
}
|
|
531
|
+
};
|
|
532
|
+
const expected = JSON.parse(JSON.stringify(data).replace("UGFnZTpmNTdmMjQ2MS0wMGY3LTQzZWUtYmIwOS03ODdiNTUyYzUyYWQ=", "testing"));
|
|
533
|
+
const replacementContext = {
|
|
534
|
+
elementHtmlIds: /* @__PURE__ */ new Set(),
|
|
535
|
+
elementKeys: /* @__PURE__ */ new Map(),
|
|
536
|
+
swatchIds: /* @__PURE__ */ new Map(),
|
|
537
|
+
pageIds: /* @__PURE__ */ new Map([["UGFnZTpmNTdmMjQ2MS0wMGY3LTQzZWUtYmIwOS03ODdiNTUyYzUyYWQ=", "testing"]]),
|
|
538
|
+
typographyIds: /* @__PURE__ */ new Map(),
|
|
539
|
+
tableIds: /* @__PURE__ */ new Map(),
|
|
540
|
+
tableColumnIds: /* @__PURE__ */ new Map(),
|
|
541
|
+
fileIds: /* @__PURE__ */ new Map(),
|
|
542
|
+
globalElementIds: /* @__PURE__ */ new Map(),
|
|
543
|
+
globalElementData: /* @__PURE__ */ new Map()
|
|
544
|
+
};
|
|
545
|
+
const result = copyLinkData(data, {
|
|
546
|
+
replacementContext,
|
|
547
|
+
copyElement: (node) => node
|
|
548
|
+
});
|
|
549
|
+
expect(result).toMatchObject(expected);
|
|
550
|
+
});
|
|
551
|
+
});
|
|
552
|
+
}
|
|
376
553
|
const RichTextPropControllerMessageType = {
|
|
377
554
|
CHANGE_BUILDER_EDIT_MODE: "CHANGE_BUILDER_EDIT_MODE",
|
|
378
555
|
INITIALIZE_EDITOR: "INITIALIZE_EDITOR",
|
|
@@ -399,19 +576,24 @@ class RichTextPropController extends PropController {
|
|
|
399
576
|
__publicField(this, "editor", null);
|
|
400
577
|
}
|
|
401
578
|
recv(message) {
|
|
402
|
-
|
|
579
|
+
if (!this.editor)
|
|
580
|
+
return;
|
|
403
581
|
switch (message.type) {
|
|
404
582
|
case RichTextPropControllerMessageType.CHANGE_BUILDER_EDIT_MODE: {
|
|
405
583
|
switch (message.editMode) {
|
|
406
584
|
case BuilderEditMode.BUILD:
|
|
407
585
|
case BuilderEditMode.INTERACT:
|
|
408
|
-
(
|
|
409
|
-
|
|
586
|
+
ReactEditor.deselect(this.editor);
|
|
587
|
+
ReactEditor.blur(this.editor);
|
|
410
588
|
}
|
|
411
589
|
break;
|
|
412
590
|
}
|
|
413
591
|
case RichTextPropControllerMessageType.FOCUS: {
|
|
414
|
-
(
|
|
592
|
+
ReactEditor.focus(this.editor);
|
|
593
|
+
Transforms.select(this.editor, {
|
|
594
|
+
anchor: Editor.start(this.editor, []),
|
|
595
|
+
focus: Editor.end(this.editor, [])
|
|
596
|
+
});
|
|
415
597
|
break;
|
|
416
598
|
}
|
|
417
599
|
}
|
|
@@ -420,14 +602,18 @@ class RichTextPropController extends PropController {
|
|
|
420
602
|
this.editor = editor;
|
|
421
603
|
this.send({
|
|
422
604
|
type: RichTextPropControllerMessageType.INITIALIZE_EDITOR,
|
|
423
|
-
value: editor.
|
|
424
|
-
});
|
|
425
|
-
}
|
|
426
|
-
onChange(change) {
|
|
427
|
-
this.send({
|
|
428
|
-
type: RichTextPropControllerMessageType.CHANGE_EDITOR_VALUE,
|
|
429
|
-
value: change.value.toJSON({ preserveSelection: true })
|
|
605
|
+
value: richTextDAOToDTO(editor.children, editor.selection)
|
|
430
606
|
});
|
|
607
|
+
const _onChange = editor.onChange;
|
|
608
|
+
this.editor.onChange = (options) => {
|
|
609
|
+
_onChange(options);
|
|
610
|
+
if ((options == null ? void 0 : options.operation) != null) {
|
|
611
|
+
this.send({
|
|
612
|
+
type: RichTextPropControllerMessageType.CHANGE_EDITOR_VALUE,
|
|
613
|
+
value: richTextDAOToDTO(editor.children, editor.selection)
|
|
614
|
+
});
|
|
615
|
+
}
|
|
616
|
+
};
|
|
431
617
|
}
|
|
432
618
|
focus() {
|
|
433
619
|
this.send({ type: RichTextPropControllerMessageType.FOCUS });
|
|
@@ -700,6 +886,47 @@ function copy$b(value, context) {
|
|
|
700
886
|
}
|
|
701
887
|
}
|
|
702
888
|
}
|
|
889
|
+
if (import_meta.vitest) {
|
|
890
|
+
const { describe, test, expect } = import_meta.vitest;
|
|
891
|
+
describe.concurrent("navigation-links copy", () => {
|
|
892
|
+
test("replace page id from replacement context", () => {
|
|
893
|
+
const data = [
|
|
894
|
+
{
|
|
895
|
+
id: "e1cf2d04-012a-4481-832a-7b4dda62195e",
|
|
896
|
+
type: "button",
|
|
897
|
+
payload: {
|
|
898
|
+
link: {
|
|
899
|
+
type: "OPEN_PAGE",
|
|
900
|
+
payload: {
|
|
901
|
+
pageId: "UGFnZTo2OGMzODZhNC1jYzRkLTQzMzUtYWZiMi05MDdhZGRkYzQ3YTM=",
|
|
902
|
+
openInNewTab: true
|
|
903
|
+
}
|
|
904
|
+
},
|
|
905
|
+
label: "Fellow Page"
|
|
906
|
+
}
|
|
907
|
+
}
|
|
908
|
+
];
|
|
909
|
+
const expected = JSON.parse(JSON.stringify(data).replace("UGFnZTo2OGMzODZhNC1jYzRkLTQzMzUtYWZiMi05MDdhZGRkYzQ3YTM=", "testing"));
|
|
910
|
+
const replacementContext = {
|
|
911
|
+
elementHtmlIds: /* @__PURE__ */ new Set(),
|
|
912
|
+
elementKeys: /* @__PURE__ */ new Map(),
|
|
913
|
+
swatchIds: /* @__PURE__ */ new Map(),
|
|
914
|
+
fileIds: /* @__PURE__ */ new Map(),
|
|
915
|
+
typographyIds: /* @__PURE__ */ new Map(),
|
|
916
|
+
tableIds: /* @__PURE__ */ new Map(),
|
|
917
|
+
tableColumnIds: /* @__PURE__ */ new Map(),
|
|
918
|
+
pageIds: /* @__PURE__ */ new Map([["UGFnZTo2OGMzODZhNC1jYzRkLTQzMzUtYWZiMi05MDdhZGRkYzQ3YTM=", "testing"]]),
|
|
919
|
+
globalElementIds: /* @__PURE__ */ new Map(),
|
|
920
|
+
globalElementData: /* @__PURE__ */ new Map()
|
|
921
|
+
};
|
|
922
|
+
const result = copy$b(data, {
|
|
923
|
+
replacementContext,
|
|
924
|
+
copyElement: (node) => node
|
|
925
|
+
});
|
|
926
|
+
expect(result).toMatchObject(expected);
|
|
927
|
+
});
|
|
928
|
+
});
|
|
929
|
+
}
|
|
703
930
|
function copy$a(value, context) {
|
|
704
931
|
if (value == null)
|
|
705
932
|
return value;
|
|
@@ -718,12 +945,85 @@ function copy$a(value, context) {
|
|
|
718
945
|
});
|
|
719
946
|
}
|
|
720
947
|
}
|
|
948
|
+
if (import_meta.vitest) {
|
|
949
|
+
const { describe, test, expect } = import_meta.vitest;
|
|
950
|
+
describe.concurrent("shadow copy", () => {
|
|
951
|
+
test("replaces the swatch id", () => {
|
|
952
|
+
const data = [
|
|
953
|
+
{
|
|
954
|
+
value: [
|
|
955
|
+
{
|
|
956
|
+
id: "8575efe6-4d04-4361-b593-e559537c4c3c",
|
|
957
|
+
payload: {
|
|
958
|
+
color: {
|
|
959
|
+
alpha: 1,
|
|
960
|
+
swatchId: "U3dhdGNoOjgwMmNmZGMyLTc5ZDgtNDkyNy1hMDUwLWE1NmM1M2EzYzE0Mg=="
|
|
961
|
+
},
|
|
962
|
+
offsetX: -5,
|
|
963
|
+
offsetY: 8.7,
|
|
964
|
+
blurRadius: 17,
|
|
965
|
+
spreadRadius: 16
|
|
966
|
+
}
|
|
967
|
+
}
|
|
968
|
+
],
|
|
969
|
+
deviceId: "desktop"
|
|
970
|
+
}
|
|
971
|
+
];
|
|
972
|
+
const expected = JSON.parse(JSON.stringify(data).replace("U3dhdGNoOjgwMmNmZGMyLTc5ZDgtNDkyNy1hMDUwLWE1NmM1M2EzYzE0Mg==", "testing"));
|
|
973
|
+
const replacementContext = {
|
|
974
|
+
elementHtmlIds: /* @__PURE__ */ new Set(),
|
|
975
|
+
elementKeys: /* @__PURE__ */ new Map(),
|
|
976
|
+
swatchIds: /* @__PURE__ */ new Map([
|
|
977
|
+
["U3dhdGNoOjgwMmNmZGMyLTc5ZDgtNDkyNy1hMDUwLWE1NmM1M2EzYzE0Mg==", "testing"]
|
|
978
|
+
]),
|
|
979
|
+
fileIds: /* @__PURE__ */ new Map(),
|
|
980
|
+
typographyIds: /* @__PURE__ */ new Map(),
|
|
981
|
+
tableIds: /* @__PURE__ */ new Map(),
|
|
982
|
+
tableColumnIds: /* @__PURE__ */ new Map(),
|
|
983
|
+
pageIds: /* @__PURE__ */ new Map(),
|
|
984
|
+
globalElementIds: /* @__PURE__ */ new Map(),
|
|
985
|
+
globalElementData: /* @__PURE__ */ new Map()
|
|
986
|
+
};
|
|
987
|
+
const result = copy$a(data, {
|
|
988
|
+
replacementContext,
|
|
989
|
+
copyElement: (node) => node
|
|
990
|
+
});
|
|
991
|
+
expect(result).toMatchObject(expected);
|
|
992
|
+
});
|
|
993
|
+
});
|
|
994
|
+
}
|
|
721
995
|
function copy$9(value, context) {
|
|
722
996
|
var _a;
|
|
723
997
|
if (value == null)
|
|
724
998
|
return value;
|
|
725
999
|
return (_a = context.replacementContext.fileIds.get(value)) != null ? _a : value;
|
|
726
1000
|
}
|
|
1001
|
+
if (import_meta.vitest) {
|
|
1002
|
+
const { describe, test, expect } = import_meta.vitest;
|
|
1003
|
+
describe.concurrent("image copy", () => {
|
|
1004
|
+
test("image is replaced by a one in replacement context", () => {
|
|
1005
|
+
const data = "file-id";
|
|
1006
|
+
const expected = JSON.parse(JSON.stringify(data).replace("file-id", "testing"));
|
|
1007
|
+
const replacementContext = {
|
|
1008
|
+
elementHtmlIds: /* @__PURE__ */ new Set(),
|
|
1009
|
+
elementKeys: /* @__PURE__ */ new Map(),
|
|
1010
|
+
swatchIds: /* @__PURE__ */ new Map(),
|
|
1011
|
+
fileIds: /* @__PURE__ */ new Map([["file-id", "testing"]]),
|
|
1012
|
+
typographyIds: /* @__PURE__ */ new Map(),
|
|
1013
|
+
tableIds: /* @__PURE__ */ new Map(),
|
|
1014
|
+
tableColumnIds: /* @__PURE__ */ new Map(),
|
|
1015
|
+
pageIds: /* @__PURE__ */ new Map(),
|
|
1016
|
+
globalElementIds: /* @__PURE__ */ new Map(),
|
|
1017
|
+
globalElementData: /* @__PURE__ */ new Map()
|
|
1018
|
+
};
|
|
1019
|
+
const result = copy$9(data, {
|
|
1020
|
+
replacementContext,
|
|
1021
|
+
copyElement: (node) => node
|
|
1022
|
+
});
|
|
1023
|
+
expect(result).toMatchObject(expected);
|
|
1024
|
+
});
|
|
1025
|
+
});
|
|
1026
|
+
}
|
|
727
1027
|
function copy$8(value, context) {
|
|
728
1028
|
if (value == null)
|
|
729
1029
|
return value;
|
|
@@ -740,6 +1040,45 @@ function copy$8(value, context) {
|
|
|
740
1040
|
});
|
|
741
1041
|
}
|
|
742
1042
|
}
|
|
1043
|
+
if (import_meta.vitest) {
|
|
1044
|
+
const { describe, test, expect } = import_meta.vitest;
|
|
1045
|
+
describe.concurrent("images copy", () => {
|
|
1046
|
+
test("images are replaced by ones in replacement context", () => {
|
|
1047
|
+
const data = [
|
|
1048
|
+
{
|
|
1049
|
+
key: "0ae80f8f-9d4a-43bc-ae7c-007164a19d22",
|
|
1050
|
+
props: {
|
|
1051
|
+
file: "RmlsZTo5ZmU3ZGUzMi1jY2E0LTRkMjktOWVlMC1jNTI2NDYxY2I1YjM="
|
|
1052
|
+
}
|
|
1053
|
+
},
|
|
1054
|
+
{
|
|
1055
|
+
key: "161674c3-8710-4fd6-90e6-6096c4e9bb88",
|
|
1056
|
+
props: {
|
|
1057
|
+
file: "RmlsZTo5ZmU3ZGUzMi1jY2E0LTRkMjktOWVlMC1jNTI2NDYxY2I1YjM="
|
|
1058
|
+
}
|
|
1059
|
+
}
|
|
1060
|
+
];
|
|
1061
|
+
const expected = JSON.parse(JSON.stringify(data).replaceAll("RmlsZTo5ZmU3ZGUzMi1jY2E0LTRkMjktOWVlMC1jNTI2NDYxY2I1YjM=", "testing"));
|
|
1062
|
+
const replacementContext = {
|
|
1063
|
+
elementHtmlIds: /* @__PURE__ */ new Set(),
|
|
1064
|
+
elementKeys: /* @__PURE__ */ new Map(),
|
|
1065
|
+
swatchIds: /* @__PURE__ */ new Map(),
|
|
1066
|
+
fileIds: /* @__PURE__ */ new Map([["RmlsZTo5ZmU3ZGUzMi1jY2E0LTRkMjktOWVlMC1jNTI2NDYxY2I1YjM=", "testing"]]),
|
|
1067
|
+
typographyIds: /* @__PURE__ */ new Map(),
|
|
1068
|
+
tableIds: /* @__PURE__ */ new Map(),
|
|
1069
|
+
tableColumnIds: /* @__PURE__ */ new Map(),
|
|
1070
|
+
pageIds: /* @__PURE__ */ new Map(),
|
|
1071
|
+
globalElementIds: /* @__PURE__ */ new Map(),
|
|
1072
|
+
globalElementData: /* @__PURE__ */ new Map()
|
|
1073
|
+
};
|
|
1074
|
+
const result = copy$8(data, {
|
|
1075
|
+
replacementContext,
|
|
1076
|
+
copyElement: (node) => node
|
|
1077
|
+
});
|
|
1078
|
+
expect(result).toMatchObject(expected);
|
|
1079
|
+
});
|
|
1080
|
+
});
|
|
1081
|
+
}
|
|
743
1082
|
function copy$7(value, context) {
|
|
744
1083
|
if (value == null)
|
|
745
1084
|
return value;
|
|
@@ -762,12 +1101,88 @@ function copy$6(value, context) {
|
|
|
762
1101
|
});
|
|
763
1102
|
}
|
|
764
1103
|
}
|
|
1104
|
+
if (import_meta.vitest) {
|
|
1105
|
+
const { describe, test, expect } = import_meta.vitest;
|
|
1106
|
+
describe.concurrent("table form fields copy", () => {
|
|
1107
|
+
test("replaces the table column id", () => {
|
|
1108
|
+
const data = {
|
|
1109
|
+
grid: [
|
|
1110
|
+
{
|
|
1111
|
+
value: {
|
|
1112
|
+
count: 12,
|
|
1113
|
+
spans: [[12], [12]]
|
|
1114
|
+
},
|
|
1115
|
+
deviceId: "desktop"
|
|
1116
|
+
}
|
|
1117
|
+
],
|
|
1118
|
+
fields: [
|
|
1119
|
+
{
|
|
1120
|
+
id: "8c4b3dcb-d9d2-4199-9a66-c35aa39248f0",
|
|
1121
|
+
label: "hello",
|
|
1122
|
+
required: true,
|
|
1123
|
+
tableColumnId: "U2luZ2xlTGluZVRleHRUYWJsZUNvbHVtbjphMzQ0Yzk3ZC04MTQ0LTRmMzctYjU2My1hODE5OTQ5OGMyYWI="
|
|
1124
|
+
}
|
|
1125
|
+
]
|
|
1126
|
+
};
|
|
1127
|
+
const expected = JSON.parse(JSON.stringify(data).replace("U2luZ2xlTGluZVRleHRUYWJsZUNvbHVtbjphMzQ0Yzk3ZC04MTQ0LTRmMzctYjU2My1hODE5OTQ5OGMyYWI=", "testing"));
|
|
1128
|
+
const replacementContext = {
|
|
1129
|
+
elementHtmlIds: /* @__PURE__ */ new Set(),
|
|
1130
|
+
elementKeys: /* @__PURE__ */ new Map(),
|
|
1131
|
+
swatchIds: /* @__PURE__ */ new Map(),
|
|
1132
|
+
fileIds: /* @__PURE__ */ new Map(),
|
|
1133
|
+
typographyIds: /* @__PURE__ */ new Map(),
|
|
1134
|
+
tableIds: /* @__PURE__ */ new Map(),
|
|
1135
|
+
tableColumnIds: /* @__PURE__ */ new Map([
|
|
1136
|
+
[
|
|
1137
|
+
"U2luZ2xlTGluZVRleHRUYWJsZUNvbHVtbjphMzQ0Yzk3ZC04MTQ0LTRmMzctYjU2My1hODE5OTQ5OGMyYWI=",
|
|
1138
|
+
"testing"
|
|
1139
|
+
]
|
|
1140
|
+
]),
|
|
1141
|
+
pageIds: /* @__PURE__ */ new Map(),
|
|
1142
|
+
globalElementIds: /* @__PURE__ */ new Map(),
|
|
1143
|
+
globalElementData: /* @__PURE__ */ new Map()
|
|
1144
|
+
};
|
|
1145
|
+
const result = copy$6(data, {
|
|
1146
|
+
replacementContext,
|
|
1147
|
+
copyElement: (node) => node
|
|
1148
|
+
});
|
|
1149
|
+
expect(result).toMatchObject(expected);
|
|
1150
|
+
});
|
|
1151
|
+
});
|
|
1152
|
+
}
|
|
765
1153
|
function copy$5(value, context) {
|
|
766
1154
|
var _a;
|
|
767
1155
|
if (value == null)
|
|
768
1156
|
return value;
|
|
769
1157
|
return (_a = context.replacementContext.tableIds.get(value)) != null ? _a : value;
|
|
770
1158
|
}
|
|
1159
|
+
if (import_meta.vitest) {
|
|
1160
|
+
const { describe, test, expect } = import_meta.vitest;
|
|
1161
|
+
describe.concurrent("table copy", () => {
|
|
1162
|
+
test("replaces the table id", () => {
|
|
1163
|
+
const data = "VGFibGU6MTM5NDhlYzMtMjgwNS00Nzk0LTliNzctNDJkN2RhNmQxZWEy";
|
|
1164
|
+
const replacementContext = {
|
|
1165
|
+
elementHtmlIds: /* @__PURE__ */ new Set(),
|
|
1166
|
+
elementKeys: /* @__PURE__ */ new Map(),
|
|
1167
|
+
swatchIds: /* @__PURE__ */ new Map(),
|
|
1168
|
+
fileIds: /* @__PURE__ */ new Map(),
|
|
1169
|
+
typographyIds: /* @__PURE__ */ new Map(),
|
|
1170
|
+
tableIds: /* @__PURE__ */ new Map([
|
|
1171
|
+
["VGFibGU6MTM5NDhlYzMtMjgwNS00Nzk0LTliNzctNDJkN2RhNmQxZWEy", "testing"]
|
|
1172
|
+
]),
|
|
1173
|
+
tableColumnIds: /* @__PURE__ */ new Map(),
|
|
1174
|
+
pageIds: /* @__PURE__ */ new Map(),
|
|
1175
|
+
globalElementIds: /* @__PURE__ */ new Map(),
|
|
1176
|
+
globalElementData: /* @__PURE__ */ new Map()
|
|
1177
|
+
};
|
|
1178
|
+
const result = copy$5(data, {
|
|
1179
|
+
replacementContext,
|
|
1180
|
+
copyElement: (node) => node
|
|
1181
|
+
});
|
|
1182
|
+
expect(result).toMatch("testing");
|
|
1183
|
+
});
|
|
1184
|
+
});
|
|
1185
|
+
}
|
|
771
1186
|
function copy$4(value, context) {
|
|
772
1187
|
if (value == null)
|
|
773
1188
|
return value;
|
|
@@ -792,6 +1207,110 @@ function copy$4(value, context) {
|
|
|
792
1207
|
});
|
|
793
1208
|
}
|
|
794
1209
|
}
|
|
1210
|
+
if (import_meta.vitest) {
|
|
1211
|
+
const { describe, test, expect } = import_meta.vitest;
|
|
1212
|
+
describe.concurrent("border copy", () => {
|
|
1213
|
+
test("replaces the swatch id", () => {
|
|
1214
|
+
const data = [
|
|
1215
|
+
{
|
|
1216
|
+
value: {
|
|
1217
|
+
borderTop: {
|
|
1218
|
+
color: {
|
|
1219
|
+
alpha: 1,
|
|
1220
|
+
swatchId: "U3dhdGNoOjgwMmNmZGMyLTc5ZDgtNDkyNy1hMDUwLWE1NmM1M2EzYzE0Mg=="
|
|
1221
|
+
},
|
|
1222
|
+
style: "solid",
|
|
1223
|
+
width: 5
|
|
1224
|
+
},
|
|
1225
|
+
borderLeft: {
|
|
1226
|
+
color: {
|
|
1227
|
+
alpha: 1,
|
|
1228
|
+
swatchId: "U3dhdGNoOjgwMmNmZGMyLTc5ZDgtNDkyNy1hMDUwLWE1NmM1M2EzYzE0Mg=="
|
|
1229
|
+
},
|
|
1230
|
+
style: "solid",
|
|
1231
|
+
width: 5
|
|
1232
|
+
},
|
|
1233
|
+
borderRight: {
|
|
1234
|
+
color: {
|
|
1235
|
+
alpha: 1,
|
|
1236
|
+
swatchId: "U3dhdGNoOjgwMmNmZGMyLTc5ZDgtNDkyNy1hMDUwLWE1NmM1M2EzYzE0Mg=="
|
|
1237
|
+
},
|
|
1238
|
+
style: "solid",
|
|
1239
|
+
width: 5
|
|
1240
|
+
},
|
|
1241
|
+
borderBottom: {
|
|
1242
|
+
color: {
|
|
1243
|
+
alpha: 1,
|
|
1244
|
+
swatchId: "U3dhdGNoOjgwMmNmZGMyLTc5ZDgtNDkyNy1hMDUwLWE1NmM1M2EzYzE0Mg=="
|
|
1245
|
+
},
|
|
1246
|
+
style: "solid",
|
|
1247
|
+
width: 5
|
|
1248
|
+
}
|
|
1249
|
+
},
|
|
1250
|
+
deviceId: "desktop"
|
|
1251
|
+
}
|
|
1252
|
+
];
|
|
1253
|
+
const expected = [
|
|
1254
|
+
{
|
|
1255
|
+
value: {
|
|
1256
|
+
borderTop: {
|
|
1257
|
+
color: {
|
|
1258
|
+
alpha: 1,
|
|
1259
|
+
swatchId: "testing"
|
|
1260
|
+
},
|
|
1261
|
+
style: "solid",
|
|
1262
|
+
width: 5
|
|
1263
|
+
},
|
|
1264
|
+
borderLeft: {
|
|
1265
|
+
color: {
|
|
1266
|
+
alpha: 1,
|
|
1267
|
+
swatchId: "testing"
|
|
1268
|
+
},
|
|
1269
|
+
style: "solid",
|
|
1270
|
+
width: 5
|
|
1271
|
+
},
|
|
1272
|
+
borderRight: {
|
|
1273
|
+
color: {
|
|
1274
|
+
alpha: 1,
|
|
1275
|
+
swatchId: "testing"
|
|
1276
|
+
},
|
|
1277
|
+
style: "solid",
|
|
1278
|
+
width: 5
|
|
1279
|
+
},
|
|
1280
|
+
borderBottom: {
|
|
1281
|
+
color: {
|
|
1282
|
+
alpha: 1,
|
|
1283
|
+
swatchId: "testing"
|
|
1284
|
+
},
|
|
1285
|
+
style: "solid",
|
|
1286
|
+
width: 5
|
|
1287
|
+
}
|
|
1288
|
+
},
|
|
1289
|
+
deviceId: "desktop"
|
|
1290
|
+
}
|
|
1291
|
+
];
|
|
1292
|
+
const replacementContext = {
|
|
1293
|
+
elementHtmlIds: /* @__PURE__ */ new Set(),
|
|
1294
|
+
elementKeys: /* @__PURE__ */ new Map(),
|
|
1295
|
+
swatchIds: /* @__PURE__ */ new Map([
|
|
1296
|
+
["U3dhdGNoOjgwMmNmZGMyLTc5ZDgtNDkyNy1hMDUwLWE1NmM1M2EzYzE0Mg==", "testing"]
|
|
1297
|
+
]),
|
|
1298
|
+
fileIds: /* @__PURE__ */ new Map(),
|
|
1299
|
+
typographyIds: /* @__PURE__ */ new Map(),
|
|
1300
|
+
tableIds: /* @__PURE__ */ new Map(),
|
|
1301
|
+
tableColumnIds: /* @__PURE__ */ new Map(),
|
|
1302
|
+
pageIds: /* @__PURE__ */ new Map(),
|
|
1303
|
+
globalElementIds: /* @__PURE__ */ new Map(),
|
|
1304
|
+
globalElementData: /* @__PURE__ */ new Map()
|
|
1305
|
+
};
|
|
1306
|
+
const result = copy$4(data, {
|
|
1307
|
+
replacementContext,
|
|
1308
|
+
copyElement: (node) => node
|
|
1309
|
+
});
|
|
1310
|
+
expect(result).toMatchObject(expected);
|
|
1311
|
+
});
|
|
1312
|
+
});
|
|
1313
|
+
}
|
|
795
1314
|
function copy$3(value, context) {
|
|
796
1315
|
if (value == null)
|
|
797
1316
|
return value;
|
|
@@ -878,6 +1397,100 @@ function copy$3(value, context) {
|
|
|
878
1397
|
}
|
|
879
1398
|
}
|
|
880
1399
|
}
|
|
1400
|
+
if (import_meta.vitest) {
|
|
1401
|
+
const { describe, test, expect } = import_meta.vitest;
|
|
1402
|
+
describe.concurrent("rich text copy", () => {
|
|
1403
|
+
test("replaces the swatch id", () => {
|
|
1404
|
+
const data = {
|
|
1405
|
+
object: "value",
|
|
1406
|
+
document: {
|
|
1407
|
+
data: {},
|
|
1408
|
+
nodes: [
|
|
1409
|
+
{
|
|
1410
|
+
data: {},
|
|
1411
|
+
type: "paragraph",
|
|
1412
|
+
nodes: [
|
|
1413
|
+
{
|
|
1414
|
+
text: "Hello world",
|
|
1415
|
+
marks: [
|
|
1416
|
+
{
|
|
1417
|
+
data: {
|
|
1418
|
+
value: {
|
|
1419
|
+
id: "VHlwb2dyYXBoeTo5ODE1NWY0Ni1mNmQzLTQ1M2YtODk5OC02ZWY5NzJhNTBlY2U=",
|
|
1420
|
+
style: [
|
|
1421
|
+
{
|
|
1422
|
+
value: {
|
|
1423
|
+
color: {
|
|
1424
|
+
alpha: 1,
|
|
1425
|
+
swatchId: "U3dhdGNoOjgwMmNmZGMyLTc5ZDgtNDkyNy1hMDUwLWE1NmM1M2EzYzE0Mg=="
|
|
1426
|
+
},
|
|
1427
|
+
fontSize: {
|
|
1428
|
+
unit: "px",
|
|
1429
|
+
value: 23
|
|
1430
|
+
},
|
|
1431
|
+
lineHeight: 2.5,
|
|
1432
|
+
strikethrough: true
|
|
1433
|
+
},
|
|
1434
|
+
deviceId: "desktop"
|
|
1435
|
+
}
|
|
1436
|
+
]
|
|
1437
|
+
}
|
|
1438
|
+
},
|
|
1439
|
+
type: "typography",
|
|
1440
|
+
object: "mark"
|
|
1441
|
+
}
|
|
1442
|
+
],
|
|
1443
|
+
object: "text"
|
|
1444
|
+
}
|
|
1445
|
+
],
|
|
1446
|
+
object: "block"
|
|
1447
|
+
}
|
|
1448
|
+
],
|
|
1449
|
+
object: "document"
|
|
1450
|
+
},
|
|
1451
|
+
selection: {
|
|
1452
|
+
focus: {
|
|
1453
|
+
path: [0, 0],
|
|
1454
|
+
object: "point",
|
|
1455
|
+
offset: 0
|
|
1456
|
+
},
|
|
1457
|
+
anchor: {
|
|
1458
|
+
path: [0, 0],
|
|
1459
|
+
object: "point",
|
|
1460
|
+
offset: 0
|
|
1461
|
+
},
|
|
1462
|
+
object: "selection",
|
|
1463
|
+
isFocused: false
|
|
1464
|
+
}
|
|
1465
|
+
};
|
|
1466
|
+
const expected = JSON.parse(JSON.stringify(data).replace("U3dhdGNoOjgwMmNmZGMyLTc5ZDgtNDkyNy1hMDUwLWE1NmM1M2EzYzE0Mg==", "swatch-testing").replace("VHlwb2dyYXBoeTo5ODE1NWY0Ni1mNmQzLTQ1M2YtODk5OC02ZWY5NzJhNTBlY2U=", "typography-testing"));
|
|
1467
|
+
const replacementContext = {
|
|
1468
|
+
elementHtmlIds: /* @__PURE__ */ new Set(),
|
|
1469
|
+
elementKeys: /* @__PURE__ */ new Map(),
|
|
1470
|
+
swatchIds: /* @__PURE__ */ new Map([
|
|
1471
|
+
["U3dhdGNoOjgwMmNmZGMyLTc5ZDgtNDkyNy1hMDUwLWE1NmM1M2EzYzE0Mg==", "swatch-testing"]
|
|
1472
|
+
]),
|
|
1473
|
+
fileIds: /* @__PURE__ */ new Map(),
|
|
1474
|
+
typographyIds: /* @__PURE__ */ new Map([
|
|
1475
|
+
[
|
|
1476
|
+
"VHlwb2dyYXBoeTo5ODE1NWY0Ni1mNmQzLTQ1M2YtODk5OC02ZWY5NzJhNTBlY2U=",
|
|
1477
|
+
"typography-testing"
|
|
1478
|
+
]
|
|
1479
|
+
]),
|
|
1480
|
+
tableIds: /* @__PURE__ */ new Map(),
|
|
1481
|
+
tableColumnIds: /* @__PURE__ */ new Map(),
|
|
1482
|
+
pageIds: /* @__PURE__ */ new Map(),
|
|
1483
|
+
globalElementIds: /* @__PURE__ */ new Map(),
|
|
1484
|
+
globalElementData: /* @__PURE__ */ new Map()
|
|
1485
|
+
};
|
|
1486
|
+
const result = copy$3(data, {
|
|
1487
|
+
replacementContext,
|
|
1488
|
+
copyElement: (node) => node
|
|
1489
|
+
});
|
|
1490
|
+
expect(result).toMatchObject(expected);
|
|
1491
|
+
});
|
|
1492
|
+
});
|
|
1493
|
+
}
|
|
881
1494
|
function copy$2(value, context) {
|
|
882
1495
|
if (value == null)
|
|
883
1496
|
return value;
|
|
@@ -955,6 +1568,248 @@ function copy(definition, value, context) {
|
|
|
955
1568
|
return value;
|
|
956
1569
|
}
|
|
957
1570
|
}
|
|
1571
|
+
const ObjectType = {
|
|
1572
|
+
Value: "value",
|
|
1573
|
+
Text: "text",
|
|
1574
|
+
Inline: "inline",
|
|
1575
|
+
Block: "block",
|
|
1576
|
+
Document: "document",
|
|
1577
|
+
Leaf: "leaf",
|
|
1578
|
+
Selection: "selection",
|
|
1579
|
+
Mark: "mark",
|
|
1580
|
+
Range: "range",
|
|
1581
|
+
Decoration: "decoration",
|
|
1582
|
+
Annotation: "annotation",
|
|
1583
|
+
Point: "point",
|
|
1584
|
+
Operation: "operation"
|
|
1585
|
+
};
|
|
1586
|
+
const TextType = {
|
|
1587
|
+
Typography: "typography",
|
|
1588
|
+
Text: "text"
|
|
1589
|
+
};
|
|
1590
|
+
const BlockType = {
|
|
1591
|
+
Paragraph: "paragraph",
|
|
1592
|
+
Heading1: "heading-one",
|
|
1593
|
+
Heading2: "heading-two",
|
|
1594
|
+
Heading3: "heading-three",
|
|
1595
|
+
Heading4: "heading-four",
|
|
1596
|
+
Heading5: "heading-five",
|
|
1597
|
+
Heading6: "heading-six",
|
|
1598
|
+
BlockQuote: "blockquote",
|
|
1599
|
+
UnorderedList: "unordered-list",
|
|
1600
|
+
OrderedList: "ordered-list",
|
|
1601
|
+
ListItem: "list-item",
|
|
1602
|
+
ListItemChild: "list-item-child"
|
|
1603
|
+
};
|
|
1604
|
+
const InlineType = {
|
|
1605
|
+
Code: "code",
|
|
1606
|
+
SuperScript: "superscript",
|
|
1607
|
+
SubScript: "subscript",
|
|
1608
|
+
Link: "link"
|
|
1609
|
+
};
|
|
1610
|
+
function toTextDAO(node) {
|
|
1611
|
+
var _a, _b, _c, _d;
|
|
1612
|
+
const typographyMark = (_a = node.marks) == null ? void 0 : _a.find((mark) => mark.type === TextType.Typography);
|
|
1613
|
+
if (typographyMark) {
|
|
1614
|
+
return [
|
|
1615
|
+
{
|
|
1616
|
+
text: (_b = node.text) != null ? _b : "",
|
|
1617
|
+
type: TextType.Typography,
|
|
1618
|
+
typography: (_c = typographyMark.data) == null ? void 0 : _c.value
|
|
1619
|
+
}
|
|
1620
|
+
];
|
|
1621
|
+
}
|
|
1622
|
+
return [
|
|
1623
|
+
{
|
|
1624
|
+
type: TextType.Text,
|
|
1625
|
+
text: (_d = node.text) != null ? _d : ""
|
|
1626
|
+
}
|
|
1627
|
+
];
|
|
1628
|
+
}
|
|
1629
|
+
function toInlineDAO(node) {
|
|
1630
|
+
var _a, _b, _c, _d;
|
|
1631
|
+
switch (node.type) {
|
|
1632
|
+
case InlineType.Link:
|
|
1633
|
+
return [
|
|
1634
|
+
{
|
|
1635
|
+
children: (_b = (_a = node.nodes) == null ? void 0 : _a.flatMap(toInlineOrTextDAO)) != null ? _b : [],
|
|
1636
|
+
[node.type]: node.data,
|
|
1637
|
+
type: node.type
|
|
1638
|
+
}
|
|
1639
|
+
];
|
|
1640
|
+
case InlineType.Code:
|
|
1641
|
+
case InlineType.SubScript:
|
|
1642
|
+
case InlineType.SuperScript:
|
|
1643
|
+
return [
|
|
1644
|
+
{
|
|
1645
|
+
children: (_d = (_c = node.nodes) == null ? void 0 : _c.flatMap(toInlineOrTextDAO)) != null ? _d : [],
|
|
1646
|
+
type: node.type
|
|
1647
|
+
}
|
|
1648
|
+
];
|
|
1649
|
+
default:
|
|
1650
|
+
return [];
|
|
1651
|
+
}
|
|
1652
|
+
}
|
|
1653
|
+
function toInlineOrTextDAO(node) {
|
|
1654
|
+
switch (node.object) {
|
|
1655
|
+
case ObjectType.Inline:
|
|
1656
|
+
return toInlineDAO(node);
|
|
1657
|
+
case ObjectType.Text:
|
|
1658
|
+
return toTextDAO(node);
|
|
1659
|
+
default:
|
|
1660
|
+
return [];
|
|
1661
|
+
}
|
|
1662
|
+
}
|
|
1663
|
+
function toNodeDAO(node) {
|
|
1664
|
+
var _a, _b;
|
|
1665
|
+
switch (node.object) {
|
|
1666
|
+
case ObjectType.Inline:
|
|
1667
|
+
case ObjectType.Text:
|
|
1668
|
+
return toInlineOrTextDAO(node);
|
|
1669
|
+
case ObjectType.Block:
|
|
1670
|
+
return [
|
|
1671
|
+
{
|
|
1672
|
+
type: node.type,
|
|
1673
|
+
textAlign: (node == null ? void 0 : node.data) && "textAlign" in node.data ? node == null ? void 0 : node.data.textAlign : void 0,
|
|
1674
|
+
children: (_b = (_a = node.nodes) == null ? void 0 : _a.flatMap(toNodeDAO)) != null ? _b : []
|
|
1675
|
+
}
|
|
1676
|
+
];
|
|
1677
|
+
default:
|
|
1678
|
+
return [];
|
|
1679
|
+
}
|
|
1680
|
+
}
|
|
1681
|
+
function richTextDTOtoSelection(data) {
|
|
1682
|
+
var _a, _b, _c, _d;
|
|
1683
|
+
if (((_b = (_a = data.selection) == null ? void 0 : _a.anchor) == null ? void 0 : _b.offset) != null && data.selection.anchor.path != null && ((_d = (_c = data.selection) == null ? void 0 : _c.focus) == null ? void 0 : _d.offset) != null && data.selection.focus.path != null)
|
|
1684
|
+
return {
|
|
1685
|
+
anchor: {
|
|
1686
|
+
offset: data.selection.anchor.offset,
|
|
1687
|
+
path: data.selection.anchor.path
|
|
1688
|
+
},
|
|
1689
|
+
focus: {
|
|
1690
|
+
offset: data.selection.focus.offset,
|
|
1691
|
+
path: data.selection.focus.path
|
|
1692
|
+
}
|
|
1693
|
+
};
|
|
1694
|
+
return null;
|
|
1695
|
+
}
|
|
1696
|
+
function richTextDTOtoDAO(data) {
|
|
1697
|
+
var _a, _b, _c;
|
|
1698
|
+
return (_c = (_b = (_a = data.document) == null ? void 0 : _a.nodes) == null ? void 0 : _b.flatMap(toNodeDAO)) != null ? _c : [];
|
|
1699
|
+
}
|
|
1700
|
+
function toInlineOrTextDTO(node) {
|
|
1701
|
+
switch (node.type) {
|
|
1702
|
+
case TextType.Typography:
|
|
1703
|
+
return [
|
|
1704
|
+
{
|
|
1705
|
+
object: "text",
|
|
1706
|
+
text: node.text,
|
|
1707
|
+
marks: [
|
|
1708
|
+
{
|
|
1709
|
+
data: {
|
|
1710
|
+
value: node.typography
|
|
1711
|
+
},
|
|
1712
|
+
type: "typography",
|
|
1713
|
+
object: "mark"
|
|
1714
|
+
}
|
|
1715
|
+
]
|
|
1716
|
+
}
|
|
1717
|
+
];
|
|
1718
|
+
case TextType.Text:
|
|
1719
|
+
return [
|
|
1720
|
+
{
|
|
1721
|
+
text: node.text,
|
|
1722
|
+
object: "text",
|
|
1723
|
+
marks: []
|
|
1724
|
+
}
|
|
1725
|
+
];
|
|
1726
|
+
case InlineType.Link:
|
|
1727
|
+
return [
|
|
1728
|
+
{
|
|
1729
|
+
object: ObjectType.Inline,
|
|
1730
|
+
nodes: node.children.flatMap(toInlineOrTextDTO),
|
|
1731
|
+
type: node.type,
|
|
1732
|
+
data: node.link
|
|
1733
|
+
}
|
|
1734
|
+
];
|
|
1735
|
+
case InlineType.Code:
|
|
1736
|
+
case InlineType.SubScript:
|
|
1737
|
+
case InlineType.SuperScript:
|
|
1738
|
+
return [
|
|
1739
|
+
{
|
|
1740
|
+
object: "inline",
|
|
1741
|
+
nodes: node.children.flatMap(toInlineOrTextDTO),
|
|
1742
|
+
type: node.type,
|
|
1743
|
+
data: {}
|
|
1744
|
+
}
|
|
1745
|
+
];
|
|
1746
|
+
}
|
|
1747
|
+
}
|
|
1748
|
+
function toNodeDTO(node) {
|
|
1749
|
+
var _a, _b;
|
|
1750
|
+
switch (node.type) {
|
|
1751
|
+
case TextType.Typography:
|
|
1752
|
+
case TextType.Text:
|
|
1753
|
+
case InlineType.Link:
|
|
1754
|
+
case InlineType.Code:
|
|
1755
|
+
case InlineType.SubScript:
|
|
1756
|
+
case InlineType.SuperScript:
|
|
1757
|
+
return toInlineOrTextDTO(node);
|
|
1758
|
+
case BlockType.Heading1:
|
|
1759
|
+
case BlockType.Heading2:
|
|
1760
|
+
case BlockType.Heading3:
|
|
1761
|
+
case BlockType.BlockQuote:
|
|
1762
|
+
case BlockType.Paragraph:
|
|
1763
|
+
case BlockType.OrderedList:
|
|
1764
|
+
case BlockType.UnorderedList:
|
|
1765
|
+
case BlockType.ListItem:
|
|
1766
|
+
case BlockType.ListItemChild:
|
|
1767
|
+
return [
|
|
1768
|
+
{
|
|
1769
|
+
type: node.type,
|
|
1770
|
+
data: node.textAlign ? {
|
|
1771
|
+
textAlign: node.textAlign
|
|
1772
|
+
} : {},
|
|
1773
|
+
object: "block",
|
|
1774
|
+
nodes: (_b = (_a = node.children) == null ? void 0 : _a.flatMap(toNodeDTO)) != null ? _b : []
|
|
1775
|
+
}
|
|
1776
|
+
];
|
|
1777
|
+
default:
|
|
1778
|
+
return [];
|
|
1779
|
+
}
|
|
1780
|
+
}
|
|
1781
|
+
function toSelectionDTO(selection) {
|
|
1782
|
+
if (selection == null)
|
|
1783
|
+
return void 0;
|
|
1784
|
+
return {
|
|
1785
|
+
isFocused: false,
|
|
1786
|
+
marks: void 0,
|
|
1787
|
+
object: "selection",
|
|
1788
|
+
anchor: {
|
|
1789
|
+
offset: selection.anchor.offset,
|
|
1790
|
+
path: selection.anchor.path,
|
|
1791
|
+
object: "point"
|
|
1792
|
+
},
|
|
1793
|
+
focus: {
|
|
1794
|
+
offset: selection.focus.offset,
|
|
1795
|
+
path: selection.focus.path,
|
|
1796
|
+
object: "point"
|
|
1797
|
+
}
|
|
1798
|
+
};
|
|
1799
|
+
}
|
|
1800
|
+
function richTextDAOToDTO(children, selection) {
|
|
1801
|
+
return {
|
|
1802
|
+
document: {
|
|
1803
|
+
data: void 0,
|
|
1804
|
+
nodes: children.flatMap(toNodeDTO),
|
|
1805
|
+
object: "document"
|
|
1806
|
+
},
|
|
1807
|
+
object: "value",
|
|
1808
|
+
selection: toSelectionDTO(selection),
|
|
1809
|
+
annotations: void 0,
|
|
1810
|
+
data: void 0
|
|
1811
|
+
};
|
|
1812
|
+
}
|
|
958
1813
|
const RichTextControlType = "makeswift::controls::rich-text";
|
|
959
1814
|
function RichText() {
|
|
960
1815
|
return { type: RichTextControlType };
|
|
@@ -975,18 +1830,24 @@ class RichTextControl extends PropController {
|
|
|
975
1830
|
__publicField(this, "editor", null);
|
|
976
1831
|
}
|
|
977
1832
|
recv(message) {
|
|
978
|
-
|
|
1833
|
+
if (!this.editor)
|
|
1834
|
+
return;
|
|
979
1835
|
switch (message.type) {
|
|
980
1836
|
case RichTextControlMessageType.CHANGE_BUILDER_EDIT_MODE: {
|
|
981
1837
|
switch (message.editMode) {
|
|
982
1838
|
case BuilderEditMode.BUILD:
|
|
983
|
-
|
|
984
|
-
|
|
1839
|
+
case BuilderEditMode.INTERACT:
|
|
1840
|
+
ReactEditor.deselect(this.editor);
|
|
1841
|
+
ReactEditor.blur(this.editor);
|
|
985
1842
|
}
|
|
986
1843
|
break;
|
|
987
1844
|
}
|
|
988
1845
|
case RichTextControlMessageType.FOCUS: {
|
|
989
|
-
(
|
|
1846
|
+
ReactEditor.focus(this.editor);
|
|
1847
|
+
Transforms.select(this.editor, {
|
|
1848
|
+
anchor: Editor.start(this.editor, []),
|
|
1849
|
+
focus: Editor.end(this.editor, [])
|
|
1850
|
+
});
|
|
990
1851
|
break;
|
|
991
1852
|
}
|
|
992
1853
|
}
|
|
@@ -995,14 +1856,18 @@ class RichTextControl extends PropController {
|
|
|
995
1856
|
this.editor = editor;
|
|
996
1857
|
this.send({
|
|
997
1858
|
type: RichTextControlMessageType.INITIALIZE_EDITOR,
|
|
998
|
-
value: editor.
|
|
999
|
-
});
|
|
1000
|
-
}
|
|
1001
|
-
onChange(change) {
|
|
1002
|
-
this.send({
|
|
1003
|
-
type: RichTextControlMessageType.CHANGE_EDITOR_VALUE,
|
|
1004
|
-
value: change.value.toJSON({ preserveSelection: true })
|
|
1859
|
+
value: richTextDAOToDTO(editor.children, editor.selection)
|
|
1005
1860
|
});
|
|
1861
|
+
const _onChange = editor.onChange;
|
|
1862
|
+
this.editor.onChange = (options) => {
|
|
1863
|
+
_onChange(options);
|
|
1864
|
+
if ((options == null ? void 0 : options.operation) != null) {
|
|
1865
|
+
this.send({
|
|
1866
|
+
type: RichTextControlMessageType.CHANGE_EDITOR_VALUE,
|
|
1867
|
+
value: richTextDAOToDTO(editor.children, editor.selection)
|
|
1868
|
+
});
|
|
1869
|
+
}
|
|
1870
|
+
};
|
|
1006
1871
|
}
|
|
1007
1872
|
focus() {
|
|
1008
1873
|
this.send({ type: RichTextControlMessageType.FOCUS });
|
|
@@ -1020,5 +1885,5 @@ class RichTextControl extends PropController {
|
|
|
1020
1885
|
this.send({ type: RichTextControlMessageType.CHANGE_BOX_MODEL, payload: { boxModel } });
|
|
1021
1886
|
}
|
|
1022
1887
|
}
|
|
1023
|
-
export { WidthPropControllerFormat as $, NavigationLinks as A, Backgrounds as B, ColorControlType as C, Date as D, ElementID as E, Font as F, GapY as G, SocialLinks as H, ImageControlType as I, RichText$1 as J, StyleControlProperty as K, ListControlType as L, Margin as M, Number as N, ImageControlValueFormat as O, Padding as P, LinkControlType as Q, RichTextPropControllerMessageType as R, SlotControlType as S, Types as T, BorderPropControllerFormat as U, Video as V, Width as W, ShadowsPropControllerFormat as X, BorderRadiusPropControllerFormat as Y, MarginPropControllerFormat as Z, PaddingPropControllerFormat as _, copy as a, RichTextControlType as a0, StyleControlType as a1, Color as a2, copyColorData as a3, Image as a4, copyImageData as a5, Link as a6, copyLinkData as a7, List as a8, ListControlMessageType as a9, ListControl as aa, copyListData as ab, Shape as ac, ShapeControlMessageType as ad, ShapeControl as ae, copyShapeData as af, Slot as ag, SlotControlMessageType as ah, SlotControl as ai, copySlotData as aj, Style as ak, copyStyleData as al,
|
|
1888
|
+
export { WidthPropControllerFormat as $, NavigationLinks as A, Backgrounds as B, ColorControlType as C, Date as D, ElementID as E, Font as F, GapY as G, SocialLinks as H, ImageControlType as I, RichText$1 as J, StyleControlProperty as K, ListControlType as L, Margin as M, Number as N, ImageControlValueFormat as O, Padding as P, LinkControlType as Q, RichTextPropControllerMessageType as R, SlotControlType as S, Types as T, BorderPropControllerFormat as U, Video as V, Width as W, ShadowsPropControllerFormat as X, BorderRadiusPropControllerFormat as Y, MarginPropControllerFormat as Z, PaddingPropControllerFormat as _, copy as a, RichTextControlType as a0, StyleControlType as a1, Color as a2, copyColorData as a3, Image as a4, copyImageData as a5, Link as a6, copyLinkData as a7, List as a8, ListControlMessageType as a9, ListControl as aa, copyListData as ab, Shape as ac, ShapeControlMessageType as ad, ShapeControl as ae, copyShapeData as af, Slot as ag, SlotControlMessageType as ah, SlotControl as ai, copySlotData as aj, Style as ak, copyStyleData as al, ObjectType as am, RichText as an, RichTextControlMessageType as ao, RichTextControl as ap, richTextDTOtoSelection as aq, richTextDTOtoDAO as ar, toSelectionDTO as as, richTextDAOToDTO as at, TextType as au, BlockType as av, InlineType as aw, BuilderEditMode as ax, createPropController as ay, TableFormFieldsMessageType as b, copyElementReference as c, descriptors as d, ShapeControlType as e, ResponsiveIconRadioGroup as f, Border as g, BorderRadius as h, Shadows as i, GapX as j, ResponsiveSelect as k, ResponsiveNumber as l, Checkbox as m, Grid as n, TextInput as o, Link$1 as p, ResponsiveColor as q, reducer as r, TextStyle as s, Images as t, ResponsiveLength as u, TextArea as v, Table as w, TableFormFields as x, Image$1 as y, ResponsiveOpacity as z };
|
|
1024
1889
|
//# sourceMappingURL=rich-text.es.js.map
|