@makeswift/runtime 0.8.5 → 0.8.7
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 +11 -11
- package/dist/Box.cjs.js.map +1 -1
- package/dist/Box.es.js +9 -9
- package/dist/Box.es.js.map +1 -1
- package/dist/Button.cjs.js +36 -37
- package/dist/Button.cjs.js.map +1 -1
- package/dist/Button.es.js +13 -14
- package/dist/Button.es.js.map +1 -1
- package/dist/Carousel.cjs.js +38 -37
- package/dist/Carousel.cjs.js.map +1 -1
- package/dist/Carousel.es.js +19 -18
- package/dist/Carousel.es.js.map +1 -1
- package/dist/Countdown.cjs.js +55 -29
- package/dist/Countdown.cjs.js.map +1 -1
- package/dist/Countdown.es.js +35 -9
- package/dist/Countdown.es.js.map +1 -1
- package/dist/Divider.cjs.js +36 -10
- package/dist/Divider.cjs.js.map +1 -1
- package/dist/Divider.es.js +31 -5
- package/dist/Divider.es.js.map +1 -1
- package/dist/Embed.cjs.js +31 -5
- package/dist/Embed.cjs.js.map +1 -1
- package/dist/Embed.es.js +30 -4
- package/dist/Embed.es.js.map +1 -1
- package/dist/Form.cjs.js +72 -73
- package/dist/Form.cjs.js.map +1 -1
- package/dist/Form.es.js +32 -33
- package/dist/Form.es.js.map +1 -1
- package/dist/Image.cjs.js +22 -21
- package/dist/Image.cjs.js.map +1 -1
- package/dist/Image.es.js +20 -19
- package/dist/Image.es.js.map +1 -1
- package/dist/LiveProvider.cjs.js +12 -12
- package/dist/LiveProvider.cjs.js.map +1 -1
- package/dist/LiveProvider.es.js +12 -12
- package/dist/LiveProvider.es.js.map +1 -1
- package/dist/Navigation.cjs.js +33 -34
- package/dist/Navigation.cjs.js.map +1 -1
- package/dist/Navigation.es.js +14 -15
- package/dist/Navigation.es.js.map +1 -1
- package/dist/PreviewProvider.cjs.js +16 -13
- package/dist/PreviewProvider.cjs.js.map +1 -1
- package/dist/PreviewProvider.es.js +16 -13
- package/dist/PreviewProvider.es.js.map +1 -1
- package/dist/ReadOnlyText.cjs.js +15 -16
- package/dist/ReadOnlyText.cjs.js.map +1 -1
- package/dist/ReadOnlyText.es.js +11 -12
- package/dist/ReadOnlyText.es.js.map +1 -1
- package/dist/Root.cjs.js +10 -10
- package/dist/Root.cjs.js.map +1 -1
- package/dist/Root.es.js +8 -8
- package/dist/SocialLinks.cjs.js +12 -13
- package/dist/SocialLinks.cjs.js.map +1 -1
- package/dist/SocialLinks.es.js +7 -8
- package/dist/SocialLinks.es.js.map +1 -1
- package/dist/Text.cjs.js +3 -4
- package/dist/Text.cjs.js.map +1 -1
- package/dist/Text.es.js +4 -5
- package/dist/Text.es.js.map +1 -1
- package/dist/Video.cjs.js +31 -5
- package/dist/Video.cjs.js.map +1 -1
- package/dist/Video.es.js +30 -4
- package/dist/Video.es.js.map +1 -1
- package/dist/actions.cjs.js +6 -1
- package/dist/actions.cjs.js.map +1 -1
- package/dist/actions.es.js +6 -2
- package/dist/actions.es.js.map +1 -1
- package/dist/components.cjs.js +10 -10
- package/dist/components.es.js +10 -10
- package/dist/constants.cjs.js +13 -3
- package/dist/constants.cjs.js.map +1 -1
- package/dist/constants.es.js +13 -4
- package/dist/constants.es.js.map +1 -1
- package/dist/descriptors.cjs.js.map +1 -1
- package/dist/descriptors.es.js.map +1 -1
- package/dist/index.cjs.js +1010 -163
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.cjs2.js +29 -29
- package/dist/index.cjs2.js.map +1 -1
- package/dist/index.cjs3.js +1 -2
- package/dist/index.cjs3.js.map +1 -1
- package/dist/index.cjs4.js +2 -2
- package/dist/index.cjs4.js.map +1 -1
- package/dist/index.cjs5.js +262 -109
- package/dist/index.cjs5.js.map +1 -1
- package/dist/index.cjs6.js +3 -4
- package/dist/index.cjs6.js.map +1 -1
- package/dist/index.cjs7.js +16 -17
- package/dist/index.cjs7.js.map +1 -1
- package/dist/index.es.js +965 -133
- package/dist/index.es.js.map +1 -1
- package/dist/index.es2.js +6 -6
- package/dist/index.es2.js.map +1 -1
- package/dist/index.es3.js +1 -2
- package/dist/index.es3.js.map +1 -1
- package/dist/index.es4.js +2 -2
- package/dist/index.es4.js.map +1 -1
- package/dist/index.es5.js +262 -109
- package/dist/index.es5.js.map +1 -1
- package/dist/index.es6.js +3 -4
- package/dist/index.es6.js.map +1 -1
- package/dist/index.es7.js +12 -13
- package/dist/index.es7.js.map +1 -1
- package/dist/introspection.cjs.js +5 -2
- package/dist/introspection.cjs.js.map +1 -1
- package/dist/introspection.es.js +4 -2
- package/dist/introspection.es.js.map +1 -1
- package/dist/leaf.cjs.js +15 -17
- package/dist/leaf.cjs.js.map +1 -1
- package/dist/leaf.es.js +10 -11
- package/dist/leaf.es.js.map +1 -1
- package/dist/main.cjs.js +2 -1
- package/dist/main.cjs.js.map +1 -1
- package/dist/main.es.js +2 -2
- package/dist/next.cjs.js +5 -6
- package/dist/next.cjs.js.map +1 -1
- package/dist/next.es.js +6 -7
- package/dist/next.es.js.map +1 -1
- package/dist/prop-controllers.cjs.js +0 -1
- package/dist/prop-controllers.cjs.js.map +1 -1
- package/dist/prop-controllers.es.js +0 -1
- package/dist/prop-controllers.es.js.map +1 -1
- package/dist/react.cjs.js +3 -4
- package/dist/react.cjs.js.map +1 -1
- package/dist/react.es.js +3 -4
- package/dist/react.es.js.map +1 -1
- package/dist/slate.cjs.js +1 -12
- package/dist/slate.cjs.js.map +1 -1
- package/dist/slate.es.js +1 -12
- package/dist/slate.es.js.map +1 -1
- package/dist/state/breakpoints.cjs.js +175 -0
- package/dist/state/breakpoints.cjs.js.map +1 -0
- package/dist/state/breakpoints.es.js +160 -0
- package/dist/state/breakpoints.es.js.map +1 -0
- package/dist/types/src/components/builtin/Box/Box.d.ts.map +1 -1
- package/dist/types/src/components/builtin/Box/register.d.ts.map +1 -1
- package/dist/types/src/components/builtin/Button/Button.d.ts.map +1 -1
- package/dist/types/src/components/builtin/Button/register.d.ts.map +1 -1
- package/dist/types/src/components/builtin/Carousel/Carousel.d.ts.map +1 -1
- package/dist/types/src/components/builtin/Carousel/register.d.ts.map +1 -1
- package/dist/types/src/components/builtin/Countdown/register.d.ts.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/Form/components/Field/components/Label/index.d.ts.map +1 -1
- package/dist/types/src/components/builtin/Form/register.d.ts.map +1 -1
- package/dist/types/src/components/builtin/Image/Image.d.ts.map +1 -1
- package/dist/types/src/components/builtin/Navigation/components/MobileMenu/components/MobileDropDownButton/index.d.ts.map +1 -1
- package/dist/types/src/components/builtin/Navigation/components/MobileMenu/index.d.ts.map +1 -1
- package/dist/types/src/components/builtin/Navigation/register.d.ts.map +1 -1
- package/dist/types/src/components/builtin/SocialLinks/register.d.ts.map +1 -1
- package/dist/types/src/components/builtin/Text/components/Leaf/leaf.d.ts +0 -4
- package/dist/types/src/components/builtin/Text/components/Leaf/leaf.d.ts.map +1 -1
- package/dist/types/src/components/builtin/Text/register.d.ts.map +1 -1
- package/dist/types/src/components/hooks/useMediaQuery.d.ts.map +1 -1
- package/dist/types/src/components/utils/drop-first.d.ts +2 -0
- package/dist/types/src/components/utils/drop-first.d.ts.map +1 -0
- package/dist/types/src/components/utils/responsive-style.d.ts +21 -10
- package/dist/types/src/components/utils/responsive-style.d.ts.map +1 -1
- package/dist/types/src/controls/types.d.ts +1 -1
- package/dist/types/src/controls/types.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +2 -2
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/next/api-handler/handlers/manifest.d.ts +1 -0
- package/dist/types/src/next/api-handler/handlers/manifest.d.ts.map +1 -1
- package/dist/types/src/next/client.d.ts +4 -1
- package/dist/types/src/next/client.d.ts.map +1 -1
- package/dist/types/src/next/index.d.ts +3 -1
- package/dist/types/src/next/index.d.ts.map +1 -1
- package/dist/types/src/prop-controllers/descriptors.d.ts +1 -1
- package/dist/types/src/prop-controllers/descriptors.d.ts.map +1 -1
- package/dist/types/src/runtimes/react/components/LiveProvider.d.ts +3 -1
- package/dist/types/src/runtimes/react/components/LiveProvider.d.ts.map +1 -1
- package/dist/types/src/runtimes/react/components/PreviewProvider.d.ts +3 -1
- package/dist/types/src/runtimes/react/components/PreviewProvider.d.ts.map +1 -1
- package/dist/types/src/runtimes/react/index.d.ts +22 -4
- package/dist/types/src/runtimes/react/index.d.ts.map +1 -1
- package/dist/types/src/slate/BlockPlugin/clearBlockKeyForDevice.d.ts +2 -2
- package/dist/types/src/slate/BlockPlugin/clearBlockKeyForDevice.d.ts.map +1 -1
- package/dist/types/src/slate/BlockPlugin/index.d.ts +4 -0
- package/dist/types/src/slate/BlockPlugin/index.d.ts.map +1 -1
- package/dist/types/src/slate/BlockPlugin/setBlockKeyForDevice.d.ts +7 -3
- package/dist/types/src/slate/BlockPlugin/setBlockKeyForDevice.d.ts.map +1 -1
- package/dist/types/src/slate/BlockPlugin/types.d.ts +2 -2
- package/dist/types/src/slate/BlockPlugin/types.d.ts.map +1 -1
- package/dist/types/src/slate/BlockPlugin/unwrapInline.d.ts +4 -0
- package/dist/types/src/slate/BlockPlugin/unwrapInline.d.ts.map +1 -0
- package/dist/types/src/slate/BlockPlugin/wrapInline.d.ts +4 -0
- package/dist/types/src/slate/BlockPlugin/wrapInline.d.ts.map +1 -0
- package/dist/types/src/slate/ListPlugin/toggleList.d.ts +2 -1
- package/dist/types/src/slate/ListPlugin/toggleList.d.ts.map +1 -1
- package/dist/types/src/slate/ListPlugin/unwrapList.d.ts +6 -2
- package/dist/types/src/slate/ListPlugin/unwrapList.d.ts.map +1 -1
- package/dist/types/src/slate/ListPlugin/utils/getSelectedListItems.d.ts +0 -1
- package/dist/types/src/slate/ListPlugin/utils/getSelectedListItems.d.ts.map +1 -1
- package/dist/types/src/slate/ListPlugin/wrapList.d.ts +2 -1
- package/dist/types/src/slate/ListPlugin/wrapList.d.ts.map +1 -1
- package/dist/types/src/slate/TypographyPlugin/clearActiveTypographyStyle.d.ts +6 -2
- package/dist/types/src/slate/TypographyPlugin/clearActiveTypographyStyle.d.ts.map +1 -1
- package/dist/types/src/slate/TypographyPlugin/clearDeviceActiveTypography.d.ts +6 -2
- package/dist/types/src/slate/TypographyPlugin/clearDeviceActiveTypography.d.ts.map +1 -1
- package/dist/types/src/slate/TypographyPlugin/detachActiveTypography.d.ts +6 -2
- package/dist/types/src/slate/TypographyPlugin/detachActiveTypography.d.ts.map +1 -1
- package/dist/types/src/slate/TypographyPlugin/index.d.ts.map +1 -1
- package/dist/types/src/slate/TypographyPlugin/setActiveTypographyId.d.ts +6 -2
- package/dist/types/src/slate/TypographyPlugin/setActiveTypographyId.d.ts.map +1 -1
- package/dist/types/src/slate/TypographyPlugin/setActiveTypographyStyle.d.ts +7 -2
- package/dist/types/src/slate/TypographyPlugin/setActiveTypographyStyle.d.ts.map +1 -1
- package/dist/types/src/slate/selectors.d.ts +19 -0
- package/dist/types/src/slate/selectors.d.ts.map +1 -0
- package/dist/types/src/slate/utils/editor.d.ts.map +1 -1
- package/dist/types/src/slate/utils/element.d.ts +2 -1
- package/dist/types/src/slate/utils/element.d.ts.map +1 -1
- package/dist/types/src/slate/utils/unhangRange.d.ts +10 -0
- package/dist/types/src/slate/utils/unhangRange.d.ts.map +1 -0
- package/dist/types/src/state/actions.d.ts +10 -1
- package/dist/types/src/state/actions.d.ts.map +1 -1
- package/dist/types/src/state/modules/breakpoints.d.ts +44 -0
- package/dist/types/src/state/modules/breakpoints.d.ts.map +1 -0
- package/dist/types/src/state/react-builder-preview.d.ts +2 -0
- package/dist/types/src/state/react-builder-preview.d.ts.map +1 -1
- package/dist/types/src/state/react-page.d.ts +5 -1
- package/dist/types/src/state/react-page.d.ts.map +1 -1
- package/dist/types/src/utils/isNonNullable.d.ts +2 -0
- package/dist/types/src/utils/isNonNullable.d.ts.map +1 -0
- package/dist/useMediaQuery.cjs.js +38 -0
- package/dist/useMediaQuery.cjs.js.map +1 -0
- package/dist/useMediaQuery.es.js +37 -0
- package/dist/useMediaQuery.es.js.map +1 -0
- package/package.json +10 -2
- package/state/breakpoints.js +1 -0
- package/dist/isNonNullable.cjs.js +0 -6
- package/dist/isNonNullable.cjs.js.map +0 -1
- package/dist/isNonNullable.es.js +0 -5
- package/dist/isNonNullable.es.js.map +0 -1
- package/dist/responsive-style.cjs.js +0 -917
- package/dist/responsive-style.cjs.js.map +0 -1
- package/dist/responsive-style.es.js +0 -853
- package/dist/responsive-style.es.js.map +0 -1
- package/dist/types/src/components/utils/devices.d.ts +0 -17
- package/dist/types/src/components/utils/devices.d.ts.map +0 -1
package/dist/index.es5.js
CHANGED
|
@@ -21,16 +21,18 @@ import { Element, Editor, Path, Range, Point, Node, Transforms, Text } from "sla
|
|
|
21
21
|
import isHotkey from "is-hotkey";
|
|
22
22
|
import { ax as BlockType, ay as InlineType } from "./descriptors.es.js";
|
|
23
23
|
import "slate-react";
|
|
24
|
-
import {
|
|
25
|
-
import { f as findDeviceOverride } from "./responsive-style.es.js";
|
|
24
|
+
import { findBreakpointOverride } from "./state/breakpoints.es.js";
|
|
26
25
|
const LIST_ITEM_CHILD_POSITION = 0;
|
|
27
26
|
const LIST_ITEM_LIST_POSITION = 1;
|
|
28
27
|
const ElementUtils = {
|
|
28
|
+
isRootBlock(node) {
|
|
29
|
+
return Element.isElement(node) && (Element.isElementType(node, BlockType.Paragraph) || Element.isElementType(node, BlockType.Heading1) || Element.isElementType(node, BlockType.Heading2) || Element.isElementType(node, BlockType.Heading3) || Element.isElementType(node, BlockType.Heading3) || Element.isElementType(node, BlockType.Heading4) || Element.isElementType(node, BlockType.Heading5) || Element.isElementType(node, BlockType.Heading6) || Element.isElementType(node, BlockType.BlockQuote) || Element.isElementType(node, BlockType.UnorderedList) || Element.isElementType(node, BlockType.OrderedList));
|
|
30
|
+
},
|
|
29
31
|
isBlock(node) {
|
|
30
|
-
return Element.isElement(node) && (
|
|
32
|
+
return Element.isElement(node) && (this.isRootBlock(node) || Element.isElementType(node, BlockType.ListItem) || Element.isElementType(node, BlockType.ListItemChild));
|
|
31
33
|
},
|
|
32
34
|
isInline(node) {
|
|
33
|
-
return Element.
|
|
35
|
+
return Element.isElementType(node, InlineType.Code) || Element.isElementType(node, InlineType.Link) || Element.isElementType(node, InlineType.SubScript) || Element.isElementType(node, InlineType.SuperScript);
|
|
34
36
|
},
|
|
35
37
|
isConvertibleToListTextNode(node) {
|
|
36
38
|
return !this.isList(node) && !this.isListItem(node) && !this.isListItemChild(node);
|
|
@@ -61,7 +63,7 @@ const ElementUtils = {
|
|
|
61
63
|
},
|
|
62
64
|
createListItem() {
|
|
63
65
|
return {
|
|
64
|
-
children: [this.
|
|
66
|
+
children: [this.createListItemChild()],
|
|
65
67
|
type: BlockType.ListItem
|
|
66
68
|
};
|
|
67
69
|
},
|
|
@@ -74,18 +76,26 @@ const ElementUtils = {
|
|
|
74
76
|
};
|
|
75
77
|
const EditorUtils = {
|
|
76
78
|
getFirstAncestorList(editor, path) {
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
79
|
+
try {
|
|
80
|
+
const parentList = Editor.above(editor, {
|
|
81
|
+
at: path,
|
|
82
|
+
match: (node) => ElementUtils.isList(node)
|
|
83
|
+
});
|
|
84
|
+
return parentList != null ? parentList : null;
|
|
85
|
+
} catch (e) {
|
|
86
|
+
return null;
|
|
87
|
+
}
|
|
82
88
|
},
|
|
83
89
|
getFirstAncestorListItem(editor, path) {
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
90
|
+
try {
|
|
91
|
+
const parentListItem = Editor.above(editor, {
|
|
92
|
+
at: path,
|
|
93
|
+
match: (node) => ElementUtils.isListItem(node)
|
|
94
|
+
});
|
|
95
|
+
return parentListItem != null ? parentListItem : null;
|
|
96
|
+
} catch (e) {
|
|
97
|
+
return null;
|
|
98
|
+
}
|
|
89
99
|
}
|
|
90
100
|
};
|
|
91
101
|
function filterForSubtreeRoots(entries) {
|
|
@@ -209,10 +219,17 @@ function unwrapPath(editor, listItemPath) {
|
|
|
209
219
|
}
|
|
210
220
|
});
|
|
211
221
|
}
|
|
212
|
-
function unwrapList(editor) {
|
|
213
|
-
|
|
222
|
+
function unwrapList(editor, options) {
|
|
223
|
+
var _a;
|
|
224
|
+
const at = (_a = options == null ? void 0 : options.at) != null ? _a : editor.selection;
|
|
225
|
+
if (!at)
|
|
214
226
|
return;
|
|
215
|
-
const listItems =
|
|
227
|
+
const listItems = Array.from(Editor.nodes(editor, {
|
|
228
|
+
at,
|
|
229
|
+
match: (node) => {
|
|
230
|
+
return Element.isElement(node) && ElementUtils.isListItem(node);
|
|
231
|
+
}
|
|
232
|
+
}));
|
|
216
233
|
const subRoots = filterForSubtreeRoots(listItems);
|
|
217
234
|
const refs = subRoots.map(([_, path]) => Editor.pathRef(editor, path));
|
|
218
235
|
refs.forEach((ref) => {
|
|
@@ -223,10 +240,12 @@ function unwrapList(editor) {
|
|
|
223
240
|
});
|
|
224
241
|
}
|
|
225
242
|
function wrapList(editor, options = { type: BlockType.UnorderedList }) {
|
|
226
|
-
|
|
243
|
+
var _a;
|
|
244
|
+
const at = (_a = options.at) != null ? _a : editor.selection;
|
|
245
|
+
if (!at)
|
|
227
246
|
return;
|
|
228
247
|
const nonListEntries = Array.from(Editor.nodes(editor, {
|
|
229
|
-
at
|
|
248
|
+
at,
|
|
230
249
|
match: (node) => {
|
|
231
250
|
return Element.isElement(node) && ElementUtils.isConvertibleToListTextNode(node);
|
|
232
251
|
}
|
|
@@ -240,6 +259,7 @@ function wrapList(editor, options = { type: BlockType.UnorderedList }) {
|
|
|
240
259
|
at: path
|
|
241
260
|
});
|
|
242
261
|
Transforms.wrapNodes(editor, ElementUtils.createListItem(), {
|
|
262
|
+
match: (node) => ElementUtils.isListItemChild(node),
|
|
243
263
|
at: path
|
|
244
264
|
});
|
|
245
265
|
Transforms.wrapNodes(editor, ElementUtils.createList(options.type), {
|
|
@@ -251,18 +271,20 @@ function wrapList(editor, options = { type: BlockType.UnorderedList }) {
|
|
|
251
271
|
});
|
|
252
272
|
}
|
|
253
273
|
function toggleList(editor, options = { type: BlockType.UnorderedList }) {
|
|
254
|
-
|
|
274
|
+
var _a;
|
|
275
|
+
const at = (_a = options.at) != null ? _a : editor.selection;
|
|
276
|
+
if (at == null)
|
|
255
277
|
return;
|
|
256
|
-
const start = LocationUtils.getStartPath(
|
|
278
|
+
const start = LocationUtils.getStartPath(at);
|
|
257
279
|
const ancestorPath = Path.ancestors(start).at(1);
|
|
258
280
|
if (!ancestorPath || !Node.has(editor, ancestorPath))
|
|
259
281
|
return;
|
|
260
282
|
const ancestor = Node.get(editor, ancestorPath);
|
|
261
283
|
if (!ElementUtils.isList(ancestor)) {
|
|
262
|
-
return wrapList(editor, { type: options.type });
|
|
284
|
+
return wrapList(editor, { type: options.type, at });
|
|
263
285
|
}
|
|
264
286
|
if (ancestor.type === options.type) {
|
|
265
|
-
unwrapList(editor);
|
|
287
|
+
unwrapList(editor, { at });
|
|
266
288
|
} else {
|
|
267
289
|
Transforms.setNodes(editor, { type: options.type }, { at: ancestorPath });
|
|
268
290
|
}
|
|
@@ -373,10 +395,10 @@ function withList(editor) {
|
|
|
373
395
|
const nodeChildren = Array.from(Node.children(editor, nodePath));
|
|
374
396
|
const childrenToBeMerged = Array.from(Node.children(editor, nodeToBeMergedPath));
|
|
375
397
|
Editor.withoutNormalizing(editor, () => {
|
|
376
|
-
childrenToBeMerged.forEach(([_, childPath]
|
|
398
|
+
childrenToBeMerged.reverse().forEach(([_, childPath]) => {
|
|
377
399
|
Transforms.moveNodes(editor, {
|
|
378
400
|
at: childPath,
|
|
379
|
-
to: [...nodePath, nodeChildren.length
|
|
401
|
+
to: [...nodePath, nodeChildren.length]
|
|
380
402
|
});
|
|
381
403
|
});
|
|
382
404
|
Transforms.removeNodes(editor, { at: nodeToBeMergedPath });
|
|
@@ -391,94 +413,168 @@ function withList(editor) {
|
|
|
391
413
|
};
|
|
392
414
|
return editor;
|
|
393
415
|
}
|
|
394
|
-
function clearActiveTypographyStyle(editor) {
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
at
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
if (Text.isText(node)) {
|
|
403
|
-
const typography = __spreadProps(__spreadValues({}, node.typography), {
|
|
404
|
-
style: []
|
|
405
|
-
});
|
|
416
|
+
function clearActiveTypographyStyle(editor, options) {
|
|
417
|
+
Editor.withoutNormalizing(editor, () => {
|
|
418
|
+
var _a;
|
|
419
|
+
const at = (_a = options == null ? void 0 : options.at) != null ? _a : editor.selection;
|
|
420
|
+
if (!at)
|
|
421
|
+
return;
|
|
422
|
+
const atRef = Editor.rangeRef(editor, at);
|
|
423
|
+
if (atRef.current) {
|
|
406
424
|
Transforms.setNodes(editor, {
|
|
407
|
-
|
|
408
|
-
}, {
|
|
425
|
+
slice: true
|
|
426
|
+
}, {
|
|
427
|
+
at: atRef.current,
|
|
428
|
+
match: (node) => Text.isText(node),
|
|
429
|
+
split: Range.isExpanded(atRef.current)
|
|
430
|
+
});
|
|
409
431
|
}
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
432
|
+
if (atRef.current) {
|
|
433
|
+
const textNodes = Array.from(Editor.nodes(editor, {
|
|
434
|
+
at: atRef.current,
|
|
435
|
+
match: (node) => Text.isText(node) && node.slice === true
|
|
436
|
+
}));
|
|
437
|
+
for (const [node, path] of textNodes) {
|
|
438
|
+
if (Text.isText(node)) {
|
|
439
|
+
const typography = __spreadProps(__spreadValues({}, node.typography), {
|
|
440
|
+
style: []
|
|
441
|
+
});
|
|
442
|
+
Transforms.setNodes(editor, {
|
|
443
|
+
typography
|
|
444
|
+
}, { at: path });
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
atRef.unref();
|
|
419
449
|
});
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
450
|
+
}
|
|
451
|
+
function clearDeviceActiveTypography(editor, currentDeviceId, options) {
|
|
452
|
+
Editor.withoutNormalizing(editor, () => {
|
|
453
|
+
var _a, _b, _c;
|
|
454
|
+
const at = (_a = options == null ? void 0 : options.at) != null ? _a : editor.selection;
|
|
455
|
+
if (!at)
|
|
456
|
+
return;
|
|
457
|
+
const atRef = Editor.rangeRef(editor, at);
|
|
458
|
+
if (atRef.current) {
|
|
425
459
|
Transforms.setNodes(editor, {
|
|
426
|
-
|
|
427
|
-
}, {
|
|
460
|
+
slice: true
|
|
461
|
+
}, {
|
|
462
|
+
at: atRef.current,
|
|
463
|
+
match: (node) => Text.isText(node),
|
|
464
|
+
split: Range.isExpanded(atRef.current)
|
|
465
|
+
});
|
|
428
466
|
}
|
|
429
|
-
|
|
467
|
+
if (atRef.current) {
|
|
468
|
+
const textNodes = Array.from(Editor.nodes(editor, {
|
|
469
|
+
at: atRef.current,
|
|
470
|
+
match: (node) => Text.isText(node) && node.slice === true
|
|
471
|
+
}));
|
|
472
|
+
for (const [node, path] of textNodes) {
|
|
473
|
+
if (Text.isText(node)) {
|
|
474
|
+
const typography = __spreadProps(__spreadValues({}, node.typography), {
|
|
475
|
+
style: (_c = (_b = node == null ? void 0 : node.typography) == null ? void 0 : _b.style.filter(({ deviceId }) => deviceId !== currentDeviceId)) != null ? _c : []
|
|
476
|
+
});
|
|
477
|
+
Transforms.setNodes(editor, {
|
|
478
|
+
typography
|
|
479
|
+
}, { at: path });
|
|
480
|
+
}
|
|
481
|
+
}
|
|
482
|
+
}
|
|
483
|
+
atRef.unref();
|
|
484
|
+
});
|
|
430
485
|
}
|
|
431
|
-
function detachActiveTypography(editor, value) {
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
at
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
if (Text.isText(node)) {
|
|
486
|
+
function detachActiveTypography(editor, value, options) {
|
|
487
|
+
Editor.withoutNormalizing(editor, () => {
|
|
488
|
+
var _a;
|
|
489
|
+
const at = (_a = options == null ? void 0 : options.at) != null ? _a : editor.selection;
|
|
490
|
+
if (!at)
|
|
491
|
+
return;
|
|
492
|
+
const atRef = Editor.rangeRef(editor, at);
|
|
493
|
+
if (atRef.current) {
|
|
440
494
|
Transforms.setNodes(editor, {
|
|
441
|
-
|
|
442
|
-
|
|
495
|
+
slice: true
|
|
496
|
+
}, {
|
|
497
|
+
at: atRef.current,
|
|
498
|
+
match: (node) => Text.isText(node),
|
|
499
|
+
split: Range.isExpanded(atRef.current)
|
|
500
|
+
});
|
|
501
|
+
}
|
|
502
|
+
if (atRef.current) {
|
|
503
|
+
const textNodes = Array.from(Editor.nodes(editor, {
|
|
504
|
+
at: atRef.current,
|
|
505
|
+
match: (node) => Text.isText(node) && node.slice === true
|
|
506
|
+
}));
|
|
507
|
+
for (const [node, path] of textNodes) {
|
|
508
|
+
if (Text.isText(node)) {
|
|
509
|
+
Transforms.setNodes(editor, {
|
|
510
|
+
typography: {
|
|
511
|
+
style: value
|
|
512
|
+
}
|
|
513
|
+
}, { at: path });
|
|
443
514
|
}
|
|
444
|
-
}
|
|
515
|
+
}
|
|
445
516
|
}
|
|
517
|
+
atRef.unref();
|
|
446
518
|
});
|
|
447
519
|
}
|
|
448
|
-
function setActiveTypographyId(editor, id) {
|
|
520
|
+
function setActiveTypographyId(editor, id, options) {
|
|
521
|
+
var _a;
|
|
522
|
+
const at = (_a = options == null ? void 0 : options.at) != null ? _a : editor.selection;
|
|
523
|
+
if (!at)
|
|
524
|
+
return;
|
|
449
525
|
Transforms.setNodes(editor, {
|
|
450
526
|
typography: {
|
|
451
527
|
id,
|
|
452
528
|
style: []
|
|
453
529
|
}
|
|
454
530
|
}, {
|
|
455
|
-
|
|
531
|
+
at,
|
|
532
|
+
match: (node) => Text.isText(node),
|
|
533
|
+
split: Range.isExpanded(at)
|
|
456
534
|
});
|
|
457
535
|
}
|
|
458
|
-
function setActiveTypographyStyle(editor, deviceId, prop, value) {
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
for (const [node, path] of textNodes) {
|
|
467
|
-
if (Text.isText(node)) {
|
|
468
|
-
const deviceOverrides = (_b = (_a = node == null ? void 0 : node.typography) == null ? void 0 : _a.style.filter(isDeviceOverride)) != null ? _b : [];
|
|
469
|
-
const deviceStyle = findDeviceOverride(deviceOverrides, deviceId, (v) => v) || { value: {} };
|
|
470
|
-
const nextDeviceStyle = {
|
|
471
|
-
deviceId,
|
|
472
|
-
value: __spreadProps(__spreadValues({}, deviceStyle.value), { [prop]: value })
|
|
473
|
-
};
|
|
474
|
-
const nextTypography = __spreadProps(__spreadValues({}, node.typography), {
|
|
475
|
-
style: [...deviceOverrides.filter((v) => v.deviceId !== deviceId), nextDeviceStyle]
|
|
476
|
-
});
|
|
536
|
+
function setActiveTypographyStyle(editor, breakpoints, deviceId, prop, value, options) {
|
|
537
|
+
Editor.withoutNormalizing(editor, () => {
|
|
538
|
+
var _a, _b, _c;
|
|
539
|
+
const at = (_a = options == null ? void 0 : options.at) != null ? _a : editor.selection;
|
|
540
|
+
if (!at)
|
|
541
|
+
return;
|
|
542
|
+
const atRef = Editor.rangeRef(editor, at);
|
|
543
|
+
if (atRef.current) {
|
|
477
544
|
Transforms.setNodes(editor, {
|
|
478
|
-
|
|
479
|
-
}, {
|
|
545
|
+
slice: true
|
|
546
|
+
}, {
|
|
547
|
+
at: atRef.current,
|
|
548
|
+
match: (node) => Text.isText(node),
|
|
549
|
+
split: Range.isExpanded(atRef.current)
|
|
550
|
+
});
|
|
480
551
|
}
|
|
481
|
-
|
|
552
|
+
if (atRef.current) {
|
|
553
|
+
const textNodes = Array.from(Editor.nodes(editor, {
|
|
554
|
+
at: atRef.current,
|
|
555
|
+
match: (node) => Text.isText(node) && node.slice === true
|
|
556
|
+
}));
|
|
557
|
+
for (const [node, path] of textNodes) {
|
|
558
|
+
if (Text.isText(node)) {
|
|
559
|
+
const deviceOverrides = (_c = (_b = node == null ? void 0 : node.typography) == null ? void 0 : _b.style) != null ? _c : [];
|
|
560
|
+
const deviceStyle = findBreakpointOverride(breakpoints, deviceOverrides, deviceId, (v) => v) || {
|
|
561
|
+
value: {}
|
|
562
|
+
};
|
|
563
|
+
const nextDeviceStyle = {
|
|
564
|
+
deviceId,
|
|
565
|
+
value: __spreadProps(__spreadValues({}, deviceStyle.value), { [prop]: value })
|
|
566
|
+
};
|
|
567
|
+
const nextTypography = __spreadProps(__spreadValues({}, node.typography), {
|
|
568
|
+
style: [...deviceOverrides.filter((v) => v.deviceId !== deviceId), nextDeviceStyle]
|
|
569
|
+
});
|
|
570
|
+
Transforms.setNodes(editor, {
|
|
571
|
+
typography: nextTypography
|
|
572
|
+
}, { at: path });
|
|
573
|
+
}
|
|
574
|
+
}
|
|
575
|
+
}
|
|
576
|
+
atRef.unref();
|
|
577
|
+
});
|
|
482
578
|
}
|
|
483
579
|
const Typography = {
|
|
484
580
|
setActiveTypographyId,
|
|
@@ -496,22 +592,67 @@ function withTypography(editor) {
|
|
|
496
592
|
Transforms.unsetNodes(editor, "typography", { at: normalizationPath });
|
|
497
593
|
return;
|
|
498
594
|
}
|
|
595
|
+
if (Text.isText(normalizationNode) && (normalizationNode == null ? void 0 : normalizationNode.slice) != null) {
|
|
596
|
+
Transforms.unsetNodes(editor, "slice", { at: normalizationPath });
|
|
597
|
+
return;
|
|
598
|
+
}
|
|
499
599
|
normalizeNode(entry);
|
|
500
600
|
};
|
|
501
601
|
return editor;
|
|
502
602
|
}
|
|
503
|
-
function
|
|
504
|
-
|
|
505
|
-
if (
|
|
506
|
-
return;
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
at:
|
|
603
|
+
function unhangRange(editor, range) {
|
|
604
|
+
let [start, end] = Range.edges(range);
|
|
605
|
+
if (start.offset !== 0 || end.offset !== 0 || Range.isCollapsed(range)) {
|
|
606
|
+
return range;
|
|
607
|
+
}
|
|
608
|
+
const endBlock = Editor.above(editor, {
|
|
609
|
+
at: end,
|
|
610
|
+
match: (n) => Element.isElement(n) && Editor.isBlock(editor, n)
|
|
510
611
|
});
|
|
612
|
+
const blockPath = endBlock ? endBlock[1] : [];
|
|
613
|
+
const first = Editor.start(editor, start);
|
|
614
|
+
const before = { anchor: first, focus: end };
|
|
615
|
+
let skip = true;
|
|
616
|
+
for (const [node, path] of Editor.nodes(editor, {
|
|
617
|
+
at: before,
|
|
618
|
+
match: Text.isText,
|
|
619
|
+
reverse: true
|
|
620
|
+
})) {
|
|
621
|
+
if (skip) {
|
|
622
|
+
skip = false;
|
|
623
|
+
continue;
|
|
624
|
+
}
|
|
625
|
+
if (node.text !== "" || Path.isBefore(path, blockPath)) {
|
|
626
|
+
end = { path, offset: node.text.length };
|
|
627
|
+
break;
|
|
628
|
+
}
|
|
629
|
+
}
|
|
630
|
+
return { anchor: start, focus: end };
|
|
631
|
+
}
|
|
632
|
+
function getSelection(editor) {
|
|
633
|
+
if (editor.selection)
|
|
634
|
+
return unhangRange(editor, editor.selection);
|
|
635
|
+
return {
|
|
636
|
+
anchor: Editor.start(editor, []),
|
|
637
|
+
focus: Editor.end(editor, [])
|
|
638
|
+
};
|
|
639
|
+
}
|
|
640
|
+
function getBlocksInSelection(editor) {
|
|
641
|
+
return Array.from(Editor.nodes(editor, {
|
|
642
|
+
at: getSelection(editor),
|
|
643
|
+
match: (node) => ElementUtils.isRootBlock(node)
|
|
644
|
+
})).filter((entry) => ElementUtils.isRootBlock(entry[0]));
|
|
645
|
+
}
|
|
646
|
+
function setBlockKeyForDevice(editor, breakpoints, deviceId, key, value, options) {
|
|
647
|
+
var _a, _b;
|
|
648
|
+
const at = (_a = options == null ? void 0 : options.at) != null ? _a : editor.selection;
|
|
649
|
+
if (!at)
|
|
650
|
+
return;
|
|
651
|
+
const rootElements = getBlocksInSelection(editor);
|
|
511
652
|
for (const [node, path] of rootElements) {
|
|
512
653
|
if (ElementUtils.isBlock(node)) {
|
|
513
|
-
const deviceValues = (
|
|
514
|
-
const currentDeviceValue =
|
|
654
|
+
const deviceValues = (_b = node[key]) != null ? _b : [];
|
|
655
|
+
const currentDeviceValue = findBreakpointOverride(breakpoints, deviceValues, deviceId, (v) => v);
|
|
515
656
|
const nextDeviceValue = __spreadProps(__spreadValues({}, currentDeviceValue), {
|
|
516
657
|
deviceId,
|
|
517
658
|
value
|
|
@@ -524,12 +665,7 @@ function setBlockKeyForDevice(editor, deviceId, key, value) {
|
|
|
524
665
|
}
|
|
525
666
|
function clearBlockKeyForDevice(editor, deviceId, key) {
|
|
526
667
|
var _a;
|
|
527
|
-
|
|
528
|
-
return;
|
|
529
|
-
const rootElements = Editor.nodes(editor, {
|
|
530
|
-
match: (_, path) => path.length === 1,
|
|
531
|
-
at: Editor.unhangRange(editor, editor.selection)
|
|
532
|
-
});
|
|
668
|
+
const rootElements = getBlocksInSelection(editor);
|
|
533
669
|
for (const [node, path] of rootElements) {
|
|
534
670
|
if (ElementUtils.isBlock(node)) {
|
|
535
671
|
const deviceOverrides = (_a = node[key]) != null ? _a : [];
|
|
@@ -539,12 +675,29 @@ function clearBlockKeyForDevice(editor, deviceId, key) {
|
|
|
539
675
|
}
|
|
540
676
|
}
|
|
541
677
|
}
|
|
678
|
+
function wrapInline(editor, inline) {
|
|
679
|
+
Transforms.wrapNodes(editor, inline, {
|
|
680
|
+
at: getSelection(editor),
|
|
681
|
+
split: true
|
|
682
|
+
});
|
|
683
|
+
}
|
|
684
|
+
function unwrapInline(editor, type) {
|
|
685
|
+
Transforms.unwrapNodes(editor, {
|
|
686
|
+
match: (node) => ElementUtils.isInline(node) && node.type === type,
|
|
687
|
+
at: getSelection(editor)
|
|
688
|
+
});
|
|
689
|
+
}
|
|
542
690
|
const Block = {
|
|
543
691
|
setBlockKeyForDevice,
|
|
544
|
-
clearBlockKeyForDevice
|
|
692
|
+
clearBlockKeyForDevice,
|
|
693
|
+
wrapInline,
|
|
694
|
+
unwrapInline
|
|
545
695
|
};
|
|
546
696
|
function withBlock(editor) {
|
|
547
697
|
const { normalizeNode } = editor;
|
|
698
|
+
editor.isInline = (entry) => {
|
|
699
|
+
return ElementUtils.isInline(entry);
|
|
700
|
+
};
|
|
548
701
|
editor.normalizeNode = (entry) => {
|
|
549
702
|
var _a;
|
|
550
703
|
const [normalizationNode, normalizationPath] = entry;
|