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