@makeswift/runtime 0.8.11 → 0.9.0

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 (182) hide show
  1. package/dist/Box.cjs.js +1 -1
  2. package/dist/Box.es.js +1 -1
  3. package/dist/Button.cjs.js +1 -1
  4. package/dist/Button.es.js +1 -1
  5. package/dist/Carousel.cjs.js +2 -2
  6. package/dist/Carousel.es.js +2 -2
  7. package/dist/Countdown.cjs.js +1 -1
  8. package/dist/Countdown.es.js +1 -1
  9. package/dist/Divider.cjs.js +1 -1
  10. package/dist/Divider.es.js +1 -1
  11. package/dist/Embed.cjs.js +1 -1
  12. package/dist/Embed.es.js +1 -1
  13. package/dist/Form.cjs.js +1 -1
  14. package/dist/Form.es.js +1 -1
  15. package/dist/Image.cjs.js +1 -1
  16. package/dist/Image.es.js +1 -1
  17. package/dist/LiveProvider.cjs.js +2 -2
  18. package/dist/LiveProvider.es.js +3 -3
  19. package/dist/Navigation.cjs.js +2 -2
  20. package/dist/Navigation.es.js +2 -2
  21. package/dist/PreviewProvider.cjs.js +17 -2
  22. package/dist/PreviewProvider.cjs.js.map +1 -1
  23. package/dist/PreviewProvider.es.js +19 -4
  24. package/dist/PreviewProvider.es.js.map +1 -1
  25. package/dist/ReadOnlyText.cjs.js +10 -9
  26. package/dist/ReadOnlyText.cjs.js.map +1 -1
  27. package/dist/ReadOnlyText.es.js +10 -9
  28. package/dist/ReadOnlyText.es.js.map +1 -1
  29. package/dist/ReadOnlyTextV2.cjs.js +10 -9
  30. package/dist/ReadOnlyTextV2.cjs.js.map +1 -1
  31. package/dist/ReadOnlyTextV2.es.js +10 -9
  32. package/dist/ReadOnlyTextV2.es.js.map +1 -1
  33. package/dist/Root.cjs.js +1 -1
  34. package/dist/Root.es.js +1 -1
  35. package/dist/SocialLinks.cjs.js +1 -1
  36. package/dist/SocialLinks.es.js +1 -1
  37. package/dist/Text.cjs.js +1 -1
  38. package/dist/Text.es.js +1 -1
  39. package/dist/Video.cjs.js +1 -1
  40. package/dist/Video.es.js +1 -1
  41. package/dist/actions.cjs.js +16 -1
  42. package/dist/actions.cjs.js.map +1 -1
  43. package/dist/actions.es.js +14 -2
  44. package/dist/actions.es.js.map +1 -1
  45. package/dist/components.cjs.js +1 -1
  46. package/dist/components.es.js +1 -1
  47. package/dist/control-serialization.cjs.js +1 -1
  48. package/dist/control-serialization.es.js +2 -2
  49. package/dist/controls.cjs.js +2 -3
  50. package/dist/controls.cjs.js.map +1 -1
  51. package/dist/controls.es.js +1 -2
  52. package/dist/controls.es.js.map +1 -1
  53. package/dist/index.cjs.js +253 -218
  54. package/dist/index.cjs.js.map +1 -1
  55. package/dist/index.cjs10.js +11 -10
  56. package/dist/index.cjs10.js.map +1 -1
  57. package/dist/index.cjs2.js +1 -1
  58. package/dist/index.cjs5.js +0 -522
  59. package/dist/index.cjs5.js.map +1 -1
  60. package/dist/index.cjs6.js +1 -2
  61. package/dist/index.cjs6.js.map +1 -1
  62. package/dist/index.cjs7.js +0 -52
  63. package/dist/index.cjs7.js.map +1 -1
  64. package/dist/index.cjs8.js +1 -1
  65. package/dist/index.cjs9.js +42 -3
  66. package/dist/index.cjs9.js.map +1 -1
  67. package/dist/index.es.js +253 -218
  68. package/dist/index.es.js.map +1 -1
  69. package/dist/index.es10.js +12 -11
  70. package/dist/index.es10.js.map +1 -1
  71. package/dist/index.es2.js +2 -2
  72. package/dist/index.es5.js +2 -514
  73. package/dist/index.es5.js.map +1 -1
  74. package/dist/index.es6.js +1 -2
  75. package/dist/index.es6.js.map +1 -1
  76. package/dist/index.es7.js +2 -53
  77. package/dist/index.es7.js.map +1 -1
  78. package/dist/index.es8.js +1 -1
  79. package/dist/index.es9.js +43 -4
  80. package/dist/index.es9.js.map +1 -1
  81. package/dist/leaf.es.js +1 -1
  82. package/dist/main.cjs.js +3 -0
  83. package/dist/main.cjs.js.map +1 -1
  84. package/dist/main.es.js +2 -2
  85. package/dist/next.cjs.js +1 -1
  86. package/dist/next.es.js +1 -1
  87. package/dist/react-page.cjs.js +711 -61
  88. package/dist/react-page.cjs.js.map +1 -1
  89. package/dist/react-page.es.js +694 -56
  90. package/dist/react-page.es.js.map +1 -1
  91. package/dist/react.cjs.js +1 -1
  92. package/dist/react.es.js +1 -1
  93. package/dist/slate.cjs.js +11 -13
  94. package/dist/slate.cjs.js.map +1 -1
  95. package/dist/slate.es.js +4 -5
  96. package/dist/slate.es.js.map +1 -1
  97. package/dist/types/src/api/graphql/documents/queries.d.ts.map +1 -1
  98. package/dist/types/src/api/graphql/generated/types.d.ts +0 -8
  99. package/dist/types/src/api/graphql/generated/types.d.ts.map +1 -1
  100. package/dist/types/src/components/builtin/Button/Button.d.ts +1 -1
  101. package/dist/types/src/components/builtin/Carousel/register.d.ts.map +1 -1
  102. package/dist/types/src/components/builtin/Countdown/register.d.ts.map +1 -1
  103. package/dist/types/src/components/builtin/Divider/register.d.ts.map +1 -1
  104. package/dist/types/src/components/builtin/Embed/register.d.ts.map +1 -1
  105. package/dist/types/src/components/builtin/Form/components/Field/components/Checkbox/index.d.ts +1 -1
  106. package/dist/types/src/components/builtin/Form/register.d.ts.map +1 -1
  107. package/dist/types/src/components/builtin/Navigation/register.d.ts.map +1 -1
  108. package/dist/types/src/components/builtin/SocialLinks/register.d.ts.map +1 -1
  109. package/dist/types/src/components/builtin/Text/EditableText/editable-text.d.ts.map +1 -1
  110. package/dist/types/src/components/builtin/Text/ReadOnlyText.d.ts.map +1 -1
  111. package/dist/types/src/components/builtin/Text/components/Element/block.d.ts.map +1 -1
  112. package/dist/types/src/components/builtin/Video/register.d.ts.map +1 -1
  113. package/dist/types/src/controls/rich-text-v2/rich-text-v2.d.ts +3 -3
  114. package/dist/types/src/controls/rich-text-v2/rich-text-v2.d.ts.map +1 -1
  115. package/dist/types/src/index.d.ts +2 -1
  116. package/dist/types/src/index.d.ts.map +1 -1
  117. package/dist/types/src/next/api-handler/handlers/manifest.d.ts +3 -1
  118. package/dist/types/src/next/api-handler/handlers/manifest.d.ts.map +1 -1
  119. package/dist/types/src/next/api-handler/handlers/proxy-preview-mode.d.ts.map +1 -1
  120. package/dist/types/src/next/api-handler/index.d.ts +2 -1
  121. package/dist/types/src/next/api-handler/index.d.ts.map +1 -1
  122. package/dist/types/src/next/client.d.ts +7 -7
  123. package/dist/types/src/next/client.d.ts.map +1 -1
  124. package/dist/types/src/next/index.d.ts +8 -5
  125. package/dist/types/src/next/index.d.ts.map +1 -1
  126. package/dist/types/src/next/preview-mode.d.ts +17 -3
  127. package/dist/types/src/next/preview-mode.d.ts.map +1 -1
  128. package/dist/types/src/runtimes/react/controls/rich-text-v2/EditableTextV2/editable-text-v2.d.ts.map +1 -1
  129. package/dist/types/src/runtimes/react/controls/rich-text-v2/ReadOnlyTextV2.d.ts.map +1 -1
  130. package/dist/types/src/runtimes/react/index.d.ts +3 -1
  131. package/dist/types/src/runtimes/react/index.d.ts.map +1 -1
  132. package/dist/types/src/slate/BlockPlugin/constants.d.ts.map +1 -0
  133. package/dist/types/src/slate/BlockPlugin/dedent.d.ts.map +1 -0
  134. package/dist/types/src/slate/BlockPlugin/indent.d.ts.map +1 -0
  135. package/dist/types/src/slate/BlockPlugin/index.d.ts +26 -3
  136. package/dist/types/src/slate/BlockPlugin/index.d.ts.map +1 -1
  137. package/dist/types/src/slate/BlockPlugin/toggleList.d.ts.map +1 -0
  138. package/dist/types/src/slate/BlockPlugin/unwrapList.d.ts.map +1 -0
  139. package/dist/types/src/slate/BlockPlugin/utils/filterForSubtreeRoots.d.ts.map +1 -0
  140. package/dist/types/src/slate/BlockPlugin/utils/getSelectedListItems.d.ts.map +1 -0
  141. package/dist/types/src/slate/BlockPlugin/utils/location.d.ts.map +1 -0
  142. package/dist/types/src/slate/BlockPlugin/wrapList.d.ts.map +1 -0
  143. package/dist/types/src/slate/InlineModePlugin/index.d.ts +1 -1
  144. package/dist/types/src/slate/index.d.ts +0 -1
  145. package/dist/types/src/slate/index.d.ts.map +1 -1
  146. package/dist/types/src/slate/utils/element.d.ts +1 -2
  147. package/dist/types/src/slate/utils/element.d.ts.map +1 -1
  148. package/dist/types/src/state/actions.d.ts +26 -1
  149. package/dist/types/src/state/actions.d.ts.map +1 -1
  150. package/dist/types/src/state/modules/components-meta.d.ts +25 -1
  151. package/dist/types/src/state/modules/components-meta.d.ts.map +1 -1
  152. package/dist/types/src/state/modules/locales.d.ts +16 -0
  153. package/dist/types/src/state/modules/locales.d.ts.map +1 -0
  154. package/dist/types/src/state/react-builder-preview.d.ts +2 -0
  155. package/dist/types/src/state/react-builder-preview.d.ts.map +1 -1
  156. package/dist/types/src/state/react-page.d.ts +5 -1
  157. package/dist/types/src/state/react-page.d.ts.map +1 -1
  158. package/package.json +6 -3
  159. package/dist/select.cjs.js +0 -8
  160. package/dist/select.cjs.js.map +0 -1
  161. package/dist/select.es.js +0 -6
  162. package/dist/select.es.js.map +0 -1
  163. package/dist/types/src/slate/ListPlugin/constants.d.ts.map +0 -1
  164. package/dist/types/src/slate/ListPlugin/dedent.d.ts.map +0 -1
  165. package/dist/types/src/slate/ListPlugin/indent.d.ts.map +0 -1
  166. package/dist/types/src/slate/ListPlugin/index.d.ts +0 -17
  167. package/dist/types/src/slate/ListPlugin/index.d.ts.map +0 -1
  168. package/dist/types/src/slate/ListPlugin/toggleList.d.ts.map +0 -1
  169. package/dist/types/src/slate/ListPlugin/unwrapList.d.ts.map +0 -1
  170. package/dist/types/src/slate/ListPlugin/utils/filterForSubtreeRoots.d.ts.map +0 -1
  171. package/dist/types/src/slate/ListPlugin/utils/getSelectedListItems.d.ts.map +0 -1
  172. package/dist/types/src/slate/ListPlugin/utils/location.d.ts.map +0 -1
  173. package/dist/types/src/slate/ListPlugin/wrapList.d.ts.map +0 -1
  174. /package/dist/types/src/slate/{ListPlugin → BlockPlugin}/constants.d.ts +0 -0
  175. /package/dist/types/src/slate/{ListPlugin → BlockPlugin}/dedent.d.ts +0 -0
  176. /package/dist/types/src/slate/{ListPlugin → BlockPlugin}/indent.d.ts +0 -0
  177. /package/dist/types/src/slate/{ListPlugin → BlockPlugin}/toggleList.d.ts +0 -0
  178. /package/dist/types/src/slate/{ListPlugin → BlockPlugin}/unwrapList.d.ts +0 -0
  179. /package/dist/types/src/slate/{ListPlugin → BlockPlugin}/utils/filterForSubtreeRoots.d.ts +0 -0
  180. /package/dist/types/src/slate/{ListPlugin → BlockPlugin}/utils/getSelectedListItems.d.ts +0 -0
  181. /package/dist/types/src/slate/{ListPlugin → BlockPlugin}/utils/location.d.ts +0 -0
  182. /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