@makeswift/runtime 0.8.11 → 0.9.1

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 (273) hide show
  1. package/dist/Box.cjs.js +16 -15
  2. package/dist/Box.cjs.js.map +1 -1
  3. package/dist/Box.es.js +11 -10
  4. package/dist/Box.es.js.map +1 -1
  5. package/dist/Button.cjs.js +13 -12
  6. package/dist/Button.cjs.js.map +1 -1
  7. package/dist/Button.es.js +11 -10
  8. package/dist/Button.es.js.map +1 -1
  9. package/dist/Carousel.cjs.js +28 -27
  10. package/dist/Carousel.cjs.js.map +1 -1
  11. package/dist/Carousel.es.js +7 -6
  12. package/dist/Carousel.es.js.map +1 -1
  13. package/dist/Countdown.cjs.js +16 -15
  14. package/dist/Countdown.cjs.js.map +1 -1
  15. package/dist/Countdown.es.js +8 -7
  16. package/dist/Countdown.es.js.map +1 -1
  17. package/dist/Divider.cjs.js +13 -12
  18. package/dist/Divider.cjs.js.map +1 -1
  19. package/dist/Divider.es.js +11 -10
  20. package/dist/Divider.es.js.map +1 -1
  21. package/dist/Embed.cjs.js +4 -29
  22. package/dist/Embed.cjs.js.map +1 -1
  23. package/dist/Embed.es.js +3 -28
  24. package/dist/Embed.es.js.map +1 -1
  25. package/dist/Form.cjs.js +52 -51
  26. package/dist/Form.cjs.js.map +1 -1
  27. package/dist/Form.es.js +8 -7
  28. package/dist/Form.es.js.map +1 -1
  29. package/dist/Image.cjs.js +9 -8
  30. package/dist/Image.cjs.js.map +1 -1
  31. package/dist/Image.es.js +8 -7
  32. package/dist/Image.es.js.map +1 -1
  33. package/dist/LiveProvider.cjs.js +6 -5
  34. package/dist/LiveProvider.cjs.js.map +1 -1
  35. package/dist/LiveProvider.es.js +8 -7
  36. package/dist/LiveProvider.es.js.map +1 -1
  37. package/dist/Navigation.cjs.js +28 -27
  38. package/dist/Navigation.cjs.js.map +1 -1
  39. package/dist/Navigation.es.js +7 -6
  40. package/dist/Navigation.es.js.map +1 -1
  41. package/dist/PreviewProvider.cjs.js +23 -7
  42. package/dist/PreviewProvider.cjs.js.map +1 -1
  43. package/dist/PreviewProvider.es.js +24 -8
  44. package/dist/PreviewProvider.es.js.map +1 -1
  45. package/dist/ReadOnlyText.cjs.js +22 -20
  46. package/dist/ReadOnlyText.cjs.js.map +1 -1
  47. package/dist/ReadOnlyText.es.js +18 -16
  48. package/dist/ReadOnlyText.es.js.map +1 -1
  49. package/dist/ReadOnlyTextV2.cjs.js +19 -17
  50. package/dist/ReadOnlyTextV2.cjs.js.map +1 -1
  51. package/dist/ReadOnlyTextV2.es.js +16 -14
  52. package/dist/ReadOnlyTextV2.es.js.map +1 -1
  53. package/dist/Root.cjs.js +8 -7
  54. package/dist/Root.cjs.js.map +1 -1
  55. package/dist/Root.es.js +6 -5
  56. package/dist/Root.es.js.map +1 -1
  57. package/dist/SocialLinks.cjs.js +15 -14
  58. package/dist/SocialLinks.cjs.js.map +1 -1
  59. package/dist/SocialLinks.es.js +11 -10
  60. package/dist/SocialLinks.es.js.map +1 -1
  61. package/dist/Text.cjs.js +5 -4
  62. package/dist/Text.cjs.js.map +1 -1
  63. package/dist/Text.es.js +6 -5
  64. package/dist/Text.es.js.map +1 -1
  65. package/dist/Video.cjs.js +4 -29
  66. package/dist/Video.cjs.js.map +1 -1
  67. package/dist/Video.es.js +3 -28
  68. package/dist/Video.es.js.map +1 -1
  69. package/dist/actions.cjs.js +16 -1
  70. package/dist/actions.cjs.js.map +1 -1
  71. package/dist/actions.es.js +14 -2
  72. package/dist/actions.es.js.map +1 -1
  73. package/dist/builder.cjs.js +5 -0
  74. package/dist/builder.cjs.js.map +1 -1
  75. package/dist/builder.es.js +5 -0
  76. package/dist/builder.es.js.map +1 -1
  77. package/dist/components.cjs.js +10 -9
  78. package/dist/components.cjs.js.map +1 -1
  79. package/dist/components.es.js +10 -9
  80. package/dist/components.es.js.map +1 -1
  81. package/dist/control-serialization.cjs.js +89 -10
  82. package/dist/control-serialization.cjs.js.map +1 -1
  83. package/dist/control-serialization.es.js +90 -11
  84. package/dist/control-serialization.es.js.map +1 -1
  85. package/dist/controls.cjs.js +12 -3
  86. package/dist/controls.cjs.js.map +1 -1
  87. package/dist/controls.es.js +6 -2
  88. package/dist/controls.es.js.map +1 -1
  89. package/dist/deepEqual.cjs.js +40 -0
  90. package/dist/deepEqual.cjs.js.map +1 -0
  91. package/dist/deepEqual.es.js +39 -0
  92. package/dist/deepEqual.es.js.map +1 -0
  93. package/dist/index.cjs.js +298 -292
  94. package/dist/index.cjs.js.map +1 -1
  95. package/dist/index.cjs10.js +18 -16
  96. package/dist/index.cjs10.js.map +1 -1
  97. package/dist/index.cjs2.js +14 -14
  98. package/dist/index.cjs2.js.map +1 -1
  99. package/dist/index.cjs4.js +2 -1
  100. package/dist/index.cjs4.js.map +1 -1
  101. package/dist/index.cjs5.js +0 -522
  102. package/dist/index.cjs5.js.map +1 -1
  103. package/dist/index.cjs6.js +1 -2
  104. package/dist/index.cjs6.js.map +1 -1
  105. package/dist/index.cjs7.js +0 -52
  106. package/dist/index.cjs7.js.map +1 -1
  107. package/dist/index.cjs8.js +5 -4
  108. package/dist/index.cjs8.js.map +1 -1
  109. package/dist/index.cjs9.js +72 -69
  110. package/dist/index.cjs9.js.map +1 -1
  111. package/dist/index.es.js +282 -275
  112. package/dist/index.es.js.map +1 -1
  113. package/dist/index.es10.js +16 -14
  114. package/dist/index.es10.js.map +1 -1
  115. package/dist/index.es2.js +3 -3
  116. package/dist/index.es3.js +1 -1
  117. package/dist/index.es4.js +2 -1
  118. package/dist/index.es4.js.map +1 -1
  119. package/dist/index.es5.js +2 -514
  120. package/dist/index.es5.js.map +1 -1
  121. package/dist/index.es6.js +1 -2
  122. package/dist/index.es6.js.map +1 -1
  123. package/dist/index.es7.js +2 -53
  124. package/dist/index.es7.js.map +1 -1
  125. package/dist/index.es8.js +5 -4
  126. package/dist/index.es8.js.map +1 -1
  127. package/dist/index.es9.js +74 -71
  128. package/dist/index.es9.js.map +1 -1
  129. package/dist/leaf.cjs.js +1 -1
  130. package/dist/leaf.cjs.js.map +1 -1
  131. package/dist/leaf.es.js +2 -2
  132. package/dist/main.cjs.js +8 -0
  133. package/dist/main.cjs.js.map +1 -1
  134. package/dist/main.es.js +7 -2
  135. package/dist/main.es.js.map +1 -1
  136. package/dist/next.cjs.js +5 -4
  137. package/dist/next.cjs.js.map +1 -1
  138. package/dist/next.es.js +6 -5
  139. package/dist/next.es.js.map +1 -1
  140. package/dist/prop-controllers.cjs.js +5 -0
  141. package/dist/prop-controllers.cjs.js.map +1 -1
  142. package/dist/prop-controllers.es.js +5 -0
  143. package/dist/prop-controllers.es.js.map +1 -1
  144. package/dist/react-page.cjs.js +1013 -190
  145. package/dist/react-page.cjs.js.map +1 -1
  146. package/dist/react-page.es.js +968 -185
  147. package/dist/react-page.es.js.map +1 -1
  148. package/dist/react.cjs.js +5 -4
  149. package/dist/react.cjs.js.map +1 -1
  150. package/dist/react.es.js +5 -4
  151. package/dist/react.es.js.map +1 -1
  152. package/dist/slate.cjs.js +96 -14
  153. package/dist/slate.cjs.js.map +1 -1
  154. package/dist/slate.es.js +89 -6
  155. package/dist/slate.es.js.map +1 -1
  156. package/dist/types/src/api/graphql/documents/queries.d.ts.map +1 -1
  157. package/dist/types/src/api/graphql/generated/types.d.ts +0 -8
  158. package/dist/types/src/api/graphql/generated/types.d.ts.map +1 -1
  159. package/dist/types/src/builder/serialization/control-serialization.d.ts +3 -3
  160. package/dist/types/src/builder/serialization/control-serialization.d.ts.map +1 -1
  161. package/dist/types/src/builder/serialization/controls/rich-text-v2.d.ts +2 -2
  162. package/dist/types/src/builder/serialization/controls/rich-text-v2.d.ts.map +1 -1
  163. package/dist/types/src/builder/serialization/controls/style-v2.d.ts +5 -0
  164. package/dist/types/src/builder/serialization/controls/style-v2.d.ts.map +1 -0
  165. package/dist/types/src/components/builtin/Button/Button.d.ts +1 -1
  166. package/dist/types/src/components/builtin/Carousel/register.d.ts.map +1 -1
  167. package/dist/types/src/components/builtin/Countdown/register.d.ts.map +1 -1
  168. package/dist/types/src/components/builtin/Divider/register.d.ts.map +1 -1
  169. package/dist/types/src/components/builtin/Embed/register.d.ts.map +1 -1
  170. package/dist/types/src/components/builtin/Form/components/Field/components/Checkbox/index.d.ts +1 -1
  171. package/dist/types/src/components/builtin/Form/register.d.ts.map +1 -1
  172. package/dist/types/src/components/builtin/Navigation/register.d.ts.map +1 -1
  173. package/dist/types/src/components/builtin/SocialLinks/register.d.ts.map +1 -1
  174. package/dist/types/src/components/builtin/Text/EditableText/editable-text.d.ts.map +1 -1
  175. package/dist/types/src/components/builtin/Text/ReadOnlyText.d.ts.map +1 -1
  176. package/dist/types/src/components/builtin/Text/components/Element/block.d.ts.map +1 -1
  177. package/dist/types/src/components/builtin/Video/register.d.ts.map +1 -1
  178. package/dist/types/src/components/hooks/useIsomorphicLayoutEffect.d.ts +2 -2
  179. package/dist/types/src/components/hooks/useIsomorphicLayoutEffect.d.ts.map +1 -1
  180. package/dist/types/src/controls/control.d.ts +3 -2
  181. package/dist/types/src/controls/control.d.ts.map +1 -1
  182. package/dist/types/src/controls/index.d.ts +1 -0
  183. package/dist/types/src/controls/index.d.ts.map +1 -1
  184. package/dist/types/src/controls/rich-text-v2/rich-text-v2.d.ts +10 -5
  185. package/dist/types/src/controls/rich-text-v2/rich-text-v2.d.ts.map +1 -1
  186. package/dist/types/src/controls/style-v2.d.ts +55 -0
  187. package/dist/types/src/controls/style-v2.d.ts.map +1 -0
  188. package/dist/types/src/index.d.ts +2 -1
  189. package/dist/types/src/index.d.ts.map +1 -1
  190. package/dist/types/src/next/api-handler/handlers/manifest.d.ts +3 -1
  191. package/dist/types/src/next/api-handler/handlers/manifest.d.ts.map +1 -1
  192. package/dist/types/src/next/api-handler/handlers/proxy-preview-mode.d.ts.map +1 -1
  193. package/dist/types/src/next/api-handler/index.d.ts +2 -1
  194. package/dist/types/src/next/api-handler/index.d.ts.map +1 -1
  195. package/dist/types/src/next/client.d.ts +7 -7
  196. package/dist/types/src/next/client.d.ts.map +1 -1
  197. package/dist/types/src/next/index.d.ts +8 -5
  198. package/dist/types/src/next/index.d.ts.map +1 -1
  199. package/dist/types/src/next/preview-mode.d.ts +17 -3
  200. package/dist/types/src/next/preview-mode.d.ts.map +1 -1
  201. package/dist/types/src/prop-controllers/descriptors.d.ts +4 -3
  202. package/dist/types/src/prop-controllers/descriptors.d.ts.map +1 -1
  203. package/dist/types/src/prop-controllers/instances.d.ts +2 -2
  204. package/dist/types/src/prop-controllers/instances.d.ts.map +1 -1
  205. package/dist/types/src/runtimes/react/controls/control.d.ts +3 -2
  206. package/dist/types/src/runtimes/react/controls/control.d.ts.map +1 -1
  207. package/dist/types/src/runtimes/react/controls/rich-text-v2/EditableTextV2/editable-text-v2.d.ts +2 -1
  208. package/dist/types/src/runtimes/react/controls/rich-text-v2/EditableTextV2/editable-text-v2.d.ts.map +1 -1
  209. package/dist/types/src/runtimes/react/controls/rich-text-v2/ReadOnlyTextV2.d.ts.map +1 -1
  210. package/dist/types/src/runtimes/react/controls/rich-text-v2/rich-text-v2.d.ts +1 -1
  211. package/dist/types/src/runtimes/react/controls/rich-text-v2/rich-text-v2.d.ts.map +1 -1
  212. package/dist/types/src/runtimes/react/controls/style-v2.d.ts +4 -0
  213. package/dist/types/src/runtimes/react/controls/style-v2.d.ts.map +1 -0
  214. package/dist/types/src/runtimes/react/controls.d.ts.map +1 -1
  215. package/dist/types/src/runtimes/react/index.d.ts +3 -1
  216. package/dist/types/src/runtimes/react/index.d.ts.map +1 -1
  217. package/dist/types/src/slate/BlockPlugin/constants.d.ts.map +1 -0
  218. package/dist/types/src/slate/BlockPlugin/dedent.d.ts.map +1 -0
  219. package/dist/types/src/slate/BlockPlugin/indent.d.ts.map +1 -0
  220. package/dist/types/src/slate/BlockPlugin/index.d.ts +29 -3
  221. package/dist/types/src/slate/BlockPlugin/index.d.ts.map +1 -1
  222. package/dist/types/src/slate/BlockPlugin/toggleList.d.ts.map +1 -0
  223. package/dist/types/src/slate/BlockPlugin/unwrapList.d.ts.map +1 -0
  224. package/dist/types/src/slate/BlockPlugin/utils/filterForSubtreeRoots.d.ts.map +1 -0
  225. package/dist/types/src/slate/BlockPlugin/utils/getSelectedListItems.d.ts.map +1 -0
  226. package/dist/types/src/slate/BlockPlugin/utils/location.d.ts.map +1 -0
  227. package/dist/types/src/slate/BlockPlugin/wrapList.d.ts.map +1 -0
  228. package/dist/types/src/slate/InlineModePlugin/index.d.ts +2 -1
  229. package/dist/types/src/slate/InlineModePlugin/index.d.ts.map +1 -1
  230. package/dist/types/src/slate/TextAlignPlugin/index.d.ts +9 -0
  231. package/dist/types/src/slate/TextAlignPlugin/index.d.ts.map +1 -0
  232. package/dist/types/src/slate/index.d.ts +1 -1
  233. package/dist/types/src/slate/index.d.ts.map +1 -1
  234. package/dist/types/src/slate/types.d.ts +18 -0
  235. package/dist/types/src/slate/types.d.ts.map +1 -1
  236. package/dist/types/src/slate/utils/element.d.ts +1 -2
  237. package/dist/types/src/slate/utils/element.d.ts.map +1 -1
  238. package/dist/types/src/state/actions.d.ts +26 -1
  239. package/dist/types/src/state/actions.d.ts.map +1 -1
  240. package/dist/types/src/state/modules/components-meta.d.ts +25 -1
  241. package/dist/types/src/state/modules/components-meta.d.ts.map +1 -1
  242. package/dist/types/src/state/modules/locales.d.ts +16 -0
  243. package/dist/types/src/state/modules/locales.d.ts.map +1 -0
  244. package/dist/types/src/state/react-builder-preview.d.ts +2 -0
  245. package/dist/types/src/state/react-builder-preview.d.ts.map +1 -1
  246. package/dist/types/src/state/react-page.d.ts +5 -1
  247. package/dist/types/src/state/react-page.d.ts.map +1 -1
  248. package/dist/useMediaQuery.es.js +1 -1
  249. package/package.json +6 -3
  250. package/dist/select.cjs.js +0 -8
  251. package/dist/select.cjs.js.map +0 -1
  252. package/dist/select.es.js +0 -6
  253. package/dist/select.es.js.map +0 -1
  254. package/dist/types/src/slate/ListPlugin/constants.d.ts.map +0 -1
  255. package/dist/types/src/slate/ListPlugin/dedent.d.ts.map +0 -1
  256. package/dist/types/src/slate/ListPlugin/indent.d.ts.map +0 -1
  257. package/dist/types/src/slate/ListPlugin/index.d.ts +0 -17
  258. package/dist/types/src/slate/ListPlugin/index.d.ts.map +0 -1
  259. package/dist/types/src/slate/ListPlugin/toggleList.d.ts.map +0 -1
  260. package/dist/types/src/slate/ListPlugin/unwrapList.d.ts.map +0 -1
  261. package/dist/types/src/slate/ListPlugin/utils/filterForSubtreeRoots.d.ts.map +0 -1
  262. package/dist/types/src/slate/ListPlugin/utils/getSelectedListItems.d.ts.map +0 -1
  263. package/dist/types/src/slate/ListPlugin/utils/location.d.ts.map +0 -1
  264. package/dist/types/src/slate/ListPlugin/wrapList.d.ts.map +0 -1
  265. /package/dist/types/src/slate/{ListPlugin → BlockPlugin}/constants.d.ts +0 -0
  266. /package/dist/types/src/slate/{ListPlugin → BlockPlugin}/dedent.d.ts +0 -0
  267. /package/dist/types/src/slate/{ListPlugin → BlockPlugin}/indent.d.ts +0 -0
  268. /package/dist/types/src/slate/{ListPlugin → BlockPlugin}/toggleList.d.ts +0 -0
  269. /package/dist/types/src/slate/{ListPlugin → BlockPlugin}/unwrapList.d.ts +0 -0
  270. /package/dist/types/src/slate/{ListPlugin → BlockPlugin}/utils/filterForSubtreeRoots.d.ts +0 -0
  271. /package/dist/types/src/slate/{ListPlugin → BlockPlugin}/utils/getSelectedListItems.d.ts +0 -0
  272. /package/dist/types/src/slate/{ListPlugin → BlockPlugin}/utils/location.d.ts +0 -0
  273. /package/dist/types/src/slate/{ListPlugin → BlockPlugin}/wrapList.d.ts +0 -0
