@freecallai/pro 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/FkpRichText.vue_vue_type_script_setup_true_lang-BuMz8Tyy.js +4416 -0
- package/dist/KnowledgeArea-BkRVWFrg.js +1224 -0
- package/dist/{ToolForm-CWpUIVTl.js → ToolForm-BSJxTJ7U.js} +1 -1
- package/dist/index-BVHYCLDv.js +5 -0
- package/dist/{index-DOEijEGU.js → index-BnFTr8u9.js} +1 -1
- package/dist/{index-5a9mHHzg.js → index-CG2j9Znw.js} +1 -1
- package/dist/index-kOPLn4DD.js +5 -0
- package/dist/index.js +3 -3
- package/dist/{media-migration-CGOFwdYm.js → media-migration-Cj-3xrxd.js} +1 -1
- package/dist/{media-upload-Dx45yv6a.js → media-upload-D7DpMJYx.js} +1 -1
- package/dist/rich-text/index.js +5 -5
- package/dist/rich-text/legacy-converter/index.js +766 -321
- package/dist/{guard-BCatAeT4.js → rules-CC6NoltX.js} +252 -190
- package/dist/style.css +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/rich-text/FkpRichText.vue.d.ts +16 -5
- package/dist/types/rich-text/__demo__/reasoning-template-examples.d.ts +12 -0
- package/dist/types/rich-text/index.d.ts +1 -1
- package/dist/types/rich-text/legacy-converter/business-attribute.d.ts +32 -0
- package/dist/types/rich-text/legacy-converter/index.d.ts +1 -0
- package/dist/types/rich-text/legacy-converter/tool-contract.d.ts +5 -0
- package/dist/types/rich-text/plugins/tool/rules.d.ts +34 -0
- package/dist/types/rich-text/public/types.d.ts +10 -0
- package/dist/types/rich-text/runtime/file-drop-guard.d.ts +2 -0
- package/dist/types/rich-text/runtime/media-policy.d.ts +15 -0
- package/dist/types/rich-text/runtime/media-target.d.ts +1 -0
- package/dist/types/rich-text/runtime/media-upload-session.d.ts +5 -1
- package/dist/types/rich-text/runtime/media-upload-slots.d.ts +4 -0
- package/dist/types/rich-text/ui/KnowledgeArea.vue.d.ts +7 -0
- package/package.json +1 -1
- package/dist/FkpRichText.vue_vue_type_script_setup_true_lang-DnknqQTh.js +0 -4115
- package/dist/KnowledgeArea-OPR7smbt.js +0 -923
- package/dist/index-BsQLwz91.js +0 -5
- package/dist/index-xAjlBylT.js +0 -5
|
@@ -1,923 +0,0 @@
|
|
|
1
|
-
import { defineComponent as De, shallowRef as Oe, ref as L, watch as H, nextTick as se, onMounted as Re, onBeforeUnmount as Ue, openBlock as _, createElementBlock as F, createVNode as oe, unref as ie, createElementVNode as J, withCtx as ze, createTextVNode as Le, createCommentVNode as He } from "vue";
|
|
2
|
-
import { EditorContent as _e, Editor as Fe } from "@tiptap/vue-3";
|
|
3
|
-
import { Tag as Je } from "@freecallai/ui";
|
|
4
|
-
import { Plugin as qe, Selection as je, TextSelection as Ge } from "@tiptap/pm/state";
|
|
5
|
-
import Ke from "@tiptap/starter-kit";
|
|
6
|
-
import We from "@tiptap/extension-placeholder";
|
|
7
|
-
import { Extension as Xe, Node as q } from "@tiptap/core";
|
|
8
|
-
import { glyphs as A } from "@freecallai/icons";
|
|
9
|
-
import { e as B, t as x, p as ce, q as ue, r as R, j as Qe, C as Ye, l as le, m as Ze } from "./guard-BCatAeT4.js";
|
|
10
|
-
import { b as de } from "./FkpRichText.vue_vue_type_script_setup_true_lang-DnknqQTh.js";
|
|
11
|
-
function fe() {
|
|
12
|
-
const r = globalThis.crypto.getRandomValues(new Uint8Array(16));
|
|
13
|
-
r[6] = r[6] & 15 | 64, r[8] = r[8] & 63 | 128;
|
|
14
|
-
const c = Array.from(
|
|
15
|
-
r,
|
|
16
|
-
(h) => h.toString(16).padStart(2, "0")
|
|
17
|
-
).join("");
|
|
18
|
-
return `${c.slice(0, 8)}-${c.slice(8, 12)}-${c.slice(
|
|
19
|
-
12,
|
|
20
|
-
16
|
|
21
|
-
)}-${c.slice(16, 20)}-${c.slice(20)}`;
|
|
22
|
-
}
|
|
23
|
-
function et(r, c) {
|
|
24
|
-
if (r !== "order_note" && r !== "small_payment") return null;
|
|
25
|
-
const h = c && typeof c == "object" && !Array.isArray(c) ? c : {};
|
|
26
|
-
if (r === "small_payment") {
|
|
27
|
-
const k = typeof h.amount == "string" ? h.amount : "", S = /^(?:0|[1-9]\d*)(?:\.\d{1,2})?$/.test(k), [v = "", o = ""] = k.split(".");
|
|
28
|
-
return {
|
|
29
|
-
label: "小额打款",
|
|
30
|
-
iconGlyph: A.tool,
|
|
31
|
-
summary: S ? `¥${v}.${o.padEnd(2, "0")}` : ""
|
|
32
|
-
};
|
|
33
|
-
}
|
|
34
|
-
const l = h.contentMode === "smart" ? "智能提取" : typeof h.content == "string" ? h.content.replace(/\s+/g, " ").trim() : "";
|
|
35
|
-
return { label: "备注", iconGlyph: A["msg-tag"], summary: l };
|
|
36
|
-
}
|
|
37
|
-
const tt = Xe.create({
|
|
38
|
-
name: "uniqueExtensionNodeIds",
|
|
39
|
-
addProseMirrorPlugins() {
|
|
40
|
-
return [
|
|
41
|
-
new qe({
|
|
42
|
-
appendTransaction(r, c, h) {
|
|
43
|
-
if (!r.some((p) => p.docChanged))
|
|
44
|
-
return null;
|
|
45
|
-
const l = /* @__PURE__ */ new Map(), k = /* @__PURE__ */ new Map();
|
|
46
|
-
c.doc.descendants((p, M) => {
|
|
47
|
-
if (!B(p.type.name) || !p.attrs.id) return;
|
|
48
|
-
k.set(String(p.attrs.id), p);
|
|
49
|
-
let g = M;
|
|
50
|
-
for (const V of r)
|
|
51
|
-
g = V.mapping.mapResult(g, 1).pos;
|
|
52
|
-
const I = h.doc.nodeAt(g);
|
|
53
|
-
(I == null ? void 0 : I.type.name) === p.type.name && I.attrs.id === p.attrs.id && l.set(String(p.attrs.id), g);
|
|
54
|
-
});
|
|
55
|
-
const S = /* @__PURE__ */ new Set();
|
|
56
|
-
for (const p of r) {
|
|
57
|
-
const M = p.getMeta(x);
|
|
58
|
-
Array.isArray(M) && M.forEach((g) => {
|
|
59
|
-
typeof g == "string" && g && S.add(g);
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
|
-
const v = /* @__PURE__ */ new Set();
|
|
63
|
-
h.doc.descendants((p) => {
|
|
64
|
-
B(p.type.name) && p.attrs.id && v.add(String(p.attrs.id));
|
|
65
|
-
});
|
|
66
|
-
const o = /* @__PURE__ */ new Set(), { tr: C } = h, b = r.some(
|
|
67
|
-
(p) => p.getMeta("uiEvent") === "drop"
|
|
68
|
-
);
|
|
69
|
-
return h.doc.descendants((p, M) => {
|
|
70
|
-
var P;
|
|
71
|
-
if (!B(p.type.name)) return;
|
|
72
|
-
let g = String(p.attrs.id || "");
|
|
73
|
-
const I = l.get(g);
|
|
74
|
-
!!g && !o.has(g) && (I === M || b && I === void 0 && ((P = k.get(g)) == null ? void 0 : P.eq(p)) || I === void 0 && S.has(g)) || (g = ce(v, fe), C.setNodeMarkup(M, void 0, {
|
|
75
|
-
...p.attrs,
|
|
76
|
-
id: g,
|
|
77
|
-
nodeVersion: 0
|
|
78
|
-
}), v.add(g)), o.add(g);
|
|
79
|
-
}), C.docChanged ? C.setMeta("addToHistory", !1) : null;
|
|
80
|
-
}
|
|
81
|
-
})
|
|
82
|
-
];
|
|
83
|
-
}
|
|
84
|
-
}), nt = q.create({
|
|
85
|
-
name: "businessToken",
|
|
86
|
-
group: "inline",
|
|
87
|
-
inline: !0,
|
|
88
|
-
atom: !0,
|
|
89
|
-
selectable: !0,
|
|
90
|
-
addAttributes() {
|
|
91
|
-
return {
|
|
92
|
-
id: { default: "" },
|
|
93
|
-
nodeVersion: { default: 0 },
|
|
94
|
-
kind: { default: "variable" },
|
|
95
|
-
key: { default: "" },
|
|
96
|
-
label: { default: "" },
|
|
97
|
-
token: { default: null },
|
|
98
|
-
params: { default: null }
|
|
99
|
-
};
|
|
100
|
-
},
|
|
101
|
-
parseHTML() {
|
|
102
|
-
return [
|
|
103
|
-
{
|
|
104
|
-
tag: "span[data-business-token]",
|
|
105
|
-
getAttrs: (r) => ({
|
|
106
|
-
kind: r.getAttribute("data-kind"),
|
|
107
|
-
key: r.getAttribute("data-key"),
|
|
108
|
-
label: r.getAttribute("data-label") || r.textContent,
|
|
109
|
-
token: r.getAttribute("data-token"),
|
|
110
|
-
params: null
|
|
111
|
-
})
|
|
112
|
-
}
|
|
113
|
-
];
|
|
114
|
-
},
|
|
115
|
-
renderHTML({ node: r }) {
|
|
116
|
-
const c = ue(r.attrs.kind) ? r.attrs.kind : null, h = c === "todo" ? A.Followup : c === "attribute" ? A.data : A["AI-ticket"], l = r.attrs.kind === "variable" ? A.variate : r.attrs.kind === "separator" ? A.sep : null, k = r.attrs.kind === "tool" ? et(r.attrs.key, r.attrs.params) : null, S = k ? r.attrs.key === "order_note" ? " fkp-tool-note fkp-tool-note--order-note" : " fkp-tool-note fkp-tool-note--small-payment" : "", v = r.attrs.kind === "tool" && !k, o = String(r.attrs.label || r.attrs.key || ""), C = o.startsWith("#") && o.endsWith("#") ? o : `#${o}#`, { summary: b } = k || { summary: "" };
|
|
117
|
-
return [
|
|
118
|
-
"span",
|
|
119
|
-
{
|
|
120
|
-
"data-business-token": "",
|
|
121
|
-
"data-kind": r.attrs.kind,
|
|
122
|
-
"data-key": r.attrs.key,
|
|
123
|
-
"data-node-id": r.attrs.id,
|
|
124
|
-
"data-token": r.attrs.token,
|
|
125
|
-
...k || c || l || v ? {
|
|
126
|
-
"data-label": r.attrs.label,
|
|
127
|
-
"aria-label": k ? b ? `${k.label}:${b}` : k.label : l ? String(r.attrs.label) : `${c === "todo" ? "待办" : c === "attribute" ? "属性" : "工单"}:${r.attrs.label}`
|
|
128
|
-
} : {},
|
|
129
|
-
class: `fk-token fk-token--${r.attrs.kind} fkp-knowledge-tag fkp-knowledge-tag--${r.attrs.kind}${S}`,
|
|
130
|
-
contenteditable: "false"
|
|
131
|
-
},
|
|
132
|
-
...k ? [
|
|
133
|
-
[
|
|
134
|
-
"span",
|
|
135
|
-
{ class: "fkp-icon fkp-tool-note-icon", "aria-hidden": "true" },
|
|
136
|
-
k.iconGlyph
|
|
137
|
-
],
|
|
138
|
-
["span", { class: "fkp-tool-note-label" }, k.label],
|
|
139
|
-
...b ? [
|
|
140
|
-
[
|
|
141
|
-
"span",
|
|
142
|
-
{ class: "fkp-tool-note-divider", "aria-hidden": "true" }
|
|
143
|
-
],
|
|
144
|
-
["span", { class: "fkp-tool-note-summary" }, b]
|
|
145
|
-
] : []
|
|
146
|
-
] : c ? [
|
|
147
|
-
[
|
|
148
|
-
"span",
|
|
149
|
-
{
|
|
150
|
-
class: `fkp-icon fkp-${c}-token-icon`,
|
|
151
|
-
"aria-hidden": "true"
|
|
152
|
-
},
|
|
153
|
-
h
|
|
154
|
-
],
|
|
155
|
-
[
|
|
156
|
-
"span",
|
|
157
|
-
{ class: `fkp-${c}-token-label` },
|
|
158
|
-
r.attrs.label
|
|
159
|
-
],
|
|
160
|
-
[
|
|
161
|
-
"span",
|
|
162
|
-
{
|
|
163
|
-
class: `fkp-icon fkp-${c}-token-arrow`,
|
|
164
|
-
"aria-hidden": "true"
|
|
165
|
-
},
|
|
166
|
-
A["arrow-down"]
|
|
167
|
-
]
|
|
168
|
-
] : v ? [
|
|
169
|
-
[
|
|
170
|
-
"span",
|
|
171
|
-
{
|
|
172
|
-
class: "fkp-icon fkp-tool-token-icon",
|
|
173
|
-
"aria-hidden": "true"
|
|
174
|
-
},
|
|
175
|
-
A.tool
|
|
176
|
-
],
|
|
177
|
-
["span", { class: "fkp-tool-token-label" }, r.attrs.label]
|
|
178
|
-
] : l ? [
|
|
179
|
-
[
|
|
180
|
-
"span",
|
|
181
|
-
{
|
|
182
|
-
class: "fkp-icon fkp-inline-token-icon",
|
|
183
|
-
"aria-hidden": "true"
|
|
184
|
-
},
|
|
185
|
-
l
|
|
186
|
-
],
|
|
187
|
-
[
|
|
188
|
-
"span",
|
|
189
|
-
{ class: "fkp-inline-token-label" },
|
|
190
|
-
r.attrs.kind === "variable" ? C : r.attrs.label
|
|
191
|
-
]
|
|
192
|
-
] : [r.attrs.label]
|
|
193
|
-
];
|
|
194
|
-
},
|
|
195
|
-
renderText({ node: r }) {
|
|
196
|
-
const c = r.attrs.kind;
|
|
197
|
-
return c === "variable" ? String(r.attrs.token || `#${r.attrs.key}#`) : c === "todo" ? `{待办@${r.attrs.key}}` : c === "attribute" ? `{属性@${r.attrs.key}}` : c === "tool" ? `{工具@${r.attrs.key}}` : c === "separator" ? "{分隔符}" : String(r.attrs.label || r.attrs.key || "");
|
|
198
|
-
}
|
|
199
|
-
}), at = q.create({
|
|
200
|
-
name: "originalReply",
|
|
201
|
-
group: "block",
|
|
202
|
-
content: "(paragraph | mediaBlock | messageSeparator)+",
|
|
203
|
-
defining: !0,
|
|
204
|
-
isolating: !0,
|
|
205
|
-
addAttributes() {
|
|
206
|
-
return { id: { default: "" }, nodeVersion: { default: 0 } };
|
|
207
|
-
},
|
|
208
|
-
parseHTML() {
|
|
209
|
-
return [{ tag: "section[data-original-reply]" }];
|
|
210
|
-
},
|
|
211
|
-
renderHTML() {
|
|
212
|
-
return [
|
|
213
|
-
"section",
|
|
214
|
-
{ "data-original-reply": "", class: "fk-original-reply" },
|
|
215
|
-
0
|
|
216
|
-
];
|
|
217
|
-
}
|
|
218
|
-
}), rt = q.create({
|
|
219
|
-
name: "messageSeparator",
|
|
220
|
-
group: "block",
|
|
221
|
-
atom: !0,
|
|
222
|
-
selectable: !0,
|
|
223
|
-
addAttributes() {
|
|
224
|
-
return { id: { default: "" }, nodeVersion: { default: 0 } };
|
|
225
|
-
},
|
|
226
|
-
parseHTML() {
|
|
227
|
-
return [{ tag: "div[data-message-separator]" }];
|
|
228
|
-
},
|
|
229
|
-
renderHTML() {
|
|
230
|
-
return [
|
|
231
|
-
"div",
|
|
232
|
-
{ "data-message-separator": "", class: "fk-message-separator" },
|
|
233
|
-
[
|
|
234
|
-
"span",
|
|
235
|
-
{
|
|
236
|
-
class: "fk-separator-tag fkp-knowledge-tag fkp-knowledge-tag--primary"
|
|
237
|
-
},
|
|
238
|
-
"分隔符"
|
|
239
|
-
]
|
|
240
|
-
];
|
|
241
|
-
},
|
|
242
|
-
renderText() {
|
|
243
|
-
return `
|
|
244
|
-
{分隔符}
|
|
245
|
-
`;
|
|
246
|
-
}
|
|
247
|
-
});
|
|
248
|
-
function st(r) {
|
|
249
|
-
return pe(r, r.state.selection.getBookmark());
|
|
250
|
-
}
|
|
251
|
-
function ot(r, c, h) {
|
|
252
|
-
if (r.isDestroyed || !Number.isFinite(c) || !Number.isFinite(h))
|
|
253
|
-
return null;
|
|
254
|
-
try {
|
|
255
|
-
const l = r.view.posAtCoords({ left: c, top: h });
|
|
256
|
-
if (!l || !Number.isInteger(l.pos)) return null;
|
|
257
|
-
const k = je.near(r.state.doc.resolve(l.pos));
|
|
258
|
-
return pe(r, k.getBookmark());
|
|
259
|
-
} catch {
|
|
260
|
-
return null;
|
|
261
|
-
}
|
|
262
|
-
}
|
|
263
|
-
function pe(r, c) {
|
|
264
|
-
let h = c, l = !0, k = !0, S = !1, { from: v, to: o } = c.resolve(r.state.doc);
|
|
265
|
-
const C = ({ transaction: b }) => {
|
|
266
|
-
const p = b.mapping.mapResult(v, 1), M = b.mapping.mapResult(o, -1);
|
|
267
|
-
!S && (p.deletedAcross || M.deletedAcross) && (k = !1), v = p.pos, o = M.pos, h = h.map(b.mapping);
|
|
268
|
-
};
|
|
269
|
-
return r.on("transaction", C), {
|
|
270
|
-
status() {
|
|
271
|
-
return !l || r.isDestroyed ? "disposed" : k ? "ready" : "lost";
|
|
272
|
-
},
|
|
273
|
-
insert(b) {
|
|
274
|
-
if (!l || !k || r.isDestroyed) return !1;
|
|
275
|
-
try {
|
|
276
|
-
const p = h.resolve(r.state.doc);
|
|
277
|
-
S = !0;
|
|
278
|
-
try {
|
|
279
|
-
return r.chain().setMeta(x, R(b)).insertContentAt(
|
|
280
|
-
{ from: p.from, to: p.to },
|
|
281
|
-
b
|
|
282
|
-
).run();
|
|
283
|
-
} finally {
|
|
284
|
-
S = !1;
|
|
285
|
-
}
|
|
286
|
-
} catch {
|
|
287
|
-
return !1;
|
|
288
|
-
}
|
|
289
|
-
},
|
|
290
|
-
dispose() {
|
|
291
|
-
l && (l = !1, r.off("transaction", C));
|
|
292
|
-
}
|
|
293
|
-
};
|
|
294
|
-
}
|
|
295
|
-
const it = {
|
|
296
|
-
key: 0,
|
|
297
|
-
class: "fkp-knowledge-area",
|
|
298
|
-
role: "alert"
|
|
299
|
-
}, lt = {
|
|
300
|
-
key: 0,
|
|
301
|
-
class: "fkp-reference-placeholder",
|
|
302
|
-
"aria-hidden": "true"
|
|
303
|
-
}, bt = /* @__PURE__ */ De({
|
|
304
|
-
__name: "KnowledgeArea",
|
|
305
|
-
props: {
|
|
306
|
-
modelValue: {},
|
|
307
|
-
editable: { type: Boolean },
|
|
308
|
-
placeholder: {},
|
|
309
|
-
referencePlaceholder: { type: Boolean },
|
|
310
|
-
schemaPlan: {},
|
|
311
|
-
activeChoiceId: {}
|
|
312
|
-
},
|
|
313
|
-
emits: ["update:modelValue", "retry-media", "load-error", "edit-tool", "choice-menu", "leave-choice"],
|
|
314
|
-
setup(r, { expose: c, emit: h }) {
|
|
315
|
-
const l = r;
|
|
316
|
-
let k = !1;
|
|
317
|
-
const S = h, v = /* @__PURE__ */ new Map(), o = Oe(), C = L(), b = L(!0), p = L(!1);
|
|
318
|
-
let M = !1, g = null, I = null, V = !1;
|
|
319
|
-
const P = `[data-business-token]:is(${Ye.map(
|
|
320
|
-
(e) => `[data-kind="${e}"]`
|
|
321
|
-
).join(", ")})`;
|
|
322
|
-
function D(e) {
|
|
323
|
-
const t = v.get(e);
|
|
324
|
-
t && (URL.revokeObjectURL(t), v.delete(e));
|
|
325
|
-
}
|
|
326
|
-
function U(e) {
|
|
327
|
-
return !l.editable || !(e.target instanceof Element) ? null : e.target.closest(P);
|
|
328
|
-
}
|
|
329
|
-
function me(e) {
|
|
330
|
-
const t = U(e);
|
|
331
|
-
!t || e.relatedTarget instanceof Node && t.contains(e.relatedTarget) || j(t);
|
|
332
|
-
}
|
|
333
|
-
function ke(e) {
|
|
334
|
-
const t = U(e);
|
|
335
|
-
t && (!(e.relatedTarget instanceof Node) || !t.contains(e.relatedTarget)) && S("leave-choice");
|
|
336
|
-
}
|
|
337
|
-
function j(e) {
|
|
338
|
-
const { nodeId: t } = e.dataset;
|
|
339
|
-
!t || !o.value || o.value.state.doc.descendants((n) => n.type.name !== "businessToken" || n.attrs.id !== t ? !0 : (ue(n.attrs.kind) && S("choice-menu", {
|
|
340
|
-
nodeId: t,
|
|
341
|
-
nodeVersion: Number(n.attrs.nodeVersion) || 0,
|
|
342
|
-
key: String(n.attrs.key),
|
|
343
|
-
kind: n.attrs.kind,
|
|
344
|
-
anchor: e
|
|
345
|
-
}), !1));
|
|
346
|
-
}
|
|
347
|
-
function ge(e) {
|
|
348
|
-
if (!l.editable || !o.value) return;
|
|
349
|
-
const { target: t } = e;
|
|
350
|
-
if (!(t instanceof Element)) return;
|
|
351
|
-
const n = U(e);
|
|
352
|
-
if (n) {
|
|
353
|
-
j(n);
|
|
354
|
-
return;
|
|
355
|
-
}
|
|
356
|
-
const a = t.closest(
|
|
357
|
-
'[data-business-token][data-kind="tool"]'
|
|
358
|
-
), s = a == null ? void 0 : a.dataset.nodeId;
|
|
359
|
-
s && o.value.state.doc.descendants((d) => {
|
|
360
|
-
if (d.type.name !== "businessToken" || d.attrs.id !== s)
|
|
361
|
-
return !0;
|
|
362
|
-
const { params: f } = d.attrs;
|
|
363
|
-
return S("edit-tool", {
|
|
364
|
-
nodeId: s,
|
|
365
|
-
nodeVersion: Number(d.attrs.nodeVersion) || 0,
|
|
366
|
-
key: String(d.attrs.key),
|
|
367
|
-
label: String(d.attrs.label || d.attrs.key),
|
|
368
|
-
params: f && typeof f == "object" && !Array.isArray(f) ? f : null
|
|
369
|
-
}), !1;
|
|
370
|
-
});
|
|
371
|
-
}
|
|
372
|
-
function G() {
|
|
373
|
-
var e;
|
|
374
|
-
(e = C.value) == null || e.querySelectorAll(P).forEach(
|
|
375
|
-
(t) => t.classList.toggle(
|
|
376
|
-
"is-menu-open",
|
|
377
|
-
!!l.activeChoiceId && t.dataset.nodeId === l.activeChoiceId
|
|
378
|
-
)
|
|
379
|
-
);
|
|
380
|
-
}
|
|
381
|
-
H(
|
|
382
|
-
[() => l.activeChoiceId, () => l.modelValue],
|
|
383
|
-
() => void se(G)
|
|
384
|
-
);
|
|
385
|
-
function ye(e) {
|
|
386
|
-
var n;
|
|
387
|
-
const t = e.target instanceof Element ? e.target.closest(".fk-media[data-drag-handle]") : null;
|
|
388
|
-
!l.editable || !(t != null && t.dataset.mediaId) || (g = t.dataset.mediaId, (n = e.dataTransfer) == null || n.setData("application/x-fkp-media-id", g), e.dataTransfer && (e.dataTransfer.effectAllowed = "move"), e.stopPropagation());
|
|
389
|
-
}
|
|
390
|
-
function he(e) {
|
|
391
|
-
!g || !l.editable || (e.preventDefault(), e.stopPropagation(), e.dataTransfer && (e.dataTransfer.dropEffect = "move"));
|
|
392
|
-
}
|
|
393
|
-
function be(e) {
|
|
394
|
-
const t = g;
|
|
395
|
-
if (!t) return;
|
|
396
|
-
g = null, e.preventDefault(), e.stopPropagation();
|
|
397
|
-
const n = o.value;
|
|
398
|
-
if (!l.editable || !n || n.isDestroyed) return;
|
|
399
|
-
const a = /* @__PURE__ */ new Map();
|
|
400
|
-
n.state.doc.descendants((u, T) => {
|
|
401
|
-
u.type.name === "mediaBlock" && typeof u.attrs.id == "string" && a.set(u.attrs.id, { pos: T, size: u.nodeSize });
|
|
402
|
-
});
|
|
403
|
-
const s = a.get(t);
|
|
404
|
-
if (!s) return;
|
|
405
|
-
const d = e.target instanceof Element ? e.target.closest(".fk-media[data-media-id]") : null, f = d == null ? void 0 : d.dataset.mediaId;
|
|
406
|
-
if (f === t) return;
|
|
407
|
-
let i;
|
|
408
|
-
const m = f ? a.get(f) : void 0;
|
|
409
|
-
if (m && d) {
|
|
410
|
-
const u = s.pos < m.pos;
|
|
411
|
-
i = m.pos + (u ? m.size : 0);
|
|
412
|
-
} else {
|
|
413
|
-
const u = n.view.posAtCoords({
|
|
414
|
-
left: e.clientX,
|
|
415
|
-
top: e.clientY
|
|
416
|
-
});
|
|
417
|
-
if (!u) return;
|
|
418
|
-
const T = [0];
|
|
419
|
-
n.state.doc.forEach((N, E) => {
|
|
420
|
-
T.push(E + N.nodeSize);
|
|
421
|
-
}), i = T.reduce(
|
|
422
|
-
(N, E) => Math.abs(E - u.pos) < Math.abs(N - u.pos) ? E : N
|
|
423
|
-
);
|
|
424
|
-
}
|
|
425
|
-
if (i === s.pos || i === s.pos + s.size)
|
|
426
|
-
return;
|
|
427
|
-
const y = n.state.doc.nodeAt(s.pos);
|
|
428
|
-
if (!(!y || y.type.name !== "mediaBlock"))
|
|
429
|
-
try {
|
|
430
|
-
const u = n.state.tr.delete(
|
|
431
|
-
s.pos,
|
|
432
|
-
s.pos + s.size
|
|
433
|
-
);
|
|
434
|
-
u.insert(u.mapping.map(i), y), u.setMeta("uiEvent", "drop"), u.setMeta(x, [t]), n.view.dispatch(u);
|
|
435
|
-
} catch {
|
|
436
|
-
}
|
|
437
|
-
}
|
|
438
|
-
function ve() {
|
|
439
|
-
g = null;
|
|
440
|
-
}
|
|
441
|
-
function z(e) {
|
|
442
|
-
const t = /* @__PURE__ */ new Set(), n = (a) => {
|
|
443
|
-
var s, d;
|
|
444
|
-
a.type === "mediaBlock" && typeof ((s = a.attrs) == null ? void 0 : s.id) == "string" && t.add(a.attrs.id), (d = a.content) == null || d.forEach(n);
|
|
445
|
-
};
|
|
446
|
-
n(e);
|
|
447
|
-
for (const a of v.keys()) t.has(a) || D(a);
|
|
448
|
-
}
|
|
449
|
-
function K(e) {
|
|
450
|
-
o.value = new Fe({
|
|
451
|
-
content: l.modelValue,
|
|
452
|
-
editable: l.editable,
|
|
453
|
-
extensions: [
|
|
454
|
-
Ke.configure({
|
|
455
|
-
heading: !1,
|
|
456
|
-
link: { openOnClick: !1, isAllowedUri: (t) => Qe(t) }
|
|
457
|
-
}),
|
|
458
|
-
We.configure({
|
|
459
|
-
placeholder: () => l.referencePlaceholder ? "" : l.placeholder || "填写知识内容"
|
|
460
|
-
}),
|
|
461
|
-
tt,
|
|
462
|
-
...l.schemaPlan.businessToken ? [nt] : [],
|
|
463
|
-
...l.schemaPlan.originalReply ? [at] : [],
|
|
464
|
-
...l.schemaPlan.separator ? [rt] : [],
|
|
465
|
-
...e
|
|
466
|
-
],
|
|
467
|
-
editorProps: {
|
|
468
|
-
attributes: {
|
|
469
|
-
class: "fkp-knowledge-document",
|
|
470
|
-
role: "textbox",
|
|
471
|
-
"aria-label": "知识内容",
|
|
472
|
-
"aria-multiline": "true"
|
|
473
|
-
}
|
|
474
|
-
},
|
|
475
|
-
onUpdate: ({ editor: t }) => {
|
|
476
|
-
b.value = t.isEmpty;
|
|
477
|
-
const n = t.getJSON();
|
|
478
|
-
z(n), k || S("update:modelValue", n);
|
|
479
|
-
}
|
|
480
|
-
}), b.value = o.value.isEmpty, G(), re();
|
|
481
|
-
}
|
|
482
|
-
Re(() => {
|
|
483
|
-
if (!l.schemaPlan.mediaBlock) {
|
|
484
|
-
K([]);
|
|
485
|
-
return;
|
|
486
|
-
}
|
|
487
|
-
import("./media-extensions-ZoxmhIhH.js").then(({ MediaBlock: e }) => {
|
|
488
|
-
M || K([e.configure({ sceneStyle: !0 })]);
|
|
489
|
-
}).catch(() => {
|
|
490
|
-
M || (p.value = !0, S("load-error", "媒体编辑器加载失败,请刷新页面重试"));
|
|
491
|
-
});
|
|
492
|
-
}), H(
|
|
493
|
-
() => l.editable,
|
|
494
|
-
(e) => {
|
|
495
|
-
var t;
|
|
496
|
-
return (t = o.value) == null ? void 0 : t.setEditable(e);
|
|
497
|
-
}
|
|
498
|
-
), H(
|
|
499
|
-
() => l.modelValue,
|
|
500
|
-
(e) => {
|
|
501
|
-
if (o.value && de(e) !== de(o.value.getJSON())) {
|
|
502
|
-
const t = ne();
|
|
503
|
-
o.value.chain().setMeta(x, R(e)).setContent(e, { emitUpdate: !1 }).run(), b.value = o.value.isEmpty, z(e), t && ae(o.value, t);
|
|
504
|
-
}
|
|
505
|
-
},
|
|
506
|
-
{ deep: !0 }
|
|
507
|
-
), Ue(() => {
|
|
508
|
-
var e;
|
|
509
|
-
M = !0, g = null;
|
|
510
|
-
for (const t of v.keys()) D(t);
|
|
511
|
-
(e = o.value) == null || e.destroy();
|
|
512
|
-
});
|
|
513
|
-
function W(e, t, n, a) {
|
|
514
|
-
var s;
|
|
515
|
-
!l.editable || !l.schemaPlan.businessToken || (s = o.value) == null || s.chain().focus().insertContent([
|
|
516
|
-
{ type: "businessToken", attrs: { kind: e, key: t, label: n, token: a } },
|
|
517
|
-
{ type: "text", text: " " }
|
|
518
|
-
]).run();
|
|
519
|
-
}
|
|
520
|
-
function Se() {
|
|
521
|
-
var t;
|
|
522
|
-
if (!l.editable || !l.schemaPlan.originalReply) return;
|
|
523
|
-
((t = o.value) == null ? void 0 : t.chain().focus().insertContent([
|
|
524
|
-
{ type: "originalReply", content: [{ type: "paragraph" }] },
|
|
525
|
-
{ type: "paragraph" }
|
|
526
|
-
]).run()) && X();
|
|
527
|
-
}
|
|
528
|
-
function Me() {
|
|
529
|
-
W("separator", "separator", "分隔符", "{分隔符}");
|
|
530
|
-
}
|
|
531
|
-
function X() {
|
|
532
|
-
const e = o.value;
|
|
533
|
-
if (!e) return;
|
|
534
|
-
const t = e.state.selection.from;
|
|
535
|
-
let n = null;
|
|
536
|
-
e.state.doc.descendants((a, s) => {
|
|
537
|
-
a.type.name === "originalReply" && s < t && (n = s);
|
|
538
|
-
}), n !== null && e.commands.setTextSelection(n + 2);
|
|
539
|
-
}
|
|
540
|
-
function Te(e, t, n) {
|
|
541
|
-
if (!l.editable || !o.value || !e.length) return null;
|
|
542
|
-
k = !0;
|
|
543
|
-
try {
|
|
544
|
-
const a = t.insert(e);
|
|
545
|
-
return a && e.some((s) => s.type === "originalReply") && X(), a && n && o.value.commands.focus(), a ? o.value.getJSON() : null;
|
|
546
|
-
} finally {
|
|
547
|
-
k = !1;
|
|
548
|
-
}
|
|
549
|
-
}
|
|
550
|
-
function Ie(e) {
|
|
551
|
-
if (!(!o.value || o.value.isDestroyed)) {
|
|
552
|
-
k = !0;
|
|
553
|
-
try {
|
|
554
|
-
o.value.chain().setMeta("addToHistory", !1).setMeta(x, R(e)).setContent(e, { emitUpdate: !1 }).run(), b.value = o.value.isEmpty, z(e);
|
|
555
|
-
} finally {
|
|
556
|
-
k = !1;
|
|
557
|
-
}
|
|
558
|
-
}
|
|
559
|
-
}
|
|
560
|
-
function Q() {
|
|
561
|
-
var t;
|
|
562
|
-
const e = new Set(v.keys());
|
|
563
|
-
return (t = o.value) == null || t.state.doc.descendants((n) => {
|
|
564
|
-
n.attrs.id && e.add(String(n.attrs.id));
|
|
565
|
-
}), ce(e, fe);
|
|
566
|
-
}
|
|
567
|
-
function Ne(e, t, n) {
|
|
568
|
-
var s;
|
|
569
|
-
if (!l.editable || !l.schemaPlan.mediaBlock) return !1;
|
|
570
|
-
const a = [
|
|
571
|
-
{
|
|
572
|
-
type: "mediaBlock",
|
|
573
|
-
attrs: {
|
|
574
|
-
id: Q(),
|
|
575
|
-
nodeVersion: 0,
|
|
576
|
-
assetId: e.id || null,
|
|
577
|
-
src: e.url,
|
|
578
|
-
kind: e.kind,
|
|
579
|
-
name: t,
|
|
580
|
-
poster: e.posterUrl || null,
|
|
581
|
-
status: "ready"
|
|
582
|
-
}
|
|
583
|
-
},
|
|
584
|
-
{ type: "paragraph" }
|
|
585
|
-
];
|
|
586
|
-
return n ? n.insert(a) : ((s = o.value) == null ? void 0 : s.chain().setMeta(x, R(a)).focus().insertContent(a).run()) || !1;
|
|
587
|
-
}
|
|
588
|
-
function Ce(e, t, n) {
|
|
589
|
-
if (!l.editable || !l.schemaPlan.mediaBlock || !o.value)
|
|
590
|
-
return null;
|
|
591
|
-
const a = Q();
|
|
592
|
-
let s;
|
|
593
|
-
try {
|
|
594
|
-
s = URL.createObjectURL(e);
|
|
595
|
-
} catch {
|
|
596
|
-
return null;
|
|
597
|
-
}
|
|
598
|
-
return v.set(a, s), n.insert([
|
|
599
|
-
{
|
|
600
|
-
type: "mediaBlock",
|
|
601
|
-
attrs: {
|
|
602
|
-
id: a,
|
|
603
|
-
nodeVersion: 0,
|
|
604
|
-
assetId: null,
|
|
605
|
-
src: s,
|
|
606
|
-
kind: t,
|
|
607
|
-
name: e.name,
|
|
608
|
-
poster: null,
|
|
609
|
-
status: "uploading",
|
|
610
|
-
error: ""
|
|
611
|
-
}
|
|
612
|
-
},
|
|
613
|
-
{ type: "paragraph" }
|
|
614
|
-
]) ? a : (D(a), null);
|
|
615
|
-
}
|
|
616
|
-
function Y(e) {
|
|
617
|
-
const t = o.value;
|
|
618
|
-
if (!t || t.isDestroyed) return null;
|
|
619
|
-
let n = null;
|
|
620
|
-
return t.state.doc.descendants((a) => {
|
|
621
|
-
a.type.name === "mediaBlock" && a.attrs.id === e && Number.isSafeInteger(a.attrs.nodeVersion) && a.attrs.nodeVersion >= 0 && (n = {
|
|
622
|
-
kind: a.attrs.kind,
|
|
623
|
-
status: a.attrs.status,
|
|
624
|
-
nodeVersion: a.attrs.nodeVersion
|
|
625
|
-
});
|
|
626
|
-
}), n;
|
|
627
|
-
}
|
|
628
|
-
function Z(e, t, n, a) {
|
|
629
|
-
const s = o.value;
|
|
630
|
-
if (!s || s.isDestroyed || !Number.isSafeInteger(t) || t < 0 || t >= Number.MAX_SAFE_INTEGER)
|
|
631
|
-
return !1;
|
|
632
|
-
let d = null;
|
|
633
|
-
if (s.state.doc.descendants((i, m) => {
|
|
634
|
-
i.type.name === "mediaBlock" && i.attrs.id === e && (d = m);
|
|
635
|
-
}), d === null) return !1;
|
|
636
|
-
const f = s.state.doc.nodeAt(d);
|
|
637
|
-
return !f || f.attrs.nodeVersion !== t || f.attrs.status !== n ? !1 : (s.view.dispatch(
|
|
638
|
-
s.state.tr.setNodeMarkup(d, void 0, {
|
|
639
|
-
...f.attrs,
|
|
640
|
-
...a,
|
|
641
|
-
nodeVersion: t + 1
|
|
642
|
-
}).setMeta("addToHistory", !1)
|
|
643
|
-
), !0);
|
|
644
|
-
}
|
|
645
|
-
function we(e, t) {
|
|
646
|
-
var f, i, m, y;
|
|
647
|
-
const n = o.value;
|
|
648
|
-
if (!l.editable || !n || n.isDestroyed) return !1;
|
|
649
|
-
let a = null, s = 0;
|
|
650
|
-
if (n.state.doc.descendants((u, T) => {
|
|
651
|
-
u.type.name === "mediaBlock" && u.attrs.id === e.nodeId && (a = T, s++);
|
|
652
|
-
}), s !== 1 || a === null) return !1;
|
|
653
|
-
const d = n.state.doc.nodeAt(a);
|
|
654
|
-
if (!d || d.attrs.kind !== t || d.attrs.status !== "uploading" || d.attrs.nodeVersion !== e.expectedNodeVersion || e.node.type !== "mediaBlock" || ((f = e.node.attrs) == null ? void 0 : f.id) !== e.nodeId || ((i = e.node.attrs) == null ? void 0 : i.kind) !== t || ((m = e.node.attrs) == null ? void 0 : m.nodeVersion) !== e.expectedNodeVersion + 1)
|
|
655
|
-
return !1;
|
|
656
|
-
try {
|
|
657
|
-
n.view.dispatch(
|
|
658
|
-
n.state.tr.setNodeMarkup(a, void 0, e.node.attrs).setMeta("addToHistory", !1)
|
|
659
|
-
);
|
|
660
|
-
} catch {
|
|
661
|
-
return !1;
|
|
662
|
-
}
|
|
663
|
-
return ((y = Y(e.nodeId)) == null ? void 0 : y.status) !== "ready" ? !1 : (D(e.nodeId), !0);
|
|
664
|
-
}
|
|
665
|
-
function ee(e, t) {
|
|
666
|
-
var d, f;
|
|
667
|
-
const n = o.value;
|
|
668
|
-
if (!l.editable || !n || n.isDestroyed || !e.length)
|
|
669
|
-
return null;
|
|
670
|
-
const a = /* @__PURE__ */ new Set(), s = [];
|
|
671
|
-
for (const i of e) {
|
|
672
|
-
if (a.has(i.nodeId)) return null;
|
|
673
|
-
a.add(i.nodeId);
|
|
674
|
-
let m = null, y = 0;
|
|
675
|
-
if (n.state.doc.descendants((T, N) => {
|
|
676
|
-
B(T.type.name) && T.attrs.id === i.nodeId && (m = N, y++);
|
|
677
|
-
}), y !== 1 || m === null) return null;
|
|
678
|
-
const u = n.state.doc.nodeAt(m);
|
|
679
|
-
if (!u || le(u.type.name, u.attrs) !== t || u.attrs.nodeVersion !== i.expectedNodeVersion || u.type.name === "originalReply" && Ze(u.toJSON()) || i.kind === "updateNode" && (u.type.name === "mediaBlock" || i.node.type !== u.type.name || ((d = i.node.attrs) == null ? void 0 : d.id) !== i.nodeId || ((f = i.node.attrs) == null ? void 0 : f.nodeVersion) !== i.expectedNodeVersion + 1 || le(i.node.type, i.node.attrs) !== t))
|
|
680
|
-
return null;
|
|
681
|
-
s.push({ plan: i, position: m, size: u.nodeSize });
|
|
682
|
-
}
|
|
683
|
-
try {
|
|
684
|
-
let i = n.state.tr;
|
|
685
|
-
for (const { plan: m, position: y, size: u } of s.sort(
|
|
686
|
-
(T, N) => N.position - T.position
|
|
687
|
-
))
|
|
688
|
-
m.kind === "removeNode" ? i = i.delete(y, y + u) : i = i.replaceWith(
|
|
689
|
-
y,
|
|
690
|
-
y + u,
|
|
691
|
-
n.schema.nodeFromJSON(m.node)
|
|
692
|
-
);
|
|
693
|
-
return i.doc.check(), i.setMeta(
|
|
694
|
-
x,
|
|
695
|
-
e.filter((m) => m.kind === "updateNode").map((m) => m.nodeId)
|
|
696
|
-
), { transaction: i, requestedIds: a };
|
|
697
|
-
} catch {
|
|
698
|
-
return null;
|
|
699
|
-
}
|
|
700
|
-
}
|
|
701
|
-
function Ae(e, t) {
|
|
702
|
-
var n;
|
|
703
|
-
return ((n = ee(e, t)) == null ? void 0 : n.transaction.doc.toJSON()) || null;
|
|
704
|
-
}
|
|
705
|
-
function te(e, t) {
|
|
706
|
-
const n = ee(e, t), a = o.value;
|
|
707
|
-
if (!n || !a || a.isDestroyed) return !1;
|
|
708
|
-
const { transaction: s, requestedIds: d } = n;
|
|
709
|
-
try {
|
|
710
|
-
a.view.dispatch(s);
|
|
711
|
-
} catch {
|
|
712
|
-
return !1;
|
|
713
|
-
}
|
|
714
|
-
const f = /* @__PURE__ */ new Map();
|
|
715
|
-
return a.state.doc.descendants((i) => {
|
|
716
|
-
B(i.type.name) && d.has(i.attrs.id) && f.set(i.attrs.id, i.attrs.nodeVersion);
|
|
717
|
-
}), e.every(
|
|
718
|
-
(i) => i.kind === "removeNode" ? !f.has(i.nodeId) : f.get(i.nodeId) === i.expectedNodeVersion + 1
|
|
719
|
-
);
|
|
720
|
-
}
|
|
721
|
-
function Ee(e, t) {
|
|
722
|
-
return te([e], t);
|
|
723
|
-
}
|
|
724
|
-
function xe(e, t, n) {
|
|
725
|
-
return Z(e, n, "uploading", {
|
|
726
|
-
status: "error",
|
|
727
|
-
error: t
|
|
728
|
-
});
|
|
729
|
-
}
|
|
730
|
-
function Ve(e, t) {
|
|
731
|
-
return Z(e, t, "error", {
|
|
732
|
-
status: "uploading",
|
|
733
|
-
error: ""
|
|
734
|
-
});
|
|
735
|
-
}
|
|
736
|
-
function Pe(e, t, n) {
|
|
737
|
-
const a = o.value;
|
|
738
|
-
if (!a || a.isDestroyed || !Number.isFinite(n))
|
|
739
|
-
return !1;
|
|
740
|
-
let s = !1;
|
|
741
|
-
return a.state.doc.descendants((d) => {
|
|
742
|
-
d.type.name === "mediaBlock" && d.attrs.id === e && d.attrs.status === "uploading" && d.attrs.nodeVersion === t && (s = !0);
|
|
743
|
-
}), s ? (a.view.dom.dispatchEvent(
|
|
744
|
-
new CustomEvent("fkp-media-progress", {
|
|
745
|
-
detail: { id: e, percent: Math.round(Math.max(0, Math.min(100, n))) }
|
|
746
|
-
})
|
|
747
|
-
), !0) : !1;
|
|
748
|
-
}
|
|
749
|
-
function $e(e) {
|
|
750
|
-
var n;
|
|
751
|
-
const t = (n = e.detail) == null ? void 0 : n.id;
|
|
752
|
-
typeof t == "string" && S("retry-media", t);
|
|
753
|
-
}
|
|
754
|
-
function ne() {
|
|
755
|
-
const e = o.value;
|
|
756
|
-
if (!e || e.isDestroyed) return null;
|
|
757
|
-
const { selection: t } = e.state;
|
|
758
|
-
let n;
|
|
759
|
-
if (t instanceof Ge && t.empty) {
|
|
760
|
-
const { $from: a } = t, s = a.start();
|
|
761
|
-
if (a.parent.forEach((d, f) => {
|
|
762
|
-
if (d.type.name !== "businessToken" || !d.attrs.id) return;
|
|
763
|
-
const i = t.from - (s + f + d.nodeSize);
|
|
764
|
-
i >= 0 && i <= 1 && (n = {
|
|
765
|
-
id: String(d.attrs.id),
|
|
766
|
-
kind: "inlineAfter",
|
|
767
|
-
offset: i
|
|
768
|
-
});
|
|
769
|
-
}), !n && a.depth >= 1 && a.parent.isTextblock && a.parentOffset <= 1) {
|
|
770
|
-
const d = a.depth - 1, f = a.index(d), i = a.node(d);
|
|
771
|
-
for (let m = f - 1; m >= 0; m--) {
|
|
772
|
-
const y = i.child(m);
|
|
773
|
-
if (y.type.name === "mediaBlock" && y.attrs.id) {
|
|
774
|
-
n = {
|
|
775
|
-
id: String(y.attrs.id),
|
|
776
|
-
kind: "blockAfter",
|
|
777
|
-
offset: a.parentOffset,
|
|
778
|
-
siblingOffset: f - m
|
|
779
|
-
};
|
|
780
|
-
break;
|
|
781
|
-
}
|
|
782
|
-
if (!y.isTextblock || y.content.size > 0) break;
|
|
783
|
-
}
|
|
784
|
-
}
|
|
785
|
-
}
|
|
786
|
-
return {
|
|
787
|
-
from: t.from,
|
|
788
|
-
to: t.to,
|
|
789
|
-
focused: e.isFocused,
|
|
790
|
-
...n ? { nodeCaret: n } : {}
|
|
791
|
-
};
|
|
792
|
-
}
|
|
793
|
-
function ae(e, t) {
|
|
794
|
-
const n = e.state.doc.content.size;
|
|
795
|
-
let a;
|
|
796
|
-
const { nodeCaret: s } = t;
|
|
797
|
-
s && t.from === t.to && e.state.doc.descendants((m, y) => {
|
|
798
|
-
if (m.attrs.id !== s.id) return;
|
|
799
|
-
if (s.kind === "inlineAfter") {
|
|
800
|
-
if (m.type.name !== "businessToken") return;
|
|
801
|
-
const w = e.state.doc.resolve(y).end();
|
|
802
|
-
a = Math.min(
|
|
803
|
-
y + m.nodeSize + s.offset,
|
|
804
|
-
w
|
|
805
|
-
);
|
|
806
|
-
return;
|
|
807
|
-
}
|
|
808
|
-
if (m.type.name !== "mediaBlock") return;
|
|
809
|
-
const u = e.state.doc.resolve(y), { parent: T } = u, N = u.index(), E = N + s.siblingOffset, O = T.maybeChild(E);
|
|
810
|
-
if (O != null && O.isTextblock && Array.from(
|
|
811
|
-
{ length: s.siblingOffset - 1 },
|
|
812
|
-
(w, $) => T.child(N + $ + 1)
|
|
813
|
-
).every((w) => w.isTextblock && w.content.size === 0)) {
|
|
814
|
-
let w = y;
|
|
815
|
-
for (let $ = N; $ < E; $++)
|
|
816
|
-
w += T.child($).nodeSize;
|
|
817
|
-
a = Math.min(
|
|
818
|
-
w + 1 + s.offset,
|
|
819
|
-
w + O.nodeSize - 1
|
|
820
|
-
);
|
|
821
|
-
}
|
|
822
|
-
});
|
|
823
|
-
const d = {
|
|
824
|
-
from: a ?? Math.min(t.from, n),
|
|
825
|
-
to: a ?? Math.min(t.to, n)
|
|
826
|
-
}, f = document.activeElement;
|
|
827
|
-
t.focused && (!f || f === document.body || f === e.view.dom || !f.isConnected) ? e.chain().setTextSelection(d).focus().run() : e.commands.setTextSelection(d);
|
|
828
|
-
}
|
|
829
|
-
async function re() {
|
|
830
|
-
if (!(V || !I)) {
|
|
831
|
-
V = !0;
|
|
832
|
-
try {
|
|
833
|
-
for (let e = 0; e < 5 && !M; e++) {
|
|
834
|
-
await se();
|
|
835
|
-
const t = o.value;
|
|
836
|
-
if (!t || t.isDestroyed || !t.view.dom.isConnected)
|
|
837
|
-
continue;
|
|
838
|
-
const n = I;
|
|
839
|
-
if (I = null, !n) return;
|
|
840
|
-
ae(t, n);
|
|
841
|
-
return;
|
|
842
|
-
}
|
|
843
|
-
} finally {
|
|
844
|
-
V = !1;
|
|
845
|
-
}
|
|
846
|
-
}
|
|
847
|
-
}
|
|
848
|
-
function Be(e) {
|
|
849
|
-
e && (I = e, re());
|
|
850
|
-
}
|
|
851
|
-
return c({
|
|
852
|
-
isSelectionInsideOriginalReply: () => {
|
|
853
|
-
const e = o.value;
|
|
854
|
-
if (!e) return !1;
|
|
855
|
-
const { selection: t } = e.state;
|
|
856
|
-
for (let { depth: n } = t.$from; n > 0; n--)
|
|
857
|
-
if (t.$from.node(n).type.name === "originalReply")
|
|
858
|
-
return !0;
|
|
859
|
-
return !1;
|
|
860
|
-
},
|
|
861
|
-
insertToken: W,
|
|
862
|
-
insertOriginal: Se,
|
|
863
|
-
insertSeparator: Me,
|
|
864
|
-
insertBatch: Te,
|
|
865
|
-
restoreDoc: Ie,
|
|
866
|
-
insertMedia: Ne,
|
|
867
|
-
insertPendingMedia: Ce,
|
|
868
|
-
applyNodeUpdate: we,
|
|
869
|
-
applyPluginNodeOperation: Ee,
|
|
870
|
-
applyPluginNodeOperations: te,
|
|
871
|
-
previewPluginNodeOperations: Ae,
|
|
872
|
-
failMedia: xe,
|
|
873
|
-
retryMedia: Ve,
|
|
874
|
-
getMediaState: Y,
|
|
875
|
-
reportMediaProgress: Pe,
|
|
876
|
-
captureSelection: ne,
|
|
877
|
-
restoreSelection: Be,
|
|
878
|
-
captureMediaTarget: () => o.value ? st(o.value) : null,
|
|
879
|
-
captureMediaTargetAt: (e, t) => o.value ? ot(o.value, e, t) : null,
|
|
880
|
-
focus: () => {
|
|
881
|
-
var e;
|
|
882
|
-
return (e = o.value) == null ? void 0 : e.commands.focus();
|
|
883
|
-
},
|
|
884
|
-
getJSON: () => {
|
|
885
|
-
var e;
|
|
886
|
-
return (e = o.value) == null ? void 0 : e.getJSON();
|
|
887
|
-
}
|
|
888
|
-
}), (e, t) => p.value ? (_(), F("div", it, "媒体编辑器加载失败,请刷新页面重试")) : (_(), F("div", {
|
|
889
|
-
key: 1,
|
|
890
|
-
ref_key: "areaRoot",
|
|
891
|
-
ref: C,
|
|
892
|
-
class: "fkp-knowledge-area",
|
|
893
|
-
onFkpMediaRetry: $e,
|
|
894
|
-
onClick: ge,
|
|
895
|
-
onMouseover: me,
|
|
896
|
-
onMouseout: ke,
|
|
897
|
-
onDragstartCapture: ye,
|
|
898
|
-
onDragoverCapture: he,
|
|
899
|
-
onDropCapture: be,
|
|
900
|
-
onDragendCapture: ve
|
|
901
|
-
}, [
|
|
902
|
-
oe(ie(_e), { editor: o.value }, null, 8, ["editor"]),
|
|
903
|
-
e.referencePlaceholder && b.value ? (_(), F("div", lt, [
|
|
904
|
-
t[1] || (t[1] = J("span", { class: "fkp-reference-bracket" }, "<", -1)),
|
|
905
|
-
oe(ie(Je), {
|
|
906
|
-
color: "arcoblue",
|
|
907
|
-
size: "small",
|
|
908
|
-
bordered: ""
|
|
909
|
-
}, {
|
|
910
|
-
default: ze(() => t[0] || (t[0] = [
|
|
911
|
-
Le("参考话术")
|
|
912
|
-
])),
|
|
913
|
-
_: 1
|
|
914
|
-
}),
|
|
915
|
-
t[2] || (t[2] = J("span", null, "请填写参考话术", -1)),
|
|
916
|
-
t[3] || (t[3] = J("span", { class: "fkp-reference-bracket" }, ">", -1))
|
|
917
|
-
])) : He("", !0)
|
|
918
|
-
], 544));
|
|
919
|
-
}
|
|
920
|
-
});
|
|
921
|
-
export {
|
|
922
|
-
bt as default
|
|
923
|
-
};
|