@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.
Files changed (239) hide show
  1. package/dist/Box.cjs.js +11 -11
  2. package/dist/Box.cjs.js.map +1 -1
  3. package/dist/Box.es.js +9 -9
  4. package/dist/Box.es.js.map +1 -1
  5. package/dist/Button.cjs.js +36 -37
  6. package/dist/Button.cjs.js.map +1 -1
  7. package/dist/Button.es.js +13 -14
  8. package/dist/Button.es.js.map +1 -1
  9. package/dist/Carousel.cjs.js +38 -37
  10. package/dist/Carousel.cjs.js.map +1 -1
  11. package/dist/Carousel.es.js +19 -18
  12. package/dist/Carousel.es.js.map +1 -1
  13. package/dist/Countdown.cjs.js +55 -29
  14. package/dist/Countdown.cjs.js.map +1 -1
  15. package/dist/Countdown.es.js +35 -9
  16. package/dist/Countdown.es.js.map +1 -1
  17. package/dist/Divider.cjs.js +36 -10
  18. package/dist/Divider.cjs.js.map +1 -1
  19. package/dist/Divider.es.js +31 -5
  20. package/dist/Divider.es.js.map +1 -1
  21. package/dist/Embed.cjs.js +31 -5
  22. package/dist/Embed.cjs.js.map +1 -1
  23. package/dist/Embed.es.js +30 -4
  24. package/dist/Embed.es.js.map +1 -1
  25. package/dist/Form.cjs.js +72 -73
  26. package/dist/Form.cjs.js.map +1 -1
  27. package/dist/Form.es.js +32 -33
  28. package/dist/Form.es.js.map +1 -1
  29. package/dist/Image.cjs.js +22 -21
  30. package/dist/Image.cjs.js.map +1 -1
  31. package/dist/Image.es.js +20 -19
  32. package/dist/Image.es.js.map +1 -1
  33. package/dist/LiveProvider.cjs.js +12 -12
  34. package/dist/LiveProvider.cjs.js.map +1 -1
  35. package/dist/LiveProvider.es.js +12 -12
  36. package/dist/LiveProvider.es.js.map +1 -1
  37. package/dist/Navigation.cjs.js +33 -34
  38. package/dist/Navigation.cjs.js.map +1 -1
  39. package/dist/Navigation.es.js +14 -15
  40. package/dist/Navigation.es.js.map +1 -1
  41. package/dist/PreviewProvider.cjs.js +16 -13
  42. package/dist/PreviewProvider.cjs.js.map +1 -1
  43. package/dist/PreviewProvider.es.js +16 -13
  44. package/dist/PreviewProvider.es.js.map +1 -1
  45. package/dist/ReadOnlyText.cjs.js +15 -16
  46. package/dist/ReadOnlyText.cjs.js.map +1 -1
  47. package/dist/ReadOnlyText.es.js +11 -12
  48. package/dist/ReadOnlyText.es.js.map +1 -1
  49. package/dist/Root.cjs.js +10 -10
  50. package/dist/Root.cjs.js.map +1 -1
  51. package/dist/Root.es.js +8 -8
  52. package/dist/SocialLinks.cjs.js +12 -13
  53. package/dist/SocialLinks.cjs.js.map +1 -1
  54. package/dist/SocialLinks.es.js +7 -8
  55. package/dist/SocialLinks.es.js.map +1 -1
  56. package/dist/Text.cjs.js +3 -4
  57. package/dist/Text.cjs.js.map +1 -1
  58. package/dist/Text.es.js +4 -5
  59. package/dist/Text.es.js.map +1 -1
  60. package/dist/Video.cjs.js +31 -5
  61. package/dist/Video.cjs.js.map +1 -1
  62. package/dist/Video.es.js +30 -4
  63. package/dist/Video.es.js.map +1 -1
  64. package/dist/actions.cjs.js +6 -1
  65. package/dist/actions.cjs.js.map +1 -1
  66. package/dist/actions.es.js +6 -2
  67. package/dist/actions.es.js.map +1 -1
  68. package/dist/components.cjs.js +10 -10
  69. package/dist/components.es.js +10 -10
  70. package/dist/constants.cjs.js +13 -3
  71. package/dist/constants.cjs.js.map +1 -1
  72. package/dist/constants.es.js +13 -4
  73. package/dist/constants.es.js.map +1 -1
  74. package/dist/descriptors.cjs.js.map +1 -1
  75. package/dist/descriptors.es.js.map +1 -1
  76. package/dist/index.cjs.js +1010 -163
  77. package/dist/index.cjs.js.map +1 -1
  78. package/dist/index.cjs2.js +29 -29
  79. package/dist/index.cjs2.js.map +1 -1
  80. package/dist/index.cjs3.js +1 -2
  81. package/dist/index.cjs3.js.map +1 -1
  82. package/dist/index.cjs4.js +2 -2
  83. package/dist/index.cjs4.js.map +1 -1
  84. package/dist/index.cjs5.js +262 -109
  85. package/dist/index.cjs5.js.map +1 -1
  86. package/dist/index.cjs6.js +3 -4
  87. package/dist/index.cjs6.js.map +1 -1
  88. package/dist/index.cjs7.js +16 -17
  89. package/dist/index.cjs7.js.map +1 -1
  90. package/dist/index.es.js +965 -133
  91. package/dist/index.es.js.map +1 -1
  92. package/dist/index.es2.js +6 -6
  93. package/dist/index.es2.js.map +1 -1
  94. package/dist/index.es3.js +1 -2
  95. package/dist/index.es3.js.map +1 -1
  96. package/dist/index.es4.js +2 -2
  97. package/dist/index.es4.js.map +1 -1
  98. package/dist/index.es5.js +262 -109
  99. package/dist/index.es5.js.map +1 -1
  100. package/dist/index.es6.js +3 -4
  101. package/dist/index.es6.js.map +1 -1
  102. package/dist/index.es7.js +12 -13
  103. package/dist/index.es7.js.map +1 -1
  104. package/dist/introspection.cjs.js +5 -2
  105. package/dist/introspection.cjs.js.map +1 -1
  106. package/dist/introspection.es.js +4 -2
  107. package/dist/introspection.es.js.map +1 -1
  108. package/dist/leaf.cjs.js +15 -17
  109. package/dist/leaf.cjs.js.map +1 -1
  110. package/dist/leaf.es.js +10 -11
  111. package/dist/leaf.es.js.map +1 -1
  112. package/dist/main.cjs.js +2 -1
  113. package/dist/main.cjs.js.map +1 -1
  114. package/dist/main.es.js +2 -2
  115. package/dist/next.cjs.js +5 -6
  116. package/dist/next.cjs.js.map +1 -1
  117. package/dist/next.es.js +6 -7
  118. package/dist/next.es.js.map +1 -1
  119. package/dist/prop-controllers.cjs.js +0 -1
  120. package/dist/prop-controllers.cjs.js.map +1 -1
  121. package/dist/prop-controllers.es.js +0 -1
  122. package/dist/prop-controllers.es.js.map +1 -1
  123. package/dist/react.cjs.js +3 -4
  124. package/dist/react.cjs.js.map +1 -1
  125. package/dist/react.es.js +3 -4
  126. package/dist/react.es.js.map +1 -1
  127. package/dist/slate.cjs.js +1 -12
  128. package/dist/slate.cjs.js.map +1 -1
  129. package/dist/slate.es.js +1 -12
  130. package/dist/slate.es.js.map +1 -1
  131. package/dist/state/breakpoints.cjs.js +175 -0
  132. package/dist/state/breakpoints.cjs.js.map +1 -0
  133. package/dist/state/breakpoints.es.js +160 -0
  134. package/dist/state/breakpoints.es.js.map +1 -0
  135. package/dist/types/src/components/builtin/Box/Box.d.ts.map +1 -1
  136. package/dist/types/src/components/builtin/Box/register.d.ts.map +1 -1
  137. package/dist/types/src/components/builtin/Button/Button.d.ts.map +1 -1
  138. package/dist/types/src/components/builtin/Button/register.d.ts.map +1 -1
  139. package/dist/types/src/components/builtin/Carousel/Carousel.d.ts.map +1 -1
  140. package/dist/types/src/components/builtin/Carousel/register.d.ts.map +1 -1
  141. package/dist/types/src/components/builtin/Countdown/register.d.ts.map +1 -1
  142. package/dist/types/src/components/builtin/Form/components/Field/components/Checkbox/index.d.ts +1 -1
  143. package/dist/types/src/components/builtin/Form/components/Field/components/Label/index.d.ts.map +1 -1
  144. package/dist/types/src/components/builtin/Form/register.d.ts.map +1 -1
  145. package/dist/types/src/components/builtin/Image/Image.d.ts.map +1 -1
  146. package/dist/types/src/components/builtin/Navigation/components/MobileMenu/components/MobileDropDownButton/index.d.ts.map +1 -1
  147. package/dist/types/src/components/builtin/Navigation/components/MobileMenu/index.d.ts.map +1 -1
  148. package/dist/types/src/components/builtin/Navigation/register.d.ts.map +1 -1
  149. package/dist/types/src/components/builtin/SocialLinks/register.d.ts.map +1 -1
  150. package/dist/types/src/components/builtin/Text/components/Leaf/leaf.d.ts +0 -4
  151. package/dist/types/src/components/builtin/Text/components/Leaf/leaf.d.ts.map +1 -1
  152. package/dist/types/src/components/builtin/Text/register.d.ts.map +1 -1
  153. package/dist/types/src/components/hooks/useMediaQuery.d.ts.map +1 -1
  154. package/dist/types/src/components/utils/drop-first.d.ts +2 -0
  155. package/dist/types/src/components/utils/drop-first.d.ts.map +1 -0
  156. package/dist/types/src/components/utils/responsive-style.d.ts +21 -10
  157. package/dist/types/src/components/utils/responsive-style.d.ts.map +1 -1
  158. package/dist/types/src/controls/types.d.ts +1 -1
  159. package/dist/types/src/controls/types.d.ts.map +1 -1
  160. package/dist/types/src/index.d.ts +2 -2
  161. package/dist/types/src/index.d.ts.map +1 -1
  162. package/dist/types/src/next/api-handler/handlers/manifest.d.ts +1 -0
  163. package/dist/types/src/next/api-handler/handlers/manifest.d.ts.map +1 -1
  164. package/dist/types/src/next/client.d.ts +4 -1
  165. package/dist/types/src/next/client.d.ts.map +1 -1
  166. package/dist/types/src/next/index.d.ts +3 -1
  167. package/dist/types/src/next/index.d.ts.map +1 -1
  168. package/dist/types/src/prop-controllers/descriptors.d.ts +1 -1
  169. package/dist/types/src/prop-controllers/descriptors.d.ts.map +1 -1
  170. package/dist/types/src/runtimes/react/components/LiveProvider.d.ts +3 -1
  171. package/dist/types/src/runtimes/react/components/LiveProvider.d.ts.map +1 -1
  172. package/dist/types/src/runtimes/react/components/PreviewProvider.d.ts +3 -1
  173. package/dist/types/src/runtimes/react/components/PreviewProvider.d.ts.map +1 -1
  174. package/dist/types/src/runtimes/react/index.d.ts +22 -4
  175. package/dist/types/src/runtimes/react/index.d.ts.map +1 -1
  176. package/dist/types/src/slate/BlockPlugin/clearBlockKeyForDevice.d.ts +2 -2
  177. package/dist/types/src/slate/BlockPlugin/clearBlockKeyForDevice.d.ts.map +1 -1
  178. package/dist/types/src/slate/BlockPlugin/index.d.ts +4 -0
  179. package/dist/types/src/slate/BlockPlugin/index.d.ts.map +1 -1
  180. package/dist/types/src/slate/BlockPlugin/setBlockKeyForDevice.d.ts +7 -3
  181. package/dist/types/src/slate/BlockPlugin/setBlockKeyForDevice.d.ts.map +1 -1
  182. package/dist/types/src/slate/BlockPlugin/types.d.ts +2 -2
  183. package/dist/types/src/slate/BlockPlugin/types.d.ts.map +1 -1
  184. package/dist/types/src/slate/BlockPlugin/unwrapInline.d.ts +4 -0
  185. package/dist/types/src/slate/BlockPlugin/unwrapInline.d.ts.map +1 -0
  186. package/dist/types/src/slate/BlockPlugin/wrapInline.d.ts +4 -0
  187. package/dist/types/src/slate/BlockPlugin/wrapInline.d.ts.map +1 -0
  188. package/dist/types/src/slate/ListPlugin/toggleList.d.ts +2 -1
  189. package/dist/types/src/slate/ListPlugin/toggleList.d.ts.map +1 -1
  190. package/dist/types/src/slate/ListPlugin/unwrapList.d.ts +6 -2
  191. package/dist/types/src/slate/ListPlugin/unwrapList.d.ts.map +1 -1
  192. package/dist/types/src/slate/ListPlugin/utils/getSelectedListItems.d.ts +0 -1
  193. package/dist/types/src/slate/ListPlugin/utils/getSelectedListItems.d.ts.map +1 -1
  194. package/dist/types/src/slate/ListPlugin/wrapList.d.ts +2 -1
  195. package/dist/types/src/slate/ListPlugin/wrapList.d.ts.map +1 -1
  196. package/dist/types/src/slate/TypographyPlugin/clearActiveTypographyStyle.d.ts +6 -2
  197. package/dist/types/src/slate/TypographyPlugin/clearActiveTypographyStyle.d.ts.map +1 -1
  198. package/dist/types/src/slate/TypographyPlugin/clearDeviceActiveTypography.d.ts +6 -2
  199. package/dist/types/src/slate/TypographyPlugin/clearDeviceActiveTypography.d.ts.map +1 -1
  200. package/dist/types/src/slate/TypographyPlugin/detachActiveTypography.d.ts +6 -2
  201. package/dist/types/src/slate/TypographyPlugin/detachActiveTypography.d.ts.map +1 -1
  202. package/dist/types/src/slate/TypographyPlugin/index.d.ts.map +1 -1
  203. package/dist/types/src/slate/TypographyPlugin/setActiveTypographyId.d.ts +6 -2
  204. package/dist/types/src/slate/TypographyPlugin/setActiveTypographyId.d.ts.map +1 -1
  205. package/dist/types/src/slate/TypographyPlugin/setActiveTypographyStyle.d.ts +7 -2
  206. package/dist/types/src/slate/TypographyPlugin/setActiveTypographyStyle.d.ts.map +1 -1
  207. package/dist/types/src/slate/selectors.d.ts +19 -0
  208. package/dist/types/src/slate/selectors.d.ts.map +1 -0
  209. package/dist/types/src/slate/utils/editor.d.ts.map +1 -1
  210. package/dist/types/src/slate/utils/element.d.ts +2 -1
  211. package/dist/types/src/slate/utils/element.d.ts.map +1 -1
  212. package/dist/types/src/slate/utils/unhangRange.d.ts +10 -0
  213. package/dist/types/src/slate/utils/unhangRange.d.ts.map +1 -0
  214. package/dist/types/src/state/actions.d.ts +10 -1
  215. package/dist/types/src/state/actions.d.ts.map +1 -1
  216. package/dist/types/src/state/modules/breakpoints.d.ts +44 -0
  217. package/dist/types/src/state/modules/breakpoints.d.ts.map +1 -0
  218. package/dist/types/src/state/react-builder-preview.d.ts +2 -0
  219. package/dist/types/src/state/react-builder-preview.d.ts.map +1 -1
  220. package/dist/types/src/state/react-page.d.ts +5 -1
  221. package/dist/types/src/state/react-page.d.ts.map +1 -1
  222. package/dist/types/src/utils/isNonNullable.d.ts +2 -0
  223. package/dist/types/src/utils/isNonNullable.d.ts.map +1 -0
  224. package/dist/useMediaQuery.cjs.js +38 -0
  225. package/dist/useMediaQuery.cjs.js.map +1 -0
  226. package/dist/useMediaQuery.es.js +37 -0
  227. package/dist/useMediaQuery.es.js.map +1 -0
  228. package/package.json +10 -2
  229. package/state/breakpoints.js +1 -0
  230. package/dist/isNonNullable.cjs.js +0 -6
  231. package/dist/isNonNullable.cjs.js.map +0 -1
  232. package/dist/isNonNullable.es.js +0 -5
  233. package/dist/isNonNullable.es.js.map +0 -1
  234. package/dist/responsive-style.cjs.js +0 -917
  235. package/dist/responsive-style.cjs.js.map +0 -1
  236. package/dist/responsive-style.es.js +0 -853
  237. package/dist/responsive-style.es.js.map +0 -1
  238. package/dist/types/src/components/utils/devices.d.ts +0 -17
  239. 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 { i as isDeviceOverride } from "./leaf.es.js";
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) && (Element.isElementType(node, BlockType.Paragraph) || Element.isElementType(node, BlockType.Heading1) || Element.isElementType(node, BlockType.Heading2) || Element.isElementType(node, BlockType.Heading3) || Element.isElementType(node, BlockType.Heading3) || Element.isElementType(node, BlockType.Heading4) || Element.isElementType(node, BlockType.Heading5) || Element.isElementType(node, BlockType.Heading6) || Element.isElementType(node, BlockType.BlockQuote) || Element.isElementType(node, BlockType.UnorderedList) || Element.isElementType(node, BlockType.OrderedList) || Element.isElementType(node, BlockType.ListItem) || Element.isElementType(node, BlockType.ListItemChild));
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.isElement(node) && (Element.isElementType(node, InlineType.Link) || Element.isElementType(node, InlineType.Link) || Element.isElementType(node, InlineType.SubScript) || Element.isElementType(node, InlineType.SuperScript));
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.createText()],
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
- const parentList = Editor.above(editor, {
78
- at: path,
79
- match: (node) => ElementUtils.isList(node)
80
- });
81
- return parentList != null ? parentList : null;
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
- const parentListItem = Editor.above(editor, {
85
- at: path,
86
- match: (node) => ElementUtils.isListItem(node)
87
- });
88
- return parentListItem != null ? parentListItem : null;
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
- if (!editor.selection)
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 = getSelectedListItems(editor);
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
- if (!editor.selection)
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: editor.selection,
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
- if (!editor.selection)
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(editor.selection);
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], index) => {
398
+ childrenToBeMerged.reverse().forEach(([_, childPath]) => {
377
399
  Transforms.moveNodes(editor, {
378
400
  at: childPath,
379
- to: [...nodePath, nodeChildren.length + index]
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
- if (!editor.selection)
396
- return;
397
- const textNodes = Editor.nodes(editor, {
398
- at: editor.selection,
399
- match: (node) => Text.isText(node)
400
- });
401
- for (const [node, path] of textNodes) {
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
- typography
408
- }, { at: path });
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
- function clearDeviceActiveTypography(editor, currentDeviceId) {
413
- var _a, _b;
414
- if (!editor.selection)
415
- return;
416
- const textNodes = Editor.nodes(editor, {
417
- at: editor.selection,
418
- match: (node) => Text.isText(node)
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
- for (const [node, path] of textNodes) {
421
- if (Text.isText(node)) {
422
- const typography = __spreadProps(__spreadValues({}, node.typography), {
423
- style: (_b = (_a = node == null ? void 0 : node.typography) == null ? void 0 : _a.style.filter(({ deviceId }) => deviceId !== currentDeviceId)) != null ? _b : []
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
- typography
427
- }, { at: path });
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
- if (!editor.selection)
433
- return;
434
- const textNodes = Array.from(Editor.nodes(editor, {
435
- at: editor.selection,
436
- match: (node) => Text.isText(node)
437
- }));
438
- textNodes.forEach(([node, path]) => {
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
- typography: {
442
- style: value
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
- }, { at: path });
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
- match: (node) => Text.isText(node)
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
- var _a, _b;
460
- if (!editor.selection)
461
- return;
462
- const textNodes = Editor.nodes(editor, {
463
- at: editor.selection,
464
- match: (node) => Text.isText(node)
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
- typography: nextTypography
479
- }, { at: path });
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 setBlockKeyForDevice(editor, deviceId, key, value) {
504
- var _a;
505
- if (!editor.selection)
506
- return;
507
- const rootElements = Editor.nodes(editor, {
508
- match: (_, path) => path.length === 1,
509
- at: Editor.unhangRange(editor, editor.selection)
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 = (_a = node[key]) != null ? _a : [];
514
- const currentDeviceValue = findDeviceOverride(deviceValues, deviceId, (v) => v);
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
- if (!editor.selection)
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;