@opentiny/tiny-robot 0.2.1 → 0.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/action-group/index.js +1 -1
- package/dist/bubble/index.js +2 -3
- package/dist/close.js +1 -1
- package/dist/dropdown-menu/index.js +41 -40
- package/dist/feedback/index.js +2 -1
- package/dist/flow-layout-buttons/index.js +22 -22
- package/dist/history/index.js +2 -3
- package/dist/index.d.ts +58 -12
- package/dist/index2.js +37 -37
- package/dist/index3.js +129 -3717
- package/dist/index4.js +7 -7
- package/dist/index5.js +931 -2011
- package/dist/index6.js +1001 -875
- package/dist/prompts/index.js +2 -3
- package/dist/sender/index.js +696 -688
- package/dist/style.css +1 -1
- package/dist/suggestion-pills/index.js +125 -104
- package/dist/suggestion-popover/index.js +247 -122
- package/dist/tiny-robot-svgs.js +11 -11
- package/package.json +3 -3
package/dist/sender/index.js
CHANGED
|
@@ -1,64 +1,65 @@
|
|
|
1
|
-
import { ref as O, watch as Y, reactive as
|
|
1
|
+
import { ref as O, watch as Y, reactive as Oe, computed as $, nextTick as W, defineComponent as ve, createElementBlock as M, openBlock as k, createCommentVNode as P, createBlock as Z, unref as x, withCtx as G, createVNode as U, normalizeClass as oe, resolveDynamicComponent as Ze, createElementVNode as K, mergeModels as Ne, useModel as Ge, onMounted as Je, useSlots as Qe, Transition as ge, renderSlot as ne, isRef as Te, createTextVNode as xe, toDisplayString as se, normalizeStyle as Re, Fragment as ke, renderList as De, withModifiers as Ye } from "vue";
|
|
2
2
|
import { I as et } from "../index5.js";
|
|
3
3
|
import { B as ue } from "../index3.js";
|
|
4
4
|
import { T as me } from "../index4.js";
|
|
5
5
|
import { i as tt } from "../close.js";
|
|
6
|
-
import { I as nt, L as st,
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
import { I as nt, L as st, v as ot, w as lt, P as at, _ as it } from "../tiny-robot-svgs.js";
|
|
7
|
+
import { t as rt } from "../utils.js";
|
|
8
|
+
function ut(t, b) {
|
|
9
|
+
const d = O(t.modelValue || t.defaultValue || ""), o = O(null);
|
|
9
10
|
Y(
|
|
10
|
-
() =>
|
|
11
|
+
() => t.modelValue,
|
|
11
12
|
(v) => {
|
|
12
|
-
v !== void 0 && v !==
|
|
13
|
+
v !== void 0 && v !== d.value && (d.value = v);
|
|
13
14
|
}
|
|
14
15
|
), Y(
|
|
15
|
-
() =>
|
|
16
|
+
() => d.value,
|
|
16
17
|
(v) => {
|
|
17
18
|
b("update:modelValue", v);
|
|
18
19
|
}
|
|
19
20
|
);
|
|
20
21
|
const S = (v) => {
|
|
21
|
-
|
|
22
|
-
},
|
|
22
|
+
d.value = v, b("update:modelValue", v);
|
|
23
|
+
}, i = (v) => {
|
|
23
24
|
v == null || v.preventDefault();
|
|
24
|
-
const
|
|
25
|
-
!
|
|
26
|
-
},
|
|
27
|
-
|
|
25
|
+
const _ = d.value;
|
|
26
|
+
!t.disabled && !t.loading && _.trim() && b("submit", _);
|
|
27
|
+
}, f = () => {
|
|
28
|
+
d.value = "", b("update:modelValue", ""), b("clear");
|
|
28
29
|
}, u = O(!1);
|
|
29
30
|
return {
|
|
30
|
-
inputValue:
|
|
31
|
+
inputValue: d,
|
|
31
32
|
inputWrapper: o,
|
|
32
33
|
isComposing: u,
|
|
33
34
|
handleChange: S,
|
|
34
|
-
handleSubmit:
|
|
35
|
-
handleClear:
|
|
35
|
+
handleSubmit: i,
|
|
36
|
+
handleClear: f,
|
|
36
37
|
clearInput: () => {
|
|
37
|
-
|
|
38
|
+
f();
|
|
38
39
|
}
|
|
39
40
|
};
|
|
40
41
|
}
|
|
41
|
-
const
|
|
42
|
-
const b =
|
|
43
|
-
return !
|
|
44
|
-
},
|
|
45
|
-
const b =
|
|
42
|
+
const Ae = "", Q = (t) => t.split("").every((b) => b === Ae), J = (t) => t.replace(/\u200B/g, ""), he = () => document.createTextNode(Ae), ct = (t) => {
|
|
43
|
+
const b = t.textContent || "", d = J(b);
|
|
44
|
+
return !d || d.trim() === "";
|
|
45
|
+
}, Fe = (t) => {
|
|
46
|
+
const b = t.nextSibling;
|
|
46
47
|
if (b && b.nodeType === Node.TEXT_NODE && Q(b.textContent || ""))
|
|
47
48
|
return;
|
|
48
|
-
const
|
|
49
|
-
|
|
50
|
-
},
|
|
51
|
-
Array.from(
|
|
52
|
-
if (
|
|
53
|
-
const o =
|
|
54
|
-
o && o.nodeType === Node.ELEMENT_NODE && o.classList.contains("template-field") ||
|
|
49
|
+
const d = he();
|
|
50
|
+
t.parentNode && t.parentNode.insertBefore(d, t.nextSibling);
|
|
51
|
+
}, dt = (t) => {
|
|
52
|
+
Array.from(t.childNodes).forEach((d) => {
|
|
53
|
+
if (d.nodeType === Node.TEXT_NODE && Q(d.textContent || "")) {
|
|
54
|
+
const o = d.previousSibling;
|
|
55
|
+
o && o.nodeType === Node.ELEMENT_NODE && o.classList.contains("template-field") || d.parentNode && d.parentNode.removeChild(d);
|
|
55
56
|
}
|
|
56
57
|
});
|
|
57
58
|
};
|
|
58
|
-
function
|
|
59
|
-
const F = (m) => !
|
|
60
|
-
F(
|
|
61
|
-
},
|
|
59
|
+
function ft(t, b, d, o, S, i, f, u, s, v, _, l, E) {
|
|
60
|
+
const F = (m) => !t.disabled && !t.loading && m.trim().length > 0, y = () => {
|
|
61
|
+
F(d.value) && b("submit", d.value.trim());
|
|
62
|
+
}, w = (m, L) => {
|
|
62
63
|
if (!(m.key === "Enter")) return !1;
|
|
63
64
|
switch (L) {
|
|
64
65
|
case "enter":
|
|
@@ -74,20 +75,20 @@ function dt(e, b, f, o, S, r, p, u, l, v, E, a, _) {
|
|
|
74
75
|
return {
|
|
75
76
|
handleKeyPress: (m) => {
|
|
76
77
|
if (o.value) return;
|
|
77
|
-
if (m.key === "Enter" && m.shiftKey && (
|
|
78
|
-
m.preventDefault(),
|
|
79
|
-
const
|
|
80
|
-
|
|
78
|
+
if (m.key === "Enter" && m.shiftKey && (l == null ? void 0 : l.value) === "single" && E) {
|
|
79
|
+
m.preventDefault(), E();
|
|
80
|
+
const I = m.target, z = I.selectionStart, j = d.value;
|
|
81
|
+
d.value = j.substring(0, z) + `
|
|
81
82
|
` + j.substring(z), setTimeout(() => {
|
|
82
|
-
|
|
83
|
+
I.selectionStart = I.selectionEnd = z + 1;
|
|
83
84
|
}, 0);
|
|
84
85
|
return;
|
|
85
86
|
}
|
|
86
|
-
if (m.key === "Tab" &&
|
|
87
|
+
if (m.key === "Tab" && i.value && f.value) {
|
|
87
88
|
m.preventDefault(), u();
|
|
88
89
|
return;
|
|
89
90
|
}
|
|
90
|
-
if (
|
|
91
|
+
if (i.value) {
|
|
91
92
|
if (m.key === "ArrowDown") {
|
|
92
93
|
m.preventDefault(), v("down");
|
|
93
94
|
return;
|
|
@@ -96,208 +97,208 @@ function dt(e, b, f, o, S, r, p, u, l, v, E, a, _) {
|
|
|
96
97
|
m.preventDefault(), v("up");
|
|
97
98
|
return;
|
|
98
99
|
}
|
|
99
|
-
if (m.key === "Enter" &&
|
|
100
|
+
if (m.key === "Enter" && f.value) {
|
|
100
101
|
m.preventDefault(), u();
|
|
101
102
|
return;
|
|
102
103
|
}
|
|
103
104
|
}
|
|
104
105
|
if (m.key === "Escape") {
|
|
105
|
-
|
|
106
|
+
i.value ? (s(), m.preventDefault()) : S.isRecording && (_(), m.preventDefault()), b("escape-press");
|
|
106
107
|
return;
|
|
107
108
|
}
|
|
108
|
-
|
|
109
|
+
w(m, t.submitType) && F(d.value) && (m.preventDefault(), y());
|
|
109
110
|
},
|
|
110
111
|
triggerSubmit: y
|
|
111
112
|
};
|
|
112
113
|
}
|
|
113
|
-
function
|
|
114
|
-
const b = (
|
|
114
|
+
function pt(t) {
|
|
115
|
+
const b = (i, f, u) => {
|
|
115
116
|
var F;
|
|
116
|
-
const { startContainer:
|
|
117
|
-
if (!
|
|
118
|
-
const
|
|
119
|
-
if (
|
|
120
|
-
let y = null,
|
|
121
|
-
if (
|
|
122
|
-
if (
|
|
123
|
-
y =
|
|
117
|
+
const { startContainer: s, startOffset: v, collapsed: _ } = f;
|
|
118
|
+
if (!_) return !1;
|
|
119
|
+
const l = s.nodeType === Node.TEXT_NODE && v === 0 && i.key === "ArrowLeft", E = s.nodeType === Node.TEXT_NODE && v === (((F = s.textContent) == null ? void 0 : F.length) || 0) && i.key === "ArrowRight";
|
|
120
|
+
if (l || E) {
|
|
121
|
+
let y = null, w = "inside";
|
|
122
|
+
if (l)
|
|
123
|
+
if (s.parentNode && s.parentNode.classList.contains("template-field"))
|
|
124
|
+
y = s.parentNode, w = "before";
|
|
124
125
|
else {
|
|
125
|
-
let
|
|
126
|
-
!
|
|
126
|
+
let C = s.previousSibling;
|
|
127
|
+
!C && s.parentNode && s.parentNode !== u && (C = s.parentNode.previousSibling), C && C.nodeType === Node.ELEMENT_NODE && C.classList.contains("template-field") && (y = C, w = "inside");
|
|
127
128
|
}
|
|
128
|
-
else if (
|
|
129
|
-
if (
|
|
130
|
-
y =
|
|
129
|
+
else if (E)
|
|
130
|
+
if (s.parentNode && s.parentNode.classList.contains("template-field"))
|
|
131
|
+
y = s.parentNode, w = "after";
|
|
131
132
|
else {
|
|
132
|
-
let
|
|
133
|
-
!
|
|
133
|
+
let C = s.nextSibling;
|
|
134
|
+
!C && s.parentNode && s.parentNode !== u && (C = s.parentNode.nextSibling), C && C.nodeType === Node.ELEMENT_NODE && C.classList.contains("template-field") && (y = C, w = "inside");
|
|
134
135
|
}
|
|
135
136
|
if (y) {
|
|
136
|
-
|
|
137
|
-
const
|
|
138
|
-
return m && (
|
|
137
|
+
i.preventDefault();
|
|
138
|
+
const C = document.createRange(), m = window.getSelection();
|
|
139
|
+
return m && (w === "before" ? C.setStartBefore(y) : w === "after" ? C.setStartAfter(y) : (C.selectNodeContents(y), C.collapse(i.key === "ArrowLeft")), m.removeAllRanges(), m.addRange(C)), !0;
|
|
139
140
|
}
|
|
140
141
|
}
|
|
141
|
-
if (
|
|
142
|
-
const
|
|
143
|
-
if (!
|
|
144
|
-
|
|
142
|
+
if (s.nodeType === Node.ELEMENT_NODE && s.classList.contains("template-field")) {
|
|
143
|
+
const w = s.textContent || "", C = J(w);
|
|
144
|
+
if (!C || C.trim() === "") {
|
|
145
|
+
i.preventDefault();
|
|
145
146
|
const m = document.createRange(), L = window.getSelection();
|
|
146
147
|
if (!L) return !0;
|
|
147
|
-
if (
|
|
148
|
-
m.setStartBefore(
|
|
148
|
+
if (i.key === "ArrowLeft")
|
|
149
|
+
m.setStartBefore(s);
|
|
149
150
|
else {
|
|
150
|
-
const
|
|
151
|
-
|
|
151
|
+
const I = s.nextSibling;
|
|
152
|
+
I && I.nodeType === Node.TEXT_NODE && Q(I.textContent || "") ? (m.setStart(I, 0), m.setEnd(I, 0)) : m.setStartAfter(s);
|
|
152
153
|
}
|
|
153
154
|
return m.collapse(!0), L.removeAllRanges(), L.addRange(m), !0;
|
|
154
155
|
}
|
|
155
156
|
}
|
|
156
|
-
if (
|
|
157
|
-
const y =
|
|
158
|
-
|
|
159
|
-
const
|
|
160
|
-
return m && (
|
|
157
|
+
if (s.nodeType === Node.TEXT_NODE && Q(s.textContent || "")) {
|
|
158
|
+
const y = s.previousSibling, w = s.nextSibling;
|
|
159
|
+
i.preventDefault();
|
|
160
|
+
const C = document.createRange(), m = window.getSelection();
|
|
161
|
+
return m && (i.key === "ArrowLeft" ? y && y.nodeType === Node.ELEMENT_NODE && y.classList.contains("template-field") ? (C.selectNodeContents(y), C.collapse(!1)) : C.setStartBefore(s) : w && w.nodeType === Node.ELEMENT_NODE && w.classList.contains("template-field") ? (C.selectNodeContents(w), C.collapse(!0)) : C.setStartAfter(s), m.removeAllRanges(), m.addRange(C)), !0;
|
|
161
162
|
}
|
|
162
163
|
return !1;
|
|
163
|
-
},
|
|
164
|
-
if (!
|
|
165
|
-
const { startContainer:
|
|
166
|
-
if (
|
|
167
|
-
const
|
|
168
|
-
if (
|
|
169
|
-
const
|
|
164
|
+
}, d = (i, f, u) => {
|
|
165
|
+
if (!f.collapsed) return !1;
|
|
166
|
+
const { startContainer: s, startOffset: v } = f;
|
|
167
|
+
if (s.nodeType === Node.TEXT_NODE && Q(s.textContent || "")) {
|
|
168
|
+
const l = s.previousSibling;
|
|
169
|
+
if (l && l.nodeType === Node.ELEMENT_NODE && l.classList.contains("template-field")) {
|
|
170
|
+
const E = l, F = E.textContent || "", y = J(F);
|
|
170
171
|
if (!y || y.trim() === "") {
|
|
171
|
-
|
|
172
|
-
const
|
|
173
|
-
|
|
172
|
+
i.preventDefault();
|
|
173
|
+
const w = E.previousSibling, C = s.nextSibling;
|
|
174
|
+
E.parentNode && E.parentNode.removeChild(E), s.parentNode && s.parentNode.removeChild(s);
|
|
174
175
|
const m = window.getSelection();
|
|
175
176
|
if (m) {
|
|
176
177
|
const L = document.createRange();
|
|
177
|
-
|
|
178
|
+
w ? w.nodeType === Node.ELEMENT_NODE && w.classList.contains("template-field") ? (L.selectNodeContents(w), L.collapse(!1)) : w.nodeType === Node.TEXT_NODE && Q(w.textContent || "") ? (L.setStart(w, 0), L.setEnd(w, 0)) : L.setStartAfter(w) : C ? L.setStartBefore(C) : L.setStart(u, 0), L.collapse(!0), m.removeAllRanges(), m.addRange(L);
|
|
178
179
|
}
|
|
179
|
-
return
|
|
180
|
+
return t.handleInput(), !0;
|
|
180
181
|
} else {
|
|
181
|
-
|
|
182
|
-
const
|
|
183
|
-
if (
|
|
184
|
-
const
|
|
185
|
-
|
|
182
|
+
i.preventDefault();
|
|
183
|
+
const w = window.getSelection();
|
|
184
|
+
if (w) {
|
|
185
|
+
const C = document.createRange();
|
|
186
|
+
C.selectNodeContents(E), C.collapse(!1), w.removeAllRanges(), w.addRange(C);
|
|
186
187
|
}
|
|
187
188
|
return !0;
|
|
188
189
|
}
|
|
189
190
|
}
|
|
190
191
|
}
|
|
191
|
-
if (
|
|
192
|
-
const
|
|
193
|
-
if (J(
|
|
194
|
-
|
|
195
|
-
const F =
|
|
192
|
+
if (s.nodeType === Node.TEXT_NODE && s.parentNode && s.parentNode.classList.contains("template-field") && s.textContent) {
|
|
193
|
+
const l = s.textContent;
|
|
194
|
+
if (J(l).length === 1 && v === l.length) {
|
|
195
|
+
i.preventDefault(), s.textContent = "";
|
|
196
|
+
const F = s.parentNode, y = window.getSelection();
|
|
196
197
|
if (y) {
|
|
197
|
-
const
|
|
198
|
-
|
|
198
|
+
const w = document.createRange();
|
|
199
|
+
w.selectNodeContents(F), w.collapse(!0), y.removeAllRanges(), y.addRange(w);
|
|
199
200
|
}
|
|
200
|
-
return
|
|
201
|
+
return t.handleInput(), !0;
|
|
201
202
|
}
|
|
202
203
|
}
|
|
203
204
|
if (v === 0) {
|
|
204
|
-
let
|
|
205
|
-
if (
|
|
206
|
-
|
|
207
|
-
const
|
|
208
|
-
return
|
|
205
|
+
let l = null;
|
|
206
|
+
if (s.nodeType === Node.ELEMENT_NODE && s.classList.contains("template-field") ? l = s : s.nodeType === Node.TEXT_NODE && s.parentNode && s.parentNode.classList.contains("template-field") && (l = s.parentNode), l) {
|
|
207
|
+
i.preventDefault();
|
|
208
|
+
const E = window.getSelection();
|
|
209
|
+
return E && (f.setStartBefore(l), f.collapse(!0), E.removeAllRanges(), E.addRange(f)), !0;
|
|
209
210
|
}
|
|
210
211
|
}
|
|
211
212
|
return !1;
|
|
212
|
-
}, o = (
|
|
213
|
-
if (!
|
|
214
|
-
const { startContainer: u, startOffset:
|
|
213
|
+
}, o = (i, f) => {
|
|
214
|
+
if (!f.collapsed) return !1;
|
|
215
|
+
const { startContainer: u, startOffset: s } = f;
|
|
215
216
|
if (u.nodeType === Node.TEXT_NODE && u.parentNode && u.parentNode.classList.contains("template-field") && u.textContent) {
|
|
216
|
-
const
|
|
217
|
-
if (
|
|
218
|
-
|
|
219
|
-
const
|
|
217
|
+
const _ = u.textContent, l = J(_);
|
|
218
|
+
if (s === _.length && l.length === 1) {
|
|
219
|
+
i.preventDefault(), u.textContent = "";
|
|
220
|
+
const E = u.parentNode, F = window.getSelection();
|
|
220
221
|
if (F) {
|
|
221
222
|
const y = document.createRange();
|
|
222
|
-
y.selectNodeContents(
|
|
223
|
+
y.selectNodeContents(E), y.collapse(!0), F.removeAllRanges(), F.addRange(y);
|
|
223
224
|
}
|
|
224
|
-
return
|
|
225
|
+
return t.handleInput(), !0;
|
|
225
226
|
}
|
|
226
227
|
}
|
|
227
228
|
return !1;
|
|
228
229
|
};
|
|
229
230
|
return {
|
|
230
|
-
handleTemplateKeyDown: (
|
|
231
|
-
if (
|
|
232
|
-
const
|
|
233
|
-
if (!
|
|
231
|
+
handleTemplateKeyDown: (i) => {
|
|
232
|
+
if (t.isComposing.value) return;
|
|
233
|
+
const f = t.editor.value;
|
|
234
|
+
if (!f) return;
|
|
234
235
|
const u = window.getSelection();
|
|
235
236
|
if (!u || u.rangeCount === 0) return;
|
|
236
|
-
const
|
|
237
|
-
if (
|
|
238
|
-
|
|
237
|
+
const s = u.getRangeAt(0);
|
|
238
|
+
if (i.key === "Enter") {
|
|
239
|
+
i.preventDefault(), t.onSubmit(t.getValueFromDOM());
|
|
239
240
|
return;
|
|
240
241
|
}
|
|
241
|
-
(
|
|
242
|
+
(i.key === "ArrowLeft" || i.key === "ArrowRight") && !i.shiftKey && b(i, s, f) || i.key === "Backspace" && d(i, s, f) || i.key === "Delete" && o(i, s);
|
|
242
243
|
}
|
|
243
244
|
};
|
|
244
245
|
}
|
|
245
|
-
function
|
|
246
|
-
const b =
|
|
246
|
+
function gt(t) {
|
|
247
|
+
const b = Oe({
|
|
247
248
|
isRecording: !1,
|
|
248
249
|
isSupported: typeof window < "u" && "webkitSpeechRecognition" in window || "SpeechRecognition" in window,
|
|
249
250
|
error: void 0
|
|
250
|
-
}),
|
|
251
|
-
|
|
252
|
-
var
|
|
253
|
-
b.isRecording = !0, b.error = void 0, (
|
|
254
|
-
},
|
|
255
|
-
var
|
|
256
|
-
b.isRecording = !1, (
|
|
257
|
-
},
|
|
258
|
-
var
|
|
259
|
-
const u = Array.from(
|
|
260
|
-
|
|
261
|
-
},
|
|
251
|
+
}), d = b.isSupported ? new (window.webkitSpeechRecognition || window.SpeechRecognition)() : void 0;
|
|
252
|
+
d !== void 0 && (d.continuous = t.continuous ?? !1, d.interimResults = t.interimResults ?? !0, d.lang = t.lang ?? navigator.language, d.onstart = () => {
|
|
253
|
+
var f;
|
|
254
|
+
b.isRecording = !0, b.error = void 0, (f = t.onStart) == null || f.call(t);
|
|
255
|
+
}, d.onend = () => {
|
|
256
|
+
var f;
|
|
257
|
+
b.isRecording = !1, (f = t.onEnd) == null || f.call(t);
|
|
258
|
+
}, d.onresult = (f) => {
|
|
259
|
+
var s, v;
|
|
260
|
+
const u = Array.from(f.results).map((_) => _[0].transcript).join("");
|
|
261
|
+
f.results[0].isFinal ? (s = t.onFinal) == null || s.call(t, u) : (v = t.onInterim) == null || v.call(t, u);
|
|
262
|
+
}, d.onerror = (f) => {
|
|
262
263
|
var u;
|
|
263
|
-
b.error = new Error(
|
|
264
|
+
b.error = new Error(f.error), b.isRecording = !1, (u = t.onError) == null || u.call(t, b.error);
|
|
264
265
|
});
|
|
265
266
|
const o = () => {
|
|
266
|
-
var
|
|
267
|
-
if (!
|
|
267
|
+
var f;
|
|
268
|
+
if (!d) {
|
|
268
269
|
const u = new Error("浏览器不支持语音识别");
|
|
269
|
-
b.error = u, (
|
|
270
|
+
b.error = u, (f = t.onError) == null || f.call(t, u);
|
|
270
271
|
return;
|
|
271
272
|
}
|
|
272
273
|
if (b.isRecording) {
|
|
273
274
|
try {
|
|
274
|
-
|
|
275
|
+
d.stop(), setTimeout(() => {
|
|
275
276
|
try {
|
|
276
|
-
|
|
277
|
+
d.start();
|
|
277
278
|
} catch (u) {
|
|
278
|
-
|
|
279
|
+
i(u);
|
|
279
280
|
}
|
|
280
281
|
}, 100);
|
|
281
282
|
} catch (u) {
|
|
282
|
-
|
|
283
|
+
i(u);
|
|
283
284
|
}
|
|
284
285
|
return;
|
|
285
286
|
}
|
|
286
287
|
try {
|
|
287
|
-
|
|
288
|
+
d.start();
|
|
288
289
|
} catch (u) {
|
|
289
|
-
|
|
290
|
+
i(u);
|
|
290
291
|
}
|
|
291
292
|
}, S = () => {
|
|
292
|
-
if (
|
|
293
|
+
if (d && b.isRecording)
|
|
293
294
|
try {
|
|
294
|
-
|
|
295
|
-
} catch (
|
|
296
|
-
|
|
295
|
+
d.stop();
|
|
296
|
+
} catch (f) {
|
|
297
|
+
i(f);
|
|
297
298
|
}
|
|
298
|
-
},
|
|
299
|
+
}, i = (f) => {
|
|
299
300
|
var u;
|
|
300
|
-
b.error =
|
|
301
|
+
b.error = f instanceof Error ? f : new Error("语音识别操作失败"), b.isRecording = !1, (u = t.onError) == null || u.call(t, b.error);
|
|
301
302
|
};
|
|
302
303
|
return {
|
|
303
304
|
speechState: b,
|
|
@@ -305,86 +306,90 @@ function pt(e) {
|
|
|
305
306
|
stop: S
|
|
306
307
|
};
|
|
307
308
|
}
|
|
308
|
-
const
|
|
309
|
-
if (!b || !
|
|
310
|
-
return [{ text:
|
|
311
|
-
const
|
|
309
|
+
const mt = (t, b) => {
|
|
310
|
+
if (!b || !t)
|
|
311
|
+
return [{ text: t, isMatch: !1 }];
|
|
312
|
+
const d = t.toLowerCase(), o = b.toLowerCase(), S = d.indexOf(o);
|
|
312
313
|
if (S === -1)
|
|
313
|
-
return [{ text:
|
|
314
|
-
const
|
|
315
|
-
return S > 0 &&
|
|
316
|
-
text:
|
|
314
|
+
return [{ text: t, isMatch: !1 }];
|
|
315
|
+
const i = [];
|
|
316
|
+
return S > 0 && i.push({
|
|
317
|
+
text: t.substring(0, S),
|
|
317
318
|
isMatch: !1
|
|
318
|
-
}),
|
|
319
|
-
text:
|
|
319
|
+
}), i.push({
|
|
320
|
+
text: t.substring(S, S + b.length),
|
|
320
321
|
isMatch: !0
|
|
321
|
-
}), S + b.length <
|
|
322
|
-
text:
|
|
322
|
+
}), S + b.length < t.length && i.push({
|
|
323
|
+
text: t.substring(S + b.length),
|
|
323
324
|
isMatch: !1
|
|
324
|
-
}),
|
|
325
|
+
}), i;
|
|
325
326
|
};
|
|
326
|
-
function
|
|
327
|
-
const S = O(!1),
|
|
328
|
-
if (!
|
|
329
|
-
const
|
|
330
|
-
return
|
|
331
|
-
}),
|
|
332
|
-
|
|
333
|
-
|
|
327
|
+
function ht(t, b, d, o) {
|
|
328
|
+
const S = O(!1), i = O(-1), f = O(""), u = O(!1), s = O(null), v = O(!1), _ = $(() => {
|
|
329
|
+
if (!t.suggestions || !d.value || t.template) return [];
|
|
330
|
+
const p = d.value.toLowerCase();
|
|
331
|
+
return t.suggestions.filter((h) => h.toLowerCase().includes(p));
|
|
332
|
+
}), l = $(() => _.value[i.value] || null), E = (p) => {
|
|
333
|
+
if (!p && i.value === -1) {
|
|
334
|
+
f.value = "";
|
|
335
|
+
return;
|
|
336
|
+
}
|
|
337
|
+
const h = p || l.value;
|
|
338
|
+
h && d.value && h.toLowerCase().startsWith(d.value.toLowerCase()) ? f.value = h.substring(d.value.length) : f.value = "";
|
|
334
339
|
}, F = () => {
|
|
335
|
-
S.value = !1,
|
|
340
|
+
S.value = !1, i.value = -1, f.value = "", u.value = !1;
|
|
336
341
|
}, y = () => {
|
|
337
|
-
S.value = !0,
|
|
338
|
-
},
|
|
342
|
+
S.value = !0, i.value = -1, E(), u.value = !0;
|
|
343
|
+
}, w = () => {
|
|
339
344
|
o.value || v.value || W(() => {
|
|
340
|
-
|
|
345
|
+
d.value && t.suggestions && t.suggestions.length > 0 && !t.template && _.value.length > 0 ? y() : F();
|
|
341
346
|
});
|
|
342
347
|
};
|
|
343
|
-
Y(
|
|
344
|
-
const
|
|
345
|
-
v.value = !0,
|
|
348
|
+
Y(d, w), Y(() => t.suggestions, w);
|
|
349
|
+
const C = (p) => {
|
|
350
|
+
v.value = !0, d.value = p, b("update:modelValue", p), b("suggestion-select", p), L(), W(() => {
|
|
346
351
|
v.value = !1;
|
|
347
352
|
});
|
|
348
353
|
}, m = () => {
|
|
349
|
-
|
|
354
|
+
l.value && C(l.value);
|
|
350
355
|
}, L = () => {
|
|
351
356
|
F();
|
|
352
357
|
};
|
|
353
358
|
return {
|
|
354
359
|
showSuggestionsPopup: S,
|
|
355
|
-
highlightedIndex:
|
|
356
|
-
completionPlaceholder:
|
|
360
|
+
highlightedIndex: i,
|
|
361
|
+
completionPlaceholder: f,
|
|
357
362
|
showTabHint: u,
|
|
358
|
-
suggestionsListRef:
|
|
359
|
-
filteredSuggestions:
|
|
360
|
-
activeSuggestion:
|
|
361
|
-
updateCompletionPlaceholder:
|
|
362
|
-
updateSuggestionsState:
|
|
363
|
-
selectSuggestion:
|
|
363
|
+
suggestionsListRef: s,
|
|
364
|
+
filteredSuggestions: _,
|
|
365
|
+
activeSuggestion: l,
|
|
366
|
+
updateCompletionPlaceholder: E,
|
|
367
|
+
updateSuggestionsState: w,
|
|
368
|
+
selectSuggestion: C,
|
|
364
369
|
acceptCurrentSuggestion: m,
|
|
365
370
|
closeSuggestionsPopup: L,
|
|
366
|
-
navigateSuggestions: (
|
|
367
|
-
if (!S.value ||
|
|
368
|
-
|
|
369
|
-
const h =
|
|
371
|
+
navigateSuggestions: (p) => {
|
|
372
|
+
if (!S.value || _.value.length === 0) return;
|
|
373
|
+
i.value === -1 ? i.value = p === "down" ? 0 : _.value.length - 1 : p === "down" ? i.value = (i.value + 1) % _.value.length : i.value = (i.value - 1 + _.value.length) % _.value.length, l.value && E(l.value);
|
|
374
|
+
const h = s.value;
|
|
370
375
|
if (h) {
|
|
371
|
-
const
|
|
372
|
-
|
|
376
|
+
const N = h.children[i.value];
|
|
377
|
+
N && N.scrollIntoView({ block: "nearest" });
|
|
373
378
|
}
|
|
374
379
|
},
|
|
375
|
-
handleSuggestionItemHover: (
|
|
376
|
-
|
|
380
|
+
handleSuggestionItemHover: (p) => {
|
|
381
|
+
i.value = p, E(_.value[p]);
|
|
377
382
|
},
|
|
378
383
|
handleClickOutside: () => {
|
|
379
384
|
L();
|
|
380
385
|
},
|
|
381
|
-
highlightSuggestionText:
|
|
386
|
+
highlightSuggestionText: mt
|
|
382
387
|
};
|
|
383
388
|
}
|
|
384
|
-
const
|
|
389
|
+
const vt = { class: "action-buttons" }, yt = {
|
|
385
390
|
key: 0,
|
|
386
391
|
class: "action-buttons__utility"
|
|
387
|
-
},
|
|
392
|
+
}, bt = { class: "action-buttons__submit-content" }, Ct = { class: "action-buttons__cancel" }, Le = /* @__PURE__ */ ve({
|
|
388
393
|
__name: "ActionButtons",
|
|
389
394
|
props: {
|
|
390
395
|
loading: { type: Boolean, default: !1 },
|
|
@@ -402,34 +407,34 @@ const ht = { class: "action-buttons" }, vt = {
|
|
|
402
407
|
isOverLimit: { type: Boolean, default: !1 }
|
|
403
408
|
},
|
|
404
409
|
emits: ["clear", "toggle-speech", "submit", "cancel"],
|
|
405
|
-
setup(
|
|
406
|
-
const
|
|
410
|
+
setup(t, { emit: b }) {
|
|
411
|
+
const d = tt(), o = t, S = b, i = $(() => o.allowSpeech), f = $(() => o.speechStatus.isRecording), u = $(() => o.disabled), s = $(() => u.value || o.isOverLimit), v = $(() => o.allowFiles || o.allowSpeech || o.showClear), _ = () => {
|
|
407
412
|
u.value || S("clear");
|
|
408
|
-
},
|
|
413
|
+
}, l = () => {
|
|
409
414
|
if (!u.value) {
|
|
410
415
|
const y = !o.speechStatus.isRecording;
|
|
411
416
|
S("toggle-speech", y);
|
|
412
417
|
}
|
|
413
|
-
},
|
|
414
|
-
|
|
418
|
+
}, E = () => {
|
|
419
|
+
s.value || S("submit");
|
|
415
420
|
}, F = () => {
|
|
416
421
|
u.value || S("cancel");
|
|
417
422
|
};
|
|
418
|
-
return (y,
|
|
419
|
-
v.value ? (k(), M("div",
|
|
420
|
-
y.allowFiles && !y.loading ? (k(), Z(
|
|
423
|
+
return (y, w) => (k(), M("div", vt, [
|
|
424
|
+
v.value ? (k(), M("div", yt, [
|
|
425
|
+
y.allowFiles && !y.loading ? (k(), Z(x(me), {
|
|
421
426
|
key: 0,
|
|
422
427
|
content: "上传文件",
|
|
423
428
|
placement: "top"
|
|
424
429
|
}, {
|
|
425
430
|
default: G(() => [
|
|
426
|
-
U(
|
|
431
|
+
U(x(ue), {
|
|
427
432
|
class: "action-buttons__button action-buttons__file-button",
|
|
428
433
|
type: "text",
|
|
429
434
|
disabled: u.value
|
|
430
435
|
}, {
|
|
431
436
|
default: G(() => [
|
|
432
|
-
U(
|
|
437
|
+
U(x(nt), {
|
|
433
438
|
class: "action-buttons__icon",
|
|
434
439
|
alt: "上传文件"
|
|
435
440
|
})
|
|
@@ -438,73 +443,73 @@ const ht = { class: "action-buttons" }, vt = {
|
|
|
438
443
|
}, 8, ["disabled"])
|
|
439
444
|
]),
|
|
440
445
|
_: 1
|
|
441
|
-
})) :
|
|
442
|
-
|
|
446
|
+
})) : P("", !0),
|
|
447
|
+
i.value && !y.loading ? (k(), Z(x(ue), {
|
|
443
448
|
key: 1,
|
|
444
|
-
class:
|
|
449
|
+
class: oe(["action-buttons__button action-buttons__speech-button", { "is-recording": f.value }]),
|
|
445
450
|
type: "text",
|
|
446
451
|
disabled: u.value,
|
|
447
|
-
onClick:
|
|
452
|
+
onClick: l
|
|
448
453
|
}, {
|
|
449
454
|
default: G(() => [
|
|
450
|
-
|
|
455
|
+
f.value ? (k(), Z(x(ot), {
|
|
451
456
|
key: 1,
|
|
452
457
|
class: "action-buttons__icon action-buttons__icon--recording",
|
|
453
458
|
alt: "语音中"
|
|
454
|
-
})) : (k(), Z(
|
|
459
|
+
})) : (k(), Z(x(st), {
|
|
455
460
|
key: 0,
|
|
456
461
|
class: "action-buttons__icon",
|
|
457
462
|
alt: "录音"
|
|
458
463
|
}))
|
|
459
464
|
]),
|
|
460
465
|
_: 1
|
|
461
|
-
}, 8, ["disabled", "class"])) :
|
|
462
|
-
y.showClear ? (k(), Z(
|
|
466
|
+
}, 8, ["disabled", "class"])) : P("", !0),
|
|
467
|
+
y.showClear ? (k(), Z(x(me), {
|
|
463
468
|
key: 2,
|
|
464
469
|
content: "清空内容",
|
|
465
470
|
placement: "top"
|
|
466
471
|
}, {
|
|
467
472
|
default: G(() => [
|
|
468
|
-
U(
|
|
473
|
+
U(x(ue), {
|
|
469
474
|
class: "action-buttons__button action-buttons__clear-button",
|
|
470
475
|
type: "text",
|
|
471
476
|
disabled: u.value || !y.hasContent,
|
|
472
|
-
onClick:
|
|
477
|
+
onClick: _
|
|
473
478
|
}, {
|
|
474
479
|
default: G(() => [
|
|
475
|
-
(k(), Z(
|
|
480
|
+
(k(), Z(Ze(x(d)), { class: "action-buttons__icon action-buttons__icon--close" }))
|
|
476
481
|
]),
|
|
477
482
|
_: 1
|
|
478
483
|
}, 8, ["disabled"])
|
|
479
484
|
]),
|
|
480
485
|
_: 1
|
|
481
|
-
})) :
|
|
482
|
-
])) :
|
|
483
|
-
y.hasContent || y.loading ? (k(), Z(
|
|
486
|
+
})) : P("", !0)
|
|
487
|
+
])) : P("", !0),
|
|
488
|
+
y.hasContent || y.loading ? (k(), Z(x(ue), {
|
|
484
489
|
key: 1,
|
|
485
490
|
type: "text",
|
|
486
491
|
class: "action-buttons__button action-buttons__submit",
|
|
487
|
-
disabled: y.loading ? u.value :
|
|
488
|
-
onClick:
|
|
492
|
+
disabled: y.loading ? u.value : s.value,
|
|
493
|
+
onClick: w[0] || (w[0] = (C) => y.loading ? F() : E())
|
|
489
494
|
}, {
|
|
490
495
|
default: G(() => [
|
|
491
|
-
K("div",
|
|
492
|
-
y.loading ? (k(), Z(
|
|
496
|
+
K("div", bt, [
|
|
497
|
+
y.loading ? (k(), Z(x(me), {
|
|
493
498
|
key: 1,
|
|
494
499
|
content: "停止生成",
|
|
495
500
|
placement: "top"
|
|
496
501
|
}, {
|
|
497
502
|
default: G(() => [
|
|
498
|
-
K("div",
|
|
499
|
-
U(
|
|
503
|
+
K("div", Ct, [
|
|
504
|
+
U(x(at), {
|
|
500
505
|
class: "action-buttons__icon action-buttons__icon--stop",
|
|
501
506
|
alt: "加载中"
|
|
502
507
|
}),
|
|
503
|
-
|
|
508
|
+
w[1] || (w[1] = K("span", { class: "action-buttons__cancel-text" }, "停止回答", -1))
|
|
504
509
|
])
|
|
505
510
|
]),
|
|
506
511
|
_: 1
|
|
507
|
-
})) : (k(), Z(
|
|
512
|
+
})) : (k(), Z(x(lt), {
|
|
508
513
|
key: 0,
|
|
509
514
|
class: "action-buttons__icon action-buttons__icon--send",
|
|
510
515
|
alt: "发送"
|
|
@@ -512,297 +517,297 @@ const ht = { class: "action-buttons" }, vt = {
|
|
|
512
517
|
])
|
|
513
518
|
]),
|
|
514
519
|
_: 1
|
|
515
|
-
}, 8, ["disabled"])) :
|
|
520
|
+
}, 8, ["disabled"])) : P("", !0)
|
|
516
521
|
]));
|
|
517
522
|
}
|
|
518
523
|
});
|
|
519
|
-
function
|
|
520
|
-
const
|
|
521
|
-
Object.assign(o,
|
|
522
|
-
},
|
|
523
|
-
const
|
|
524
|
-
let
|
|
525
|
-
const
|
|
526
|
-
let
|
|
527
|
-
for (; (
|
|
528
|
-
|
|
529
|
-
return
|
|
530
|
-
},
|
|
531
|
-
if (!
|
|
532
|
-
let
|
|
533
|
-
const
|
|
534
|
-
let
|
|
535
|
-
if (
|
|
536
|
-
const
|
|
537
|
-
|
|
538
|
-
} else if (
|
|
539
|
-
const
|
|
540
|
-
if (
|
|
541
|
-
const
|
|
542
|
-
|
|
543
|
-
} else if (
|
|
544
|
-
const
|
|
545
|
-
|
|
546
|
-
} else if (
|
|
547
|
-
|
|
524
|
+
function wt(t, b) {
|
|
525
|
+
const d = O(!1), o = Oe({ ...b }), S = (n) => {
|
|
526
|
+
Object.assign(o, n);
|
|
527
|
+
}, i = (n) => {
|
|
528
|
+
const r = [];
|
|
529
|
+
let e = 0;
|
|
530
|
+
const a = /\[(.*?)\]/g;
|
|
531
|
+
let g;
|
|
532
|
+
for (; (g = a.exec(n)) !== null; )
|
|
533
|
+
g.index > e && r.push({ type: "text", content: n.substring(e, g.index) }), r.push({ type: "field", content: g[1] }), e = g.index + g[0].length;
|
|
534
|
+
return e < n.length && r.push({ type: "text", content: n.substring(e) }), r;
|
|
535
|
+
}, f = () => {
|
|
536
|
+
if (!t.value) return "";
|
|
537
|
+
let n = "";
|
|
538
|
+
const r = (e) => {
|
|
539
|
+
let a = "";
|
|
540
|
+
if (e.nodeType === Node.TEXT_NODE) {
|
|
541
|
+
const g = e.textContent || "";
|
|
542
|
+
a += J(g);
|
|
543
|
+
} else if (e.nodeType === Node.ELEMENT_NODE) {
|
|
544
|
+
const g = e;
|
|
545
|
+
if (g.classList.contains("template-field")) {
|
|
546
|
+
const T = g.textContent || "";
|
|
547
|
+
a += J(T);
|
|
548
|
+
} else if (g.tagName.toLowerCase() === "span") {
|
|
549
|
+
const T = g.textContent || "";
|
|
550
|
+
a += J(T);
|
|
551
|
+
} else if (g.tagName.toLowerCase() === "br")
|
|
552
|
+
a += `
|
|
548
553
|
`;
|
|
549
554
|
else
|
|
550
|
-
for (const
|
|
551
|
-
|
|
555
|
+
for (const T of Array.from(g.childNodes))
|
|
556
|
+
a += r(T);
|
|
552
557
|
}
|
|
553
|
-
return
|
|
558
|
+
return a;
|
|
554
559
|
};
|
|
555
|
-
return
|
|
556
|
-
|
|
557
|
-
}), t;
|
|
558
|
-
}, u = (t) => o.initialValues && typeof o.initialValues[t] == "string" ? o.initialValues[t] : "", l = (t, i) => {
|
|
559
|
-
const n = document.createElement("span");
|
|
560
|
-
return n.className = "template-field", n.setAttribute("data-placeholder", t), i && (n.textContent = i), W(() => {
|
|
561
|
-
v(n, i || "");
|
|
560
|
+
return t.value.childNodes.forEach((e) => {
|
|
561
|
+
n += r(e);
|
|
562
562
|
}), n;
|
|
563
|
-
},
|
|
564
|
-
const
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
563
|
+
}, u = (n) => o.initialValues && typeof o.initialValues[n] == "string" ? o.initialValues[n] : "", s = (n, r) => {
|
|
564
|
+
const e = document.createElement("span");
|
|
565
|
+
return e.className = "template-field", e.setAttribute("data-placeholder", n), r && (e.textContent = r), W(() => {
|
|
566
|
+
v(e, r || "");
|
|
567
|
+
}), e;
|
|
568
|
+
}, v = (n, r) => {
|
|
569
|
+
const e = J(r);
|
|
570
|
+
if (!e || e.trim() === "") {
|
|
571
|
+
const a = n.getAttribute("data-placeholder") || "";
|
|
572
|
+
a ? _(n, a, !0) : (n.style.minWidth = "", n.style.width = "");
|
|
568
573
|
} else
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
},
|
|
572
|
-
const
|
|
573
|
-
|
|
574
|
-
const
|
|
575
|
-
document.body.removeChild(
|
|
576
|
-
const V =
|
|
577
|
-
|
|
578
|
-
const
|
|
579
|
-
B >
|
|
580
|
-
},
|
|
581
|
-
const
|
|
582
|
-
|
|
583
|
-
},
|
|
574
|
+
_(n, e, !1);
|
|
575
|
+
Fe(n);
|
|
576
|
+
}, _ = (n, r, e) => {
|
|
577
|
+
const a = document.createElement("span");
|
|
578
|
+
a.className = "template-field", a.style.visibility = "hidden", a.style.position = "absolute", a.style.top = "-9999px", a.style.left = "-9999px", a.style.whiteSpace = "nowrap", a.style.padding = "3px 8px", a.style.margin = "0 2px", a.style.boxSizing = "border-box", a.textContent = r, document.body.appendChild(a);
|
|
579
|
+
const g = getComputedStyle(a), T = a.offsetWidth, A = parseFloat(g.fontSize);
|
|
580
|
+
document.body.removeChild(a);
|
|
581
|
+
const V = e ? 1.5 : 2, X = T / A, B = Math.max(V, Math.ceil(X));
|
|
582
|
+
n.style.setProperty("min-width", `${B}em`, "important");
|
|
583
|
+
const q = 20;
|
|
584
|
+
B > q ? (n.style.setProperty("max-width", `${q}em`, "important"), n.style.setProperty("white-space", "normal", "important"), n.style.setProperty("word-break", "break-word", "important")) : n.style.removeProperty("max-width");
|
|
585
|
+
}, l = (n) => {
|
|
586
|
+
const e = (n === void 0 ? f() : n).trim().length > 0;
|
|
587
|
+
d.value !== e && (d.value = e, o.onContentStatusChange(e));
|
|
588
|
+
}, E = (n, r = "inside", e = !1) => {
|
|
584
589
|
W(() => {
|
|
585
|
-
const
|
|
586
|
-
if (!
|
|
587
|
-
const
|
|
588
|
-
switch (
|
|
590
|
+
const a = window.getSelection();
|
|
591
|
+
if (!a) return;
|
|
592
|
+
const g = document.createRange();
|
|
593
|
+
switch (r) {
|
|
589
594
|
case "before":
|
|
590
|
-
|
|
595
|
+
g.setStartBefore(n);
|
|
591
596
|
break;
|
|
592
597
|
case "after":
|
|
593
|
-
|
|
598
|
+
g.setStartAfter(n);
|
|
594
599
|
break;
|
|
595
600
|
case "inside":
|
|
596
601
|
default:
|
|
597
|
-
|
|
602
|
+
g.selectNodeContents(n), g.collapse(e);
|
|
598
603
|
break;
|
|
599
604
|
}
|
|
600
|
-
|
|
605
|
+
a.removeAllRanges(), a.addRange(g), n.focus && n.focus();
|
|
601
606
|
});
|
|
602
607
|
}, F = () => {
|
|
603
608
|
W(() => {
|
|
604
|
-
const
|
|
605
|
-
if (
|
|
606
|
-
const
|
|
607
|
-
|
|
609
|
+
const n = t.value;
|
|
610
|
+
if (n) {
|
|
611
|
+
const r = document.createRange(), e = window.getSelection();
|
|
612
|
+
r.selectNodeContents(n), r.collapse(!1), e && (e.removeAllRanges(), e.addRange(r)), n.focus();
|
|
608
613
|
}
|
|
609
614
|
});
|
|
610
|
-
}, y = (
|
|
611
|
-
const
|
|
612
|
-
if (!
|
|
613
|
-
|
|
614
|
-
let
|
|
615
|
-
if (!
|
|
616
|
-
|
|
617
|
-
if (
|
|
618
|
-
const
|
|
619
|
-
|
|
615
|
+
}, y = (n, r) => {
|
|
616
|
+
const e = t.value;
|
|
617
|
+
if (!e) return null;
|
|
618
|
+
e.innerHTML = "";
|
|
619
|
+
let a = null;
|
|
620
|
+
if (!r || r === o.template)
|
|
621
|
+
n.forEach((g) => {
|
|
622
|
+
if (g.type === "field") {
|
|
623
|
+
const T = u(g.content), A = s(g.content, T);
|
|
624
|
+
e.appendChild(A);
|
|
620
625
|
const V = he();
|
|
621
|
-
|
|
626
|
+
e.appendChild(V), a || (a = A);
|
|
622
627
|
} else
|
|
623
|
-
|
|
628
|
+
e.appendChild(document.createTextNode(g.content));
|
|
624
629
|
}), o.initialValues && Object.keys(o.initialValues).length > 0 && W(() => {
|
|
625
|
-
const
|
|
626
|
-
|
|
630
|
+
const g = f();
|
|
631
|
+
g !== o.value && (o.onValueChange(g), o.onInput(g));
|
|
627
632
|
});
|
|
628
633
|
else {
|
|
629
|
-
const
|
|
630
|
-
|
|
631
|
-
if (
|
|
632
|
-
const
|
|
633
|
-
|
|
634
|
+
const g = w(n, r);
|
|
635
|
+
g.success ? g.elements.forEach((T) => {
|
|
636
|
+
if (e.appendChild(T.node), T.isField) {
|
|
637
|
+
const A = he();
|
|
638
|
+
e.appendChild(A);
|
|
634
639
|
}
|
|
635
|
-
|
|
636
|
-
}) : (
|
|
640
|
+
T.isField && !a && (a = T.node);
|
|
641
|
+
}) : (e.appendChild(document.createTextNode(r)), a = null);
|
|
637
642
|
}
|
|
638
|
-
return
|
|
639
|
-
},
|
|
640
|
-
const
|
|
641
|
-
let
|
|
642
|
-
for (;
|
|
643
|
-
const
|
|
644
|
-
if (
|
|
645
|
-
|
|
646
|
-
node: document.createTextNode(
|
|
643
|
+
return a;
|
|
644
|
+
}, w = (n, r) => {
|
|
645
|
+
const e = [];
|
|
646
|
+
let a = 0, g = 0, T = !0;
|
|
647
|
+
for (; g < n.length && a <= r.length && T; ) {
|
|
648
|
+
const A = n[g];
|
|
649
|
+
if (A.type === "text")
|
|
650
|
+
r.substring(a).startsWith(A.content) ? (e.push({
|
|
651
|
+
node: document.createTextNode(A.content),
|
|
647
652
|
isField: !1
|
|
648
|
-
}),
|
|
653
|
+
}), a += A.content.length, g++) : T = !1;
|
|
649
654
|
else {
|
|
650
655
|
let V = "";
|
|
651
|
-
const
|
|
652
|
-
if (
|
|
653
|
-
const B =
|
|
654
|
-
|
|
656
|
+
const X = n.find((B, q) => q > g && B.type === "text");
|
|
657
|
+
if (X) {
|
|
658
|
+
const B = r.substring(a), q = B.indexOf(X.content);
|
|
659
|
+
q !== -1 ? (V = B.substring(0, q), a += V.length) : T = !1;
|
|
655
660
|
} else
|
|
656
|
-
V =
|
|
657
|
-
if (
|
|
658
|
-
const B =
|
|
659
|
-
|
|
661
|
+
V = r.substring(a), a = r.length;
|
|
662
|
+
if (T) {
|
|
663
|
+
const B = s(A.content, V);
|
|
664
|
+
e.push({ node: B, isField: !0 }), g++;
|
|
660
665
|
}
|
|
661
666
|
}
|
|
662
667
|
}
|
|
663
|
-
if (
|
|
664
|
-
for (let
|
|
665
|
-
const V =
|
|
668
|
+
if (T && g < n.length)
|
|
669
|
+
for (let A = g; A < n.length; A++) {
|
|
670
|
+
const V = n[A];
|
|
666
671
|
if (V.type === "field") {
|
|
667
|
-
const
|
|
668
|
-
|
|
672
|
+
const X = !o.value || o.value === "" ? u(V.content) : "", B = s(V.content, X);
|
|
673
|
+
e.push({ node: B, isField: !0 });
|
|
669
674
|
} else
|
|
670
|
-
|
|
675
|
+
e.push({
|
|
671
676
|
node: document.createTextNode(V.content),
|
|
672
677
|
isField: !1
|
|
673
678
|
});
|
|
674
679
|
}
|
|
675
|
-
return { success:
|
|
676
|
-
},
|
|
677
|
-
if (!
|
|
680
|
+
return { success: T, elements: e };
|
|
681
|
+
}, C = () => {
|
|
682
|
+
if (!t.value) return;
|
|
678
683
|
o.isInternalUpdate = !0;
|
|
679
|
-
const
|
|
680
|
-
|
|
681
|
-
if (h(),
|
|
682
|
-
const
|
|
683
|
-
|
|
684
|
+
const n = i(o.template), r = y(n, o.value);
|
|
685
|
+
l(), W(() => {
|
|
686
|
+
if (h(), r) {
|
|
687
|
+
const e = r.textContent || "", a = J(e);
|
|
688
|
+
a && a.trim() !== "" ? E(r, "inside", !1) : E(r, "inside", !0);
|
|
684
689
|
} else
|
|
685
690
|
F();
|
|
686
691
|
o.isInternalUpdate = !1;
|
|
687
692
|
});
|
|
688
693
|
}, m = () => {
|
|
689
694
|
if (o.isComposing) return;
|
|
690
|
-
|
|
691
|
-
const
|
|
692
|
-
|
|
695
|
+
I(), p(), L(), h();
|
|
696
|
+
const n = f();
|
|
697
|
+
n !== o.value && (o.onValueChange(n), o.onInput(n)), l(n), n === "" && t.value && Array.from(t.value.childNodes).every((e) => e.nodeType === Node.ELEMENT_NODE && e.classList.contains("template-field") ? ct(e) : !!(e.nodeType === Node.TEXT_NODE && Q(e.textContent || ""))) && I();
|
|
693
698
|
}, L = () => {
|
|
694
|
-
if (!
|
|
695
|
-
|
|
696
|
-
|
|
699
|
+
if (!t.value) return;
|
|
700
|
+
dt(t.value), t.value.querySelectorAll(".template-field").forEach((r) => {
|
|
701
|
+
Fe(r);
|
|
697
702
|
});
|
|
698
|
-
},
|
|
699
|
-
if (!
|
|
700
|
-
const
|
|
701
|
-
|
|
702
|
-
if (
|
|
703
|
-
const
|
|
704
|
-
if (Q(
|
|
705
|
-
const
|
|
706
|
-
if (
|
|
703
|
+
}, I = () => {
|
|
704
|
+
if (!t.value) return;
|
|
705
|
+
const n = [];
|
|
706
|
+
t.value.childNodes.forEach((r) => {
|
|
707
|
+
if (r.nodeType === Node.TEXT_NODE) {
|
|
708
|
+
const e = r.textContent || "";
|
|
709
|
+
if (Q(e)) {
|
|
710
|
+
const a = r.previousSibling;
|
|
711
|
+
if (a && a.nodeType === Node.ELEMENT_NODE && a.classList.contains("template-field"))
|
|
707
712
|
return;
|
|
708
713
|
}
|
|
709
|
-
(
|
|
710
|
-
} else
|
|
711
|
-
}),
|
|
712
|
-
|
|
714
|
+
(e.trim() === "" || Q(e)) && n.push(r);
|
|
715
|
+
} else r.nodeType === Node.ELEMENT_NODE && r.tagName.toLowerCase() === "br" && n.push(r);
|
|
716
|
+
}), n.forEach((r) => {
|
|
717
|
+
r.parentNode && r.parentNode.removeChild(r);
|
|
713
718
|
});
|
|
714
|
-
}, z = (
|
|
719
|
+
}, z = (n) => {
|
|
715
720
|
if (!o.template || !o.initialValues)
|
|
716
721
|
return "字段";
|
|
717
|
-
for (const [
|
|
718
|
-
if (
|
|
719
|
-
return
|
|
720
|
-
return
|
|
721
|
-
}, j = (
|
|
722
|
-
const
|
|
723
|
-
if (
|
|
724
|
-
return
|
|
725
|
-
const
|
|
726
|
-
if (
|
|
727
|
-
return
|
|
728
|
-
const
|
|
729
|
-
return z(
|
|
730
|
-
},
|
|
731
|
-
if (!
|
|
732
|
-
|
|
733
|
-
const
|
|
734
|
-
if (
|
|
722
|
+
for (const [r, e] of Object.entries(o.initialValues))
|
|
723
|
+
if (e === n)
|
|
724
|
+
return r;
|
|
725
|
+
return n.length <= 2 || /^[[\]{}()]+$/.test(n) || n.includes("[") && n.includes("]") ? n : "字段";
|
|
726
|
+
}, j = (n) => {
|
|
727
|
+
const r = n.getAttribute("data-placeholder");
|
|
728
|
+
if (r)
|
|
729
|
+
return r;
|
|
730
|
+
const e = n.getAttribute("title") || n.getAttribute("data-field") || n.getAttribute("data-key") || n.getAttribute("placeholder") || "";
|
|
731
|
+
if (e)
|
|
732
|
+
return e;
|
|
733
|
+
const a = n.textContent || "";
|
|
734
|
+
return z(a);
|
|
735
|
+
}, p = () => {
|
|
736
|
+
if (!t.value) return;
|
|
737
|
+
t.value.querySelectorAll("span").forEach((r) => {
|
|
738
|
+
const e = r, a = e.style, g = e.classList.contains("template-field"), T = e.hasAttribute("data-placeholder");
|
|
739
|
+
if (g && T)
|
|
735
740
|
return;
|
|
736
|
-
const
|
|
737
|
-
(
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
if (
|
|
741
|
-
if (
|
|
742
|
-
const B = j(
|
|
743
|
-
B &&
|
|
741
|
+
const A = a.backgroundColor && // 标准格式
|
|
742
|
+
(a.backgroundColor === "rgba(0, 0, 0, 0.05)" || a.backgroundColor === "rgba(0, 0, 0, 0.08)" || // 可能的变体格式
|
|
743
|
+
a.backgroundColor.includes("rgba(0, 0, 0, 0.05)") || a.backgroundColor.includes("rgba(0, 0, 0, 0.08)") || // 十六进制或其他可能的格式
|
|
744
|
+
a.backgroundColor.toLowerCase().includes("0.05") || a.backgroundColor.toLowerCase().includes("0.08")), V = a.borderRadius === "4px" || a.padding === "3px 8px" || a.margin === "0px 2px" || a.whiteSpace === "nowrap" && a.padding && a.margin;
|
|
745
|
+
if (A || V || T) {
|
|
746
|
+
if (e.className = "template-field", !e.getAttribute("data-placeholder")) {
|
|
747
|
+
const B = j(e);
|
|
748
|
+
B && e.setAttribute("data-placeholder", B);
|
|
744
749
|
}
|
|
745
|
-
|
|
746
|
-
const
|
|
747
|
-
v(
|
|
750
|
+
e.removeAttribute("style");
|
|
751
|
+
const X = e.textContent || "";
|
|
752
|
+
v(e, X);
|
|
748
753
|
}
|
|
749
754
|
});
|
|
750
755
|
}, h = () => {
|
|
751
|
-
if (!
|
|
752
|
-
|
|
753
|
-
const
|
|
754
|
-
v(
|
|
756
|
+
if (!t.value) return;
|
|
757
|
+
t.value.querySelectorAll(".template-field").forEach((r) => {
|
|
758
|
+
const e = r.textContent || "";
|
|
759
|
+
v(r, e);
|
|
755
760
|
});
|
|
756
761
|
};
|
|
757
762
|
return {
|
|
758
763
|
// 状态
|
|
759
|
-
hasContent:
|
|
764
|
+
hasContent: d,
|
|
760
765
|
// 解析和DOM操作
|
|
761
|
-
parseTemplateToParts:
|
|
762
|
-
getValueFromDOM:
|
|
766
|
+
parseTemplateToParts: i,
|
|
767
|
+
getValueFromDOM: f,
|
|
763
768
|
getInitialContentForField: u,
|
|
764
|
-
createFieldElement:
|
|
769
|
+
createFieldElement: s,
|
|
765
770
|
// 光标操作
|
|
766
|
-
setCursorTo:
|
|
771
|
+
setCursorTo: E,
|
|
767
772
|
setCursorToEnd: F,
|
|
768
773
|
// DOM更新
|
|
769
|
-
updateEditorDOM:
|
|
774
|
+
updateEditorDOM: C,
|
|
770
775
|
renderTemplateToDOM: y,
|
|
771
776
|
// 事件处理
|
|
772
777
|
handleInput: m,
|
|
773
|
-
checkHasContent:
|
|
774
|
-
cleanupEmptyTextNodes:
|
|
778
|
+
checkHasContent: l,
|
|
779
|
+
cleanupEmptyTextNodes: I,
|
|
775
780
|
// 推断 placeholder
|
|
776
781
|
inferPlaceholderForContent: z,
|
|
777
782
|
extractPlaceholderFromElement: j,
|
|
778
783
|
// 方法
|
|
779
784
|
resetFields: () => {
|
|
780
|
-
if (!
|
|
785
|
+
if (!t.value) return;
|
|
781
786
|
o.isInternalUpdate = !0;
|
|
782
|
-
const
|
|
783
|
-
|
|
784
|
-
const
|
|
785
|
-
let
|
|
786
|
-
|
|
787
|
-
if (
|
|
788
|
-
const
|
|
789
|
-
|
|
787
|
+
const n = t.value;
|
|
788
|
+
n.innerHTML = "";
|
|
789
|
+
const r = i(o.template);
|
|
790
|
+
let e = "";
|
|
791
|
+
r.forEach((a) => {
|
|
792
|
+
if (a.type === "field") {
|
|
793
|
+
const g = u(a.content), T = s(a.content, g);
|
|
794
|
+
g && (e += g), n.appendChild(T);
|
|
790
795
|
} else
|
|
791
|
-
|
|
792
|
-
}), o.onValueChange(
|
|
796
|
+
n.appendChild(document.createTextNode(a.content)), e += a.content;
|
|
797
|
+
}), o.onValueChange(e), F(), l(e), W(() => {
|
|
793
798
|
o.isInternalUpdate = !1;
|
|
794
799
|
});
|
|
795
800
|
},
|
|
796
801
|
activateFirstField: () => {
|
|
797
|
-
var
|
|
798
|
-
const
|
|
799
|
-
|
|
802
|
+
var r;
|
|
803
|
+
const n = (r = t.value) == null ? void 0 : r.querySelector(".template-field");
|
|
804
|
+
n ? E(n, "inside", !1) : F();
|
|
800
805
|
},
|
|
801
806
|
// 选项更新
|
|
802
807
|
updateOptions: S
|
|
803
808
|
};
|
|
804
809
|
}
|
|
805
|
-
const
|
|
810
|
+
const St = /* @__PURE__ */ ve({
|
|
806
811
|
__name: "TemplateEditor",
|
|
807
812
|
props: /* @__PURE__ */ Ne({
|
|
808
813
|
value: {},
|
|
@@ -812,208 +817,208 @@ const wt = /* @__PURE__ */ ve({
|
|
|
812
817
|
valueModifiers: {}
|
|
813
818
|
}),
|
|
814
819
|
emits: /* @__PURE__ */ Ne(["input", "content-status", "submit", "focus", "blur", "empty-content"], ["update:value"]),
|
|
815
|
-
setup(
|
|
816
|
-
const o =
|
|
820
|
+
setup(t, { expose: b, emit: d }) {
|
|
821
|
+
const o = Ge(t, "value"), S = t, i = d, f = O(null), u = O(""), s = O({}), v = O(!1), _ = O(!1), l = wt(f, {
|
|
817
822
|
template: u.value,
|
|
818
823
|
value: o.value,
|
|
819
|
-
initialValues:
|
|
824
|
+
initialValues: s.value,
|
|
820
825
|
isInternalUpdate: v,
|
|
821
|
-
isComposing:
|
|
822
|
-
onValueChange: (
|
|
823
|
-
if (o.value !==
|
|
826
|
+
isComposing: _,
|
|
827
|
+
onValueChange: (p) => {
|
|
828
|
+
if (o.value !== p) {
|
|
824
829
|
const h = v.value;
|
|
825
|
-
v.value = !0, o.value =
|
|
830
|
+
v.value = !0, o.value = p, W(() => {
|
|
826
831
|
v.value = h;
|
|
827
832
|
});
|
|
828
833
|
}
|
|
829
834
|
},
|
|
830
|
-
onInput: (
|
|
831
|
-
|
|
835
|
+
onInput: (p) => {
|
|
836
|
+
i("input", p);
|
|
832
837
|
},
|
|
833
|
-
onContentStatusChange: (
|
|
834
|
-
onSubmit: (
|
|
835
|
-
}),
|
|
836
|
-
editor:
|
|
837
|
-
isComposing:
|
|
838
|
-
getValueFromDOM:
|
|
839
|
-
handleInput:
|
|
840
|
-
onSubmit: (
|
|
841
|
-
}), F = (
|
|
842
|
-
let
|
|
843
|
-
return Object.entries(h).forEach(([H,
|
|
844
|
-
const
|
|
845
|
-
|
|
846
|
-
}),
|
|
847
|
-
}, y = (
|
|
848
|
-
v.value = !0, u.value =
|
|
849
|
-
const h = F(u.value,
|
|
850
|
-
|
|
838
|
+
onContentStatusChange: (p) => i("content-status", p),
|
|
839
|
+
onSubmit: (p) => i("submit", p)
|
|
840
|
+
}), E = pt({
|
|
841
|
+
editor: f,
|
|
842
|
+
isComposing: _,
|
|
843
|
+
getValueFromDOM: l.getValueFromDOM,
|
|
844
|
+
handleInput: l.handleInput,
|
|
845
|
+
onSubmit: (p) => i("submit", p)
|
|
846
|
+
}), F = (p, h) => {
|
|
847
|
+
let N = p;
|
|
848
|
+
return Object.entries(h).forEach(([H, n]) => {
|
|
849
|
+
const r = `[${H}]`;
|
|
850
|
+
N = N.replace(new RegExp(r.replace(/[[\]]/g, "\\$&"), "g"), n);
|
|
851
|
+
}), N;
|
|
852
|
+
}, y = (p) => {
|
|
853
|
+
v.value = !0, u.value = p.template, s.value = p.initialValues || {};
|
|
854
|
+
const h = F(u.value, s.value);
|
|
855
|
+
l.updateOptions({
|
|
851
856
|
template: u.value,
|
|
852
857
|
value: h,
|
|
853
858
|
// 使用新生成的内容而不是旧的inputValue
|
|
854
|
-
initialValues:
|
|
855
|
-
}),
|
|
859
|
+
initialValues: s.value
|
|
860
|
+
}), l.updateEditorDOM(), o.value = h, W(() => {
|
|
856
861
|
v.value = !1;
|
|
857
862
|
});
|
|
858
|
-
}, C = () => {
|
|
859
|
-
E.value = !0;
|
|
860
863
|
}, w = () => {
|
|
861
|
-
|
|
862
|
-
},
|
|
864
|
+
_.value = !0;
|
|
865
|
+
}, C = () => {
|
|
866
|
+
_.value = !1, l.handleInput();
|
|
867
|
+
}, m = (p) => {
|
|
863
868
|
var H;
|
|
864
|
-
if (!
|
|
865
|
-
const h =
|
|
866
|
-
let
|
|
867
|
-
if (h.classList.contains("template-field") ?
|
|
868
|
-
const
|
|
869
|
-
|
|
869
|
+
if (!f.value) return;
|
|
870
|
+
const h = p.target;
|
|
871
|
+
let N = null;
|
|
872
|
+
if (h.classList.contains("template-field") ? N = h : (H = h.parentElement) != null && H.classList.contains("template-field") && (N = h.parentElement), N && (!N.textContent || N.textContent.trim() === "")) {
|
|
873
|
+
const n = window.getSelection(), r = document.createRange();
|
|
874
|
+
n && (r.selectNodeContents(N), r.collapse(!0), n.removeAllRanges(), n.addRange(r), N.focus(), p.preventDefault(), p.stopPropagation());
|
|
870
875
|
}
|
|
871
|
-
}, L = (
|
|
872
|
-
|
|
873
|
-
const h =
|
|
876
|
+
}, L = (p) => {
|
|
877
|
+
p.preventDefault();
|
|
878
|
+
const h = p.clipboardData;
|
|
874
879
|
if (!h) return;
|
|
875
|
-
const
|
|
876
|
-
if (
|
|
877
|
-
const
|
|
878
|
-
|
|
879
|
-
const
|
|
880
|
-
let
|
|
881
|
-
if (
|
|
882
|
-
const
|
|
883
|
-
(
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
if (
|
|
887
|
-
if (
|
|
888
|
-
const
|
|
889
|
-
|
|
880
|
+
const N = h.getData("text/html"), H = h.getData("text/plain");
|
|
881
|
+
if (N) {
|
|
882
|
+
const n = document.createElement("div");
|
|
883
|
+
n.innerHTML = N;
|
|
884
|
+
const r = n.querySelectorAll("span");
|
|
885
|
+
let e = !1;
|
|
886
|
+
if (r.forEach((a) => {
|
|
887
|
+
const g = a, T = g.style, A = g.classList.contains("template-field"), V = g.hasAttribute("data-placeholder"), X = T.backgroundColor && // 标准格式
|
|
888
|
+
(T.backgroundColor === "rgba(0, 0, 0, 0.05)" || T.backgroundColor === "rgba(0, 0, 0, 0.08)" || // 可能的变体格式
|
|
889
|
+
T.backgroundColor.includes("rgba(0, 0, 0, 0.05)") || T.backgroundColor.includes("rgba(0, 0, 0, 0.08)") || // 十六进制或其他可能的格式
|
|
890
|
+
T.backgroundColor.toLowerCase().includes("0.05") || T.backgroundColor.toLowerCase().includes("0.08")), B = T.borderRadius === "4px" || T.padding === "3px 8px" || T.margin === "0px 2px" || T.whiteSpace === "nowrap";
|
|
891
|
+
if (A || V || X || B) {
|
|
892
|
+
if (e = !0, g.className = "template-field", !g.getAttribute("data-placeholder")) {
|
|
893
|
+
const q = l.extractPlaceholderFromElement(g);
|
|
894
|
+
q && g.setAttribute("data-placeholder", q);
|
|
890
895
|
}
|
|
891
|
-
|
|
896
|
+
g.removeAttribute("style");
|
|
892
897
|
}
|
|
893
|
-
}),
|
|
894
|
-
|
|
898
|
+
}), e) {
|
|
899
|
+
I(n);
|
|
895
900
|
return;
|
|
896
901
|
}
|
|
897
902
|
}
|
|
898
903
|
H && z(H);
|
|
899
|
-
},
|
|
904
|
+
}, I = (p) => {
|
|
900
905
|
const h = window.getSelection();
|
|
901
906
|
if (h && h.rangeCount > 0) {
|
|
902
|
-
const
|
|
903
|
-
|
|
907
|
+
const N = h.getRangeAt(0);
|
|
908
|
+
N.deleteContents();
|
|
904
909
|
const H = document.createDocumentFragment();
|
|
905
|
-
for (;
|
|
906
|
-
H.appendChild(
|
|
907
|
-
|
|
910
|
+
for (; p.firstChild; )
|
|
911
|
+
H.appendChild(p.firstChild);
|
|
912
|
+
N.insertNode(H), N.collapse(!1), h.removeAllRanges(), h.addRange(N), j();
|
|
908
913
|
}
|
|
909
|
-
}, z = (
|
|
914
|
+
}, z = (p) => {
|
|
910
915
|
const h = window.getSelection();
|
|
911
916
|
if (h && h.rangeCount > 0) {
|
|
912
|
-
const
|
|
913
|
-
|
|
917
|
+
const N = h.getRangeAt(0);
|
|
918
|
+
N.deleteContents(), N.insertNode(document.createTextNode(p)), N.collapse(!1), h.removeAllRanges(), h.addRange(N), j();
|
|
914
919
|
}
|
|
915
920
|
}, j = () => {
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
const
|
|
919
|
-
if (
|
|
921
|
+
_.value = !1, W(() => {
|
|
922
|
+
l.handleInput();
|
|
923
|
+
const p = l.getValueFromDOM();
|
|
924
|
+
if (p !== o.value) {
|
|
920
925
|
const h = v.value;
|
|
921
|
-
v.value = !0, o.value =
|
|
926
|
+
v.value = !0, o.value = p, i("input", p), W(() => {
|
|
922
927
|
v.value = h;
|
|
923
928
|
});
|
|
924
929
|
}
|
|
925
930
|
setTimeout(() => {
|
|
926
|
-
const h =
|
|
927
|
-
h !== o.value && (v.value = !0, o.value = h,
|
|
931
|
+
const h = l.getValueFromDOM();
|
|
932
|
+
h !== o.value && (v.value = !0, o.value = h, i("input", h), W(() => {
|
|
928
933
|
v.value = !1;
|
|
929
934
|
}));
|
|
930
935
|
}, 50);
|
|
931
936
|
});
|
|
932
937
|
};
|
|
933
|
-
return
|
|
934
|
-
u.value &&
|
|
938
|
+
return Je(() => {
|
|
939
|
+
u.value && l.updateEditorDOM(), S.autofocus && f.value && l.setCursorToEnd();
|
|
935
940
|
}), Y(
|
|
936
941
|
() => u.value,
|
|
937
942
|
() => {
|
|
938
|
-
v.value || (
|
|
943
|
+
v.value || (l.updateOptions({
|
|
939
944
|
template: u.value,
|
|
940
945
|
value: o.value,
|
|
941
|
-
initialValues:
|
|
942
|
-
}),
|
|
946
|
+
initialValues: s.value
|
|
947
|
+
}), l.updateEditorDOM());
|
|
943
948
|
}
|
|
944
949
|
), Y(
|
|
945
|
-
() =>
|
|
950
|
+
() => s.value,
|
|
946
951
|
() => {
|
|
947
|
-
v.value || (
|
|
952
|
+
v.value || (l.updateOptions({
|
|
948
953
|
template: u.value,
|
|
949
954
|
value: o.value,
|
|
950
|
-
initialValues:
|
|
951
|
-
}),
|
|
955
|
+
initialValues: s.value
|
|
956
|
+
}), l.updateEditorDOM());
|
|
952
957
|
},
|
|
953
958
|
{ deep: !0 }
|
|
954
959
|
), Y(
|
|
955
960
|
() => o.value,
|
|
956
|
-
(
|
|
957
|
-
v.value || (
|
|
961
|
+
(p) => {
|
|
962
|
+
v.value || (l.updateOptions({
|
|
958
963
|
template: u.value,
|
|
959
|
-
value:
|
|
960
|
-
initialValues:
|
|
961
|
-
}),
|
|
964
|
+
value: p,
|
|
965
|
+
initialValues: s.value
|
|
966
|
+
}), l.updateEditorDOM()), (!p || p.trim() === "") && i("empty-content");
|
|
962
967
|
}
|
|
963
968
|
), b({
|
|
964
969
|
focus: () => {
|
|
965
|
-
var
|
|
966
|
-
(
|
|
970
|
+
var p;
|
|
971
|
+
(p = f.value) == null || p.focus(), l.setCursorToEnd();
|
|
967
972
|
},
|
|
968
|
-
resetFields:
|
|
969
|
-
activateFirstField:
|
|
970
|
-
getValueFromDOM:
|
|
973
|
+
resetFields: l.resetFields,
|
|
974
|
+
activateFirstField: l.activateFirstField,
|
|
975
|
+
getValueFromDOM: l.getValueFromDOM,
|
|
971
976
|
setTemplate: y
|
|
972
|
-
}), (
|
|
977
|
+
}), (p, h) => (k(), M("div", {
|
|
973
978
|
class: "template-editor",
|
|
974
979
|
ref_key: "contentEditableRef",
|
|
975
|
-
ref:
|
|
980
|
+
ref: f,
|
|
976
981
|
contenteditable: "true",
|
|
977
982
|
onInput: h[0] || (h[0] = //@ts-ignore
|
|
978
|
-
(...
|
|
983
|
+
(...N) => x(l).handleInput && x(l).handleInput(...N)),
|
|
979
984
|
onKeydown: h[1] || (h[1] = //@ts-ignore
|
|
980
|
-
(...
|
|
985
|
+
(...N) => x(E).handleTemplateKeyDown && x(E).handleTemplateKeyDown(...N)),
|
|
981
986
|
onClick: m,
|
|
982
|
-
onCompositionstart:
|
|
983
|
-
onCompositionend:
|
|
984
|
-
onFocus: h[2] || (h[2] = (
|
|
985
|
-
onBlur: h[3] || (h[3] = (
|
|
987
|
+
onCompositionstart: w,
|
|
988
|
+
onCompositionend: C,
|
|
989
|
+
onFocus: h[2] || (h[2] = (N) => p.$emit("focus", N)),
|
|
990
|
+
onBlur: h[3] || (h[3] = (N) => p.$emit("blur", N)),
|
|
986
991
|
onPaste: L
|
|
987
992
|
}, null, 544));
|
|
988
993
|
}
|
|
989
|
-
}),
|
|
994
|
+
}), Et = ["data-theme"], _t = { class: "tiny-sender__container" }, Nt = {
|
|
990
995
|
key: 0,
|
|
991
996
|
class: "tiny-sender__header-slot"
|
|
992
|
-
},
|
|
997
|
+
}, Tt = {
|
|
993
998
|
key: 0,
|
|
994
999
|
class: "tiny-sender__prefix-slot"
|
|
995
|
-
},
|
|
1000
|
+
}, xt = { class: "tiny-sender__content-area" }, Rt = {
|
|
996
1001
|
key: 0,
|
|
997
1002
|
class: "tiny-sender__decorative-content"
|
|
998
|
-
},
|
|
1003
|
+
}, kt = {
|
|
999
1004
|
key: 2,
|
|
1000
1005
|
class: "tiny-sender__input-field-wrapper"
|
|
1001
|
-
},
|
|
1006
|
+
}, Dt = {
|
|
1002
1007
|
key: 0,
|
|
1003
1008
|
class: "tiny-sender__completion-placeholder"
|
|
1004
|
-
},
|
|
1009
|
+
}, Ft = { class: "user-input-mirror" }, Lt = {
|
|
1005
1010
|
key: 0,
|
|
1006
1011
|
class: "tiny-sender__tab-hint"
|
|
1007
|
-
},
|
|
1012
|
+
}, Ot = {
|
|
1008
1013
|
key: 1,
|
|
1009
1014
|
class: "tiny-sender__actions-slot"
|
|
1010
|
-
},
|
|
1015
|
+
}, At = { class: "tiny-sender__footer-left" }, It = { class: "tiny-sender__footer-right" }, Mt = { class: "real-word-length" }, Vt = {
|
|
1011
1016
|
key: 1,
|
|
1012
1017
|
class: "tiny-sender__toolbar"
|
|
1013
|
-
},
|
|
1018
|
+
}, Bt = { class: "tiny-sender__buttons-container" }, Wt = {
|
|
1014
1019
|
key: 1,
|
|
1015
1020
|
class: "tiny-sender__footer-slot"
|
|
1016
|
-
},
|
|
1021
|
+
}, $t = ["onMouseenter", "onMousedown"], Pt = { class: "suggestion-item__text" }, Kt = {
|
|
1017
1022
|
key: 0,
|
|
1018
1023
|
class: "tiny-sender__error"
|
|
1019
1024
|
}, ce = /* @__PURE__ */ ve({
|
|
@@ -1035,90 +1040,90 @@ const wt = /* @__PURE__ */ ve({
|
|
|
1035
1040
|
placeholder: { default: "请输入内容..." },
|
|
1036
1041
|
showWordLimit: { type: Boolean, default: !1 },
|
|
1037
1042
|
suggestions: { default: () => [] },
|
|
1043
|
+
suggestionPopupWidth: { default: 400 },
|
|
1038
1044
|
theme: { default: "light" },
|
|
1039
1045
|
template: { default: "" },
|
|
1040
1046
|
hasContent: { type: Boolean, default: void 0 },
|
|
1041
1047
|
templateInitialValues: { default: () => ({}) }
|
|
1042
1048
|
},
|
|
1043
1049
|
emits: ["update:modelValue", "submit", "clear", "speech-start", "speech-end", "speech-interim", "speech-error", "suggestion-select", "focus", "blur", "escape-press", "cancel", "reset-template"],
|
|
1044
|
-
setup(
|
|
1045
|
-
const o =
|
|
1050
|
+
setup(t, { expose: b, emit: d }) {
|
|
1051
|
+
const o = t, S = d, i = O(null), f = O(null), u = O(null), s = O(null), v = O(null), _ = O(!1), { inputValue: l, isComposing: E, clearInput: F } = ut(o, S), {
|
|
1046
1052
|
showSuggestionsPopup: y,
|
|
1047
|
-
highlightedIndex:
|
|
1048
|
-
completionPlaceholder:
|
|
1053
|
+
highlightedIndex: w,
|
|
1054
|
+
completionPlaceholder: C,
|
|
1049
1055
|
showTabHint: m,
|
|
1050
1056
|
suggestionsListRef: L,
|
|
1051
|
-
filteredSuggestions:
|
|
1057
|
+
filteredSuggestions: I,
|
|
1052
1058
|
activeSuggestion: z,
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
s.value === "single" && (s.value = "multiple", W(() => {
|
|
1059
|
+
updateSuggestionsState: j,
|
|
1060
|
+
selectSuggestion: p,
|
|
1061
|
+
acceptCurrentSuggestion: h,
|
|
1062
|
+
closeSuggestionsPopup: N,
|
|
1063
|
+
navigateSuggestions: H,
|
|
1064
|
+
handleSuggestionItemHover: n,
|
|
1065
|
+
highlightSuggestionText: r
|
|
1066
|
+
} = ht(o, S, l, E), e = O(o.mode), a = O(!1), g = () => {
|
|
1067
|
+
e.value === "single" && (e.value = "multiple", W(() => {
|
|
1063
1068
|
setTimeout(() => {
|
|
1064
1069
|
const c = document.querySelector(".tiny-textarea__inner");
|
|
1065
1070
|
if (c) {
|
|
1066
1071
|
c.style.whiteSpace = "pre-wrap";
|
|
1067
|
-
const R =
|
|
1072
|
+
const R = l.value.length;
|
|
1068
1073
|
c.focus(), c.setSelectionRange(R, R);
|
|
1069
1074
|
}
|
|
1070
1075
|
}, 50);
|
|
1071
1076
|
}));
|
|
1072
|
-
},
|
|
1077
|
+
}, T = (c, R) => {
|
|
1073
1078
|
const D = document.createElement("span");
|
|
1074
1079
|
D.style.visibility = "hidden", D.style.position = "absolute", D.style.whiteSpace = "nowrap", D.style.font = R, D.textContent = c, document.body.appendChild(D);
|
|
1075
1080
|
const ee = D.offsetWidth;
|
|
1076
1081
|
return document.body.removeChild(D), ee;
|
|
1077
|
-
},
|
|
1078
|
-
if (o.mode !== "single" || !
|
|
1082
|
+
}, A = () => {
|
|
1083
|
+
if (o.mode !== "single" || !i.value || a.value) return;
|
|
1079
1084
|
const R = document.querySelector(".tiny-sender__content-area").querySelector(".tiny-input__inner"), D = v.value || document.querySelector(".tiny-sender__buttons-container");
|
|
1080
1085
|
if (!R) return;
|
|
1081
|
-
const ee = window.getComputedStyle(R).font, te =
|
|
1082
|
-
te >
|
|
1083
|
-
|
|
1086
|
+
const ee = window.getComputedStyle(R).font, te = T(l.value, ee), Ue = R.offsetWidth - ((D == null ? void 0 : D.offsetWidth) || 0) - 20;
|
|
1087
|
+
te > Ue && e.value === "single" && (a.value = !0, e.value = "multiple", W(() => {
|
|
1088
|
+
i.value ? setTimeout(() => {
|
|
1084
1089
|
const re = document.querySelector(".tiny-textarea__inner");
|
|
1085
1090
|
if (re) {
|
|
1086
1091
|
re.style.whiteSpace = "pre-wrap";
|
|
1087
|
-
const _e =
|
|
1092
|
+
const _e = l.value.length;
|
|
1088
1093
|
re.focus(), re.setSelectionRange(_e, _e);
|
|
1089
1094
|
}
|
|
1090
|
-
|
|
1091
|
-
}, 300) :
|
|
1095
|
+
a.value = !1;
|
|
1096
|
+
}, 300) : a.value = !1;
|
|
1092
1097
|
}));
|
|
1093
|
-
},
|
|
1094
|
-
if (
|
|
1098
|
+
}, V = () => {
|
|
1099
|
+
if (_.value && u.value)
|
|
1095
1100
|
ye();
|
|
1096
|
-
else if (
|
|
1097
|
-
|
|
1101
|
+
else if (i.value)
|
|
1102
|
+
i.value.focus();
|
|
1098
1103
|
else {
|
|
1099
1104
|
const c = document.querySelector(".tiny-input__inner");
|
|
1100
1105
|
c == null || c.focus();
|
|
1101
1106
|
}
|
|
1102
|
-
},
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1107
|
+
}, X = () => {
|
|
1108
|
+
_.value = !1, S("reset-template"), W(() => {
|
|
1109
|
+
l.value === "" && (e.value = o.mode || "single"), setTimeout(() => {
|
|
1110
|
+
V();
|
|
1106
1111
|
}, 50);
|
|
1107
1112
|
});
|
|
1108
|
-
},
|
|
1113
|
+
}, B = () => {
|
|
1109
1114
|
var c;
|
|
1110
|
-
F(),
|
|
1111
|
-
|
|
1112
|
-
}),
|
|
1113
|
-
},
|
|
1115
|
+
F(), _.value ? X() : (c = f.value) == null || c.focus(), W(() => {
|
|
1116
|
+
l.value === "" && (e.value = o.mode || "single");
|
|
1117
|
+
}), N();
|
|
1118
|
+
}, q = (c) => {
|
|
1114
1119
|
S("update:modelValue", c);
|
|
1115
1120
|
}, ye = () => {
|
|
1116
1121
|
u.value && u.value.activateFirstField();
|
|
1117
1122
|
}, Ie = (c, R) => {
|
|
1118
|
-
|
|
1123
|
+
_.value = !0, W(() => {
|
|
1119
1124
|
u.value && u.value.setTemplate({ template: c, initialValues: R });
|
|
1120
1125
|
});
|
|
1121
|
-
}, Me =
|
|
1126
|
+
}, Me = $(() => {
|
|
1122
1127
|
const c = typeof o.speech == "object" ? o.speech : {};
|
|
1123
1128
|
return {
|
|
1124
1129
|
...c,
|
|
@@ -1127,73 +1132,77 @@ const wt = /* @__PURE__ */ ve({
|
|
|
1127
1132
|
onInterim: (R) => S("speech-interim", R),
|
|
1128
1133
|
onFinal: (R) => {
|
|
1129
1134
|
if (c.autoReplace)
|
|
1130
|
-
|
|
1135
|
+
l.value = R;
|
|
1131
1136
|
else {
|
|
1132
|
-
const D =
|
|
1133
|
-
D && R && !D.endsWith(" ") && !R.startsWith(" ") && D.length > 0 ?
|
|
1137
|
+
const D = l.value;
|
|
1138
|
+
D && R && !D.endsWith(" ") && !R.startsWith(" ") && D.length > 0 ? l.value = D + " " + R : l.value = D + R;
|
|
1134
1139
|
}
|
|
1135
1140
|
S("speech-end", R);
|
|
1136
1141
|
},
|
|
1137
1142
|
onError: (R) => {
|
|
1138
|
-
|
|
1143
|
+
ze(R.message), S("speech-error", R);
|
|
1139
1144
|
}
|
|
1140
1145
|
};
|
|
1141
|
-
}), { speechState: ae, start: be, stop: Ce } =
|
|
1146
|
+
}), { speechState: ae, start: be, stop: Ce } = gt(Me.value), de = () => {
|
|
1142
1147
|
ae.isRecording ? Ce() : be();
|
|
1143
|
-
}, { handleKeyPress: Ve, triggerSubmit: fe } =
|
|
1148
|
+
}, { handleKeyPress: Ve, triggerSubmit: fe } = ft(
|
|
1144
1149
|
o,
|
|
1145
1150
|
S,
|
|
1146
|
-
|
|
1147
|
-
|
|
1151
|
+
l,
|
|
1152
|
+
E,
|
|
1148
1153
|
ae,
|
|
1149
1154
|
y,
|
|
1150
1155
|
z,
|
|
1151
|
-
|
|
1156
|
+
h,
|
|
1157
|
+
N,
|
|
1152
1158
|
H,
|
|
1153
|
-
t,
|
|
1154
1159
|
de,
|
|
1155
|
-
|
|
1156
|
-
|
|
1160
|
+
e,
|
|
1161
|
+
g
|
|
1157
1162
|
), Be = (c) => {
|
|
1158
|
-
S("focus", c),
|
|
1163
|
+
S("focus", c), l.value && I.value.length > 0 && !o.template && (y.value = !0, m.value = !0);
|
|
1159
1164
|
}, We = (c) => {
|
|
1160
|
-
S("blur", c);
|
|
1161
|
-
}, $e =
|
|
1165
|
+
S("blur", c), N();
|
|
1166
|
+
}, $e = $(() => e.value === "multiple" ? "textarea" : "text"), Pe = $(
|
|
1162
1167
|
() => ({
|
|
1163
1168
|
display: "flex",
|
|
1164
1169
|
justifyContent: o.showWordLimit && o.maxLength !== 1 / 0 ? "space-between" : "flex-end",
|
|
1165
1170
|
alignItems: "center"
|
|
1166
1171
|
})
|
|
1167
|
-
), Ke =
|
|
1172
|
+
), Ke = Qe(), He = $(() => !!Ke.decorativeContent), ie = $(() => o.disabled || He.value), we = $(() => o.loading), Se = $(() => o.hasContent !== void 0 ? o.hasContent : !!l.value), Xe = $(() => ({
|
|
1168
1173
|
"is-disabled": ie.value,
|
|
1169
1174
|
"is-loading": we.value,
|
|
1170
|
-
"has-error": !!
|
|
1171
|
-
"is-auto-switching":
|
|
1172
|
-
})),
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1175
|
+
"has-error": !!le.value,
|
|
1176
|
+
"is-auto-switching": a.value
|
|
1177
|
+
})), qe = $(() => ({
|
|
1178
|
+
width: rt(o.suggestionPopupWidth),
|
|
1179
|
+
maxWidth: "100%"
|
|
1180
|
+
// 确保不超出父容器宽度
|
|
1181
|
+
})), le = O(""), ze = (c) => {
|
|
1182
|
+
le.value = c, setTimeout(() => le.value = "", 5e3);
|
|
1183
|
+
}, je = () => {
|
|
1184
|
+
E.value = !1, setTimeout(() => {
|
|
1185
|
+
E.value = !1, j();
|
|
1177
1186
|
}, 50);
|
|
1178
|
-
}, pe =
|
|
1179
|
-
return Y(
|
|
1180
|
-
W(
|
|
1187
|
+
}, pe = $(() => o.maxLength !== 1 / 0 && l.value.length > o.maxLength);
|
|
1188
|
+
return Y(l, () => {
|
|
1189
|
+
W(A), l.value === "" && o.mode === "single" && (e.value = "single");
|
|
1181
1190
|
}), Y(
|
|
1182
|
-
() =>
|
|
1191
|
+
() => _.value,
|
|
1183
1192
|
(c) => {
|
|
1184
|
-
c && (
|
|
1193
|
+
c && (e.value = "multiple");
|
|
1185
1194
|
}
|
|
1186
1195
|
), b({
|
|
1187
|
-
focus:
|
|
1196
|
+
focus: V,
|
|
1188
1197
|
blur: () => {
|
|
1189
|
-
if (
|
|
1190
|
-
|
|
1198
|
+
if (i.value)
|
|
1199
|
+
i.value.blur();
|
|
1191
1200
|
else {
|
|
1192
1201
|
const c = document.querySelector(".tiny-input__inner");
|
|
1193
1202
|
c == null || c.blur();
|
|
1194
1203
|
}
|
|
1195
1204
|
},
|
|
1196
|
-
clear:
|
|
1205
|
+
clear: B,
|
|
1197
1206
|
submit: fe,
|
|
1198
1207
|
startSpeech: be,
|
|
1199
1208
|
stopSpeech: Ce,
|
|
@@ -1201,135 +1210,135 @@ const wt = /* @__PURE__ */ ve({
|
|
|
1201
1210
|
setTemplate: Ie
|
|
1202
1211
|
}), (c, R) => (k(), M("div", {
|
|
1203
1212
|
ref_key: "senderRef",
|
|
1204
|
-
ref:
|
|
1205
|
-
class:
|
|
1213
|
+
ref: f,
|
|
1214
|
+
class: oe(["tiny-sender", [Xe.value, `theme-${c.theme}`, `mode-${e.value}`]]),
|
|
1206
1215
|
"data-theme": c.theme
|
|
1207
1216
|
}, [
|
|
1208
|
-
K("div",
|
|
1217
|
+
K("div", _t, [
|
|
1209
1218
|
K("div", {
|
|
1210
1219
|
class: "tiny-sender__input-wrapper",
|
|
1211
1220
|
ref_key: "inputWrapperRef",
|
|
1212
|
-
ref:
|
|
1221
|
+
ref: s
|
|
1213
1222
|
}, [
|
|
1214
1223
|
U(ge, { name: "tiny-sender-slide-down" }, {
|
|
1215
1224
|
default: G(() => [
|
|
1216
|
-
c.$slots.header ? (k(), M("div",
|
|
1225
|
+
c.$slots.header ? (k(), M("div", Nt, [
|
|
1217
1226
|
ne(c.$slots, "header")
|
|
1218
|
-
])) :
|
|
1227
|
+
])) : P("", !0)
|
|
1219
1228
|
]),
|
|
1220
1229
|
_: 3
|
|
1221
1230
|
}),
|
|
1222
1231
|
K("div", {
|
|
1223
|
-
class:
|
|
1232
|
+
class: oe(["tiny-sender__input-row", { "has-prefix": c.$slots.prefix, "has-header": c.$slots.header }])
|
|
1224
1233
|
}, [
|
|
1225
|
-
c.$slots.prefix ? (k(), M("div",
|
|
1234
|
+
c.$slots.prefix ? (k(), M("div", Tt, [
|
|
1226
1235
|
ne(c.$slots, "prefix")
|
|
1227
|
-
])) :
|
|
1228
|
-
K("div",
|
|
1229
|
-
c.$slots.decorativeContent ? (k(), M("div",
|
|
1236
|
+
])) : P("", !0),
|
|
1237
|
+
K("div", xt, [
|
|
1238
|
+
c.$slots.decorativeContent ? (k(), M("div", Rt, [
|
|
1230
1239
|
ne(c.$slots, "decorativeContent")
|
|
1231
|
-
])) :
|
|
1232
|
-
|
|
1240
|
+
])) : P("", !0),
|
|
1241
|
+
_.value ? (k(), Z(St, {
|
|
1233
1242
|
key: 1,
|
|
1234
1243
|
ref_key: "templateEditorRef",
|
|
1235
1244
|
ref: u,
|
|
1236
|
-
value:
|
|
1237
|
-
"onUpdate:value": R[0] || (R[0] = (D) => Te(
|
|
1238
|
-
onInput:
|
|
1239
|
-
onEmptyContent:
|
|
1240
|
-
}, null, 8, ["value"])) : (k(), M("div",
|
|
1241
|
-
U(
|
|
1245
|
+
value: x(l),
|
|
1246
|
+
"onUpdate:value": R[0] || (R[0] = (D) => Te(l) ? l.value = D : null),
|
|
1247
|
+
onInput: q,
|
|
1248
|
+
onEmptyContent: X
|
|
1249
|
+
}, null, 8, ["value"])) : (k(), M("div", kt, [
|
|
1250
|
+
U(x(et), {
|
|
1242
1251
|
ref_key: "inputRef",
|
|
1243
|
-
ref:
|
|
1252
|
+
ref: i,
|
|
1244
1253
|
autosize: c.autoSize,
|
|
1245
1254
|
type: $e.value,
|
|
1246
1255
|
readonly: we.value,
|
|
1247
1256
|
resize: "none",
|
|
1248
|
-
modelValue:
|
|
1249
|
-
"onUpdate:modelValue": R[1] || (R[1] = (D) => Te(
|
|
1257
|
+
modelValue: x(l),
|
|
1258
|
+
"onUpdate:modelValue": R[1] || (R[1] = (D) => Te(l) ? l.value = D : null),
|
|
1250
1259
|
disabled: ie.value,
|
|
1251
1260
|
placeholder: c.placeholder,
|
|
1252
1261
|
autofocus: c.autofocus,
|
|
1253
|
-
onKeydown:
|
|
1254
|
-
onCompositionstart: R[2] || (R[2] = (D) =>
|
|
1255
|
-
onCompositionend:
|
|
1262
|
+
onKeydown: x(Ve),
|
|
1263
|
+
onCompositionstart: R[2] || (R[2] = (D) => E.value = !0),
|
|
1264
|
+
onCompositionend: je,
|
|
1256
1265
|
onFocus: Be,
|
|
1257
1266
|
onBlur: We
|
|
1258
1267
|
}, null, 8, ["autosize", "type", "readonly", "modelValue", "disabled", "placeholder", "autofocus", "onKeydown"]),
|
|
1259
|
-
|
|
1260
|
-
K("span",
|
|
1261
|
-
xe(se(
|
|
1262
|
-
|
|
1263
|
-
])) :
|
|
1268
|
+
x(C) && !x(E) ? (k(), M("div", Dt, [
|
|
1269
|
+
K("span", Ft, se(x(l)), 1),
|
|
1270
|
+
xe(se(x(C)) + " ", 1),
|
|
1271
|
+
x(m) ? (k(), M("div", Lt, "TAB")) : P("", !0)
|
|
1272
|
+
])) : P("", !0)
|
|
1264
1273
|
]))
|
|
1265
1274
|
]),
|
|
1266
|
-
|
|
1275
|
+
e.value === "single" ? (k(), M("div", Ot, [
|
|
1267
1276
|
K("div", {
|
|
1268
1277
|
class: "tiny-sender__buttons-container",
|
|
1269
1278
|
ref_key: "buttonsContainerRef",
|
|
1270
1279
|
ref: v
|
|
1271
1280
|
}, [
|
|
1272
1281
|
ne(c.$slots, "actions"),
|
|
1273
|
-
U(
|
|
1282
|
+
U(Le, {
|
|
1274
1283
|
"allow-speech": c.allowSpeech,
|
|
1275
1284
|
"allow-files": c.allowFiles,
|
|
1276
1285
|
loading: c.loading,
|
|
1277
1286
|
disabled: ie.value,
|
|
1278
1287
|
"show-clear": c.clearable,
|
|
1279
1288
|
"has-content": Se.value,
|
|
1280
|
-
"speech-status":
|
|
1289
|
+
"speech-status": x(ae),
|
|
1281
1290
|
"submit-type": c.submitType,
|
|
1282
1291
|
"is-over-limit": pe.value,
|
|
1283
|
-
onClear:
|
|
1292
|
+
onClear: B,
|
|
1284
1293
|
onToggleSpeech: de,
|
|
1285
|
-
onSubmit:
|
|
1294
|
+
onSubmit: x(fe),
|
|
1286
1295
|
onCancel: R[3] || (R[3] = (D) => c.$emit("cancel"))
|
|
1287
1296
|
}, null, 8, ["allow-speech", "allow-files", "loading", "disabled", "show-clear", "has-content", "speech-status", "submit-type", "is-over-limit", "onSubmit"])
|
|
1288
1297
|
], 512)
|
|
1289
|
-
])) :
|
|
1298
|
+
])) : P("", !0)
|
|
1290
1299
|
], 2),
|
|
1291
1300
|
U(ge, { name: "tiny-sender-slide-up" }, {
|
|
1292
1301
|
default: G(() => [
|
|
1293
|
-
|
|
1302
|
+
e.value === "multiple" ? (k(), M("div", {
|
|
1294
1303
|
key: 0,
|
|
1295
|
-
style:
|
|
1304
|
+
style: Re(Pe.value),
|
|
1296
1305
|
class: "tiny-sender__footer-slot tiny-sender__bottom-row"
|
|
1297
1306
|
}, [
|
|
1298
|
-
K("div",
|
|
1307
|
+
K("div", At, [
|
|
1299
1308
|
ne(c.$slots, "footer-left")
|
|
1300
1309
|
]),
|
|
1301
|
-
K("div",
|
|
1310
|
+
K("div", It, [
|
|
1302
1311
|
ne(c.$slots, "footer-right"),
|
|
1303
1312
|
c.showWordLimit && c.maxLength !== 1 / 0 ? (k(), M("div", {
|
|
1304
1313
|
key: 0,
|
|
1305
|
-
class:
|
|
1314
|
+
class: oe(["tiny-sender__word-limit", { "is-over-limit": pe.value }])
|
|
1306
1315
|
}, [
|
|
1307
|
-
K("span",
|
|
1316
|
+
K("span", Mt, se(x(l).length), 1),
|
|
1308
1317
|
xe("/" + se(c.maxLength), 1)
|
|
1309
|
-
], 2)) :
|
|
1310
|
-
|
|
1311
|
-
K("div",
|
|
1312
|
-
U(
|
|
1318
|
+
], 2)) : P("", !0),
|
|
1319
|
+
e.value === "multiple" ? (k(), M("div", Vt, [
|
|
1320
|
+
K("div", Bt, [
|
|
1321
|
+
U(Le, {
|
|
1313
1322
|
"allow-speech": c.allowSpeech,
|
|
1314
1323
|
"allow-files": c.allowFiles,
|
|
1315
1324
|
loading: c.loading,
|
|
1316
1325
|
disabled: ie.value,
|
|
1317
1326
|
"show-clear": c.clearable,
|
|
1318
1327
|
"has-content": Se.value,
|
|
1319
|
-
"speech-status":
|
|
1328
|
+
"speech-status": x(ae),
|
|
1320
1329
|
"submit-type": c.submitType,
|
|
1321
1330
|
"is-over-limit": pe.value,
|
|
1322
|
-
onClear:
|
|
1331
|
+
onClear: B,
|
|
1323
1332
|
onToggleSpeech: de,
|
|
1324
|
-
onSubmit:
|
|
1333
|
+
onSubmit: x(fe),
|
|
1325
1334
|
onCancel: R[4] || (R[4] = (D) => c.$emit("cancel"))
|
|
1326
1335
|
}, null, 8, ["allow-speech", "allow-files", "loading", "disabled", "show-clear", "has-content", "speech-status", "submit-type", "is-over-limit", "onSubmit"])
|
|
1327
1336
|
])
|
|
1328
|
-
])) :
|
|
1337
|
+
])) : P("", !0)
|
|
1329
1338
|
])
|
|
1330
|
-
], 4)) : c.$slots.footer ? (k(), M("div",
|
|
1339
|
+
], 4)) : c.$slots.footer ? (k(), M("div", Wt, [
|
|
1331
1340
|
ne(c.$slots, "footer")
|
|
1332
|
-
])) :
|
|
1341
|
+
])) : P("", !0)
|
|
1333
1342
|
]),
|
|
1334
1343
|
_: 3
|
|
1335
1344
|
})
|
|
@@ -1337,39 +1346,38 @@ const wt = /* @__PURE__ */ ve({
|
|
|
1337
1346
|
]),
|
|
1338
1347
|
U(ge, { name: "tiny-sender-slide-up" }, {
|
|
1339
1348
|
default: G(() => [
|
|
1340
|
-
|
|
1349
|
+
x(y) && x(I).length ? (k(), M("div", {
|
|
1341
1350
|
key: 0,
|
|
1342
1351
|
ref_key: "suggestionsListRef",
|
|
1343
1352
|
ref: L,
|
|
1344
|
-
class: "tiny-sender__suggestions"
|
|
1353
|
+
class: "tiny-sender__suggestions",
|
|
1354
|
+
style: Re(qe.value)
|
|
1345
1355
|
}, [
|
|
1346
|
-
(k(!0), M(
|
|
1356
|
+
(k(!0), M(ke, null, De(x(I), (D, ee) => (k(), M("div", {
|
|
1347
1357
|
key: ee,
|
|
1348
|
-
class:
|
|
1349
|
-
onMouseenter: (te) =>
|
|
1350
|
-
onMousedown: Ye((te) =>
|
|
1358
|
+
class: oe(["suggestion-item", { highlighted: ee === x(w) }]),
|
|
1359
|
+
onMouseenter: (te) => x(n)(ee),
|
|
1360
|
+
onMousedown: Ye((te) => x(p)(D), ["prevent"])
|
|
1351
1361
|
}, [
|
|
1352
|
-
|
|
1353
|
-
U(T(it))
|
|
1354
|
-
]),
|
|
1362
|
+
U(x(it), { class: "suggestion-item__icon" }),
|
|
1355
1363
|
K("span", Pt, [
|
|
1356
|
-
(k(!0), M(
|
|
1364
|
+
(k(!0), M(ke, null, De(x(r)(D, x(l)), (te, Ee) => (k(), M("span", {
|
|
1357
1365
|
key: Ee,
|
|
1358
|
-
class:
|
|
1366
|
+
class: oe({ "suggestion-item__text--match": te.isMatch, "suggestion-item__text--normal": !te.isMatch })
|
|
1359
1367
|
}, se(te.text), 3))), 128))
|
|
1360
1368
|
])
|
|
1361
|
-
], 42,
|
|
1362
|
-
],
|
|
1369
|
+
], 42, $t))), 128))
|
|
1370
|
+
], 4)) : P("", !0)
|
|
1363
1371
|
]),
|
|
1364
1372
|
_: 1
|
|
1365
1373
|
}),
|
|
1366
|
-
|
|
1367
|
-
], 10,
|
|
1374
|
+
le.value ? (k(), M("div", Kt, se(le.value), 1)) : P("", !0)
|
|
1375
|
+
], 10, Et));
|
|
1368
1376
|
}
|
|
1369
1377
|
});
|
|
1370
1378
|
ce.name = "TrSender";
|
|
1371
|
-
const Ht = function(
|
|
1372
|
-
|
|
1379
|
+
const Ht = function(t) {
|
|
1380
|
+
t.component(ce.name, ce);
|
|
1373
1381
|
};
|
|
1374
1382
|
ce.install = Ht;
|
|
1375
1383
|
export {
|