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