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