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