ai-word-editor 0.0.62 → 0.0.63
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/index.js
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
import { useUmoEditor as An } from "@umoteam/editor";
|
|
2
|
-
import { computed as K, ref as b, watch as rt, nextTick as we, openBlock as _, createElementBlock as O, createElementVNode as l, createTextVNode as he, toDisplayString as S, createCommentVNode as ft, Fragment as kt, renderList as It, normalizeClass as _t, withModifiers as dt, onMounted as pe, createBlock as
|
|
3
|
-
import { E as Un, p as ke, g as Le, u as
|
|
4
|
-
import { parseDocxToJson as
|
|
5
|
-
const zt = (
|
|
6
|
-
const e =
|
|
2
|
+
import { computed as K, ref as b, watch as rt, nextTick as we, openBlock as _, createElementBlock as O, createElementVNode as l, createTextVNode as he, toDisplayString as S, createCommentVNode as ft, Fragment as kt, renderList as It, normalizeClass as _t, withModifiers as dt, onMounted as pe, createBlock as Nt, Teleport as ge, withDirectives as Qe, withKeys as ve, vModelText as $n, normalizeStyle as zn, defineComponent as Dn, onUnmounted as Fe, useAttrs as Jn, resolveComponent as Rn, createVNode as Fn, mergeProps as Bn, withCtx as Be, renderSlot as Ln, unref as vt, createApp as Hn, h as qn, vModelCheckbox as Pn } from "vue";
|
|
3
|
+
import { E as Un, p as ke, m as Wn, g as Le, u as Gn, e as Vn, a as He, b as Kn, c as qe, s as Pe, C as jn, d as ut } from "./wordDocxExport-C18xmH1z.js";
|
|
4
|
+
import { parseDocxToJson as Xn, parseDocxToHtml as Qn, parseDocxComments as Yn } from "./wordDocxImport.js";
|
|
5
|
+
const zt = (s, t) => {
|
|
6
|
+
const e = s.__vccOpts || s;
|
|
7
7
|
for (const [n, o] of t)
|
|
8
8
|
e[n] = o;
|
|
9
9
|
return e;
|
|
10
|
-
},
|
|
10
|
+
}, Zn = { class: "comment-panel__header" }, to = { class: "comment-panel__title" }, eo = {
|
|
11
11
|
key: 0,
|
|
12
12
|
class: "comment-panel__badge"
|
|
13
|
-
},
|
|
13
|
+
}, no = {
|
|
14
14
|
key: 0,
|
|
15
15
|
class: "comment-panel__empty"
|
|
16
|
-
},
|
|
16
|
+
}, oo = {
|
|
17
17
|
key: 1,
|
|
18
18
|
class: "comment-panel__list"
|
|
19
|
-
},
|
|
19
|
+
}, ro = ["data-comment-id", "onClick"], so = { class: "comment-item__quote" }, io = { class: "comment-item__note" }, lo = { class: "comment-item__meta" }, ao = { class: "comment-item__author" }, co = { class: "comment-item__time" }, uo = { class: "comment-item__actions" }, mo = ["onClick"], fo = ["onClick"], ho = {
|
|
20
20
|
__name: "CommentPanel",
|
|
21
21
|
props: {
|
|
22
22
|
comments: {
|
|
@@ -29,12 +29,12 @@ const zt = (i, t) => {
|
|
|
29
29
|
},
|
|
30
30
|
formatTime: {
|
|
31
31
|
type: Function,
|
|
32
|
-
default: (
|
|
32
|
+
default: (s) => String(s ?? "")
|
|
33
33
|
}
|
|
34
34
|
},
|
|
35
35
|
emits: ["activate", "delete", "resolve"],
|
|
36
|
-
setup(
|
|
37
|
-
const e =
|
|
36
|
+
setup(s, { emit: t }) {
|
|
37
|
+
const e = s, n = t, o = K(() => e.comments.filter((m) => !m?.resolved).length), r = b(null), u = (m, d) => m ? m.length > d ? m.slice(0, d) + "…" : m : "", c = (m) => {
|
|
38
38
|
n("activate", m);
|
|
39
39
|
};
|
|
40
40
|
return rt(
|
|
@@ -52,58 +52,58 @@ const zt = (i, t) => {
|
|
|
52
52
|
ref: r,
|
|
53
53
|
class: "comment-panel"
|
|
54
54
|
}, [
|
|
55
|
-
l("div",
|
|
56
|
-
l("h3",
|
|
55
|
+
l("div", Zn, [
|
|
56
|
+
l("h3", to, [
|
|
57
57
|
d[0] || (d[0] = he(" 批注 ", -1)),
|
|
58
|
-
o.value ? (_(), O("span",
|
|
58
|
+
o.value ? (_(), O("span", eo, S(o.value), 1)) : ft("", !0)
|
|
59
59
|
])
|
|
60
60
|
]),
|
|
61
|
-
|
|
61
|
+
s.comments.length === 0 ? (_(), O("div", no, [...d[1] || (d[1] = [
|
|
62
62
|
l("div", { class: "comment-panel__empty-icon" }, "💬", -1),
|
|
63
63
|
l("p", null, "暂无批注", -1),
|
|
64
64
|
l("p", { class: "comment-panel__empty-hint" }, "选中文本后点击「添加批注」", -1)
|
|
65
|
-
])])) : (_(), O("ul",
|
|
66
|
-
(_(!0), O(kt, null, It(
|
|
65
|
+
])])) : (_(), O("ul", oo, [
|
|
66
|
+
(_(!0), O(kt, null, It(s.comments, (h) => (_(), O("li", {
|
|
67
67
|
key: h.id,
|
|
68
68
|
class: _t(["comment-item", [
|
|
69
69
|
`comment-item--c${h.colorIndex ?? 0}`,
|
|
70
70
|
{
|
|
71
|
-
"comment-item--active":
|
|
71
|
+
"comment-item--active": s.activeCommentId === h.id,
|
|
72
72
|
"comment-item--resolved": h.resolved
|
|
73
73
|
}
|
|
74
74
|
]]),
|
|
75
75
|
"data-comment-id": h.id,
|
|
76
|
-
onClick: (
|
|
76
|
+
onClick: (A) => c(h.id)
|
|
77
77
|
}, [
|
|
78
|
-
l("div",
|
|
78
|
+
l("div", so, [
|
|
79
79
|
d[2] || (d[2] = l("span", { class: "comment-item__quote-icon" }, "❝", -1)),
|
|
80
80
|
he(" " + S(u(h.selectedText, 40)), 1)
|
|
81
81
|
]),
|
|
82
|
-
l("div",
|
|
83
|
-
l("div",
|
|
84
|
-
l("span",
|
|
85
|
-
l("span",
|
|
82
|
+
l("div", io, S(h.note), 1),
|
|
83
|
+
l("div", lo, [
|
|
84
|
+
l("span", ao, S(h.author), 1),
|
|
85
|
+
l("span", co, S(s.formatTime(h.createdAt)), 1)
|
|
86
86
|
]),
|
|
87
|
-
l("div",
|
|
87
|
+
l("div", uo, [
|
|
88
88
|
l("button", {
|
|
89
89
|
class: "comment-btn comment-btn--resolve",
|
|
90
90
|
type: "button",
|
|
91
|
-
onClick: dt((
|
|
92
|
-
}, S(h.resolved ? "取消解决" : "已解决"), 9,
|
|
91
|
+
onClick: dt((A) => n("resolve", h.id), ["stop"])
|
|
92
|
+
}, S(h.resolved ? "取消解决" : "已解决"), 9, mo),
|
|
93
93
|
l("button", {
|
|
94
94
|
class: "comment-btn comment-btn--delete",
|
|
95
95
|
type: "button",
|
|
96
|
-
onClick: dt((
|
|
97
|
-
}, " 删除 ", 8,
|
|
96
|
+
onClick: dt((A) => n("delete", h.id), ["stop"])
|
|
97
|
+
}, " 删除 ", 8, fo)
|
|
98
98
|
])
|
|
99
|
-
], 10,
|
|
99
|
+
], 10, ro))), 128))
|
|
100
100
|
]))
|
|
101
101
|
], 512));
|
|
102
102
|
}
|
|
103
|
-
},
|
|
103
|
+
}, po = /* @__PURE__ */ zt(ho, [["__scopeId", "data-v-0f4b5fed"]]), go = { class: "dialog" }, vo = { class: "dialog__header" }, yo = {
|
|
104
104
|
key: 0,
|
|
105
105
|
class: "dialog__quote"
|
|
106
|
-
},
|
|
106
|
+
}, wo = { class: "dialog__quote-text" }, ko = { class: "dialog__body" }, _o = ["onKeydown"], xo = { class: "dialog__footer" }, Co = ["disabled"], bo = {
|
|
107
107
|
__name: "CommentAddDialog",
|
|
108
108
|
props: {
|
|
109
109
|
selectedText: {
|
|
@@ -116,32 +116,32 @@ const zt = (i, t) => {
|
|
|
116
116
|
}
|
|
117
117
|
},
|
|
118
118
|
emits: ["confirm", "cancel"],
|
|
119
|
-
setup(
|
|
120
|
-
const e =
|
|
119
|
+
setup(s, { emit: t }) {
|
|
120
|
+
const e = s, n = t, o = b(e.initialNote), r = b(null);
|
|
121
121
|
pe(() => {
|
|
122
122
|
r.value?.focus();
|
|
123
123
|
});
|
|
124
|
-
const u = (m, d) => m ? m.length > d ? m.slice(0, d) + "…" : m : "",
|
|
124
|
+
const u = (m, d) => m ? m.length > d ? m.slice(0, d) + "…" : m : "", c = () => {
|
|
125
125
|
o.value.trim() && (n("confirm", o.value.trim()), o.value = "");
|
|
126
126
|
};
|
|
127
|
-
return (m, d) => (_(),
|
|
127
|
+
return (m, d) => (_(), Nt(ge, { to: "body" }, [
|
|
128
128
|
l("div", {
|
|
129
129
|
class: "dialog-backdrop",
|
|
130
130
|
onClick: d[4] || (d[4] = dt((h) => m.$emit("cancel"), ["self"]))
|
|
131
131
|
}, [
|
|
132
|
-
l("div",
|
|
133
|
-
l("div",
|
|
132
|
+
l("div", go, [
|
|
133
|
+
l("div", vo, [
|
|
134
134
|
d[5] || (d[5] = l("h4", { class: "dialog__title" }, "添加批注", -1)),
|
|
135
135
|
l("button", {
|
|
136
136
|
class: "dialog__close",
|
|
137
137
|
onClick: d[0] || (d[0] = (h) => m.$emit("cancel"))
|
|
138
138
|
}, "✕")
|
|
139
139
|
]),
|
|
140
|
-
|
|
140
|
+
s.selectedText ? (_(), O("div", yo, [
|
|
141
141
|
d[6] || (d[6] = l("span", { class: "dialog__quote-label" }, "选中文本", -1)),
|
|
142
|
-
l("blockquote",
|
|
142
|
+
l("blockquote", wo, S(u(s.selectedText, 120)), 1)
|
|
143
143
|
])) : ft("", !0),
|
|
144
|
-
l("div",
|
|
144
|
+
l("div", ko, [
|
|
145
145
|
d[7] || (d[7] = l("label", {
|
|
146
146
|
class: "dialog__label",
|
|
147
147
|
for: "comment-input"
|
|
@@ -155,15 +155,15 @@ const zt = (i, t) => {
|
|
|
155
155
|
placeholder: "请输入批注内容…",
|
|
156
156
|
rows: "4",
|
|
157
157
|
onKeydown: [
|
|
158
|
-
ve(dt(
|
|
158
|
+
ve(dt(c, ["ctrl"]), ["enter"]),
|
|
159
159
|
d[2] || (d[2] = ve((h) => m.$emit("cancel"), ["escape"]))
|
|
160
160
|
]
|
|
161
|
-
}, null, 40,
|
|
161
|
+
}, null, 40, _o), [
|
|
162
162
|
[$n, o.value]
|
|
163
163
|
]),
|
|
164
164
|
d[8] || (d[8] = l("p", { class: "dialog__hint" }, "Ctrl+Enter 确认 · Esc 取消", -1))
|
|
165
165
|
]),
|
|
166
|
-
l("div",
|
|
166
|
+
l("div", xo, [
|
|
167
167
|
l("button", {
|
|
168
168
|
class: "dialog__btn dialog__btn--cancel",
|
|
169
169
|
onClick: d[3] || (d[3] = (h) => m.$emit("cancel"))
|
|
@@ -171,18 +171,18 @@ const zt = (i, t) => {
|
|
|
171
171
|
l("button", {
|
|
172
172
|
class: "dialog__btn dialog__btn--confirm",
|
|
173
173
|
disabled: !o.value.trim(),
|
|
174
|
-
onClick:
|
|
175
|
-
}, " 确认添加 ", 8,
|
|
174
|
+
onClick: c
|
|
175
|
+
}, " 确认添加 ", 8, Co)
|
|
176
176
|
])
|
|
177
177
|
])
|
|
178
178
|
])
|
|
179
179
|
]));
|
|
180
180
|
}
|
|
181
|
-
},
|
|
181
|
+
}, So = /* @__PURE__ */ zt(bo, [["__scopeId", "data-v-8cbc8293"]]), To = {
|
|
182
182
|
class: "comment-gutter",
|
|
183
183
|
style: { "margin-top": "-100px" },
|
|
184
184
|
"aria-label": "批注贴行栏"
|
|
185
|
-
},
|
|
185
|
+
}, Eo = ["onClick", "onKeydown"], Mo = { class: "gutter-item__quote" }, No = { class: "gutter-item__note" }, Io = { class: "gutter-item__meta" }, Oo = { class: "gutter-item__author" }, Ao = { class: "gutter-item__time" }, $o = {
|
|
186
186
|
__name: "CommentGutter",
|
|
187
187
|
props: {
|
|
188
188
|
anchors: { type: Array, default: () => [] },
|
|
@@ -193,31 +193,31 @@ const zt = (i, t) => {
|
|
|
193
193
|
minGap: { type: Number, default: 10 },
|
|
194
194
|
// 气泡的估算高度(用于避让);实际高度变化不大
|
|
195
195
|
itemHeight: { type: Number, default: 78 },
|
|
196
|
-
formatTime: { type: Function, default: (
|
|
196
|
+
formatTime: { type: Function, default: (s) => "" }
|
|
197
197
|
},
|
|
198
198
|
emits: ["activate"],
|
|
199
|
-
setup(
|
|
200
|
-
const t =
|
|
201
|
-
if (!
|
|
202
|
-
const d = String(
|
|
199
|
+
setup(s) {
|
|
200
|
+
const t = s, e = (c, m) => {
|
|
201
|
+
if (!c) return "";
|
|
202
|
+
const d = String(c);
|
|
203
203
|
return d.length > m ? d.slice(0, m) + "…" : d;
|
|
204
204
|
}, n = b([]);
|
|
205
205
|
rt(
|
|
206
206
|
() => ({ anchors: t.anchors, commentsLen: (t.comments || []).length }),
|
|
207
|
-
({ anchors:
|
|
208
|
-
!
|
|
207
|
+
({ anchors: c, commentsLen: m }) => {
|
|
208
|
+
!c || !c.length || m && (!n.value.length || n.value.length < m) && c.length >= m && (n.value = c.slice());
|
|
209
209
|
},
|
|
210
210
|
{ immediate: !0 }
|
|
211
211
|
);
|
|
212
212
|
const o = K(() => {
|
|
213
|
-
const
|
|
214
|
-
for (const m of t.comments || [])
|
|
215
|
-
return
|
|
213
|
+
const c = /* @__PURE__ */ new Map();
|
|
214
|
+
for (const m of t.comments || []) c.set(m.id, m);
|
|
215
|
+
return c;
|
|
216
216
|
}), r = K(() => {
|
|
217
|
-
const
|
|
217
|
+
const c = [], m = n.value.length ? n.value : t.anchors || [];
|
|
218
218
|
for (const d of m) {
|
|
219
219
|
const h = o.value.get(d.id);
|
|
220
|
-
h &&
|
|
220
|
+
h && c.push({
|
|
221
221
|
id: d.id,
|
|
222
222
|
anchorTop: Math.max(0, Number(d.top) || 0),
|
|
223
223
|
selectedText: h.selectedText,
|
|
@@ -228,18 +228,18 @@ const zt = (i, t) => {
|
|
|
228
228
|
colorIndex: h.colorIndex ?? 0
|
|
229
229
|
});
|
|
230
230
|
}
|
|
231
|
-
return
|
|
231
|
+
return c.sort((d, h) => d.anchorTop - h.anchorTop);
|
|
232
232
|
}), u = K(() => {
|
|
233
|
-
const
|
|
233
|
+
const c = [];
|
|
234
234
|
let m = 0;
|
|
235
235
|
const d = t.itemHeight, h = t.minGap;
|
|
236
|
-
for (const
|
|
237
|
-
const
|
|
238
|
-
|
|
236
|
+
for (const A of r.value) {
|
|
237
|
+
const R = A.anchorTop, B = R - m, y = B > 0 ? B : 0;
|
|
238
|
+
c.push({ ...A, marginTop: y }), m = R + d + h;
|
|
239
239
|
}
|
|
240
|
-
return
|
|
240
|
+
return c;
|
|
241
241
|
});
|
|
242
|
-
return (
|
|
242
|
+
return (c, m) => (_(), O("div", To, [
|
|
243
243
|
(_(!0), O(kt, null, It(u.value, (d) => (_(), O("div", {
|
|
244
244
|
key: d.id,
|
|
245
245
|
class: "gutter-item-wrapper",
|
|
@@ -249,31 +249,31 @@ const zt = (i, t) => {
|
|
|
249
249
|
class: _t(["gutter-item", [
|
|
250
250
|
`gutter-item--c${d.colorIndex ?? 0}`,
|
|
251
251
|
{
|
|
252
|
-
"gutter-item--active":
|
|
252
|
+
"gutter-item--active": s.activeCommentId === d.id,
|
|
253
253
|
"gutter-item--resolved": d.resolved
|
|
254
254
|
}
|
|
255
255
|
]]),
|
|
256
256
|
role: "button",
|
|
257
257
|
tabindex: "0",
|
|
258
|
-
onClick: (h) =>
|
|
259
|
-
onKeydown: ve(dt((h) =>
|
|
258
|
+
onClick: (h) => c.$emit("activate", d.id),
|
|
259
|
+
onKeydown: ve(dt((h) => c.$emit("activate", d.id), ["prevent"]), ["enter"])
|
|
260
260
|
}, [
|
|
261
|
-
l("div",
|
|
261
|
+
l("div", Mo, S(e(d.selectedText, 28)), 1),
|
|
262
262
|
l("div", No, S(e(d.note, 36)), 1),
|
|
263
|
-
l("div",
|
|
264
|
-
l("span",
|
|
265
|
-
l("span",
|
|
263
|
+
l("div", Io, [
|
|
264
|
+
l("span", Oo, S(d.author), 1),
|
|
265
|
+
l("span", Ao, S(s.formatTime(d.createdAt)), 1)
|
|
266
266
|
])
|
|
267
|
-
], 42,
|
|
267
|
+
], 42, Eo)
|
|
268
268
|
], 4))), 128))
|
|
269
269
|
]));
|
|
270
270
|
}
|
|
271
|
-
},
|
|
272
|
-
function Ye(
|
|
271
|
+
}, zo = /* @__PURE__ */ zt($o, [["__scopeId", "data-v-ac6164bd"]]);
|
|
272
|
+
function Ye(s, t, e) {
|
|
273
273
|
for (let n = 0; ; n++) {
|
|
274
|
-
if (n ==
|
|
275
|
-
return
|
|
276
|
-
let o =
|
|
274
|
+
if (n == s.childCount || n == t.childCount)
|
|
275
|
+
return s.childCount == t.childCount ? null : e;
|
|
276
|
+
let o = s.child(n), r = t.child(n);
|
|
277
277
|
if (o == r) {
|
|
278
278
|
e += o.nodeSize;
|
|
279
279
|
continue;
|
|
@@ -293,32 +293,32 @@ function Ye(i, t, e) {
|
|
|
293
293
|
e += o.nodeSize;
|
|
294
294
|
}
|
|
295
295
|
}
|
|
296
|
-
function Ze(
|
|
297
|
-
for (let o =
|
|
296
|
+
function Ze(s, t, e, n) {
|
|
297
|
+
for (let o = s.childCount, r = t.childCount; ; ) {
|
|
298
298
|
if (o == 0 || r == 0)
|
|
299
299
|
return o == r ? null : { a: e, b: n };
|
|
300
|
-
let u =
|
|
301
|
-
if (u ==
|
|
300
|
+
let u = s.child(--o), c = t.child(--r), m = u.nodeSize;
|
|
301
|
+
if (u == c) {
|
|
302
302
|
e -= m, n -= m;
|
|
303
303
|
continue;
|
|
304
304
|
}
|
|
305
|
-
if (!u.sameMarkup(
|
|
305
|
+
if (!u.sameMarkup(c))
|
|
306
306
|
return { a: e, b: n };
|
|
307
|
-
if (u.isText && u.text !=
|
|
308
|
-
let d = 0, h = Math.min(u.text.length,
|
|
309
|
-
for (; d < h && u.text[u.text.length - d - 1] ==
|
|
307
|
+
if (u.isText && u.text != c.text) {
|
|
308
|
+
let d = 0, h = Math.min(u.text.length, c.text.length);
|
|
309
|
+
for (; d < h && u.text[u.text.length - d - 1] == c.text[c.text.length - d - 1]; )
|
|
310
310
|
d++, e--, n--;
|
|
311
311
|
return { a: e, b: n };
|
|
312
312
|
}
|
|
313
|
-
if (u.content.size ||
|
|
314
|
-
let d = Ze(u.content,
|
|
313
|
+
if (u.content.size || c.content.size) {
|
|
314
|
+
let d = Ze(u.content, c.content, e - 1, n - 1);
|
|
315
315
|
if (d)
|
|
316
316
|
return d;
|
|
317
317
|
}
|
|
318
318
|
e -= m, n -= m;
|
|
319
319
|
}
|
|
320
320
|
}
|
|
321
|
-
class
|
|
321
|
+
class $ {
|
|
322
322
|
/**
|
|
323
323
|
@internal
|
|
324
324
|
*/
|
|
@@ -333,13 +333,13 @@ class A {
|
|
|
333
333
|
into a node when the callback returns `false`.
|
|
334
334
|
*/
|
|
335
335
|
nodesBetween(t, e, n, o = 0, r) {
|
|
336
|
-
for (let u = 0,
|
|
337
|
-
let m = this.content[u], d =
|
|
338
|
-
if (d > t && n(m, o +
|
|
339
|
-
let h =
|
|
336
|
+
for (let u = 0, c = 0; c < e; u++) {
|
|
337
|
+
let m = this.content[u], d = c + m.nodeSize;
|
|
338
|
+
if (d > t && n(m, o + c, r || null, u) !== !1 && m.content.size) {
|
|
339
|
+
let h = c + 1;
|
|
340
340
|
m.nodesBetween(Math.max(0, t - h), Math.min(m.content.size, e - h), n, o + h);
|
|
341
341
|
}
|
|
342
|
-
|
|
342
|
+
c = d;
|
|
343
343
|
}
|
|
344
344
|
}
|
|
345
345
|
/**
|
|
@@ -356,9 +356,9 @@ class A {
|
|
|
356
356
|
*/
|
|
357
357
|
textBetween(t, e, n, o) {
|
|
358
358
|
let r = "", u = !0;
|
|
359
|
-
return this.nodesBetween(t, e, (
|
|
360
|
-
let d =
|
|
361
|
-
|
|
359
|
+
return this.nodesBetween(t, e, (c, m) => {
|
|
360
|
+
let d = c.isText ? c.text.slice(Math.max(t, m) - m, e - m) : c.isLeaf ? o ? typeof o == "function" ? o(c) : o : c.type.spec.leafText ? c.type.spec.leafText(c) : "" : "";
|
|
361
|
+
c.isBlock && (c.isLeaf && d || c.isTextblock) && n && (u ? u = !1 : r += n), r += d;
|
|
362
362
|
}, 0), r;
|
|
363
363
|
}
|
|
364
364
|
/**
|
|
@@ -373,7 +373,7 @@ class A {
|
|
|
373
373
|
let e = this.lastChild, n = t.firstChild, o = this.content.slice(), r = 0;
|
|
374
374
|
for (e.isText && e.sameMarkup(n) && (o[o.length - 1] = e.withText(e.text + n.text), r = 1); r < t.content.length; r++)
|
|
375
375
|
o.push(t.content[r]);
|
|
376
|
-
return new
|
|
376
|
+
return new $(o, this.size + t.size);
|
|
377
377
|
}
|
|
378
378
|
/**
|
|
379
379
|
Cut out the sub-fragment between the two given positions.
|
|
@@ -384,16 +384,16 @@ class A {
|
|
|
384
384
|
let n = [], o = 0;
|
|
385
385
|
if (e > t)
|
|
386
386
|
for (let r = 0, u = 0; u < e; r++) {
|
|
387
|
-
let
|
|
388
|
-
m > t && ((u < t || m > e) && (
|
|
387
|
+
let c = this.content[r], m = u + c.nodeSize;
|
|
388
|
+
m > t && ((u < t || m > e) && (c.isText ? c = c.cut(Math.max(0, t - u), Math.min(c.text.length, e - u)) : c = c.cut(Math.max(0, t - u - 1), Math.min(c.content.size, e - u - 1))), n.push(c), o += c.nodeSize), u = m;
|
|
389
389
|
}
|
|
390
|
-
return new
|
|
390
|
+
return new $(n, o);
|
|
391
391
|
}
|
|
392
392
|
/**
|
|
393
393
|
@internal
|
|
394
394
|
*/
|
|
395
395
|
cutByIndex(t, e) {
|
|
396
|
-
return t == e ?
|
|
396
|
+
return t == e ? $.empty : t == 0 && e == this.content.length ? this : new $(this.content.slice(t, e));
|
|
397
397
|
}
|
|
398
398
|
/**
|
|
399
399
|
Create a new fragment in which the node at the given index is
|
|
@@ -404,21 +404,21 @@ class A {
|
|
|
404
404
|
if (n == e)
|
|
405
405
|
return this;
|
|
406
406
|
let o = this.content.slice(), r = this.size + e.nodeSize - n.nodeSize;
|
|
407
|
-
return o[t] = e, new
|
|
407
|
+
return o[t] = e, new $(o, r);
|
|
408
408
|
}
|
|
409
409
|
/**
|
|
410
410
|
Create a new fragment by prepending the given node to this
|
|
411
411
|
fragment.
|
|
412
412
|
*/
|
|
413
413
|
addToStart(t) {
|
|
414
|
-
return new
|
|
414
|
+
return new $([t].concat(this.content), this.size + t.nodeSize);
|
|
415
415
|
}
|
|
416
416
|
/**
|
|
417
417
|
Create a new fragment by appending the given node to this
|
|
418
418
|
fragment.
|
|
419
419
|
*/
|
|
420
420
|
addToEnd(t) {
|
|
421
|
-
return new
|
|
421
|
+
return new $(this.content.concat(t), this.size + t.nodeSize);
|
|
422
422
|
}
|
|
423
423
|
/**
|
|
424
424
|
Compare this fragment to another one.
|
|
@@ -533,10 +533,10 @@ class A {
|
|
|
533
533
|
*/
|
|
534
534
|
static fromJSON(t, e) {
|
|
535
535
|
if (!e)
|
|
536
|
-
return
|
|
536
|
+
return $.empty;
|
|
537
537
|
if (!Array.isArray(e))
|
|
538
538
|
throw new RangeError("Invalid input for Fragment.fromJSON");
|
|
539
|
-
return new
|
|
539
|
+
return new $(e.map(t.nodeFromJSON));
|
|
540
540
|
}
|
|
541
541
|
/**
|
|
542
542
|
Build a fragment from an array of nodes. Ensures that adjacent
|
|
@@ -544,13 +544,13 @@ class A {
|
|
|
544
544
|
*/
|
|
545
545
|
static fromArray(t) {
|
|
546
546
|
if (!t.length)
|
|
547
|
-
return
|
|
547
|
+
return $.empty;
|
|
548
548
|
let e, n = 0;
|
|
549
549
|
for (let o = 0; o < t.length; o++) {
|
|
550
550
|
let r = t[o];
|
|
551
551
|
n += r.nodeSize, o && r.isText && t[o - 1].sameMarkup(r) ? (e || (e = t.slice(0, o)), e[e.length - 1] = r.withText(e[e.length - 1].text + r.text)) : e && e.push(r);
|
|
552
552
|
}
|
|
553
|
-
return new
|
|
553
|
+
return new $(e || t, n);
|
|
554
554
|
}
|
|
555
555
|
/**
|
|
556
556
|
Create a fragment from something that can be interpreted as a
|
|
@@ -560,22 +560,22 @@ class A {
|
|
|
560
560
|
*/
|
|
561
561
|
static from(t) {
|
|
562
562
|
if (!t)
|
|
563
|
-
return
|
|
564
|
-
if (t instanceof
|
|
563
|
+
return $.empty;
|
|
564
|
+
if (t instanceof $)
|
|
565
565
|
return t;
|
|
566
566
|
if (Array.isArray(t))
|
|
567
567
|
return this.fromArray(t);
|
|
568
568
|
if (t.attrs)
|
|
569
|
-
return new
|
|
569
|
+
return new $([t], t.nodeSize);
|
|
570
570
|
throw new RangeError("Can not convert " + t + " to a Fragment" + (t.nodesBetween ? " (looks like multiple versions of prosemirror-model were loaded)" : ""));
|
|
571
571
|
}
|
|
572
572
|
}
|
|
573
|
-
|
|
573
|
+
$.empty = new $([], 0);
|
|
574
574
|
const ue = { index: 0, offset: 0 };
|
|
575
|
-
function Kt(
|
|
576
|
-
return ue.index =
|
|
575
|
+
function Kt(s, t) {
|
|
576
|
+
return ue.index = s, ue.offset = t, ue;
|
|
577
577
|
}
|
|
578
|
-
class
|
|
578
|
+
class Do extends Error {
|
|
579
579
|
}
|
|
580
580
|
class I {
|
|
581
581
|
/**
|
|
@@ -642,7 +642,7 @@ class I {
|
|
|
642
642
|
let n = e.openStart || 0, o = e.openEnd || 0;
|
|
643
643
|
if (typeof n != "number" || typeof o != "number")
|
|
644
644
|
throw new RangeError("Invalid input for Slice.fromJSON");
|
|
645
|
-
return new I(
|
|
645
|
+
return new I($.fromJSON(t, e.content), n, o);
|
|
646
646
|
}
|
|
647
647
|
/**
|
|
648
648
|
Create a slice from a fragment by taking the maximum possible
|
|
@@ -657,34 +657,34 @@ class I {
|
|
|
657
657
|
return new I(t, n, o);
|
|
658
658
|
}
|
|
659
659
|
}
|
|
660
|
-
I.empty = new I(
|
|
661
|
-
function tn(
|
|
662
|
-
let { index: n, offset: o } =
|
|
660
|
+
I.empty = new I($.empty, 0, 0);
|
|
661
|
+
function tn(s, t, e) {
|
|
662
|
+
let { index: n, offset: o } = s.findIndex(t), r = s.maybeChild(n), { index: u, offset: c } = s.findIndex(e);
|
|
663
663
|
if (o == t || r.isText) {
|
|
664
|
-
if (
|
|
664
|
+
if (c != e && !s.child(u).isText)
|
|
665
665
|
throw new RangeError("Removing non-flat range");
|
|
666
|
-
return
|
|
666
|
+
return s.cut(0, t).append(s.cut(e));
|
|
667
667
|
}
|
|
668
668
|
if (n != u)
|
|
669
669
|
throw new RangeError("Removing non-flat range");
|
|
670
|
-
return
|
|
670
|
+
return s.replaceChild(n, r.copy(tn(r.content, t - o - 1, e - o - 1)));
|
|
671
671
|
}
|
|
672
|
-
function en(
|
|
673
|
-
let { index: o, offset: r } =
|
|
672
|
+
function en(s, t, e, n) {
|
|
673
|
+
let { index: o, offset: r } = s.findIndex(t), u = s.maybeChild(o);
|
|
674
674
|
if (r == t || u.isText)
|
|
675
|
-
return n && !n.canReplace(o, o, e) ? null :
|
|
676
|
-
let
|
|
677
|
-
return
|
|
675
|
+
return n && !n.canReplace(o, o, e) ? null : s.cut(0, t).append(e).append(s.cut(t));
|
|
676
|
+
let c = en(u.content, t - r - 1, e, u);
|
|
677
|
+
return c && s.replaceChild(o, u.copy(c));
|
|
678
678
|
}
|
|
679
679
|
const nn = 65535, on = Math.pow(2, 16);
|
|
680
|
-
function
|
|
681
|
-
return
|
|
680
|
+
function Jo(s, t) {
|
|
681
|
+
return s + t * on;
|
|
682
682
|
}
|
|
683
|
-
function Ue(
|
|
684
|
-
return
|
|
683
|
+
function Ue(s) {
|
|
684
|
+
return s & nn;
|
|
685
685
|
}
|
|
686
|
-
function
|
|
687
|
-
return (
|
|
686
|
+
function Ro(s) {
|
|
687
|
+
return (s - (s & nn)) / on;
|
|
688
688
|
}
|
|
689
689
|
const rn = 1, sn = 2, Xt = 4, ln = 8;
|
|
690
690
|
class We {
|
|
@@ -741,7 +741,7 @@ class j {
|
|
|
741
741
|
if (!this.inverted)
|
|
742
742
|
for (let o = 0; o < n; o++)
|
|
743
743
|
e += this.ranges[o * 3 + 2] - this.ranges[o * 3 + 1];
|
|
744
|
-
return this.ranges[n * 3] + e +
|
|
744
|
+
return this.ranges[n * 3] + e + Ro(t);
|
|
745
745
|
}
|
|
746
746
|
mapResult(t, e = 1) {
|
|
747
747
|
return this._map(t, e, !1);
|
|
@@ -754,17 +754,17 @@ class j {
|
|
|
754
754
|
*/
|
|
755
755
|
_map(t, e, n) {
|
|
756
756
|
let o = 0, r = this.inverted ? 2 : 1, u = this.inverted ? 1 : 2;
|
|
757
|
-
for (let
|
|
758
|
-
let m = this.ranges[
|
|
757
|
+
for (let c = 0; c < this.ranges.length; c += 3) {
|
|
758
|
+
let m = this.ranges[c] - (this.inverted ? o : 0);
|
|
759
759
|
if (m > t)
|
|
760
760
|
break;
|
|
761
|
-
let d = this.ranges[
|
|
762
|
-
if (t <=
|
|
763
|
-
let
|
|
761
|
+
let d = this.ranges[c + r], h = this.ranges[c + u], A = m + d;
|
|
762
|
+
if (t <= A) {
|
|
763
|
+
let R = d ? t == m ? -1 : t == A ? 1 : e : e, B = m + o + (R < 0 ? 0 : h);
|
|
764
764
|
if (n)
|
|
765
|
-
return
|
|
766
|
-
let y = t == (e < 0 ? m :
|
|
767
|
-
return (e < 0 ? t != m : t !=
|
|
765
|
+
return B;
|
|
766
|
+
let y = t == (e < 0 ? m : A) ? null : Jo(c / 3, t - m), v = t == m ? sn : t == A ? rn : Xt;
|
|
767
|
+
return (e < 0 ? t != m : t != A) && (v |= ln), new We(B, v, y);
|
|
768
768
|
}
|
|
769
769
|
o += h - d;
|
|
770
770
|
}
|
|
@@ -775,14 +775,14 @@ class j {
|
|
|
775
775
|
*/
|
|
776
776
|
touches(t, e) {
|
|
777
777
|
let n = 0, o = Ue(e), r = this.inverted ? 2 : 1, u = this.inverted ? 1 : 2;
|
|
778
|
-
for (let
|
|
779
|
-
let m = this.ranges[
|
|
778
|
+
for (let c = 0; c < this.ranges.length; c += 3) {
|
|
779
|
+
let m = this.ranges[c] - (this.inverted ? n : 0);
|
|
780
780
|
if (m > t)
|
|
781
781
|
break;
|
|
782
|
-
let d = this.ranges[
|
|
783
|
-
if (t <= h &&
|
|
782
|
+
let d = this.ranges[c + r], h = m + d;
|
|
783
|
+
if (t <= h && c == o * 3)
|
|
784
784
|
return !0;
|
|
785
|
-
n += this.ranges[
|
|
785
|
+
n += this.ranges[c + u] - d;
|
|
786
786
|
}
|
|
787
787
|
return !1;
|
|
788
788
|
}
|
|
@@ -793,8 +793,8 @@ class j {
|
|
|
793
793
|
forEach(t) {
|
|
794
794
|
let e = this.inverted ? 2 : 1, n = this.inverted ? 1 : 2;
|
|
795
795
|
for (let o = 0, r = 0; o < this.ranges.length; o += 3) {
|
|
796
|
-
let u = this.ranges[o],
|
|
797
|
-
t(
|
|
796
|
+
let u = this.ranges[o], c = u - (this.inverted ? r : 0), m = u + (this.inverted ? 0 : r), d = this.ranges[o + e], h = this.ranges[o + n];
|
|
797
|
+
t(c, c + d, m, m + h), r += h - d;
|
|
798
798
|
}
|
|
799
799
|
}
|
|
800
800
|
/**
|
|
@@ -821,7 +821,7 @@ class j {
|
|
|
821
821
|
}
|
|
822
822
|
j.empty = new j([]);
|
|
823
823
|
const de = /* @__PURE__ */ Object.create(null);
|
|
824
|
-
class
|
|
824
|
+
class W {
|
|
825
825
|
/**
|
|
826
826
|
Get the step map that represents the changes made by this step,
|
|
827
827
|
and which can be used to transform between positions in the old
|
|
@@ -890,21 +890,21 @@ class J {
|
|
|
890
890
|
try {
|
|
891
891
|
return J.ok(t.replace(e, n, o));
|
|
892
892
|
} catch (r) {
|
|
893
|
-
if (r instanceof
|
|
893
|
+
if (r instanceof Do)
|
|
894
894
|
return J.fail(r.message);
|
|
895
895
|
throw r;
|
|
896
896
|
}
|
|
897
897
|
}
|
|
898
898
|
}
|
|
899
|
-
function _e(
|
|
899
|
+
function _e(s, t, e) {
|
|
900
900
|
let n = [];
|
|
901
|
-
for (let o = 0; o <
|
|
902
|
-
let r =
|
|
901
|
+
for (let o = 0; o < s.childCount; o++) {
|
|
902
|
+
let r = s.child(o);
|
|
903
903
|
r.content.size && (r = r.copy(_e(r.content, t, r))), r.isInline && (r = t(r, e, o)), n.push(r);
|
|
904
904
|
}
|
|
905
|
-
return
|
|
905
|
+
return $.fromArray(n);
|
|
906
906
|
}
|
|
907
|
-
class ht extends
|
|
907
|
+
class ht extends W {
|
|
908
908
|
/**
|
|
909
909
|
Create a mark step.
|
|
910
910
|
*/
|
|
@@ -912,7 +912,7 @@ class ht extends U {
|
|
|
912
912
|
super(), this.from = t, this.to = e, this.mark = n;
|
|
913
913
|
}
|
|
914
914
|
apply(t) {
|
|
915
|
-
let e = t.slice(this.from, this.to), n = t.resolve(this.from), o = n.node(n.sharedDepth(this.to)), r = new I(_e(e.content, (u,
|
|
915
|
+
let e = t.slice(this.from, this.to), n = t.resolve(this.from), o = n.node(n.sharedDepth(this.to)), r = new I(_e(e.content, (u, c) => !u.isAtom || !c.type.allowsMarkType(this.mark.type) ? u : u.mark(this.mark.addToSet(u.marks)), o), e.openStart, e.openEnd);
|
|
916
916
|
return J.fromReplace(t, this.from, this.to, r);
|
|
917
917
|
}
|
|
918
918
|
invert() {
|
|
@@ -942,8 +942,8 @@ class ht extends U {
|
|
|
942
942
|
return new ht(e.from, e.to, t.markFromJSON(e.mark));
|
|
943
943
|
}
|
|
944
944
|
}
|
|
945
|
-
|
|
946
|
-
class pt extends
|
|
945
|
+
W.jsonID("addMark", ht);
|
|
946
|
+
class pt extends W {
|
|
947
947
|
/**
|
|
948
948
|
Create a mark-removing step.
|
|
949
949
|
*/
|
|
@@ -981,8 +981,8 @@ class pt extends U {
|
|
|
981
981
|
return new pt(e.from, e.to, t.markFromJSON(e.mark));
|
|
982
982
|
}
|
|
983
983
|
}
|
|
984
|
-
|
|
985
|
-
class gt extends
|
|
984
|
+
W.jsonID("removeMark", pt);
|
|
985
|
+
class gt extends W {
|
|
986
986
|
/**
|
|
987
987
|
Create a node mark step.
|
|
988
988
|
*/
|
|
@@ -994,7 +994,7 @@ class gt extends U {
|
|
|
994
994
|
if (!e)
|
|
995
995
|
return J.fail("No node at mark step's position");
|
|
996
996
|
let n = e.type.create(e.attrs, null, this.mark.addToSet(e.marks));
|
|
997
|
-
return J.fromReplace(t, this.pos, this.pos + 1, new I(
|
|
997
|
+
return J.fromReplace(t, this.pos, this.pos + 1, new I($.from(n), 0, e.isLeaf ? 0 : 1));
|
|
998
998
|
}
|
|
999
999
|
invert(t) {
|
|
1000
1000
|
let e = t.nodeAt(this.pos);
|
|
@@ -1025,8 +1025,8 @@ class gt extends U {
|
|
|
1025
1025
|
return new gt(e.pos, t.markFromJSON(e.mark));
|
|
1026
1026
|
}
|
|
1027
1027
|
}
|
|
1028
|
-
|
|
1029
|
-
class At extends
|
|
1028
|
+
W.jsonID("addNodeMark", gt);
|
|
1029
|
+
class At extends W {
|
|
1030
1030
|
/**
|
|
1031
1031
|
Create a mark-removing step.
|
|
1032
1032
|
*/
|
|
@@ -1038,7 +1038,7 @@ class At extends U {
|
|
|
1038
1038
|
if (!e)
|
|
1039
1039
|
return J.fail("No node at mark step's position");
|
|
1040
1040
|
let n = e.type.create(e.attrs, null, this.mark.removeFromSet(e.marks));
|
|
1041
|
-
return J.fromReplace(t, this.pos, this.pos + 1, new I(
|
|
1041
|
+
return J.fromReplace(t, this.pos, this.pos + 1, new I($.from(n), 0, e.isLeaf ? 0 : 1));
|
|
1042
1042
|
}
|
|
1043
1043
|
invert(t) {
|
|
1044
1044
|
let e = t.nodeAt(this.pos);
|
|
@@ -1060,8 +1060,8 @@ class At extends U {
|
|
|
1060
1060
|
return new At(e.pos, t.markFromJSON(e.mark));
|
|
1061
1061
|
}
|
|
1062
1062
|
}
|
|
1063
|
-
|
|
1064
|
-
class ot extends
|
|
1063
|
+
W.jsonID("removeNodeMark", At);
|
|
1064
|
+
class ot extends W {
|
|
1065
1065
|
/**
|
|
1066
1066
|
The given `slice` should fit the 'gap' between `from` and
|
|
1067
1067
|
`to`—the depths must line up, and the surrounding nodes must be
|
|
@@ -1112,16 +1112,16 @@ class ot extends U {
|
|
|
1112
1112
|
return new ot(e.from, e.to, I.fromJSON(t, e.slice), !!e.structure);
|
|
1113
1113
|
}
|
|
1114
1114
|
}
|
|
1115
|
-
|
|
1116
|
-
class xt extends
|
|
1115
|
+
W.jsonID("replace", ot);
|
|
1116
|
+
class xt extends W {
|
|
1117
1117
|
/**
|
|
1118
1118
|
Create a replace-around step with the given range and gap.
|
|
1119
1119
|
`insert` should be the point in the slice into which the content
|
|
1120
1120
|
of the gap should be moved. `structure` has the same meaning as
|
|
1121
1121
|
it has in the [`ReplaceStep`](https://prosemirror.net/docs/ref/#transform.ReplaceStep) class.
|
|
1122
1122
|
*/
|
|
1123
|
-
constructor(t, e, n, o, r, u,
|
|
1124
|
-
super(), this.from = t, this.to = e, this.gapFrom = n, this.gapTo = o, this.slice = r, this.insert = u, this.structure =
|
|
1123
|
+
constructor(t, e, n, o, r, u, c = !1) {
|
|
1124
|
+
super(), this.from = t, this.to = e, this.gapFrom = n, this.gapTo = o, this.slice = r, this.insert = u, this.structure = c;
|
|
1125
1125
|
}
|
|
1126
1126
|
apply(t) {
|
|
1127
1127
|
if (this.structure && (ye(t, this.from, this.gapFrom) || ye(t, this.gapTo, this.to)))
|
|
@@ -1170,9 +1170,9 @@ class xt extends U {
|
|
|
1170
1170
|
return new xt(e.from, e.to, e.gapFrom, e.gapTo, I.fromJSON(t, e.slice), e.insert, !!e.structure);
|
|
1171
1171
|
}
|
|
1172
1172
|
}
|
|
1173
|
-
|
|
1174
|
-
function ye(
|
|
1175
|
-
let n =
|
|
1173
|
+
W.jsonID("replaceAround", xt);
|
|
1174
|
+
function ye(s, t, e) {
|
|
1175
|
+
let n = s.resolve(t), o = e - t, r = n.depth;
|
|
1176
1176
|
for (; o > 0 && r > 0 && n.indexAfter(r) == n.node(r).childCount; )
|
|
1177
1177
|
r--, o--;
|
|
1178
1178
|
if (o > 0) {
|
|
@@ -1185,7 +1185,7 @@ function ye(i, t, e) {
|
|
|
1185
1185
|
}
|
|
1186
1186
|
return !1;
|
|
1187
1187
|
}
|
|
1188
|
-
class Ot extends
|
|
1188
|
+
class Ot extends W {
|
|
1189
1189
|
/**
|
|
1190
1190
|
Construct an attribute step.
|
|
1191
1191
|
*/
|
|
@@ -1201,7 +1201,7 @@ class Ot extends U {
|
|
|
1201
1201
|
n[r] = e.attrs[r];
|
|
1202
1202
|
n[this.attr] = this.value;
|
|
1203
1203
|
let o = e.type.create(n, null, e.marks);
|
|
1204
|
-
return J.fromReplace(t, this.pos, this.pos + 1, new I(
|
|
1204
|
+
return J.fromReplace(t, this.pos, this.pos + 1, new I($.from(o), 0, e.isLeaf ? 0 : 1));
|
|
1205
1205
|
}
|
|
1206
1206
|
getMap() {
|
|
1207
1207
|
return j.empty;
|
|
@@ -1222,8 +1222,8 @@ class Ot extends U {
|
|
|
1222
1222
|
return new Ot(e.pos, e.attr, e.value);
|
|
1223
1223
|
}
|
|
1224
1224
|
}
|
|
1225
|
-
|
|
1226
|
-
class Qt extends
|
|
1225
|
+
W.jsonID("attr", Ot);
|
|
1226
|
+
class Qt extends W {
|
|
1227
1227
|
/**
|
|
1228
1228
|
Construct an attribute step.
|
|
1229
1229
|
*/
|
|
@@ -1256,25 +1256,25 @@ class Qt extends U {
|
|
|
1256
1256
|
return new Qt(e.attr, e.value);
|
|
1257
1257
|
}
|
|
1258
1258
|
}
|
|
1259
|
-
|
|
1259
|
+
W.jsonID("docAttr", Qt);
|
|
1260
1260
|
let $t = class extends Error {
|
|
1261
1261
|
};
|
|
1262
|
-
$t = function
|
|
1262
|
+
$t = function s(t) {
|
|
1263
1263
|
let e = Error.call(this, t);
|
|
1264
|
-
return e.__proto__ =
|
|
1264
|
+
return e.__proto__ = s.prototype, e;
|
|
1265
1265
|
};
|
|
1266
1266
|
$t.prototype = Object.create(Error.prototype);
|
|
1267
1267
|
$t.prototype.constructor = $t;
|
|
1268
1268
|
$t.prototype.name = "TransformError";
|
|
1269
1269
|
const me = /* @__PURE__ */ Object.create(null);
|
|
1270
|
-
class
|
|
1270
|
+
class H {
|
|
1271
1271
|
/**
|
|
1272
1272
|
Initialize a selection with the head and anchor and ranges. If no
|
|
1273
1273
|
ranges are given, constructs a single range across `$anchor` and
|
|
1274
1274
|
`$head`.
|
|
1275
1275
|
*/
|
|
1276
1276
|
constructor(t, e, n) {
|
|
1277
|
-
this.$anchor = t, this.$head = e, this.ranges = n || [new
|
|
1277
|
+
this.$anchor = t, this.$head = e, this.ranges = n || [new Fo(t.min(e), t.max(e))];
|
|
1278
1278
|
}
|
|
1279
1279
|
/**
|
|
1280
1280
|
The selection's anchor, as an unresolved position.
|
|
@@ -1334,12 +1334,12 @@ class B {
|
|
|
1334
1334
|
*/
|
|
1335
1335
|
replace(t, e = I.empty) {
|
|
1336
1336
|
let n = e.content.lastChild, o = null;
|
|
1337
|
-
for (let
|
|
1337
|
+
for (let c = 0; c < e.openEnd; c++)
|
|
1338
1338
|
o = n, n = n.lastChild;
|
|
1339
1339
|
let r = t.steps.length, u = this.ranges;
|
|
1340
|
-
for (let
|
|
1341
|
-
let { $from: m, $to: d } = u[
|
|
1342
|
-
t.replaceRange(h.map(m.pos), h.map(d.pos),
|
|
1340
|
+
for (let c = 0; c < u.length; c++) {
|
|
1341
|
+
let { $from: m, $to: d } = u[c], h = t.mapping.slice(r);
|
|
1342
|
+
t.replaceRange(h.map(m.pos), h.map(d.pos), c ? I.empty : e), c == 0 && Ke(t, r, (n ? n.isInline : o && o.isTextblock) ? -1 : 1);
|
|
1343
1343
|
}
|
|
1344
1344
|
}
|
|
1345
1345
|
/**
|
|
@@ -1349,7 +1349,7 @@ class B {
|
|
|
1349
1349
|
replaceWith(t, e) {
|
|
1350
1350
|
let n = t.steps.length, o = this.ranges;
|
|
1351
1351
|
for (let r = 0; r < o.length; r++) {
|
|
1352
|
-
let { $from: u, $to:
|
|
1352
|
+
let { $from: u, $to: c } = o[r], m = t.mapping.slice(n), d = m.map(u.pos), h = m.map(c.pos);
|
|
1353
1353
|
r ? t.deleteRange(d, h) : (t.replaceRangeWith(d, h, e), Ke(t, n, e.isInline ? -1 : 1));
|
|
1354
1354
|
}
|
|
1355
1355
|
}
|
|
@@ -1431,8 +1431,8 @@ class B {
|
|
|
1431
1431
|
return tt.between(this.$anchor, this.$head).getBookmark();
|
|
1432
1432
|
}
|
|
1433
1433
|
}
|
|
1434
|
-
|
|
1435
|
-
class
|
|
1434
|
+
H.prototype.visible = !0;
|
|
1435
|
+
class Fo {
|
|
1436
1436
|
/**
|
|
1437
1437
|
Create a range.
|
|
1438
1438
|
*/
|
|
@@ -1441,10 +1441,10 @@ class Ro {
|
|
|
1441
1441
|
}
|
|
1442
1442
|
}
|
|
1443
1443
|
let Ge = !1;
|
|
1444
|
-
function Ve(
|
|
1445
|
-
!Ge && !
|
|
1444
|
+
function Ve(s) {
|
|
1445
|
+
!Ge && !s.parent.inlineContent && (Ge = !0, console.warn("TextSelection endpoint not pointing into a node with inline content (" + s.parent.type.name + ")"));
|
|
1446
1446
|
}
|
|
1447
|
-
class tt extends
|
|
1447
|
+
class tt extends H {
|
|
1448
1448
|
/**
|
|
1449
1449
|
Construct a text selection between the given points.
|
|
1450
1450
|
*/
|
|
@@ -1461,7 +1461,7 @@ class tt extends B {
|
|
|
1461
1461
|
map(t, e) {
|
|
1462
1462
|
let n = t.resolve(e.map(this.head));
|
|
1463
1463
|
if (!n.parent.inlineContent)
|
|
1464
|
-
return
|
|
1464
|
+
return H.near(n);
|
|
1465
1465
|
let o = t.resolve(e.map(this.anchor));
|
|
1466
1466
|
return new tt(o.parent.inlineContent ? o : n, n);
|
|
1467
1467
|
}
|
|
@@ -1506,16 +1506,16 @@ class tt extends B {
|
|
|
1506
1506
|
static between(t, e, n) {
|
|
1507
1507
|
let o = t.pos - e.pos;
|
|
1508
1508
|
if ((!n || o) && (n = o >= 0 ? 1 : -1), !e.parent.inlineContent) {
|
|
1509
|
-
let r =
|
|
1509
|
+
let r = H.findFrom(e, n, !0) || H.findFrom(e, -n, !0);
|
|
1510
1510
|
if (r)
|
|
1511
1511
|
e = r.$head;
|
|
1512
1512
|
else
|
|
1513
|
-
return
|
|
1513
|
+
return H.near(e, n);
|
|
1514
1514
|
}
|
|
1515
|
-
return t.parent.inlineContent || (o == 0 ? t = e : (t = (
|
|
1515
|
+
return t.parent.inlineContent || (o == 0 ? t = e : (t = (H.findFrom(t, -n, !0) || H.findFrom(t, n, !0)).$anchor, t.pos < e.pos != o < 0 && (t = e))), new tt(t, e);
|
|
1516
1516
|
}
|
|
1517
1517
|
}
|
|
1518
|
-
|
|
1518
|
+
H.jsonID("text", tt);
|
|
1519
1519
|
class Yt {
|
|
1520
1520
|
constructor(t, e) {
|
|
1521
1521
|
this.anchor = t, this.head = e;
|
|
@@ -1527,7 +1527,7 @@ class Yt {
|
|
|
1527
1527
|
return tt.between(t.resolve(this.anchor), t.resolve(this.head));
|
|
1528
1528
|
}
|
|
1529
1529
|
}
|
|
1530
|
-
class Z extends
|
|
1530
|
+
class Z extends H {
|
|
1531
1531
|
/**
|
|
1532
1532
|
Create a node selection. Does not verify the validity of its
|
|
1533
1533
|
argument.
|
|
@@ -1538,10 +1538,10 @@ class Z extends B {
|
|
|
1538
1538
|
}
|
|
1539
1539
|
map(t, e) {
|
|
1540
1540
|
let { deleted: n, pos: o } = e.mapResult(this.anchor), r = t.resolve(o);
|
|
1541
|
-
return n ?
|
|
1541
|
+
return n ? H.near(r) : new Z(r);
|
|
1542
1542
|
}
|
|
1543
1543
|
content() {
|
|
1544
|
-
return new I(
|
|
1544
|
+
return new I($.from(this.node), 0, 0);
|
|
1545
1545
|
}
|
|
1546
1546
|
eq(t) {
|
|
1547
1547
|
return t instanceof Z && t.anchor == this.anchor;
|
|
@@ -1575,7 +1575,7 @@ class Z extends B {
|
|
|
1575
1575
|
}
|
|
1576
1576
|
}
|
|
1577
1577
|
Z.prototype.visible = !1;
|
|
1578
|
-
|
|
1578
|
+
H.jsonID("node", Z);
|
|
1579
1579
|
class xe {
|
|
1580
1580
|
constructor(t) {
|
|
1581
1581
|
this.anchor = t;
|
|
@@ -1586,10 +1586,10 @@ class xe {
|
|
|
1586
1586
|
}
|
|
1587
1587
|
resolve(t) {
|
|
1588
1588
|
let e = t.resolve(this.anchor), n = e.nodeAfter;
|
|
1589
|
-
return n && Z.isSelectable(n) ? new Z(e) :
|
|
1589
|
+
return n && Z.isSelectable(n) ? new Z(e) : H.near(e);
|
|
1590
1590
|
}
|
|
1591
1591
|
}
|
|
1592
|
-
class st extends
|
|
1592
|
+
class st extends H {
|
|
1593
1593
|
/**
|
|
1594
1594
|
Create an all-selection over the given document.
|
|
1595
1595
|
*/
|
|
@@ -1599,7 +1599,7 @@ class st extends B {
|
|
|
1599
1599
|
replace(t, e = I.empty) {
|
|
1600
1600
|
if (e == I.empty) {
|
|
1601
1601
|
t.delete(0, t.doc.content.size);
|
|
1602
|
-
let n =
|
|
1602
|
+
let n = H.atStart(t.doc);
|
|
1603
1603
|
n.eq(t.selection) || t.setSelection(n);
|
|
1604
1604
|
} else
|
|
1605
1605
|
super.replace(t, e);
|
|
@@ -1620,49 +1620,49 @@ class st extends B {
|
|
|
1620
1620
|
return t instanceof st;
|
|
1621
1621
|
}
|
|
1622
1622
|
getBookmark() {
|
|
1623
|
-
return
|
|
1623
|
+
return Bo;
|
|
1624
1624
|
}
|
|
1625
1625
|
}
|
|
1626
|
-
|
|
1627
|
-
const
|
|
1626
|
+
H.jsonID("all", st);
|
|
1627
|
+
const Bo = {
|
|
1628
1628
|
map() {
|
|
1629
1629
|
return this;
|
|
1630
1630
|
},
|
|
1631
|
-
resolve(
|
|
1632
|
-
return new st(
|
|
1631
|
+
resolve(s) {
|
|
1632
|
+
return new st(s);
|
|
1633
1633
|
}
|
|
1634
1634
|
};
|
|
1635
|
-
function wt(
|
|
1635
|
+
function wt(s, t, e, n, o, r = !1) {
|
|
1636
1636
|
if (t.inlineContent)
|
|
1637
|
-
return tt.create(
|
|
1637
|
+
return tt.create(s, e);
|
|
1638
1638
|
for (let u = n - (o > 0 ? 0 : 1); o > 0 ? u < t.childCount : u >= 0; u += o) {
|
|
1639
|
-
let
|
|
1640
|
-
if (
|
|
1641
|
-
if (!r && Z.isSelectable(
|
|
1642
|
-
return Z.create(
|
|
1639
|
+
let c = t.child(u);
|
|
1640
|
+
if (c.isAtom) {
|
|
1641
|
+
if (!r && Z.isSelectable(c))
|
|
1642
|
+
return Z.create(s, e - (o < 0 ? c.nodeSize : 0));
|
|
1643
1643
|
} else {
|
|
1644
|
-
let m = wt(
|
|
1644
|
+
let m = wt(s, c, e + o, o < 0 ? c.childCount : 0, o, r);
|
|
1645
1645
|
if (m)
|
|
1646
1646
|
return m;
|
|
1647
1647
|
}
|
|
1648
|
-
e +=
|
|
1648
|
+
e += c.nodeSize * o;
|
|
1649
1649
|
}
|
|
1650
1650
|
return null;
|
|
1651
1651
|
}
|
|
1652
|
-
function Ke(
|
|
1653
|
-
let n =
|
|
1652
|
+
function Ke(s, t, e) {
|
|
1653
|
+
let n = s.steps.length - 1;
|
|
1654
1654
|
if (n < t)
|
|
1655
1655
|
return;
|
|
1656
|
-
let o =
|
|
1656
|
+
let o = s.steps[n];
|
|
1657
1657
|
if (!(o instanceof ot || o instanceof xt))
|
|
1658
1658
|
return;
|
|
1659
|
-
let r =
|
|
1660
|
-
r.forEach((
|
|
1659
|
+
let r = s.mapping.maps[n], u;
|
|
1660
|
+
r.forEach((c, m, d, h) => {
|
|
1661
1661
|
u == null && (u = h);
|
|
1662
|
-
}),
|
|
1662
|
+
}), s.setSelection(H.near(s.doc.resolve(u), e));
|
|
1663
1663
|
}
|
|
1664
|
-
function je(
|
|
1665
|
-
return !t || !
|
|
1664
|
+
function je(s, t) {
|
|
1665
|
+
return !t || !s ? s : s.bind(t);
|
|
1666
1666
|
}
|
|
1667
1667
|
class jt {
|
|
1668
1668
|
constructor(t, e, n) {
|
|
@@ -1670,42 +1670,42 @@ class jt {
|
|
|
1670
1670
|
}
|
|
1671
1671
|
}
|
|
1672
1672
|
new jt("doc", {
|
|
1673
|
-
init(
|
|
1674
|
-
return
|
|
1673
|
+
init(s) {
|
|
1674
|
+
return s.doc || s.schema.topNodeType.createAndFill();
|
|
1675
1675
|
},
|
|
1676
|
-
apply(
|
|
1677
|
-
return
|
|
1676
|
+
apply(s) {
|
|
1677
|
+
return s.doc;
|
|
1678
1678
|
}
|
|
1679
1679
|
}), new jt("selection", {
|
|
1680
|
-
init(
|
|
1681
|
-
return
|
|
1680
|
+
init(s, t) {
|
|
1681
|
+
return s.selection || H.atStart(t.doc);
|
|
1682
1682
|
},
|
|
1683
|
-
apply(
|
|
1684
|
-
return
|
|
1683
|
+
apply(s) {
|
|
1684
|
+
return s.selection;
|
|
1685
1685
|
}
|
|
1686
1686
|
}), new jt("storedMarks", {
|
|
1687
|
-
init(
|
|
1688
|
-
return
|
|
1687
|
+
init(s) {
|
|
1688
|
+
return s.storedMarks || null;
|
|
1689
1689
|
},
|
|
1690
|
-
apply(
|
|
1691
|
-
return n.selection.$cursor ?
|
|
1690
|
+
apply(s, t, e, n) {
|
|
1691
|
+
return n.selection.$cursor ? s.storedMarks : null;
|
|
1692
1692
|
}
|
|
1693
1693
|
}), new jt("scrollToSelection", {
|
|
1694
1694
|
init() {
|
|
1695
1695
|
return 0;
|
|
1696
1696
|
},
|
|
1697
|
-
apply(
|
|
1698
|
-
return
|
|
1697
|
+
apply(s, t) {
|
|
1698
|
+
return s.scrolledIntoView ? t + 1 : t;
|
|
1699
1699
|
}
|
|
1700
1700
|
});
|
|
1701
|
-
function an(
|
|
1702
|
-
for (let n in
|
|
1703
|
-
let o =
|
|
1701
|
+
function an(s, t, e) {
|
|
1702
|
+
for (let n in s) {
|
|
1703
|
+
let o = s[n];
|
|
1704
1704
|
o instanceof Function ? o = o.bind(t) : n == "handleDOMEvents" && (o = an(o, t, {})), e[n] = o;
|
|
1705
1705
|
}
|
|
1706
1706
|
return e;
|
|
1707
1707
|
}
|
|
1708
|
-
class
|
|
1708
|
+
class Lo {
|
|
1709
1709
|
/**
|
|
1710
1710
|
Create a plugin.
|
|
1711
1711
|
*/
|
|
@@ -1720,10 +1720,10 @@ class Bo {
|
|
|
1720
1720
|
}
|
|
1721
1721
|
}
|
|
1722
1722
|
const fe = /* @__PURE__ */ Object.create(null);
|
|
1723
|
-
function cn(
|
|
1724
|
-
return
|
|
1723
|
+
function cn(s) {
|
|
1724
|
+
return s in fe ? s + "$" + ++fe[s] : (fe[s] = 0, s + "$");
|
|
1725
1725
|
}
|
|
1726
|
-
class
|
|
1726
|
+
class Ho {
|
|
1727
1727
|
/**
|
|
1728
1728
|
Create a plugin key.
|
|
1729
1729
|
*/
|
|
@@ -1744,7 +1744,7 @@ class Lo {
|
|
|
1744
1744
|
return t[this.key];
|
|
1745
1745
|
}
|
|
1746
1746
|
}
|
|
1747
|
-
const qo = new
|
|
1747
|
+
const qo = new Ho("commentGutter"), Po = Un.create({
|
|
1748
1748
|
name: "commentGutter",
|
|
1749
1749
|
addOptions() {
|
|
1750
1750
|
return {
|
|
@@ -1753,31 +1753,31 @@ const qo = new Lo("commentGutter"), Ho = Un.create({
|
|
|
1753
1753
|
// 返回可滚动容器(没有则回退用 stageEl)
|
|
1754
1754
|
getScrollEl: () => null,
|
|
1755
1755
|
// anchors: [{ id, top, height }]
|
|
1756
|
-
onAnchors: (
|
|
1756
|
+
onAnchors: (s) => {
|
|
1757
1757
|
},
|
|
1758
1758
|
// 宿主提供:在 rootEl 上挂载实际的 CommentGutter 组件
|
|
1759
|
-
mountGutter: (
|
|
1759
|
+
mountGutter: (s, t) => {
|
|
1760
1760
|
},
|
|
1761
1761
|
// 调试:打印是否收到 scroll/resize 事件
|
|
1762
1762
|
debug: !1
|
|
1763
1763
|
};
|
|
1764
1764
|
},
|
|
1765
1765
|
addProseMirrorPlugins() {
|
|
1766
|
-
const
|
|
1766
|
+
const s = this.options.getStageEl, t = this.options.getScrollEl, e = this.options.onAnchors, n = this.options.mountGutter;
|
|
1767
1767
|
return [
|
|
1768
|
-
new
|
|
1768
|
+
new Lo({
|
|
1769
1769
|
key: qo,
|
|
1770
1770
|
view: (o) => {
|
|
1771
|
-
let r = !1, u = null,
|
|
1771
|
+
let r = !1, u = null, c = !1;
|
|
1772
1772
|
const m = () => {
|
|
1773
1773
|
if (u) return u;
|
|
1774
1774
|
const h = o.dom;
|
|
1775
1775
|
if (!h) return null;
|
|
1776
|
-
const
|
|
1777
|
-
if (!
|
|
1778
|
-
const
|
|
1779
|
-
if (y.className = "my-comment-gutter-root", (
|
|
1780
|
-
|
|
1776
|
+
const A = h.closest?.(".umo-zoomable-container") || h.parentElement, R = A?.querySelector?.(".umo-zoomable-content") || A;
|
|
1777
|
+
if (!R) return null;
|
|
1778
|
+
const B = R.querySelector?.(".umo-watermark.umo-page-content") || R.querySelector?.(".umo-page-content") || null, y = document.createElement("div");
|
|
1779
|
+
if (y.className = "my-comment-gutter-root", (B || R).appendChild(y), u = y, !c && typeof n == "function") {
|
|
1780
|
+
c = !0;
|
|
1781
1781
|
try {
|
|
1782
1782
|
n(u, o);
|
|
1783
1783
|
} catch (v) {
|
|
@@ -1790,7 +1790,7 @@ const qo = new Lo("commentGutter"), Ho = Un.create({
|
|
|
1790
1790
|
m();
|
|
1791
1791
|
const h = o.dom;
|
|
1792
1792
|
if (!h) return;
|
|
1793
|
-
const
|
|
1793
|
+
const A = s?.(), B = t?.() || A || h, y = B.getBoundingClientRect(), v = typeof B.scrollTop == "number" ? B.scrollTop : 0, x = h.querySelectorAll(".comment-mark") || [], T = /* @__PURE__ */ new Map();
|
|
1794
1794
|
x.forEach((z) => {
|
|
1795
1795
|
const X = ke(z);
|
|
1796
1796
|
if (!X.length) return;
|
|
@@ -1818,37 +1818,63 @@ const qo = new Lo("commentGutter"), Ho = Un.create({
|
|
|
1818
1818
|
];
|
|
1819
1819
|
}
|
|
1820
1820
|
});
|
|
1821
|
-
function
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
|
|
1821
|
+
function Uo(s, t) {
|
|
1822
|
+
const e = s?.view, n = s?.state;
|
|
1823
|
+
if (!e || !n) return [];
|
|
1824
|
+
const o = String(t), r = n.schema.marks.comment;
|
|
1825
|
+
if (!r) return [];
|
|
1826
|
+
const u = /* @__PURE__ */ new Set(), c = [];
|
|
1827
|
+
return n.doc.descendants((m, d) => {
|
|
1828
|
+
if (!(!m.isText || !m.marks.find(
|
|
1829
|
+
(A) => A.type === r && Wn(A.attrs, o)
|
|
1830
|
+
)))
|
|
1831
|
+
try {
|
|
1832
|
+
const R = e.domAtPos(d)?.node, y = (R?.nodeType === 3 ? R.parentElement : R instanceof Element ? R : null)?.closest?.(".comment-mark");
|
|
1833
|
+
y instanceof HTMLElement && !u.has(y) && (u.add(y), c.push(y));
|
|
1834
|
+
} catch {
|
|
1835
|
+
}
|
|
1836
|
+
}), c;
|
|
1831
1837
|
}
|
|
1832
|
-
function
|
|
1833
|
-
|
|
1834
|
-
|
|
1838
|
+
function Wo(s) {
|
|
1839
|
+
const t = "rgba(251, 191, 36, 0.95)";
|
|
1840
|
+
if (!(s instanceof HTMLElement)) return;
|
|
1841
|
+
const e = s.style.backgroundColor || "", n = () => s.style.setProperty("background-color", t, "important"), o = () => {
|
|
1842
|
+
e ? s.style.setProperty("background-color", e, "important") : s.style.removeProperty("background-color");
|
|
1843
|
+
};
|
|
1844
|
+
n(), setTimeout(o, 250), setTimeout(n, 500), setTimeout(o, 750), setTimeout(n, 1e3), setTimeout(o, 1500);
|
|
1845
|
+
}
|
|
1846
|
+
function Go(s, t) {
|
|
1847
|
+
if (s == null || s === "") return;
|
|
1848
|
+
const e = String(s);
|
|
1849
|
+
let n = Uo(t, e);
|
|
1850
|
+
if (!n.length) {
|
|
1851
|
+
const o = [];
|
|
1852
|
+
document.querySelectorAll(".comment-mark").forEach((r) => {
|
|
1853
|
+
r instanceof HTMLElement && ke(r).includes(e) && o.push(r);
|
|
1854
|
+
}), n = o;
|
|
1855
|
+
}
|
|
1856
|
+
n.forEach((o) => Wo(o));
|
|
1857
|
+
}
|
|
1858
|
+
function Xe(s, t) {
|
|
1859
|
+
Go(t, s), setTimeout(() => {
|
|
1860
|
+
s?.commands?.focusComment?.(t);
|
|
1835
1861
|
}, 0);
|
|
1836
1862
|
}
|
|
1837
|
-
const
|
|
1863
|
+
const Vo = { class: "app-layout" }, Ko = { class: "editor-wrapper" }, jo = { class: "umo-editor-instance" }, Xo = { class: "umo-custom-huge-btn__text" }, Qo = ["disabled"], Yo = { class: "umo-custom-huge-btn__text" }, Zo = ["disabled"], tr = { class: "umo-custom-huge-btn__text" }, er = ["disabled"], nr = { class: "umo-custom-huge-btn__text" }, or = { class: "umo-custom-huge-btn__icon" }, rr = {
|
|
1838
1864
|
viewBox: "0 0 24 24",
|
|
1839
1865
|
fill: "none",
|
|
1840
1866
|
xmlns: "http://www.w3.org/2000/svg"
|
|
1841
|
-
},
|
|
1867
|
+
}, sr = {
|
|
1842
1868
|
key: 0,
|
|
1843
1869
|
d: "M12 14l2 2 4-4",
|
|
1844
1870
|
stroke: "currentColor",
|
|
1845
1871
|
"stroke-width": "1.5",
|
|
1846
1872
|
"stroke-linecap": "round",
|
|
1847
1873
|
"stroke-linejoin": "round"
|
|
1848
|
-
},
|
|
1874
|
+
}, ir = { class: "umo-custom-huge-btn__text" }, lr = ["disabled"], ar = { class: "umo-custom-huge-btn__text" }, cr = {
|
|
1849
1875
|
key: 0,
|
|
1850
1876
|
class: "app-layout__comment-aside"
|
|
1851
|
-
},
|
|
1877
|
+
}, ur = { class: "html-dialog" }, dr = { class: "html-dialog__header" }, mr = { class: "html-dialog__toolbar" }, fr = { class: "html-dialog__content" }, hr = { class: "html-dialog" }, pr = { class: "html-dialog__header" }, gr = { class: "html-dialog__toolbar" }, vr = { class: "html-dialog__content" }, yt = "doc-origin", Et = "external", yr = /* @__PURE__ */ Dn({
|
|
1852
1878
|
__name: "App",
|
|
1853
1879
|
props: {
|
|
1854
1880
|
/**
|
|
@@ -1884,13 +1910,13 @@ const Uo = { class: "app-layout" }, Wo = { class: "editor-wrapper" }, Go = { cla
|
|
|
1884
1910
|
}
|
|
1885
1911
|
},
|
|
1886
1912
|
emits: ["change", "save", "fileUpload", "fileDelete", "activeCommentChange"],
|
|
1887
|
-
setup(
|
|
1913
|
+
setup(s, { expose: t, emit: e }) {
|
|
1888
1914
|
function n() {
|
|
1889
1915
|
if (typeof crypto < "u" && typeof crypto.randomUUID == "function")
|
|
1890
1916
|
return crypto.randomUUID();
|
|
1891
|
-
const
|
|
1892
|
-
return crypto.getRandomValues(
|
|
1893
|
-
(
|
|
1917
|
+
const i = new Uint8Array(16);
|
|
1918
|
+
return crypto.getRandomValues(i), i[6] = i[6] & 15 | 64, i[8] = i[8] & 63 | 128, [...i].map(
|
|
1919
|
+
(a, f) => ([4, 6, 8, 10].includes(f) ? "-" : "") + a.toString(16).padStart(2, "0")
|
|
1894
1920
|
).join("");
|
|
1895
1921
|
}
|
|
1896
1922
|
const o = b(!1);
|
|
@@ -1899,11 +1925,11 @@ const Uo = { class: "app-layout" }, Wo = { class: "editor-wrapper" }, Go = { cla
|
|
|
1899
1925
|
}
|
|
1900
1926
|
async function u() {
|
|
1901
1927
|
try {
|
|
1902
|
-
const
|
|
1903
|
-
if (!
|
|
1904
|
-
document.fullscreenElement !==
|
|
1905
|
-
} catch (
|
|
1906
|
-
console.error("Fullscreen failed:",
|
|
1928
|
+
const i = mt.value;
|
|
1929
|
+
if (!i || typeof i.requestFullscreen != "function") return;
|
|
1930
|
+
document.fullscreenElement !== i ? await i.requestFullscreen() : await document.exitFullscreen();
|
|
1931
|
+
} catch (i) {
|
|
1932
|
+
console.error("Fullscreen failed:", i);
|
|
1907
1933
|
}
|
|
1908
1934
|
}
|
|
1909
1935
|
pe(() => {
|
|
@@ -1911,22 +1937,22 @@ const Uo = { class: "app-layout" }, Wo = { class: "editor-wrapper" }, Go = { cla
|
|
|
1911
1937
|
}), Fe(() => {
|
|
1912
1938
|
document.removeEventListener("fullscreenchange", r);
|
|
1913
1939
|
});
|
|
1914
|
-
const
|
|
1915
|
-
function
|
|
1916
|
-
q()?.setEditable?.(!!
|
|
1940
|
+
const c = s, m = e, d = K(() => !!c.enableCommentPanel), h = K(() => !!c.enableCommentBubble), A = K(() => d.value || h.value), R = Jn();
|
|
1941
|
+
function B() {
|
|
1942
|
+
q()?.setEditable?.(!!c.editable);
|
|
1917
1943
|
}
|
|
1918
1944
|
const y = b(""), v = /* @__PURE__ */ new Map();
|
|
1919
1945
|
let x = null;
|
|
1920
|
-
const T = (
|
|
1946
|
+
const T = (i) => {
|
|
1921
1947
|
clearTimeout(x), x = setTimeout(() => {
|
|
1922
|
-
const
|
|
1923
|
-
if (!
|
|
1948
|
+
const a = i ?? q();
|
|
1949
|
+
if (!a || E.value.length === 0 && v.size === 0) return;
|
|
1924
1950
|
const f = /* @__PURE__ */ new Set();
|
|
1925
|
-
|
|
1951
|
+
a.state.doc.descendants((g) => {
|
|
1926
1952
|
g.marks.forEach((w) => {
|
|
1927
1953
|
if (w.type.name === "comment")
|
|
1928
|
-
for (const
|
|
1929
|
-
f.add(
|
|
1954
|
+
for (const M of Le(w.attrs))
|
|
1955
|
+
f.add(M);
|
|
1930
1956
|
});
|
|
1931
1957
|
});
|
|
1932
1958
|
for (const [g, { comment: w }] of v)
|
|
@@ -1937,19 +1963,19 @@ const Uo = { class: "app-layout" }, Wo = { class: "editor-wrapper" }, Go = { cla
|
|
|
1937
1963
|
E.value = E.value.filter((w) => w.id !== g.id), v.set(g.id, { comment: { ...g } }), mn(g.id);
|
|
1938
1964
|
});
|
|
1939
1965
|
}, 500);
|
|
1940
|
-
}, V = (
|
|
1941
|
-
const
|
|
1942
|
-
if (!
|
|
1966
|
+
}, V = (i) => {
|
|
1967
|
+
const a = i ?? q();
|
|
1968
|
+
if (!a || E.value.length === 0) return;
|
|
1943
1969
|
const f = /* @__PURE__ */ new Map();
|
|
1944
|
-
|
|
1970
|
+
a.state.doc.descendants((p) => {
|
|
1945
1971
|
p.marks.forEach((g) => {
|
|
1946
1972
|
if (g.type.name !== "comment") return;
|
|
1947
1973
|
const w = Le(g.attrs);
|
|
1948
1974
|
if (!w.length) return;
|
|
1949
|
-
const
|
|
1975
|
+
const M = g.attrs.commentColors && typeof g.attrs.commentColors == "object" ? g.attrs.commentColors : {};
|
|
1950
1976
|
for (const k of w) {
|
|
1951
|
-
const
|
|
1952
|
-
f.set(k,
|
|
1977
|
+
const F = M[k] != null ? M[k] : g.attrs.colorIndex ?? 0, G = Number.parseInt(F, 10), N = Number.isNaN(G) || !Number.isFinite(G) ? 0 : (G % ut + ut) % ut;
|
|
1978
|
+
f.set(k, N);
|
|
1953
1979
|
}
|
|
1954
1980
|
});
|
|
1955
1981
|
}), f.size !== 0 && (E.value = E.value.map(
|
|
@@ -1959,11 +1985,11 @@ const Uo = { class: "app-layout" }, Wo = { class: "editor-wrapper" }, Go = { cla
|
|
|
1959
1985
|
let X = null;
|
|
1960
1986
|
rt(
|
|
1961
1987
|
() => z.value,
|
|
1962
|
-
() =>
|
|
1988
|
+
() => B(),
|
|
1963
1989
|
{ immediate: !0 }
|
|
1964
1990
|
), rt(
|
|
1965
|
-
() =>
|
|
1966
|
-
() =>
|
|
1991
|
+
() => c.editable,
|
|
1992
|
+
() => B(),
|
|
1967
1993
|
{ immediate: !0 }
|
|
1968
1994
|
);
|
|
1969
1995
|
const {
|
|
@@ -1978,22 +2004,22 @@ const Uo = { class: "app-layout" }, Wo = { class: "editor-wrapper" }, Go = { cla
|
|
|
1978
2004
|
resetPending: dn,
|
|
1979
2005
|
queueDelete: mn,
|
|
1980
2006
|
cancelPendingDelete: fn
|
|
1981
|
-
} =
|
|
1982
|
-
rt(it, (
|
|
1983
|
-
m("activeCommentChange",
|
|
2007
|
+
} = Gn();
|
|
2008
|
+
rt(it, (i) => {
|
|
2009
|
+
m("activeCommentChange", i);
|
|
1984
2010
|
});
|
|
1985
|
-
const mt = b(null), ee = b([]), hn = () => mt.value, pn = () => mt.value?.querySelector?.(".umo-scrollable-container") || mt.value?.querySelector?.(".umo-scrollable") || mt.value, gn = (
|
|
1986
|
-
if (!h.value || !
|
|
1987
|
-
|
|
2011
|
+
const mt = b(null), ee = b([]), hn = () => mt.value, pn = () => mt.value?.querySelector?.(".umo-scrollable-container") || mt.value?.querySelector?.(".umo-scrollable") || mt.value, gn = (i, a) => {
|
|
2012
|
+
if (!h.value || !i || i.__gutterMounted) return;
|
|
2013
|
+
i.__gutterMounted = !0, Hn({
|
|
1988
2014
|
setup() {
|
|
1989
2015
|
const p = (g) => {
|
|
1990
2016
|
ie(g);
|
|
1991
2017
|
try {
|
|
1992
|
-
|
|
2018
|
+
a?.commands?.focusComment?.(g);
|
|
1993
2019
|
} catch {
|
|
1994
2020
|
}
|
|
1995
2021
|
};
|
|
1996
|
-
return () =>
|
|
2022
|
+
return () => qn(zo, {
|
|
1997
2023
|
anchors: ee.value,
|
|
1998
2024
|
comments: E.value,
|
|
1999
2025
|
activeCommentId: it.value,
|
|
@@ -2001,25 +2027,25 @@ const Uo = { class: "app-layout" }, Wo = { class: "editor-wrapper" }, Go = { cla
|
|
|
2001
2027
|
onActivate: p
|
|
2002
2028
|
});
|
|
2003
2029
|
}
|
|
2004
|
-
}).mount(
|
|
2030
|
+
}).mount(i);
|
|
2005
2031
|
}, ne = b(!1), oe = b(""), vn = b(""), bt = b(!1), Ce = async () => {
|
|
2006
2032
|
if (bt.value) return;
|
|
2007
|
-
const
|
|
2033
|
+
const i = q();
|
|
2008
2034
|
bt.value = !0;
|
|
2009
2035
|
try {
|
|
2010
|
-
const
|
|
2011
|
-
if (
|
|
2012
|
-
await
|
|
2036
|
+
const a = i?.getJSON?.();
|
|
2037
|
+
if (a)
|
|
2038
|
+
await Vn(a, E.value, y.value || "文档");
|
|
2013
2039
|
else {
|
|
2014
|
-
const f =
|
|
2040
|
+
const f = i?.getHTML() ?? z.value?.getHTML();
|
|
2015
2041
|
if (!f) throw new Error("编辑器内容为空,无法导出");
|
|
2016
|
-
await
|
|
2042
|
+
await He(f, E.value, y.value || "文档");
|
|
2017
2043
|
}
|
|
2018
|
-
} catch (
|
|
2044
|
+
} catch (a) {
|
|
2019
2045
|
try {
|
|
2020
|
-
const f =
|
|
2021
|
-
if (!f) throw
|
|
2022
|
-
await
|
|
2046
|
+
const f = i?.getHTML() ?? z.value?.getHTML();
|
|
2047
|
+
if (!f) throw a;
|
|
2048
|
+
await He(f, E.value, y.value || "文档");
|
|
2023
2049
|
} catch (f) {
|
|
2024
2050
|
console.error("导出 Word 失败:", f), alert("导出 Word 失败,请稍后重试");
|
|
2025
2051
|
}
|
|
@@ -2028,24 +2054,24 @@ const Uo = { class: "app-layout" }, Wo = { class: "editor-wrapper" }, Go = { cla
|
|
|
2028
2054
|
}
|
|
2029
2055
|
}, St = b(!1), be = async () => {
|
|
2030
2056
|
if (St.value) return;
|
|
2031
|
-
const
|
|
2057
|
+
const i = q();
|
|
2032
2058
|
St.value = !0;
|
|
2033
2059
|
try {
|
|
2034
|
-
const
|
|
2060
|
+
const a = i?.getJSON?.();
|
|
2035
2061
|
let f;
|
|
2036
|
-
if (
|
|
2037
|
-
f = await
|
|
2062
|
+
if (a)
|
|
2063
|
+
f = await Kn(a, E.value, y.value || "文档");
|
|
2038
2064
|
else {
|
|
2039
|
-
const p =
|
|
2065
|
+
const p = i?.getHTML() ?? z.value?.getHTML();
|
|
2040
2066
|
if (!p) throw new Error("编辑器内容为空,无法导出");
|
|
2041
|
-
f = await
|
|
2067
|
+
f = await qe(p, y.value || "文档");
|
|
2042
2068
|
}
|
|
2043
2069
|
Pe(f, `${y.value || "文档"}.docx`);
|
|
2044
|
-
} catch (
|
|
2070
|
+
} catch (a) {
|
|
2045
2071
|
try {
|
|
2046
|
-
const f =
|
|
2047
|
-
if (!f) throw
|
|
2048
|
-
const p = await
|
|
2072
|
+
const f = i?.getHTML() ?? z.value?.getHTML();
|
|
2073
|
+
if (!f) throw a;
|
|
2074
|
+
const p = await qe(f, y.value || "文档");
|
|
2049
2075
|
Pe(p, `${y.value || "文档"}.docx`);
|
|
2050
2076
|
} catch (f) {
|
|
2051
2077
|
console.error("Word 流导出失败:", f), alert("Word 流导出失败,请稍后重试");
|
|
@@ -2055,98 +2081,98 @@ const Uo = { class: "app-layout" }, Wo = { class: "editor-wrapper" }, Go = { cla
|
|
|
2055
2081
|
}
|
|
2056
2082
|
}, Se = b(null), Rt = b(!1), yn = () => {
|
|
2057
2083
|
Se.value?.click();
|
|
2058
|
-
}, Te = async (
|
|
2084
|
+
}, Te = async (i) => {
|
|
2059
2085
|
Rt.value = !0;
|
|
2060
2086
|
try {
|
|
2061
|
-
const
|
|
2062
|
-
uploadImageFile: async (
|
|
2063
|
-
const et = await
|
|
2087
|
+
const a = Ie.value?.onFileUpload, f = typeof a == "function" ? {
|
|
2088
|
+
uploadImageFile: async (N) => {
|
|
2089
|
+
const et = await a(N);
|
|
2064
2090
|
return { url: et?.url ?? "", id: et?.id };
|
|
2065
2091
|
}
|
|
2066
2092
|
} : void 0;
|
|
2067
2093
|
let p = null;
|
|
2068
2094
|
try {
|
|
2069
|
-
p = await
|
|
2070
|
-
} catch (
|
|
2071
|
-
console.warn("[Word 导入] JSON 导入失败,回退到 HTML:",
|
|
2095
|
+
p = await Xn(i, f);
|
|
2096
|
+
} catch (N) {
|
|
2097
|
+
console.warn("[Word 导入] JSON 导入失败,回退到 HTML:", N), p = await Qn(i, f);
|
|
2072
2098
|
}
|
|
2073
2099
|
let g = q();
|
|
2074
|
-
for (let
|
|
2100
|
+
for (let N = 0; N < 40 && !g; N++)
|
|
2075
2101
|
await new Promise((et) => setTimeout(et, 50)), g = q();
|
|
2076
2102
|
if (!g) throw new Error("编辑器未就绪");
|
|
2077
2103
|
g.commands.setContent(p, !1);
|
|
2078
2104
|
const w = g.view.dom;
|
|
2079
|
-
Oe(w), await new Promise((
|
|
2080
|
-
const
|
|
2081
|
-
if (
|
|
2105
|
+
Oe(w), await new Promise((N) => setTimeout(N, 50)), Oe(w);
|
|
2106
|
+
const M = await Yn(i);
|
|
2107
|
+
if (M.length === 0) {
|
|
2082
2108
|
console.info("[Word 导入] 文档导入成功,未检测到批注");
|
|
2083
2109
|
return;
|
|
2084
2110
|
}
|
|
2085
|
-
await new Promise((
|
|
2111
|
+
await new Promise((N) => setTimeout(N, 100));
|
|
2086
2112
|
const k = [];
|
|
2087
|
-
for (const
|
|
2088
|
-
|
|
2113
|
+
for (const N of M)
|
|
2114
|
+
N.selectedText && k.push({
|
|
2089
2115
|
id: n(),
|
|
2090
|
-
selectedText:
|
|
2091
|
-
note:
|
|
2092
|
-
author:
|
|
2093
|
-
preferDel: !!
|
|
2116
|
+
selectedText: N.selectedText,
|
|
2117
|
+
note: N.note,
|
|
2118
|
+
author: N.author || "导入",
|
|
2119
|
+
preferDel: !!N.containsDelText
|
|
2094
2120
|
});
|
|
2095
|
-
const { applied:
|
|
2121
|
+
const { applied: F } = await Me(g, k, {
|
|
2096
2122
|
defaultAuthor: "导入",
|
|
2097
2123
|
source: yt
|
|
2098
|
-
}),
|
|
2099
|
-
console.info("[Word 导入]",
|
|
2100
|
-
} catch (
|
|
2101
|
-
console.error("导入 Word 失败:",
|
|
2124
|
+
}), G = `Word 导入成功!共检测到 ${M.length} 条批注,成功恢复 ${F} 条。` + (F < k.length ? `(${k.length - F} 条因文字无法匹配而跳过)` : "");
|
|
2125
|
+
console.info("[Word 导入]", G);
|
|
2126
|
+
} catch (a) {
|
|
2127
|
+
console.error("导入 Word 失败:", a), console.error("[Word 导入] 失败:", a.message);
|
|
2102
2128
|
} finally {
|
|
2103
2129
|
Rt.value = !1;
|
|
2104
2130
|
}
|
|
2105
|
-
}, wn = async (
|
|
2106
|
-
await Te(
|
|
2107
|
-
}, kn = async (
|
|
2108
|
-
const
|
|
2109
|
-
|
|
2131
|
+
}, wn = async (i) => {
|
|
2132
|
+
await Te(i);
|
|
2133
|
+
}, kn = async (i) => {
|
|
2134
|
+
const a = i.target.files?.[0];
|
|
2135
|
+
a && (i.target.value = "", await Te(a));
|
|
2110
2136
|
};
|
|
2111
|
-
function Ee(
|
|
2112
|
-
const
|
|
2113
|
-
return
|
|
2137
|
+
function Ee(i) {
|
|
2138
|
+
const a = i.charCodeAt(0);
|
|
2139
|
+
return a === 8203 || a === 8204 || a === 8205 || a === 65279 || /\s/.test(i) || i === " " || i === " " ? " " : a >= 65281 && a <= 65374 ? String.fromCharCode(a - 65248) : i;
|
|
2114
2140
|
}
|
|
2115
|
-
function Ft(
|
|
2116
|
-
return typeof
|
|
2141
|
+
function Ft(i) {
|
|
2142
|
+
return typeof i != "string" ? "" : i.replace(/[\u200B\u200C\u200D\uFEFF]/g, " ").trim().replace(/\s+/g, " ").replace(/[\uFF01-\uFF5E]/g, (a) => String.fromCharCode(a.charCodeAt(0) - 65248));
|
|
2117
2143
|
}
|
|
2118
|
-
function _n(
|
|
2144
|
+
function _n(i, a, f) {
|
|
2119
2145
|
let p = !1;
|
|
2120
|
-
return
|
|
2146
|
+
return i.doc.nodesBetween(a, f, (g) => {
|
|
2121
2147
|
p || !g?.isText || g.marks.some((w) => w.type.name === "comment") && (p = !0);
|
|
2122
2148
|
}), p;
|
|
2123
2149
|
}
|
|
2124
|
-
function Bt(
|
|
2125
|
-
return !
|
|
2150
|
+
function Bt(i, a) {
|
|
2151
|
+
return !a || a.length === 0 ? null : a.length === 1 ? a[0] : a.find((p) => !_n(i, p.from, p.to)) ?? a[0];
|
|
2126
2152
|
}
|
|
2127
|
-
const xn = (
|
|
2128
|
-
const w =
|
|
2153
|
+
const xn = (i, a, f, p = 0, g = {}) => {
|
|
2154
|
+
const w = a.trim();
|
|
2129
2155
|
if (!w) return !1;
|
|
2130
|
-
const { doc:
|
|
2156
|
+
const { doc: M } = i.state, k = Ft(a);
|
|
2131
2157
|
if (!k) return !1;
|
|
2132
|
-
const
|
|
2158
|
+
const F = !!g.preferDel, G = g.source === yt ? yt : Et, N = (D) => !D || !D.isText ? !1 : (D.marks || []).some((C) => {
|
|
2133
2159
|
if (!C || !C.type) return !1;
|
|
2134
2160
|
if (C.type.name === "strike") return !0;
|
|
2135
2161
|
if (C.type.name === "textStyle") {
|
|
2136
|
-
const
|
|
2137
|
-
return typeof
|
|
2162
|
+
const P = C.attrs?.style;
|
|
2163
|
+
return typeof P == "string" && /line-through/i.test(P);
|
|
2138
2164
|
}
|
|
2139
2165
|
return !1;
|
|
2140
2166
|
}), et = (D) => !D || D.length !== 1 ? null : D[0] || null, ae = (D) => {
|
|
2141
|
-
const
|
|
2142
|
-
return
|
|
2143
|
-
if (C.isText && !(D && !
|
|
2167
|
+
const L = [];
|
|
2168
|
+
return M.descendants((C, P) => {
|
|
2169
|
+
if (C.isText && !(D && !N(C))) {
|
|
2144
2170
|
if (C.text && C.text.includes(w)) {
|
|
2145
2171
|
let Q = 0;
|
|
2146
2172
|
for (; ; ) {
|
|
2147
2173
|
const Y = C.text.indexOf(w, Q);
|
|
2148
2174
|
if (Y === -1) break;
|
|
2149
|
-
|
|
2175
|
+
L.push({ from: P + Y, to: P + Y + w.length }), Q = Y + 1;
|
|
2150
2176
|
}
|
|
2151
2177
|
return;
|
|
2152
2178
|
}
|
|
@@ -2157,73 +2183,73 @@ const Uo = { class: "app-layout" }, Wo = { class: "editor-wrapper" }, Go = { cla
|
|
|
2157
2183
|
for (; ; ) {
|
|
2158
2184
|
const at = Q.indexOf(k, Y);
|
|
2159
2185
|
if (at === -1) break;
|
|
2160
|
-
const Gt =
|
|
2161
|
-
|
|
2186
|
+
const Gt = P + Ne(C.text, at), nt = P + Ne(C.text, at + k.length);
|
|
2187
|
+
L.push({ from: Gt, to: nt }), Y = at + 1;
|
|
2162
2188
|
}
|
|
2163
2189
|
}
|
|
2164
2190
|
}
|
|
2165
2191
|
}
|
|
2166
|
-
}),
|
|
2167
|
-
}, lt = (D,
|
|
2192
|
+
}), L;
|
|
2193
|
+
}, lt = (D, L) => {
|
|
2168
2194
|
const C = [];
|
|
2169
|
-
if (
|
|
2170
|
-
if (
|
|
2171
|
-
if (
|
|
2172
|
-
for (let Vt = 0; Vt <
|
|
2173
|
-
C.push({ char:
|
|
2195
|
+
if (M.descendants((U, ct) => {
|
|
2196
|
+
if (U.isBlock && C.length > 0 && C.push({ char: " ", pos: null }), U.type.name === "hardBreak" && C.push({ char: " ", pos: null }), U.isText) {
|
|
2197
|
+
if (L && !N(U)) return;
|
|
2198
|
+
for (let Vt = 0; Vt < U.text.length; Vt++)
|
|
2199
|
+
C.push({ char: U.text[Vt], pos: ct + Vt });
|
|
2174
2200
|
}
|
|
2175
2201
|
}), !C.length) return [];
|
|
2176
|
-
const
|
|
2202
|
+
const P = [];
|
|
2177
2203
|
let Q = "", Y = !1;
|
|
2178
|
-
for (let
|
|
2179
|
-
const ct = Ee(C[
|
|
2180
|
-
ct === " " ? Y || (Q += " ",
|
|
2204
|
+
for (let U = 0; U < C.length; U++) {
|
|
2205
|
+
const ct = Ee(C[U].char);
|
|
2206
|
+
ct === " " ? Y || (Q += " ", P.push(U), Y = !0) : (Q += ct, P.push(U), Y = !1);
|
|
2181
2207
|
}
|
|
2182
2208
|
const at = Ft(D);
|
|
2183
2209
|
if (!at) return [];
|
|
2184
2210
|
const Gt = [];
|
|
2185
2211
|
let nt = 0;
|
|
2186
2212
|
for (; nt = Q.indexOf(at, nt), nt !== -1; ) {
|
|
2187
|
-
const
|
|
2188
|
-
|
|
2213
|
+
const U = C[P[nt]], ct = C[P[nt + at.length - 1]];
|
|
2214
|
+
U && U.pos !== null && ct && ct.pos !== null && Gt.push({ from: U.pos, to: ct.pos + 1 }), nt = nt + 1;
|
|
2189
2215
|
}
|
|
2190
2216
|
return Gt;
|
|
2191
2217
|
};
|
|
2192
|
-
if (
|
|
2193
|
-
const D = ae(!0),
|
|
2194
|
-
if (
|
|
2195
|
-
return
|
|
2218
|
+
if (F) {
|
|
2219
|
+
const D = ae(!0), L = Bt(i.state, D);
|
|
2220
|
+
if (L)
|
|
2221
|
+
return i.chain().setTextSelection(L).addComment(f, p, G).run(), !0;
|
|
2196
2222
|
}
|
|
2197
|
-
const On = ae(!1), De = Bt(
|
|
2223
|
+
const On = ae(!1), De = Bt(i.state, On);
|
|
2198
2224
|
if (De)
|
|
2199
|
-
return
|
|
2200
|
-
if (
|
|
2201
|
-
const D = lt(k, !0),
|
|
2202
|
-
if (
|
|
2203
|
-
return
|
|
2225
|
+
return i.chain().setTextSelection(De).addComment(f, p, G).run(), !0;
|
|
2226
|
+
if (F) {
|
|
2227
|
+
const D = lt(k, !0), L = Bt(i.state, D);
|
|
2228
|
+
if (L)
|
|
2229
|
+
return i.chain().setTextSelection(L).addComment(f, p, G).run(), !0;
|
|
2204
2230
|
}
|
|
2205
2231
|
let ce = lt(k, !1);
|
|
2206
|
-
const Je = Bt(
|
|
2232
|
+
const Je = Bt(i.state, ce);
|
|
2207
2233
|
if (Je)
|
|
2208
|
-
return
|
|
2234
|
+
return i.chain().setTextSelection(Je).addComment(f, p, G).run(), !0;
|
|
2209
2235
|
const Re = Math.min(30, Math.max(8, Math.floor(k.length * 0.6)));
|
|
2210
2236
|
if (Re < k.length) {
|
|
2211
2237
|
const D = k.slice(0, Re);
|
|
2212
|
-
if (
|
|
2213
|
-
const C = lt(D, !0),
|
|
2214
|
-
if (
|
|
2215
|
-
return
|
|
2238
|
+
if (F) {
|
|
2239
|
+
const C = lt(D, !0), P = et(C);
|
|
2240
|
+
if (P)
|
|
2241
|
+
return i.chain().setTextSelection(P).addComment(f, p, G).run(), !0;
|
|
2216
2242
|
}
|
|
2217
2243
|
ce = lt(D, !1);
|
|
2218
|
-
const
|
|
2219
|
-
if (
|
|
2220
|
-
return
|
|
2244
|
+
const L = et(ce);
|
|
2245
|
+
if (L)
|
|
2246
|
+
return i.chain().setTextSelection(L).addComment(f, p, G).run(), !0;
|
|
2221
2247
|
}
|
|
2222
2248
|
try {
|
|
2223
|
-
const D =
|
|
2224
|
-
`, " "),
|
|
2249
|
+
const D = i.state.doc.textBetween(0, i.state.doc.content.size, `
|
|
2250
|
+
`, " "), L = Ft(D), C = L.includes(k), P = k.slice(0, Math.min(30, k.length)), Q = L.includes(P);
|
|
2225
2251
|
console.info("[Word 批注恢复][match-failed]", {
|
|
2226
|
-
searchPreview: String(
|
|
2252
|
+
searchPreview: String(a).slice(0, 60),
|
|
2227
2253
|
normLen: k.length,
|
|
2228
2254
|
hasInDocNorm: C,
|
|
2229
2255
|
hasPrefixInDocNorm: Q
|
|
@@ -2232,90 +2258,90 @@ const Uo = { class: "app-layout" }, Wo = { class: "editor-wrapper" }, Go = { cla
|
|
|
2232
2258
|
}
|
|
2233
2259
|
return !1;
|
|
2234
2260
|
};
|
|
2235
|
-
async function
|
|
2261
|
+
async function Me(i, a, f = {}) {
|
|
2236
2262
|
const p = f.defaultAuthor ?? "智能审核", g = f.source === yt ? yt : Et;
|
|
2237
2263
|
let w = 0;
|
|
2238
|
-
const
|
|
2239
|
-
for (const k of
|
|
2240
|
-
const
|
|
2241
|
-
if (typeof
|
|
2242
|
-
|
|
2264
|
+
const M = [];
|
|
2265
|
+
for (const k of a) {
|
|
2266
|
+
const F = k.selectedText;
|
|
2267
|
+
if (typeof F != "string" || !F.trim()) {
|
|
2268
|
+
M.push({ selectedTextPreview: "", reason: "empty_text" });
|
|
2243
2269
|
continue;
|
|
2244
2270
|
}
|
|
2245
|
-
const
|
|
2246
|
-
let
|
|
2247
|
-
k.colorIndex != null && !Number.isNaN(Number(k.colorIndex)) ?
|
|
2271
|
+
const G = k.id ?? n();
|
|
2272
|
+
let N;
|
|
2273
|
+
k.colorIndex != null && !Number.isNaN(Number(k.colorIndex)) ? N = (Number(k.colorIndex) % ut + ut) % ut : N = (E.value.length + w) % ut;
|
|
2248
2274
|
const et = k.source === yt || k.source === Et ? k.source : g;
|
|
2249
|
-
if (xn(
|
|
2275
|
+
if (xn(i, F, G, N, {
|
|
2250
2276
|
preferDel: !!k.preferDel,
|
|
2251
2277
|
source: et
|
|
2252
2278
|
}))
|
|
2253
2279
|
await Dt({
|
|
2254
|
-
id:
|
|
2255
|
-
selectedText:
|
|
2280
|
+
id: G,
|
|
2281
|
+
selectedText: F,
|
|
2256
2282
|
note: k.note,
|
|
2257
2283
|
author: k.author ?? p,
|
|
2258
|
-
colorIndex:
|
|
2284
|
+
colorIndex: N
|
|
2259
2285
|
}), w++;
|
|
2260
2286
|
else {
|
|
2261
|
-
const lt = String(
|
|
2262
|
-
|
|
2287
|
+
const lt = String(F).slice(0, 50);
|
|
2288
|
+
M.push({ selectedTextPreview: lt, reason: "no_match" }), console.warn("[批注] 文字无法匹配而跳过:", { preview: lt, note: String(k.note ?? "").slice(0, 30) });
|
|
2263
2289
|
}
|
|
2264
2290
|
}
|
|
2265
2291
|
return {
|
|
2266
2292
|
applied: w,
|
|
2267
|
-
skipped:
|
|
2268
|
-
skippedItems:
|
|
2293
|
+
skipped: a.length - w,
|
|
2294
|
+
skippedItems: M
|
|
2269
2295
|
};
|
|
2270
2296
|
}
|
|
2271
|
-
function
|
|
2297
|
+
function Ne(i, a) {
|
|
2272
2298
|
let f = 0, p = !1;
|
|
2273
|
-
for (let g = 0; g <
|
|
2274
|
-
if (Ee(
|
|
2299
|
+
for (let g = 0; g < i.length; g++)
|
|
2300
|
+
if (Ee(i[g]) === " ") {
|
|
2275
2301
|
if (!p) {
|
|
2276
|
-
if (f ===
|
|
2302
|
+
if (f === a) return g;
|
|
2277
2303
|
f++, p = !0;
|
|
2278
2304
|
}
|
|
2279
2305
|
} else {
|
|
2280
|
-
if (f ===
|
|
2306
|
+
if (f === a) return g;
|
|
2281
2307
|
f++, p = !1;
|
|
2282
2308
|
}
|
|
2283
|
-
return
|
|
2309
|
+
return i.length;
|
|
2284
2310
|
}
|
|
2285
|
-
const Lt = b(!1), re = b(""),
|
|
2286
|
-
const
|
|
2287
|
-
if (!
|
|
2311
|
+
const Lt = b(!1), re = b(""), Ht = b(!1), Cn = () => {
|
|
2312
|
+
const i = z.value?.getHTML();
|
|
2313
|
+
if (!i) {
|
|
2288
2314
|
alert("编辑器内容为空,无法导出");
|
|
2289
2315
|
return;
|
|
2290
2316
|
}
|
|
2291
|
-
re.value =
|
|
2317
|
+
re.value = i, Ht.value = !1, Lt.value = !0;
|
|
2292
2318
|
}, bn = async () => {
|
|
2293
2319
|
try {
|
|
2294
|
-
await navigator.clipboard.writeText(re.value),
|
|
2320
|
+
await navigator.clipboard.writeText(re.value), Ht.value = !0, setTimeout(() => Ht.value = !1, 2e3);
|
|
2295
2321
|
} catch {
|
|
2296
2322
|
alert("复制失败,请手动选中后复制");
|
|
2297
2323
|
}
|
|
2298
|
-
},
|
|
2299
|
-
const
|
|
2300
|
-
if (!
|
|
2324
|
+
}, qt = b(!1), Sn = async () => {
|
|
2325
|
+
const i = z.value?.getHTML();
|
|
2326
|
+
if (!i) {
|
|
2301
2327
|
alert("编辑器内容为空");
|
|
2302
2328
|
return;
|
|
2303
2329
|
}
|
|
2304
2330
|
try {
|
|
2305
|
-
await navigator.clipboard.writeText(
|
|
2331
|
+
await navigator.clipboard.writeText(i), qt.value = !0, setTimeout(() => qt.value = !1, 2e3);
|
|
2306
2332
|
} catch {
|
|
2307
2333
|
alert("复制失败,请手动操作");
|
|
2308
2334
|
}
|
|
2309
2335
|
}, Tt = b(!1), Tn = async () => {
|
|
2310
2336
|
if (Tt.value) return;
|
|
2311
|
-
const
|
|
2312
|
-
if (!
|
|
2337
|
+
const a = q()?.getJSON?.();
|
|
2338
|
+
if (!a) {
|
|
2313
2339
|
alert("编辑器内容为空,无法导出");
|
|
2314
2340
|
return;
|
|
2315
2341
|
}
|
|
2316
2342
|
Tt.value = !0;
|
|
2317
2343
|
try {
|
|
2318
|
-
se.value = JSON.stringify(
|
|
2344
|
+
se.value = JSON.stringify(a, null, 2), Ut.value = !1, Pt.value = !0;
|
|
2319
2345
|
} catch (f) {
|
|
2320
2346
|
console.error("导出 JSON 失败:", f), alert("导出 JSON 失败,请稍后重试");
|
|
2321
2347
|
} finally {
|
|
@@ -2329,20 +2355,20 @@ const Uo = { class: "app-layout" }, Wo = { class: "editor-wrapper" }, Go = { cla
|
|
|
2329
2355
|
}
|
|
2330
2356
|
};
|
|
2331
2357
|
b(!1), b("http://your-internal-ai-model/api/annotation");
|
|
2332
|
-
const
|
|
2333
|
-
const
|
|
2334
|
-
return h.value ?
|
|
2335
|
-
|
|
2358
|
+
const Mn = () => {
|
|
2359
|
+
const i = [jn];
|
|
2360
|
+
return h.value ? i.push(
|
|
2361
|
+
Po.configure({
|
|
2336
2362
|
getStageEl: hn,
|
|
2337
2363
|
getScrollEl: pn,
|
|
2338
|
-
onAnchors: (
|
|
2339
|
-
ee.value =
|
|
2364
|
+
onAnchors: (a) => {
|
|
2365
|
+
ee.value = a || [];
|
|
2340
2366
|
},
|
|
2341
2367
|
mountGutter: gn,
|
|
2342
2368
|
debug: !1
|
|
2343
2369
|
})
|
|
2344
|
-
) : ee.value = [],
|
|
2345
|
-
},
|
|
2370
|
+
) : ee.value = [], i;
|
|
2371
|
+
}, Nn = K(() => ({
|
|
2346
2372
|
// 文件上传:由宿主接管(emit + 可选 await 回调)
|
|
2347
2373
|
// onFileUpload: async (file) => {
|
|
2348
2374
|
// if (!file) {
|
|
@@ -2360,26 +2386,26 @@ const Uo = { class: "app-layout" }, Wo = { class: "editor-wrapper" }, Go = { cla
|
|
|
2360
2386
|
// debugger
|
|
2361
2387
|
// return await requestSave({ silent: true })
|
|
2362
2388
|
// },
|
|
2363
|
-
onChanged: ({ editor:
|
|
2364
|
-
T(
|
|
2389
|
+
onChanged: ({ editor: i }) => {
|
|
2390
|
+
T(i);
|
|
2365
2391
|
}
|
|
2366
2392
|
})), Ie = K(() => {
|
|
2367
|
-
const
|
|
2368
|
-
...
|
|
2393
|
+
const i = R ?? {}, a = Array.isArray(i.extensions) ? i.extensions : [], f = Mn(), p = [...a, ...f], g = i.cdnUrl ?? "/node_modules/@umoteam/editor-external", w = {
|
|
2394
|
+
...i,
|
|
2369
2395
|
cdnUrl: g,
|
|
2370
2396
|
disableExtensions: ["import-word"],
|
|
2371
2397
|
extensions: p
|
|
2372
|
-
},
|
|
2373
|
-
return w.onChanged == null &&
|
|
2398
|
+
}, M = Nn.value;
|
|
2399
|
+
return w.onChanged == null && M?.onChanged && (w.onChanged = M.onChanged), w.onSave == null && M?.onSave && (w.onSave = M.onSave), w.onFileUpload == null && M?.onFileUpload && (w.onFileUpload = M.onFileUpload), w.onFileDelete == null && M?.onFileDelete && (w.onFileDelete = M.onFileDelete), w;
|
|
2374
2400
|
});
|
|
2375
2401
|
function q() {
|
|
2376
|
-
const
|
|
2377
|
-
return
|
|
2402
|
+
const i = z.value;
|
|
2403
|
+
return i ? typeof i.useEditor == "function" ? i.useEditor() : i.editor ? i.editor : null : null;
|
|
2378
2404
|
}
|
|
2379
|
-
const Wt = (
|
|
2380
|
-
const
|
|
2381
|
-
return
|
|
2382
|
-
`, " ") ?? "" :
|
|
2405
|
+
const Wt = (i = "html") => {
|
|
2406
|
+
const a = q();
|
|
2407
|
+
return a ? i === "json" ? a.getJSON?.() ?? null : i === "text" ? a.state?.doc?.textBetween?.(0, a.state.doc.content.size, `
|
|
2408
|
+
`, " ") ?? "" : a.getHTML?.() ?? null : null;
|
|
2383
2409
|
};
|
|
2384
2410
|
t({
|
|
2385
2411
|
getContent: Wt,
|
|
@@ -2388,12 +2414,12 @@ const Uo = { class: "app-layout" }, Wo = { class: "editor-wrapper" }, Go = { cla
|
|
|
2388
2414
|
getText: () => Wt("text"),
|
|
2389
2415
|
getEditor: () => q(),
|
|
2390
2416
|
importDocxFile: wn,
|
|
2391
|
-
setContent: (
|
|
2417
|
+
setContent: (i, a = !1) => {
|
|
2392
2418
|
const f = q();
|
|
2393
|
-
return f?.commands?.setContent ? (f.commands.setContent(
|
|
2419
|
+
return f?.commands?.setContent ? (f.commands.setContent(i, !!a), !0) : !1;
|
|
2394
2420
|
},
|
|
2395
|
-
setComments: async (
|
|
2396
|
-
const f = q(), p = Array.isArray(
|
|
2421
|
+
setComments: async (i, a) => {
|
|
2422
|
+
const f = q(), p = Array.isArray(i) ? i : [];
|
|
2397
2423
|
if (!f)
|
|
2398
2424
|
return {
|
|
2399
2425
|
ok: !1,
|
|
@@ -2401,13 +2427,13 @@ const Uo = { class: "app-layout" }, Wo = { class: "editor-wrapper" }, Go = { cla
|
|
|
2401
2427
|
skipped: p.length,
|
|
2402
2428
|
skippedItems: []
|
|
2403
2429
|
};
|
|
2404
|
-
if (
|
|
2405
|
-
const k = E.value.map((
|
|
2406
|
-
for (const
|
|
2407
|
-
f.commands.removeComment(
|
|
2430
|
+
if (a?.replace) {
|
|
2431
|
+
const k = E.value.map((F) => F.id);
|
|
2432
|
+
for (const F of k)
|
|
2433
|
+
f.commands.removeComment(F);
|
|
2408
2434
|
dn(), v.clear(), Zt(null), await un(void 0, []);
|
|
2409
2435
|
}
|
|
2410
|
-
const { applied: g, skipped: w, skippedItems:
|
|
2436
|
+
const { applied: g, skipped: w, skippedItems: M } = await Me(f, p, {
|
|
2411
2437
|
defaultAuthor: "智能审核",
|
|
2412
2438
|
source: Et
|
|
2413
2439
|
});
|
|
@@ -2415,42 +2441,42 @@ const Uo = { class: "app-layout" }, Wo = { class: "editor-wrapper" }, Go = { cla
|
|
|
2415
2441
|
ok: !0,
|
|
2416
2442
|
applied: g,
|
|
2417
2443
|
skipped: w,
|
|
2418
|
-
skippedItems:
|
|
2444
|
+
skippedItems: M
|
|
2419
2445
|
};
|
|
2420
2446
|
},
|
|
2421
|
-
activateCommentInEditor: (
|
|
2447
|
+
activateCommentInEditor: (i) => Xe(q(), i),
|
|
2422
2448
|
exportWord: Ce,
|
|
2423
2449
|
exportWordBlob: be
|
|
2424
2450
|
});
|
|
2425
|
-
function Oe(
|
|
2426
|
-
!
|
|
2427
|
-
const f =
|
|
2451
|
+
function Oe(i) {
|
|
2452
|
+
!i || !i.querySelectorAll || i.querySelectorAll("table").forEach((a) => {
|
|
2453
|
+
const f = a.querySelector("colgroup"), p = a.querySelectorAll("tbody tr, tr"), g = a.querySelectorAll("td");
|
|
2428
2454
|
f && !f.hasAttribute("data-word-col-layout") && p.length === 1 && g.length === 2 && f.setAttribute("data-word-col-layout", "1");
|
|
2429
2455
|
});
|
|
2430
2456
|
}
|
|
2431
|
-
const In = async (
|
|
2432
|
-
const
|
|
2433
|
-
if (!
|
|
2457
|
+
const In = async (i) => {
|
|
2458
|
+
const a = q();
|
|
2459
|
+
if (!a) return;
|
|
2434
2460
|
const f = n(), p = E.value.length % ut;
|
|
2435
|
-
|
|
2461
|
+
a.commands.addComment(f, p, Et);
|
|
2436
2462
|
try {
|
|
2437
|
-
await Dt({ id: f, selectedText: oe.value, note:
|
|
2463
|
+
await Dt({ id: f, selectedText: oe.value, note: i, colorIndex: p });
|
|
2438
2464
|
} catch {
|
|
2439
|
-
|
|
2465
|
+
a.commands.removeComment(f);
|
|
2440
2466
|
}
|
|
2441
2467
|
ne.value = !1, oe.value = "";
|
|
2442
|
-
}, Ae = async (
|
|
2443
|
-
q()?.commands.removeComment(
|
|
2444
|
-
}, $e = async (
|
|
2445
|
-
await Jt(
|
|
2446
|
-
}, ze = (
|
|
2447
|
-
Zt(
|
|
2448
|
-
}, ie = (
|
|
2449
|
-
Xe(q(),
|
|
2450
|
-
}, le = (
|
|
2451
|
-
const
|
|
2452
|
-
if (!(
|
|
2453
|
-
const f =
|
|
2468
|
+
}, Ae = async (i) => {
|
|
2469
|
+
q()?.commands.removeComment(i), await Ct(i);
|
|
2470
|
+
}, $e = async (i) => {
|
|
2471
|
+
await Jt(i);
|
|
2472
|
+
}, ze = (i) => {
|
|
2473
|
+
Zt(i), ie(i);
|
|
2474
|
+
}, ie = (i) => {
|
|
2475
|
+
Xe(q(), i);
|
|
2476
|
+
}, le = (i) => {
|
|
2477
|
+
const a = i.target;
|
|
2478
|
+
if (!(a instanceof Element)) return;
|
|
2479
|
+
const f = a.closest(".comment-mark");
|
|
2454
2480
|
if (!f) return;
|
|
2455
2481
|
const p = ke(f);
|
|
2456
2482
|
if (!p.length) return;
|
|
@@ -2460,23 +2486,23 @@ const Uo = { class: "app-layout" }, Wo = { class: "editor-wrapper" }, Go = { cla
|
|
|
2460
2486
|
return rt(
|
|
2461
2487
|
() => z.value,
|
|
2462
2488
|
() => {
|
|
2463
|
-
const
|
|
2464
|
-
|
|
2489
|
+
const a = q()?.view?.dom;
|
|
2490
|
+
a instanceof HTMLElement && X !== a && (X && X.removeEventListener("click", le), X = a, X.addEventListener("click", le));
|
|
2465
2491
|
},
|
|
2466
2492
|
{ immediate: !0 }
|
|
2467
2493
|
), pe(() => {
|
|
2468
2494
|
y.value || (y.value = "未命名文档");
|
|
2469
2495
|
}), Fe(() => {
|
|
2470
2496
|
clearTimeout(x), X && (X.removeEventListener("click", le), X = null);
|
|
2471
|
-
}), (
|
|
2497
|
+
}), (i, a) => {
|
|
2472
2498
|
const f = Rn("umo-editor");
|
|
2473
|
-
return _(), O("div",
|
|
2474
|
-
l("div",
|
|
2475
|
-
l("div",
|
|
2499
|
+
return _(), O("div", Vo, [
|
|
2500
|
+
l("div", Ko, [
|
|
2501
|
+
l("div", jo, [
|
|
2476
2502
|
l("div", {
|
|
2477
2503
|
ref_key: "editorStageRef",
|
|
2478
2504
|
ref: mt,
|
|
2479
|
-
class: _t(["umo-editor-stage", { "comment-hidden":
|
|
2505
|
+
class: _t(["umo-editor-stage", { "comment-hidden": !A.value }])
|
|
2480
2506
|
}, [
|
|
2481
2507
|
Fn(f, Bn({
|
|
2482
2508
|
ref_key: "editorRef",
|
|
@@ -2488,7 +2514,7 @@ const Uo = { class: "app-layout" }, Wo = { class: "editor-wrapper" }, Go = { cla
|
|
|
2488
2514
|
type: "button",
|
|
2489
2515
|
onClick: u
|
|
2490
2516
|
}, [
|
|
2491
|
-
|
|
2517
|
+
a[5] || (a[5] = l("span", { class: "umo-custom-huge-btn__icon" }, [
|
|
2492
2518
|
l("svg", {
|
|
2493
2519
|
viewBox: "0 0 24 24",
|
|
2494
2520
|
fill: "none",
|
|
@@ -2503,7 +2529,7 @@ const Uo = { class: "app-layout" }, Wo = { class: "editor-wrapper" }, Go = { cla
|
|
|
2503
2529
|
})
|
|
2504
2530
|
])
|
|
2505
2531
|
], -1)),
|
|
2506
|
-
l("span",
|
|
2532
|
+
l("span", Xo, S(o.value ? "退出全屏" : "全屏"), 1)
|
|
2507
2533
|
])
|
|
2508
2534
|
]),
|
|
2509
2535
|
toolbar_export: Be(() => [
|
|
@@ -2520,7 +2546,7 @@ const Uo = { class: "app-layout" }, Wo = { class: "editor-wrapper" }, Go = { cla
|
|
|
2520
2546
|
disabled: Rt.value,
|
|
2521
2547
|
onClick: yn
|
|
2522
2548
|
}, [
|
|
2523
|
-
|
|
2549
|
+
a[6] || (a[6] = l("span", { class: "umo-custom-huge-btn__icon" }, [
|
|
2524
2550
|
l("svg", {
|
|
2525
2551
|
viewBox: "0 0 24 24",
|
|
2526
2552
|
fill: "none",
|
|
@@ -2549,14 +2575,14 @@ const Uo = { class: "app-layout" }, Wo = { class: "editor-wrapper" }, Go = { cla
|
|
|
2549
2575
|
})
|
|
2550
2576
|
])
|
|
2551
2577
|
], -1)),
|
|
2552
|
-
l("span",
|
|
2553
|
-
], 8,
|
|
2578
|
+
l("span", Yo, S(Rt.value ? "导入中…" : "导入 Word"), 1)
|
|
2579
|
+
], 8, Qo),
|
|
2554
2580
|
l("button", {
|
|
2555
2581
|
class: "umo-custom-huge-btn",
|
|
2556
2582
|
disabled: bt.value,
|
|
2557
2583
|
onClick: Ce
|
|
2558
2584
|
}, [
|
|
2559
|
-
|
|
2585
|
+
a[7] || (a[7] = l("span", { class: "umo-custom-huge-btn__icon" }, [
|
|
2560
2586
|
l("svg", {
|
|
2561
2587
|
viewBox: "0 0 24 24",
|
|
2562
2588
|
fill: "none",
|
|
@@ -2585,14 +2611,14 @@ const Uo = { class: "app-layout" }, Wo = { class: "editor-wrapper" }, Go = { cla
|
|
|
2585
2611
|
})
|
|
2586
2612
|
])
|
|
2587
2613
|
], -1)),
|
|
2588
|
-
l("span",
|
|
2589
|
-
], 8,
|
|
2614
|
+
l("span", tr, S(bt.value ? "导出中…" : "导出 Word"), 1)
|
|
2615
|
+
], 8, Zo),
|
|
2590
2616
|
l("button", {
|
|
2591
2617
|
class: "umo-custom-huge-btn",
|
|
2592
2618
|
disabled: St.value,
|
|
2593
2619
|
onClick: be
|
|
2594
2620
|
}, [
|
|
2595
|
-
|
|
2621
|
+
a[8] || (a[8] = l("span", { class: "umo-custom-huge-btn__icon" }, [
|
|
2596
2622
|
l("svg", {
|
|
2597
2623
|
viewBox: "0 0 24 24",
|
|
2598
2624
|
fill: "none",
|
|
@@ -2621,12 +2647,12 @@ const Uo = { class: "app-layout" }, Wo = { class: "editor-wrapper" }, Go = { cla
|
|
|
2621
2647
|
})
|
|
2622
2648
|
])
|
|
2623
2649
|
], -1)),
|
|
2624
|
-
l("span",
|
|
2625
|
-
], 8,
|
|
2650
|
+
l("span", nr, S(St.value ? "生成中…" : "Word 流下载"), 1)
|
|
2651
|
+
], 8, er),
|
|
2626
2652
|
l("button", {
|
|
2627
2653
|
class: "umo-custom-huge-btn",
|
|
2628
2654
|
onClick: Cn
|
|
2629
|
-
}, [...
|
|
2655
|
+
}, [...a[9] || (a[9] = [
|
|
2630
2656
|
l("span", { class: "umo-custom-huge-btn__icon" }, [
|
|
2631
2657
|
l("svg", {
|
|
2632
2658
|
viewBox: "0 0 24 24",
|
|
@@ -2662,9 +2688,9 @@ const Uo = { class: "app-layout" }, Wo = { class: "editor-wrapper" }, Go = { cla
|
|
|
2662
2688
|
class: "umo-custom-huge-btn",
|
|
2663
2689
|
onClick: Sn
|
|
2664
2690
|
}, [
|
|
2665
|
-
l("span",
|
|
2666
|
-
(_(), O("svg",
|
|
2667
|
-
|
|
2691
|
+
l("span", or, [
|
|
2692
|
+
(_(), O("svg", rr, [
|
|
2693
|
+
a[10] || (a[10] = l("rect", {
|
|
2668
2694
|
x: "9",
|
|
2669
2695
|
y: "9",
|
|
2670
2696
|
width: "13",
|
|
@@ -2675,24 +2701,24 @@ const Uo = { class: "app-layout" }, Wo = { class: "editor-wrapper" }, Go = { cla
|
|
|
2675
2701
|
"stroke-linecap": "round",
|
|
2676
2702
|
"stroke-linejoin": "round"
|
|
2677
2703
|
}, null, -1)),
|
|
2678
|
-
|
|
2704
|
+
a[11] || (a[11] = l("path", {
|
|
2679
2705
|
d: "M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1",
|
|
2680
2706
|
stroke: "currentColor",
|
|
2681
2707
|
"stroke-width": "1.5",
|
|
2682
2708
|
"stroke-linecap": "round",
|
|
2683
2709
|
"stroke-linejoin": "round"
|
|
2684
2710
|
}, null, -1)),
|
|
2685
|
-
|
|
2711
|
+
qt.value ? (_(), O("path", sr)) : ft("", !0)
|
|
2686
2712
|
]))
|
|
2687
2713
|
]),
|
|
2688
|
-
l("span",
|
|
2714
|
+
l("span", ir, S(qt.value ? "已复制" : "复制 HTML"), 1)
|
|
2689
2715
|
]),
|
|
2690
2716
|
l("button", {
|
|
2691
2717
|
class: "umo-custom-huge-btn",
|
|
2692
2718
|
disabled: Tt.value,
|
|
2693
2719
|
onClick: Tn
|
|
2694
2720
|
}, [
|
|
2695
|
-
|
|
2721
|
+
a[12] || (a[12] = l("span", { class: "umo-custom-huge-btn__icon" }, [
|
|
2696
2722
|
l("svg", {
|
|
2697
2723
|
viewBox: "0 0 24 24",
|
|
2698
2724
|
fill: "none",
|
|
@@ -2721,16 +2747,16 @@ const Uo = { class: "app-layout" }, Wo = { class: "editor-wrapper" }, Go = { cla
|
|
|
2721
2747
|
})
|
|
2722
2748
|
])
|
|
2723
2749
|
], -1)),
|
|
2724
|
-
l("span",
|
|
2725
|
-
], 8,
|
|
2750
|
+
l("span", ar, S(Tt.value ? "生成中…" : "导出 JSON"), 1)
|
|
2751
|
+
], 8, lr)
|
|
2726
2752
|
]),
|
|
2727
2753
|
_: 1
|
|
2728
2754
|
}, 16)
|
|
2729
2755
|
], 2)
|
|
2730
2756
|
])
|
|
2731
2757
|
]),
|
|
2732
|
-
d.value ? (_(), O("div",
|
|
2733
|
-
|
|
2758
|
+
d.value ? (_(), O("div", cr, [
|
|
2759
|
+
i.$slots["comment-panel"] ? Ln(i.$slots, "comment-panel", {
|
|
2734
2760
|
key: 0,
|
|
2735
2761
|
comments: vt(E),
|
|
2736
2762
|
activeCommentId: vt(it),
|
|
@@ -2738,7 +2764,7 @@ const Uo = { class: "app-layout" }, Wo = { class: "editor-wrapper" }, Go = { cla
|
|
|
2738
2764
|
activate: ze,
|
|
2739
2765
|
deleteComment: Ae,
|
|
2740
2766
|
resolveComment: $e
|
|
2741
|
-
}, void 0, !0) : (_(),
|
|
2767
|
+
}, void 0, !0) : (_(), Nt(po, {
|
|
2742
2768
|
key: 1,
|
|
2743
2769
|
comments: vt(E),
|
|
2744
2770
|
"active-comment-id": vt(it),
|
|
@@ -2748,75 +2774,75 @@ const Uo = { class: "app-layout" }, Wo = { class: "editor-wrapper" }, Go = { cla
|
|
|
2748
2774
|
onResolve: $e
|
|
2749
2775
|
}, null, 8, ["comments", "active-comment-id", "format-time"]))
|
|
2750
2776
|
])) : ft("", !0),
|
|
2751
|
-
(_(),
|
|
2777
|
+
(_(), Nt(ge, { to: "body" }, [
|
|
2752
2778
|
Lt.value ? (_(), O("div", {
|
|
2753
2779
|
key: 0,
|
|
2754
2780
|
class: "html-dialog-mask",
|
|
2755
|
-
onClick:
|
|
2781
|
+
onClick: a[1] || (a[1] = dt((p) => Lt.value = !1, ["self"]))
|
|
2756
2782
|
}, [
|
|
2757
|
-
l("div",
|
|
2758
|
-
l("div",
|
|
2759
|
-
|
|
2783
|
+
l("div", ur, [
|
|
2784
|
+
l("div", dr, [
|
|
2785
|
+
a[13] || (a[13] = l("span", { class: "html-dialog__title" }, "导出 HTML", -1)),
|
|
2760
2786
|
l("button", {
|
|
2761
2787
|
class: "html-dialog__close",
|
|
2762
|
-
onClick:
|
|
2788
|
+
onClick: a[0] || (a[0] = (p) => Lt.value = !1)
|
|
2763
2789
|
}, "✕")
|
|
2764
2790
|
]),
|
|
2765
|
-
l("div",
|
|
2791
|
+
l("div", mr, [
|
|
2766
2792
|
l("button", {
|
|
2767
2793
|
class: "html-dialog__copy-btn",
|
|
2768
2794
|
onClick: bn
|
|
2769
|
-
}, S(
|
|
2795
|
+
}, S(Ht.value ? "✓ 已复制" : "复制"), 1)
|
|
2770
2796
|
]),
|
|
2771
|
-
l("pre",
|
|
2797
|
+
l("pre", fr, [
|
|
2772
2798
|
l("code", null, S(re.value), 1)
|
|
2773
2799
|
])
|
|
2774
2800
|
])
|
|
2775
2801
|
])) : ft("", !0)
|
|
2776
2802
|
])),
|
|
2777
|
-
(_(),
|
|
2803
|
+
(_(), Nt(ge, { to: "body" }, [
|
|
2778
2804
|
Pt.value ? (_(), O("div", {
|
|
2779
2805
|
key: 0,
|
|
2780
2806
|
class: "html-dialog-mask",
|
|
2781
|
-
onClick:
|
|
2807
|
+
onClick: a[3] || (a[3] = dt((p) => Pt.value = !1, ["self"]))
|
|
2782
2808
|
}, [
|
|
2783
|
-
l("div",
|
|
2784
|
-
l("div",
|
|
2785
|
-
|
|
2809
|
+
l("div", hr, [
|
|
2810
|
+
l("div", pr, [
|
|
2811
|
+
a[14] || (a[14] = l("span", { class: "html-dialog__title" }, "导出 JSON", -1)),
|
|
2786
2812
|
l("button", {
|
|
2787
2813
|
class: "html-dialog__close",
|
|
2788
|
-
onClick:
|
|
2814
|
+
onClick: a[2] || (a[2] = (p) => Pt.value = !1)
|
|
2789
2815
|
}, "✕")
|
|
2790
2816
|
]),
|
|
2791
|
-
l("div",
|
|
2817
|
+
l("div", gr, [
|
|
2792
2818
|
l("button", {
|
|
2793
2819
|
class: "html-dialog__copy-btn",
|
|
2794
2820
|
onClick: En
|
|
2795
2821
|
}, S(Ut.value ? "✓ 已复制" : "复制"), 1)
|
|
2796
2822
|
]),
|
|
2797
|
-
l("pre",
|
|
2823
|
+
l("pre", vr, [
|
|
2798
2824
|
l("code", null, S(se.value), 1)
|
|
2799
2825
|
])
|
|
2800
2826
|
])
|
|
2801
2827
|
])) : ft("", !0)
|
|
2802
2828
|
])),
|
|
2803
|
-
ne.value ? (_(),
|
|
2829
|
+
ne.value ? (_(), Nt(So, {
|
|
2804
2830
|
key: 1,
|
|
2805
2831
|
"selected-text": oe.value,
|
|
2806
2832
|
"initial-note": vn.value,
|
|
2807
2833
|
onConfirm: In,
|
|
2808
|
-
onCancel:
|
|
2834
|
+
onCancel: a[4] || (a[4] = (p) => ne.value = !1)
|
|
2809
2835
|
}, null, 8, ["selected-text", "initial-note"])) : ft("", !0)
|
|
2810
2836
|
]);
|
|
2811
2837
|
};
|
|
2812
2838
|
}
|
|
2813
|
-
}),
|
|
2839
|
+
}), wr = /* @__PURE__ */ zt(yr, [["__scopeId", "data-v-4f8bdaba"]]), kr = { class: "complex-comment-panel__header" }, _r = { class: "complex-comment-panel__title" }, xr = { class: "complex-comment-panel__toolbar" }, Cr = { class: "complex-comment-panel__risk-toggle" }, br = {
|
|
2814
2840
|
key: 0,
|
|
2815
2841
|
class: "complex-comment-panel__empty"
|
|
2816
|
-
},
|
|
2842
|
+
}, Sr = {
|
|
2817
2843
|
class: "complex-comment-panel__tabs",
|
|
2818
2844
|
role: "tablist"
|
|
2819
|
-
},
|
|
2845
|
+
}, Tr = ["onClick"], Er = { class: "complex-comment-panel__body" }, Mr = { class: "complex-comment-panel__section-head" }, Nr = { class: "complex-comment-panel__section-title" }, Ir = { class: "complex-comment-panel__cards" }, Or = ["data-comment-id", "onClick"], Ar = { class: "audit-card__head" }, $r = ["title"], zr = { class: "audit-card__block" }, Dr = { class: "audit-card__quote" }, Jr = ["onClick"], Rr = { class: "audit-card__block audit-card__block--desc" }, Fr = { class: "audit-card__desc" }, Mt = "__all__", Br = {
|
|
2820
2846
|
__name: "ComplexCommentPanel",
|
|
2821
2847
|
props: {
|
|
2822
2848
|
items: {
|
|
@@ -2833,32 +2859,32 @@ const Uo = { class: "app-layout" }, Wo = { class: "editor-wrapper" }, Go = { cla
|
|
|
2833
2859
|
}
|
|
2834
2860
|
},
|
|
2835
2861
|
emits: ["activate", "download"],
|
|
2836
|
-
setup(
|
|
2837
|
-
const e =
|
|
2862
|
+
setup(s, { emit: t }) {
|
|
2863
|
+
const e = s, n = t, o = b(!1), r = b(Mt), u = b(null);
|
|
2838
2864
|
rt(
|
|
2839
2865
|
() => e.items,
|
|
2840
2866
|
() => {
|
|
2841
|
-
r.value =
|
|
2867
|
+
r.value = Mt;
|
|
2842
2868
|
}
|
|
2843
2869
|
), rt(o, () => {
|
|
2844
|
-
r.value =
|
|
2870
|
+
r.value = Mt;
|
|
2845
2871
|
});
|
|
2846
|
-
const
|
|
2872
|
+
const c = K(() => {
|
|
2847
2873
|
const y = [...e.items ?? []];
|
|
2848
2874
|
return o.value ? y.filter((v) => String(v?.reviewStatus ?? "") === "risk") : y;
|
|
2849
2875
|
}), m = K(() => {
|
|
2850
|
-
const y =
|
|
2876
|
+
const y = c.value, v = /* @__PURE__ */ new Map(), x = [], T = /* @__PURE__ */ new Set();
|
|
2851
2877
|
for (const z of y) {
|
|
2852
2878
|
const E = (z ?? {}).category || "未分类";
|
|
2853
2879
|
v.set(E, (v.get(E) ?? 0) + 1), T.has(E) || (T.add(E), x.push(E));
|
|
2854
2880
|
}
|
|
2855
|
-
const V = [{ key:
|
|
2881
|
+
const V = [{ key: Mt, label: "全部", count: y.length }];
|
|
2856
2882
|
for (const z of x)
|
|
2857
2883
|
V.push({ key: z, label: z, count: v.get(z) ?? 0 });
|
|
2858
2884
|
return V;
|
|
2859
2885
|
}), d = K(() => {
|
|
2860
|
-
let y =
|
|
2861
|
-
return r.value !==
|
|
2886
|
+
let y = c.value;
|
|
2887
|
+
return r.value !== Mt && (y = y.filter((v) => (v?.category || "未分类") === r.value)), y;
|
|
2862
2888
|
}), h = K(() => {
|
|
2863
2889
|
const y = d.value, v = [], x = /* @__PURE__ */ new Map();
|
|
2864
2890
|
for (const T of y) {
|
|
@@ -2869,13 +2895,13 @@ const Uo = { class: "app-layout" }, Wo = { class: "editor-wrapper" }, Go = { cla
|
|
|
2869
2895
|
category: T,
|
|
2870
2896
|
rows: x.get(T)
|
|
2871
2897
|
}));
|
|
2872
|
-
}),
|
|
2898
|
+
}), A = (y) => {
|
|
2873
2899
|
const v = String(y ?? "");
|
|
2874
2900
|
return v === "risk" ? "有风险" : v === "compliance" ? "合规" : v || "—";
|
|
2875
|
-
},
|
|
2901
|
+
}, R = (y) => {
|
|
2876
2902
|
const v = String(y ?? "");
|
|
2877
2903
|
return v === "risk" ? "audit-card__badge--risk" : v === "compliance" ? "audit-card__badge--ok" : "audit-card__badge--muted";
|
|
2878
|
-
},
|
|
2904
|
+
}, B = (y) => {
|
|
2879
2905
|
n("activate", y);
|
|
2880
2906
|
};
|
|
2881
2907
|
return rt(
|
|
@@ -2893,15 +2919,15 @@ const Uo = { class: "app-layout" }, Wo = { class: "editor-wrapper" }, Go = { cla
|
|
|
2893
2919
|
ref: u,
|
|
2894
2920
|
class: "complex-comment-panel"
|
|
2895
2921
|
}, [
|
|
2896
|
-
l("div",
|
|
2897
|
-
l("h3",
|
|
2898
|
-
l("div",
|
|
2922
|
+
l("div", kr, [
|
|
2923
|
+
l("h3", _r, S(s.title), 1),
|
|
2924
|
+
l("div", xr, [
|
|
2899
2925
|
l("button", {
|
|
2900
2926
|
type: "button",
|
|
2901
2927
|
class: "complex-comment-panel__download",
|
|
2902
2928
|
onClick: v[0] || (v[0] = (x) => n("download"))
|
|
2903
2929
|
}, " 下载 "),
|
|
2904
|
-
l("label",
|
|
2930
|
+
l("label", Cr, [
|
|
2905
2931
|
Qe(l("input", {
|
|
2906
2932
|
"onUpdate:modelValue": v[1] || (v[1] = (x) => o.value = x),
|
|
2907
2933
|
type: "checkbox"
|
|
@@ -2912,84 +2938,84 @@ const Uo = { class: "app-layout" }, Wo = { class: "editor-wrapper" }, Go = { cla
|
|
|
2912
2938
|
])
|
|
2913
2939
|
])
|
|
2914
2940
|
]),
|
|
2915
|
-
|
|
2941
|
+
s.items.length === 0 ? (_(), O("div", br, [...v[3] || (v[3] = [
|
|
2916
2942
|
l("p", null, "暂无审查结果", -1)
|
|
2917
2943
|
])])) : (_(), O(kt, { key: 1 }, [
|
|
2918
|
-
l("div",
|
|
2944
|
+
l("div", Sr, [
|
|
2919
2945
|
(_(!0), O(kt, null, It(m.value, (x) => (_(), O("button", {
|
|
2920
2946
|
key: x.key,
|
|
2921
2947
|
type: "button",
|
|
2922
2948
|
role: "tab",
|
|
2923
2949
|
class: _t(["complex-comment-panel__tab", { "complex-comment-panel__tab--active": r.value === x.key }]),
|
|
2924
2950
|
onClick: (T) => r.value = x.key
|
|
2925
|
-
}, S(x.label) + " (" + S(x.count) + ") ", 11,
|
|
2951
|
+
}, S(x.label) + " (" + S(x.count) + ") ", 11, Tr))), 128))
|
|
2926
2952
|
]),
|
|
2927
|
-
l("div",
|
|
2953
|
+
l("div", Er, [
|
|
2928
2954
|
(_(!0), O(kt, null, It(h.value, (x) => (_(), O("section", {
|
|
2929
2955
|
key: x.category,
|
|
2930
2956
|
class: "complex-comment-panel__section"
|
|
2931
2957
|
}, [
|
|
2932
|
-
l("div",
|
|
2933
|
-
l("span",
|
|
2958
|
+
l("div", Mr, [
|
|
2959
|
+
l("span", Nr, S(x.category), 1)
|
|
2934
2960
|
]),
|
|
2935
|
-
l("ul",
|
|
2961
|
+
l("ul", Ir, [
|
|
2936
2962
|
(_(!0), O(kt, null, It(x.rows, (T) => (_(), O("li", {
|
|
2937
2963
|
key: T.id,
|
|
2938
|
-
class: _t(["audit-card", { "audit-card--active":
|
|
2964
|
+
class: _t(["audit-card", { "audit-card--active": s.activeCommentId === T.id }]),
|
|
2939
2965
|
"data-comment-id": T.id,
|
|
2940
|
-
onClick: (V) =>
|
|
2966
|
+
onClick: (V) => B(T.id)
|
|
2941
2967
|
}, [
|
|
2942
|
-
l("div",
|
|
2968
|
+
l("div", Ar, [
|
|
2943
2969
|
l("span", {
|
|
2944
2970
|
class: "audit-card__point",
|
|
2945
2971
|
title: T.reviewPoint || "(无审查点)"
|
|
2946
|
-
}, S(T.reviewPoint || "(无审查点)"), 9,
|
|
2972
|
+
}, S(T.reviewPoint || "(无审查点)"), 9, $r),
|
|
2947
2973
|
l("span", {
|
|
2948
|
-
class: _t(["audit-card__badge",
|
|
2949
|
-
}, S(
|
|
2974
|
+
class: _t(["audit-card__badge", R(T.reviewStatus)])
|
|
2975
|
+
}, S(A(T.reviewStatus)), 3)
|
|
2950
2976
|
]),
|
|
2951
|
-
l("div",
|
|
2977
|
+
l("div", zr, [
|
|
2952
2978
|
v[5] || (v[5] = l("div", { class: "audit-card__label" }, "原文内容", -1)),
|
|
2953
|
-
l("div",
|
|
2979
|
+
l("div", Dr, S(T.originalText || "无原文"), 1),
|
|
2954
2980
|
l("button", {
|
|
2955
2981
|
type: "button",
|
|
2956
2982
|
class: "audit-card__locate",
|
|
2957
|
-
onClick: dt((V) =>
|
|
2983
|
+
onClick: dt((V) => B(T.id), ["stop"])
|
|
2958
2984
|
}, [...v[4] || (v[4] = [
|
|
2959
2985
|
l("span", {
|
|
2960
2986
|
class: "audit-card__locate-icon",
|
|
2961
2987
|
"aria-hidden": "true"
|
|
2962
2988
|
}, "⌖", -1),
|
|
2963
2989
|
he(" 原文定位 ", -1)
|
|
2964
|
-
])], 8,
|
|
2990
|
+
])], 8, Jr)
|
|
2965
2991
|
]),
|
|
2966
2992
|
v[7] || (v[7] = l("div", { class: "audit-card__divider" }, null, -1)),
|
|
2967
|
-
l("div",
|
|
2993
|
+
l("div", Rr, [
|
|
2968
2994
|
v[6] || (v[6] = l("div", { class: "audit-card__label audit-card__label--strong" }, "审查说明", -1)),
|
|
2969
|
-
l("p",
|
|
2995
|
+
l("p", Fr, S(T.auditDescription || "—"), 1)
|
|
2970
2996
|
])
|
|
2971
|
-
], 10,
|
|
2997
|
+
], 10, Or))), 128))
|
|
2972
2998
|
])
|
|
2973
2999
|
]))), 128))
|
|
2974
3000
|
])
|
|
2975
3001
|
], 64))
|
|
2976
3002
|
], 512));
|
|
2977
3003
|
}
|
|
2978
|
-
},
|
|
2979
|
-
function
|
|
3004
|
+
}, Gr = /* @__PURE__ */ zt(Br, [["__scopeId", "data-v-bc202f94"]]);
|
|
3005
|
+
function Vr() {
|
|
2980
3006
|
}
|
|
2981
|
-
const
|
|
2982
|
-
install(
|
|
3007
|
+
const Kr = {
|
|
3008
|
+
install(s, t) {
|
|
2983
3009
|
const e = { ...t ?? {} };
|
|
2984
3010
|
for (const n of ["onFileUpload", "onFileDelete", "onSave"])
|
|
2985
3011
|
n in e && typeof e[n] != "function" && delete e[n];
|
|
2986
|
-
|
|
3012
|
+
s.use(An, e), s.component("UmoEditorApp", wr);
|
|
2987
3013
|
}
|
|
2988
3014
|
};
|
|
2989
3015
|
export {
|
|
2990
|
-
|
|
2991
|
-
|
|
2992
|
-
|
|
2993
|
-
|
|
2994
|
-
|
|
3016
|
+
po as CommentPanel,
|
|
3017
|
+
Gr as ComplexCommentPanel,
|
|
3018
|
+
wr as UmoEditorApp,
|
|
3019
|
+
Kr as UmoEditorAppPlugin,
|
|
3020
|
+
Vr as ensureUmoEditorGlobals
|
|
2995
3021
|
};
|