@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 +43 -25
- package/dist/package.js +1 -1
- package/dist/sender/components/SlotTextArea.js +42 -24
- package/es/antdv-next-x.esm.js +30 -31
- package/package.json +1 -1
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.
|
|
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
|
|
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
|
|
8661
|
+
const focusOffset = selection.focusOffset;
|
|
8662
8662
|
if (!anchorNode || !editable.contains(anchorNode)) return false;
|
|
8663
|
-
|
|
8664
|
-
|
|
8665
|
-
const
|
|
8666
|
-
|
|
8667
|
-
|
|
8668
|
-
|
|
8669
|
-
|
|
8670
|
-
|
|
8671
|
-
|
|
8672
|
-
|
|
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
|
-
}
|
|
8675
|
-
|
|
8676
|
-
|
|
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 (
|
|
8679
|
-
|
|
8680
|
-
|
|
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
|
-
|
|
8686
|
-
const
|
|
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" &&
|
|
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
|
@@ -495,38 +495,56 @@ var SlotTextArea_default = /* @__PURE__ */ defineComponent({
|
|
|
495
495
|
}
|
|
496
496
|
return null;
|
|
497
497
|
};
|
|
498
|
-
const
|
|
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
|
|
504
|
+
const focusOffset = selection.focusOffset;
|
|
505
505
|
if (!anchorNode || !editable.contains(anchorNode)) return false;
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
const
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
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
|
-
}
|
|
518
|
-
|
|
519
|
-
|
|
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 (
|
|
522
|
-
|
|
523
|
-
|
|
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
|
-
|
|
529
|
-
const
|
|
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" &&
|
|
562
|
+
if (event.key === "Backspace" && handleDeleteOperation(event, "backspace")) return;
|
|
545
563
|
if (shouldSubmit(event)) {
|
|
546
564
|
event.preventDefault();
|
|
547
565
|
keyLock.value = true;
|
package/es/antdv-next-x.esm.js
CHANGED
|
@@ -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
|
+
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
|
|
59228
|
-
if (!
|
|
59229
|
-
let n =
|
|
59230
|
-
if (!
|
|
59231
|
-
|
|
59232
|
-
|
|
59233
|
-
|
|
59234
|
-
|
|
59235
|
-
|
|
59236
|
-
|
|
59237
|
-
|
|
59238
|
-
|
|
59239
|
-
|
|
59240
|
-
|
|
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
|
-
|
|
59242
|
+
if (!c(t)) return null;
|
|
59243
|
+
t = t.previousSibling;
|
|
59252
59244
|
}
|
|
59253
|
-
|
|
59254
|
-
|
|
59255
|
-
|
|
59256
|
-
|
|
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;
|