@opentiny/tiny-robot 0.3.0-alpha.2 → 0.3.0-alpha.21
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/action-group/index.js +46 -43
- package/dist/attachments/index.js +526 -0
- package/dist/base-popper/index.js +4 -0
- package/dist/bubble/index.js +1217 -1253
- package/dist/container/index.js +44 -40
- package/dist/drag-overlay/index.js +57 -0
- package/dist/dropdown-menu/index.js +151 -64
- package/dist/feedback/index.js +79 -80
- package/dist/flow-layout-buttons/index.js +28 -25
- package/dist/history/index.js +71 -72
- package/dist/icon-button/index.js +18 -19
- package/dist/index.d.ts +1319 -885
- package/dist/index.js +216 -77
- package/dist/index2.js +501 -343
- package/dist/index3.js +152 -298
- package/dist/mcp-add-form/index.js +212 -0
- package/dist/mcp-server-picker/index.js +551 -0
- package/dist/no-data.js +4 -0
- package/dist/prompts/index.js +36 -39
- package/dist/sender/index.js +1131 -1210
- package/dist/style.css +1 -1
- package/dist/suggestion-pills/index.js +131 -155
- package/dist/suggestion-popover/index.js +253 -221
- package/dist/theme-provider/index.js +83 -0
- package/dist/useSlotRefs.js +36 -0
- package/dist/utils.js +8 -13
- package/package.json +4 -9
- package/dist/close.js +0 -29
- package/dist/index4.js +0 -637
- package/dist/index5.js +0 -2157
- package/dist/index6.js +0 -4752
- package/dist/question/index.js +0 -429
- package/dist/suggestion/index.js +0 -497
- package/dist/tiny-robot-svgs.js +0 -643
package/dist/sender/index.js
CHANGED
|
@@ -1,438 +1,234 @@
|
|
|
1
|
-
import { ref as
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const m = O(t.modelValue || t.defaultValue || ""), o = O(null);
|
|
1
|
+
import { ref as K, watch as te, reactive as nt, computed as D, defineComponent as we, createElementBlock as I, openBlock as b, createCommentVNode as W, normalizeStyle as je, createBlock as Q, unref as C, withCtx as pe, createElementVNode as U, createVNode as X, normalizeClass as ne, toDisplayString as ie, useAttrs as ot, resolveComponent as st, mergeProps as be, Fragment as he, renderList as _e, mergeModels as at, useModel as lt, onMounted as rt, onUnmounted as it, nextTick as ee, Transition as Pe, withModifiers as ut, useSlots as ct, renderSlot as re, isRef as dt, createTextVNode as ze } from "vue";
|
|
2
|
+
import { TinyTooltip as Me, TinyInput as ft } from "@opentiny/vue";
|
|
3
|
+
import { d as pt } from "../index2.js";
|
|
4
|
+
import { IconUpload as ht, IconVoice as vt, IconLoadingSpeech as yt, IconClear as gt, IconSend as mt, IconStop as bt, IconAssociate as _t } from "@opentiny/tiny-robot-svgs";
|
|
5
|
+
import { _ as Se } from "../_plugin-vue_export-helper.js";
|
|
6
|
+
import { t as wt } from "../utils.js";
|
|
7
|
+
function St(l, c) {
|
|
8
|
+
const s = K(l.modelValue || l.defaultValue || ""), u = K(null);
|
|
10
9
|
te(
|
|
11
|
-
() =>
|
|
12
|
-
(
|
|
13
|
-
|
|
10
|
+
() => l.modelValue,
|
|
11
|
+
(h) => {
|
|
12
|
+
h !== void 0 && h !== s.value && (s.value = h);
|
|
14
13
|
}
|
|
15
14
|
), te(
|
|
16
|
-
() =>
|
|
17
|
-
(
|
|
18
|
-
|
|
15
|
+
() => s.value,
|
|
16
|
+
(h) => {
|
|
17
|
+
c("update:modelValue", h);
|
|
19
18
|
}
|
|
20
19
|
);
|
|
21
|
-
const
|
|
22
|
-
|
|
23
|
-
},
|
|
24
|
-
|
|
25
|
-
const
|
|
26
|
-
!
|
|
27
|
-
},
|
|
28
|
-
|
|
29
|
-
},
|
|
20
|
+
const y = (h) => {
|
|
21
|
+
s.value = h, c("update:modelValue", h);
|
|
22
|
+
}, S = (h) => {
|
|
23
|
+
h == null || h.preventDefault();
|
|
24
|
+
const _ = s.value;
|
|
25
|
+
!l.disabled && !l.loading && _.trim() && c("submit", _);
|
|
26
|
+
}, a = () => {
|
|
27
|
+
s.value = "", c("update:modelValue", ""), c("clear");
|
|
28
|
+
}, d = K(!1);
|
|
30
29
|
return {
|
|
31
|
-
inputValue:
|
|
32
|
-
inputWrapper:
|
|
33
|
-
isComposing:
|
|
34
|
-
handleChange:
|
|
35
|
-
handleSubmit:
|
|
36
|
-
handleClear:
|
|
30
|
+
inputValue: s,
|
|
31
|
+
inputWrapper: u,
|
|
32
|
+
isComposing: d,
|
|
33
|
+
handleChange: y,
|
|
34
|
+
handleSubmit: S,
|
|
35
|
+
handleClear: a,
|
|
37
36
|
clearInput: () => {
|
|
38
|
-
|
|
37
|
+
a();
|
|
39
38
|
}
|
|
40
39
|
};
|
|
41
40
|
}
|
|
42
|
-
|
|
43
|
-
const
|
|
44
|
-
|
|
45
|
-
},
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
return;
|
|
49
|
-
const m = ye();
|
|
50
|
-
t.parentNode && t.parentNode.insertBefore(m, t.nextSibling);
|
|
51
|
-
}, _t = (t) => {
|
|
52
|
-
Array.from(t.childNodes).forEach((m) => {
|
|
53
|
-
if (m.nodeType === Node.TEXT_NODE && ee(m.textContent || "")) {
|
|
54
|
-
const o = m.previousSibling;
|
|
55
|
-
o && o.nodeType === Node.ELEMENT_NODE && o.classList.contains("template-field") || m.parentNode && m.parentNode.removeChild(m);
|
|
56
|
-
}
|
|
57
|
-
});
|
|
58
|
-
};
|
|
59
|
-
function Tt(t, y, m, o, x, u, i, r, c, f, p, a, b, L) {
|
|
60
|
-
const _ = (h) => !(t.disabled || t.loading || h.trim().length === 0 || a.value), v = () => {
|
|
61
|
-
_(m.value) && y("submit", m.value.trim());
|
|
62
|
-
}, R = (h, $) => {
|
|
63
|
-
if (!(h.key === "Enter")) return !1;
|
|
64
|
-
switch ($) {
|
|
41
|
+
function Ct(l, c, s, u, y, S, a, d, x, h, _, v, A, P, M, F) {
|
|
42
|
+
const T = () => {
|
|
43
|
+
v.value && (M != null && M.value && (F == null || F()), c("submit", s.value.trim()));
|
|
44
|
+
}, g = (p, Z) => {
|
|
45
|
+
if (!(p.key === "Enter")) return !1;
|
|
46
|
+
switch (Z) {
|
|
65
47
|
case "enter":
|
|
66
|
-
return !
|
|
48
|
+
return !p.shiftKey && !p.ctrlKey && !p.metaKey;
|
|
67
49
|
case "ctrlEnter":
|
|
68
|
-
return (
|
|
50
|
+
return (p.ctrlKey || p.metaKey) && !p.shiftKey;
|
|
69
51
|
case "shiftEnter":
|
|
70
|
-
return
|
|
52
|
+
return p.shiftKey && !p.ctrlKey && !p.metaKey;
|
|
71
53
|
default:
|
|
72
54
|
return !1;
|
|
73
55
|
}
|
|
74
56
|
};
|
|
75
57
|
return {
|
|
76
|
-
handleKeyPress: (
|
|
77
|
-
if (
|
|
78
|
-
if (
|
|
79
|
-
|
|
80
|
-
const
|
|
81
|
-
|
|
82
|
-
` +
|
|
83
|
-
|
|
58
|
+
handleKeyPress: (p) => {
|
|
59
|
+
if (u.value) return;
|
|
60
|
+
if (p.key === "Enter" && p.shiftKey && (A == null ? void 0 : A.value) === "single" && P) {
|
|
61
|
+
p.preventDefault(), P();
|
|
62
|
+
const B = p.target, q = B.selectionStart, Y = s.value;
|
|
63
|
+
s.value = Y.substring(0, q) + `
|
|
64
|
+
` + Y.substring(q), setTimeout(() => {
|
|
65
|
+
B.selectionStart = B.selectionEnd = q + 1;
|
|
84
66
|
}, 0);
|
|
85
67
|
return;
|
|
86
68
|
}
|
|
87
|
-
if (
|
|
88
|
-
|
|
69
|
+
if (p.key === "Tab" && S.value && a.value) {
|
|
70
|
+
p.preventDefault(), d();
|
|
89
71
|
return;
|
|
90
72
|
}
|
|
91
|
-
if (
|
|
92
|
-
if (
|
|
93
|
-
|
|
73
|
+
if (S.value) {
|
|
74
|
+
if (p.key === "ArrowDown") {
|
|
75
|
+
p.preventDefault(), h("down");
|
|
94
76
|
return;
|
|
95
77
|
}
|
|
96
|
-
if (
|
|
97
|
-
|
|
78
|
+
if (p.key === "ArrowUp") {
|
|
79
|
+
p.preventDefault(), h("up");
|
|
98
80
|
return;
|
|
99
81
|
}
|
|
100
|
-
if (
|
|
101
|
-
|
|
82
|
+
if (p.key === "Enter" && a.value) {
|
|
83
|
+
p.preventDefault(), d();
|
|
102
84
|
return;
|
|
103
85
|
}
|
|
104
86
|
}
|
|
105
|
-
if (
|
|
106
|
-
|
|
87
|
+
if (p.key === "Escape") {
|
|
88
|
+
S.value ? (x(), p.preventDefault()) : y.isRecording && (_(), p.preventDefault()), c("escape-press");
|
|
107
89
|
return;
|
|
108
90
|
}
|
|
109
|
-
|
|
91
|
+
g(p, l.submitType) && (p.preventDefault(), v.value && T());
|
|
110
92
|
},
|
|
111
|
-
triggerSubmit:
|
|
112
|
-
};
|
|
113
|
-
}
|
|
114
|
-
function Nt(t) {
|
|
115
|
-
const y = (u, i, r) => {
|
|
116
|
-
var L, _;
|
|
117
|
-
const { startOffset: c, collapsed: f } = i;
|
|
118
|
-
let p = i.startContainer;
|
|
119
|
-
if ((L = p.parentElement) != null && L.classList.contains("template-field") && (p = p.parentElement), !f) return !1;
|
|
120
|
-
const a = p.nodeType === Node.TEXT_NODE && c === 0 && u.key === "ArrowLeft", b = p.nodeType === Node.TEXT_NODE && c === (((_ = p.textContent) == null ? void 0 : _.length) || 0) && u.key === "ArrowRight";
|
|
121
|
-
if (a || b) {
|
|
122
|
-
let v = null, R = "inside";
|
|
123
|
-
if (a)
|
|
124
|
-
if (p.parentNode && p.parentNode.classList.contains("template-field"))
|
|
125
|
-
v = p.parentNode, R = "before";
|
|
126
|
-
else {
|
|
127
|
-
let w = p.previousSibling;
|
|
128
|
-
!w && p.parentNode && p.parentNode !== r && (w = p.parentNode.previousSibling), w && w.nodeType === Node.ELEMENT_NODE && w.classList.contains("template-field") && (v = w, R = "inside");
|
|
129
|
-
}
|
|
130
|
-
else if (b)
|
|
131
|
-
if (p.parentNode && p.parentNode.classList.contains("template-field"))
|
|
132
|
-
v = p.parentNode, R = "after";
|
|
133
|
-
else {
|
|
134
|
-
let w = p.nextSibling;
|
|
135
|
-
!w && p.parentNode && p.parentNode !== r && (w = p.parentNode.nextSibling), w && w.nodeType === Node.ELEMENT_NODE && w.classList.contains("template-field") && (v = w, R = "inside");
|
|
136
|
-
}
|
|
137
|
-
if (v) {
|
|
138
|
-
u.preventDefault();
|
|
139
|
-
const w = document.createRange(), h = z(r);
|
|
140
|
-
return h && (R === "before" ? w.setStartBefore(v) : R === "after" ? w.setStartAfter(v) : (w.selectNodeContents(v), w.collapse(u.key === "ArrowLeft")), h.removeAllRanges(), h.addRange(w)), !0;
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
if (p.nodeType === Node.ELEMENT_NODE && p.classList.contains("template-field")) {
|
|
144
|
-
const R = p.textContent || "", w = J(R);
|
|
145
|
-
if (!w || w.trim() === "") {
|
|
146
|
-
u.preventDefault();
|
|
147
|
-
const h = document.createRange(), $ = z(r);
|
|
148
|
-
if (!$) return !0;
|
|
149
|
-
if (u.key === "ArrowLeft")
|
|
150
|
-
h.setStartBefore(p);
|
|
151
|
-
else {
|
|
152
|
-
const V = p.nextSibling;
|
|
153
|
-
V && V.nodeType === Node.TEXT_NODE && ee(V.textContent || "") ? (h.setStart(V, 0), h.setEnd(V, 0)) : h.setStartAfter(p);
|
|
154
|
-
}
|
|
155
|
-
return h.collapse(!0), $.removeAllRanges(), $.addRange(h), !0;
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
if (p.nodeType === Node.TEXT_NODE && ee(p.textContent || "")) {
|
|
159
|
-
const v = p.previousSibling, R = p.nextSibling;
|
|
160
|
-
u.preventDefault();
|
|
161
|
-
const w = document.createRange(), h = z(r);
|
|
162
|
-
return h && (u.key === "ArrowLeft" ? v && v.nodeType === Node.ELEMENT_NODE && v.classList.contains("template-field") ? (w.selectNodeContents(v), w.collapse(!1)) : w.setStartBefore(p) : R ? R.nodeType === Node.ELEMENT_NODE && R.classList.contains("template-field") ? (w.selectNodeContents(R), w.collapse(!0)) : pt(r) ? (w.setStart(R, 1), w.collapse(!0)) : w.setStartAfter(p) : w.setStartAfter(p), h.removeAllRanges(), h.addRange(w)), !0;
|
|
163
|
-
}
|
|
164
|
-
return !1;
|
|
165
|
-
}, m = (u, i, r) => {
|
|
166
|
-
if (!i.collapsed) return !1;
|
|
167
|
-
const { startContainer: c, startOffset: f } = i;
|
|
168
|
-
if (c.nodeType === Node.TEXT_NODE && ee(c.textContent || "")) {
|
|
169
|
-
const a = c.previousSibling;
|
|
170
|
-
if (a && a.nodeType === Node.ELEMENT_NODE && a.classList.contains("template-field")) {
|
|
171
|
-
const b = a, L = b.textContent || "", _ = J(L);
|
|
172
|
-
if (!_ || _.trim() === "") {
|
|
173
|
-
u.preventDefault();
|
|
174
|
-
const v = b.previousSibling, R = c.nextSibling;
|
|
175
|
-
b.parentNode && b.parentNode.removeChild(b), c.parentNode && c.parentNode.removeChild(c);
|
|
176
|
-
const w = z(r);
|
|
177
|
-
if (w) {
|
|
178
|
-
const h = document.createRange();
|
|
179
|
-
v ? v.nodeType === Node.ELEMENT_NODE && v.classList.contains("template-field") ? (h.selectNodeContents(v), h.collapse(!1)) : v.nodeType === Node.TEXT_NODE && ee(v.textContent || "") ? (h.setStart(v, 0), h.setEnd(v, 0)) : h.setStartAfter(v) : R ? h.setStartBefore(R) : h.setStart(r, 0), h.collapse(!0), w.removeAllRanges(), w.addRange(h);
|
|
180
|
-
}
|
|
181
|
-
return t.handleInput(), !0;
|
|
182
|
-
} else {
|
|
183
|
-
u.preventDefault();
|
|
184
|
-
const v = z(r);
|
|
185
|
-
if (v) {
|
|
186
|
-
const R = document.createRange();
|
|
187
|
-
R.selectNodeContents(b), R.collapse(!1), v.removeAllRanges(), v.addRange(R);
|
|
188
|
-
}
|
|
189
|
-
return !0;
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
if (c.nodeType === Node.TEXT_NODE && c.parentNode && c.parentNode.classList.contains("template-field") && c.textContent) {
|
|
194
|
-
const a = c.textContent;
|
|
195
|
-
if (J(a).length === 1 && f === a.length) {
|
|
196
|
-
u.preventDefault(), c.textContent = "";
|
|
197
|
-
const L = c.parentNode, _ = z(r);
|
|
198
|
-
if (_) {
|
|
199
|
-
const v = document.createRange();
|
|
200
|
-
v.selectNodeContents(L), v.collapse(!0), _.removeAllRanges(), _.addRange(v);
|
|
201
|
-
}
|
|
202
|
-
return t.handleInput(), !0;
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
if (f === 0) {
|
|
206
|
-
let a = null;
|
|
207
|
-
if (c.nodeType === Node.ELEMENT_NODE && c.classList.contains("template-field") ? a = c : c.nodeType === Node.TEXT_NODE && c.parentNode && c.parentNode.classList.contains("template-field") && (a = c.parentNode), a) {
|
|
208
|
-
u.preventDefault();
|
|
209
|
-
const b = z(r);
|
|
210
|
-
return b && (i.setStartBefore(a), i.collapse(!0), b.removeAllRanges(), b.addRange(i)), !0;
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
return !1;
|
|
214
|
-
}, o = (u, i, r) => {
|
|
215
|
-
if (!i.collapsed) return !1;
|
|
216
|
-
const { startContainer: c, startOffset: f } = i;
|
|
217
|
-
if (c.nodeType === Node.TEXT_NODE && c.parentNode && c.parentNode.classList.contains("template-field") && c.textContent) {
|
|
218
|
-
const a = c.textContent, b = J(a);
|
|
219
|
-
if (f === a.length && b.length === 1) {
|
|
220
|
-
u.preventDefault(), c.textContent = "";
|
|
221
|
-
const L = c.parentNode, _ = z(r);
|
|
222
|
-
if (_) {
|
|
223
|
-
const v = document.createRange();
|
|
224
|
-
v.selectNodeContents(L), v.collapse(!0), _.removeAllRanges(), _.addRange(v);
|
|
225
|
-
}
|
|
226
|
-
return t.handleInput(), !0;
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
return !1;
|
|
230
|
-
};
|
|
231
|
-
return {
|
|
232
|
-
handleTemplateKeyDown: (u) => {
|
|
233
|
-
if (t.isComposing.value) return;
|
|
234
|
-
const i = t.editor.value;
|
|
235
|
-
if (!i) return;
|
|
236
|
-
const r = z(i);
|
|
237
|
-
if (!r || r.rangeCount === 0) return;
|
|
238
|
-
const c = r.getRangeAt(0);
|
|
239
|
-
if (u.key === "Enter") {
|
|
240
|
-
u.preventDefault(), t.onSubmit(t.getValueFromDOM());
|
|
241
|
-
return;
|
|
242
|
-
}
|
|
243
|
-
(u.key === "ArrowLeft" || u.key === "ArrowRight") && !u.shiftKey && y(u, c, i) || u.key === "Backspace" && m(u, c, i) || u.key === "Delete" && o(u, c, i);
|
|
244
|
-
}
|
|
93
|
+
triggerSubmit: T
|
|
245
94
|
};
|
|
246
95
|
}
|
|
247
|
-
function xt(
|
|
248
|
-
const
|
|
96
|
+
function xt(l) {
|
|
97
|
+
const c = nt({
|
|
249
98
|
isRecording: !1,
|
|
250
99
|
isSupported: typeof window < "u" && "webkitSpeechRecognition" in window || "SpeechRecognition" in window,
|
|
251
100
|
error: void 0
|
|
252
|
-
}),
|
|
253
|
-
|
|
254
|
-
var
|
|
255
|
-
|
|
256
|
-
},
|
|
257
|
-
var
|
|
258
|
-
|
|
259
|
-
},
|
|
260
|
-
var
|
|
261
|
-
const
|
|
262
|
-
|
|
263
|
-
},
|
|
264
|
-
var
|
|
265
|
-
|
|
101
|
+
}), s = c.isSupported ? new (window.webkitSpeechRecognition || window.SpeechRecognition)() : void 0;
|
|
102
|
+
s !== void 0 && (s.continuous = l.continuous ?? !1, s.interimResults = l.interimResults ?? !0, s.lang = l.lang ?? navigator.language, s.onstart = () => {
|
|
103
|
+
var a;
|
|
104
|
+
c.isRecording = !0, c.error = void 0, (a = l.onStart) == null || a.call(l);
|
|
105
|
+
}, s.onend = () => {
|
|
106
|
+
var a;
|
|
107
|
+
c.isRecording = !1, (a = l.onEnd) == null || a.call(l);
|
|
108
|
+
}, s.onresult = (a) => {
|
|
109
|
+
var x, h;
|
|
110
|
+
const d = Array.from(a.results).map((_) => _[0].transcript).join("");
|
|
111
|
+
a.results[0].isFinal ? (x = l.onFinal) == null || x.call(l, d) : (h = l.onInterim) == null || h.call(l, d);
|
|
112
|
+
}, s.onerror = (a) => {
|
|
113
|
+
var d;
|
|
114
|
+
c.error = new Error(a.error), c.isRecording = !1, (d = l.onError) == null || d.call(l, c.error);
|
|
266
115
|
});
|
|
267
|
-
const
|
|
268
|
-
var
|
|
269
|
-
if (!
|
|
270
|
-
const
|
|
271
|
-
|
|
116
|
+
const u = () => {
|
|
117
|
+
var a;
|
|
118
|
+
if (!s) {
|
|
119
|
+
const d = new Error("浏览器不支持语音识别");
|
|
120
|
+
c.error = d, (a = l.onError) == null || a.call(l, d);
|
|
272
121
|
return;
|
|
273
122
|
}
|
|
274
|
-
if (
|
|
123
|
+
if (c.isRecording) {
|
|
275
124
|
try {
|
|
276
|
-
|
|
125
|
+
s.stop(), setTimeout(() => {
|
|
277
126
|
try {
|
|
278
|
-
|
|
279
|
-
} catch (
|
|
280
|
-
|
|
127
|
+
s.start();
|
|
128
|
+
} catch (d) {
|
|
129
|
+
S(d);
|
|
281
130
|
}
|
|
282
131
|
}, 100);
|
|
283
|
-
} catch (
|
|
284
|
-
|
|
132
|
+
} catch (d) {
|
|
133
|
+
S(d);
|
|
285
134
|
}
|
|
286
135
|
return;
|
|
287
136
|
}
|
|
288
137
|
try {
|
|
289
|
-
|
|
290
|
-
} catch (
|
|
291
|
-
|
|
138
|
+
s.start();
|
|
139
|
+
} catch (d) {
|
|
140
|
+
S(d);
|
|
292
141
|
}
|
|
293
|
-
},
|
|
294
|
-
if (
|
|
142
|
+
}, y = () => {
|
|
143
|
+
if (s && c.isRecording)
|
|
295
144
|
try {
|
|
296
|
-
|
|
297
|
-
} catch (
|
|
298
|
-
|
|
145
|
+
s.stop();
|
|
146
|
+
} catch (a) {
|
|
147
|
+
S(a);
|
|
299
148
|
}
|
|
300
|
-
},
|
|
301
|
-
var
|
|
302
|
-
|
|
149
|
+
}, S = (a) => {
|
|
150
|
+
var d;
|
|
151
|
+
c.error = a instanceof Error ? a : new Error("语音识别操作失败"), c.isRecording = !1, (d = l.onError) == null || d.call(l, c.error);
|
|
303
152
|
};
|
|
304
153
|
return {
|
|
305
|
-
speechState:
|
|
306
|
-
start:
|
|
307
|
-
stop:
|
|
154
|
+
speechState: c,
|
|
155
|
+
start: u,
|
|
156
|
+
stop: y
|
|
308
157
|
};
|
|
309
158
|
}
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
return [{ text: t, isMatch: !1 }];
|
|
325
|
-
const i = [];
|
|
326
|
-
for (const f of x)
|
|
327
|
-
if (i.length === 0)
|
|
328
|
-
i.push(f);
|
|
329
|
-
else {
|
|
330
|
-
const p = i[i.length - 1];
|
|
331
|
-
f.start <= p.end ? p.end = Math.max(p.end, f.end) : i.push(f);
|
|
332
|
-
}
|
|
333
|
-
const r = [];
|
|
334
|
-
let c = 0;
|
|
335
|
-
for (const f of i)
|
|
336
|
-
c < f.start && r.push({
|
|
337
|
-
text: t.substring(c, f.start),
|
|
338
|
-
isMatch: !1
|
|
339
|
-
}), r.push({
|
|
340
|
-
text: t.substring(f.start, f.end),
|
|
341
|
-
isMatch: !0
|
|
342
|
-
}), c = f.end;
|
|
343
|
-
return c < t.length && r.push({
|
|
344
|
-
text: t.substring(c),
|
|
345
|
-
isMatch: !1
|
|
346
|
-
}), r;
|
|
347
|
-
};
|
|
348
|
-
function Rt(t, y, m, o) {
|
|
349
|
-
const x = O(!1), u = O(-1), i = O(-1), r = O(""), c = O(!1), f = O(null), p = O(!1), a = O(null), b = P(() => {
|
|
350
|
-
if (!t.suggestions || !m.value || t.template) return [];
|
|
351
|
-
const e = m.value.toLowerCase();
|
|
352
|
-
return t.suggestions.filter((l) => l.toLowerCase().includes(e));
|
|
353
|
-
}), L = P(() => {
|
|
354
|
-
let e = -1;
|
|
355
|
-
return a.value === "mouse" && i.value !== -1 ? e = i.value : a.value === "keyboard" && u.value !== -1 && (e = u.value), b.value[e] || null;
|
|
356
|
-
}), _ = (e) => e === u.value || e === i.value, v = (e) => {
|
|
357
|
-
if (a.value === null) {
|
|
358
|
-
r.value = "", c.value = !1;
|
|
159
|
+
function kt(l, c, s, u, y, S) {
|
|
160
|
+
const a = K(!1), d = K(-1), x = K(-1), h = K(null), _ = K(""), v = K(!1), A = D(() => {
|
|
161
|
+
var G, j;
|
|
162
|
+
if (!((G = l.value) != null && G.length)) return "";
|
|
163
|
+
const k = h.value === "mouse" ? x.value : d.value;
|
|
164
|
+
return ((j = l.value[k]) == null ? void 0 : j.content) || "";
|
|
165
|
+
}), P = (k) => {
|
|
166
|
+
_.value = k, v.value = !0;
|
|
167
|
+
}, M = () => {
|
|
168
|
+
_.value = "", v.value = !1;
|
|
169
|
+
}, F = (k) => {
|
|
170
|
+
const G = k || A.value;
|
|
171
|
+
if (!G || !c.value) {
|
|
172
|
+
M();
|
|
359
173
|
return;
|
|
360
174
|
}
|
|
361
|
-
const
|
|
362
|
-
|
|
363
|
-
},
|
|
364
|
-
|
|
365
|
-
},
|
|
366
|
-
|
|
367
|
-
},
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
175
|
+
const j = G.substring(c.value.length);
|
|
176
|
+
G.toLowerCase().startsWith(c.value.toLowerCase()) && j ? P(j) : M();
|
|
177
|
+
}, T = () => {
|
|
178
|
+
d.value = -1, x.value = -1, h.value = null;
|
|
179
|
+
}, g = () => {
|
|
180
|
+
a.value = !0, F();
|
|
181
|
+
}, E = () => {
|
|
182
|
+
a.value = !1, T(), M();
|
|
183
|
+
}, p = D(() => {
|
|
184
|
+
var k;
|
|
185
|
+
return s.value ? !0 : !!(c.value && ((k = l.value) == null ? void 0 : k.length) > 0 && !u.value);
|
|
186
|
+
}), Z = (k) => {
|
|
187
|
+
E(), c.value = k, y(k), S(k);
|
|
188
|
+
}, B = () => {
|
|
189
|
+
A.value && Z(A.value);
|
|
190
|
+
}, q = (k) => {
|
|
191
|
+
!a.value || !l.value || (h.value = "keyboard", d.value === -1 ? d.value = k === "down" ? 0 : l.value.length - 1 : k === "down" ? d.value = (d.value + 1) % l.value.length : d.value = (d.value - 1 + l.value.length) % l.value.length, F());
|
|
192
|
+
}, Y = (k) => {
|
|
193
|
+
l.value && (h.value = "mouse", x.value = k, F());
|
|
194
|
+
}, N = () => {
|
|
195
|
+
l.value && (x.value = -1, d.value !== -1 ? h.value = "keyboard" : h.value = null, F());
|
|
381
196
|
};
|
|
382
|
-
return {
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
}
|
|
405
|
-
},
|
|
406
|
-
handleSuggestionItemHover: (e) => {
|
|
407
|
-
a.value = "mouse", i.value = e, v(b.value[e]);
|
|
408
|
-
},
|
|
409
|
-
handleSuggestionItemLeave: () => {
|
|
410
|
-
if (i.value = -1, u.value !== -1) {
|
|
411
|
-
a.value = "keyboard";
|
|
412
|
-
const e = b.value[u.value];
|
|
413
|
-
e && v(e);
|
|
414
|
-
} else
|
|
415
|
-
a.value = null, v();
|
|
416
|
-
},
|
|
417
|
-
handleClickOutside: () => {
|
|
418
|
-
K();
|
|
419
|
-
},
|
|
420
|
-
highlightSuggestionText: kt
|
|
197
|
+
return te(p, (k) => {
|
|
198
|
+
k ? a.value || g() : a.value && E();
|
|
199
|
+
}), {
|
|
200
|
+
// 弹窗控制
|
|
201
|
+
isPopupVisible: a,
|
|
202
|
+
openPopup: g,
|
|
203
|
+
closePopup: E,
|
|
204
|
+
// 自动完成占位符
|
|
205
|
+
autoCompleteText: _,
|
|
206
|
+
showTabIndicator: v,
|
|
207
|
+
syncAutoComplete: F,
|
|
208
|
+
// 选中控制层
|
|
209
|
+
activeSuggestion: A,
|
|
210
|
+
activeKeyboardIndex: d,
|
|
211
|
+
activeMouseIndex: x,
|
|
212
|
+
// 交互处理
|
|
213
|
+
navigateWithKeyboard: q,
|
|
214
|
+
handleMouseEnter: Y,
|
|
215
|
+
handleMouseLeave: N,
|
|
216
|
+
// 业务操作
|
|
217
|
+
applySuggestion: Z,
|
|
218
|
+
confirmSelection: B
|
|
421
219
|
};
|
|
422
220
|
}
|
|
423
|
-
const
|
|
221
|
+
const It = { class: "action-buttons" }, Tt = { class: "action-buttons__submit-content" }, Rt = {
|
|
424
222
|
key: 0,
|
|
425
|
-
class: "action-
|
|
426
|
-
},
|
|
427
|
-
key: 1,
|
|
428
|
-
class: "action-buttons__cancel"
|
|
429
|
-
}, We = /* @__PURE__ */ be({
|
|
223
|
+
class: "action-buttons__cancel-text"
|
|
224
|
+
}, Ot = /* @__PURE__ */ we({
|
|
430
225
|
__name: "ActionButtons",
|
|
431
226
|
props: {
|
|
432
227
|
loading: { type: Boolean, default: !1 },
|
|
433
228
|
disabled: { type: Boolean, default: !1 },
|
|
434
229
|
showClear: { type: Boolean, default: !0 },
|
|
435
230
|
hasContent: { type: Boolean, default: !1 },
|
|
231
|
+
buttonGroup: {},
|
|
436
232
|
allowSpeech: { type: Boolean, default: !1 },
|
|
437
233
|
speechStatus: { default: () => ({
|
|
438
234
|
isRecording: !1,
|
|
@@ -441,617 +237,748 @@ const Dt = { class: "action-buttons" }, Ft = {
|
|
|
441
237
|
allowFiles: { type: Boolean, default: !1 },
|
|
442
238
|
submitType: { default: "enter" },
|
|
443
239
|
showShortcuts: { type: Boolean },
|
|
444
|
-
isOverLimit: { type: Boolean, default: !1 }
|
|
240
|
+
isOverLimit: { type: Boolean, default: !1 },
|
|
241
|
+
stopText: { default: void 0 }
|
|
445
242
|
},
|
|
446
|
-
emits: ["clear", "toggle-speech", "submit", "cancel"],
|
|
447
|
-
setup(
|
|
448
|
-
const
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
if (
|
|
452
|
-
|
|
453
|
-
|
|
243
|
+
emits: ["clear", "toggle-speech", "submit", "cancel", "trigger-select"],
|
|
244
|
+
setup(l, { emit: c }) {
|
|
245
|
+
const s = l, u = c, y = D(() => {
|
|
246
|
+
var E, p;
|
|
247
|
+
const g = (p = (E = s.buttonGroup) == null ? void 0 : E.file) == null ? void 0 : p.tooltips;
|
|
248
|
+
if (typeof g == "string" && g)
|
|
249
|
+
return () => g;
|
|
250
|
+
if (typeof g == "function")
|
|
251
|
+
return g;
|
|
252
|
+
}), S = D(() => {
|
|
253
|
+
var E, p;
|
|
254
|
+
const g = (p = (E = s.buttonGroup) == null ? void 0 : E.submit) == null ? void 0 : p.tooltips;
|
|
255
|
+
if (typeof g == "string" && g)
|
|
256
|
+
return () => g;
|
|
257
|
+
if (typeof g == "function")
|
|
258
|
+
return g;
|
|
259
|
+
}), a = D(() => s.allowSpeech), d = D(() => s.speechStatus.isRecording), x = D(() => s.disabled), h = D(() => {
|
|
260
|
+
var g, E;
|
|
261
|
+
return x.value || s.isOverLimit || ((E = (g = s.buttonGroup) == null ? void 0 : g.submit) == null ? void 0 : E.disabled);
|
|
262
|
+
}), _ = D(() => s.allowFiles || s.allowSpeech || s.showClear), v = () => {
|
|
263
|
+
x.value || u("clear");
|
|
264
|
+
}, A = () => {
|
|
265
|
+
if (!x.value) {
|
|
266
|
+
const g = !s.speechStatus.isRecording;
|
|
267
|
+
u("toggle-speech", g);
|
|
454
268
|
}
|
|
455
|
-
},
|
|
456
|
-
|
|
457
|
-
},
|
|
458
|
-
|
|
269
|
+
}, P = () => {
|
|
270
|
+
h.value || u("submit");
|
|
271
|
+
}, M = () => {
|
|
272
|
+
x.value || u("cancel");
|
|
273
|
+
}, F = D(() => {
|
|
274
|
+
var g, E;
|
|
275
|
+
return x.value || ((E = (g = s.buttonGroup) == null ? void 0 : g.file) == null ? void 0 : E.disabled);
|
|
276
|
+
}), T = () => {
|
|
277
|
+
F.value || u("trigger-select");
|
|
459
278
|
};
|
|
460
|
-
return (
|
|
461
|
-
|
|
462
|
-
|
|
279
|
+
return (g, E) => (b(), I("div", It, [
|
|
280
|
+
_.value ? (b(), I("div", {
|
|
281
|
+
key: 0,
|
|
282
|
+
class: "action-buttons__utility",
|
|
283
|
+
style: je({ "padding-right": g.hasContent || g.loading ? "0" : "6px" })
|
|
284
|
+
}, [
|
|
285
|
+
g.allowFiles && !g.loading ? (b(), Q(C(Me), {
|
|
463
286
|
key: 0,
|
|
464
|
-
|
|
465
|
-
placement: "top"
|
|
287
|
+
effect: "light",
|
|
288
|
+
placement: "top",
|
|
289
|
+
"render-content": y.value,
|
|
290
|
+
"visible-arrow": !1
|
|
466
291
|
}, {
|
|
467
|
-
default:
|
|
468
|
-
|
|
469
|
-
class: "action-buttons__button
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
})
|
|
478
|
-
]),
|
|
479
|
-
_: 1
|
|
480
|
-
}, 8, ["disabled"])
|
|
292
|
+
default: pe(() => [
|
|
293
|
+
U("div", {
|
|
294
|
+
class: "action-buttons__button",
|
|
295
|
+
onClick: T
|
|
296
|
+
}, [
|
|
297
|
+
X(C(ht), {
|
|
298
|
+
class: ne(["action-buttons__icon", { "is-disabled": F.value }]),
|
|
299
|
+
alt: "上传文件"
|
|
300
|
+
}, null, 8, ["class"])
|
|
301
|
+
])
|
|
481
302
|
]),
|
|
482
303
|
_: 1
|
|
483
|
-
})) :
|
|
484
|
-
|
|
304
|
+
}, 8, ["render-content"])) : W("", !0),
|
|
305
|
+
a.value && !g.loading ? (b(), I("div", {
|
|
485
306
|
key: 1,
|
|
486
|
-
class:
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
}))
|
|
501
|
-
]),
|
|
502
|
-
_: 1
|
|
503
|
-
}, 8, ["disabled", "class"])) : H("", !0),
|
|
504
|
-
_.showClear ? (D(), Q(E(Ve), {
|
|
307
|
+
class: ne(["action-buttons__button", { "is-recording": d.value }]),
|
|
308
|
+
onClick: A
|
|
309
|
+
}, [
|
|
310
|
+
d.value ? (b(), Q(C(yt), {
|
|
311
|
+
key: 1,
|
|
312
|
+
class: "action-buttons__icon action-buttons__icon--recording",
|
|
313
|
+
alt: "语音中"
|
|
314
|
+
})) : (b(), Q(C(vt), {
|
|
315
|
+
key: 0,
|
|
316
|
+
class: "action-buttons__icon",
|
|
317
|
+
alt: "录音"
|
|
318
|
+
}))
|
|
319
|
+
], 2)) : W("", !0),
|
|
320
|
+
g.showClear ? (b(), Q(C(Me), {
|
|
505
321
|
key: 2,
|
|
506
322
|
content: "清空内容",
|
|
507
323
|
placement: "top"
|
|
508
324
|
}, {
|
|
509
|
-
default:
|
|
510
|
-
|
|
511
|
-
class: "action-buttons__button
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
default: Y(() => [
|
|
517
|
-
(D(), Q(it(E(m)), { class: "action-buttons__icon action-buttons__icon--close" }))
|
|
518
|
-
]),
|
|
519
|
-
_: 1
|
|
520
|
-
}, 8, ["disabled"])
|
|
325
|
+
default: pe(() => [
|
|
326
|
+
U("div", {
|
|
327
|
+
class: "action-buttons__button",
|
|
328
|
+
onClick: v
|
|
329
|
+
}, [
|
|
330
|
+
X(C(gt), { class: "action-buttons__icon" })
|
|
331
|
+
])
|
|
521
332
|
]),
|
|
522
333
|
_: 1
|
|
523
|
-
})) :
|
|
524
|
-
])) :
|
|
525
|
-
|
|
334
|
+
})) : W("", !0)
|
|
335
|
+
], 4)) : W("", !0),
|
|
336
|
+
g.hasContent || g.loading ? (b(), I("div", {
|
|
526
337
|
key: 1,
|
|
527
|
-
type: "text",
|
|
528
338
|
class: "action-buttons__button action-buttons__submit",
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
339
|
+
onClick: E[0] || (E[0] = (p) => g.loading ? M() : P())
|
|
340
|
+
}, [
|
|
341
|
+
U("div", Tt, [
|
|
342
|
+
g.loading ? (b(), I("div", {
|
|
343
|
+
key: 1,
|
|
344
|
+
class: ne(["action-buttons__cancel", { "action-buttons__cancel--icon-only": !g.stopText }])
|
|
345
|
+
}, [
|
|
346
|
+
X(C(bt), {
|
|
347
|
+
class: "action-buttons__icon action-buttons__icon--cancel",
|
|
348
|
+
alt: "停止"
|
|
349
|
+
}),
|
|
350
|
+
g.stopText ? (b(), I("span", Rt, ie(g.stopText), 1)) : W("", !0)
|
|
351
|
+
], 2)) : (b(), Q(C(Me), {
|
|
352
|
+
key: 0,
|
|
353
|
+
effect: "light",
|
|
354
|
+
placement: "top",
|
|
355
|
+
"render-content": S.value,
|
|
356
|
+
"visible-arrow": !1
|
|
357
|
+
}, {
|
|
358
|
+
default: pe(() => [
|
|
359
|
+
X(C(mt), {
|
|
360
|
+
class: ne(["action-buttons__icon", "action-buttons__icon--send", { "is-disabled": h.value }]),
|
|
361
|
+
alt: "发送"
|
|
362
|
+
}, null, 8, ["class"])
|
|
363
|
+
]),
|
|
364
|
+
_: 1
|
|
365
|
+
}, 8, ["render-content"]))
|
|
366
|
+
])
|
|
367
|
+
])) : W("", !0)
|
|
549
368
|
]));
|
|
550
369
|
}
|
|
551
|
-
});
|
|
552
|
-
function
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
370
|
+
}), Ge = /* @__PURE__ */ Se(Ot, [["__scopeId", "data-v-f95cab32"]]);
|
|
371
|
+
function Et(l, c = {}) {
|
|
372
|
+
let s = [], u = [], y = l;
|
|
373
|
+
return { commit: (_) => {
|
|
374
|
+
var v;
|
|
375
|
+
s.push(y), y = _, u.length && ((v = c.onRemoveHistory) == null || v.call(c, u)), u = [];
|
|
376
|
+
}, undo: () => s.length ? (u.push(y), y = s.pop(), y) : null, redo: () => u.length ? (s.push(y), y = u.pop(), y) : null, clear: () => {
|
|
377
|
+
var _, v;
|
|
378
|
+
s.length && ((_ = c.onRemoveHistory) == null || _.call(c, s)), u.length && ((v = c.onRemoveHistory) == null || v.call(c, u)), s = [], u = [];
|
|
379
|
+
}, get: () => y };
|
|
380
|
+
}
|
|
381
|
+
const $t = ["data-id", "data-type"], Bt = ["data-id", "data-type"], Lt = /* @__PURE__ */ we({
|
|
382
|
+
inheritAttrs: !1,
|
|
383
|
+
__name: "Block",
|
|
384
|
+
props: {
|
|
385
|
+
id: {},
|
|
386
|
+
type: {},
|
|
387
|
+
content: {},
|
|
388
|
+
readonly: { type: Boolean },
|
|
389
|
+
asChild: { type: Boolean }
|
|
390
|
+
},
|
|
391
|
+
setup(l) {
|
|
392
|
+
const c = l, s = ot();
|
|
393
|
+
return (u, y) => {
|
|
394
|
+
const S = st("Block", !0);
|
|
395
|
+
return c.type !== "block" ? (b(), I("span", be({
|
|
396
|
+
key: 0,
|
|
397
|
+
"data-id": c.id,
|
|
398
|
+
"data-type": c.type
|
|
399
|
+
}, C(s)), ie(c.content), 17, $t)) : (b(), I(he, { key: 1 }, [
|
|
400
|
+
c.asChild ? (b(!0), I(he, { key: 0 }, _e(c.content, (a) => (b(), Q(S, be({
|
|
401
|
+
key: `${a.id}-${a.type}`
|
|
402
|
+
}, { ref_for: !0 }, a), null, 16))), 128)) : (b(), I("span", be({
|
|
403
|
+
key: 1,
|
|
404
|
+
"data-id": c.id,
|
|
405
|
+
"data-type": c.type
|
|
406
|
+
}, C(s)), [
|
|
407
|
+
(b(!0), I(he, null, _e(c.content, (a) => (b(), Q(S, be({
|
|
408
|
+
key: `${a.id}-${a.type}`
|
|
409
|
+
}, { ref_for: !0 }, a), null, 16))), 128))
|
|
410
|
+
], 16, Bt))
|
|
411
|
+
], 64));
|
|
587
412
|
};
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
const
|
|
598
|
-
|
|
599
|
-
const
|
|
600
|
-
|
|
601
|
-
}
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
const n = (e === void 0 ? i() : e).trim().length > 0;
|
|
615
|
-
m.value !== n && (m.value = n, o.onContentStatusChange(n));
|
|
616
|
-
}, b = (e, l = "inside", n = !1) => {
|
|
617
|
-
W(() => {
|
|
618
|
-
const s = z(t.value);
|
|
619
|
-
if (!s) return;
|
|
620
|
-
const g = document.createRange();
|
|
621
|
-
switch (l) {
|
|
622
|
-
case "before":
|
|
623
|
-
g.setStartBefore(e);
|
|
624
|
-
break;
|
|
625
|
-
case "after":
|
|
626
|
-
g.setStartAfter(e);
|
|
627
|
-
break;
|
|
628
|
-
case "inside":
|
|
629
|
-
default:
|
|
630
|
-
g.selectNodeContents(e), g.collapse(n);
|
|
631
|
-
break;
|
|
413
|
+
}
|
|
414
|
+
}), Dt = /* @__PURE__ */ Se(Lt, [["__scopeId", "data-v-13862606"]]), At = { class: "editor-container" }, Fe = "", Kt = /* @__PURE__ */ we({
|
|
415
|
+
__name: "TemplateEditor",
|
|
416
|
+
props: {
|
|
417
|
+
modelValue: { default: () => [] },
|
|
418
|
+
modelModifiers: {}
|
|
419
|
+
},
|
|
420
|
+
emits: /* @__PURE__ */ at(["submit"], ["update:modelValue"]),
|
|
421
|
+
setup(l, { expose: c, emit: s }) {
|
|
422
|
+
const u = typeof window.ShadowRoot.prototype.getSelection == "function", y = typeof window.Selection.prototype.getComposedRanges == "function";
|
|
423
|
+
function S() {
|
|
424
|
+
const e = navigator.userAgent;
|
|
425
|
+
return e.includes("Safari") && !e.includes("Chrome") && !e.includes("Chromium") && !e.includes("CriOS");
|
|
426
|
+
}
|
|
427
|
+
const a = S(), d = () => Math.random().toString(36).substring(2, 15), x = Fe, h = Fe, _ = Fe, v = lt(l, "modelValue"), A = s, P = K(0), M = (e) => e.map((n) => ({
|
|
428
|
+
id: n.id || d(),
|
|
429
|
+
...n.type === "template" ? { ...n, prefix: h, suffix: _ } : n
|
|
430
|
+
})), F = (e) => e.map((n) => ({ id: n.id, type: n.type, content: n.content })), T = K(M(v.value || [])), g = (e) => {
|
|
431
|
+
T.value = e;
|
|
432
|
+
}, E = D(() => {
|
|
433
|
+
const e = [], n = [], o = T.value;
|
|
434
|
+
if (o.length >= 2) {
|
|
435
|
+
const r = o[0], f = o[1];
|
|
436
|
+
r.type === "text" && r.content.length === 0 && f.type === "template" && e.push({ ...r, content: x });
|
|
437
|
+
const w = o[o.length - 1], L = o[o.length - 2];
|
|
438
|
+
w.type === "text" && w.content.length === 0 && L.type === "template" && n.push({ ...w, content: x });
|
|
632
439
|
}
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
440
|
+
o.length > 0 && o[0].type === "template" && e.push({ type: "text", content: x, id: d() }), o.length > 0 && o[o.length - 1].type === "template" && n.push({ type: "text", content: x, id: d() });
|
|
441
|
+
const i = new RegExp(x, "g");
|
|
442
|
+
return o.length > 0 && (o[0].content !== x && (o[0].content = o[0].content.replace(i, "")), o[o.length - 1].content !== x && (o[o.length - 1].content = o[o.length - 1].content.replace(i, ""))), e.concat(o).concat(n);
|
|
443
|
+
}), p = D(() => T.value.map((e) => e.type === "template" ? [
|
|
444
|
+
{ id: e.id, type: "prefix", content: e.prefix },
|
|
445
|
+
{ id: e.id, type: "template", content: e.content },
|
|
446
|
+
{ id: e.id, type: "suffix", content: e.suffix }
|
|
447
|
+
] : [e]).flat()), Z = D(() => E.value.map((e) => e.type === "text" ? e : a ? {
|
|
448
|
+
id: e.id,
|
|
449
|
+
type: "block",
|
|
450
|
+
asChild: !0,
|
|
451
|
+
content: [
|
|
452
|
+
{ id: e.id, type: "prefix", content: e.prefix },
|
|
453
|
+
{
|
|
454
|
+
id: e.id,
|
|
455
|
+
type: "block",
|
|
456
|
+
content: [
|
|
457
|
+
{ id: e.id, type: "template", content: e.content },
|
|
458
|
+
{ id: e.id, type: "suffix", content: e.suffix }
|
|
459
|
+
]
|
|
460
|
+
}
|
|
461
|
+
]
|
|
462
|
+
} : {
|
|
463
|
+
id: e.id,
|
|
464
|
+
type: "block",
|
|
465
|
+
asChild: !0,
|
|
466
|
+
content: [
|
|
467
|
+
{
|
|
468
|
+
id: e.id,
|
|
469
|
+
type: "block",
|
|
470
|
+
content: [
|
|
471
|
+
{ id: e.id, type: "prefix", content: e.prefix },
|
|
472
|
+
{ id: e.id, type: "template", content: e.content }
|
|
473
|
+
]
|
|
474
|
+
},
|
|
475
|
+
{ id: e.id, type: "suffix", content: e.suffix }
|
|
476
|
+
]
|
|
477
|
+
})), B = K(null), q = (e) => {
|
|
478
|
+
const n = Date.now(), o = JSON.stringify(e);
|
|
479
|
+
return `${n}:${o}`;
|
|
480
|
+
}, Y = (e) => {
|
|
481
|
+
const n = parseInt(e.slice(0, 13)), o = JSON.parse(e.slice(14));
|
|
482
|
+
return {
|
|
483
|
+
timestamp: n,
|
|
484
|
+
data: o
|
|
485
|
+
};
|
|
486
|
+
}, N = /* @__PURE__ */ new Map(), k = Et(q(T.value), {
|
|
487
|
+
onRemoveHistory: (e) => {
|
|
488
|
+
for (const n of e)
|
|
489
|
+
N.delete(n);
|
|
641
490
|
}
|
|
642
491
|
});
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
n.
|
|
653
|
-
const M = ye();
|
|
654
|
-
n.appendChild(M), s || (s = I);
|
|
655
|
-
} else
|
|
656
|
-
n.appendChild(document.createTextNode(g.content));
|
|
657
|
-
}), o.initialValues && Object.keys(o.initialValues).length > 0 && W(() => {
|
|
658
|
-
const g = i();
|
|
659
|
-
g !== o.value && (o.onValueChange(g), o.onInput(g));
|
|
660
|
-
});
|
|
661
|
-
else {
|
|
662
|
-
const g = v(e, l);
|
|
663
|
-
g.success ? g.elements.forEach((T) => {
|
|
664
|
-
if (n.appendChild(T.node), T.isField) {
|
|
665
|
-
const I = ye();
|
|
666
|
-
n.appendChild(I);
|
|
667
|
-
}
|
|
668
|
-
T.isField && !s && (s = T.node);
|
|
669
|
-
}) : (n.appendChild(document.createTextNode(l)), s = null);
|
|
670
|
-
}
|
|
671
|
-
return s;
|
|
672
|
-
}, v = (e, l) => {
|
|
673
|
-
const n = [];
|
|
674
|
-
let s = 0, g = 0, T = !0;
|
|
675
|
-
for (; g < e.length && s <= l.length && T; ) {
|
|
676
|
-
const I = e[g];
|
|
677
|
-
if (I.type === "text")
|
|
678
|
-
l.substring(s).startsWith(I.content) ? (n.push({
|
|
679
|
-
node: document.createTextNode(I.content),
|
|
680
|
-
isField: !1
|
|
681
|
-
}), s += I.content.length, g++) : T = !1;
|
|
682
|
-
else {
|
|
683
|
-
let M = "";
|
|
684
|
-
const j = e.find((B, X) => X > g && B.type === "text");
|
|
685
|
-
if (j) {
|
|
686
|
-
const B = l.substring(s), X = B.indexOf(j.content);
|
|
687
|
-
X !== -1 ? (M = B.substring(0, X), s += M.length) : T = !1;
|
|
688
|
-
} else
|
|
689
|
-
M = l.substring(s), s = l.length;
|
|
690
|
-
if (T) {
|
|
691
|
-
const B = c(I.content, M);
|
|
692
|
-
n.push({ node: B, isField: !0 }), g++;
|
|
492
|
+
te(
|
|
493
|
+
() => v.value,
|
|
494
|
+
(e) => {
|
|
495
|
+
const n = M(e || []);
|
|
496
|
+
if (JSON.stringify(n) !== JSON.stringify(T.value)) {
|
|
497
|
+
if (B.value) {
|
|
498
|
+
const i = ae(B.value);
|
|
499
|
+
i && N.set(k.get(), J(i));
|
|
500
|
+
}
|
|
501
|
+
g(n), k.commit(q(T.value));
|
|
693
502
|
}
|
|
503
|
+
},
|
|
504
|
+
{ deep: !0 }
|
|
505
|
+
);
|
|
506
|
+
const G = (e, n = document.body) => n.contains(e) ? e instanceof HTMLElement && e.dataset.id ? e : e.parentElement ? G(e.parentElement, n) : null : null, j = (e) => e === B.value, ae = (e) => {
|
|
507
|
+
const n = window.getSelection();
|
|
508
|
+
if (!n)
|
|
509
|
+
return null;
|
|
510
|
+
const o = n.rangeCount > 0 ? n.getRangeAt(0) : null, i = e.getRootNode();
|
|
511
|
+
if (!(i instanceof ShadowRoot))
|
|
512
|
+
return o;
|
|
513
|
+
if (y) {
|
|
514
|
+
const r = n.getComposedRanges(a ? i : { shadowRoots: [i] });
|
|
515
|
+
return (r == null ? void 0 : r[0]) ?? null;
|
|
694
516
|
}
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
const M = e[I];
|
|
699
|
-
if (M.type === "field") {
|
|
700
|
-
const j = !o.value || o.value === "" ? r(M.content) : "", B = c(M.content, j);
|
|
701
|
-
n.push({ node: B, isField: !0 });
|
|
702
|
-
} else
|
|
703
|
-
n.push({
|
|
704
|
-
node: document.createTextNode(M.content),
|
|
705
|
-
isField: !1
|
|
706
|
-
});
|
|
517
|
+
if (u) {
|
|
518
|
+
const r = i.getSelection();
|
|
519
|
+
return r.rangeCount > 0 ? r.getRangeAt(0) : null;
|
|
707
520
|
}
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
521
|
+
return o;
|
|
522
|
+
}, V = (e, n) => {
|
|
523
|
+
var i;
|
|
524
|
+
if (!e.firstChild || e.firstChild.nodeType !== Node.TEXT_NODE)
|
|
525
|
+
return { node: e, offset: 0 };
|
|
526
|
+
const o = ((i = e.firstChild.textContent) == null ? void 0 : i.length) ?? 0;
|
|
527
|
+
return { node: e.firstChild, offset: Math.min(n, o) };
|
|
528
|
+
}, z = (e, n, o, i) => {
|
|
529
|
+
const r = window.getSelection();
|
|
530
|
+
if (!r)
|
|
531
|
+
return;
|
|
532
|
+
const { node: f, offset: w } = V(e, n);
|
|
533
|
+
if (!o) {
|
|
534
|
+
r.setBaseAndExtent(f, w, f, w);
|
|
535
|
+
return;
|
|
536
|
+
}
|
|
537
|
+
const { node: L, offset: H } = V(o, i ?? 0);
|
|
538
|
+
r.setBaseAndExtent(f, w, L, H);
|
|
539
|
+
}, ve = (e, n) => {
|
|
540
|
+
const o = d(), i = { id: o, type: "text", content: e };
|
|
541
|
+
if (n) {
|
|
542
|
+
const r = T.value.findIndex((f) => f.id === n);
|
|
543
|
+
r !== -1 ? (g(
|
|
544
|
+
T.value.slice(0, r + 1).concat(i).concat(T.value.slice(r + 1))
|
|
545
|
+
), k.commit(q(T.value))) : console.warn(`can not find item with id: ${n}`);
|
|
717
546
|
} else
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
t.value.childNodes.forEach((l) => {
|
|
735
|
-
if (l.nodeType === Node.TEXT_NODE) {
|
|
736
|
-
const n = l.textContent || "";
|
|
737
|
-
if (ee(n)) {
|
|
738
|
-
const s = l.previousSibling;
|
|
739
|
-
if (s && s.nodeType === Node.ELEMENT_NODE && s.classList.contains("template-field"))
|
|
740
|
-
return;
|
|
741
|
-
}
|
|
742
|
-
(n.trim() === "" || ee(n)) && e.push(l);
|
|
743
|
-
} else l.nodeType === Node.ELEMENT_NODE && l.tagName.toLowerCase() === "br" && e.push(l);
|
|
744
|
-
}), e.forEach((l) => {
|
|
745
|
-
l.parentNode && l.parentNode.removeChild(l);
|
|
746
|
-
});
|
|
747
|
-
}, V = (e) => {
|
|
748
|
-
if (!o.template || !o.initialValues)
|
|
749
|
-
return "字段";
|
|
750
|
-
for (const [l, n] of Object.entries(o.initialValues))
|
|
751
|
-
if (n === e)
|
|
752
|
-
return l;
|
|
753
|
-
return e.length <= 2 || /^[[\]{}()]+$/.test(e) || e.includes("[") && e.includes("]") ? e : "字段";
|
|
754
|
-
}, K = (e) => {
|
|
755
|
-
const l = e.getAttribute("data-placeholder");
|
|
756
|
-
if (l)
|
|
757
|
-
return l;
|
|
758
|
-
const n = e.getAttribute("title") || e.getAttribute("data-field") || e.getAttribute("data-key") || e.getAttribute("placeholder") || "";
|
|
759
|
-
if (n)
|
|
760
|
-
return n;
|
|
761
|
-
const s = e.textContent || "";
|
|
762
|
-
return V(s);
|
|
763
|
-
}, C = () => {
|
|
764
|
-
if (!t.value) return;
|
|
765
|
-
t.value.querySelectorAll("span").forEach((l) => {
|
|
766
|
-
const n = l, s = n.style, g = n.classList.contains("template-field"), T = n.hasAttribute("data-placeholder");
|
|
767
|
-
if (g && T)
|
|
547
|
+
g([i].concat(T.value)), k.commit(q(T.value));
|
|
548
|
+
ee(() => {
|
|
549
|
+
var f;
|
|
550
|
+
const r = (f = B.value) == null ? void 0 : f.querySelector(`[data-id="${o}"][data-type="text"]`);
|
|
551
|
+
r && z(r, e.length);
|
|
552
|
+
}), v.value = F(T.value);
|
|
553
|
+
}, oe = K({
|
|
554
|
+
hasStarted: !1,
|
|
555
|
+
range: null
|
|
556
|
+
}), Ce = (e) => {
|
|
557
|
+
var L;
|
|
558
|
+
const n = e;
|
|
559
|
+
e.preventDefault();
|
|
560
|
+
const { inputType: o } = n, i = (n.data || ((L = n.dataTransfer) == null ? void 0 : L.getData("text/plain")) || "").replace(h, "").replace(_, ""), r = n.getTargetRanges()[0];
|
|
561
|
+
if (!r) {
|
|
562
|
+
console.warn("range is null", r);
|
|
768
563
|
return;
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
564
|
+
}
|
|
565
|
+
const f = [
|
|
566
|
+
"insertText",
|
|
567
|
+
"insertFromPaste",
|
|
568
|
+
"insertReplacementText",
|
|
569
|
+
"deleteContentBackward",
|
|
570
|
+
"deleteContentForward",
|
|
571
|
+
"deleteWordBackward",
|
|
572
|
+
"deleteWordForward",
|
|
573
|
+
"deleteSoftLineBackward",
|
|
574
|
+
"deleteSoftLineForward",
|
|
575
|
+
"deleteByCut"
|
|
576
|
+
], w = ae(B.value);
|
|
577
|
+
if (f.includes(o)) {
|
|
578
|
+
if (i && j(r.startContainer) && j(r.endContainer)) {
|
|
579
|
+
w && N.set(k.get(), J(w)), ve(i);
|
|
580
|
+
return;
|
|
777
581
|
}
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
582
|
+
const H = J(r);
|
|
583
|
+
H.startId && H.endId ? (w && N.set(k.get(), J(w)), ue(H, o, i)) : console.warn("range is not valid, range:", H);
|
|
584
|
+
} else o === "insertCompositionText" && oe.value.hasStarted && (oe.value = { hasStarted: !1, range: J(r) });
|
|
585
|
+
}, J = (e) => {
|
|
586
|
+
const n = G(e.startContainer, B.value), o = G(e.endContainer, B.value);
|
|
587
|
+
return {
|
|
588
|
+
collapsed: e.collapsed,
|
|
589
|
+
endContainer: e.endContainer,
|
|
590
|
+
endId: o == null ? void 0 : o.dataset.id,
|
|
591
|
+
endEl: o,
|
|
592
|
+
endOffset: e.endOffset,
|
|
593
|
+
endType: o == null ? void 0 : o.dataset.type,
|
|
594
|
+
startContainer: e.startContainer,
|
|
595
|
+
startId: n == null ? void 0 : n.dataset.id,
|
|
596
|
+
startEl: n,
|
|
597
|
+
startOffset: e.startOffset,
|
|
598
|
+
startType: n == null ? void 0 : n.dataset.type
|
|
599
|
+
};
|
|
600
|
+
}, xe = (e, n, o, i) => e.slice(0, o) + n + e.slice(i), ue = (e, n, o) => {
|
|
601
|
+
const i = Be(e);
|
|
602
|
+
if (!Array.isArray(i) || i.length === 0)
|
|
603
|
+
return;
|
|
604
|
+
const r = Le(i, e, n, o);
|
|
605
|
+
if (r.some((O) => O.tag === "new")) {
|
|
606
|
+
const { afterId: O, content: $ } = r[0];
|
|
607
|
+
ve($, O);
|
|
608
|
+
return;
|
|
781
609
|
}
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
updateEditorDOM: R,
|
|
803
|
-
renderTemplateToDOM: _,
|
|
804
|
-
// 事件处理
|
|
805
|
-
handleInput: w,
|
|
806
|
-
checkHasContent: a,
|
|
807
|
-
cleanupEmptyTextNodes: $,
|
|
808
|
-
// 推断 placeholder
|
|
809
|
-
inferPlaceholderForContent: V,
|
|
810
|
-
extractPlaceholderFromElement: K,
|
|
811
|
-
// 方法
|
|
812
|
-
resetFields: () => {
|
|
813
|
-
if (!t.value) return;
|
|
814
|
-
o.isInternalUpdate = !0;
|
|
815
|
-
const e = t.value;
|
|
816
|
-
e.innerHTML = "";
|
|
817
|
-
const l = u(o.template);
|
|
818
|
-
let n = "";
|
|
819
|
-
l.forEach((s) => {
|
|
820
|
-
if (s.type === "field") {
|
|
821
|
-
const g = r(s.content), T = c(s.content, g);
|
|
822
|
-
g && (n += g), e.appendChild(T);
|
|
823
|
-
} else
|
|
824
|
-
e.appendChild(document.createTextNode(s.content)), n += s.content;
|
|
825
|
-
}), o.onValueChange(n), L(), a(n), W(() => {
|
|
826
|
-
o.isInternalUpdate = !1;
|
|
827
|
-
});
|
|
828
|
-
},
|
|
829
|
-
activateFirstField: () => {
|
|
830
|
-
var l;
|
|
831
|
-
const e = (l = t.value) == null ? void 0 : l.querySelector(".template-field");
|
|
832
|
-
e ? b(e, "inside", !1) : L();
|
|
833
|
-
},
|
|
834
|
-
// 选项更新
|
|
835
|
-
updateOptions: x
|
|
836
|
-
};
|
|
837
|
-
}
|
|
838
|
-
const At = /* @__PURE__ */ be({
|
|
839
|
-
__name: "TemplateEditor",
|
|
840
|
-
props: /* @__PURE__ */ Fe({
|
|
841
|
-
value: {},
|
|
842
|
-
autofocus: { type: Boolean }
|
|
843
|
-
}, {
|
|
844
|
-
value: { default: "" },
|
|
845
|
-
valueModifiers: {}
|
|
846
|
-
}),
|
|
847
|
-
emits: /* @__PURE__ */ Fe(["input", "content-status", "submit", "focus", "blur", "empty-content"], ["update:value"]),
|
|
848
|
-
setup(t, { expose: y, emit: m }) {
|
|
849
|
-
const o = rt(t, "value"), x = t, u = m, i = O(null), r = O(""), c = O({}), f = O(!1), p = O(!1), a = It(i, {
|
|
850
|
-
template: r.value,
|
|
851
|
-
value: o.value,
|
|
852
|
-
initialValues: c.value,
|
|
853
|
-
isInternalUpdate: f,
|
|
854
|
-
isComposing: p,
|
|
855
|
-
onValueChange: (C) => {
|
|
856
|
-
if (o.value !== C) {
|
|
857
|
-
const S = f.value;
|
|
858
|
-
f.value = !0, o.value = C, W(() => {
|
|
859
|
-
f.value = S;
|
|
860
|
-
});
|
|
610
|
+
const f = r, w = [];
|
|
611
|
+
for (const [O, $] of f.entries()) {
|
|
612
|
+
const t = T.value.find((R) => R.id === $.id), m = O === 0 ? o : "";
|
|
613
|
+
t ? t.type === "text" ? t.content = xe(t.content, m, $.startOffset, $.endOffset) : t.type === "template" ? $.type === "prefix" || $.type === "suffix" ? $.startOffset === 0 && $.endOffset === 1 && m.length === 0 ? t[$.type] = "" : console.warn(`${$.type} can not be inserted text. it only can be deleted`, $) : $.startOffset < 0 || $.endOffset > t.content.length ? w.push(t.id) : t.content = xe(t.content, m, $.startOffset, $.endOffset) : console.warn("dataItem.type is not text or template", t) : console.warn("can not find dataItem", $);
|
|
614
|
+
}
|
|
615
|
+
let L = T.value.filter((O) => !w.includes(O.id));
|
|
616
|
+
L = L.filter((O) => !(O.type === "template" && [O.prefix, O.suffix, O.content].join("").length === 0));
|
|
617
|
+
const H = /* @__PURE__ */ new Set();
|
|
618
|
+
L.forEach((O, $, t) => {
|
|
619
|
+
if (t.length >= 2) {
|
|
620
|
+
if ($ === 0 || $ === 1) {
|
|
621
|
+
const m = t[0], R = t[1];
|
|
622
|
+
if (m.type === "text" && m.content.length === 0 && R.type === "template")
|
|
623
|
+
return;
|
|
624
|
+
}
|
|
625
|
+
if ($ === t.length - 2 || $ === t.length - 1) {
|
|
626
|
+
const m = t[t.length - 1], R = t[t.length - 2];
|
|
627
|
+
if (m.type === "text" && m.content.length === 0 && R.type === "template")
|
|
628
|
+
return;
|
|
629
|
+
}
|
|
861
630
|
}
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
template: r.value,
|
|
885
|
-
value: S,
|
|
886
|
-
// 使用新生成的内容而不是旧的inputValue
|
|
887
|
-
initialValues: c.value
|
|
888
|
-
}), a.updateEditorDOM(), o.value = S, W(() => {
|
|
889
|
-
f.value = !1;
|
|
631
|
+
O.type === "text" && O.content.length === 0 && H.add(O.id);
|
|
632
|
+
}), L = L.filter((O) => !H.has(O.id));
|
|
633
|
+
for (const O of L.filter(($) => $.type === "template"))
|
|
634
|
+
O.prefix.length === 0 && (O.prefix = h), O.suffix.length === 0 && (O.suffix = _);
|
|
635
|
+
g(L), k.commit(q(T.value)), f.length > 0 && ye(f, o), v.value = F(T.value);
|
|
636
|
+
}, ye = (e, n) => {
|
|
637
|
+
const o = e[0], i = `[data-id="${o.id}"][data-type="${o.type}"]`, r = e.slice(1).map((f) => `[data-id="${f.id}"][data-type="${f.type}"]`);
|
|
638
|
+
ee(() => {
|
|
639
|
+
var w, L;
|
|
640
|
+
const f = (w = B.value) == null ? void 0 : w.querySelector(i);
|
|
641
|
+
if (f)
|
|
642
|
+
z(f, o.startOffset + n.length);
|
|
643
|
+
else if (n.length === 0)
|
|
644
|
+
for (const H of r) {
|
|
645
|
+
const O = (L = B.value) == null ? void 0 : L.querySelector(H);
|
|
646
|
+
if (O) {
|
|
647
|
+
z(O, 0);
|
|
648
|
+
break;
|
|
649
|
+
}
|
|
650
|
+
}
|
|
651
|
+
else
|
|
652
|
+
console.warn(`can not find el with selector: ${i}`);
|
|
890
653
|
});
|
|
891
|
-
},
|
|
892
|
-
p.value =
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
654
|
+
}, Be = (e) => {
|
|
655
|
+
const n = p.value.findIndex((w) => w.id === e.startId && w.type === e.startType), o = p.value.findIndex((w) => w.id === e.endId && w.type === e.endType);
|
|
656
|
+
if (n === -1 || o === -1 || n > o)
|
|
657
|
+
return console.warn("startIndex or endIndex is -1, or startIndex > endIndex. ", { range: e }), null;
|
|
658
|
+
const i = p.value[n], r = p.value[o];
|
|
659
|
+
if (n === o)
|
|
660
|
+
return [
|
|
661
|
+
{
|
|
662
|
+
id: i.id,
|
|
663
|
+
type: i.type,
|
|
664
|
+
startOffset: e.startOffset,
|
|
665
|
+
endOffset: e.endOffset
|
|
666
|
+
}
|
|
667
|
+
];
|
|
668
|
+
const f = [
|
|
669
|
+
{
|
|
670
|
+
id: i.id,
|
|
671
|
+
type: i.type,
|
|
672
|
+
startOffset: e.startOffset,
|
|
673
|
+
endOffset: i.content.length
|
|
674
|
+
}
|
|
675
|
+
];
|
|
676
|
+
for (let w = n + 1; w < o; w++) {
|
|
677
|
+
const L = p.value[w];
|
|
678
|
+
f.push({
|
|
679
|
+
id: L.id,
|
|
680
|
+
type: L.type,
|
|
681
|
+
startOffset: 0,
|
|
682
|
+
endOffset: L.content.length
|
|
683
|
+
});
|
|
903
684
|
}
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
e
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
685
|
+
return f.push({
|
|
686
|
+
id: r.id,
|
|
687
|
+
type: r.type,
|
|
688
|
+
startOffset: 0,
|
|
689
|
+
endOffset: e.endOffset
|
|
690
|
+
}), f;
|
|
691
|
+
}, Le = (e, n, o, i) => {
|
|
692
|
+
const r = e[0];
|
|
693
|
+
if (r.type !== "prefix" && r.type !== "suffix")
|
|
694
|
+
return e;
|
|
695
|
+
if (e.length === 1) {
|
|
696
|
+
if (n.collapsed)
|
|
697
|
+
if (n.startOffset === 0) {
|
|
698
|
+
const f = se(r, i);
|
|
699
|
+
return f ? [f] : [];
|
|
700
|
+
} else {
|
|
701
|
+
const f = ce(r, i);
|
|
702
|
+
return f ? [f] : [];
|
|
703
|
+
}
|
|
704
|
+
if (o.startsWith("insert"))
|
|
705
|
+
if (a) {
|
|
706
|
+
const f = se(r, i);
|
|
707
|
+
return f ? [f] : [];
|
|
708
|
+
} else {
|
|
709
|
+
const f = ce(r, i);
|
|
710
|
+
return f ? [f] : [];
|
|
711
|
+
}
|
|
712
|
+
if (o.startsWith("delete")) {
|
|
713
|
+
if (o.includes("Backward")) {
|
|
714
|
+
const f = se(r, i, 1);
|
|
715
|
+
return f ? [f] : [];
|
|
716
|
+
} else if (o.includes("Forward")) {
|
|
717
|
+
const f = ce(r, i, 1);
|
|
718
|
+
return f ? [f] : [];
|
|
927
719
|
}
|
|
928
|
-
}), n) {
|
|
929
|
-
$(e);
|
|
930
|
-
return;
|
|
931
720
|
}
|
|
932
721
|
}
|
|
933
|
-
|
|
934
|
-
},
|
|
935
|
-
const
|
|
936
|
-
if (
|
|
937
|
-
const
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
722
|
+
return i.length > 0 ? e.slice(1) : e;
|
|
723
|
+
}, se = (e, n, o = 0) => {
|
|
724
|
+
const i = p.value.findIndex((r) => r.id === e.id && r.type === e.type);
|
|
725
|
+
if (i > 0) {
|
|
726
|
+
const r = p.value[i - 1], { id: f, type: w, content: L } = r;
|
|
727
|
+
if (w === "text" || w === "template")
|
|
728
|
+
return {
|
|
729
|
+
id: f,
|
|
730
|
+
type: w,
|
|
731
|
+
startOffset: L.length - o,
|
|
732
|
+
endOffset: L.length
|
|
733
|
+
};
|
|
734
|
+
if (n.length > 0)
|
|
735
|
+
return { tag: "new", afterId: f, type: "text", content: n };
|
|
736
|
+
if (console.warn("the previous item is not text or template", { current: e, previous: r }), o === 1)
|
|
737
|
+
return { ...e, endOffset: e.startOffset };
|
|
738
|
+
} else return n.length > 0 ? { tag: "new", type: "text", content: n } : (console.warn("the previous item of current is not found", { current: e }), null);
|
|
739
|
+
return e;
|
|
740
|
+
}, ce = (e, n, o = 0) => {
|
|
741
|
+
const i = p.value.findIndex((r) => r.id === e.id && r.type === e.type);
|
|
742
|
+
if (i < p.value.length - 1) {
|
|
743
|
+
const r = p.value[i + 1], { id: f, type: w } = r;
|
|
744
|
+
if (w === "text" || w === "template")
|
|
745
|
+
return {
|
|
746
|
+
id: f,
|
|
747
|
+
type: w,
|
|
748
|
+
startOffset: 0,
|
|
749
|
+
endOffset: 0 + o
|
|
750
|
+
};
|
|
751
|
+
if (n.length > 0)
|
|
752
|
+
return { tag: "new", afterId: e.id, type: "text", content: n };
|
|
753
|
+
if (console.warn("the next item is not text or template", { current: e, next: r }), o === 1)
|
|
754
|
+
return { ...e, startOffset: e.endOffset };
|
|
755
|
+
} else return n.length > 0 ? { tag: "new", afterId: e.id, type: "text", content: n } : (console.warn("the next item of current is not found", { current: e }), null);
|
|
756
|
+
return e;
|
|
757
|
+
}, ke = () => {
|
|
758
|
+
oe.value = { hasStarted: !0, range: null };
|
|
759
|
+
}, ge = (e) => {
|
|
760
|
+
const n = oe.value.range;
|
|
761
|
+
n ? (e.data && j(n.startContainer) && j(n.endContainer) ? (N.set(k.get(), J(n)), ve(e.data)) : n.startId && n.endId ? (N.set(k.get(), J(n)), ue(n, "insertCompositionText", e.data)) : console.warn("range is not valid, range:", n), P.value++) : console.warn("range is null, compositionEnd:", e), oe.value = { hasStarted: !1, range: null };
|
|
762
|
+
}, de = (() => {
|
|
763
|
+
const e = navigator.userAgent.toLowerCase();
|
|
764
|
+
return /macintosh|mac os x|iphone|ipad|ipod/.test(e);
|
|
765
|
+
})(), fe = (e) => {
|
|
766
|
+
const n = de && e.metaKey && !e.shiftKey && e.key.toLowerCase() === "z" || // Cmd+Z
|
|
767
|
+
!de && e.ctrlKey && !e.shiftKey && e.key.toLowerCase() === "z", o = de && e.metaKey && e.shiftKey && e.key.toLowerCase() === "z" || // Cmd+Shift+z
|
|
768
|
+
!de && e.ctrlKey && (e.key.toLowerCase() === "y" || e.shiftKey && e.key.toLowerCase() === "z"), i = e.key.toLowerCase() === "enter";
|
|
769
|
+
if (n) {
|
|
770
|
+
e.preventDefault();
|
|
771
|
+
const r = ae(B.value);
|
|
772
|
+
r && N.set(k.get(), J(r));
|
|
773
|
+
const f = k.undo();
|
|
774
|
+
f && Ie(f);
|
|
943
775
|
}
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
N.deleteContents(), N.insertNode(document.createTextNode(C)), N.collapse(!1), S.removeAllRanges(), S.addRange(N), K();
|
|
776
|
+
if (o) {
|
|
777
|
+
e.preventDefault();
|
|
778
|
+
const r = k.redo();
|
|
779
|
+
r && Ie(r);
|
|
949
780
|
}
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
781
|
+
i && (e.preventDefault(), A("submit"));
|
|
782
|
+
}, Ie = (e) => {
|
|
783
|
+
const { data: n } = Y(e);
|
|
784
|
+
if (g(n), N.has(e)) {
|
|
785
|
+
const o = N.get(e);
|
|
786
|
+
ee(() => {
|
|
787
|
+
const i = B.value.querySelector(`[data-id="${o.startId}"][data-type="${o.startType}"]`), r = B.value.querySelector(`[data-id="${o.endId}"][data-type="${o.endType}"]`);
|
|
788
|
+
i && z(i, o.startOffset, r, o.endOffset);
|
|
789
|
+
});
|
|
790
|
+
}
|
|
791
|
+
v.value = F(T.value);
|
|
792
|
+
}, Te = (e, n) => {
|
|
793
|
+
var r, f;
|
|
794
|
+
const o = (r = B.value) == null ? void 0 : r.querySelector(`[data-id="${e}"][data-type="${n}"]`);
|
|
795
|
+
if (!o) return;
|
|
796
|
+
const i = ((f = o.textContent) == null ? void 0 : f.length) || 0;
|
|
797
|
+
z(o, i);
|
|
798
|
+
}, De = () => {
|
|
799
|
+
B.value && ee(() => {
|
|
800
|
+
const e = T.value, n = e.find((i) => i.type === "template");
|
|
801
|
+
n && Te(n.id, "template"), e.every((i) => i.type === "text") && e.length === 1 && Te(e[0].id, "text");
|
|
966
802
|
});
|
|
967
|
-
}
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
()
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
803
|
+
}, Ae = () => {
|
|
804
|
+
k.clear(), N.clear();
|
|
805
|
+
}, Re = () => {
|
|
806
|
+
if (!B.value || oe.value.range)
|
|
807
|
+
return;
|
|
808
|
+
const e = ae(B.value);
|
|
809
|
+
if (e != null && e.collapsed && E.value.length > 0) {
|
|
810
|
+
const n = J(e), o = E.value[0];
|
|
811
|
+
if (n.startEl && n.startId === o.id && n.startOffset === 0 && o.content === x && o.type === "text") {
|
|
812
|
+
z(n.startEl, 1);
|
|
813
|
+
return;
|
|
814
|
+
}
|
|
815
|
+
const i = E.value[E.value.length - 1];
|
|
816
|
+
if (n.endEl && n.endId === i.id && n.endOffset === 1 && i.content === x && i.type === "text") {
|
|
817
|
+
z(n.endEl, 0);
|
|
818
|
+
return;
|
|
819
|
+
}
|
|
978
820
|
}
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
()
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
821
|
+
};
|
|
822
|
+
return rt(() => {
|
|
823
|
+
document.addEventListener("selectionchange", Re);
|
|
824
|
+
}), it(() => {
|
|
825
|
+
document.removeEventListener("selectionchange", Re);
|
|
826
|
+
}), c({
|
|
827
|
+
clearHistory: Ae,
|
|
828
|
+
activateFirstField: De
|
|
829
|
+
}), (e, n) => (b(), I("div", At, [
|
|
830
|
+
(b(), I("div", {
|
|
831
|
+
contenteditable: "true",
|
|
832
|
+
ref_key: "editorRef",
|
|
833
|
+
ref: B,
|
|
834
|
+
key: P.value,
|
|
835
|
+
class: "editor",
|
|
836
|
+
onBeforeinput: Ce,
|
|
837
|
+
onCompositionstart: ke,
|
|
838
|
+
onCompositionend: ge,
|
|
839
|
+
onKeydown: fe
|
|
840
|
+
}, [
|
|
841
|
+
(b(!0), I(he, null, _e(Z.value, (o) => (b(), Q(Dt, be({
|
|
842
|
+
key: `${o.id}-${o.type}`
|
|
843
|
+
}, { ref_for: !0 }, o), null, 16))), 128))
|
|
844
|
+
], 32))
|
|
845
|
+
]));
|
|
846
|
+
}
|
|
847
|
+
}), Mt = /* @__PURE__ */ Se(Kt, [["__scopeId", "data-v-5fda773e"]]), Je = (l, c) => {
|
|
848
|
+
if (!c.length)
|
|
849
|
+
return [{ text: l, isMatch: !1 }];
|
|
850
|
+
const s = [];
|
|
851
|
+
for (const a of c) {
|
|
852
|
+
if (!a) continue;
|
|
853
|
+
let d = 0;
|
|
854
|
+
const x = l.toLowerCase(), h = a.toLowerCase();
|
|
855
|
+
for (; ; ) {
|
|
856
|
+
const _ = x.indexOf(h, d);
|
|
857
|
+
if (_ === -1) break;
|
|
858
|
+
s.push({
|
|
859
|
+
start: _,
|
|
860
|
+
end: _ + a.length
|
|
861
|
+
}), d = _ + 1;
|
|
862
|
+
}
|
|
863
|
+
}
|
|
864
|
+
if (s.length === 0)
|
|
865
|
+
return [{ text: l, isMatch: !1 }];
|
|
866
|
+
s.sort((a, d) => a.start - d.start);
|
|
867
|
+
const u = [];
|
|
868
|
+
for (const a of s)
|
|
869
|
+
if (u.length === 0)
|
|
870
|
+
u.push(a);
|
|
871
|
+
else {
|
|
872
|
+
const d = u[u.length - 1];
|
|
873
|
+
a.start <= d.end ? d.end = Math.max(d.end, a.end) : u.push(a);
|
|
874
|
+
}
|
|
875
|
+
const y = [];
|
|
876
|
+
let S = 0;
|
|
877
|
+
for (const a of u)
|
|
878
|
+
S < a.start && y.push({
|
|
879
|
+
text: l.substring(S, a.start),
|
|
880
|
+
isMatch: !1
|
|
881
|
+
}), y.push({
|
|
882
|
+
text: l.substring(a.start, a.end),
|
|
883
|
+
isMatch: !0
|
|
884
|
+
}), S = a.end;
|
|
885
|
+
return S < l.length && y.push({
|
|
886
|
+
text: l.substring(S),
|
|
887
|
+
isMatch: !1
|
|
888
|
+
}), y;
|
|
889
|
+
}, Ft = (l, c) => !c || !l ? [{ text: l, isMatch: !1 }] : Je(l, [c]), Pt = (l, c) => {
|
|
890
|
+
const { content: s, highlights: u } = l;
|
|
891
|
+
return typeof u == "function" ? u(s, c) : Array.isArray(u) ? Je(s, u) : Ft(s, c);
|
|
892
|
+
}, Vt = ["onMouseenter", "onMousedown"], Wt = { class: "suggestion-list__text" }, Nt = /* @__PURE__ */ we({
|
|
893
|
+
__name: "SuggestionList",
|
|
894
|
+
props: {
|
|
895
|
+
show: { type: Boolean },
|
|
896
|
+
suggestions: {},
|
|
897
|
+
popupStyle: {},
|
|
898
|
+
activeKeyboardIndex: {},
|
|
899
|
+
activeMouseIndex: {},
|
|
900
|
+
inputValue: {}
|
|
901
|
+
},
|
|
902
|
+
emits: ["select", "mouse-enter", "mouse-leave"],
|
|
903
|
+
setup(l, { emit: c }) {
|
|
904
|
+
const s = l, u = c, y = K(null), S = (h) => h === s.activeKeyboardIndex || h === s.activeMouseIndex, a = (h) => {
|
|
905
|
+
u("mouse-enter", h);
|
|
906
|
+
}, d = () => {
|
|
907
|
+
u("mouse-leave");
|
|
908
|
+
}, x = (h) => {
|
|
909
|
+
u("select", h);
|
|
910
|
+
};
|
|
911
|
+
return te(
|
|
912
|
+
() => s.activeKeyboardIndex,
|
|
913
|
+
(h) => {
|
|
914
|
+
if (h !== -1 && y.value) {
|
|
915
|
+
const _ = y.value.children[h];
|
|
916
|
+
_ && _.scrollIntoView({ block: "nearest" });
|
|
917
|
+
}
|
|
997
918
|
}
|
|
998
|
-
),
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
919
|
+
), (h, _) => (b(), Q(Pe, { name: "tiny-sender-slide-up" }, {
|
|
920
|
+
default: pe(() => [
|
|
921
|
+
s.show && s.suggestions.length ? (b(), I("div", {
|
|
922
|
+
key: 0,
|
|
923
|
+
ref_key: "suggestionsListRef",
|
|
924
|
+
ref: y,
|
|
925
|
+
class: "suggestion-list",
|
|
926
|
+
style: je(s.popupStyle)
|
|
927
|
+
}, [
|
|
928
|
+
(b(!0), I(he, null, _e(s.suggestions, (v, A) => (b(), I("div", {
|
|
929
|
+
key: A,
|
|
930
|
+
class: ne(["suggestion-list__item", { highlighted: S(A) }]),
|
|
931
|
+
onMouseenter: (P) => a(A),
|
|
932
|
+
onMouseleave: d,
|
|
933
|
+
onMousedown: ut((P) => x(v.content), ["prevent"])
|
|
934
|
+
}, [
|
|
935
|
+
X(C(_t), { class: "suggestion-list__icon" }),
|
|
936
|
+
U("span", Wt, [
|
|
937
|
+
(b(!0), I(he, null, _e(C(Pt)(v, s.inputValue), (P, M) => (b(), I("span", {
|
|
938
|
+
key: M,
|
|
939
|
+
class: ne({
|
|
940
|
+
"suggestion-list__text--match": P.isMatch,
|
|
941
|
+
"suggestion-list__text--normal": !P.isMatch
|
|
942
|
+
})
|
|
943
|
+
}, ie(P.text), 3))), 128))
|
|
944
|
+
])
|
|
945
|
+
], 42, Vt))), 128))
|
|
946
|
+
], 4)) : W("", !0)
|
|
947
|
+
]),
|
|
948
|
+
_: 1
|
|
949
|
+
}));
|
|
1023
950
|
}
|
|
1024
|
-
}),
|
|
951
|
+
}), Ht = /* @__PURE__ */ Se(Nt, [["__scopeId", "data-v-e0ec9fe3"]]), Ut = ["data-theme"], qt = { class: "tiny-sender__container" }, zt = {
|
|
1025
952
|
key: 0,
|
|
1026
953
|
class: "tiny-sender__header-slot"
|
|
1027
|
-
},
|
|
954
|
+
}, Gt = {
|
|
1028
955
|
key: 0,
|
|
1029
956
|
class: "tiny-sender__prefix-slot"
|
|
1030
|
-
},
|
|
957
|
+
}, jt = { class: "tiny-sender__content-area" }, Jt = {
|
|
1031
958
|
key: 0,
|
|
1032
959
|
class: "tiny-sender__decorative-content"
|
|
1033
|
-
},
|
|
960
|
+
}, Xt = {
|
|
1034
961
|
key: 2,
|
|
1035
962
|
class: "tiny-sender__input-field-wrapper"
|
|
1036
|
-
},
|
|
963
|
+
}, Zt = {
|
|
1037
964
|
key: 0,
|
|
1038
965
|
class: "tiny-sender__completion-placeholder"
|
|
1039
|
-
},
|
|
966
|
+
}, Qt = { class: "user-input-mirror" }, Yt = {
|
|
1040
967
|
key: 0,
|
|
1041
968
|
class: "tiny-sender__tab-hint"
|
|
1042
|
-
},
|
|
969
|
+
}, en = {
|
|
1043
970
|
key: 1,
|
|
1044
971
|
class: "tiny-sender__actions-slot"
|
|
1045
|
-
},
|
|
972
|
+
}, tn = {
|
|
973
|
+
key: 0,
|
|
974
|
+
class: "tiny-sender__footer-slot tiny-sender__bottom-row"
|
|
975
|
+
}, nn = { class: "tiny-sender__footer-left" }, on = { class: "tiny-sender__footer-right" }, sn = { class: "real-word-length" }, an = {
|
|
1046
976
|
key: 1,
|
|
1047
977
|
class: "tiny-sender__toolbar"
|
|
1048
|
-
},
|
|
978
|
+
}, ln = { class: "tiny-sender__buttons-container" }, rn = {
|
|
1049
979
|
key: 1,
|
|
1050
980
|
class: "tiny-sender__footer-slot"
|
|
1051
|
-
},
|
|
1052
|
-
key: 0,
|
|
1053
|
-
class: "tiny-sender__error"
|
|
1054
|
-
}, pe = /* @__PURE__ */ be({
|
|
981
|
+
}, un = /* @__PURE__ */ we({
|
|
1055
982
|
__name: "index",
|
|
1056
983
|
props: {
|
|
1057
984
|
autofocus: { type: Boolean, default: !1 },
|
|
@@ -1065,6 +992,7 @@ const At = /* @__PURE__ */ be({
|
|
|
1065
992
|
modelValue: { default: "" },
|
|
1066
993
|
mode: { default: "single" },
|
|
1067
994
|
maxLength: { default: 1 / 0 },
|
|
995
|
+
buttonGroup: {},
|
|
1068
996
|
submitType: { default: "enter" },
|
|
1069
997
|
speech: { type: [Boolean, Object] },
|
|
1070
998
|
placeholder: { default: "请输入内容..." },
|
|
@@ -1072,360 +1000,353 @@ const At = /* @__PURE__ */ be({
|
|
|
1072
1000
|
suggestions: { default: () => [] },
|
|
1073
1001
|
suggestionPopupWidth: { default: 400 },
|
|
1074
1002
|
theme: { default: "light" },
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
templateInitialValues: { default: () => ({}) }
|
|
1003
|
+
templateData: { default: () => [] },
|
|
1004
|
+
stopText: { default: "" }
|
|
1078
1005
|
},
|
|
1079
|
-
emits: ["update:modelValue", "submit", "clear", "speech-start", "speech-end", "speech-interim", "speech-error", "suggestion-select", "focus", "blur", "escape-press", "cancel", "reset-template"],
|
|
1080
|
-
setup(
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
activeSuggestion:
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1006
|
+
emits: ["update:modelValue", "update:templateData", "submit", "clear", "speech-start", "speech-end", "speech-interim", "speech-error", "suggestion-select", "focus", "blur", "escape-press", "cancel", "reset-template", "files-selected"],
|
|
1007
|
+
setup(l, { expose: c, emit: s }) {
|
|
1008
|
+
var $;
|
|
1009
|
+
const u = l, y = s, S = K(null), a = K(null), d = K(null), x = K(null), h = K(null), _ = D(() => u.templateData && u.templateData.length > 0), { inputValue: v, isComposing: A, clearInput: P } = St(u, y), M = D(() => !!v.value.trim()), F = D(() => {
|
|
1010
|
+
var t, m;
|
|
1011
|
+
return !(u.disabled || u.loading || !M.value || me.value || (m = (t = u.buttonGroup) == null ? void 0 : t.submit) != null && m.disabled);
|
|
1012
|
+
}), {
|
|
1013
|
+
isPopupVisible: T,
|
|
1014
|
+
activeSuggestion: g,
|
|
1015
|
+
activeKeyboardIndex: E,
|
|
1016
|
+
activeMouseIndex: p,
|
|
1017
|
+
autoCompleteText: Z,
|
|
1018
|
+
showTabIndicator: B,
|
|
1019
|
+
syncAutoComplete: q,
|
|
1020
|
+
closePopup: Y,
|
|
1021
|
+
applySuggestion: N,
|
|
1022
|
+
confirmSelection: k,
|
|
1023
|
+
navigateWithKeyboard: G,
|
|
1024
|
+
handleMouseEnter: j,
|
|
1025
|
+
handleMouseLeave: ae
|
|
1026
|
+
} = kt(
|
|
1027
|
+
D(() => u.suggestions),
|
|
1028
|
+
v,
|
|
1029
|
+
A,
|
|
1030
|
+
_,
|
|
1031
|
+
(t) => y("update:modelValue", t),
|
|
1032
|
+
(t) => y("suggestion-select", t)
|
|
1033
|
+
), V = K(u.mode), z = K(!1), ve = () => {
|
|
1034
|
+
V.value === "single" && (V.value = "multiple", ee(() => {
|
|
1099
1035
|
setTimeout(() => {
|
|
1100
|
-
const
|
|
1101
|
-
if (
|
|
1102
|
-
|
|
1103
|
-
const
|
|
1104
|
-
|
|
1036
|
+
const t = document.querySelector(".tiny-textarea__inner");
|
|
1037
|
+
if (t) {
|
|
1038
|
+
t.style.whiteSpace = "pre-wrap";
|
|
1039
|
+
const m = v.value.length;
|
|
1040
|
+
t.focus(), t.setSelectionRange(m, m);
|
|
1105
1041
|
}
|
|
1106
1042
|
}, 50);
|
|
1107
1043
|
}));
|
|
1108
|
-
},
|
|
1109
|
-
const
|
|
1110
|
-
|
|
1111
|
-
const
|
|
1112
|
-
return document.body.removeChild(
|
|
1113
|
-
},
|
|
1114
|
-
var
|
|
1115
|
-
if (
|
|
1116
|
-
const
|
|
1117
|
-
if (!
|
|
1118
|
-
const
|
|
1119
|
-
if (!
|
|
1044
|
+
}, oe = (t, m) => {
|
|
1045
|
+
const R = document.createElement("span");
|
|
1046
|
+
R.style.visibility = "hidden", R.style.position = "absolute", R.style.whiteSpace = "nowrap", R.style.font = m, R.textContent = t, document.body.appendChild(R);
|
|
1047
|
+
const le = R.offsetWidth;
|
|
1048
|
+
return document.body.removeChild(R), le;
|
|
1049
|
+
}, Ce = () => {
|
|
1050
|
+
var Oe, Ne, He;
|
|
1051
|
+
if (u.mode !== "single" || !S.value || z.value || !a.value || !x.value) return;
|
|
1052
|
+
const t = a.value.querySelector(".tiny-sender__content-area");
|
|
1053
|
+
if (!t) return;
|
|
1054
|
+
const m = ((Ne = (Oe = S.value) == null ? void 0 : Oe.querySelector) == null ? void 0 : Ne.call(Oe, ".tiny-input__inner")) || t.querySelector(".tiny-input__inner"), R = h.value || a.value.querySelector(".tiny-sender__buttons-container");
|
|
1055
|
+
if (!m) {
|
|
1120
1056
|
console.warn("Cannot find input element for overflow check");
|
|
1121
1057
|
return;
|
|
1122
1058
|
}
|
|
1123
|
-
const
|
|
1124
|
-
if (
|
|
1125
|
-
setTimeout(() =>
|
|
1059
|
+
const le = m.getBoundingClientRect(), Ke = R == null ? void 0 : R.getBoundingClientRect();
|
|
1060
|
+
if (le.width === 0) {
|
|
1061
|
+
setTimeout(() => Ce(), 50);
|
|
1126
1062
|
return;
|
|
1127
1063
|
}
|
|
1128
|
-
const
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
var
|
|
1132
|
-
const
|
|
1133
|
-
if (
|
|
1134
|
-
|
|
1135
|
-
const
|
|
1136
|
-
|
|
1064
|
+
const Xe = window.getComputedStyle(m).font, Ze = oe(v.value, Xe), Ve = (He = a.value) == null ? void 0 : He.classList.contains("tr-sender-compact"), Qe = Ve ? 12 : 20, Ye = le.width, et = (Ke == null ? void 0 : Ke.width) || 0, We = Ye - et - Qe, tt = Ve ? 50 : 80;
|
|
1065
|
+
Ze > We && We > tt && V.value === "single" && (z.value = !0, V.value = "multiple", ee(() => {
|
|
1066
|
+
S.value ? setTimeout(() => {
|
|
1067
|
+
var Ue;
|
|
1068
|
+
const Ee = (Ue = a.value) == null ? void 0 : Ue.querySelector(".tiny-textarea__inner");
|
|
1069
|
+
if (Ee) {
|
|
1070
|
+
Ee.style.whiteSpace = "pre-wrap";
|
|
1071
|
+
const qe = v.value.length;
|
|
1072
|
+
Ee.focus(), Ee.setSelectionRange(qe, qe);
|
|
1137
1073
|
}
|
|
1138
|
-
|
|
1139
|
-
}, 300) :
|
|
1074
|
+
z.value = !1;
|
|
1075
|
+
}, 300) : z.value = !1;
|
|
1140
1076
|
}));
|
|
1141
|
-
},
|
|
1142
|
-
if (
|
|
1143
|
-
|
|
1144
|
-
else if (
|
|
1145
|
-
|
|
1077
|
+
}, J = () => {
|
|
1078
|
+
if (_.value && d.value)
|
|
1079
|
+
f();
|
|
1080
|
+
else if (S.value)
|
|
1081
|
+
S.value.focus();
|
|
1082
|
+
else {
|
|
1083
|
+
const t = document.querySelector(".tiny-input__inner");
|
|
1084
|
+
t == null || t.focus();
|
|
1085
|
+
}
|
|
1086
|
+
}, xe = () => {
|
|
1087
|
+
if (S.value)
|
|
1088
|
+
S.value.blur();
|
|
1146
1089
|
else {
|
|
1147
|
-
const
|
|
1148
|
-
|
|
1090
|
+
const t = document.querySelector(".tiny-input__inner");
|
|
1091
|
+
t == null || t.blur();
|
|
1149
1092
|
}
|
|
1150
|
-
},
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1093
|
+
}, ue = () => {
|
|
1094
|
+
var t;
|
|
1095
|
+
y("update:templateData", []), (t = d.value) == null || t.clearHistory(), ee(() => {
|
|
1096
|
+
v.value === "" && (V.value = u.mode || "single"), setTimeout(() => {
|
|
1097
|
+
J();
|
|
1154
1098
|
}, 50);
|
|
1155
1099
|
});
|
|
1156
|
-
},
|
|
1157
|
-
var
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
}), N();
|
|
1161
|
-
}, He = (d) => {
|
|
1162
|
-
x("update:modelValue", d);
|
|
1163
|
-
}, Ce = () => {
|
|
1164
|
-
r.value && r.value.activateFirstField();
|
|
1165
|
-
}, Ke = (d, k) => {
|
|
1166
|
-
p.value = !0, W(() => {
|
|
1167
|
-
r.value && r.value.setTemplate({ template: d, initialValues: k });
|
|
1100
|
+
}, ye = () => {
|
|
1101
|
+
var t;
|
|
1102
|
+
P(), _.value ? ue() : (t = a.value) == null || t.focus(), ee(() => {
|
|
1103
|
+
v.value === "" && (V.value = u.mode || "single");
|
|
1168
1104
|
});
|
|
1169
|
-
},
|
|
1170
|
-
const
|
|
1105
|
+
}, Be = (t) => {
|
|
1106
|
+
const m = (le) => le.type === "text" && le.content === "";
|
|
1107
|
+
if (t.length === 0 || t.every(m)) {
|
|
1108
|
+
ue();
|
|
1109
|
+
return;
|
|
1110
|
+
}
|
|
1111
|
+
y("update:templateData", t);
|
|
1112
|
+
};
|
|
1113
|
+
te(
|
|
1114
|
+
() => u.templateData,
|
|
1115
|
+
() => {
|
|
1116
|
+
v.value = u.templateData.map((t) => t.content).join("");
|
|
1117
|
+
},
|
|
1118
|
+
{ deep: !0 }
|
|
1119
|
+
);
|
|
1120
|
+
const Le = D(() => {
|
|
1121
|
+
const t = typeof u.speech == "object" ? u.speech : {};
|
|
1171
1122
|
return {
|
|
1172
|
-
...
|
|
1173
|
-
onStart: () =>
|
|
1174
|
-
onEnd: (
|
|
1175
|
-
onInterim: (
|
|
1176
|
-
onFinal: (
|
|
1177
|
-
if (
|
|
1178
|
-
|
|
1123
|
+
...t,
|
|
1124
|
+
onStart: () => y("speech-start"),
|
|
1125
|
+
onEnd: (m) => y("speech-end", m),
|
|
1126
|
+
onInterim: (m) => y("speech-interim", m),
|
|
1127
|
+
onFinal: (m) => {
|
|
1128
|
+
if (t.autoReplace)
|
|
1129
|
+
v.value = m;
|
|
1179
1130
|
else {
|
|
1180
|
-
const
|
|
1181
|
-
|
|
1131
|
+
const R = v.value;
|
|
1132
|
+
R && m && !R.endsWith(" ") && !m.startsWith(" ") && R.length > 0 ? v.value = R + " " + m : v.value = R + m;
|
|
1182
1133
|
}
|
|
1183
|
-
|
|
1134
|
+
y("speech-end", m);
|
|
1184
1135
|
},
|
|
1185
|
-
onError: (
|
|
1186
|
-
|
|
1136
|
+
onError: (m) => {
|
|
1137
|
+
y("speech-error", m);
|
|
1187
1138
|
}
|
|
1188
1139
|
};
|
|
1189
|
-
}), { speechState:
|
|
1190
|
-
|
|
1191
|
-
},
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1140
|
+
}), { speechState: se, start: ce, stop: ke } = xt(Le.value), ge = () => {
|
|
1141
|
+
se.isRecording ? ke() : ce();
|
|
1142
|
+
}, me = D(() => u.maxLength !== 1 / 0 && v.value.length > u.maxLength), { handleKeyPress: de, triggerSubmit: fe } = Ct(
|
|
1143
|
+
u,
|
|
1144
|
+
y,
|
|
1145
|
+
v,
|
|
1146
|
+
A,
|
|
1147
|
+
se,
|
|
1148
|
+
T,
|
|
1149
|
+
g,
|
|
1150
|
+
k,
|
|
1151
|
+
Y,
|
|
1152
|
+
G,
|
|
1153
|
+
ge,
|
|
1154
|
+
F,
|
|
1155
|
+
V,
|
|
1156
|
+
ve,
|
|
1197
1157
|
_,
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
x("blur", d), N();
|
|
1210
|
-
}, Ue = P(() => s.value === "multiple" ? "textarea" : "text"), Ze = P(
|
|
1211
|
-
() => ({
|
|
1212
|
-
display: "flex",
|
|
1213
|
-
justifyContent: o.showWordLimit && o.maxLength !== 1 / 0 ? "space-between" : "flex-end",
|
|
1214
|
-
alignItems: "center"
|
|
1215
|
-
})
|
|
1216
|
-
), Ge = ct(), Je = P(() => !!Ge.decorativeContent), ue = P(() => o.disabled || Je.value), Ee = P(() => o.loading), _e = P(() => o.hasContent !== void 0 ? o.hasContent : !!a.value), Qe = P(() => ({
|
|
1217
|
-
"is-disabled": ue.value,
|
|
1218
|
-
"is-loading": Ee.value,
|
|
1219
|
-
"has-error": !!oe.value,
|
|
1220
|
-
"is-auto-switching": g.value
|
|
1221
|
-
})), Ye = P(() => ({
|
|
1222
|
-
width: ht(o.suggestionPopupWidth),
|
|
1158
|
+
ue
|
|
1159
|
+
), Ie = (t) => {
|
|
1160
|
+
y("focus", t), v.value && !_.value && (T.value = !0);
|
|
1161
|
+
}, Te = (t) => {
|
|
1162
|
+
y("blur", t), Y();
|
|
1163
|
+
}, De = D(() => V.value === "multiple" ? "textarea" : "text"), Ae = ct(), Re = D(() => !!Ae.decorativeContent), e = D(() => u.disabled || Re.value), n = D(() => u.loading), o = D(() => ({
|
|
1164
|
+
"is-disabled": e.value,
|
|
1165
|
+
"is-loading": n.value,
|
|
1166
|
+
"is-auto-switching": z.value
|
|
1167
|
+
})), i = D(() => ({
|
|
1168
|
+
width: wt(u.suggestionPopupWidth),
|
|
1223
1169
|
maxWidth: "100%"
|
|
1224
1170
|
// 确保不超出父容器宽度
|
|
1225
|
-
})),
|
|
1226
|
-
|
|
1227
|
-
}, tt = () => {
|
|
1228
|
-
b.value = !1, setTimeout(() => {
|
|
1229
|
-
b.value = !1, K();
|
|
1230
|
-
}, 50);
|
|
1171
|
+
})), r = () => {
|
|
1172
|
+
A.value = !1;
|
|
1231
1173
|
};
|
|
1232
|
-
|
|
1233
|
-
|
|
1174
|
+
te(v, () => {
|
|
1175
|
+
ee(Ce), v.value === "" && u.mode === "single" && (V.value = "single"), q();
|
|
1234
1176
|
}), te(
|
|
1235
|
-
() =>
|
|
1236
|
-
(
|
|
1237
|
-
|
|
1177
|
+
() => _.value,
|
|
1178
|
+
(t) => {
|
|
1179
|
+
t && (V.value = "multiple");
|
|
1238
1180
|
}
|
|
1239
|
-
)
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
setTemplate: Ke
|
|
1255
|
-
}), (d, k) => (D(), A("div", {
|
|
1181
|
+
);
|
|
1182
|
+
const f = () => {
|
|
1183
|
+
d.value && d.value.activateFirstField();
|
|
1184
|
+
}, { accept: w = "*", multiple: L = !0 } = (($ = u.buttonGroup) == null ? void 0 : $.file) || {}, { open: H, files: O } = pt({ accept: w, multiple: L });
|
|
1185
|
+
return te(O, (t) => {
|
|
1186
|
+
t && t.length > 0 && y("files-selected", Array.from(t));
|
|
1187
|
+
}), c({
|
|
1188
|
+
focus: J,
|
|
1189
|
+
blur: xe,
|
|
1190
|
+
clear: ye,
|
|
1191
|
+
submit: fe,
|
|
1192
|
+
startSpeech: ce,
|
|
1193
|
+
stopSpeech: ke,
|
|
1194
|
+
activateTemplateFirstField: f
|
|
1195
|
+
}), (t, m) => (b(), I("div", {
|
|
1256
1196
|
ref_key: "senderRef",
|
|
1257
|
-
ref:
|
|
1258
|
-
class:
|
|
1259
|
-
"data-theme":
|
|
1197
|
+
ref: a,
|
|
1198
|
+
class: ne(["tiny-sender", [o.value, `theme-${t.theme}`, `mode-${V.value}`]]),
|
|
1199
|
+
"data-theme": t.theme
|
|
1260
1200
|
}, [
|
|
1261
|
-
U("div",
|
|
1201
|
+
U("div", qt, [
|
|
1262
1202
|
U("div", {
|
|
1263
1203
|
class: "tiny-sender__input-wrapper",
|
|
1264
1204
|
ref_key: "inputWrapperRef",
|
|
1265
|
-
ref:
|
|
1205
|
+
ref: x
|
|
1266
1206
|
}, [
|
|
1267
|
-
|
|
1268
|
-
default:
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
])) :
|
|
1207
|
+
X(Pe, { name: "tiny-sender-slide-down" }, {
|
|
1208
|
+
default: pe(() => [
|
|
1209
|
+
t.$slots.header ? (b(), I("div", zt, [
|
|
1210
|
+
re(t.$slots, "header", {}, void 0, !0)
|
|
1211
|
+
])) : W("", !0)
|
|
1272
1212
|
]),
|
|
1273
1213
|
_: 3
|
|
1274
1214
|
}),
|
|
1275
1215
|
U("div", {
|
|
1276
|
-
class:
|
|
1216
|
+
class: ne(["tiny-sender__input-row", { "has-prefix": t.$slots.prefix, "has-header": t.$slots.header }])
|
|
1277
1217
|
}, [
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
])) :
|
|
1281
|
-
U("div",
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
])) :
|
|
1285
|
-
|
|
1218
|
+
t.$slots.prefix ? (b(), I("div", Gt, [
|
|
1219
|
+
re(t.$slots, "prefix", {}, void 0, !0)
|
|
1220
|
+
])) : W("", !0),
|
|
1221
|
+
U("div", jt, [
|
|
1222
|
+
t.$slots.decorativeContent ? (b(), I("div", Jt, [
|
|
1223
|
+
re(t.$slots, "decorativeContent", {}, void 0, !0)
|
|
1224
|
+
])) : W("", !0),
|
|
1225
|
+
_.value ? (b(), Q(Mt, {
|
|
1286
1226
|
key: 1,
|
|
1287
1227
|
ref_key: "templateEditorRef",
|
|
1288
|
-
ref:
|
|
1289
|
-
value:
|
|
1290
|
-
"onUpdate:
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
G(E(ft), {
|
|
1228
|
+
ref: d,
|
|
1229
|
+
"model-value": u.templateData,
|
|
1230
|
+
"onUpdate:modelValue": Be,
|
|
1231
|
+
onSubmit: C(fe)
|
|
1232
|
+
}, null, 8, ["model-value", "onSubmit"])) : (b(), I("div", Xt, [
|
|
1233
|
+
X(C(ft), {
|
|
1295
1234
|
ref_key: "inputRef",
|
|
1296
|
-
ref:
|
|
1297
|
-
autosize:
|
|
1298
|
-
type:
|
|
1299
|
-
readonly: Ee.value,
|
|
1235
|
+
ref: S,
|
|
1236
|
+
autosize: t.autoSize,
|
|
1237
|
+
type: De.value,
|
|
1300
1238
|
resize: "none",
|
|
1301
|
-
modelValue:
|
|
1302
|
-
"onUpdate:modelValue":
|
|
1303
|
-
disabled:
|
|
1304
|
-
placeholder:
|
|
1305
|
-
autofocus:
|
|
1306
|
-
onKeydown:
|
|
1307
|
-
onCompositionstart:
|
|
1308
|
-
onCompositionend:
|
|
1309
|
-
onFocus:
|
|
1310
|
-
onBlur:
|
|
1311
|
-
}, null, 8, ["autosize", "type", "
|
|
1312
|
-
|
|
1313
|
-
U("span",
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
])) :
|
|
1239
|
+
modelValue: C(v),
|
|
1240
|
+
"onUpdate:modelValue": m[0] || (m[0] = (R) => dt(v) ? v.value = R : null),
|
|
1241
|
+
disabled: e.value,
|
|
1242
|
+
placeholder: t.placeholder,
|
|
1243
|
+
autofocus: t.autofocus,
|
|
1244
|
+
onKeydown: C(de),
|
|
1245
|
+
onCompositionstart: m[1] || (m[1] = (R) => A.value = !0),
|
|
1246
|
+
onCompositionend: r,
|
|
1247
|
+
onFocus: Ie,
|
|
1248
|
+
onBlur: Te
|
|
1249
|
+
}, null, 8, ["autosize", "type", "modelValue", "disabled", "placeholder", "autofocus", "onKeydown"]),
|
|
1250
|
+
C(Z) && !C(A) ? (b(), I("div", Zt, [
|
|
1251
|
+
U("span", Qt, ie(C(v)), 1),
|
|
1252
|
+
ze(ie(C(Z)) + " ", 1),
|
|
1253
|
+
C(B) ? (b(), I("div", Yt, "TAB")) : W("", !0)
|
|
1254
|
+
])) : W("", !0)
|
|
1317
1255
|
]))
|
|
1318
1256
|
]),
|
|
1319
|
-
|
|
1257
|
+
V.value === "single" ? (b(), I("div", en, [
|
|
1320
1258
|
U("div", {
|
|
1321
1259
|
class: "tiny-sender__buttons-container",
|
|
1322
1260
|
ref_key: "buttonsContainerRef",
|
|
1323
|
-
ref:
|
|
1261
|
+
ref: h
|
|
1324
1262
|
}, [
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
"allow-speech":
|
|
1328
|
-
"allow-files":
|
|
1329
|
-
loading:
|
|
1330
|
-
disabled:
|
|
1331
|
-
"show-clear":
|
|
1332
|
-
"has-content":
|
|
1333
|
-
"speech-status":
|
|
1334
|
-
"
|
|
1335
|
-
"
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1263
|
+
re(t.$slots, "actions", {}, void 0, !0),
|
|
1264
|
+
X(Ge, {
|
|
1265
|
+
"allow-speech": t.allowSpeech,
|
|
1266
|
+
"allow-files": t.allowFiles,
|
|
1267
|
+
loading: t.loading,
|
|
1268
|
+
disabled: e.value,
|
|
1269
|
+
"show-clear": t.clearable,
|
|
1270
|
+
"has-content": M.value,
|
|
1271
|
+
"speech-status": C(se),
|
|
1272
|
+
"button-group": t.buttonGroup,
|
|
1273
|
+
"submit-type": t.submitType,
|
|
1274
|
+
"is-over-limit": me.value,
|
|
1275
|
+
"stop-text": t.stopText,
|
|
1276
|
+
onClear: ye,
|
|
1277
|
+
onToggleSpeech: ge,
|
|
1278
|
+
onSubmit: C(fe),
|
|
1279
|
+
onCancel: m[2] || (m[2] = (R) => t.$emit("cancel")),
|
|
1280
|
+
onTriggerSelect: C(H)
|
|
1281
|
+
}, null, 8, ["allow-speech", "allow-files", "loading", "disabled", "show-clear", "has-content", "speech-status", "button-group", "submit-type", "is-over-limit", "stop-text", "onSubmit", "onTriggerSelect"])
|
|
1341
1282
|
], 512)
|
|
1342
|
-
])) :
|
|
1283
|
+
])) : W("", !0)
|
|
1343
1284
|
], 2),
|
|
1344
|
-
|
|
1345
|
-
default:
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
class: "tiny-sender__footer-slot tiny-sender__bottom-row"
|
|
1350
|
-
}, [
|
|
1351
|
-
U("div", jt, [
|
|
1352
|
-
se(d.$slots, "footer-left")
|
|
1285
|
+
X(Pe, { name: "tiny-sender-slide-up" }, {
|
|
1286
|
+
default: pe(() => [
|
|
1287
|
+
V.value === "multiple" ? (b(), I("div", tn, [
|
|
1288
|
+
U("div", nn, [
|
|
1289
|
+
re(t.$slots, "footer-left", {}, void 0, !0)
|
|
1353
1290
|
]),
|
|
1354
|
-
U("div",
|
|
1355
|
-
|
|
1356
|
-
|
|
1291
|
+
U("div", on, [
|
|
1292
|
+
re(t.$slots, "footer-right", {}, void 0, !0),
|
|
1293
|
+
t.showWordLimit && t.maxLength !== 1 / 0 ? (b(), I("div", {
|
|
1357
1294
|
key: 0,
|
|
1358
|
-
class:
|
|
1295
|
+
class: ne(["tiny-sender__word-limit", { "is-over-limit": me.value }])
|
|
1359
1296
|
}, [
|
|
1360
|
-
U("span",
|
|
1361
|
-
|
|
1362
|
-
], 2)) :
|
|
1363
|
-
|
|
1364
|
-
U("div",
|
|
1365
|
-
|
|
1366
|
-
"allow-speech":
|
|
1367
|
-
"allow-files":
|
|
1368
|
-
loading:
|
|
1369
|
-
disabled:
|
|
1370
|
-
"show-clear":
|
|
1371
|
-
"has-content":
|
|
1372
|
-
"speech-status":
|
|
1373
|
-
"
|
|
1374
|
-
"
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1297
|
+
U("span", sn, ie(C(v).length), 1),
|
|
1298
|
+
ze("/" + ie(t.maxLength), 1)
|
|
1299
|
+
], 2)) : W("", !0),
|
|
1300
|
+
V.value === "multiple" ? (b(), I("div", an, [
|
|
1301
|
+
U("div", ln, [
|
|
1302
|
+
X(Ge, {
|
|
1303
|
+
"allow-speech": t.allowSpeech,
|
|
1304
|
+
"allow-files": t.allowFiles,
|
|
1305
|
+
loading: t.loading,
|
|
1306
|
+
disabled: e.value,
|
|
1307
|
+
"show-clear": t.clearable,
|
|
1308
|
+
"has-content": M.value,
|
|
1309
|
+
"speech-status": C(se),
|
|
1310
|
+
"button-group": t.buttonGroup,
|
|
1311
|
+
"submit-type": t.submitType,
|
|
1312
|
+
"is-over-limit": me.value,
|
|
1313
|
+
"stop-text": t.stopText,
|
|
1314
|
+
onClear: ye,
|
|
1315
|
+
onToggleSpeech: ge,
|
|
1316
|
+
onSubmit: C(fe),
|
|
1317
|
+
onCancel: m[3] || (m[3] = (R) => t.$emit("cancel")),
|
|
1318
|
+
onTriggerSelect: C(H)
|
|
1319
|
+
}, null, 8, ["allow-speech", "allow-files", "loading", "disabled", "show-clear", "has-content", "speech-status", "button-group", "submit-type", "is-over-limit", "stop-text", "onSubmit", "onTriggerSelect"])
|
|
1380
1320
|
])
|
|
1381
|
-
])) :
|
|
1321
|
+
])) : W("", !0)
|
|
1382
1322
|
])
|
|
1383
|
-
]
|
|
1384
|
-
|
|
1385
|
-
])) :
|
|
1323
|
+
])) : t.$slots.footer ? (b(), I("div", rn, [
|
|
1324
|
+
re(t.$slots, "footer", {}, void 0, !0)
|
|
1325
|
+
])) : W("", !0)
|
|
1386
1326
|
]),
|
|
1387
1327
|
_: 3
|
|
1388
1328
|
})
|
|
1389
1329
|
], 512)
|
|
1390
1330
|
]),
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
onMouseenter: (Z) => E(e)(ne),
|
|
1404
|
-
onMouseleave: k[5] || (k[5] = //@ts-ignore
|
|
1405
|
-
(...Z) => E(l) && E(l)(...Z)),
|
|
1406
|
-
onMousedown: dt((Z) => E(C)(F), ["prevent"])
|
|
1407
|
-
}, [
|
|
1408
|
-
G(E(St), { class: "suggestion-item__icon" }),
|
|
1409
|
-
U("span", en, [
|
|
1410
|
-
(D(!0), A(Ae, null, Me(E(n)(F, E(a)), (Z, ge) => (D(), A("span", {
|
|
1411
|
-
key: ge,
|
|
1412
|
-
class: ae({ "suggestion-item__text--match": Z.isMatch, "suggestion-item__text--normal": !Z.isMatch })
|
|
1413
|
-
}, le(Z.text), 3))), 128))
|
|
1414
|
-
])
|
|
1415
|
-
], 42, Yt))), 128))
|
|
1416
|
-
], 4)) : H("", !0)
|
|
1417
|
-
]),
|
|
1418
|
-
_: 1
|
|
1419
|
-
}),
|
|
1420
|
-
oe.value ? (D(), A("div", tn, le(oe.value), 1)) : H("", !0)
|
|
1421
|
-
], 10, Mt));
|
|
1331
|
+
X(Ht, {
|
|
1332
|
+
show: C(T),
|
|
1333
|
+
suggestions: t.suggestions,
|
|
1334
|
+
"popup-style": i.value,
|
|
1335
|
+
"active-keyboard-index": C(E),
|
|
1336
|
+
"active-mouse-index": C(p),
|
|
1337
|
+
"input-value": C(v),
|
|
1338
|
+
onSelect: C(N),
|
|
1339
|
+
onMouseEnter: C(j),
|
|
1340
|
+
onMouseLeave: C(ae)
|
|
1341
|
+
}, null, 8, ["show", "suggestions", "popup-style", "active-keyboard-index", "active-mouse-index", "input-value", "onSelect", "onMouseEnter", "onMouseLeave"])
|
|
1342
|
+
], 10, Ut));
|
|
1422
1343
|
}
|
|
1423
|
-
});
|
|
1424
|
-
|
|
1425
|
-
const
|
|
1426
|
-
|
|
1344
|
+
}), $e = /* @__PURE__ */ Se(un, [["__scopeId", "data-v-6b3efd0e"]]);
|
|
1345
|
+
$e.name = "TrSender";
|
|
1346
|
+
const cn = function(l) {
|
|
1347
|
+
l.component($e.name, $e);
|
|
1427
1348
|
};
|
|
1428
|
-
|
|
1349
|
+
$e.install = cn;
|
|
1429
1350
|
export {
|
|
1430
|
-
|
|
1351
|
+
$e as default
|
|
1431
1352
|
};
|