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