@hmg-report-editor/core 1.0.0 → 1.0.1
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,16 +1,16 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var p = (r, t, e) =>
|
|
4
|
-
import { Extension as
|
|
5
|
-
import { closeHistory as
|
|
6
|
-
import { Slice as nt, Fragment as
|
|
7
|
-
import { PluginKey as
|
|
8
|
-
import { DecorationSet as U, Decoration as
|
|
9
|
-
import { insertPoint as
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
import
|
|
1
|
+
var De = Object.defineProperty;
|
|
2
|
+
var xe = (r, t, e) => t in r ? De(r, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : r[t] = e;
|
|
3
|
+
var p = (r, t, e) => xe(r, typeof t != "symbol" ? t + "" : t, e);
|
|
4
|
+
import { Extension as D, Node as ut, mergeAttributes as ct, Mark as Pe, createDocument as Kt, getSchema as Be, Editor as Oe } from "@tiptap/core";
|
|
5
|
+
import { closeHistory as Le } from "@tiptap/pm/history";
|
|
6
|
+
import { Slice as nt, Fragment as It, DOMSerializer as Fe } from "@tiptap/pm/model";
|
|
7
|
+
import { PluginKey as ht, Plugin as X, TextSelection as A, NodeSelection as B, Selection as W } from "@tiptap/pm/state";
|
|
8
|
+
import { DecorationSet as U, Decoration as Jt } from "@tiptap/pm/view";
|
|
9
|
+
import { insertPoint as Ve, dropPoint as Re } from "@tiptap/pm/transform";
|
|
10
|
+
import ze from "@tiptap/starter-kit";
|
|
11
|
+
import $e from "@tiptap/extension-font-family";
|
|
12
|
+
import _e from "@tiptap/extension-text-style";
|
|
13
|
+
import He from "@tiptap/extension-underline";
|
|
14
14
|
class b {
|
|
15
15
|
/** 转义文本节点内容。 */
|
|
16
16
|
static text(t) {
|
|
@@ -31,7 +31,7 @@ class Et {
|
|
|
31
31
|
}
|
|
32
32
|
/** 添加经过 CSS 值白名单校验的样式声明。 */
|
|
33
33
|
addSafe(t, e) {
|
|
34
|
-
const n =
|
|
34
|
+
const n = M.sanitize(t, e);
|
|
35
35
|
return n && this.declarations.push(`${t}: ${n}`), this;
|
|
36
36
|
}
|
|
37
37
|
/** 输出完整 style 属性字符串。 */
|
|
@@ -39,7 +39,7 @@ class Et {
|
|
|
39
39
|
return this.declarations.length === 0 ? "" : ` style="${b.attr(this.declarations.join("; "))}"`;
|
|
40
40
|
}
|
|
41
41
|
}
|
|
42
|
-
class
|
|
42
|
+
class M {
|
|
43
43
|
/** 按 CSS 属性名清洗单个样式值,非法值返回 undefined。 */
|
|
44
44
|
static sanitize(t, e) {
|
|
45
45
|
if (typeof e == "number")
|
|
@@ -89,11 +89,11 @@ class z {
|
|
|
89
89
|
return t == null ? !0 : typeof t == "string" ? t.trim().length === 0 : !1;
|
|
90
90
|
}
|
|
91
91
|
}
|
|
92
|
-
const I = "visibilityGroup",
|
|
93
|
-
function
|
|
92
|
+
const I = "visibilityGroup", Z = "all-controls-empty";
|
|
93
|
+
function pt(r) {
|
|
94
94
|
if (typeof r.groupId != "string" || !r.groupId.trim())
|
|
95
95
|
throw new Error("Visibility group requires a non-empty groupId.");
|
|
96
|
-
if (r.condition !==
|
|
96
|
+
if (r.condition !== Z)
|
|
97
97
|
throw new Error(`Unsupported visibility group condition: ${String(r.condition ?? "")}.`);
|
|
98
98
|
}
|
|
99
99
|
function Xt() {
|
|
@@ -125,7 +125,7 @@ class Yt {
|
|
|
125
125
|
return t.map((n) => {
|
|
126
126
|
if (n.type.name !== I)
|
|
127
127
|
return n;
|
|
128
|
-
|
|
128
|
+
pt(n.attrs);
|
|
129
129
|
const o = String(n.attrs.groupId);
|
|
130
130
|
let s = e.get(o);
|
|
131
131
|
return s || (s = Xt(), e.set(o, s)), n.type.create({
|
|
@@ -138,22 +138,22 @@ class Yt {
|
|
|
138
138
|
const n = [];
|
|
139
139
|
return t.forEach((o) => {
|
|
140
140
|
n.push(this.mapNode(o, e));
|
|
141
|
-
}),
|
|
141
|
+
}), It.fromArray(n);
|
|
142
142
|
}
|
|
143
143
|
mapNode(t, e) {
|
|
144
144
|
const n = e(t.marks);
|
|
145
145
|
if (t.isText)
|
|
146
|
-
return
|
|
146
|
+
return At(n, t.marks) ? t : t.mark(n);
|
|
147
147
|
const o = t.content.size > 0 ? this.mapFragment(t.content, e) : t.content;
|
|
148
|
-
return o === t.content &&
|
|
148
|
+
return o === t.content && At(n, t.marks) ? t : t.type.create(t.attrs, o, n);
|
|
149
149
|
}
|
|
150
150
|
}
|
|
151
|
-
function
|
|
151
|
+
function At(r, t) {
|
|
152
152
|
return r.length === t.length && r.every((e, n) => e.eq(t[n]));
|
|
153
153
|
}
|
|
154
|
-
const ot = "[data-report-node][data-control-id]", Mt = "hmg-control-gap-caret",
|
|
155
|
-
function
|
|
156
|
-
const t =
|
|
154
|
+
const ot = "[data-report-node][data-control-id]", Mt = "hmg-control-gap-caret", T = new ht("reportControlGapCursor");
|
|
155
|
+
function Ge(r = []) {
|
|
156
|
+
const t = fr(r);
|
|
157
157
|
let e = null;
|
|
158
158
|
const n = (o) => {
|
|
159
159
|
if (!e || e.finishScheduled)
|
|
@@ -161,72 +161,72 @@ function He(r = []) {
|
|
|
161
161
|
e.ending = !0, e.finishScheduled = !0;
|
|
162
162
|
const s = e.sessionId;
|
|
163
163
|
setTimeout(() => {
|
|
164
|
-
(e == null ? void 0 : e.sessionId) === s && (e =
|
|
164
|
+
(e == null ? void 0 : e.sessionId) === s && (e = ir(
|
|
165
165
|
o,
|
|
166
166
|
e,
|
|
167
167
|
t
|
|
168
168
|
));
|
|
169
169
|
});
|
|
170
170
|
};
|
|
171
|
-
return
|
|
171
|
+
return D.create({
|
|
172
172
|
name: "reportControlGapCursor",
|
|
173
173
|
priority: 1e3,
|
|
174
174
|
addProseMirrorPlugins() {
|
|
175
175
|
return [
|
|
176
|
-
new
|
|
177
|
-
key:
|
|
176
|
+
new X({
|
|
177
|
+
key: T,
|
|
178
178
|
state: {
|
|
179
|
-
init: () =>
|
|
179
|
+
init: () => Q(),
|
|
180
180
|
apply(o, s, i, a) {
|
|
181
|
-
const l = o.getMeta(
|
|
181
|
+
const l = o.getMeta(T);
|
|
182
182
|
if (e && o.docChanged) {
|
|
183
183
|
const u = o.getMeta("composition");
|
|
184
|
-
e = (l == null ? void 0 : l.type) === "compositionInput" && l.sessionId === e.sessionId || e.compositionId !== void 0 && u === e.compositionId ?
|
|
184
|
+
e = (l == null ? void 0 : l.type) === "compositionInput" && l.sessionId === e.sessionId || e.compositionId !== void 0 && u === e.compositionId ? or(e, o) : sr(
|
|
185
185
|
e,
|
|
186
186
|
o
|
|
187
187
|
);
|
|
188
188
|
}
|
|
189
189
|
if ((l == null ? void 0 : l.type) === "clear")
|
|
190
|
-
return
|
|
190
|
+
return Q();
|
|
191
191
|
if ((l == null ? void 0 : l.type) === "showBoundaryCaret")
|
|
192
192
|
return Dt(a, l.pos);
|
|
193
193
|
if (s.boundaryCaretPos !== null)
|
|
194
|
-
return o.docChanged ?
|
|
194
|
+
return o.docChanged ? Q() : Dt(a, s.boundaryCaretPos);
|
|
195
195
|
let d = (l == null ? void 0 : l.type) === "activate" ? l.active : s.active;
|
|
196
|
-
return d && o.docChanged && (l == null ? void 0 : l.type) !== "activate" && (d = st(d, o.mapping)),
|
|
196
|
+
return d && o.docChanged && (l == null ? void 0 : l.type) !== "activate" && (d = st(d, o.mapping)), tr(a, d, t);
|
|
197
197
|
}
|
|
198
198
|
},
|
|
199
199
|
props: {
|
|
200
200
|
decorations(o) {
|
|
201
201
|
var s;
|
|
202
|
-
return (s =
|
|
202
|
+
return (s = T.getState(o)) == null ? void 0 : s.decorations;
|
|
203
203
|
},
|
|
204
204
|
handleClick(o, s, i) {
|
|
205
|
-
return
|
|
205
|
+
return Ue(o, s, i, t);
|
|
206
206
|
},
|
|
207
207
|
handleTextInput(o, s, i, a, l) {
|
|
208
208
|
return !e && o.composing && (e = xt(o)), e ? (e.awaitingInput = {
|
|
209
209
|
from: s,
|
|
210
210
|
text: a
|
|
211
211
|
}, o.dispatch(
|
|
212
|
-
Zt(l(), s, a.length).setMeta(
|
|
212
|
+
Zt(l(), s, a.length).setMeta(T, {
|
|
213
213
|
type: "compositionInput",
|
|
214
214
|
sessionId: e.sessionId
|
|
215
215
|
})
|
|
216
|
-
), !0) :
|
|
216
|
+
), !0) : qe(o, a, l, t);
|
|
217
217
|
},
|
|
218
218
|
handleDOMEvents: {
|
|
219
219
|
compositionstart(o) {
|
|
220
|
-
return e != null && e.ending && (e =
|
|
220
|
+
return e != null && e.ending && (e = nr(
|
|
221
221
|
o.state,
|
|
222
222
|
e
|
|
223
|
-
) ?
|
|
223
|
+
) ? rr(e) : null), e ?? (e = xt(o)), !1;
|
|
224
224
|
},
|
|
225
225
|
compositionend(o) {
|
|
226
226
|
return n(o), !1;
|
|
227
227
|
},
|
|
228
228
|
blur(o) {
|
|
229
|
-
return n(o),
|
|
229
|
+
return n(o), lr(o), !1;
|
|
230
230
|
}
|
|
231
231
|
}
|
|
232
232
|
},
|
|
@@ -242,28 +242,28 @@ function He(r = []) {
|
|
|
242
242
|
}
|
|
243
243
|
});
|
|
244
244
|
}
|
|
245
|
-
function
|
|
245
|
+
function Ue(r, t, e, n) {
|
|
246
246
|
if (e.button !== 0 || !r.editable || e.defaultPrevented || e.altKey || e.ctrlKey || e.metaKey || e.shiftKey)
|
|
247
247
|
return !1;
|
|
248
248
|
const o = e.target;
|
|
249
249
|
if (!(o instanceof Element) || !r.dom.contains(o) || o.closest(ot))
|
|
250
250
|
return !1;
|
|
251
|
-
const s =
|
|
251
|
+
const s = dr(r.state.doc, t, n);
|
|
252
252
|
for (const i of s) {
|
|
253
253
|
const a = Bt(r, i.left), l = Bt(r, i.right);
|
|
254
|
-
if (!a || !l || !
|
|
254
|
+
if (!a || !l || !je(e, a, l))
|
|
255
255
|
continue;
|
|
256
|
-
const d = r.state.tr.setSelection(
|
|
256
|
+
const d = r.state.tr.setSelection(A.create(r.state.doc, i.cursorPos)).setMeta(T, {
|
|
257
257
|
type: "activate",
|
|
258
|
-
active:
|
|
258
|
+
active: er(i)
|
|
259
259
|
});
|
|
260
260
|
return d.setMeta("addToHistory", !1), r.dispatch(d), r.focus(), e.preventDefault(), !0;
|
|
261
261
|
}
|
|
262
262
|
return !1;
|
|
263
263
|
}
|
|
264
|
-
function
|
|
265
|
-
const { selection: o } = r.state, s =
|
|
266
|
-
if (!r.editable || !t || !(s != null && s.active) || !(o instanceof
|
|
264
|
+
function qe(r, t, e, n) {
|
|
265
|
+
const { selection: o } = r.state, s = T.getState(r.state);
|
|
266
|
+
if (!r.editable || !t || !(s != null && s.active) || !(o instanceof A) || !o.empty || o.from !== s.active.pos)
|
|
267
267
|
return !1;
|
|
268
268
|
const i = ee(r.state.doc, s.active, n);
|
|
269
269
|
if (!i)
|
|
@@ -278,7 +278,7 @@ function Ue(r, t, e, n) {
|
|
|
278
278
|
}).scrollIntoView();
|
|
279
279
|
return l !== void 0 && d.setMeta("composition", l), r.dispatch(d), !0;
|
|
280
280
|
}
|
|
281
|
-
function
|
|
281
|
+
function je(r, t, e) {
|
|
282
282
|
const n = t.getBoundingClientRect(), o = e.getBoundingClientRect(), s = Math.max(n.top, o.top), i = Math.min(n.bottom, o.bottom);
|
|
283
283
|
let a, l;
|
|
284
284
|
if (s >= i)
|
|
@@ -291,30 +291,30 @@ function qe(r, t, e) {
|
|
|
291
291
|
return !1;
|
|
292
292
|
return r.clientX >= a && r.clientX <= l && r.clientY >= s && r.clientY <= i;
|
|
293
293
|
}
|
|
294
|
-
function
|
|
294
|
+
function Q() {
|
|
295
295
|
return {
|
|
296
296
|
active: null,
|
|
297
297
|
boundaryCaretPos: null,
|
|
298
298
|
decorations: U.empty
|
|
299
299
|
};
|
|
300
300
|
}
|
|
301
|
-
function
|
|
302
|
-
return r.setMeta(
|
|
301
|
+
function We(r, t) {
|
|
302
|
+
return r.setMeta(T, {
|
|
303
303
|
type: "showBoundaryCaret",
|
|
304
304
|
pos: t
|
|
305
305
|
});
|
|
306
306
|
}
|
|
307
|
-
function
|
|
307
|
+
function Ke(r) {
|
|
308
308
|
var t;
|
|
309
|
-
return ((t =
|
|
309
|
+
return ((t = T.getState(r)) == null ? void 0 : t.boundaryCaretPos) ?? null;
|
|
310
310
|
}
|
|
311
311
|
function Je(r) {
|
|
312
|
-
return r.setMeta(
|
|
312
|
+
return r.setMeta(T, {
|
|
313
313
|
type: "clear"
|
|
314
314
|
});
|
|
315
315
|
}
|
|
316
|
-
function
|
|
317
|
-
const s =
|
|
316
|
+
function Xe(r, t, e, n, o) {
|
|
317
|
+
const s = T.get(r.state), i = s == null ? void 0 : s.props.handleTextInput;
|
|
318
318
|
if (!s || !i)
|
|
319
319
|
return !1;
|
|
320
320
|
if (i.call(s, r, t, e, n, o) === !0)
|
|
@@ -322,9 +322,9 @@ function Ke(r, t, e, n, o) {
|
|
|
322
322
|
if (!r.editable || !n)
|
|
323
323
|
return !1;
|
|
324
324
|
const a = o();
|
|
325
|
-
if (!
|
|
325
|
+
if (!Ye(a.doc, t, t + n.length))
|
|
326
326
|
return !1;
|
|
327
|
-
const l = () => Qt(o()), d =
|
|
327
|
+
const l = () => Qt(o()), d = Ze(r);
|
|
328
328
|
for (const u of r.state.plugins)
|
|
329
329
|
if (!(u === s || !u.props.handleTextInput) && u.props.handleTextInput.call(
|
|
330
330
|
u,
|
|
@@ -341,11 +341,11 @@ function Zt(r, t, e) {
|
|
|
341
341
|
const n = r.doc.type.schema.marks[I], o = Math.min(r.doc.content.size, t + e);
|
|
342
342
|
return n && e > 0 && t >= 0 && t < o && r.removeMark(t, o, n), r;
|
|
343
343
|
}
|
|
344
|
-
function
|
|
344
|
+
function Ye(r, t, e) {
|
|
345
345
|
const n = r.type.schema.marks[I], o = Math.max(0, t), s = Math.min(r.content.size, e);
|
|
346
346
|
return !!(n && o < s && r.rangeHasMark(o, s, n));
|
|
347
347
|
}
|
|
348
|
-
function
|
|
348
|
+
function Ze(r) {
|
|
349
349
|
const t = Object.create(r);
|
|
350
350
|
return Object.defineProperty(t, "dispatch", {
|
|
351
351
|
configurable: !0,
|
|
@@ -368,11 +368,11 @@ function Qt(r) {
|
|
|
368
368
|
c < g && r.doc.rangeHasMark(c, g, t) && n.push({ from: c, to: g });
|
|
369
369
|
});
|
|
370
370
|
});
|
|
371
|
-
for (const o of
|
|
371
|
+
for (const o of Qe(n))
|
|
372
372
|
r.removeMark(o.from, o.to, t);
|
|
373
373
|
return r;
|
|
374
374
|
}
|
|
375
|
-
function
|
|
375
|
+
function Qe(r) {
|
|
376
376
|
const t = [...r].sort((n, o) => n.from - o.from || n.to - o.to), e = [];
|
|
377
377
|
for (const n of t) {
|
|
378
378
|
const o = e[e.length - 1];
|
|
@@ -385,12 +385,12 @@ function Ze(r) {
|
|
|
385
385
|
return e;
|
|
386
386
|
}
|
|
387
387
|
function kt(r, t) {
|
|
388
|
-
const e =
|
|
388
|
+
const e = T.get(r.state), n = e == null ? void 0 : e.props.handleDOMEvents, o = n == null ? void 0 : n[t.type];
|
|
389
389
|
return !e || !o ? !1 : o.call(e, r, t) === !0;
|
|
390
390
|
}
|
|
391
|
-
function
|
|
391
|
+
function tr(r, t, e) {
|
|
392
392
|
const { selection: n } = r;
|
|
393
|
-
return !t || !(n instanceof
|
|
393
|
+
return !t || !(n instanceof A) || !n.empty || n.from !== t.pos || !ee(r.doc, t, e) ? Q() : {
|
|
394
394
|
active: t,
|
|
395
395
|
boundaryCaretPos: null,
|
|
396
396
|
decorations: te(r, t.pos)
|
|
@@ -398,14 +398,14 @@ function Qe(r, t, e) {
|
|
|
398
398
|
}
|
|
399
399
|
function Dt(r, t) {
|
|
400
400
|
const { selection: e } = r;
|
|
401
|
-
return !(e instanceof
|
|
401
|
+
return !(e instanceof A) || !e.empty || e.from !== t || t < 0 || t > r.doc.content.size || !r.doc.resolve(t).parent.inlineContent ? Q() : {
|
|
402
402
|
active: null,
|
|
403
403
|
boundaryCaretPos: t,
|
|
404
404
|
decorations: te(r, t)
|
|
405
405
|
};
|
|
406
406
|
}
|
|
407
407
|
function te(r, t) {
|
|
408
|
-
const e =
|
|
408
|
+
const e = Jt.widget(
|
|
409
409
|
t,
|
|
410
410
|
(n) => {
|
|
411
411
|
const o = n.dom.ownerDocument.createElement("span");
|
|
@@ -419,7 +419,7 @@ function te(r, t) {
|
|
|
419
419
|
);
|
|
420
420
|
return U.create(r.doc, [e]);
|
|
421
421
|
}
|
|
422
|
-
function
|
|
422
|
+
function er(r) {
|
|
423
423
|
return {
|
|
424
424
|
pos: r.cursorPos,
|
|
425
425
|
leftPos: r.left.pos,
|
|
@@ -443,7 +443,7 @@ function st(r, t) {
|
|
|
443
443
|
}
|
|
444
444
|
function xt(r) {
|
|
445
445
|
var e;
|
|
446
|
-
const t = (e =
|
|
446
|
+
const t = (e = T.getState(r.state)) == null ? void 0 : e.active;
|
|
447
447
|
return t ? {
|
|
448
448
|
sessionId: Symbol("control-gap-composition"),
|
|
449
449
|
active: { ...t },
|
|
@@ -458,7 +458,7 @@ function xt(r) {
|
|
|
458
458
|
finishScheduled: !1
|
|
459
459
|
} : null;
|
|
460
460
|
}
|
|
461
|
-
function
|
|
461
|
+
function rr(r) {
|
|
462
462
|
return {
|
|
463
463
|
...r,
|
|
464
464
|
sessionId: Symbol("control-gap-composition"),
|
|
@@ -468,11 +468,11 @@ function er(r) {
|
|
|
468
468
|
finishScheduled: !1
|
|
469
469
|
};
|
|
470
470
|
}
|
|
471
|
-
function
|
|
471
|
+
function nr(r, t) {
|
|
472
472
|
const { selection: e } = r;
|
|
473
473
|
return !!(t.range && e.from >= t.range.from && e.to <= t.range.to || e.empty && e.from === t.active.pos);
|
|
474
474
|
}
|
|
475
|
-
function
|
|
475
|
+
function or(r, t) {
|
|
476
476
|
const e = st(r.active, t.mapping), n = t.getMeta("composition") ?? r.compositionId, o = r.range ? {
|
|
477
477
|
from: t.mapping.map(r.range.from, -1),
|
|
478
478
|
to: t.mapping.map(r.range.to, 1)
|
|
@@ -499,7 +499,7 @@ function nr(r, t) {
|
|
|
499
499
|
compositionId: n
|
|
500
500
|
};
|
|
501
501
|
}
|
|
502
|
-
function
|
|
502
|
+
function sr(r, t) {
|
|
503
503
|
if (t.getMeta("addToHistory") !== !1)
|
|
504
504
|
return null;
|
|
505
505
|
if (!r.range)
|
|
@@ -524,11 +524,11 @@ function or(r, t) {
|
|
|
524
524
|
range: { from: o, to: s }
|
|
525
525
|
} : null;
|
|
526
526
|
}
|
|
527
|
-
function
|
|
527
|
+
function ir(r, t, e) {
|
|
528
528
|
if (!t || !t.ending || r.isDestroyed || !t.range || !t.text)
|
|
529
529
|
return null;
|
|
530
530
|
const { from: n, to: o } = t.range, s = r.state.selection.from >= n && r.state.selection.to <= o || r.state.selection.empty && r.state.selection.from === t.active.pos;
|
|
531
|
-
if (n < 0 || o > r.state.doc.content.size || n >= o || r.state.doc.textBetween(n, o, "", "") !== t.text ||
|
|
531
|
+
if (n < 0 || o > r.state.doc.content.size || n >= o || r.state.doc.textBetween(n, o, "", "") !== t.text || ar(r.state.doc, n, o))
|
|
532
532
|
return null;
|
|
533
533
|
const i = r.state.tr.delete(n, o), a = i.mapping.map(t.active.leftPos, 1), l = i.mapping.map(t.active.rightPos, 1), d = i.doc.nodeAt(a), u = i.doc.nodeAt(l);
|
|
534
534
|
if (!d || !u || !e(d) || !e(u) || d.attrs.controlId !== t.active.leftControlId || u.attrs.controlId !== t.active.rightControlId)
|
|
@@ -538,26 +538,26 @@ function sr(r, t, e) {
|
|
|
538
538
|
{ node: d, pos: a },
|
|
539
539
|
{ node: u, pos: l }
|
|
540
540
|
);
|
|
541
|
-
return h && (i.insert(h.cursorPos, i.doc.type.schema.text(t.text, t.marks)).scrollIntoView(), s && i.setSelection(
|
|
541
|
+
return h && (i.insert(h.cursorPos, i.doc.type.schema.text(t.text, t.marks)).scrollIntoView(), s && i.setSelection(A.create(i.doc, h.cursorPos + t.text.length)), t.compositionId !== void 0 && i.setMeta("composition", t.compositionId), r.dispatch(i)), null;
|
|
542
542
|
}
|
|
543
|
-
function
|
|
543
|
+
function ar(r, t, e) {
|
|
544
544
|
let n = !1;
|
|
545
545
|
return r.nodesBetween(t, e, (o, s) => {
|
|
546
546
|
if ((o.isLeaf || o.isAtom) && !o.isText && s < e && s + o.nodeSize > t)
|
|
547
547
|
return n = !0, !1;
|
|
548
548
|
}), n;
|
|
549
549
|
}
|
|
550
|
-
function
|
|
551
|
-
const t =
|
|
550
|
+
function lr(r) {
|
|
551
|
+
const t = T.getState(r.state);
|
|
552
552
|
if (!(t != null && t.active) && (t == null ? void 0 : t.boundaryCaretPos) === null)
|
|
553
553
|
return;
|
|
554
|
-
const e = r.state.tr.setMeta(
|
|
554
|
+
const e = r.state.tr.setMeta(T, {
|
|
555
555
|
type: "clear"
|
|
556
556
|
}).setMeta("addToHistory", !1);
|
|
557
557
|
r.dispatch(e);
|
|
558
558
|
}
|
|
559
|
-
function
|
|
560
|
-
const n =
|
|
559
|
+
function dr(r, t, e) {
|
|
560
|
+
const n = ur(r, t), o = [], s = /* @__PURE__ */ new Set();
|
|
561
561
|
for (const i of n) {
|
|
562
562
|
const a = ne(r, i, e);
|
|
563
563
|
if (a) {
|
|
@@ -571,7 +571,7 @@ function lr(r, t, e) {
|
|
|
571
571
|
(i, a) => Pt(t, i.from, i.to) - Pt(t, a.from, a.to)
|
|
572
572
|
);
|
|
573
573
|
}
|
|
574
|
-
function
|
|
574
|
+
function ur(r, t) {
|
|
575
575
|
const e = r.resolve(t), n = /* @__PURE__ */ new Set([t]);
|
|
576
576
|
for (let o = e.depth; o >= 0; o -= 1) {
|
|
577
577
|
const s = e.node(o);
|
|
@@ -588,7 +588,7 @@ function Pt(r, t, e) {
|
|
|
588
588
|
}
|
|
589
589
|
function re(r, t, e) {
|
|
590
590
|
const n = t.pos + t.node.nodeSize, o = e.pos;
|
|
591
|
-
if (n > o ||
|
|
591
|
+
if (n > o || cr(r, n, o))
|
|
592
592
|
return;
|
|
593
593
|
const s = r.resolve(t.pos), i = r.resolve(e.pos), a = s.sharedDepth(e.pos);
|
|
594
594
|
if (!s.node(a).inlineContent)
|
|
@@ -603,7 +603,7 @@ function re(r, t, e) {
|
|
|
603
603
|
cursorPos: l
|
|
604
604
|
};
|
|
605
605
|
}
|
|
606
|
-
function
|
|
606
|
+
function cr(r, t, e) {
|
|
607
607
|
let n = !1;
|
|
608
608
|
return r.nodesBetween(t, e, (o, s) => {
|
|
609
609
|
if ((o.isLeaf || o.isAtom) && s < e && s + o.nodeSize > t)
|
|
@@ -617,13 +617,13 @@ function ne(r, t, e) {
|
|
|
617
617
|
for (let a = 1; a <= n.depth; a += 1)
|
|
618
618
|
if (n.node(a).isAtom)
|
|
619
619
|
return;
|
|
620
|
-
const o =
|
|
620
|
+
const o = hr(n), s = pr(n);
|
|
621
621
|
if (!o || !s || !e(o.node) || !e(s.node))
|
|
622
622
|
return;
|
|
623
623
|
const i = re(r, o, s);
|
|
624
624
|
return i && t >= i.from && t <= i.to ? i : void 0;
|
|
625
625
|
}
|
|
626
|
-
function
|
|
626
|
+
function hr(r) {
|
|
627
627
|
for (let t = r.depth; t >= 0; t -= 1) {
|
|
628
628
|
const e = r.node(t), n = r.index(t);
|
|
629
629
|
for (let o = n - 1; o >= 0; o -= 1) {
|
|
@@ -639,7 +639,7 @@ function cr(r) {
|
|
|
639
639
|
break;
|
|
640
640
|
}
|
|
641
641
|
}
|
|
642
|
-
function
|
|
642
|
+
function pr(r) {
|
|
643
643
|
const t = r.depth;
|
|
644
644
|
for (let e = t; e >= 0; e -= 1) {
|
|
645
645
|
const n = r.node(e), o = r.index(e) + (e < t ? 1 : 0);
|
|
@@ -675,22 +675,22 @@ function wt(r, t, e) {
|
|
|
675
675
|
function Bt(r, t) {
|
|
676
676
|
const e = t.node.attrs.controlId, n = r.nodeDOM(t.pos);
|
|
677
677
|
if (n instanceof HTMLElement) {
|
|
678
|
-
if (
|
|
678
|
+
if (bt(n, e))
|
|
679
679
|
return n;
|
|
680
|
-
const o = Array.from(n.querySelectorAll(ot)).find((s) =>
|
|
680
|
+
const o = Array.from(n.querySelectorAll(ot)).find((s) => bt(s, e));
|
|
681
681
|
if (o)
|
|
682
682
|
return o;
|
|
683
683
|
}
|
|
684
|
-
return Array.from(r.dom.querySelectorAll(ot)).find((o) =>
|
|
684
|
+
return Array.from(r.dom.querySelectorAll(ot)).find((o) => bt(o, e));
|
|
685
685
|
}
|
|
686
|
-
function
|
|
686
|
+
function bt(r, t) {
|
|
687
687
|
return r.matches(ot) && r.dataset.controlId === t;
|
|
688
688
|
}
|
|
689
|
-
function
|
|
689
|
+
function fr(r) {
|
|
690
690
|
const t = new Set(r);
|
|
691
691
|
return (e) => !!(t.has(e.type.name) && e.isAtom && typeof e.attrs.controlId == "string" && e.attrs.controlId);
|
|
692
692
|
}
|
|
693
|
-
const
|
|
693
|
+
const mr = new ht("reportControlShortcuts"), O = {
|
|
694
694
|
nextControl: "ArrowRight",
|
|
695
695
|
previousControl: "ArrowLeft",
|
|
696
696
|
openDropdown: "Enter",
|
|
@@ -699,32 +699,32 @@ const fr = new It("reportControlShortcuts"), O = {
|
|
|
699
699
|
previousDropdownOption: "ArrowUp",
|
|
700
700
|
selectDropdownOption: "Enter",
|
|
701
701
|
submitInput: "Enter"
|
|
702
|
-
},
|
|
702
|
+
}, gr = {
|
|
703
703
|
Left: "ArrowLeft",
|
|
704
704
|
Right: "ArrowRight",
|
|
705
705
|
Up: "ArrowUp",
|
|
706
706
|
Down: "ArrowDown",
|
|
707
707
|
Esc: "Escape"
|
|
708
708
|
};
|
|
709
|
-
function
|
|
709
|
+
function ft(r, t = ["structuredField", "dropdownField"], e = t.map(Ir), n) {
|
|
710
710
|
return {
|
|
711
|
-
shortcuts:
|
|
711
|
+
shortcuts: yr(r),
|
|
712
712
|
controlNodeNames: t,
|
|
713
713
|
controlReportNodeNames: e,
|
|
714
714
|
editorGroup: n
|
|
715
715
|
};
|
|
716
716
|
}
|
|
717
|
-
function
|
|
717
|
+
function yr(r = {}) {
|
|
718
718
|
return {
|
|
719
719
|
enabled: r.enabled !== !1,
|
|
720
|
-
nextControl:
|
|
721
|
-
previousControl:
|
|
722
|
-
openDropdown:
|
|
723
|
-
closeDropdown:
|
|
724
|
-
nextDropdownOption:
|
|
725
|
-
previousDropdownOption:
|
|
726
|
-
selectDropdownOption:
|
|
727
|
-
submitInput:
|
|
720
|
+
nextControl: x(r.nextControl) ?? O.nextControl,
|
|
721
|
+
previousControl: x(r.previousControl) ?? O.previousControl,
|
|
722
|
+
openDropdown: x(r.openDropdown) ?? O.openDropdown,
|
|
723
|
+
closeDropdown: x(r.closeDropdown) ?? O.closeDropdown,
|
|
724
|
+
nextDropdownOption: x(r.nextDropdownOption) ?? O.nextDropdownOption,
|
|
725
|
+
previousDropdownOption: x(r.previousDropdownOption) ?? O.previousDropdownOption,
|
|
726
|
+
selectDropdownOption: x(r.selectDropdownOption) ?? O.selectDropdownOption,
|
|
727
|
+
submitInput: x(r.submitInput) ?? O.submitInput,
|
|
728
728
|
autoFocusNextOnEnter: r.autoFocusNextOnEnter !== !1
|
|
729
729
|
};
|
|
730
730
|
}
|
|
@@ -737,10 +737,10 @@ function oe(r, t) {
|
|
|
737
737
|
}
|
|
738
738
|
}
|
|
739
739
|
function P(r, t) {
|
|
740
|
-
return r.defaultPrevented || r.isComposing || r.altKey || r.ctrlKey || r.metaKey || r.shiftKey ? !1 :
|
|
740
|
+
return r.defaultPrevented || r.isComposing || r.altKey || r.ctrlKey || r.metaKey || r.shiftKey ? !1 : x(r.key) === t;
|
|
741
741
|
}
|
|
742
|
-
function
|
|
743
|
-
const t =
|
|
742
|
+
function br(r) {
|
|
743
|
+
const t = x(r.key);
|
|
744
744
|
return t === "ArrowLeft" || t === "ArrowRight";
|
|
745
745
|
}
|
|
746
746
|
function se(r, t, e, n, o = !1) {
|
|
@@ -756,11 +756,11 @@ function se(r, t, e, n, o = !1) {
|
|
|
756
756
|
), l = a.findIndex((d) => d.element === s);
|
|
757
757
|
if (l < 0 || a.length < 2)
|
|
758
758
|
return !1;
|
|
759
|
-
for (const d of
|
|
759
|
+
for (const d of Er(a, l, n))
|
|
760
760
|
return de(r, d.element, e.controlNodeNames), d.focusTarget.focus(), ue(d.focusTarget, n, o), !0;
|
|
761
761
|
return !1;
|
|
762
762
|
}
|
|
763
|
-
function
|
|
763
|
+
function Cr(r, t, e, n, o = !1) {
|
|
764
764
|
if (!e.shortcuts.enabled || !r.editable)
|
|
765
765
|
return !1;
|
|
766
766
|
const s = le(r.dom, e), i = ae(
|
|
@@ -778,14 +778,14 @@ function br(r, t, e, n, o = !1) {
|
|
|
778
778
|
const u = n === "next" ? l[l.length - 1].navigationIndex : l[0].navigationIndex, h = n === "next" ? (u + 1) % i.length : (u - 1 + i.length) % i.length;
|
|
779
779
|
return Lt(r), Ot(r, i[h], e, n, o);
|
|
780
780
|
}
|
|
781
|
-
function
|
|
782
|
-
return
|
|
781
|
+
function Sr(r) {
|
|
782
|
+
return D.create({
|
|
783
783
|
name: "reportControlShortcuts",
|
|
784
784
|
/** 注册处理整节点选中态导航的插件。 */
|
|
785
785
|
addProseMirrorPlugins() {
|
|
786
786
|
return r.shortcuts.enabled ? [
|
|
787
|
-
new
|
|
788
|
-
key:
|
|
787
|
+
new X({
|
|
788
|
+
key: mr,
|
|
789
789
|
props: {
|
|
790
790
|
/** 在控件整节点选中时响应左右导航快捷键。 */
|
|
791
791
|
handleKeyDown(t, e) {
|
|
@@ -794,8 +794,8 @@ function Cr(r) {
|
|
|
794
794
|
return !1;
|
|
795
795
|
if (n instanceof B && r.controlNodeNames.includes(n.node.type.name))
|
|
796
796
|
return se(t, n.from, r, o, !0) ? (e.preventDefault(), !0) : !1;
|
|
797
|
-
const s =
|
|
798
|
-
return s === null || !(n instanceof
|
|
797
|
+
const s = Ke(t.state);
|
|
798
|
+
return s === null || !(n instanceof A) || !n.empty || n.from !== s || !Cr(t, s, r, o, !0) ? !1 : (e.preventDefault(), !0);
|
|
799
799
|
}
|
|
800
800
|
}
|
|
801
801
|
})
|
|
@@ -803,12 +803,12 @@ function Cr(r) {
|
|
|
803
803
|
}
|
|
804
804
|
});
|
|
805
805
|
}
|
|
806
|
-
function
|
|
806
|
+
function x(r) {
|
|
807
807
|
const t = r == null ? void 0 : r.trim();
|
|
808
808
|
if (t)
|
|
809
|
-
return
|
|
809
|
+
return gr[t] ?? t;
|
|
810
810
|
}
|
|
811
|
-
function
|
|
811
|
+
function Ir(r) {
|
|
812
812
|
return r.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase();
|
|
813
813
|
}
|
|
814
814
|
function ie(r, t) {
|
|
@@ -825,7 +825,7 @@ function ae(r, t, e) {
|
|
|
825
825
|
for (const i of s) {
|
|
826
826
|
if (e && !e.some((l) => l.contains(i) || l === i))
|
|
827
827
|
continue;
|
|
828
|
-
const a =
|
|
828
|
+
const a = wr(i);
|
|
829
829
|
a && n.push({ element: i, focusTarget: a });
|
|
830
830
|
}
|
|
831
831
|
return n;
|
|
@@ -837,7 +837,7 @@ function le(r, t) {
|
|
|
837
837
|
const n = e.getEditorElements().filter((o) => o.ownerDocument === r.ownerDocument);
|
|
838
838
|
return n.some((o) => o.contains(r) || o === r) ? n : [];
|
|
839
839
|
}
|
|
840
|
-
function
|
|
840
|
+
function Er(r, t, e) {
|
|
841
841
|
const n = [], o = e === "next" ? 1 : -1;
|
|
842
842
|
for (let s = 1; s < r.length; s += 1) {
|
|
843
843
|
const i = (t + o * s + r.length) % r.length;
|
|
@@ -849,9 +849,9 @@ function de(r, t, e) {
|
|
|
849
849
|
if (!r.dom.contains(t))
|
|
850
850
|
return;
|
|
851
851
|
const n = ie(r.state.doc, e).find((o) => r.nodeDOM(o.pos) === t);
|
|
852
|
-
n &&
|
|
852
|
+
n && Nr(r, n);
|
|
853
853
|
}
|
|
854
|
-
function
|
|
854
|
+
function wr(r) {
|
|
855
855
|
return r.querySelector(
|
|
856
856
|
"input:not([disabled]), textarea:not([disabled]), select:not([disabled])"
|
|
857
857
|
);
|
|
@@ -863,8 +863,8 @@ function Lt(r) {
|
|
|
863
863
|
const t = Je(r.state.tr);
|
|
864
864
|
t.setMeta("addToHistory", !1), r.dispatch(t);
|
|
865
865
|
}
|
|
866
|
-
function
|
|
867
|
-
const e = Math.min(t.pos + t.node.nodeSize, r.state.doc.content.size), n = r.state.tr.setSelection(
|
|
866
|
+
function Nr(r, t) {
|
|
867
|
+
const e = Math.min(t.pos + t.node.nodeSize, r.state.doc.content.size), n = r.state.tr.setSelection(A.near(r.state.doc.resolve(e), 1));
|
|
868
868
|
n.setMeta("addToHistory", !1), r.dispatch(n);
|
|
869
869
|
}
|
|
870
870
|
function ue(r, t, e) {
|
|
@@ -877,22 +877,22 @@ function ue(r, t, e) {
|
|
|
877
877
|
}
|
|
878
878
|
}
|
|
879
879
|
const ce = /* @__PURE__ */ new WeakMap();
|
|
880
|
-
function
|
|
881
|
-
const e =
|
|
880
|
+
function Ct(r, t) {
|
|
881
|
+
const e = mt(r), n = new Set((e == null ? void 0 : e.controlIds) ?? []);
|
|
882
882
|
for (const o of t)
|
|
883
883
|
o.trim() && n.add(o);
|
|
884
884
|
return n.size === 0 || ce.set(r, {
|
|
885
885
|
controlIds: Array.from(n)
|
|
886
886
|
}), r;
|
|
887
887
|
}
|
|
888
|
-
function
|
|
888
|
+
function mt(r) {
|
|
889
889
|
return ce.get(r);
|
|
890
890
|
}
|
|
891
891
|
function he(r) {
|
|
892
892
|
const t = r.filter((e) => e.docChanged);
|
|
893
|
-
return t.length > 0 && t.every((e) => !!
|
|
893
|
+
return t.length > 0 && t.every((e) => !!mt(e));
|
|
894
894
|
}
|
|
895
|
-
function
|
|
895
|
+
function vr(r) {
|
|
896
896
|
return r === null || typeof r == "string" || typeof r == "boolean" || typeof r == "number" && Number.isFinite(r);
|
|
897
897
|
}
|
|
898
898
|
function F(r) {
|
|
@@ -936,7 +936,7 @@ class at {
|
|
|
936
936
|
}
|
|
937
937
|
class pe {
|
|
938
938
|
/** 创建控件根 DOM 并绑定通用交互事件。 */
|
|
939
|
-
constructor(t, e, n =
|
|
939
|
+
constructor(t, e, n = ft()) {
|
|
940
940
|
p(this, "dom");
|
|
941
941
|
p(this, "node");
|
|
942
942
|
p(this, "selected", !1);
|
|
@@ -983,7 +983,7 @@ class pe {
|
|
|
983
983
|
...this.node.attrs,
|
|
984
984
|
value: t
|
|
985
985
|
}, this.node.marks);
|
|
986
|
-
n.trim() && o.trim() && (s =
|
|
986
|
+
n.trim() && o.trim() && (s = Ct(s, [n])), this.props.view.dispatch(s);
|
|
987
987
|
}
|
|
988
988
|
/** 完成当前输入,并按配置跳转到下一个控件。 */
|
|
989
989
|
completeInputAndMaybeFocusNext(t) {
|
|
@@ -1053,7 +1053,7 @@ class pe {
|
|
|
1053
1053
|
const { state: e } = this.props.view;
|
|
1054
1054
|
if (e.selection.empty && !(e.selection instanceof B))
|
|
1055
1055
|
return;
|
|
1056
|
-
const n = Math.min(t + this.node.nodeSize, e.doc.content.size), o = e.tr.setSelection(
|
|
1056
|
+
const n = Math.min(t + this.node.nodeSize, e.doc.content.size), o = e.tr.setSelection(A.near(e.doc.resolve(n), 1));
|
|
1057
1057
|
o.setMeta("addToHistory", !1), this.props.view.dispatch(o);
|
|
1058
1058
|
}
|
|
1059
1059
|
/** 判断鼠标事件是否应该触发整节点选择。 */
|
|
@@ -1062,7 +1062,7 @@ class pe {
|
|
|
1062
1062
|
}
|
|
1063
1063
|
/** 判断方向键是否已经到达输入边界并可跳转控件。 */
|
|
1064
1064
|
shouldNavigateFromInteractiveTarget(t) {
|
|
1065
|
-
if (!
|
|
1065
|
+
if (!br(t))
|
|
1066
1066
|
return !0;
|
|
1067
1067
|
const e = t.target;
|
|
1068
1068
|
if (!(e instanceof HTMLInputElement) && !(e instanceof HTMLTextAreaElement))
|
|
@@ -1080,7 +1080,7 @@ class pe {
|
|
|
1080
1080
|
}
|
|
1081
1081
|
/** 生成控件 HTML 和纯文本并写入剪贴板。 */
|
|
1082
1082
|
writeControlToClipboard(t) {
|
|
1083
|
-
const e = this.clipboardText(), n =
|
|
1083
|
+
const e = this.clipboardText(), n = Fe.fromSchema(this.node.type.schema).serializeNode(
|
|
1084
1084
|
this.node,
|
|
1085
1085
|
{ document: this.dom.ownerDocument }
|
|
1086
1086
|
);
|
|
@@ -1093,27 +1093,28 @@ class pe {
|
|
|
1093
1093
|
}
|
|
1094
1094
|
return at.write(t, o, e);
|
|
1095
1095
|
}
|
|
1096
|
-
/** Deletes an empty control
|
|
1096
|
+
/** Deletes an empty control from its input shortcut. */
|
|
1097
1097
|
deleteEmptyControlFromInput(t) {
|
|
1098
1098
|
if (t.isComposing || t.altKey || t.ctrlKey || t.metaKey || t.shiftKey || t.key !== "Backspace" && t.key !== "Delete")
|
|
1099
1099
|
return !1;
|
|
1100
1100
|
const e = t.target;
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1101
|
+
return !(e instanceof HTMLInputElement) || e.value.length !== 0 || e.selectionStart !== 0 || e.selectionEnd !== 0 || typeof this.props.getPos() != "number" ? !1 : (t.preventDefault(), t.stopPropagation(), this.removeControlAndRestoreCaret());
|
|
1102
|
+
}
|
|
1103
|
+
/** Removes this control and restores the editor caret at its former document position. */
|
|
1104
|
+
removeControlAndRestoreCaret() {
|
|
1105
|
+
const t = this.props.getPos();
|
|
1106
|
+
if (typeof t != "number")
|
|
1105
1107
|
return !1;
|
|
1106
|
-
t.
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
) && je(o, s), this.props.view.dispatch(o), this.props.view.focus(), !0;
|
|
1108
|
+
const e = this.props.view.state.tr.delete(t, t + this.node.nodeSize), n = Math.min(t, e.doc.content.size), o = e.doc.resolve(n), s = o.parent.inlineContent ? A.create(e.doc, n) : A.near(o, 1);
|
|
1109
|
+
return e.setSelection(s).scrollIntoView(), o.parent.inlineContent && [o.nodeBefore, o.nodeAfter].some(
|
|
1110
|
+
(i) => i ? this.controlShortcutRuntime.controlNodeNames.includes(i.type.name) : !1
|
|
1111
|
+
) && We(e, n), this.props.view.dispatch(e), this.props.view.focus(), !0;
|
|
1111
1112
|
}
|
|
1112
1113
|
/** 允许子类追加节点特有的剪贴板属性。 */
|
|
1113
1114
|
decorateClipboardElement(t) {
|
|
1114
1115
|
}
|
|
1115
1116
|
}
|
|
1116
|
-
const Ft = "--hmg-report-editor-control-auto-width",
|
|
1117
|
+
const Ft = "--hmg-report-editor-control-auto-width", Tr = 1, Ar = 1, Vt = 2, Mr = [
|
|
1117
1118
|
"font",
|
|
1118
1119
|
"font-family",
|
|
1119
1120
|
"font-feature-settings",
|
|
@@ -1132,16 +1133,16 @@ const Ft = "--hmg-report-editor-control-auto-width", vr = 1, Ar = 1, Vt = 2, Tr
|
|
|
1132
1133
|
"word-spacing"
|
|
1133
1134
|
];
|
|
1134
1135
|
function fe(r, t) {
|
|
1135
|
-
const e = r.value || " ", n =
|
|
1136
|
+
const e = r.value || " ", n = kr(r, e), o = n === null ? `calc(${Math.max(Dr(e), Tr)}ch + ${Vt}px)` : `${Math.ceil(Math.max(n, Ar) + Vt)}px`;
|
|
1136
1137
|
t.style.getPropertyValue(Ft) !== o && t.style.setProperty(Ft, o);
|
|
1137
1138
|
}
|
|
1138
|
-
function
|
|
1139
|
+
function kr(r, t) {
|
|
1139
1140
|
const e = r.ownerDocument, n = e.body;
|
|
1140
1141
|
if (!n)
|
|
1141
1142
|
return null;
|
|
1142
1143
|
const o = e.createElement("span"), s = e.defaultView, i = s == null ? void 0 : s.getComputedStyle(r);
|
|
1143
1144
|
if (i)
|
|
1144
|
-
for (const l of
|
|
1145
|
+
for (const l of Mr) {
|
|
1145
1146
|
const d = i.getPropertyValue(l);
|
|
1146
1147
|
d && o.style.setProperty(l, d);
|
|
1147
1148
|
}
|
|
@@ -1149,7 +1150,7 @@ function Mr(r, t) {
|
|
|
1149
1150
|
const a = o.getBoundingClientRect().width;
|
|
1150
1151
|
return o.remove(), Number.isFinite(a) && a > 0 ? a : null;
|
|
1151
1152
|
}
|
|
1152
|
-
function
|
|
1153
|
+
function Dr(r) {
|
|
1153
1154
|
let t = 0;
|
|
1154
1155
|
for (const e of r) {
|
|
1155
1156
|
const n = e.codePointAt(0) ?? 0;
|
|
@@ -1157,7 +1158,7 @@ function kr(r) {
|
|
|
1157
1158
|
}
|
|
1158
1159
|
return t;
|
|
1159
1160
|
}
|
|
1160
|
-
class
|
|
1161
|
+
class xr extends pe {
|
|
1161
1162
|
/** 创建输入框和菜单 DOM。 */
|
|
1162
1163
|
constructor(e, n) {
|
|
1163
1164
|
super(e, "dropdownField", n);
|
|
@@ -1221,13 +1222,16 @@ class Dr extends pe {
|
|
|
1221
1222
|
/** 渲染下拉选项菜单并绑定选项提交。 */
|
|
1222
1223
|
renderMenu(e, n) {
|
|
1223
1224
|
this.menu.innerHTML = "";
|
|
1224
|
-
for (const [
|
|
1225
|
-
const
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
}), this.menu.append(
|
|
1225
|
+
for (const [s, i] of e.entries()) {
|
|
1226
|
+
const a = document.createElement("button");
|
|
1227
|
+
a.type = "button", a.className = "hmg-dropdown-field__option", a.textContent = i.label, a.setAttribute("role", "option"), a.setAttribute("data-value", i.value), a.setAttribute("aria-selected", String(i.value === n)), a.toggleAttribute("data-active", this.activeOptionIndex === s), a.addEventListener("mousedown", (l) => {
|
|
1228
|
+
l.preventDefault(), this.commitValue(i.value), this.input.focus(), this.setOpen(!1);
|
|
1229
|
+
}), this.menu.append(a);
|
|
1229
1230
|
}
|
|
1230
|
-
|
|
1231
|
+
const o = document.createElement("button");
|
|
1232
|
+
o.type = "button", o.className = "hmg-dropdown-field__delete", o.textContent = "删除", o.setAttribute("aria-label", "删除下拉控件"), o.addEventListener("mousedown", (s) => {
|
|
1233
|
+
s.preventDefault(), s.stopPropagation(), this.setOpen(!1), this.removeControlAndRestoreCaret();
|
|
1234
|
+
}), this.menu.append(o), this.menu.classList.toggle("hmg-dropdown-field__menu--empty", e.length === 0), this.syncActiveOptionState();
|
|
1231
1235
|
}
|
|
1232
1236
|
/** 切换菜单展开状态。 */
|
|
1233
1237
|
setOpen(e) {
|
|
@@ -1348,7 +1352,7 @@ class Dr extends pe {
|
|
|
1348
1352
|
return $(e);
|
|
1349
1353
|
}
|
|
1350
1354
|
}
|
|
1351
|
-
class
|
|
1355
|
+
class Pr extends pe {
|
|
1352
1356
|
/** 创建文本输入框并绑定值提交事件。 */
|
|
1353
1357
|
constructor(e, n) {
|
|
1354
1358
|
super(e, "structuredField", n);
|
|
@@ -1399,7 +1403,7 @@ function Rt(r) {
|
|
|
1399
1403
|
return [];
|
|
1400
1404
|
}
|
|
1401
1405
|
}
|
|
1402
|
-
function
|
|
1406
|
+
function Br(r) {
|
|
1403
1407
|
if (Array.isArray(r))
|
|
1404
1408
|
return r;
|
|
1405
1409
|
if (typeof r != "string" || !r.trim())
|
|
@@ -1411,7 +1415,7 @@ function Pr(r) {
|
|
|
1411
1415
|
return [];
|
|
1412
1416
|
}
|
|
1413
1417
|
}
|
|
1414
|
-
const
|
|
1418
|
+
const Or = ut.create({
|
|
1415
1419
|
name: "dropdownField",
|
|
1416
1420
|
group: "inline",
|
|
1417
1421
|
inline: !0,
|
|
@@ -1420,7 +1424,7 @@ const Br = ut.create({
|
|
|
1420
1424
|
/** 提供控件快捷键运行时默认值。 */
|
|
1421
1425
|
addOptions() {
|
|
1422
1426
|
return {
|
|
1423
|
-
controlShortcutRuntime:
|
|
1427
|
+
controlShortcutRuntime: ft()
|
|
1424
1428
|
};
|
|
1425
1429
|
},
|
|
1426
1430
|
/** 声明从 HTML 读取和保存的下拉控件属性。 */
|
|
@@ -1476,7 +1480,7 @@ const Br = ut.create({
|
|
|
1476
1480
|
},
|
|
1477
1481
|
rules: {
|
|
1478
1482
|
default: [],
|
|
1479
|
-
parseHTML: (r) =>
|
|
1483
|
+
parseHTML: (r) => Br(r.getAttribute("data-rules")),
|
|
1480
1484
|
renderHTML: (r) => ({
|
|
1481
1485
|
"data-rules": JSON.stringify(r.rules ?? [])
|
|
1482
1486
|
})
|
|
@@ -1513,7 +1517,7 @@ const Br = ut.create({
|
|
|
1513
1517
|
},
|
|
1514
1518
|
/** 渲染下拉控件的静态 HTML 表示。 */
|
|
1515
1519
|
renderHTML({ HTMLAttributes: r }) {
|
|
1516
|
-
const e = Rt(r.options ?? r["data-options"]).find((s) => s.value === String(r.value ?? "")), n = (e == null ? void 0 : e.label) ?? (z.isEmpty(r.value) ? r.placeholder : r.value), o =
|
|
1520
|
+
const e = Rt(r.options ?? r["data-options"]).find((s) => s.value === String(r.value ?? "")), n = (e == null ? void 0 : e.label) ?? (z.isEmpty(r.value) ? r.placeholder : r.value), o = M.sanitize("color", r.ruleStyleColor);
|
|
1517
1521
|
return [
|
|
1518
1522
|
"span",
|
|
1519
1523
|
ct(r, {
|
|
@@ -1544,7 +1548,7 @@ const Br = ut.create({
|
|
|
1544
1548
|
},
|
|
1545
1549
|
/** 使用自定义 NodeView 提供可输入、可展开的下拉体验。 */
|
|
1546
1550
|
addNodeView() {
|
|
1547
|
-
return (r) => new
|
|
1551
|
+
return (r) => new xr(r, this.options.controlShortcutRuntime);
|
|
1548
1552
|
},
|
|
1549
1553
|
/** 注册插入下拉控件的 Tiptap 命令。 */
|
|
1550
1554
|
addCommands() {
|
|
@@ -1555,7 +1559,7 @@ const Br = ut.create({
|
|
|
1555
1559
|
})
|
|
1556
1560
|
};
|
|
1557
1561
|
}
|
|
1558
|
-
}),
|
|
1562
|
+
}), Lr = D.create({
|
|
1559
1563
|
name: "fontSize",
|
|
1560
1564
|
/** 声明字号全局属性的 HTML 解析和渲染规则。 */
|
|
1561
1565
|
addGlobalAttributes() {
|
|
@@ -1565,9 +1569,9 @@ const Br = ut.create({
|
|
|
1565
1569
|
attributes: {
|
|
1566
1570
|
fontSize: {
|
|
1567
1571
|
default: null,
|
|
1568
|
-
parseHTML: (r) =>
|
|
1572
|
+
parseHTML: (r) => M.sanitize("font-size", r.style.fontSize) ?? null,
|
|
1569
1573
|
renderHTML: (r) => {
|
|
1570
|
-
const t =
|
|
1574
|
+
const t = M.sanitize("font-size", r.fontSize);
|
|
1571
1575
|
return t ? {
|
|
1572
1576
|
style: `font-size: ${t}`
|
|
1573
1577
|
} : {};
|
|
@@ -1580,11 +1584,11 @@ const Br = ut.create({
|
|
|
1580
1584
|
/** 注册设置和清除字号的命令。 */
|
|
1581
1585
|
addCommands() {
|
|
1582
1586
|
return {
|
|
1583
|
-
setFontSize: (r) => ({ chain: t }) =>
|
|
1587
|
+
setFontSize: (r) => ({ chain: t }) => M.sanitize("font-size", r) ? t().setMark("textStyle", { fontSize: r }).run() : !1,
|
|
1584
1588
|
unsetFontSize: () => ({ chain: r }) => r().setMark("textStyle", { fontSize: null }).removeEmptyTextStyle().run()
|
|
1585
1589
|
};
|
|
1586
1590
|
}
|
|
1587
|
-
}),
|
|
1591
|
+
}), Fr = D.create({
|
|
1588
1592
|
name: "hiddenParagraph",
|
|
1589
1593
|
/** 声明段落 hidden 属性的 HTML 解析和渲染规则。 */
|
|
1590
1594
|
addGlobalAttributes() {
|
|
@@ -1631,13 +1635,13 @@ const Br = ut.create({
|
|
|
1631
1635
|
}
|
|
1632
1636
|
};
|
|
1633
1637
|
}
|
|
1634
|
-
}),
|
|
1635
|
-
function
|
|
1636
|
-
return Math.max(
|
|
1638
|
+
}), Vr = 0, Rr = 8, zr = ["paragraph", "listItem", "reportNumberedBlock"];
|
|
1639
|
+
function $r(r) {
|
|
1640
|
+
return Math.max(Vr, Math.min(Rr, r));
|
|
1637
1641
|
}
|
|
1638
|
-
function me(r =
|
|
1642
|
+
function me(r = zr) {
|
|
1639
1643
|
const t = Array.from(new Set(r));
|
|
1640
|
-
return
|
|
1644
|
+
return D.create({
|
|
1641
1645
|
name: "indentation",
|
|
1642
1646
|
/** 声明缩进属性的 HTML 解析和渲染规则。 */
|
|
1643
1647
|
addGlobalAttributes() {
|
|
@@ -1667,7 +1671,7 @@ function me(r = Rr) {
|
|
|
1667
1671
|
let a = !1;
|
|
1668
1672
|
return o.doc.nodesBetween(o.selection.from, o.selection.to, (l, d) => {
|
|
1669
1673
|
if (t.includes(l.type.name)) {
|
|
1670
|
-
const u = Number(l.attrs.indent ?? 0), h =
|
|
1674
|
+
const u = Number(l.attrs.indent ?? 0), h = $r(n(u));
|
|
1671
1675
|
i.setNodeMarkup(d, void 0, { ...l.attrs, indent: h }), a = !0;
|
|
1672
1676
|
}
|
|
1673
1677
|
}), a && s && s(i), a;
|
|
@@ -1681,10 +1685,10 @@ function me(r = Rr) {
|
|
|
1681
1685
|
});
|
|
1682
1686
|
}
|
|
1683
1687
|
me();
|
|
1684
|
-
const
|
|
1685
|
-
function ge(r =
|
|
1688
|
+
const _r = ["paragraph", "listItem", "reportNumberedBlock"];
|
|
1689
|
+
function ge(r = _r) {
|
|
1686
1690
|
const t = Array.from(new Set(r));
|
|
1687
|
-
return
|
|
1691
|
+
return D.create({
|
|
1688
1692
|
name: "lineHeight",
|
|
1689
1693
|
/** 声明行高属性的 HTML 解析和渲染规则。 */
|
|
1690
1694
|
addGlobalAttributes() {
|
|
@@ -1694,9 +1698,9 @@ function ge(r = $r) {
|
|
|
1694
1698
|
attributes: {
|
|
1695
1699
|
lineHeight: {
|
|
1696
1700
|
default: null,
|
|
1697
|
-
parseHTML: (e) =>
|
|
1701
|
+
parseHTML: (e) => M.sanitize("line-height", e.style.lineHeight) ?? null,
|
|
1698
1702
|
renderHTML: (e) => {
|
|
1699
|
-
const n =
|
|
1703
|
+
const n = M.sanitize("line-height", e.lineHeight);
|
|
1700
1704
|
return n ? {
|
|
1701
1705
|
style: `line-height: ${n}`
|
|
1702
1706
|
} : {};
|
|
@@ -1709,7 +1713,7 @@ function ge(r = $r) {
|
|
|
1709
1713
|
/** 注册设置和清除行高的命令。 */
|
|
1710
1714
|
addCommands() {
|
|
1711
1715
|
const e = (n) => ({ state: o, dispatch: s }) => {
|
|
1712
|
-
if (n !== null && !
|
|
1716
|
+
if (n !== null && !M.sanitize("line-height", n))
|
|
1713
1717
|
return !1;
|
|
1714
1718
|
const i = o.tr;
|
|
1715
1719
|
let a = !1;
|
|
@@ -1726,7 +1730,7 @@ function ge(r = $r) {
|
|
|
1726
1730
|
});
|
|
1727
1731
|
}
|
|
1728
1732
|
ge();
|
|
1729
|
-
const
|
|
1733
|
+
const k = "pageBreak";
|
|
1730
1734
|
function q(r = /* @__PURE__ */ new Set()) {
|
|
1731
1735
|
let t = zt();
|
|
1732
1736
|
for (; r.has(t); )
|
|
@@ -1746,7 +1750,7 @@ class ye {
|
|
|
1746
1750
|
collectTransactionUpdates(t) {
|
|
1747
1751
|
const e = /* @__PURE__ */ new Set(), n = [];
|
|
1748
1752
|
return t.descendants((o, s) => {
|
|
1749
|
-
if (o.type.name !==
|
|
1753
|
+
if (o.type.name !== k)
|
|
1750
1754
|
return;
|
|
1751
1755
|
const i = this.getId(o.attrs);
|
|
1752
1756
|
if (!i || e.has(i)) {
|
|
@@ -1769,7 +1773,7 @@ class ye {
|
|
|
1769
1773
|
n.setMeta("addToHistory", !1);
|
|
1770
1774
|
for (const o of e) {
|
|
1771
1775
|
const s = n.doc.nodeAt(o.pos);
|
|
1772
|
-
(s == null ? void 0 : s.type.name) ===
|
|
1776
|
+
(s == null ? void 0 : s.type.name) === k && n.setNodeMarkup(o.pos, void 0, {
|
|
1773
1777
|
...s.attrs,
|
|
1774
1778
|
id: o.id
|
|
1775
1779
|
}, s.marks);
|
|
@@ -1780,7 +1784,7 @@ class ye {
|
|
|
1780
1784
|
normalizeReportNodes(t, e) {
|
|
1781
1785
|
return t.map((n) => {
|
|
1782
1786
|
const o = n.content ? this.normalizeReportNodes(n.content, e) : void 0;
|
|
1783
|
-
if (n.type !==
|
|
1787
|
+
if (n.type !== k)
|
|
1784
1788
|
return {
|
|
1785
1789
|
...n,
|
|
1786
1790
|
...o ? { content: o } : {}
|
|
@@ -1797,14 +1801,14 @@ class ye {
|
|
|
1797
1801
|
const e = [];
|
|
1798
1802
|
return t.forEach((n) => {
|
|
1799
1803
|
e.push(this.assignFreshIdsToNode(n));
|
|
1800
|
-
}),
|
|
1804
|
+
}), It.fromArray(e);
|
|
1801
1805
|
}
|
|
1802
1806
|
/** 刷新单个节点及其子树中的分页符 ID。 */
|
|
1803
1807
|
assignFreshIdsToNode(t) {
|
|
1804
1808
|
if (t.isText)
|
|
1805
1809
|
return t;
|
|
1806
1810
|
const e = t.content.size > 0 ? this.assignFreshIdsToFragment(t.content) : t.content;
|
|
1807
|
-
return t.type.name ===
|
|
1811
|
+
return t.type.name === k ? t.type.create(
|
|
1808
1812
|
{
|
|
1809
1813
|
...t.attrs,
|
|
1810
1814
|
id: q()
|
|
@@ -1823,7 +1827,7 @@ function zt() {
|
|
|
1823
1827
|
const r = globalThis.crypto;
|
|
1824
1828
|
return r != null && r.randomUUID ? `page_break_${r.randomUUID()}` : `page_break_${Date.now().toString(36)}_${Math.random().toString(36).slice(2)}`;
|
|
1825
1829
|
}
|
|
1826
|
-
class
|
|
1830
|
+
class Hr {
|
|
1827
1831
|
constructor(t) {
|
|
1828
1832
|
p(this, "dom");
|
|
1829
1833
|
p(this, "node");
|
|
@@ -1849,11 +1853,11 @@ class _r {
|
|
|
1849
1853
|
/** 渲染编辑态分隔线和提示文本。 */
|
|
1850
1854
|
render() {
|
|
1851
1855
|
const t = String(this.node.attrs.id ?? "");
|
|
1852
|
-
this.dom.className = "
|
|
1856
|
+
this.dom.className = "hmg-page-break", this.dom.id = t, this.dom.dataset.editor2Id = t, this.dom.innerHTML = '<span class="hmg-page-break__label">报告将在此处分页</span>', this.dom.classList.toggle("hmg-page-break--selected", this.selected);
|
|
1853
1857
|
}
|
|
1854
1858
|
}
|
|
1855
|
-
const
|
|
1856
|
-
name:
|
|
1859
|
+
const Gr = ut.create({
|
|
1860
|
+
name: k,
|
|
1857
1861
|
group: "inline",
|
|
1858
1862
|
inline: !0,
|
|
1859
1863
|
atom: !0,
|
|
@@ -1879,7 +1883,7 @@ const Hr = ut.create({
|
|
|
1879
1883
|
},
|
|
1880
1884
|
/** 编辑态显示整行提示,保存时仍使用节点 renderHTML。 */
|
|
1881
1885
|
addNodeView() {
|
|
1882
|
-
return (r) => new
|
|
1886
|
+
return (r) => new Hr(r);
|
|
1883
1887
|
},
|
|
1884
1888
|
/** 注册分页符插入和删除命令。 */
|
|
1885
1889
|
addCommands() {
|
|
@@ -1904,7 +1908,7 @@ const Hr = ut.create({
|
|
|
1904
1908
|
const a = t.schema.nodes.paragraph;
|
|
1905
1909
|
if (!a)
|
|
1906
1910
|
return !1;
|
|
1907
|
-
const l = a.create(null, i), d =
|
|
1911
|
+
const l = a.create(null, i), d = Ve(t.doc, s.to, a);
|
|
1908
1912
|
if (d === null)
|
|
1909
1913
|
return !1;
|
|
1910
1914
|
if (o) {
|
|
@@ -1935,16 +1939,16 @@ function be(r, t, e) {
|
|
|
1935
1939
|
if (t) {
|
|
1936
1940
|
let i;
|
|
1937
1941
|
return r.state.doc.descendants((a, l) => {
|
|
1938
|
-
i === void 0 && a.type.name ===
|
|
1942
|
+
i === void 0 && a.type.name === k && a.attrs.id === t && (i = l);
|
|
1939
1943
|
}), i;
|
|
1940
1944
|
}
|
|
1941
1945
|
const { selection: n } = r.state;
|
|
1942
|
-
if (n instanceof B && n.node.type.name ===
|
|
1946
|
+
if (n instanceof B && n.node.type.name === k)
|
|
1943
1947
|
return n.from;
|
|
1944
1948
|
if (!(!n.empty || e === void 0)) {
|
|
1945
|
-
if (e < 0 && ((o = n.$from.nodeBefore) == null ? void 0 : o.type.name) ===
|
|
1949
|
+
if (e < 0 && ((o = n.$from.nodeBefore) == null ? void 0 : o.type.name) === k)
|
|
1946
1950
|
return n.from - n.$from.nodeBefore.nodeSize;
|
|
1947
|
-
if (e > 0 && ((s = n.$from.nodeAfter) == null ? void 0 : s.type.name) ===
|
|
1951
|
+
if (e > 0 && ((s = n.$from.nodeAfter) == null ? void 0 : s.type.name) === k)
|
|
1948
1952
|
return n.from;
|
|
1949
1953
|
}
|
|
1950
1954
|
}
|
|
@@ -1959,7 +1963,7 @@ function $t(r, t) {
|
|
|
1959
1963
|
}
|
|
1960
1964
|
function Ce(r, t, e, n, o) {
|
|
1961
1965
|
const { state: s } = r, i = t.doc.nodeAt(e);
|
|
1962
|
-
if ((i == null ? void 0 : i.type.name) !==
|
|
1966
|
+
if ((i == null ? void 0 : i.type.name) !== k)
|
|
1963
1967
|
return !1;
|
|
1964
1968
|
if (!o)
|
|
1965
1969
|
return !0;
|
|
@@ -1972,7 +1976,7 @@ function Ce(r, t, e, n, o) {
|
|
|
1972
1976
|
t.delete(e, e + i.nodeSize);
|
|
1973
1977
|
return u = Math.max(0, Math.min(u, t.doc.content.size)), t.setSelection(W.near(t.doc.resolve(u), n)), t.scrollIntoView(), !0;
|
|
1974
1978
|
}
|
|
1975
|
-
const
|
|
1979
|
+
const Ur = ut.create({
|
|
1976
1980
|
name: "reportNumberedBlock",
|
|
1977
1981
|
group: "block",
|
|
1978
1982
|
content: "inline*",
|
|
@@ -2033,7 +2037,7 @@ const Gr = ut.create({
|
|
|
2033
2037
|
};
|
|
2034
2038
|
}
|
|
2035
2039
|
});
|
|
2036
|
-
function
|
|
2040
|
+
function qr(r) {
|
|
2037
2041
|
if (Array.isArray(r))
|
|
2038
2042
|
return r;
|
|
2039
2043
|
if (typeof r != "string" || !r.trim())
|
|
@@ -2045,7 +2049,7 @@ function Ur(r) {
|
|
|
2045
2049
|
return [];
|
|
2046
2050
|
}
|
|
2047
2051
|
}
|
|
2048
|
-
const
|
|
2052
|
+
const jr = ut.create({
|
|
2049
2053
|
name: "structuredField",
|
|
2050
2054
|
group: "inline",
|
|
2051
2055
|
inline: !0,
|
|
@@ -2054,7 +2058,7 @@ const qr = ut.create({
|
|
|
2054
2058
|
/** 提供控件快捷键运行时默认值。 */
|
|
2055
2059
|
addOptions() {
|
|
2056
2060
|
return {
|
|
2057
|
-
controlShortcutRuntime:
|
|
2061
|
+
controlShortcutRuntime: ft()
|
|
2058
2062
|
};
|
|
2059
2063
|
},
|
|
2060
2064
|
/** 声明从 HTML 读取和保存的控件属性。 */
|
|
@@ -2110,7 +2114,7 @@ const qr = ut.create({
|
|
|
2110
2114
|
},
|
|
2111
2115
|
rules: {
|
|
2112
2116
|
default: [],
|
|
2113
|
-
parseHTML: (r) =>
|
|
2117
|
+
parseHTML: (r) => qr(r.getAttribute("data-rules")),
|
|
2114
2118
|
renderHTML: (r) => ({
|
|
2115
2119
|
"data-rules": JSON.stringify(r.rules ?? [])
|
|
2116
2120
|
})
|
|
@@ -2136,7 +2140,7 @@ const qr = ut.create({
|
|
|
2136
2140
|
},
|
|
2137
2141
|
/** 渲染结构化输入控件的静态 HTML 表示。 */
|
|
2138
2142
|
renderHTML({ HTMLAttributes: r }) {
|
|
2139
|
-
const t = z.isEmpty(r.value) ? r.placeholder : r.value, e =
|
|
2143
|
+
const t = z.isEmpty(r.value) ? r.placeholder : r.value, e = M.sanitize("color", r.ruleStyleColor);
|
|
2140
2144
|
return [
|
|
2141
2145
|
"span",
|
|
2142
2146
|
ct(r, {
|
|
@@ -2166,7 +2170,7 @@ const qr = ut.create({
|
|
|
2166
2170
|
},
|
|
2167
2171
|
/** 使用自定义 NodeView 提供可编辑输入框体验。 */
|
|
2168
2172
|
addNodeView() {
|
|
2169
|
-
return (r) => new
|
|
2173
|
+
return (r) => new Pr(r, this.options.controlShortcutRuntime);
|
|
2170
2174
|
},
|
|
2171
2175
|
/** 注册插入结构化输入控件的 Tiptap 命令。 */
|
|
2172
2176
|
addCommands() {
|
|
@@ -2177,7 +2181,41 @@ const qr = ut.create({
|
|
|
2177
2181
|
})
|
|
2178
2182
|
};
|
|
2179
2183
|
}
|
|
2180
|
-
}),
|
|
2184
|
+
}), Wr = ["paragraph", "listItem", "reportNumberedBlock"], Kr = " ", Jr = new ht("reportTabIndentation");
|
|
2185
|
+
function Xr(r, t) {
|
|
2186
|
+
for (let e = r.$from.depth; e > 0; e -= 1)
|
|
2187
|
+
if (t.has(r.$from.node(e).type.name))
|
|
2188
|
+
return r.$from.start(e);
|
|
2189
|
+
}
|
|
2190
|
+
function Yr(r, t) {
|
|
2191
|
+
const e = Xr(r, t);
|
|
2192
|
+
if (e === void 0) return !1;
|
|
2193
|
+
const n = r.$from.doc.textBetween(e, r.from, "", "");
|
|
2194
|
+
return /^\u3000*$/.test(n);
|
|
2195
|
+
}
|
|
2196
|
+
function Se(r = Wr) {
|
|
2197
|
+
const t = new Set(r);
|
|
2198
|
+
return D.create({
|
|
2199
|
+
name: "reportTabIndentation",
|
|
2200
|
+
addProseMirrorPlugins() {
|
|
2201
|
+
return [
|
|
2202
|
+
new X({
|
|
2203
|
+
key: Jr,
|
|
2204
|
+
props: {
|
|
2205
|
+
handleKeyDown(e, n) {
|
|
2206
|
+
if (!e.editable || n.defaultPrevented || n.isComposing || n.key !== "Tab" || n.shiftKey || n.altKey || n.ctrlKey || n.metaKey || !(e.state.selection instanceof A))
|
|
2207
|
+
return !1;
|
|
2208
|
+
const o = e.state.selection, s = Yr(o, t) ? Kr : " ", i = o.from, a = e.state.tr.insertText(s, o.from, o.to), l = Math.min(i + s.length, a.doc.content.size);
|
|
2209
|
+
return a.setSelection(A.create(a.doc, l)), e.dispatch(a.scrollIntoView()), n.preventDefault(), !0;
|
|
2210
|
+
}
|
|
2211
|
+
}
|
|
2212
|
+
})
|
|
2213
|
+
];
|
|
2214
|
+
}
|
|
2215
|
+
});
|
|
2216
|
+
}
|
|
2217
|
+
Se();
|
|
2218
|
+
const Zr = Pe.create({
|
|
2181
2219
|
name: I,
|
|
2182
2220
|
inclusive: !1,
|
|
2183
2221
|
keepOnSplit: !1,
|
|
@@ -2219,16 +2257,16 @@ const qr = ut.create({
|
|
|
2219
2257
|
0
|
|
2220
2258
|
];
|
|
2221
2259
|
}
|
|
2222
|
-
}), j = new
|
|
2260
|
+
}), j = new ht(
|
|
2223
2261
|
"reportControlSelectionLifecycle"
|
|
2224
|
-
),
|
|
2225
|
-
function
|
|
2262
|
+
), Qr = "hmg-control-range-selected";
|
|
2263
|
+
function tn(r) {
|
|
2226
2264
|
const t = new Set(r);
|
|
2227
|
-
return
|
|
2265
|
+
return D.create({
|
|
2228
2266
|
name: "reportControlSelectionLifecycle",
|
|
2229
2267
|
addProseMirrorPlugins() {
|
|
2230
2268
|
return [
|
|
2231
|
-
new
|
|
2269
|
+
new X({
|
|
2232
2270
|
key: j,
|
|
2233
2271
|
state: {
|
|
2234
2272
|
init: (e, n) => ({
|
|
@@ -2250,10 +2288,10 @@ function Jr(r) {
|
|
|
2250
2288
|
},
|
|
2251
2289
|
handleDOMEvents: {
|
|
2252
2290
|
focus(e) {
|
|
2253
|
-
return
|
|
2291
|
+
return rn(e, !0), !1;
|
|
2254
2292
|
},
|
|
2255
2293
|
blur(e) {
|
|
2256
|
-
return
|
|
2294
|
+
return en(e, t, !1), !1;
|
|
2257
2295
|
}
|
|
2258
2296
|
}
|
|
2259
2297
|
}
|
|
@@ -2262,15 +2300,15 @@ function Jr(r) {
|
|
|
2262
2300
|
}
|
|
2263
2301
|
});
|
|
2264
2302
|
}
|
|
2265
|
-
function
|
|
2303
|
+
function en(r, t, e) {
|
|
2266
2304
|
const { selection: n } = r.state, o = r.state.tr;
|
|
2267
2305
|
if (n instanceof B && t.has(n.node.type.name)) {
|
|
2268
2306
|
const s = Math.min(n.to, r.state.doc.content.size);
|
|
2269
|
-
o.setSelection(
|
|
2307
|
+
o.setSelection(A.near(r.state.doc.resolve(s), 1));
|
|
2270
2308
|
}
|
|
2271
2309
|
o.setMeta(j, e), o.setMeta("addToHistory", !1), r.dispatch(o);
|
|
2272
2310
|
}
|
|
2273
|
-
function
|
|
2311
|
+
function rn(r, t) {
|
|
2274
2312
|
const e = j.getState(r.state);
|
|
2275
2313
|
if ((e == null ? void 0 : e.focused) === t)
|
|
2276
2314
|
return;
|
|
@@ -2284,14 +2322,14 @@ function _t(r, t) {
|
|
|
2284
2322
|
const n = [];
|
|
2285
2323
|
return r.doc.nodesBetween(e.from, e.to, (o, s) => {
|
|
2286
2324
|
t.has(o.type.name) && s >= e.from && s + o.nodeSize <= e.to && n.push(
|
|
2287
|
-
|
|
2288
|
-
class:
|
|
2325
|
+
Jt.node(s, s + o.nodeSize, {
|
|
2326
|
+
class: Qr,
|
|
2289
2327
|
"data-range-selected": "true"
|
|
2290
2328
|
})
|
|
2291
2329
|
);
|
|
2292
2330
|
}), n.length > 0 ? U.create(r.doc, n) : U.empty;
|
|
2293
2331
|
}
|
|
2294
|
-
class
|
|
2332
|
+
class Ie {
|
|
2295
2333
|
/** 绑定需要维护编号的节点名。 */
|
|
2296
2334
|
constructor(t = "reportNumberedBlock") {
|
|
2297
2335
|
this.nodeName = t;
|
|
@@ -2355,14 +2393,14 @@ class Se {
|
|
|
2355
2393
|
return a.delete(s.pos, d), a.insert(u, s.node), this.applyToTransaction(a), t.view.dispatch(a.scrollIntoView()), !0;
|
|
2356
2394
|
}
|
|
2357
2395
|
}
|
|
2358
|
-
class
|
|
2396
|
+
class nn {
|
|
2359
2397
|
/** 绑定编号节点名和编号服务。 */
|
|
2360
|
-
constructor(t = "reportNumberedBlock", e = new
|
|
2398
|
+
constructor(t = "reportNumberedBlock", e = new Ie(t)) {
|
|
2361
2399
|
this.nodeName = t, this.service = e;
|
|
2362
2400
|
}
|
|
2363
2401
|
/** 创建 appendTransaction 编号修复插件。 */
|
|
2364
2402
|
create() {
|
|
2365
|
-
return new
|
|
2403
|
+
return new X({
|
|
2366
2404
|
/** 文档变更后自动写回顺序编号,且不进入撤销历史。 */
|
|
2367
2405
|
appendTransaction: (t, e, n) => {
|
|
2368
2406
|
if (!t.some((i) => i.docChanged) || he(t))
|
|
@@ -2385,17 +2423,17 @@ class Yr {
|
|
|
2385
2423
|
});
|
|
2386
2424
|
}
|
|
2387
2425
|
}
|
|
2388
|
-
function
|
|
2389
|
-
return
|
|
2426
|
+
function Ee(r = "reportNumberedBlock") {
|
|
2427
|
+
return D.create({
|
|
2390
2428
|
name: "numbering",
|
|
2391
2429
|
/** 注册自动编号 ProseMirror 插件。 */
|
|
2392
2430
|
addProseMirrorPlugins() {
|
|
2393
|
-
return [new
|
|
2431
|
+
return [new nn(r).create()];
|
|
2394
2432
|
}
|
|
2395
2433
|
});
|
|
2396
2434
|
}
|
|
2397
|
-
|
|
2398
|
-
const
|
|
2435
|
+
Ee();
|
|
2436
|
+
const on = D.create({
|
|
2399
2437
|
name: "textColor",
|
|
2400
2438
|
/** 声明文字颜色全局属性的 HTML 解析和渲染规则。 */
|
|
2401
2439
|
addGlobalAttributes() {
|
|
@@ -2405,9 +2443,9 @@ const Zr = x.create({
|
|
|
2405
2443
|
attributes: {
|
|
2406
2444
|
color: {
|
|
2407
2445
|
default: null,
|
|
2408
|
-
parseHTML: (r) =>
|
|
2446
|
+
parseHTML: (r) => M.sanitize("color", r.style.color) ?? null,
|
|
2409
2447
|
renderHTML: (r) => {
|
|
2410
|
-
const t =
|
|
2448
|
+
const t = M.sanitize("color", r.color);
|
|
2411
2449
|
return t ? {
|
|
2412
2450
|
style: `color: ${t}`
|
|
2413
2451
|
} : {};
|
|
@@ -2420,7 +2458,7 @@ const Zr = x.create({
|
|
|
2420
2458
|
/** 注册设置和清除文字颜色的命令。 */
|
|
2421
2459
|
addCommands() {
|
|
2422
2460
|
return {
|
|
2423
|
-
setTextColor: (r) => ({ chain: t }) =>
|
|
2461
|
+
setTextColor: (r) => ({ chain: t }) => M.sanitize("color", r) ? t().setMark("textStyle", { color: r }).run() : !1,
|
|
2424
2462
|
unsetTextColor: () => ({ chain: r }) => r().setMark("textStyle", { color: null }).removeEmptyTextStyle().run()
|
|
2425
2463
|
};
|
|
2426
2464
|
}
|
|
@@ -2428,7 +2466,7 @@ const Zr = x.create({
|
|
|
2428
2466
|
function lt(r) {
|
|
2429
2467
|
return r.attrs ?? {};
|
|
2430
2468
|
}
|
|
2431
|
-
function
|
|
2469
|
+
function K(r) {
|
|
2432
2470
|
return !!r && typeof r == "object" && !Array.isArray(r);
|
|
2433
2471
|
}
|
|
2434
2472
|
function V(r, t, e, n = !1) {
|
|
@@ -2443,40 +2481,40 @@ function rt(r, t, e) {
|
|
|
2443
2481
|
}
|
|
2444
2482
|
function Ht(r, t, e, n = !1) {
|
|
2445
2483
|
const o = r[t];
|
|
2446
|
-
if (!(o === void 0 && !n) && !
|
|
2484
|
+
if (!(o === void 0 && !n) && !vr(o))
|
|
2447
2485
|
throw new Error(`${e} ${t} must be string, finite number, boolean or null.`);
|
|
2448
2486
|
}
|
|
2449
|
-
function
|
|
2487
|
+
function sn(r) {
|
|
2450
2488
|
if (r !== void 0) {
|
|
2451
2489
|
if (!Array.isArray(r))
|
|
2452
2490
|
throw new Error("Control rules must be an array.");
|
|
2453
2491
|
for (const t of r) {
|
|
2454
|
-
if (!
|
|
2492
|
+
if (!K(t))
|
|
2455
2493
|
throw new Error("Control rule must be an object.");
|
|
2456
2494
|
if (typeof t.title != "string")
|
|
2457
2495
|
throw new Error("Control rule requires title.");
|
|
2458
2496
|
const e = t.contents ?? t.list;
|
|
2459
|
-
e !== void 0 &&
|
|
2497
|
+
e !== void 0 && an(e);
|
|
2460
2498
|
}
|
|
2461
2499
|
}
|
|
2462
2500
|
}
|
|
2463
|
-
function
|
|
2501
|
+
function an(r) {
|
|
2464
2502
|
if (!Array.isArray(r))
|
|
2465
2503
|
throw new Error("Control rule contents must be an array.");
|
|
2466
2504
|
for (const t of r) {
|
|
2467
|
-
if (!
|
|
2505
|
+
if (!K(t))
|
|
2468
2506
|
throw new Error("Control rule content must be an object.");
|
|
2469
2507
|
const e = t.premises ?? t.premiss;
|
|
2470
|
-
if (e !== void 0 &&
|
|
2508
|
+
if (e !== void 0 && ln(e), !K(t.result))
|
|
2471
2509
|
throw new Error("Control rule content requires result.");
|
|
2472
|
-
|
|
2510
|
+
un(t.result);
|
|
2473
2511
|
}
|
|
2474
2512
|
}
|
|
2475
|
-
function
|
|
2513
|
+
function ln(r) {
|
|
2476
2514
|
if (!Array.isArray(r))
|
|
2477
2515
|
throw new Error("Control rule premises must be an array.");
|
|
2478
2516
|
for (const t of r) {
|
|
2479
|
-
if (!
|
|
2517
|
+
if (!K(t))
|
|
2480
2518
|
throw new Error("Control rule premise must be an object.");
|
|
2481
2519
|
if (typeof t.condition != "string")
|
|
2482
2520
|
throw new Error("Control rule premise requires condition.");
|
|
@@ -2484,11 +2522,11 @@ function en(r) {
|
|
|
2484
2522
|
throw new Error("Control rule premise entryType must be input or math.");
|
|
2485
2523
|
if (typeof t.inputSerialMath != "string")
|
|
2486
2524
|
throw new Error("Control rule premise requires inputSerialMath.");
|
|
2487
|
-
t.conditionRange !== void 0 &&
|
|
2525
|
+
t.conditionRange !== void 0 && dn(t.conditionRange);
|
|
2488
2526
|
}
|
|
2489
2527
|
}
|
|
2490
|
-
function
|
|
2491
|
-
if (!
|
|
2528
|
+
function dn(r) {
|
|
2529
|
+
if (!K(r))
|
|
2492
2530
|
throw new Error("Control rule conditionRange must be an object.");
|
|
2493
2531
|
for (const t of ["symbol1", "symbol2"]) {
|
|
2494
2532
|
const e = r[t];
|
|
@@ -2501,7 +2539,7 @@ function rn(r) {
|
|
|
2501
2539
|
throw new Error(`Control rule conditionRange ${t} must be a string or number.`);
|
|
2502
2540
|
}
|
|
2503
2541
|
}
|
|
2504
|
-
function
|
|
2542
|
+
function un(r) {
|
|
2505
2543
|
if (typeof r.type != "string")
|
|
2506
2544
|
throw new Error("Control rule result requires type.");
|
|
2507
2545
|
if (typeof r.value != "string")
|
|
@@ -2518,35 +2556,35 @@ function nn(r) {
|
|
|
2518
2556
|
if (r.exactType !== void 0 && typeof r.exactType != "string")
|
|
2519
2557
|
throw new Error("Control rule result exactType must be a string.");
|
|
2520
2558
|
}
|
|
2521
|
-
function
|
|
2559
|
+
function St(r) {
|
|
2522
2560
|
if (typeof r.fieldId != "string" || !r.fieldId.trim() || typeof r.fieldName != "string" || !r.fieldName.trim())
|
|
2523
2561
|
throw new Error("Structured field requires fieldId and fieldName.");
|
|
2524
|
-
V(r, "controlId", "Structured field", !0), V(r, "batchId", "Structured field", !0), V(r, "templateId", "Structured field"), V(r, "widgetNumber", "Structured field"), Ht(r, "value", "Structured field", !0), Ht(r, "defaultValue", "Structured field"), V(r, "placeholder", "Structured field"), rt(r, "required", "Structured field"), rt(r, "hideWhenEmpty", "Structured field"), rt(r, "noMatchDefault", "Structured field"),
|
|
2562
|
+
V(r, "controlId", "Structured field", !0), V(r, "batchId", "Structured field", !0), V(r, "templateId", "Structured field"), V(r, "widgetNumber", "Structured field"), Ht(r, "value", "Structured field", !0), Ht(r, "defaultValue", "Structured field"), V(r, "placeholder", "Structured field"), rt(r, "required", "Structured field"), rt(r, "hideWhenEmpty", "Structured field"), rt(r, "noMatchDefault", "Structured field"), sn(r.rules), V(r, "nextWidgetNumber", "Structured field"), V(r, "ruleStyleColor", "Structured field", !0);
|
|
2525
2563
|
}
|
|
2526
2564
|
function Gt(r) {
|
|
2527
|
-
if (
|
|
2565
|
+
if (St(r), !Array.isArray(r.options))
|
|
2528
2566
|
throw new Error("Dropdown field requires options.");
|
|
2529
2567
|
for (const t of r.options)
|
|
2530
|
-
if (!
|
|
2568
|
+
if (!K(t) || typeof t.label != "string" || typeof t.value != "string")
|
|
2531
2569
|
throw new Error("Dropdown option requires string label and value.");
|
|
2532
2570
|
rt(r, "allowCustomText", "Dropdown field");
|
|
2533
2571
|
}
|
|
2534
|
-
function
|
|
2572
|
+
function we(r, t = !1) {
|
|
2535
2573
|
const e = [
|
|
2536
2574
|
` data-control-id="${b.attr(r.controlId ?? "")}"`,
|
|
2537
2575
|
` data-field-id="${b.attr(r.fieldId)}"`,
|
|
2538
2576
|
` data-field-name="${b.attr(r.fieldName)}"`
|
|
2539
2577
|
];
|
|
2540
|
-
return t && r.value !== null && r.value !== void 0 && (e.push(` data-value="${b.attr(r.value)}"`), e.push(` data-value-type="${F(r.value)}"`)), t && (e.push(` data-batch-id="${b.attr(r.batchId ?? "")}"`), e.push(` data-template-id="${b.attr(r.templateId ?? "")}"`), e.push(` data-widget-number="${b.attr(r.widgetNumber ?? "")}"`), r.defaultValue !== null && r.defaultValue !== void 0 && (e.push(` data-default-value="${b.attr(r.defaultValue)}"`), e.push(` data-default-value-type="${F(r.defaultValue)}"`)), e.push(` data-placeholder="${b.attr(r.placeholder ?? "")}"`), e.push(` data-no-match-default="${String(!!r.noMatchDefault)}"`), e.push(` data-rules="${b.attr(JSON.stringify(r.rules ?? []))}"`), e.push(` data-next-widget-number="${b.attr(r.nextWidgetNumber ?? "")}"`), e.push(` data-rule-style-color="${b.attr(
|
|
2578
|
+
return t && r.value !== null && r.value !== void 0 && (e.push(` data-value="${b.attr(r.value)}"`), e.push(` data-value-type="${F(r.value)}"`)), t && (e.push(` data-batch-id="${b.attr(r.batchId ?? "")}"`), e.push(` data-template-id="${b.attr(r.templateId ?? "")}"`), e.push(` data-widget-number="${b.attr(r.widgetNumber ?? "")}"`), r.defaultValue !== null && r.defaultValue !== void 0 && (e.push(` data-default-value="${b.attr(r.defaultValue)}"`), e.push(` data-default-value-type="${F(r.defaultValue)}"`)), e.push(` data-placeholder="${b.attr(r.placeholder ?? "")}"`), e.push(` data-no-match-default="${String(!!r.noMatchDefault)}"`), e.push(` data-rules="${b.attr(JSON.stringify(r.rules ?? []))}"`), e.push(` data-next-widget-number="${b.attr(r.nextWidgetNumber ?? "")}"`), e.push(` data-rule-style-color="${b.attr(M.sanitize("color", r.ruleStyleColor) ?? "")}"`)), e.push(` data-required="${String(!!r.required)}"`), e.push(` data-hide-when-empty="${String(!!r.hideWhenEmpty)}"`), e;
|
|
2541
2579
|
}
|
|
2542
|
-
function
|
|
2580
|
+
function Ne(r) {
|
|
2543
2581
|
return new Et().addSafe("color", r.ruleStyleColor).toAttribute();
|
|
2544
2582
|
}
|
|
2545
|
-
function
|
|
2546
|
-
const e =
|
|
2583
|
+
function cn(r, t = !1) {
|
|
2584
|
+
const e = we(r, t), n = $(r.options);
|
|
2547
2585
|
return t && (e.push(` data-options="${b.attr(JSON.stringify(n))}"`), e.push(` data-allow-custom-text="${String(r.allowCustomText !== !1)}"`)), e;
|
|
2548
2586
|
}
|
|
2549
|
-
function
|
|
2587
|
+
function hn(r, t) {
|
|
2550
2588
|
var n, o, s;
|
|
2551
2589
|
return `<span${new Et().addSafe("font-family", (n = r.attrs) == null ? void 0 : n.fontFamily).addSafe("font-size", (o = r.attrs) == null ? void 0 : o.fontSize).addSafe("color", (s = r.attrs) == null ? void 0 : s.color).toAttribute()}>${t}</span>`;
|
|
2552
2590
|
}
|
|
@@ -2556,13 +2594,13 @@ function et(r) {
|
|
|
2556
2594
|
function _() {
|
|
2557
2595
|
return (r, t) => t;
|
|
2558
2596
|
}
|
|
2559
|
-
function
|
|
2560
|
-
|
|
2597
|
+
function pn(r) {
|
|
2598
|
+
pt(r);
|
|
2561
2599
|
}
|
|
2562
|
-
const
|
|
2600
|
+
const fn = [
|
|
2563
2601
|
{
|
|
2564
2602
|
markName: I,
|
|
2565
|
-
validateAttrs:
|
|
2603
|
+
validateAttrs: pn,
|
|
2566
2604
|
renderHTML: (r, t, e) => {
|
|
2567
2605
|
var s, i;
|
|
2568
2606
|
if (e.mode !== "edit")
|
|
@@ -2601,20 +2639,20 @@ const ln = [
|
|
|
2601
2639
|
},
|
|
2602
2640
|
{
|
|
2603
2641
|
markName: "textStyle",
|
|
2604
|
-
renderHTML: (r, t, e) =>
|
|
2642
|
+
renderHTML: (r, t, e) => hn(r, t),
|
|
2605
2643
|
renderText: _()
|
|
2606
2644
|
}
|
|
2607
|
-
],
|
|
2645
|
+
], mn = {
|
|
2608
2646
|
nodeName: "structuredField",
|
|
2609
2647
|
templateType: "structuredField",
|
|
2610
2648
|
dataNode: "structured-field",
|
|
2611
|
-
extension:
|
|
2649
|
+
extension: jr,
|
|
2612
2650
|
isInline: !0,
|
|
2613
2651
|
isControl: !0,
|
|
2614
|
-
validateAttrs:
|
|
2652
|
+
validateAttrs: St,
|
|
2615
2653
|
/** 校验模板中的结构化输入控件 attrs。 */
|
|
2616
2654
|
validateTemplate(r) {
|
|
2617
|
-
|
|
2655
|
+
St(lt(r));
|
|
2618
2656
|
},
|
|
2619
2657
|
/** 转换为 ProseMirror 控件节点并分配新的 controlId。 */
|
|
2620
2658
|
toProseMirrorNode(r, t) {
|
|
@@ -2636,8 +2674,8 @@ const ln = [
|
|
|
2636
2674
|
return t.mode !== "edit" ? b.text(o) : [
|
|
2637
2675
|
`<span class="hmg-structured-field${n ? " hmg-structured-field--empty" : ""}"`,
|
|
2638
2676
|
' data-report-node="structured-field"',
|
|
2639
|
-
...
|
|
2640
|
-
|
|
2677
|
+
...we(e, t.mode === "edit"),
|
|
2678
|
+
Ne(e),
|
|
2641
2679
|
">",
|
|
2642
2680
|
b.text(o),
|
|
2643
2681
|
"</span>"
|
|
@@ -2650,11 +2688,11 @@ const ln = [
|
|
|
2650
2688
|
}, n = z.isEmpty(t.value) ? t.placeholder ?? "" : t.value;
|
|
2651
2689
|
return String(n ?? "");
|
|
2652
2690
|
}
|
|
2653
|
-
},
|
|
2691
|
+
}, gn = {
|
|
2654
2692
|
nodeName: "dropdownField",
|
|
2655
2693
|
templateType: "dropdownField",
|
|
2656
2694
|
dataNode: "dropdown-field",
|
|
2657
|
-
extension:
|
|
2695
|
+
extension: Or,
|
|
2658
2696
|
isInline: !0,
|
|
2659
2697
|
isControl: !0,
|
|
2660
2698
|
validateAttrs: Gt,
|
|
@@ -2685,8 +2723,8 @@ const ln = [
|
|
|
2685
2723
|
return t.mode !== "edit" ? b.text(i) : [
|
|
2686
2724
|
`<span class="hmg-dropdown-field${n ? " hmg-dropdown-field--empty" : ""}"`,
|
|
2687
2725
|
' data-report-node="dropdown-field"',
|
|
2688
|
-
...
|
|
2689
|
-
|
|
2726
|
+
...cn(e, t.mode === "edit"),
|
|
2727
|
+
Ne(e),
|
|
2690
2728
|
">",
|
|
2691
2729
|
b.text(i),
|
|
2692
2730
|
"</span>"
|
|
@@ -2704,11 +2742,11 @@ const ln = [
|
|
|
2704
2742
|
const i = (s == null ? void 0 : s.label) ?? (n ? e.placeholder ?? "" : e.value);
|
|
2705
2743
|
return String(i ?? "");
|
|
2706
2744
|
}
|
|
2707
|
-
},
|
|
2745
|
+
}, yn = {
|
|
2708
2746
|
nodeName: "reportNumberedBlock",
|
|
2709
2747
|
templateType: "numberedBlock",
|
|
2710
2748
|
dataNode: "numbered-block",
|
|
2711
|
-
extension:
|
|
2749
|
+
extension: Ur,
|
|
2712
2750
|
supportsBlockFormatting: !0,
|
|
2713
2751
|
isNumberedBlock: !0,
|
|
2714
2752
|
/** 校验编号块的子节点。 */
|
|
@@ -2731,7 +2769,7 @@ const ln = [
|
|
|
2731
2769
|
renderHTML(r, t) {
|
|
2732
2770
|
var s, i;
|
|
2733
2771
|
const e = String(((s = r.attrs) == null ? void 0 : s.number) ?? ""), n = !!((i = r.attrs) != null && i.manualNumber), o = t.renderContent(r.content);
|
|
2734
|
-
return t.mode !== "edit" && !o.trim() &&
|
|
2772
|
+
return t.mode !== "edit" && !o.trim() && ve(r.content, "pageBreak") ? "" : [
|
|
2735
2773
|
`<div${t.renderBlockAttrs(r, "hmg-numbered-block")}`,
|
|
2736
2774
|
' data-report-node="numbered-block"',
|
|
2737
2775
|
` data-number="${b.attr(e)}"`,
|
|
@@ -2749,14 +2787,14 @@ const ln = [
|
|
|
2749
2787
|
return e ? n ? `${e}. ${n}` : `${e}.` : n;
|
|
2750
2788
|
}
|
|
2751
2789
|
};
|
|
2752
|
-
function
|
|
2753
|
-
return (r ?? []).some((e) => e.type === t ||
|
|
2790
|
+
function ve(r, t) {
|
|
2791
|
+
return (r ?? []).some((e) => e.type === t || ve(e.content, t));
|
|
2754
2792
|
}
|
|
2755
|
-
const
|
|
2793
|
+
const bn = {
|
|
2756
2794
|
nodeName: "pageBreak",
|
|
2757
2795
|
templateType: "pageBreak",
|
|
2758
2796
|
dataNode: "page-break",
|
|
2759
|
-
extension:
|
|
2797
|
+
extension: Gr,
|
|
2760
2798
|
isInline: !0,
|
|
2761
2799
|
/** 每次应用模板时创建新的分页符实例。 */
|
|
2762
2800
|
toProseMirrorNode() {
|
|
@@ -2776,32 +2814,32 @@ const hn = {
|
|
|
2776
2814
|
renderText() {
|
|
2777
2815
|
return "";
|
|
2778
2816
|
}
|
|
2779
|
-
},
|
|
2780
|
-
|
|
2781
|
-
|
|
2782
|
-
|
|
2783
|
-
|
|
2784
|
-
],
|
|
2817
|
+
}, Cn = [
|
|
2818
|
+
mn,
|
|
2819
|
+
gn,
|
|
2820
|
+
yn,
|
|
2821
|
+
bn
|
|
2822
|
+
], Sn = {
|
|
2785
2823
|
name: "hmg-base",
|
|
2786
2824
|
extensions: [
|
|
2787
|
-
jr,
|
|
2788
|
-
Re,
|
|
2789
|
-
$e,
|
|
2790
|
-
ze,
|
|
2791
|
-
Or,
|
|
2792
2825
|
Zr,
|
|
2826
|
+
ze,
|
|
2793
2827
|
_e,
|
|
2794
|
-
|
|
2828
|
+
$e,
|
|
2829
|
+
Lr,
|
|
2830
|
+
on,
|
|
2831
|
+
He,
|
|
2832
|
+
Fr
|
|
2795
2833
|
],
|
|
2796
|
-
marks:
|
|
2797
|
-
},
|
|
2834
|
+
marks: fn
|
|
2835
|
+
}, In = {
|
|
2798
2836
|
name: "hmg-report-nodes",
|
|
2799
|
-
nodes:
|
|
2800
|
-
},
|
|
2801
|
-
|
|
2802
|
-
|
|
2837
|
+
nodes: Cn
|
|
2838
|
+
}, En = [
|
|
2839
|
+
Sn,
|
|
2840
|
+
In
|
|
2803
2841
|
];
|
|
2804
|
-
class
|
|
2842
|
+
class wn {
|
|
2805
2843
|
/** 注册所有内置和传入的 feature。 */
|
|
2806
2844
|
constructor(t) {
|
|
2807
2845
|
p(this, "featureList", []);
|
|
@@ -2890,28 +2928,28 @@ class yn {
|
|
|
2890
2928
|
this.byMarkName.set(t.markName, t);
|
|
2891
2929
|
}
|
|
2892
2930
|
}
|
|
2893
|
-
function
|
|
2931
|
+
function Yn(r) {
|
|
2894
2932
|
return r;
|
|
2895
2933
|
}
|
|
2896
|
-
function
|
|
2934
|
+
function Zn(r) {
|
|
2897
2935
|
return {
|
|
2898
2936
|
...r,
|
|
2899
2937
|
isControl: !0,
|
|
2900
2938
|
isInline: r.isInline ?? !0
|
|
2901
2939
|
};
|
|
2902
2940
|
}
|
|
2903
|
-
function
|
|
2941
|
+
function Qn(r) {
|
|
2904
2942
|
return r;
|
|
2905
2943
|
}
|
|
2906
|
-
function
|
|
2944
|
+
function to(r) {
|
|
2907
2945
|
return r;
|
|
2908
2946
|
}
|
|
2909
|
-
function
|
|
2910
|
-
return new
|
|
2947
|
+
function Y(r = []) {
|
|
2948
|
+
return new wn([...En, ...r]);
|
|
2911
2949
|
}
|
|
2912
2950
|
class Nt {
|
|
2913
2951
|
/** 绑定 feature 注册表以识别控件节点。 */
|
|
2914
|
-
constructor(t =
|
|
2952
|
+
constructor(t = Y()) {
|
|
2915
2953
|
this.registry = t;
|
|
2916
2954
|
}
|
|
2917
2955
|
/** 创建不与已有集合冲突的新 controlId。 */
|
|
@@ -2972,7 +3010,7 @@ class Nt {
|
|
|
2972
3010
|
const n = [];
|
|
2973
3011
|
return t.forEach((o) => {
|
|
2974
3012
|
n.push(this.assignFreshControlIdsToNode(o, e));
|
|
2975
|
-
}),
|
|
3013
|
+
}), It.fromArray(n);
|
|
2976
3014
|
}
|
|
2977
3015
|
/** 为单个 ProseMirror 节点及其子树刷新控件 ID。 */
|
|
2978
3016
|
assignFreshControlIdsToNode(t, e) {
|
|
@@ -3040,7 +3078,7 @@ class Nt {
|
|
|
3040
3078
|
return `${t}_${Date.now().toString(36)}_${n}`;
|
|
3041
3079
|
}
|
|
3042
3080
|
}
|
|
3043
|
-
const
|
|
3081
|
+
const Nn = /* @__PURE__ */ new Set([
|
|
3044
3082
|
"P",
|
|
3045
3083
|
"DIV",
|
|
3046
3084
|
"BR",
|
|
@@ -3055,8 +3093,8 @@ const bn = /* @__PURE__ */ new Set([
|
|
|
3055
3093
|
"OL",
|
|
3056
3094
|
"LI",
|
|
3057
3095
|
"SPAN"
|
|
3058
|
-
]),
|
|
3059
|
-
class
|
|
3096
|
+
]), vn = /* @__PURE__ */ new Set(["color", "font-weight", "font-style", "text-decoration", "font-size", "font-family", "line-height"]), Tn = /* @__PURE__ */ new Set(["SCRIPT", "STYLE", "IFRAME", "OBJECT", "EMBED", "LINK", "META"]), R = /* @__PURE__ */ new WeakMap();
|
|
3097
|
+
class Te {
|
|
3060
3098
|
/** 清洗粘贴 HTML,浏览器环境优先使用 DOMParser。 */
|
|
3061
3099
|
sanitize(t) {
|
|
3062
3100
|
if (this.assertSupportedReportMarkup(t), typeof DOMParser > "u")
|
|
@@ -3087,11 +3125,11 @@ class ve {
|
|
|
3087
3125
|
/** 递归清洗子元素并扁平化不支持标签。 */
|
|
3088
3126
|
sanitizeChildren(t) {
|
|
3089
3127
|
for (const e of Array.from(t.children)) {
|
|
3090
|
-
if (
|
|
3128
|
+
if (Tn.has(e.tagName)) {
|
|
3091
3129
|
e.remove();
|
|
3092
3130
|
continue;
|
|
3093
3131
|
}
|
|
3094
|
-
if (!
|
|
3132
|
+
if (!Nn.has(e.tagName)) {
|
|
3095
3133
|
this.sanitizeChildren(e), e.replaceWith(...Array.from(e.childNodes));
|
|
3096
3134
|
continue;
|
|
3097
3135
|
}
|
|
@@ -3125,9 +3163,9 @@ class ve {
|
|
|
3125
3163
|
const e = [], n = ((o = t.getAttribute("style")) == null ? void 0 : o.split(";")) ?? [];
|
|
3126
3164
|
for (const s of n) {
|
|
3127
3165
|
const [i, ...a] = s.split(":"), l = i == null ? void 0 : i.trim().toLowerCase(), d = a.join(":").trim();
|
|
3128
|
-
if (!l || !d || !
|
|
3166
|
+
if (!l || !d || !vn.has(l))
|
|
3129
3167
|
continue;
|
|
3130
|
-
const u =
|
|
3168
|
+
const u = M.sanitize(l, d);
|
|
3131
3169
|
u && e.push(`${l}: ${u}`);
|
|
3132
3170
|
}
|
|
3133
3171
|
if (e.length === 0) {
|
|
@@ -3141,25 +3179,25 @@ class ve {
|
|
|
3141
3179
|
return b.text(t.replace(/<(script|style|iframe|object|embed|link|meta)[\s\S]*?>[\s\S]*?<\/\1>/gi, ""));
|
|
3142
3180
|
}
|
|
3143
3181
|
}
|
|
3144
|
-
function Ae(r =
|
|
3145
|
-
return
|
|
3182
|
+
function Ae(r = Y(), t, e, n, o) {
|
|
3183
|
+
return D.create({
|
|
3146
3184
|
name: "pasteSanitizer",
|
|
3147
3185
|
/** 注册粘贴清洗、拖拽识别和控件 ID 修复插件。 */
|
|
3148
3186
|
addProseMirrorPlugins() {
|
|
3149
|
-
const s = new
|
|
3187
|
+
const s = new Te(), i = new Nt(r), a = new ye(), l = new Yt();
|
|
3150
3188
|
let d = null, u = null;
|
|
3151
3189
|
const h = () => (t == null ? void 0 : t()) ?? i.createBatchId(), f = (c, g) => {
|
|
3152
3190
|
let m;
|
|
3153
3191
|
return c.someProp("dragCopies", (C) => {
|
|
3154
3192
|
m = m || C(g);
|
|
3155
|
-
}), m !== void 0 ? m :
|
|
3193
|
+
}), m !== void 0 ? m : An() ? g.altKey : g.ctrlKey;
|
|
3156
3194
|
};
|
|
3157
3195
|
return [
|
|
3158
|
-
new
|
|
3196
|
+
new X({
|
|
3159
3197
|
filterTransaction(c) {
|
|
3160
|
-
if (!c.docChanged ||
|
|
3198
|
+
if (!c.docChanged || mt(c))
|
|
3161
3199
|
return !0;
|
|
3162
|
-
const g =
|
|
3200
|
+
const g = kn(c.doc);
|
|
3163
3201
|
return g ? (n == null || n(g), !1) : !0;
|
|
3164
3202
|
},
|
|
3165
3203
|
props: {
|
|
@@ -3249,7 +3287,7 @@ function Ae(r = X(), t, e, n, o) {
|
|
|
3249
3287
|
},
|
|
3250
3288
|
/** 在同组的另一个编辑器完成落点插入,并在移动语义下同步删除源选区。 */
|
|
3251
3289
|
handleDrop(c, g, m) {
|
|
3252
|
-
var
|
|
3290
|
+
var Tt;
|
|
3253
3291
|
const C = u;
|
|
3254
3292
|
if (!C)
|
|
3255
3293
|
return !1;
|
|
@@ -3265,24 +3303,24 @@ function Ae(r = X(), t, e, n, o) {
|
|
|
3265
3303
|
});
|
|
3266
3304
|
if (!v)
|
|
3267
3305
|
return N(), !0;
|
|
3268
|
-
const E =
|
|
3269
|
-
if (tt ? y.replaceRangeWith(w, w, m.content.firstChild) : y.replaceRange(w, w, m), y.doc.eq(
|
|
3306
|
+
const E = Re(c.state.doc, v.pos, m) ?? v.pos, y = c.state.tr, w = y.mapping.map(E), tt = m.openStart === 0 && m.openEnd === 0 && m.content.childCount === 1, ke = y.doc;
|
|
3307
|
+
if (tt ? y.replaceRangeWith(w, w, m.content.firstChild) : y.replaceRange(w, w, m), y.doc.eq(ke))
|
|
3270
3308
|
return N(), !0;
|
|
3271
|
-
if (tt && B.isSelectable(m.content.firstChild) && ((
|
|
3309
|
+
if (tt && B.isSelectable(m.content.firstChild) && ((Tt = y.doc.resolve(w).nodeAfter) != null && Tt.sameMarkup(m.content.firstChild)))
|
|
3272
3310
|
y.setSelection(B.create(y.doc, w));
|
|
3273
3311
|
else {
|
|
3274
|
-
const
|
|
3312
|
+
const yt = Math.min(
|
|
3275
3313
|
y.mapping.map(E),
|
|
3276
3314
|
y.doc.content.size
|
|
3277
3315
|
);
|
|
3278
|
-
y.setSelection(W.near(y.doc.resolve(
|
|
3316
|
+
y.setSelection(W.near(y.doc.resolve(yt), -1));
|
|
3279
3317
|
}
|
|
3280
3318
|
if (c.focus(), c.dispatch(y.setMeta("uiEvent", "drop").scrollIntoView()), !C.copy) {
|
|
3281
|
-
const
|
|
3319
|
+
const yt = C.sourceView.state.tr.delete(
|
|
3282
3320
|
C.sourceFrom,
|
|
3283
3321
|
C.sourceTo
|
|
3284
3322
|
);
|
|
3285
|
-
C.sourceView.dispatch(
|
|
3323
|
+
C.sourceView.dispatch(yt.setMeta("uiEvent", "drop").scrollIntoView());
|
|
3286
3324
|
}
|
|
3287
3325
|
return N(), !0;
|
|
3288
3326
|
}
|
|
@@ -3291,7 +3329,7 @@ function Ae(r = X(), t, e, n, o) {
|
|
|
3291
3329
|
appendTransaction(c, g, m) {
|
|
3292
3330
|
if (he(c))
|
|
3293
3331
|
return null;
|
|
3294
|
-
const C = i.collectTransactionUpdates(m.doc, h()), N = a.collectTransactionUpdates(m.doc), v =
|
|
3332
|
+
const C = i.collectTransactionUpdates(m.doc, h()), N = a.collectTransactionUpdates(m.doc), v = Mn(m.doc, r);
|
|
3295
3333
|
if (C.length === 0 && N.length === 0 && v.length === 0)
|
|
3296
3334
|
return null;
|
|
3297
3335
|
const E = m.tr;
|
|
@@ -3306,7 +3344,7 @@ function Ae(r = X(), t, e, n, o) {
|
|
|
3306
3344
|
}
|
|
3307
3345
|
for (const y of N) {
|
|
3308
3346
|
const w = E.doc.nodeAt(y.pos);
|
|
3309
|
-
(w == null ? void 0 : w.type.name) ===
|
|
3347
|
+
(w == null ? void 0 : w.type.name) === k && E.setNodeMarkup(y.pos, void 0, {
|
|
3310
3348
|
...w.attrs,
|
|
3311
3349
|
id: y.id
|
|
3312
3350
|
}, w.marks);
|
|
@@ -3325,7 +3363,7 @@ function Ae(r = X(), t, e, n, o) {
|
|
|
3325
3363
|
});
|
|
3326
3364
|
}
|
|
3327
3365
|
Ae();
|
|
3328
|
-
function
|
|
3366
|
+
function An() {
|
|
3329
3367
|
return typeof navigator > "u" ? !1 : /Mac|iP(?:hone|ad|od)/.test(`${navigator.platform} ${navigator.userAgent}`);
|
|
3330
3368
|
}
|
|
3331
3369
|
function Ut(r, t, e) {
|
|
@@ -3348,7 +3386,7 @@ function Ut(r, t, e) {
|
|
|
3348
3386
|
});
|
|
3349
3387
|
}), Array.from(n.values()).filter((o) => o.intersects).map(({ intersects: o, ...s }) => s);
|
|
3350
3388
|
}
|
|
3351
|
-
function
|
|
3389
|
+
function Mn(r, t) {
|
|
3352
3390
|
const e = [];
|
|
3353
3391
|
return r.descendants((n, o) => {
|
|
3354
3392
|
if (!t.isControlNode(n.type.name))
|
|
@@ -3368,7 +3406,7 @@ function En(r, t) {
|
|
|
3368
3406
|
}
|
|
3369
3407
|
}), e;
|
|
3370
3408
|
}
|
|
3371
|
-
function
|
|
3409
|
+
function kn(r) {
|
|
3372
3410
|
let t;
|
|
3373
3411
|
const e = (n, o) => {
|
|
3374
3412
|
var a;
|
|
@@ -3394,7 +3432,7 @@ function wn(r) {
|
|
|
3394
3432
|
return;
|
|
3395
3433
|
}
|
|
3396
3434
|
try {
|
|
3397
|
-
|
|
3435
|
+
pt(i.attrs);
|
|
3398
3436
|
} catch (l) {
|
|
3399
3437
|
t = {
|
|
3400
3438
|
nodeName: n.type.name,
|
|
@@ -3412,12 +3450,12 @@ function wn(r) {
|
|
|
3412
3450
|
}
|
|
3413
3451
|
class vt {
|
|
3414
3452
|
/** 绑定 feature 注册表、快捷键配置和编辑器分组。 */
|
|
3415
|
-
constructor(t =
|
|
3453
|
+
constructor(t = Y(), e, n, o, s, i) {
|
|
3416
3454
|
this.registry = t, this.controlShortcuts = e, this.editorGroup = n, this.getCurrentBatchId = o, this.onInvalidControlAttrs = s, this.onInvalidVisibilityGroup = i;
|
|
3417
3455
|
}
|
|
3418
3456
|
/** 创建包含内置、业务扩展和运行时插件的扩展数组。 */
|
|
3419
3457
|
create() {
|
|
3420
|
-
const t = this.registry.descriptors().filter((i) => i.isControl), e =
|
|
3458
|
+
const t = this.registry.descriptors().filter((i) => i.isControl), e = ft(
|
|
3421
3459
|
this.controlShortcuts,
|
|
3422
3460
|
t.map((i) => i.nodeName),
|
|
3423
3461
|
t.map((i) => i.dataNode ?? i.nodeName),
|
|
@@ -3427,7 +3465,8 @@ class vt {
|
|
|
3427
3465
|
...this.registry.extensions().map((i) => i.name === "structuredField" || i.name === "dropdownField" ? i.configure({ controlShortcutRuntime: e }) : i),
|
|
3428
3466
|
ge(n),
|
|
3429
3467
|
me(n),
|
|
3430
|
-
|
|
3468
|
+
Se(n),
|
|
3469
|
+
Ee(o),
|
|
3431
3470
|
Ae(
|
|
3432
3471
|
this.registry,
|
|
3433
3472
|
this.getCurrentBatchId,
|
|
@@ -3435,9 +3474,9 @@ class vt {
|
|
|
3435
3474
|
this.onInvalidVisibilityGroup,
|
|
3436
3475
|
this.editorGroup
|
|
3437
3476
|
),
|
|
3438
|
-
|
|
3439
|
-
|
|
3440
|
-
|
|
3477
|
+
Ge(t.map((i) => i.nodeName)),
|
|
3478
|
+
tn(t.map((i) => i.nodeName)),
|
|
3479
|
+
Sr(e)
|
|
3441
3480
|
];
|
|
3442
3481
|
}
|
|
3443
3482
|
/** 创建默认配置下的扩展数组。 */
|
|
@@ -3445,7 +3484,7 @@ class vt {
|
|
|
3445
3484
|
return new vt().create();
|
|
3446
3485
|
}
|
|
3447
3486
|
}
|
|
3448
|
-
const
|
|
3487
|
+
const J = "1.0.3";
|
|
3449
3488
|
class L {
|
|
3450
3489
|
/** 将报告文档转换为 Tiptap setContent 可接受的内容。 */
|
|
3451
3490
|
static toTiptapContent(t) {
|
|
@@ -3455,7 +3494,7 @@ class L {
|
|
|
3455
3494
|
};
|
|
3456
3495
|
}
|
|
3457
3496
|
/** 将 Tiptap JSON 包装为报告文档。 */
|
|
3458
|
-
static fromTiptapJSON(t, e =
|
|
3497
|
+
static fromTiptapJSON(t, e = J) {
|
|
3459
3498
|
return {
|
|
3460
3499
|
version: e,
|
|
3461
3500
|
type: "doc",
|
|
@@ -3463,7 +3502,7 @@ class L {
|
|
|
3463
3502
|
};
|
|
3464
3503
|
}
|
|
3465
3504
|
/** 创建空报告文档。 */
|
|
3466
|
-
static empty(t =
|
|
3505
|
+
static empty(t = J) {
|
|
3467
3506
|
return {
|
|
3468
3507
|
version: t,
|
|
3469
3508
|
type: "doc",
|
|
@@ -3476,7 +3515,7 @@ class L {
|
|
|
3476
3515
|
};
|
|
3477
3516
|
}
|
|
3478
3517
|
}
|
|
3479
|
-
class
|
|
3518
|
+
class gt {
|
|
3480
3519
|
/** 创建错误派发器并绑定可选监听器。 */
|
|
3481
3520
|
constructor(t) {
|
|
3482
3521
|
this.listener = t;
|
|
@@ -3512,7 +3551,7 @@ class qt {
|
|
|
3512
3551
|
const n = /* @__PURE__ */ new Map();
|
|
3513
3552
|
this.scan(t, n);
|
|
3514
3553
|
for (const [o, s] of n)
|
|
3515
|
-
s.condition ===
|
|
3554
|
+
s.condition === Z && (s.controlValues.length > 0 ? s.controlValues.every((i) => z.isEmpty(i)) : !s.hasRawContent) && this.hiddenGroupIds.add(o);
|
|
3516
3555
|
}
|
|
3517
3556
|
/** 判断节点是否属于任一满足隐藏条件的分组。 */
|
|
3518
3557
|
isNodeHidden(t) {
|
|
@@ -3541,7 +3580,7 @@ class qt {
|
|
|
3541
3580
|
throw new Error("Visibility groups cannot be nested.");
|
|
3542
3581
|
const u = d.length > 0 ? d : n;
|
|
3543
3582
|
for (const h of u) {
|
|
3544
|
-
|
|
3583
|
+
pt(h.attrs ?? {});
|
|
3545
3584
|
const f = String((o = h.attrs) == null ? void 0 : o.groupId);
|
|
3546
3585
|
let c = e.get(f);
|
|
3547
3586
|
c || (c = {
|
|
@@ -3561,9 +3600,9 @@ class qt {
|
|
|
3561
3600
|
return t.type === "text" ? !!((e = t.text) != null && e.trim()) : (n = t.content) != null && n.length ? !1 : !["pageBreak", "hardBreak"].includes(t.type);
|
|
3562
3601
|
}
|
|
3563
3602
|
}
|
|
3564
|
-
class
|
|
3603
|
+
class Dn {
|
|
3565
3604
|
/** 创建序列化器并绑定版本、错误派发器和 feature 注册表。 */
|
|
3566
|
-
constructor(t = "1.0.3", e = new
|
|
3605
|
+
constructor(t = "1.0.3", e = new gt(), n = Y()) {
|
|
3567
3606
|
this.documentVersion = t, this.errors = e, this.registry = n;
|
|
3568
3607
|
}
|
|
3569
3608
|
/** 从 Tiptap editor 导出报告 JSON。 */
|
|
@@ -3841,9 +3880,9 @@ class Nn {
|
|
|
3841
3880
|
));
|
|
3842
3881
|
}
|
|
3843
3882
|
}
|
|
3844
|
-
class
|
|
3883
|
+
class xn {
|
|
3845
3884
|
/** 创建选区管理器并绑定错误派发器。 */
|
|
3846
|
-
constructor(t = new
|
|
3885
|
+
constructor(t = new gt()) {
|
|
3847
3886
|
p(this, "savedSelection", null);
|
|
3848
3887
|
this.errors = t;
|
|
3849
3888
|
}
|
|
@@ -3864,7 +3903,7 @@ class vn {
|
|
|
3864
3903
|
return !1;
|
|
3865
3904
|
const n = t.state.doc, o = n.content.size, s = this.clamp(e.from, 0, o), i = this.clamp(e.to, s, o);
|
|
3866
3905
|
try {
|
|
3867
|
-
const a =
|
|
3906
|
+
const a = A.create(n, s, i);
|
|
3868
3907
|
return t.view.dispatch(t.state.tr.setSelection(a).scrollIntoView()), !0;
|
|
3869
3908
|
} catch (a) {
|
|
3870
3909
|
try {
|
|
@@ -3890,9 +3929,9 @@ class vn {
|
|
|
3890
3929
|
return Math.max(e, Math.min(n, t));
|
|
3891
3930
|
}
|
|
3892
3931
|
}
|
|
3893
|
-
class
|
|
3932
|
+
class Pn {
|
|
3894
3933
|
/** 创建模板引擎并绑定错误派发、控件身份和 feature 注册表。 */
|
|
3895
|
-
constructor(t = new
|
|
3934
|
+
constructor(t = new gt(), e = new Nt(), n = Y()) {
|
|
3896
3935
|
this.errors = t, this.identity = e, this.registry = n;
|
|
3897
3936
|
}
|
|
3898
3937
|
/** 校验模板根结构和所有子节点。 */
|
|
@@ -3901,7 +3940,7 @@ class An {
|
|
|
3901
3940
|
throw new Error("Template must be an object.");
|
|
3902
3941
|
if (!t.version)
|
|
3903
3942
|
throw new Error("Template version is required.");
|
|
3904
|
-
if (t.version !==
|
|
3943
|
+
if (t.version !== J)
|
|
3905
3944
|
throw new Error(`Unsupported report template version: ${t.version}.`);
|
|
3906
3945
|
if (!Array.isArray(t.content))
|
|
3907
3946
|
throw new Error("Template content must be an array.");
|
|
@@ -3913,7 +3952,7 @@ class An {
|
|
|
3913
3952
|
this.validate(t);
|
|
3914
3953
|
const n = /* @__PURE__ */ new Set();
|
|
3915
3954
|
return {
|
|
3916
|
-
version:
|
|
3955
|
+
version: J,
|
|
3917
3956
|
type: "doc",
|
|
3918
3957
|
content: t.content.map((o) => this.toProseMirrorNode(o, e, n))
|
|
3919
3958
|
};
|
|
@@ -4005,8 +4044,8 @@ class An {
|
|
|
4005
4044
|
throw new Error("Visibility group only supports the condition template attribute.");
|
|
4006
4045
|
if (!Array.isArray(t.content) || t.content.length === 0)
|
|
4007
4046
|
throw new Error("Visibility group requires at least one child node.");
|
|
4008
|
-
const n = ((o = t.attrs) == null ? void 0 : o.condition) ??
|
|
4009
|
-
if (n !==
|
|
4047
|
+
const n = ((o = t.attrs) == null ? void 0 : o.condition) ?? Z;
|
|
4048
|
+
if (n !== Z)
|
|
4010
4049
|
throw new Error(`Unsupported visibility group condition: ${String(n)}.`);
|
|
4011
4050
|
for (const s of t.content) {
|
|
4012
4051
|
if (s.type === "visibilityGroup")
|
|
@@ -4083,7 +4122,7 @@ class An {
|
|
|
4083
4122
|
var a;
|
|
4084
4123
|
if (o.type !== "visibilityGroup")
|
|
4085
4124
|
return [this.toProseMirrorNode(o, e, n)];
|
|
4086
|
-
const s = ((a = o.attrs) == null ? void 0 : a.condition) ??
|
|
4125
|
+
const s = ((a = o.attrs) == null ? void 0 : a.condition) ?? Z, i = {
|
|
4087
4126
|
type: I,
|
|
4088
4127
|
attrs: {
|
|
4089
4128
|
groupId: Xt(),
|
|
@@ -4109,7 +4148,7 @@ class S extends Error {
|
|
|
4109
4148
|
super(e), this.code = t, this.detail = n, this.name = "ReportDocumentValidationError";
|
|
4110
4149
|
}
|
|
4111
4150
|
}
|
|
4112
|
-
function
|
|
4151
|
+
function Bn(r, t) {
|
|
4113
4152
|
if (!r || typeof r != "object" || Array.isArray(r))
|
|
4114
4153
|
throw new S("INVALID_DOCUMENT", "Report document must be an object.", r);
|
|
4115
4154
|
const e = r;
|
|
@@ -4124,27 +4163,27 @@ function Tn(r, t) {
|
|
|
4124
4163
|
if (!Array.isArray(e.content))
|
|
4125
4164
|
throw new S("INVALID_DOCUMENT", "Report document content must be an array.", r);
|
|
4126
4165
|
}
|
|
4127
|
-
function
|
|
4166
|
+
function On(r, t) {
|
|
4128
4167
|
for (const e of r.content)
|
|
4129
|
-
|
|
4168
|
+
Me(e, t);
|
|
4130
4169
|
}
|
|
4131
|
-
function
|
|
4170
|
+
function Ln(r, t) {
|
|
4132
4171
|
try {
|
|
4133
4172
|
const e = L.toTiptapContent(r);
|
|
4134
4173
|
if (!e || typeof e == "string")
|
|
4135
4174
|
throw new Error("Report document could not be mapped to Tiptap content.");
|
|
4136
|
-
|
|
4175
|
+
Kt(e, t, {}, { errorOnInvalidContent: !0 });
|
|
4137
4176
|
} catch (e) {
|
|
4138
4177
|
throw new S("INVALID_DOCUMENT", "Report document does not match the editor schema.", e);
|
|
4139
4178
|
}
|
|
4140
4179
|
}
|
|
4141
4180
|
function jt(r, t, e) {
|
|
4142
|
-
|
|
4181
|
+
On(r, t), Ln(r, e);
|
|
4143
4182
|
}
|
|
4144
4183
|
function dt(r) {
|
|
4145
4184
|
return !!r && typeof r == "object" && !Array.isArray(r);
|
|
4146
4185
|
}
|
|
4147
|
-
function
|
|
4186
|
+
function Me(r, t, e = !1) {
|
|
4148
4187
|
if (!dt(r))
|
|
4149
4188
|
throw new S("INVALID_DOCUMENT", "Report node must be an object.", r);
|
|
4150
4189
|
if (typeof r.type != "string" || !r.type.trim())
|
|
@@ -4155,18 +4194,18 @@ function Te(r, t, e = !1) {
|
|
|
4155
4194
|
throw new S("INVALID_DOCUMENT", `Report node content must be an array: ${r.type}.`, r);
|
|
4156
4195
|
if (r.type === "text" && typeof r.text != "string")
|
|
4157
4196
|
throw new S("INVALID_DOCUMENT", "Text node requires string text.", r);
|
|
4158
|
-
const n = r.marks !== void 0 ?
|
|
4197
|
+
const n = r.marks !== void 0 ? Fn(r, t) : !1;
|
|
4159
4198
|
if (e && n)
|
|
4160
4199
|
throw new S(
|
|
4161
4200
|
"INVALID_DOCUMENT",
|
|
4162
4201
|
"Visibility groups cannot be nested.",
|
|
4163
4202
|
r
|
|
4164
4203
|
);
|
|
4165
|
-
t.isControlNode(r.type) &&
|
|
4204
|
+
t.isControlNode(r.type) && Vn(r, t);
|
|
4166
4205
|
for (const o of r.content ?? [])
|
|
4167
|
-
|
|
4206
|
+
Me(o, t, e || n);
|
|
4168
4207
|
}
|
|
4169
|
-
function
|
|
4208
|
+
function Fn(r, t) {
|
|
4170
4209
|
if (!Array.isArray(r.marks))
|
|
4171
4210
|
throw new S("INVALID_DOCUMENT", `Report node marks must be an array: ${r.type}.`, r);
|
|
4172
4211
|
let e = 0;
|
|
@@ -4195,7 +4234,7 @@ function Dn(r, t) {
|
|
|
4195
4234
|
);
|
|
4196
4235
|
return e === 1;
|
|
4197
4236
|
}
|
|
4198
|
-
function
|
|
4237
|
+
function Vn(r, t) {
|
|
4199
4238
|
const e = t.getByNodeName(r.type);
|
|
4200
4239
|
if (e != null && e.validateAttrs)
|
|
4201
4240
|
try {
|
|
@@ -4207,7 +4246,7 @@ function xn(r, t) {
|
|
|
4207
4246
|
});
|
|
4208
4247
|
}
|
|
4209
4248
|
}
|
|
4210
|
-
class
|
|
4249
|
+
class Rn {
|
|
4211
4250
|
/** 初始化 Tiptap 编辑器并注入报告扩展和回调。 */
|
|
4212
4251
|
constructor(t = {}) {
|
|
4213
4252
|
p(this, "editor");
|
|
@@ -4240,7 +4279,7 @@ class Pn {
|
|
|
4240
4279
|
this.controlSnapshotsDirty = !0;
|
|
4241
4280
|
return;
|
|
4242
4281
|
}
|
|
4243
|
-
const e =
|
|
4282
|
+
const e = mt(t);
|
|
4244
4283
|
if (e) {
|
|
4245
4284
|
this.syncChangedControlSnapshots(e.controlIds);
|
|
4246
4285
|
return;
|
|
@@ -4248,12 +4287,12 @@ class Pn {
|
|
|
4248
4287
|
this.syncControlPlugins();
|
|
4249
4288
|
});
|
|
4250
4289
|
var i;
|
|
4251
|
-
if (this.options = t, t.documentVersion !== void 0 && t.documentVersion !==
|
|
4290
|
+
if (this.options = t, t.documentVersion !== void 0 && t.documentVersion !== J)
|
|
4252
4291
|
throw new S(
|
|
4253
4292
|
"INVALID_DOCUMENT",
|
|
4254
4293
|
`Unsupported report document version: ${t.documentVersion}.`
|
|
4255
4294
|
);
|
|
4256
|
-
this.editorId = t.editorId ?? this.createEditorId(), this.controlPlugins = t.controlPlugins ?? [], this.documentVersion = t.documentVersion ??
|
|
4295
|
+
this.editorId = t.editorId ?? this.createEditorId(), this.controlPlugins = t.controlPlugins ?? [], this.documentVersion = t.documentVersion ?? J, this.registry = Y(t.features), this.errors = new gt(t.onError), this.identity = new Nt(this.registry), this.pageBreakIdentity = new ye(), this.pasteSanitizer = new Te(), this.serializer = new Dn(this.documentVersion, this.errors, this.registry), this.templateEngine = new Pn(this.errors, this.identity, this.registry), this.selectionManager = new xn(this.errors), this.numberingService = new Ie(this.registry.numberedBlockNodeNames()[0] ?? "reportNumberedBlock");
|
|
4257
4296
|
const e = this.createOperationBatchId();
|
|
4258
4297
|
this.currentOperationBatchId = e;
|
|
4259
4298
|
const n = this.resolveInitialContent(t, e), o = new vt(
|
|
@@ -4271,15 +4310,15 @@ class Pn {
|
|
|
4271
4310
|
`Invalid visibilityGroup mark rejected from transaction: ${a.nodeName}.`,
|
|
4272
4311
|
a
|
|
4273
4312
|
)
|
|
4274
|
-
).create(), s =
|
|
4275
|
-
this.editor = new
|
|
4313
|
+
).create(), s = Be(o);
|
|
4314
|
+
this.editor = new Oe({
|
|
4276
4315
|
element: t.element,
|
|
4277
4316
|
extensions: o,
|
|
4278
4317
|
content: this.resolveInitialTiptapContent(n, e, s),
|
|
4279
4318
|
editable: !t.readonly,
|
|
4280
4319
|
enableContentCheck: !0,
|
|
4281
4320
|
editorProps: {
|
|
4282
|
-
handleTextInput:
|
|
4321
|
+
handleTextInput: Xe,
|
|
4283
4322
|
handleDOMEvents: {
|
|
4284
4323
|
compositionstart: kt,
|
|
4285
4324
|
compositionend: kt
|
|
@@ -4404,7 +4443,7 @@ class Pn {
|
|
|
4404
4443
|
getPageBreaks() {
|
|
4405
4444
|
const t = [];
|
|
4406
4445
|
return this.editor.state.doc.descendants((e, n) => {
|
|
4407
|
-
if (e.type.name !==
|
|
4446
|
+
if (e.type.name !== k)
|
|
4408
4447
|
return;
|
|
4409
4448
|
const o = e.attrs.id;
|
|
4410
4449
|
typeof o == "string" && o.trim() && t.push({ id: o, pos: n });
|
|
@@ -4614,7 +4653,7 @@ class Pn {
|
|
|
4614
4653
|
}
|
|
4615
4654
|
/** Separates high-level content operations from adjacent local ProseMirror history events. */
|
|
4616
4655
|
closeLocalHistoryEvent() {
|
|
4617
|
-
const t =
|
|
4656
|
+
const t = Le(this.editor.state.tr).setMeta("addToHistory", !1);
|
|
4618
4657
|
this.editor.view.dispatch(t);
|
|
4619
4658
|
}
|
|
4620
4659
|
/** 从插件读取外层共享批次。 */
|
|
@@ -4671,14 +4710,14 @@ class Pn {
|
|
|
4671
4710
|
const s = this.parseHTMLContent(t, n), i = this.pageBreakIdentity.normalizeDocument(this.identity.normalizeDocument(s, e));
|
|
4672
4711
|
return jt(i, this.registry, n), i;
|
|
4673
4712
|
}
|
|
4674
|
-
|
|
4713
|
+
Bn(t, this.documentVersion);
|
|
4675
4714
|
const o = this.pageBreakIdentity.normalizeDocument(this.identity.normalizeDocument(t, e));
|
|
4676
4715
|
return jt(o, this.registry, n), o;
|
|
4677
4716
|
}
|
|
4678
4717
|
/** 将 HTML 输入解析为报告文档,随后仍走统一文档校验。 */
|
|
4679
4718
|
parseHTMLContent(t, e) {
|
|
4680
4719
|
try {
|
|
4681
|
-
const n = this.pasteSanitizer.sanitize(t), o =
|
|
4720
|
+
const n = this.pasteSanitizer.sanitize(t), o = Kt(n, e, {}, { errorOnInvalidContent: !1 });
|
|
4682
4721
|
return L.fromTiptapJSON(o.toJSON(), this.documentVersion);
|
|
4683
4722
|
} catch (n) {
|
|
4684
4723
|
throw new S("INVALID_DOCUMENT", "HTML content could not be parsed.", n);
|
|
@@ -4743,7 +4782,7 @@ class Pn {
|
|
|
4743
4782
|
a.setNodeMarkup(d, void 0, {
|
|
4744
4783
|
...u
|
|
4745
4784
|
}, l.marks), i = this.isStableControlIdentity(l.attrs, u), n = !0;
|
|
4746
|
-
}), n ? s ? (o && (i && (a =
|
|
4785
|
+
}), n ? s ? (o && (i && (a = Ct(a, [t])), this.editor.view.dispatch(a)), !0) : !1 : (this.errors.warning("INVALID_FIELD_CONFIG", `Control not found: ${t}.`, { controlId: t }), !1);
|
|
4747
4786
|
}
|
|
4748
4787
|
/** 在文档树中按 fieldName 查找控件并批量更新节点属性。 */
|
|
4749
4788
|
updateNodeAttrsByFieldName(t, e) {
|
|
@@ -4779,7 +4818,7 @@ class Pn {
|
|
|
4779
4818
|
const d = a.doc.nodeAt(l.pos);
|
|
4780
4819
|
a.setNodeMarkup(l.pos, void 0, l.attrs, d == null ? void 0 : d.marks);
|
|
4781
4820
|
}
|
|
4782
|
-
return i.every((l) => l.stableIdentity) && (a =
|
|
4821
|
+
return i.every((l) => l.stableIdentity) && (a = Ct(
|
|
4783
4822
|
a,
|
|
4784
4823
|
i.map((l) => String(l.attrs.controlId ?? ""))
|
|
4785
4824
|
)), this.editor.view.dispatch(a), !0;
|
|
@@ -4789,10 +4828,10 @@ class Pn {
|
|
|
4789
4828
|
return typeof e.controlId == "string" && e.controlId.trim().length > 0 && e.controlId === t.controlId && typeof e.batchId == "string" && e.batchId.trim().length > 0;
|
|
4790
4829
|
}
|
|
4791
4830
|
}
|
|
4792
|
-
function
|
|
4793
|
-
return new
|
|
4831
|
+
function eo(r = {}) {
|
|
4832
|
+
return new Rn(r);
|
|
4794
4833
|
}
|
|
4795
|
-
class
|
|
4834
|
+
class zn {
|
|
4796
4835
|
/** 创建编辑器分组管理器。 */
|
|
4797
4836
|
constructor(t = {}) {
|
|
4798
4837
|
p(this, "editors", /* @__PURE__ */ new Map());
|
|
@@ -4864,7 +4903,7 @@ const G = class G {
|
|
|
4864
4903
|
this.options = t, this.maxDepth = Math.min(
|
|
4865
4904
|
Math.max(1, t.maxDepth ?? G.DEFAULT_MAX_DEPTH),
|
|
4866
4905
|
G.MAX_DEPTH_LIMIT
|
|
4867
|
-
), this.editorGroup = t.editorGroup ?? new
|
|
4906
|
+
), this.editorGroup = t.editorGroup ?? new zn();
|
|
4868
4907
|
}
|
|
4869
4908
|
/** Registers an editor and stores its initial document snapshot. */
|
|
4870
4909
|
register(t, e) {
|
|
@@ -5315,12 +5354,12 @@ function H(r) {
|
|
|
5315
5354
|
return (typeof r == "object" || typeof r == "function") && r !== null && "then" in r && typeof r.then == "function";
|
|
5316
5355
|
}
|
|
5317
5356
|
export {
|
|
5318
|
-
|
|
5357
|
+
zn as ReportEditorGroupManager,
|
|
5319
5358
|
Wt as SharedHistoryManager,
|
|
5320
|
-
|
|
5321
|
-
|
|
5322
|
-
|
|
5323
|
-
|
|
5324
|
-
|
|
5325
|
-
|
|
5359
|
+
eo as createReportEditor,
|
|
5360
|
+
Y as createReportFeatureRegistry,
|
|
5361
|
+
Zn as defineReportControl,
|
|
5362
|
+
to as defineReportFeature,
|
|
5363
|
+
Qn as defineReportMark,
|
|
5364
|
+
Yn as defineReportNode
|
|
5326
5365
|
};
|