slate-vue3 0.12.0 → 0.12.2

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.
package/dist/core.js CHANGED
@@ -1,6 +1,5 @@
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-DY8oRnih.js";
2
- import { E as E2, a as a10, 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-BAqw4zjw.js";
3
- import { L as L2, S as S3 } from "./location-DOXieCWO.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-CKqY-8iC.js";
2
+ import { E as E2, a as a10, L as L2, N as N2, O as O2, P as P2, b as b2, R as R2, c as c2, S as S2, T as T2, d as d2, i as i2, e as e2 } from "./index-BzxeM0Pe.js";
4
3
  export {
5
4
  E2 as Editor,
6
5
  a10 as Element,
@@ -13,10 +12,10 @@ export {
13
12
  a7 as PointRef,
14
13
  R2 as Range,
15
14
  a8 as RangeRef,
16
- S2 as Scrubber,
17
- S3 as Span,
15
+ c2 as Scrubber,
16
+ S2 as Span,
18
17
  T2 as Text,
19
- c2 as Transforms,
18
+ d2 as Transforms,
20
19
  d as above,
21
20
  e as addMark,
22
21
  f as after,
@@ -53,7 +52,7 @@ export {
53
52
  D as isEmpty,
54
53
  E as isEnd,
55
54
  F as isNormalizing,
56
- d2 as isObject,
55
+ e2 as isObject,
57
56
  G as isStart,
58
57
  H as last,
59
58
  I as leaf,
@@ -1,6 +1,5 @@
1
- import { P as Path, b as Point, R as Range, E as Editor, c as Transforms, N as Node, T as Text, g as getDefaultInsertLocation, S as Scrubber } from "./index-BAqw4zjw.js";
1
+ import { P as Path, b as Point, R as Range, E as Editor, d as Transforms, N as Node, T as Text, L as Location, g as getDefaultInsertLocation, c as Scrubber } from "./index-BzxeM0Pe.js";
2
2
  import { shallowReactive, ref } from "vue";
3
- import { S as Span } from "./location-DOXieCWO.js";
4
3
  const PathRef = {
5
4
  transform(ref2, op) {
6
5
  const { current, affinity } = ref2;
@@ -439,78 +438,83 @@ const normalizeNode = (editor, entry, options) => {
439
438
  if (Node.isText(node2)) {
440
439
  return;
441
440
  }
442
- if (Node.isElement(node2) && node2.children.length === 0) {
443
- const child = { text: "" };
444
- Transforms.insertNodes(editor, child, {
445
- at: path2.concat(0),
446
- voids: true
447
- });
448
- return;
441
+ if (!("children" in node2)) {
442
+ node2.children = [];
449
443
  }
450
- const shouldHaveInlines = node2 === editor ? false : Node.isElement(node2) && (editor.isInline(node2) || node2.children.length === 0 || Node.isText(node2.children[0]) || editor.isInline(node2.children[0]));
451
- let n = 0;
452
- for (let i = 0; i < node2.children.length; i++, n++) {
453
- const currentNode = Node.get(editor, path2);
454
- if (Node.isText(currentNode)) continue;
455
- const child = currentNode.children[n];
456
- if (child === void 0) continue;
457
- const prev = currentNode.children[n - 1];
458
- const isLast = i === node2.children.length - 1;
459
- const isInlineOrText = Node.isText(child) || Node.isElement(child) && editor.isInline(child);
460
- if (isInlineOrText !== shouldHaveInlines) {
461
- if (isInlineOrText) {
462
- if (options?.fallbackElement) {
463
- Transforms.wrapNodes(editor, options.fallbackElement(), {
464
- at: path2.concat(n),
465
- voids: true
466
- });
467
- } else {
468
- Transforms.removeNodes(editor, { at: path2.concat(n), voids: true });
444
+ let element = node2;
445
+ if (element !== editor && element.children.length === 0) {
446
+ const child = { text: "" };
447
+ Transforms.insertNodes(editor, child, { at: path2.concat(0), voids: true });
448
+ element = Node.get(editor, path2);
449
+ }
450
+ const shouldHaveInlines = !(element === editor) && (editor.isInline(element) || Node.isText(element.children[0]) || editor.isInline(element.children[0]));
451
+ if (shouldHaveInlines) {
452
+ for (let n = 0; n < element.children.length; n++) {
453
+ const child = element.children[n];
454
+ const prev = element.children[n - 1];
455
+ if (Node.isText(child)) {
456
+ if (prev != null && Node.isText(prev)) {
457
+ if (child.text === "") {
458
+ Transforms.removeNodes(editor, {
459
+ at: path2.concat(n),
460
+ voids: true
461
+ });
462
+ element = Node.get(editor, path2);
463
+ n--;
464
+ } else if (prev.text === "") {
465
+ Transforms.removeNodes(editor, {
466
+ at: path2.concat(n - 1),
467
+ voids: true
468
+ });
469
+ element = Node.get(editor, path2);
470
+ n--;
471
+ } else if (Text.equals(child, prev, { loose: true })) {
472
+ Transforms.mergeNodes(editor, { at: path2.concat(n), voids: true });
473
+ element = Node.get(editor, path2);
474
+ n--;
475
+ }
469
476
  }
470
477
  } else {
471
- Transforms.unwrapNodes(editor, { at: path2.concat(n), voids: true });
472
- }
473
- n--;
474
- } else if (Node.isElement(child)) {
475
- if (editor.isInline(child)) {
476
- if (prev == null || !Node.isText(prev)) {
477
- const newChild = { text: "" };
478
- Transforms.insertNodes(editor, newChild, {
479
- at: path2.concat(n),
480
- voids: true
481
- });
482
- n++;
483
- } else if (isLast) {
484
- const newChild = { text: "" };
485
- Transforms.insertNodes(editor, newChild, {
486
- at: path2.concat(n + 1),
487
- voids: true
488
- });
489
- n++;
478
+ if (editor.isInline(child)) {
479
+ if (prev == null || !Node.isText(prev)) {
480
+ const newChild = { text: "" };
481
+ Transforms.insertNodes(editor, newChild, {
482
+ at: path2.concat(n),
483
+ voids: true
484
+ });
485
+ element = Node.get(editor, path2);
486
+ n++;
487
+ }
488
+ if (n === element.children.length - 1) {
489
+ const newChild = { text: "" };
490
+ Transforms.insertNodes(editor, newChild, {
491
+ at: path2.concat(n + 1),
492
+ voids: true
493
+ });
494
+ element = Node.get(editor, path2);
495
+ n++;
496
+ }
497
+ } else {
498
+ Transforms.unwrapNodes(editor, { at: path2.concat(n), voids: true });
499
+ element = Node.get(editor, path2);
500
+ n--;
490
501
  }
491
502
  }
492
- } else {
493
- if (!Node.isText(child) && !("children" in child)) {
494
- const elementChild = child;
495
- elementChild.children = [];
496
- }
497
- if (prev != null && Node.isText(prev)) {
498
- if (Text.equals(child, prev, { loose: true })) {
499
- Transforms.mergeNodes(editor, { at: path2.concat(n), voids: true });
500
- n--;
501
- } else if (prev.text === "") {
502
- Transforms.removeNodes(editor, {
503
- at: path2.concat(n - 1),
504
- voids: true
505
- });
506
- n--;
507
- } else if (child.text === "") {
508
- Transforms.removeNodes(editor, {
503
+ }
504
+ } else {
505
+ for (let n = 0; n < element.children.length; n++) {
506
+ const child = element.children[n];
507
+ if (Node.isText(child) || editor.isInline(child)) {
508
+ if (options?.fallbackElement) {
509
+ Transforms.wrapNodes(editor, options.fallbackElement(), {
509
510
  at: path2.concat(n),
510
511
  voids: true
511
512
  });
512
- n--;
513
+ } else {
514
+ Transforms.removeNodes(editor, { at: path2.concat(n), voids: true });
513
515
  }
516
+ element = Node.get(editor, path2);
517
+ n--;
514
518
  }
515
519
  }
516
520
  }
@@ -535,7 +539,7 @@ const above = (editor, options = {}) => {
535
539
  return;
536
540
  }
537
541
  let path2 = Editor.path(editor, at);
538
- if (!Range.isRange(at) || Path.equals(at.focus.path, at.anchor.path)) {
542
+ if (!Location.isRange(at) || Path.equals(at.focus.path, at.anchor.path)) {
539
543
  if (path2.length === 0) return;
540
544
  path2 = Path.parent(path2);
541
545
  }
@@ -844,11 +848,11 @@ const next = (editor, options = {}) => {
844
848
  if (!pointAfterLocation) return;
845
849
  const [, to] = Editor.last(editor, []);
846
850
  const span = [pointAfterLocation.path, to];
847
- if (Path.isPath(at) && at.length === 0) {
851
+ if (Location.isPath(at) && at.length === 0) {
848
852
  throw new Error(`Cannot get the next node from the root node!`);
849
853
  }
850
854
  if (match == null) {
851
- if (Path.isPath(at)) {
855
+ if (Location.isPath(at)) {
852
856
  const [parent2] = Editor.parent(editor, at);
853
857
  match = (n) => parent2.children.includes(n);
854
858
  } else {
@@ -881,7 +885,7 @@ function* nodes(editor, options = {}) {
881
885
  }
882
886
  let from;
883
887
  let to;
884
- if (Span.isSpan(at)) {
888
+ if (Location.isSpan(at)) {
885
889
  from = at[0];
886
890
  to = at[1];
887
891
  } else {
@@ -1032,7 +1036,7 @@ const pathRefs = (editor) => {
1032
1036
  };
1033
1037
  const path = (editor, at, options = {}) => {
1034
1038
  const { depth, edge } = options;
1035
- if (Path.isPath(at)) {
1039
+ if (Location.isPath(at)) {
1036
1040
  if (edge === "start") {
1037
1041
  const [, firstPath] = Node.first(editor, at);
1038
1042
  at = firstPath;
@@ -1041,7 +1045,7 @@ const path = (editor, at, options = {}) => {
1041
1045
  at = lastPath;
1042
1046
  }
1043
1047
  }
1044
- if (Range.isRange(at)) {
1048
+ if (Location.isRange(at)) {
1045
1049
  if (edge === "start") {
1046
1050
  at = Range.start(at);
1047
1051
  } else if (edge === "end") {
@@ -1050,7 +1054,7 @@ const path = (editor, at, options = {}) => {
1050
1054
  at = Path.common(at.anchor.path, at.focus.path);
1051
1055
  }
1052
1056
  }
1053
- if (Point.isPoint(at)) {
1057
+ if (Location.isPoint(at)) {
1054
1058
  at = at.path;
1055
1059
  }
1056
1060
  if (depth != null) {
@@ -1085,7 +1089,7 @@ const pointRefs = (editor) => {
1085
1089
  };
1086
1090
  const point = (editor, at, options = {}) => {
1087
1091
  const { edge = "start" } = options;
1088
- if (Path.isPath(at)) {
1092
+ if (Location.isPath(at)) {
1089
1093
  let path2;
1090
1094
  if (edge === "end") {
1091
1095
  const [, lastPath] = Node.last(editor, at);
@@ -1102,7 +1106,7 @@ const point = (editor, at, options = {}) => {
1102
1106
  }
1103
1107
  return { path: path2, offset: edge === "end" ? node2.text.length : 0 };
1104
1108
  }
1105
- if (Range.isRange(at)) {
1109
+ if (Location.isRange(at)) {
1106
1110
  const [start2, end2] = Range.edges(at);
1107
1111
  return edge === "start" ? start2 : end2;
1108
1112
  }
@@ -1222,11 +1226,11 @@ const previous = (editor, options = {}) => {
1222
1226
  }
1223
1227
  const [, to] = Editor.first(editor, []);
1224
1228
  const span = [pointBeforeLocation.path, to];
1225
- if (Path.isPath(at) && at.length === 0) {
1229
+ if (Location.isPath(at) && at.length === 0) {
1226
1230
  throw new Error(`Cannot get the previous node from the root node!`);
1227
1231
  }
1228
1232
  if (match == null) {
1229
- if (Path.isPath(at)) {
1233
+ if (Location.isPath(at)) {
1230
1234
  const [parent2] = Editor.parent(editor, at);
1231
1235
  match = (n) => parent2.children.includes(n);
1232
1236
  } else {
@@ -1268,7 +1272,7 @@ const rangeRefs = (editor) => {
1268
1272
  return refs;
1269
1273
  };
1270
1274
  const range = (editor, at, to) => {
1271
- if (Range.isRange(at) && !to) {
1275
+ if (Location.isRange(at) && !to) {
1272
1276
  return at;
1273
1277
  }
1274
1278
  const start2 = Editor.start(editor, at);
@@ -2080,11 +2084,11 @@ const deleteText = (editor, options = {}) => {
2080
2084
  return;
2081
2085
  }
2082
2086
  let isCollapsed = false;
2083
- if (Range.isRange(at) && Range.isCollapsed(at)) {
2087
+ if (Location.isRange(at) && Range.isCollapsed(at)) {
2084
2088
  isCollapsed = true;
2085
2089
  at = at.anchor;
2086
2090
  }
2087
- if (Point.isPoint(at)) {
2091
+ if (Location.isPoint(at)) {
2088
2092
  const furthestVoid = Editor.void(editor, { at, mode: "highest" });
2089
2093
  if (!voids && furthestVoid) {
2090
2094
  const [, voidPath] = furthestVoid;
@@ -2096,7 +2100,7 @@ const deleteText = (editor, options = {}) => {
2096
2100
  hanging = true;
2097
2101
  }
2098
2102
  }
2099
- if (Path.isPath(at)) {
2103
+ if (Location.isPath(at)) {
2100
2104
  Transforms.removeNodes(editor, { at, voids });
2101
2105
  return;
2102
2106
  }
@@ -2208,7 +2212,7 @@ const insertFragment = (editor, fragment2, options = {}) => {
2208
2212
  if (!fragment2.length) {
2209
2213
  return;
2210
2214
  }
2211
- if (Range.isRange(at)) {
2215
+ if (Location.isRange(at)) {
2212
2216
  if (!hanging) {
2213
2217
  at = Editor.unhangRange(editor, at, { voids });
2214
2218
  }
@@ -2223,7 +2227,7 @@ const insertFragment = (editor, fragment2, options = {}) => {
2223
2227
  Transforms.delete(editor, { at });
2224
2228
  at = pointRef2.unref();
2225
2229
  }
2226
- } else if (Path.isPath(at)) {
2230
+ } else if (Location.isPath(at)) {
2227
2231
  at = Editor.start(editor, at);
2228
2232
  }
2229
2233
  if (!voids && Editor.void(editor, { at })) {
@@ -2431,7 +2435,7 @@ const select = (editor, target) => {
2431
2435
  Transforms.setSelection(editor, target);
2432
2436
  return;
2433
2437
  }
2434
- if (!Range.isRange(target)) {
2438
+ if (!Location.isRange(target)) {
2435
2439
  throw new Error(
2436
2440
  `When setting the selection and the current selection is \`null\` you must provide at least an \`anchor\` and \`focus\`, but you passed: ${Scrubber.stringify(
2437
2441
  target
@@ -2508,7 +2512,7 @@ const insertNodes = (editor, nodes2, options = {}) => {
2508
2512
  if (select2 == null) {
2509
2513
  select2 = false;
2510
2514
  }
2511
- if (Range.isRange(at)) {
2515
+ if (Location.isRange(at)) {
2512
2516
  if (!hanging) {
2513
2517
  at = Editor.unhangRange(editor, at, { voids });
2514
2518
  }
@@ -2521,7 +2525,7 @@ const insertNodes = (editor, nodes2, options = {}) => {
2521
2525
  at = pointRef2.unref();
2522
2526
  }
2523
2527
  }
2524
- if (Point.isPoint(at)) {
2528
+ if (Location.isPoint(at)) {
2525
2529
  if (match == null) {
2526
2530
  if (Node.isText(node2)) {
2527
2531
  match = (n) => Node.isText(n);
@@ -2615,12 +2619,12 @@ const liftNodes = (editor, options = {}) => {
2615
2619
  Editor.withoutNormalizing(editor, () => {
2616
2620
  const { at = editor.selection, mode = "lowest", voids = false } = options;
2617
2621
  let { match } = options;
2618
- if (match == null) {
2619
- match = Path.isPath(at) ? matchPath(editor, at) : (n) => Node.isElement(n) && Editor.isBlock(editor, n);
2620
- }
2621
2622
  if (!at) {
2622
2623
  return;
2623
2624
  }
2625
+ if (match == null) {
2626
+ match = Location.isPath(at) ? matchPath(editor, at) : (n) => Node.isElement(n) && Editor.isBlock(editor, n);
2627
+ }
2624
2628
  const matches = Editor.nodes(editor, { at, match, mode, voids });
2625
2629
  const pathRefs2 = Array.from(matches, ([, p]) => Editor.pathRef(editor, p));
2626
2630
  for (const pathRef2 of pathRefs2) {
@@ -2663,17 +2667,17 @@ const mergeNodes = (editor, options = {}) => {
2663
2667
  return;
2664
2668
  }
2665
2669
  if (match == null) {
2666
- if (Path.isPath(at)) {
2670
+ if (Location.isPath(at)) {
2667
2671
  const [parent2] = Editor.parent(editor, at);
2668
2672
  match = (n) => parent2.children.includes(n);
2669
2673
  } else {
2670
2674
  match = (n) => Node.isElement(n) && Editor.isBlock(editor, n);
2671
2675
  }
2672
2676
  }
2673
- if (!hanging && Range.isRange(at)) {
2677
+ if (!hanging && Location.isRange(at)) {
2674
2678
  at = Editor.unhangRange(editor, at, { voids });
2675
2679
  }
2676
- if (Range.isRange(at)) {
2680
+ if (Location.isRange(at)) {
2677
2681
  if (Range.isCollapsed(at)) {
2678
2682
  at = at.anchor;
2679
2683
  } else {
@@ -2757,7 +2761,7 @@ const moveNodes = (editor, options) => {
2757
2761
  return;
2758
2762
  }
2759
2763
  if (match == null) {
2760
- match = Path.isPath(at) ? matchPath(editor, at) : (n) => Node.isElement(n) && Editor.isBlock(editor, n);
2764
+ match = Location.isPath(at) ? matchPath(editor, at) : (n) => Node.isElement(n) && Editor.isBlock(editor, n);
2761
2765
  }
2762
2766
  const toRef = Editor.pathRef(editor, to);
2763
2767
  const targets = Editor.nodes(editor, { at, match, mode, voids });
@@ -2783,9 +2787,9 @@ const removeNodes = (editor, options = {}) => {
2783
2787
  return;
2784
2788
  }
2785
2789
  if (match == null) {
2786
- match = Path.isPath(at) ? matchPath(editor, at) : (n) => Node.isElement(n) && Editor.isBlock(editor, n);
2790
+ match = Location.isPath(at) ? matchPath(editor, at) : (n) => Node.isElement(n) && Editor.isBlock(editor, n);
2787
2791
  }
2788
- if (!hanging && Range.isRange(at)) {
2792
+ if (!hanging && Location.isRange(at)) {
2789
2793
  at = Editor.unhangRange(editor, at, { voids });
2790
2794
  }
2791
2795
  const depths = Editor.nodes(editor, { at, match, mode, voids });
@@ -2813,12 +2817,12 @@ const setNodes = (editor, props, options = {}) => {
2813
2817
  return;
2814
2818
  }
2815
2819
  if (match == null) {
2816
- match = Path.isPath(at) ? matchPath(editor, at) : (n) => Node.isElement(n) && Editor.isBlock(editor, n);
2820
+ match = Location.isPath(at) ? matchPath(editor, at) : (n) => Node.isElement(n) && Editor.isBlock(editor, n);
2817
2821
  }
2818
- if (!hanging && Range.isRange(at)) {
2822
+ if (!hanging && Location.isRange(at)) {
2819
2823
  at = Editor.unhangRange(editor, at, { voids });
2820
2824
  }
2821
- if (split && Range.isRange(at)) {
2825
+ if (split && Location.isRange(at)) {
2822
2826
  if (Range.isCollapsed(at) && Editor.leaf(editor, at.anchor)[0].text.length > 0) {
2823
2827
  return;
2824
2828
  }
@@ -2911,13 +2915,15 @@ const splitNodes = (editor, options = {}) => {
2911
2915
  height = 0,
2912
2916
  always = false
2913
2917
  } = options;
2918
+ if (!at) return;
2914
2919
  if (match == null) {
2915
2920
  match = (n) => Node.isElement(n) && Editor.isBlock(editor, n);
2916
2921
  }
2917
- if (Range.isRange(at)) {
2922
+ if (Location.isRange(at)) {
2918
2923
  at = deleteRange(editor, at);
2924
+ if (!at) return;
2919
2925
  }
2920
- if (Path.isPath(at)) {
2926
+ if (Location.isPath(at)) {
2921
2927
  const path2 = at;
2922
2928
  const point2 = Editor.point(editor, path2);
2923
2929
  const [parent2] = Editor.parent(editor, path2);
@@ -2926,9 +2932,6 @@ const splitNodes = (editor, options = {}) => {
2926
2932
  at = point2;
2927
2933
  always = true;
2928
2934
  }
2929
- if (!at) {
2930
- return;
2931
- }
2932
2935
  const beforeRef = Editor.pointRef(editor, at, {
2933
2936
  affinity: "backward"
2934
2937
  });
@@ -3013,12 +3016,12 @@ const unwrapNodes = (editor, options = {}) => {
3013
3016
  return;
3014
3017
  }
3015
3018
  if (match == null) {
3016
- match = Path.isPath(at) ? matchPath(editor, at) : (n) => Node.isElement(n) && Editor.isBlock(editor, n);
3019
+ match = Location.isPath(at) ? matchPath(editor, at) : (n) => Node.isElement(n) && Editor.isBlock(editor, n);
3017
3020
  }
3018
- if (Path.isPath(at)) {
3021
+ if (Location.isPath(at)) {
3019
3022
  at = Editor.range(editor, at);
3020
3023
  }
3021
- const rangeRef2 = Range.isRange(at) ? Editor.rangeRef(editor, at) : null;
3024
+ const rangeRef2 = Location.isRange(at) ? Editor.rangeRef(editor, at) : null;
3022
3025
  const matches = Editor.nodes(editor, { at, match, mode, voids });
3023
3026
  const pathRefs2 = Array.from(
3024
3027
  matches,
@@ -3053,7 +3056,7 @@ const wrapNodes = (editor, element, options = {}) => {
3053
3056
  return;
3054
3057
  }
3055
3058
  if (match == null) {
3056
- if (Path.isPath(at)) {
3059
+ if (Location.isPath(at)) {
3057
3060
  match = matchPath(editor, at);
3058
3061
  } else if (editor.isInline(element)) {
3059
3062
  match = (n) => Node.isElement(n) && Editor.isInline(editor, n) || Node.isText(n);
@@ -3061,7 +3064,7 @@ const wrapNodes = (editor, element, options = {}) => {
3061
3064
  match = (n) => Node.isElement(n) && Editor.isBlock(editor, n);
3062
3065
  }
3063
3066
  }
3064
- if (split && Range.isRange(at)) {
3067
+ if (split && Location.isRange(at)) {
3065
3068
  const [start2, end2] = Range.edges(at);
3066
3069
  const rangeRef2 = Editor.rangeRef(editor, at, {
3067
3070
  affinity: "inward"
package/dist/dom.js CHANGED
@@ -1,6 +1,6 @@
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, f as EDITOR_TO_ON_IMMEDIATE_CHANGE } from "./hotkeys-BDV_qcIo.js";
2
- import { R, $, _, a0, T, U, F, M, C, K, L, a4, J, G, O, a3, I, a2, S, P, H, Q, W, V, a5, a1, Y, Z, h, A, B, x, u, j, t, s, v, r, z, y, k, l, m, o, p, w, q, n, X } from "./hotkeys-BDV_qcIo.js";
3
- import { E as Editor, R as Range, N as Node, c as Transforms, P as Path } from "./index-BAqw4zjw.js";
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, f as EDITOR_TO_ON_IMMEDIATE_CHANGE } from "./hotkeys-D6R9vfnD.js";
2
+ import { R, $, _, a0, T, U, F, M, C, K, L, a4, J, G, O, a3, I, a2, S, P, H, Q, W, V, a5, a1, Y, Z, h, A, B, x, u, j, t, s, v, r, z, y, k, l, m, o, p, w, q, n, X } from "./hotkeys-D6R9vfnD.js";
3
+ import { E as Editor, R as Range, N as Node, d as Transforms, P as Path } from "./index-BzxeM0Pe.js";
4
4
  import "vue";
5
5
  const doRectsIntersect = (rect, compareRect) => {
6
6
  const middle = (compareRect.top + compareRect.bottom) / 2;
package/dist/history.js CHANGED
@@ -1,4 +1,4 @@
1
- import { d as isObject, O as Operation, E as Editor, c as Transforms, P as Path } from "./index-BAqw4zjw.js";
1
+ import { e as isObject, O as Operation, E as Editor, d as Transforms, P as Path } from "./index-BzxeM0Pe.js";
2
2
  import { shallowReactive } from "vue";
3
3
  const History = {
4
4
  /**
@@ -1,5 +1,5 @@
1
1
  import { shallowReactive } from "vue";
2
- import { S as Scrubber, R as Range, E as Editor, N as Node, c as Transforms, P as Path } from "./index-BAqw4zjw.js";
2
+ import { c as Scrubber, R as Range, E as Editor, N as Node, d as Transforms, P as Path } from "./index-BzxeM0Pe.js";
3
3
  import { t as toRawWeakMap } from "./index-Ban80MbP.js";
4
4
  const getDefaultView = (value) => {
5
5
  return value && value.ownerDocument && value.ownerDocument.defaultView || null;
@@ -1,5 +1,5 @@
1
- import { R as Range, N as Node, T as Text, a as Element, d as isObject } from "./index-BAqw4zjw.js";
2
- import { c as createEditor$1 } from "./create-editor-DY8oRnih.js";
1
+ import { R as Range, N as Node, T as Text, a as Element, e as isObject } from "./index-BzxeM0Pe.js";
2
+ import { c as createEditor$1 } from "./create-editor-CKqY-8iC.js";
3
3
  import "vue";
4
4
  import { t as toRawWeakMap } from "./index-Ban80MbP.js";
5
5
  const ANCHOR = new toRawWeakMap();
@@ -80,7 +80,7 @@ const Path = {
80
80
  return path.length + 1 === another.length && Path.compare(path, another) === 0;
81
81
  },
82
82
  isPath(value) {
83
- return Array.isArray(value) && (value.length === 0 || typeof value[0] === "number");
83
+ return Array.isArray(value) && value.every((n) => typeof n === "number");
84
84
  },
85
85
  isSibling(path, another) {
86
86
  if (path.length !== another.length) {
@@ -395,7 +395,7 @@ const GeneralTransforms = {
395
395
  break;
396
396
  }
397
397
  if (editor.selection == null) {
398
- if (!Range.isRange(newProperties)) {
398
+ if (!(newProperties.anchor && newProperties.focus)) {
399
399
  throw new Error(
400
400
  `Cannot apply an incomplete 'set_selection' operation properties ${Scrubber.stringify(
401
401
  newProperties
@@ -560,7 +560,7 @@ const Range = {
560
560
  return Range.equals(intersectionRange, target);
561
561
  },
562
562
  includes(range, target) {
563
- if (Range.isRange(target)) {
563
+ if (Location.isRange(target)) {
564
564
  if (Range.includes(range, target.anchor) || Range.includes(range, target.focus)) {
565
565
  return true;
566
566
  }
@@ -571,7 +571,7 @@ const Range = {
571
571
  const [start, end] = Range.edges(range);
572
572
  let isAfterStart = false;
573
573
  let isBeforeEnd = false;
574
- if (Point.isPoint(target)) {
574
+ if (Location.isPoint(target)) {
575
575
  isAfterStart = Point.compare(target, start) >= 0;
576
576
  isBeforeEnd = Point.compare(target, end) <= 0;
577
577
  } else {
@@ -797,6 +797,7 @@ const Node = {
797
797
  const index = end.path[i];
798
798
  node.children = node.children.slice(0, index + 1);
799
799
  if (Node.isElement(node.children[index])) {
800
+ node.children[index] = { ...node.children[index] };
800
801
  node = node.children[index];
801
802
  }
802
803
  }
@@ -805,6 +806,7 @@ const Node = {
805
806
  const index = start.path[i];
806
807
  node.children = node.children.slice(index);
807
808
  if (Node.isElement(node.children[0])) {
809
+ node.children[0] = { ...node.children[0] };
808
810
  node = node.children[0];
809
811
  }
810
812
  }
@@ -1275,6 +1277,28 @@ const Editor = {
1275
1277
  return editor.shouldMergeNodesRemovePrevNode(prevNode, curNode);
1276
1278
  }
1277
1279
  };
1280
+ const Location = {
1281
+ isLocation(value) {
1282
+ return Path.isPath(value) || Point.isPoint(value) || Range.isRange(value);
1283
+ },
1284
+ isPath(at) {
1285
+ return Array.isArray(at);
1286
+ },
1287
+ isPoint(at) {
1288
+ return "offset" in at;
1289
+ },
1290
+ isRange(at) {
1291
+ return "anchor" in at;
1292
+ },
1293
+ isSpan(at) {
1294
+ return Array.isArray(at) && Array.isArray(at[0]);
1295
+ }
1296
+ };
1297
+ const Span = {
1298
+ isSpan(value) {
1299
+ return Array.isArray(value) && value.length === 2 && value.every(Path.isPath);
1300
+ }
1301
+ };
1278
1302
  const Point = {
1279
1303
  compare(point, another) {
1280
1304
  const result = Path.compare(point.path, another.path);
@@ -1483,10 +1507,10 @@ const TextTransforms = {
1483
1507
  Editor.withoutNormalizing(editor, () => {
1484
1508
  const { voids = false } = options;
1485
1509
  let { at = getDefaultInsertLocation(editor) } = options;
1486
- if (Path.isPath(at)) {
1510
+ if (Location.isPath(at)) {
1487
1511
  at = Editor.range(editor, at);
1488
1512
  }
1489
- if (Range.isRange(at)) {
1513
+ if (Location.isRange(at)) {
1490
1514
  if (Range.isCollapsed(at)) {
1491
1515
  at = at.anchor;
1492
1516
  } else {
@@ -1521,16 +1545,18 @@ const Transforms = {
1521
1545
  };
1522
1546
  export {
1523
1547
  Editor as E,
1548
+ Location as L,
1524
1549
  Node as N,
1525
1550
  Operation as O,
1526
1551
  Path as P,
1527
1552
  Range as R,
1528
- Scrubber as S,
1553
+ Span as S,
1529
1554
  Text as T,
1530
1555
  Element as a,
1531
1556
  Point as b,
1532
- Transforms as c,
1533
- isObject as d,
1557
+ Scrubber as c,
1558
+ Transforms as d,
1559
+ isObject as e,
1534
1560
  getDefaultInsertLocation as g,
1535
1561
  isEditor as i
1536
1562
  };
package/dist/index.js CHANGED
@@ -1,8 +1,8 @@
1
- import { u as useElementIf, a as useEditor, S as SLATE_USE_SELECTION } from "./use-focused-CkMZ3Xb4.js";
2
- import { n, p, k, l, o, D, m, E, b, j, h, g, i, c, f, d, e } from "./use-focused-CkMZ3Xb4.js";
3
- import { E as Editor, R as Range } from "./index-BAqw4zjw.js";
1
+ import { u as useElementIf, a as useEditor, S as SLATE_USE_SELECTION } from "./use-focused-rvrvwwCw.js";
2
+ import { n, p, k, l, o, D, m, E, b, j, h, g, i, c, f, d, e } from "./use-focused-rvrvwwCw.js";
3
+ import { E as Editor, R as Range } from "./index-BzxeM0Pe.js";
4
4
  import { computed, inject } from "vue";
5
- import { D as DOMEditor } from "./hotkeys-BDV_qcIo.js";
5
+ import { D as DOMEditor } from "./hotkeys-D6R9vfnD.js";
6
6
  import { t } from "./index-Ban80MbP.js";
7
7
  const useSelected = () => {
8
8
  const element = useElementIf();
@@ -1,3 +1,3 @@
1
1
  import { WithEditorFirstArg } from '../utils/types';
2
- import { Editor } from '../interfaces/editor';
2
+ import { Editor } from '../interfaces';
3
3
  export declare const normalizeNode: WithEditorFirstArg<Editor["normalizeNode"]>;
@@ -13,6 +13,22 @@ export interface LocationInterface {
13
13
  * Check if a value implements the `Location` interface.
14
14
  */
15
15
  isLocation: (value: any) => value is Location;
16
+ /**
17
+ * Check if a location is a `Path`.
18
+ */
19
+ isPath: (at: Location) => at is Path;
20
+ /**
21
+ * Check if a location is a `Point`.
22
+ */
23
+ isPoint: (at: Location) => at is Point;
24
+ /**
25
+ * Check if a location is a `Range`.
26
+ */
27
+ isRange: (at: Location) => at is Range;
28
+ /**
29
+ * Differentiate between a normal `Location` and a `Span`.
30
+ */
31
+ isSpan: (at: Location | Span) => at is Span;
16
32
  }
17
33
  export declare const Location: LocationInterface;
18
34
  /**
@@ -1,4 +1,4 @@
1
- import { ExtendedType, Operation, Path, Point, PointEntry } from '..';
1
+ import { ExtendedType, Location, Operation, Point, PointEntry } from '..';
2
2
  import { RangeDirection } from '../types/types';
3
3
  /**
4
4
  * `Range` objects are a set of points that refer to a specific span of a Slate
@@ -33,7 +33,7 @@ export interface RangeInterface {
33
33
  /**
34
34
  * Check if a range includes a path, a point or part of another range.
35
35
  */
36
- includes: (range: Range, target: Path | Point | Range) => boolean;
36
+ includes: (range: Range, target: Location) => boolean;
37
37
  /**
38
38
  * Check if a range includes another range.
39
39
  */
@@ -1,6 +1,6 @@
1
1
  import { h, inject, provide, computed, defineComponent, ref, onMounted, onUnmounted, renderSlot, renderList, watch, onUpdated, useAttrs, reactive, toRaw } from "vue";
2
- import { R as Range, N as Node, S as Scrubber, T as Text, E as Editor, P as Path, c as Transforms, a as Element } from "./index-BAqw4zjw.js";
3
- import { F as IS_ANDROID, m as isDOMNode, D as DOMEditor, a5 as MARK_PLACEHOLDER_SYMBOL, e as EDITOR_TO_ON_CHANGE, f as EDITOR_TO_ON_IMMEDIATE_CHANGE, H as IS_WEBKIT, E as EDITOR_TO_KEY_TO_ELEMENT, a0 as ELEMENT_TO_NODE, a1 as NODE_TO_ELEMENT, Y as NODE_TO_INDEX, Z as NODE_TO_PARENT, G as IS_FIREFOX, g as getChunkTreeForNode, X as reconcileChildren, h as applyStringDiff, o as isDOMSelection, n as normalizeStringDiff, a2 as IS_READ_ONLY, j as getDefaultView, _ as EDITOR_TO_WINDOW, $ as EDITOR_TO_ELEMENT, v as getSelection, T as HAS_BEFORE_INPUT_SUPPORT, R as CAN_USE_DOM, B as containsShadowAware, x as getActiveElement, a3 as IS_FOCUSED, p as isPlainTextOnlyPaste, a4 as IS_COMPOSING, U as Hotkeys, K as IS_CHROME, O as IS_FIREFOX_LEGACY, I as IS_IOS, Q as IS_WECHATBROWSER, P as IS_UC_MOBILE, a as EDITOR_TO_USER_MARKS, l as isDOMElement, b as EDITOR_TO_USER_SELECTION } from "./hotkeys-BDV_qcIo.js";
2
+ import { R as Range, N as Node, c as Scrubber, T as Text, E as Editor, P as Path, d as Transforms, a as Element } from "./index-BzxeM0Pe.js";
3
+ import { F as IS_ANDROID, m as isDOMNode, D as DOMEditor, a5 as MARK_PLACEHOLDER_SYMBOL, e as EDITOR_TO_ON_CHANGE, f as EDITOR_TO_ON_IMMEDIATE_CHANGE, H as IS_WEBKIT, E as EDITOR_TO_KEY_TO_ELEMENT, a0 as ELEMENT_TO_NODE, a1 as NODE_TO_ELEMENT, Y as NODE_TO_INDEX, Z as NODE_TO_PARENT, G as IS_FIREFOX, g as getChunkTreeForNode, X as reconcileChildren, h as applyStringDiff, o as isDOMSelection, n as normalizeStringDiff, a2 as IS_READ_ONLY, j as getDefaultView, _ as EDITOR_TO_WINDOW, $ as EDITOR_TO_ELEMENT, v as getSelection, T as HAS_BEFORE_INPUT_SUPPORT, R as CAN_USE_DOM, B as containsShadowAware, x as getActiveElement, a3 as IS_FOCUSED, p as isPlainTextOnlyPaste, a4 as IS_COMPOSING, U as Hotkeys, K as IS_CHROME, O as IS_FIREFOX_LEGACY, I as IS_IOS, Q as IS_WECHATBROWSER, P as IS_UC_MOBILE, a as EDITOR_TO_USER_MARKS, l as isDOMElement, b as EDITOR_TO_USER_SELECTION } from "./hotkeys-D6R9vfnD.js";
4
4
  const SLATE_USE_EDITOR = /* @__PURE__ */ Symbol("SLATE_USE_EDITOR");
5
5
  const SLATE_USE_ELEMENT = /* @__PURE__ */ Symbol("SLATE_USE_ELEMENT");
6
6
  const SLATE_USE_FOCUSED = /* @__PURE__ */ Symbol("SLATE_USE_FOCUSED");
package/dist/yjs.js CHANGED
@@ -1,9 +1,8 @@
1
- import { d as isObject, N as Node, P as Path, E as Editor, c as Transforms, R as Range } from "./index-BAqw4zjw.js";
1
+ import { e as isObject, N as Node, P as Path, E as Editor, L as Location, d as Transforms, R as Range } from "./index-BzxeM0Pe.js";
2
2
  import { ref, onMounted, onUnmounted, watch, onUpdated, computed } from "vue";
3
3
  import { XmlText, YTextEvent, createRelativePositionFromTypeIndex, createAbsolutePositionFromRelativePosition, createRelativePositionFromJSON, decodeRelativePosition, encodeRelativePosition, UndoManager, compareRelativePositions } from "yjs";
4
- import { L as Location } from "./location-DOXieCWO.js";
5
- import { a as useEditor, d as useFocused } from "./use-focused-CkMZ3Xb4.js";
6
- import { D as DOMEditor } from "./hotkeys-BDV_qcIo.js";
4
+ import { a as useEditor, d as useFocused } from "./use-focused-rvrvwwCw.js";
5
+ import { D as DOMEditor } from "./hotkeys-D6R9vfnD.js";
7
6
  function deepEquals(node, another) {
8
7
  for (const key in node) {
9
8
  const a = node[key];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "slate-vue3",
3
- "version": "0.12.0",
3
+ "version": "0.12.2",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",
@@ -79,21 +79,21 @@
79
79
  "@actions/core": "^2.0.2",
80
80
  "@eslint/js": "^9.39.2",
81
81
  "@faker-js/faker": "^10.2.0",
82
- "@liveblocks/client": "^3.12.1",
83
- "@liveblocks/yjs": "^3.12.1",
82
+ "@liveblocks/client": "^3.13.1",
83
+ "@liveblocks/yjs": "^3.13.1",
84
84
  "@playwright/test": "^1.57.0",
85
85
  "@testing-library/vue": "^8.1.0",
86
86
  "@types/is-hotkey": "^0.1.10",
87
87
  "@types/is-url": "^1.2.32",
88
88
  "@types/lodash-es": "^4.17.12",
89
- "@types/node": "^25.0.3",
89
+ "@types/node": "^25.0.9",
90
90
  "@types/prismjs": "^1.26.5",
91
91
  "@vitejs/plugin-vue": "^6.0.3",
92
92
  "@vue/eslint-config-prettier": "^10.2.0",
93
93
  "babel-plugin-transform-regex": "^6.1.0",
94
94
  "eslint": "^9.39.2",
95
- "eslint-plugin-vue": "^10.6.2",
96
- "globals": "^16.5.0",
95
+ "eslint-plugin-vue": "^10.7.0",
96
+ "globals": "^17.0.0",
97
97
  "husky": "^9.1.7",
98
98
  "image-extensions": "^1.1.0",
99
99
  "is-url": "^1.2.4",
@@ -105,13 +105,13 @@
105
105
  "remark-parse": "^11.0.0",
106
106
  "remark-slate-transformer": "^0.9.0",
107
107
  "typescript": "~5.9.3",
108
- "typescript-eslint": "^8.52.0",
108
+ "typescript-eslint": "^8.53.0",
109
109
  "unified": "^11.0.5",
110
110
  "vite": "^7.3.1",
111
- "vite-plugin-babel": "^1.3.2",
111
+ "vite-plugin-babel": "^1.4.1",
112
112
  "vite-plugin-dts": "^4.5.4",
113
113
  "vite-plugin-eslint": "^1.8.1",
114
- "vitest": "^4.0.16",
114
+ "vitest": "^4.0.17",
115
115
  "vue-router": "^4.6.4",
116
116
  "yjs": "^13.6.29"
117
117
  },
@@ -1,16 +0,0 @@
1
- import { P as Path, b as Point, R as Range } from "./index-BAqw4zjw.js";
2
- import "vue";
3
- const Location = {
4
- isLocation(value) {
5
- return Path.isPath(value) || Point.isPoint(value) || Range.isRange(value);
6
- }
7
- };
8
- const Span = {
9
- isSpan(value) {
10
- return Array.isArray(value) && value.length === 2 && value.every(Path.isPath);
11
- }
12
- };
13
- export {
14
- Location as L,
15
- Span as S
16
- };