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