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