slate-vue3 0.7.6 → 0.7.7

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,4 +1,4 @@
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-D7Z9o-3p.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-CDo9JOV_.js";
2
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 "./batch-dirty-paths-9ixbU5Xv.js";
3
3
  import { L as L2, S as S3 } from "./location-Df07ugyf.js";
4
4
  export {
@@ -439,7 +439,7 @@ const normalizeNode = (editor, entry, options) => {
439
439
  const isInlineOrText = Text.isText(child) || Element.isElement(child) && editor.isInline(child);
440
440
  if (isInlineOrText !== shouldHaveInlines) {
441
441
  if (isInlineOrText) {
442
- if (options == null ? void 0 : options.fallbackElement) {
442
+ if (options?.fallbackElement) {
443
443
  Transforms.wrapNodes(editor, options.fallbackElement(), {
444
444
  at: path2.concat(n),
445
445
  voids: true
@@ -2276,7 +2276,7 @@ const splitNodes = (editor, options = {}) => {
2276
2276
  }
2277
2277
  } finally {
2278
2278
  beforeRef.unref();
2279
- afterRef == null ? void 0 : afterRef.unref();
2279
+ afterRef?.unref();
2280
2280
  }
2281
2281
  });
2282
2282
  };
package/dist/dom.js CHANGED
@@ -1,5 +1,5 @@
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-CoLjwqzn.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-CoLjwqzn.js";
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-WTh2lFjJ.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-WTh2lFjJ.js";
3
3
  import { E as Editor, R as Range, a as Element, c as Transforms, N as Node, P as Path } from "./batch-dirty-paths-9ixbU5Xv.js";
4
4
  import { reactive } from "vue";
5
5
  const doRectsIntersect = (rect, compareRect) => {
@@ -102,7 +102,6 @@ const withDOM = (editor, clipboardFormatKey = "x-slate-fragment") => {
102
102
  }
103
103
  };
104
104
  e2.apply = (op) => {
105
- var _a;
106
105
  if (op.type === "move_node") {
107
106
  const parent = Node.parent(e2, op.path);
108
107
  const chunking = !!e2.getChunkSize(parent);
@@ -124,7 +123,7 @@ const withDOM = (editor, clipboardFormatKey = "x-slate-fragment") => {
124
123
  break;
125
124
  }
126
125
  case "set_selection": {
127
- (_a = EDITOR_TO_USER_SELECTION.get(e2)) == null ? void 0 : _a.unref();
126
+ EDITOR_TO_USER_SELECTION.get(e2)?.unref();
128
127
  EDITOR_TO_USER_SELECTION.delete(e2);
129
128
  break;
130
129
  }
@@ -1,7 +1,3 @@
1
- var __defProp = Object.defineProperty;
2
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
- var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
4
- var _a, _b;
5
1
  import { t as toRawWeakMap, R as Range, E as Editor, S as Scrubber, a as Element, c as Transforms, P as Path } from "./batch-dirty-paths-9ixbU5Xv.js";
6
2
  import { markRaw } from "vue";
7
3
  const getDefaultView = (value) => {
@@ -143,10 +139,9 @@ const isTrackedMutation = (editor, mutation, batch) => {
143
139
  return isTrackedMutation(editor, parentMutation, batch);
144
140
  };
145
141
  const getActiveElement = () => {
146
- var _a2, _b2;
147
142
  let activeElement = document.activeElement;
148
- while ((activeElement == null ? void 0 : activeElement.shadowRoot) && ((_a2 = activeElement.shadowRoot) == null ? void 0 : _a2.activeElement)) {
149
- activeElement = (_b2 = activeElement == null ? void 0 : activeElement.shadowRoot) == null ? void 0 : _b2.activeElement;
143
+ while (activeElement?.shadowRoot && activeElement.shadowRoot?.activeElement) {
144
+ activeElement = activeElement?.shadowRoot?.activeElement;
150
145
  }
151
146
  return activeElement;
152
147
  };
@@ -171,14 +166,14 @@ const IS_FIREFOX_LEGACY = typeof navigator !== "undefined" && /^(?!.*Seamonkey)(
171
166
  const IS_UC_MOBILE = typeof navigator !== "undefined" && /.*UCBrowser/.test(navigator.userAgent);
172
167
  const IS_WECHATBROWSER = typeof navigator !== "undefined" && /.*Wechat/.test(navigator.userAgent) && !/.*MacWechat/.test(navigator.userAgent);
173
168
  const CAN_USE_DOM = !!(typeof window !== "undefined" && typeof window.document !== "undefined" && typeof window.document.createElement !== "undefined");
174
- typeof navigator !== "undefined" && /Safari/.test(navigator.userAgent) && /Version\/(\d+)/.test(navigator.userAgent) && (((_a = navigator.userAgent.match(/Version\/(\d+)/)) == null ? void 0 : _a[1]) ? parseInt((_b = navigator.userAgent.match(/Version\/(\d+)/)) == null ? void 0 : _b[1], 10) < 17 : false);
169
+ typeof navigator !== "undefined" && /Safari/.test(navigator.userAgent) && /Version\/(\d+)/.test(navigator.userAgent) && (navigator.userAgent.match(/Version\/(\d+)/)?.[1] ? parseInt(navigator.userAgent.match(/Version\/(\d+)/)?.[1], 10) < 17 : false);
175
170
  const HAS_BEFORE_INPUT_SUPPORT = (!IS_CHROME_LEGACY || !IS_ANDROID_CHROME_LEGACY) && !IS_EDGE_LEGACY && // globalThis is undefined in older browsers
176
171
  typeof globalThis !== "undefined" && globalThis.InputEvent && // @ts-ignore The `getTargetRanges` property isn't recognized.
177
172
  typeof globalThis.InputEvent.prototype.getTargetRanges === "function";
178
173
  let n = 0;
179
174
  class Key {
175
+ id;
180
176
  constructor() {
181
- __publicField(this, "id");
182
177
  this.id = `${n++}`;
183
178
  }
184
179
  }
@@ -200,13 +195,12 @@ const MARK_PLACEHOLDER_SYMBOL = Symbol(
200
195
  "mark-placeholder"
201
196
  );
202
197
  function compatEmptyNode([node, offset]) {
203
- var _a2;
204
198
  if (node.nodeType !== 3 || node.textContent !== "") {
205
199
  return [node, offset];
206
200
  } else {
207
201
  const isLeft = node.previousSibling === null;
208
202
  let el = node[isLeft ? "nextSibling" : "previousSibling"];
209
- while (el == null ? void 0 : el.firstChild) {
203
+ while (el?.firstChild) {
210
204
  el = isLeft ? el.firstChild : el.lastChild;
211
205
  }
212
206
  if (!el) {
@@ -216,7 +210,7 @@ function compatEmptyNode([node, offset]) {
216
210
  )}`
217
211
  );
218
212
  }
219
- return [el, isLeft ? 0 : ((_a2 = el.textContent) == null ? void 0 : _a2.length) || 0];
213
+ return [el, isLeft ? 0 : el.textContent?.length || 0];
220
214
  }
221
215
  }
222
216
  const DOMEditor = {
@@ -335,8 +329,8 @@ const DOMEditor = {
335
329
  if (editor.selection && root instanceof Document) {
336
330
  const domSelection = getSelection(root);
337
331
  const domRange = DOMEditor.toDOMRange(editor, editor.selection);
338
- domSelection == null ? void 0 : domSelection.removeAllRanges();
339
- domSelection == null ? void 0 : domSelection.addRange(domRange);
332
+ domSelection?.removeAllRanges();
333
+ domSelection?.addRange(domRange);
340
334
  }
341
335
  if (!editor.selection) {
342
336
  Transforms.select(editor, Editor.start(editor, []));
@@ -395,7 +389,7 @@ const DOMEditor = {
395
389
  setFragmentData: (editor, data, originEvent) => editor.setFragmentData(data, originEvent),
396
390
  toDOMNode: (editor, node) => {
397
391
  const KEY_TO_ELEMENT = EDITOR_TO_KEY_TO_ELEMENT.get(editor);
398
- const domNode = Editor.isEditor(node) ? EDITOR_TO_ELEMENT.get(editor) : KEY_TO_ELEMENT == null ? void 0 : KEY_TO_ELEMENT.get(DOMEditor.findKey(editor, node));
392
+ const domNode = Editor.isEditor(node) ? EDITOR_TO_ELEMENT.get(editor) : KEY_TO_ELEMENT?.get(DOMEditor.findKey(editor, node));
399
393
  if (!domNode) {
400
394
  throw new Error(
401
395
  `Cannot resolve a DOM node from Slate node: ${Scrubber.stringify(node)}`
@@ -404,7 +398,6 @@ const DOMEditor = {
404
398
  return domNode;
405
399
  },
406
400
  toDOMPoint: (editor, point) => {
407
- var _a2;
408
401
  const [node] = Editor.node(editor, point.path);
409
402
  const el = DOMEditor.toDOMNode(editor, node);
410
403
  let domPoint;
@@ -425,7 +418,7 @@ const DOMEditor = {
425
418
  const trueLength = attr == null ? length : parseInt(attr, 10);
426
419
  const end = start + trueLength;
427
420
  const nextText = texts[i + 1];
428
- if (point.offset === end && (nextText == null ? void 0 : nextText.hasAttribute("data-slate-mark-placeholder"))) {
421
+ if (point.offset === end && nextText?.hasAttribute("data-slate-mark-placeholder")) {
429
422
  const domText = nextText.childNodes[0];
430
423
  domPoint = [
431
424
  // COMPAT: If we don't explicity set the dom point to be on the actual
@@ -434,7 +427,7 @@ const DOMEditor = {
434
427
  // selection to return incorrect zero values (https://bugs.chromium.org/p/chromium/issues/detail?id=435438)
435
428
  // which will cause issues when scrolling to it.
436
429
  domText instanceof globalThis.Text ? domText : nextText,
437
- ((_a2 = nextText.textContent) == null ? void 0 : _a2.startsWith("\uFEFF")) ? 1 : 0
430
+ nextText.textContent?.startsWith("\uFEFF") ? 1 : 0
438
431
  ];
439
432
  break;
440
433
  }
@@ -483,7 +476,6 @@ const DOMEditor = {
483
476
  return node;
484
477
  },
485
478
  toSlatePoint: (editor, domPoint, options) => {
486
- var _a2, _b2;
487
479
  const { exactMatch, suppressThrow, searchDirection = "backward" } = options;
488
480
  const [nearestNode, nearestOffset] = compatEmptyNode(
489
481
  exactMatch ? domPoint : normalizeDOMPoint(domPoint)
@@ -559,12 +551,12 @@ const DOMEditor = {
559
551
  if (searchDirection === "forward") {
560
552
  const leafNodes = [
561
553
  ...getLeafNodes(elementNode),
562
- ...getLeafNodes(elementNode == null ? void 0 : elementNode.nextElementSibling)
554
+ ...getLeafNodes(elementNode?.nextElementSibling)
563
555
  ];
564
556
  leafNode = leafNodes.find((leaf) => isAfter(nonEditableNode, leaf)) ?? null;
565
557
  } else {
566
558
  const leafNodes = [
567
- ...getLeafNodes(elementNode == null ? void 0 : elementNode.previousElementSibling),
559
+ ...getLeafNodes(elementNode?.previousElementSibling),
568
560
  ...getLeafNodes(elementNode)
569
561
  ];
570
562
  leafNode = leafNodes.findLast((leaf) => isBefore(nonEditableNode, leaf)) ?? null;
@@ -584,7 +576,7 @@ const DOMEditor = {
584
576
  }
585
577
  if (domNode && offset === domNode.textContent.length && // COMPAT: Android IMEs might remove the zero width space while composing,
586
578
  // and we don't add it for line-breaks.
587
- IS_ANDROID && domNode.getAttribute("data-slate-zero-width") === "z" && ((_a2 = domNode.textContent) == null ? void 0 : _a2.startsWith("\uFEFF")) && // COMPAT: If the parent node is a Slate zero-width space, editor is
579
+ IS_ANDROID && domNode.getAttribute("data-slate-zero-width") === "z" && domNode.textContent?.startsWith("\uFEFF") && // COMPAT: If the parent node is a Slate zero-width space, editor is
588
580
  // because the text node should have no characters. However, during IME
589
581
  // composition the ASCII characters will be prepended to the zero-width
590
582
  // space, so subtract 1 from the offset to account for the zero-width
@@ -592,7 +584,7 @@ const DOMEditor = {
592
584
  (parentNode.hasAttribute("data-slate-zero-width") || // COMPAT: In Firefox, `range.cloneContents()` returns an extra trailing '\n'
593
585
  // when the document ends with a new-line character. This results in the offset
594
586
  // length being off by one, so we need to subtract one to account for this.
595
- IS_FIREFOX && ((_b2 = domNode.textContent) == null ? void 0 : _b2.endsWith("\n\n")))) {
587
+ IS_FIREFOX && domNode.textContent?.endsWith("\n\n"))) {
596
588
  offset--;
597
589
  }
598
590
  }
@@ -623,7 +615,6 @@ const DOMEditor = {
623
615
  return { path, offset };
624
616
  },
625
617
  toSlateRange: (editor, domRange, options) => {
626
- var _a2, _b2;
627
618
  const { exactMatch, suppressThrow } = options;
628
619
  const el = isDOMSelection(domRange) ? domRange.anchorNode : domRange.startContainer;
629
620
  let anchorNode;
@@ -639,17 +630,17 @@ const DOMEditor = {
639
630
  focusOffset = domRange.focusOffset;
640
631
  if (IS_FIREFOX) {
641
632
  const anchorAttr = anchorNode instanceof HTMLElement ? anchorNode.attributes : null;
642
- if (anchorAttr == null ? void 0 : anchorAttr.getNamedItem("data-slate-editor")) {
633
+ if (anchorAttr?.getNamedItem("data-slate-editor")) {
643
634
  while (anchorNode instanceof HTMLElement && anchorNode.firstElementChild) {
644
635
  anchorNode = anchorNode.firstElementChild;
645
636
  }
646
637
  while (focusNode instanceof HTMLElement && focusNode.lastElementChild) {
647
638
  focusNode = focusNode.lastElementChild;
648
639
  }
649
- anchorNode = anchorNode == null ? void 0 : anchorNode.firstChild;
640
+ anchorNode = anchorNode?.firstChild;
650
641
  anchorOffset = 0;
651
- focusNode = focusNode == null ? void 0 : focusNode.lastChild;
652
- focusOffset = ((_a2 = focusNode == null ? void 0 : focusNode.textContent) == null ? void 0 : _a2.length) || 0;
642
+ focusNode = focusNode?.lastChild;
643
+ focusOffset = focusNode?.textContent?.length || 0;
653
644
  } else {
654
645
  if (anchorNode) {
655
646
  const [el2, offset] = compatEmptyNode([anchorNode, anchorOffset]);
@@ -696,7 +687,7 @@ const DOMEditor = {
696
687
  `Cannot resolve a Slate range from DOM range: ${domRange}`
697
688
  );
698
689
  }
699
- if (IS_FIREFOX && ((_b2 = focusNode.textContent) == null ? void 0 : _b2.endsWith("\n\n")) && focusOffset === focusNode.textContent.length) {
690
+ if (IS_FIREFOX && focusNode.textContent?.endsWith("\n\n") && focusOffset === focusNode.textContent.length) {
700
691
  focusOffset--;
701
692
  }
702
693
  const anchor = DOMEditor.toSlatePoint(editor, [anchorNode, anchorOffset], {
@@ -723,56 +714,56 @@ const DOMEditor = {
723
714
  }
724
715
  };
725
716
  class ChunkTreeHelper {
717
+ /**
718
+ * The root of the chunk tree
719
+ */
720
+ root;
721
+ /**
722
+ * The ideal size of a chunk
723
+ */
724
+ chunkSize;
725
+ /**
726
+ * Whether debug mode is enabled
727
+ *
728
+ * If enabled, the pointer state will be checked for internal consistency
729
+ * after each mutating operation.
730
+ */
731
+ debug;
732
+ /**
733
+ * Whether the traversal has reached the end of the chunk tree
734
+ *
735
+ * When this is true, the pointerChunk and pointerIndex point to the last
736
+ * top-level node in the chunk tree, although pointerNode returns null.
737
+ */
738
+ reachedEnd;
739
+ /**
740
+ * The chunk containing the current node
741
+ */
742
+ pointerChunk;
743
+ /**
744
+ * The index of the current node within pointerChunk
745
+ *
746
+ * Can be -1 to indicate that the pointer is before the start of the tree.
747
+ */
748
+ pointerIndex;
749
+ /**
750
+ * Similar to a Slate path; tracks the path of pointerChunk relative to the
751
+ * root.
752
+ *
753
+ * Used to move the pointer from the current chunk to the parent chunk more
754
+ * efficiently.
755
+ */
756
+ pointerIndexStack;
757
+ /**
758
+ * Indexing the current chunk's children has a slight time cost, which adds up
759
+ * when traversing very large trees, so the current node is cached.
760
+ *
761
+ * A value of undefined means that the current node is not cached. This
762
+ * property must be set to undefined whenever the pointer is moved, unless
763
+ * the pointer is guaranteed to point to the same node that it did previously.
764
+ */
765
+ cachedPointerNode;
726
766
  constructor(chunkTree, { chunkSize, debug }) {
727
- /**
728
- * The root of the chunk tree
729
- */
730
- __publicField(this, "root");
731
- /**
732
- * The ideal size of a chunk
733
- */
734
- __publicField(this, "chunkSize");
735
- /**
736
- * Whether debug mode is enabled
737
- *
738
- * If enabled, the pointer state will be checked for internal consistency
739
- * after each mutating operation.
740
- */
741
- __publicField(this, "debug");
742
- /**
743
- * Whether the traversal has reached the end of the chunk tree
744
- *
745
- * When this is true, the pointerChunk and pointerIndex point to the last
746
- * top-level node in the chunk tree, although pointerNode returns null.
747
- */
748
- __publicField(this, "reachedEnd");
749
- /**
750
- * The chunk containing the current node
751
- */
752
- __publicField(this, "pointerChunk");
753
- /**
754
- * The index of the current node within pointerChunk
755
- *
756
- * Can be -1 to indicate that the pointer is before the start of the tree.
757
- */
758
- __publicField(this, "pointerIndex");
759
- /**
760
- * Similar to a Slate path; tracks the path of pointerChunk relative to the
761
- * root.
762
- *
763
- * Used to move the pointer from the current chunk to the parent chunk more
764
- * efficiently.
765
- */
766
- __publicField(this, "pointerIndexStack");
767
- /**
768
- * Indexing the current chunk's children has a slight time cost, which adds up
769
- * when traversing very large trees, so the current node is cached.
770
- *
771
- * A value of undefined means that the current node is not cached. This
772
- * property must be set to undefined whenever the pointer is moved, unless
773
- * the pointer is guaranteed to point to the same node that it did previously.
774
- */
775
- __publicField(this, "cachedPointerNode");
776
767
  this.root = chunkTree;
777
768
  this.chunkSize = chunkSize;
778
769
  this.debug = debug ?? false;
@@ -1003,8 +994,7 @@ class ChunkTreeHelper {
1003
994
  * Otherwise, place the pointer on the first node.
1004
995
  */
1005
996
  enterChunk(end) {
1006
- var _a2;
1007
- if (((_a2 = this.pointerNode) == null ? void 0 : _a2.type) !== "chunk") {
997
+ if (this.pointerNode?.type !== "chunk") {
1008
998
  throw new Error("Cannot enter non-chunk");
1009
999
  }
1010
1000
  this.pointerIndexStack.push(this.pointerIndex);
@@ -1024,8 +1014,7 @@ class ChunkTreeHelper {
1024
1014
  * Otherwise, place the pointer on the first node.
1025
1015
  */
1026
1016
  enterChunkUntilLeaf(end) {
1027
- var _a2;
1028
- while (((_a2 = this.pointerNode) == null ? void 0 : _a2.type) === "chunk") {
1017
+ while (this.pointerNode?.type === "chunk") {
1029
1018
  this.enterChunk(end);
1030
1019
  }
1031
1020
  }
@@ -1124,20 +1113,20 @@ class ChunkTreeHelper {
1124
1113
  }
1125
1114
  }
1126
1115
  class ChildrenHelper {
1116
+ editor;
1117
+ children;
1118
+ /**
1119
+ * Sparse array of Slate node keys, each index corresponding to an index in
1120
+ * the children array
1121
+ *
1122
+ * Fetching the key for a Slate node is expensive, so we cache them here.
1123
+ */
1124
+ cachedKeys;
1125
+ /**
1126
+ * The index of the next node to be read in the children array
1127
+ */
1128
+ pointerIndex;
1127
1129
  constructor(editor, children) {
1128
- __publicField(this, "editor");
1129
- __publicField(this, "children");
1130
- /**
1131
- * Sparse array of Slate node keys, each index corresponding to an index in
1132
- * the children array
1133
- *
1134
- * Fetching the key for a Slate node is expensive, so we cache them here.
1135
- */
1136
- __publicField(this, "cachedKeys");
1137
- /**
1138
- * The index of the next node to be read in the children array
1139
- */
1140
- __publicField(this, "pointerIndex");
1141
1130
  this.editor = editor;
1142
1131
  this.children = children;
1143
1132
  this.cachedKeys = markRaw(new Array(children.length));
@@ -1249,17 +1238,17 @@ const reconcileChildren = (editor, {
1249
1238
  );
1250
1239
  chunkTreeHelper.insertBefore(leavesToInsert);
1251
1240
  insertedChildren.forEach((node, relativeIndex) => {
1252
- onInsert == null ? void 0 : onInsert(node, insertedChildrenStartIndex + relativeIndex);
1241
+ onInsert?.(node, insertedChildrenStartIndex + relativeIndex);
1253
1242
  });
1254
1243
  }
1255
1244
  const matchingChildIndex = childrenHelper.pointerIndex - 1;
1256
1245
  if (treeLeaf.node !== matchingChild) {
1257
1246
  treeLeaf.node = matchingChild;
1258
- onUpdate == null ? void 0 : onUpdate(matchingChild, matchingChildIndex);
1247
+ onUpdate?.(matchingChild, matchingChildIndex);
1259
1248
  }
1260
1249
  if (treeLeaf.index !== matchingChildIndex) {
1261
1250
  treeLeaf.index = matchingChildIndex;
1262
- onIndexChange == null ? void 0 : onIndexChange(matchingChild, matchingChildIndex);
1251
+ onIndexChange?.(matchingChild, matchingChildIndex);
1263
1252
  }
1264
1253
  }
1265
1254
  if (!childrenHelper.reachedEnd) {
@@ -1271,7 +1260,7 @@ const reconcileChildren = (editor, {
1271
1260
  chunkTreeHelper.returnToPreviousLeaf();
1272
1261
  chunkTreeHelper.insertAfter(leavesToInsert);
1273
1262
  remainingChildren.forEach((node, relativeIndex) => {
1274
- onInsert == null ? void 0 : onInsert(node, childrenHelper.pointerIndex + relativeIndex);
1263
+ onInsert?.(node, childrenHelper.pointerIndex + relativeIndex);
1275
1264
  });
1276
1265
  }
1277
1266
  chunkTree.movedNodeKeys.clear();
@@ -1,28 +1,25 @@
1
- var __defProp = Object.defineProperty;
2
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
- var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
4
1
  import { t as toRawWeakMap, R as Range, N as Node, T as Text, a as Element, d as isObject } from "./batch-dirty-paths-9ixbU5Xv.js";
5
- import { c as createEditor$1 } from "./create-editor-D7Z9o-3p.js";
2
+ import { c as createEditor$1 } from "./create-editor-CDo9JOV_.js";
6
3
  import "vue";
7
4
  const ANCHOR = new toRawWeakMap();
8
5
  const FOCUS = new toRawWeakMap();
9
6
  class Token {
10
7
  }
11
8
  class AnchorToken extends Token {
9
+ offset;
10
+ path;
12
11
  constructor(props = {}) {
13
12
  super();
14
- __publicField(this, "offset");
15
- __publicField(this, "path");
16
13
  const { offset, path } = props;
17
14
  this.offset = offset;
18
15
  this.path = path;
19
16
  }
20
17
  }
21
18
  class FocusToken extends Token {
19
+ offset;
20
+ path;
22
21
  constructor(props = {}) {
23
22
  super();
24
- __publicField(this, "offset");
25
- __publicField(this, "path");
26
23
  const { offset, path } = props;
27
24
  this.offset = offset;
28
25
  this.path = path;
package/dist/index.js CHANGED
@@ -1,9 +1,9 @@
1
- import { S as SLATE_USE_ELEMENT, u as useEditor, a as SLATE_USE_SELECTION } from "./use-focused-5BbdVK79.js";
2
- import { g, D, c, e, f, d, E, b, h, i, j } from "./use-focused-5BbdVK79.js";
1
+ import { S as SLATE_USE_ELEMENT, u as useEditor, a as SLATE_USE_SELECTION } from "./use-focused-CVsb6MZ7.js";
2
+ import { g, D, c, e, f, d, E, b, h, i, j } from "./use-focused-CVsb6MZ7.js";
3
3
  import { E as Editor, R as Range } from "./batch-dirty-paths-9ixbU5Xv.js";
4
4
  import { t } from "./batch-dirty-paths-9ixbU5Xv.js";
5
5
  import { inject, computed } from "vue";
6
- import { D as DOMEditor } from "./hotkeys-CoLjwqzn.js";
6
+ import { D as DOMEditor } from "./hotkeys-WTh2lFjJ.js";
7
7
  const useElement = () => {
8
8
  const element = inject(SLATE_USE_ELEMENT);
9
9
  if (element === void 0) {
@@ -21,7 +21,7 @@ const useSelected = () => {
21
21
  const element = useElementIf();
22
22
  const editor = useEditor();
23
23
  return computed(() => {
24
- if (!editor.selection || !(element == null ? void 0 : element.value)) return false;
24
+ if (!editor.selection || !element?.value) return false;
25
25
  const path = DOMEditor.findPath(editor, element.value);
26
26
  const range = Editor.range(editor, path);
27
27
  return !!Range.intersection(range, editor.selection);
@@ -1,6 +1,6 @@
1
1
  import { h, defineComponent, provide, ref, computed, onMounted, onUnmounted, renderSlot, inject, watch, renderList, onUpdated, reactive, useAttrs, toRaw } from "vue";
2
2
  import { R as Range, N as Node, S as Scrubber, T as Text, P as Path, E as Editor, a as Element, c as Transforms } from "./batch-dirty-paths-9ixbU5Xv.js";
3
- import { I as IS_ANDROID, p as isDOMNode, D as DOMEditor, Q as MARK_PLACEHOLDER_SYMBOL, d as EDITOR_TO_ON_CHANGE, w as IS_FIREFOX, z as IS_WEBKIT, E as EDITOR_TO_KEY_TO_ELEMENT, L as ELEMENT_TO_NODE, R as NODE_TO_ELEMENT, S as NODE_TO_INDEX, T as NODE_TO_PARENT, r as reconcileChildren, e as applyStringDiff, q as isDOMSelection, n as normalizeStringDiff, P as IS_READ_ONLY, h as getDefaultView, J as EDITOR_TO_WINDOW, G as EDITOR_TO_ELEMENT, H as HAS_BEFORE_INPUT_SUPPORT, C as CAN_USE_DOM, f as getActiveElement, j as getSelection, O as IS_FOCUSED, s as isPlainTextOnlyPaste, M as IS_COMPOSING, F as Hotkeys, v as IS_CHROME, x as IS_FIREFOX_LEGACY, y as IS_IOS, B as IS_WECHATBROWSER, A as IS_UC_MOBILE, a as EDITOR_TO_USER_MARKS, o as isDOMElement, b as EDITOR_TO_USER_SELECTION } from "./hotkeys-CoLjwqzn.js";
3
+ import { I as IS_ANDROID, p as isDOMNode, D as DOMEditor, Q as MARK_PLACEHOLDER_SYMBOL, d as EDITOR_TO_ON_CHANGE, w as IS_FIREFOX, z as IS_WEBKIT, E as EDITOR_TO_KEY_TO_ELEMENT, L as ELEMENT_TO_NODE, R as NODE_TO_ELEMENT, S as NODE_TO_INDEX, T as NODE_TO_PARENT, r as reconcileChildren, e as applyStringDiff, q as isDOMSelection, n as normalizeStringDiff, P as IS_READ_ONLY, h as getDefaultView, J as EDITOR_TO_WINDOW, G as EDITOR_TO_ELEMENT, H as HAS_BEFORE_INPUT_SUPPORT, C as CAN_USE_DOM, f as getActiveElement, j as getSelection, O as IS_FOCUSED, s as isPlainTextOnlyPaste, M as IS_COMPOSING, F as Hotkeys, v as IS_CHROME, x as IS_FIREFOX_LEGACY, y as IS_IOS, B as IS_WECHATBROWSER, A as IS_UC_MOBILE, a as EDITOR_TO_USER_MARKS, o as isDOMElement, b as EDITOR_TO_USER_SELECTION } from "./hotkeys-WTh2lFjJ.js";
4
4
  const SLATE_USE_EDITOR = Symbol("SLATE_USE_EDITOR");
5
5
  const SLATE_USE_ELEMENT = Symbol("SLATE_USE_ELEMENT");
6
6
  const SLATE_USE_FOCUSED = Symbol("SLATE_USE_FOCUSED");
@@ -151,7 +151,7 @@ const DEFAULT_ELEMENT_RENDER = ({
151
151
  children,
152
152
  editor
153
153
  }) => {
154
- const tag = (editor == null ? void 0 : editor.isInline(element)) ? "span" : "div";
154
+ const tag = editor?.isInline(element) ? "span" : "div";
155
155
  return h(
156
156
  tag,
157
157
  {
@@ -268,10 +268,9 @@ const Slate = defineComponent({
268
268
  document.addEventListener("focusin", focusCb);
269
269
  document.addEventListener("focusout", focusCb);
270
270
  EDITOR_TO_ON_CHANGE.set(editor, (options) => {
271
- var _a;
272
271
  emit("change", options);
273
272
  changeEffect.value++;
274
- switch ((_a = options == null ? void 0 : options.operation) == null ? void 0 : _a.type) {
273
+ switch (options?.operation?.type) {
275
274
  case "set_selection":
276
275
  emit("selectionchange", options);
277
276
  break;
@@ -491,15 +490,13 @@ const PlaceholderComp = defineComponent({
491
490
  onVnodeMounted(vNode) {
492
491
  if (vNode.el) {
493
492
  placeholderResizeObserver.value = new ResizeObserver(() => {
494
- var _a, _b;
495
- onPlaceholderResize((_b = (_a = vNode.el) == null ? void 0 : _a.getBoundingClientRect()) == null ? void 0 : _b.height);
493
+ onPlaceholderResize(vNode.el?.getBoundingClientRect()?.height);
496
494
  });
497
495
  placeholderResizeObserver.value.observe(vNode.el);
498
496
  }
499
497
  },
500
498
  onVnodeUnmounted() {
501
- var _a;
502
- (_a = placeholderResizeObserver.value) == null ? void 0 : _a.disconnect();
499
+ placeholderResizeObserver.value?.disconnect();
503
500
  placeholderResizeObserver.value = void 0;
504
501
  onPlaceholderResize();
505
502
  }
@@ -542,7 +539,7 @@ const TextComp = defineComponent({
542
539
  const key = DOMEditor.findKey(editor, text);
543
540
  if (spanRef.value) {
544
541
  const KEY_TO_ELEMENT = EDITOR_TO_KEY_TO_ELEMENT.get(editor);
545
- KEY_TO_ELEMENT == null ? void 0 : KEY_TO_ELEMENT.set(key, spanRef.value);
542
+ KEY_TO_ELEMENT?.set(key, spanRef.value);
546
543
  ELEMENT_TO_NODE.set(spanRef.value, text);
547
544
  NODE_TO_ELEMENT.set(text, spanRef.value);
548
545
  }
@@ -631,11 +628,11 @@ const ElementComp = defineComponent({
631
628
  const key = DOMEditor.findKey(editor, element);
632
629
  const KEY_TO_ELEMENT = EDITOR_TO_KEY_TO_ELEMENT.get(editor);
633
630
  if (ref2) {
634
- KEY_TO_ELEMENT == null ? void 0 : KEY_TO_ELEMENT.set(key, ref2);
631
+ KEY_TO_ELEMENT?.set(key, ref2);
635
632
  NODE_TO_ELEMENT.set(element, ref2);
636
633
  ELEMENT_TO_NODE.set(ref2, element);
637
634
  } else {
638
- KEY_TO_ELEMENT == null ? void 0 : KEY_TO_ELEMENT.delete(key);
635
+ KEY_TO_ELEMENT?.delete(key);
639
636
  NODE_TO_ELEMENT.delete(element);
640
637
  }
641
638
  }
@@ -675,9 +672,8 @@ const ElementComp = defineComponent({
675
672
  return h(tag, VOID_CHILDREN_ATTRS, h(TextComp, { element, text }));
676
673
  });
677
674
  IS_FIREFOX && onUpdated(() => {
678
- var _a;
679
- const nodes = (_a = elementRef.value) == null ? void 0 : _a.childNodes;
680
- if (!(nodes == null ? void 0 : nodes.length)) {
675
+ const nodes = elementRef.value?.childNodes;
676
+ if (!nodes?.length) {
681
677
  return;
682
678
  }
683
679
  const lastIndex = nodes.length - 1;
@@ -808,9 +804,8 @@ const useAndroidManager = (editableRef) => {
808
804
  let insertPositionHint = false;
809
805
  onMounted(() => {
810
806
  mutationObserver.value = new MutationObserver((mutations) => {
811
- var _a, _b, _c;
812
- (_a = mutationObserver.value) == null ? void 0 : _a.disconnect();
813
- (_b = mutationObserver.value) == null ? void 0 : _b.takeRecords();
807
+ mutationObserver.value?.disconnect();
808
+ mutationObserver.value?.takeRecords();
814
809
  mutations.reverse().forEach((mutation) => {
815
810
  if (mutation.type === "characterData") {
816
811
  return;
@@ -822,7 +817,7 @@ const useAndroidManager = (editableRef) => {
822
817
  mutation.target.removeChild(node);
823
818
  });
824
819
  });
825
- (_c = schedule.value) == null ? void 0 : _c.call(schedule);
820
+ schedule.value?.();
826
821
  schedule.value = void 0;
827
822
  });
828
823
  });
@@ -848,8 +843,7 @@ const useAndroidManager = (editableRef) => {
848
843
  });
849
844
  };
850
845
  const handleDOMBeforeInput = (event) => {
851
- var _a;
852
- (_a = mutationObserver.value) == null ? void 0 : _a.observe(
846
+ mutationObserver.value?.observe(
853
847
  editableRef.value,
854
848
  MUTATION_OBSERVER_CONFIG
855
849
  );
@@ -881,22 +875,27 @@ const useAndroidManager = (editableRef) => {
881
875
  }
882
876
  let canStoreDiff = true;
883
877
  if (type.startsWith("delete")) {
878
+ const direction2 = type.endsWith("Backward") ? "backward" : "forward";
879
+ let [start, end] = Range.edges(targetRange);
880
+ let [leaf, path] = Editor.leaf(editor, start.path);
884
881
  if (Range.isExpanded(targetRange)) {
885
- const [start2, end2] = Range.edges(targetRange);
886
- const leaf2 = Node.leaf(editor, start2.path);
887
- if (leaf2.text.length === start2.offset && end2.offset === 0) {
882
+ if (leaf.text.length === start.offset && end.offset === 0) {
888
883
  const next = Editor.next(editor, {
889
- at: start2.path,
884
+ at: start.path,
890
885
  match: Text.isText
891
886
  });
892
- if (next && Path.equals(next[1], end2.path)) {
893
- targetRange = { anchor: end2, focus: end2 };
887
+ if (next && Path.equals(next[1], end.path)) {
888
+ if (direction2 === "backward") {
889
+ targetRange = { anchor: end, focus: end };
890
+ start = end;
891
+ [leaf, path] = next;
892
+ } else {
893
+ targetRange = { anchor: start, focus: start };
894
+ end = start;
895
+ }
894
896
  }
895
897
  }
896
898
  }
897
- const direction2 = type.endsWith("Backward") ? "backward" : "forward";
898
- const [start, end] = Range.edges(targetRange);
899
- const [leaf] = Editor.leaf(editor, start.path);
900
899
  const diff = {
901
900
  text: "",
902
901
  start: start.offset,
@@ -945,7 +944,7 @@ const useAndroidManager = (editableRef) => {
945
944
  }
946
945
  case "deleteContentBackward": {
947
946
  const { anchor } = targetRange;
948
- const nativeCollapsed = isDOMSelection(nativeTargetRange) ? nativeTargetRange.isCollapsed : !!(nativeTargetRange == null ? void 0 : nativeTargetRange.collapsed);
947
+ const nativeCollapsed = isDOMSelection(nativeTargetRange) ? nativeTargetRange.isCollapsed : !!nativeTargetRange?.collapsed;
949
948
  if (canStoreDiff && nativeCollapsed && Range.isCollapsed(targetRange) && anchor.offset > 0) {
950
949
  return storeDiff(anchor.path, {
951
950
  text: "",
@@ -1115,9 +1114,9 @@ const Editable = defineComponent({
1115
1114
  const onPlaceholderResize = (h2) => placeholderHeight.value = h2;
1116
1115
  const processing = ref(false);
1117
1116
  const onDOMSelectionChange = (event) => {
1118
- const target = event == null ? void 0 : event.target;
1117
+ const target = event?.target;
1119
1118
  const targetElement = target instanceof HTMLElement ? target : null;
1120
- const targetTagName = targetElement == null ? void 0 : targetElement.tagName;
1119
+ const targetTagName = targetElement?.tagName;
1121
1120
  if (targetTagName === "INPUT" || targetTagName === "TEXTAREA") {
1122
1121
  return;
1123
1122
  }
@@ -1193,7 +1192,6 @@ const Editable = defineComponent({
1193
1192
  return false;
1194
1193
  });
1195
1194
  const setDomSelection = () => {
1196
- var _a;
1197
1195
  const root = DOMEditor.findDocumentOrShadowRoot(editor);
1198
1196
  const domSelection = getSelection(root);
1199
1197
  if (!domSelection) {
@@ -1232,7 +1230,7 @@ const Editable = defineComponent({
1232
1230
  if (!hasMarkPlaceholder.value) {
1233
1231
  return;
1234
1232
  }
1235
- if ((_a = anchorNode == null ? void 0 : anchorNode.parentElement) == null ? void 0 : _a.hasAttribute(
1233
+ if (anchorNode?.parentElement?.hasAttribute(
1236
1234
  "data-slate-mark-placeholder"
1237
1235
  )) {
1238
1236
  return;
@@ -1287,13 +1285,12 @@ const Editable = defineComponent({
1287
1285
  });
1288
1286
  const stoppedDragging = () => state.isDraggingInternally = false;
1289
1287
  onMounted(() => {
1290
- var _a;
1291
1288
  const window2 = DOMEditor.getWindow(editor);
1292
1289
  window2.document.addEventListener("selectionchange", onDOMSelectionChange);
1293
1290
  window2.document.addEventListener("dragend", stoppedDragging);
1294
1291
  window2.document.addEventListener("drop", stoppedDragging);
1295
1292
  if (autoFocus) {
1296
- (_a = editableRef.value) == null ? void 0 : _a.focus();
1293
+ editableRef.value?.focus();
1297
1294
  }
1298
1295
  });
1299
1296
  onUnmounted(() => {
@@ -1307,7 +1304,6 @@ const Editable = defineComponent({
1307
1304
  });
1308
1305
  const deferredOperations = ref([]);
1309
1306
  const onBeforeinput = (event) => {
1310
- var _a, _b, _c, _d, _e;
1311
1307
  if (HAS_BEFORE_INPUT_SUPPORT) {
1312
1308
  handleNativeHistoryEvents(editor, event);
1313
1309
  const el = DOMEditor.toDOMNode(editor, editor);
@@ -1341,7 +1337,7 @@ const Editable = defineComponent({
1341
1337
  }
1342
1338
  if (!readOnly && DOMEditor.hasEditableTarget(editor, event.target) && !isDOMEventHandled(event, attributes.onBeforeinput)) {
1343
1339
  if (IS_ANDROID) {
1344
- return (_a = androidManager.value) == null ? void 0 : _a.handleDOMBeforeInput(event);
1340
+ return androidManager.value?.handleDOMBeforeInput(event);
1345
1341
  }
1346
1342
  const { selection } = editor;
1347
1343
  const { inputType } = event;
@@ -1364,15 +1360,15 @@ const Editable = defineComponent({
1364
1360
  }
1365
1361
  const { anchor } = selection;
1366
1362
  const [node, offset] = DOMEditor.toDOMPoint(editor, anchor);
1367
- const anchorNode = (_b = node.parentElement) == null ? void 0 : _b.closest("a");
1363
+ const anchorNode = node.parentElement?.closest("a");
1368
1364
  const window2 = DOMEditor.getWindow(editor);
1369
1365
  if (native && anchorNode && DOMEditor.hasDOMNode(editor, anchorNode)) {
1370
- const lastText = window2 == null ? void 0 : window2.document.createTreeWalker(anchorNode, NodeFilter.SHOW_TEXT).lastChild();
1371
- if (lastText === node && ((_c = lastText.textContent) == null ? void 0 : _c.length) === offset) {
1366
+ const lastText = window2?.document.createTreeWalker(anchorNode, NodeFilter.SHOW_TEXT).lastChild();
1367
+ if (lastText === node && lastText.textContent?.length === offset) {
1372
1368
  native = false;
1373
1369
  }
1374
1370
  }
1375
- if (native && node.parentElement && ((_d = window2 == null ? void 0 : window2.getComputedStyle(node.parentElement)) == null ? void 0 : _d.whiteSpace) === "pre") {
1371
+ if (native && node.parentElement && window2?.getComputedStyle(node.parentElement)?.whiteSpace === "pre") {
1376
1372
  const block = Editor.above(editor, {
1377
1373
  at: anchor.path,
1378
1374
  match: (n2) => Element.isElement(n2) && Editor.isBlock(editor, n2)
@@ -1474,7 +1470,7 @@ const Editable = defineComponent({
1474
1470
  IS_COMPOSING.set(editor, false);
1475
1471
  }
1476
1472
  }
1477
- if ((data == null ? void 0 : data.constructor.name) === "DataTransfer") {
1473
+ if (data?.constructor.name === "DataTransfer") {
1478
1474
  DOMEditor.insertData(editor, data);
1479
1475
  } else if (typeof data === "string") {
1480
1476
  if (native) {
@@ -1488,7 +1484,7 @@ const Editable = defineComponent({
1488
1484
  break;
1489
1485
  }
1490
1486
  }
1491
- const toRestore = (_e = EDITOR_TO_USER_SELECTION.get(editor)) == null ? void 0 : _e.unref();
1487
+ const toRestore = EDITOR_TO_USER_SELECTION.get(editor)?.unref();
1492
1488
  EDITOR_TO_USER_SELECTION.delete(editor);
1493
1489
  if (toRestore && (!editor.selection || !Range.equals(editor.selection, toRestore))) {
1494
1490
  Transforms.select(editor, toRestore);
@@ -1538,7 +1534,7 @@ const Editable = defineComponent({
1538
1534
  }
1539
1535
  if (IS_WEBKIT) {
1540
1536
  const domSelection = getSelection(root);
1541
- domSelection == null ? void 0 : domSelection.removeAllRanges();
1537
+ domSelection?.removeAllRanges();
1542
1538
  }
1543
1539
  IS_FOCUSED.delete(editor);
1544
1540
  };
@@ -1556,7 +1552,7 @@ const Editable = defineComponent({
1556
1552
  match: (n2) => Element.isElement(n2) && Editor.isBlock(editor, n2),
1557
1553
  at: path
1558
1554
  });
1559
- blockPath = (block == null ? void 0 : block[1]) ?? path.slice(0, 1);
1555
+ blockPath = block?.[1] ?? path.slice(0, 1);
1560
1556
  }
1561
1557
  const range = Editor.range(editor, blockPath);
1562
1558
  Transforms.select(editor, range);
@@ -1922,10 +1918,7 @@ const Editable = defineComponent({
1922
1918
  () => HAS_BEFORE_INPUT_SUPPORT || !CAN_USE_DOM ? attributes.autocapitalize : void 0
1923
1919
  );
1924
1920
  const showPlaceholder = computed(
1925
- () => {
1926
- var _a;
1927
- return placeholder && ((_a = editor.children) == null ? void 0 : _a.length) === 1 && Array.from(Node.texts(editor)).length === 1 && Node.string(editor) === "" && !isComposing.value;
1928
- }
1921
+ () => placeholder && editor.children?.length === 1 && Array.from(Node.texts(editor)).length === 1 && Node.string(editor) === "" && !isComposing.value
1929
1922
  );
1930
1923
  provide(
1931
1924
  SLATE_INNER_PLACEHOLDER,
package/dist/yjs.js CHANGED
@@ -2,8 +2,8 @@ import { d as isObject, T as Text, N as Node, P as Path, E as Editor, t as toRaw
2
2
  import { toRaw, ref, onMounted, onUnmounted, watch, onUpdated, computed } from "vue";
3
3
  import { XmlText, YTextEvent, createRelativePositionFromTypeIndex, createAbsolutePositionFromRelativePosition, createRelativePositionFromJSON, decodeRelativePosition, encodeRelativePosition, UndoManager, compareRelativePositions } from "yjs";
4
4
  import { L as Location } from "./location-Df07ugyf.js";
5
- import { u as useEditor, i as useFocused } from "./use-focused-5BbdVK79.js";
6
- import { D as DOMEditor } from "./hotkeys-CoLjwqzn.js";
5
+ import { u as useEditor, i as useFocused } from "./use-focused-CVsb6MZ7.js";
6
+ import { D as DOMEditor } from "./hotkeys-WTh2lFjJ.js";
7
7
  function deepEquals(node, another) {
8
8
  for (const key in node) {
9
9
  const a = node[key];
@@ -158,7 +158,6 @@ function slatePathOffsetToYOffset(element, pathOffset) {
158
158
  return element.children.slice(0, pathOffset).reduce((yOffset, node) => yOffset + getSlateNodeYLength(node), 0);
159
159
  }
160
160
  function getYTarget(yRoot, slateRoot, path) {
161
- var _a;
162
161
  if (path.length === 0) {
163
162
  throw new Error("Path has to a have a length >= 1");
164
163
  }
@@ -174,7 +173,7 @@ function getYTarget(yRoot, slateRoot, path) {
174
173
  if (targetDelta.length > 1) {
175
174
  throw new Error("Path doesn't match yText, yTarget spans multiple nodes");
176
175
  }
177
- const yTarget = (_a = targetDelta[0]) == null ? void 0 : _a.insert;
176
+ const yTarget = targetDelta[0]?.insert;
178
177
  if (childPath.length > 0) {
179
178
  if (!(yTarget instanceof XmlText)) {
180
179
  throw new Error(
@@ -1174,8 +1173,7 @@ const CursorEditor = {
1174
1173
  }
1175
1174
  },
1176
1175
  cursorState(editor, clientId) {
1177
- var _a;
1178
- if (clientId === ((_a = editor.sharedRoot.doc) == null ? void 0 : _a.clientID) || !YjsEditor.connected(editor)) {
1176
+ if (clientId === editor.sharedRoot.doc?.clientID || !YjsEditor.connected(editor)) {
1179
1177
  return null;
1180
1178
  }
1181
1179
  const state = editor.awareness.getStates().get(clientId);
@@ -1195,8 +1193,7 @@ const CursorEditor = {
1195
1193
  Array.from(
1196
1194
  editor.awareness.getStates().entries(),
1197
1195
  ([id, state]) => {
1198
- var _a;
1199
- if (id === ((_a = editor.sharedRoot.doc) == null ? void 0 : _a.clientID) || !state) {
1196
+ if (id === editor.sharedRoot.doc?.clientID || !state) {
1200
1197
  return null;
1201
1198
  }
1202
1199
  return [
@@ -1242,12 +1239,11 @@ function withCursors(editor, awareness, {
1242
1239
  }
1243
1240
  };
1244
1241
  const awarenessChangeListener = (yEvent) => {
1245
- var _a;
1246
1242
  const listeners = CURSOR_CHANGE_EVENT_LISTENERS.get(e);
1247
1243
  if (!listeners) {
1248
1244
  return;
1249
1245
  }
1250
- const localId = (_a = e.sharedRoot.doc) == null ? void 0 : _a.clientID;
1246
+ const localId = e.sharedRoot.doc?.clientID;
1251
1247
  const event = {
1252
1248
  added: yEvent.added.filter((id) => id !== localId),
1253
1249
  removed: yEvent.removed.filter((id) => id !== localId),
@@ -1324,7 +1320,7 @@ function useRemoteCursorStates() {
1324
1320
  unsubscribe = subscribe();
1325
1321
  });
1326
1322
  onUnmounted(() => {
1327
- unsubscribe == null ? void 0 : unsubscribe();
1323
+ unsubscribe?.();
1328
1324
  });
1329
1325
  return cursors;
1330
1326
  }
@@ -1368,10 +1364,10 @@ function useUnsetCursorPositionOnBlur() {
1368
1364
  function useOnResize(_ref, onResize) {
1369
1365
  const observer = new ResizeObserver(onResize);
1370
1366
  onMounted(() => {
1371
- (_ref == null ? void 0 : _ref.value) && observer.observe(_ref.value);
1367
+ _ref?.value && observer.observe(_ref.value);
1372
1368
  });
1373
1369
  onUnmounted(() => {
1374
- (_ref == null ? void 0 : _ref.value) && observer.unobserve(_ref.value);
1370
+ _ref?.value && observer.unobserve(_ref.value);
1375
1371
  });
1376
1372
  }
1377
1373
  const CHILDREN_TO_CURSOR_STATE_TO_RANGE = new toRawWeakMap();
@@ -1480,8 +1476,8 @@ function useRemoteCursorOverlayPositions(containerRef, shouldGenerateOverlay) {
1480
1476
  return;
1481
1477
  }
1482
1478
  const containerRect = containerRef.value.getBoundingClientRect();
1483
- const xOffset = (containerRect == null ? void 0 : containerRect.x) ?? 0;
1484
- const yOffset = (containerRect == null ? void 0 : containerRect.y) ?? 0;
1479
+ const xOffset = containerRect?.x ?? 0;
1480
+ const yOffset = containerRect?.y ?? 0;
1485
1481
  let overlayPositionsChanged = Object.keys(overlayPositions.value).length !== Object.keys(cursorStates.value).length;
1486
1482
  const updated = Object.fromEntries(
1487
1483
  Object.entries(cursorStates.value).map(([key, state]) => {
@@ -1520,8 +1516,8 @@ function useRemoteCursorOverlayPositions(containerRef, shouldGenerateOverlay) {
1520
1516
  return {
1521
1517
  ...state,
1522
1518
  range,
1523
- caretPosition: (overlayPosition == null ? void 0 : overlayPosition.caretPosition) ?? null,
1524
- selectionRects: (overlayPosition == null ? void 0 : overlayPosition.selectionRects) ?? FROZEN_EMPTY_ARRAY
1519
+ caretPosition: overlayPosition?.caretPosition ?? null,
1520
+ selectionRects: overlayPosition?.selectionRects ?? FROZEN_EMPTY_ARRAY
1525
1521
  };
1526
1522
  })
1527
1523
  );
@@ -1577,7 +1573,7 @@ function useDecorateRemoteCursors(editor, carets) {
1577
1573
  unsubscribe = subscribe();
1578
1574
  });
1579
1575
  onUnmounted(() => {
1580
- unsubscribe == null ? void 0 : unsubscribe();
1576
+ unsubscribe?.();
1581
1577
  });
1582
1578
  return (entry) => {
1583
1579
  const [, path] = entry;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "slate-vue3",
3
- "version": "0.7.6",
3
+ "version": "0.7.7",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",
@@ -64,20 +64,20 @@
64
64
  "scroll-into-view-if-needed": "^3.1.0"
65
65
  },
66
66
  "peerDependencies": {
67
- "vue": "^3.5.13"
67
+ "vue": "^3.0.0"
68
68
  },
69
69
  "devDependencies": {
70
70
  "@faker-js/faker": "^9.8.0",
71
- "@liveblocks/client": "^2.24.3",
72
- "@liveblocks/yjs": "^2.24.3",
73
- "@playwright/test": "^1.53.0",
71
+ "@liveblocks/client": "^3.0.0",
72
+ "@liveblocks/yjs": "^3.0.0",
73
+ "@playwright/test": "^1.53.1",
74
74
  "@testing-library/vue": "^8.1.0",
75
75
  "@types/is-hotkey": "^0.1.10",
76
76
  "@types/is-url": "^1.2.32",
77
77
  "@types/lodash-es": "^4.17.12",
78
- "@types/node": "^24.0.1",
78
+ "@types/node": "^24.0.4",
79
79
  "@types/prismjs": "^1.26.5",
80
- "@vitejs/plugin-vue": "^5.2.4",
80
+ "@vitejs/plugin-vue": "^6.0.0",
81
81
  "babel-plugin-transform-regex": "^6.0.1",
82
82
  "image-extensions": "^1.1.0",
83
83
  "is-url": "^1.2.4",
@@ -88,10 +88,10 @@
88
88
  "remark-slate-transformer": "^0.9.0",
89
89
  "typescript": "~5.8.3",
90
90
  "unified": "^11.0.5",
91
- "vite": "^6.3.5",
91
+ "vite": "^7.0.0",
92
92
  "vite-plugin-babel": "^1.3.1",
93
93
  "vite-plugin-dts": "^4.5.4",
94
- "vitest": "^3.2.3",
94
+ "vitest": "^3.2.4",
95
95
  "vue-router": "^4.5.1",
96
96
  "yjs": "^13.6.27"
97
97
  },