@opentiny/tiny-robot 0.3.1-alpha.8 → 0.3.1-alpha.9
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/base-popper/index.js +1 -1
- package/dist/bubble/index.js +4017 -11
- package/dist/chat-input/index.js +3154 -0
- package/dist/dropdown-menu/index.js +1 -1
- package/dist/history/index.js +1 -1
- package/dist/index.d.ts +684 -968
- package/dist/index.js +104 -108
- package/dist/index2.js +90 -90
- package/dist/index3.js +150 -155
- package/dist/index4.js +295 -319
- package/dist/index5.js +279 -507
- package/dist/index6.js +146 -286
- package/dist/loading.js +4 -0
- package/dist/mcp-server-picker/index.js +57 -58
- package/dist/sender/index.js +6 -3261
- package/dist/sender-compat/index.js +109 -105
- package/dist/style.css +1 -1
- package/dist/suggestion-popover/index.js +185 -184
- package/package.json +17 -17
- package/dist/index7.js +0 -161
- /package/dist/{sender-actions → chat-input-actions}/index.js +0 -0
package/dist/sender/index.js
CHANGED
|
@@ -1,3263 +1,8 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
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
|
-
};
|
|
424
|
-
}
|
|
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;
|
|
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)
|
|
577
|
-
);
|
|
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);
|
|
689
|
-
return {
|
|
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
|
|
867
|
-
}
|
|
868
|
-
};
|
|
869
|
-
};
|
|
870
|
-
function io(e) {
|
|
871
|
-
return q(e).direction === "rtl";
|
|
872
|
-
}
|
|
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;
|
|
920
|
-
}
|
|
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);
|
|
929
|
-
}
|
|
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);
|
|
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;
|
|
997
|
-
return {
|
|
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;
|
|
1206
|
-
}
|
|
1207
|
-
}
|
|
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;
|
|
1225
|
-
}
|
|
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;
|
|
1227
|
-
}
|
|
1228
|
-
},
|
|
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
|
-
});
|
|
1271
|
-
}
|
|
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 = {
|
|
1284
|
-
/**
|
|
1285
|
-
* 插入 mention 节点
|
|
1286
|
-
*/
|
|
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
|
-
}),
|
|
1295
|
-
/**
|
|
1296
|
-
* 删除 mention 节点
|
|
1297
|
-
*/
|
|
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
|
-
];
|
|
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 = {
|
|
1870
|
-
/**
|
|
1871
|
-
* 设置模板数据(批量)
|
|
1872
|
-
*/
|
|
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
|
-
},
|
|
1906
|
-
/**
|
|
1907
|
-
* 插入模板块
|
|
1908
|
-
*/
|
|
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
|
-
] : []
|
|
1923
|
-
});
|
|
1924
|
-
},
|
|
1925
|
-
/**
|
|
1926
|
-
* 聚焦到第一个模板块
|
|
1927
|
-
*/
|
|
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
|
-
},
|
|
1948
|
-
/**
|
|
1949
|
-
* 插入选择器
|
|
1950
|
-
*/
|
|
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
|
|
1958
|
-
}
|
|
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
|
-
}
|
|
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"]));
|
|
2024
|
-
}
|
|
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;
|
|
2396
|
-
}
|
|
2397
|
-
}
|
|
2398
|
-
});
|
|
2399
|
-
}
|
|
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;
|
|
2415
|
-
}
|
|
2416
|
-
});
|
|
2417
|
-
}
|
|
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
|
-
}
|
|
2468
|
-
}
|
|
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));
|
|
2475
|
-
};
|
|
2476
|
-
return setTimeout(() => {
|
|
2477
|
-
document.addEventListener("click", o);
|
|
2478
|
-
}, 0), () => {
|
|
2479
|
-
document.removeEventListener("click", o);
|
|
2480
|
-
};
|
|
2481
|
-
}
|
|
2482
|
-
const qo = { class: "template-select__icon" }, Uo = ["onMousedown", "onMouseenter"], Xo = /* @__PURE__ */ j({
|
|
2483
|
-
__name: "template-select-view",
|
|
2484
|
-
props: {
|
|
2485
|
-
node: {},
|
|
2486
|
-
updateAttributes: { type: Function },
|
|
2487
|
-
editor: {}
|
|
2488
|
-
},
|
|
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"])
|
|
2582
|
-
}, [
|
|
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", {
|
|
2596
|
-
key: 0,
|
|
2597
|
-
ref_key: "dropdownRef",
|
|
2598
|
-
ref: s,
|
|
2599
|
-
class: "template-select__dropdown"
|
|
2600
|
-
}, [
|
|
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
|
-
}));
|
|
2615
|
-
}
|
|
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
|
-
}
|
|
2648
|
-
},
|
|
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": "[]" };
|
|
2654
|
-
}
|
|
2655
|
-
}
|
|
2656
|
-
},
|
|
2657
|
-
value: {
|
|
2658
|
-
default: null,
|
|
2659
|
-
parseHTML: (e) => e.getAttribute("data-value") || null,
|
|
2660
|
-
renderHTML: (e) => e.value ? { "data-value": e.value } : {}
|
|
2661
|
-
}
|
|
2662
|
-
};
|
|
2663
|
-
},
|
|
2664
|
-
// HTML 解析
|
|
2665
|
-
parseHTML() {
|
|
2666
|
-
return [
|
|
2667
|
-
{
|
|
2668
|
-
tag: "span[data-template-select]"
|
|
2669
|
-
}
|
|
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;
|
|
2754
|
-
}
|
|
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);
|
|
2778
|
-
}
|
|
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;
|
|
2802
|
-
}
|
|
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;
|
|
2814
|
-
}
|
|
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();
|
|
2888
|
-
});
|
|
2889
|
-
},
|
|
2890
|
-
{ immediate: !0 }
|
|
2891
|
-
), K(
|
|
2892
|
-
s,
|
|
2893
|
-
() => {
|
|
2894
|
-
pe(() => {
|
|
2895
|
-
l();
|
|
2896
|
-
});
|
|
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;
|
|
2932
|
-
}
|
|
2933
|
-
}
|
|
2934
|
-
});
|
|
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
|
|
3003
|
-
}
|
|
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();
|
|
3024
|
-
}
|
|
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), {
|
|
3046
|
-
key: 0,
|
|
3047
|
-
editor: L(t),
|
|
3048
|
-
class: "tr-sender-editor-content"
|
|
3049
|
-
}, null, 8, ["editor"])) : W("", !0)
|
|
3050
|
-
])
|
|
3051
|
-
], 512));
|
|
3052
|
-
}
|
|
3053
|
-
}), Ut = /* @__PURE__ */ Z(os, [["__scopeId", "data-v-7f5b51aa"]]), ss = { class: "tr-sender-single-layout" }, rs = {
|
|
3054
|
-
key: 0,
|
|
3055
|
-
class: "tr-sender-header"
|
|
3056
|
-
}, is = { class: "tr-sender-container" }, ls = { class: "tr-sender-main" }, as = {
|
|
3057
|
-
key: 0,
|
|
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 = {
|
|
3089
|
-
key: 0,
|
|
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 = {
|
|
3107
|
-
key: 0,
|
|
3108
|
-
class: "tr-sender-header"
|
|
3109
|
-
}, Ts = { class: "tr-sender-main" }, vs = {
|
|
3110
|
-
key: 0,
|
|
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({
|
|
3144
|
-
__name: "index",
|
|
3145
|
-
props: {
|
|
3146
|
-
modelValue: {},
|
|
3147
|
-
defaultValue: {},
|
|
3148
|
-
placeholder: { default: "请输入内容..." },
|
|
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" }
|
|
3162
|
-
},
|
|
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
|
|
3174
|
-
}
|
|
3175
|
-
])
|
|
3176
|
-
}, [
|
|
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));
|
|
3244
|
-
}
|
|
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
|
-
});
|
|
1
|
+
import e from "../chat-input/index.js";
|
|
2
|
+
import { u as a } from "../index2.js";
|
|
3
|
+
const r = e;
|
|
4
|
+
r.name = "TrSender";
|
|
3260
5
|
export {
|
|
3261
|
-
|
|
3262
|
-
|
|
6
|
+
r as default,
|
|
7
|
+
a as useSenderContext
|
|
3263
8
|
};
|