@makeswift/runtime 0.7.12 → 0.7.14
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 +1 -0
- package/dist/Box.cjs.js.map +1 -1
- package/dist/Box.es.js +1 -0
- package/dist/Box.es.js.map +1 -1
- package/dist/Button.cjs.js +1 -0
- package/dist/Button.cjs.js.map +1 -1
- package/dist/Button.es.js +1 -0
- package/dist/Button.es.js.map +1 -1
- package/dist/Carousel.cjs.js +1 -0
- package/dist/Carousel.cjs.js.map +1 -1
- package/dist/Carousel.es.js +1 -0
- package/dist/Carousel.es.js.map +1 -1
- package/dist/Countdown.cjs.js +1 -0
- package/dist/Countdown.cjs.js.map +1 -1
- package/dist/Countdown.es.js +1 -0
- package/dist/Countdown.es.js.map +1 -1
- package/dist/Divider.cjs.js +1 -0
- package/dist/Divider.cjs.js.map +1 -1
- package/dist/Divider.es.js +1 -0
- 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 +1 -0
- package/dist/Embed.es.js.map +1 -1
- package/dist/Form.cjs.js +1 -0
- package/dist/Form.cjs.js.map +1 -1
- package/dist/Form.es.js +1 -0
- package/dist/Form.es.js.map +1 -1
- package/dist/Image.cjs.js +1 -0
- package/dist/Image.cjs.js.map +1 -1
- package/dist/Image.es.js +1 -0
- package/dist/Image.es.js.map +1 -1
- package/dist/LiveProvider.cjs.js +1 -0
- package/dist/LiveProvider.cjs.js.map +1 -1
- package/dist/LiveProvider.es.js +2 -1
- package/dist/LiveProvider.es.js.map +1 -1
- package/dist/Navigation.cjs.js +1 -0
- package/dist/Navigation.cjs.js.map +1 -1
- package/dist/Navigation.es.js +1 -0
- package/dist/Navigation.es.js.map +1 -1
- package/dist/PreviewProvider.cjs.js +1 -0
- package/dist/PreviewProvider.cjs.js.map +1 -1
- package/dist/PreviewProvider.es.js +2 -1
- package/dist/PreviewProvider.es.js.map +1 -1
- package/dist/ReadOnlyText.cjs.js +16 -26
- package/dist/ReadOnlyText.cjs.js.map +1 -1
- package/dist/ReadOnlyText.es.js +16 -25
- package/dist/ReadOnlyText.es.js.map +1 -1
- package/dist/Root.cjs.js +1 -0
- package/dist/Root.cjs.js.map +1 -1
- package/dist/Root.es.js +1 -0
- package/dist/Root.es.js.map +1 -1
- package/dist/SocialLinks.cjs.js +1 -0
- package/dist/SocialLinks.cjs.js.map +1 -1
- package/dist/SocialLinks.es.js +1 -0
- package/dist/SocialLinks.es.js.map +1 -1
- package/dist/Text.cjs.js +1 -0
- package/dist/Text.cjs.js.map +1 -1
- package/dist/Text.es.js +1 -0
- 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 +1 -0
- package/dist/Video.es.js.map +1 -1
- package/dist/components.cjs.js +1 -0
- package/dist/components.cjs.js.map +1 -1
- package/dist/components.es.js +1 -0
- package/dist/components.es.js.map +1 -1
- package/dist/constants.cjs.js +3 -313
- package/dist/constants.cjs.js.map +1 -1
- package/dist/constants.es.js +3 -300
- package/dist/constants.es.js.map +1 -1
- package/dist/controls.cjs.js +1 -4
- package/dist/controls.cjs.js.map +1 -1
- package/dist/controls.es.js +1 -2
- package/dist/controls.es.js.map +1 -1
- package/dist/index.cjs.js +15 -13
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.cjs2.js +6 -6
- package/dist/index.cjs2.js.map +1 -1
- package/dist/index.cjs5.js +1 -0
- package/dist/index.cjs5.js.map +1 -1
- package/dist/index.cjs6.js +146 -134
- package/dist/index.cjs6.js.map +1 -1
- package/dist/index.es.js +5 -4
- package/dist/index.es.js.map +1 -1
- package/dist/index.es2.js +1 -1
- package/dist/index.es5.js +1 -0
- package/dist/index.es5.js.map +1 -1
- package/dist/index.es6.js +147 -135
- package/dist/index.es6.js.map +1 -1
- package/dist/introspection.cjs.js +331 -0
- package/dist/introspection.cjs.js.map +1 -0
- package/dist/introspection.es.js +317 -0
- package/dist/introspection.es.js.map +1 -0
- package/dist/{typography.cjs.js → leaf.cjs.js} +51 -14
- package/dist/leaf.cjs.js.map +1 -0
- package/dist/{typography.es.js → leaf.es.js} +49 -12
- package/dist/leaf.es.js.map +1 -0
- package/dist/main.cjs.js +1 -0
- package/dist/main.cjs.js.map +1 -1
- package/dist/main.es.js +1 -0
- package/dist/main.es.js.map +1 -1
- package/dist/next.cjs.js +1 -0
- package/dist/next.cjs.js.map +1 -1
- package/dist/next.es.js +2 -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 +1 -0
- package/dist/prop-controllers.es.js.map +1 -1
- package/dist/react.cjs.js +1 -0
- package/dist/react.cjs.js.map +1 -1
- package/dist/react.es.js +1 -0
- package/dist/react.es.js.map +1 -1
- package/dist/rich-text.cjs.js +29 -43
- package/dist/rich-text.cjs.js.map +1 -1
- package/dist/rich-text.es.js +30 -44
- package/dist/rich-text.es.js.map +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/editable-text.d.ts.map +1 -1
- package/dist/types/src/components/builtin/Text/EditableText/useSyncWithBuilder.d.ts.map +1 -1
- package/dist/types/src/components/builtin/Text/ReadOnlyText.d.ts +2 -5
- package/dist/types/src/components/builtin/Text/ReadOnlyText.d.ts.map +1 -1
- package/dist/types/src/components/builtin/Text/components/Leaf/index.d.ts +0 -1
- package/dist/types/src/components/builtin/Text/components/Leaf/index.d.ts.map +1 -1
- package/dist/types/src/components/builtin/Text/components/Leaf/leaf.d.ts +21 -0
- package/dist/types/src/components/builtin/Text/components/Leaf/leaf.d.ts.map +1 -1
- package/dist/types/src/controls/rich-text/index.d.ts +0 -1
- package/dist/types/src/controls/rich-text/index.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/types.d.ts +47 -27
- package/dist/types/src/controls/rich-text/types.d.ts.map +1 -1
- package/dist/types/src/prop-controllers/index.d.ts +1 -0
- package/dist/types/src/prop-controllers/index.d.ts.map +1 -1
- package/dist/types/src/slate/BlockPlugin/clearBlockKeyForDevice.d.ts +5 -0
- package/dist/types/src/slate/BlockPlugin/clearBlockKeyForDevice.d.ts.map +1 -0
- package/dist/types/src/slate/BlockPlugin/index.d.ts +9 -0
- package/dist/types/src/slate/BlockPlugin/index.d.ts.map +1 -0
- package/dist/types/src/slate/BlockPlugin/setBlockKeyForDevice.d.ts +5 -0
- package/dist/types/src/slate/BlockPlugin/setBlockKeyForDevice.d.ts.map +1 -0
- package/dist/types/src/slate/BlockPlugin/types.d.ts +4 -0
- package/dist/types/src/slate/BlockPlugin/types.d.ts.map +1 -0
- package/dist/types/src/slate/ListPlugin/constants.d.ts.map +1 -0
- package/dist/types/src/slate/ListPlugin/dedent.d.ts.map +1 -0
- package/dist/types/src/slate/ListPlugin/indent.d.ts.map +1 -0
- package/dist/types/src/{components/builtin/Text/EditableText/ListPlugin/ListPlugin.d.ts → slate/ListPlugin/index.d.ts} +6 -2
- package/dist/types/src/slate/ListPlugin/index.d.ts.map +1 -0
- package/dist/types/src/{components/builtin/Text/EditableText/ListPlugin/lib → slate/ListPlugin}/toggleList.d.ts +1 -1
- package/dist/types/src/slate/ListPlugin/toggleList.d.ts.map +1 -0
- package/dist/types/src/slate/ListPlugin/unwrapList.d.ts.map +1 -0
- package/dist/types/src/slate/ListPlugin/utils/filterForSubtreeRoots.d.ts.map +1 -0
- package/dist/types/src/slate/ListPlugin/utils/getSelectedListItems.d.ts.map +1 -0
- package/dist/types/src/slate/ListPlugin/utils/location.d.ts.map +1 -0
- package/dist/types/src/{components/builtin/Text/EditableText/ListPlugin/lib → slate/ListPlugin}/wrapList.d.ts +1 -1
- package/dist/types/src/slate/ListPlugin/wrapList.d.ts.map +1 -0
- package/dist/types/src/slate/TypographyPlugin/clearActiveTypographyStyle.d.ts +3 -0
- package/dist/types/src/slate/TypographyPlugin/clearActiveTypographyStyle.d.ts.map +1 -0
- package/dist/types/src/slate/TypographyPlugin/clearDeviceActiveTypography.d.ts +3 -0
- package/dist/types/src/slate/TypographyPlugin/clearDeviceActiveTypography.d.ts.map +1 -0
- package/dist/types/src/slate/TypographyPlugin/detachActiveTypography.d.ts +4 -0
- package/dist/types/src/slate/TypographyPlugin/detachActiveTypography.d.ts.map +1 -0
- package/dist/types/src/slate/TypographyPlugin/index.d.ts +15 -0
- package/dist/types/src/slate/TypographyPlugin/index.d.ts.map +1 -0
- package/dist/types/src/slate/TypographyPlugin/setActiveTypographyId.d.ts +3 -0
- package/dist/types/src/slate/TypographyPlugin/setActiveTypographyId.d.ts.map +1 -0
- package/dist/types/src/slate/TypographyPlugin/setActiveTypographyStyle.d.ts +3 -0
- package/dist/types/src/slate/TypographyPlugin/setActiveTypographyStyle.d.ts.map +1 -0
- package/dist/types/src/slate/index.d.ts +4 -0
- package/dist/types/src/slate/index.d.ts.map +1 -0
- package/dist/types/src/{components/builtin/Text/EditableText/ListPlugin/lib → slate}/utils/editor.d.ts +1 -1
- package/dist/types/src/slate/utils/editor.d.ts.map +1 -0
- package/dist/types/src/{components/builtin/Text/EditableText/ListPlugin/lib → slate}/utils/element.d.ts +3 -5
- package/dist/types/src/slate/utils/element.d.ts.map +1 -0
- package/package.json +8 -1
- package/dist/compare.cjs.js +0 -126
- package/dist/compare.cjs.js.map +0 -1
- package/dist/compare.es.js +0 -124
- package/dist/compare.es.js.map +0 -1
- package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/ListPlugin.d.ts.map +0 -1
- package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/constants.d.ts.map +0 -1
- package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/index.d.ts +0 -2
- package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/index.d.ts.map +0 -1
- package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/lib/dedent.d.ts.map +0 -1
- package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/lib/indent.d.ts.map +0 -1
- package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/lib/index.d.ts +0 -6
- package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/lib/index.d.ts.map +0 -1
- package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/lib/toggleList.d.ts.map +0 -1
- package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/lib/unwrapList.d.ts.map +0 -1
- package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/lib/utils/editor.d.ts.map +0 -1
- package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/lib/utils/element.d.ts.map +0 -1
- package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/lib/utils/filterForSubtreeRoots.d.ts.map +0 -1
- package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/lib/utils/getSelectedListItems.d.ts.map +0 -1
- package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/lib/utils/location.d.ts.map +0 -1
- package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/lib/wrapList.d.ts.map +0 -1
- package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/test/dedent.test.d.ts +0 -3
- package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/test/dedent.test.d.ts.map +0 -1
- package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/test/indent.test.d.ts +0 -3
- package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/test/indent.test.d.ts.map +0 -1
- package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/test/normalization.test.d.ts +0 -3
- package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/test/normalization.test.d.ts.map +0 -1
- package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/test/slate-test-helper.d.ts +0 -48
- package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/test/slate-test-helper.d.ts.map +0 -1
- package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/test/toggleList.test.d.ts +0 -3
- package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/test/toggleList.test.d.ts.map +0 -1
- package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/test/types.d.ts +0 -21
- package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/test/types.d.ts.map +0 -1
- package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/test/unwrapList.test.d.ts +0 -3
- package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/test/unwrapList.test.d.ts.map +0 -1
- package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/test/utils/filterForSubtreeRoots.test.d.ts +0 -2
- package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/test/utils/filterForSubtreeRoots.test.d.ts.map +0 -1
- package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/test/utils/getSelectedListItems.test.d.ts +0 -3
- package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/test/utils/getSelectedListItems.test.d.ts.map +0 -1
- package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/test/wrapList.test.d.ts +0 -3
- package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/test/wrapList.test.d.ts.map +0 -1
- package/dist/types/src/components/builtin/Text/components/Leaf/typography.d.ts +0 -27
- package/dist/types/src/components/builtin/Text/components/Leaf/typography.d.ts.map +0 -1
- package/dist/types/src/controls/rich-text/compare.d.ts +0 -5
- package/dist/types/src/controls/rich-text/compare.d.ts.map +0 -1
- package/dist/types/src/controls/rich-text/compare.test.d.ts +0 -2
- package/dist/types/src/controls/rich-text/compare.test.d.ts.map +0 -1
- package/dist/typography.cjs.js.map +0 -1
- package/dist/typography.es.js.map +0 -1
- /package/dist/types/src/{components/builtin/Text/EditableText → slate}/ListPlugin/constants.d.ts +0 -0
- /package/dist/types/src/{components/builtin/Text/EditableText/ListPlugin/lib → slate/ListPlugin}/dedent.d.ts +0 -0
- /package/dist/types/src/{components/builtin/Text/EditableText/ListPlugin/lib → slate/ListPlugin}/indent.d.ts +0 -0
- /package/dist/types/src/{components/builtin/Text/EditableText/ListPlugin/lib → slate/ListPlugin}/unwrapList.d.ts +0 -0
- /package/dist/types/src/{components/builtin/Text/EditableText/ListPlugin/lib → slate/ListPlugin}/utils/filterForSubtreeRoots.d.ts +0 -0
- /package/dist/types/src/{components/builtin/Text/EditableText/ListPlugin/lib → slate/ListPlugin}/utils/getSelectedListItems.d.ts +0 -0
- /package/dist/types/src/{components/builtin/Text/EditableText/ListPlugin/lib → slate/ListPlugin}/utils/location.d.ts +0 -0
package/dist/index.cjs6.js
CHANGED
|
@@ -37,22 +37,22 @@ var slateReact = require("slate-react");
|
|
|
37
37
|
var css = require("@emotion/css");
|
|
38
38
|
var boxModels = require("./box-models.cjs.js");
|
|
39
39
|
var richText = require("./rich-text.cjs.js");
|
|
40
|
-
var
|
|
40
|
+
var leaf = require("./leaf.cjs.js");
|
|
41
|
+
var next = require("./index.cjs.js");
|
|
41
42
|
var jsxRuntime = require("react/jsx-runtime");
|
|
43
|
+
var index = require("./index.cjs3.js");
|
|
44
|
+
var isHotkey = require("is-hotkey");
|
|
42
45
|
require("use-sync-external-store/shim");
|
|
43
|
-
var next = require("./index.cjs.js");
|
|
44
46
|
require("@emotion/serialize");
|
|
45
47
|
require("@emotion/utils");
|
|
46
|
-
var index = require("./index.cjs3.js");
|
|
47
|
-
var compare = require("./compare.cjs.js");
|
|
48
|
-
var isHotkey = require("is-hotkey");
|
|
49
48
|
require("css-box-model");
|
|
50
49
|
require("./actions.cjs.js");
|
|
50
|
+
require("./introspection.cjs.js");
|
|
51
|
+
require("use-sync-external-store/shim/with-selector");
|
|
52
|
+
require("next/dynamic");
|
|
51
53
|
require("./constants.cjs.js");
|
|
52
54
|
require("redux");
|
|
53
55
|
require("redux-thunk");
|
|
54
|
-
require("use-sync-external-store/shim/with-selector");
|
|
55
|
-
require("next/dynamic");
|
|
56
56
|
require("./text-input.cjs.js");
|
|
57
57
|
require("./combobox.cjs.js");
|
|
58
58
|
require("./types.cjs.js");
|
|
@@ -74,23 +74,6 @@ function _interopDefaultLegacy(e) {
|
|
|
74
74
|
return e && typeof e === "object" && "default" in e ? e : { "default": e };
|
|
75
75
|
}
|
|
76
76
|
var isHotkey__default = /* @__PURE__ */ _interopDefaultLegacy(isHotkey);
|
|
77
|
-
function Leaf(_a) {
|
|
78
|
-
var _b = _a, {
|
|
79
|
-
leaf
|
|
80
|
-
} = _b, props = __objRest(_b, [
|
|
81
|
-
"leaf"
|
|
82
|
-
]);
|
|
83
|
-
switch (leaf.type) {
|
|
84
|
-
case richText.TextType.Typography:
|
|
85
|
-
return /* @__PURE__ */ jsxRuntime.jsx(typography.TypographyLeaf, __spreadValues({
|
|
86
|
-
leaf
|
|
87
|
-
}, props));
|
|
88
|
-
default:
|
|
89
|
-
return /* @__PURE__ */ jsxRuntime.jsx("span", __spreadProps(__spreadValues({}, props.attributes), {
|
|
90
|
-
children: props.children
|
|
91
|
-
}));
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
77
|
function BlockElement({
|
|
95
78
|
element,
|
|
96
79
|
attributes,
|
|
@@ -175,10 +158,10 @@ function BlockElement({
|
|
|
175
158
|
}));
|
|
176
159
|
}
|
|
177
160
|
}
|
|
178
|
-
function StyledLink(
|
|
179
|
-
var
|
|
161
|
+
function StyledLink(_a) {
|
|
162
|
+
var _b = _a, {
|
|
180
163
|
className
|
|
181
|
-
} =
|
|
164
|
+
} = _b, restOfProps = __objRest(_b, [
|
|
182
165
|
"className"
|
|
183
166
|
]);
|
|
184
167
|
return /* @__PURE__ */ jsxRuntime.jsx(index.Link, __spreadProps(__spreadValues({}, restOfProps), {
|
|
@@ -212,10 +195,10 @@ function InlineElement({
|
|
|
212
195
|
}));
|
|
213
196
|
}
|
|
214
197
|
}
|
|
215
|
-
function Element(
|
|
216
|
-
var
|
|
198
|
+
function Element(_c) {
|
|
199
|
+
var _d = _c, {
|
|
217
200
|
element
|
|
218
|
-
} =
|
|
201
|
+
} = _d, props = __objRest(_d, [
|
|
219
202
|
"element"
|
|
220
203
|
]);
|
|
221
204
|
switch (element.type) {
|
|
@@ -251,7 +234,7 @@ function useSyncWithBuilder(editor, text) {
|
|
|
251
234
|
if (shouldCommit && text) {
|
|
252
235
|
const nextValue = richText.richTextDTOtoDAO(text);
|
|
253
236
|
const nextSelection = richText.richTextDTOtoSelection(text);
|
|
254
|
-
if (!
|
|
237
|
+
if (!next.deepEqual(editor.children, nextValue) || !next.deepEqual(editor.selection, nextSelection)) {
|
|
255
238
|
editor.children = nextValue;
|
|
256
239
|
editor.selection = nextSelection;
|
|
257
240
|
editor.onChange();
|
|
@@ -270,15 +253,17 @@ function useSyncWithBuilder(editor, text) {
|
|
|
270
253
|
}, [shouldCommit]);
|
|
271
254
|
return React.useCallback(() => setShouldCommit(false), []);
|
|
272
255
|
}
|
|
256
|
+
const LIST_ITEM_CHILD_POSITION = 0;
|
|
257
|
+
const LIST_ITEM_LIST_POSITION = 1;
|
|
273
258
|
const ElementUtils = {
|
|
274
|
-
|
|
275
|
-
return
|
|
259
|
+
isBlock(node) {
|
|
260
|
+
return slate.Element.isElement(node) && (slate.Element.isElementType(node, richText.BlockType.Paragraph) || slate.Element.isElementType(node, richText.BlockType.Heading1) || slate.Element.isElementType(node, richText.BlockType.Heading2) || slate.Element.isElementType(node, richText.BlockType.Heading3) || slate.Element.isElementType(node, richText.BlockType.Heading3) || slate.Element.isElementType(node, richText.BlockType.Heading4) || slate.Element.isElementType(node, richText.BlockType.Heading5) || slate.Element.isElementType(node, richText.BlockType.Heading6) || slate.Element.isElementType(node, richText.BlockType.BlockQuote) || slate.Element.isElementType(node, richText.BlockType.UnorderedList) || slate.Element.isElementType(node, richText.BlockType.OrderedList) || slate.Element.isElementType(node, richText.BlockType.ListItem) || slate.Element.isElementType(node, richText.BlockType.ListItemChild));
|
|
276
261
|
},
|
|
277
|
-
|
|
278
|
-
return slate.Element.isElementType(node, richText.
|
|
262
|
+
isInline(node) {
|
|
263
|
+
return slate.Element.isElement(node) && (slate.Element.isElementType(node, richText.InlineType.Link) || slate.Element.isElementType(node, richText.InlineType.Link) || slate.Element.isElementType(node, richText.InlineType.SubScript) || slate.Element.isElementType(node, richText.InlineType.SuperScript));
|
|
279
264
|
},
|
|
280
|
-
|
|
281
|
-
return
|
|
265
|
+
isConvertibleToListTextNode(node) {
|
|
266
|
+
return !this.isList(node) && !this.isListItem(node) && !this.isListItemChild(node);
|
|
282
267
|
},
|
|
283
268
|
isParagraph(node) {
|
|
284
269
|
return slate.Element.isElementType(node, richText.BlockType.Paragraph);
|
|
@@ -293,7 +278,7 @@ const ElementUtils = {
|
|
|
293
278
|
return slate.Element.isElementType(node, richText.BlockType.ListItemChild);
|
|
294
279
|
},
|
|
295
280
|
createText() {
|
|
296
|
-
return { text: ""
|
|
281
|
+
return { text: "" };
|
|
297
282
|
},
|
|
298
283
|
createParagraph() {
|
|
299
284
|
return {
|
|
@@ -317,36 +302,6 @@ const ElementUtils = {
|
|
|
317
302
|
};
|
|
318
303
|
}
|
|
319
304
|
};
|
|
320
|
-
function wrapList(editor, options = { type: richText.BlockType.UnorderedList }) {
|
|
321
|
-
if (!editor.selection)
|
|
322
|
-
return;
|
|
323
|
-
const nonListEntries = Array.from(slate.Editor.nodes(editor, {
|
|
324
|
-
at: editor.selection,
|
|
325
|
-
match: (node) => {
|
|
326
|
-
return slate.Element.isElement(node) && ElementUtils.isConvertibleToListTextNode(node);
|
|
327
|
-
}
|
|
328
|
-
}));
|
|
329
|
-
const refs = nonListEntries.map(([_, path]) => slate.Editor.pathRef(editor, path));
|
|
330
|
-
refs.forEach((ref) => {
|
|
331
|
-
const path = ref.current;
|
|
332
|
-
if (path) {
|
|
333
|
-
slate.Editor.withoutNormalizing(editor, () => {
|
|
334
|
-
slate.Transforms.setNodes(editor, { type: richText.BlockType.ListItemChild }, {
|
|
335
|
-
at: path
|
|
336
|
-
});
|
|
337
|
-
slate.Transforms.wrapNodes(editor, ElementUtils.createListItem(), {
|
|
338
|
-
at: path
|
|
339
|
-
});
|
|
340
|
-
slate.Transforms.wrapNodes(editor, ElementUtils.createList(options.type), {
|
|
341
|
-
at: path
|
|
342
|
-
});
|
|
343
|
-
});
|
|
344
|
-
}
|
|
345
|
-
ref.unref();
|
|
346
|
-
});
|
|
347
|
-
}
|
|
348
|
-
const LIST_ITEM_CHILD_POSITION = 0;
|
|
349
|
-
const LIST_ITEM_LIST_POSITION = 1;
|
|
350
305
|
const EditorUtils = {
|
|
351
306
|
getFirstAncestorList(editor, path) {
|
|
352
307
|
const parentList = slate.Editor.above(editor, {
|
|
@@ -389,58 +344,6 @@ function getSelectedListItems(editor) {
|
|
|
389
344
|
const firstAncestorPath = (_b = (_a = EditorUtils.getFirstAncestorListItem(editor, start)) == null ? void 0 : _a[1]) != null ? _b : [];
|
|
390
345
|
return Array.from(listItems).filter((node) => slate.Path.isDescendant(start, node[1]) ? slate.Path.equals(node[1], firstAncestorPath) : !slate.Path.isAfter(start, node[1]));
|
|
391
346
|
}
|
|
392
|
-
function unwrapPath(editor, listItemPath) {
|
|
393
|
-
const parentList = EditorUtils.getFirstAncestorList(editor, listItemPath);
|
|
394
|
-
const listItemContainingParentList = EditorUtils.getFirstAncestorListItem(editor, listItemPath);
|
|
395
|
-
if (!parentList || listItemContainingParentList)
|
|
396
|
-
return;
|
|
397
|
-
slate.Editor.withoutNormalizing(editor, () => {
|
|
398
|
-
const listItemTextPath = [...listItemPath, LIST_ITEM_CHILD_POSITION];
|
|
399
|
-
const listItemNestedListPath = [...listItemPath, LIST_ITEM_LIST_POSITION];
|
|
400
|
-
if (slate.Node.has(editor, listItemNestedListPath)) {
|
|
401
|
-
slate.Transforms.setNodes(editor, { type: parentList[0].type }, { at: listItemNestedListPath });
|
|
402
|
-
slate.Transforms.liftNodes(editor, { at: listItemNestedListPath });
|
|
403
|
-
slate.Transforms.liftNodes(editor, { at: slate.Path.next(listItemPath) });
|
|
404
|
-
}
|
|
405
|
-
if (slate.Node.has(editor, listItemTextPath)) {
|
|
406
|
-
slate.Transforms.setNodes(editor, { type: richText.BlockType.Paragraph }, {
|
|
407
|
-
at: listItemTextPath
|
|
408
|
-
});
|
|
409
|
-
slate.Transforms.liftNodes(editor, { at: listItemTextPath });
|
|
410
|
-
slate.Transforms.liftNodes(editor, { at: listItemPath });
|
|
411
|
-
}
|
|
412
|
-
});
|
|
413
|
-
}
|
|
414
|
-
function unwrapList(editor) {
|
|
415
|
-
if (!editor.selection)
|
|
416
|
-
return;
|
|
417
|
-
const listItems = getSelectedListItems(editor);
|
|
418
|
-
const subRoots = filterForSubtreeRoots(listItems);
|
|
419
|
-
const refs = subRoots.map(([_, path]) => slate.Editor.pathRef(editor, path));
|
|
420
|
-
refs.forEach((ref) => {
|
|
421
|
-
if (ref.current) {
|
|
422
|
-
unwrapPath(editor, ref.current);
|
|
423
|
-
}
|
|
424
|
-
ref.unref();
|
|
425
|
-
});
|
|
426
|
-
}
|
|
427
|
-
function toggleList(editor, options = { type: richText.BlockType.UnorderedList }) {
|
|
428
|
-
if (!editor.selection)
|
|
429
|
-
return;
|
|
430
|
-
const start = LocationUtils.getStartPath(editor.selection);
|
|
431
|
-
const ancestorPath = slate.Path.ancestors(start).at(1);
|
|
432
|
-
if (!ancestorPath || !slate.Node.has(editor, ancestorPath))
|
|
433
|
-
return;
|
|
434
|
-
const ancestor = slate.Node.get(editor, ancestorPath);
|
|
435
|
-
if (!ElementUtils.isList(ancestor)) {
|
|
436
|
-
return wrapList(editor, { type: options.type });
|
|
437
|
-
}
|
|
438
|
-
if (ancestor.type === options.type) {
|
|
439
|
-
unwrapList(editor);
|
|
440
|
-
} else {
|
|
441
|
-
slate.Transforms.setNodes(editor, { type: options.type }, { at: ancestorPath });
|
|
442
|
-
}
|
|
443
|
-
}
|
|
444
347
|
function indentPath(editor, path) {
|
|
445
348
|
const parent = slate.Node.parent(editor, path);
|
|
446
349
|
if (!path || !slate.Path.hasPrevious(path) || !ElementUtils.isList(parent))
|
|
@@ -514,6 +417,86 @@ function dedent(editor) {
|
|
|
514
417
|
ref.unref();
|
|
515
418
|
});
|
|
516
419
|
}
|
|
420
|
+
function unwrapPath(editor, listItemPath) {
|
|
421
|
+
const parentList = EditorUtils.getFirstAncestorList(editor, listItemPath);
|
|
422
|
+
const listItemContainingParentList = EditorUtils.getFirstAncestorListItem(editor, listItemPath);
|
|
423
|
+
if (!parentList || listItemContainingParentList)
|
|
424
|
+
return;
|
|
425
|
+
slate.Editor.withoutNormalizing(editor, () => {
|
|
426
|
+
const listItemTextPath = [...listItemPath, LIST_ITEM_CHILD_POSITION];
|
|
427
|
+
const listItemNestedListPath = [...listItemPath, LIST_ITEM_LIST_POSITION];
|
|
428
|
+
if (slate.Node.has(editor, listItemNestedListPath)) {
|
|
429
|
+
slate.Transforms.setNodes(editor, { type: parentList[0].type }, { at: listItemNestedListPath });
|
|
430
|
+
slate.Transforms.liftNodes(editor, { at: listItemNestedListPath });
|
|
431
|
+
slate.Transforms.liftNodes(editor, { at: slate.Path.next(listItemPath) });
|
|
432
|
+
}
|
|
433
|
+
if (slate.Node.has(editor, listItemTextPath)) {
|
|
434
|
+
slate.Transforms.setNodes(editor, { type: richText.BlockType.Paragraph }, {
|
|
435
|
+
at: listItemTextPath
|
|
436
|
+
});
|
|
437
|
+
slate.Transforms.liftNodes(editor, { at: listItemTextPath });
|
|
438
|
+
slate.Transforms.liftNodes(editor, { at: listItemPath });
|
|
439
|
+
}
|
|
440
|
+
});
|
|
441
|
+
}
|
|
442
|
+
function unwrapList(editor) {
|
|
443
|
+
if (!editor.selection)
|
|
444
|
+
return;
|
|
445
|
+
const listItems = getSelectedListItems(editor);
|
|
446
|
+
const subRoots = filterForSubtreeRoots(listItems);
|
|
447
|
+
const refs = subRoots.map(([_, path]) => slate.Editor.pathRef(editor, path));
|
|
448
|
+
refs.forEach((ref) => {
|
|
449
|
+
if (ref.current) {
|
|
450
|
+
unwrapPath(editor, ref.current);
|
|
451
|
+
}
|
|
452
|
+
ref.unref();
|
|
453
|
+
});
|
|
454
|
+
}
|
|
455
|
+
function wrapList(editor, options = { type: richText.BlockType.UnorderedList }) {
|
|
456
|
+
if (!editor.selection)
|
|
457
|
+
return;
|
|
458
|
+
const nonListEntries = Array.from(slate.Editor.nodes(editor, {
|
|
459
|
+
at: editor.selection,
|
|
460
|
+
match: (node) => {
|
|
461
|
+
return slate.Element.isElement(node) && ElementUtils.isConvertibleToListTextNode(node);
|
|
462
|
+
}
|
|
463
|
+
}));
|
|
464
|
+
const refs = nonListEntries.map(([_, path]) => slate.Editor.pathRef(editor, path));
|
|
465
|
+
refs.forEach((ref) => {
|
|
466
|
+
const path = ref.current;
|
|
467
|
+
if (path) {
|
|
468
|
+
slate.Editor.withoutNormalizing(editor, () => {
|
|
469
|
+
slate.Transforms.setNodes(editor, { type: richText.BlockType.ListItemChild }, {
|
|
470
|
+
at: path
|
|
471
|
+
});
|
|
472
|
+
slate.Transforms.wrapNodes(editor, ElementUtils.createListItem(), {
|
|
473
|
+
at: path
|
|
474
|
+
});
|
|
475
|
+
slate.Transforms.wrapNodes(editor, ElementUtils.createList(options.type), {
|
|
476
|
+
at: path
|
|
477
|
+
});
|
|
478
|
+
});
|
|
479
|
+
}
|
|
480
|
+
ref.unref();
|
|
481
|
+
});
|
|
482
|
+
}
|
|
483
|
+
function toggleList(editor, options = { type: richText.BlockType.UnorderedList }) {
|
|
484
|
+
if (!editor.selection)
|
|
485
|
+
return;
|
|
486
|
+
const start = LocationUtils.getStartPath(editor.selection);
|
|
487
|
+
const ancestorPath = slate.Path.ancestors(start).at(1);
|
|
488
|
+
if (!ancestorPath || !slate.Node.has(editor, ancestorPath))
|
|
489
|
+
return;
|
|
490
|
+
const ancestor = slate.Node.get(editor, ancestorPath);
|
|
491
|
+
if (!ElementUtils.isList(ancestor)) {
|
|
492
|
+
return wrapList(editor, { type: options.type });
|
|
493
|
+
}
|
|
494
|
+
if (ancestor.type === options.type) {
|
|
495
|
+
unwrapList(editor);
|
|
496
|
+
} else {
|
|
497
|
+
slate.Transforms.setNodes(editor, { type: options.type }, { at: ancestorPath });
|
|
498
|
+
}
|
|
499
|
+
}
|
|
517
500
|
const List = {
|
|
518
501
|
unwrapList,
|
|
519
502
|
wrapList,
|
|
@@ -580,6 +563,7 @@ function onKeyDown(e, editor) {
|
|
|
580
563
|
}
|
|
581
564
|
}
|
|
582
565
|
function withList(editor) {
|
|
566
|
+
const { normalizeNode } = editor;
|
|
583
567
|
editor.normalizeNode = (entry) => {
|
|
584
568
|
const [normalizationNode, normalizationPath] = entry;
|
|
585
569
|
if (ElementUtils.isListItem(normalizationNode)) {
|
|
@@ -599,18 +583,10 @@ function withList(editor) {
|
|
|
599
583
|
return;
|
|
600
584
|
}
|
|
601
585
|
}
|
|
602
|
-
if (
|
|
603
|
-
Array.from(slate.Node.children(editor, normalizationPath)).forEach(([node, path]) => {
|
|
604
|
-
if (ElementUtils.isText(node)) {
|
|
605
|
-
slate.Transforms.removeNodes(editor, { at: path });
|
|
606
|
-
return;
|
|
607
|
-
}
|
|
608
|
-
});
|
|
609
|
-
}
|
|
610
|
-
if (!ElementUtils.isText(normalizationNode) && !ElementUtils.isTypography(normalizationNode)) {
|
|
586
|
+
if (!slate.Text.isText(normalizationNode)) {
|
|
611
587
|
const mergeableChildren = Array.from(slate.Node.children(editor, normalizationPath)).map((child, index2, children) => {
|
|
612
588
|
const potentialNodeToBeMerged = children.at(index2 + 1);
|
|
613
|
-
if (!potentialNodeToBeMerged || !ElementUtils.isList(potentialNodeToBeMerged[0]) || potentialNodeToBeMerged[0].type !== child[0].type) {
|
|
589
|
+
if (!potentialNodeToBeMerged || !ElementUtils.isList(potentialNodeToBeMerged[0]) || !ElementUtils.isList(child[0]) || potentialNodeToBeMerged[0].type !== child[0].type) {
|
|
614
590
|
return null;
|
|
615
591
|
}
|
|
616
592
|
return [
|
|
@@ -641,13 +617,39 @@ function withList(editor) {
|
|
|
641
617
|
return;
|
|
642
618
|
}
|
|
643
619
|
}
|
|
620
|
+
normalizeNode(entry);
|
|
621
|
+
};
|
|
622
|
+
return editor;
|
|
623
|
+
}
|
|
624
|
+
function withTypography(editor) {
|
|
625
|
+
const { normalizeNode } = editor;
|
|
626
|
+
editor.normalizeNode = (entry) => {
|
|
627
|
+
var _a, _b;
|
|
628
|
+
const [normalizationNode, normalizationPath] = entry;
|
|
629
|
+
if (slate.Text.isText(normalizationNode) && ((_a = normalizationNode == null ? void 0 : normalizationNode.typography) == null ? void 0 : _a.id) == null && ((_b = normalizationNode == null ? void 0 : normalizationNode.typography) == null ? void 0 : _b.style.length) === 0) {
|
|
630
|
+
slate.Transforms.unsetNodes(editor, "typography", { at: normalizationPath });
|
|
631
|
+
return;
|
|
632
|
+
}
|
|
633
|
+
normalizeNode(entry);
|
|
634
|
+
};
|
|
635
|
+
return editor;
|
|
636
|
+
}
|
|
637
|
+
function withBlock(editor) {
|
|
638
|
+
const { normalizeNode } = editor;
|
|
639
|
+
editor.normalizeNode = (entry) => {
|
|
640
|
+
var _a;
|
|
641
|
+
const [normalizationNode, normalizationPath] = entry;
|
|
642
|
+
if (ElementUtils.isBlock(normalizationNode) && ((_a = normalizationNode == null ? void 0 : normalizationNode.textAlign) == null ? void 0 : _a.length) == 0) {
|
|
643
|
+
slate.Transforms.unsetNodes(editor, "textAlign", { at: normalizationPath });
|
|
644
|
+
return;
|
|
645
|
+
}
|
|
646
|
+
normalizeNode(entry);
|
|
644
647
|
};
|
|
645
648
|
return editor;
|
|
646
649
|
}
|
|
647
650
|
const defaultText = [{
|
|
648
651
|
type: richText.BlockType.Paragraph,
|
|
649
652
|
children: [{
|
|
650
|
-
type: richText.TextType.Text,
|
|
651
653
|
text: ""
|
|
652
654
|
}]
|
|
653
655
|
}];
|
|
@@ -657,11 +659,20 @@ const EditableText = React.forwardRef(function EditableText2({
|
|
|
657
659
|
width,
|
|
658
660
|
margin
|
|
659
661
|
}, ref) {
|
|
660
|
-
const [editor] = React.useState(() => withList(slateReact.withReact(slate.createEditor())));
|
|
662
|
+
const [editor] = React.useState(() => withBlock(withTypography(withList(slateReact.withReact(slate.createEditor())))));
|
|
661
663
|
const delaySync = useSyncWithBuilder(editor, text);
|
|
662
664
|
const editMode = next.useBuilderEditMode();
|
|
663
665
|
const [propControllers, setPropControllers] = React.useState(null);
|
|
664
666
|
const controller = propControllers == null ? void 0 : propControllers.text;
|
|
667
|
+
React.useEffect(() => {
|
|
668
|
+
if (controller == null)
|
|
669
|
+
return;
|
|
670
|
+
const element = slateReact.ReactEditor.toDOMNode(editor, editor);
|
|
671
|
+
return next.pollBoxModel({
|
|
672
|
+
element,
|
|
673
|
+
onBoxModelChange: (boxModel) => controller.changeBoxModel(boxModel)
|
|
674
|
+
});
|
|
675
|
+
}, [editor, controller]);
|
|
665
676
|
React.useImperativeHandle(ref, () => ({
|
|
666
677
|
getDomNode() {
|
|
667
678
|
return slateReact.ReactEditor.toDOMNode(editor, editor);
|
|
@@ -693,12 +704,13 @@ const EditableText = React.forwardRef(function EditableText2({
|
|
|
693
704
|
onChange: delaySync,
|
|
694
705
|
children: /* @__PURE__ */ jsxRuntime.jsx(slateReact.Editable, {
|
|
695
706
|
id,
|
|
696
|
-
renderLeaf: Leaf,
|
|
707
|
+
renderLeaf: leaf.Leaf,
|
|
697
708
|
renderElement: Element,
|
|
698
709
|
onKeyDown: handleKeyDown,
|
|
699
710
|
onFocus: handleFocus,
|
|
700
711
|
className: css.cx(width, margin),
|
|
701
|
-
readOnly: editMode === richText.BuilderEditMode.INTERACT
|
|
712
|
+
readOnly: editMode === richText.BuilderEditMode.INTERACT,
|
|
713
|
+
placeholder: "Write some text..."
|
|
702
714
|
})
|
|
703
715
|
});
|
|
704
716
|
});
|