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