@opentiny/tiny-robot 0.3.1-alpha.7 → 0.3.1-alpha.8
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 +9 -9
- package/dist/attachments/index.js +1 -1
- package/dist/base-popper/index.js +1 -1
- package/dist/bubble/index.js +11 -6
- package/dist/container/index.js +7 -7
- package/dist/drag-overlay/index.js +7 -7
- package/dist/dropdown-menu/index.js +7 -7
- package/dist/feedback/index.js +1 -1
- package/dist/flow-layout-buttons/index.js +17 -17
- package/dist/history/index.js +1 -1
- package/dist/icon-button/index.js +1 -1
- package/dist/index.d.ts +2653 -1357
- package/dist/index.js +158 -123
- package/dist/index2.js +183 -4062
- package/dist/index3.js +266 -285
- package/dist/index4.js +380 -323
- package/dist/index5.js +510 -142
- package/dist/index6.js +301 -0
- package/dist/index7.js +161 -0
- package/dist/mcp-add-form/index.js +7 -7
- package/dist/mcp-server-picker/index.js +1 -1
- package/dist/prompts/index.js +3 -3
- package/dist/sender/index.js +3180 -1399
- package/dist/sender-actions/index.js +13 -0
- package/dist/sender-compat/index.js +229 -0
- package/dist/style.css +1 -1
- package/dist/suggestion-pills/index.js +14 -14
- package/dist/suggestion-popover/index.js +181 -182
- package/dist/theme-provider/index.js +7 -7
- package/dist/utils.js +1 -1
- package/dist/welcome/index.js +4 -4
- package/package.json +18 -5
- package/dist/loading.js +0 -4
package/dist/sender/index.js
CHANGED
|
@@ -1,1482 +1,3263 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
1
|
+
import { defineComponent as j, openBlock as M, createBlock as G, unref as L, withCtx as $, createTextVNode as Gt, toDisplayString as fe, ref as V, watch as K, createElementBlock as O, Fragment as De, renderList as Be, withModifiers as Ye, normalizeClass as ee, createCommentVNode as W, createElementVNode as k, nextTick as pe, isRef as _e, Transition as Yt, normalizeStyle as jt, createVNode as oe, toRaw as Zt, computed as B, onMounted as Jt, onUnmounted as Qt, Teleport as en, toRef as Re, onBeforeUnmount as tn, provide as nn, renderSlot as R, normalizeProps as me, guardReactiveProps as he, createSlots as pt } from "vue";
|
|
2
|
+
import { a as on, u as Me, W as bt, D as St } from "../index2.js";
|
|
3
|
+
import { NodeViewWrapper as Je, VueRenderer as At, VueNodeViewRenderer as Qe, NodeViewContent as sn, useEditor as rn, EditorContent as ln } from "@tiptap/vue-3";
|
|
4
|
+
import an from "@tiptap/extension-document";
|
|
5
|
+
import cn from "@tiptap/extension-paragraph";
|
|
6
|
+
import un from "@tiptap/extension-text";
|
|
7
|
+
import dn from "@tiptap/extension-history";
|
|
8
|
+
import fn from "@tiptap/extension-placeholder";
|
|
9
|
+
import pn from "@tiptap/extension-character-count";
|
|
10
|
+
import { j as mn, k as hn, l as gn } from "../index4.js";
|
|
11
|
+
import { PluginKey as re, Plugin as ie, TextSelection as P } from "@tiptap/pm/state";
|
|
12
|
+
import { DecorationSet as Ce, Decoration as Ct } from "@tiptap/pm/view";
|
|
13
|
+
import { _ as Z } from "../_plugin-vue_export-helper.js";
|
|
14
|
+
import { IconAssociate as yn, IconArrowDown as xn } from "@opentiny/tiny-robot-svgs";
|
|
15
|
+
import { Node as et, mergeAttributes as tt, Extension as _t } from "@tiptap/core";
|
|
16
|
+
const Tn = /* @__PURE__ */ j({
|
|
17
|
+
__name: "mention-view",
|
|
18
|
+
props: {
|
|
19
|
+
node: {},
|
|
20
|
+
extension: {}
|
|
21
|
+
},
|
|
22
|
+
setup(e) {
|
|
23
|
+
return (t, n) => (M(), G(L(Je), {
|
|
24
|
+
as: "span",
|
|
25
|
+
class: "mention",
|
|
26
|
+
"data-id": e.node.attrs.id,
|
|
27
|
+
"data-value": e.node.attrs.value
|
|
28
|
+
}, {
|
|
29
|
+
default: $(() => [
|
|
30
|
+
Gt(fe(e.extension.options.char) + fe(e.node.attrs.label), 1)
|
|
31
|
+
]),
|
|
32
|
+
_: 1
|
|
33
|
+
}, 8, ["data-id", "data-value"]));
|
|
34
|
+
}
|
|
35
|
+
}), vn = /* @__PURE__ */ Z(Tn, [["__scopeId", "data-v-b42c4fae"]]), ke = Math.min, de = Math.max, Ie = Math.round, Pe = Math.floor, X = (e) => ({
|
|
36
|
+
x: e,
|
|
37
|
+
y: e
|
|
38
|
+
}), En = {
|
|
39
|
+
left: "right",
|
|
40
|
+
right: "left",
|
|
41
|
+
bottom: "top",
|
|
42
|
+
top: "bottom"
|
|
43
|
+
}, wn = {
|
|
44
|
+
start: "end",
|
|
45
|
+
end: "start"
|
|
46
|
+
};
|
|
47
|
+
function mt(e, t, n) {
|
|
48
|
+
return de(e, ke(t, n));
|
|
49
|
+
}
|
|
50
|
+
function Ke(e, t) {
|
|
51
|
+
return typeof e == "function" ? e(t) : e;
|
|
52
|
+
}
|
|
53
|
+
function ge(e) {
|
|
54
|
+
return e.split("-")[0];
|
|
55
|
+
}
|
|
56
|
+
function He(e) {
|
|
57
|
+
return e.split("-")[1];
|
|
58
|
+
}
|
|
59
|
+
function Lt(e) {
|
|
60
|
+
return e === "x" ? "y" : "x";
|
|
61
|
+
}
|
|
62
|
+
function Mt(e) {
|
|
63
|
+
return e === "y" ? "height" : "width";
|
|
64
|
+
}
|
|
65
|
+
const bn = /* @__PURE__ */ new Set(["top", "bottom"]);
|
|
66
|
+
function ne(e) {
|
|
67
|
+
return bn.has(ge(e)) ? "y" : "x";
|
|
68
|
+
}
|
|
69
|
+
function Ot(e) {
|
|
70
|
+
return Lt(ne(e));
|
|
71
|
+
}
|
|
72
|
+
function Sn(e, t, n) {
|
|
73
|
+
n === void 0 && (n = !1);
|
|
74
|
+
const o = He(e), i = Ot(e), s = Mt(i);
|
|
75
|
+
let l = i === "x" ? o === (n ? "end" : "start") ? "right" : "left" : o === "start" ? "bottom" : "top";
|
|
76
|
+
return t.reference[s] > t.floating[s] && (l = $e(l)), [l, $e(l)];
|
|
77
|
+
}
|
|
78
|
+
function An(e) {
|
|
79
|
+
const t = $e(e);
|
|
80
|
+
return [je(e), t, je(t)];
|
|
81
|
+
}
|
|
82
|
+
function je(e) {
|
|
83
|
+
return e.replace(/start|end/g, (t) => wn[t]);
|
|
84
|
+
}
|
|
85
|
+
const ht = ["left", "right"], gt = ["right", "left"], Cn = ["top", "bottom"], _n = ["bottom", "top"];
|
|
86
|
+
function Ln(e, t, n) {
|
|
87
|
+
switch (e) {
|
|
88
|
+
case "top":
|
|
89
|
+
case "bottom":
|
|
90
|
+
return n ? t ? gt : ht : t ? ht : gt;
|
|
91
|
+
case "left":
|
|
92
|
+
case "right":
|
|
93
|
+
return t ? Cn : _n;
|
|
94
|
+
default:
|
|
95
|
+
return [];
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
function Mn(e, t, n, o) {
|
|
99
|
+
const i = He(e);
|
|
100
|
+
let s = Ln(ge(e), n === "start", o);
|
|
101
|
+
return i && (s = s.map((l) => l + "-" + i), t && (s = s.concat(s.map(je)))), s;
|
|
102
|
+
}
|
|
103
|
+
function $e(e) {
|
|
104
|
+
return e.replace(/left|right|bottom|top/g, (t) => En[t]);
|
|
105
|
+
}
|
|
106
|
+
function On(e) {
|
|
107
|
+
return {
|
|
108
|
+
top: 0,
|
|
109
|
+
right: 0,
|
|
110
|
+
bottom: 0,
|
|
111
|
+
left: 0,
|
|
112
|
+
...e
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
function Pn(e) {
|
|
116
|
+
return typeof e != "number" ? On(e) : {
|
|
117
|
+
top: e,
|
|
118
|
+
right: e,
|
|
119
|
+
bottom: e,
|
|
120
|
+
left: e
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
function Ne(e) {
|
|
124
|
+
const {
|
|
125
|
+
x: t,
|
|
126
|
+
y: n,
|
|
127
|
+
width: o,
|
|
128
|
+
height: i
|
|
129
|
+
} = e;
|
|
130
|
+
return {
|
|
131
|
+
width: o,
|
|
132
|
+
height: i,
|
|
133
|
+
top: n,
|
|
134
|
+
left: t,
|
|
135
|
+
right: t + o,
|
|
136
|
+
bottom: n + i,
|
|
137
|
+
x: t,
|
|
138
|
+
y: n
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
function yt(e, t, n) {
|
|
142
|
+
let {
|
|
143
|
+
reference: o,
|
|
144
|
+
floating: i
|
|
145
|
+
} = e;
|
|
146
|
+
const s = ne(t), l = Ot(t), r = Mt(l), a = ge(t), c = s === "y", f = o.x + o.width / 2 - i.width / 2, u = o.y + o.height / 2 - i.height / 2, T = o[r] / 2 - i[r] / 2;
|
|
147
|
+
let y;
|
|
148
|
+
switch (a) {
|
|
149
|
+
case "top":
|
|
150
|
+
y = {
|
|
151
|
+
x: f,
|
|
152
|
+
y: o.y - i.height
|
|
153
|
+
};
|
|
154
|
+
break;
|
|
155
|
+
case "bottom":
|
|
156
|
+
y = {
|
|
157
|
+
x: f,
|
|
158
|
+
y: o.y + o.height
|
|
159
|
+
};
|
|
160
|
+
break;
|
|
161
|
+
case "right":
|
|
162
|
+
y = {
|
|
163
|
+
x: o.x + o.width,
|
|
164
|
+
y: u
|
|
165
|
+
};
|
|
166
|
+
break;
|
|
167
|
+
case "left":
|
|
168
|
+
y = {
|
|
169
|
+
x: o.x - i.width,
|
|
170
|
+
y: u
|
|
171
|
+
};
|
|
172
|
+
break;
|
|
173
|
+
default:
|
|
174
|
+
y = {
|
|
175
|
+
x: o.x,
|
|
176
|
+
y: o.y
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
switch (He(t)) {
|
|
180
|
+
case "start":
|
|
181
|
+
y[l] -= T * (n && c ? -1 : 1);
|
|
182
|
+
break;
|
|
183
|
+
case "end":
|
|
184
|
+
y[l] += T * (n && c ? -1 : 1);
|
|
185
|
+
break;
|
|
186
|
+
}
|
|
187
|
+
return y;
|
|
188
|
+
}
|
|
189
|
+
const Rn = async (e, t, n) => {
|
|
190
|
+
const {
|
|
191
|
+
placement: o = "bottom",
|
|
192
|
+
strategy: i = "absolute",
|
|
193
|
+
middleware: s = [],
|
|
194
|
+
platform: l
|
|
195
|
+
} = n, r = s.filter(Boolean), a = await (l.isRTL == null ? void 0 : l.isRTL(t));
|
|
196
|
+
let c = await l.getElementRects({
|
|
197
|
+
reference: e,
|
|
198
|
+
floating: t,
|
|
199
|
+
strategy: i
|
|
200
|
+
}), {
|
|
201
|
+
x: f,
|
|
202
|
+
y: u
|
|
203
|
+
} = yt(c, o, a), T = o, y = {}, w = 0;
|
|
204
|
+
for (let b = 0; b < r.length; b++) {
|
|
205
|
+
const {
|
|
206
|
+
name: v,
|
|
207
|
+
fn: h
|
|
208
|
+
} = r[b], {
|
|
209
|
+
x: g,
|
|
210
|
+
y: m,
|
|
211
|
+
data: p,
|
|
212
|
+
reset: d
|
|
213
|
+
} = await h({
|
|
214
|
+
x: f,
|
|
215
|
+
y: u,
|
|
216
|
+
initialPlacement: o,
|
|
217
|
+
placement: T,
|
|
218
|
+
strategy: i,
|
|
219
|
+
middlewareData: y,
|
|
220
|
+
rects: c,
|
|
221
|
+
platform: l,
|
|
222
|
+
elements: {
|
|
223
|
+
reference: e,
|
|
224
|
+
floating: t
|
|
225
|
+
}
|
|
226
|
+
});
|
|
227
|
+
f = g ?? f, u = m ?? u, y = {
|
|
228
|
+
...y,
|
|
229
|
+
[v]: {
|
|
230
|
+
...y[v],
|
|
231
|
+
...p
|
|
232
|
+
}
|
|
233
|
+
}, d && w <= 50 && (w++, typeof d == "object" && (d.placement && (T = d.placement), d.rects && (c = d.rects === !0 ? await l.getElementRects({
|
|
234
|
+
reference: e,
|
|
235
|
+
floating: t,
|
|
236
|
+
strategy: i
|
|
237
|
+
}) : d.rects), {
|
|
238
|
+
x: f,
|
|
239
|
+
y: u
|
|
240
|
+
} = yt(c, T, a)), b = -1);
|
|
241
|
+
}
|
|
242
|
+
return {
|
|
243
|
+
x: f,
|
|
244
|
+
y: u,
|
|
245
|
+
placement: T,
|
|
246
|
+
strategy: i,
|
|
247
|
+
middlewareData: y
|
|
248
|
+
};
|
|
249
|
+
};
|
|
250
|
+
async function Pt(e, t) {
|
|
251
|
+
var n;
|
|
252
|
+
t === void 0 && (t = {});
|
|
253
|
+
const {
|
|
254
|
+
x: o,
|
|
255
|
+
y: i,
|
|
256
|
+
platform: s,
|
|
257
|
+
rects: l,
|
|
258
|
+
elements: r,
|
|
259
|
+
strategy: a
|
|
260
|
+
} = e, {
|
|
261
|
+
boundary: c = "clippingAncestors",
|
|
262
|
+
rootBoundary: f = "viewport",
|
|
263
|
+
elementContext: u = "floating",
|
|
264
|
+
altBoundary: T = !1,
|
|
265
|
+
padding: y = 0
|
|
266
|
+
} = Ke(t, e), w = Pn(y), v = r[T ? u === "floating" ? "reference" : "floating" : u], h = Ne(await s.getClippingRect({
|
|
267
|
+
element: (n = await (s.isElement == null ? void 0 : s.isElement(v))) == null || n ? v : v.contextElement || await (s.getDocumentElement == null ? void 0 : s.getDocumentElement(r.floating)),
|
|
268
|
+
boundary: c,
|
|
269
|
+
rootBoundary: f,
|
|
270
|
+
strategy: a
|
|
271
|
+
})), g = u === "floating" ? {
|
|
272
|
+
x: o,
|
|
273
|
+
y: i,
|
|
274
|
+
width: l.floating.width,
|
|
275
|
+
height: l.floating.height
|
|
276
|
+
} : l.reference, m = await (s.getOffsetParent == null ? void 0 : s.getOffsetParent(r.floating)), p = await (s.isElement == null ? void 0 : s.isElement(m)) ? await (s.getScale == null ? void 0 : s.getScale(m)) || {
|
|
277
|
+
x: 1,
|
|
278
|
+
y: 1
|
|
279
|
+
} : {
|
|
280
|
+
x: 1,
|
|
281
|
+
y: 1
|
|
282
|
+
}, d = Ne(s.convertOffsetParentRelativeRectToViewportRelativeRect ? await s.convertOffsetParentRelativeRectToViewportRelativeRect({
|
|
283
|
+
elements: r,
|
|
284
|
+
rect: g,
|
|
285
|
+
offsetParent: m,
|
|
286
|
+
strategy: a
|
|
287
|
+
}) : g);
|
|
288
|
+
return {
|
|
289
|
+
top: (h.top - d.top + w.top) / p.y,
|
|
290
|
+
bottom: (d.bottom - h.bottom + w.bottom) / p.y,
|
|
291
|
+
left: (h.left - d.left + w.left) / p.x,
|
|
292
|
+
right: (d.right - h.right + w.right) / p.x
|
|
293
|
+
};
|
|
294
|
+
}
|
|
295
|
+
const Dn = function(e) {
|
|
296
|
+
return e === void 0 && (e = {}), {
|
|
297
|
+
name: "flip",
|
|
298
|
+
options: e,
|
|
299
|
+
async fn(t) {
|
|
300
|
+
var n, o;
|
|
301
|
+
const {
|
|
302
|
+
placement: i,
|
|
303
|
+
middlewareData: s,
|
|
304
|
+
rects: l,
|
|
305
|
+
initialPlacement: r,
|
|
306
|
+
platform: a,
|
|
307
|
+
elements: c
|
|
308
|
+
} = t, {
|
|
309
|
+
mainAxis: f = !0,
|
|
310
|
+
crossAxis: u = !0,
|
|
311
|
+
fallbackPlacements: T,
|
|
312
|
+
fallbackStrategy: y = "bestFit",
|
|
313
|
+
fallbackAxisSideDirection: w = "none",
|
|
314
|
+
flipAlignment: b = !0,
|
|
315
|
+
...v
|
|
316
|
+
} = Ke(e, t);
|
|
317
|
+
if ((n = s.arrow) != null && n.alignmentOffset)
|
|
318
|
+
return {};
|
|
319
|
+
const h = ge(i), g = ne(r), m = ge(r) === r, p = await (a.isRTL == null ? void 0 : a.isRTL(c.floating)), d = T || (m || !b ? [$e(r)] : An(r)), x = w !== "none";
|
|
320
|
+
!T && x && d.push(...Mn(r, b, w, p));
|
|
321
|
+
const E = [r, ...d], _ = await Pt(t, v), C = [];
|
|
322
|
+
let I = ((o = s.flip) == null ? void 0 : o.overflows) || [];
|
|
323
|
+
if (f && C.push(_[h]), u) {
|
|
324
|
+
const ae = Sn(i, l, p);
|
|
325
|
+
C.push(_[ae[0]], _[ae[1]]);
|
|
326
|
+
}
|
|
327
|
+
if (I = [...I, {
|
|
328
|
+
placement: i,
|
|
329
|
+
overflows: C
|
|
330
|
+
}], !C.every((ae) => ae <= 0)) {
|
|
331
|
+
var Q, dt;
|
|
332
|
+
const ae = (((Q = s.flip) == null ? void 0 : Q.index) || 0) + 1, Ue = E[ae];
|
|
333
|
+
if (Ue && (!(u === "alignment" ? g !== ne(Ue) : !1) || // We leave the current main axis only if every placement on that axis
|
|
334
|
+
// overflows the main axis.
|
|
335
|
+
I.every((H) => ne(H.placement) === g ? H.overflows[0] > 0 : !0)))
|
|
336
|
+
return {
|
|
337
|
+
data: {
|
|
338
|
+
index: ae,
|
|
339
|
+
overflows: I
|
|
340
|
+
},
|
|
341
|
+
reset: {
|
|
342
|
+
placement: Ue
|
|
343
|
+
}
|
|
344
|
+
};
|
|
345
|
+
let Ae = (dt = I.filter((ce) => ce.overflows[0] <= 0).sort((ce, H) => ce.overflows[1] - H.overflows[1])[0]) == null ? void 0 : dt.placement;
|
|
346
|
+
if (!Ae)
|
|
347
|
+
switch (y) {
|
|
348
|
+
case "bestFit": {
|
|
349
|
+
var ft;
|
|
350
|
+
const ce = (ft = I.filter((H) => {
|
|
351
|
+
if (x) {
|
|
352
|
+
const te = ne(H.placement);
|
|
353
|
+
return te === g || // Create a bias to the `y` side axis due to horizontal
|
|
354
|
+
// reading directions favoring greater width.
|
|
355
|
+
te === "y";
|
|
356
|
+
}
|
|
357
|
+
return !0;
|
|
358
|
+
}).map((H) => [H.placement, H.overflows.filter((te) => te > 0).reduce((te, Xt) => te + Xt, 0)]).sort((H, te) => H[1] - te[1])[0]) == null ? void 0 : ft[0];
|
|
359
|
+
ce && (Ae = ce);
|
|
360
|
+
break;
|
|
361
|
+
}
|
|
362
|
+
case "initialPlacement":
|
|
363
|
+
Ae = r;
|
|
364
|
+
break;
|
|
365
|
+
}
|
|
366
|
+
if (i !== Ae)
|
|
367
|
+
return {
|
|
368
|
+
reset: {
|
|
369
|
+
placement: Ae
|
|
370
|
+
}
|
|
371
|
+
};
|
|
372
|
+
}
|
|
373
|
+
return {};
|
|
374
|
+
}
|
|
375
|
+
};
|
|
376
|
+
}, Bn = /* @__PURE__ */ new Set(["left", "top"]);
|
|
377
|
+
async function kn(e, t) {
|
|
378
|
+
const {
|
|
379
|
+
placement: n,
|
|
380
|
+
platform: o,
|
|
381
|
+
elements: i
|
|
382
|
+
} = e, s = await (o.isRTL == null ? void 0 : o.isRTL(i.floating)), l = ge(n), r = He(n), a = ne(n) === "y", c = Bn.has(l) ? -1 : 1, f = s && a ? -1 : 1, u = Ke(t, e);
|
|
383
|
+
let {
|
|
384
|
+
mainAxis: T,
|
|
385
|
+
crossAxis: y,
|
|
386
|
+
alignmentAxis: w
|
|
387
|
+
} = typeof u == "number" ? {
|
|
388
|
+
mainAxis: u,
|
|
389
|
+
crossAxis: 0,
|
|
390
|
+
alignmentAxis: null
|
|
391
|
+
} : {
|
|
392
|
+
mainAxis: u.mainAxis || 0,
|
|
393
|
+
crossAxis: u.crossAxis || 0,
|
|
394
|
+
alignmentAxis: u.alignmentAxis
|
|
395
|
+
};
|
|
396
|
+
return r && typeof w == "number" && (y = r === "end" ? w * -1 : w), a ? {
|
|
397
|
+
x: y * f,
|
|
398
|
+
y: T * c
|
|
399
|
+
} : {
|
|
400
|
+
x: T * c,
|
|
401
|
+
y: y * f
|
|
402
|
+
};
|
|
403
|
+
}
|
|
404
|
+
const In = function(e) {
|
|
405
|
+
return e === void 0 && (e = 0), {
|
|
406
|
+
name: "offset",
|
|
407
|
+
options: e,
|
|
408
|
+
async fn(t) {
|
|
409
|
+
var n, o;
|
|
410
|
+
const {
|
|
411
|
+
x: i,
|
|
412
|
+
y: s,
|
|
413
|
+
placement: l,
|
|
414
|
+
middlewareData: r
|
|
415
|
+
} = t, a = await kn(t, e);
|
|
416
|
+
return l === ((n = r.offset) == null ? void 0 : n.placement) && (o = r.arrow) != null && o.alignmentOffset ? {} : {
|
|
417
|
+
x: i + a.x,
|
|
418
|
+
y: s + a.y,
|
|
419
|
+
data: {
|
|
420
|
+
...a,
|
|
421
|
+
placement: l
|
|
422
|
+
}
|
|
423
|
+
};
|
|
16
424
|
}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
425
|
+
};
|
|
426
|
+
}, $n = function(e) {
|
|
427
|
+
return e === void 0 && (e = {}), {
|
|
428
|
+
name: "shift",
|
|
429
|
+
options: e,
|
|
430
|
+
async fn(t) {
|
|
431
|
+
const {
|
|
432
|
+
x: n,
|
|
433
|
+
y: o,
|
|
434
|
+
placement: i
|
|
435
|
+
} = t, {
|
|
436
|
+
mainAxis: s = !0,
|
|
437
|
+
crossAxis: l = !1,
|
|
438
|
+
limiter: r = {
|
|
439
|
+
fn: (v) => {
|
|
440
|
+
let {
|
|
441
|
+
x: h,
|
|
442
|
+
y: g
|
|
443
|
+
} = v;
|
|
444
|
+
return {
|
|
445
|
+
x: h,
|
|
446
|
+
y: g
|
|
447
|
+
};
|
|
448
|
+
}
|
|
449
|
+
},
|
|
450
|
+
...a
|
|
451
|
+
} = Ke(e, t), c = {
|
|
452
|
+
x: n,
|
|
453
|
+
y: o
|
|
454
|
+
}, f = await Pt(t, a), u = ne(ge(i)), T = Lt(u);
|
|
455
|
+
let y = c[T], w = c[u];
|
|
456
|
+
if (s) {
|
|
457
|
+
const v = T === "y" ? "top" : "left", h = T === "y" ? "bottom" : "right", g = y + f[v], m = y - f[h];
|
|
458
|
+
y = mt(g, y, m);
|
|
459
|
+
}
|
|
460
|
+
if (l) {
|
|
461
|
+
const v = u === "y" ? "top" : "left", h = u === "y" ? "bottom" : "right", g = w + f[v], m = w - f[h];
|
|
462
|
+
w = mt(g, w, m);
|
|
463
|
+
}
|
|
464
|
+
const b = r.fn({
|
|
465
|
+
...t,
|
|
466
|
+
[T]: y,
|
|
467
|
+
[u]: w
|
|
468
|
+
});
|
|
469
|
+
return {
|
|
470
|
+
...b,
|
|
471
|
+
data: {
|
|
472
|
+
x: b.x - n,
|
|
473
|
+
y: b.y - o,
|
|
474
|
+
enabled: {
|
|
475
|
+
[T]: s,
|
|
476
|
+
[u]: l
|
|
477
|
+
}
|
|
478
|
+
}
|
|
479
|
+
};
|
|
480
|
+
}
|
|
481
|
+
};
|
|
482
|
+
};
|
|
483
|
+
function Fe() {
|
|
484
|
+
return typeof window < "u";
|
|
485
|
+
}
|
|
486
|
+
function Se(e) {
|
|
487
|
+
return Rt(e) ? (e.nodeName || "").toLowerCase() : "#document";
|
|
488
|
+
}
|
|
489
|
+
function N(e) {
|
|
490
|
+
var t;
|
|
491
|
+
return (e == null || (t = e.ownerDocument) == null ? void 0 : t.defaultView) || window;
|
|
492
|
+
}
|
|
493
|
+
function J(e) {
|
|
494
|
+
var t;
|
|
495
|
+
return (t = (Rt(e) ? e.ownerDocument : e.document) || window.document) == null ? void 0 : t.documentElement;
|
|
496
|
+
}
|
|
497
|
+
function Rt(e) {
|
|
498
|
+
return Fe() ? e instanceof Node || e instanceof N(e).Node : !1;
|
|
499
|
+
}
|
|
500
|
+
function z(e) {
|
|
501
|
+
return Fe() ? e instanceof Element || e instanceof N(e).Element : !1;
|
|
502
|
+
}
|
|
503
|
+
function Y(e) {
|
|
504
|
+
return Fe() ? e instanceof HTMLElement || e instanceof N(e).HTMLElement : !1;
|
|
505
|
+
}
|
|
506
|
+
function xt(e) {
|
|
507
|
+
return !Fe() || typeof ShadowRoot > "u" ? !1 : e instanceof ShadowRoot || e instanceof N(e).ShadowRoot;
|
|
508
|
+
}
|
|
509
|
+
const Nn = /* @__PURE__ */ new Set(["inline", "contents"]);
|
|
510
|
+
function Oe(e) {
|
|
511
|
+
const {
|
|
512
|
+
overflow: t,
|
|
513
|
+
overflowX: n,
|
|
514
|
+
overflowY: o,
|
|
515
|
+
display: i
|
|
516
|
+
} = q(e);
|
|
517
|
+
return /auto|scroll|overlay|hidden|clip/.test(t + o + n) && !Nn.has(i);
|
|
518
|
+
}
|
|
519
|
+
const Wn = /* @__PURE__ */ new Set(["table", "td", "th"]);
|
|
520
|
+
function Kn(e) {
|
|
521
|
+
return Wn.has(Se(e));
|
|
522
|
+
}
|
|
523
|
+
const Hn = [":popover-open", ":modal"];
|
|
524
|
+
function Ve(e) {
|
|
525
|
+
return Hn.some((t) => {
|
|
526
|
+
try {
|
|
527
|
+
return e.matches(t);
|
|
528
|
+
} catch {
|
|
529
|
+
return !1;
|
|
21
530
|
}
|
|
531
|
+
});
|
|
532
|
+
}
|
|
533
|
+
const Fn = ["transform", "translate", "scale", "rotate", "perspective"], Vn = ["transform", "translate", "scale", "rotate", "perspective", "filter"], zn = ["paint", "layout", "strict", "content"];
|
|
534
|
+
function nt(e) {
|
|
535
|
+
const t = ot(), n = z(e) ? q(e) : e;
|
|
536
|
+
return Fn.some((o) => n[o] ? n[o] !== "none" : !1) || (n.containerType ? n.containerType !== "normal" : !1) || !t && (n.backdropFilter ? n.backdropFilter !== "none" : !1) || !t && (n.filter ? n.filter !== "none" : !1) || Vn.some((o) => (n.willChange || "").includes(o)) || zn.some((o) => (n.contain || "").includes(o));
|
|
537
|
+
}
|
|
538
|
+
function qn(e) {
|
|
539
|
+
let t = se(e);
|
|
540
|
+
for (; Y(t) && !Ee(t); ) {
|
|
541
|
+
if (nt(t))
|
|
542
|
+
return t;
|
|
543
|
+
if (Ve(t))
|
|
544
|
+
return null;
|
|
545
|
+
t = se(t);
|
|
546
|
+
}
|
|
547
|
+
return null;
|
|
548
|
+
}
|
|
549
|
+
function ot() {
|
|
550
|
+
return typeof CSS > "u" || !CSS.supports ? !1 : CSS.supports("-webkit-backdrop-filter", "none");
|
|
551
|
+
}
|
|
552
|
+
const Un = /* @__PURE__ */ new Set(["html", "body", "#document"]);
|
|
553
|
+
function Ee(e) {
|
|
554
|
+
return Un.has(Se(e));
|
|
555
|
+
}
|
|
556
|
+
function q(e) {
|
|
557
|
+
return N(e).getComputedStyle(e);
|
|
558
|
+
}
|
|
559
|
+
function ze(e) {
|
|
560
|
+
return z(e) ? {
|
|
561
|
+
scrollLeft: e.scrollLeft,
|
|
562
|
+
scrollTop: e.scrollTop
|
|
563
|
+
} : {
|
|
564
|
+
scrollLeft: e.scrollX,
|
|
565
|
+
scrollTop: e.scrollY
|
|
566
|
+
};
|
|
567
|
+
}
|
|
568
|
+
function se(e) {
|
|
569
|
+
if (Se(e) === "html")
|
|
570
|
+
return e;
|
|
571
|
+
const t = (
|
|
572
|
+
// Step into the shadow DOM of the parent of a slotted node.
|
|
573
|
+
e.assignedSlot || // DOM Element detected.
|
|
574
|
+
e.parentNode || // ShadowRoot detected.
|
|
575
|
+
xt(e) && e.host || // Fallback.
|
|
576
|
+
J(e)
|
|
22
577
|
);
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
578
|
+
return xt(t) ? t.host : t;
|
|
579
|
+
}
|
|
580
|
+
function Dt(e) {
|
|
581
|
+
const t = se(e);
|
|
582
|
+
return Ee(t) ? e.ownerDocument ? e.ownerDocument.body : e.body : Y(t) && Oe(t) ? t : Dt(t);
|
|
583
|
+
}
|
|
584
|
+
function Le(e, t, n) {
|
|
585
|
+
var o;
|
|
586
|
+
t === void 0 && (t = []), n === void 0 && (n = !0);
|
|
587
|
+
const i = Dt(e), s = i === ((o = e.ownerDocument) == null ? void 0 : o.body), l = N(i);
|
|
588
|
+
if (s) {
|
|
589
|
+
const r = Ze(l);
|
|
590
|
+
return t.concat(l, l.visualViewport || [], Oe(i) ? i : [], r && n ? Le(r) : []);
|
|
591
|
+
}
|
|
592
|
+
return t.concat(i, Le(i, [], n));
|
|
593
|
+
}
|
|
594
|
+
function Ze(e) {
|
|
595
|
+
return e.parent && Object.getPrototypeOf(e.parent) ? e.frameElement : null;
|
|
596
|
+
}
|
|
597
|
+
function Bt(e) {
|
|
598
|
+
const t = q(e);
|
|
599
|
+
let n = parseFloat(t.width) || 0, o = parseFloat(t.height) || 0;
|
|
600
|
+
const i = Y(e), s = i ? e.offsetWidth : n, l = i ? e.offsetHeight : o, r = Ie(n) !== s || Ie(o) !== l;
|
|
601
|
+
return r && (n = s, o = l), {
|
|
602
|
+
width: n,
|
|
603
|
+
height: o,
|
|
604
|
+
$: r
|
|
605
|
+
};
|
|
606
|
+
}
|
|
607
|
+
function st(e) {
|
|
608
|
+
return z(e) ? e : e.contextElement;
|
|
609
|
+
}
|
|
610
|
+
function ve(e) {
|
|
611
|
+
const t = st(e);
|
|
612
|
+
if (!Y(t))
|
|
613
|
+
return X(1);
|
|
614
|
+
const n = t.getBoundingClientRect(), {
|
|
615
|
+
width: o,
|
|
616
|
+
height: i,
|
|
617
|
+
$: s
|
|
618
|
+
} = Bt(t);
|
|
619
|
+
let l = (s ? Ie(n.width) : n.width) / o, r = (s ? Ie(n.height) : n.height) / i;
|
|
620
|
+
return (!l || !Number.isFinite(l)) && (l = 1), (!r || !Number.isFinite(r)) && (r = 1), {
|
|
621
|
+
x: l,
|
|
622
|
+
y: r
|
|
623
|
+
};
|
|
624
|
+
}
|
|
625
|
+
const Xn = /* @__PURE__ */ X(0);
|
|
626
|
+
function kt(e) {
|
|
627
|
+
const t = N(e);
|
|
628
|
+
return !ot() || !t.visualViewport ? Xn : {
|
|
629
|
+
x: t.visualViewport.offsetLeft,
|
|
630
|
+
y: t.visualViewport.offsetTop
|
|
631
|
+
};
|
|
632
|
+
}
|
|
633
|
+
function Gn(e, t, n) {
|
|
634
|
+
return t === void 0 && (t = !1), !n || t && n !== N(e) ? !1 : t;
|
|
635
|
+
}
|
|
636
|
+
function ye(e, t, n, o) {
|
|
637
|
+
t === void 0 && (t = !1), n === void 0 && (n = !1);
|
|
638
|
+
const i = e.getBoundingClientRect(), s = st(e);
|
|
639
|
+
let l = X(1);
|
|
640
|
+
t && (o ? z(o) && (l = ve(o)) : l = ve(e));
|
|
641
|
+
const r = Gn(s, n, o) ? kt(s) : X(0);
|
|
642
|
+
let a = (i.left + r.x) / l.x, c = (i.top + r.y) / l.y, f = i.width / l.x, u = i.height / l.y;
|
|
643
|
+
if (s) {
|
|
644
|
+
const T = N(s), y = o && z(o) ? N(o) : o;
|
|
645
|
+
let w = T, b = Ze(w);
|
|
646
|
+
for (; b && o && y !== w; ) {
|
|
647
|
+
const v = ve(b), h = b.getBoundingClientRect(), g = q(b), m = h.left + (b.clientLeft + parseFloat(g.paddingLeft)) * v.x, p = h.top + (b.clientTop + parseFloat(g.paddingTop)) * v.y;
|
|
648
|
+
a *= v.x, c *= v.y, f *= v.x, u *= v.y, a += m, c += p, w = N(b), b = Ze(w);
|
|
649
|
+
}
|
|
650
|
+
}
|
|
651
|
+
return Ne({
|
|
652
|
+
width: f,
|
|
653
|
+
height: u,
|
|
654
|
+
x: a,
|
|
655
|
+
y: c
|
|
656
|
+
});
|
|
657
|
+
}
|
|
658
|
+
function qe(e, t) {
|
|
659
|
+
const n = ze(e).scrollLeft;
|
|
660
|
+
return t ? t.left + n : ye(J(e)).left + n;
|
|
661
|
+
}
|
|
662
|
+
function It(e, t) {
|
|
663
|
+
const n = e.getBoundingClientRect(), o = n.left + t.scrollLeft - qe(e, n), i = n.top + t.scrollTop;
|
|
664
|
+
return {
|
|
665
|
+
x: o,
|
|
666
|
+
y: i
|
|
667
|
+
};
|
|
668
|
+
}
|
|
669
|
+
function Yn(e) {
|
|
670
|
+
let {
|
|
671
|
+
elements: t,
|
|
672
|
+
rect: n,
|
|
673
|
+
offsetParent: o,
|
|
674
|
+
strategy: i
|
|
675
|
+
} = e;
|
|
676
|
+
const s = i === "fixed", l = J(o), r = t ? Ve(t.floating) : !1;
|
|
677
|
+
if (o === l || r && s)
|
|
678
|
+
return n;
|
|
679
|
+
let a = {
|
|
680
|
+
scrollLeft: 0,
|
|
681
|
+
scrollTop: 0
|
|
682
|
+
}, c = X(1);
|
|
683
|
+
const f = X(0), u = Y(o);
|
|
684
|
+
if ((u || !u && !s) && ((Se(o) !== "body" || Oe(l)) && (a = ze(o)), Y(o))) {
|
|
685
|
+
const y = ye(o);
|
|
686
|
+
c = ve(o), f.x = y.x + o.clientLeft, f.y = y.y + o.clientTop;
|
|
687
|
+
}
|
|
688
|
+
const T = l && !u && !s ? It(l, a) : X(0);
|
|
32
689
|
return {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
690
|
+
width: n.width * c.x,
|
|
691
|
+
height: n.height * c.y,
|
|
692
|
+
x: n.x * c.x - a.scrollLeft * c.x + f.x + T.x,
|
|
693
|
+
y: n.y * c.y - a.scrollTop * c.y + f.y + T.y
|
|
694
|
+
};
|
|
695
|
+
}
|
|
696
|
+
function jn(e) {
|
|
697
|
+
return Array.from(e.getClientRects());
|
|
698
|
+
}
|
|
699
|
+
function Zn(e) {
|
|
700
|
+
const t = J(e), n = ze(e), o = e.ownerDocument.body, i = de(t.scrollWidth, t.clientWidth, o.scrollWidth, o.clientWidth), s = de(t.scrollHeight, t.clientHeight, o.scrollHeight, o.clientHeight);
|
|
701
|
+
let l = -n.scrollLeft + qe(e);
|
|
702
|
+
const r = -n.scrollTop;
|
|
703
|
+
return q(o).direction === "rtl" && (l += de(t.clientWidth, o.clientWidth) - i), {
|
|
704
|
+
width: i,
|
|
705
|
+
height: s,
|
|
706
|
+
x: l,
|
|
707
|
+
y: r
|
|
708
|
+
};
|
|
709
|
+
}
|
|
710
|
+
const Tt = 25;
|
|
711
|
+
function Jn(e, t) {
|
|
712
|
+
const n = N(e), o = J(e), i = n.visualViewport;
|
|
713
|
+
let s = o.clientWidth, l = o.clientHeight, r = 0, a = 0;
|
|
714
|
+
if (i) {
|
|
715
|
+
s = i.width, l = i.height;
|
|
716
|
+
const f = ot();
|
|
717
|
+
(!f || f && t === "fixed") && (r = i.offsetLeft, a = i.offsetTop);
|
|
718
|
+
}
|
|
719
|
+
const c = qe(o);
|
|
720
|
+
if (c <= 0) {
|
|
721
|
+
const f = o.ownerDocument, u = f.body, T = getComputedStyle(u), y = f.compatMode === "CSS1Compat" && parseFloat(T.marginLeft) + parseFloat(T.marginRight) || 0, w = Math.abs(o.clientWidth - u.clientWidth - y);
|
|
722
|
+
w <= Tt && (s -= w);
|
|
723
|
+
} else c <= Tt && (s += c);
|
|
724
|
+
return {
|
|
725
|
+
width: s,
|
|
726
|
+
height: l,
|
|
727
|
+
x: r,
|
|
728
|
+
y: a
|
|
729
|
+
};
|
|
730
|
+
}
|
|
731
|
+
const Qn = /* @__PURE__ */ new Set(["absolute", "fixed"]);
|
|
732
|
+
function eo(e, t) {
|
|
733
|
+
const n = ye(e, !0, t === "fixed"), o = n.top + e.clientTop, i = n.left + e.clientLeft, s = Y(e) ? ve(e) : X(1), l = e.clientWidth * s.x, r = e.clientHeight * s.y, a = i * s.x, c = o * s.y;
|
|
734
|
+
return {
|
|
735
|
+
width: l,
|
|
736
|
+
height: r,
|
|
737
|
+
x: a,
|
|
738
|
+
y: c
|
|
739
|
+
};
|
|
740
|
+
}
|
|
741
|
+
function vt(e, t, n) {
|
|
742
|
+
let o;
|
|
743
|
+
if (t === "viewport")
|
|
744
|
+
o = Jn(e, n);
|
|
745
|
+
else if (t === "document")
|
|
746
|
+
o = Zn(J(e));
|
|
747
|
+
else if (z(t))
|
|
748
|
+
o = eo(t, n);
|
|
749
|
+
else {
|
|
750
|
+
const i = kt(e);
|
|
751
|
+
o = {
|
|
752
|
+
x: t.x - i.x,
|
|
753
|
+
y: t.y - i.y,
|
|
754
|
+
width: t.width,
|
|
755
|
+
height: t.height
|
|
756
|
+
};
|
|
757
|
+
}
|
|
758
|
+
return Ne(o);
|
|
759
|
+
}
|
|
760
|
+
function $t(e, t) {
|
|
761
|
+
const n = se(e);
|
|
762
|
+
return n === t || !z(n) || Ee(n) ? !1 : q(n).position === "fixed" || $t(n, t);
|
|
763
|
+
}
|
|
764
|
+
function to(e, t) {
|
|
765
|
+
const n = t.get(e);
|
|
766
|
+
if (n)
|
|
767
|
+
return n;
|
|
768
|
+
let o = Le(e, [], !1).filter((r) => z(r) && Se(r) !== "body"), i = null;
|
|
769
|
+
const s = q(e).position === "fixed";
|
|
770
|
+
let l = s ? se(e) : e;
|
|
771
|
+
for (; z(l) && !Ee(l); ) {
|
|
772
|
+
const r = q(l), a = nt(l);
|
|
773
|
+
!a && r.position === "fixed" && (i = null), (s ? !a && !i : !a && r.position === "static" && !!i && Qn.has(i.position) || Oe(l) && !a && $t(e, l)) ? o = o.filter((f) => f !== l) : i = r, l = se(l);
|
|
774
|
+
}
|
|
775
|
+
return t.set(e, o), o;
|
|
776
|
+
}
|
|
777
|
+
function no(e) {
|
|
778
|
+
let {
|
|
779
|
+
element: t,
|
|
780
|
+
boundary: n,
|
|
781
|
+
rootBoundary: o,
|
|
782
|
+
strategy: i
|
|
783
|
+
} = e;
|
|
784
|
+
const l = [...n === "clippingAncestors" ? Ve(t) ? [] : to(t, this._c) : [].concat(n), o], r = l[0], a = l.reduce((c, f) => {
|
|
785
|
+
const u = vt(t, f, i);
|
|
786
|
+
return c.top = de(u.top, c.top), c.right = ke(u.right, c.right), c.bottom = ke(u.bottom, c.bottom), c.left = de(u.left, c.left), c;
|
|
787
|
+
}, vt(t, r, i));
|
|
788
|
+
return {
|
|
789
|
+
width: a.right - a.left,
|
|
790
|
+
height: a.bottom - a.top,
|
|
791
|
+
x: a.left,
|
|
792
|
+
y: a.top
|
|
793
|
+
};
|
|
794
|
+
}
|
|
795
|
+
function oo(e) {
|
|
796
|
+
const {
|
|
797
|
+
width: t,
|
|
798
|
+
height: n
|
|
799
|
+
} = Bt(e);
|
|
800
|
+
return {
|
|
801
|
+
width: t,
|
|
802
|
+
height: n
|
|
803
|
+
};
|
|
804
|
+
}
|
|
805
|
+
function so(e, t, n) {
|
|
806
|
+
const o = Y(t), i = J(t), s = n === "fixed", l = ye(e, !0, s, t);
|
|
807
|
+
let r = {
|
|
808
|
+
scrollLeft: 0,
|
|
809
|
+
scrollTop: 0
|
|
810
|
+
};
|
|
811
|
+
const a = X(0);
|
|
812
|
+
function c() {
|
|
813
|
+
a.x = qe(i);
|
|
814
|
+
}
|
|
815
|
+
if (o || !o && !s)
|
|
816
|
+
if ((Se(t) !== "body" || Oe(i)) && (r = ze(t)), o) {
|
|
817
|
+
const y = ye(t, !0, s, t);
|
|
818
|
+
a.x = y.x + t.clientLeft, a.y = y.y + t.clientTop;
|
|
819
|
+
} else i && c();
|
|
820
|
+
s && !o && i && c();
|
|
821
|
+
const f = i && !o && !s ? It(i, r) : X(0), u = l.left + r.scrollLeft - a.x - f.x, T = l.top + r.scrollTop - a.y - f.y;
|
|
822
|
+
return {
|
|
823
|
+
x: u,
|
|
824
|
+
y: T,
|
|
825
|
+
width: l.width,
|
|
826
|
+
height: l.height
|
|
827
|
+
};
|
|
828
|
+
}
|
|
829
|
+
function Xe(e) {
|
|
830
|
+
return q(e).position === "static";
|
|
831
|
+
}
|
|
832
|
+
function Et(e, t) {
|
|
833
|
+
if (!Y(e) || q(e).position === "fixed")
|
|
834
|
+
return null;
|
|
835
|
+
if (t)
|
|
836
|
+
return t(e);
|
|
837
|
+
let n = e.offsetParent;
|
|
838
|
+
return J(e) === n && (n = n.ownerDocument.body), n;
|
|
839
|
+
}
|
|
840
|
+
function Nt(e, t) {
|
|
841
|
+
const n = N(e);
|
|
842
|
+
if (Ve(e))
|
|
843
|
+
return n;
|
|
844
|
+
if (!Y(e)) {
|
|
845
|
+
let i = se(e);
|
|
846
|
+
for (; i && !Ee(i); ) {
|
|
847
|
+
if (z(i) && !Xe(i))
|
|
848
|
+
return i;
|
|
849
|
+
i = se(i);
|
|
850
|
+
}
|
|
851
|
+
return n;
|
|
852
|
+
}
|
|
853
|
+
let o = Et(e, t);
|
|
854
|
+
for (; o && Kn(o) && Xe(o); )
|
|
855
|
+
o = Et(o, t);
|
|
856
|
+
return o && Ee(o) && Xe(o) && !nt(o) ? n : o || qn(e) || n;
|
|
857
|
+
}
|
|
858
|
+
const ro = async function(e) {
|
|
859
|
+
const t = this.getOffsetParent || Nt, n = this.getDimensions, o = await n(e.floating);
|
|
860
|
+
return {
|
|
861
|
+
reference: so(e.reference, await t(e.floating), e.strategy),
|
|
862
|
+
floating: {
|
|
863
|
+
x: 0,
|
|
864
|
+
y: 0,
|
|
865
|
+
width: o.width,
|
|
866
|
+
height: o.height
|
|
41
867
|
}
|
|
42
868
|
};
|
|
869
|
+
};
|
|
870
|
+
function io(e) {
|
|
871
|
+
return q(e).direction === "rtl";
|
|
43
872
|
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
873
|
+
const lo = {
|
|
874
|
+
convertOffsetParentRelativeRectToViewportRelativeRect: Yn,
|
|
875
|
+
getDocumentElement: J,
|
|
876
|
+
getClippingRect: no,
|
|
877
|
+
getOffsetParent: Nt,
|
|
878
|
+
getElementRects: ro,
|
|
879
|
+
getClientRects: jn,
|
|
880
|
+
getDimensions: oo,
|
|
881
|
+
getScale: ve,
|
|
882
|
+
isElement: z,
|
|
883
|
+
isRTL: io
|
|
884
|
+
};
|
|
885
|
+
function Wt(e, t) {
|
|
886
|
+
return e.x === t.x && e.y === t.y && e.width === t.width && e.height === t.height;
|
|
887
|
+
}
|
|
888
|
+
function ao(e, t) {
|
|
889
|
+
let n = null, o;
|
|
890
|
+
const i = J(e);
|
|
891
|
+
function s() {
|
|
892
|
+
var r;
|
|
893
|
+
clearTimeout(o), (r = n) == null || r.disconnect(), n = null;
|
|
894
|
+
}
|
|
895
|
+
function l(r, a) {
|
|
896
|
+
r === void 0 && (r = !1), a === void 0 && (a = 1), s();
|
|
897
|
+
const c = e.getBoundingClientRect(), {
|
|
898
|
+
left: f,
|
|
899
|
+
top: u,
|
|
900
|
+
width: T,
|
|
901
|
+
height: y
|
|
902
|
+
} = c;
|
|
903
|
+
if (r || t(), !T || !y)
|
|
904
|
+
return;
|
|
905
|
+
const w = Pe(u), b = Pe(i.clientWidth - (f + T)), v = Pe(i.clientHeight - (u + y)), h = Pe(f), m = {
|
|
906
|
+
rootMargin: -w + "px " + -b + "px " + -v + "px " + -h + "px",
|
|
907
|
+
threshold: de(0, ke(1, a)) || 1
|
|
908
|
+
};
|
|
909
|
+
let p = !0;
|
|
910
|
+
function d(x) {
|
|
911
|
+
const E = x[0].intersectionRatio;
|
|
912
|
+
if (E !== a) {
|
|
913
|
+
if (!p)
|
|
914
|
+
return l();
|
|
915
|
+
E ? l(!1, E) : o = setTimeout(() => {
|
|
916
|
+
l(!1, 1e-7);
|
|
917
|
+
}, 1e3);
|
|
918
|
+
}
|
|
919
|
+
E === 1 && !Wt(c, e.getBoundingClientRect()) && l(), p = !1;
|
|
58
920
|
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
if (t.submitType !== "enter" || p.key !== "Enter") return !1;
|
|
68
|
-
const _ = p.ctrlKey && !p.shiftKey, U = p.shiftKey && !p.ctrlKey;
|
|
69
|
-
if (_ || U) {
|
|
70
|
-
p.preventDefault();
|
|
71
|
-
const Z = p.target;
|
|
72
|
-
return (L == null ? void 0 : L.value) === "single" && F && F(), N(Z), !0;
|
|
921
|
+
try {
|
|
922
|
+
n = new IntersectionObserver(d, {
|
|
923
|
+
...m,
|
|
924
|
+
// Handle <iframe>s
|
|
925
|
+
root: i.ownerDocument
|
|
926
|
+
});
|
|
927
|
+
} catch {
|
|
928
|
+
n = new IntersectionObserver(d, m);
|
|
73
929
|
}
|
|
74
|
-
|
|
930
|
+
n.observe(e);
|
|
931
|
+
}
|
|
932
|
+
return l(!0), s;
|
|
933
|
+
}
|
|
934
|
+
function rt(e, t, n, o) {
|
|
935
|
+
o === void 0 && (o = {});
|
|
936
|
+
const {
|
|
937
|
+
ancestorScroll: i = !0,
|
|
938
|
+
ancestorResize: s = !0,
|
|
939
|
+
elementResize: l = typeof ResizeObserver == "function",
|
|
940
|
+
layoutShift: r = typeof IntersectionObserver == "function",
|
|
941
|
+
animationFrame: a = !1
|
|
942
|
+
} = o, c = st(e), f = i || s ? [...c ? Le(c) : [], ...Le(t)] : [];
|
|
943
|
+
f.forEach((h) => {
|
|
944
|
+
i && h.addEventListener("scroll", n, {
|
|
945
|
+
passive: !0
|
|
946
|
+
}), s && h.addEventListener("resize", n);
|
|
947
|
+
});
|
|
948
|
+
const u = c && r ? ao(c, n) : null;
|
|
949
|
+
let T = -1, y = null;
|
|
950
|
+
l && (y = new ResizeObserver((h) => {
|
|
951
|
+
let [g] = h;
|
|
952
|
+
g && g.target === c && y && (y.unobserve(t), cancelAnimationFrame(T), T = requestAnimationFrame(() => {
|
|
953
|
+
var m;
|
|
954
|
+
(m = y) == null || m.observe(t);
|
|
955
|
+
})), n();
|
|
956
|
+
}), c && !a && y.observe(c), y.observe(t));
|
|
957
|
+
let w, b = a ? ye(e) : null;
|
|
958
|
+
a && v();
|
|
959
|
+
function v() {
|
|
960
|
+
const h = ye(e);
|
|
961
|
+
b && !Wt(b, h) && n(), b = h, w = requestAnimationFrame(v);
|
|
962
|
+
}
|
|
963
|
+
return n(), () => {
|
|
964
|
+
var h;
|
|
965
|
+
f.forEach((g) => {
|
|
966
|
+
i && g.removeEventListener("scroll", n), s && g.removeEventListener("resize", n);
|
|
967
|
+
}), u == null || u(), (h = y) == null || h.disconnect(), y = null, a && cancelAnimationFrame(w);
|
|
75
968
|
};
|
|
969
|
+
}
|
|
970
|
+
const it = In, lt = $n, at = Dn, ct = (e, t, n) => {
|
|
971
|
+
const o = /* @__PURE__ */ new Map(), i = {
|
|
972
|
+
platform: lo,
|
|
973
|
+
...n
|
|
974
|
+
}, s = {
|
|
975
|
+
...i.platform,
|
|
976
|
+
_c: o
|
|
977
|
+
};
|
|
978
|
+
return Rn(e, t, {
|
|
979
|
+
...i,
|
|
980
|
+
platform: s
|
|
981
|
+
});
|
|
982
|
+
};
|
|
983
|
+
function Te(e) {
|
|
984
|
+
return `${e}_${Date.now()}_${Math.random().toString(36).slice(2, 9)}`;
|
|
985
|
+
}
|
|
986
|
+
function co(e, t, n = !1) {
|
|
987
|
+
const { $from: o } = e;
|
|
988
|
+
if (!e.empty || !o.parent.isTextblock)
|
|
989
|
+
return null;
|
|
990
|
+
const i = o.parent.textBetween(0, o.parentOffset, void 0, ""), s = i.lastIndexOf(t);
|
|
991
|
+
if (s === -1)
|
|
992
|
+
return null;
|
|
993
|
+
const l = i.slice(s + t.length);
|
|
994
|
+
if (!n && l.includes(" "))
|
|
995
|
+
return null;
|
|
996
|
+
const r = o.start() + s, a = o.pos;
|
|
76
997
|
return {
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
998
|
+
range: { from: r, to: a },
|
|
999
|
+
query: l
|
|
1000
|
+
};
|
|
1001
|
+
}
|
|
1002
|
+
const xe = {
|
|
1003
|
+
/** Template 扩展(包含 TemplateBlock 和 TemplateSelect 子扩展) */
|
|
1004
|
+
TEMPLATE: "template",
|
|
1005
|
+
/** Mention 扩展 */
|
|
1006
|
+
MENTION: "mention",
|
|
1007
|
+
/** Suggestion 扩展 */
|
|
1008
|
+
SUGGESTION: "suggestion"
|
|
1009
|
+
}, A = {
|
|
1010
|
+
/** TemplateBlock 节点类型(可编辑块) */
|
|
1011
|
+
TEMPLATE_BLOCK: "templateBlock",
|
|
1012
|
+
/** TemplateSelect 节点类型(下拉选择) */
|
|
1013
|
+
TEMPLATE_SELECT: "templateSelect",
|
|
1014
|
+
/** Mention 节点类型 */
|
|
1015
|
+
MENTION: "mention",
|
|
1016
|
+
/** Paragraph 节点类型(ProseMirror 内置) */
|
|
1017
|
+
PARAGRAPH: "paragraph",
|
|
1018
|
+
/** Text 节点类型(ProseMirror 内置) */
|
|
1019
|
+
TEXT: "text"
|
|
1020
|
+
}, le = {
|
|
1021
|
+
/** Mention 插件 */
|
|
1022
|
+
MENTION: "mention",
|
|
1023
|
+
/** Suggestion 插件 */
|
|
1024
|
+
SUGGESTION: "suggestion",
|
|
1025
|
+
/** Template Select 下拉菜单插件 */
|
|
1026
|
+
TEMPLATE_SELECT_DROPDOWN: "templateSelectDropdown",
|
|
1027
|
+
/** Template Select 零宽字符插件 */
|
|
1028
|
+
TEMPLATE_SELECT_ZERO_WIDTH: "templateSelectZeroWidth",
|
|
1029
|
+
/** Template Select 键盘导航插件 */
|
|
1030
|
+
TEMPLATE_SELECT_KEYBOARD: "templateSelectKeyboard",
|
|
1031
|
+
/** Template Block 零宽字符插件 */
|
|
1032
|
+
TEMPLATE_BLOCK_ZERO_WIDTH: "templateBlockZeroWidth",
|
|
1033
|
+
/** Template Block 键盘导航插件 */
|
|
1034
|
+
TEMPLATE_BLOCK_KEYBOARD: "templateBlockKeyboard",
|
|
1035
|
+
/** Template Block 粘贴处理插件 */
|
|
1036
|
+
TEMPLATE_BLOCK_PASTE: "templateBlockPaste"
|
|
1037
|
+
}, U = {
|
|
1038
|
+
/** 文本类型 */
|
|
1039
|
+
TEXT: "text",
|
|
1040
|
+
/** 模板块类型(对应内部的 TemplateBlock 节点) */
|
|
1041
|
+
BLOCK: "block",
|
|
1042
|
+
/** 选择器类型(对应内部的 TemplateSelect 节点) */
|
|
1043
|
+
SELECT: "select",
|
|
1044
|
+
/** Mention 类型 */
|
|
1045
|
+
MENTION: "mention"
|
|
1046
|
+
}, Kt = {
|
|
1047
|
+
/** Enter 键 */
|
|
1048
|
+
ENTER: "Enter",
|
|
1049
|
+
/** Escape 键 */
|
|
1050
|
+
ESCAPE: "Escape",
|
|
1051
|
+
/** Tab 键 */
|
|
1052
|
+
TAB: "Tab",
|
|
1053
|
+
/** Backspace 键 */
|
|
1054
|
+
BACKSPACE: "Backspace",
|
|
1055
|
+
/** Delete 键 */
|
|
1056
|
+
DELETE: "Delete",
|
|
1057
|
+
/** 上箭头键 */
|
|
1058
|
+
ARROW_UP: "ArrowUp",
|
|
1059
|
+
/** 下箭头键 */
|
|
1060
|
+
ARROW_DOWN: "ArrowDown",
|
|
1061
|
+
/** 左箭头键 */
|
|
1062
|
+
ARROW_LEFT: "ArrowLeft",
|
|
1063
|
+
/** 右箭头键 */
|
|
1064
|
+
ARROW_RIGHT: "ArrowRight",
|
|
1065
|
+
/** 空格键 */
|
|
1066
|
+
SPACE: " "
|
|
1067
|
+
}, D = (e, t) => e.key === Kt[t], we = (e, t) => t.some((n) => e.key === Kt[n]), uo = ["onMousedown", "onMouseenter"], fo = {
|
|
1068
|
+
key: 0,
|
|
1069
|
+
class: "mention-icon"
|
|
1070
|
+
}, po = { class: "mention-label" }, mo = {
|
|
1071
|
+
key: 0,
|
|
1072
|
+
class: "mention-empty"
|
|
1073
|
+
}, ho = /* @__PURE__ */ j({
|
|
1074
|
+
__name: "mention-list",
|
|
1075
|
+
props: {
|
|
1076
|
+
items: {},
|
|
1077
|
+
command: { type: Function }
|
|
1078
|
+
},
|
|
1079
|
+
setup(e, { expose: t }) {
|
|
1080
|
+
const n = e, o = V(0), i = V(null);
|
|
1081
|
+
K(
|
|
1082
|
+
() => n.items,
|
|
1083
|
+
() => {
|
|
1084
|
+
o.value = 0;
|
|
1085
|
+
}
|
|
1086
|
+
);
|
|
1087
|
+
function s({ event: c }) {
|
|
1088
|
+
return D(c, "ARROW_UP") ? (o.value = Math.max(0, o.value - 1), l(), !0) : D(c, "ARROW_DOWN") ? (o.value = Math.min(n.items.length - 1, o.value + 1), l(), !0) : we(c, ["ENTER", "TAB"]) ? (r(o.value), !0) : !1;
|
|
1089
|
+
}
|
|
1090
|
+
function l() {
|
|
1091
|
+
pe(() => {
|
|
1092
|
+
var f;
|
|
1093
|
+
const c = (f = i.value) == null ? void 0 : f.querySelector(".mention-item.is-selected");
|
|
1094
|
+
c && c.scrollIntoView({
|
|
1095
|
+
block: "nearest",
|
|
1096
|
+
behavior: "smooth"
|
|
1097
|
+
});
|
|
1098
|
+
});
|
|
1099
|
+
}
|
|
1100
|
+
function r(c) {
|
|
1101
|
+
const f = n.items[c];
|
|
1102
|
+
f && n.command({
|
|
1103
|
+
id: f.id,
|
|
1104
|
+
label: f.label,
|
|
1105
|
+
value: f.value
|
|
1106
|
+
});
|
|
1107
|
+
}
|
|
1108
|
+
function a(c) {
|
|
1109
|
+
o.value = c;
|
|
1110
|
+
}
|
|
1111
|
+
return t({
|
|
1112
|
+
onKeyDown: s
|
|
1113
|
+
}), (c, f) => (M(), O("div", {
|
|
1114
|
+
ref_key: "listRef",
|
|
1115
|
+
ref: i,
|
|
1116
|
+
class: "mention-list"
|
|
1117
|
+
}, [
|
|
1118
|
+
(M(!0), O(De, null, Be(e.items, (u, T) => (M(), O("button", {
|
|
1119
|
+
key: u.id,
|
|
1120
|
+
type: "button",
|
|
1121
|
+
class: ee(["mention-item", { "is-selected": T === o.value }]),
|
|
1122
|
+
onMousedown: Ye((y) => r(T), ["prevent"]),
|
|
1123
|
+
onMouseenter: (y) => a(T)
|
|
1124
|
+
}, [
|
|
1125
|
+
u.icon ? (M(), O("span", fo, fe(u.icon), 1)) : W("", !0),
|
|
1126
|
+
k("span", po, fe(u.label), 1)
|
|
1127
|
+
], 42, uo))), 128)),
|
|
1128
|
+
e.items.length === 0 ? (M(), O("div", mo, [...f[0] || (f[0] = [
|
|
1129
|
+
k("span", null, "未找到匹配的提及项", -1)
|
|
1130
|
+
])])) : W("", !0)
|
|
1131
|
+
], 512));
|
|
1132
|
+
}
|
|
1133
|
+
}), go = /* @__PURE__ */ Z(ho, [["__scopeId", "data-v-aaa34d1a"]]), ue = new re(le.MENTION);
|
|
1134
|
+
function yo(e, t) {
|
|
1135
|
+
if (!t)
|
|
1136
|
+
return e;
|
|
1137
|
+
const n = t.toLowerCase();
|
|
1138
|
+
return e.filter((o) => {
|
|
1139
|
+
var i;
|
|
1140
|
+
return !!(o.label.toLowerCase().includes(n) || (i = o.value) != null && i.toLowerCase().includes(n));
|
|
1141
|
+
});
|
|
1142
|
+
}
|
|
1143
|
+
function xo(e) {
|
|
1144
|
+
const { editor: t, char: n, items: o, allowSpaces: i } = e;
|
|
1145
|
+
let s = null, l = null, r = null;
|
|
1146
|
+
return new ie({
|
|
1147
|
+
key: ue,
|
|
1148
|
+
state: {
|
|
1149
|
+
init() {
|
|
1150
|
+
return {
|
|
1151
|
+
active: !1,
|
|
1152
|
+
range: null,
|
|
1153
|
+
query: "",
|
|
1154
|
+
filteredItems: []
|
|
1155
|
+
};
|
|
1156
|
+
},
|
|
1157
|
+
apply(a, c) {
|
|
1158
|
+
const f = a.getMeta(ue);
|
|
1159
|
+
if (f && f.type === "close")
|
|
1160
|
+
return {
|
|
1161
|
+
active: !1,
|
|
1162
|
+
range: null,
|
|
1163
|
+
query: "",
|
|
1164
|
+
filteredItems: []
|
|
1165
|
+
};
|
|
1166
|
+
if (!a.docChanged && !a.selectionSet)
|
|
1167
|
+
return c;
|
|
1168
|
+
const u = co(a.selection, n, i);
|
|
1169
|
+
if (!u)
|
|
1170
|
+
return {
|
|
1171
|
+
active: !1,
|
|
1172
|
+
range: null,
|
|
1173
|
+
query: "",
|
|
1174
|
+
filteredItems: []
|
|
1175
|
+
};
|
|
1176
|
+
const T = _e(o) ? o.value : o, y = yo(T, u.query);
|
|
1177
|
+
return {
|
|
1178
|
+
active: y.length > 0,
|
|
1179
|
+
range: u.range,
|
|
1180
|
+
query: u.query,
|
|
1181
|
+
filteredItems: y
|
|
1182
|
+
};
|
|
1183
|
+
}
|
|
1184
|
+
},
|
|
1185
|
+
props: {
|
|
1186
|
+
// 装饰器:高亮触发区域
|
|
1187
|
+
decorations(a) {
|
|
1188
|
+
const c = this.getState(a);
|
|
1189
|
+
if (!(c != null && c.active) || !c.range)
|
|
1190
|
+
return Ce.empty;
|
|
1191
|
+
const f = Ct.inline(c.range.from, c.range.to, {
|
|
1192
|
+
class: "mention-trigger"
|
|
1193
|
+
});
|
|
1194
|
+
return Ce.create(a.doc, [f]);
|
|
1195
|
+
},
|
|
1196
|
+
// 键盘处理
|
|
1197
|
+
handleKeyDown(a, c) {
|
|
1198
|
+
var u, T, y, w;
|
|
1199
|
+
const f = ue.getState(a.state);
|
|
1200
|
+
if (D(c, "BACKSPACE")) {
|
|
1201
|
+
const { selection: b } = a.state, { $from: v } = b;
|
|
1202
|
+
if (v.nodeBefore && v.nodeBefore.type.name === A.MENTION) {
|
|
1203
|
+
c.preventDefault();
|
|
1204
|
+
const { tr: h } = a.state, g = v.pos - v.nodeBefore.nodeSize;
|
|
1205
|
+
return h.delete(g, v.pos), h.insertText(n, g), h.setSelection(P.create(h.doc, g + 1)), a.dispatch(h), a.focus(), !0;
|
|
91
1206
|
}
|
|
92
1207
|
}
|
|
93
|
-
if (
|
|
94
|
-
|
|
95
|
-
|
|
1208
|
+
if (!(f != null && f.active))
|
|
1209
|
+
return !1;
|
|
1210
|
+
if (D(c, "ESCAPE")) {
|
|
1211
|
+
c.preventDefault();
|
|
1212
|
+
const b = a.state.tr;
|
|
1213
|
+
return b.setMeta(ue, {
|
|
1214
|
+
type: "close"
|
|
1215
|
+
}), a.dispatch(b), s && (r == null || r(), r = null, s.destroy(), s = null), l && (l.remove(), l = null), !0;
|
|
1216
|
+
}
|
|
1217
|
+
if (we(c, ["ENTER", "TAB"])) {
|
|
1218
|
+
if (c.preventDefault(), (T = (u = s == null ? void 0 : s.ref) == null ? void 0 : u.onKeyDown) == null ? void 0 : T.call(u, { event: c }))
|
|
1219
|
+
return !0;
|
|
1220
|
+
if (f.filteredItems.length > 0 && f.range) {
|
|
1221
|
+
const v = f.filteredItems[0];
|
|
1222
|
+
return wt(a, f.range, v), !0;
|
|
1223
|
+
}
|
|
1224
|
+
return !0;
|
|
96
1225
|
}
|
|
97
|
-
|
|
1226
|
+
return we(c, ["ARROW_UP", "ARROW_DOWN"]) && ((w = (y = s == null ? void 0 : s.ref) == null ? void 0 : y.onKeyDown) == null ? void 0 : w.call(y, { event: c })) || !1;
|
|
98
1227
|
}
|
|
99
1228
|
},
|
|
100
|
-
|
|
101
|
-
|
|
1229
|
+
view() {
|
|
1230
|
+
return {
|
|
1231
|
+
update(a) {
|
|
1232
|
+
const c = ue.getState(a.state);
|
|
1233
|
+
if (c != null && c.active && c.filteredItems.length > 0) {
|
|
1234
|
+
s ? s.updateProps({
|
|
1235
|
+
items: c.filteredItems
|
|
1236
|
+
}) : (s = new At(go, {
|
|
1237
|
+
props: {
|
|
1238
|
+
items: c.filteredItems,
|
|
1239
|
+
command: (u) => {
|
|
1240
|
+
const T = {
|
|
1241
|
+
id: u.id,
|
|
1242
|
+
label: u.label,
|
|
1243
|
+
value: u.value || ""
|
|
1244
|
+
};
|
|
1245
|
+
c.range && wt(a, c.range, T);
|
|
1246
|
+
}
|
|
1247
|
+
},
|
|
1248
|
+
editor: t
|
|
1249
|
+
}), l = s.element, l.style.position = "absolute", l.style.zIndex = "1000", document.body.appendChild(l));
|
|
1250
|
+
const f = a.dom.querySelector(".mention-trigger");
|
|
1251
|
+
f && l && (r == null || r(), r = rt(f, l, () => {
|
|
1252
|
+
ct(f, l, {
|
|
1253
|
+
placement: "bottom-start",
|
|
1254
|
+
middleware: [it(8), at(), lt({ padding: 8 })]
|
|
1255
|
+
}).then((u) => {
|
|
1256
|
+
l && Object.assign(l.style, {
|
|
1257
|
+
left: `${u.x}px`,
|
|
1258
|
+
top: `${u.y}px`
|
|
1259
|
+
});
|
|
1260
|
+
});
|
|
1261
|
+
}));
|
|
1262
|
+
} else
|
|
1263
|
+
s && (r == null || r(), r = null, s.destroy(), s = null), l && (l.remove(), l = null);
|
|
1264
|
+
},
|
|
1265
|
+
destroy() {
|
|
1266
|
+
r == null || r(), s == null || s.destroy(), l == null || l.remove();
|
|
1267
|
+
}
|
|
1268
|
+
};
|
|
1269
|
+
}
|
|
1270
|
+
});
|
|
102
1271
|
}
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
1272
|
+
function wt(e, t, n) {
|
|
1273
|
+
e.focus();
|
|
1274
|
+
const { state: o, dispatch: i } = e, { tr: s } = o, l = o.schema.nodes.mention.create({
|
|
1275
|
+
id: n.id || Te("mention"),
|
|
1276
|
+
label: n.label,
|
|
1277
|
+
value: n.value || ""
|
|
1278
|
+
}), r = o.schema.text(" ");
|
|
1279
|
+
s.delete(t.from, t.to), s.insert(t.from, [l, r]);
|
|
1280
|
+
const a = t.from + 2;
|
|
1281
|
+
s.setSelection(P.create(s.doc, a)), s.scrollIntoView(), i(s);
|
|
1282
|
+
}
|
|
1283
|
+
const To = {
|
|
109
1284
|
/**
|
|
110
|
-
*
|
|
1285
|
+
* 插入 mention 节点
|
|
111
1286
|
*/
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
1287
|
+
insertMention: (e) => ({ commands: t }) => t.insertContent({
|
|
1288
|
+
type: A.MENTION,
|
|
1289
|
+
attrs: {
|
|
1290
|
+
id: e.id || Te("mention"),
|
|
1291
|
+
label: e.label || "",
|
|
1292
|
+
value: e.value
|
|
1293
|
+
}
|
|
1294
|
+
}),
|
|
115
1295
|
/**
|
|
116
|
-
*
|
|
1296
|
+
* 删除 mention 节点
|
|
117
1297
|
*/
|
|
118
|
-
|
|
119
|
-
|
|
1298
|
+
deleteMention: (e) => ({ tr: t, state: n }) => {
|
|
1299
|
+
let o = !1;
|
|
1300
|
+
return n.doc.descendants((i, s) => {
|
|
1301
|
+
if (i.type.name === A.MENTION && i.attrs.id === e)
|
|
1302
|
+
return t.delete(s, s + i.nodeSize), o = !0, !1;
|
|
1303
|
+
}), o;
|
|
1304
|
+
}
|
|
1305
|
+
}, Ht = et.create({
|
|
1306
|
+
name: xe.MENTION,
|
|
1307
|
+
// 节点配置
|
|
1308
|
+
group: "inline",
|
|
1309
|
+
inline: !0,
|
|
1310
|
+
atom: !0,
|
|
1311
|
+
// 不可编辑,作为整体
|
|
1312
|
+
selectable: !0,
|
|
1313
|
+
draggable: !1,
|
|
1314
|
+
// 节点属性
|
|
1315
|
+
addAttributes() {
|
|
1316
|
+
return {
|
|
1317
|
+
id: {
|
|
1318
|
+
default: null,
|
|
1319
|
+
parseHTML: (e) => e.getAttribute("data-id"),
|
|
1320
|
+
renderHTML: (e) => e.id ? {
|
|
1321
|
+
"data-id": e.id
|
|
1322
|
+
} : {}
|
|
1323
|
+
},
|
|
1324
|
+
label: {
|
|
1325
|
+
default: null,
|
|
1326
|
+
parseHTML: (e) => e.getAttribute("data-label"),
|
|
1327
|
+
renderHTML: (e) => e.label ? {
|
|
1328
|
+
"data-label": e.label
|
|
1329
|
+
} : {}
|
|
1330
|
+
},
|
|
1331
|
+
value: {
|
|
1332
|
+
default: null,
|
|
1333
|
+
parseHTML: (e) => e.getAttribute("data-value"),
|
|
1334
|
+
renderHTML: (e) => e.value ? {
|
|
1335
|
+
"data-value": e.value
|
|
1336
|
+
} : {}
|
|
1337
|
+
}
|
|
1338
|
+
};
|
|
1339
|
+
},
|
|
1340
|
+
// HTML 解析
|
|
1341
|
+
parseHTML() {
|
|
1342
|
+
return [
|
|
1343
|
+
{
|
|
1344
|
+
tag: "span[data-mention]"
|
|
1345
|
+
}
|
|
1346
|
+
];
|
|
1347
|
+
},
|
|
1348
|
+
// HTML 渲染
|
|
1349
|
+
renderHTML({ node: e, HTMLAttributes: t }) {
|
|
1350
|
+
return [
|
|
1351
|
+
"span",
|
|
1352
|
+
tt(this.options.HTMLAttributes || {}, t, {
|
|
1353
|
+
"data-mention": "",
|
|
1354
|
+
"data-id": e.attrs.id,
|
|
1355
|
+
"data-label": e.attrs.label,
|
|
1356
|
+
"data-value": e.attrs.value
|
|
1357
|
+
}),
|
|
1358
|
+
`${this.options.char}${e.attrs.label}`
|
|
1359
|
+
];
|
|
1360
|
+
},
|
|
1361
|
+
// 使用 Vue 组件渲染
|
|
1362
|
+
addNodeView() {
|
|
1363
|
+
return Qe(vn);
|
|
1364
|
+
},
|
|
1365
|
+
// 添加 storage 用于存储实例状态
|
|
1366
|
+
addStorage() {
|
|
1367
|
+
return {
|
|
1368
|
+
watchStopHandle: null
|
|
1369
|
+
};
|
|
1370
|
+
},
|
|
1371
|
+
onCreate() {
|
|
1372
|
+
const { items: e } = this.options;
|
|
1373
|
+
_e(e) && (this.storage.watchStopHandle = K(
|
|
1374
|
+
e,
|
|
1375
|
+
() => {
|
|
1376
|
+
const t = this.editor.state.tr;
|
|
1377
|
+
t.setMeta(ue, { type: "mention-update" }), this.editor.view.dispatch(t);
|
|
1378
|
+
},
|
|
1379
|
+
{ deep: !0 }
|
|
1380
|
+
));
|
|
1381
|
+
},
|
|
1382
|
+
onDestroy() {
|
|
1383
|
+
this.storage.watchStopHandle && (this.storage.watchStopHandle(), this.storage.watchStopHandle = null);
|
|
1384
|
+
},
|
|
1385
|
+
// 添加 Suggestion 插件
|
|
1386
|
+
addProseMirrorPlugins() {
|
|
1387
|
+
return [
|
|
1388
|
+
xo({
|
|
1389
|
+
editor: this.editor,
|
|
1390
|
+
char: this.options.char,
|
|
1391
|
+
items: this.options.items,
|
|
1392
|
+
allowSpaces: this.options.allowSpaces || !1
|
|
1393
|
+
})
|
|
1394
|
+
];
|
|
1395
|
+
},
|
|
1396
|
+
// 配置选项
|
|
1397
|
+
addOptions() {
|
|
1398
|
+
return {
|
|
1399
|
+
items: [],
|
|
1400
|
+
char: "@"
|
|
1401
|
+
};
|
|
1402
|
+
},
|
|
1403
|
+
// 自定义命令
|
|
1404
|
+
addCommands() {
|
|
1405
|
+
return To;
|
|
1406
|
+
}
|
|
1407
|
+
});
|
|
1408
|
+
function vo(e) {
|
|
1409
|
+
var i;
|
|
1410
|
+
const t = e.extensionManager.extensions.find((s) => s.name === xe.MENTION), n = ((i = t == null ? void 0 : t.options) == null ? void 0 : i.char) || "@";
|
|
1411
|
+
let o = "";
|
|
1412
|
+
return e.state.doc.descendants((s) => {
|
|
1413
|
+
s.type.name === A.MENTION ? o += `${n}${s.attrs.label}` : s.type.name === A.TEXT && (o += s.text || "");
|
|
1414
|
+
}), o.trim();
|
|
1415
|
+
}
|
|
1416
|
+
function Eo(e) {
|
|
1417
|
+
const t = [];
|
|
1418
|
+
return e.state.doc.descendants((n, o, i) => {
|
|
1419
|
+
if (i && i.type.name === A.PARAGRAPH) {
|
|
1420
|
+
if (n.type.name === A.MENTION)
|
|
1421
|
+
t.push({
|
|
1422
|
+
type: U.MENTION,
|
|
1423
|
+
content: n.attrs.label,
|
|
1424
|
+
value: n.attrs.value || ""
|
|
1425
|
+
});
|
|
1426
|
+
else if (n.type.name === A.TEXT) {
|
|
1427
|
+
const s = n.text || "";
|
|
1428
|
+
if (s) {
|
|
1429
|
+
const l = t[t.length - 1];
|
|
1430
|
+
l && l.type === U.TEXT ? l.content = (l.content || "") + s : t.push({
|
|
1431
|
+
type: U.TEXT,
|
|
1432
|
+
content: s
|
|
1433
|
+
});
|
|
1434
|
+
}
|
|
1435
|
+
}
|
|
1436
|
+
}
|
|
1437
|
+
}), t;
|
|
1438
|
+
}
|
|
1439
|
+
function wo(e, t = "@", n) {
|
|
1440
|
+
return Ht.configure({
|
|
1441
|
+
items: e,
|
|
1442
|
+
char: t,
|
|
1443
|
+
...n
|
|
1444
|
+
});
|
|
1445
|
+
}
|
|
1446
|
+
const Ft = (e, t) => {
|
|
1447
|
+
if (!t.length)
|
|
1448
|
+
return [{ text: e, isMatch: !1 }];
|
|
1449
|
+
const n = [];
|
|
1450
|
+
for (const l of t) {
|
|
1451
|
+
if (!l) continue;
|
|
1452
|
+
let r = 0;
|
|
1453
|
+
const a = e.toLowerCase(), c = l.toLowerCase();
|
|
1454
|
+
for (; ; ) {
|
|
1455
|
+
const f = a.indexOf(c, r);
|
|
1456
|
+
if (f === -1) break;
|
|
1457
|
+
n.push({
|
|
1458
|
+
start: f,
|
|
1459
|
+
end: f + l.length
|
|
1460
|
+
}), r = f + 1;
|
|
1461
|
+
}
|
|
1462
|
+
}
|
|
1463
|
+
if (n.length === 0)
|
|
1464
|
+
return [{ text: e, isMatch: !1 }];
|
|
1465
|
+
n.sort((l, r) => l.start - r.start);
|
|
1466
|
+
const o = [];
|
|
1467
|
+
for (const l of n)
|
|
1468
|
+
if (o.length === 0)
|
|
1469
|
+
o.push(l);
|
|
1470
|
+
else {
|
|
1471
|
+
const r = o[o.length - 1];
|
|
1472
|
+
l.start <= r.end ? r.end = Math.max(r.end, l.end) : o.push(l);
|
|
1473
|
+
}
|
|
1474
|
+
const i = [];
|
|
1475
|
+
let s = 0;
|
|
1476
|
+
for (const l of o)
|
|
1477
|
+
s < l.start && i.push({
|
|
1478
|
+
text: e.substring(s, l.start),
|
|
1479
|
+
isMatch: !1
|
|
1480
|
+
}), i.push({
|
|
1481
|
+
text: e.substring(l.start, l.end),
|
|
1482
|
+
isMatch: !0
|
|
1483
|
+
}), s = l.end;
|
|
1484
|
+
return s < e.length && i.push({
|
|
1485
|
+
text: e.substring(s),
|
|
1486
|
+
isMatch: !1
|
|
1487
|
+
}), i;
|
|
1488
|
+
}, bo = (e, t) => !t || !e ? [{ text: e, isMatch: !1 }] : Ft(e, [t]), So = (e, t) => {
|
|
1489
|
+
const { content: n, highlights: o } = e;
|
|
1490
|
+
return typeof o == "function" ? o(n, t) : Array.isArray(o) ? Ft(n, o) : bo(n, t);
|
|
1491
|
+
}, Ao = ["onMouseenter", "onClick"], Co = { class: "suggestion-list__text" }, _o = /* @__PURE__ */ j({
|
|
1492
|
+
__name: "suggestion-list",
|
|
1493
|
+
props: {
|
|
1494
|
+
show: { type: Boolean },
|
|
1495
|
+
suggestions: {},
|
|
1496
|
+
popupStyle: {},
|
|
1497
|
+
activeKeyboardIndex: {},
|
|
1498
|
+
activeMouseIndex: {},
|
|
1499
|
+
inputValue: {},
|
|
1500
|
+
onSelect: { type: Function },
|
|
1501
|
+
onMouseEnter: { type: Function },
|
|
1502
|
+
onMouseLeave: { type: Function }
|
|
1503
|
+
},
|
|
1504
|
+
setup(e) {
|
|
1505
|
+
const t = e, n = V(null), o = (r) => r === t.activeKeyboardIndex || r === t.activeMouseIndex, i = (r) => {
|
|
1506
|
+
var a;
|
|
1507
|
+
(a = t.onMouseEnter) == null || a.call(t, r);
|
|
1508
|
+
}, s = () => {
|
|
1509
|
+
var r;
|
|
1510
|
+
(r = t.onMouseLeave) == null || r.call(t);
|
|
1511
|
+
}, l = (r) => {
|
|
1512
|
+
var c;
|
|
1513
|
+
const a = t.suggestions[r];
|
|
1514
|
+
a && ((c = t.onSelect) == null || c.call(t, Zt(a)));
|
|
1515
|
+
};
|
|
1516
|
+
return K(
|
|
1517
|
+
() => t.activeKeyboardIndex,
|
|
1518
|
+
(r) => {
|
|
1519
|
+
if (r !== -1 && n.value) {
|
|
1520
|
+
const a = n.value.children[r];
|
|
1521
|
+
a && a.scrollIntoView({ block: "nearest" });
|
|
1522
|
+
}
|
|
1523
|
+
}
|
|
1524
|
+
), (r, a) => (M(), G(Yt, { name: "suggestion-slide-up" }, {
|
|
1525
|
+
default: $(() => [
|
|
1526
|
+
t.show && t.suggestions.length ? (M(), O("div", {
|
|
1527
|
+
key: 0,
|
|
1528
|
+
ref_key: "suggestionsListRef",
|
|
1529
|
+
ref: n,
|
|
1530
|
+
class: "suggestion-list",
|
|
1531
|
+
style: jt(t.popupStyle)
|
|
1532
|
+
}, [
|
|
1533
|
+
(M(!0), O(De, null, Be(t.suggestions, (c, f) => (M(), O("div", {
|
|
1534
|
+
key: f,
|
|
1535
|
+
class: ee(["suggestion-list__item", { highlighted: o(f) }]),
|
|
1536
|
+
onMouseenter: (u) => i(f),
|
|
1537
|
+
onMouseleave: s,
|
|
1538
|
+
onClick: (u) => l(f)
|
|
1539
|
+
}, [
|
|
1540
|
+
oe(L(yn), { class: "suggestion-list__icon" }),
|
|
1541
|
+
k("span", Co, [
|
|
1542
|
+
(M(!0), O(De, null, Be(L(So)(c, t.inputValue), (u, T) => (M(), O("span", {
|
|
1543
|
+
key: T,
|
|
1544
|
+
class: ee({
|
|
1545
|
+
"suggestion-list__text--match": u.isMatch,
|
|
1546
|
+
"suggestion-list__text--normal": !u.isMatch
|
|
1547
|
+
})
|
|
1548
|
+
}, fe(u.text), 3))), 128))
|
|
1549
|
+
])
|
|
1550
|
+
], 42, Ao))), 128))
|
|
1551
|
+
], 4)) : W("", !0)
|
|
1552
|
+
]),
|
|
1553
|
+
_: 1
|
|
1554
|
+
}));
|
|
1555
|
+
}
|
|
1556
|
+
}), Lo = /* @__PURE__ */ Z(_o, [["__scopeId", "data-v-76a6f35e"]]), Mo = (e, t) => {
|
|
1557
|
+
if (!e || !t)
|
|
1558
|
+
return { text: "", show: !1, showTab: !1 };
|
|
1559
|
+
const n = e.toLowerCase(), o = t.toLowerCase();
|
|
1560
|
+
if (!n.startsWith(o))
|
|
1561
|
+
return { text: "", show: !1, showTab: !1 };
|
|
1562
|
+
const i = e.substring(t.length), s = i.length > 0;
|
|
1563
|
+
return {
|
|
1564
|
+
text: i,
|
|
1565
|
+
show: s,
|
|
1566
|
+
showTab: s
|
|
1567
|
+
};
|
|
1568
|
+
}, F = new re(le.SUGGESTION);
|
|
1569
|
+
function Oo(e) {
|
|
1570
|
+
const {
|
|
1571
|
+
editor: t,
|
|
1572
|
+
activeSuggestionKeys: n = ["Enter"],
|
|
1573
|
+
popupWidth: o = 400,
|
|
1574
|
+
showAutoComplete: i = !0,
|
|
1575
|
+
filterFn: s,
|
|
1576
|
+
onSelect: l
|
|
1577
|
+
} = e;
|
|
1578
|
+
let r = null, a = null, c = null, f = !1;
|
|
1579
|
+
function u() {
|
|
1580
|
+
const m = t.extensionManager.extensions.find(
|
|
1581
|
+
(x) => x.name === xe.SUGGESTION
|
|
1582
|
+
), p = m == null ? void 0 : m.options, d = (p == null ? void 0 : p.items) || (p == null ? void 0 : p.suggestions) || [];
|
|
1583
|
+
return d && typeof d == "object" && "value" in d ? d.value : d;
|
|
1584
|
+
}
|
|
1585
|
+
function T(m) {
|
|
1586
|
+
const p = u();
|
|
1587
|
+
return s ? s(p, m) : p;
|
|
1588
|
+
}
|
|
1589
|
+
function y(m) {
|
|
1590
|
+
return m;
|
|
1591
|
+
}
|
|
1592
|
+
function w(m, p, d) {
|
|
1593
|
+
if (m === -1 || !d[m])
|
|
1594
|
+
return { text: "", show: !1, showTab: !1 };
|
|
1595
|
+
const x = d[m];
|
|
1596
|
+
return Mo(x.content, p);
|
|
1597
|
+
}
|
|
1598
|
+
function b(m, p, d) {
|
|
1599
|
+
if (!p) return;
|
|
1600
|
+
(l == null ? void 0 : l(d)) !== !1 && t.commands.setContent(d.content), t.commands.focus();
|
|
1601
|
+
}
|
|
1602
|
+
function v(m, p) {
|
|
1603
|
+
const d = p.filteredSuggestions[p.selectedIndex];
|
|
1604
|
+
d && b(m, p.range, d);
|
|
1605
|
+
const x = m.state.tr;
|
|
1606
|
+
x.setMeta(F, { type: "close" }), m.dispatch(x);
|
|
1607
|
+
}
|
|
1608
|
+
function h(m, p) {
|
|
1609
|
+
c == null || c();
|
|
1610
|
+
const x = m.dom.closest(".tr-sender") || m.dom, E = () => {
|
|
1611
|
+
if (typeof o == "number")
|
|
1612
|
+
return `${o}px`;
|
|
1613
|
+
if (typeof o == "string") {
|
|
1614
|
+
if (o.endsWith("%")) {
|
|
1615
|
+
const _ = parseFloat(o) / 100;
|
|
1616
|
+
return `${x.offsetWidth * _}px`;
|
|
1617
|
+
}
|
|
1618
|
+
return o;
|
|
1619
|
+
}
|
|
1620
|
+
return "400px";
|
|
1621
|
+
};
|
|
1622
|
+
c = rt(x, p, () => {
|
|
1623
|
+
ct(x, p, {
|
|
1624
|
+
placement: "top-start",
|
|
1625
|
+
middleware: [
|
|
1626
|
+
it(8),
|
|
1627
|
+
at({
|
|
1628
|
+
fallbackPlacements: ["bottom-start", "top-start"]
|
|
1629
|
+
}),
|
|
1630
|
+
lt({ padding: 8 })
|
|
1631
|
+
]
|
|
1632
|
+
}).then(({ x: _, y: C }) => {
|
|
1633
|
+
p.style.position = "absolute", p.style.left = `${_}px`, p.style.top = `${C}px`, p.style.zIndex = "2000", p.style.width = E();
|
|
1634
|
+
});
|
|
1635
|
+
});
|
|
1636
|
+
}
|
|
1637
|
+
function g(m) {
|
|
1638
|
+
if (!i || !m.active || !m.autoCompleteText || !m.range)
|
|
1639
|
+
return Ce.empty;
|
|
1640
|
+
const p = t.state.doc, { selection: d } = t.state, x = d.$head.pos;
|
|
1641
|
+
if (!(x >= p.content.size - 1))
|
|
1642
|
+
return Ce.empty;
|
|
1643
|
+
const _ = Ct.widget(
|
|
1644
|
+
x,
|
|
1645
|
+
() => {
|
|
1646
|
+
const C = document.createElement("span");
|
|
1647
|
+
C.className = "suggestion-autocomplete", C.contentEditable = "false";
|
|
1648
|
+
const I = document.createElement("span");
|
|
1649
|
+
if (I.className = "autocomplete-text", I.textContent = m.autoCompleteText, C.appendChild(I), m.showTabIndicator) {
|
|
1650
|
+
const Q = document.createElement("span");
|
|
1651
|
+
Q.className = "tab-hint", Q.textContent = "TAB", C.appendChild(Q);
|
|
1652
|
+
}
|
|
1653
|
+
return C;
|
|
1654
|
+
},
|
|
1655
|
+
{
|
|
1656
|
+
side: 1
|
|
1657
|
+
// 显示在光标右侧
|
|
1658
|
+
}
|
|
1659
|
+
);
|
|
1660
|
+
return Ce.create(p, [_]);
|
|
1661
|
+
}
|
|
1662
|
+
return new ie({
|
|
1663
|
+
key: F,
|
|
1664
|
+
state: {
|
|
1665
|
+
init() {
|
|
1666
|
+
return {
|
|
1667
|
+
active: !1,
|
|
1668
|
+
range: null,
|
|
1669
|
+
query: "",
|
|
1670
|
+
filteredSuggestions: [],
|
|
1671
|
+
selectedIndex: -1,
|
|
1672
|
+
autoCompleteText: "",
|
|
1673
|
+
showTabIndicator: !1
|
|
1674
|
+
};
|
|
1675
|
+
},
|
|
1676
|
+
apply(m, p) {
|
|
1677
|
+
const d = m.getMeta(F);
|
|
1678
|
+
if (d) {
|
|
1679
|
+
if (d.type === "close")
|
|
1680
|
+
return f = !0, setTimeout(() => {
|
|
1681
|
+
f = !1;
|
|
1682
|
+
}, 0), {
|
|
1683
|
+
active: !1,
|
|
1684
|
+
range: null,
|
|
1685
|
+
query: "",
|
|
1686
|
+
filteredSuggestions: [],
|
|
1687
|
+
selectedIndex: -1,
|
|
1688
|
+
autoCompleteText: "",
|
|
1689
|
+
showTabIndicator: !1
|
|
1690
|
+
};
|
|
1691
|
+
if (d.type === "updateIndex") {
|
|
1692
|
+
const I = { ...p, selectedIndex: d.index }, Q = w(d.index, p.query, p.filteredSuggestions);
|
|
1693
|
+
return {
|
|
1694
|
+
...I,
|
|
1695
|
+
autoCompleteText: Q.text,
|
|
1696
|
+
showTabIndicator: Q.showTab
|
|
1697
|
+
};
|
|
1698
|
+
}
|
|
1699
|
+
}
|
|
1700
|
+
if (f || !m.docChanged && !m.selectionSet)
|
|
1701
|
+
return p;
|
|
1702
|
+
const x = m.doc.textContent.trim(), E = x;
|
|
1703
|
+
if (!x)
|
|
1704
|
+
return {
|
|
1705
|
+
active: !1,
|
|
1706
|
+
range: null,
|
|
1707
|
+
query: "",
|
|
1708
|
+
filteredSuggestions: [],
|
|
1709
|
+
selectedIndex: -1,
|
|
1710
|
+
autoCompleteText: "",
|
|
1711
|
+
showTabIndicator: !1
|
|
1712
|
+
};
|
|
1713
|
+
const _ = T(E);
|
|
1714
|
+
if (_.length === 0)
|
|
1715
|
+
return {
|
|
1716
|
+
active: !1,
|
|
1717
|
+
range: null,
|
|
1718
|
+
query: "",
|
|
1719
|
+
filteredSuggestions: [],
|
|
1720
|
+
selectedIndex: -1,
|
|
1721
|
+
autoCompleteText: "",
|
|
1722
|
+
showTabIndicator: !1
|
|
1723
|
+
};
|
|
1724
|
+
const C = w(0, E, _);
|
|
1725
|
+
return {
|
|
1726
|
+
active: !0,
|
|
1727
|
+
range: { from: 0, to: m.doc.content.size },
|
|
1728
|
+
query: E,
|
|
1729
|
+
filteredSuggestions: _,
|
|
1730
|
+
selectedIndex: 0,
|
|
1731
|
+
autoCompleteText: C.text,
|
|
1732
|
+
showTabIndicator: C.showTab
|
|
1733
|
+
};
|
|
1734
|
+
}
|
|
1735
|
+
},
|
|
1736
|
+
props: {
|
|
1737
|
+
decorations(m) {
|
|
1738
|
+
const p = this.getState(m);
|
|
1739
|
+
return g(
|
|
1740
|
+
p || {
|
|
1741
|
+
active: !1,
|
|
1742
|
+
range: null,
|
|
1743
|
+
autoCompleteText: "",
|
|
1744
|
+
showTabIndicator: !1
|
|
1745
|
+
}
|
|
1746
|
+
);
|
|
1747
|
+
},
|
|
1748
|
+
handleKeyDown(m, p) {
|
|
1749
|
+
const d = F.getState(m.state);
|
|
1750
|
+
if (!(d != null && d.active))
|
|
1751
|
+
return !1;
|
|
1752
|
+
if (D(p, "TAB") && d.autoCompleteText)
|
|
1753
|
+
return p.preventDefault(), v(m, d), !0;
|
|
1754
|
+
if (we(p, ["ARROW_UP", "ARROW_DOWN"])) {
|
|
1755
|
+
p.preventDefault();
|
|
1756
|
+
const x = D(p, "ARROW_DOWN") ? 1 : -1, E = d.filteredSuggestions.length;
|
|
1757
|
+
let _ = d.selectedIndex + x;
|
|
1758
|
+
_ < 0 ? _ = E - 1 : _ >= E && (_ = 0);
|
|
1759
|
+
const C = m.state.tr;
|
|
1760
|
+
return C.setMeta(F, {
|
|
1761
|
+
type: "updateIndex",
|
|
1762
|
+
index: _
|
|
1763
|
+
}), m.dispatch(C), !0;
|
|
1764
|
+
}
|
|
1765
|
+
if (n.includes(p.key))
|
|
1766
|
+
return p.preventDefault(), v(m, d), !0;
|
|
1767
|
+
if (D(p, "ESCAPE")) {
|
|
1768
|
+
p.preventDefault();
|
|
1769
|
+
const x = m.state.tr;
|
|
1770
|
+
return x.setMeta(F, { type: "close" }), m.dispatch(x), !0;
|
|
1771
|
+
}
|
|
1772
|
+
return !1;
|
|
1773
|
+
}
|
|
1774
|
+
},
|
|
1775
|
+
view() {
|
|
1776
|
+
return {
|
|
1777
|
+
update(m) {
|
|
1778
|
+
const p = F.getState(m.state);
|
|
1779
|
+
p != null && p.active && p.filteredSuggestions.length > 0 ? (r ? r.updateProps({
|
|
1780
|
+
show: p.active && p.filteredSuggestions.length > 0,
|
|
1781
|
+
suggestions: p.filteredSuggestions,
|
|
1782
|
+
popupStyle: {
|
|
1783
|
+
// 宽度在 computePosition 回调中动态设置,这里只设置 maxWidth
|
|
1784
|
+
maxWidth: "100%"
|
|
1785
|
+
},
|
|
1786
|
+
activeKeyboardIndex: p.selectedIndex,
|
|
1787
|
+
inputValue: p.query
|
|
1788
|
+
}) : (r = new At(Lo, {
|
|
1789
|
+
props: {
|
|
1790
|
+
show: p.active && p.filteredSuggestions.length > 0,
|
|
1791
|
+
suggestions: p.filteredSuggestions,
|
|
1792
|
+
popupStyle: {
|
|
1793
|
+
// 宽度在 computePosition 回调中动态设置,这里只设置 maxWidth
|
|
1794
|
+
maxWidth: "100%"
|
|
1795
|
+
},
|
|
1796
|
+
activeKeyboardIndex: p.selectedIndex,
|
|
1797
|
+
activeMouseIndex: -1,
|
|
1798
|
+
inputValue: p.query,
|
|
1799
|
+
onSelect: (d) => {
|
|
1800
|
+
b(m, p.range, d);
|
|
1801
|
+
const x = m.state.tr;
|
|
1802
|
+
x.setMeta(F, { type: "close" }), m.dispatch(x);
|
|
1803
|
+
},
|
|
1804
|
+
onMouseEnter: (d) => {
|
|
1805
|
+
const x = m.state.tr;
|
|
1806
|
+
x.setMeta(F, { type: "updateIndex", index: d }), m.dispatch(x);
|
|
1807
|
+
}
|
|
1808
|
+
},
|
|
1809
|
+
editor: t
|
|
1810
|
+
}), a = r.element, document.body.appendChild(a)), a && h(m, a)) : (r && (c == null || c(), c = null, r.destroy(), r = null), a && (a.remove(), a = null));
|
|
1811
|
+
},
|
|
1812
|
+
destroy() {
|
|
1813
|
+
c == null || c(), r == null || r.destroy(), a == null || a.remove();
|
|
1814
|
+
}
|
|
1815
|
+
};
|
|
1816
|
+
}
|
|
1817
|
+
});
|
|
1818
|
+
}
|
|
1819
|
+
const Vt = _t.create({
|
|
1820
|
+
name: xe.SUGGESTION,
|
|
1821
|
+
addOptions() {
|
|
1822
|
+
return {
|
|
1823
|
+
items: [],
|
|
1824
|
+
activeSuggestionKeys: ["Enter"],
|
|
1825
|
+
popupWidth: 400,
|
|
1826
|
+
showAutoComplete: !0
|
|
1827
|
+
};
|
|
1828
|
+
},
|
|
1829
|
+
// 添加 storage 用于存储实例状态
|
|
1830
|
+
addStorage() {
|
|
1831
|
+
return {
|
|
1832
|
+
watchStopHandle: null
|
|
1833
|
+
};
|
|
1834
|
+
},
|
|
1835
|
+
onCreate() {
|
|
1836
|
+
_e(this.options.items) && (this.storage.watchStopHandle = K(
|
|
1837
|
+
this.options.items,
|
|
1838
|
+
() => {
|
|
1839
|
+
const e = this.editor.state.tr;
|
|
1840
|
+
e.setMeta(F, { type: "update" }), this.editor.view.dispatch(e);
|
|
1841
|
+
},
|
|
1842
|
+
{ deep: !0 }
|
|
1843
|
+
));
|
|
1844
|
+
},
|
|
1845
|
+
onDestroy() {
|
|
1846
|
+
this.storage.watchStopHandle && (this.storage.watchStopHandle(), this.storage.watchStopHandle = null);
|
|
1847
|
+
},
|
|
1848
|
+
addProseMirrorPlugins() {
|
|
1849
|
+
return [
|
|
1850
|
+
Oo({
|
|
1851
|
+
editor: this.editor,
|
|
1852
|
+
...this.options
|
|
1853
|
+
})
|
|
1854
|
+
];
|
|
120
1855
|
}
|
|
1856
|
+
});
|
|
1857
|
+
function Po(e, t) {
|
|
1858
|
+
return Vt.configure({
|
|
1859
|
+
items: e,
|
|
1860
|
+
...t
|
|
1861
|
+
});
|
|
1862
|
+
}
|
|
1863
|
+
function Ro(e) {
|
|
1864
|
+
const t = [];
|
|
1865
|
+
return e.state.doc.descendants((n, o) => {
|
|
1866
|
+
n.type.name === A.TEMPLATE_BLOCK && t.push({ node: n, pos: o });
|
|
1867
|
+
}), t;
|
|
1868
|
+
}
|
|
1869
|
+
const Do = {
|
|
121
1870
|
/**
|
|
122
|
-
*
|
|
1871
|
+
* 设置模板数据(批量)
|
|
123
1872
|
*/
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
1873
|
+
setTemplateData: (e) => ({ commands: t }) => {
|
|
1874
|
+
t.clearContent();
|
|
1875
|
+
const n = [];
|
|
1876
|
+
return e.forEach((o) => {
|
|
1877
|
+
o.type === U.TEXT ? o.content && n.push({
|
|
1878
|
+
type: A.TEXT,
|
|
1879
|
+
text: o.content
|
|
1880
|
+
}) : o.type === U.BLOCK ? n.push({
|
|
1881
|
+
type: A.TEMPLATE_BLOCK,
|
|
1882
|
+
attrs: {
|
|
1883
|
+
id: o.id || Te("template"),
|
|
1884
|
+
content: o.content
|
|
1885
|
+
},
|
|
1886
|
+
content: o.content ? [
|
|
1887
|
+
{
|
|
1888
|
+
type: A.TEXT,
|
|
1889
|
+
text: o.content
|
|
1890
|
+
}
|
|
1891
|
+
] : []
|
|
1892
|
+
}) : o.type === U.SELECT && n.push({
|
|
1893
|
+
type: A.TEMPLATE_SELECT,
|
|
1894
|
+
attrs: {
|
|
1895
|
+
id: o.id || Te("select"),
|
|
1896
|
+
placeholder: o.placeholder,
|
|
1897
|
+
options: o.options,
|
|
1898
|
+
value: o.value || null
|
|
1899
|
+
}
|
|
1900
|
+
});
|
|
1901
|
+
}), n.length > 0 && t.insertContent({
|
|
1902
|
+
type: A.PARAGRAPH,
|
|
1903
|
+
content: n
|
|
1904
|
+
}), !0;
|
|
1905
|
+
},
|
|
127
1906
|
/**
|
|
128
|
-
*
|
|
129
|
-
* @param callbacks 语音识别回调函数集合
|
|
1907
|
+
* 插入模板块
|
|
130
1908
|
*/
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
1909
|
+
insertTemplate: (e) => ({ commands: t }) => {
|
|
1910
|
+
const n = e.content || "";
|
|
1911
|
+
return t.insertContent({
|
|
1912
|
+
type: A.TEMPLATE_BLOCK,
|
|
1913
|
+
attrs: {
|
|
1914
|
+
id: e.id || Te("template"),
|
|
1915
|
+
content: n
|
|
1916
|
+
},
|
|
1917
|
+
content: n ? [
|
|
1918
|
+
{
|
|
1919
|
+
type: A.TEXT,
|
|
1920
|
+
text: n
|
|
1921
|
+
}
|
|
1922
|
+
] : []
|
|
141
1923
|
});
|
|
142
|
-
}
|
|
1924
|
+
},
|
|
143
1925
|
/**
|
|
144
|
-
*
|
|
1926
|
+
* 聚焦到第一个模板块
|
|
145
1927
|
*/
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
1928
|
+
focusFirstTemplate: () => ({ editor: e }) => {
|
|
1929
|
+
const t = Ro(e);
|
|
1930
|
+
return setTimeout(() => {
|
|
1931
|
+
var s;
|
|
1932
|
+
const { state: n, view: o } = e, i = n.tr;
|
|
1933
|
+
try {
|
|
1934
|
+
let l;
|
|
1935
|
+
if (t.length === 0)
|
|
1936
|
+
l = n.doc.content.size - 1;
|
|
1937
|
+
else {
|
|
1938
|
+
const { node: a, pos: c } = t[0], f = ((s = a.textContent) == null ? void 0 : s.length) || 0;
|
|
1939
|
+
l = c + 1 + f;
|
|
1940
|
+
}
|
|
1941
|
+
const r = P.create(n.doc, l);
|
|
1942
|
+
i.setSelection(r), o.dispatch(i), o.focus();
|
|
1943
|
+
} catch (l) {
|
|
1944
|
+
console.error("[focusFirstTemplate] 设置光标失败", l);
|
|
1945
|
+
}
|
|
1946
|
+
}, 0), !0;
|
|
1947
|
+
},
|
|
149
1948
|
/**
|
|
150
|
-
*
|
|
151
|
-
* @param callbacks 语音识别回调函数集合
|
|
1949
|
+
* 插入选择器
|
|
152
1950
|
*/
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
1951
|
+
insertTemplateSelect: (e) => ({ commands: t }) => t.insertContent({
|
|
1952
|
+
type: A.TEMPLATE_SELECT,
|
|
1953
|
+
attrs: {
|
|
1954
|
+
id: e.id || Te("select"),
|
|
1955
|
+
placeholder: e.placeholder || "Please select",
|
|
1956
|
+
options: e.options || [],
|
|
1957
|
+
value: e.value || null
|
|
157
1958
|
}
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
1959
|
+
})
|
|
1960
|
+
}, S = "";
|
|
1961
|
+
function Ge(e) {
|
|
1962
|
+
return zt(e).map((n) => n.content).join("");
|
|
1963
|
+
}
|
|
1964
|
+
function zt(e) {
|
|
1965
|
+
const t = [];
|
|
1966
|
+
return e.state.doc.descendants((n, o, i) => {
|
|
1967
|
+
if (i && i.type.name === A.PARAGRAPH) {
|
|
1968
|
+
if (n.type.name === A.TEMPLATE_BLOCK) {
|
|
1969
|
+
const s = (n.textContent || "").replace(new RegExp(S, "g"), "");
|
|
1970
|
+
t.push({
|
|
1971
|
+
type: U.BLOCK,
|
|
1972
|
+
content: s
|
|
1973
|
+
});
|
|
1974
|
+
} else if (n.type.name === A.TEMPLATE_SELECT) {
|
|
1975
|
+
const s = n.attrs.options.find((r) => r.value === n.attrs.value), l = (s == null ? void 0 : s.value) || "";
|
|
1976
|
+
t.push({
|
|
1977
|
+
type: U.SELECT,
|
|
1978
|
+
content: l
|
|
1979
|
+
});
|
|
1980
|
+
} else if (n.type.name === A.TEXT) {
|
|
1981
|
+
const s = (n.text || "").replace(new RegExp(S, "g"), "");
|
|
1982
|
+
if (s) {
|
|
1983
|
+
const l = t[t.length - 1];
|
|
1984
|
+
l && l.type === U.TEXT ? l.content += s : t.push({
|
|
1985
|
+
type: U.TEXT,
|
|
1986
|
+
content: s
|
|
1987
|
+
});
|
|
1988
|
+
}
|
|
1989
|
+
}
|
|
163
1990
|
}
|
|
1991
|
+
}), t;
|
|
1992
|
+
}
|
|
1993
|
+
const Bo = /* @__PURE__ */ j({
|
|
1994
|
+
__name: "template-block-view",
|
|
1995
|
+
props: {
|
|
1996
|
+
node: {}
|
|
1997
|
+
},
|
|
1998
|
+
setup(e) {
|
|
1999
|
+
const t = e, n = B(() => {
|
|
2000
|
+
const o = t.node.textContent || "";
|
|
2001
|
+
return o.length === 0 || o === S;
|
|
2002
|
+
});
|
|
2003
|
+
return (o, i) => (M(), G(L(Je), {
|
|
2004
|
+
as: "span",
|
|
2005
|
+
class: ee(["template-block", { "is-empty": n.value }]),
|
|
2006
|
+
"data-id": e.node.attrs.id
|
|
2007
|
+
}, {
|
|
2008
|
+
default: $(() => [
|
|
2009
|
+
i[0] || (i[0] = k("span", {
|
|
2010
|
+
contenteditable: "false",
|
|
2011
|
+
class: "template-block__prefix"
|
|
2012
|
+
}, " ", -1)),
|
|
2013
|
+
oe(L(sn), {
|
|
2014
|
+
as: "span",
|
|
2015
|
+
class: "template-block__content"
|
|
2016
|
+
}),
|
|
2017
|
+
i[1] || (i[1] = k("span", {
|
|
2018
|
+
contenteditable: "false",
|
|
2019
|
+
class: "template-block__suffix"
|
|
2020
|
+
}, " ", -1))
|
|
2021
|
+
]),
|
|
2022
|
+
_: 1
|
|
2023
|
+
}, 8, ["class", "data-id"]));
|
|
164
2024
|
}
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
2025
|
+
}), ko = /* @__PURE__ */ Z(Bo, [["__scopeId", "data-v-aa55b9db"]]);
|
|
2026
|
+
function Io(e) {
|
|
2027
|
+
const t = [];
|
|
2028
|
+
let { tr: n } = e;
|
|
2029
|
+
return e.doc.descendants((o, i, s) => {
|
|
2030
|
+
if (o.type.name === A.PARAGRAPH && o.childCount > 0) {
|
|
2031
|
+
const { lastChild: l, firstChild: r } = o;
|
|
2032
|
+
if (r && r.type.name === A.TEMPLATE_BLOCK && t.push(i + 1), l && l.type.name === A.TEMPLATE_BLOCK) {
|
|
2033
|
+
const a = i + o.nodeSize - 1;
|
|
2034
|
+
n.doc.textBetween(a - 1, a, "", "") !== S && t.push(a);
|
|
2035
|
+
}
|
|
2036
|
+
l === r && l && l.isText && l.text === S && t.push(["remove", i + 1]);
|
|
2037
|
+
}
|
|
2038
|
+
if (o.type.name === A.TEMPLATE_BLOCK && o.content.size === 0 && t.push(i + 1), o.type.name === A.TEMPLATE_BLOCK && s) {
|
|
2039
|
+
let l = -1;
|
|
2040
|
+
if (s.forEach((r, a, c) => {
|
|
2041
|
+
r === o && (l = c);
|
|
2042
|
+
}), l > -1 && l < s.childCount - 1 && s.child(l + 1).type.name === A.TEMPLATE_BLOCK) {
|
|
2043
|
+
const a = i + o.nodeSize;
|
|
2044
|
+
n.doc.textBetween(a, a + 1, "", "") !== S && t.push(a);
|
|
2045
|
+
}
|
|
2046
|
+
}
|
|
2047
|
+
}), t.length > 0 ? (t.sort((o, i) => {
|
|
2048
|
+
const s = Array.isArray(o) ? o[1] : o;
|
|
2049
|
+
return (Array.isArray(i) ? i[1] : i) - s;
|
|
2050
|
+
}).forEach((o) => {
|
|
2051
|
+
Array.isArray(o) && o[0] === "remove" ? n = n.delete(o[1], o[1] + 1) : typeof o == "number" && (n = n.insertText(S, o, o));
|
|
2052
|
+
}), n) : null;
|
|
2053
|
+
}
|
|
2054
|
+
function $o() {
|
|
2055
|
+
return new ie({
|
|
2056
|
+
key: new re(le.TEMPLATE_BLOCK_ZERO_WIDTH),
|
|
2057
|
+
appendTransaction(e, t, n) {
|
|
2058
|
+
return e.some((i) => i.docChanged) ? Io(n) : null;
|
|
2059
|
+
}
|
|
2060
|
+
});
|
|
2061
|
+
}
|
|
2062
|
+
function No() {
|
|
2063
|
+
return new ie({
|
|
2064
|
+
key: new re(le.TEMPLATE_BLOCK_KEYBOARD),
|
|
2065
|
+
props: {
|
|
2066
|
+
handleKeyDown(e, t) {
|
|
2067
|
+
var r, a, c, f, u, T, y, w, b;
|
|
2068
|
+
const { state: n, dispatch: o } = e, { selection: i } = n, { $from: s } = i;
|
|
2069
|
+
if (D(t, "ARROW_LEFT") && s.nodeBefore && s.nodeBefore.isText && s.nodeBefore.text && s.nodeBefore.text === S) {
|
|
2070
|
+
const v = s.parent, h = s.index();
|
|
2071
|
+
if (h >= 2) {
|
|
2072
|
+
if (v.child(h - 2).type.name === A.TEMPLATE_BLOCK) {
|
|
2073
|
+
const m = s.pos - 2;
|
|
2074
|
+
return o(n.tr.setSelection(P.create(n.doc, m))), t.preventDefault(), !0;
|
|
2075
|
+
}
|
|
2076
|
+
} else if (h === 1 && s.pos !== 0) {
|
|
2077
|
+
const g = s.before() - 1;
|
|
2078
|
+
if (g >= 0)
|
|
2079
|
+
return o(n.tr.setSelection(P.create(n.doc, g))), t.preventDefault(), !0;
|
|
2080
|
+
}
|
|
2081
|
+
}
|
|
2082
|
+
if (D(t, "ARROW_RIGHT") && s.nodeAfter && s.nodeAfter.isText && s.nodeAfter.text === S) {
|
|
2083
|
+
const v = s.parent, h = s.index();
|
|
2084
|
+
if (h < v.childCount - 1) {
|
|
2085
|
+
if (v.child(h + 1).type.name === A.TEMPLATE_BLOCK) {
|
|
2086
|
+
const m = s.pos + 2;
|
|
2087
|
+
return o(n.tr.setSelection(P.create(n.doc, m))), t.preventDefault(), !0;
|
|
2088
|
+
}
|
|
2089
|
+
} else if (h === v.childCount - 1 && n.doc.lastChild !== s.node()) {
|
|
2090
|
+
const g = s.after() + 1;
|
|
2091
|
+
return o(n.tr.setSelection(P.create(n.doc, g))), t.preventDefault(), !0;
|
|
2092
|
+
}
|
|
2093
|
+
}
|
|
2094
|
+
const l = s.node();
|
|
2095
|
+
if (l.type.name === A.TEMPLATE_BLOCK) {
|
|
2096
|
+
const v = l.textContent || "";
|
|
2097
|
+
if (v === "" || v === S) {
|
|
2098
|
+
if (we(t, ["ARROW_LEFT", "ARROW_RIGHT"])) {
|
|
2099
|
+
const h = D(t, "ARROW_LEFT") ? s.before() : s.after();
|
|
2100
|
+
if (i.from !== h)
|
|
2101
|
+
return o(n.tr.setSelection(P.create(n.doc, h))), t.preventDefault(), !0;
|
|
2102
|
+
}
|
|
2103
|
+
} else {
|
|
2104
|
+
if (D(t, "ARROW_LEFT") && s.pos === s.start()) {
|
|
2105
|
+
const h = s.before();
|
|
2106
|
+
return o(n.tr.setSelection(P.create(n.doc, h))), t.preventDefault(), !0;
|
|
2107
|
+
}
|
|
2108
|
+
if (D(t, "ARROW_RIGHT") && s.pos === s.end()) {
|
|
2109
|
+
const h = s.after();
|
|
2110
|
+
return o(n.tr.setSelection(P.create(n.doc, h))), t.preventDefault(), !0;
|
|
2111
|
+
}
|
|
2112
|
+
}
|
|
2113
|
+
}
|
|
2114
|
+
if (D(t, "BACKSPACE") && i.empty) {
|
|
2115
|
+
const v = s.node(), h = s.nodeBefore;
|
|
2116
|
+
if (v.type.name === A.TEMPLATE_BLOCK) {
|
|
2117
|
+
const g = v.textContent || "";
|
|
2118
|
+
if (s.pos === s.end() && g.length === 1 && g !== S) {
|
|
2119
|
+
const m = s.pos - 1;
|
|
2120
|
+
return o(n.tr.insertText(S, m, m + 1)), t.preventDefault(), !0;
|
|
2121
|
+
}
|
|
2122
|
+
if (g === S) {
|
|
2123
|
+
const m = s.before(), p = n.tr.setSelection(P.create(n.doc, m));
|
|
2124
|
+
return o(p), t.preventDefault(), !0;
|
|
2125
|
+
}
|
|
2126
|
+
if (g === "") {
|
|
2127
|
+
const m = s.before(), p = n.tr.setSelection(P.create(n.doc, m));
|
|
2128
|
+
return o(p), t.preventDefault(), !0;
|
|
2129
|
+
}
|
|
2130
|
+
if (s.pos === s.start() && g.length > 0 && g !== S) {
|
|
2131
|
+
const m = s.before();
|
|
2132
|
+
return o(n.tr.setSelection(P.create(n.doc, m))), t.preventDefault(), !0;
|
|
2133
|
+
}
|
|
2134
|
+
return !1;
|
|
2135
|
+
}
|
|
2136
|
+
if (h && h.isText && ((r = h.text) == null ? void 0 : r.length) === 1 && h.text !== S && s.nodeAfter && s.nodeAfter.type.name === A.TEMPLATE_BLOCK) {
|
|
2137
|
+
const g = s.pos - h.nodeSize, m = s.pos;
|
|
2138
|
+
let p = n.tr.delete(g, m);
|
|
2139
|
+
return p = p.insertText(S, g, g), o(p), t.preventDefault(), !0;
|
|
2140
|
+
}
|
|
2141
|
+
if (h && h.type.name === A.TEMPLATE_BLOCK) {
|
|
2142
|
+
const g = h.textContent || "";
|
|
2143
|
+
if (g.length === 0 || g === S) {
|
|
2144
|
+
const p = s.parent, d = s.index(), x = s.nodeAfter;
|
|
2145
|
+
let E = s.pos - h.nodeSize, _ = s.pos;
|
|
2146
|
+
if (d > 1) {
|
|
2147
|
+
const C = p.child(d - 2);
|
|
2148
|
+
C && C.isText && C.text === S && (E = E - 1);
|
|
2149
|
+
}
|
|
2150
|
+
return x && x.isText && ((a = x.text) != null && a.startsWith(S)) && (_ = _ + 1), o(n.tr.delete(E, _)), t.preventDefault(), !0;
|
|
2151
|
+
} else {
|
|
2152
|
+
const p = s.pos - 1;
|
|
2153
|
+
return o(n.tr.setSelection(P.create(n.doc, p))), t.preventDefault(), !0;
|
|
2154
|
+
}
|
|
2155
|
+
}
|
|
2156
|
+
if (h && h.isText) {
|
|
2157
|
+
const g = s.parent, m = s.index();
|
|
2158
|
+
if (h.text === S) {
|
|
2159
|
+
if (m > 1) {
|
|
2160
|
+
const p = g.child(m - 2);
|
|
2161
|
+
if (p.type.name === A.TEMPLATE_BLOCK) {
|
|
2162
|
+
const d = p.textContent || "";
|
|
2163
|
+
if (d.length === 0 || d === S) {
|
|
2164
|
+
const E = s.pos - h.nodeSize - p.nodeSize, _ = s.nodeAfter;
|
|
2165
|
+
let C = s.pos;
|
|
2166
|
+
return _ && _.isText && _.text === S && (C = C + 1), o(n.tr.delete(E, C)), t.preventDefault(), !0;
|
|
2167
|
+
} else {
|
|
2168
|
+
const E = s.pos - 2;
|
|
2169
|
+
if (E >= 0)
|
|
2170
|
+
return o(n.tr.setSelection(P.create(n.doc, E))), t.preventDefault(), !0;
|
|
2171
|
+
}
|
|
2172
|
+
}
|
|
2173
|
+
}
|
|
2174
|
+
} else if (m === 1 && s.pos !== 1 && h.text === S) {
|
|
2175
|
+
const p = i.from - 1 - 2;
|
|
2176
|
+
if (p >= 0)
|
|
2177
|
+
return o(n.tr.delete(p, i.to)), t.preventDefault(), !0;
|
|
2178
|
+
}
|
|
2179
|
+
}
|
|
2180
|
+
}
|
|
2181
|
+
if (D(t, "BACKSPACE") && !i.empty) {
|
|
2182
|
+
let v = i.from, h = i.to;
|
|
2183
|
+
const g = s.nodeBefore, m = s.nodeAfter;
|
|
2184
|
+
if (g && g.isText && ((c = g.text) != null && c.endsWith(S)) && (v -= 1), m && m.isText && ((f = m.text) != null && f.startsWith(S)) && (h += 1), v !== i.from || h !== i.to) {
|
|
2185
|
+
const p = n.tr.delete(v, h);
|
|
2186
|
+
return o(p), t.preventDefault(), !0;
|
|
2187
|
+
}
|
|
2188
|
+
}
|
|
2189
|
+
if (D(t, "DELETE") && i.empty) {
|
|
2190
|
+
const v = s.node(), h = s.nodeAfter;
|
|
2191
|
+
if (v.type.name === A.TEMPLATE_BLOCK) {
|
|
2192
|
+
const g = v.textContent || "";
|
|
2193
|
+
if (s.pos === s.start() && g.length === 1 && g !== S) {
|
|
2194
|
+
const m = s.pos;
|
|
2195
|
+
return o(n.tr.insertText(S, m, m + 1)), t.preventDefault(), !0;
|
|
2196
|
+
}
|
|
2197
|
+
if (g === S) {
|
|
2198
|
+
const m = s.after(), p = n.tr.setSelection(P.create(n.doc, m));
|
|
2199
|
+
return o(p), t.preventDefault(), !0;
|
|
2200
|
+
}
|
|
2201
|
+
if (g === "") {
|
|
2202
|
+
const m = s.after(), p = n.tr.setSelection(P.create(n.doc, m));
|
|
2203
|
+
return o(p), t.preventDefault(), !0;
|
|
2204
|
+
}
|
|
2205
|
+
if (s.pos === s.end() && g.length > 0 && g !== S) {
|
|
2206
|
+
const m = s.after();
|
|
2207
|
+
return o(n.tr.setSelection(P.create(n.doc, m))), t.preventDefault(), !0;
|
|
2208
|
+
}
|
|
2209
|
+
return !1;
|
|
2210
|
+
}
|
|
2211
|
+
if (h && h.isText && ((u = h.text) == null ? void 0 : u.length) === 1 && h.text !== S && s.nodeBefore && s.nodeBefore.type.name === A.TEMPLATE_BLOCK) {
|
|
2212
|
+
const g = s.pos, m = s.pos + h.nodeSize;
|
|
2213
|
+
let p = n.tr.delete(g, m);
|
|
2214
|
+
return p = p.insertText(S, g, g), o(p), t.preventDefault(), !0;
|
|
2215
|
+
}
|
|
2216
|
+
if (h && h.type.name === A.TEMPLATE_BLOCK) {
|
|
2217
|
+
const g = h.textContent || "";
|
|
2218
|
+
if (g.length === 0 || g === S) {
|
|
2219
|
+
const p = s.parent, d = s.index(), x = s.nodeBefore;
|
|
2220
|
+
let E = s.pos, _ = s.pos + h.nodeSize;
|
|
2221
|
+
if (x && x.isText && x.text === S && (E = E - 1), d < p.childCount - 1) {
|
|
2222
|
+
const C = p.child(d + 1);
|
|
2223
|
+
C && C.isText && C.text === S && (_ = _ + 1);
|
|
2224
|
+
}
|
|
2225
|
+
return o(n.tr.delete(E, _)), t.preventDefault(), !0;
|
|
2226
|
+
} else {
|
|
2227
|
+
const p = s.pos + 1;
|
|
2228
|
+
return o(n.tr.setSelection(P.create(n.doc, p))), t.preventDefault(), !0;
|
|
2229
|
+
}
|
|
2230
|
+
}
|
|
2231
|
+
if (h && h.isText) {
|
|
2232
|
+
const g = s.parent, m = s.index();
|
|
2233
|
+
if (m < g.childCount - 1) {
|
|
2234
|
+
const p = g.child(m + 1);
|
|
2235
|
+
if (p.type.name === A.TEMPLATE_BLOCK) {
|
|
2236
|
+
const d = p.textContent || "";
|
|
2237
|
+
if (d.length === 0 || d === S) {
|
|
2238
|
+
let E = s.pos;
|
|
2239
|
+
const _ = s.pos + h.nodeSize + p.nodeSize, C = s.nodeBefore;
|
|
2240
|
+
return C && C.isText && ((T = C.text) != null && T.endsWith(S)) && (E = E - 1), o(n.tr.delete(E, _)), t.preventDefault(), !0;
|
|
2241
|
+
}
|
|
2242
|
+
if (h.text === S || (y = h.text) != null && y.startsWith(S)) {
|
|
2243
|
+
const E = s.pos + 2;
|
|
2244
|
+
return o(n.tr.setSelection(P.create(n.doc, E))), t.preventDefault(), !0;
|
|
2245
|
+
}
|
|
2246
|
+
}
|
|
2247
|
+
}
|
|
2248
|
+
}
|
|
2249
|
+
}
|
|
2250
|
+
if (D(t, "DELETE") && !i.empty) {
|
|
2251
|
+
let v = i.from, h = i.to;
|
|
2252
|
+
const g = s.nodeBefore, m = s.nodeAfter;
|
|
2253
|
+
if (g && g.isText && ((w = g.text) != null && w.endsWith(S)) && (v -= 1), m && m.isText && ((b = m.text) != null && b.startsWith(S)) && (h += 1), v !== i.from || h !== i.to) {
|
|
2254
|
+
const p = n.tr.delete(v, h);
|
|
2255
|
+
return o(p), t.preventDefault(), !0;
|
|
2256
|
+
}
|
|
2257
|
+
}
|
|
2258
|
+
return !1;
|
|
2259
|
+
}
|
|
2260
|
+
}
|
|
2261
|
+
});
|
|
2262
|
+
}
|
|
2263
|
+
function Wo() {
|
|
2264
|
+
return new ie({
|
|
2265
|
+
key: new re(le.TEMPLATE_BLOCK_PASTE),
|
|
2266
|
+
props: {
|
|
2267
|
+
handlePaste(e, t) {
|
|
2268
|
+
var s, l, r;
|
|
2269
|
+
const n = ((s = t.clipboardData) == null ? void 0 : s.types) || [], o = (l = t.clipboardData) == null ? void 0 : l.getData("text/html");
|
|
2270
|
+
if (n.includes("text/html") && (o != null && o.includes("data-template")) || n.includes("application/x-prosemirror-slice"))
|
|
2271
|
+
return !1;
|
|
2272
|
+
const i = (r = t.clipboardData) == null ? void 0 : r.getData("text/plain");
|
|
2273
|
+
if (i) {
|
|
2274
|
+
const { state: a, dispatch: c } = e, f = a.selection.$from;
|
|
2275
|
+
let u = a.tr;
|
|
2276
|
+
f.nodeBefore && f.nodeBefore.isText && f.nodeBefore.text === S && (u = u.delete(f.pos - f.nodeBefore.nodeSize, f.pos)), f.nodeAfter && f.nodeAfter.isText && f.nodeAfter.text === S && (u = u.delete(f.pos, f.pos + f.nodeAfter.nodeSize));
|
|
2277
|
+
const T = i.split(`
|
|
2278
|
+
`);
|
|
2279
|
+
let y;
|
|
2280
|
+
if (T.length === 1)
|
|
2281
|
+
u = u.insertText(T[0], u.selection.from, u.selection.to), y = u.selection.$to.pos;
|
|
2282
|
+
else {
|
|
2283
|
+
u = u.insertText(T[0], u.selection.from, u.selection.to);
|
|
2284
|
+
let w = u.selection.$to.pos;
|
|
2285
|
+
for (let b = 1; b < T.length; b++) {
|
|
2286
|
+
const v = a.schema.nodes.paragraph.create({}, T[b] ? a.schema.text(T[b]) : null);
|
|
2287
|
+
u = u.insert(w, v), w += v.nodeSize;
|
|
2288
|
+
}
|
|
2289
|
+
y = w;
|
|
2290
|
+
}
|
|
2291
|
+
return u = u.setSelection(P.create(u.doc, y)), u = u.scrollIntoView(), c(u), t.preventDefault(), !0;
|
|
2292
|
+
}
|
|
2293
|
+
return !1;
|
|
2294
|
+
}
|
|
2295
|
+
}
|
|
2296
|
+
});
|
|
2297
|
+
}
|
|
2298
|
+
const Ko = et.create({
|
|
2299
|
+
name: A.TEMPLATE_BLOCK,
|
|
2300
|
+
// 节点配置
|
|
2301
|
+
group: "inline",
|
|
2302
|
+
inline: !0,
|
|
2303
|
+
content: "text*",
|
|
2304
|
+
// 允许内部有文本内容
|
|
2305
|
+
atom: !1,
|
|
2306
|
+
// 不是 atom 节点,允许光标进入
|
|
2307
|
+
selectable: !0,
|
|
2308
|
+
draggable: !1,
|
|
2309
|
+
onCreate() {
|
|
2310
|
+
const { items: e } = this.options;
|
|
2311
|
+
e && _e(e) && K(
|
|
2312
|
+
e,
|
|
2313
|
+
() => {
|
|
2314
|
+
const t = _e(e) ? e.value : e;
|
|
2315
|
+
t != null && (this.editor.commands.setTemplateData(t), this.editor.commands.focusFirstTemplate());
|
|
2316
|
+
},
|
|
2317
|
+
{ deep: !0, immediate: !0 }
|
|
2318
|
+
);
|
|
2319
|
+
},
|
|
2320
|
+
// 节点属性
|
|
2321
|
+
addAttributes() {
|
|
2322
|
+
return {
|
|
2323
|
+
id: {
|
|
2324
|
+
default: null,
|
|
2325
|
+
parseHTML: (e) => e.getAttribute("data-id"),
|
|
2326
|
+
renderHTML: (e) => e.id ? {
|
|
2327
|
+
"data-id": e.id
|
|
2328
|
+
} : {}
|
|
2329
|
+
},
|
|
2330
|
+
content: {
|
|
2331
|
+
default: "",
|
|
2332
|
+
parseHTML: (e) => e.getAttribute("data-content") || e.textContent,
|
|
2333
|
+
renderHTML: (e) => ({
|
|
2334
|
+
"data-content": e.content
|
|
2335
|
+
})
|
|
2336
|
+
}
|
|
2337
|
+
};
|
|
2338
|
+
},
|
|
2339
|
+
// HTML 解析
|
|
2340
|
+
parseHTML() {
|
|
2341
|
+
return [
|
|
2342
|
+
{
|
|
2343
|
+
tag: "span[data-template]"
|
|
2344
|
+
}
|
|
2345
|
+
];
|
|
2346
|
+
},
|
|
2347
|
+
// HTML 渲染
|
|
2348
|
+
renderHTML({ node: e, HTMLAttributes: t }) {
|
|
2349
|
+
const n = e.textContent || "";
|
|
2350
|
+
return [
|
|
2351
|
+
"span",
|
|
2352
|
+
tt(this.options.HTMLAttributes || {}, t, {
|
|
2353
|
+
"data-template": "",
|
|
2354
|
+
"data-id": e.attrs.id,
|
|
2355
|
+
"data-content": n
|
|
2356
|
+
}),
|
|
2357
|
+
n
|
|
2358
|
+
];
|
|
2359
|
+
},
|
|
2360
|
+
// 使用 Vue 组件渲染
|
|
2361
|
+
addNodeView() {
|
|
2362
|
+
return Qe(ko);
|
|
2363
|
+
},
|
|
2364
|
+
// 添加插件
|
|
2365
|
+
addProseMirrorPlugins() {
|
|
2366
|
+
return [$o(), No(), Wo()];
|
|
2367
|
+
}
|
|
2368
|
+
}), be = new re(
|
|
2369
|
+
le.TEMPLATE_SELECT_DROPDOWN
|
|
2370
|
+
);
|
|
2371
|
+
function Ho() {
|
|
2372
|
+
return new ie({
|
|
2373
|
+
key: be,
|
|
2374
|
+
state: {
|
|
2375
|
+
init() {
|
|
2376
|
+
return {
|
|
2377
|
+
isOpen: !1,
|
|
2378
|
+
selectId: null
|
|
2379
|
+
};
|
|
2380
|
+
},
|
|
2381
|
+
apply(e, t) {
|
|
2382
|
+
const n = e.getMeta(be);
|
|
2383
|
+
if (n) {
|
|
2384
|
+
if (n.type === "open")
|
|
2385
|
+
return {
|
|
2386
|
+
isOpen: !0,
|
|
2387
|
+
selectId: n.selectId
|
|
2388
|
+
};
|
|
2389
|
+
if (n.type === "close")
|
|
2390
|
+
return {
|
|
2391
|
+
isOpen: !1,
|
|
2392
|
+
selectId: null
|
|
2393
|
+
};
|
|
2394
|
+
}
|
|
2395
|
+
return t;
|
|
175
2396
|
}
|
|
176
2397
|
}
|
|
177
|
-
}
|
|
2398
|
+
});
|
|
178
2399
|
}
|
|
179
|
-
function
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
var g;
|
|
195
|
-
(g = t.onFinal) == null || g.call(t, v);
|
|
196
|
-
},
|
|
197
|
-
onEnd: (v) => {
|
|
198
|
-
var g;
|
|
199
|
-
s.isRecording && (s.isRecording = !1, (g = t.onEnd) == null || g.call(t, v));
|
|
200
|
-
},
|
|
201
|
-
onError: (v) => {
|
|
202
|
-
var g;
|
|
203
|
-
s.error = v, s.isRecording = !1, (g = t.onError) == null || g.call(t, v);
|
|
204
|
-
}
|
|
205
|
-
}, r = Le.isSupported();
|
|
206
|
-
s.isSupported = t.customHandler ? t.customHandler.isSupported() : r;
|
|
207
|
-
const f = t.customHandler ?? (r ? new Le(t) : null), I = () => {
|
|
208
|
-
var v;
|
|
209
|
-
if (!s.isSupported || !f) {
|
|
210
|
-
const g = new Error("语音识别不受支持");
|
|
211
|
-
s.error = g, (v = t.onError) == null || v.call(t, g);
|
|
212
|
-
return;
|
|
213
|
-
}
|
|
214
|
-
if (s.isRecording) {
|
|
215
|
-
f.stop(), s.isRecording = !1, setTimeout(() => {
|
|
216
|
-
f.start(a);
|
|
217
|
-
}, 200);
|
|
218
|
-
return;
|
|
2400
|
+
function Fo() {
|
|
2401
|
+
return new ie({
|
|
2402
|
+
key: new re(le.TEMPLATE_SELECT_ZERO_WIDTH),
|
|
2403
|
+
appendTransaction(e, t, n) {
|
|
2404
|
+
if (!e.some((l) => l.docChanged)) return null;
|
|
2405
|
+
const i = [];
|
|
2406
|
+
let { tr: s } = n;
|
|
2407
|
+
return n.doc.descendants((l, r) => {
|
|
2408
|
+
if (l.type.name === A.PARAGRAPH && l.childCount > 0) {
|
|
2409
|
+
const { lastChild: a, firstChild: c } = l;
|
|
2410
|
+
a === c && a && a.isText && a.text === S && i.push(["remove", r + 1]);
|
|
2411
|
+
}
|
|
2412
|
+
}), i.length > 0 ? (i.forEach(([, l]) => {
|
|
2413
|
+
s = s.delete(l, l + 1);
|
|
2414
|
+
}), s) : null;
|
|
219
2415
|
}
|
|
220
|
-
|
|
221
|
-
}, h = () => {
|
|
222
|
-
!s.isRecording || !f || (f.stop(), a.onEnd());
|
|
223
|
-
};
|
|
224
|
-
return tt(() => {
|
|
225
|
-
s.isRecording && f && (f.stop(), s.isRecording = !1);
|
|
226
|
-
}), {
|
|
227
|
-
speechState: s,
|
|
228
|
-
start: I,
|
|
229
|
-
stop: h
|
|
230
|
-
};
|
|
2416
|
+
});
|
|
231
2417
|
}
|
|
232
|
-
function
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
2418
|
+
function Vo() {
|
|
2419
|
+
return new ie({
|
|
2420
|
+
key: new re(le.TEMPLATE_SELECT_KEYBOARD),
|
|
2421
|
+
props: {
|
|
2422
|
+
handleKeyDown(e, t) {
|
|
2423
|
+
const { state: n, dispatch: o } = e, { selection: i } = n, { $from: s } = i, l = be.getState(e.state);
|
|
2424
|
+
if (l != null && l.isOpen && we(t, ["ENTER", "ARROW_UP", "ARROW_DOWN", "ESCAPE"]))
|
|
2425
|
+
return !0;
|
|
2426
|
+
if (D(t, "BACKSPACE") && i.empty) {
|
|
2427
|
+
const r = s.nodeBefore, a = s.nodeAfter;
|
|
2428
|
+
if ((r == null ? void 0 : r.type.name) === A.TEMPLATE_SELECT)
|
|
2429
|
+
return o(n.tr.delete(s.pos - r.nodeSize, s.pos)), t.preventDefault(), !0;
|
|
2430
|
+
if (r != null && r.isText && r.text === S) {
|
|
2431
|
+
const c = s.pos - 1, u = n.doc.resolve(c).nodeBefore;
|
|
2432
|
+
if ((u == null ? void 0 : u.type.name) === A.TEMPLATE_SELECT) {
|
|
2433
|
+
const T = c - u.nodeSize, y = s.pos;
|
|
2434
|
+
return o(n.tr.delete(T, y)), t.preventDefault(), !0;
|
|
2435
|
+
}
|
|
2436
|
+
}
|
|
2437
|
+
if ((a == null ? void 0 : a.type.name) === A.TEMPLATE_SELECT) {
|
|
2438
|
+
if (r != null && r.isText && r.text !== S)
|
|
2439
|
+
return o(n.tr.delete(s.pos - 1, s.pos)), t.preventDefault(), !0;
|
|
2440
|
+
if ((r == null ? void 0 : r.type.name) === A.TEMPLATE_BLOCK)
|
|
2441
|
+
return !1;
|
|
2442
|
+
}
|
|
2443
|
+
if (!a && (r != null && r.isText) && r.text !== S)
|
|
2444
|
+
return o(n.tr.delete(s.pos - 1, s.pos)), t.preventDefault(), !0;
|
|
2445
|
+
}
|
|
2446
|
+
if (D(t, "DELETE") && i.empty) {
|
|
2447
|
+
const r = s.nodeAfter, a = s.nodeBefore;
|
|
2448
|
+
if ((r == null ? void 0 : r.type.name) === A.TEMPLATE_SELECT)
|
|
2449
|
+
return o(n.tr.delete(s.pos, s.pos + r.nodeSize)), t.preventDefault(), !0;
|
|
2450
|
+
if (r != null && r.isText && r.text === S) {
|
|
2451
|
+
const c = s.pos + 1, u = n.doc.resolve(c).nodeAfter;
|
|
2452
|
+
if ((u == null ? void 0 : u.type.name) === A.TEMPLATE_SELECT) {
|
|
2453
|
+
const T = c + u.nodeSize;
|
|
2454
|
+
return o(n.tr.delete(s.pos, T)), t.preventDefault(), !0;
|
|
2455
|
+
}
|
|
2456
|
+
}
|
|
2457
|
+
if ((a == null ? void 0 : a.type.name) === A.TEMPLATE_SELECT) {
|
|
2458
|
+
if (r != null && r.isText && r.text !== S)
|
|
2459
|
+
return o(n.tr.delete(s.pos, s.pos + 1)), t.preventDefault(), !0;
|
|
2460
|
+
if ((r == null ? void 0 : r.type.name) === A.TEMPLATE_BLOCK)
|
|
2461
|
+
return !1;
|
|
2462
|
+
}
|
|
2463
|
+
if (!a && (r != null && r.isText) && r.text !== S)
|
|
2464
|
+
return o(n.tr.delete(s.pos, s.pos + 1)), t.preventDefault(), !0;
|
|
2465
|
+
}
|
|
2466
|
+
return !1;
|
|
2467
|
+
}
|
|
247
2468
|
}
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
}, N = () => {
|
|
255
|
-
h.value = !1, W(), V();
|
|
256
|
-
}, C = B(() => {
|
|
257
|
-
var D;
|
|
258
|
-
return a.value ? !0 : !!(s.value && ((D = t.value) == null ? void 0 : D.length) > 0 && !r.value);
|
|
259
|
-
}), x = (D) => {
|
|
260
|
-
N(), s.value = D, f(D), I(D);
|
|
261
|
-
}, p = () => {
|
|
262
|
-
L.value && x(L.value);
|
|
263
|
-
}, _ = (D) => {
|
|
264
|
-
!h.value || !t.value || (m.value = "keyboard", v.value === -1 ? v.value = D === "down" ? 0 : t.value.length - 1 : D === "down" ? v.value = (v.value + 1) % t.value.length : v.value = (v.value - 1 + t.value.length) % t.value.length, P());
|
|
265
|
-
}, U = (D) => {
|
|
266
|
-
t.value && (m.value = "mouse", g.value = D, P());
|
|
267
|
-
}, Z = () => {
|
|
268
|
-
t.value && (g.value = -1, v.value !== -1 ? m.value = "keyboard" : m.value = null, P());
|
|
2469
|
+
});
|
|
2470
|
+
}
|
|
2471
|
+
function zo(e, t, n) {
|
|
2472
|
+
const o = (i) => {
|
|
2473
|
+
const s = i.target;
|
|
2474
|
+
!e.contains(s) && !t.contains(s) && (n(), document.removeEventListener("click", o));
|
|
269
2475
|
};
|
|
270
|
-
return
|
|
271
|
-
|
|
272
|
-
}), {
|
|
273
|
-
|
|
274
|
-
isPopupVisible: h,
|
|
275
|
-
openPopup: $,
|
|
276
|
-
closePopup: N,
|
|
277
|
-
// 自动完成占位符
|
|
278
|
-
autoCompleteText: k,
|
|
279
|
-
showTabIndicator: w,
|
|
280
|
-
syncAutoComplete: P,
|
|
281
|
-
// 选中控制层
|
|
282
|
-
activeSuggestion: L,
|
|
283
|
-
activeKeyboardIndex: v,
|
|
284
|
-
activeMouseIndex: g,
|
|
285
|
-
// 交互处理
|
|
286
|
-
navigateWithKeyboard: _,
|
|
287
|
-
handleMouseEnter: U,
|
|
288
|
-
handleMouseLeave: Z,
|
|
289
|
-
// 业务操作
|
|
290
|
-
applySuggestion: x,
|
|
291
|
-
confirmSelection: p
|
|
2476
|
+
return setTimeout(() => {
|
|
2477
|
+
document.addEventListener("click", o);
|
|
2478
|
+
}, 0), () => {
|
|
2479
|
+
document.removeEventListener("click", o);
|
|
292
2480
|
};
|
|
293
2481
|
}
|
|
294
|
-
const
|
|
295
|
-
|
|
296
|
-
class: "action-buttons__cancel-text"
|
|
297
|
-
}, At = /* @__PURE__ */ Ce({
|
|
298
|
-
__name: "ActionButtons",
|
|
2482
|
+
const qo = { class: "template-select__icon" }, Uo = ["onMousedown", "onMouseenter"], Xo = /* @__PURE__ */ j({
|
|
2483
|
+
__name: "template-select-view",
|
|
299
2484
|
props: {
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
hasContent: { type: Boolean, default: !1 },
|
|
304
|
-
buttonGroup: {},
|
|
305
|
-
allowSpeech: { type: Boolean, default: !1 },
|
|
306
|
-
speechStatus: { default: () => ({
|
|
307
|
-
isRecording: !1,
|
|
308
|
-
isSupported: !1
|
|
309
|
-
}) },
|
|
310
|
-
allowFiles: { type: Boolean, default: !1 },
|
|
311
|
-
submitType: { default: "enter" },
|
|
312
|
-
showShortcuts: { type: Boolean },
|
|
313
|
-
isOverLimit: { type: Boolean, default: !1 },
|
|
314
|
-
stopText: { default: void 0 }
|
|
2485
|
+
node: {},
|
|
2486
|
+
updateAttributes: { type: Function },
|
|
2487
|
+
editor: {}
|
|
315
2488
|
},
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
},
|
|
344
|
-
|
|
345
|
-
},
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
"
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
2489
|
+
setup(e) {
|
|
2490
|
+
const t = e, n = V(!1), o = V(-1), i = V(), s = V();
|
|
2491
|
+
let l = null, r = null;
|
|
2492
|
+
const a = B(() => t.node.attrs.options.find((d) => d.value === t.node.attrs.value)), c = B(() => {
|
|
2493
|
+
var d;
|
|
2494
|
+
return ((d = a.value) == null ? void 0 : d.label) || t.node.attrs.placeholder;
|
|
2495
|
+
}), f = B(() => !t.node.attrs.value), u = () => {
|
|
2496
|
+
n.value ? y() : T();
|
|
2497
|
+
}, T = async () => {
|
|
2498
|
+
var d;
|
|
2499
|
+
if (n.value = !0, (d = t.editor) != null && d.view) {
|
|
2500
|
+
const x = t.editor.view, E = x.state.tr;
|
|
2501
|
+
E.setMeta(be, {
|
|
2502
|
+
type: "open",
|
|
2503
|
+
selectId: t.node.attrs.id
|
|
2504
|
+
}), x.dispatch(E);
|
|
2505
|
+
}
|
|
2506
|
+
t.node.attrs.value ? o.value = t.node.attrs.options.findIndex((x) => x.value === t.node.attrs.value) : o.value = -1, await pe(), b(), i.value && s.value && (l = zo(i.value, s.value, y));
|
|
2507
|
+
}, y = async () => {
|
|
2508
|
+
var d;
|
|
2509
|
+
if (n.value = !1, o.value = -1, (d = t.editor) != null && d.view) {
|
|
2510
|
+
const x = t.editor.view, E = x.state.tr;
|
|
2511
|
+
E.setMeta(be, {
|
|
2512
|
+
type: "close"
|
|
2513
|
+
}), x.dispatch(E);
|
|
2514
|
+
}
|
|
2515
|
+
l && (l(), l = null), r && (r(), r = null);
|
|
2516
|
+
}, w = (d) => {
|
|
2517
|
+
t.updateAttributes({ value: d.value }), y();
|
|
2518
|
+
}, b = () => {
|
|
2519
|
+
!i.value || !s.value || (r && (r(), r = null), r = rt(i.value, s.value, () => {
|
|
2520
|
+
!i.value || !s.value || ct(i.value, s.value, {
|
|
2521
|
+
placement: "bottom-start",
|
|
2522
|
+
strategy: "fixed",
|
|
2523
|
+
// 使用 fixed 定位策略,相对于视口
|
|
2524
|
+
middleware: [it(4), at(), lt({ padding: 8 })]
|
|
2525
|
+
}).then(({ x: d, y: x }) => {
|
|
2526
|
+
s.value && Object.assign(s.value.style, {
|
|
2527
|
+
left: `${d}px`,
|
|
2528
|
+
top: `${x}px`
|
|
2529
|
+
});
|
|
2530
|
+
});
|
|
2531
|
+
}));
|
|
2532
|
+
}, v = (d) => {
|
|
2533
|
+
if (n.value)
|
|
2534
|
+
switch (d.key) {
|
|
2535
|
+
case "ArrowUp":
|
|
2536
|
+
d.preventDefault(), h();
|
|
2537
|
+
break;
|
|
2538
|
+
case "ArrowDown":
|
|
2539
|
+
d.preventDefault(), g();
|
|
2540
|
+
break;
|
|
2541
|
+
case "Enter":
|
|
2542
|
+
d.preventDefault(), p();
|
|
2543
|
+
break;
|
|
2544
|
+
case "Escape":
|
|
2545
|
+
d.preventDefault(), y();
|
|
2546
|
+
break;
|
|
2547
|
+
}
|
|
2548
|
+
}, h = () => {
|
|
2549
|
+
o.value === -1 || o.value <= 0 ? o.value = t.node.attrs.options.length - 1 : o.value -= 1, m();
|
|
2550
|
+
}, g = () => {
|
|
2551
|
+
o.value === -1 || o.value >= t.node.attrs.options.length - 1 ? o.value = 0 : o.value += 1, m();
|
|
2552
|
+
}, m = () => {
|
|
2553
|
+
pe(() => {
|
|
2554
|
+
if (!s.value) return;
|
|
2555
|
+
const d = s.value.querySelector(".template-select__option.is-highlighted");
|
|
2556
|
+
d && d.scrollIntoView({
|
|
2557
|
+
block: "nearest",
|
|
2558
|
+
behavior: "smooth"
|
|
2559
|
+
});
|
|
2560
|
+
});
|
|
2561
|
+
}, p = () => {
|
|
2562
|
+
o.value >= 0 && o.value < t.node.attrs.options.length ? w(t.node.attrs.options[o.value]) : y();
|
|
2563
|
+
};
|
|
2564
|
+
return Jt(() => {
|
|
2565
|
+
document.addEventListener("keydown", v);
|
|
2566
|
+
}), Qt(() => {
|
|
2567
|
+
document.removeEventListener("keydown", v), l && l(), r && r();
|
|
2568
|
+
}), (d, x) => (M(), G(L(Je), {
|
|
2569
|
+
as: "span",
|
|
2570
|
+
class: "template-select"
|
|
2571
|
+
}, {
|
|
2572
|
+
default: $(() => [
|
|
2573
|
+
x[0] || (x[0] = k("span", {
|
|
2574
|
+
contenteditable: "false",
|
|
2575
|
+
class: "template-select__prefix"
|
|
2576
|
+
}, "", -1)),
|
|
2577
|
+
k("span", {
|
|
2578
|
+
ref_key: "triggerRef",
|
|
2579
|
+
ref: i,
|
|
2580
|
+
class: ee(["template-select__trigger", { "is-open": n.value }]),
|
|
2581
|
+
onMousedown: Ye(u, ["prevent"])
|
|
388
2582
|
}, [
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
2583
|
+
k("span", {
|
|
2584
|
+
class: ee(["template-select__text", { "is-placeholder": f.value }])
|
|
2585
|
+
}, fe(c.value), 3),
|
|
2586
|
+
k("span", qo, [
|
|
2587
|
+
oe(L(xn))
|
|
2588
|
+
])
|
|
2589
|
+
], 34),
|
|
2590
|
+
x[1] || (x[1] = k("span", {
|
|
2591
|
+
contenteditable: "false",
|
|
2592
|
+
class: "template-select__suffix"
|
|
2593
|
+
}, "", -1)),
|
|
2594
|
+
(M(), G(en, { to: "body" }, [
|
|
2595
|
+
n.value ? (M(), O("div", {
|
|
394
2596
|
key: 0,
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
], 2)) : M("", !0),
|
|
399
|
-
t.showClear && t.hasContent ? (S(), ee(R(Me), {
|
|
400
|
-
key: 2,
|
|
401
|
-
content: "清空内容",
|
|
402
|
-
placement: "top"
|
|
403
|
-
}, {
|
|
404
|
-
default: ve(() => [
|
|
405
|
-
z("div", {
|
|
406
|
-
class: "action-buttons__button",
|
|
407
|
-
onClick: L
|
|
408
|
-
}, [
|
|
409
|
-
Y(R(kt), { class: "action-buttons__icon" })
|
|
410
|
-
])
|
|
411
|
-
]),
|
|
412
|
-
_: 1
|
|
413
|
-
})) : M("", !0)
|
|
414
|
-
], 4)) : M("", !0),
|
|
415
|
-
t.hasContent || t.loading ? (S(), E("div", {
|
|
416
|
-
key: 1,
|
|
417
|
-
class: "action-buttons__button action-buttons__submit",
|
|
418
|
-
onClick: x[1] || (x[1] = (p) => t.loading ? P() : V())
|
|
419
|
-
}, [
|
|
420
|
-
z("div", Kt, [
|
|
421
|
-
t.loading ? (S(), E("div", {
|
|
422
|
-
key: 1,
|
|
423
|
-
class: oe(["action-buttons__cancel", { "action-buttons__cancel--icon-only": !t.stopText }])
|
|
2597
|
+
ref_key: "dropdownRef",
|
|
2598
|
+
ref: s,
|
|
2599
|
+
class: "template-select__dropdown"
|
|
424
2600
|
}, [
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
class: oe(["action-buttons__icon", "action-buttons__icon--send", { "is-disabled": m.value }]),
|
|
440
|
-
alt: "发送"
|
|
441
|
-
}, null, 8, ["class"])
|
|
442
|
-
]),
|
|
443
|
-
_: 1
|
|
444
|
-
}, 8, ["render-content"]))
|
|
445
|
-
])
|
|
446
|
-
])) : M("", !0)
|
|
447
|
-
]));
|
|
448
|
-
}
|
|
449
|
-
}), et = /* @__PURE__ */ _e(At, [["__scopeId", "data-v-f71ebb23"]]);
|
|
450
|
-
function Vt(t, s = {}) {
|
|
451
|
-
let a = [], r = [], f = t;
|
|
452
|
-
return { commit: (k) => {
|
|
453
|
-
var w;
|
|
454
|
-
a.push(f), f = k, r.length && ((w = s.onRemoveHistory) == null || w.call(s, r)), r = [];
|
|
455
|
-
}, undo: () => a.length ? (r.push(f), f = a.pop(), f) : null, redo: () => r.length ? (a.push(f), f = r.pop(), f) : null, clear: () => {
|
|
456
|
-
var k, w;
|
|
457
|
-
a.length && ((k = s.onRemoveHistory) == null || k.call(s, a)), r.length && ((w = s.onRemoveHistory) == null || w.call(s, r)), a = [], r = [];
|
|
458
|
-
}, get: () => f };
|
|
459
|
-
}
|
|
460
|
-
const Ft = ["data-id", "data-type"], Pt = ["data-id", "data-type"], Mt = /* @__PURE__ */ Ce({
|
|
461
|
-
inheritAttrs: !1,
|
|
462
|
-
__name: "Block",
|
|
463
|
-
props: {
|
|
464
|
-
id: {},
|
|
465
|
-
type: {},
|
|
466
|
-
content: {},
|
|
467
|
-
readonly: { type: Boolean },
|
|
468
|
-
asChild: { type: Boolean }
|
|
469
|
-
},
|
|
470
|
-
setup(t) {
|
|
471
|
-
const s = t, a = pt();
|
|
472
|
-
return (r, f) => {
|
|
473
|
-
const I = ht("Block", !0);
|
|
474
|
-
return s.type !== "block" ? (S(), E("span", Se({
|
|
475
|
-
key: 0,
|
|
476
|
-
"data-id": s.id,
|
|
477
|
-
"data-type": s.type
|
|
478
|
-
}, R(a)), de(s.content), 17, Ft)) : (S(), E(ye, { key: 1 }, [
|
|
479
|
-
s.asChild ? (S(!0), E(ye, { key: 0 }, xe(s.content, (h) => (S(), ee(I, Se({
|
|
480
|
-
key: `${h.id}-${h.type}`
|
|
481
|
-
}, { ref_for: !0 }, h), null, 16))), 128)) : (S(), E("span", Se({
|
|
482
|
-
key: 1,
|
|
483
|
-
"data-id": s.id,
|
|
484
|
-
"data-type": s.type
|
|
485
|
-
}, R(a)), [
|
|
486
|
-
(S(!0), E(ye, null, xe(s.content, (h) => (S(), ee(I, Se({
|
|
487
|
-
key: `${h.id}-${h.type}`
|
|
488
|
-
}, { ref_for: !0 }, h), null, 16))), 128))
|
|
489
|
-
], 16, Pt))
|
|
490
|
-
], 64));
|
|
491
|
-
};
|
|
2601
|
+
(M(!0), O(De, null, Be(e.node.attrs.options, (E, _) => (M(), O("div", {
|
|
2602
|
+
key: E.value,
|
|
2603
|
+
class: ee(["template-select__option", {
|
|
2604
|
+
"is-highlighted": _ === o.value,
|
|
2605
|
+
"is-selected": E.value === e.node.attrs.value
|
|
2606
|
+
}]),
|
|
2607
|
+
onMousedown: Ye((C) => w(E), ["prevent"]),
|
|
2608
|
+
onMouseenter: (C) => o.value = _
|
|
2609
|
+
}, fe(E.label), 43, Uo))), 128))
|
|
2610
|
+
], 512)) : W("", !0)
|
|
2611
|
+
]))
|
|
2612
|
+
]),
|
|
2613
|
+
_: 1
|
|
2614
|
+
}));
|
|
492
2615
|
}
|
|
493
|
-
}),
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
{ id: e.id, type: "prefix", content: e.prefix },
|
|
526
|
-
{ id: e.id, type: "template", content: e.content },
|
|
527
|
-
{ id: e.id, type: "suffix", content: e.suffix }
|
|
528
|
-
] : [e]).flat()), p = B(() => C.value.map((e) => e.type === "text" ? e : h ? {
|
|
529
|
-
id: e.id,
|
|
530
|
-
type: "block",
|
|
531
|
-
asChild: !0,
|
|
532
|
-
content: [
|
|
533
|
-
{ id: e.id, type: "prefix", content: e.prefix },
|
|
534
|
-
{
|
|
535
|
-
id: e.id,
|
|
536
|
-
type: "block",
|
|
537
|
-
content: [
|
|
538
|
-
{ id: e.id, type: "template", content: e.content },
|
|
539
|
-
{ id: e.id, type: "suffix", content: e.suffix }
|
|
540
|
-
]
|
|
541
|
-
}
|
|
542
|
-
]
|
|
543
|
-
} : {
|
|
544
|
-
id: e.id,
|
|
545
|
-
type: "block",
|
|
546
|
-
asChild: !0,
|
|
547
|
-
content: [
|
|
548
|
-
{
|
|
549
|
-
id: e.id,
|
|
550
|
-
type: "block",
|
|
551
|
-
content: [
|
|
552
|
-
{ id: e.id, type: "prefix", content: e.prefix },
|
|
553
|
-
{ id: e.id, type: "template", content: e.content }
|
|
554
|
-
]
|
|
2616
|
+
}), Go = /* @__PURE__ */ Z(Xo, [["__scopeId", "data-v-dbb18436"]]), Yo = et.create({
|
|
2617
|
+
name: A.TEMPLATE_SELECT,
|
|
2618
|
+
// 节点配置
|
|
2619
|
+
group: "inline",
|
|
2620
|
+
inline: !0,
|
|
2621
|
+
atom: !0,
|
|
2622
|
+
// 原子节点,光标不能进入
|
|
2623
|
+
selectable: !1,
|
|
2624
|
+
draggable: !1,
|
|
2625
|
+
// 节点属性
|
|
2626
|
+
addAttributes() {
|
|
2627
|
+
return {
|
|
2628
|
+
id: {
|
|
2629
|
+
default: null,
|
|
2630
|
+
parseHTML: (e) => e.getAttribute("data-id"),
|
|
2631
|
+
renderHTML: (e) => e.id ? { "data-id": e.id } : {}
|
|
2632
|
+
},
|
|
2633
|
+
placeholder: {
|
|
2634
|
+
default: "Please select",
|
|
2635
|
+
parseHTML: (e) => e.getAttribute("data-placeholder"),
|
|
2636
|
+
renderHTML: (e) => ({ "data-placeholder": e.placeholder })
|
|
2637
|
+
},
|
|
2638
|
+
options: {
|
|
2639
|
+
default: [],
|
|
2640
|
+
parseHTML: (e) => {
|
|
2641
|
+
const t = e.getAttribute("data-options");
|
|
2642
|
+
if (!t) return [];
|
|
2643
|
+
try {
|
|
2644
|
+
return JSON.parse(t);
|
|
2645
|
+
} catch (n) {
|
|
2646
|
+
return console.warn("Failed to parse template select options:", n), [];
|
|
2647
|
+
}
|
|
555
2648
|
},
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
U.value = isNaN(o) ? n * 2.5 : o;
|
|
562
|
-
}, D = B(() => {
|
|
563
|
-
if (!w.autoSize)
|
|
564
|
-
return {};
|
|
565
|
-
const e = typeof w.autoSize == "boolean" ? { minRows: 1, maxRows: 3 } : w.autoSize, n = e.minRows * U.value, o = e.maxRows * U.value;
|
|
566
|
-
return {
|
|
567
|
-
minHeight: `${n}px`,
|
|
568
|
-
maxHeight: `${o}px`,
|
|
569
|
-
overflowY: "auto",
|
|
570
|
-
overflowX: "hidden"
|
|
571
|
-
};
|
|
572
|
-
}), J = () => {
|
|
573
|
-
if (!_.value) return;
|
|
574
|
-
const e = window.getSelection();
|
|
575
|
-
if (!e || e.rangeCount === 0) return;
|
|
576
|
-
const o = e.getRangeAt(0).getBoundingClientRect(), c = _.value.getBoundingClientRect(), l = o.top - c.top, d = o.bottom - c.top, b = _.value.scrollTop, O = _.value.clientHeight;
|
|
577
|
-
d > O ? _.value.scrollTop = b + (d - O) + 10 : l < 0 && (_.value.scrollTop = b + l - 10);
|
|
578
|
-
}, q = (e) => {
|
|
579
|
-
const n = Date.now(), o = JSON.stringify(e);
|
|
580
|
-
return `${n}:${o}`;
|
|
581
|
-
}, ke = (e) => {
|
|
582
|
-
const n = parseInt(e.slice(0, 13)), o = JSON.parse(e.slice(14));
|
|
583
|
-
return {
|
|
584
|
-
timestamp: n,
|
|
585
|
-
data: o
|
|
586
|
-
};
|
|
587
|
-
}, K = /* @__PURE__ */ new Map(), A = Vt(q($.value), {
|
|
588
|
-
onRemoveHistory: (e) => {
|
|
589
|
-
for (const n of e)
|
|
590
|
-
K.delete(n);
|
|
591
|
-
}
|
|
592
|
-
});
|
|
593
|
-
ne(
|
|
594
|
-
() => L.value,
|
|
595
|
-
(e) => {
|
|
596
|
-
const n = P(e || []);
|
|
597
|
-
if (JSON.stringify(n) !== JSON.stringify($.value)) {
|
|
598
|
-
if (_.value) {
|
|
599
|
-
const c = le(_.value);
|
|
600
|
-
c && K.set(A.get(), X(c));
|
|
2649
|
+
renderHTML: (e) => {
|
|
2650
|
+
try {
|
|
2651
|
+
return { "data-options": JSON.stringify(e.options) };
|
|
2652
|
+
} catch (t) {
|
|
2653
|
+
return console.error("Failed to stringify template select options:", t), { "data-options": "[]" };
|
|
601
2654
|
}
|
|
602
|
-
N(n), A.commit(q($.value));
|
|
603
2655
|
}
|
|
604
2656
|
},
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
if (!n)
|
|
610
|
-
return null;
|
|
611
|
-
const o = n.rangeCount > 0 ? n.getRangeAt(0) : null, c = e.getRootNode();
|
|
612
|
-
if (!(c instanceof ShadowRoot))
|
|
613
|
-
return o;
|
|
614
|
-
if (f) {
|
|
615
|
-
const l = n.getComposedRanges(h ? c : { shadowRoots: [c] });
|
|
616
|
-
return (l == null ? void 0 : l[0]) ?? null;
|
|
2657
|
+
value: {
|
|
2658
|
+
default: null,
|
|
2659
|
+
parseHTML: (e) => e.getAttribute("data-value") || null,
|
|
2660
|
+
renderHTML: (e) => e.value ? { "data-value": e.value } : {}
|
|
617
2661
|
}
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
2662
|
+
};
|
|
2663
|
+
},
|
|
2664
|
+
// HTML 解析
|
|
2665
|
+
parseHTML() {
|
|
2666
|
+
return [
|
|
2667
|
+
{
|
|
2668
|
+
tag: "span[data-template-select]"
|
|
621
2669
|
}
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
2670
|
+
];
|
|
2671
|
+
},
|
|
2672
|
+
// HTML 渲染
|
|
2673
|
+
renderHTML({ node: e, HTMLAttributes: t }) {
|
|
2674
|
+
const n = e.attrs.options.find(
|
|
2675
|
+
(s) => s.value === e.attrs.value
|
|
2676
|
+
), o = (n == null ? void 0 : n.label) || e.attrs.placeholder;
|
|
2677
|
+
let i = "[]";
|
|
2678
|
+
try {
|
|
2679
|
+
i = JSON.stringify(e.attrs.options);
|
|
2680
|
+
} catch (s) {
|
|
2681
|
+
console.error("Failed to stringify template select options in renderHTML:", s);
|
|
2682
|
+
}
|
|
2683
|
+
return [
|
|
2684
|
+
"span",
|
|
2685
|
+
tt(t, {
|
|
2686
|
+
"data-template-select": "",
|
|
2687
|
+
"data-id": e.attrs.id,
|
|
2688
|
+
"data-placeholder": e.attrs.placeholder,
|
|
2689
|
+
"data-options": i,
|
|
2690
|
+
"data-value": e.attrs.value || ""
|
|
2691
|
+
}),
|
|
2692
|
+
o
|
|
2693
|
+
];
|
|
2694
|
+
},
|
|
2695
|
+
// 使用 Vue 组件渲染
|
|
2696
|
+
addNodeView() {
|
|
2697
|
+
return Qe(Go);
|
|
2698
|
+
},
|
|
2699
|
+
// 添加插件
|
|
2700
|
+
addProseMirrorPlugins() {
|
|
2701
|
+
return [Ho(), Fo(), Vo()];
|
|
2702
|
+
}
|
|
2703
|
+
}), qt = _t.create({
|
|
2704
|
+
name: xe.TEMPLATE,
|
|
2705
|
+
addExtensions() {
|
|
2706
|
+
return [Ko.configure(this.options), Yo];
|
|
2707
|
+
},
|
|
2708
|
+
// 添加命令(统一命令入口)
|
|
2709
|
+
addCommands() {
|
|
2710
|
+
return Do;
|
|
2711
|
+
}
|
|
2712
|
+
});
|
|
2713
|
+
function jo(e, t) {
|
|
2714
|
+
return qt.configure({
|
|
2715
|
+
items: e,
|
|
2716
|
+
...t
|
|
2717
|
+
});
|
|
2718
|
+
}
|
|
2719
|
+
function Zo(e, t) {
|
|
2720
|
+
const n = V(null), o = Re(e, "placeholder"), i = () => {
|
|
2721
|
+
var r;
|
|
2722
|
+
const l = [
|
|
2723
|
+
an,
|
|
2724
|
+
cn,
|
|
2725
|
+
un,
|
|
2726
|
+
dn,
|
|
2727
|
+
// 提供 undo/redo 功能
|
|
2728
|
+
fn.configure({
|
|
2729
|
+
placeholder: () => o.value || "请输入内容..."
|
|
2730
|
+
}),
|
|
2731
|
+
pn.configure({
|
|
2732
|
+
mode: "textSize"
|
|
2733
|
+
})
|
|
2734
|
+
];
|
|
2735
|
+
return (r = e.extensions) != null && r.length && l.push(...e.extensions), l;
|
|
2736
|
+
}, s = rn({
|
|
2737
|
+
content: e.modelValue ?? e.defaultValue ?? "",
|
|
2738
|
+
extensions: i(),
|
|
2739
|
+
autofocus: e.autofocus ? "end" : !1,
|
|
2740
|
+
editorProps: {
|
|
2741
|
+
attributes: {
|
|
2742
|
+
class: "tr-sender-editor"
|
|
2743
|
+
},
|
|
2744
|
+
// 处理粘贴事件 - 只粘贴纯文本
|
|
2745
|
+
handlePaste(l, r) {
|
|
2746
|
+
var T;
|
|
2747
|
+
const a = (T = r.clipboardData) == null ? void 0 : T.getData("text/plain");
|
|
2748
|
+
if (!a) return !1;
|
|
2749
|
+
const c = e.mode === "single" ? a.replace(/\r?\n/g, " ") : a, { state: f } = l, { tr: u } = f;
|
|
2750
|
+
return u.insertText(c), l.dispatch(u), pe(() => {
|
|
2751
|
+
var y;
|
|
2752
|
+
(y = s.value) == null || y.commands.scrollIntoView();
|
|
2753
|
+
}), !0;
|
|
639
2754
|
}
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
e.preventDefault();
|
|
664
|
-
const { inputType: o } = n, c = (n.data || ((O = n.dataTransfer) == null ? void 0 : O.getData("text/plain")) || "").replace(m, "").replace(k, ""), l = n.getTargetRanges()[0];
|
|
665
|
-
if (!l) {
|
|
666
|
-
console.warn("range is null", l);
|
|
667
|
-
return;
|
|
2755
|
+
},
|
|
2756
|
+
onUpdate: (l) => {
|
|
2757
|
+
const r = l.editor.getText();
|
|
2758
|
+
t("update:modelValue", r), t("input", r);
|
|
2759
|
+
},
|
|
2760
|
+
onFocus: (l) => {
|
|
2761
|
+
t("focus", l.event);
|
|
2762
|
+
},
|
|
2763
|
+
onBlur: (l) => {
|
|
2764
|
+
t("blur", l.event);
|
|
2765
|
+
}
|
|
2766
|
+
});
|
|
2767
|
+
return K(
|
|
2768
|
+
() => e.modelValue,
|
|
2769
|
+
(l) => {
|
|
2770
|
+
s.value && l !== s.value.getText() && s.value.commands.setContent(l ?? "", { emitUpdate: !1 });
|
|
2771
|
+
}
|
|
2772
|
+
), K(
|
|
2773
|
+
() => e.placeholder,
|
|
2774
|
+
() => {
|
|
2775
|
+
if (s.value) {
|
|
2776
|
+
const { state: l } = s.value, r = l.tr;
|
|
2777
|
+
s.value.view.dispatch(r);
|
|
668
2778
|
}
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
collapsed: e.collapsed,
|
|
693
|
-
endContainer: e.endContainer,
|
|
694
|
-
endId: o == null ? void 0 : o.dataset.id,
|
|
695
|
-
endEl: o,
|
|
696
|
-
endOffset: e.endOffset,
|
|
697
|
-
endType: o == null ? void 0 : o.dataset.type,
|
|
698
|
-
startContainer: e.startContainer,
|
|
699
|
-
startId: n == null ? void 0 : n.dataset.id,
|
|
700
|
-
startEl: n,
|
|
701
|
-
startOffset: e.startOffset,
|
|
702
|
-
startType: n == null ? void 0 : n.dataset.type
|
|
703
|
-
};
|
|
704
|
-
}, se = (e, n, o, c) => e.slice(0, o) + n + e.slice(c), we = (e, n, o) => {
|
|
705
|
-
const c = Re(e);
|
|
706
|
-
if (!Array.isArray(c) || c.length === 0)
|
|
707
|
-
return;
|
|
708
|
-
const l = Te(c, e, n, o);
|
|
709
|
-
if (l.some((u) => u.tag === "new")) {
|
|
710
|
-
const { afterId: u, content: y } = l[0];
|
|
711
|
-
re(y, u);
|
|
712
|
-
return;
|
|
2779
|
+
}
|
|
2780
|
+
), tn(() => {
|
|
2781
|
+
var l;
|
|
2782
|
+
(l = s.value) == null || l.destroy();
|
|
2783
|
+
}), {
|
|
2784
|
+
editor: s,
|
|
2785
|
+
editorRef: n
|
|
2786
|
+
};
|
|
2787
|
+
}
|
|
2788
|
+
function Jo(e) {
|
|
2789
|
+
const { submitType: t } = e;
|
|
2790
|
+
return {
|
|
2791
|
+
checkSubmitShortcut: (i) => {
|
|
2792
|
+
if (!D(i, "ENTER")) return !1;
|
|
2793
|
+
switch (t.value) {
|
|
2794
|
+
case "enter":
|
|
2795
|
+
return !i.shiftKey && !i.ctrlKey && !i.metaKey;
|
|
2796
|
+
case "ctrlEnter":
|
|
2797
|
+
return (i.ctrlKey || i.metaKey) && !i.shiftKey;
|
|
2798
|
+
case "shiftEnter":
|
|
2799
|
+
return i.shiftKey && !i.ctrlKey && !i.metaKey;
|
|
2800
|
+
default:
|
|
2801
|
+
return !1;
|
|
713
2802
|
}
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
2803
|
+
},
|
|
2804
|
+
checkNewlineShortcut: (i) => {
|
|
2805
|
+
if (!D(i, "ENTER")) return !1;
|
|
2806
|
+
switch (t.value) {
|
|
2807
|
+
case "enter":
|
|
2808
|
+
return i.shiftKey || i.ctrlKey || i.metaKey;
|
|
2809
|
+
case "ctrlEnter":
|
|
2810
|
+
case "shiftEnter":
|
|
2811
|
+
return !i.shiftKey && !i.ctrlKey && !i.metaKey;
|
|
2812
|
+
default:
|
|
2813
|
+
return !1;
|
|
718
2814
|
}
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
2815
|
+
}
|
|
2816
|
+
};
|
|
2817
|
+
}
|
|
2818
|
+
function Qo(e, t, n) {
|
|
2819
|
+
const o = V(e.mode || "single"), i = V(!1), s = V(e.mode || "single"), { start: l, stop: r } = mn(
|
|
2820
|
+
() => {
|
|
2821
|
+
i.value = !1;
|
|
2822
|
+
},
|
|
2823
|
+
300,
|
|
2824
|
+
{ immediate: !1 }
|
|
2825
|
+
), a = B(() => {
|
|
2826
|
+
var u;
|
|
2827
|
+
return (u = n.value) == null ? void 0 : u.closest(".tr-sender-main");
|
|
2828
|
+
}), c = () => {
|
|
2829
|
+
if (s.value !== "single" || i.value || !t.value || !n.value) return;
|
|
2830
|
+
const u = n.value.querySelector(".ProseMirror");
|
|
2831
|
+
if (!u) return;
|
|
2832
|
+
const T = t.value.getText();
|
|
2833
|
+
o.value === "single" ? u.scrollWidth > u.clientWidth && f("multiple") : T.length || f("single");
|
|
2834
|
+
}, f = (u) => {
|
|
2835
|
+
o.value !== u && (i.value = !0, o.value = u, pe(() => {
|
|
2836
|
+
t.value && t.value.commands.focus("end"), r(), l();
|
|
2837
|
+
}));
|
|
2838
|
+
};
|
|
2839
|
+
return hn(a, () => {
|
|
2840
|
+
requestAnimationFrame(() => {
|
|
2841
|
+
c();
|
|
2842
|
+
});
|
|
2843
|
+
}), K(
|
|
2844
|
+
() => e.mode,
|
|
2845
|
+
(u) => {
|
|
2846
|
+
u && u !== o.value && (s.value = u, f(u));
|
|
2847
|
+
}
|
|
2848
|
+
), {
|
|
2849
|
+
currentMode: o,
|
|
2850
|
+
isAutoSwitching: i,
|
|
2851
|
+
setMode: f,
|
|
2852
|
+
checkOverflow: c
|
|
2853
|
+
};
|
|
2854
|
+
}
|
|
2855
|
+
function es(e, t, n) {
|
|
2856
|
+
const o = gn("--tr-sender-line-height", t), i = B(() => {
|
|
2857
|
+
const r = o.value;
|
|
2858
|
+
if (r) {
|
|
2859
|
+
const a = parseFloat(r);
|
|
2860
|
+
return isNaN(a) ? 26 : a;
|
|
2861
|
+
}
|
|
2862
|
+
return 26;
|
|
2863
|
+
}), s = B(() => n === !1 || n === void 0 ? null : n === !0 ? {
|
|
2864
|
+
minRows: 1,
|
|
2865
|
+
maxRows: 5
|
|
2866
|
+
} : typeof n == "object" ? {
|
|
2867
|
+
minRows: n.minRows,
|
|
2868
|
+
maxRows: n.maxRows
|
|
2869
|
+
} : null), l = () => {
|
|
2870
|
+
if (!t.value) return;
|
|
2871
|
+
const r = t.value.querySelector(".tr-sender-editor-scroll");
|
|
2872
|
+
if (!r) {
|
|
2873
|
+
console.warn("⚠️ 找不到滚动容器 .tr-sender-editor-scroll");
|
|
2874
|
+
return;
|
|
2875
|
+
}
|
|
2876
|
+
const a = s.value;
|
|
2877
|
+
if (e.value === "multiple" && a) {
|
|
2878
|
+
const c = i.value * a.minRows, f = i.value * a.maxRows;
|
|
2879
|
+
r.style.minHeight = `${c}px`, r.style.maxHeight = `${f}px`, r.style.overflowY = "auto";
|
|
2880
|
+
} else
|
|
2881
|
+
r.style.minHeight = "", r.style.maxHeight = "", r.style.overflowY = e.value === "single" ? "hidden" : "auto";
|
|
2882
|
+
};
|
|
2883
|
+
return K(
|
|
2884
|
+
e,
|
|
2885
|
+
() => {
|
|
2886
|
+
pe(() => {
|
|
2887
|
+
l();
|
|
741
2888
|
});
|
|
742
|
-
},
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
else if (n.length === 0)
|
|
750
|
-
for (const i of l) {
|
|
751
|
-
const u = (O = _.value) == null ? void 0 : O.querySelector(i);
|
|
752
|
-
if (u) {
|
|
753
|
-
te(u, 0);
|
|
754
|
-
break;
|
|
755
|
-
}
|
|
756
|
-
}
|
|
757
|
-
else
|
|
758
|
-
console.warn(`can not find el with selector: ${c}`);
|
|
2889
|
+
},
|
|
2890
|
+
{ immediate: !0 }
|
|
2891
|
+
), K(
|
|
2892
|
+
s,
|
|
2893
|
+
() => {
|
|
2894
|
+
pe(() => {
|
|
2895
|
+
l();
|
|
759
2896
|
});
|
|
760
|
-
},
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
const
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
endOffset: e.endOffset
|
|
796
|
-
}), d;
|
|
797
|
-
}, Te = (e, n, o, c) => {
|
|
798
|
-
const l = e[0];
|
|
799
|
-
if (l.type !== "prefix" && l.type !== "suffix")
|
|
800
|
-
return e;
|
|
801
|
-
if (e.length === 1) {
|
|
802
|
-
if (n.collapsed)
|
|
803
|
-
if (n.startOffset === 0) {
|
|
804
|
-
const d = ie(l, c);
|
|
805
|
-
return d ? [d] : [];
|
|
806
|
-
} else {
|
|
807
|
-
const d = be(l, c);
|
|
808
|
-
return d ? [d] : [];
|
|
809
|
-
}
|
|
810
|
-
if (o.startsWith("insert"))
|
|
811
|
-
if (h) {
|
|
812
|
-
const d = ie(l, c);
|
|
813
|
-
return d ? [d] : [];
|
|
814
|
-
} else {
|
|
815
|
-
const d = be(l, c);
|
|
816
|
-
return d ? [d] : [];
|
|
817
|
-
}
|
|
818
|
-
if (o.startsWith("delete")) {
|
|
819
|
-
if (o.includes("Backward")) {
|
|
820
|
-
const d = ie(l, c, 1);
|
|
821
|
-
return d ? [d] : [];
|
|
822
|
-
} else if (o.includes("Forward")) {
|
|
823
|
-
const d = be(l, c, 1);
|
|
824
|
-
return d ? [d] : [];
|
|
2897
|
+
},
|
|
2898
|
+
{ immediate: !0 }
|
|
2899
|
+
), {
|
|
2900
|
+
updateHeight: l
|
|
2901
|
+
};
|
|
2902
|
+
}
|
|
2903
|
+
function ts(e, t) {
|
|
2904
|
+
const { editor: n, editorRef: o } = Zo(e, t), i = B(() => n.value ? Ge(n.value).trim().length > 0 : !1), s = B(() => n.value ? Ge(n.value).length : 0), l = B(() => e.maxLength ? s.value > e.maxLength : !1), r = B(() => {
|
|
2905
|
+
var d, x;
|
|
2906
|
+
return !e.disabled && !e.loading && i.value && !l.value && !((x = (d = e.defaultActions) == null ? void 0 : d.submit) != null && x.disabled);
|
|
2907
|
+
}), a = () => {
|
|
2908
|
+
if (!r.value || !n.value) return;
|
|
2909
|
+
let d, x = "";
|
|
2910
|
+
if (n.value.extensionManager.extensions.some((E) => E.name === xe.TEMPLATE)) {
|
|
2911
|
+
const E = zt(n.value);
|
|
2912
|
+
E.length > 0 && (d = E), x = Ge(n.value);
|
|
2913
|
+
} else if (n.value.extensionManager.extensions.some((E) => E.name === xe.MENTION)) {
|
|
2914
|
+
const E = Eo(n.value);
|
|
2915
|
+
E.length > 0 && (d = E), x = vo(n.value);
|
|
2916
|
+
}
|
|
2917
|
+
x || (x = n.value.getText()), t("submit", x, d);
|
|
2918
|
+
}, { currentMode: c, isAutoSwitching: f, setMode: u, checkOverflow: T } = Qo(e, n, o), y = Jo({
|
|
2919
|
+
submitType: B(() => e.submitType ?? "enter")
|
|
2920
|
+
});
|
|
2921
|
+
K(
|
|
2922
|
+
n,
|
|
2923
|
+
(d) => {
|
|
2924
|
+
d && d.setOptions({
|
|
2925
|
+
editorProps: {
|
|
2926
|
+
...d.options.editorProps,
|
|
2927
|
+
handleKeyDown: (x, E) => {
|
|
2928
|
+
const _ = ue.getState(x.state), C = F.getState(x.state), I = be.getState(x.state);
|
|
2929
|
+
return _ && _.active || C && C.active || I && I.isOpen ? !1 : y.checkSubmitShortcut(E) ? (E.preventDefault(), a(), !0) : y.checkNewlineShortcut(E) ? (E.preventDefault(), c.value === "single" ? (u("multiple"), setTimeout(() => {
|
|
2930
|
+
d.commands.splitBlock(), d.commands.focus();
|
|
2931
|
+
}, 0)) : d.commands.splitBlock(), !0) : !1;
|
|
825
2932
|
}
|
|
826
2933
|
}
|
|
827
|
-
}
|
|
828
|
-
return c.length > 0 ? e.slice(1) : e;
|
|
829
|
-
}, ie = (e, n, o = 0) => {
|
|
830
|
-
const c = x.value.findIndex((l) => l.id === e.id && l.type === e.type);
|
|
831
|
-
if (c > 0) {
|
|
832
|
-
const l = x.value[c - 1], { id: d, type: b, content: O } = l;
|
|
833
|
-
if (b === "text" || b === "template")
|
|
834
|
-
return {
|
|
835
|
-
id: d,
|
|
836
|
-
type: b,
|
|
837
|
-
startOffset: O.length - o,
|
|
838
|
-
endOffset: O.length
|
|
839
|
-
};
|
|
840
|
-
if (n.length > 0)
|
|
841
|
-
return { tag: "new", afterId: d, type: "text", content: n };
|
|
842
|
-
if (console.warn("the previous item is not text or template", { current: e, previous: l }), o === 1)
|
|
843
|
-
return { ...e, endOffset: e.startOffset };
|
|
844
|
-
} else return n.length > 0 ? { tag: "new", type: "text", content: n } : (console.warn("the previous item of current is not found", { current: e }), null);
|
|
845
|
-
return e;
|
|
846
|
-
}, be = (e, n, o = 0) => {
|
|
847
|
-
const c = x.value.findIndex((l) => l.id === e.id && l.type === e.type);
|
|
848
|
-
if (c < x.value.length - 1) {
|
|
849
|
-
const l = x.value[c + 1], { id: d, type: b } = l;
|
|
850
|
-
if (b === "text" || b === "template")
|
|
851
|
-
return {
|
|
852
|
-
id: d,
|
|
853
|
-
type: b,
|
|
854
|
-
startOffset: 0,
|
|
855
|
-
endOffset: 0 + o
|
|
856
|
-
};
|
|
857
|
-
if (n.length > 0)
|
|
858
|
-
return { tag: "new", afterId: e.id, type: "text", content: n };
|
|
859
|
-
if (console.warn("the next item is not text or template", { current: e, next: l }), o === 1)
|
|
860
|
-
return { ...e, startOffset: e.endOffset };
|
|
861
|
-
} else return n.length > 0 ? { tag: "new", afterId: e.id, type: "text", content: n } : (console.warn("the next item of current is not found", { current: e }), null);
|
|
862
|
-
return e;
|
|
863
|
-
}, pe = () => {
|
|
864
|
-
Q.value = { hasStarted: !0, range: null };
|
|
865
|
-
}, He = (e) => {
|
|
866
|
-
const n = Q.value.range;
|
|
867
|
-
n ? (e.data && fe(n.startContainer) && fe(n.endContainer) ? (K.set(A.get(), X(n)), re(e.data)) : n.startId && n.endId ? (K.set(A.get(), X(n)), we(n, "insertCompositionText", e.data)) : console.warn("range is not valid, range:", n), V.value++, j(() => {
|
|
868
|
-
J();
|
|
869
|
-
})) : console.warn("range is null, compositionEnd:", e), Q.value = { hasStarted: !1, range: null };
|
|
870
|
-
}, he = (() => {
|
|
871
|
-
const e = navigator.userAgent.toLowerCase();
|
|
872
|
-
return /macintosh|mac os x|iphone|ipad|ipod/.test(e);
|
|
873
|
-
})(), Ae = (e) => {
|
|
874
|
-
const n = he && e.metaKey && !e.shiftKey && e.key.toLowerCase() === "z" || // Cmd+Z
|
|
875
|
-
!he && e.ctrlKey && !e.shiftKey && e.key.toLowerCase() === "z", o = he && e.metaKey && e.shiftKey && e.key.toLowerCase() === "z" || // Cmd+Shift+z
|
|
876
|
-
!he && e.ctrlKey && (e.key.toLowerCase() === "y" || e.shiftKey && e.key.toLowerCase() === "z"), c = e.key.toLowerCase() === "enter";
|
|
877
|
-
if (n) {
|
|
878
|
-
e.preventDefault();
|
|
879
|
-
const l = le(_.value);
|
|
880
|
-
l && K.set(A.get(), X(l));
|
|
881
|
-
const d = A.undo();
|
|
882
|
-
d && Ee(d);
|
|
883
|
-
}
|
|
884
|
-
if (o) {
|
|
885
|
-
e.preventDefault();
|
|
886
|
-
const l = A.redo();
|
|
887
|
-
l && Ee(l);
|
|
888
|
-
}
|
|
889
|
-
c && (e.preventDefault(), F("submit"));
|
|
890
|
-
}, Ee = (e) => {
|
|
891
|
-
const { data: n } = ke(e);
|
|
892
|
-
if (N(n), K.has(e)) {
|
|
893
|
-
const o = K.get(e);
|
|
894
|
-
j(() => {
|
|
895
|
-
const c = _.value.querySelector(`[data-id="${o.startId}"][data-type="${o.startType}"]`), l = _.value.querySelector(`[data-id="${o.endId}"][data-type="${o.endType}"]`);
|
|
896
|
-
c && te(c, o.startOffset, l, o.endOffset);
|
|
897
|
-
});
|
|
898
|
-
}
|
|
899
|
-
L.value = W($.value);
|
|
900
|
-
}, ce = (e, n) => {
|
|
901
|
-
var l, d;
|
|
902
|
-
const o = (l = _.value) == null ? void 0 : l.querySelector(`[data-id="${e}"][data-type="${n}"]`);
|
|
903
|
-
if (!o) return;
|
|
904
|
-
const c = ((d = o.textContent) == null ? void 0 : d.length) || 0;
|
|
905
|
-
te(o, c);
|
|
906
|
-
}, Ve = () => {
|
|
907
|
-
_.value && j(() => {
|
|
908
|
-
const e = $.value, n = e.find((c) => c.type === "template");
|
|
909
|
-
n && ce(n.id, "template"), e.every((c) => c.type === "text") && e.length === 1 && ce(e[0].id, "text");
|
|
910
|
-
});
|
|
911
|
-
}, Fe = () => {
|
|
912
|
-
A.clear(), K.clear();
|
|
913
|
-
}, Oe = () => {
|
|
914
|
-
if (!_.value || Q.value.range)
|
|
915
|
-
return;
|
|
916
|
-
const e = le(_.value);
|
|
917
|
-
if (e != null && e.collapsed && C.value.length > 0) {
|
|
918
|
-
const n = X(e), o = C.value[0];
|
|
919
|
-
if (n.startEl && n.startId === o.id && n.startOffset === 0 && o.content === g && o.type === "text") {
|
|
920
|
-
te(n.startEl, 1);
|
|
921
|
-
return;
|
|
922
|
-
}
|
|
923
|
-
const c = C.value[C.value.length - 1];
|
|
924
|
-
if (n.endEl && n.endId === c.id && n.endOffset === 1 && c.content === g && c.type === "text") {
|
|
925
|
-
te(n.endEl, 0);
|
|
926
|
-
return;
|
|
927
|
-
}
|
|
928
|
-
}
|
|
929
|
-
};
|
|
930
|
-
return yt(() => {
|
|
931
|
-
document.addEventListener("selectionchange", Oe), j(() => {
|
|
932
|
-
Z();
|
|
933
2934
|
});
|
|
934
|
-
}
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
2935
|
+
},
|
|
2936
|
+
{ immediate: !0 }
|
|
2937
|
+
), es(c, o, e.autoSize), K(
|
|
2938
|
+
() => {
|
|
2939
|
+
var d;
|
|
2940
|
+
return (d = n.value) == null ? void 0 : d.state.doc.content;
|
|
2941
|
+
},
|
|
2942
|
+
() => {
|
|
2943
|
+
setTimeout(() => {
|
|
2944
|
+
T();
|
|
2945
|
+
}, 0);
|
|
2946
|
+
},
|
|
2947
|
+
{ deep: !0 }
|
|
2948
|
+
);
|
|
2949
|
+
const w = () => {
|
|
2950
|
+
var d;
|
|
2951
|
+
(d = n.value) == null || d.commands.focus();
|
|
2952
|
+
}, b = () => {
|
|
2953
|
+
var d, x;
|
|
2954
|
+
(d = n.value) == null || d.commands.clearContent(), (x = n.value) == null || x.commands.focus(), t("clear");
|
|
2955
|
+
}, v = () => {
|
|
2956
|
+
t("cancel");
|
|
2957
|
+
}, h = () => {
|
|
2958
|
+
var d;
|
|
2959
|
+
(d = n.value) == null || d.commands.blur();
|
|
2960
|
+
}, g = (d) => {
|
|
2961
|
+
var x;
|
|
2962
|
+
(x = n.value) == null || x.commands.setContent(d);
|
|
2963
|
+
}, m = () => {
|
|
2964
|
+
var d;
|
|
2965
|
+
return ((d = n.value) == null ? void 0 : d.getText()) || "";
|
|
2966
|
+
}, p = {
|
|
2967
|
+
editor: n,
|
|
2968
|
+
editorRef: o,
|
|
2969
|
+
mode: c,
|
|
2970
|
+
isAutoSwitching: f,
|
|
2971
|
+
loading: B(() => e.loading ?? !1),
|
|
2972
|
+
disabled: B(() => e.disabled ?? !1),
|
|
2973
|
+
hasContent: i,
|
|
2974
|
+
canSubmit: r,
|
|
2975
|
+
isOverLimit: l,
|
|
2976
|
+
characterCount: s,
|
|
2977
|
+
maxLength: Re(e, "maxLength"),
|
|
2978
|
+
size: B(() => e.size ?? "normal"),
|
|
2979
|
+
showWordLimit: B(() => e.showWordLimit ?? !1),
|
|
2980
|
+
clearable: B(() => e.clearable ?? !1),
|
|
2981
|
+
defaultActions: Re(e, "defaultActions"),
|
|
2982
|
+
submitType: B(() => e.submitType ?? "enter"),
|
|
2983
|
+
stopText: Re(e, "stopText"),
|
|
2984
|
+
submit: a,
|
|
2985
|
+
clear: b,
|
|
2986
|
+
cancel: v,
|
|
2987
|
+
focus: w,
|
|
2988
|
+
blur: h,
|
|
2989
|
+
setContent: g,
|
|
2990
|
+
getContent: m
|
|
2991
|
+
};
|
|
2992
|
+
return nn(on, p), {
|
|
2993
|
+
context: p,
|
|
2994
|
+
expose: {
|
|
2995
|
+
submit: a,
|
|
2996
|
+
clear: b,
|
|
2997
|
+
cancel: v,
|
|
2998
|
+
focus: w,
|
|
2999
|
+
blur: h,
|
|
3000
|
+
setContent: g,
|
|
3001
|
+
getContent: m,
|
|
3002
|
+
editor: n
|
|
985
3003
|
}
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
},
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
show: { type: Boolean },
|
|
1007
|
-
suggestions: {},
|
|
1008
|
-
popupStyle: {},
|
|
1009
|
-
activeKeyboardIndex: {},
|
|
1010
|
-
activeMouseIndex: {},
|
|
1011
|
-
inputValue: {}
|
|
1012
|
-
},
|
|
1013
|
-
emits: ["select", "mouse-enter", "mouse-leave"],
|
|
1014
|
-
setup(t, { emit: s }) {
|
|
1015
|
-
const a = t, r = s, f = H(null), I = (m) => m === a.activeKeyboardIndex || m === a.activeMouseIndex, h = (m) => {
|
|
1016
|
-
r("mouse-enter", m);
|
|
1017
|
-
}, v = () => {
|
|
1018
|
-
r("mouse-leave");
|
|
1019
|
-
}, g = (m) => {
|
|
1020
|
-
r("select", m);
|
|
1021
|
-
};
|
|
1022
|
-
return ne(
|
|
1023
|
-
() => a.activeKeyboardIndex,
|
|
1024
|
-
(m) => {
|
|
1025
|
-
if (m !== -1 && f.value) {
|
|
1026
|
-
const k = f.value.children[m];
|
|
1027
|
-
k && k.scrollIntoView({ block: "nearest" });
|
|
1028
|
-
}
|
|
3004
|
+
};
|
|
3005
|
+
}
|
|
3006
|
+
function ut() {
|
|
3007
|
+
const e = Me();
|
|
3008
|
+
return B(() => ({
|
|
3009
|
+
// 编辑器实例
|
|
3010
|
+
editor: e.editor.value,
|
|
3011
|
+
// 基础操作
|
|
3012
|
+
focus: e.focus,
|
|
3013
|
+
blur: e.blur,
|
|
3014
|
+
// 内容操作(为增强按钮设计)
|
|
3015
|
+
insert: (t) => {
|
|
3016
|
+
var n;
|
|
3017
|
+
(n = e.editor.value) == null || n.commands.insertContent(t + " "), e.focus();
|
|
3018
|
+
},
|
|
3019
|
+
append: (t) => {
|
|
3020
|
+
const n = e.editor.value;
|
|
3021
|
+
if (n) {
|
|
3022
|
+
const o = n.state.doc.content.size;
|
|
3023
|
+
n.chain().focus().insertContentAt(o, t).run();
|
|
1029
3024
|
}
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
3025
|
+
},
|
|
3026
|
+
replace: (t) => {
|
|
3027
|
+
e.setContent(t), e.focus();
|
|
3028
|
+
},
|
|
3029
|
+
// 常用状态
|
|
3030
|
+
disabled: e.disabled.value,
|
|
3031
|
+
loading: e.loading.value,
|
|
3032
|
+
hasContent: e.hasContent.value
|
|
3033
|
+
}));
|
|
3034
|
+
}
|
|
3035
|
+
const ns = { class: "tr-sender-editor-scroll" }, os = /* @__PURE__ */ j({
|
|
3036
|
+
__name: "index",
|
|
3037
|
+
setup(e) {
|
|
3038
|
+
const { editor: t, editorRef: n } = Me();
|
|
3039
|
+
return (o, i) => (M(), O("div", {
|
|
3040
|
+
ref_key: "editorRef",
|
|
3041
|
+
ref: n,
|
|
3042
|
+
class: "tr-sender-editor-wrapper"
|
|
3043
|
+
}, [
|
|
3044
|
+
k("div", ns, [
|
|
3045
|
+
L(t) ? (M(), G(L(ln), {
|
|
1033
3046
|
key: 0,
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
(S(!0), E(ye, null, xe(a.suggestions, (w, L) => (S(), E("div", {
|
|
1040
|
-
key: L,
|
|
1041
|
-
class: oe(["suggestion-list__item", { highlighted: I(L) }]),
|
|
1042
|
-
onMouseenter: (F) => h(L),
|
|
1043
|
-
onMouseleave: v,
|
|
1044
|
-
onMousedown: gt((F) => g(w.content), ["prevent"])
|
|
1045
|
-
}, [
|
|
1046
|
-
Y(R(Tt), { class: "suggestion-list__icon" }),
|
|
1047
|
-
z("span", Xt, [
|
|
1048
|
-
(S(!0), E(ye, null, xe(R(jt)(w, a.inputValue), (F, V) => (S(), E("span", {
|
|
1049
|
-
key: V,
|
|
1050
|
-
class: oe({
|
|
1051
|
-
"suggestion-list__text--match": F.isMatch,
|
|
1052
|
-
"suggestion-list__text--normal": !F.isMatch
|
|
1053
|
-
})
|
|
1054
|
-
}, de(F.text), 3))), 128))
|
|
1055
|
-
])
|
|
1056
|
-
], 42, Jt))), 128))
|
|
1057
|
-
], 4)) : M("", !0)
|
|
1058
|
-
]),
|
|
1059
|
-
_: 1
|
|
1060
|
-
}));
|
|
3047
|
+
editor: L(t),
|
|
3048
|
+
class: "tr-sender-editor-content"
|
|
3049
|
+
}, null, 8, ["editor"])) : W("", !0)
|
|
3050
|
+
])
|
|
3051
|
+
], 512));
|
|
1061
3052
|
}
|
|
1062
|
-
}),
|
|
1063
|
-
key: 0,
|
|
1064
|
-
class: "tiny-sender__header-slot"
|
|
1065
|
-
}, nn = {
|
|
3053
|
+
}), Ut = /* @__PURE__ */ Z(os, [["__scopeId", "data-v-7f5b51aa"]]), ss = { class: "tr-sender-single-layout" }, rs = {
|
|
1066
3054
|
key: 0,
|
|
1067
|
-
class: "
|
|
1068
|
-
},
|
|
3055
|
+
class: "tr-sender-header"
|
|
3056
|
+
}, is = { class: "tr-sender-container" }, ls = { class: "tr-sender-main" }, as = {
|
|
1069
3057
|
key: 0,
|
|
1070
|
-
class: "
|
|
1071
|
-
},
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
},
|
|
3058
|
+
class: "tr-sender-prefix"
|
|
3059
|
+
}, cs = { class: "tr-sender-content" }, us = /* @__PURE__ */ j({
|
|
3060
|
+
__name: "SingleLineLayout",
|
|
3061
|
+
setup(e) {
|
|
3062
|
+
const { editor: t, hasContent: n, loading: o, showWordLimit: i, maxLength: s } = Me(), l = ut();
|
|
3063
|
+
return (r, a) => (M(), O("div", ss, [
|
|
3064
|
+
r.$slots.header ? (M(), O("div", rs, [
|
|
3065
|
+
R(r.$slots, "header", {}, void 0, !0)
|
|
3066
|
+
])) : W("", !0),
|
|
3067
|
+
k("div", is, [
|
|
3068
|
+
k("div", ls, [
|
|
3069
|
+
r.$slots.prefix ? (M(), O("div", as, [
|
|
3070
|
+
R(r.$slots, "prefix", {}, void 0, !0)
|
|
3071
|
+
])) : W("", !0),
|
|
3072
|
+
k("div", cs, [
|
|
3073
|
+
R(r.$slots, "content", { editor: L(t) }, () => [
|
|
3074
|
+
oe(Ut)
|
|
3075
|
+
], !0)
|
|
3076
|
+
])
|
|
3077
|
+
]),
|
|
3078
|
+
k("div", {
|
|
3079
|
+
class: ee(["tr-sender-actions-inline", { "has-content": L(n) || L(o) }])
|
|
3080
|
+
}, [
|
|
3081
|
+
L(i) && L(s) ? (M(), G(L(bt), { key: 0 })) : W("", !0),
|
|
3082
|
+
R(r.$slots, "actions-inline", me(he(L(l))), void 0, !0),
|
|
3083
|
+
oe(L(St))
|
|
3084
|
+
], 2)
|
|
3085
|
+
])
|
|
3086
|
+
]));
|
|
3087
|
+
}
|
|
3088
|
+
}), ds = /* @__PURE__ */ Z(us, [["__scopeId", "data-v-87bc03b2"]]), fs = {
|
|
1075
3089
|
key: 0,
|
|
1076
|
-
class: "
|
|
1077
|
-
},
|
|
3090
|
+
class: "tr-sender-footer"
|
|
3091
|
+
}, ps = { class: "tr-sender-footer-left" }, ms = { class: "tr-sender-footer-right" }, hs = /* @__PURE__ */ j({
|
|
3092
|
+
__name: "index",
|
|
3093
|
+
setup(e) {
|
|
3094
|
+
const { mode: t, showWordLimit: n, maxLength: o } = Me(), i = ut();
|
|
3095
|
+
return (s, l) => L(t) === "multiple" ? (M(), O("div", fs, [
|
|
3096
|
+
k("div", ps, [
|
|
3097
|
+
R(s.$slots, "footer", me(he(L(i))), void 0, !0)
|
|
3098
|
+
]),
|
|
3099
|
+
k("div", ms, [
|
|
3100
|
+
L(n) && L(o) ? (M(), G(L(bt), { key: 0 })) : W("", !0),
|
|
3101
|
+
R(s.$slots, "footer-right", me(he(L(i))), void 0, !0),
|
|
3102
|
+
oe(L(St))
|
|
3103
|
+
])
|
|
3104
|
+
])) : W("", !0);
|
|
3105
|
+
}
|
|
3106
|
+
}), gs = /* @__PURE__ */ Z(hs, [["__scopeId", "data-v-3a92a161"]]), ys = { class: "tr-sender-multi-layout" }, xs = {
|
|
1078
3107
|
key: 0,
|
|
1079
|
-
class: "
|
|
1080
|
-
},
|
|
1081
|
-
key: 1,
|
|
1082
|
-
class: "tiny-sender__actions-slot"
|
|
1083
|
-
}, dn = {
|
|
3108
|
+
class: "tr-sender-header"
|
|
3109
|
+
}, Ts = { class: "tr-sender-main" }, vs = {
|
|
1084
3110
|
key: 0,
|
|
1085
|
-
class: "
|
|
1086
|
-
},
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
3111
|
+
class: "tr-sender-prefix"
|
|
3112
|
+
}, Es = { class: "tr-sender-content" }, ws = /* @__PURE__ */ j({
|
|
3113
|
+
__name: "MultiLineLayout",
|
|
3114
|
+
setup(e) {
|
|
3115
|
+
const t = Me(), n = ut();
|
|
3116
|
+
return (o, i) => (M(), O("div", ys, [
|
|
3117
|
+
o.$slots.header ? (M(), O("div", xs, [
|
|
3118
|
+
R(o.$slots, "header", {}, void 0, !0)
|
|
3119
|
+
])) : W("", !0),
|
|
3120
|
+
k("div", Ts, [
|
|
3121
|
+
o.$slots.prefix ? (M(), O("div", vs, [
|
|
3122
|
+
R(o.$slots, "prefix", {}, void 0, !0)
|
|
3123
|
+
])) : W("", !0),
|
|
3124
|
+
k("div", Es, [
|
|
3125
|
+
R(o.$slots, "content", {
|
|
3126
|
+
editor: L(t).editor
|
|
3127
|
+
}, () => [
|
|
3128
|
+
oe(Ut)
|
|
3129
|
+
], !0)
|
|
3130
|
+
])
|
|
3131
|
+
]),
|
|
3132
|
+
oe(gs, null, {
|
|
3133
|
+
footer: $(() => [
|
|
3134
|
+
R(o.$slots, "footer", me(he(L(n))), void 0, !0)
|
|
3135
|
+
]),
|
|
3136
|
+
"footer-right": $(() => [
|
|
3137
|
+
R(o.$slots, "footer-right", me(he(L(n))), void 0, !0)
|
|
3138
|
+
]),
|
|
3139
|
+
_: 3
|
|
3140
|
+
})
|
|
3141
|
+
]));
|
|
3142
|
+
}
|
|
3143
|
+
}), bs = /* @__PURE__ */ Z(ws, [["__scopeId", "data-v-0b507198"]]), Ss = /* @__PURE__ */ j({
|
|
1093
3144
|
__name: "index",
|
|
1094
3145
|
props: {
|
|
1095
|
-
|
|
1096
|
-
autoSize: { type: [Boolean, Object], default: () => ({ minRows: 1, maxRows: 3 }) },
|
|
1097
|
-
allowSpeech: { type: Boolean, default: !0 },
|
|
1098
|
-
allowFiles: { type: Boolean, default: !1 },
|
|
1099
|
-
clearable: { type: Boolean, default: !1 },
|
|
1100
|
-
disabled: { type: Boolean, default: !1 },
|
|
3146
|
+
modelValue: {},
|
|
1101
3147
|
defaultValue: {},
|
|
1102
|
-
loading: { type: Boolean, default: !1 },
|
|
1103
|
-
modelValue: { default: "" },
|
|
1104
|
-
mode: { default: "single" },
|
|
1105
|
-
maxLength: { default: 1 / 0 },
|
|
1106
|
-
buttonGroup: {},
|
|
1107
|
-
submitType: { default: "enter" },
|
|
1108
|
-
speech: { type: [Boolean, Object] },
|
|
1109
3148
|
placeholder: { default: "请输入内容..." },
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
3149
|
+
disabled: { type: Boolean },
|
|
3150
|
+
loading: { type: Boolean },
|
|
3151
|
+
autofocus: { type: Boolean },
|
|
3152
|
+
mode: { default: "single" },
|
|
3153
|
+
autoSize: { type: [Boolean, Object], default: () => ({ minRows: 1, maxRows: 5 }) },
|
|
3154
|
+
maxLength: {},
|
|
3155
|
+
showWordLimit: { type: Boolean },
|
|
3156
|
+
clearable: { type: Boolean },
|
|
3157
|
+
extensions: { default: () => [] },
|
|
3158
|
+
size: { default: "normal" },
|
|
3159
|
+
stopText: {},
|
|
3160
|
+
defaultActions: {},
|
|
3161
|
+
submitType: { default: "enter" }
|
|
1117
3162
|
},
|
|
1118
|
-
emits: ["update:modelValue", "
|
|
1119
|
-
setup(
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
autoCompleteText: x,
|
|
1130
|
-
showTabIndicator: p,
|
|
1131
|
-
syncAutoComplete: _,
|
|
1132
|
-
closePopup: U,
|
|
1133
|
-
applySuggestion: Z,
|
|
1134
|
-
confirmSelection: D,
|
|
1135
|
-
navigateWithKeyboard: J,
|
|
1136
|
-
handleMouseEnter: q,
|
|
1137
|
-
handleMouseLeave: ke
|
|
1138
|
-
} = Lt(
|
|
1139
|
-
B(() => r.suggestions),
|
|
1140
|
-
w,
|
|
1141
|
-
L,
|
|
1142
|
-
k,
|
|
1143
|
-
(i) => f("update:modelValue", i),
|
|
1144
|
-
(i) => f("suggestion-select", i)
|
|
1145
|
-
), K = H(r.mode), A = H(!1), ge = () => {
|
|
1146
|
-
K.value === "single" && (K.value = "multiple", j(() => {
|
|
1147
|
-
setTimeout(() => {
|
|
1148
|
-
const i = document.querySelector(".tiny-textarea__inner");
|
|
1149
|
-
if (i) {
|
|
1150
|
-
i.style.whiteSpace = "pre-wrap";
|
|
1151
|
-
const u = w.value.length;
|
|
1152
|
-
i.focus(), i.setSelectionRange(u, u);
|
|
1153
|
-
}
|
|
1154
|
-
}, 50);
|
|
1155
|
-
}));
|
|
1156
|
-
}, fe = (i, u) => {
|
|
1157
|
-
const y = document.createElement("span");
|
|
1158
|
-
y.style.visibility = "hidden", y.style.position = "absolute", y.style.whiteSpace = "nowrap", y.style.font = u, y.textContent = i, document.body.appendChild(y);
|
|
1159
|
-
const T = y.offsetWidth;
|
|
1160
|
-
return document.body.removeChild(y), T;
|
|
1161
|
-
}, le = () => {
|
|
1162
|
-
var $e, je, Je;
|
|
1163
|
-
if (r.mode !== "single" || !I.value || A.value || !h.value || !g.value) return;
|
|
1164
|
-
const i = h.value.querySelector(".tiny-sender__content-area");
|
|
1165
|
-
if (!i) return;
|
|
1166
|
-
const u = ((je = ($e = I.value) == null ? void 0 : $e.querySelector) == null ? void 0 : je.call($e, ".tiny-input__inner")) || i.querySelector(".tiny-input__inner"), y = m.value || h.value.querySelector(".tiny-sender__buttons-container");
|
|
1167
|
-
if (!u) {
|
|
1168
|
-
console.warn("Cannot find input element for overflow check");
|
|
1169
|
-
return;
|
|
1170
|
-
}
|
|
1171
|
-
const T = u.getBoundingClientRect(), G = y == null ? void 0 : y.getBoundingClientRect();
|
|
1172
|
-
if (T.width === 0) {
|
|
1173
|
-
setTimeout(() => le(), 50);
|
|
1174
|
-
return;
|
|
1175
|
-
}
|
|
1176
|
-
const ue = window.getComputedStyle(u).font, ot = fe(w.value, ue), qe = (Je = h.value) == null ? void 0 : Je.classList.contains("tr-sender-compact"), st = qe ? 12 : 20, it = T.width, at = (G == null ? void 0 : G.width) || 0, Ge = it - at - st, lt = qe ? 50 : 80;
|
|
1177
|
-
ot > Ge && Ge > lt && K.value === "single" && (A.value = !0, K.value = "multiple", j(() => {
|
|
1178
|
-
I.value ? setTimeout(() => {
|
|
1179
|
-
var Xe;
|
|
1180
|
-
const Be = (Xe = h.value) == null ? void 0 : Xe.querySelector(".tiny-textarea__inner");
|
|
1181
|
-
if (Be) {
|
|
1182
|
-
Be.style.whiteSpace = "pre-wrap";
|
|
1183
|
-
const Ye = w.value.length;
|
|
1184
|
-
Be.focus(), Be.setSelectionRange(Ye, Ye);
|
|
1185
|
-
}
|
|
1186
|
-
A.value = !1;
|
|
1187
|
-
}, 300) : A.value = !1;
|
|
1188
|
-
}));
|
|
1189
|
-
}, me = () => {
|
|
1190
|
-
if (k.value && v.value)
|
|
1191
|
-
n();
|
|
1192
|
-
else if (I.value)
|
|
1193
|
-
I.value.focus();
|
|
1194
|
-
else {
|
|
1195
|
-
const i = document.querySelector(".tiny-input__inner");
|
|
1196
|
-
i == null || i.focus();
|
|
1197
|
-
}
|
|
1198
|
-
}, te = () => {
|
|
1199
|
-
if (I.value)
|
|
1200
|
-
I.value.blur();
|
|
1201
|
-
else {
|
|
1202
|
-
const i = document.querySelector(".tiny-input__inner");
|
|
1203
|
-
i == null || i.blur();
|
|
1204
|
-
}
|
|
1205
|
-
}, re = () => {
|
|
1206
|
-
var i;
|
|
1207
|
-
f("update:templateData", []), (i = v.value) == null || i.clearHistory(), j(() => {
|
|
1208
|
-
w.value === "" && (K.value = r.mode || "single"), setTimeout(() => {
|
|
1209
|
-
me();
|
|
1210
|
-
}, 50);
|
|
1211
|
-
});
|
|
1212
|
-
}, Q = () => {
|
|
1213
|
-
var i;
|
|
1214
|
-
F(), k.value ? re() : (i = h.value) == null || i.focus(), j(() => {
|
|
1215
|
-
w.value === "" && (K.value = r.mode || "single");
|
|
1216
|
-
});
|
|
1217
|
-
}, Ke = (i) => {
|
|
1218
|
-
const u = (T) => T.type === "text" && T.content === "";
|
|
1219
|
-
if (i.length === 0 || i.every(u)) {
|
|
1220
|
-
re();
|
|
1221
|
-
return;
|
|
1222
|
-
}
|
|
1223
|
-
f("update:templateData", i);
|
|
1224
|
-
};
|
|
1225
|
-
ne(
|
|
1226
|
-
() => r.templateData,
|
|
1227
|
-
() => {
|
|
1228
|
-
w.value = r.templateData.map((i) => i.content).join("");
|
|
1229
|
-
},
|
|
1230
|
-
{ deep: !0 }
|
|
1231
|
-
);
|
|
1232
|
-
const X = B(() => {
|
|
1233
|
-
const i = typeof r.speech == "object" ? r.speech : {};
|
|
1234
|
-
return {
|
|
1235
|
-
...i,
|
|
1236
|
-
onStart: () => f("speech-start"),
|
|
1237
|
-
onEnd: (u) => f("speech-end", u),
|
|
1238
|
-
onInterim: (u) => f("speech-interim", u),
|
|
1239
|
-
onFinal: (u) => {
|
|
1240
|
-
if (i.autoReplace)
|
|
1241
|
-
w.value = u;
|
|
1242
|
-
else {
|
|
1243
|
-
const y = w.value;
|
|
1244
|
-
y && u && !y.endsWith(" ") && !u.startsWith(" ") && y.length > 0 ? w.value = y + " " + u : w.value = y + u;
|
|
1245
|
-
}
|
|
1246
|
-
f("speech-end", u);
|
|
1247
|
-
},
|
|
1248
|
-
onError: (u) => {
|
|
1249
|
-
f("speech-error", u);
|
|
1250
|
-
}
|
|
1251
|
-
};
|
|
1252
|
-
}), { speechState: se, start: we, stop: Ie } = Bt(X.value), Re = () => {
|
|
1253
|
-
se.isRecording ? Ie() : we();
|
|
1254
|
-
}, Te = async () => {
|
|
1255
|
-
const i = typeof r.speech == "object" ? r.speech : {}, u = se.isRecording;
|
|
1256
|
-
if (i.onVoiceButtonClick) {
|
|
1257
|
-
let y = !1;
|
|
1258
|
-
try {
|
|
1259
|
-
await i.onVoiceButtonClick(u, () => {
|
|
1260
|
-
y = !0;
|
|
1261
|
-
});
|
|
1262
|
-
} catch (T) {
|
|
1263
|
-
console.error("语音按钮点击拦截器执行失败:", T);
|
|
3163
|
+
emits: ["update:modelValue", "submit", "focus", "blur", "clear", "cancel", "input"],
|
|
3164
|
+
setup(e, { expose: t, emit: n }) {
|
|
3165
|
+
const o = e, i = n, { context: s, expose: l } = ts(o, i);
|
|
3166
|
+
return t(l), (r, a) => (M(), O("div", {
|
|
3167
|
+
class: ee([
|
|
3168
|
+
"tr-sender",
|
|
3169
|
+
`tr-sender--${L(s).mode.value}`,
|
|
3170
|
+
`tr-sender--${L(s).size.value}`,
|
|
3171
|
+
{
|
|
3172
|
+
"is-auto-switching": L(s).isAutoSwitching.value,
|
|
3173
|
+
"is-disabled": L(s).disabled.value
|
|
1264
3174
|
}
|
|
1265
|
-
|
|
1266
|
-
return;
|
|
1267
|
-
}
|
|
1268
|
-
Re();
|
|
1269
|
-
}, ie = B(() => r.maxLength !== 1 / 0 && w.value.length > r.maxLength), { handleKeyPress: be, triggerSubmit: pe } = $t(
|
|
1270
|
-
r,
|
|
1271
|
-
f,
|
|
1272
|
-
w,
|
|
1273
|
-
L,
|
|
1274
|
-
se,
|
|
1275
|
-
W,
|
|
1276
|
-
$,
|
|
1277
|
-
D,
|
|
1278
|
-
U,
|
|
1279
|
-
J,
|
|
1280
|
-
Re,
|
|
1281
|
-
P,
|
|
1282
|
-
K,
|
|
1283
|
-
ge,
|
|
1284
|
-
k,
|
|
1285
|
-
re
|
|
1286
|
-
), He = (i) => {
|
|
1287
|
-
f("focus", i), w.value && !k.value && (W.value = !0);
|
|
1288
|
-
}, Ue = (i) => {
|
|
1289
|
-
f("blur", i), U();
|
|
1290
|
-
}, he = B(() => K.value === "multiple" ? "textarea" : "text"), Ae = mt(), Ee = B(() => !!Ae.decorativeContent), ce = B(() => r.disabled || Ee.value), Ve = B(() => r.loading), Fe = B(() => ({
|
|
1291
|
-
"is-disabled": ce.value,
|
|
1292
|
-
"is-loading": Ve.value,
|
|
1293
|
-
"is-auto-switching": A.value
|
|
1294
|
-
})), Oe = B(() => ({
|
|
1295
|
-
width: Et(r.suggestionPopupWidth),
|
|
1296
|
-
maxWidth: "100%"
|
|
1297
|
-
// 确保不超出父容器宽度
|
|
1298
|
-
})), e = () => {
|
|
1299
|
-
L.value = !1;
|
|
1300
|
-
};
|
|
1301
|
-
ne(w, () => {
|
|
1302
|
-
j(le), w.value === "" && r.mode === "single" && (K.value = "single"), _();
|
|
1303
|
-
}), ne(
|
|
1304
|
-
() => k.value,
|
|
1305
|
-
(i) => {
|
|
1306
|
-
i && (K.value = "multiple");
|
|
1307
|
-
}
|
|
1308
|
-
);
|
|
1309
|
-
const n = () => {
|
|
1310
|
-
v.value && v.value.activateFirstField();
|
|
1311
|
-
}, { accept: o = "*", multiple: c = !0, reset: l = !0 } = ((O = r.buttonGroup) == null ? void 0 : O.file) || {}, { open: d, files: b } = St({ accept: o, multiple: c, reset: l });
|
|
1312
|
-
return ne(b, (i) => {
|
|
1313
|
-
i && i.length > 0 && f("files-selected", Array.from(i));
|
|
1314
|
-
}), s({
|
|
1315
|
-
focus: me,
|
|
1316
|
-
blur: te,
|
|
1317
|
-
clear: Q,
|
|
1318
|
-
submit: pe,
|
|
1319
|
-
startSpeech: we,
|
|
1320
|
-
stopSpeech: Ie,
|
|
1321
|
-
activateTemplateFirstField: n
|
|
1322
|
-
}), (i, u) => (S(), E("div", {
|
|
1323
|
-
ref_key: "senderRef",
|
|
1324
|
-
ref: h,
|
|
1325
|
-
class: oe(["tiny-sender", [Fe.value, `theme-${t.theme}`, `mode-${K.value}`]]),
|
|
1326
|
-
"data-theme": t.theme
|
|
3175
|
+
])
|
|
1327
3176
|
}, [
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
"allow-speech": t.allowSpeech,
|
|
1396
|
-
"allow-files": t.allowFiles,
|
|
1397
|
-
loading: t.loading,
|
|
1398
|
-
disabled: ce.value,
|
|
1399
|
-
"show-clear": t.clearable,
|
|
1400
|
-
"has-content": V.value,
|
|
1401
|
-
"speech-status": R(se),
|
|
1402
|
-
"button-group": t.buttonGroup,
|
|
1403
|
-
"submit-type": t.submitType,
|
|
1404
|
-
"is-over-limit": ie.value,
|
|
1405
|
-
"stop-text": t.stopText,
|
|
1406
|
-
onClear: Q,
|
|
1407
|
-
onVoiceButtonClick: Te,
|
|
1408
|
-
onSubmit: R(pe),
|
|
1409
|
-
onCancel: u[2] || (u[2] = (y) => i.$emit("cancel")),
|
|
1410
|
-
onTriggerSelect: R(d)
|
|
1411
|
-
}, null, 8, ["allow-speech", "allow-files", "loading", "disabled", "show-clear", "has-content", "speech-status", "button-group", "submit-type", "is-over-limit", "stop-text", "onSubmit", "onTriggerSelect"])
|
|
1412
|
-
], 512)
|
|
1413
|
-
])) : M("", !0)
|
|
1414
|
-
], 2),
|
|
1415
|
-
Y(Ne, { name: "tiny-sender-slide-up" }, {
|
|
1416
|
-
default: ve(() => [
|
|
1417
|
-
K.value === "multiple" ? (S(), E("div", dn, [
|
|
1418
|
-
z("div", fn, [
|
|
1419
|
-
ae(i.$slots, "footer-left", {}, void 0, !0)
|
|
1420
|
-
]),
|
|
1421
|
-
z("div", pn, [
|
|
1422
|
-
ae(i.$slots, "footer-right", {}, void 0, !0),
|
|
1423
|
-
t.showWordLimit && t.maxLength !== 1 / 0 ? (S(), E("div", {
|
|
1424
|
-
key: 0,
|
|
1425
|
-
class: oe(["tiny-sender__word-limit", { "is-over-limit": ie.value }])
|
|
1426
|
-
}, [
|
|
1427
|
-
z("span", hn, de(R(w).length), 1),
|
|
1428
|
-
Qe("/" + de(t.maxLength), 1)
|
|
1429
|
-
], 2)) : M("", !0),
|
|
1430
|
-
K.value === "multiple" ? (S(), E("div", vn, [
|
|
1431
|
-
z("div", yn, [
|
|
1432
|
-
Y(et, {
|
|
1433
|
-
"allow-speech": t.allowSpeech,
|
|
1434
|
-
"allow-files": t.allowFiles,
|
|
1435
|
-
loading: t.loading,
|
|
1436
|
-
disabled: ce.value,
|
|
1437
|
-
"show-clear": t.clearable,
|
|
1438
|
-
"has-content": V.value,
|
|
1439
|
-
"speech-status": R(se),
|
|
1440
|
-
"button-group": t.buttonGroup,
|
|
1441
|
-
"submit-type": t.submitType,
|
|
1442
|
-
"is-over-limit": ie.value,
|
|
1443
|
-
"stop-text": t.stopText,
|
|
1444
|
-
onClear: Q,
|
|
1445
|
-
onVoiceButtonClick: Te,
|
|
1446
|
-
onSubmit: R(pe),
|
|
1447
|
-
onCancel: u[3] || (u[3] = (y) => i.$emit("cancel")),
|
|
1448
|
-
onTriggerSelect: R(d)
|
|
1449
|
-
}, null, 8, ["allow-speech", "allow-files", "loading", "disabled", "show-clear", "has-content", "speech-status", "button-group", "submit-type", "is-over-limit", "stop-text", "onSubmit", "onTriggerSelect"])
|
|
1450
|
-
])
|
|
1451
|
-
])) : M("", !0)
|
|
1452
|
-
])
|
|
1453
|
-
])) : i.$slots.footer ? (S(), E("div", gn, [
|
|
1454
|
-
ae(i.$slots, "footer", {}, void 0, !0)
|
|
1455
|
-
])) : M("", !0)
|
|
1456
|
-
]),
|
|
1457
|
-
_: 3
|
|
1458
|
-
})
|
|
1459
|
-
], 512)
|
|
1460
|
-
]),
|
|
1461
|
-
Y(Zt, {
|
|
1462
|
-
show: R(W),
|
|
1463
|
-
suggestions: t.suggestions,
|
|
1464
|
-
"popup-style": Oe.value,
|
|
1465
|
-
"active-keyboard-index": R(N),
|
|
1466
|
-
"active-mouse-index": R(C),
|
|
1467
|
-
"input-value": R(w),
|
|
1468
|
-
onSelect: R(Z),
|
|
1469
|
-
onMouseEnter: R(q),
|
|
1470
|
-
onMouseLeave: R(ke)
|
|
1471
|
-
}, null, 8, ["show", "suggestions", "popup-style", "active-keyboard-index", "active-mouse-index", "input-value", "onSelect", "onMouseEnter", "onMouseLeave"])
|
|
1472
|
-
], 10, Qt));
|
|
3177
|
+
L(s).mode.value === "single" ? (M(), G(ds, { key: 0 }, pt({ _: 2 }, [
|
|
3178
|
+
r.$slots.header ? {
|
|
3179
|
+
name: "header",
|
|
3180
|
+
fn: $(() => [
|
|
3181
|
+
R(r.$slots, "header", {}, void 0, !0)
|
|
3182
|
+
]),
|
|
3183
|
+
key: "0"
|
|
3184
|
+
} : void 0,
|
|
3185
|
+
r.$slots.prefix ? {
|
|
3186
|
+
name: "prefix",
|
|
3187
|
+
fn: $(() => [
|
|
3188
|
+
R(r.$slots, "prefix", {}, void 0, !0)
|
|
3189
|
+
]),
|
|
3190
|
+
key: "1"
|
|
3191
|
+
} : void 0,
|
|
3192
|
+
r.$slots.content ? {
|
|
3193
|
+
name: "content",
|
|
3194
|
+
fn: $((c) => [
|
|
3195
|
+
R(r.$slots, "content", me(he(c)), void 0, !0)
|
|
3196
|
+
]),
|
|
3197
|
+
key: "2"
|
|
3198
|
+
} : void 0,
|
|
3199
|
+
r.$slots["actions-inline"] ? {
|
|
3200
|
+
name: "actions-inline",
|
|
3201
|
+
fn: $(() => [
|
|
3202
|
+
R(r.$slots, "actions-inline", {}, void 0, !0)
|
|
3203
|
+
]),
|
|
3204
|
+
key: "3"
|
|
3205
|
+
} : void 0
|
|
3206
|
+
]), 1024)) : (M(), G(bs, { key: 1 }, pt({ _: 2 }, [
|
|
3207
|
+
r.$slots.header ? {
|
|
3208
|
+
name: "header",
|
|
3209
|
+
fn: $(() => [
|
|
3210
|
+
R(r.$slots, "header", {}, void 0, !0)
|
|
3211
|
+
]),
|
|
3212
|
+
key: "0"
|
|
3213
|
+
} : void 0,
|
|
3214
|
+
r.$slots.prefix ? {
|
|
3215
|
+
name: "prefix",
|
|
3216
|
+
fn: $(() => [
|
|
3217
|
+
R(r.$slots, "prefix", {}, void 0, !0)
|
|
3218
|
+
]),
|
|
3219
|
+
key: "1"
|
|
3220
|
+
} : void 0,
|
|
3221
|
+
r.$slots.content ? {
|
|
3222
|
+
name: "content",
|
|
3223
|
+
fn: $((c) => [
|
|
3224
|
+
R(r.$slots, "content", me(he(c)), void 0, !0)
|
|
3225
|
+
]),
|
|
3226
|
+
key: "2"
|
|
3227
|
+
} : void 0,
|
|
3228
|
+
r.$slots.footer ? {
|
|
3229
|
+
name: "footer",
|
|
3230
|
+
fn: $(() => [
|
|
3231
|
+
R(r.$slots, "footer", {}, void 0, !0)
|
|
3232
|
+
]),
|
|
3233
|
+
key: "3"
|
|
3234
|
+
} : void 0,
|
|
3235
|
+
r.$slots["footer-right"] ? {
|
|
3236
|
+
name: "footer-right",
|
|
3237
|
+
fn: $(() => [
|
|
3238
|
+
R(r.$slots, "footer-right", {}, void 0, !0)
|
|
3239
|
+
]),
|
|
3240
|
+
key: "4"
|
|
3241
|
+
} : void 0
|
|
3242
|
+
]), 1024))
|
|
3243
|
+
], 2));
|
|
1473
3244
|
}
|
|
1474
|
-
}),
|
|
1475
|
-
|
|
1476
|
-
const
|
|
1477
|
-
|
|
1478
|
-
}
|
|
1479
|
-
|
|
3245
|
+
}), We = /* @__PURE__ */ Z(Ss, [["__scopeId", "data-v-283d5f77"]]);
|
|
3246
|
+
We.name = "TrSender";
|
|
3247
|
+
const As = function(e) {
|
|
3248
|
+
e.component(We.name, We);
|
|
3249
|
+
}, Hs = Object.assign(We, {
|
|
3250
|
+
install: As,
|
|
3251
|
+
// 扩展类(用于继承)
|
|
3252
|
+
Mention: Ht,
|
|
3253
|
+
Suggestion: Vt,
|
|
3254
|
+
Template: qt,
|
|
3255
|
+
// 便捷函数(用于简单场景)
|
|
3256
|
+
mention: wo,
|
|
3257
|
+
suggestion: Po,
|
|
3258
|
+
template: jo
|
|
3259
|
+
});
|
|
1480
3260
|
export {
|
|
1481
|
-
|
|
3261
|
+
Hs as default,
|
|
3262
|
+
Me as useSenderContext
|
|
1482
3263
|
};
|