@antdv-next/x 1.1.2-beta.5 → 1.1.2-beta.6

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/index.umd.js CHANGED
@@ -48,7 +48,7 @@
48
48
  shiki_dist_themes_vitesse_dark_mjs = __toESM(shiki_dist_themes_vitesse_dark_mjs);
49
49
  shiki_dist_themes_vitesse_light_mjs = __toESM(shiki_dist_themes_vitesse_light_mjs);
50
50
  //#region package.json
51
- var version = "1.1.2-beta.5";
51
+ var version = "1.1.2-beta.6";
52
52
  //#endregion
53
53
  //#region components/x-provider/context.ts
54
54
  var XProviderContextKey = Symbol("antdv-next-x-provider-context");
@@ -8652,38 +8652,56 @@
8652
8652
  }
8653
8653
  return null;
8654
8654
  };
8655
- const handleBackspaceDelete = (event) => {
8655
+ const handleDeleteOperation = (event, operationType) => {
8656
8656
  const selection = getSelection();
8657
- if (!selection || !selection.isCollapsed) return false;
8658
8657
  const editable = editableRef.value;
8659
- if (!editable) return false;
8658
+ if (!editable || !selection || selection.rangeCount === 0) return false;
8659
+ const range = selection.getRangeAt(0);
8660
8660
  const anchorNode = selection.anchorNode;
8661
- const offset = selection.anchorOffset;
8661
+ const focusOffset = selection.focusOffset;
8662
8662
  if (!anchorNode || !editable.contains(anchorNode)) return false;
8663
- const isSlotOrSkill = (node) => {
8664
- if (!(node instanceof HTMLElement)) return false;
8665
- const info = getNodeInfo(node);
8666
- return !!(info?.slotKey || info?.skillKey);
8667
- };
8668
- let previous = null;
8669
- if (anchorNode === editable) {
8670
- for (let i = offset - 1; i >= 0; i--) if (isSlotOrSkill(editable.childNodes[i])) {
8671
- previous = editable.childNodes[i];
8672
- break;
8663
+ if (anchorNode.nodeType === Node.TEXT_NODE && range) {
8664
+ const parentElement = anchorNode.parentNode;
8665
+ const nodeInfo = getNodeInfo(parentElement);
8666
+ const selectedText = range.toString();
8667
+ const textLength = anchorNode.textContent?.length ?? 0;
8668
+ const isFullTextSelected = textLength === selectedText.length;
8669
+ const isSingleCharAtEnd = textLength === 1 && focusOffset === 1;
8670
+ if (nodeInfo?.slotConfig?.type === "content" && (isFullTextSelected || isSingleCharAtEnd)) {
8671
+ event.preventDefault();
8672
+ parentElement.innerHTML = "";
8673
+ parentElement.innerText = "";
8674
+ return true;
8673
8675
  }
8674
- } else {
8675
- if (anchorNode.nodeType === Node.TEXT_NODE && offset > 0) return false;
8676
- let current = anchorNode.nodeType === Node.TEXT_NODE ? anchorNode.previousSibling : anchorNode.previousSibling;
8676
+ }
8677
+ const isIgnorableBoundaryNode = (node) => {
8678
+ if (node.nodeType === Node.TEXT_NODE) return !(node.textContent ?? "");
8679
+ if (!(node instanceof HTMLElement)) return true;
8680
+ if (node.tagName === "BR") return true;
8681
+ return !node.textContent;
8682
+ };
8683
+ const getPreviousSibling = () => {
8684
+ if (operationType !== "backspace") return null;
8685
+ if (anchorNode === editable) return editable.childNodes[focusOffset - 1] || null;
8686
+ if (focusOffset !== 0) return null;
8687
+ const outer = findOuterContainer(anchorNode);
8688
+ return (outer && editable.contains(outer) ? outer : anchorNode.nodeType === Node.TEXT_NODE ? anchorNode : anchorNode).previousSibling;
8689
+ };
8690
+ const findPreviousDeletableNode = (node) => {
8691
+ let current = node;
8677
8692
  while (current) {
8678
- if (isSlotOrSkill(current)) {
8679
- previous = current;
8680
- break;
8693
+ if (current instanceof HTMLElement) {
8694
+ const nodeInfo = getNodeInfo(current);
8695
+ if (nodeInfo?.slotKey || nodeInfo?.skillKey) return current;
8681
8696
  }
8697
+ if (!isIgnorableBoundaryNode(current)) return null;
8682
8698
  current = current.previousSibling;
8683
8699
  }
8684
- }
8685
- if (!previous) return false;
8686
- const info = getNodeInfo(previous);
8700
+ return null;
8701
+ };
8702
+ const target = findPreviousDeletableNode(getPreviousSibling());
8703
+ if (!target) return false;
8704
+ const info = getNodeInfo(target);
8687
8705
  if (info?.slotKey) {
8688
8706
  event.preventDefault();
8689
8707
  removeSlot(info.slotKey, event);
@@ -8698,7 +8716,7 @@
8698
8716
  };
8699
8717
  const onInternalKeyDown = (event) => {
8700
8718
  if (senderCtx.value.onKeyDown?.(event) === false || keyLock.value || isComposing.value) return;
8701
- if (event.key === "Backspace" && handleBackspaceDelete(event)) return;
8719
+ if (event.key === "Backspace" && handleDeleteOperation(event, "backspace")) return;
8702
8720
  if (shouldSubmit(event)) {
8703
8721
  event.preventDefault();
8704
8722
  keyLock.value = true;
package/dist/package.js CHANGED
@@ -1,4 +1,4 @@
1
1
  //#region package.json
2
- var version = "1.1.2-beta.5";
2
+ var version = "1.1.2-beta.6";
3
3
  //#endregion
4
4
  export { version };
@@ -495,38 +495,56 @@ var SlotTextArea_default = /* @__PURE__ */ defineComponent({
495
495
  }
496
496
  return null;
497
497
  };
498
- const handleBackspaceDelete = (event) => {
498
+ const handleDeleteOperation = (event, operationType) => {
499
499
  const selection = getSelection();
500
- if (!selection || !selection.isCollapsed) return false;
501
500
  const editable = editableRef.value;
502
- if (!editable) return false;
501
+ if (!editable || !selection || selection.rangeCount === 0) return false;
502
+ const range = selection.getRangeAt(0);
503
503
  const anchorNode = selection.anchorNode;
504
- const offset = selection.anchorOffset;
504
+ const focusOffset = selection.focusOffset;
505
505
  if (!anchorNode || !editable.contains(anchorNode)) return false;
506
- const isSlotOrSkill = (node) => {
507
- if (!(node instanceof HTMLElement)) return false;
508
- const info = getNodeInfo(node);
509
- return !!(info?.slotKey || info?.skillKey);
510
- };
511
- let previous = null;
512
- if (anchorNode === editable) {
513
- for (let i = offset - 1; i >= 0; i--) if (isSlotOrSkill(editable.childNodes[i])) {
514
- previous = editable.childNodes[i];
515
- break;
506
+ if (anchorNode.nodeType === Node.TEXT_NODE && range) {
507
+ const parentElement = anchorNode.parentNode;
508
+ const nodeInfo = getNodeInfo(parentElement);
509
+ const selectedText = range.toString();
510
+ const textLength = anchorNode.textContent?.length ?? 0;
511
+ const isFullTextSelected = textLength === selectedText.length;
512
+ const isSingleCharAtEnd = textLength === 1 && focusOffset === 1;
513
+ if (nodeInfo?.slotConfig?.type === "content" && (isFullTextSelected || isSingleCharAtEnd)) {
514
+ event.preventDefault();
515
+ parentElement.innerHTML = "";
516
+ parentElement.innerText = "";
517
+ return true;
516
518
  }
517
- } else {
518
- if (anchorNode.nodeType === Node.TEXT_NODE && offset > 0) return false;
519
- let current = anchorNode.nodeType === Node.TEXT_NODE ? anchorNode.previousSibling : anchorNode.previousSibling;
519
+ }
520
+ const isIgnorableBoundaryNode = (node) => {
521
+ if (node.nodeType === Node.TEXT_NODE) return !(node.textContent ?? "");
522
+ if (!(node instanceof HTMLElement)) return true;
523
+ if (node.tagName === "BR") return true;
524
+ return !node.textContent;
525
+ };
526
+ const getPreviousSibling = () => {
527
+ if (operationType !== "backspace") return null;
528
+ if (anchorNode === editable) return editable.childNodes[focusOffset - 1] || null;
529
+ if (focusOffset !== 0) return null;
530
+ const outer = findOuterContainer(anchorNode);
531
+ return (outer && editable.contains(outer) ? outer : anchorNode.nodeType === Node.TEXT_NODE ? anchorNode : anchorNode).previousSibling;
532
+ };
533
+ const findPreviousDeletableNode = (node) => {
534
+ let current = node;
520
535
  while (current) {
521
- if (isSlotOrSkill(current)) {
522
- previous = current;
523
- break;
536
+ if (current instanceof HTMLElement) {
537
+ const nodeInfo = getNodeInfo(current);
538
+ if (nodeInfo?.slotKey || nodeInfo?.skillKey) return current;
524
539
  }
540
+ if (!isIgnorableBoundaryNode(current)) return null;
525
541
  current = current.previousSibling;
526
542
  }
527
- }
528
- if (!previous) return false;
529
- const info = getNodeInfo(previous);
543
+ return null;
544
+ };
545
+ const target = findPreviousDeletableNode(getPreviousSibling());
546
+ if (!target) return false;
547
+ const info = getNodeInfo(target);
530
548
  if (info?.slotKey) {
531
549
  event.preventDefault();
532
550
  removeSlot(info.slotKey, event);
@@ -541,7 +559,7 @@ var SlotTextArea_default = /* @__PURE__ */ defineComponent({
541
559
  };
542
560
  const onInternalKeyDown = (event) => {
543
561
  if (senderCtx.value.onKeyDown?.(event) === false || keyLock.value || isComposing.value) return;
544
- if (event.key === "Backspace" && handleBackspaceDelete(event)) return;
562
+ if (event.key === "Backspace" && handleDeleteOperation(event, "backspace")) return;
545
563
  if (shouldSubmit(event)) {
546
564
  event.preventDefault();
547
565
  keyLock.value = true;
@@ -2,7 +2,7 @@ import { r as e } from "./chunk-WQLz0Won.js";
2
2
  import { S as t, _ as n, a as r, b as i, c as a, d as o, f as s, g as c, h as l, i as u, l as d, m as f, n as p, o as m, p as h, r as g, s as _, t as v, u as y, v as b, x, y as S } from "./Serializer-y_SfSPKv.js";
3
3
  import { Comment as C, Fragment as w, Teleport as T, Text as E, Transition as D, TransitionGroup as O, cloneVNode as k, computed as A, createTextVNode as j, createVNode as M, defineComponent as N, getCurrentInstance as P, getCurrentScope as F, h as I, inject as L, isVNode as R, markRaw as ee, mergeDefaults as z, mergeProps as B, nextTick as V, onBeforeMount as te, onBeforeUnmount as H, onBeforeUpdate as ne, onMounted as re, onScopeDispose as ie, onUnmounted as ae, onUpdated as oe, provide as U, reactive as se, ref as W, render as ce, resolveDynamicComponent as le, shallowReactive as ue, shallowRef as G, toRaw as de, toRef as fe, toRefs as pe, toValue as me, triggerRef as he, unref as ge, useAttrs as _e, useId as ve, useSlots as ye, vShow as be, watch as K, watchEffect as xe, withDirectives as Se } from "vue";
4
4
  //#region package.json
5
- var Ce = "1.1.2-beta.5", we = "anticon", Te = {}, Ee = [
5
+ var Ce = "1.1.2-beta.6", we = "anticon", Te = {}, Ee = [
6
6
  "outlined",
7
7
  "borderless",
8
8
  "filled",
@@ -59223,39 +59223,38 @@ var YW = /* @__PURE__ */ N({
59223
59223
  n = n.parentNode;
59224
59224
  }
59225
59225
  return null;
59226
- }, G = (e) => {
59227
- let t = L();
59228
- if (!t || !t.isCollapsed) return !1;
59229
- let n = r.value;
59230
- if (!n) return !1;
59231
- let i = t.anchorNode, a = t.anchorOffset;
59232
- if (!i || !n.contains(i)) return !1;
59233
- let o = (e) => {
59234
- if (!(e instanceof HTMLElement)) return !1;
59235
- let t = _(e);
59236
- return !!(t?.slotKey || t?.skillKey);
59237
- }, s = null;
59238
- if (i === n) {
59239
- for (let e = a - 1; e >= 0; e--) if (o(n.childNodes[e])) {
59240
- s = n.childNodes[e];
59241
- break;
59242
- }
59243
- } else {
59244
- if (i.nodeType === Node.TEXT_NODE && a > 0) return !1;
59245
- let e = (i.nodeType, Node.TEXT_NODE, i.previousSibling);
59246
- for (; e;) {
59247
- if (o(e)) {
59248
- s = e;
59249
- break;
59226
+ }, G = (e, t) => {
59227
+ let n = L(), i = r.value;
59228
+ if (!i || !n || n.rangeCount === 0) return !1;
59229
+ let a = n.getRangeAt(0), o = n.anchorNode, s = n.focusOffset;
59230
+ if (!o || !i.contains(o)) return !1;
59231
+ if (o.nodeType === Node.TEXT_NODE && a) {
59232
+ let t = o.parentNode, n = _(t), r = a.toString(), i = o.textContent?.length ?? 0, c = i === r.length, l = i === 1 && s === 1;
59233
+ if (n?.slotConfig?.type === "content" && (c || l)) return e.preventDefault(), t.innerHTML = "", t.innerText = "", !0;
59234
+ }
59235
+ let c = (e) => e.nodeType === Node.TEXT_NODE ? !(e.textContent ?? "") : !(e instanceof HTMLElement) || e.tagName === "BR" ? !0 : !e.textContent, l = ((e) => {
59236
+ let t = e;
59237
+ for (; t;) {
59238
+ if (t instanceof HTMLElement) {
59239
+ let e = _(t);
59240
+ if (e?.slotKey || e?.skillKey) return t;
59250
59241
  }
59251
- e = e.previousSibling;
59242
+ if (!c(t)) return null;
59243
+ t = t.previousSibling;
59252
59244
  }
59253
- }
59254
- if (!s) return !1;
59255
- let c = _(s);
59256
- return c?.slotKey ? (e.preventDefault(), re(c.slotKey, e), !0) : c?.skillKey ? (e.preventDefault(), ie(!0), !0) : !1;
59245
+ return null;
59246
+ })((() => {
59247
+ if (t !== "backspace") return null;
59248
+ if (o === i) return i.childNodes[s - 1] || null;
59249
+ if (s !== 0) return null;
59250
+ let e = ue(o);
59251
+ return (e && i.contains(e) ? e : (o.nodeType, Node.TEXT_NODE, o)).previousSibling;
59252
+ })());
59253
+ if (!l) return !1;
59254
+ let u = _(l);
59255
+ return u?.slotKey ? (e.preventDefault(), re(u.slotKey, e), !0) : u?.skillKey ? (e.preventDefault(), ie(!0), !0) : !1;
59257
59256
  }, de = (e) => {
59258
- if (!(n.value.onKeyDown?.(e) === !1 || p.value || f.value) && !(e.key === "Backspace" && G(e))) {
59257
+ if (!(n.value.onKeyDown?.(e) === !1 || p.value || f.value) && !(e.key === "Backspace" && G(e, "backspace"))) {
59259
59258
  if (le(e)) {
59260
59259
  e.preventDefault(), p.value = !0, n.value.triggerSend?.();
59261
59260
  return;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@antdv-next/x",
3
- "version": "1.1.2-beta.5",
3
+ "version": "1.1.2-beta.6",
4
4
  "license": "MIT",
5
5
  "files": [
6
6
  "dist",