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