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