@sw7d/paper-renderer 0.5.2 → 0.5.3
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/paper-renderer.js +53 -22
- package/package.json +1 -1
package/dist/paper-renderer.js
CHANGED
|
@@ -3651,7 +3651,10 @@ function br(e) {
|
|
|
3651
3651
|
//#region src/utils/questionHtmlParser.ts
|
|
3652
3652
|
var xr = 0, Sr = 0, Cr = 0, wr = .5;
|
|
3653
3653
|
function Tr(e, t = {}) {
|
|
3654
|
-
let { questionNo: n = "", score: r = "", contentWidth: i = 600, fontSize: a = 16, lineSpacing: o = 1, protectContent: s = !1, inlineOnly: c = !1 } = t, l = new DOMParser().parseFromString(e, "text/html"), u = [], d = Math.round(a * o * 1.67), f =
|
|
3654
|
+
let { questionNo: n = "", score: r = "", contentWidth: i = 600, fontSize: a = 16, lineSpacing: o = 1, protectContent: s = !1, inlineOnly: c = !1 } = t, l = new DOMParser().parseFromString(e, "text/html"), u = [], d = Math.round(a * o * 1.67), f = Xe({
|
|
3655
|
+
type: "question",
|
|
3656
|
+
metadata: { questionNo: n }
|
|
3657
|
+
}), p = new Set([
|
|
3655
3658
|
"p",
|
|
3656
3659
|
"h1",
|
|
3657
3660
|
"h2",
|
|
@@ -3673,7 +3676,8 @@ function Tr(e, t = {}) {
|
|
|
3673
3676
|
u.push({
|
|
3674
3677
|
lines: e,
|
|
3675
3678
|
y: 0,
|
|
3676
|
-
height: t
|
|
3679
|
+
height: t,
|
|
3680
|
+
split: !0
|
|
3677
3681
|
});
|
|
3678
3682
|
continue;
|
|
3679
3683
|
}
|
|
@@ -3684,7 +3688,8 @@ function Tr(e, t = {}) {
|
|
|
3684
3688
|
u.push({
|
|
3685
3689
|
lines: t,
|
|
3686
3690
|
y: 0,
|
|
3687
|
-
height: n
|
|
3691
|
+
height: n,
|
|
3692
|
+
split: !0
|
|
3688
3693
|
});
|
|
3689
3694
|
}
|
|
3690
3695
|
continue;
|
|
@@ -3701,7 +3706,8 @@ function Tr(e, t = {}) {
|
|
|
3701
3706
|
lines: r,
|
|
3702
3707
|
y: 0,
|
|
3703
3708
|
height: o,
|
|
3704
|
-
justification: Or(n, e, c)
|
|
3709
|
+
justification: Or(n, e, c),
|
|
3710
|
+
split: !0
|
|
3705
3711
|
});
|
|
3706
3712
|
} else if (n === "table" || n === "figure") {
|
|
3707
3713
|
let e = n === "table" ? t : t.querySelector("table");
|
|
@@ -3712,7 +3718,8 @@ function Tr(e, t = {}) {
|
|
|
3712
3718
|
u.push({
|
|
3713
3719
|
lines: n,
|
|
3714
3720
|
y: 0,
|
|
3715
|
-
height: r
|
|
3721
|
+
height: r,
|
|
3722
|
+
split: !0
|
|
3716
3723
|
});
|
|
3717
3724
|
continue;
|
|
3718
3725
|
}
|
|
@@ -3720,7 +3727,8 @@ function Tr(e, t = {}) {
|
|
|
3720
3727
|
u.push({
|
|
3721
3728
|
lines: r,
|
|
3722
3729
|
y: 0,
|
|
3723
|
-
height: o
|
|
3730
|
+
height: o,
|
|
3731
|
+
split: !0
|
|
3724
3732
|
});
|
|
3725
3733
|
} else {
|
|
3726
3734
|
let e = t.getAttribute("style") || "", n = Er(t, a, e, i, f, c);
|
|
@@ -3730,7 +3738,8 @@ function Tr(e, t = {}) {
|
|
|
3730
3738
|
lines: r,
|
|
3731
3739
|
y: 0,
|
|
3732
3740
|
height: o,
|
|
3733
|
-
justification: Or(n, e, c)
|
|
3741
|
+
justification: Or(n, e, c),
|
|
3742
|
+
split: !0
|
|
3734
3743
|
});
|
|
3735
3744
|
}
|
|
3736
3745
|
}
|
|
@@ -3743,7 +3752,8 @@ function Tr(e, t = {}) {
|
|
|
3743
3752
|
lines: h,
|
|
3744
3753
|
y: 0,
|
|
3745
3754
|
height: g,
|
|
3746
|
-
justification: Or(m, s, c)
|
|
3755
|
+
justification: Or(m, s, c),
|
|
3756
|
+
split: !0
|
|
3747
3757
|
});
|
|
3748
3758
|
}
|
|
3749
3759
|
let m = U(u), h = `topic-html-${++Sr}`;
|
|
@@ -4151,7 +4161,13 @@ function zr(e, t) {
|
|
|
4151
4161
|
return f.height = U(f.paragraphs), [f];
|
|
4152
4162
|
}
|
|
4153
4163
|
function Br(e, t) {
|
|
4154
|
-
let { questionNo: n, score: r, contentWidth: i, fontSize: a, lineSpacing: o, protectContent: s } = t, c = "answer_question", l = Date.now(), u = Math.random().toString(36).slice(2, 8), d = e.id ? `group-${e.id}-${l}-${u}` : `group-${e.qid || l}-${u}`, f =
|
|
4164
|
+
let { questionNo: n, score: r, contentWidth: i, fontSize: a, lineSpacing: o, protectContent: s } = t, c = "answer_question", l = Date.now(), u = Math.random().toString(36).slice(2, 8), d = e.id ? `group-${e.id}-${l}-${u}` : `group-${e.qid || l}-${u}`, f = Xe({
|
|
4165
|
+
type: "question",
|
|
4166
|
+
metadata: { questionNo: n }
|
|
4167
|
+
}), p = Xe({
|
|
4168
|
+
type: "sub-question",
|
|
4169
|
+
metadata: { subLabel: "(1)" }
|
|
4170
|
+
}), m = i + f, h = Math.max(100, m - p), g = [], _ = Tr(e.question, {
|
|
4155
4171
|
questionNo: n,
|
|
4156
4172
|
score: r || "",
|
|
4157
4173
|
contentWidth: i,
|
|
@@ -4159,8 +4175,8 @@ function Br(e, t) {
|
|
|
4159
4175
|
lineSpacing: o,
|
|
4160
4176
|
protectContent: s
|
|
4161
4177
|
});
|
|
4162
|
-
if (
|
|
4163
|
-
let t =
|
|
4178
|
+
if (_.length > 0) {
|
|
4179
|
+
let t = _[0];
|
|
4164
4180
|
t.type = "question", t.metadata = {
|
|
4165
4181
|
...t.metadata,
|
|
4166
4182
|
qid: e.qid,
|
|
@@ -4171,11 +4187,11 @@ function Br(e, t) {
|
|
|
4171
4187
|
blockGroup: d,
|
|
4172
4188
|
hasSubQuestions: !0,
|
|
4173
4189
|
score: r || ""
|
|
4174
|
-
}, t.keepNext = !0, t.height = U(t.paragraphs),
|
|
4190
|
+
}, t.keepNext = !0, t.height = U(t.paragraphs), g.push(t);
|
|
4175
4191
|
}
|
|
4176
4192
|
if (e.children) for (let t = 0; t < e.children.length; t++) {
|
|
4177
4193
|
let n = e.children[t], r = `(${t + 1})`, i = Tr(n.question, {
|
|
4178
|
-
contentWidth:
|
|
4194
|
+
contentWidth: h,
|
|
4179
4195
|
fontSize: a,
|
|
4180
4196
|
lineSpacing: o,
|
|
4181
4197
|
protectContent: s
|
|
@@ -4195,9 +4211,9 @@ function Br(e, t) {
|
|
|
4195
4211
|
tenantId: n.tenant_id,
|
|
4196
4212
|
tags: n.tags,
|
|
4197
4213
|
score: ""
|
|
4198
|
-
}, l.height = U(l.paragraphs),
|
|
4214
|
+
}, l.height = U(l.paragraphs), g.push(l);
|
|
4199
4215
|
}
|
|
4200
|
-
return
|
|
4216
|
+
return g;
|
|
4201
4217
|
}
|
|
4202
4218
|
function Vr(e, t, n, r) {
|
|
4203
4219
|
let i = Math.max(100, t - 20);
|
|
@@ -4218,7 +4234,8 @@ function Vr(e, t, n, r) {
|
|
|
4218
4234
|
y: 0
|
|
4219
4235
|
}],
|
|
4220
4236
|
y: 0,
|
|
4221
|
-
height: e + 4
|
|
4237
|
+
height: e + 4,
|
|
4238
|
+
split: !0
|
|
4222
4239
|
});
|
|
4223
4240
|
}
|
|
4224
4241
|
return {
|
|
@@ -10332,7 +10349,7 @@ function Zi(e) {
|
|
|
10332
10349
|
}
|
|
10333
10350
|
u = We(l, r, o, t > 0 ? t : void 0, 0), a = !0;
|
|
10334
10351
|
}
|
|
10335
|
-
e.paragraphs[s].justification && (u.justification = e.paragraphs[s].justification), i.push(u);
|
|
10352
|
+
e.paragraphs[s].justification && (u.justification = e.paragraphs[s].justification), e.paragraphs[s].split !== void 0 && (u.split = e.paragraphs[s].split), i.push(u);
|
|
10336
10353
|
}
|
|
10337
10354
|
let c = i.length;
|
|
10338
10355
|
for (let e = 0; e < i.length; e++) {
|
|
@@ -10754,9 +10771,17 @@ function Zi(e) {
|
|
|
10754
10771
|
let o = e.content.split("\n").filter((e) => e.trim());
|
|
10755
10772
|
o.length === 0 && o.push("");
|
|
10756
10773
|
let s = e.score ? `(${e.score}分)` : "", c = o.some((e) => /^\(\d+\)\s*/.test(e)), l = V(n.value), u = He(n.value), f = a.value.columnWidth, p;
|
|
10757
|
-
if (c)
|
|
10758
|
-
|
|
10759
|
-
|
|
10774
|
+
if (c) {
|
|
10775
|
+
let t = Xe({
|
|
10776
|
+
type: "sub-question",
|
|
10777
|
+
metadata: { subLabel: "(1)" }
|
|
10778
|
+
});
|
|
10779
|
+
p = nt(e.no, s, o, l, u, f - t, r);
|
|
10780
|
+
} else {
|
|
10781
|
+
let t = Xe({
|
|
10782
|
+
type: "question",
|
|
10783
|
+
metadata: { questionNo: e.no }
|
|
10784
|
+
});
|
|
10760
10785
|
p = [tt(e.no, s, o, l, u, f - t, r)];
|
|
10761
10786
|
}
|
|
10762
10787
|
for (let e of p) t.value = [...t.value, e];
|
|
@@ -10764,7 +10789,10 @@ function Zi(e) {
|
|
|
10764
10789
|
}
|
|
10765
10790
|
function ue(e, r, o, s = !1) {
|
|
10766
10791
|
y();
|
|
10767
|
-
let c = V(n.value), l = He(n.value), u = a.value.columnWidth, f = (
|
|
10792
|
+
let c = V(n.value), l = He(n.value), u = a.value.columnWidth, f = Xe({
|
|
10793
|
+
type: "question",
|
|
10794
|
+
metadata: { questionNo: r || "" }
|
|
10795
|
+
}), p = Tr(e, {
|
|
10768
10796
|
questionNo: r || "",
|
|
10769
10797
|
score: o || "",
|
|
10770
10798
|
contentWidth: u - f,
|
|
@@ -10777,7 +10805,10 @@ function Zi(e) {
|
|
|
10777
10805
|
}
|
|
10778
10806
|
function de(e, r, o, s = !1) {
|
|
10779
10807
|
y();
|
|
10780
|
-
let c = V(n.value), l = He(n.value), u = a.value.columnWidth, f = (
|
|
10808
|
+
let c = V(n.value), l = He(n.value), u = a.value.columnWidth, f = Xe({
|
|
10809
|
+
type: "question",
|
|
10810
|
+
metadata: { questionNo: r || "" }
|
|
10811
|
+
}), p;
|
|
10781
10812
|
try {
|
|
10782
10813
|
p = JSON.parse(e);
|
|
10783
10814
|
} catch {
|