@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.es2.js
CHANGED
|
@@ -37,7 +37,7 @@ import "slate";
|
|
|
37
37
|
import "slate-react";
|
|
38
38
|
import { cx } from "@emotion/css";
|
|
39
39
|
import { jsx, Fragment, jsxs } from "react/jsx-runtime";
|
|
40
|
-
import {
|
|
40
|
+
import { j as isNonNullable, m as getBackgroundsFileIds, n as getBackgroundsSwatchIds } from "./introspection.es.js";
|
|
41
41
|
import NextImage from "next/image";
|
|
42
42
|
import { u as useIsomorphicLayoutEffect } from "./useIsomorphicLayoutEffect.es.js";
|
|
43
43
|
import ReactPlayer from "react-player";
|
package/dist/index.es5.js
CHANGED
package/dist/index.es5.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.es5.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.es5.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/dist/index.es6.js
CHANGED
|
@@ -30,27 +30,27 @@ var __objRest = (source, exclude) => {
|
|
|
30
30
|
return target;
|
|
31
31
|
};
|
|
32
32
|
import { useCallback, useState, useEffect, forwardRef, useImperativeHandle, useMemo } from "react";
|
|
33
|
-
import { Element as Element$1,
|
|
33
|
+
import { Element as Element$1, Editor, Path, Range, Point, Node, Transforms, Text, createEditor } from "slate";
|
|
34
34
|
import { withReact, ReactEditor, Slate, Editable } from "slate-react";
|
|
35
35
|
import { cx } from "@emotion/css";
|
|
36
36
|
import { g as getBox } from "./box-models.es.js";
|
|
37
|
-
import { au as
|
|
38
|
-
import {
|
|
37
|
+
import { au as BlockType, av as InlineType, ar as richTextDTOtoDAO, aq as richTextDTOtoSelection, ax as BuilderEditMode } from "./rich-text.es.js";
|
|
38
|
+
import { L as Leaf } from "./leaf.es.js";
|
|
39
|
+
import { o as useStyle, r as responsiveStyle, N as deepEqual, V as useBuilderEditMode, W as pollBoxModel } from "./index.es.js";
|
|
39
40
|
import { jsx } from "react/jsx-runtime";
|
|
41
|
+
import { L as Link } from "./index.es3.js";
|
|
42
|
+
import isHotkey from "is-hotkey";
|
|
40
43
|
import "use-sync-external-store/shim";
|
|
41
|
-
import { o as useStyle, r as responsiveStyle, V as useBuilderEditMode } from "./index.es.js";
|
|
42
44
|
import "@emotion/serialize";
|
|
43
45
|
import "@emotion/utils";
|
|
44
|
-
import { L as Link } from "./index.es3.js";
|
|
45
|
-
import { c as compareRichTextDAO, a as compareRichTextSelection } from "./compare.es.js";
|
|
46
|
-
import isHotkey from "is-hotkey";
|
|
47
46
|
import "css-box-model";
|
|
48
47
|
import "./actions.es.js";
|
|
48
|
+
import "./introspection.es.js";
|
|
49
|
+
import "use-sync-external-store/shim/with-selector";
|
|
50
|
+
import "next/dynamic";
|
|
49
51
|
import "./constants.es.js";
|
|
50
52
|
import "redux";
|
|
51
53
|
import "redux-thunk";
|
|
52
|
-
import "use-sync-external-store/shim/with-selector";
|
|
53
|
-
import "next/dynamic";
|
|
54
54
|
import "./text-input.es.js";
|
|
55
55
|
import "./combobox.es.js";
|
|
56
56
|
import "./types.es.js";
|
|
@@ -68,23 +68,6 @@ import "set-cookie-parser";
|
|
|
68
68
|
import "uuid";
|
|
69
69
|
import "corporate-ipsum";
|
|
70
70
|
import "next/link";
|
|
71
|
-
function Leaf(_a) {
|
|
72
|
-
var _b = _a, {
|
|
73
|
-
leaf
|
|
74
|
-
} = _b, props = __objRest(_b, [
|
|
75
|
-
"leaf"
|
|
76
|
-
]);
|
|
77
|
-
switch (leaf.type) {
|
|
78
|
-
case TextType.Typography:
|
|
79
|
-
return /* @__PURE__ */ jsx(TypographyLeaf, __spreadValues({
|
|
80
|
-
leaf
|
|
81
|
-
}, props));
|
|
82
|
-
default:
|
|
83
|
-
return /* @__PURE__ */ jsx("span", __spreadProps(__spreadValues({}, props.attributes), {
|
|
84
|
-
children: props.children
|
|
85
|
-
}));
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
71
|
function BlockElement({
|
|
89
72
|
element,
|
|
90
73
|
attributes,
|
|
@@ -169,10 +152,10 @@ function BlockElement({
|
|
|
169
152
|
}));
|
|
170
153
|
}
|
|
171
154
|
}
|
|
172
|
-
function StyledLink(
|
|
173
|
-
var
|
|
155
|
+
function StyledLink(_a) {
|
|
156
|
+
var _b = _a, {
|
|
174
157
|
className
|
|
175
|
-
} =
|
|
158
|
+
} = _b, restOfProps = __objRest(_b, [
|
|
176
159
|
"className"
|
|
177
160
|
]);
|
|
178
161
|
return /* @__PURE__ */ jsx(Link, __spreadProps(__spreadValues({}, restOfProps), {
|
|
@@ -206,10 +189,10 @@ function InlineElement({
|
|
|
206
189
|
}));
|
|
207
190
|
}
|
|
208
191
|
}
|
|
209
|
-
function Element(
|
|
210
|
-
var
|
|
192
|
+
function Element(_c) {
|
|
193
|
+
var _d = _c, {
|
|
211
194
|
element
|
|
212
|
-
} =
|
|
195
|
+
} = _d, props = __objRest(_d, [
|
|
213
196
|
"element"
|
|
214
197
|
]);
|
|
215
198
|
switch (element.type) {
|
|
@@ -245,7 +228,7 @@ function useSyncWithBuilder(editor, text) {
|
|
|
245
228
|
if (shouldCommit && text) {
|
|
246
229
|
const nextValue = richTextDTOtoDAO(text);
|
|
247
230
|
const nextSelection = richTextDTOtoSelection(text);
|
|
248
|
-
if (!
|
|
231
|
+
if (!deepEqual(editor.children, nextValue) || !deepEqual(editor.selection, nextSelection)) {
|
|
249
232
|
editor.children = nextValue;
|
|
250
233
|
editor.selection = nextSelection;
|
|
251
234
|
editor.onChange();
|
|
@@ -264,15 +247,17 @@ function useSyncWithBuilder(editor, text) {
|
|
|
264
247
|
}, [shouldCommit]);
|
|
265
248
|
return useCallback(() => setShouldCommit(false), []);
|
|
266
249
|
}
|
|
250
|
+
const LIST_ITEM_CHILD_POSITION = 0;
|
|
251
|
+
const LIST_ITEM_LIST_POSITION = 1;
|
|
267
252
|
const ElementUtils = {
|
|
268
|
-
|
|
269
|
-
return
|
|
253
|
+
isBlock(node) {
|
|
254
|
+
return Element$1.isElement(node) && (Element$1.isElementType(node, BlockType.Paragraph) || Element$1.isElementType(node, BlockType.Heading1) || Element$1.isElementType(node, BlockType.Heading2) || Element$1.isElementType(node, BlockType.Heading3) || Element$1.isElementType(node, BlockType.Heading3) || Element$1.isElementType(node, BlockType.Heading4) || Element$1.isElementType(node, BlockType.Heading5) || Element$1.isElementType(node, BlockType.Heading6) || Element$1.isElementType(node, BlockType.BlockQuote) || Element$1.isElementType(node, BlockType.UnorderedList) || Element$1.isElementType(node, BlockType.OrderedList) || Element$1.isElementType(node, BlockType.ListItem) || Element$1.isElementType(node, BlockType.ListItemChild));
|
|
270
255
|
},
|
|
271
|
-
|
|
272
|
-
return Element$1.isElementType(node,
|
|
256
|
+
isInline(node) {
|
|
257
|
+
return Element$1.isElement(node) && (Element$1.isElementType(node, InlineType.Link) || Element$1.isElementType(node, InlineType.Link) || Element$1.isElementType(node, InlineType.SubScript) || Element$1.isElementType(node, InlineType.SuperScript));
|
|
273
258
|
},
|
|
274
|
-
|
|
275
|
-
return
|
|
259
|
+
isConvertibleToListTextNode(node) {
|
|
260
|
+
return !this.isList(node) && !this.isListItem(node) && !this.isListItemChild(node);
|
|
276
261
|
},
|
|
277
262
|
isParagraph(node) {
|
|
278
263
|
return Element$1.isElementType(node, BlockType.Paragraph);
|
|
@@ -287,7 +272,7 @@ const ElementUtils = {
|
|
|
287
272
|
return Element$1.isElementType(node, BlockType.ListItemChild);
|
|
288
273
|
},
|
|
289
274
|
createText() {
|
|
290
|
-
return { text: ""
|
|
275
|
+
return { text: "" };
|
|
291
276
|
},
|
|
292
277
|
createParagraph() {
|
|
293
278
|
return {
|
|
@@ -311,36 +296,6 @@ const ElementUtils = {
|
|
|
311
296
|
};
|
|
312
297
|
}
|
|
313
298
|
};
|
|
314
|
-
function wrapList(editor, options = { type: BlockType.UnorderedList }) {
|
|
315
|
-
if (!editor.selection)
|
|
316
|
-
return;
|
|
317
|
-
const nonListEntries = Array.from(Editor.nodes(editor, {
|
|
318
|
-
at: editor.selection,
|
|
319
|
-
match: (node) => {
|
|
320
|
-
return Element$1.isElement(node) && ElementUtils.isConvertibleToListTextNode(node);
|
|
321
|
-
}
|
|
322
|
-
}));
|
|
323
|
-
const refs = nonListEntries.map(([_, path]) => Editor.pathRef(editor, path));
|
|
324
|
-
refs.forEach((ref) => {
|
|
325
|
-
const path = ref.current;
|
|
326
|
-
if (path) {
|
|
327
|
-
Editor.withoutNormalizing(editor, () => {
|
|
328
|
-
Transforms.setNodes(editor, { type: BlockType.ListItemChild }, {
|
|
329
|
-
at: path
|
|
330
|
-
});
|
|
331
|
-
Transforms.wrapNodes(editor, ElementUtils.createListItem(), {
|
|
332
|
-
at: path
|
|
333
|
-
});
|
|
334
|
-
Transforms.wrapNodes(editor, ElementUtils.createList(options.type), {
|
|
335
|
-
at: path
|
|
336
|
-
});
|
|
337
|
-
});
|
|
338
|
-
}
|
|
339
|
-
ref.unref();
|
|
340
|
-
});
|
|
341
|
-
}
|
|
342
|
-
const LIST_ITEM_CHILD_POSITION = 0;
|
|
343
|
-
const LIST_ITEM_LIST_POSITION = 1;
|
|
344
299
|
const EditorUtils = {
|
|
345
300
|
getFirstAncestorList(editor, path) {
|
|
346
301
|
const parentList = Editor.above(editor, {
|
|
@@ -383,58 +338,6 @@ function getSelectedListItems(editor) {
|
|
|
383
338
|
const firstAncestorPath = (_b = (_a = EditorUtils.getFirstAncestorListItem(editor, start)) == null ? void 0 : _a[1]) != null ? _b : [];
|
|
384
339
|
return Array.from(listItems).filter((node) => Path.isDescendant(start, node[1]) ? Path.equals(node[1], firstAncestorPath) : !Path.isAfter(start, node[1]));
|
|
385
340
|
}
|
|
386
|
-
function unwrapPath(editor, listItemPath) {
|
|
387
|
-
const parentList = EditorUtils.getFirstAncestorList(editor, listItemPath);
|
|
388
|
-
const listItemContainingParentList = EditorUtils.getFirstAncestorListItem(editor, listItemPath);
|
|
389
|
-
if (!parentList || listItemContainingParentList)
|
|
390
|
-
return;
|
|
391
|
-
Editor.withoutNormalizing(editor, () => {
|
|
392
|
-
const listItemTextPath = [...listItemPath, LIST_ITEM_CHILD_POSITION];
|
|
393
|
-
const listItemNestedListPath = [...listItemPath, LIST_ITEM_LIST_POSITION];
|
|
394
|
-
if (Node.has(editor, listItemNestedListPath)) {
|
|
395
|
-
Transforms.setNodes(editor, { type: parentList[0].type }, { at: listItemNestedListPath });
|
|
396
|
-
Transforms.liftNodes(editor, { at: listItemNestedListPath });
|
|
397
|
-
Transforms.liftNodes(editor, { at: Path.next(listItemPath) });
|
|
398
|
-
}
|
|
399
|
-
if (Node.has(editor, listItemTextPath)) {
|
|
400
|
-
Transforms.setNodes(editor, { type: BlockType.Paragraph }, {
|
|
401
|
-
at: listItemTextPath
|
|
402
|
-
});
|
|
403
|
-
Transforms.liftNodes(editor, { at: listItemTextPath });
|
|
404
|
-
Transforms.liftNodes(editor, { at: listItemPath });
|
|
405
|
-
}
|
|
406
|
-
});
|
|
407
|
-
}
|
|
408
|
-
function unwrapList(editor) {
|
|
409
|
-
if (!editor.selection)
|
|
410
|
-
return;
|
|
411
|
-
const listItems = getSelectedListItems(editor);
|
|
412
|
-
const subRoots = filterForSubtreeRoots(listItems);
|
|
413
|
-
const refs = subRoots.map(([_, path]) => Editor.pathRef(editor, path));
|
|
414
|
-
refs.forEach((ref) => {
|
|
415
|
-
if (ref.current) {
|
|
416
|
-
unwrapPath(editor, ref.current);
|
|
417
|
-
}
|
|
418
|
-
ref.unref();
|
|
419
|
-
});
|
|
420
|
-
}
|
|
421
|
-
function toggleList(editor, options = { type: BlockType.UnorderedList }) {
|
|
422
|
-
if (!editor.selection)
|
|
423
|
-
return;
|
|
424
|
-
const start = LocationUtils.getStartPath(editor.selection);
|
|
425
|
-
const ancestorPath = Path.ancestors(start).at(1);
|
|
426
|
-
if (!ancestorPath || !Node.has(editor, ancestorPath))
|
|
427
|
-
return;
|
|
428
|
-
const ancestor = Node.get(editor, ancestorPath);
|
|
429
|
-
if (!ElementUtils.isList(ancestor)) {
|
|
430
|
-
return wrapList(editor, { type: options.type });
|
|
431
|
-
}
|
|
432
|
-
if (ancestor.type === options.type) {
|
|
433
|
-
unwrapList(editor);
|
|
434
|
-
} else {
|
|
435
|
-
Transforms.setNodes(editor, { type: options.type }, { at: ancestorPath });
|
|
436
|
-
}
|
|
437
|
-
}
|
|
438
341
|
function indentPath(editor, path) {
|
|
439
342
|
const parent = Node.parent(editor, path);
|
|
440
343
|
if (!path || !Path.hasPrevious(path) || !ElementUtils.isList(parent))
|
|
@@ -508,6 +411,86 @@ function dedent(editor) {
|
|
|
508
411
|
ref.unref();
|
|
509
412
|
});
|
|
510
413
|
}
|
|
414
|
+
function unwrapPath(editor, listItemPath) {
|
|
415
|
+
const parentList = EditorUtils.getFirstAncestorList(editor, listItemPath);
|
|
416
|
+
const listItemContainingParentList = EditorUtils.getFirstAncestorListItem(editor, listItemPath);
|
|
417
|
+
if (!parentList || listItemContainingParentList)
|
|
418
|
+
return;
|
|
419
|
+
Editor.withoutNormalizing(editor, () => {
|
|
420
|
+
const listItemTextPath = [...listItemPath, LIST_ITEM_CHILD_POSITION];
|
|
421
|
+
const listItemNestedListPath = [...listItemPath, LIST_ITEM_LIST_POSITION];
|
|
422
|
+
if (Node.has(editor, listItemNestedListPath)) {
|
|
423
|
+
Transforms.setNodes(editor, { type: parentList[0].type }, { at: listItemNestedListPath });
|
|
424
|
+
Transforms.liftNodes(editor, { at: listItemNestedListPath });
|
|
425
|
+
Transforms.liftNodes(editor, { at: Path.next(listItemPath) });
|
|
426
|
+
}
|
|
427
|
+
if (Node.has(editor, listItemTextPath)) {
|
|
428
|
+
Transforms.setNodes(editor, { type: BlockType.Paragraph }, {
|
|
429
|
+
at: listItemTextPath
|
|
430
|
+
});
|
|
431
|
+
Transforms.liftNodes(editor, { at: listItemTextPath });
|
|
432
|
+
Transforms.liftNodes(editor, { at: listItemPath });
|
|
433
|
+
}
|
|
434
|
+
});
|
|
435
|
+
}
|
|
436
|
+
function unwrapList(editor) {
|
|
437
|
+
if (!editor.selection)
|
|
438
|
+
return;
|
|
439
|
+
const listItems = getSelectedListItems(editor);
|
|
440
|
+
const subRoots = filterForSubtreeRoots(listItems);
|
|
441
|
+
const refs = subRoots.map(([_, path]) => Editor.pathRef(editor, path));
|
|
442
|
+
refs.forEach((ref) => {
|
|
443
|
+
if (ref.current) {
|
|
444
|
+
unwrapPath(editor, ref.current);
|
|
445
|
+
}
|
|
446
|
+
ref.unref();
|
|
447
|
+
});
|
|
448
|
+
}
|
|
449
|
+
function wrapList(editor, options = { type: BlockType.UnorderedList }) {
|
|
450
|
+
if (!editor.selection)
|
|
451
|
+
return;
|
|
452
|
+
const nonListEntries = Array.from(Editor.nodes(editor, {
|
|
453
|
+
at: editor.selection,
|
|
454
|
+
match: (node) => {
|
|
455
|
+
return Element$1.isElement(node) && ElementUtils.isConvertibleToListTextNode(node);
|
|
456
|
+
}
|
|
457
|
+
}));
|
|
458
|
+
const refs = nonListEntries.map(([_, path]) => Editor.pathRef(editor, path));
|
|
459
|
+
refs.forEach((ref) => {
|
|
460
|
+
const path = ref.current;
|
|
461
|
+
if (path) {
|
|
462
|
+
Editor.withoutNormalizing(editor, () => {
|
|
463
|
+
Transforms.setNodes(editor, { type: BlockType.ListItemChild }, {
|
|
464
|
+
at: path
|
|
465
|
+
});
|
|
466
|
+
Transforms.wrapNodes(editor, ElementUtils.createListItem(), {
|
|
467
|
+
at: path
|
|
468
|
+
});
|
|
469
|
+
Transforms.wrapNodes(editor, ElementUtils.createList(options.type), {
|
|
470
|
+
at: path
|
|
471
|
+
});
|
|
472
|
+
});
|
|
473
|
+
}
|
|
474
|
+
ref.unref();
|
|
475
|
+
});
|
|
476
|
+
}
|
|
477
|
+
function toggleList(editor, options = { type: BlockType.UnorderedList }) {
|
|
478
|
+
if (!editor.selection)
|
|
479
|
+
return;
|
|
480
|
+
const start = LocationUtils.getStartPath(editor.selection);
|
|
481
|
+
const ancestorPath = Path.ancestors(start).at(1);
|
|
482
|
+
if (!ancestorPath || !Node.has(editor, ancestorPath))
|
|
483
|
+
return;
|
|
484
|
+
const ancestor = Node.get(editor, ancestorPath);
|
|
485
|
+
if (!ElementUtils.isList(ancestor)) {
|
|
486
|
+
return wrapList(editor, { type: options.type });
|
|
487
|
+
}
|
|
488
|
+
if (ancestor.type === options.type) {
|
|
489
|
+
unwrapList(editor);
|
|
490
|
+
} else {
|
|
491
|
+
Transforms.setNodes(editor, { type: options.type }, { at: ancestorPath });
|
|
492
|
+
}
|
|
493
|
+
}
|
|
511
494
|
const List = {
|
|
512
495
|
unwrapList,
|
|
513
496
|
wrapList,
|
|
@@ -574,6 +557,7 @@ function onKeyDown(e, editor) {
|
|
|
574
557
|
}
|
|
575
558
|
}
|
|
576
559
|
function withList(editor) {
|
|
560
|
+
const { normalizeNode } = editor;
|
|
577
561
|
editor.normalizeNode = (entry) => {
|
|
578
562
|
const [normalizationNode, normalizationPath] = entry;
|
|
579
563
|
if (ElementUtils.isListItem(normalizationNode)) {
|
|
@@ -593,18 +577,10 @@ function withList(editor) {
|
|
|
593
577
|
return;
|
|
594
578
|
}
|
|
595
579
|
}
|
|
596
|
-
if (
|
|
597
|
-
Array.from(Node.children(editor, normalizationPath)).forEach(([node, path]) => {
|
|
598
|
-
if (ElementUtils.isText(node)) {
|
|
599
|
-
Transforms.removeNodes(editor, { at: path });
|
|
600
|
-
return;
|
|
601
|
-
}
|
|
602
|
-
});
|
|
603
|
-
}
|
|
604
|
-
if (!ElementUtils.isText(normalizationNode) && !ElementUtils.isTypography(normalizationNode)) {
|
|
580
|
+
if (!Text.isText(normalizationNode)) {
|
|
605
581
|
const mergeableChildren = Array.from(Node.children(editor, normalizationPath)).map((child, index, children) => {
|
|
606
582
|
const potentialNodeToBeMerged = children.at(index + 1);
|
|
607
|
-
if (!potentialNodeToBeMerged || !ElementUtils.isList(potentialNodeToBeMerged[0]) || potentialNodeToBeMerged[0].type !== child[0].type) {
|
|
583
|
+
if (!potentialNodeToBeMerged || !ElementUtils.isList(potentialNodeToBeMerged[0]) || !ElementUtils.isList(child[0]) || potentialNodeToBeMerged[0].type !== child[0].type) {
|
|
608
584
|
return null;
|
|
609
585
|
}
|
|
610
586
|
return [
|
|
@@ -635,13 +611,39 @@ function withList(editor) {
|
|
|
635
611
|
return;
|
|
636
612
|
}
|
|
637
613
|
}
|
|
614
|
+
normalizeNode(entry);
|
|
615
|
+
};
|
|
616
|
+
return editor;
|
|
617
|
+
}
|
|
618
|
+
function withTypography(editor) {
|
|
619
|
+
const { normalizeNode } = editor;
|
|
620
|
+
editor.normalizeNode = (entry) => {
|
|
621
|
+
var _a, _b;
|
|
622
|
+
const [normalizationNode, normalizationPath] = entry;
|
|
623
|
+
if (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) {
|
|
624
|
+
Transforms.unsetNodes(editor, "typography", { at: normalizationPath });
|
|
625
|
+
return;
|
|
626
|
+
}
|
|
627
|
+
normalizeNode(entry);
|
|
628
|
+
};
|
|
629
|
+
return editor;
|
|
630
|
+
}
|
|
631
|
+
function withBlock(editor) {
|
|
632
|
+
const { normalizeNode } = editor;
|
|
633
|
+
editor.normalizeNode = (entry) => {
|
|
634
|
+
var _a;
|
|
635
|
+
const [normalizationNode, normalizationPath] = entry;
|
|
636
|
+
if (ElementUtils.isBlock(normalizationNode) && ((_a = normalizationNode == null ? void 0 : normalizationNode.textAlign) == null ? void 0 : _a.length) == 0) {
|
|
637
|
+
Transforms.unsetNodes(editor, "textAlign", { at: normalizationPath });
|
|
638
|
+
return;
|
|
639
|
+
}
|
|
640
|
+
normalizeNode(entry);
|
|
638
641
|
};
|
|
639
642
|
return editor;
|
|
640
643
|
}
|
|
641
644
|
const defaultText = [{
|
|
642
645
|
type: BlockType.Paragraph,
|
|
643
646
|
children: [{
|
|
644
|
-
type: TextType.Text,
|
|
645
647
|
text: ""
|
|
646
648
|
}]
|
|
647
649
|
}];
|
|
@@ -651,11 +653,20 @@ const EditableText = forwardRef(function EditableText2({
|
|
|
651
653
|
width,
|
|
652
654
|
margin
|
|
653
655
|
}, ref) {
|
|
654
|
-
const [editor] = useState(() => withList(withReact(createEditor())));
|
|
656
|
+
const [editor] = useState(() => withBlock(withTypography(withList(withReact(createEditor())))));
|
|
655
657
|
const delaySync = useSyncWithBuilder(editor, text);
|
|
656
658
|
const editMode = useBuilderEditMode();
|
|
657
659
|
const [propControllers, setPropControllers] = useState(null);
|
|
658
660
|
const controller = propControllers == null ? void 0 : propControllers.text;
|
|
661
|
+
useEffect(() => {
|
|
662
|
+
if (controller == null)
|
|
663
|
+
return;
|
|
664
|
+
const element = ReactEditor.toDOMNode(editor, editor);
|
|
665
|
+
return pollBoxModel({
|
|
666
|
+
element,
|
|
667
|
+
onBoxModelChange: (boxModel) => controller.changeBoxModel(boxModel)
|
|
668
|
+
});
|
|
669
|
+
}, [editor, controller]);
|
|
659
670
|
useImperativeHandle(ref, () => ({
|
|
660
671
|
getDomNode() {
|
|
661
672
|
return ReactEditor.toDOMNode(editor, editor);
|
|
@@ -692,7 +703,8 @@ const EditableText = forwardRef(function EditableText2({
|
|
|
692
703
|
onKeyDown: handleKeyDown,
|
|
693
704
|
onFocus: handleFocus,
|
|
694
705
|
className: cx(width, margin),
|
|
695
|
-
readOnly: editMode === BuilderEditMode.INTERACT
|
|
706
|
+
readOnly: editMode === BuilderEditMode.INTERACT,
|
|
707
|
+
placeholder: "Write some text..."
|
|
696
708
|
})
|
|
697
709
|
});
|
|
698
710
|
});
|