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