slate-vue3 0.8.1 → 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 (118) hide show
  1. package/README.md +1 -1
  2. package/dist/core.js +3 -3
  3. package/dist/{create-editor-BEF9fMF8.js → create-editor-C9yJ-Zny.js} +40 -13
  4. package/dist/dom.js +87 -111
  5. package/dist/history.js +7 -4
  6. package/dist/{hotkeys-B9cuO97x.js → hotkeys-DpQWNvFe.js} +59 -42
  7. package/dist/hyperscript.js +8 -4
  8. package/dist/{index-CCzZ6aOH.js → index-Bj4hXlPm.js} +11 -5
  9. package/dist/index.js +4 -4
  10. package/dist/{location-Be5j1v5S.js → location-Ca0TF-GI.js} +1 -1
  11. package/dist/slate/core/apply.d.ts +1 -1
  12. package/dist/slate/core/get-dirty-paths.d.ts +1 -1
  13. package/dist/slate/core/get-fragment.d.ts +1 -1
  14. package/dist/slate/core/normalize-node.d.ts +1 -1
  15. package/dist/slate/core/should-normalize.d.ts +1 -1
  16. package/dist/slate/editor/above.d.ts +1 -1
  17. package/dist/slate/editor/add-mark.d.ts +1 -1
  18. package/dist/slate/editor/after.d.ts +1 -1
  19. package/dist/slate/editor/before.d.ts +1 -1
  20. package/dist/slate/editor/delete-backward.d.ts +1 -1
  21. package/dist/slate/editor/delete-forward.d.ts +1 -1
  22. package/dist/slate/editor/delete-fragment.d.ts +1 -1
  23. package/dist/slate/editor/edges.d.ts +1 -1
  24. package/dist/slate/editor/element-read-only.d.ts +1 -1
  25. package/dist/slate/editor/end.d.ts +1 -1
  26. package/dist/slate/editor/first.d.ts +1 -1
  27. package/dist/slate/editor/fragment.d.ts +1 -1
  28. package/dist/slate/editor/get-void.d.ts +1 -1
  29. package/dist/slate/editor/has-blocks.d.ts +1 -1
  30. package/dist/slate/editor/has-inlines.d.ts +1 -1
  31. package/dist/slate/editor/has-path.d.ts +1 -1
  32. package/dist/slate/editor/has-texts.d.ts +1 -1
  33. package/dist/slate/editor/insert-break.d.ts +1 -1
  34. package/dist/slate/editor/insert-node.d.ts +1 -1
  35. package/dist/slate/editor/insert-soft-break.d.ts +1 -1
  36. package/dist/slate/editor/insert-text.d.ts +1 -1
  37. package/dist/slate/editor/is-block.d.ts +1 -1
  38. package/dist/slate/editor/is-edge.d.ts +1 -1
  39. package/dist/slate/editor/is-editor.d.ts +1 -1
  40. package/dist/slate/editor/is-empty.d.ts +1 -1
  41. package/dist/slate/editor/is-end.d.ts +1 -1
  42. package/dist/slate/editor/is-normalizing.d.ts +1 -1
  43. package/dist/slate/editor/is-start.d.ts +1 -1
  44. package/dist/slate/editor/last.d.ts +1 -1
  45. package/dist/slate/editor/leaf.d.ts +1 -1
  46. package/dist/slate/editor/marks.d.ts +1 -1
  47. package/dist/slate/editor/next.d.ts +1 -1
  48. package/dist/slate/editor/node.d.ts +1 -1
  49. package/dist/slate/editor/normalize.d.ts +1 -1
  50. package/dist/slate/editor/parent.d.ts +1 -1
  51. package/dist/slate/editor/path-ref.d.ts +1 -1
  52. package/dist/slate/editor/path-refs.d.ts +1 -1
  53. package/dist/slate/editor/path.d.ts +1 -1
  54. package/dist/slate/editor/point-ref.d.ts +1 -1
  55. package/dist/slate/editor/point-refs.d.ts +1 -1
  56. package/dist/slate/editor/point.d.ts +1 -1
  57. package/dist/slate/editor/previous.d.ts +1 -1
  58. package/dist/slate/editor/range-ref.d.ts +1 -1
  59. package/dist/slate/editor/range-refs.d.ts +1 -1
  60. package/dist/slate/editor/range.d.ts +1 -1
  61. package/dist/slate/editor/remove-mark.d.ts +1 -1
  62. package/dist/slate/editor/set-normalizing.d.ts +1 -1
  63. package/dist/slate/editor/should-merge-nodes-remove-prev-node.d.ts +1 -1
  64. package/dist/slate/editor/start.d.ts +1 -1
  65. package/dist/slate/editor/string.d.ts +1 -1
  66. package/dist/slate/editor/unhang-range.d.ts +1 -1
  67. package/dist/slate/editor/without-normalizing.d.ts +1 -1
  68. package/dist/slate/interfaces/editor.d.ts +4 -4
  69. package/dist/slate/interfaces/element.d.ts +1 -1
  70. package/dist/slate/interfaces/node.d.ts +2 -2
  71. package/dist/slate/interfaces/operation.d.ts +21 -21
  72. package/dist/slate/interfaces/path-ref.d.ts +1 -1
  73. package/dist/slate/interfaces/point.d.ts +2 -2
  74. package/dist/slate/interfaces/range-ref.d.ts +1 -1
  75. package/dist/slate/interfaces/range.d.ts +1 -1
  76. package/dist/slate/interfaces/text.d.ts +1 -1
  77. package/dist/slate/transforms-node/insert-nodes.d.ts +1 -1
  78. package/dist/slate/transforms-node/lift-nodes.d.ts +1 -1
  79. package/dist/slate/transforms-node/merge-nodes.d.ts +1 -1
  80. package/dist/slate/transforms-node/move-nodes.d.ts +1 -1
  81. package/dist/slate/transforms-node/remove-nodes.d.ts +1 -1
  82. package/dist/slate/transforms-node/set-nodes.d.ts +1 -1
  83. package/dist/slate/transforms-node/split-nodes.d.ts +1 -1
  84. package/dist/slate/transforms-node/unset-nodes.d.ts +1 -1
  85. package/dist/slate/transforms-node/unwrap-nodes.d.ts +1 -1
  86. package/dist/slate/transforms-node/wrap-nodes.d.ts +1 -1
  87. package/dist/slate/transforms-selection/collapse.d.ts +1 -1
  88. package/dist/slate/transforms-selection/deselect.d.ts +1 -1
  89. package/dist/slate/transforms-selection/move.d.ts +1 -1
  90. package/dist/slate/transforms-selection/select.d.ts +1 -1
  91. package/dist/slate/transforms-selection/set-point.d.ts +1 -1
  92. package/dist/slate/transforms-selection/set-selection.d.ts +1 -1
  93. package/dist/slate/transforms-text/delete-text.d.ts +1 -1
  94. package/dist/slate/transforms-text/insert-fragment.d.ts +1 -1
  95. package/dist/slate/types/custom-types.d.ts +1 -1
  96. package/dist/slate/types/types.d.ts +10 -10
  97. package/dist/slate/utils/types.d.ts +1 -1
  98. package/dist/slate-dom/chunking/children-helper.d.ts +1 -1
  99. package/dist/slate-dom/chunking/get-chunk-tree-for-node.d.ts +1 -4
  100. package/dist/slate-dom/chunking/reconcile-children.d.ts +1 -3
  101. package/dist/slate-dom/chunking/types.d.ts +3 -3
  102. package/dist/slate-dom/index.d.ts +1 -1
  103. package/dist/slate-dom/utils/dom.d.ts +3 -3
  104. package/dist/slate-hyperscript/hyperscript.d.ts +1 -1
  105. package/dist/slate-hyperscript/index.d.ts +1 -1
  106. package/dist/slate-vue/hooks/use-editor.d.ts +2 -7
  107. package/dist/slate-vue/hooks/use-render.d.ts +2 -2
  108. package/dist/slate-vue/index.d.ts +1 -1
  109. package/dist/slate-vue/utils/interface.d.ts +2 -2
  110. package/dist/slate-yjs/hooks/useRemoteCursorOverlayPositions.d.ts +1 -1
  111. package/dist/slate-yjs/hooks/utils.d.ts +1 -1
  112. package/dist/slate-yjs/index.d.ts +3 -3
  113. package/dist/slate-yjs/utils/position.d.ts +1 -1
  114. package/dist/slate-yjs/utils/slate.d.ts +1 -1
  115. package/dist/slate-yjs/utils/yjs.d.ts +1 -1
  116. package/dist/{use-focused-Dy4w0CWr.js → use-focused-MykI6tSp.js} +63 -39
  117. package/dist/yjs.js +15 -14
  118. package/package.json +31 -11
