@opentiny/tiny-robot 0.3.2 → 0.3.3
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/index.d.ts +3 -3
- package/dist/sender/index.js +376 -370
- package/package.json +3 -3
package/dist/sender/index.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var Pe = (n,
|
|
4
|
-
import { ref as K, watch as ne, reactive as lt, onUnmounted as tt, computed as E, defineComponent as Ce, isVNode as rt, openBlock as m, createElementBlock as I, normalizeStyle as Ue, createBlock as ee, unref as k, withCtx as ve, createElementVNode as
|
|
1
|
+
var at = Object.defineProperty;
|
|
2
|
+
var it = (n, i, l) => i in n ? at(n, i, { enumerable: !0, configurable: !0, writable: !0, value: l }) : n[i] = l;
|
|
3
|
+
var Pe = (n, i, l) => it(n, typeof i != "symbol" ? i + "" : i, l);
|
|
4
|
+
import { ref as K, watch as ne, reactive as lt, onUnmounted as tt, computed as E, defineComponent as Ce, isVNode as rt, openBlock as m, createElementBlock as I, normalizeStyle as Ue, createBlock as ee, unref as k, withCtx as ve, createElementVNode as U, createVNode as Z, normalizeClass as oe, createCommentVNode as P, resolveDynamicComponent as ct, toDisplayString as de, useAttrs as ut, resolveComponent as dt, mergeProps as Se, Fragment as ye, renderList as xe, useModel as ft, onMounted as pt, nextTick as q, mergeModels as Ze, Transition as ze, withModifiers as ht, useSlots as vt, toRef as Me, renderSlot as ie, isRef as yt, createTextVNode as Qe } from "vue";
|
|
5
5
|
import { TinyTooltip as We, TinyInput as gt } from "@opentiny/vue";
|
|
6
6
|
import { f as mt } from "../index4.js";
|
|
7
7
|
import { IconVoice as wt, IconUpload as bt, IconRecordingWave as St, IconClear as xt, IconSend as Ct, IconStop as _t, IconAssociate as kt } from "@opentiny/tiny-robot-svgs";
|
|
8
8
|
import { _ as _e } from "../_plugin-vue_export-helper.js";
|
|
9
9
|
import { t as It } from "../utils.js";
|
|
10
|
-
function Rt(n,
|
|
10
|
+
function Rt(n, i) {
|
|
11
11
|
const l = K(n.modelValue || n.defaultValue || ""), r = K(null);
|
|
12
12
|
ne(
|
|
13
13
|
() => n.modelValue,
|
|
@@ -17,23 +17,23 @@ function Rt(n, a) {
|
|
|
17
17
|
), ne(
|
|
18
18
|
() => l.value,
|
|
19
19
|
(y) => {
|
|
20
|
-
|
|
20
|
+
i("update:modelValue", y);
|
|
21
21
|
}
|
|
22
22
|
);
|
|
23
|
-
const
|
|
24
|
-
l.value = y,
|
|
23
|
+
const f = (y) => {
|
|
24
|
+
l.value = y, i("update:modelValue", y);
|
|
25
25
|
}, _ = (y) => {
|
|
26
26
|
y == null || y.preventDefault();
|
|
27
27
|
const C = l.value;
|
|
28
|
-
!n.disabled && !n.loading && C.trim() &&
|
|
28
|
+
!n.disabled && !n.loading && C.trim() && i("submit", C);
|
|
29
29
|
}, p = () => {
|
|
30
|
-
l.value = "",
|
|
30
|
+
l.value = "", i("update:modelValue", ""), i("clear");
|
|
31
31
|
}, h = K(!1);
|
|
32
32
|
return {
|
|
33
33
|
inputValue: l,
|
|
34
34
|
inputWrapper: r,
|
|
35
35
|
isComposing: h,
|
|
36
|
-
handleChange:
|
|
36
|
+
handleChange: f,
|
|
37
37
|
handleSubmit: _,
|
|
38
38
|
handleClear: p,
|
|
39
39
|
clearInput: () => {
|
|
@@ -41,70 +41,76 @@ function Rt(n, a) {
|
|
|
41
41
|
}
|
|
42
42
|
};
|
|
43
43
|
}
|
|
44
|
-
function Tt(n,
|
|
44
|
+
function Tt(n, i, l, r, f, _, p, h, v, y, C, g, O, V, H, F) {
|
|
45
45
|
const M = () => {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
if (
|
|
49
|
-
|
|
46
|
+
if (!g.value) return;
|
|
47
|
+
const d = l.value.trim();
|
|
48
|
+
if (H != null && H.value && Array.isArray(n.templateData)) {
|
|
49
|
+
const b = n.templateData.map(({ id: z, ...j }) => j);
|
|
50
|
+
i("submit", d, b), F == null || F();
|
|
51
|
+
} else
|
|
52
|
+
i("submit", d);
|
|
53
|
+
}, R = (d, b) => {
|
|
54
|
+
if (!(d.key === "Enter")) return !1;
|
|
55
|
+
switch (b) {
|
|
50
56
|
case "enter":
|
|
51
|
-
return !
|
|
57
|
+
return !d.shiftKey && !d.ctrlKey && !d.metaKey;
|
|
52
58
|
case "ctrlEnter":
|
|
53
|
-
return (
|
|
59
|
+
return (d.ctrlKey || d.metaKey) && !d.shiftKey;
|
|
54
60
|
case "shiftEnter":
|
|
55
|
-
return
|
|
61
|
+
return d.shiftKey && !d.ctrlKey && !d.metaKey;
|
|
56
62
|
default:
|
|
57
63
|
return !1;
|
|
58
64
|
}
|
|
59
|
-
}, W = (
|
|
60
|
-
const
|
|
61
|
-
l.value =
|
|
62
|
-
` +
|
|
63
|
-
const B =
|
|
64
|
-
|
|
65
|
+
}, W = (d) => {
|
|
66
|
+
const b = d.selectionStart ?? 0, z = d.selectionEnd ?? b, j = l.value;
|
|
67
|
+
l.value = j.substring(0, b) + `
|
|
68
|
+
` + j.substring(z), setTimeout(() => {
|
|
69
|
+
const B = b + 1;
|
|
70
|
+
d.selectionStart = d.selectionEnd = B, d.scrollTop = d.scrollHeight;
|
|
65
71
|
}, 0);
|
|
66
|
-
},
|
|
67
|
-
if (n.submitType !== "enter" ||
|
|
68
|
-
const
|
|
69
|
-
if (
|
|
70
|
-
|
|
71
|
-
const
|
|
72
|
-
return (O == null ? void 0 : O.value) === "single" && V && V(), W(
|
|
72
|
+
}, S = (d) => {
|
|
73
|
+
if (n.submitType !== "enter" || d.key !== "Enter") return !1;
|
|
74
|
+
const b = d.ctrlKey && !d.shiftKey, z = d.shiftKey && !d.ctrlKey;
|
|
75
|
+
if (b || z) {
|
|
76
|
+
d.preventDefault();
|
|
77
|
+
const j = d.target;
|
|
78
|
+
return (O == null ? void 0 : O.value) === "single" && V && V(), W(j), !0;
|
|
73
79
|
}
|
|
74
80
|
return !1;
|
|
75
81
|
};
|
|
76
82
|
return {
|
|
77
|
-
handleKeyPress: (
|
|
78
|
-
if (!r.value && !
|
|
83
|
+
handleKeyPress: (d) => {
|
|
84
|
+
if (!r.value && !S(d)) {
|
|
79
85
|
if (_.value) {
|
|
80
|
-
if (
|
|
81
|
-
|
|
86
|
+
if (d.key === "ArrowDown") {
|
|
87
|
+
d.preventDefault(), y("down");
|
|
82
88
|
return;
|
|
83
89
|
}
|
|
84
|
-
if (
|
|
85
|
-
|
|
90
|
+
if (d.key === "ArrowUp") {
|
|
91
|
+
d.preventDefault(), y("up");
|
|
86
92
|
return;
|
|
87
93
|
}
|
|
88
|
-
if (p.value && (n.activeSuggestionKeys || ["Enter", "Tab"]).includes(
|
|
89
|
-
|
|
94
|
+
if (p.value && (n.activeSuggestionKeys || ["Enter", "Tab"]).includes(d.key)) {
|
|
95
|
+
d.preventDefault(), h();
|
|
90
96
|
return;
|
|
91
97
|
}
|
|
92
98
|
}
|
|
93
|
-
if (
|
|
94
|
-
_.value ? (v(),
|
|
99
|
+
if (d.key === "Escape") {
|
|
100
|
+
_.value ? (v(), d.preventDefault()) : f.isRecording && (C(), d.preventDefault()), i("escape-press");
|
|
95
101
|
return;
|
|
96
102
|
}
|
|
97
|
-
R(
|
|
103
|
+
R(d, n.submitType) && g.value && (d.preventDefault(), M());
|
|
98
104
|
}
|
|
99
105
|
},
|
|
100
106
|
triggerSubmit: M
|
|
101
107
|
};
|
|
102
108
|
}
|
|
103
109
|
class Le {
|
|
104
|
-
constructor(
|
|
110
|
+
constructor(i) {
|
|
105
111
|
Pe(this, "recognition");
|
|
106
112
|
Pe(this, "options");
|
|
107
|
-
this.options =
|
|
113
|
+
this.options = i, this.initialize();
|
|
108
114
|
}
|
|
109
115
|
/**
|
|
110
116
|
* 初始化语音识别实例
|
|
@@ -128,16 +134,16 @@ class Le {
|
|
|
128
134
|
* 设置语音识别事件处理器
|
|
129
135
|
* @param callbacks 语音识别回调函数集合
|
|
130
136
|
*/
|
|
131
|
-
setupEventHandlers(
|
|
132
|
-
!this.recognition || !
|
|
133
|
-
|
|
137
|
+
setupEventHandlers(i) {
|
|
138
|
+
!this.recognition || !i || (this.recognition.onstart = () => {
|
|
139
|
+
i.onStart();
|
|
134
140
|
}, this.recognition.onend = () => {
|
|
135
|
-
|
|
141
|
+
i.onEnd();
|
|
136
142
|
}, this.recognition.onresult = (l) => {
|
|
137
|
-
const r = Array.from(l.results).map((_) => _[0].transcript).join(""),
|
|
138
|
-
|
|
143
|
+
const r = Array.from(l.results).map((_) => _[0].transcript).join(""), f = l.results[l.resultIndex];
|
|
144
|
+
f != null && f.isFinal ? i.onFinal(r) : i.onInterim(r);
|
|
139
145
|
}, this.recognition.onerror = (l) => {
|
|
140
|
-
|
|
146
|
+
i.onError(new Error(l.error)), this.cleanup();
|
|
141
147
|
});
|
|
142
148
|
}
|
|
143
149
|
/**
|
|
@@ -150,16 +156,16 @@ class Le {
|
|
|
150
156
|
* 开始语音识别
|
|
151
157
|
* @param callbacks 语音识别回调函数集合
|
|
152
158
|
*/
|
|
153
|
-
start(
|
|
159
|
+
start(i) {
|
|
154
160
|
if (!this.recognition) {
|
|
155
|
-
|
|
161
|
+
i.onError(new Error("浏览器不支持语音识别"));
|
|
156
162
|
return;
|
|
157
163
|
}
|
|
158
|
-
this.setupEventHandlers(
|
|
164
|
+
this.setupEventHandlers(i);
|
|
159
165
|
try {
|
|
160
166
|
this.recognition.start();
|
|
161
167
|
} catch (l) {
|
|
162
|
-
|
|
168
|
+
i.onError(l instanceof Error ? l : new Error("语音识别启动失败"));
|
|
163
169
|
}
|
|
164
170
|
}
|
|
165
171
|
/**
|
|
@@ -170,21 +176,21 @@ class Le {
|
|
|
170
176
|
this.cleanup();
|
|
171
177
|
try {
|
|
172
178
|
this.recognition.stop();
|
|
173
|
-
} catch (
|
|
174
|
-
console.warn("停止语音识别时发生错误:",
|
|
179
|
+
} catch (i) {
|
|
180
|
+
console.warn("停止语音识别时发生错误:", i);
|
|
175
181
|
}
|
|
176
182
|
}
|
|
177
183
|
}
|
|
178
184
|
}
|
|
179
185
|
function Et(n) {
|
|
180
|
-
const
|
|
186
|
+
const i = lt({
|
|
181
187
|
isRecording: !1,
|
|
182
188
|
isSupported: !1,
|
|
183
189
|
error: void 0
|
|
184
190
|
}), l = {
|
|
185
191
|
onStart: () => {
|
|
186
192
|
var h;
|
|
187
|
-
|
|
193
|
+
i.isRecording = !0, i.error = void 0, (h = n.onStart) == null || h.call(n);
|
|
188
194
|
},
|
|
189
195
|
onInterim: (h) => {
|
|
190
196
|
var v;
|
|
@@ -196,78 +202,78 @@ function Et(n) {
|
|
|
196
202
|
},
|
|
197
203
|
onEnd: (h) => {
|
|
198
204
|
var v;
|
|
199
|
-
|
|
205
|
+
i.isRecording && (i.isRecording = !1, (v = n.onEnd) == null || v.call(n, h));
|
|
200
206
|
},
|
|
201
207
|
onError: (h) => {
|
|
202
208
|
var v;
|
|
203
|
-
|
|
209
|
+
i.error = h, i.isRecording = !1, (v = n.onError) == null || v.call(n, h);
|
|
204
210
|
}
|
|
205
211
|
}, r = Le.isSupported();
|
|
206
|
-
|
|
207
|
-
const
|
|
212
|
+
i.isSupported = n.customHandler ? n.customHandler.isSupported() : r;
|
|
213
|
+
const f = n.customHandler ?? (r ? new Le(n) : null), _ = () => {
|
|
208
214
|
var h;
|
|
209
|
-
if (!
|
|
215
|
+
if (!i.isSupported || !f) {
|
|
210
216
|
const v = new Error("语音识别不受支持");
|
|
211
|
-
|
|
217
|
+
i.error = v, (h = n.onError) == null || h.call(n, v);
|
|
212
218
|
return;
|
|
213
219
|
}
|
|
214
|
-
if (
|
|
215
|
-
|
|
216
|
-
|
|
220
|
+
if (i.isRecording) {
|
|
221
|
+
f.stop(), i.isRecording = !1, setTimeout(() => {
|
|
222
|
+
f.start(l);
|
|
217
223
|
}, 200);
|
|
218
224
|
return;
|
|
219
225
|
}
|
|
220
|
-
|
|
226
|
+
f.start(l);
|
|
221
227
|
}, p = () => {
|
|
222
|
-
!
|
|
228
|
+
!i.isRecording || !f || (f.stop(), l.onEnd());
|
|
223
229
|
};
|
|
224
230
|
return tt(() => {
|
|
225
|
-
|
|
231
|
+
i.isRecording && f && (f.stop(), i.isRecording = !1);
|
|
226
232
|
}), {
|
|
227
|
-
speechState:
|
|
233
|
+
speechState: i,
|
|
228
234
|
start: _,
|
|
229
235
|
stop: p
|
|
230
236
|
};
|
|
231
237
|
}
|
|
232
|
-
function Ot(n,
|
|
238
|
+
function Ot(n, i, l, r, f, _) {
|
|
233
239
|
const p = K(!1), h = K(-1), v = K(-1), y = K(null), C = K(""), g = K(!1), O = E(() => {
|
|
234
|
-
var
|
|
235
|
-
if (!((
|
|
240
|
+
var J, G;
|
|
241
|
+
if (!((J = n.value) != null && J.length)) return "";
|
|
236
242
|
const B = y.value === "mouse" ? v.value : h.value;
|
|
237
243
|
return ((G = n.value[B]) == null ? void 0 : G.content) || "";
|
|
238
244
|
}), V = (B) => {
|
|
239
245
|
C.value = B, g.value = !0;
|
|
240
|
-
},
|
|
246
|
+
}, H = () => {
|
|
241
247
|
C.value = "", g.value = !1;
|
|
242
248
|
}, F = (B) => {
|
|
243
|
-
const
|
|
244
|
-
if (!
|
|
245
|
-
|
|
249
|
+
const J = B || O.value;
|
|
250
|
+
if (!J || !i.value) {
|
|
251
|
+
H();
|
|
246
252
|
return;
|
|
247
253
|
}
|
|
248
|
-
const G =
|
|
249
|
-
|
|
254
|
+
const G = J.substring(i.value.length);
|
|
255
|
+
J.toLowerCase().startsWith(i.value.toLowerCase()) && G ? V(G) : H();
|
|
250
256
|
}, M = () => {
|
|
251
257
|
h.value = -1, v.value = -1, y.value = null;
|
|
252
258
|
}, R = () => {
|
|
253
259
|
p.value = !0, F();
|
|
254
260
|
}, W = () => {
|
|
255
|
-
p.value = !1, M(),
|
|
256
|
-
},
|
|
261
|
+
p.value = !1, M(), H();
|
|
262
|
+
}, S = E(() => {
|
|
257
263
|
var B;
|
|
258
|
-
return l.value ? !0 : !!(
|
|
264
|
+
return l.value ? !0 : !!(i.value && ((B = n.value) == null ? void 0 : B.length) > 0 && !r.value);
|
|
259
265
|
}), w = (B) => {
|
|
260
|
-
W(),
|
|
261
|
-
},
|
|
266
|
+
W(), i.value = B, f(B), _(B);
|
|
267
|
+
}, d = () => {
|
|
262
268
|
O.value && w(O.value);
|
|
263
|
-
},
|
|
269
|
+
}, b = (B) => {
|
|
264
270
|
!p.value || !n.value || (y.value = "keyboard", h.value === -1 ? h.value = B === "down" ? 0 : n.value.length - 1 : B === "down" ? h.value = (h.value + 1) % n.value.length : h.value = (h.value - 1 + n.value.length) % n.value.length, F());
|
|
265
|
-
},
|
|
271
|
+
}, z = (B) => {
|
|
266
272
|
n.value && (y.value = "mouse", v.value = B, F());
|
|
267
|
-
},
|
|
273
|
+
}, j = () => {
|
|
268
274
|
n.value && (v.value = -1, h.value !== -1 ? y.value = "keyboard" : y.value = null, F());
|
|
269
275
|
};
|
|
270
|
-
return ne(
|
|
276
|
+
return ne(S, (B) => {
|
|
271
277
|
B ? p.value || R() : p.value && W();
|
|
272
278
|
}), {
|
|
273
279
|
// 弹窗控制
|
|
@@ -283,12 +289,12 @@ function Ot(n, a, l, r, d, _) {
|
|
|
283
289
|
activeKeyboardIndex: h,
|
|
284
290
|
activeMouseIndex: v,
|
|
285
291
|
// 交互处理
|
|
286
|
-
navigateWithKeyboard:
|
|
287
|
-
handleMouseEnter:
|
|
288
|
-
handleMouseLeave:
|
|
292
|
+
navigateWithKeyboard: b,
|
|
293
|
+
handleMouseEnter: z,
|
|
294
|
+
handleMouseLeave: j,
|
|
289
295
|
// 业务操作
|
|
290
296
|
applySuggestion: w,
|
|
291
|
-
confirmSelection:
|
|
297
|
+
confirmSelection: d
|
|
292
298
|
};
|
|
293
299
|
}
|
|
294
300
|
const $t = { class: "action-buttons" }, Bt = { class: "action-buttons__submit-content" }, Lt = {
|
|
@@ -314,46 +320,46 @@ const $t = { class: "action-buttons" }, Bt = { class: "action-buttons__submit-co
|
|
|
314
320
|
stopText: { default: void 0 }
|
|
315
321
|
},
|
|
316
322
|
emits: ["clear", "submit", "cancel", "trigger-select", "voice-button-click"],
|
|
317
|
-
setup(n, { emit:
|
|
318
|
-
const l = n, r =
|
|
319
|
-
var w,
|
|
320
|
-
const
|
|
321
|
-
if (typeof
|
|
322
|
-
return () =>
|
|
323
|
-
if (typeof
|
|
324
|
-
return
|
|
323
|
+
setup(n, { emit: i }) {
|
|
324
|
+
const l = n, r = i, f = E(() => {
|
|
325
|
+
var w, d;
|
|
326
|
+
const S = (d = (w = l.buttonGroup) == null ? void 0 : w.file) == null ? void 0 : d.tooltips;
|
|
327
|
+
if (typeof S == "string" && S)
|
|
328
|
+
return () => S;
|
|
329
|
+
if (typeof S == "function")
|
|
330
|
+
return S;
|
|
325
331
|
}), _ = E(() => {
|
|
326
|
-
var w,
|
|
327
|
-
const
|
|
328
|
-
if (typeof
|
|
329
|
-
return () =>
|
|
330
|
-
if (typeof
|
|
331
|
-
return
|
|
332
|
+
var w, d;
|
|
333
|
+
const S = (d = (w = l.buttonGroup) == null ? void 0 : w.submit) == null ? void 0 : d.tooltips;
|
|
334
|
+
if (typeof S == "string" && S)
|
|
335
|
+
return () => S;
|
|
336
|
+
if (typeof S == "function")
|
|
337
|
+
return S;
|
|
332
338
|
}), p = E(() => l.allowSpeech), h = E(() => l.speechStatus.isRecording), v = E(() => l.disabled), y = E(() => {
|
|
333
|
-
var
|
|
334
|
-
return v.value || l.isOverLimit || ((w = (
|
|
339
|
+
var S, w;
|
|
340
|
+
return v.value || l.isOverLimit || ((w = (S = l.buttonGroup) == null ? void 0 : S.submit) == null ? void 0 : w.disabled);
|
|
335
341
|
}), C = E(() => l.allowFiles || l.allowSpeech || l.showClear), g = E(() => {
|
|
336
|
-
var w,
|
|
337
|
-
const
|
|
338
|
-
return
|
|
342
|
+
var w, d;
|
|
343
|
+
const S = (d = (w = l.buttonGroup) == null ? void 0 : w.voice) == null ? void 0 : d.icon;
|
|
344
|
+
return S ? rt(S) ? () => S : S : wt;
|
|
339
345
|
}), O = () => {
|
|
340
346
|
v.value || r("clear");
|
|
341
347
|
}, V = () => {
|
|
342
348
|
v.value || r("voice-button-click");
|
|
343
|
-
},
|
|
349
|
+
}, H = () => {
|
|
344
350
|
y.value || r("submit");
|
|
345
351
|
}, F = () => {
|
|
346
352
|
v.value || r("cancel");
|
|
347
353
|
}, M = E(() => {
|
|
348
|
-
var
|
|
349
|
-
return v.value || ((w = (
|
|
354
|
+
var S, w;
|
|
355
|
+
return v.value || ((w = (S = l.buttonGroup) == null ? void 0 : S.file) == null ? void 0 : w.disabled);
|
|
350
356
|
}), R = () => {
|
|
351
357
|
M.value || r("trigger-select");
|
|
352
358
|
}, W = E(() => {
|
|
353
|
-
var
|
|
354
|
-
return ((w = (
|
|
359
|
+
var S, w;
|
|
360
|
+
return ((w = (S = l.buttonGroup) == null ? void 0 : S.file) == null ? void 0 : w.tooltipPlacement) || "top";
|
|
355
361
|
});
|
|
356
|
-
return (
|
|
362
|
+
return (S, w) => (m(), I("div", $t, [
|
|
357
363
|
C.value ? (m(), I("div", {
|
|
358
364
|
key: 0,
|
|
359
365
|
class: "action-buttons__utility",
|
|
@@ -363,17 +369,17 @@ const $t = { class: "action-buttons" }, Bt = { class: "action-buttons__submit-co
|
|
|
363
369
|
key: 0,
|
|
364
370
|
effect: "light",
|
|
365
371
|
placement: W.value,
|
|
366
|
-
"render-content":
|
|
372
|
+
"render-content": f.value,
|
|
367
373
|
"visible-arrow": !1,
|
|
368
374
|
"popper-class": "tr-sender-actions-upload-button-popper"
|
|
369
375
|
}, {
|
|
370
376
|
default: ve(() => [
|
|
371
|
-
|
|
377
|
+
U("div", {
|
|
372
378
|
class: "action-buttons__button",
|
|
373
379
|
onClick: R,
|
|
374
|
-
onFocusCapture: w[0] || (w[0] = (
|
|
380
|
+
onFocusCapture: w[0] || (w[0] = (d) => d.stopPropagation())
|
|
375
381
|
}, [
|
|
376
|
-
|
|
382
|
+
Z(k(bt), {
|
|
377
383
|
class: oe(["action-buttons__icon", { "is-disabled": M.value }]),
|
|
378
384
|
alt: "上传文件"
|
|
379
385
|
}, null, 8, ["class"])
|
|
@@ -402,11 +408,11 @@ const $t = { class: "action-buttons" }, Bt = { class: "action-buttons__submit-co
|
|
|
402
408
|
placement: "top"
|
|
403
409
|
}, {
|
|
404
410
|
default: ve(() => [
|
|
405
|
-
|
|
411
|
+
U("div", {
|
|
406
412
|
class: "action-buttons__button",
|
|
407
413
|
onClick: O
|
|
408
414
|
}, [
|
|
409
|
-
|
|
415
|
+
Z(k(xt), { class: "action-buttons__icon" })
|
|
410
416
|
])
|
|
411
417
|
]),
|
|
412
418
|
_: 1
|
|
@@ -415,14 +421,14 @@ const $t = { class: "action-buttons" }, Bt = { class: "action-buttons__submit-co
|
|
|
415
421
|
n.hasContent || n.loading ? (m(), I("div", {
|
|
416
422
|
key: 1,
|
|
417
423
|
class: "action-buttons__button action-buttons__submit",
|
|
418
|
-
onClick: w[1] || (w[1] = (
|
|
424
|
+
onClick: w[1] || (w[1] = (d) => n.loading ? F() : H())
|
|
419
425
|
}, [
|
|
420
|
-
|
|
426
|
+
U("div", Bt, [
|
|
421
427
|
n.loading ? (m(), I("div", {
|
|
422
428
|
key: 1,
|
|
423
429
|
class: oe(["action-buttons__cancel", { "action-buttons__cancel--icon-only": !n.stopText }])
|
|
424
430
|
}, [
|
|
425
|
-
|
|
431
|
+
Z(k(_t), {
|
|
426
432
|
class: "action-buttons__icon action-buttons__icon--cancel",
|
|
427
433
|
alt: "停止"
|
|
428
434
|
}),
|
|
@@ -435,7 +441,7 @@ const $t = { class: "action-buttons" }, Bt = { class: "action-buttons__submit-co
|
|
|
435
441
|
"visible-arrow": !1
|
|
436
442
|
}, {
|
|
437
443
|
default: ve(() => [
|
|
438
|
-
|
|
444
|
+
Z(k(Ct), {
|
|
439
445
|
class: oe(["action-buttons__icon", "action-buttons__icon--send", { "is-disabled": y.value }]),
|
|
440
446
|
alt: "发送"
|
|
441
447
|
}, null, 8, ["class"])
|
|
@@ -447,17 +453,17 @@ const $t = { class: "action-buttons" }, Bt = { class: "action-buttons__submit-co
|
|
|
447
453
|
]));
|
|
448
454
|
}
|
|
449
455
|
}), et = /* @__PURE__ */ _e(Dt, [["__scopeId", "data-v-f71ebb23"]]);
|
|
450
|
-
function Kt(n,
|
|
451
|
-
let l = [], r = [],
|
|
456
|
+
function Kt(n, i = {}) {
|
|
457
|
+
let l = [], r = [], f = n;
|
|
452
458
|
return { commit: (C) => {
|
|
453
459
|
var g;
|
|
454
|
-
l.push(
|
|
455
|
-
}, undo: () => l.length ? (r.push(
|
|
460
|
+
l.push(f), f = C, r.length && ((g = i.onRemoveHistory) == null || g.call(i, r)), r = [];
|
|
461
|
+
}, undo: () => l.length ? (r.push(f), f = l.pop(), f) : null, redo: () => r.length ? (l.push(f), f = r.pop(), f) : null, clear: () => {
|
|
456
462
|
var C, g;
|
|
457
|
-
l.length && ((C =
|
|
458
|
-
}, get: () =>
|
|
463
|
+
l.length && ((C = i.onRemoveHistory) == null || C.call(i, l)), r.length && ((g = i.onRemoveHistory) == null || g.call(i, r)), l = [], r = [];
|
|
464
|
+
}, get: () => f };
|
|
459
465
|
}
|
|
460
|
-
const
|
|
466
|
+
const At = ["data-id", "data-type"], Ht = ["data-id", "data-type"], Vt = /* @__PURE__ */ Ce({
|
|
461
467
|
inheritAttrs: !1,
|
|
462
468
|
__name: "Block",
|
|
463
469
|
props: {
|
|
@@ -468,25 +474,25 @@ const Ht = ["data-id", "data-type"], At = ["data-id", "data-type"], Vt = /* @__P
|
|
|
468
474
|
asChild: { type: Boolean }
|
|
469
475
|
},
|
|
470
476
|
setup(n) {
|
|
471
|
-
const
|
|
472
|
-
return (r,
|
|
477
|
+
const i = n, l = ut();
|
|
478
|
+
return (r, f) => {
|
|
473
479
|
const _ = dt("Block", !0);
|
|
474
|
-
return
|
|
480
|
+
return i.type !== "block" ? (m(), I("span", Se({
|
|
475
481
|
key: 0,
|
|
476
|
-
"data-id":
|
|
477
|
-
"data-type":
|
|
478
|
-
}, k(l)), de(
|
|
479
|
-
|
|
482
|
+
"data-id": i.id,
|
|
483
|
+
"data-type": i.type
|
|
484
|
+
}, k(l)), de(i.content), 17, At)) : (m(), I(ye, { key: 1 }, [
|
|
485
|
+
i.asChild ? (m(!0), I(ye, { key: 0 }, xe(i.content, (p) => (m(), ee(_, Se({
|
|
480
486
|
key: `${p.id}-${p.type}`
|
|
481
487
|
}, { ref_for: !0 }, p), null, 16))), 128)) : (m(), I("span", Se({
|
|
482
488
|
key: 1,
|
|
483
|
-
"data-id":
|
|
484
|
-
"data-type":
|
|
489
|
+
"data-id": i.id,
|
|
490
|
+
"data-type": i.type
|
|
485
491
|
}, k(l)), [
|
|
486
|
-
(m(!0), I(ye, null, xe(
|
|
492
|
+
(m(!0), I(ye, null, xe(i.content, (p) => (m(), ee(_, Se({
|
|
487
493
|
key: `${p.id}-${p.type}`
|
|
488
494
|
}, { ref_for: !0 }, p), null, 16))), 128))
|
|
489
|
-
], 16,
|
|
495
|
+
], 16, Ht))
|
|
490
496
|
], 64));
|
|
491
497
|
};
|
|
492
498
|
}
|
|
@@ -499,22 +505,22 @@ const Ht = ["data-id", "data-type"], At = ["data-id", "data-type"], Vt = /* @__P
|
|
|
499
505
|
modelModifiers: {}
|
|
500
506
|
}),
|
|
501
507
|
emits: /* @__PURE__ */ Ze(["submit"], ["update:modelValue"]),
|
|
502
|
-
setup(n, { expose:
|
|
503
|
-
const r = typeof window.ShadowRoot.prototype.getSelection == "function",
|
|
508
|
+
setup(n, { expose: i, emit: l }) {
|
|
509
|
+
const r = typeof window.ShadowRoot.prototype.getSelection == "function", f = typeof window.Selection.prototype.getComposedRanges == "function";
|
|
504
510
|
function _() {
|
|
505
511
|
const e = navigator.userAgent;
|
|
506
512
|
return e.includes("Safari") && !e.includes("Chrome") && !e.includes("Chromium") && !e.includes("CriOS");
|
|
507
513
|
}
|
|
508
|
-
const p = _(), h = () => Math.random().toString(36).substring(2, 15), v = Ne, y = Ne, C = Ne, g = n, O = ft(n, "modelValue"), V = l,
|
|
514
|
+
const p = _(), h = () => Math.random().toString(36).substring(2, 15), v = Ne, y = Ne, C = Ne, g = n, O = ft(n, "modelValue"), V = l, H = K(0), F = (e) => e.map((o) => ({
|
|
509
515
|
id: o.id || h(),
|
|
510
516
|
...o.type === "template" ? { ...o, prefix: y, suffix: C } : o
|
|
511
517
|
})), M = (e) => e.map((o) => ({ id: o.id, type: o.type, content: o.content })), R = K(F(O.value || [])), W = (e) => {
|
|
512
518
|
R.value = e;
|
|
513
|
-
},
|
|
519
|
+
}, S = E(() => {
|
|
514
520
|
const e = [], o = [], s = R.value;
|
|
515
521
|
if (s.length >= 2) {
|
|
516
|
-
const t = s[0],
|
|
517
|
-
t.type === "text" && t.content.length === 0 &&
|
|
522
|
+
const t = s[0], a = s[1];
|
|
523
|
+
t.type === "text" && t.content.length === 0 && a.type === "template" && e.push({ ...t, content: v });
|
|
518
524
|
const u = s[s.length - 1], x = s[s.length - 2];
|
|
519
525
|
u.type === "text" && u.content.length === 0 && x.type === "template" && o.push({ ...u, content: v });
|
|
520
526
|
}
|
|
@@ -525,7 +531,7 @@ const Ht = ["data-id", "data-type"], At = ["data-id", "data-type"], Vt = /* @__P
|
|
|
525
531
|
{ id: e.id, type: "prefix", content: e.prefix },
|
|
526
532
|
{ id: e.id, type: "template", content: e.content },
|
|
527
533
|
{ id: e.id, type: "suffix", content: e.suffix }
|
|
528
|
-
] : [e]).flat()),
|
|
534
|
+
] : [e]).flat()), d = E(() => S.value.map((e) => e.type === "text" ? e : p ? {
|
|
529
535
|
id: e.id,
|
|
530
536
|
type: "block",
|
|
531
537
|
asChild: !0,
|
|
@@ -555,26 +561,26 @@ const Ht = ["data-id", "data-type"], At = ["data-id", "data-type"], Vt = /* @__P
|
|
|
555
561
|
},
|
|
556
562
|
{ id: e.id, type: "suffix", content: e.suffix }
|
|
557
563
|
]
|
|
558
|
-
})),
|
|
559
|
-
if (!
|
|
560
|
-
const e = window.getComputedStyle(
|
|
561
|
-
|
|
564
|
+
})), b = K(null), z = K(Mt), j = () => {
|
|
565
|
+
if (!b.value) return;
|
|
566
|
+
const e = window.getComputedStyle(b.value), o = parseFloat(e.fontSize), s = parseFloat(e.lineHeight);
|
|
567
|
+
z.value = isNaN(s) ? o * 2.5 : s;
|
|
562
568
|
}, B = E(() => {
|
|
563
569
|
if (!g.autoSize)
|
|
564
570
|
return {};
|
|
565
|
-
const e = typeof g.autoSize == "boolean" ? { minRows: 1, maxRows: 3 } : g.autoSize, o = e.minRows *
|
|
571
|
+
const e = typeof g.autoSize == "boolean" ? { minRows: 1, maxRows: 3 } : g.autoSize, o = e.minRows * z.value, s = e.maxRows * z.value;
|
|
566
572
|
return {
|
|
567
573
|
minHeight: `${o}px`,
|
|
568
574
|
maxHeight: `${s}px`,
|
|
569
575
|
overflowY: "auto",
|
|
570
576
|
overflowX: "hidden"
|
|
571
577
|
};
|
|
572
|
-
}),
|
|
573
|
-
if (!
|
|
578
|
+
}), J = () => {
|
|
579
|
+
if (!b.value) return;
|
|
574
580
|
const e = window.getSelection();
|
|
575
581
|
if (!e || e.rangeCount === 0) return;
|
|
576
|
-
const s = e.getRangeAt(0).getBoundingClientRect(), c =
|
|
577
|
-
|
|
582
|
+
const s = e.getRangeAt(0).getBoundingClientRect(), c = b.value.getBoundingClientRect(), t = s.top - c.top, a = s.bottom - c.top, u = b.value.scrollTop, x = b.value.clientHeight;
|
|
583
|
+
a > x ? b.value.scrollTop = u + (a - x) + 10 : t < 0 && (b.value.scrollTop = u + t - 10);
|
|
578
584
|
}, G = (e) => {
|
|
579
585
|
const o = Date.now(), s = JSON.stringify(e);
|
|
580
586
|
return `${o}:${s}`;
|
|
@@ -584,7 +590,7 @@ const Ht = ["data-id", "data-type"], At = ["data-id", "data-type"], Vt = /* @__P
|
|
|
584
590
|
timestamp: o,
|
|
585
591
|
data: s
|
|
586
592
|
};
|
|
587
|
-
}, L = /* @__PURE__ */ new Map(),
|
|
593
|
+
}, L = /* @__PURE__ */ new Map(), A = Kt(G(R.value), {
|
|
588
594
|
onRemoveHistory: (e) => {
|
|
589
595
|
for (const o of e)
|
|
590
596
|
L.delete(o);
|
|
@@ -595,23 +601,23 @@ const Ht = ["data-id", "data-type"], At = ["data-id", "data-type"], Vt = /* @__P
|
|
|
595
601
|
(e) => {
|
|
596
602
|
const o = F(e || []);
|
|
597
603
|
if (JSON.stringify(o) !== JSON.stringify(R.value)) {
|
|
598
|
-
if (
|
|
599
|
-
const c = le(
|
|
600
|
-
c && L.set(
|
|
604
|
+
if (b.value) {
|
|
605
|
+
const c = le(b.value);
|
|
606
|
+
c && L.set(A.get(), X(c));
|
|
601
607
|
}
|
|
602
|
-
W(o),
|
|
608
|
+
W(o), A.commit(G(R.value));
|
|
603
609
|
}
|
|
604
610
|
},
|
|
605
611
|
{ deep: !0 }
|
|
606
612
|
);
|
|
607
|
-
const ge = (e, o = document.body) => o.contains(e) ? e instanceof HTMLElement && e.dataset.id ? e : e.parentElement ? ge(e.parentElement, o) : null : null, fe = (e) => e ===
|
|
613
|
+
const ge = (e, o = document.body) => o.contains(e) ? e instanceof HTMLElement && e.dataset.id ? e : e.parentElement ? ge(e.parentElement, o) : null : null, fe = (e) => e === b.value, le = (e) => {
|
|
608
614
|
const o = window.getSelection();
|
|
609
615
|
if (!o)
|
|
610
616
|
return null;
|
|
611
617
|
const s = o.rangeCount > 0 ? o.getRangeAt(0) : null, c = e.getRootNode();
|
|
612
618
|
if (!(c instanceof ShadowRoot))
|
|
613
619
|
return s;
|
|
614
|
-
if (
|
|
620
|
+
if (f) {
|
|
615
621
|
const t = o.getComposedRanges(p ? c : { shadowRoots: [c] });
|
|
616
622
|
return (t == null ? void 0 : t[0]) ?? null;
|
|
617
623
|
}
|
|
@@ -630,28 +636,28 @@ const Ht = ["data-id", "data-type"], At = ["data-id", "data-type"], Vt = /* @__P
|
|
|
630
636
|
const t = window.getSelection();
|
|
631
637
|
if (!t)
|
|
632
638
|
return;
|
|
633
|
-
const { node:
|
|
639
|
+
const { node: a, offset: u } = me(e, o);
|
|
634
640
|
if (!s)
|
|
635
|
-
t.setBaseAndExtent(
|
|
641
|
+
t.setBaseAndExtent(a, u, a, u);
|
|
636
642
|
else {
|
|
637
643
|
const { node: x, offset: N } = me(s, c ?? 0);
|
|
638
|
-
t.setBaseAndExtent(
|
|
644
|
+
t.setBaseAndExtent(a, u, x, N);
|
|
639
645
|
}
|
|
640
646
|
q(() => {
|
|
641
|
-
|
|
647
|
+
J();
|
|
642
648
|
});
|
|
643
649
|
}, re = (e, o) => {
|
|
644
650
|
const s = h(), c = { id: s, type: "text", content: e };
|
|
645
651
|
if (o) {
|
|
646
|
-
const t = R.value.findIndex((
|
|
652
|
+
const t = R.value.findIndex((a) => a.id === o);
|
|
647
653
|
t !== -1 ? (W(
|
|
648
654
|
R.value.slice(0, t + 1).concat(c).concat(R.value.slice(t + 1))
|
|
649
|
-
),
|
|
655
|
+
), A.commit(G(R.value))) : console.warn(`can not find item with id: ${o}`);
|
|
650
656
|
} else
|
|
651
|
-
W([c].concat(R.value)),
|
|
657
|
+
W([c].concat(R.value)), A.commit(G(R.value));
|
|
652
658
|
q(() => {
|
|
653
|
-
var
|
|
654
|
-
const t = (
|
|
659
|
+
var a;
|
|
660
|
+
const t = (a = b.value) == null ? void 0 : a.querySelector(`[data-id="${s}"][data-type="text"]`);
|
|
655
661
|
t && te(t, e.length);
|
|
656
662
|
}), O.value = M(R.value);
|
|
657
663
|
}, Q = K({
|
|
@@ -666,7 +672,7 @@ const Ht = ["data-id", "data-type"], At = ["data-id", "data-type"], Vt = /* @__P
|
|
|
666
672
|
console.warn("range is null", t);
|
|
667
673
|
return;
|
|
668
674
|
}
|
|
669
|
-
const
|
|
675
|
+
const a = [
|
|
670
676
|
"insertText",
|
|
671
677
|
"insertFromPaste",
|
|
672
678
|
"insertReplacementText",
|
|
@@ -677,17 +683,17 @@ const Ht = ["data-id", "data-type"], At = ["data-id", "data-type"], Vt = /* @__P
|
|
|
677
683
|
"deleteSoftLineBackward",
|
|
678
684
|
"deleteSoftLineForward",
|
|
679
685
|
"deleteByCut"
|
|
680
|
-
], u = le(
|
|
681
|
-
if (
|
|
686
|
+
], u = le(b.value);
|
|
687
|
+
if (a.includes(s)) {
|
|
682
688
|
if (c && fe(t.startContainer) && fe(t.endContainer)) {
|
|
683
|
-
u && L.set(
|
|
689
|
+
u && L.set(A.get(), X(u)), re(c);
|
|
684
690
|
return;
|
|
685
691
|
}
|
|
686
|
-
const N =
|
|
687
|
-
N.startId && N.endId ? (u && L.set(
|
|
688
|
-
} else s === "insertCompositionText" && Q.value.hasStarted && (Q.value = { hasStarted: !1, range:
|
|
689
|
-
},
|
|
690
|
-
const o = ge(e.startContainer,
|
|
692
|
+
const N = X(t);
|
|
693
|
+
N.startId && N.endId ? (u && L.set(A.get(), X(u)), we(N, s, c)) : console.warn("range is not valid, range:", N);
|
|
694
|
+
} else s === "insertCompositionText" && Q.value.hasStarted && (Q.value = { hasStarted: !1, range: X(t) });
|
|
695
|
+
}, X = (e) => {
|
|
696
|
+
const o = ge(e.startContainer, b.value), s = ge(e.endContainer, b.value);
|
|
691
697
|
return {
|
|
692
698
|
collapsed: e.collapsed,
|
|
693
699
|
endContainer: e.endContainer,
|
|
@@ -711,10 +717,10 @@ const Ht = ["data-id", "data-type"], At = ["data-id", "data-type"], Vt = /* @__P
|
|
|
711
717
|
re($, T);
|
|
712
718
|
return;
|
|
713
719
|
}
|
|
714
|
-
const
|
|
715
|
-
for (const [T, $] of
|
|
716
|
-
const D = R.value.find((ue) => ue.id === $.id),
|
|
717
|
-
D ? D.type === "text" ? D.content = se(D.content,
|
|
720
|
+
const a = t, u = [];
|
|
721
|
+
for (const [T, $] of a.entries()) {
|
|
722
|
+
const D = R.value.find((ue) => ue.id === $.id), Y = T === 0 ? s : "";
|
|
723
|
+
D ? D.type === "text" ? D.content = se(D.content, Y, $.startOffset, $.endOffset) : D.type === "template" ? $.type === "prefix" || $.type === "suffix" ? $.startOffset === 0 && $.endOffset === 1 && Y.length === 0 ? D[$.type] = "" : console.warn(`${$.type} can not be inserted text. it only can be deleted`, $) : $.startOffset < 0 || $.endOffset > D.content.length ? u.push(D.id) : D.content = se(D.content, Y, $.startOffset, $.endOffset) : console.warn("dataItem.type is not text or template", D) : console.warn("can not find dataItem", $);
|
|
718
724
|
}
|
|
719
725
|
let x = R.value.filter((T) => !u.includes(T.id));
|
|
720
726
|
x = x.filter((T) => !(T.type === "template" && [T.prefix, T.suffix, T.content].join("").length === 0));
|
|
@@ -722,13 +728,13 @@ const Ht = ["data-id", "data-type"], At = ["data-id", "data-type"], Vt = /* @__P
|
|
|
722
728
|
x.forEach((T, $, D) => {
|
|
723
729
|
if (D.length >= 2) {
|
|
724
730
|
if ($ === 0 || $ === 1) {
|
|
725
|
-
const
|
|
726
|
-
if (
|
|
731
|
+
const Y = D[0], ue = D[1];
|
|
732
|
+
if (Y.type === "text" && Y.content.length === 0 && ue.type === "template")
|
|
727
733
|
return;
|
|
728
734
|
}
|
|
729
735
|
if ($ === D.length - 2 || $ === D.length - 1) {
|
|
730
|
-
const
|
|
731
|
-
if (
|
|
736
|
+
const Y = D[D.length - 1], ue = D[D.length - 2];
|
|
737
|
+
if (Y.type === "text" && Y.content.length === 0 && ue.type === "template")
|
|
732
738
|
return;
|
|
733
739
|
}
|
|
734
740
|
}
|
|
@@ -736,19 +742,19 @@ const Ht = ["data-id", "data-type"], At = ["data-id", "data-type"], Vt = /* @__P
|
|
|
736
742
|
}), x = x.filter((T) => !N.has(T.id));
|
|
737
743
|
for (const T of x.filter(($) => $.type === "template"))
|
|
738
744
|
T.prefix.length === 0 && (T.prefix = y), T.suffix.length === 0 && (T.suffix = C);
|
|
739
|
-
W(x),
|
|
740
|
-
|
|
745
|
+
W(x), A.commit(G(R.value)), a.length > 0 && Ie(a, s), O.value = M(R.value), q(() => {
|
|
746
|
+
J();
|
|
741
747
|
});
|
|
742
748
|
}, Ie = (e, o) => {
|
|
743
|
-
const s = e[0], c = `[data-id="${s.id}"][data-type="${s.type}"]`, t = e.slice(1).map((
|
|
749
|
+
const s = e[0], c = `[data-id="${s.id}"][data-type="${s.type}"]`, t = e.slice(1).map((a) => `[data-id="${a.id}"][data-type="${a.type}"]`);
|
|
744
750
|
q(() => {
|
|
745
751
|
var u, x;
|
|
746
|
-
const
|
|
747
|
-
if (
|
|
748
|
-
te(
|
|
752
|
+
const a = (u = b.value) == null ? void 0 : u.querySelector(c);
|
|
753
|
+
if (a)
|
|
754
|
+
te(a, s.startOffset + o.length);
|
|
749
755
|
else if (o.length === 0)
|
|
750
756
|
for (const N of t) {
|
|
751
|
-
const T = (x =
|
|
757
|
+
const T = (x = b.value) == null ? void 0 : x.querySelector(N);
|
|
752
758
|
if (T) {
|
|
753
759
|
te(T, 0);
|
|
754
760
|
break;
|
|
@@ -771,7 +777,7 @@ const Ht = ["data-id", "data-type"], At = ["data-id", "data-type"], Vt = /* @__P
|
|
|
771
777
|
endOffset: e.endOffset
|
|
772
778
|
}
|
|
773
779
|
];
|
|
774
|
-
const
|
|
780
|
+
const a = [
|
|
775
781
|
{
|
|
776
782
|
id: c.id,
|
|
777
783
|
type: c.type,
|
|
@@ -781,19 +787,19 @@ const Ht = ["data-id", "data-type"], At = ["data-id", "data-type"], Vt = /* @__P
|
|
|
781
787
|
];
|
|
782
788
|
for (let u = o + 1; u < s; u++) {
|
|
783
789
|
const x = w.value[u];
|
|
784
|
-
|
|
790
|
+
a.push({
|
|
785
791
|
id: x.id,
|
|
786
792
|
type: x.type,
|
|
787
793
|
startOffset: 0,
|
|
788
794
|
endOffset: x.content.length
|
|
789
795
|
});
|
|
790
796
|
}
|
|
791
|
-
return
|
|
797
|
+
return a.push({
|
|
792
798
|
id: t.id,
|
|
793
799
|
type: t.type,
|
|
794
800
|
startOffset: 0,
|
|
795
801
|
endOffset: e.endOffset
|
|
796
|
-
}),
|
|
802
|
+
}), a;
|
|
797
803
|
}, Te = (e, o, s, c) => {
|
|
798
804
|
const t = e[0];
|
|
799
805
|
if (t.type !== "prefix" && t.type !== "suffix")
|
|
@@ -801,44 +807,44 @@ const Ht = ["data-id", "data-type"], At = ["data-id", "data-type"], Vt = /* @__P
|
|
|
801
807
|
if (e.length === 1) {
|
|
802
808
|
if (o.collapsed)
|
|
803
809
|
if (o.startOffset === 0) {
|
|
804
|
-
const
|
|
805
|
-
return
|
|
810
|
+
const a = ae(t, c);
|
|
811
|
+
return a ? [a] : [];
|
|
806
812
|
} else {
|
|
807
|
-
const
|
|
808
|
-
return
|
|
813
|
+
const a = be(t, c);
|
|
814
|
+
return a ? [a] : [];
|
|
809
815
|
}
|
|
810
816
|
if (s.startsWith("insert"))
|
|
811
817
|
if (p) {
|
|
812
|
-
const
|
|
813
|
-
return
|
|
818
|
+
const a = ae(t, c);
|
|
819
|
+
return a ? [a] : [];
|
|
814
820
|
} else {
|
|
815
|
-
const
|
|
816
|
-
return
|
|
821
|
+
const a = be(t, c);
|
|
822
|
+
return a ? [a] : [];
|
|
817
823
|
}
|
|
818
824
|
if (s.startsWith("delete")) {
|
|
819
825
|
if (s.includes("Backward")) {
|
|
820
|
-
const
|
|
821
|
-
return
|
|
826
|
+
const a = ae(t, c, 1);
|
|
827
|
+
return a ? [a] : [];
|
|
822
828
|
} else if (s.includes("Forward")) {
|
|
823
|
-
const
|
|
824
|
-
return
|
|
829
|
+
const a = be(t, c, 1);
|
|
830
|
+
return a ? [a] : [];
|
|
825
831
|
}
|
|
826
832
|
}
|
|
827
833
|
}
|
|
828
834
|
return c.length > 0 ? e.slice(1) : e;
|
|
829
|
-
},
|
|
835
|
+
}, ae = (e, o, s = 0) => {
|
|
830
836
|
const c = w.value.findIndex((t) => t.id === e.id && t.type === e.type);
|
|
831
837
|
if (c > 0) {
|
|
832
|
-
const t = w.value[c - 1], { id:
|
|
838
|
+
const t = w.value[c - 1], { id: a, type: u, content: x } = t;
|
|
833
839
|
if (u === "text" || u === "template")
|
|
834
840
|
return {
|
|
835
|
-
id:
|
|
841
|
+
id: a,
|
|
836
842
|
type: u,
|
|
837
843
|
startOffset: x.length - s,
|
|
838
844
|
endOffset: x.length
|
|
839
845
|
};
|
|
840
846
|
if (o.length > 0)
|
|
841
|
-
return { tag: "new", afterId:
|
|
847
|
+
return { tag: "new", afterId: a, type: "text", content: o };
|
|
842
848
|
if (console.warn("the previous item is not text or template", { current: e, previous: t }), s === 1)
|
|
843
849
|
return { ...e, endOffset: e.startOffset };
|
|
844
850
|
} else return o.length > 0 ? { tag: "new", type: "text", content: o } : (console.warn("the previous item of current is not found", { current: e }), null);
|
|
@@ -846,10 +852,10 @@ const Ht = ["data-id", "data-type"], At = ["data-id", "data-type"], Vt = /* @__P
|
|
|
846
852
|
}, be = (e, o, s = 0) => {
|
|
847
853
|
const c = w.value.findIndex((t) => t.id === e.id && t.type === e.type);
|
|
848
854
|
if (c < w.value.length - 1) {
|
|
849
|
-
const t = w.value[c + 1], { id:
|
|
855
|
+
const t = w.value[c + 1], { id: a, type: u } = t;
|
|
850
856
|
if (u === "text" || u === "template")
|
|
851
857
|
return {
|
|
852
|
-
id:
|
|
858
|
+
id: a,
|
|
853
859
|
type: u,
|
|
854
860
|
startOffset: 0,
|
|
855
861
|
endOffset: 0 + s
|
|
@@ -862,28 +868,28 @@ const Ht = ["data-id", "data-type"], At = ["data-id", "data-type"], Vt = /* @__P
|
|
|
862
868
|
return e;
|
|
863
869
|
}, pe = () => {
|
|
864
870
|
Q.value = { hasStarted: !0, range: null };
|
|
865
|
-
},
|
|
871
|
+
}, Ae = (e) => {
|
|
866
872
|
const o = Q.value.range;
|
|
867
|
-
o ? (e.data && fe(o.startContainer) && fe(o.endContainer) ? (L.set(
|
|
868
|
-
|
|
873
|
+
o ? (e.data && fe(o.startContainer) && fe(o.endContainer) ? (L.set(A.get(), X(o)), re(e.data)) : o.startId && o.endId ? (L.set(A.get(), X(o)), we(o, "insertCompositionText", e.data)) : console.warn("range is not valid, range:", o), H.value++, q(() => {
|
|
874
|
+
J();
|
|
869
875
|
})) : console.warn("range is null, compositionEnd:", e), Q.value = { hasStarted: !1, range: null };
|
|
870
876
|
}, he = (() => {
|
|
871
877
|
const e = navigator.userAgent.toLowerCase();
|
|
872
878
|
return /macintosh|mac os x|iphone|ipad|ipod/.test(e);
|
|
873
|
-
})(),
|
|
879
|
+
})(), He = (e) => {
|
|
874
880
|
const o = he && e.metaKey && !e.shiftKey && e.key.toLowerCase() === "z" || // Cmd+Z
|
|
875
881
|
!he && e.ctrlKey && !e.shiftKey && e.key.toLowerCase() === "z", s = he && e.metaKey && e.shiftKey && e.key.toLowerCase() === "z" || // Cmd+Shift+z
|
|
876
882
|
!he && e.ctrlKey && (e.key.toLowerCase() === "y" || e.shiftKey && e.key.toLowerCase() === "z"), c = e.key.toLowerCase() === "enter";
|
|
877
883
|
if (o) {
|
|
878
884
|
e.preventDefault();
|
|
879
|
-
const t = le(
|
|
880
|
-
t && L.set(
|
|
881
|
-
const
|
|
882
|
-
|
|
885
|
+
const t = le(b.value);
|
|
886
|
+
t && L.set(A.get(), X(t));
|
|
887
|
+
const a = A.undo();
|
|
888
|
+
a && Ee(a);
|
|
883
889
|
}
|
|
884
890
|
if (s) {
|
|
885
891
|
e.preventDefault();
|
|
886
|
-
const t =
|
|
892
|
+
const t = A.redo();
|
|
887
893
|
t && Ee(t);
|
|
888
894
|
}
|
|
889
895
|
c && (e.preventDefault(), V("submit"));
|
|
@@ -892,35 +898,35 @@ const Ht = ["data-id", "data-type"], At = ["data-id", "data-type"], Vt = /* @__P
|
|
|
892
898
|
if (W(o), L.has(e)) {
|
|
893
899
|
const s = L.get(e);
|
|
894
900
|
q(() => {
|
|
895
|
-
const c =
|
|
901
|
+
const c = b.value.querySelector(`[data-id="${s.startId}"][data-type="${s.startType}"]`), t = b.value.querySelector(`[data-id="${s.endId}"][data-type="${s.endType}"]`);
|
|
896
902
|
c && te(c, s.startOffset, t, s.endOffset);
|
|
897
903
|
});
|
|
898
904
|
}
|
|
899
905
|
O.value = M(R.value);
|
|
900
906
|
}, ce = (e, o) => {
|
|
901
|
-
var t,
|
|
902
|
-
const s = (t =
|
|
907
|
+
var t, a;
|
|
908
|
+
const s = (t = b.value) == null ? void 0 : t.querySelector(`[data-id="${e}"][data-type="${o}"]`);
|
|
903
909
|
if (!s) return;
|
|
904
|
-
const c = ((
|
|
910
|
+
const c = ((a = s.textContent) == null ? void 0 : a.length) || 0;
|
|
905
911
|
te(s, c);
|
|
906
912
|
}, Ve = () => {
|
|
907
|
-
|
|
913
|
+
b.value && q(() => {
|
|
908
914
|
const e = R.value, o = e.find((c) => c.type === "template");
|
|
909
915
|
o && ce(o.id, "template"), e.every((c) => c.type === "text") && e.length === 1 && ce(e[0].id, "text");
|
|
910
916
|
});
|
|
911
917
|
}, Fe = () => {
|
|
912
|
-
|
|
918
|
+
A.clear(), L.clear();
|
|
913
919
|
}, Oe = () => {
|
|
914
|
-
if (!
|
|
920
|
+
if (!b.value || Q.value.range)
|
|
915
921
|
return;
|
|
916
|
-
const e = le(
|
|
917
|
-
if (e != null && e.collapsed &&
|
|
918
|
-
const o =
|
|
922
|
+
const e = le(b.value);
|
|
923
|
+
if (e != null && e.collapsed && S.value.length > 0) {
|
|
924
|
+
const o = X(e), s = S.value[0];
|
|
919
925
|
if (o.startEl && o.startId === s.id && o.startOffset === 0 && s.content === v && s.type === "text") {
|
|
920
926
|
te(o.startEl, 1);
|
|
921
927
|
return;
|
|
922
928
|
}
|
|
923
|
-
const c =
|
|
929
|
+
const c = S.value[S.value.length - 1];
|
|
924
930
|
if (o.endEl && o.endId === c.id && o.endOffset === 1 && c.content === v && c.type === "text") {
|
|
925
931
|
te(o.endEl, 0);
|
|
926
932
|
return;
|
|
@@ -929,37 +935,37 @@ const Ht = ["data-id", "data-type"], At = ["data-id", "data-type"], Vt = /* @__P
|
|
|
929
935
|
};
|
|
930
936
|
return pt(() => {
|
|
931
937
|
document.addEventListener("selectionchange", Oe), q(() => {
|
|
932
|
-
|
|
938
|
+
j();
|
|
933
939
|
});
|
|
934
940
|
}), tt(() => {
|
|
935
941
|
document.removeEventListener("selectionchange", Oe);
|
|
936
|
-
}),
|
|
942
|
+
}), i({
|
|
937
943
|
clearHistory: Fe,
|
|
938
944
|
activateFirstField: Ve
|
|
939
945
|
}), (e, o) => (m(), I("div", Pt, [
|
|
940
946
|
(m(), I("div", {
|
|
941
947
|
contenteditable: "true",
|
|
942
948
|
ref_key: "editorRef",
|
|
943
|
-
ref:
|
|
944
|
-
key:
|
|
949
|
+
ref: b,
|
|
950
|
+
key: H.value,
|
|
945
951
|
class: "editor",
|
|
946
952
|
style: Ue(B.value),
|
|
947
953
|
onBeforeinput: Ke,
|
|
948
954
|
onCompositionstart: pe,
|
|
949
|
-
onCompositionend:
|
|
950
|
-
onKeydown:
|
|
955
|
+
onCompositionend: Ae,
|
|
956
|
+
onKeydown: He
|
|
951
957
|
}, [
|
|
952
|
-
(m(!0), I(ye, null, xe(
|
|
958
|
+
(m(!0), I(ye, null, xe(d.value, (s) => (m(), ee(Ft, Se({
|
|
953
959
|
key: `${s.id}-${s.type}`
|
|
954
960
|
}, { ref_for: !0 }, s), null, 16))), 128))
|
|
955
961
|
], 36))
|
|
956
962
|
]));
|
|
957
963
|
}
|
|
958
|
-
}), Nt = /* @__PURE__ */ _e(Wt, [["__scopeId", "data-v-b5c1a845"]]), nt = (n,
|
|
959
|
-
if (!
|
|
964
|
+
}), Nt = /* @__PURE__ */ _e(Wt, [["__scopeId", "data-v-b5c1a845"]]), nt = (n, i) => {
|
|
965
|
+
if (!i.length)
|
|
960
966
|
return [{ text: n, isMatch: !1 }];
|
|
961
967
|
const l = [];
|
|
962
|
-
for (const p of
|
|
968
|
+
for (const p of i) {
|
|
963
969
|
if (!p) continue;
|
|
964
970
|
let h = 0;
|
|
965
971
|
const v = n.toLowerCase(), y = p.toLowerCase();
|
|
@@ -983,23 +989,23 @@ const Ht = ["data-id", "data-type"], At = ["data-id", "data-type"], Vt = /* @__P
|
|
|
983
989
|
const h = r[r.length - 1];
|
|
984
990
|
p.start <= h.end ? h.end = Math.max(h.end, p.end) : r.push(p);
|
|
985
991
|
}
|
|
986
|
-
const
|
|
992
|
+
const f = [];
|
|
987
993
|
let _ = 0;
|
|
988
994
|
for (const p of r)
|
|
989
|
-
_ < p.start &&
|
|
995
|
+
_ < p.start && f.push({
|
|
990
996
|
text: n.substring(_, p.start),
|
|
991
997
|
isMatch: !1
|
|
992
|
-
}),
|
|
998
|
+
}), f.push({
|
|
993
999
|
text: n.substring(p.start, p.end),
|
|
994
1000
|
isMatch: !0
|
|
995
1001
|
}), _ = p.end;
|
|
996
|
-
return _ < n.length &&
|
|
1002
|
+
return _ < n.length && f.push({
|
|
997
1003
|
text: n.substring(_),
|
|
998
1004
|
isMatch: !1
|
|
999
|
-
}),
|
|
1000
|
-
}, zt = (n,
|
|
1005
|
+
}), f;
|
|
1006
|
+
}, zt = (n, i) => !i || !n ? [{ text: n, isMatch: !1 }] : nt(n, [i]), Ut = (n, i) => {
|
|
1001
1007
|
const { content: l, highlights: r } = n;
|
|
1002
|
-
return typeof r == "function" ? r(l,
|
|
1008
|
+
return typeof r == "function" ? r(l, i) : Array.isArray(r) ? nt(l, r) : zt(l, i);
|
|
1003
1009
|
}, Gt = ["onMouseenter", "onMousedown"], qt = { class: "suggestion-list__text" }, jt = /* @__PURE__ */ Ce({
|
|
1004
1010
|
__name: "SuggestionList",
|
|
1005
1011
|
props: {
|
|
@@ -1011,8 +1017,8 @@ const Ht = ["data-id", "data-type"], At = ["data-id", "data-type"], Vt = /* @__P
|
|
|
1011
1017
|
inputValue: {}
|
|
1012
1018
|
},
|
|
1013
1019
|
emits: ["select", "mouse-enter", "mouse-leave"],
|
|
1014
|
-
setup(n, { emit:
|
|
1015
|
-
const l = n, r =
|
|
1020
|
+
setup(n, { emit: i }) {
|
|
1021
|
+
const l = n, r = i, f = K(null), _ = (y) => y === l.activeKeyboardIndex || y === l.activeMouseIndex, p = (y) => {
|
|
1016
1022
|
r("mouse-enter", y);
|
|
1017
1023
|
}, h = () => {
|
|
1018
1024
|
r("mouse-leave");
|
|
@@ -1022,8 +1028,8 @@ const Ht = ["data-id", "data-type"], At = ["data-id", "data-type"], Vt = /* @__P
|
|
|
1022
1028
|
return ne(
|
|
1023
1029
|
() => l.activeKeyboardIndex,
|
|
1024
1030
|
(y) => {
|
|
1025
|
-
if (y !== -1 &&
|
|
1026
|
-
const C =
|
|
1031
|
+
if (y !== -1 && f.value) {
|
|
1032
|
+
const C = f.value.children[y];
|
|
1027
1033
|
C && C.scrollIntoView({ block: "nearest" });
|
|
1028
1034
|
}
|
|
1029
1035
|
}
|
|
@@ -1032,7 +1038,7 @@ const Ht = ["data-id", "data-type"], At = ["data-id", "data-type"], Vt = /* @__P
|
|
|
1032
1038
|
l.show && l.suggestions.length ? (m(), I("div", {
|
|
1033
1039
|
key: 0,
|
|
1034
1040
|
ref_key: "suggestionsListRef",
|
|
1035
|
-
ref:
|
|
1041
|
+
ref: f,
|
|
1036
1042
|
class: "suggestion-list",
|
|
1037
1043
|
style: Ue(l.popupStyle)
|
|
1038
1044
|
}, [
|
|
@@ -1043,10 +1049,10 @@ const Ht = ["data-id", "data-type"], At = ["data-id", "data-type"], Vt = /* @__P
|
|
|
1043
1049
|
onMouseleave: h,
|
|
1044
1050
|
onMousedown: ht((V) => v(g.content), ["prevent"])
|
|
1045
1051
|
}, [
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
(m(!0), I(ye, null, xe(k(Ut)(g, l.inputValue), (V,
|
|
1049
|
-
key:
|
|
1052
|
+
Z(k(kt), { class: "suggestion-list__icon" }),
|
|
1053
|
+
U("span", qt, [
|
|
1054
|
+
(m(!0), I(ye, null, xe(k(Ut)(g, l.inputValue), (V, H) => (m(), I("span", {
|
|
1055
|
+
key: H,
|
|
1050
1056
|
class: oe({
|
|
1051
1057
|
"suggestion-list__text--match": V.isMatch,
|
|
1052
1058
|
"suggestion-list__text--normal": !V.isMatch
|
|
@@ -1116,22 +1122,22 @@ const Ht = ["data-id", "data-type"], At = ["data-id", "data-type"], Vt = /* @__P
|
|
|
1116
1122
|
stopText: { default: "" }
|
|
1117
1123
|
},
|
|
1118
1124
|
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"],
|
|
1119
|
-
setup(n, { expose:
|
|
1120
|
-
const r = n,
|
|
1121
|
-
var t,
|
|
1122
|
-
return !(r.disabled || r.loading || !
|
|
1125
|
+
setup(n, { expose: i, emit: l }) {
|
|
1126
|
+
const r = n, f = l, _ = K(null), p = K(null), h = K(null), v = K(null), y = K(null), C = E(() => r.templateData && r.templateData.length > 0), { inputValue: g, isComposing: O, clearInput: V } = Rt(r, f), H = E(() => !!g.value.trim()), F = E(() => {
|
|
1127
|
+
var t, a;
|
|
1128
|
+
return !(r.disabled || r.loading || !H.value || ae.value || (a = (t = r.buttonGroup) == null ? void 0 : t.submit) != null && a.disabled);
|
|
1123
1129
|
}), {
|
|
1124
1130
|
isPopupVisible: M,
|
|
1125
1131
|
activeSuggestion: R,
|
|
1126
1132
|
activeKeyboardIndex: W,
|
|
1127
|
-
activeMouseIndex:
|
|
1133
|
+
activeMouseIndex: S,
|
|
1128
1134
|
autoCompleteText: w,
|
|
1129
|
-
showTabIndicator:
|
|
1130
|
-
syncAutoComplete:
|
|
1131
|
-
closePopup:
|
|
1132
|
-
applySuggestion:
|
|
1135
|
+
showTabIndicator: d,
|
|
1136
|
+
syncAutoComplete: b,
|
|
1137
|
+
closePopup: z,
|
|
1138
|
+
applySuggestion: j,
|
|
1133
1139
|
confirmSelection: B,
|
|
1134
|
-
navigateWithKeyboard:
|
|
1140
|
+
navigateWithKeyboard: J,
|
|
1135
1141
|
handleMouseEnter: G,
|
|
1136
1142
|
handleMouseLeave: ke
|
|
1137
1143
|
} = Ot(
|
|
@@ -1139,41 +1145,41 @@ const Ht = ["data-id", "data-type"], At = ["data-id", "data-type"], Vt = /* @__P
|
|
|
1139
1145
|
g,
|
|
1140
1146
|
O,
|
|
1141
1147
|
C,
|
|
1142
|
-
(t) =>
|
|
1143
|
-
(t) =>
|
|
1144
|
-
), L = K(r.mode),
|
|
1148
|
+
(t) => f("update:modelValue", t),
|
|
1149
|
+
(t) => f("suggestion-select", t)
|
|
1150
|
+
), L = K(r.mode), A = K(!1), ge = () => {
|
|
1145
1151
|
L.value === "single" && (L.value = "multiple", q(() => {
|
|
1146
1152
|
setTimeout(() => {
|
|
1147
1153
|
const t = document.querySelector(".tiny-textarea__inner");
|
|
1148
1154
|
if (t) {
|
|
1149
1155
|
t.style.whiteSpace = "pre-wrap";
|
|
1150
|
-
const
|
|
1151
|
-
t.focus(), t.setSelectionRange(
|
|
1156
|
+
const a = g.value.length;
|
|
1157
|
+
t.focus(), t.setSelectionRange(a, a);
|
|
1152
1158
|
}
|
|
1153
1159
|
}, 50);
|
|
1154
1160
|
}));
|
|
1155
|
-
}, fe = (t,
|
|
1161
|
+
}, fe = (t, a) => {
|
|
1156
1162
|
const u = document.createElement("span");
|
|
1157
|
-
u.style.visibility = "hidden", u.style.position = "absolute", u.style.whiteSpace = "nowrap", u.style.font =
|
|
1163
|
+
u.style.visibility = "hidden", u.style.position = "absolute", u.style.whiteSpace = "nowrap", u.style.font = a, u.textContent = t, document.body.appendChild(u);
|
|
1158
1164
|
const x = u.offsetWidth;
|
|
1159
1165
|
return document.body.removeChild(u), x;
|
|
1160
1166
|
}, le = () => {
|
|
1161
1167
|
var $e, je, Je;
|
|
1162
|
-
if (r.mode !== "single" || !_.value ||
|
|
1168
|
+
if (r.mode !== "single" || !_.value || A.value || !p.value || !v.value) return;
|
|
1163
1169
|
const t = p.value.querySelector(".tiny-sender__content-area");
|
|
1164
1170
|
if (!t) return;
|
|
1165
|
-
const
|
|
1166
|
-
if (!
|
|
1171
|
+
const a = ((je = ($e = _.value) == null ? void 0 : $e.querySelector) == null ? void 0 : je.call($e, ".tiny-input__inner")) || t.querySelector(".tiny-input__inner"), u = y.value || p.value.querySelector(".tiny-sender__buttons-container");
|
|
1172
|
+
if (!a) {
|
|
1167
1173
|
console.warn("Cannot find input element for overflow check");
|
|
1168
1174
|
return;
|
|
1169
1175
|
}
|
|
1170
|
-
const x =
|
|
1176
|
+
const x = a.getBoundingClientRect(), N = u == null ? void 0 : u.getBoundingClientRect();
|
|
1171
1177
|
if (x.width === 0) {
|
|
1172
1178
|
setTimeout(() => le(), 50);
|
|
1173
1179
|
return;
|
|
1174
1180
|
}
|
|
1175
|
-
const T = window.getComputedStyle(
|
|
1176
|
-
$ > qe && qe > st && L.value === "single" && (
|
|
1181
|
+
const T = window.getComputedStyle(a).font, $ = fe(g.value, T), D = (Je = p.value) == null ? void 0 : Je.classList.contains("tr-sender-compact"), Y = D ? 12 : 20, ue = x.width, ot = (N == null ? void 0 : N.width) || 0, qe = ue - ot - Y, st = D ? 50 : 80;
|
|
1182
|
+
$ > qe && qe > st && L.value === "single" && (A.value = !0, L.value = "multiple", q(() => {
|
|
1177
1183
|
_.value ? setTimeout(() => {
|
|
1178
1184
|
var Xe;
|
|
1179
1185
|
const Be = (Xe = p.value) == null ? void 0 : Xe.querySelector(".tiny-textarea__inner");
|
|
@@ -1182,8 +1188,8 @@ const Ht = ["data-id", "data-type"], At = ["data-id", "data-type"], Vt = /* @__P
|
|
|
1182
1188
|
const Ye = g.value.length;
|
|
1183
1189
|
Be.focus(), Be.setSelectionRange(Ye, Ye);
|
|
1184
1190
|
}
|
|
1185
|
-
|
|
1186
|
-
}, 300) :
|
|
1191
|
+
A.value = !1;
|
|
1192
|
+
}, 300) : A.value = !1;
|
|
1187
1193
|
}));
|
|
1188
1194
|
}, me = () => {
|
|
1189
1195
|
if (C.value && h.value)
|
|
@@ -1203,7 +1209,7 @@ const Ht = ["data-id", "data-type"], At = ["data-id", "data-type"], Vt = /* @__P
|
|
|
1203
1209
|
}
|
|
1204
1210
|
}, re = () => {
|
|
1205
1211
|
var t;
|
|
1206
|
-
|
|
1212
|
+
f("update:templateData", []), (t = h.value) == null || t.clearHistory(), q(() => {
|
|
1207
1213
|
g.value === "" && (L.value = r.mode || "single"), setTimeout(() => {
|
|
1208
1214
|
me();
|
|
1209
1215
|
}, 50);
|
|
@@ -1214,12 +1220,12 @@ const Ht = ["data-id", "data-type"], At = ["data-id", "data-type"], Vt = /* @__P
|
|
|
1214
1220
|
g.value === "" && (L.value = r.mode || "single");
|
|
1215
1221
|
});
|
|
1216
1222
|
}, Ke = (t) => {
|
|
1217
|
-
const
|
|
1218
|
-
if (t.length === 0 || t.every(
|
|
1223
|
+
const a = (x) => x.type === "text" && x.content === "";
|
|
1224
|
+
if (t.length === 0 || t.every(a)) {
|
|
1219
1225
|
re();
|
|
1220
1226
|
return;
|
|
1221
1227
|
}
|
|
1222
|
-
|
|
1228
|
+
f("update:templateData", t);
|
|
1223
1229
|
};
|
|
1224
1230
|
ne(
|
|
1225
1231
|
() => r.templateData,
|
|
@@ -1228,34 +1234,34 @@ const Ht = ["data-id", "data-type"], At = ["data-id", "data-type"], Vt = /* @__P
|
|
|
1228
1234
|
},
|
|
1229
1235
|
{ deep: !0 }
|
|
1230
1236
|
);
|
|
1231
|
-
const
|
|
1237
|
+
const X = E(() => {
|
|
1232
1238
|
const t = typeof r.speech == "object" ? r.speech : {};
|
|
1233
1239
|
return {
|
|
1234
1240
|
...t,
|
|
1235
|
-
onStart: () =>
|
|
1236
|
-
onEnd: (
|
|
1237
|
-
onInterim: (
|
|
1238
|
-
onFinal: (
|
|
1241
|
+
onStart: () => f("speech-start"),
|
|
1242
|
+
onEnd: (a) => f("speech-end", a),
|
|
1243
|
+
onInterim: (a) => f("speech-interim", a),
|
|
1244
|
+
onFinal: (a) => {
|
|
1239
1245
|
if (t.autoReplace)
|
|
1240
|
-
g.value =
|
|
1246
|
+
g.value = a;
|
|
1241
1247
|
else {
|
|
1242
1248
|
const u = g.value;
|
|
1243
|
-
u &&
|
|
1249
|
+
u && a && !u.endsWith(" ") && !a.startsWith(" ") && u.length > 0 ? g.value = u + " " + a : g.value = u + a;
|
|
1244
1250
|
}
|
|
1245
|
-
|
|
1251
|
+
f("speech-end", a);
|
|
1246
1252
|
},
|
|
1247
|
-
onError: (
|
|
1248
|
-
|
|
1253
|
+
onError: (a) => {
|
|
1254
|
+
f("speech-error", a);
|
|
1249
1255
|
}
|
|
1250
1256
|
};
|
|
1251
|
-
}), { speechState: se, start: we, stop: Ie } = Et(
|
|
1257
|
+
}), { speechState: se, start: we, stop: Ie } = Et(X.value), Re = () => {
|
|
1252
1258
|
se.isRecording ? Ie() : we();
|
|
1253
1259
|
}, Te = async () => {
|
|
1254
|
-
const t = typeof r.speech == "object" ? r.speech : {},
|
|
1260
|
+
const t = typeof r.speech == "object" ? r.speech : {}, a = se.isRecording;
|
|
1255
1261
|
if (t.onVoiceButtonClick) {
|
|
1256
1262
|
let u = !1;
|
|
1257
1263
|
try {
|
|
1258
|
-
await t.onVoiceButtonClick(
|
|
1264
|
+
await t.onVoiceButtonClick(a, () => {
|
|
1259
1265
|
u = !0;
|
|
1260
1266
|
});
|
|
1261
1267
|
} catch (x) {
|
|
@@ -1265,31 +1271,31 @@ const Ht = ["data-id", "data-type"], At = ["data-id", "data-type"], Vt = /* @__P
|
|
|
1265
1271
|
return;
|
|
1266
1272
|
}
|
|
1267
1273
|
Re();
|
|
1268
|
-
},
|
|
1274
|
+
}, ae = E(() => r.maxLength !== 1 / 0 && g.value.length > r.maxLength), { handleKeyPress: be, triggerSubmit: pe } = Tt(
|
|
1269
1275
|
r,
|
|
1270
|
-
|
|
1276
|
+
f,
|
|
1271
1277
|
g,
|
|
1272
1278
|
O,
|
|
1273
1279
|
se,
|
|
1274
1280
|
M,
|
|
1275
1281
|
R,
|
|
1276
1282
|
B,
|
|
1277
|
-
|
|
1278
|
-
|
|
1283
|
+
z,
|
|
1284
|
+
J,
|
|
1279
1285
|
Re,
|
|
1280
1286
|
F,
|
|
1281
1287
|
L,
|
|
1282
1288
|
ge,
|
|
1283
1289
|
C,
|
|
1284
1290
|
re
|
|
1285
|
-
),
|
|
1286
|
-
|
|
1291
|
+
), Ae = (t) => {
|
|
1292
|
+
f("focus", t), g.value && !C.value && (M.value = !0);
|
|
1287
1293
|
}, Ge = (t) => {
|
|
1288
|
-
|
|
1289
|
-
}, he = E(() => L.value === "multiple" ? "textarea" : "text"),
|
|
1294
|
+
f("blur", t), z();
|
|
1295
|
+
}, he = E(() => L.value === "multiple" ? "textarea" : "text"), He = vt(), Ee = E(() => !!He.decorativeContent), ce = E(() => r.disabled || Ee.value), Ve = E(() => r.loading), Fe = E(() => ({
|
|
1290
1296
|
"is-disabled": ce.value,
|
|
1291
1297
|
"is-loading": Ve.value,
|
|
1292
|
-
"is-auto-switching":
|
|
1298
|
+
"is-auto-switching": A.value
|
|
1293
1299
|
})), Oe = E(() => ({
|
|
1294
1300
|
width: It(r.suggestionPopupWidth),
|
|
1295
1301
|
maxWidth: "100%"
|
|
@@ -1298,7 +1304,7 @@ const Ht = ["data-id", "data-type"], At = ["data-id", "data-type"], Vt = /* @__P
|
|
|
1298
1304
|
O.value = !1;
|
|
1299
1305
|
};
|
|
1300
1306
|
ne(g, () => {
|
|
1301
|
-
q(le), g.value === "" && r.mode === "single" && (L.value = "single"),
|
|
1307
|
+
q(le), g.value === "" && r.mode === "single" && (L.value = "single"), b();
|
|
1302
1308
|
}), ne(
|
|
1303
1309
|
() => C.value,
|
|
1304
1310
|
(t) => {
|
|
@@ -1309,21 +1315,21 @@ const Ht = ["data-id", "data-type"], At = ["data-id", "data-type"], Vt = /* @__P
|
|
|
1309
1315
|
h.value && h.value.activateFirstField();
|
|
1310
1316
|
}, { open: s, files: c } = mt({
|
|
1311
1317
|
accept: Me(() => {
|
|
1312
|
-
var t,
|
|
1313
|
-
return ((
|
|
1318
|
+
var t, a;
|
|
1319
|
+
return ((a = (t = r.buttonGroup) == null ? void 0 : t.file) == null ? void 0 : a.accept) ?? "*";
|
|
1314
1320
|
}),
|
|
1315
1321
|
multiple: Me(() => {
|
|
1316
|
-
var t,
|
|
1317
|
-
return ((
|
|
1322
|
+
var t, a;
|
|
1323
|
+
return ((a = (t = r.buttonGroup) == null ? void 0 : t.file) == null ? void 0 : a.multiple) ?? !0;
|
|
1318
1324
|
}),
|
|
1319
1325
|
reset: Me(() => {
|
|
1320
|
-
var t,
|
|
1321
|
-
return ((
|
|
1326
|
+
var t, a;
|
|
1327
|
+
return ((a = (t = r.buttonGroup) == null ? void 0 : t.file) == null ? void 0 : a.reset) ?? !0;
|
|
1322
1328
|
})
|
|
1323
1329
|
});
|
|
1324
1330
|
return ne(c, (t) => {
|
|
1325
|
-
t && t.length > 0 &&
|
|
1326
|
-
}),
|
|
1331
|
+
t && t.length > 0 && f("files-selected", Array.from(t));
|
|
1332
|
+
}), i({
|
|
1327
1333
|
focus: me,
|
|
1328
1334
|
blur: te,
|
|
1329
1335
|
clear: Q,
|
|
@@ -1331,36 +1337,36 @@ const Ht = ["data-id", "data-type"], At = ["data-id", "data-type"], Vt = /* @__P
|
|
|
1331
1337
|
startSpeech: we,
|
|
1332
1338
|
stopSpeech: Ie,
|
|
1333
1339
|
activateTemplateFirstField: o
|
|
1334
|
-
}), (t,
|
|
1340
|
+
}), (t, a) => (m(), I("div", {
|
|
1335
1341
|
ref_key: "senderRef",
|
|
1336
1342
|
ref: p,
|
|
1337
1343
|
class: oe(["tiny-sender", [Fe.value, `theme-${n.theme}`, `mode-${L.value}`]]),
|
|
1338
1344
|
"data-theme": n.theme
|
|
1339
1345
|
}, [
|
|
1340
|
-
|
|
1341
|
-
|
|
1346
|
+
U("div", Yt, [
|
|
1347
|
+
U("div", {
|
|
1342
1348
|
class: "tiny-sender__input-wrapper",
|
|
1343
1349
|
ref_key: "inputWrapperRef",
|
|
1344
1350
|
ref: v
|
|
1345
1351
|
}, [
|
|
1346
|
-
|
|
1352
|
+
Z(ze, { name: "tiny-sender-slide-down" }, {
|
|
1347
1353
|
default: ve(() => [
|
|
1348
1354
|
t.$slots.header ? (m(), I("div", Zt, [
|
|
1349
|
-
|
|
1355
|
+
ie(t.$slots, "header", {}, void 0, !0)
|
|
1350
1356
|
])) : P("", !0)
|
|
1351
1357
|
]),
|
|
1352
1358
|
_: 3
|
|
1353
1359
|
}),
|
|
1354
|
-
|
|
1360
|
+
U("div", {
|
|
1355
1361
|
class: oe(["tiny-sender__input-row", { "has-prefix": t.$slots.prefix, "has-header": t.$slots.header }])
|
|
1356
1362
|
}, [
|
|
1357
1363
|
t.$slots.prefix ? (m(), I("div", Qt, [
|
|
1358
|
-
|
|
1364
|
+
ie(t.$slots, "prefix", {}, void 0, !0)
|
|
1359
1365
|
])) : P("", !0),
|
|
1360
|
-
|
|
1361
|
-
|
|
1366
|
+
U("div", en, [
|
|
1367
|
+
ie(t.$slots, "content", {}, () => [
|
|
1362
1368
|
t.$slots.decorativeContent ? (m(), I("div", tn, [
|
|
1363
|
-
|
|
1369
|
+
ie(t.$slots, "decorativeContent", {}, void 0, !0)
|
|
1364
1370
|
])) : P("", !0),
|
|
1365
1371
|
C.value ? (m(), ee(Nt, {
|
|
1366
1372
|
key: 1,
|
|
@@ -1371,113 +1377,113 @@ const Ht = ["data-id", "data-type"], At = ["data-id", "data-type"], Vt = /* @__P
|
|
|
1371
1377
|
"onUpdate:modelValue": Ke,
|
|
1372
1378
|
onSubmit: k(pe)
|
|
1373
1379
|
}, null, 8, ["model-value", "auto-size", "onSubmit"])) : (m(), I("div", nn, [
|
|
1374
|
-
|
|
1380
|
+
Z(k(gt), {
|
|
1375
1381
|
ref_key: "inputRef",
|
|
1376
1382
|
ref: _,
|
|
1377
1383
|
autosize: n.autoSize,
|
|
1378
1384
|
type: he.value,
|
|
1379
1385
|
resize: "none",
|
|
1380
1386
|
modelValue: k(g),
|
|
1381
|
-
"onUpdate:modelValue":
|
|
1387
|
+
"onUpdate:modelValue": a[0] || (a[0] = (u) => yt(g) ? g.value = u : null),
|
|
1382
1388
|
disabled: ce.value,
|
|
1383
1389
|
placeholder: n.placeholder,
|
|
1384
1390
|
autofocus: n.autofocus,
|
|
1385
1391
|
onKeydown: k(be),
|
|
1386
|
-
onCompositionstart:
|
|
1392
|
+
onCompositionstart: a[1] || (a[1] = (u) => O.value = !0),
|
|
1387
1393
|
onCompositionend: e,
|
|
1388
|
-
onFocus:
|
|
1394
|
+
onFocus: Ae,
|
|
1389
1395
|
onBlur: Ge
|
|
1390
1396
|
}, null, 8, ["autosize", "type", "modelValue", "disabled", "placeholder", "autofocus", "onKeydown"]),
|
|
1391
1397
|
k(w) && !k(O) ? (m(), I("div", on, [
|
|
1392
|
-
|
|
1398
|
+
U("span", sn, de(k(g)), 1),
|
|
1393
1399
|
Qe(" " + de(k(w)) + " ", 1),
|
|
1394
|
-
k(
|
|
1400
|
+
k(d) ? (m(), I("div", an, "TAB")) : P("", !0)
|
|
1395
1401
|
])) : P("", !0)
|
|
1396
1402
|
]))
|
|
1397
1403
|
], !0)
|
|
1398
1404
|
]),
|
|
1399
1405
|
L.value === "single" ? (m(), I("div", ln, [
|
|
1400
|
-
|
|
1406
|
+
U("div", {
|
|
1401
1407
|
class: "tiny-sender__buttons-container",
|
|
1402
1408
|
ref_key: "buttonsContainerRef",
|
|
1403
1409
|
ref: y
|
|
1404
1410
|
}, [
|
|
1405
|
-
|
|
1406
|
-
|
|
1411
|
+
ie(t.$slots, "actions", {}, void 0, !0),
|
|
1412
|
+
Z(et, {
|
|
1407
1413
|
"allow-speech": n.allowSpeech,
|
|
1408
1414
|
"allow-files": n.allowFiles,
|
|
1409
1415
|
loading: n.loading,
|
|
1410
1416
|
disabled: ce.value,
|
|
1411
1417
|
"show-clear": n.clearable,
|
|
1412
|
-
"has-content":
|
|
1418
|
+
"has-content": H.value,
|
|
1413
1419
|
"speech-status": k(se),
|
|
1414
1420
|
"button-group": n.buttonGroup,
|
|
1415
1421
|
"submit-type": n.submitType,
|
|
1416
|
-
"is-over-limit":
|
|
1422
|
+
"is-over-limit": ae.value,
|
|
1417
1423
|
"stop-text": n.stopText,
|
|
1418
1424
|
onClear: Q,
|
|
1419
1425
|
onVoiceButtonClick: Te,
|
|
1420
1426
|
onSubmit: k(pe),
|
|
1421
|
-
onCancel:
|
|
1427
|
+
onCancel: a[2] || (a[2] = (u) => t.$emit("cancel")),
|
|
1422
1428
|
onTriggerSelect: k(s)
|
|
1423
1429
|
}, 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"])
|
|
1424
1430
|
], 512)
|
|
1425
1431
|
])) : P("", !0)
|
|
1426
1432
|
], 2),
|
|
1427
|
-
|
|
1433
|
+
Z(ze, { name: "tiny-sender-slide-up" }, {
|
|
1428
1434
|
default: ve(() => [
|
|
1429
1435
|
L.value === "multiple" ? (m(), I("div", rn, [
|
|
1430
|
-
|
|
1431
|
-
|
|
1436
|
+
U("div", cn, [
|
|
1437
|
+
ie(t.$slots, "footer-left", {}, void 0, !0)
|
|
1432
1438
|
]),
|
|
1433
|
-
|
|
1434
|
-
|
|
1439
|
+
U("div", un, [
|
|
1440
|
+
ie(t.$slots, "footer-right", {}, void 0, !0),
|
|
1435
1441
|
n.showWordLimit && n.maxLength !== 1 / 0 ? (m(), I("div", {
|
|
1436
1442
|
key: 0,
|
|
1437
|
-
class: oe(["tiny-sender__word-limit", { "is-over-limit":
|
|
1443
|
+
class: oe(["tiny-sender__word-limit", { "is-over-limit": ae.value }])
|
|
1438
1444
|
}, [
|
|
1439
|
-
|
|
1445
|
+
U("span", dn, de(k(g).length), 1),
|
|
1440
1446
|
Qe("/" + de(n.maxLength), 1)
|
|
1441
1447
|
], 2)) : P("", !0),
|
|
1442
1448
|
L.value === "multiple" ? (m(), I("div", fn, [
|
|
1443
|
-
|
|
1444
|
-
|
|
1449
|
+
U("div", pn, [
|
|
1450
|
+
Z(et, {
|
|
1445
1451
|
"allow-speech": n.allowSpeech,
|
|
1446
1452
|
"allow-files": n.allowFiles,
|
|
1447
1453
|
loading: n.loading,
|
|
1448
1454
|
disabled: ce.value,
|
|
1449
1455
|
"show-clear": n.clearable,
|
|
1450
|
-
"has-content":
|
|
1456
|
+
"has-content": H.value,
|
|
1451
1457
|
"speech-status": k(se),
|
|
1452
1458
|
"button-group": n.buttonGroup,
|
|
1453
1459
|
"submit-type": n.submitType,
|
|
1454
|
-
"is-over-limit":
|
|
1460
|
+
"is-over-limit": ae.value,
|
|
1455
1461
|
"stop-text": n.stopText,
|
|
1456
1462
|
onClear: Q,
|
|
1457
1463
|
onVoiceButtonClick: Te,
|
|
1458
1464
|
onSubmit: k(pe),
|
|
1459
|
-
onCancel:
|
|
1465
|
+
onCancel: a[3] || (a[3] = (u) => t.$emit("cancel")),
|
|
1460
1466
|
onTriggerSelect: k(s)
|
|
1461
1467
|
}, 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"])
|
|
1462
1468
|
])
|
|
1463
1469
|
])) : P("", !0)
|
|
1464
1470
|
])
|
|
1465
1471
|
])) : t.$slots.footer ? (m(), I("div", hn, [
|
|
1466
|
-
|
|
1472
|
+
ie(t.$slots, "footer", {}, void 0, !0)
|
|
1467
1473
|
])) : P("", !0)
|
|
1468
1474
|
]),
|
|
1469
1475
|
_: 3
|
|
1470
1476
|
})
|
|
1471
1477
|
], 512)
|
|
1472
1478
|
]),
|
|
1473
|
-
|
|
1479
|
+
Z(Jt, {
|
|
1474
1480
|
show: k(M),
|
|
1475
1481
|
suggestions: n.suggestions,
|
|
1476
1482
|
"popup-style": Oe.value,
|
|
1477
1483
|
"active-keyboard-index": k(W),
|
|
1478
|
-
"active-mouse-index": k(
|
|
1484
|
+
"active-mouse-index": k(S),
|
|
1479
1485
|
"input-value": k(g),
|
|
1480
|
-
onSelect: k(
|
|
1486
|
+
onSelect: k(j),
|
|
1481
1487
|
onMouseEnter: k(G),
|
|
1482
1488
|
onMouseLeave: k(ke)
|
|
1483
1489
|
}, null, 8, ["show", "suggestions", "popup-style", "active-keyboard-index", "active-mouse-index", "input-value", "onSelect", "onMouseEnter", "onMouseLeave"])
|