package/dist/index.es5.js CHANGED
@@ -17,354 +17,8 @@ var __spreadValues = (a, b) => {
17
17
  return a;
18
18
  };
19
19
  var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
- import { Editor, Path, Range, Point, Node, Transforms, Element, Text } from "slate";
21
- import isHotkey from "is-hotkey";
22
- import { E as ElementUtils } from "./index.es7.js";
23
- import { b4 as BlockType, a$ as createRichTextV2Plugin, b3 as RootBlockType } from "./react-page.es.js";
20
+ import { Editor, Transforms, Text, Range } from "slate";
24
21
  import { findBreakpointOverride } from "./state/breakpoints.es.js";
25
- import { a as Select } from "./select.es.js";
26
- import "slate-react";
27
- const LIST_ITEM_CHILD_POSITION = 0;
28
- const LIST_ITEM_LIST_POSITION = 1;
29
- const EditorUtils = {
30
- getFirstAncestorList(editor, path) {
31
- try {
32
- const parentList = Editor.above(editor, {
33
- at: path,
34
- match: (node) => ElementUtils.isList(node)
35
- });
36
- return parentList != null ? parentList : null;
37
- } catch (e) {
38
- return null;
39
- }
40
- },
41
- getFirstAncestorListItem(editor, path) {
42
- try {
43
- const parentListItem = Editor.above(editor, {
44
- at: path,
45
- match: (node) => ElementUtils.isListItem(node)
46
- });
47
- return parentListItem != null ? parentListItem : null;
48
- } catch (e) {
49
- return null;
50
- }
51
- }
52
- };
53
- function filterForSubtreeRoots(entries) {
54
- return entries.filter(([, nodePath]) => !Path.ancestors(nodePath).some((ancestor) => {
55
- return entries.some(([, path]) => Path.equals(path, ancestor));
56
- }));
57
- }
58
- const LocationUtils = {
59
- getStartPath(location) {
60
- if (Range.isRange(location))
61
- return Range.start(location).path;
62
- if (Point.isPoint(location))
63
- return location.path;
64
- return location;
65
- }
66
- };
67
- function getSelectedListItems(editor) {
68
- var _a, _b;
69
- if (!editor.selection)
70
- return [];
71
- const start = LocationUtils.getStartPath(editor.selection);
72
- const listItems = Editor.nodes(editor, {
73
- at: editor.selection,
74
- match: (node) => ElementUtils.isListItem(node)
75
- });
76
- const firstAncestorPath = (_b = (_a = EditorUtils.getFirstAncestorListItem(editor, start)) == null ? void 0 : _a[1]) != null ? _b : [];
77
- return Array.from(listItems).filter((node) => Path.isDescendant(start, node[1]) ? Path.equals(node[1], firstAncestorPath) : !Path.isAfter(start, node[1]));
78
- }
79
- function indentPath(editor, path) {
80
- const parent = Node.parent(editor, path);
81
- if (!path || !Path.hasPrevious(path) || !ElementUtils.isList(parent))
82
- return;
83
- const previosPath = Path.previous(path);
84
- const previousChildListPath = [...previosPath, LIST_ITEM_LIST_POSITION];
85
- const previousHasChildList = Node.has(editor, previousChildListPath);
86
- Editor.withoutNormalizing(editor, () => {
87
- if (!previousHasChildList) {
88
- Transforms.insertNodes(editor, ElementUtils.createList(parent.type), {
89
- at: previousChildListPath
90
- });
91
- }
92
- const previousChildList = Node.get(editor, previousChildListPath);
93
- if (ElementUtils.isList(previousChildList)) {
94
- const index = previousHasChildList ? previousChildList.children.length : 0;
95
- Transforms.moveNodes(editor, {
96
- at: path,
97
- to: [...previousChildListPath, index]
98
- });
99
- }
100
- });
101
- }
102
- function indent(editor) {
103
- if (!editor.selection)
104
- return;
105
- const listItems = getSelectedListItems(editor);
106
- const subRoots = filterForSubtreeRoots(listItems);
107
- const refs = subRoots.map(([_, path]) => Editor.pathRef(editor, path));
108
- refs.forEach((ref) => {
109
- if (ref.current) {
110
- indentPath(editor, ref.current);
111
- }
112
- ref.unref();
113
- });
114
- }
115
- function dedentPath(editor, listItemPath) {
116
- const parentList = EditorUtils.getFirstAncestorList(editor, listItemPath);
117
- const listItemContainingParentList = EditorUtils.getFirstAncestorListItem(editor, listItemPath);
118
- if (!parentList || !listItemContainingParentList)
119
- return;
120
- const [parentListNode, parentListPath] = parentList;
121
- const [_, listItemContainingParentListPath] = listItemContainingParentList;
122
- const listItemPosition = listItemPath[listItemPath.length - 1];
123
- const previousSiblings = parentListNode.children.slice(0, listItemPosition);
124
- const nextSiblings = parentListNode.children.slice(listItemPosition + 1);
125
- Editor.withoutNormalizing(editor, () => {
126
- nextSiblings.forEach(() => {
127
- const nextSiblingPath = [...parentListPath, listItemPosition + 1];
128
- indentPath(editor, nextSiblingPath);
129
- });
130
- Transforms.moveNodes(editor, {
131
- at: listItemPath,
132
- to: Path.next(listItemContainingParentListPath)
133
- });
134
- if (previousSiblings.length === 0) {
135
- Transforms.removeNodes(editor, { at: parentListPath });
136
- }
137
- });
138
- }
139
- function dedent(editor) {
140
- if (!editor.selection)
141
- return;
142
- const listItems = getSelectedListItems(editor);
143
- const subRoots = filterForSubtreeRoots(listItems);
144
- const refs = subRoots.map(([_, path]) => Editor.pathRef(editor, path));
145
- refs.forEach((ref) => {
146
- if (ref.current) {
147
- dedentPath(editor, ref.current);
148
- }
149
- ref.unref();
150
- });
151
- }
152
- function unwrapPath(editor, listItemPath) {
153
- const parentList = EditorUtils.getFirstAncestorList(editor, listItemPath);
154
- const listItemContainingParentList = EditorUtils.getFirstAncestorListItem(editor, listItemPath);
155
- if (!parentList || listItemContainingParentList)
156
- return;
157
- Editor.withoutNormalizing(editor, () => {
158
- const listItemTextPath = [...listItemPath, LIST_ITEM_CHILD_POSITION];
159
- const listItemNestedListPath = [...listItemPath, LIST_ITEM_LIST_POSITION];
160
- if (Node.has(editor, listItemNestedListPath)) {
161
- Transforms.setNodes(editor, { type: parentList[0].type }, { at: listItemNestedListPath });
162
- Transforms.liftNodes(editor, { at: listItemNestedListPath });
163
- Transforms.liftNodes(editor, { at: Path.next(listItemPath) });
164
- }
165
- if (Node.has(editor, listItemTextPath)) {
166
- Transforms.setNodes(editor, { type: BlockType.Paragraph }, {
167
- at: listItemTextPath
168
- });
169
- Transforms.liftNodes(editor, { at: listItemTextPath });
170
- Transforms.liftNodes(editor, { at: listItemPath });
171
- }
172
- });
173
- }
174
- function unwrapList(editor, options) {
175
- var _a;
176
- const at = (_a = options == null ? void 0 : options.at) != null ? _a : editor.selection;
177
- if (!at)
178
- return;
179
- const listItems = Array.from(Editor.nodes(editor, {
180
- at,
181
- match: (node) => {
182
- return Element.isElement(node) && ElementUtils.isListItem(node);
183
- }
184
- }));
185
- const subRoots = filterForSubtreeRoots(listItems);
186
- const refs = subRoots.map(([_, path]) => Editor.pathRef(editor, path));
187
- refs.forEach((ref) => {
188
- if (ref.current) {
189
- unwrapPath(editor, ref.current);
190
- }
191
- ref.unref();
192
- });
193
- }
194
- function wrapList(editor, options = { type: BlockType.UnorderedList }) {
195
- var _a;
196
- const at = (_a = options.at) != null ? _a : editor.selection;
197
- if (!at)
198
- return;
199
- const nonListEntries = Array.from(Editor.nodes(editor, {
200
- at,
201
- match: (node) => {
202
- return Element.isElement(node) && ElementUtils.isConvertibleToListTextNode(node);
203
- }
204
- }));
205
- const refs = nonListEntries.map(([_, path]) => Editor.pathRef(editor, path));
206
- refs.forEach((ref) => {
207
- const path = ref.current;
208
- if (path) {
209
- Editor.withoutNormalizing(editor, () => {
210
- Transforms.setNodes(editor, { type: BlockType.ListItemChild }, {
211
- at: path
212
- });
213
- Transforms.wrapNodes(editor, ElementUtils.createListItem(), {
214
- match: (node) => ElementUtils.isListItemChild(node),
215
- at: path
216
- });
217
- Transforms.wrapNodes(editor, ElementUtils.createList(options.type), {
218
- at: path
219
- });
220
- });
221
- }
222
- ref.unref();
223
- });
224
- }
225
- function toggleList(editor, options = { type: BlockType.UnorderedList }) {
226
- var _a;
227
- const at = (_a = options.at) != null ? _a : editor.selection;
228
- if (at == null)
229
- return;
230
- const start = LocationUtils.getStartPath(at);
231
- const ancestorPath = Path.ancestors(start).at(1);
232
- if (!ancestorPath || !Node.has(editor, ancestorPath))
233
- return;
234
- const ancestor = Node.get(editor, ancestorPath);
235
- if (!ElementUtils.isList(ancestor)) {
236
- return wrapList(editor, { type: options.type, at });
237
- }
238
- if (ancestor.type === options.type) {
239
- unwrapList(editor, { at });
240
- } else {
241
- Transforms.setNodes(editor, { type: options.type }, { at: ancestorPath });
242
- }
243
- }
244
- const ListActions = {
245
- unwrapList,
246
- wrapList,
247
- indent,
248
- dedent,
249
- toggleList
250
- };
251
- function onKeyDown(e, editor) {
252
- if (!editor.selection || Array.from(Editor.nodes(editor, { match: (node) => ElementUtils.isListItem(node) })).length === 0)
253
- return;
254
- if (isHotkey("shift+tab", e)) {
255
- e.preventDefault();
256
- ListActions.dedent(editor);
257
- }
258
- if (isHotkey("tab", e)) {
259
- e.preventDefault();
260
- ListActions.indent(editor);
261
- }
262
- if (isHotkey("backspace", e)) {
263
- if (!editor.selection)
264
- return;
265
- if (Range.isExpanded(editor.selection))
266
- return;
267
- const listItem = EditorUtils.getFirstAncestorListItem(editor, editor.selection.anchor.path);
268
- if (editor.selection.anchor.offset === 0 && listItem) {
269
- e.preventDefault();
270
- const parentListItem = EditorUtils.getFirstAncestorListItem(editor, listItem[1]);
271
- const list = EditorUtils.getFirstAncestorList(editor, listItem[1]);
272
- if (parentListItem) {
273
- ListActions.dedent(editor);
274
- } else if (list) {
275
- ListActions.unwrapList(editor);
276
- }
277
- return;
278
- }
279
- }
280
- if (isHotkey("enter", e)) {
281
- e.preventDefault();
282
- if (!editor.selection)
283
- return;
284
- if (Range.isExpanded(editor.selection)) {
285
- Transforms.delete(editor);
286
- return;
287
- }
288
- const listItem = EditorUtils.getFirstAncestorListItem(editor, editor.selection.anchor.path);
289
- if (editor.selection.anchor.offset === 0 && listItem && Editor.string(editor, listItem[1]) === "") {
290
- const parentListItem = EditorUtils.getFirstAncestorListItem(editor, listItem[1]);
291
- if (parentListItem) {
292
- ListActions.dedent(editor);
293
- } else {
294
- ListActions.unwrapList(editor);
295
- }
296
- return;
297
- }
298
- Transforms.splitNodes(editor, {
299
- at: editor.selection,
300
- always: true,
301
- match: (node) => ElementUtils.isListItem(node)
302
- });
303
- }
304
- if (isHotkey("shift+enter", e)) {
305
- e.preventDefault();
306
- editor.insertText("\n");
307
- }
308
- }
309
- function withList(editor) {
310
- const { normalizeNode } = editor;
311
- editor.normalizeNode = (entry) => {
312
- const [normalizationNode, normalizationPath] = entry;
313
- if (ElementUtils.isListItem(normalizationNode)) {
314
- const pathToListItemText = [...normalizationPath, LIST_ITEM_CHILD_POSITION];
315
- if (Node.has(editor, pathToListItemText)) {
316
- const nodeInListItemTextPosition = Node.get(editor, pathToListItemText);
317
- if (ElementUtils.isParagraph(nodeInListItemTextPosition)) {
318
- Transforms.setNodes(editor, { type: BlockType.ListItemChild }, {
319
- at: pathToListItemText
320
- });
321
- return;
322
- }
323
- } else {
324
- Transforms.insertNodes(editor, ElementUtils.createListItem(), {
325
- at: pathToListItemText
326
- });
327
- return;
328
- }
329
- }
330
- if (!Text.isText(normalizationNode)) {
331
- const mergeableChildren = Array.from(Node.children(editor, normalizationPath)).map((child, index, children) => {
332
- const potentialNodeToBeMerged = children.at(index + 1);
333
- if (!potentialNodeToBeMerged || !ElementUtils.isList(potentialNodeToBeMerged[0]) || !ElementUtils.isList(child[0]) || potentialNodeToBeMerged[0].type !== child[0].type) {
334
- return null;
335
- }
336
- return [
337
- Editor.pathRef(editor, child[1]),
338
- Editor.pathRef(editor, potentialNodeToBeMerged[1])
339
- ];
340
- }).filter((mergeableNodes) => Boolean(mergeableNodes));
341
- if (mergeableChildren.length !== 0) {
342
- mergeableChildren.reverse().forEach(([nodePathRef, nodeToBeMergedPathRef]) => {
343
- const nodePath = nodePathRef.current;
344
- const nodeToBeMergedPath = nodeToBeMergedPathRef.current;
345
- if (nodePath == null || nodeToBeMergedPath == null)
346
- return;
347
- const nodeChildren = Array.from(Node.children(editor, nodePath));
348
- const childrenToBeMerged = Array.from(Node.children(editor, nodeToBeMergedPath));
349
- Editor.withoutNormalizing(editor, () => {
350
- childrenToBeMerged.reverse().forEach(([_, childPath]) => {
351
- Transforms.moveNodes(editor, {
352
- at: childPath,
353
- to: [...nodePath, nodeChildren.length]
354
- });
355
- });
356
- Transforms.removeNodes(editor, { at: nodeToBeMergedPath });
357
- });
358
- nodePathRef.unref();
359
- nodeToBeMergedPathRef.unref();
360
- });
361
- return;
362
- }
363
- }
364
- normalizeNode(entry);
365
- };
366
- return editor;
367
- }
368
22
  function clearActiveTypographyStyle(editor, options) {
369
23
  Editor.withoutNormalizing(editor, () => {
370
24
  var _a;
@@ -552,171 +206,5 @@ function withTypography(editor) {
552
206
  };
553
207
  return editor;
554
208
  }
555
- function unhangRange(editor, range) {
556
- let [start, end] = Range.edges(range);
557
- if (start.offset !== 0 || end.offset !== 0 || Range.isCollapsed(range)) {
558
- return range;
559
- }
560
- const endBlock = Editor.above(editor, {
561
- at: end,
562
- match: (n) => Element.isElement(n) && Editor.isBlock(editor, n)
563
- });
564
- const blockPath = endBlock ? endBlock[1] : [];
565
- const first = Editor.start(editor, start);
566
- const before = { anchor: first, focus: end };
567
- let skip = true;
568
- for (const [node, path] of Editor.nodes(editor, {
569
- at: before,
570
- match: Text.isText,
571
- reverse: true
572
- })) {
573
- if (skip) {
574
- skip = false;
575
- continue;
576
- }
577
- if (node.text !== "" || Path.isBefore(path, blockPath)) {
578
- end = { path, offset: node.text.length };
579
- break;
580
- }
581
- }
582
- return { anchor: start, focus: end };
583
- }
584
- function getSelection(editor) {
585
- if (editor.selection)
586
- return unhangRange(editor, editor.selection);
587
- return {
588
- anchor: Editor.start(editor, []),
589
- focus: Editor.end(editor, [])
590
- };
591
- }
592
- function getBlocksInSelection(editor) {
593
- return Array.from(Editor.nodes(editor, {
594
- at: getSelection(editor),
595
- match: (node) => ElementUtils.isRootBlock(node)
596
- })).filter((entry) => ElementUtils.isRootBlock(entry[0]));
597
- }
598
- function getActiveBlockType(editor) {
599
- var _a;
600
- const rootBlocks = getBlocksInSelection(editor).map(([node]) => node.type);
601
- return rootBlocks.reduce((a, b) => a === b ? b : null, (_a = rootBlocks.at(0)) != null ? _a : null);
602
- }
603
- function setBlockKeyForDevice(editor, breakpoints, deviceId, key, value, options) {
604
- var _a, _b;
605
- const at = (_a = options == null ? void 0 : options.at) != null ? _a : editor.selection;
606
- if (!at)
607
- return;
608
- const rootElements = getBlocksInSelection(editor);
609
- for (const [node, path] of rootElements) {
610
- if (ElementUtils.isBlock(node)) {
611
- const deviceValues = (_b = node[key]) != null ? _b : [];
612
- const currentDeviceValue = findBreakpointOverride(breakpoints, deviceValues, deviceId, (v) => v);
613
- const nextDeviceValue = __spreadProps(__spreadValues({}, currentDeviceValue), {
614
- deviceId,
615
- value
616
- });
617
- Transforms.setNodes(editor, {
618
- [key]: [...deviceValues.filter((v) => v.deviceId !== deviceId), nextDeviceValue]
619
- }, { at: path });
620
- }
621
- }
622
- }
623
- function clearBlockKeyForDevice(editor, deviceId, key) {
624
- var _a;
625
- const rootElements = getBlocksInSelection(editor);
626
- for (const [node, path] of rootElements) {
627
- if (ElementUtils.isBlock(node)) {
628
- const deviceOverrides = (_a = node[key]) != null ? _a : [];
629
- Transforms.setNodes(editor, {
630
- [key]: deviceOverrides.filter((v) => v.deviceId !== deviceId)
631
- }, { at: path });
632
- }
633
- }
634
- }
635
- function wrapInline(editor, inline) {
636
- Transforms.wrapNodes(editor, inline, {
637
- at: getSelection(editor),
638
- split: true
639
- });
640
- }
641
- function unwrapInline(editor, type) {
642
- Transforms.unwrapNodes(editor, {
643
- match: (node) => ElementUtils.isInline(node) && node.type === type,
644
- at: getSelection(editor)
645
- });
646
- }
647
- const BlockActions = {
648
- setBlockKeyForDevice,
649
- clearBlockKeyForDevice,
650
- wrapInline,
651
- unwrapInline
652
- };
653
- function withBlock(editor) {
654
- const { normalizeNode } = editor;
655
- editor.isInline = (entry) => {
656
- return ElementUtils.isInline(entry);
657
- };
658
- editor.normalizeNode = (entry) => {
659
- var _a;
660
- const [normalizationNode, normalizationPath] = entry;
661
- if (ElementUtils.isBlock(normalizationNode) && ((_a = normalizationNode == null ? void 0 : normalizationNode.textAlign) == null ? void 0 : _a.length) == 0) {
662
- Transforms.unsetNodes(editor, "textAlign", { at: normalizationPath });
663
- return;
664
- }
665
- normalizeNode(entry);
666
- };
667
- return editor;
668
- }
669
- function BlockPlugin() {
670
- return createRichTextV2Plugin({
671
- withPlugin: withBlock,
672
- control: {
673
- definition: Select({
674
- label: "Block",
675
- options: [
676
- {
677
- value: BlockType.Heading1,
678
- label: "Heading1"
679
- },
680
- {
681
- value: BlockType.Heading2,
682
- label: "Heading2"
683
- },
684
- {
685
- value: BlockType.Heading3,
686
- label: "Heading3"
687
- },
688
- {
689
- value: BlockType.Heading4,
690
- label: "Heading4"
691
- },
692
- {
693
- value: BlockType.Heading5,
694
- label: "Heading5"
695
- },
696
- {
697
- value: BlockType.Heading6,
698
- label: "Heading6"
699
- },
700
- {
701
- value: BlockType.Paragraph,
702
- label: "Paragraph"
703
- }
704
- ],
705
- defaultValue: BlockType.Paragraph
706
- }),
707
- onChange: (editor, value) => {
708
- Transforms.setNodes(editor, {
709
- type: value != null ? value : BlockType.Default
710
- }, { at: getSelection(editor) });
711
- },
712
- getValue: (editor) => {
713
- const activeBlock = getActiveBlockType(editor);
714
- if (activeBlock === RootBlockType.BlockQuote || activeBlock === RootBlockType.OrderedList || activeBlock === RootBlockType.UnorderedList || activeBlock === RootBlockType.Text || activeBlock === RootBlockType.Default)
715
- return void 0;
716
- return activeBlock;
717
- }
718
- }
719
- });
720
- }
721
- export { BlockActions as B, ListActions as L, TypographyActions as T, withTypography as a, withBlock as b, BlockPlugin as c, onKeyDown as o, withList as w };
209
+ export { TypographyActions as T, withTypography as w };
722
210
  //# sourceMappingURL=index.es5.js.map