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