package/README.md CHANGED
@@ -53,7 +53,7 @@ editor.children = initialValue;
53
53
  </script>
54
54
 
55
55
  <template>
56
- <Slate :editor="editor">
56
+ <Slate :editor>
57
57
  <Editable />
58
58
  </Slate>
59
59
  </template>
package/dist/core.js CHANGED
@@ -1,6 +1,6 @@
1
- import { a6, a7, a8, d, e, f, a, h, aj, c, i, j, k, ap, ak, l, m, o, p, q, g, b, r, t, u, v, w, x, aq, y, a9, z, A, B, C, D, E, F, G, H, I, J, aa, K, ab, al, ac, L, M, N, O, n, P, S, Q, R, V, T, U, W, X, _, Y, Z, $, ad, am, ae, a0, an, ao, a5, s, af, a1, a2, a3, ag, ah, a4, ai } from "./create-editor-BEF9fMF8.js";
2
- import { E as E2, a as a10, I as I2, N as N2, O as O2, P as P2, b as b2, R as R2, S as S2, T as T2, c as c2, i as i2, d as d2 } from "./index-CCzZ6aOH.js";
3
- import { L as L2, S as S3 } from "./location-Be5j1v5S.js";
1
+ import { a6, a7, a8, d, e, f, a, h, aj, c, i, j, k, ap, ak, l, m, o, p, q, g, b, r, t, u, v, w, x, aq, y, a9, z, A, B, C, D, E, F, G, H, I, J, aa, K, ab, al, ac, L, M, N, O, n, P, S, Q, R, V, T, U, W, X, _, Y, Z, $, ad, am, ae, a0, an, ao, a5, s, af, a1, a2, a3, ag, ah, a4, ai } from "./create-editor-C9yJ-Zny.js";
2
+ import { E as E2, a as a10, I as I2, N as N2, O as O2, P as P2, b as b2, R as R2, S as S2, T as T2, c as c2, i as i2, d as d2 } from "./index-Bj4hXlPm.js";
3
+ import { L as L2, S as S3 } from "./location-Ca0TF-GI.js";
4
4
  export {
5
5
  E2 as Editor,
6
6
  a10 as Element,
@@ -1,6 +1,6 @@
1
- import { P as Path, b as Point, R as Range, E as Editor, c as Transforms, T as Text, N as Node, a as Element, e as cloneDeep, g as getDefaultInsertLocation, S as Scrubber, I as IS_EDITOR_SET } from "./index-CCzZ6aOH.js";
2
- import { reactive } from "vue";
3
- import { S as Span } from "./location-Be5j1v5S.js";
1
+ import { P as Path, b as Point, R as Range, E as Editor, c as Transforms, T as Text, N as Node, a as Element, e as cloneDeep, g as getDefaultInsertLocation, S as Scrubber, I as IS_EDITOR_SET } from "./index-Bj4hXlPm.js";
2
+ import { shallowReactive, reactive } from "vue";
3
+ import { S as Span } from "./location-Ca0TF-GI.js";
4
4
  const PathRef = {
5
5
  transform(ref, op) {
6
6
  const { current, affinity } = ref;
@@ -180,7 +180,10 @@ const isLowSurrogate = (charCode) => {
180
180
  };
181
181
  const reExtend = /^[\p{Gr_Ext}\p{EMod}]$/u;
182
182
  const rePrepend = /^[\u0600-\u0605\u06DD\u070F\u0890-\u0891\u08E2\u0D4E\u{110BD}\u{110CD}\u{111C2}-\u{111C3}\u{1193F}\u{11941}\u{11A3A}\u{11A84}-\u{11A89}\u{11D46}]$/u;
183
- const reSpacingMark = /^[\u0903\u093B\u093E-\u0940\u0949-\u094C\u094E-\u094F\u0982-\u0983\u09BF-\u09C0\u09C7-\u09C8\u09CB-\u09CC\u0A03\u0A3E-\u0A40\u0A83\u0ABE-\u0AC0\u0AC9\u0ACB-\u0ACC\u0B02-\u0B03\u0B40\u0B47-\u0B48\u0B4B-\u0B4C\u0BBF\u0BC1-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCC\u0C01-\u0C03\u0C41-\u0C44\u0C82-\u0C83\u0CBE\u0CC0-\u0CC1\u0CC3-\u0CC4\u0CC7-\u0CC8\u0CCA-\u0CCB\u0D02-\u0D03\u0D3F-\u0D40\u0D46-\u0D48\u0D4A-\u0D4C\u0D82-\u0D83\u0DD0-\u0DD1\u0DD8-\u0DDE\u0DF2-\u0DF3\u0E33\u0EB3\u0F3E-\u0F3F\u0F7F\u1031\u103B-\u103C\u1056-\u1057\u1084\u1715\u1734\u17B6\u17BE-\u17C5\u17C7-\u17C8\u1923-\u1926\u1929-\u192B\u1930-\u1931\u1933-\u1938\u1A19-\u1A1A\u1A55\u1A57\u1A6D-\u1A72\u1B04\u1B3B\u1B3D-\u1B41\u1B43-\u1B44\u1B82\u1BA1\u1BA6-\u1BA7\u1BAA\u1BE7\u1BEA-\u1BEC\u1BEE\u1BF2-\u1BF3\u1C24-\u1C2B\u1C34-\u1C35\u1CE1\u1CF7\uA823-\uA824\uA827\uA880-\uA881\uA8B4-\uA8C3\uA952-\uA953\uA983\uA9B4-\uA9B5\uA9BA-\uA9BB\uA9BE-\uA9C0\uAA2F-\uAA30\uAA33-\uAA34\uAA4D\uAAEB\uAAEE-\uAAEF\uAAF5\uABE3-\uABE4\uABE6-\uABE7\uABE9-\uABEA\uABEC\u{11000}\u{11002}\u{11082}\u{110B0}-\u{110B2}\u{110B7}-\u{110B8}\u{1112C}\u{11145}-\u{11146}\u{11182}\u{111B3}-\u{111B5}\u{111BF}-\u{111C0}\u{111CE}\u{1122C}-\u{1122E}\u{11232}-\u{11233}\u{11235}\u{112E0}-\u{112E2}\u{11302}-\u{11303}\u{1133F}\u{11341}-\u{11344}\u{11347}-\u{11348}\u{1134B}-\u{1134D}\u{11362}-\u{11363}\u{11435}-\u{11437}\u{11440}-\u{11441}\u{11445}\u{114B1}-\u{114B2}\u{114B9}\u{114BB}-\u{114BC}\u{114BE}\u{114C1}\u{115B0}-\u{115B1}\u{115B8}-\u{115BB}\u{115BE}\u{11630}-\u{11632}\u{1163B}-\u{1163C}\u{1163E}\u{116AC}\u{116AE}-\u{116AF}\u{116B6}\u{11726}\u{1182C}-\u{1182E}\u{11838}\u{11931}-\u{11935}\u{11937}-\u{11938}\u{1193D}\u{11940}\u{11942}\u{119D1}-\u{119D3}\u{119DC}-\u{119DF}\u{119E4}\u{11A39}\u{11A57}-\u{11A58}\u{11A97}\u{11C2F}\u{11C3E}\u{11CA9}\u{11CB1}\u{11CB4}\u{11D8A}-\u{11D8E}\u{11D93}-\u{11D94}\u{11D96}\u{11EF5}-\u{11EF6}\u{16F51}-\u{16F87}\u{16FF0}-\u{16FF1}\u{1D166}\u{1D16D}]$/u;
183
+ const reSpacingMark = (
184
+ // eslint-disable-next-line no-misleading-character-class
185
+ /^[\u0903\u093B\u093E-\u0940\u0949-\u094C\u094E-\u094F\u0982-\u0983\u09BF-\u09C0\u09C7-\u09C8\u09CB-\u09CC\u0A03\u0A3E-\u0A40\u0A83\u0ABE-\u0AC0\u0AC9\u0ACB-\u0ACC\u0B02-\u0B03\u0B40\u0B47-\u0B48\u0B4B-\u0B4C\u0BBF\u0BC1-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCC\u0C01-\u0C03\u0C41-\u0C44\u0C82-\u0C83\u0CBE\u0CC0-\u0CC1\u0CC3-\u0CC4\u0CC7-\u0CC8\u0CCA-\u0CCB\u0D02-\u0D03\u0D3F-\u0D40\u0D46-\u0D48\u0D4A-\u0D4C\u0D82-\u0D83\u0DD0-\u0DD1\u0DD8-\u0DDE\u0DF2-\u0DF3\u0E33\u0EB3\u0F3E-\u0F3F\u0F7F\u1031\u103B-\u103C\u1056-\u1057\u1084\u1715\u1734\u17B6\u17BE-\u17C5\u17C7-\u17C8\u1923-\u1926\u1929-\u192B\u1930-\u1931\u1933-\u1938\u1A19-\u1A1A\u1A55\u1A57\u1A6D-\u1A72\u1B04\u1B3B\u1B3D-\u1B41\u1B43-\u1B44\u1B82\u1BA1\u1BA6-\u1BA7\u1BAA\u1BE7\u1BEA-\u1BEC\u1BEE\u1BF2-\u1BF3\u1C24-\u1C2B\u1C34-\u1C35\u1CE1\u1CF7\uA823-\uA824\uA827\uA880-\uA881\uA8B4-\uA8C3\uA952-\uA953\uA983\uA9B4-\uA9B5\uA9BA-\uA9BB\uA9BE-\uA9C0\uAA2F-\uAA30\uAA33-\uAA34\uAA4D\uAAEB\uAAEE-\uAAEF\uAAF5\uABE3-\uABE4\uABE6-\uABE7\uABE9-\uABEA\uABEC\u{11000}\u{11002}\u{11082}\u{110B0}-\u{110B2}\u{110B7}-\u{110B8}\u{1112C}\u{11145}-\u{11146}\u{11182}\u{111B3}-\u{111B5}\u{111BF}-\u{111C0}\u{111CE}\u{1122C}-\u{1122E}\u{11232}-\u{11233}\u{11235}\u{112E0}-\u{112E2}\u{11302}-\u{11303}\u{1133F}\u{11341}-\u{11344}\u{11347}-\u{11348}\u{1134B}-\u{1134D}\u{11362}-\u{11363}\u{11435}-\u{11437}\u{11440}-\u{11441}\u{11445}\u{114B1}-\u{114B2}\u{114B9}\u{114BB}-\u{114BC}\u{114BE}\u{114C1}\u{115B0}-\u{115B1}\u{115B8}-\u{115BB}\u{115BE}\u{11630}-\u{11632}\u{1163B}-\u{1163C}\u{1163E}\u{116AC}\u{116AE}-\u{116AF}\u{116B6}\u{11726}\u{1182C}-\u{1182E}\u{11838}\u{11931}-\u{11935}\u{11937}-\u{11938}\u{1193D}\u{11940}\u{11942}\u{119D1}-\u{119D3}\u{119DC}-\u{119DF}\u{119E4}\u{11A39}\u{11A57}-\u{11A58}\u{11A97}\u{11C2F}\u{11C3E}\u{11CA9}\u{11CB1}\u{11CB4}\u{11D8A}-\u{11D8E}\u{11D93}-\u{11D94}\u{11D96}\u{11EF5}-\u{11EF6}\u{16F51}-\u{16F87}\u{16FF0}-\u{16FF1}\u{1D166}\u{1D16D}]$/u
186
+ );
184
187
  const reL = /^[\u1100-\u115F\uA960-\uA97C]$/u;
185
188
  const reV = /^[\u1160-\u11A7\uD7B0-\uD7C6]$/u;
186
189
  const reT = /^[\u11A8-\u11FF\uD7CB-\uD7FB]$/u;
@@ -838,7 +841,8 @@ const marks = (editor, options = {}) => {
838
841
  };
839
842
  const next = (editor, options = {}) => {
840
843
  const { mode = "lowest", voids = false } = options;
841
- let { match, at = editor.selection } = options;
844
+ const { at = editor.selection } = options;
845
+ let { match } = options;
842
846
  if (!at) {
843
847
  return;
844
848
  }
@@ -1134,7 +1138,9 @@ function* positions(editor, options = {}) {
1134
1138
  reverse,
1135
1139
  voids
1136
1140
  })) {
1137
- const hasSkippedAncestor = skippedPaths.some((p) => Path.isAncestor(p, path2));
1141
+ const hasSkippedAncestor = skippedPaths.some(
1142
+ (p) => Path.isAncestor(p, path2)
1143
+ );
1138
1144
  function* maybeYield(point2) {
1139
1145
  if (!hasSkippedAncestor) {
1140
1146
  yield point2;
@@ -1211,7 +1217,8 @@ function* positions(editor, options = {}) {
1211
1217
  }
1212
1218
  const previous = (editor, options = {}) => {
1213
1219
  const { mode = "lowest", voids = false } = options;
1214
- let { match, at = editor.selection } = options;
1220
+ let { match } = options;
1221
+ const { at = editor.selection } = options;
1215
1222
  if (!at) {
1216
1223
  return;
1217
1224
  }
@@ -1338,7 +1345,9 @@ const string = (editor, at, options = {}) => {
1338
1345
  };
1339
1346
  const unhangRange = (editor, range2, options = {}) => {
1340
1347
  const { voids = false } = options;
1341
- let [start2, end2] = Range.edges(range2);
1348
+ const edges2 = Range.edges(range2);
1349
+ const [start2] = edges2;
1350
+ let [, end2] = edges2;
1342
1351
  if (start2.offset !== 0 || end2.offset !== 0 || Range.isCollapsed(range2) || Path.hasPrevious(end2.path)) {
1343
1352
  return range2;
1344
1353
  }
@@ -1498,6 +1507,7 @@ const deleteText = (editor, options = {}) => {
1498
1507
  });
1499
1508
  }
1500
1509
  if (isCollapsed && reverse && unit === "character" && removedText.length > 1 && removedText.match(
1510
+ // eslint-disable-next-line no-misleading-character-class
1501
1511
  /[\u0980-\u09FF\u0E00-\u0E7F\u1000-\u109F\u0900-\u097F\u1780-\u17FF\u0D00-\u0D7F\u0B00-\u0B7F\u0A00-\u0A7F\u0B80-\u0BFF\u0C00-\u0C7F]+/
1502
1512
  )) {
1503
1513
  Transforms.insertText(
@@ -1516,7 +1526,8 @@ const deleteText = (editor, options = {}) => {
1516
1526
  const insertFragment = (editor, fragment2, options = {}) => {
1517
1527
  Editor.withoutNormalizing(editor, () => {
1518
1528
  const { hanging = false, voids = false } = options;
1519
- let { at = getDefaultInsertLocation(editor), batchDirty = true } = options;
1529
+ let { at = getDefaultInsertLocation(editor) } = options;
1530
+ const { batchDirty = true } = options;
1520
1531
  if (!fragment2.length) {
1521
1532
  return;
1522
1533
  }
@@ -2126,7 +2137,8 @@ const removeNodes = (editor, options = {}) => {
2126
2137
  };
2127
2138
  const setNodes = (editor, props, options = {}) => {
2128
2139
  Editor.withoutNormalizing(editor, () => {
2129
- let { match, at = cloneDeep(editor.selection), compare, merge } = options;
2140
+ let { match, at = cloneDeep(editor.selection), compare } = options;
2141
+ const { merge } = options;
2130
2142
  const {
2131
2143
  hanging = false,
2132
2144
  mode = "lowest",
@@ -2191,7 +2203,7 @@ const setNodes = (editor, props, options = {}) => {
2191
2203
  }
2192
2204
  if (compare(props[k], node2[k])) {
2193
2205
  hasChanges = true;
2194
- if (node2.hasOwnProperty(k))
2206
+ if (Object.prototype.hasOwnProperty.call(node2, k))
2195
2207
  properties[k] = node2[k];
2196
2208
  if (merge) {
2197
2209
  if (props[k] != null)
@@ -2229,7 +2241,12 @@ const deleteRange = (editor, range2) => {
2229
2241
  const splitNodes = (editor, options = {}) => {
2230
2242
  Editor.withoutNormalizing(editor, () => {
2231
2243
  const { mode = "lowest", voids = false } = options;
2232
- let { match, at = cloneDeep(editor.selection), height = 0, always = false } = options;
2244
+ let {
2245
+ match,
2246
+ at = cloneDeep(editor.selection),
2247
+ height = 0,
2248
+ always = false
2249
+ } = options;
2233
2250
  if (match == null) {
2234
2251
  match = (n) => Element.isElement(n) && Editor.isBlock(editor, n);
2235
2252
  }
@@ -2452,7 +2469,7 @@ const wrapNodes = (editor, element, options = {}) => {
2452
2469
  });
2453
2470
  };
2454
2471
  const createEditor = () => {
2455
- const editor = reactive({
2472
+ const editor = shallowReactive({
2456
2473
  children: [],
2457
2474
  operations: [],
2458
2475
  selection: null,
@@ -2545,6 +2562,16 @@ const createEditor = () => {
2545
2562
  wrapNodes: (...args) => wrapNodes(editor, ...args),
2546
2563
  shouldMergeNodesRemovePrevNode: (...args) => shouldMergeNodesRemovePrevNode(editor, ...args)
2547
2564
  });
2565
+ const _children = reactive([]);
2566
+ Object.defineProperty(editor, "children", {
2567
+ get() {
2568
+ return _children;
2569
+ },
2570
+ set(value) {
2571
+ _children.length = 0;
2572
+ _children.push(...value);
2573
+ }
2574
+ });
2548
2575
  IS_EDITOR_SET.add(editor);
2549
2576
  return editor;
2550
2577
  };
package/dist/dom.js CHANGED
@@ -1,7 +1,7 @@
1
- import { D as DOMEditor, r as reconcileChildren, E as EDITOR_TO_KEY_TO_ELEMENT, a as EDITOR_TO_USER_MARKS, b as EDITOR_TO_USER_SELECTION, N as NODE_TO_KEY, i as isDOMText, g as getPlainText, c as getSlateFragmentAttribute, d as EDITOR_TO_ON_CHANGE } from "./hotkeys-B9cuO97x.js";
2
- import { C, G, J, L, H, F, I, v, M, w, x, O, y, P, A, z, B, K, Q, R, S, T, e, f, h, j, k, l, m, o, p, q, s, t, u, n } from "./hotkeys-B9cuO97x.js";
3
- import { E as Editor, R as Range, a as Element, c as Transforms, N as Node, P as Path } from "./index-CCzZ6aOH.js";
4
- import { reactive } from "vue";
1
+ import { D as DOMEditor, E as EDITOR_TO_KEY_TO_ELEMENT, a as EDITOR_TO_USER_MARKS, g as getChunkTreeForNode, b as EDITOR_TO_USER_SELECTION, N as NODE_TO_KEY, i as isDOMText, c as getPlainText, d as getSlateFragmentAttribute, e as EDITOR_TO_ON_CHANGE } from "./hotkeys-DpQWNvFe.js";
2
+ import { C, L, M, O, H, F, I, v, P, w, x, Q, y, R, A, z, B, J, K, S, T, U, V, f, h, j, k, l, m, o, p, q, r, s, t, u, n, G } from "./hotkeys-DpQWNvFe.js";
3
+ import { E as Editor, R as Range, a as Element, c as Transforms, N as Node, P as Path } from "./index-Bj4hXlPm.js";
4
+ import "vue";
5
5
  const doRectsIntersect = (rect, compareRect) => {
6
6
  const middle = (compareRect.top + compareRect.bottom) / 2;
7
7
  return rect.top <= middle && rect.bottom >= middle;
@@ -45,70 +45,49 @@ const findCurrentLineRange = (editor, parentRange) => {
45
45
  }
46
46
  return Editor.range(editor, positions[left], parentRangeBoundary);
47
47
  };
48
- const KEY_TO_CHUNK_TREE = /* @__PURE__ */ new WeakMap();
49
- const getChunkTreeForNode = (editor, node, options = {}) => {
50
- const key = DOMEditor.findKey(editor, node);
51
- let chunkTree = KEY_TO_CHUNK_TREE.get(key);
52
- if (!chunkTree) {
53
- chunkTree = {
54
- type: "root",
55
- movedNodeKeys: /* @__PURE__ */ new Set(),
56
- children: reactive([])
57
- };
58
- KEY_TO_CHUNK_TREE.set(key, chunkTree);
59
- }
60
- if (options.reconcile) {
61
- reconcileChildren(editor, {
62
- chunkTree,
63
- children: node.children,
64
- ...options.reconcile
65
- });
66
- }
67
- return chunkTree;
68
- };
69
48
  const withDOM = (editor, clipboardFormatKey = "x-slate-fragment") => {
70
- const e2 = editor;
71
- const { apply, onChange, deleteBackward, addMark, removeMark } = e2;
72
- EDITOR_TO_KEY_TO_ELEMENT.set(e2, /* @__PURE__ */ new WeakMap());
73
- e2.addMark = (key, value) => {
74
- EDITOR_TO_USER_MARKS.delete(e2);
49
+ const e = editor;
50
+ const { apply, onChange, deleteBackward, addMark, removeMark } = e;
51
+ EDITOR_TO_KEY_TO_ELEMENT.set(e, /* @__PURE__ */ new WeakMap());
52
+ e.addMark = (key, value) => {
53
+ EDITOR_TO_USER_MARKS.delete(e);
75
54
  addMark(key, value);
76
55
  };
77
- e2.removeMark = (key) => {
78
- EDITOR_TO_USER_MARKS.delete(e2);
56
+ e.removeMark = (key) => {
57
+ EDITOR_TO_USER_MARKS.delete(e);
79
58
  removeMark(key);
80
59
  };
81
- e2.deleteBackward = (unit) => {
60
+ e.deleteBackward = (unit) => {
82
61
  if (unit !== "line") {
83
62
  return deleteBackward(unit);
84
63
  }
85
- if (e2.selection && Range.isCollapsed(e2.selection)) {
86
- const parentBlockEntry = Editor.above(e2, {
87
- match: (n2) => Element.isElement(n2) && Editor.isBlock(e2, n2),
88
- at: e2.selection
64
+ if (e.selection && Range.isCollapsed(e.selection)) {
65
+ const parentBlockEntry = Editor.above(e, {
66
+ match: (n2) => Element.isElement(n2) && Editor.isBlock(e, n2),
67
+ at: e.selection
89
68
  });
90
69
  if (parentBlockEntry) {
91
70
  const [, parentBlockPath] = parentBlockEntry;
92
71
  const parentElementRange = Editor.range(
93
- e2,
72
+ e,
94
73
  parentBlockPath,
95
- e2.selection.anchor
74
+ e.selection.anchor
96
75
  );
97
- const currentLineRange = findCurrentLineRange(e2, parentElementRange);
76
+ const currentLineRange = findCurrentLineRange(e, parentElementRange);
98
77
  if (!Range.isCollapsed(currentLineRange)) {
99
- Transforms.delete(e2, { at: currentLineRange });
78
+ Transforms.delete(e, { at: currentLineRange });
100
79
  }
101
80
  }
102
81
  }
103
82
  };
104
- e2.apply = (op) => {
83
+ e.apply = (op) => {
105
84
  if (op.type === "move_node") {
106
- const parent = Node.parent(e2, op.path);
107
- const chunking = !!e2.getChunkSize(parent);
85
+ const parent = Node.parent(e, op.path);
86
+ const chunking = !!e.getChunkSize(parent);
108
87
  if (chunking) {
109
- const node = Node.get(e2, op.path);
110
- const chunkTree = getChunkTreeForNode(e2, parent);
111
- const key = DOMEditor.findKey(e2, node);
88
+ const node = Node.get(e, op.path);
89
+ const chunkTree = getChunkTreeForNode(e, parent);
90
+ const key = DOMEditor.findKey(e, node);
112
91
  chunkTree.movedNodeKeys.add(key);
113
92
  }
114
93
  }
@@ -119,22 +98,22 @@ const withDOM = (editor, clipboardFormatKey = "x-slate-fragment") => {
119
98
  case "remove_text":
120
99
  case "set_node":
121
100
  case "split_node": {
122
- matches.push(...getMatches(e2, op.path));
101
+ matches.push(...getMatches(e, op.path));
123
102
  break;
124
103
  }
125
104
  case "set_selection": {
126
- EDITOR_TO_USER_SELECTION.get(e2)?.unref();
127
- EDITOR_TO_USER_SELECTION.delete(e2);
105
+ EDITOR_TO_USER_SELECTION.get(e)?.unref();
106
+ EDITOR_TO_USER_SELECTION.delete(e);
128
107
  break;
129
108
  }
130
109
  case "insert_node":
131
110
  case "remove_node": {
132
- matches.push(...getMatches(e2, Path.parent(op.path)));
111
+ matches.push(...getMatches(e, Path.parent(op.path)));
133
112
  break;
134
113
  }
135
114
  case "merge_node": {
136
115
  const prevPath = Path.previous(op.path);
137
- matches.push(...getMatches(e2, prevPath));
116
+ matches.push(...getMatches(e, prevPath));
138
117
  break;
139
118
  }
140
119
  case "move_node": {
@@ -142,47 +121,47 @@ const withDOM = (editor, clipboardFormatKey = "x-slate-fragment") => {
142
121
  Path.parent(op.path),
143
122
  Path.parent(op.newPath)
144
123
  );
145
- matches.push(...getMatches(e2, commonPath));
124
+ matches.push(...getMatches(e, commonPath));
146
125
  let changedPath;
147
126
  if (Path.isBefore(op.path, op.newPath)) {
148
- matches.push(...getMatches(e2, Path.parent(op.path)));
127
+ matches.push(...getMatches(e, Path.parent(op.path)));
149
128
  changedPath = op.newPath;
150
129
  } else {
151
- matches.push(...getMatches(e2, Path.parent(op.newPath)));
130
+ matches.push(...getMatches(e, Path.parent(op.newPath)));
152
131
  changedPath = op.path;
153
132
  }
154
133
  const changedNode = Node.get(editor, Path.parent(changedPath));
155
- const changedNodeKey = DOMEditor.findKey(e2, changedNode);
156
- const changedPathRef = Editor.pathRef(e2, Path.parent(changedPath));
134
+ const changedNodeKey = DOMEditor.findKey(e, changedNode);
135
+ const changedPathRef = Editor.pathRef(e, Path.parent(changedPath));
157
136
  pathRefMatches.push([changedPathRef, changedNodeKey]);
158
137
  break;
159
138
  }
160
139
  }
161
140
  apply(op);
162
141
  for (const [path, key] of matches) {
163
- const [node] = Editor.node(e2, path);
142
+ const [node] = Editor.node(e, path);
164
143
  NODE_TO_KEY.set(node, key);
165
144
  }
166
145
  for (const [pathRef, key] of pathRefMatches) {
167
146
  if (pathRef.current) {
168
- const [node] = Editor.node(e2, pathRef.current);
147
+ const [node] = Editor.node(e, pathRef.current);
169
148
  NODE_TO_KEY.set(node, key);
170
149
  }
171
150
  pathRef.unref();
172
151
  }
173
152
  };
174
- e2.setFragmentData = (data) => {
175
- const { selection } = e2;
153
+ e.setFragmentData = (data) => {
154
+ const { selection } = e;
176
155
  if (!selection) {
177
156
  return;
178
157
  }
179
158
  const [start, end] = Range.edges(selection);
180
- const startVoid = Editor.void(e2, { at: start.path });
181
- const endVoid = Editor.void(e2, { at: end.path });
159
+ const startVoid = Editor.void(e, { at: start.path });
160
+ const endVoid = Editor.void(e, { at: end.path });
182
161
  if (Range.isCollapsed(selection) && !startVoid) {
183
162
  return;
184
163
  }
185
- const domRange = DOMEditor.toDOMRange(e2, selection);
164
+ const domRange = DOMEditor.toDOMRange(e, selection);
186
165
  let contents = domRange.cloneContents();
187
166
  let attach = contents.childNodes[0];
188
167
  contents.childNodes.forEach((node) => {
@@ -192,10 +171,10 @@ const withDOM = (editor, clipboardFormatKey = "x-slate-fragment") => {
192
171
  });
193
172
  if (endVoid) {
194
173
  const [voidNode] = endVoid;
195
- const r = domRange.cloneRange();
196
- const domNode = DOMEditor.toDOMNode(e2, voidNode);
197
- r.setEndAfter(domNode);
198
- contents = r.cloneContents();
174
+ const r2 = domRange.cloneRange();
175
+ const domNode = DOMEditor.toDOMNode(e, voidNode);
176
+ r2.setEndAfter(domNode);
177
+ contents = r2.cloneContents();
199
178
  }
200
179
  if (startVoid) {
201
180
  attach = contents.querySelector("[data-slate-spacer]");
@@ -213,7 +192,7 @@ const withDOM = (editor, clipboardFormatKey = "x-slate-fragment") => {
213
192
  contents.appendChild(span);
214
193
  attach = span;
215
194
  }
216
- const fragment = e2.getFragment();
195
+ const fragment = e.getFragment();
217
196
  const string = JSON.stringify(fragment);
218
197
  const encoded = window.btoa(encodeURIComponent(string));
219
198
  attach.setAttribute("data-slate-fragment", encoded);
@@ -227,65 +206,62 @@ const withDOM = (editor, clipboardFormatKey = "x-slate-fragment") => {
227
206
  contents.ownerDocument.body.removeChild(div);
228
207
  return data;
229
208
  };
230
- e2.insertData = (data) => {
231
- if (!e2.insertFragmentData(data)) {
232
- e2.insertTextData(data);
209
+ e.insertData = (data) => {
210
+ if (!e.insertFragmentData(data)) {
211
+ e.insertTextData(data);
233
212
  }
234
213
  };
235
- e2.insertFragmentData = (data) => {
214
+ e.insertFragmentData = (data) => {
236
215
  const fragment = data.getData(`application/${clipboardFormatKey}`) || getSlateFragmentAttribute(data);
237
216
  if (fragment) {
238
217
  const decoded = decodeURIComponent(window.atob(fragment));
239
218
  const parsed = JSON.parse(decoded);
240
- e2.insertFragment(parsed);
219
+ e.insertFragment(parsed);
241
220
  return true;
242
221
  }
243
222
  return false;
244
223
  };
245
- e2.insertTextData = (data) => {
224
+ e.insertTextData = (data) => {
246
225
  const text = data.getData("text/plain");
247
226
  if (text) {
248
227
  const lines = text.split(/\r\n|\r|\n/);
249
228
  let split = false;
250
229
  for (const line of lines) {
251
230
  if (split) {
252
- Transforms.splitNodes(e2, { always: true });
231
+ Transforms.splitNodes(e, { always: true });
253
232
  }
254
- e2.insertText(line);
233
+ e.insertText(line);
255
234
  split = true;
256
235
  }
257
236
  return true;
258
237
  }
259
238
  return false;
260
239
  };
261
- e2.getChunkSize = () => null;
262
- e2.onChange = (options) => {
263
- const onContextChange = EDITOR_TO_ON_CHANGE.get(e2);
240
+ e.getChunkSize = () => null;
241
+ e.onChange = (options) => {
242
+ const onContextChange = EDITOR_TO_ON_CHANGE.get(e);
264
243
  if (onContextChange) {
265
244
  onContextChange(options);
266
245
  }
267
246
  onChange(options);
268
247
  };
269
- return e2;
248
+ return e;
270
249
  };
271
- const getMatches = (e2, path) => {
250
+ const getMatches = (e, path) => {
272
251
  const matches = [];
273
- for (const [n2, p2] of Editor.levels(e2, { at: path })) {
274
- const key = DOMEditor.findKey(e2, n2);
252
+ for (const [n2, p2] of Editor.levels(e, { at: path })) {
253
+ const key = DOMEditor.findKey(e, n2);
275
254
  matches.push([p2, key]);
276
255
  }
277
256
  return matches;
278
257
  };
279
258
  const shallowCompare = (obj1, obj2) => Object.keys(obj1).length === Object.keys(obj2).length && Object.keys(obj1).every(
280
- (key) => obj2.hasOwnProperty(key) && obj1[key] === obj2[key]
259
+ (key) => Object.prototype.hasOwnProperty.call(obj2, key) && obj1[key] === obj2[key]
281
260
  );
282
261
  const isDecorationFlagsEqual = (range, other) => {
283
262
  const { anchor: rangeAnchor, focus: rangeFocus, ...rangeOwnProps } = range;
284
263
  const { anchor: otherAnchor, focus: otherFocus, ...otherOwnProps } = other;
285
- return shallowCompare(
286
- rangeOwnProps,
287
- otherOwnProps
288
- );
264
+ return shallowCompare(rangeOwnProps, otherOwnProps);
289
265
  };
290
266
  const isElementDecorationsEqual = (list, another) => {
291
267
  if (list === another) {
@@ -364,51 +340,51 @@ const splitDecorationsByChild = (editor, node, decorations) => {
364
340
  export {
365
341
  C as CAN_USE_DOM,
366
342
  DOMEditor,
367
- G as EDITOR_TO_ELEMENT,
343
+ L as EDITOR_TO_ELEMENT,
368
344
  EDITOR_TO_KEY_TO_ELEMENT,
369
345
  EDITOR_TO_ON_CHANGE,
370
346
  EDITOR_TO_USER_MARKS,
371
347
  EDITOR_TO_USER_SELECTION,
372
- J as EDITOR_TO_WINDOW,
373
- L as ELEMENT_TO_NODE,
348
+ M as EDITOR_TO_WINDOW,
349
+ O as ELEMENT_TO_NODE,
374
350
  H as HAS_BEFORE_INPUT_SUPPORT,
375
351
  F as Hotkeys,
376
352
  I as IS_ANDROID,
377
353
  v as IS_CHROME,
378
- M as IS_COMPOSING,
354
+ P as IS_COMPOSING,
379
355
  w as IS_FIREFOX,
380
356
  x as IS_FIREFOX_LEGACY,
381
- O as IS_FOCUSED,
357
+ Q as IS_FOCUSED,
382
358
  y as IS_IOS,
383
- P as IS_READ_ONLY,
359
+ R as IS_READ_ONLY,
384
360
  A as IS_UC_MOBILE,
385
361
  z as IS_WEBKIT,
386
362
  B as IS_WECHATBROWSER,
387
- KEY_TO_CHUNK_TREE,
363
+ J as KEY_TO_CHUNK_TREE,
388
364
  K as Key,
389
- Q as MARK_PLACEHOLDER_SYMBOL,
390
- R as NODE_TO_ELEMENT,
391
- S as NODE_TO_INDEX,
365
+ S as MARK_PLACEHOLDER_SYMBOL,
366
+ T as NODE_TO_ELEMENT,
367
+ U as NODE_TO_INDEX,
392
368
  NODE_TO_KEY,
393
- T as NODE_TO_PARENT,
394
- e as applyStringDiff,
395
- f as getActiveElement,
369
+ V as NODE_TO_PARENT,
370
+ f as applyStringDiff,
371
+ h as getActiveElement,
396
372
  getChunkTreeForNode,
397
- h as getDefaultView,
398
- j as getSelection,
399
- k as hasShadowRoot,
400
- l as isAfter,
401
- m as isBefore,
402
- o as isDOMElement,
403
- p as isDOMNode,
404
- q as isDOMSelection,
373
+ j as getDefaultView,
374
+ k as getSelection,
375
+ l as hasShadowRoot,
376
+ m as isAfter,
377
+ o as isBefore,
378
+ p as isDOMElement,
379
+ q as isDOMNode,
380
+ r as isDOMSelection,
405
381
  isElementDecorationsEqual,
406
382
  s as isPlainTextOnlyPaste,
407
383
  isTextDecorationsEqual,
408
384
  t as isTrackedMutation,
409
385
  u as normalizeDOMPoint,
410
386
  n as normalizeStringDiff,
411
- reconcileChildren,
387
+ G as reconcileChildren,
412
388
  splitDecorationsByChild,
413
389
  withDOM
414
390
  };
package/dist/history.js CHANGED
@@ -1,5 +1,5 @@
1
- import { d as isObject, O as Operation, E as Editor, c as Transforms, P as Path } from "./index-CCzZ6aOH.js";
2
- import "vue";
1
+ import { d as isObject, O as Operation, E as Editor, c as Transforms, P as Path } from "./index-Bj4hXlPm.js";
2
+ import { shallowReactive } from "vue";
3
3
  const History = {
4
4
  /**
5
5
  * Check if a value is a `History` object.
@@ -102,10 +102,13 @@ const HistoryEditor = {
102
102
  const withHistory = (editor) => {
103
103
  const e = editor;
104
104
  const { apply } = e;
105
- e.history = { undos: [], redos: [] };
105
+ e.history = {
106
+ undos: shallowReactive([]),
107
+ redos: shallowReactive([])
108
+ };
106
109
  e.redo = () => {
107
110
  const { history } = e;
108
- const { redos } = history;
111
+ const redos = history.redos;
109
112
  if (redos.length > 0) {
110
113
  const batch = redos[redos.length - 1];
111
114
  if (batch.selectionBefore) {