@freecallai/pro 0.0.4 → 0.0.5
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/LICENSE +20 -20
- package/README.md +23 -23
- package/dist/FkpKnowledgeTypePicker.vue_vue_type_script_setup_true_lang--MPtqZY_.js +193 -0
- package/dist/FkpRichText.vue_vue_type_script_setup_true_lang-bw74hFS9.js +4980 -0
- package/dist/KnowledgeArea-CEX1esVZ.js +4 -0
- package/dist/KnowledgeArea.vue_vue_type_script_setup_true_lang-Bg1e7xYT.js +1653 -0
- package/dist/ToolForm-DA-EFBhw.js +196 -0
- package/dist/agent-prompt-editor/index.js +917 -0
- package/dist/agent-prompt-editor/legacy-converter/index.js +490 -0
- package/dist/{choice-C1SxozNA.js → choice-2dbddjJU.js} +1 -1
- package/dist/edition-info/index.js +1 -1
- package/dist/filters/index.js +1 -1
- package/dist/{guard-CXpVx8UR.js → guard-Cr_ny-sR.js} +226 -213
- package/dist/index-7x1OTv0m.js +98 -0
- package/dist/{index-CM0MN2DT.js → index-BBxrpF3v.js} +1 -1
- package/dist/{index-UjI4WA5F.js → index-CgRisH4B.js} +1 -1
- package/dist/index-Ck8RYpuE.js +816 -0
- package/dist/index-CnjG7Mj4.js +5 -0
- package/dist/{index-lNhA3N9x.js → index-DBQsQ1ZK.js} +1 -0
- package/dist/index-DCZKt14c.js +5 -0
- package/dist/{index-BqXNMfLG.js → index-DiaPY8Db.js} +2 -2
- package/dist/{index-bSNw0XAf.js → index-DmdrsEvk.js} +1 -1
- package/dist/index-DnmCPdCI.js +168 -0
- package/dist/{index-Cy4DqT8R.js → index-DwDYy2lj.js} +1 -1
- package/dist/{index-B8jg37Wj.js → index-FQQfN6nm.js} +1 -1
- package/dist/{index-CZc2Gyjb.js → index-aic1yCBs.js} +1 -1
- package/dist/index.js +13 -13
- package/dist/{inline-Zj7Hqg-_.js → inline-8aNfINLF.js} +1 -1
- package/dist/knowledge-type-picker/index.js +1 -1
- package/dist/{knowledge-DaTnF2IW.js → knowledge-y2j0ijgx.js} +1 -1
- package/dist/media-id-b2dgniSy.js +15 -0
- package/dist/{media-migration-C2QLMSpd.js → media-migration-Dy_rbdkK.js} +1 -1
- package/dist/media-policy-BwKjZPWt.js +158 -0
- package/dist/{media-upload-D9MYBbLg.js → media-upload-NzWYyCm3.js} +1 -1
- package/dist/model-DvukseoR.js +146 -0
- package/dist/navigation/index.js +1 -1
- package/dist/rich-text/index.js +75 -73
- package/dist/rich-text/legacy-converter/index.js +822 -799
- package/dist/style.css +1 -1
- package/dist/switcher/index.js +1 -1
- package/dist/types/agent-prompt-editor/FkpAgentPromptEditor.vue.d.ts +550 -0
- package/dist/types/agent-prompt-editor/agent-size-chart.d.ts +3 -0
- package/dist/types/agent-prompt-editor/document-adapter.d.ts +3 -0
- package/dist/types/agent-prompt-editor/index.d.ts +6 -0
- package/dist/types/agent-prompt-editor/legacy-converter-index.d.ts +2 -0
- package/dist/types/agent-prompt-editor/legacy-converter.d.ts +26 -0
- package/dist/types/agent-prompt-editor/model.d.ts +21 -0
- package/dist/types/agent-prompt-editor/types.d.ts +56 -0
- package/dist/types/edition-info/FkpEditionInfo.vue.d.ts +1 -3
- package/dist/types/edition-info/presets.d.ts +8 -0
- package/dist/types/edition-info/types.d.ts +1 -0
- package/dist/types/filters/FkpFilter.vue.d.ts +2 -2
- package/dist/types/filters/FkpFilterDateRange.vue.d.ts +2 -2
- package/dist/types/filters/FkpFilterPeriod.vue.d.ts +2 -2
- package/dist/types/filters/FkpSearchableMultiSelect.vue.d.ts +2 -2
- package/dist/types/index.d.ts +4 -1
- package/dist/types/navigation/FkpNavigation.vue.d.ts +20 -29
- package/dist/types/navigation/NavigationButton.vue.d.ts +26 -0
- package/dist/types/navigation/NavigationGroup.vue.d.ts +45 -0
- package/dist/types/navigation/NavigationIcon.vue.d.ts +28 -0
- package/dist/types/navigation/NavigationNodes.vue.d.ts +40 -0
- package/dist/types/navigation/index.d.ts +1 -1
- package/dist/types/navigation/types.d.ts +43 -5
- package/dist/types/navigation/use-navigation-tree.d.ts +13 -0
- package/dist/types/rich-text/FkpRichText.vue.d.ts +28 -8
- package/dist/types/rich-text/config/descriptor.d.ts +1 -0
- package/dist/types/rich-text/config/resolve.d.ts +1 -1
- package/dist/types/rich-text/index.d.ts +4 -1
- package/dist/types/rich-text/knowledge-document-adapter.d.ts +2 -0
- package/dist/types/rich-text/model/question-text.d.ts +1 -1
- package/dist/types/rich-text/plugins/registry.d.ts +2 -1
- package/dist/types/rich-text/public/types.d.ts +12 -0
- package/dist/types/rich-text/runtime/document-adapter.d.ts +9 -0
- package/dist/types/rich-text/runtime/knowledge-clipboard.d.ts +9 -3
- package/dist/types/rich-text/runtime/media-sources.d.ts +7 -0
- package/dist/types/rich-text/runtime/media-upload-session.d.ts +2 -0
- package/dist/types/rich-text/ui/FkpKnowledgeTypePicker.vue.d.ts +3 -3
- package/dist/types/rich-text/ui/KnowledgeArea.vue.d.ts +18 -3
- package/dist/types/rich-text/ui/MediaSourceControls.vue.d.ts +190 -0
- package/dist/types/rich-text/ui/ToolForm.vue.d.ts +2 -2
- package/dist/types/rich-text/ui/token-renderer.d.ts +3 -0
- package/dist/types/rich-text/ui/useMediaHint.d.ts +6 -0
- package/dist/types/switcher/FkpSwitcher.vue.d.ts +2 -2
- package/dist/types-PvYB5e85.js +14 -0
- package/package.json +13 -5
- package/dist/FkpKnowledgeTypePicker.vue_vue_type_script_setup_true_lang-DYwu7oQs.js +0 -187
- package/dist/FkpRichText.vue_vue_type_script_setup_true_lang-BowbZoTQ.js +0 -4885
- package/dist/KnowledgeArea-BH-_uF6R.js +0 -1438
- package/dist/ToolForm-C6XW31Y7.js +0 -185
- package/dist/index-CS2xQQ8W.js +0 -168
- package/dist/index-D0bJAQSN.js +0 -327
- package/dist/index-DAZ1ulyA.js +0 -5
- package/dist/index-DCmHHi07.js +0 -71
- package/dist/index-F7lDP1lI.js +0 -5
|
@@ -1,1438 +0,0 @@
|
|
|
1
|
-
import { defineComponent as St, shallowRef as At, ref as U, onBeforeUnmount as Be, watch as Z, nextTick as Oe, onMounted as Mt, openBlock as V, createElementBlock as $, createVNode as Ve, unref as K, createBlock as Et, withCtx as le, createElementVNode as I, normalizeStyle as de, createCommentVNode as ee, toDisplayString as Le, createTextVNode as Ct } from "vue";
|
|
2
|
-
import { EditorContent as Nt, Editor as wt } from "@tiptap/vue-3";
|
|
3
|
-
import { Popover as It, Tag as Dt } from "@freecallai/ui";
|
|
4
|
-
import { Plugin as qe, PluginKey as xt, Selection as Rt, TextSelection as Pt } from "@tiptap/pm/state";
|
|
5
|
-
import Bt from "@tiptap/starter-kit";
|
|
6
|
-
import Ot from "@tiptap/extension-placeholder";
|
|
7
|
-
import { Extension as Vt, Node as ue } from "@tiptap/core";
|
|
8
|
-
import { DecorationSet as Lt, Decoration as zt } from "@tiptap/pm/view";
|
|
9
|
-
import { glyphs as Y } from "@freecallai/icons";
|
|
10
|
-
import { g as fe, i as X, t as H, m as ce, n as $t, o as Ht, q as Je, r as Ke, b as te, u as ne, C as Ft, v as Ut, w as _t, x as qt, y as ze, z as Jt } from "./guard-CXpVx8UR.js";
|
|
11
|
-
import { m as Kt, f as $e } from "./FkpRichText.vue_vue_type_script_setup_true_lang-BowbZoTQ.js";
|
|
12
|
-
import { DOMParser as Yt, DOMSerializer as Xt } from "@tiptap/pm/model";
|
|
13
|
-
function ae() {
|
|
14
|
-
const r = globalThis.crypto.getRandomValues(new Uint8Array(16));
|
|
15
|
-
r[6] = r[6] & 15 | 64, r[8] = r[8] & 63 | 128;
|
|
16
|
-
const s = Array.from(
|
|
17
|
-
r,
|
|
18
|
-
(f) => f.toString(16).padStart(2, "0")
|
|
19
|
-
).join("");
|
|
20
|
-
return `${s.slice(0, 8)}-${s.slice(8, 12)}-${s.slice(
|
|
21
|
-
12,
|
|
22
|
-
16
|
|
23
|
-
)}-${s.slice(16, 20)}-${s.slice(20)}`;
|
|
24
|
-
}
|
|
25
|
-
function Gt(r) {
|
|
26
|
-
var i;
|
|
27
|
-
const s = (i = fe(r.kind)) == null ? void 0 : i.present(r), f = String(r.kind || ""), o = (s == null ? void 0 : s.label) || String(r.label || r.key || ""), g = (A, v) => [
|
|
28
|
-
"span",
|
|
29
|
-
{ class: `fkp-icon ${A}`, "aria-hidden": "true" },
|
|
30
|
-
v
|
|
31
|
-
], k = (A) => [
|
|
32
|
-
"span",
|
|
33
|
-
{ class: A },
|
|
34
|
-
o
|
|
35
|
-
];
|
|
36
|
-
let h = [o];
|
|
37
|
-
return (s == null ? void 0 : s.layout) === "choice" && (h = [
|
|
38
|
-
g(`fkp-choice-token-icon fkp-${f}-token-icon`, Y[s.icon]),
|
|
39
|
-
k(`fkp-choice-token-label fkp-${f}-token-label`),
|
|
40
|
-
g(
|
|
41
|
-
`fkp-choice-token-arrow fkp-${f}-token-arrow`,
|
|
42
|
-
Y["arrow-down"]
|
|
43
|
-
)
|
|
44
|
-
]), (s == null ? void 0 : s.layout) === "inline" && (h = [
|
|
45
|
-
g("fkp-inline-token-icon", Y[s.icon]),
|
|
46
|
-
k("fkp-inline-token-label")
|
|
47
|
-
]), (s == null ? void 0 : s.layout) === "tool" && (h = [
|
|
48
|
-
g("fkp-tool-token-icon", Y[s.icon]),
|
|
49
|
-
k("fkp-tool-token-label")
|
|
50
|
-
]), (s == null ? void 0 : s.layout) === "toolNote" && (h = [
|
|
51
|
-
g("fkp-tool-note-icon", Y[s.icon]),
|
|
52
|
-
k("fkp-tool-note-label"),
|
|
53
|
-
...s.summary ? [
|
|
54
|
-
[
|
|
55
|
-
"span",
|
|
56
|
-
{ class: "fkp-tool-note-divider", "aria-hidden": "true" }
|
|
57
|
-
],
|
|
58
|
-
[
|
|
59
|
-
"span",
|
|
60
|
-
{ class: "fkp-tool-note-summary" },
|
|
61
|
-
s.summary
|
|
62
|
-
]
|
|
63
|
-
] : []
|
|
64
|
-
]), [
|
|
65
|
-
"span",
|
|
66
|
-
{
|
|
67
|
-
"data-business-token": "",
|
|
68
|
-
"data-fkp-node": "business-token",
|
|
69
|
-
"data-kind": r.kind,
|
|
70
|
-
"data-key": r.key,
|
|
71
|
-
"data-node-id": r.id,
|
|
72
|
-
"data-token": r.token,
|
|
73
|
-
...r.params ? { "data-fkp-params": JSON.stringify(r.params) } : {},
|
|
74
|
-
...s ? { "data-label": r.label, "aria-label": s.ariaLabel } : {},
|
|
75
|
-
class: `fk-token fk-token--${f} fkp-knowledge-tag fkp-knowledge-tag--${f}${(s == null ? void 0 : s.layout) === "choice" ? " fkp-choice-token" : ""}${s != null && s.className ? ` ${s.className}` : ""}`,
|
|
76
|
-
contenteditable: "false"
|
|
77
|
-
},
|
|
78
|
-
...h
|
|
79
|
-
];
|
|
80
|
-
}
|
|
81
|
-
function Ye(r) {
|
|
82
|
-
var s;
|
|
83
|
-
return ((s = fe(r.kind)) == null ? void 0 : s.serialize(r)) || String(r.label || r.key || "");
|
|
84
|
-
}
|
|
85
|
-
const jt = Vt.create({
|
|
86
|
-
name: "uniqueExtensionNodeIds",
|
|
87
|
-
addProseMirrorPlugins() {
|
|
88
|
-
return [
|
|
89
|
-
new qe({
|
|
90
|
-
appendTransaction(r, s, f) {
|
|
91
|
-
if (!r.some((p) => p.docChanged))
|
|
92
|
-
return null;
|
|
93
|
-
const o = /* @__PURE__ */ new Map(), g = /* @__PURE__ */ new Map();
|
|
94
|
-
s.doc.descendants((p, T) => {
|
|
95
|
-
if (!X(p.type.name) || !p.attrs.id) return;
|
|
96
|
-
g.set(String(p.attrs.id), p);
|
|
97
|
-
let u = T;
|
|
98
|
-
for (const R of r)
|
|
99
|
-
u = R.mapping.mapResult(u, 1).pos;
|
|
100
|
-
const M = f.doc.nodeAt(u);
|
|
101
|
-
(M == null ? void 0 : M.type.name) === p.type.name && M.attrs.id === p.attrs.id && o.set(String(p.attrs.id), u);
|
|
102
|
-
});
|
|
103
|
-
const k = /* @__PURE__ */ new Set();
|
|
104
|
-
for (const p of r) {
|
|
105
|
-
const T = p.getMeta(H);
|
|
106
|
-
Array.isArray(T) && T.forEach((u) => {
|
|
107
|
-
typeof u == "string" && u && k.add(u);
|
|
108
|
-
});
|
|
109
|
-
}
|
|
110
|
-
const h = /* @__PURE__ */ new Set();
|
|
111
|
-
f.doc.descendants((p) => {
|
|
112
|
-
X(p.type.name) && p.attrs.id && h.add(String(p.attrs.id));
|
|
113
|
-
});
|
|
114
|
-
const i = /* @__PURE__ */ new Set(), { tr: A } = f, v = r.some(
|
|
115
|
-
(p) => p.getMeta("uiEvent") === "drop"
|
|
116
|
-
);
|
|
117
|
-
return f.doc.descendants((p, T) => {
|
|
118
|
-
var E;
|
|
119
|
-
if (!X(p.type.name)) return;
|
|
120
|
-
let u = String(p.attrs.id || "");
|
|
121
|
-
const M = o.get(u);
|
|
122
|
-
!!u && !i.has(u) && (M === T || v && M === void 0 && ((E = g.get(u)) == null ? void 0 : E.eq(p)) || M === void 0 && k.has(u)) || (u = ce(h, ae), A.setNodeMarkup(T, void 0, {
|
|
123
|
-
...p.attrs,
|
|
124
|
-
id: u,
|
|
125
|
-
nodeVersion: 0
|
|
126
|
-
}), h.add(u)), i.add(u);
|
|
127
|
-
}), A.docChanged ? A.setMeta("addToHistory", !1) : null;
|
|
128
|
-
}
|
|
129
|
-
})
|
|
130
|
-
];
|
|
131
|
-
}
|
|
132
|
-
}), Wt = ue.create({
|
|
133
|
-
name: "businessToken",
|
|
134
|
-
group: "inline",
|
|
135
|
-
inline: !0,
|
|
136
|
-
atom: !0,
|
|
137
|
-
selectable: !0,
|
|
138
|
-
addAttributes() {
|
|
139
|
-
return {
|
|
140
|
-
id: { default: "" },
|
|
141
|
-
nodeVersion: { default: 0 },
|
|
142
|
-
kind: { default: "variable" },
|
|
143
|
-
key: { default: "" },
|
|
144
|
-
label: { default: "" },
|
|
145
|
-
token: { default: null },
|
|
146
|
-
params: { default: null }
|
|
147
|
-
};
|
|
148
|
-
},
|
|
149
|
-
parseHTML() {
|
|
150
|
-
return [
|
|
151
|
-
{
|
|
152
|
-
tag: "span[data-business-token]",
|
|
153
|
-
getAttrs: (r) => ({
|
|
154
|
-
kind: r.getAttribute("data-kind"),
|
|
155
|
-
key: r.getAttribute("data-key"),
|
|
156
|
-
label: r.getAttribute("data-label") || r.textContent,
|
|
157
|
-
token: r.getAttribute("data-token"),
|
|
158
|
-
params: (() => {
|
|
159
|
-
const s = r.getAttribute("data-fkp-params");
|
|
160
|
-
if (!s || s.length > 8192) return null;
|
|
161
|
-
try {
|
|
162
|
-
return JSON.parse(s);
|
|
163
|
-
} catch {
|
|
164
|
-
return null;
|
|
165
|
-
}
|
|
166
|
-
})()
|
|
167
|
-
})
|
|
168
|
-
}
|
|
169
|
-
];
|
|
170
|
-
},
|
|
171
|
-
renderHTML: ({ node: r }) => Gt(r.attrs),
|
|
172
|
-
renderText: ({ node: r }) => Ye(r.attrs)
|
|
173
|
-
}), He = new xt(
|
|
174
|
-
"inlineReplyNeighbors"
|
|
175
|
-
);
|
|
176
|
-
function Fe(r) {
|
|
177
|
-
const s = [];
|
|
178
|
-
r.forEach((o, g) => {
|
|
179
|
-
s.push({ node: o, position: g });
|
|
180
|
-
});
|
|
181
|
-
const f = /* @__PURE__ */ new Set();
|
|
182
|
-
return s.forEach(({ node: o }, g) => {
|
|
183
|
-
var k;
|
|
184
|
-
if (!(o.type.name !== "originalReply" || o.childCount !== 1 || ((k = o.firstChild) == null ? void 0 : k.type.name) !== "paragraph"))
|
|
185
|
-
for (const h of [s[g - 1], s[g + 1]])
|
|
186
|
-
(h == null ? void 0 : h.node.type.name) === "paragraph" && f.add(h.position);
|
|
187
|
-
}), Lt.create(
|
|
188
|
-
r,
|
|
189
|
-
[...f].map((o) => {
|
|
190
|
-
const g = r.nodeAt(o);
|
|
191
|
-
return zt.node(o, o + g.nodeSize, {
|
|
192
|
-
class: "fk-inline-reply-neighbor"
|
|
193
|
-
});
|
|
194
|
-
})
|
|
195
|
-
);
|
|
196
|
-
}
|
|
197
|
-
const Qt = ue.create({
|
|
198
|
-
name: "originalReply",
|
|
199
|
-
group: "block",
|
|
200
|
-
content: "(paragraph | mediaBlock | messageSeparator)+",
|
|
201
|
-
defining: !0,
|
|
202
|
-
isolating: !0,
|
|
203
|
-
addAttributes() {
|
|
204
|
-
return { id: { default: "" }, nodeVersion: { default: 0 } };
|
|
205
|
-
},
|
|
206
|
-
parseHTML() {
|
|
207
|
-
return [{ tag: "section[data-original-reply]" }];
|
|
208
|
-
},
|
|
209
|
-
renderHTML() {
|
|
210
|
-
return [
|
|
211
|
-
"section",
|
|
212
|
-
{
|
|
213
|
-
"data-original-reply": "",
|
|
214
|
-
"data-fkp-node": "original-reply",
|
|
215
|
-
class: "fk-original-reply"
|
|
216
|
-
},
|
|
217
|
-
0
|
|
218
|
-
];
|
|
219
|
-
},
|
|
220
|
-
addProseMirrorPlugins() {
|
|
221
|
-
return [
|
|
222
|
-
new qe({
|
|
223
|
-
key: He,
|
|
224
|
-
state: {
|
|
225
|
-
init: (r, s) => Fe(s.doc),
|
|
226
|
-
apply: (r, s, f) => r.docChanged ? Fe(f.doc) : s
|
|
227
|
-
},
|
|
228
|
-
props: {
|
|
229
|
-
decorations(r) {
|
|
230
|
-
return He.getState(r);
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
})
|
|
234
|
-
];
|
|
235
|
-
}
|
|
236
|
-
}), Zt = ue.create({
|
|
237
|
-
name: "messageSeparator",
|
|
238
|
-
group: "block",
|
|
239
|
-
atom: !0,
|
|
240
|
-
selectable: !0,
|
|
241
|
-
addAttributes() {
|
|
242
|
-
return { id: { default: "" }, nodeVersion: { default: 0 } };
|
|
243
|
-
},
|
|
244
|
-
parseHTML() {
|
|
245
|
-
return [{ tag: "div[data-message-separator]" }];
|
|
246
|
-
},
|
|
247
|
-
renderHTML() {
|
|
248
|
-
return [
|
|
249
|
-
"div",
|
|
250
|
-
{
|
|
251
|
-
"data-message-separator": "",
|
|
252
|
-
"data-fkp-node": "message-separator",
|
|
253
|
-
class: "fk-message-separator"
|
|
254
|
-
},
|
|
255
|
-
[
|
|
256
|
-
"span",
|
|
257
|
-
{
|
|
258
|
-
class: "fk-separator-tag fkp-knowledge-tag fkp-knowledge-tag--primary"
|
|
259
|
-
},
|
|
260
|
-
"分隔符"
|
|
261
|
-
]
|
|
262
|
-
];
|
|
263
|
-
},
|
|
264
|
-
renderText() {
|
|
265
|
-
return `
|
|
266
|
-
{分隔符}
|
|
267
|
-
`;
|
|
268
|
-
}
|
|
269
|
-
}), en = 1024 * 1024, tn = 1e4, nn = /* @__PURE__ */ new Set([
|
|
270
|
-
"SCRIPT",
|
|
271
|
-
"STYLE",
|
|
272
|
-
"SVG",
|
|
273
|
-
"IFRAME",
|
|
274
|
-
"OBJECT",
|
|
275
|
-
"TEMPLATE"
|
|
276
|
-
]), an = /* @__PURE__ */ new Set([
|
|
277
|
-
"P",
|
|
278
|
-
"DIV",
|
|
279
|
-
"BLOCKQUOTE",
|
|
280
|
-
"UL",
|
|
281
|
-
"OL",
|
|
282
|
-
"LI"
|
|
283
|
-
]);
|
|
284
|
-
function rn(r, s, f) {
|
|
285
|
-
if (!s.content.size) return !1;
|
|
286
|
-
const o = document.createElement("div");
|
|
287
|
-
o.appendChild(
|
|
288
|
-
Xt.fromSchema(f).serializeFragment(s.content)
|
|
289
|
-
);
|
|
290
|
-
const g = s.content.textBetween(
|
|
291
|
-
0,
|
|
292
|
-
s.content.size,
|
|
293
|
-
`
|
|
294
|
-
`,
|
|
295
|
-
(k) => k.type.name === "mediaBlock" ? `[${k.attrs.kind === "video" ? "视频" : "图片"}:${k.attrs.name || ""}]` : k.type.name === "businessToken" ? Ye(k.attrs) : k.type.name === "messageSeparator" ? "{分隔符}" : ""
|
|
296
|
-
);
|
|
297
|
-
try {
|
|
298
|
-
return r.setData("text/plain", g), r.setData("text/html", o.innerHTML), !0;
|
|
299
|
-
} catch {
|
|
300
|
-
return !1;
|
|
301
|
-
}
|
|
302
|
-
}
|
|
303
|
-
function on(r, s, f) {
|
|
304
|
-
var T;
|
|
305
|
-
const o = r.getAttribute("data-kind"), g = r.getAttribute("data-key"), k = r.getAttribute("data-label"), h = r.getAttribute("data-token");
|
|
306
|
-
if (!$t(o) || !g || !k || f && ((T = fe(o)) == null ? void 0 : T.allowInOriginalReply) === !1 || !s.has(`${o}:knowledgeInline`))
|
|
307
|
-
return null;
|
|
308
|
-
const i = r.getAttribute("data-fkp-params");
|
|
309
|
-
let A = null;
|
|
310
|
-
if (i != null) {
|
|
311
|
-
if (i.length > 8192) return null;
|
|
312
|
-
try {
|
|
313
|
-
const u = JSON.parse(i);
|
|
314
|
-
if (!u || typeof u != "object" || Array.isArray(u))
|
|
315
|
-
return null;
|
|
316
|
-
A = u;
|
|
317
|
-
} catch {
|
|
318
|
-
return null;
|
|
319
|
-
}
|
|
320
|
-
}
|
|
321
|
-
if (o === "tool" && (!A || g === "small_payment" && !Ht(A.amount) || g === "order_note" && !Je(A)) || Ke({
|
|
322
|
-
type: "doc",
|
|
323
|
-
content: [
|
|
324
|
-
{ type: "paragraph", content: [{ type: "businessToken", attrs: { kind: o, key: g, label: k, token: h, params: A } }] }
|
|
325
|
-
]
|
|
326
|
-
}))
|
|
327
|
-
return null;
|
|
328
|
-
const p = document.createElement("span");
|
|
329
|
-
return p.setAttribute("data-business-token", ""), p.setAttribute("data-fkp-node", "business-token"), p.setAttribute("data-kind", o), p.setAttribute("data-key", g), p.setAttribute("data-label", k), h && p.setAttribute("data-token", h), A && p.setAttribute("data-fkp-params", JSON.stringify(A)), p.textContent = r.textContent, p;
|
|
330
|
-
}
|
|
331
|
-
function sn(r, s, f) {
|
|
332
|
-
var v, p;
|
|
333
|
-
const o = r.tagName === "IMG" || r.tagName === "VIDEO" ? r : r.querySelector("img,video");
|
|
334
|
-
if (!o) return !1;
|
|
335
|
-
const g = o.tagName === "VIDEO" ? "video" : "image", k = o.getAttribute("src") || (g === "video" ? (v = o.querySelector("source[src]")) == null ? void 0 : v.getAttribute("src") : null);
|
|
336
|
-
let h = "";
|
|
337
|
-
if (te(k))
|
|
338
|
-
try {
|
|
339
|
-
h = decodeURIComponent(
|
|
340
|
-
new URL(k).pathname.split("/").pop() || ""
|
|
341
|
-
);
|
|
342
|
-
} catch {
|
|
343
|
-
h = "";
|
|
344
|
-
}
|
|
345
|
-
const i = [
|
|
346
|
-
r.getAttribute("data-name"),
|
|
347
|
-
(p = r.querySelector("figcaption")) == null ? void 0 : p.textContent,
|
|
348
|
-
o.getAttribute("alt"),
|
|
349
|
-
h
|
|
350
|
-
].filter((T) => !!(T != null && T.trim())).map((T) => T.trim().toLowerCase());
|
|
351
|
-
if (!i.length) return !1;
|
|
352
|
-
const A = s.findIndex(
|
|
353
|
-
(T, u) => {
|
|
354
|
-
var M;
|
|
355
|
-
return !f.has(u) && ((M = Kt(T)) == null ? void 0 : M.kind) === g && i.includes(T.name.toLowerCase());
|
|
356
|
-
}
|
|
357
|
-
);
|
|
358
|
-
return A < 0 ? !1 : (f.add(A), !0);
|
|
359
|
-
}
|
|
360
|
-
function ln(r, s) {
|
|
361
|
-
var u, M;
|
|
362
|
-
const f = r.tagName === "IMG" || r.tagName === "VIDEO" ? r : r.querySelector("img,video"), o = r.getAttribute("data-kind") || ((f == null ? void 0 : f.tagName) === "VIDEO" ? "video" : "image"), g = (f == null ? void 0 : f.getAttribute("src")) || ((f == null ? void 0 : f.tagName) === "VIDEO" ? (u = f.querySelector("source[src]")) == null ? void 0 : u.getAttribute("src") : null), k = f == null ? void 0 : f.getAttribute("poster");
|
|
363
|
-
if (r.getAttribute("data-fkp-node") === "media-block" && r.getAttribute("status") !== "ready" || f && (o === "image" && f.tagName !== "IMG" || o === "video" && f.tagName !== "VIDEO") || !["image", "video"].includes(o) || !s.has(`${o}:knowledgeBlock`) || !te(g) || k && !te(k))
|
|
364
|
-
return null;
|
|
365
|
-
const h = r.getAttribute("data-name") || ((M = r.querySelector("figcaption")) == null ? void 0 : M.textContent) || (f == null ? void 0 : f.getAttribute("alt")) || "", i = r.getAttribute("data-asset-id"), A = {
|
|
366
|
-
id: ae(),
|
|
367
|
-
kind: o,
|
|
368
|
-
src: g,
|
|
369
|
-
name: h,
|
|
370
|
-
status: "ready",
|
|
371
|
-
...k ? { poster: k } : {},
|
|
372
|
-
...i ? { assetId: i } : {}
|
|
373
|
-
};
|
|
374
|
-
if (Ke({
|
|
375
|
-
type: "doc",
|
|
376
|
-
content: [{ type: "mediaBlock", attrs: A }]
|
|
377
|
-
}))
|
|
378
|
-
return null;
|
|
379
|
-
const v = document.createElement("figure");
|
|
380
|
-
v.setAttribute("data-media-block", ""), v.setAttribute("data-fkp-node", "media-block"), v.setAttribute("data-id", A.id), v.setAttribute("data-kind", o), i && v.setAttribute("data-asset-id", i);
|
|
381
|
-
const p = document.createElement(o === "video" ? "video" : "img");
|
|
382
|
-
p.setAttribute("src", g), k && p.setAttribute("poster", k), v.appendChild(p);
|
|
383
|
-
const T = document.createElement("figcaption");
|
|
384
|
-
return T.textContent = h, v.appendChild(T), v;
|
|
385
|
-
}
|
|
386
|
-
function dn(r, s, f, o = []) {
|
|
387
|
-
var T;
|
|
388
|
-
if (!r || r.length > en)
|
|
389
|
-
return { slice: null, handled: !1 };
|
|
390
|
-
const g = new Set(
|
|
391
|
-
f.map((u) => `${u.id}:${u.slot}`)
|
|
392
|
-
), k = new DOMParser().parseFromString(r, "text/html"), h = document.createElement("div"), i = /* @__PURE__ */ new Set();
|
|
393
|
-
let A = 0, v = !1;
|
|
394
|
-
const p = (u, M = !1) => {
|
|
395
|
-
if (++A > tn)
|
|
396
|
-
throw new Error("Clipboard HTML is too large");
|
|
397
|
-
if (u.nodeType === Node.TEXT_NODE)
|
|
398
|
-
return document.createTextNode(u.textContent || "");
|
|
399
|
-
if (!(u instanceof Element) || nn.has(u.tagName))
|
|
400
|
-
return null;
|
|
401
|
-
if (u.getAttribute("data-fkp-node") === "business-token") {
|
|
402
|
-
const E = on(u, g, M);
|
|
403
|
-
return E || (v = !0), E;
|
|
404
|
-
}
|
|
405
|
-
if (u.getAttribute("data-fkp-node") === "media-block" || u.tagName === "IMG" || u.tagName === "VIDEO" || u.tagName === "FIGURE" && u.querySelector("img,video")) {
|
|
406
|
-
if (sn(u, o, i))
|
|
407
|
-
return v = !0, null;
|
|
408
|
-
const E = ln(u, g);
|
|
409
|
-
return E || (v = !0), E;
|
|
410
|
-
}
|
|
411
|
-
if (u.getAttribute("data-fkp-node") === "message-separator") {
|
|
412
|
-
if (!g.has("separator:knowledgeInline"))
|
|
413
|
-
return v = !0, null;
|
|
414
|
-
const E = document.createElement("div");
|
|
415
|
-
return E.setAttribute("data-message-separator", ""), E;
|
|
416
|
-
}
|
|
417
|
-
if (u.getAttribute("data-fkp-node") === "original-reply") {
|
|
418
|
-
const E = g.has("originalReply:knowledgeBlock");
|
|
419
|
-
E || (v = !0);
|
|
420
|
-
const D = E ? document.createElement("section") : document.createDocumentFragment();
|
|
421
|
-
return D instanceof HTMLElement && D.setAttribute("data-original-reply", ""), u.childNodes.forEach((_) => {
|
|
422
|
-
const q = p(_, E);
|
|
423
|
-
q && D.appendChild(q);
|
|
424
|
-
}), D;
|
|
425
|
-
}
|
|
426
|
-
if (u.hasAttribute("data-fkp-node") || u.hasAttribute("data-business-token") || u.hasAttribute("data-message-separator") || u.getAttribute("data-tag") === "true" || u.getAttribute("data-variable") === "true" || u.getAttribute("data-divider") === "true")
|
|
427
|
-
return v = !0, null;
|
|
428
|
-
const R = an.has(u.tagName) ? document.createElement(u.tagName.toLowerCase()) : u.tagName === "BR" ? document.createElement("br") : document.createDocumentFragment();
|
|
429
|
-
return u.childNodes.forEach((E) => {
|
|
430
|
-
const D = p(E, M);
|
|
431
|
-
D && R.appendChild(D);
|
|
432
|
-
}), R;
|
|
433
|
-
};
|
|
434
|
-
try {
|
|
435
|
-
if (k.body.childNodes.forEach((M) => {
|
|
436
|
-
const R = p(M);
|
|
437
|
-
R && h.appendChild(R);
|
|
438
|
-
}), !((T = h.textContent) != null && T.trim()) && !h.querySelector(
|
|
439
|
-
"figure, [data-message-separator], [data-original-reply]"
|
|
440
|
-
))
|
|
441
|
-
return { slice: null, handled: v };
|
|
442
|
-
const u = Yt.fromSchema(s).parseSlice(h, {
|
|
443
|
-
preserveWhitespace: !0
|
|
444
|
-
});
|
|
445
|
-
return u.content.size ? { slice: u, handled: !0 } : { slice: null, handled: v };
|
|
446
|
-
} catch {
|
|
447
|
-
return { slice: null, handled: !1 };
|
|
448
|
-
}
|
|
449
|
-
}
|
|
450
|
-
function cn(r) {
|
|
451
|
-
return Xe(r, r.state.selection.getBookmark());
|
|
452
|
-
}
|
|
453
|
-
function Ue(r, s) {
|
|
454
|
-
if (r.isDestroyed || !Number.isInteger(s) || s < 0 || s > r.state.doc.content.size)
|
|
455
|
-
return null;
|
|
456
|
-
let f = s, o = !0, g = !0;
|
|
457
|
-
const k = ({ transaction: h }) => {
|
|
458
|
-
const i = h.mapping.mapResult(f, 1);
|
|
459
|
-
i.deletedAcross && (g = !1), f = i.pos;
|
|
460
|
-
};
|
|
461
|
-
return r.on("transaction", k), {
|
|
462
|
-
status() {
|
|
463
|
-
return !o || r.isDestroyed ? "disposed" : g ? "ready" : "lost";
|
|
464
|
-
},
|
|
465
|
-
insert(h) {
|
|
466
|
-
if (!o || !g || r.isDestroyed) return !1;
|
|
467
|
-
try {
|
|
468
|
-
return r.chain().setMeta(H, ne(h)).insertContentAt(f, h).run();
|
|
469
|
-
} catch {
|
|
470
|
-
return !1;
|
|
471
|
-
}
|
|
472
|
-
},
|
|
473
|
-
dispose() {
|
|
474
|
-
o && (o = !1, r.off("transaction", k));
|
|
475
|
-
}
|
|
476
|
-
};
|
|
477
|
-
}
|
|
478
|
-
function _e(r, s) {
|
|
479
|
-
if (r.isDestroyed || !Number.isInteger(s) || s < 0 || s > r.state.doc.content.size)
|
|
480
|
-
return null;
|
|
481
|
-
try {
|
|
482
|
-
const f = Rt.near(
|
|
483
|
-
r.state.doc.resolve(s)
|
|
484
|
-
).getBookmark();
|
|
485
|
-
return Xe(r, f);
|
|
486
|
-
} catch {
|
|
487
|
-
return null;
|
|
488
|
-
}
|
|
489
|
-
}
|
|
490
|
-
function Xe(r, s) {
|
|
491
|
-
let f = s, o = !0, g = !0, k = !1, { from: h, to: i } = s.resolve(r.state.doc);
|
|
492
|
-
const A = ({ transaction: v }) => {
|
|
493
|
-
const p = v.mapping.mapResult(h, 1), T = v.mapping.mapResult(i, -1);
|
|
494
|
-
!k && (p.deletedAcross || T.deletedAcross) && (g = !1), h = p.pos, i = T.pos, f = f.map(v.mapping);
|
|
495
|
-
};
|
|
496
|
-
return r.on("transaction", A), {
|
|
497
|
-
status() {
|
|
498
|
-
return !o || r.isDestroyed ? "disposed" : g ? "ready" : "lost";
|
|
499
|
-
},
|
|
500
|
-
insert(v) {
|
|
501
|
-
if (!o || !g || r.isDestroyed) return !1;
|
|
502
|
-
try {
|
|
503
|
-
const p = f.resolve(r.state.doc);
|
|
504
|
-
k = !0;
|
|
505
|
-
try {
|
|
506
|
-
return r.chain().setMeta(H, ne(v)).insertContentAt(
|
|
507
|
-
{ from: p.from, to: p.to },
|
|
508
|
-
v
|
|
509
|
-
).run();
|
|
510
|
-
} finally {
|
|
511
|
-
k = !1;
|
|
512
|
-
}
|
|
513
|
-
} catch {
|
|
514
|
-
return !1;
|
|
515
|
-
}
|
|
516
|
-
},
|
|
517
|
-
dispose() {
|
|
518
|
-
o && (o = !1, r.off("transaction", A));
|
|
519
|
-
}
|
|
520
|
-
};
|
|
521
|
-
}
|
|
522
|
-
const un = {
|
|
523
|
-
key: 0,
|
|
524
|
-
class: "fkp-knowledge-area",
|
|
525
|
-
role: "alert"
|
|
526
|
-
}, fn = { class: "fkp-order-remark-detail-title" }, pn = {
|
|
527
|
-
key: 0,
|
|
528
|
-
class: "fkp-order-remark-extract"
|
|
529
|
-
}, mn = { class: "fkp-order-remark-detail-content" }, gn = { class: "fkp-order-remark-detail-row" }, kn = { key: 0 }, yn = ["aria-label"], hn = { class: "fkp-order-remark-detail-row" }, bn = {
|
|
530
|
-
key: 2,
|
|
531
|
-
class: "fkp-reference-placeholder",
|
|
532
|
-
"aria-hidden": "true"
|
|
533
|
-
}, Rn = /* @__PURE__ */ St({
|
|
534
|
-
__name: "KnowledgeArea",
|
|
535
|
-
props: {
|
|
536
|
-
modelValue: {},
|
|
537
|
-
editable: { type: Boolean },
|
|
538
|
-
placeholder: {},
|
|
539
|
-
referencePlaceholder: { type: Boolean },
|
|
540
|
-
schemaPlan: {},
|
|
541
|
-
pasteCapabilities: {},
|
|
542
|
-
activeChoiceId: {}
|
|
543
|
-
},
|
|
544
|
-
emits: ["update:modelValue", "retry-media", "load-error", "edit-tool", "choice-menu", "leave-choice"],
|
|
545
|
-
setup(r, { expose: s, emit: f }) {
|
|
546
|
-
const o = r;
|
|
547
|
-
let g = !1;
|
|
548
|
-
const k = f, h = /* @__PURE__ */ new Map(), i = At();
|
|
549
|
-
let A = () => {
|
|
550
|
-
};
|
|
551
|
-
const v = new Promise((e) => {
|
|
552
|
-
A = e;
|
|
553
|
-
}), p = U(), T = U(!0), u = U(!1), M = U(null), R = U({});
|
|
554
|
-
let E = null;
|
|
555
|
-
function D() {
|
|
556
|
-
E && clearTimeout(E), E = null;
|
|
557
|
-
}
|
|
558
|
-
function _() {
|
|
559
|
-
D(), E = setTimeout(() => {
|
|
560
|
-
M.value = null;
|
|
561
|
-
}, 150);
|
|
562
|
-
}
|
|
563
|
-
function q(e) {
|
|
564
|
-
const { target: t } = e;
|
|
565
|
-
if (!(t instanceof Element) || !i.value) return;
|
|
566
|
-
const n = t.closest(
|
|
567
|
-
'[data-business-token][data-key="order_note"]'
|
|
568
|
-
);
|
|
569
|
-
n != null && n.dataset.nodeId && (D(), i.value.state.doc.descendants((a) => {
|
|
570
|
-
if (a.type.name !== "businessToken" || a.attrs.id !== n.dataset.nodeId)
|
|
571
|
-
return !0;
|
|
572
|
-
M.value = Je(a.attrs.params) ? a.attrs.params : null;
|
|
573
|
-
const l = n.getBoundingClientRect();
|
|
574
|
-
return R.value = {
|
|
575
|
-
left: `${l.left}px`,
|
|
576
|
-
top: `${l.top}px`,
|
|
577
|
-
width: `${l.width}px`,
|
|
578
|
-
height: `${l.height}px`
|
|
579
|
-
}, !1;
|
|
580
|
-
}));
|
|
581
|
-
}
|
|
582
|
-
function Ge(e) {
|
|
583
|
-
const { target: t } = e;
|
|
584
|
-
if (!(t instanceof Element)) return;
|
|
585
|
-
const n = t.closest('[data-business-token][data-key="order_note"]');
|
|
586
|
-
n && (!(e.relatedTarget instanceof Node) || !n.contains(e.relatedTarget)) && _();
|
|
587
|
-
}
|
|
588
|
-
Be(D);
|
|
589
|
-
let G = !1, L = null;
|
|
590
|
-
const w = U(null);
|
|
591
|
-
let P = null, z = null;
|
|
592
|
-
function j() {
|
|
593
|
-
P = null, z !== null && cancelAnimationFrame(z), z = null;
|
|
594
|
-
}
|
|
595
|
-
function B() {
|
|
596
|
-
j(), L = null, w.value = null;
|
|
597
|
-
}
|
|
598
|
-
function pe(e) {
|
|
599
|
-
e.key === "Escape" && B();
|
|
600
|
-
}
|
|
601
|
-
function re() {
|
|
602
|
-
if (!P) return;
|
|
603
|
-
const e = be({
|
|
604
|
-
clientX: P.x,
|
|
605
|
-
clientY: P.y
|
|
606
|
-
}), t = e === null ? null : he(e, "file"), n = w.value;
|
|
607
|
-
(t == null ? void 0 : t.pos) === (n == null ? void 0 : n.pos) && (t == null ? void 0 : t.top) === (n == null ? void 0 : n.top) && (t == null ? void 0 : t.left) === (n == null ? void 0 : n.left) && (t == null ? void 0 : t.width) === (n == null ? void 0 : n.width) && (t == null ? void 0 : t.kind) === (n == null ? void 0 : n.kind) || (w.value = t);
|
|
608
|
-
}
|
|
609
|
-
Z(
|
|
610
|
-
() => o.editable,
|
|
611
|
-
(e) => {
|
|
612
|
-
e || B();
|
|
613
|
-
}
|
|
614
|
-
);
|
|
615
|
-
function me() {
|
|
616
|
-
z = null;
|
|
617
|
-
const e = p.value, t = P;
|
|
618
|
-
if (!e || !t || !o.editable) return;
|
|
619
|
-
const n = e.getBoundingClientRect(), a = Math.min(40, n.height / 3);
|
|
620
|
-
if (a <= 0) return;
|
|
621
|
-
const l = t.y < n.top + a ? -Math.ceil(12 * Math.min(1, (n.top + a - t.y) / a)) : t.y > n.bottom - a ? Math.ceil(12 * Math.min(1, (t.y - n.bottom + a) / a)) : 0, d = e.scrollHeight - e.clientHeight;
|
|
622
|
-
if (!l || d <= 0) return;
|
|
623
|
-
const m = Math.max(0, Math.min(d, e.scrollTop + l));
|
|
624
|
-
m !== e.scrollTop && (e.scrollTop = m, z = requestAnimationFrame(me));
|
|
625
|
-
}
|
|
626
|
-
function je() {
|
|
627
|
-
M.value = null, P ? re() : w.value = null;
|
|
628
|
-
}
|
|
629
|
-
let W = null, oe = !1;
|
|
630
|
-
const ge = `[data-business-token]:is(${Ft.map(
|
|
631
|
-
(e) => `[data-kind="${e}"]`
|
|
632
|
-
).join(", ")})`;
|
|
633
|
-
function Q(e) {
|
|
634
|
-
const t = h.get(e);
|
|
635
|
-
t && (URL.revokeObjectURL(t), h.delete(e));
|
|
636
|
-
}
|
|
637
|
-
function se(e) {
|
|
638
|
-
return !o.editable || !(e.target instanceof Element) ? null : e.target.closest(ge);
|
|
639
|
-
}
|
|
640
|
-
function We(e) {
|
|
641
|
-
const t = se(e);
|
|
642
|
-
!t || e.relatedTarget instanceof Node && t.contains(e.relatedTarget) || ke(t);
|
|
643
|
-
}
|
|
644
|
-
function Qe(e) {
|
|
645
|
-
const t = se(e);
|
|
646
|
-
t && (!(e.relatedTarget instanceof Node) || !t.contains(e.relatedTarget)) && k("leave-choice");
|
|
647
|
-
}
|
|
648
|
-
function ke(e) {
|
|
649
|
-
const { nodeId: t } = e.dataset;
|
|
650
|
-
!t || !i.value || i.value.state.doc.descendants((n) => n.type.name !== "businessToken" || n.attrs.id !== t ? !0 : (qt(n.attrs.kind) && k("choice-menu", {
|
|
651
|
-
nodeId: t,
|
|
652
|
-
nodeVersion: Number(n.attrs.nodeVersion) || 0,
|
|
653
|
-
key: String(n.attrs.key),
|
|
654
|
-
kind: n.attrs.kind,
|
|
655
|
-
anchor: e
|
|
656
|
-
}), !1));
|
|
657
|
-
}
|
|
658
|
-
function Ze(e) {
|
|
659
|
-
if (!o.editable || !i.value) return;
|
|
660
|
-
const { target: t } = e;
|
|
661
|
-
if (!(t instanceof Element)) return;
|
|
662
|
-
const n = se(e);
|
|
663
|
-
if (n) {
|
|
664
|
-
ke(n);
|
|
665
|
-
return;
|
|
666
|
-
}
|
|
667
|
-
const a = t.closest(
|
|
668
|
-
'[data-business-token][data-kind="tool"]'
|
|
669
|
-
);
|
|
670
|
-
a && (M.value = null);
|
|
671
|
-
const l = a == null ? void 0 : a.dataset.nodeId;
|
|
672
|
-
l && i.value.state.doc.descendants((d) => {
|
|
673
|
-
if (d.type.name !== "businessToken" || d.attrs.id !== l)
|
|
674
|
-
return !0;
|
|
675
|
-
const { params: m } = d.attrs;
|
|
676
|
-
return k("edit-tool", {
|
|
677
|
-
nodeId: l,
|
|
678
|
-
nodeVersion: Number(d.attrs.nodeVersion) || 0,
|
|
679
|
-
key: String(d.attrs.key),
|
|
680
|
-
label: String(d.attrs.label || d.attrs.key),
|
|
681
|
-
params: m && typeof m == "object" && !Array.isArray(m) ? m : null
|
|
682
|
-
}), !1;
|
|
683
|
-
});
|
|
684
|
-
}
|
|
685
|
-
function et(e) {
|
|
686
|
-
if (!o.editable || !i.value) return;
|
|
687
|
-
const { target: t } = e;
|
|
688
|
-
if (t === p.value || t === i.value.view.dom.parentElement) {
|
|
689
|
-
i.value.commands.focus("end");
|
|
690
|
-
return;
|
|
691
|
-
}
|
|
692
|
-
Ze(e);
|
|
693
|
-
}
|
|
694
|
-
function ye() {
|
|
695
|
-
var e;
|
|
696
|
-
(e = p.value) == null || e.querySelectorAll(ge).forEach(
|
|
697
|
-
(t) => t.classList.toggle(
|
|
698
|
-
"is-menu-open",
|
|
699
|
-
!!o.activeChoiceId && t.dataset.nodeId === o.activeChoiceId
|
|
700
|
-
)
|
|
701
|
-
);
|
|
702
|
-
}
|
|
703
|
-
Z(
|
|
704
|
-
[() => o.activeChoiceId, () => o.modelValue],
|
|
705
|
-
() => void Oe(ye)
|
|
706
|
-
);
|
|
707
|
-
function tt(e) {
|
|
708
|
-
var n;
|
|
709
|
-
const t = e.target instanceof Element ? e.target.closest(".fk-media[data-drag-handle]") : null;
|
|
710
|
-
!o.editable || !(t != null && t.dataset.mediaId) || (L = t.dataset.mediaId, w.value = null, (n = e.dataTransfer) == null || n.setData("application/x-fkp-media-id", L), e.dataTransfer && (e.dataTransfer.effectAllowed = "move"), e.stopPropagation());
|
|
711
|
-
}
|
|
712
|
-
function he(e, t) {
|
|
713
|
-
const n = i.value, a = p.value;
|
|
714
|
-
if (!n || !a) return null;
|
|
715
|
-
const { doc: l } = n.state, d = e === l.content.size, m = l.lastChild, c = d && m ? e - m.nodeSize : e, y = n.view.nodeDOM(c);
|
|
716
|
-
if (!(y instanceof HTMLElement)) return null;
|
|
717
|
-
const b = y.getBoundingClientRect(), S = a.getBoundingClientRect();
|
|
718
|
-
return {
|
|
719
|
-
top: (d ? b.bottom : b.top) - S.top + a.scrollTop,
|
|
720
|
-
left: a.scrollLeft,
|
|
721
|
-
width: a.clientWidth || S.right - S.left,
|
|
722
|
-
pos: e,
|
|
723
|
-
kind: t
|
|
724
|
-
};
|
|
725
|
-
}
|
|
726
|
-
function be(e) {
|
|
727
|
-
const t = i.value;
|
|
728
|
-
if (!t) return null;
|
|
729
|
-
const { view: n } = t, a = n.posAtCoords({ left: e.clientX, top: e.clientY });
|
|
730
|
-
if (!a) {
|
|
731
|
-
const S = n.dom.children;
|
|
732
|
-
let C = 0, N = S.length;
|
|
733
|
-
for (; C < N; ) {
|
|
734
|
-
const O = Math.floor((C + N) / 2), x = S[O].getBoundingClientRect();
|
|
735
|
-
e.clientY > x.top + x.height / 2 ? C = O + 1 : N = O;
|
|
736
|
-
}
|
|
737
|
-
if (C === S.length) return n.state.doc.content.size;
|
|
738
|
-
const F = n.state.doc.resolve(n.posAtDOM(S[C], 0));
|
|
739
|
-
return F.depth ? F.before(1) : F.pos;
|
|
740
|
-
}
|
|
741
|
-
const { doc: l } = n.state, d = l.resolve(a.pos);
|
|
742
|
-
let m = d.depth ? d.before(1) : a.pos;
|
|
743
|
-
m === l.content.size && l.lastChild && (m -= l.lastChild.nodeSize);
|
|
744
|
-
const c = l.nodeAt(m), y = n.nodeDOM(m);
|
|
745
|
-
if (!c || !(y instanceof HTMLElement)) return null;
|
|
746
|
-
const b = y.getBoundingClientRect();
|
|
747
|
-
return e.clientY > b.top + b.height / 2 ? m + c.nodeSize : m;
|
|
748
|
-
}
|
|
749
|
-
function ve(e, t) {
|
|
750
|
-
const n = i.value;
|
|
751
|
-
if (!n) return null;
|
|
752
|
-
const a = /* @__PURE__ */ new Map();
|
|
753
|
-
n.state.doc.descendants((b, S) => {
|
|
754
|
-
b.type.name === "mediaBlock" && typeof b.attrs.id == "string" && a.set(b.attrs.id, { pos: S, size: b.nodeSize });
|
|
755
|
-
});
|
|
756
|
-
const l = a.get(t);
|
|
757
|
-
if (!l) return null;
|
|
758
|
-
const d = e.target instanceof Element ? e.target.closest(".fk-media[data-media-id]") : null, m = d == null ? void 0 : d.dataset.mediaId;
|
|
759
|
-
if (m === t) return null;
|
|
760
|
-
const c = m ? a.get(m) : void 0;
|
|
761
|
-
let y;
|
|
762
|
-
if (c && d) {
|
|
763
|
-
const b = l.pos < c.pos;
|
|
764
|
-
y = c.pos + (b ? c.size : 0);
|
|
765
|
-
} else {
|
|
766
|
-
const b = n.view.posAtCoords({
|
|
767
|
-
left: e.clientX,
|
|
768
|
-
top: e.clientY
|
|
769
|
-
});
|
|
770
|
-
if (!b) return null;
|
|
771
|
-
const S = [0];
|
|
772
|
-
n.state.doc.forEach((C, N) => {
|
|
773
|
-
S.push(N + C.nodeSize);
|
|
774
|
-
}), y = S.reduce(
|
|
775
|
-
(C, N) => Math.abs(N - b.pos) < Math.abs(C - b.pos) ? N : C
|
|
776
|
-
);
|
|
777
|
-
}
|
|
778
|
-
return y === l.pos || y === l.pos + l.size ? null : { source: l, insertion: y };
|
|
779
|
-
}
|
|
780
|
-
function nt(e) {
|
|
781
|
-
var t;
|
|
782
|
-
if (o.editable) {
|
|
783
|
-
if (L) {
|
|
784
|
-
e.preventDefault(), e.stopPropagation(), e.dataTransfer && (e.dataTransfer.dropEffect = "move");
|
|
785
|
-
const n = ve(e, L);
|
|
786
|
-
w.value = n ? he(n.insertion, "media") : null;
|
|
787
|
-
return;
|
|
788
|
-
}
|
|
789
|
-
!o.schemaPlan.mediaBlock || !Array.from(((t = e.dataTransfer) == null ? void 0 : t.types) || []).includes("Files") || (e.preventDefault(), e.stopPropagation(), e.dataTransfer && (e.dataTransfer.dropEffect = "copy"), P = { x: e.clientX, y: e.clientY }, re(), z === null && (z = requestAnimationFrame(me)));
|
|
790
|
-
}
|
|
791
|
-
}
|
|
792
|
-
function at(e) {
|
|
793
|
-
var c;
|
|
794
|
-
j();
|
|
795
|
-
const t = L;
|
|
796
|
-
if (!t) {
|
|
797
|
-
(c = e.dataTransfer) != null && c.files.length || (w.value = null);
|
|
798
|
-
return;
|
|
799
|
-
}
|
|
800
|
-
L = null, w.value = null, e.preventDefault(), e.stopPropagation();
|
|
801
|
-
const n = i.value;
|
|
802
|
-
if (!o.editable || !n || n.isDestroyed) return;
|
|
803
|
-
const a = ve(e, t);
|
|
804
|
-
if (!a) return;
|
|
805
|
-
const { source: l, insertion: d } = a, m = n.state.doc.nodeAt(l.pos);
|
|
806
|
-
if (!(!m || m.type.name !== "mediaBlock"))
|
|
807
|
-
try {
|
|
808
|
-
const y = n.state.tr.delete(
|
|
809
|
-
l.pos,
|
|
810
|
-
l.pos + l.size
|
|
811
|
-
);
|
|
812
|
-
y.insert(y.mapping.map(d), m), y.setMeta("uiEvent", "drop"), y.setMeta(H, [t]), n.view.dispatch(y);
|
|
813
|
-
} catch {
|
|
814
|
-
}
|
|
815
|
-
}
|
|
816
|
-
function rt(e) {
|
|
817
|
-
const t = p.value;
|
|
818
|
-
if (!t || !w.value || e.relatedTarget instanceof Node && t.contains(e.relatedTarget))
|
|
819
|
-
return;
|
|
820
|
-
const n = t.getBoundingClientRect();
|
|
821
|
-
e.clientX >= n.left && e.clientX <= n.right && e.clientY >= n.top && e.clientY <= n.bottom || (j(), w.value = null);
|
|
822
|
-
}
|
|
823
|
-
function ot() {
|
|
824
|
-
B();
|
|
825
|
-
}
|
|
826
|
-
function ie(e) {
|
|
827
|
-
const t = /* @__PURE__ */ new Set(), n = (a) => {
|
|
828
|
-
var l, d;
|
|
829
|
-
a.type === "mediaBlock" && typeof ((l = a.attrs) == null ? void 0 : l.id) == "string" && t.add(a.attrs.id), (d = a.content) == null || d.forEach(n);
|
|
830
|
-
};
|
|
831
|
-
n(e);
|
|
832
|
-
for (const a of h.keys()) t.has(a) || Q(a);
|
|
833
|
-
}
|
|
834
|
-
function Te(e) {
|
|
835
|
-
i.value = new wt({
|
|
836
|
-
content: o.modelValue,
|
|
837
|
-
editable: o.editable,
|
|
838
|
-
extensions: [
|
|
839
|
-
Bt.configure({
|
|
840
|
-
heading: !1,
|
|
841
|
-
dropcursor: { color: "#4884e4", width: 2 },
|
|
842
|
-
link: { openOnClick: !1, isAllowedUri: (t) => te(t) }
|
|
843
|
-
}),
|
|
844
|
-
Ot.configure({
|
|
845
|
-
placeholder: () => o.referencePlaceholder ? "" : o.placeholder || "填写知识内容"
|
|
846
|
-
}),
|
|
847
|
-
jt,
|
|
848
|
-
...o.schemaPlan.businessToken ? [Wt] : [],
|
|
849
|
-
...o.schemaPlan.originalReply ? [Qt] : [],
|
|
850
|
-
...o.schemaPlan.separator ? [Zt] : [],
|
|
851
|
-
...e
|
|
852
|
-
],
|
|
853
|
-
editorProps: {
|
|
854
|
-
attributes: {
|
|
855
|
-
class: "fkp-knowledge-document",
|
|
856
|
-
role: "textbox",
|
|
857
|
-
"aria-label": "知识内容",
|
|
858
|
-
"aria-multiline": "true"
|
|
859
|
-
}
|
|
860
|
-
},
|
|
861
|
-
onUpdate: ({ editor: t }) => {
|
|
862
|
-
T.value = t.isEmpty;
|
|
863
|
-
const n = t.getJSON();
|
|
864
|
-
ie(n), g || k("update:modelValue", n);
|
|
865
|
-
}
|
|
866
|
-
}), T.value = i.value.isEmpty, A(!0), ye(), Re();
|
|
867
|
-
}
|
|
868
|
-
Mt(() => {
|
|
869
|
-
if (document.addEventListener("keydown", pe), document.addEventListener("dragend", B), document.addEventListener("drop", B), !o.schemaPlan.mediaBlock) {
|
|
870
|
-
Te([]);
|
|
871
|
-
return;
|
|
872
|
-
}
|
|
873
|
-
import("./media-extensions-wlcCEdtg.js").then(({ MediaBlock: e }) => {
|
|
874
|
-
G || Te([e.configure({ sceneStyle: !0 })]);
|
|
875
|
-
}).catch(() => {
|
|
876
|
-
G || (u.value = !0, A(!1), k("load-error", "媒体编辑器加载失败,请刷新页面重试"));
|
|
877
|
-
});
|
|
878
|
-
}), Z(
|
|
879
|
-
() => o.editable,
|
|
880
|
-
(e) => {
|
|
881
|
-
var t;
|
|
882
|
-
return (t = i.value) == null ? void 0 : t.setEditable(e);
|
|
883
|
-
}
|
|
884
|
-
), Z(
|
|
885
|
-
() => o.modelValue,
|
|
886
|
-
(e) => {
|
|
887
|
-
if (i.value && $e(e) !== $e(i.value.getJSON())) {
|
|
888
|
-
const t = De();
|
|
889
|
-
i.value.chain().setMeta(H, ne(e)).setContent(e, { emitUpdate: !1 }).run(), T.value = i.value.isEmpty, ie(e), P && re(), t && xe(i.value, t);
|
|
890
|
-
}
|
|
891
|
-
},
|
|
892
|
-
{ deep: !0 }
|
|
893
|
-
), Be(() => {
|
|
894
|
-
var e;
|
|
895
|
-
G = !0, A(!1), document.removeEventListener("keydown", pe), document.removeEventListener("dragend", B), document.removeEventListener("drop", B), B();
|
|
896
|
-
for (const t of h.keys()) Q(t);
|
|
897
|
-
(e = i.value) == null || e.destroy();
|
|
898
|
-
});
|
|
899
|
-
function Se(e, t, n, a) {
|
|
900
|
-
var l;
|
|
901
|
-
!o.editable || !o.schemaPlan.businessToken || (l = i.value) == null || l.chain().focus().insertContent([
|
|
902
|
-
{ type: "businessToken", attrs: { kind: e, key: t, label: n, token: a } },
|
|
903
|
-
{ type: "text", text: " " }
|
|
904
|
-
]).run();
|
|
905
|
-
}
|
|
906
|
-
function st() {
|
|
907
|
-
if (!o.editable || !o.schemaPlan.originalReply) return;
|
|
908
|
-
const e = i.value;
|
|
909
|
-
if (!e) return;
|
|
910
|
-
e.commands.focus();
|
|
911
|
-
const { from: t, to: n } = e.state.selection;
|
|
912
|
-
e.commands.insertContentAt(
|
|
913
|
-
{ from: t, to: n },
|
|
914
|
-
{ type: "originalReply", content: [{ type: "paragraph" }] }
|
|
915
|
-
) && Ae();
|
|
916
|
-
}
|
|
917
|
-
function it() {
|
|
918
|
-
Se("separator", "separator", "分隔符", "{分隔符}");
|
|
919
|
-
}
|
|
920
|
-
function Ae() {
|
|
921
|
-
const e = i.value;
|
|
922
|
-
if (!e) return;
|
|
923
|
-
const t = e.state.selection.from;
|
|
924
|
-
let n = null;
|
|
925
|
-
e.state.doc.descendants((a, l) => {
|
|
926
|
-
a.type.name === "originalReply" && l < t && (n = l);
|
|
927
|
-
}), n !== null && e.commands.setTextSelection(n + 2);
|
|
928
|
-
}
|
|
929
|
-
function Me(e, t, n) {
|
|
930
|
-
if (!o.editable || !i.value || !e.length) return null;
|
|
931
|
-
g = !0;
|
|
932
|
-
try {
|
|
933
|
-
const a = t.insert(e);
|
|
934
|
-
return a && e.some((l) => l.type === "originalReply") && Ae(), a && n && i.value.commands.focus(), a ? i.value.getJSON() : null;
|
|
935
|
-
} finally {
|
|
936
|
-
g = !1;
|
|
937
|
-
}
|
|
938
|
-
}
|
|
939
|
-
function lt(e) {
|
|
940
|
-
if (!(!i.value || i.value.isDestroyed)) {
|
|
941
|
-
g = !0;
|
|
942
|
-
try {
|
|
943
|
-
i.value.chain().setMeta("addToHistory", !1).setMeta(H, ne(e)).setContent(e, { emitUpdate: !1 }).run(), T.value = i.value.isEmpty, ie(e);
|
|
944
|
-
} finally {
|
|
945
|
-
g = !1;
|
|
946
|
-
}
|
|
947
|
-
}
|
|
948
|
-
}
|
|
949
|
-
function dt() {
|
|
950
|
-
var t;
|
|
951
|
-
const e = new Set(h.keys());
|
|
952
|
-
return (t = i.value) == null || t.state.doc.descendants((n) => {
|
|
953
|
-
n.attrs.id && e.add(String(n.attrs.id));
|
|
954
|
-
}), ce(e, ae);
|
|
955
|
-
}
|
|
956
|
-
function ct(e, t, n, a) {
|
|
957
|
-
if (!o.editable || !o.schemaPlan.mediaBlock) return null;
|
|
958
|
-
const l = [
|
|
959
|
-
{
|
|
960
|
-
type: "mediaBlock",
|
|
961
|
-
attrs: {
|
|
962
|
-
id: dt(),
|
|
963
|
-
nodeVersion: 0,
|
|
964
|
-
assetId: e.id || null,
|
|
965
|
-
src: e.url,
|
|
966
|
-
kind: e.kind,
|
|
967
|
-
name: t,
|
|
968
|
-
poster: e.posterUrl || null,
|
|
969
|
-
status: "ready"
|
|
970
|
-
}
|
|
971
|
-
},
|
|
972
|
-
{ type: "paragraph" }
|
|
973
|
-
];
|
|
974
|
-
return Me(l, n, a);
|
|
975
|
-
}
|
|
976
|
-
function ut(e, t, n) {
|
|
977
|
-
var a;
|
|
978
|
-
return ((a = Ee([{ file: e, kind: t }], n)) == null ? void 0 : a[0]) || null;
|
|
979
|
-
}
|
|
980
|
-
function Ee(e, t) {
|
|
981
|
-
if (!o.editable || !o.schemaPlan.mediaBlock || !i.value || !e.length)
|
|
982
|
-
return null;
|
|
983
|
-
const n = new Set(h.keys());
|
|
984
|
-
i.value.state.doc.descendants((d) => {
|
|
985
|
-
d.attrs.id && n.add(String(d.attrs.id));
|
|
986
|
-
});
|
|
987
|
-
const a = [], l = [];
|
|
988
|
-
try {
|
|
989
|
-
for (const { file: d, kind: m } of e) {
|
|
990
|
-
const c = ce(n, ae);
|
|
991
|
-
n.add(c);
|
|
992
|
-
const y = URL.createObjectURL(d);
|
|
993
|
-
h.set(c, y), a.push(c), l.push({
|
|
994
|
-
type: "mediaBlock",
|
|
995
|
-
attrs: {
|
|
996
|
-
id: c,
|
|
997
|
-
nodeVersion: 0,
|
|
998
|
-
assetId: null,
|
|
999
|
-
src: y,
|
|
1000
|
-
kind: m,
|
|
1001
|
-
name: d.name,
|
|
1002
|
-
poster: null,
|
|
1003
|
-
status: "uploading",
|
|
1004
|
-
error: ""
|
|
1005
|
-
}
|
|
1006
|
-
});
|
|
1007
|
-
}
|
|
1008
|
-
if (l.push({ type: "paragraph" }), t.insert(l)) return a;
|
|
1009
|
-
} catch {
|
|
1010
|
-
}
|
|
1011
|
-
return a.forEach(Q), null;
|
|
1012
|
-
}
|
|
1013
|
-
function Ce(e) {
|
|
1014
|
-
const t = i.value;
|
|
1015
|
-
if (!t || t.isDestroyed) return null;
|
|
1016
|
-
let n = null;
|
|
1017
|
-
return t.state.doc.descendants((a) => {
|
|
1018
|
-
a.type.name === "mediaBlock" && a.attrs.id === e && Number.isSafeInteger(a.attrs.nodeVersion) && a.attrs.nodeVersion >= 0 && (n = {
|
|
1019
|
-
kind: a.attrs.kind,
|
|
1020
|
-
status: a.attrs.status,
|
|
1021
|
-
nodeVersion: a.attrs.nodeVersion
|
|
1022
|
-
});
|
|
1023
|
-
}), n;
|
|
1024
|
-
}
|
|
1025
|
-
function Ne(e, t, n, a) {
|
|
1026
|
-
const l = i.value;
|
|
1027
|
-
if (!l || l.isDestroyed || !Number.isSafeInteger(t) || t < 0 || t >= Number.MAX_SAFE_INTEGER)
|
|
1028
|
-
return !1;
|
|
1029
|
-
let d = null;
|
|
1030
|
-
if (l.state.doc.descendants((c, y) => {
|
|
1031
|
-
c.type.name === "mediaBlock" && c.attrs.id === e && (d = y);
|
|
1032
|
-
}), d === null) return !1;
|
|
1033
|
-
const m = l.state.doc.nodeAt(d);
|
|
1034
|
-
return !m || m.attrs.nodeVersion !== t || m.attrs.status !== n ? !1 : (l.view.dispatch(
|
|
1035
|
-
l.state.tr.setNodeMarkup(d, void 0, {
|
|
1036
|
-
...m.attrs,
|
|
1037
|
-
...a,
|
|
1038
|
-
nodeVersion: t + 1
|
|
1039
|
-
}).setMeta("addToHistory", !1)
|
|
1040
|
-
), !0);
|
|
1041
|
-
}
|
|
1042
|
-
function ft(e, t) {
|
|
1043
|
-
var m, c, y, b;
|
|
1044
|
-
const n = i.value;
|
|
1045
|
-
if (!o.editable || !n || n.isDestroyed) return !1;
|
|
1046
|
-
let a = null, l = 0;
|
|
1047
|
-
if (n.state.doc.descendants((S, C) => {
|
|
1048
|
-
S.type.name === "mediaBlock" && S.attrs.id === e.nodeId && (a = C, l++);
|
|
1049
|
-
}), l !== 1 || a === null) return !1;
|
|
1050
|
-
const d = n.state.doc.nodeAt(a);
|
|
1051
|
-
if (!d || d.attrs.kind !== t || d.attrs.status !== "uploading" || d.attrs.nodeVersion !== e.expectedNodeVersion || e.node.type !== "mediaBlock" || ((m = e.node.attrs) == null ? void 0 : m.id) !== e.nodeId || ((c = e.node.attrs) == null ? void 0 : c.kind) !== t || ((y = e.node.attrs) == null ? void 0 : y.nodeVersion) !== e.expectedNodeVersion + 1)
|
|
1052
|
-
return !1;
|
|
1053
|
-
try {
|
|
1054
|
-
n.view.dispatch(
|
|
1055
|
-
n.state.tr.setNodeMarkup(a, void 0, e.node.attrs).setMeta("addToHistory", !1)
|
|
1056
|
-
);
|
|
1057
|
-
} catch {
|
|
1058
|
-
return !1;
|
|
1059
|
-
}
|
|
1060
|
-
return ((b = Ce(e.nodeId)) == null ? void 0 : b.status) !== "ready" ? !1 : (Q(e.nodeId), !0);
|
|
1061
|
-
}
|
|
1062
|
-
function we(e, t) {
|
|
1063
|
-
var d, m;
|
|
1064
|
-
const n = i.value;
|
|
1065
|
-
if (!o.editable || !n || n.isDestroyed || !e.length)
|
|
1066
|
-
return null;
|
|
1067
|
-
const a = /* @__PURE__ */ new Set(), l = [];
|
|
1068
|
-
for (const c of e) {
|
|
1069
|
-
if (a.has(c.nodeId)) return null;
|
|
1070
|
-
a.add(c.nodeId);
|
|
1071
|
-
let y = null, b = 0;
|
|
1072
|
-
if (n.state.doc.descendants((C, N) => {
|
|
1073
|
-
X(C.type.name) && C.attrs.id === c.nodeId && (y = N, b++);
|
|
1074
|
-
}), b !== 1 || y === null) return null;
|
|
1075
|
-
const S = n.state.doc.nodeAt(y);
|
|
1076
|
-
if (!S || ze(S.type.name, S.attrs) !== t || S.attrs.nodeVersion !== c.expectedNodeVersion || S.type.name === "originalReply" && Jt(S.toJSON()) || c.kind === "updateNode" && (S.type.name === "mediaBlock" || c.node.type !== S.type.name || ((d = c.node.attrs) == null ? void 0 : d.id) !== c.nodeId || ((m = c.node.attrs) == null ? void 0 : m.nodeVersion) !== c.expectedNodeVersion + 1 || ze(c.node.type, c.node.attrs) !== t))
|
|
1077
|
-
return null;
|
|
1078
|
-
l.push({ plan: c, position: y, size: S.nodeSize });
|
|
1079
|
-
}
|
|
1080
|
-
try {
|
|
1081
|
-
let c = n.state.tr;
|
|
1082
|
-
for (const { plan: y, position: b, size: S } of l.sort(
|
|
1083
|
-
(C, N) => N.position - C.position
|
|
1084
|
-
))
|
|
1085
|
-
y.kind === "removeNode" ? c = c.delete(b, b + S) : c = c.replaceWith(
|
|
1086
|
-
b,
|
|
1087
|
-
b + S,
|
|
1088
|
-
n.schema.nodeFromJSON(y.node)
|
|
1089
|
-
);
|
|
1090
|
-
return c.doc.check(), c.setMeta(
|
|
1091
|
-
H,
|
|
1092
|
-
e.filter((y) => y.kind === "updateNode").map((y) => y.nodeId)
|
|
1093
|
-
), { transaction: c, requestedIds: a };
|
|
1094
|
-
} catch {
|
|
1095
|
-
return null;
|
|
1096
|
-
}
|
|
1097
|
-
}
|
|
1098
|
-
function pt(e, t) {
|
|
1099
|
-
var n;
|
|
1100
|
-
return ((n = we(e, t)) == null ? void 0 : n.transaction.doc.toJSON()) || null;
|
|
1101
|
-
}
|
|
1102
|
-
function Ie(e, t) {
|
|
1103
|
-
const n = we(e, t), a = i.value;
|
|
1104
|
-
if (!n || !a || a.isDestroyed) return !1;
|
|
1105
|
-
const { transaction: l, requestedIds: d } = n;
|
|
1106
|
-
try {
|
|
1107
|
-
a.view.dispatch(l);
|
|
1108
|
-
} catch {
|
|
1109
|
-
return !1;
|
|
1110
|
-
}
|
|
1111
|
-
const m = /* @__PURE__ */ new Map();
|
|
1112
|
-
return a.state.doc.descendants((c) => {
|
|
1113
|
-
X(c.type.name) && d.has(c.attrs.id) && m.set(c.attrs.id, c.attrs.nodeVersion);
|
|
1114
|
-
}), e.every(
|
|
1115
|
-
(c) => c.kind === "removeNode" ? !m.has(c.nodeId) : m.get(c.nodeId) === c.expectedNodeVersion + 1
|
|
1116
|
-
);
|
|
1117
|
-
}
|
|
1118
|
-
function mt(e, t) {
|
|
1119
|
-
return Ie([e], t);
|
|
1120
|
-
}
|
|
1121
|
-
function gt(e, t, n) {
|
|
1122
|
-
return Ne(e, n, "uploading", {
|
|
1123
|
-
status: "error",
|
|
1124
|
-
error: t
|
|
1125
|
-
});
|
|
1126
|
-
}
|
|
1127
|
-
function kt(e, t) {
|
|
1128
|
-
return Ne(e, t, "error", {
|
|
1129
|
-
status: "uploading",
|
|
1130
|
-
error: ""
|
|
1131
|
-
});
|
|
1132
|
-
}
|
|
1133
|
-
function yt(e, t, n) {
|
|
1134
|
-
const a = i.value;
|
|
1135
|
-
if (!a || a.isDestroyed || !Number.isFinite(n))
|
|
1136
|
-
return !1;
|
|
1137
|
-
let l = !1;
|
|
1138
|
-
return a.state.doc.descendants((d) => {
|
|
1139
|
-
d.type.name === "mediaBlock" && d.attrs.id === e && d.attrs.status === "uploading" && d.attrs.nodeVersion === t && (l = !0);
|
|
1140
|
-
}), l ? (a.view.dom.dispatchEvent(
|
|
1141
|
-
new CustomEvent("fkp-media-progress", {
|
|
1142
|
-
detail: { id: e, percent: Math.round(Math.max(0, Math.min(100, n))) }
|
|
1143
|
-
})
|
|
1144
|
-
), !0) : !1;
|
|
1145
|
-
}
|
|
1146
|
-
function ht(e) {
|
|
1147
|
-
var n;
|
|
1148
|
-
const t = (n = e.detail) == null ? void 0 : n.id;
|
|
1149
|
-
typeof t == "string" && k("retry-media", t);
|
|
1150
|
-
}
|
|
1151
|
-
function De() {
|
|
1152
|
-
const e = i.value;
|
|
1153
|
-
if (!e || e.isDestroyed) return null;
|
|
1154
|
-
const { selection: t } = e.state;
|
|
1155
|
-
let n;
|
|
1156
|
-
if (t instanceof Pt && t.empty) {
|
|
1157
|
-
const { $from: a } = t, l = a.start();
|
|
1158
|
-
if (a.parent.forEach((d, m) => {
|
|
1159
|
-
if (d.type.name !== "businessToken" || !d.attrs.id) return;
|
|
1160
|
-
const c = t.from - (l + m + d.nodeSize);
|
|
1161
|
-
c >= 0 && c <= 1 && (n = {
|
|
1162
|
-
id: String(d.attrs.id),
|
|
1163
|
-
kind: "inlineAfter",
|
|
1164
|
-
offset: c
|
|
1165
|
-
});
|
|
1166
|
-
}), !n && a.depth >= 1 && a.parent.isTextblock && a.parentOffset <= 1) {
|
|
1167
|
-
const d = a.depth - 1, m = a.index(d), c = a.node(d);
|
|
1168
|
-
for (let y = m - 1; y >= 0; y--) {
|
|
1169
|
-
const b = c.child(y);
|
|
1170
|
-
if (b.type.name === "mediaBlock" && b.attrs.id) {
|
|
1171
|
-
n = {
|
|
1172
|
-
id: String(b.attrs.id),
|
|
1173
|
-
kind: "blockAfter",
|
|
1174
|
-
offset: a.parentOffset,
|
|
1175
|
-
siblingOffset: m - y
|
|
1176
|
-
};
|
|
1177
|
-
break;
|
|
1178
|
-
}
|
|
1179
|
-
if (!b.isTextblock || b.content.size > 0) break;
|
|
1180
|
-
}
|
|
1181
|
-
}
|
|
1182
|
-
}
|
|
1183
|
-
return {
|
|
1184
|
-
from: t.from,
|
|
1185
|
-
to: t.to,
|
|
1186
|
-
focused: e.isFocused,
|
|
1187
|
-
...n ? { nodeCaret: n } : {}
|
|
1188
|
-
};
|
|
1189
|
-
}
|
|
1190
|
-
function xe(e, t) {
|
|
1191
|
-
const n = e.state.doc.content.size;
|
|
1192
|
-
let a;
|
|
1193
|
-
const { nodeCaret: l } = t;
|
|
1194
|
-
l && t.from === t.to && e.state.doc.descendants((y, b) => {
|
|
1195
|
-
if (y.attrs.id !== l.id) return;
|
|
1196
|
-
if (l.kind === "inlineAfter") {
|
|
1197
|
-
if (y.type.name !== "businessToken") return;
|
|
1198
|
-
const x = e.state.doc.resolve(b).end();
|
|
1199
|
-
a = Math.min(
|
|
1200
|
-
b + y.nodeSize + l.offset,
|
|
1201
|
-
x
|
|
1202
|
-
);
|
|
1203
|
-
return;
|
|
1204
|
-
}
|
|
1205
|
-
if (y.type.name !== "mediaBlock") return;
|
|
1206
|
-
const S = e.state.doc.resolve(b), { parent: C } = S, N = S.index(), F = N + l.siblingOffset, O = C.maybeChild(F);
|
|
1207
|
-
if (O != null && O.isTextblock && Array.from(
|
|
1208
|
-
{ length: l.siblingOffset - 1 },
|
|
1209
|
-
(x, J) => C.child(N + J + 1)
|
|
1210
|
-
).every((x) => x.isTextblock && x.content.size === 0)) {
|
|
1211
|
-
let x = b;
|
|
1212
|
-
for (let J = N; J < F; J++)
|
|
1213
|
-
x += C.child(J).nodeSize;
|
|
1214
|
-
a = Math.min(
|
|
1215
|
-
x + 1 + l.offset,
|
|
1216
|
-
x + O.nodeSize - 1
|
|
1217
|
-
);
|
|
1218
|
-
}
|
|
1219
|
-
});
|
|
1220
|
-
const d = {
|
|
1221
|
-
from: a ?? Math.min(t.from, n),
|
|
1222
|
-
to: a ?? Math.min(t.to, n)
|
|
1223
|
-
}, m = document.activeElement;
|
|
1224
|
-
t.focused && (!m || m === document.body || m === e.view.dom || !m.isConnected) ? e.chain().setTextSelection(d).focus().run() : e.commands.setTextSelection(d);
|
|
1225
|
-
}
|
|
1226
|
-
async function Re() {
|
|
1227
|
-
if (!(oe || !W)) {
|
|
1228
|
-
oe = !0;
|
|
1229
|
-
try {
|
|
1230
|
-
for (let e = 0; e < 5 && !G; e++) {
|
|
1231
|
-
await Oe();
|
|
1232
|
-
const t = i.value;
|
|
1233
|
-
if (!t || t.isDestroyed || !t.view.dom.isConnected)
|
|
1234
|
-
continue;
|
|
1235
|
-
const n = W;
|
|
1236
|
-
if (W = null, !n) return;
|
|
1237
|
-
xe(t, n);
|
|
1238
|
-
return;
|
|
1239
|
-
}
|
|
1240
|
-
} finally {
|
|
1241
|
-
oe = !1;
|
|
1242
|
-
}
|
|
1243
|
-
}
|
|
1244
|
-
}
|
|
1245
|
-
function bt(e) {
|
|
1246
|
-
e && (W = e, Re());
|
|
1247
|
-
}
|
|
1248
|
-
function Pe(e) {
|
|
1249
|
-
const t = e.clipboardData, n = i.value;
|
|
1250
|
-
if (!o.editable || !n || !t) return null;
|
|
1251
|
-
const a = () => t.files.length ? Ue(n, n.state.selection.to) : null, l = t.getData("text/html"), { slice: d, handled: m } = dn(
|
|
1252
|
-
l,
|
|
1253
|
-
n.state.schema,
|
|
1254
|
-
o.pasteCapabilities || [],
|
|
1255
|
-
Array.from(t.files)
|
|
1256
|
-
);
|
|
1257
|
-
if (d)
|
|
1258
|
-
return n.view.dispatch(
|
|
1259
|
-
n.state.tr.replaceSelection(d).setMeta("uiEvent", "paste")
|
|
1260
|
-
), a();
|
|
1261
|
-
if (m) return null;
|
|
1262
|
-
const c = t.getData("text/plain");
|
|
1263
|
-
return c && n.view.pasteText(c, new Event("paste")), c ? a() : null;
|
|
1264
|
-
}
|
|
1265
|
-
function vt(e) {
|
|
1266
|
-
const t = i.value;
|
|
1267
|
-
!t || !e.clipboardData || !(e.target instanceof Element) || !e.target.closest(".fkp-knowledge-document") || rn(
|
|
1268
|
-
e.clipboardData,
|
|
1269
|
-
t.state.selection.content(),
|
|
1270
|
-
t.state.schema
|
|
1271
|
-
) && (e.preventDefault(), e.stopPropagation());
|
|
1272
|
-
}
|
|
1273
|
-
function Tt(e) {
|
|
1274
|
-
var t;
|
|
1275
|
-
e.defaultPrevented || (t = e.clipboardData) != null && t.files.length || !(e.target instanceof Element) || !e.target.closest(".fkp-knowledge-document") || (e.preventDefault(), e.stopPropagation(), Pe(e));
|
|
1276
|
-
}
|
|
1277
|
-
return s({
|
|
1278
|
-
pasteClipboardContent: Pe,
|
|
1279
|
-
isSelectionInsideOriginalReply: () => {
|
|
1280
|
-
const e = i.value;
|
|
1281
|
-
if (!e) return !1;
|
|
1282
|
-
const { selection: t } = e.state;
|
|
1283
|
-
for (let { depth: n } = t.$from; n > 0; n--)
|
|
1284
|
-
if (t.$from.node(n).type.name === "originalReply")
|
|
1285
|
-
return !0;
|
|
1286
|
-
return !1;
|
|
1287
|
-
},
|
|
1288
|
-
insertToken: Se,
|
|
1289
|
-
insertOriginal: st,
|
|
1290
|
-
insertSeparator: it,
|
|
1291
|
-
insertBatch: Me,
|
|
1292
|
-
restoreDoc: lt,
|
|
1293
|
-
insertMedia: ct,
|
|
1294
|
-
insertPendingMedia: ut,
|
|
1295
|
-
insertPendingMediaBatch: Ee,
|
|
1296
|
-
applyNodeUpdate: ft,
|
|
1297
|
-
applyPluginNodeOperation: mt,
|
|
1298
|
-
applyPluginNodeOperations: Ie,
|
|
1299
|
-
previewPluginNodeOperations: pt,
|
|
1300
|
-
failMedia: gt,
|
|
1301
|
-
retryMedia: kt,
|
|
1302
|
-
getMediaState: Ce,
|
|
1303
|
-
reportMediaProgress: yt,
|
|
1304
|
-
captureSelection: De,
|
|
1305
|
-
restoreSelection: bt,
|
|
1306
|
-
captureMediaTarget: () => i.value ? cn(i.value) : null,
|
|
1307
|
-
whenReady: () => v,
|
|
1308
|
-
captureEndTarget: () => {
|
|
1309
|
-
var n;
|
|
1310
|
-
const e = i.value;
|
|
1311
|
-
if (!e) return null;
|
|
1312
|
-
const { doc: t } = e.state;
|
|
1313
|
-
return (n = t.lastChild) != null && n.isTextblock ? _e(e, t.content.size - 1) : Ue(e, t.content.size);
|
|
1314
|
-
},
|
|
1315
|
-
captureMediaTargetAt: (e, t) => {
|
|
1316
|
-
const n = i.value, a = n ? be({ clientX: e, clientY: t }) : null;
|
|
1317
|
-
return j(), w.value = null, n && a !== null ? _e(n, a) : null;
|
|
1318
|
-
},
|
|
1319
|
-
focus: () => {
|
|
1320
|
-
var e;
|
|
1321
|
-
return (e = i.value) == null ? void 0 : e.commands.focus();
|
|
1322
|
-
},
|
|
1323
|
-
getJSON: () => {
|
|
1324
|
-
var e;
|
|
1325
|
-
return (e = i.value) == null ? void 0 : e.getJSON();
|
|
1326
|
-
}
|
|
1327
|
-
}), (e, t) => u.value ? (V(), $("div", un, "媒体编辑器加载失败,请刷新页面重试")) : (V(), $("div", {
|
|
1328
|
-
key: 1,
|
|
1329
|
-
ref_key: "areaRoot",
|
|
1330
|
-
ref: p,
|
|
1331
|
-
class: "fkp-knowledge-area",
|
|
1332
|
-
onFkpMediaRetry: ht,
|
|
1333
|
-
onClick: et,
|
|
1334
|
-
onMouseover: t[0] || (t[0] = (n) => {
|
|
1335
|
-
We(n), q(n);
|
|
1336
|
-
}),
|
|
1337
|
-
onMouseout: t[1] || (t[1] = (n) => {
|
|
1338
|
-
Qe(n), Ge(n);
|
|
1339
|
-
}),
|
|
1340
|
-
onFocusin: q,
|
|
1341
|
-
onFocusout: _,
|
|
1342
|
-
onDragstartCapture: tt,
|
|
1343
|
-
onDragoverCapture: nt,
|
|
1344
|
-
onDragleaveCapture: rt,
|
|
1345
|
-
onDropCapture: at,
|
|
1346
|
-
onDragendCapture: ot,
|
|
1347
|
-
onCopyCapture: vt,
|
|
1348
|
-
onPasteCapture: Tt,
|
|
1349
|
-
onScrollCapture: je
|
|
1350
|
-
}, [
|
|
1351
|
-
Ve(K(Nt), {
|
|
1352
|
-
class: "fkp-knowledge-editor",
|
|
1353
|
-
editor: i.value
|
|
1354
|
-
}, null, 8, ["editor"]),
|
|
1355
|
-
M.value ? (V(), Et(K(It), {
|
|
1356
|
-
key: 0,
|
|
1357
|
-
"popup-visible": !0,
|
|
1358
|
-
trigger: [],
|
|
1359
|
-
position: "tl",
|
|
1360
|
-
"content-class": "fkp-order-remark-popover",
|
|
1361
|
-
"content-style": {
|
|
1362
|
-
width: "326px",
|
|
1363
|
-
maxWidth: "calc(100vw - 32px)",
|
|
1364
|
-
padding: "16px",
|
|
1365
|
-
border: "none",
|
|
1366
|
-
boxSizing: "border-box",
|
|
1367
|
-
maxHeight: "420px",
|
|
1368
|
-
overflowY: "auto"
|
|
1369
|
-
}
|
|
1370
|
-
}, {
|
|
1371
|
-
content: le(() => [
|
|
1372
|
-
I("div", {
|
|
1373
|
-
class: "fkp-order-remark-detail",
|
|
1374
|
-
onMouseenter: D,
|
|
1375
|
-
onMouseleave: _
|
|
1376
|
-
}, [
|
|
1377
|
-
I("div", fn, [
|
|
1378
|
-
t[2] || (t[2] = I("strong", null, "订单备注", -1)),
|
|
1379
|
-
M.value.contentMode === "smart" ? (V(), $("span", pn, "智能提取")) : ee("", !0)
|
|
1380
|
-
]),
|
|
1381
|
-
I("div", mn, Le(M.value.content), 1),
|
|
1382
|
-
I("div", gn, [
|
|
1383
|
-
t[3] || (t[3] = I("span", null, "备注插旗", -1)),
|
|
1384
|
-
M.value.flag === "none" ? (V(), $("span", kn, "不标记")) : (V(), $("span", {
|
|
1385
|
-
key: 1,
|
|
1386
|
-
class: "fkp-order-remark-detail-flag",
|
|
1387
|
-
role: "img",
|
|
1388
|
-
"aria-label": K(_t)[M.value.flag],
|
|
1389
|
-
style: de({
|
|
1390
|
-
backgroundColor: K(Ut)[M.value.flag]
|
|
1391
|
-
})
|
|
1392
|
-
}, null, 12, yn))
|
|
1393
|
-
]),
|
|
1394
|
-
I("div", hn, [
|
|
1395
|
-
t[4] || (t[4] = I("span", null, "备注位置", -1)),
|
|
1396
|
-
I("span", null, Le(M.value.position === "first" ? "最前" : "最后"), 1)
|
|
1397
|
-
])
|
|
1398
|
-
], 32)
|
|
1399
|
-
]),
|
|
1400
|
-
default: le(() => [
|
|
1401
|
-
I("span", {
|
|
1402
|
-
class: "fkp-order-remark-anchor",
|
|
1403
|
-
style: de(R.value)
|
|
1404
|
-
}, null, 4)
|
|
1405
|
-
]),
|
|
1406
|
-
_: 1
|
|
1407
|
-
})) : ee("", !0),
|
|
1408
|
-
w.value ? (V(), $("div", {
|
|
1409
|
-
key: 1,
|
|
1410
|
-
class: "fkp-media-drop-line",
|
|
1411
|
-
style: de({
|
|
1412
|
-
top: `${w.value.top}px`,
|
|
1413
|
-
left: `${w.value.left}px`,
|
|
1414
|
-
width: `${w.value.width}px`
|
|
1415
|
-
}),
|
|
1416
|
-
"aria-hidden": "true"
|
|
1417
|
-
}, null, 4)) : ee("", !0),
|
|
1418
|
-
e.referencePlaceholder && T.value ? (V(), $("div", bn, [
|
|
1419
|
-
t[6] || (t[6] = I("span", { class: "fkp-reference-bracket" }, "<", -1)),
|
|
1420
|
-
Ve(K(Dt), {
|
|
1421
|
-
color: "arcoblue",
|
|
1422
|
-
size: "small",
|
|
1423
|
-
bordered: ""
|
|
1424
|
-
}, {
|
|
1425
|
-
default: le(() => t[5] || (t[5] = [
|
|
1426
|
-
Ct("参考话术")
|
|
1427
|
-
])),
|
|
1428
|
-
_: 1
|
|
1429
|
-
}),
|
|
1430
|
-
t[7] || (t[7] = I("span", null, "请填写参考话术", -1)),
|
|
1431
|
-
t[8] || (t[8] = I("span", { class: "fkp-reference-bracket" }, ">", -1))
|
|
1432
|
-
])) : ee("", !0)
|
|
1433
|
-
], 544));
|
|
1434
|
-
}
|
|
1435
|
-
});
|
|
1436
|
-
export {
|
|
1437
|
-
Rn as default
|
|
1438
|
-
};
|