@sw7d/paper-renderer 0.1.9 → 0.1.10
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 +196 -186
- package/package.json +1 -1
package/dist/paper-renderer.js
CHANGED
|
@@ -2048,7 +2048,7 @@ function mt(e) {
|
|
|
2048
2048
|
isTitle: !0
|
|
2049
2049
|
};
|
|
2050
2050
|
return t.topicTitle && (r.title = String(t.title || "")), {
|
|
2051
|
-
id: `title-${e.props.id}`,
|
|
2051
|
+
id: `title-${e.props.id}-${++ht}`,
|
|
2052
2052
|
type: "title",
|
|
2053
2053
|
paragraphs: [],
|
|
2054
2054
|
height: e.props.rect?.height || 40,
|
|
@@ -2056,9 +2056,10 @@ function mt(e) {
|
|
|
2056
2056
|
keepNext: e.props.keepNext ?? !1
|
|
2057
2057
|
};
|
|
2058
2058
|
}
|
|
2059
|
+
var ht = 0;
|
|
2059
2060
|
//#endregion
|
|
2060
2061
|
//#region src/utils/documentSerializer.ts
|
|
2061
|
-
function
|
|
2062
|
+
function gt(e, t, n = {}) {
|
|
2062
2063
|
let r = Xe(e, t), i = {
|
|
2063
2064
|
info: {
|
|
2064
2065
|
author: "",
|
|
@@ -2320,13 +2321,13 @@ function ht(e, t, n = {}) {
|
|
|
2320
2321
|
};
|
|
2321
2322
|
return n.pages && n.pages.length > 0 && (i._pages = et(n.pages, n.blocks || [], t.showScore)), JSON.stringify(i, null, 2);
|
|
2322
2323
|
}
|
|
2323
|
-
function
|
|
2324
|
+
function _t(e) {
|
|
2324
2325
|
return ft(e);
|
|
2325
2326
|
}
|
|
2326
2327
|
//#endregion
|
|
2327
2328
|
//#region src/utils/questionHtmlParser.ts
|
|
2328
|
-
var
|
|
2329
|
-
function
|
|
2329
|
+
var vt = 0, yt = 0, bt = 0, xt = .5;
|
|
2330
|
+
function St(e, t = {}) {
|
|
2330
2331
|
let { questionNo: n = "", score: r = "", contentWidth: i = 600, fontSize: a = 14, lineSpacing: o = 1.5, skipAnswerArea: s = !1, protectContent: c = !1 } = t, l = new DOMParser().parseFromString(e, "text/html"), u = [], d = Math.round(a * o * 1.67), f = n.length > 2 ? 26.25 : 17.5, p = new Set([
|
|
2331
2332
|
"p",
|
|
2332
2333
|
"h1",
|
|
@@ -2345,7 +2346,7 @@ function xt(e, t = {}) {
|
|
|
2345
2346
|
if (t.nodeType !== Node.ELEMENT_NODE) continue;
|
|
2346
2347
|
let n = t, r = n.tagName.toLowerCase();
|
|
2347
2348
|
if (r === "table") {
|
|
2348
|
-
let e =
|
|
2349
|
+
let e = Mt(n, i, d), t = e.reduce((e, t) => e + t.lineHeight, 0) + 4;
|
|
2349
2350
|
u.push({
|
|
2350
2351
|
lines: e,
|
|
2351
2352
|
y: 0,
|
|
@@ -2356,7 +2357,7 @@ function xt(e, t = {}) {
|
|
|
2356
2357
|
if (r === "figure") {
|
|
2357
2358
|
let e = n.querySelector("table");
|
|
2358
2359
|
if (e) {
|
|
2359
|
-
let t =
|
|
2360
|
+
let t = Mt(e, i, d), n = t.reduce((e, t) => e + t.lineHeight, 0) + 4;
|
|
2360
2361
|
u.push({
|
|
2361
2362
|
lines: t,
|
|
2362
2363
|
y: 0,
|
|
@@ -2368,7 +2369,7 @@ function xt(e, t = {}) {
|
|
|
2368
2369
|
if (!p.has(r)) continue;
|
|
2369
2370
|
let o = n, s = o.getAttribute("style") || "", c = J(o, a, s, i, f);
|
|
2370
2371
|
if (c.length === 0) continue;
|
|
2371
|
-
let m = it(c, i, d), h = m.reduce((e, t) => e + t.lineHeight, 0) + 4, g =
|
|
2372
|
+
let m = it(c, i, d), h = m.reduce((e, t) => e + t.lineHeight, 0) + 4, g = Tt(s), _ = g === "center" ? "center" : g === "right" ? "right" : void 0;
|
|
2372
2373
|
u.push({
|
|
2373
2374
|
lines: m,
|
|
2374
2375
|
y: 0,
|
|
@@ -2390,7 +2391,7 @@ function xt(e, t = {}) {
|
|
|
2390
2391
|
y: 0,
|
|
2391
2392
|
height: d + 4
|
|
2392
2393
|
});
|
|
2393
|
-
let m = u.reduce((e, t) => e + (t.height || 26), 0), h = `topic-html-${++
|
|
2394
|
+
let m = u.reduce((e, t) => e + (t.height || 26), 0), h = `topic-html-${++yt}`;
|
|
2394
2395
|
return [{
|
|
2395
2396
|
id: `q-html-${Date.now()}-${Math.random().toString(36).slice(2, 6)}`,
|
|
2396
2397
|
type: "question",
|
|
@@ -2416,13 +2417,13 @@ function J(e, t, n, r, i) {
|
|
|
2416
2417
|
let r = e.replace(/\u00A0/g, " ").replace(/\n/g, "").replace(/\s+/g, " ");
|
|
2417
2418
|
if (!r.trim()) {
|
|
2418
2419
|
if (a.length > 0) {
|
|
2419
|
-
let e =
|
|
2420
|
-
a.push(
|
|
2420
|
+
let e = Et(n) || t, r = Dt(n) || "\"Times New Roman\", SimSun", i = Ot(n) || "#000", o = /font-style:\s*(italic|oblique)/.test(n);
|
|
2421
|
+
a.push(wt("\xA0", e, r, !1, i, o));
|
|
2421
2422
|
}
|
|
2422
2423
|
continue;
|
|
2423
2424
|
}
|
|
2424
|
-
let i = r.startsWith(" ") && a.length > 0, o = r.endsWith(" "), c = r.trim(), l = (i ? "\xA0" : "") + c + (o ? "\xA0" : ""), u =
|
|
2425
|
-
a.push(
|
|
2425
|
+
let i = r.startsWith(" ") && a.length > 0, o = r.endsWith(" "), c = r.trim(), l = (i ? "\xA0" : "") + c + (o ? "\xA0" : ""), u = Et(n) || t, d = Dt(n) || "\"Times New Roman\", SimSun", f = Ot(n) || "#000", p = /font-weight:\s*(bold|700|[89]\d\d)/.test(n), m = /font-style:\s*(italic|oblique)/.test(n);
|
|
2426
|
+
a.push(wt(l, u, d, p, f, m));
|
|
2426
2427
|
continue;
|
|
2427
2428
|
}
|
|
2428
2429
|
if (s.nodeType !== Node.ELEMENT_NODE) continue;
|
|
@@ -2463,14 +2464,14 @@ function J(e, t, n, r, i) {
|
|
|
2463
2464
|
}
|
|
2464
2465
|
a.push({
|
|
2465
2466
|
type: "image",
|
|
2466
|
-
id: `inline-img-${++
|
|
2467
|
+
id: `inline-img-${++bt}`,
|
|
2467
2468
|
src: e,
|
|
2468
2469
|
width: l,
|
|
2469
2470
|
height: d
|
|
2470
2471
|
});
|
|
2471
2472
|
continue;
|
|
2472
2473
|
}
|
|
2473
|
-
let f =
|
|
2474
|
+
let f = Ct(d);
|
|
2474
2475
|
if (l === "span" && f) {
|
|
2475
2476
|
let e = c.textContent || "", { blankType: t, isEmpty: n } = f, r;
|
|
2476
2477
|
if (t === "tiankong") {
|
|
@@ -2479,7 +2480,7 @@ function J(e, t, n, r, i) {
|
|
|
2479
2480
|
} else r = Math.max(40, e.length * 14 + 10);
|
|
2480
2481
|
a.push({
|
|
2481
2482
|
type: "underline",
|
|
2482
|
-
id: `ul-html-${++
|
|
2483
|
+
id: `ul-html-${++vt}`,
|
|
2483
2484
|
width: r,
|
|
2484
2485
|
height: 20,
|
|
2485
2486
|
placeholder: t === "tiankong" ? "空" : t === "xuanze" ? "选" : "判",
|
|
@@ -2493,7 +2494,7 @@ function J(e, t, n, r, i) {
|
|
|
2493
2494
|
if (l === "span" && d.includes("under-point")) {
|
|
2494
2495
|
let e = c.textContent || "";
|
|
2495
2496
|
if (e.trim()) {
|
|
2496
|
-
let r =
|
|
2497
|
+
let r = Et(u) || Et(n) || t, i = Dt(u) || Dt(n) || "\"Times New Roman\", SimSun", o = Ot(u) || Ot(n) || "#000", s = /font-style:\s*(italic|oblique)/.test(u) || /font-style:\s*(italic|oblique)/.test(n), c = wt(e.trim(), r, i, !1, o, s);
|
|
2497
2498
|
c.dotAbove = !0, a.push(c);
|
|
2498
2499
|
}
|
|
2499
2500
|
continue;
|
|
@@ -2501,7 +2502,7 @@ function J(e, t, n, r, i) {
|
|
|
2501
2502
|
if (l === "span" && d.includes("wavy-line")) {
|
|
2502
2503
|
let e = c.textContent || "";
|
|
2503
2504
|
if (e.trim()) {
|
|
2504
|
-
let r =
|
|
2505
|
+
let r = Et(u) || Et(n) || t, i = Dt(u) || Dt(n) || "\"Times New Roman\", SimSun", o = Ot(u) || Ot(n) || "#000", s = /font-style:\s*(italic|oblique)/.test(u) || /font-style:\s*(italic|oblique)/.test(n), c = wt(e.trim(), r, i, !1, o, s);
|
|
2505
2506
|
c.wavyLine = !0, a.push(c);
|
|
2506
2507
|
}
|
|
2507
2508
|
continue;
|
|
@@ -2541,7 +2542,7 @@ function J(e, t, n, r, i) {
|
|
|
2541
2542
|
let e = c.outerHTML, t = parseInt(u.match(/width:\s*(\d+)px/)?.[1] || "0"), n = u.match(/width:\s*([\d.]+)%/), i = c.querySelectorAll("tr").length, o = Math.max(60, i * 30 + 40), s = n ? Math.round(parseFloat(n[1]) / 100 * r) : t || r;
|
|
2542
2543
|
a.push({
|
|
2543
2544
|
type: "image",
|
|
2544
|
-
id: `inline-img-${++
|
|
2545
|
+
id: `inline-img-${++bt}`,
|
|
2545
2546
|
src: "",
|
|
2546
2547
|
width: Math.min(s, r),
|
|
2547
2548
|
height: o,
|
|
@@ -2555,7 +2556,7 @@ function J(e, t, n, r, i) {
|
|
|
2555
2556
|
let t = e.outerHTML, n = e.getAttribute("style") || "", i = parseInt(n.match(/width:\s*(\d+)px/)?.[1] || "0"), o = n.match(/width:\s*([\d.]+)%/), s = e.querySelectorAll("tr").length, c = Math.max(60, s * 30 + 40), l = o ? Math.round(parseFloat(o[1]) / 100 * r) : i || r;
|
|
2556
2557
|
a.push({
|
|
2557
2558
|
type: "image",
|
|
2558
|
-
id: `inline-img-${++
|
|
2559
|
+
id: `inline-img-${++bt}`,
|
|
2559
2560
|
src: "",
|
|
2560
2561
|
width: Math.min(l, r),
|
|
2561
2562
|
height: c,
|
|
@@ -2568,7 +2569,7 @@ function J(e, t, n, r, i) {
|
|
|
2568
2569
|
continue;
|
|
2569
2570
|
}
|
|
2570
2571
|
if (l === "sub" || l === "sup") {
|
|
2571
|
-
let e = Math.round(t *
|
|
2572
|
+
let e = Math.round(t * xt), o = J(c, e, (u || n).replace(/font-size:\s*[^;]+;?/, "") + `;font-size:${e}px`, r, i), s = Math.round(l === "sub" ? t * .52 : -t * .25);
|
|
2572
2573
|
for (let e of o) e.type === "text" && (e.verticalAlign = s);
|
|
2573
2574
|
a.push(...o);
|
|
2574
2575
|
continue;
|
|
@@ -2586,7 +2587,7 @@ function J(e, t, n, r, i) {
|
|
|
2586
2587
|
}
|
|
2587
2588
|
let f = u.match(/background-color:\s*([^;]+)/);
|
|
2588
2589
|
if (f && f[1] && f[1] !== "transparent") {
|
|
2589
|
-
let e =
|
|
2590
|
+
let e = jt(f[1]);
|
|
2590
2591
|
if (e) for (let t of l) t.type === "text" && (t.backgroundColor = e);
|
|
2591
2592
|
}
|
|
2592
2593
|
a.push(...l);
|
|
@@ -2597,7 +2598,7 @@ function J(e, t, n, r, i) {
|
|
|
2597
2598
|
}
|
|
2598
2599
|
return a;
|
|
2599
2600
|
}
|
|
2600
|
-
function
|
|
2601
|
+
function Ct(e) {
|
|
2601
2602
|
return e.includes("blank-tiankong") || e.includes("blank_tiankong") ? {
|
|
2602
2603
|
blankType: "tiankong",
|
|
2603
2604
|
isEmpty: !0
|
|
@@ -2609,7 +2610,7 @@ function St(e) {
|
|
|
2609
2610
|
isEmpty: !1
|
|
2610
2611
|
} : null;
|
|
2611
2612
|
}
|
|
2612
|
-
function
|
|
2613
|
+
function wt(e, t, n, r, i, a) {
|
|
2613
2614
|
let o = e.split(""), s = B(e, t, n, r, a || !1), c = s.length > 0 ? s[s.length - 1] + z(o[o.length - 1], t, n, r, a || !1) : 0;
|
|
2614
2615
|
return {
|
|
2615
2616
|
type: "text",
|
|
@@ -2624,19 +2625,19 @@ function Ct(e, t, n, r, i, a) {
|
|
|
2624
2625
|
xPositions: s
|
|
2625
2626
|
};
|
|
2626
2627
|
}
|
|
2627
|
-
function
|
|
2628
|
+
function Tt(e) {
|
|
2628
2629
|
let t = e.match(/text-align:\s*(right|center|left)/);
|
|
2629
2630
|
return t ? t[1] : "left";
|
|
2630
2631
|
}
|
|
2631
|
-
function
|
|
2632
|
+
function Et(e) {
|
|
2632
2633
|
let t = e.match(/font-size:\s*(\d+)px/);
|
|
2633
2634
|
return t ? parseInt(t[1]) : null;
|
|
2634
2635
|
}
|
|
2635
|
-
function
|
|
2636
|
+
function Dt(e) {
|
|
2636
2637
|
let t = e.match(/font-family:\s*([^;]+)/);
|
|
2637
2638
|
return t ? t[1].trim().replace(/["']/g, "") : null;
|
|
2638
2639
|
}
|
|
2639
|
-
function
|
|
2640
|
+
function Ot(e) {
|
|
2640
2641
|
let t = e.match(/color:\s*rgb\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)/);
|
|
2641
2642
|
if (t) return `#${parseInt(t[1]).toString(16).padStart(2, "0")}${parseInt(t[2]).toString(16).padStart(2, "0")}${parseInt(t[3]).toString(16).padStart(2, "0")}`;
|
|
2642
2643
|
let n = e.match(/color:\s*rgba\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,[^)]+\)/);
|
|
@@ -2644,9 +2645,9 @@ function Dt(e) {
|
|
|
2644
2645
|
let r = e.match(/color:\s*(#[0-9a-fA-F]{3,6})/);
|
|
2645
2646
|
if (r) return r[1];
|
|
2646
2647
|
let i = e.match(/color:\s*([a-zA-Z]+)/);
|
|
2647
|
-
return i &&
|
|
2648
|
+
return i && At(i[1]) || null;
|
|
2648
2649
|
}
|
|
2649
|
-
var
|
|
2650
|
+
var kt = {
|
|
2650
2651
|
red: "#ff0000",
|
|
2651
2652
|
green: "#008000",
|
|
2652
2653
|
blue: "#0000ff",
|
|
@@ -2673,16 +2674,16 @@ var Ot = {
|
|
|
2673
2674
|
lightgrey: "#d3d3d3",
|
|
2674
2675
|
transparent: "#000000"
|
|
2675
2676
|
};
|
|
2676
|
-
function kt(e) {
|
|
2677
|
-
return Ot[e.toLowerCase()];
|
|
2678
|
-
}
|
|
2679
2677
|
function At(e) {
|
|
2678
|
+
return kt[e.toLowerCase()];
|
|
2679
|
+
}
|
|
2680
|
+
function jt(e) {
|
|
2680
2681
|
let t = e.trim(), n = t.match(/^#[0-9a-fA-F]{3,6}$/);
|
|
2681
2682
|
if (n) return n[0];
|
|
2682
2683
|
let r = t.match(/^rgb\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)$/);
|
|
2683
|
-
return r ? `#${parseInt(r[1]).toString(16).padStart(2, "0")}${parseInt(r[2]).toString(16).padStart(2, "0")}${parseInt(r[3]).toString(16).padStart(2, "0")}` :
|
|
2684
|
+
return r ? `#${parseInt(r[1]).toString(16).padStart(2, "0")}${parseInt(r[2]).toString(16).padStart(2, "0")}${parseInt(r[3]).toString(16).padStart(2, "0")}` : At(t) || null;
|
|
2684
2685
|
}
|
|
2685
|
-
function
|
|
2686
|
+
function Mt(e, t, n) {
|
|
2686
2687
|
let r = e.outerHTML, i = e.getAttribute("style") || "", a = parseInt(i.match(/width:\s*(\d+)px/)?.[1] || "0"), o = i.match(/width:\s*([\d.]+)%/), s = e.querySelectorAll("tr").length, c = Math.max(60, s * 30 + 40), l = o ? Math.round(parseFloat(o[1]) / 100 * t) : a || t, u = Math.min(l, t), d = c;
|
|
2687
2688
|
return u <= 0 || d <= 0 ? [{
|
|
2688
2689
|
...rt([], n),
|
|
@@ -2690,7 +2691,7 @@ function jt(e, t, n) {
|
|
|
2690
2691
|
}] : [{
|
|
2691
2692
|
...rt([{
|
|
2692
2693
|
type: "image",
|
|
2693
|
-
id: `inline-img-${++
|
|
2694
|
+
id: `inline-img-${++bt}`,
|
|
2694
2695
|
src: "",
|
|
2695
2696
|
width: u,
|
|
2696
2697
|
height: d,
|
|
@@ -2701,8 +2702,8 @@ function jt(e, t, n) {
|
|
|
2701
2702
|
}
|
|
2702
2703
|
//#endregion
|
|
2703
2704
|
//#region src/utils/questionJsonParser.ts
|
|
2704
|
-
function
|
|
2705
|
-
let { questionNo: n = "", score: r = "", contentWidth: i = 600, fontSize: a = 14, lineSpacing: o = 1.5, protectContent: s = !1 } = t, c = e.extra_json?.quest_type || "answer_question", l = c === "single_chose" || c === "multi_chose", u = Math.round(a * o * 1.67), d =
|
|
2705
|
+
function Nt(e, t = {}) {
|
|
2706
|
+
let { questionNo: n = "", score: r = "", contentWidth: i = 600, fontSize: a = 14, lineSpacing: o = 1.5, protectContent: s = !1 } = t, c = e.extra_json?.quest_type || "answer_question", l = c === "single_chose" || c === "multi_chose", u = Math.round(a * o * 1.67), d = St(e.question, {
|
|
2706
2707
|
questionNo: n,
|
|
2707
2708
|
score: r,
|
|
2708
2709
|
contentWidth: i,
|
|
@@ -2729,14 +2730,14 @@ function Mt(e, t = {}) {
|
|
|
2729
2730
|
tags: e.tags
|
|
2730
2731
|
}
|
|
2731
2732
|
};
|
|
2732
|
-
if (l && e.extra_json?.options && e.extra_json.options.length > 0) p.options =
|
|
2733
|
-
else for (let e = 0; e < 2; e++) p.paragraphs.push(
|
|
2733
|
+
if (l && e.extra_json?.options && e.extra_json.options.length > 0) p.options = Pt(e.extra_json.options, i, a, o), p.paragraphs.push(Ft(u));
|
|
2734
|
+
else for (let e = 0; e < 2; e++) p.paragraphs.push(Ft(u));
|
|
2734
2735
|
return p.height = p.paragraphs.reduce((e, t) => e + (t.height || 26), 0), [p];
|
|
2735
2736
|
}
|
|
2736
|
-
function
|
|
2737
|
+
function Pt(e, t, n, r) {
|
|
2737
2738
|
let i = Math.max(100, t - 20);
|
|
2738
2739
|
return e.map((e) => {
|
|
2739
|
-
let t =
|
|
2740
|
+
let t = St(e.content, {
|
|
2740
2741
|
contentWidth: i,
|
|
2741
2742
|
fontSize: n,
|
|
2742
2743
|
lineSpacing: r,
|
|
@@ -2762,7 +2763,7 @@ function Nt(e, t, n, r) {
|
|
|
2762
2763
|
};
|
|
2763
2764
|
});
|
|
2764
2765
|
}
|
|
2765
|
-
function
|
|
2766
|
+
function Ft(e) {
|
|
2766
2767
|
return {
|
|
2767
2768
|
lines: [{
|
|
2768
2769
|
elements: [{
|
|
@@ -2780,7 +2781,7 @@ function Pt(e) {
|
|
|
2780
2781
|
}
|
|
2781
2782
|
//#endregion
|
|
2782
2783
|
//#region src/utils/chineseNumber.ts
|
|
2783
|
-
var
|
|
2784
|
+
var It = [
|
|
2784
2785
|
"",
|
|
2785
2786
|
"一",
|
|
2786
2787
|
"二",
|
|
@@ -2793,34 +2794,34 @@ var Ft = [
|
|
|
2793
2794
|
"九",
|
|
2794
2795
|
"十"
|
|
2795
2796
|
];
|
|
2796
|
-
function
|
|
2797
|
+
function Lt(e) {
|
|
2797
2798
|
if (e <= 0) return "";
|
|
2798
|
-
if (e <= 10) return
|
|
2799
|
+
if (e <= 10) return It[e];
|
|
2799
2800
|
if (e < 20) {
|
|
2800
2801
|
let t = e % 10;
|
|
2801
|
-
return "十" + (t > 0 ?
|
|
2802
|
+
return "十" + (t > 0 ? It[t] : "");
|
|
2802
2803
|
}
|
|
2803
2804
|
if (e < 100) {
|
|
2804
2805
|
let t = Math.floor(e / 10), n = e % 10;
|
|
2805
|
-
return
|
|
2806
|
+
return It[t] + "十" + (n > 0 ? It[n] : "");
|
|
2806
2807
|
}
|
|
2807
2808
|
if (e < 1e3) {
|
|
2808
|
-
let t = Math.floor(e / 100), n = e % 100, r =
|
|
2809
|
-
return n === 0 ? r : n < 10 ? r + "零" +
|
|
2809
|
+
let t = Math.floor(e / 100), n = e % 100, r = It[t] + "百";
|
|
2810
|
+
return n === 0 ? r : n < 10 ? r + "零" + It[n] : r + Lt(n);
|
|
2810
2811
|
}
|
|
2811
2812
|
return String(e);
|
|
2812
2813
|
}
|
|
2813
|
-
function
|
|
2814
|
-
let n =
|
|
2814
|
+
function Rt(e, t) {
|
|
2815
|
+
let n = Lt(t);
|
|
2815
2816
|
return n ? n + "、" + e : e;
|
|
2816
2817
|
}
|
|
2817
|
-
function
|
|
2818
|
+
function zt(e) {
|
|
2818
2819
|
let t = e.match(/^[一二三四五六七八九十百零]+、(.+)$/);
|
|
2819
2820
|
return t ? t[1] : e;
|
|
2820
2821
|
}
|
|
2821
2822
|
//#endregion
|
|
2822
2823
|
//#region src/utils/paperHtmlBuilder.ts
|
|
2823
|
-
function
|
|
2824
|
+
function Bt(e) {
|
|
2824
2825
|
let t = A[e];
|
|
2825
2826
|
return `
|
|
2826
2827
|
/* ---------- Reset & Base ---------- */
|
|
@@ -3141,7 +3142,7 @@ text.swed-question-score {
|
|
|
3141
3142
|
}
|
|
3142
3143
|
`;
|
|
3143
3144
|
}
|
|
3144
|
-
function
|
|
3145
|
+
function Vt(e) {
|
|
3145
3146
|
let { svgs: t, paperName: n = "试卷", paperSize: r = "A4" } = e, i = t.map((e) => {
|
|
3146
3147
|
let t = e.match(/viewBox="0 0 (\d+(?:\.\d+)?)\s+(\d+(?:\.\d+)?)"/), [, n, r] = t ? [
|
|
3147
3148
|
null,
|
|
@@ -3161,20 +3162,20 @@ function Bt(e) {
|
|
|
3161
3162
|
<head>
|
|
3162
3163
|
<meta charset="UTF-8">
|
|
3163
3164
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
3164
|
-
<title>${
|
|
3165
|
-
<style>${
|
|
3165
|
+
<title>${Ht(n)}</title>
|
|
3166
|
+
<style>${Bt(r)}</style>
|
|
3166
3167
|
</head>
|
|
3167
3168
|
<body>
|
|
3168
3169
|
${i}
|
|
3169
3170
|
</body>
|
|
3170
3171
|
</html>`;
|
|
3171
3172
|
}
|
|
3172
|
-
function
|
|
3173
|
+
function Ht(e) {
|
|
3173
3174
|
return e.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
3174
3175
|
}
|
|
3175
3176
|
//#endregion
|
|
3176
3177
|
//#region ../node_modules/qrcode/lib/can-promise.js
|
|
3177
|
-
var
|
|
3178
|
+
var Ut = /* @__PURE__ */ D(((e, t) => {
|
|
3178
3179
|
t.exports = function() {
|
|
3179
3180
|
return typeof Promise == "function" && Promise.prototype && Promise.prototype.then;
|
|
3180
3181
|
};
|
|
@@ -3240,7 +3241,7 @@ var Ht = /* @__PURE__ */ D(((e, t) => {
|
|
|
3240
3241
|
}, e.toSJIS = function(e) {
|
|
3241
3242
|
return t(e);
|
|
3242
3243
|
};
|
|
3243
|
-
})),
|
|
3244
|
+
})), Wt = /* @__PURE__ */ D(((e) => {
|
|
3244
3245
|
e.L = { bit: 1 }, e.M = { bit: 0 }, e.Q = { bit: 3 }, e.H = { bit: 2 };
|
|
3245
3246
|
function t(t) {
|
|
3246
3247
|
if (typeof t != "string") throw Error("Param is not a string");
|
|
@@ -3266,7 +3267,7 @@ var Ht = /* @__PURE__ */ D(((e, t) => {
|
|
|
3266
3267
|
return r;
|
|
3267
3268
|
}
|
|
3268
3269
|
};
|
|
3269
|
-
})),
|
|
3270
|
+
})), Gt = /* @__PURE__ */ D(((e, t) => {
|
|
3270
3271
|
function n() {
|
|
3271
3272
|
this.buffer = [], this.length = 0;
|
|
3272
3273
|
}
|
|
@@ -3286,7 +3287,7 @@ var Ht = /* @__PURE__ */ D(((e, t) => {
|
|
|
3286
3287
|
this.buffer.length <= t && this.buffer.push(0), e && (this.buffer[t] |= 128 >>> this.length % 8), this.length++;
|
|
3287
3288
|
}
|
|
3288
3289
|
}, t.exports = n;
|
|
3289
|
-
})),
|
|
3290
|
+
})), Kt = /* @__PURE__ */ D(((e, t) => {
|
|
3290
3291
|
function n(e) {
|
|
3291
3292
|
if (!e || e < 1) throw Error("BitMatrix size must be defined and greater than 0");
|
|
3292
3293
|
this.size = e, this.data = new Uint8Array(e * e), this.reservedBit = new Uint8Array(e * e);
|
|
@@ -3301,7 +3302,7 @@ var Ht = /* @__PURE__ */ D(((e, t) => {
|
|
|
3301
3302
|
}, n.prototype.isReserved = function(e, t) {
|
|
3302
3303
|
return this.reservedBit[e * this.size + t];
|
|
3303
3304
|
}, t.exports = n;
|
|
3304
|
-
})),
|
|
3305
|
+
})), qt = /* @__PURE__ */ D(((e) => {
|
|
3305
3306
|
var t = Y().getSymbolSize;
|
|
3306
3307
|
e.getRowColCoords = function(e) {
|
|
3307
3308
|
if (e === 1) return [];
|
|
@@ -3313,7 +3314,7 @@ var Ht = /* @__PURE__ */ D(((e, t) => {
|
|
|
3313
3314
|
for (let e = 0; e < i; e++) for (let t = 0; t < i; t++) e === 0 && t === 0 || e === 0 && t === i - 1 || e === i - 1 && t === 0 || n.push([r[e], r[t]]);
|
|
3314
3315
|
return n;
|
|
3315
3316
|
};
|
|
3316
|
-
})),
|
|
3317
|
+
})), Jt = /* @__PURE__ */ D(((e) => {
|
|
3317
3318
|
var t = Y().getSymbolSize, n = 7;
|
|
3318
3319
|
e.getPositions = function(e) {
|
|
3319
3320
|
let r = t(e);
|
|
@@ -3323,7 +3324,7 @@ var Ht = /* @__PURE__ */ D(((e, t) => {
|
|
|
3323
3324
|
[0, r - n]
|
|
3324
3325
|
];
|
|
3325
3326
|
};
|
|
3326
|
-
})),
|
|
3327
|
+
})), Yt = /* @__PURE__ */ D(((e) => {
|
|
3327
3328
|
e.Patterns = {
|
|
3328
3329
|
PATTERN000: 0,
|
|
3329
3330
|
PATTERN001: 1,
|
|
@@ -3399,8 +3400,8 @@ var Ht = /* @__PURE__ */ D(((e, t) => {
|
|
|
3399
3400
|
}
|
|
3400
3401
|
return i;
|
|
3401
3402
|
};
|
|
3402
|
-
})),
|
|
3403
|
-
var t =
|
|
3403
|
+
})), Xt = /* @__PURE__ */ D(((e) => {
|
|
3404
|
+
var t = Wt(), n = [
|
|
3404
3405
|
1,
|
|
3405
3406
|
1,
|
|
3406
3407
|
1,
|
|
@@ -3740,7 +3741,7 @@ var Ht = /* @__PURE__ */ D(((e, t) => {
|
|
|
3740
3741
|
default: return;
|
|
3741
3742
|
}
|
|
3742
3743
|
};
|
|
3743
|
-
})),
|
|
3744
|
+
})), Zt = /* @__PURE__ */ D(((e) => {
|
|
3744
3745
|
var t = new Uint8Array(512), n = new Uint8Array(256);
|
|
3745
3746
|
(function() {
|
|
3746
3747
|
let e = 1;
|
|
@@ -3754,8 +3755,8 @@ var Ht = /* @__PURE__ */ D(((e, t) => {
|
|
|
3754
3755
|
}, e.mul = function(e, r) {
|
|
3755
3756
|
return e === 0 || r === 0 ? 0 : t[n[e] + n[r]];
|
|
3756
3757
|
};
|
|
3757
|
-
})),
|
|
3758
|
-
var t =
|
|
3758
|
+
})), Qt = /* @__PURE__ */ D(((e) => {
|
|
3759
|
+
var t = Zt();
|
|
3759
3760
|
e.mul = function(e, n) {
|
|
3760
3761
|
let r = new Uint8Array(e.length + n.length - 1);
|
|
3761
3762
|
for (let i = 0; i < e.length; i++) for (let a = 0; a < n.length; a++) r[i + a] ^= t.mul(e[i], n[a]);
|
|
@@ -3775,8 +3776,8 @@ var Ht = /* @__PURE__ */ D(((e, t) => {
|
|
|
3775
3776
|
for (let i = 0; i < n; i++) r = e.mul(r, new Uint8Array([1, t.exp(i)]));
|
|
3776
3777
|
return r;
|
|
3777
3778
|
};
|
|
3778
|
-
})),
|
|
3779
|
-
var n =
|
|
3779
|
+
})), $t = /* @__PURE__ */ D(((e, t) => {
|
|
3780
|
+
var n = Qt();
|
|
3780
3781
|
function r(e) {
|
|
3781
3782
|
this.genPoly = void 0, this.degree = e, this.degree && this.initialize(this.degree);
|
|
3782
3783
|
}
|
|
@@ -3793,11 +3794,11 @@ var Ht = /* @__PURE__ */ D(((e, t) => {
|
|
|
3793
3794
|
}
|
|
3794
3795
|
return r;
|
|
3795
3796
|
}, t.exports = r;
|
|
3796
|
-
})),
|
|
3797
|
+
})), en = /* @__PURE__ */ D(((e) => {
|
|
3797
3798
|
e.isValid = function(e) {
|
|
3798
3799
|
return !isNaN(e) && e >= 1 && e <= 40;
|
|
3799
3800
|
};
|
|
3800
|
-
})),
|
|
3801
|
+
})), tn = /* @__PURE__ */ D(((e) => {
|
|
3801
3802
|
var t = "[0-9]+", n = "[A-Z $%*+\\-./:]+", r = "(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+";
|
|
3802
3803
|
r = r.replace(/u/g, "\\u");
|
|
3803
3804
|
var i = "(?:(?![A-Z0-9 $%*+\\-./:]|" + r + ")(?:.|[\r\n]))+";
|
|
@@ -3811,7 +3812,7 @@ var Ht = /* @__PURE__ */ D(((e, t) => {
|
|
|
3811
3812
|
return s.test(e);
|
|
3812
3813
|
};
|
|
3813
3814
|
})), X = /* @__PURE__ */ D(((e) => {
|
|
3814
|
-
var t =
|
|
3815
|
+
var t = en(), n = tn();
|
|
3815
3816
|
e.NUMERIC = {
|
|
3816
3817
|
id: "Numeric",
|
|
3817
3818
|
bit: 1,
|
|
@@ -3874,8 +3875,8 @@ var Ht = /* @__PURE__ */ D(((e, t) => {
|
|
|
3874
3875
|
return n;
|
|
3875
3876
|
}
|
|
3876
3877
|
};
|
|
3877
|
-
})),
|
|
3878
|
-
var t = Y(), n =
|
|
3878
|
+
})), nn = /* @__PURE__ */ D(((e) => {
|
|
3879
|
+
var t = Y(), n = Xt(), r = Wt(), i = X(), a = en(), o = 7973, s = t.getBCHDigit(o);
|
|
3879
3880
|
function c(t, n, r) {
|
|
3880
3881
|
for (let i = 1; i <= 40; i++) if (n <= e.getCapacity(i, r, t)) return i;
|
|
3881
3882
|
}
|
|
@@ -3921,14 +3922,14 @@ var Ht = /* @__PURE__ */ D(((e, t) => {
|
|
|
3921
3922
|
for (; t.getBCHDigit(n) - s >= 0;) n ^= o << t.getBCHDigit(n) - s;
|
|
3922
3923
|
return e << 12 | n;
|
|
3923
3924
|
};
|
|
3924
|
-
})),
|
|
3925
|
+
})), rn = /* @__PURE__ */ D(((e) => {
|
|
3925
3926
|
var t = Y(), n = 1335, r = 21522, i = t.getBCHDigit(n);
|
|
3926
3927
|
e.getEncodedBits = function(e, a) {
|
|
3927
3928
|
let o = e.bit << 3 | a, s = o << 10;
|
|
3928
3929
|
for (; t.getBCHDigit(s) - i >= 0;) s ^= n << t.getBCHDigit(s) - i;
|
|
3929
3930
|
return (o << 10 | s) ^ r;
|
|
3930
3931
|
};
|
|
3931
|
-
})),
|
|
3932
|
+
})), an = /* @__PURE__ */ D(((e, t) => {
|
|
3932
3933
|
var n = X();
|
|
3933
3934
|
function r(e) {
|
|
3934
3935
|
this.mode = n.NUMERIC, this.data = e.toString();
|
|
@@ -3945,7 +3946,7 @@ var Ht = /* @__PURE__ */ D(((e, t) => {
|
|
|
3945
3946
|
let i = this.data.length - t;
|
|
3946
3947
|
i > 0 && (n = this.data.substr(t), r = parseInt(n, 10), e.put(r, i * 3 + 1));
|
|
3947
3948
|
}, t.exports = r;
|
|
3948
|
-
})),
|
|
3949
|
+
})), on = /* @__PURE__ */ D(((e, t) => {
|
|
3949
3950
|
var n = X(), r = /* @__PURE__ */ "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:".split("");
|
|
3950
3951
|
function i(e) {
|
|
3951
3952
|
this.mode = n.ALPHANUMERIC, this.data = e;
|
|
@@ -3964,7 +3965,7 @@ var Ht = /* @__PURE__ */ D(((e, t) => {
|
|
|
3964
3965
|
}
|
|
3965
3966
|
this.data.length % 2 && e.put(r.indexOf(this.data[t]), 6);
|
|
3966
3967
|
}, t.exports = i;
|
|
3967
|
-
})),
|
|
3968
|
+
})), sn = /* @__PURE__ */ D(((e, t) => {
|
|
3968
3969
|
var n = X();
|
|
3969
3970
|
function r(e) {
|
|
3970
3971
|
this.mode = n.BYTE, typeof e == "string" ? this.data = new TextEncoder().encode(e) : this.data = new Uint8Array(e);
|
|
@@ -3978,7 +3979,7 @@ var Ht = /* @__PURE__ */ D(((e, t) => {
|
|
|
3978
3979
|
}, r.prototype.write = function(e) {
|
|
3979
3980
|
for (let t = 0, n = this.data.length; t < n; t++) e.put(this.data[t], 8);
|
|
3980
3981
|
}, t.exports = r;
|
|
3981
|
-
})),
|
|
3982
|
+
})), cn = /* @__PURE__ */ D(((e, t) => {
|
|
3982
3983
|
var n = X(), r = Y();
|
|
3983
3984
|
function i(e) {
|
|
3984
3985
|
this.mode = n.KANJI, this.data = e;
|
|
@@ -3999,7 +4000,7 @@ var Ht = /* @__PURE__ */ D(((e, t) => {
|
|
|
3999
4000
|
n = (n >>> 8 & 255) * 192 + (n & 255), e.put(n, 13);
|
|
4000
4001
|
}
|
|
4001
4002
|
}, t.exports = i;
|
|
4002
|
-
})),
|
|
4003
|
+
})), ln = /* @__PURE__ */ D(((e, t) => {
|
|
4003
4004
|
var n = {
|
|
4004
4005
|
single_source_shortest_paths: function(e, t, r) {
|
|
4005
4006
|
var i = {}, a = {};
|
|
@@ -4052,8 +4053,8 @@ var Ht = /* @__PURE__ */ D(((e, t) => {
|
|
|
4052
4053
|
}
|
|
4053
4054
|
};
|
|
4054
4055
|
t !== void 0 && (t.exports = n);
|
|
4055
|
-
})),
|
|
4056
|
-
var t = X(), n =
|
|
4056
|
+
})), un = /* @__PURE__ */ D(((e) => {
|
|
4057
|
+
var t = X(), n = an(), r = on(), i = sn(), a = cn(), o = tn(), s = Y(), c = ln();
|
|
4057
4058
|
function l(e) {
|
|
4058
4059
|
return unescape(encodeURIComponent(e)).length;
|
|
4059
4060
|
}
|
|
@@ -4180,8 +4181,8 @@ var Ht = /* @__PURE__ */ D(((e, t) => {
|
|
|
4180
4181
|
}, e.rawSplit = function(t) {
|
|
4181
4182
|
return e.fromArray(d(t, s.isKanjiModeEnabled()));
|
|
4182
4183
|
};
|
|
4183
|
-
})),
|
|
4184
|
-
var t = Y(), n =
|
|
4184
|
+
})), dn = /* @__PURE__ */ D(((e) => {
|
|
4185
|
+
var t = Y(), n = Wt(), r = Gt(), i = Kt(), a = qt(), o = Jt(), s = Yt(), c = Xt(), l = $t(), u = nn(), d = rn(), f = X(), p = un();
|
|
4185
4186
|
function m(e, t) {
|
|
4186
4187
|
let n = e.size, r = o.getPositions(t);
|
|
4187
4188
|
for (let t = 0; t < r.length; t++) {
|
|
@@ -4276,7 +4277,7 @@ var Ht = /* @__PURE__ */ D(((e, t) => {
|
|
|
4276
4277
|
let i = n.M, a, o;
|
|
4277
4278
|
return r !== void 0 && (i = n.from(r.errorCorrectionLevel, n.M), a = u.from(r.version), o = s.from(r.maskPattern), r.toSJISFunc && t.setToSJISFunction(r.toSJISFunc)), S(e, a, i, o);
|
|
4278
4279
|
};
|
|
4279
|
-
})),
|
|
4280
|
+
})), fn = /* @__PURE__ */ D(((e) => {
|
|
4280
4281
|
function t(e) {
|
|
4281
4282
|
if (typeof e == "number" && (e = e.toString()), typeof e != "string") throw Error("Color should be defined as hex string");
|
|
4282
4283
|
let t = e.slice().replace("#", "").split("");
|
|
@@ -4323,8 +4324,8 @@ var Ht = /* @__PURE__ */ D(((e, t) => {
|
|
|
4323
4324
|
t[u++] = d.r, t[u++] = d.g, t[u++] = d.b, t[u] = d.a;
|
|
4324
4325
|
}
|
|
4325
4326
|
};
|
|
4326
|
-
})),
|
|
4327
|
-
var t =
|
|
4327
|
+
})), pn = /* @__PURE__ */ D(((e) => {
|
|
4328
|
+
var t = fn();
|
|
4328
4329
|
function n(e, t, n) {
|
|
4329
4330
|
e.clearRect(0, 0, t.width, t.height), t.style ||= {}, t.height = n, t.width = n, t.style.height = n + "px", t.style.width = n + "px";
|
|
4330
4331
|
}
|
|
@@ -4346,8 +4347,8 @@ var Ht = /* @__PURE__ */ D(((e, t) => {
|
|
|
4346
4347
|
let a = e.render(t, n, i), o = i.type || "image/png", s = i.rendererOpts || {};
|
|
4347
4348
|
return a.toDataURL(o, s.quality);
|
|
4348
4349
|
};
|
|
4349
|
-
})),
|
|
4350
|
-
var t =
|
|
4350
|
+
})), mn = /* @__PURE__ */ D(((e) => {
|
|
4351
|
+
var t = fn();
|
|
4351
4352
|
function n(e, t) {
|
|
4352
4353
|
let n = e.a / 255, r = t + "=\"" + e.hex + "\"";
|
|
4353
4354
|
return n < 1 ? r + " " + t + "-opacity=\"" + n.toFixed(2).slice(1) + "\"" : r;
|
|
@@ -4368,8 +4369,8 @@ var Ht = /* @__PURE__ */ D(((e, t) => {
|
|
|
4368
4369
|
let o = t.getOptions(r), s = e.modules.size, c = e.modules.data, l = s + o.margin * 2, u = o.color.light.a ? "<path " + n(o.color.light, "fill") + " d=\"M0 0h" + l + "v" + l + "H0z\"/>" : "", d = "<path " + n(o.color.dark, "stroke") + " d=\"" + i(c, s, o.margin) + "\"/>", f = "viewBox=\"0 0 " + l + " " + l + "\"", p = "<svg xmlns=\"http://www.w3.org/2000/svg\" " + (o.width ? "width=\"" + o.width + "\" height=\"" + o.width + "\" " : "") + f + " shape-rendering=\"crispEdges\">" + u + d + "</svg>\n";
|
|
4369
4370
|
return typeof a == "function" && a(null, p), p;
|
|
4370
4371
|
};
|
|
4371
|
-
})),
|
|
4372
|
-
var t =
|
|
4372
|
+
})), hn = /* @__PURE__ */ O((/* @__PURE__ */ D(((e) => {
|
|
4373
|
+
var t = Ut(), n = dn(), r = pn(), i = mn();
|
|
4373
4374
|
function a(e, r, i, a, o) {
|
|
4374
4375
|
let s = [].slice.call(arguments, 1), c = s.length, l = typeof s[c - 1] == "function";
|
|
4375
4376
|
if (!l && !t()) throw Error("Callback required as last argument");
|
|
@@ -4397,10 +4398,10 @@ var Ht = /* @__PURE__ */ D(((e, t) => {
|
|
|
4397
4398
|
return i.render(e, n);
|
|
4398
4399
|
});
|
|
4399
4400
|
})))(), 1);
|
|
4400
|
-
async function
|
|
4401
|
+
async function gn(e, t = 200) {
|
|
4401
4402
|
if (!e || e.trim() === "") return "";
|
|
4402
4403
|
try {
|
|
4403
|
-
return await
|
|
4404
|
+
return await hn.toDataURL(e, {
|
|
4404
4405
|
width: t,
|
|
4405
4406
|
margin: 1,
|
|
4406
4407
|
color: {
|
|
@@ -4415,7 +4416,7 @@ async function hn(e, t = 200) {
|
|
|
4415
4416
|
}
|
|
4416
4417
|
//#endregion
|
|
4417
4418
|
//#region src/composables/usePaperSelection.ts
|
|
4418
|
-
function
|
|
4419
|
+
function _n(e) {
|
|
4419
4420
|
let n = f(null), r = f(null), i = f(null), a = t(() => n.value && e.value.find((e) => e.id === n.value) || null), o = t(() => r.value ? d(r.value) : null), s = t(() => i.value ? p(i.value) : null);
|
|
4420
4421
|
function c(e) {
|
|
4421
4422
|
n.value = e, e && (r.value = null);
|
|
@@ -4480,7 +4481,7 @@ function gn(e) {
|
|
|
4480
4481
|
}
|
|
4481
4482
|
//#endregion
|
|
4482
4483
|
//#region src/composables/paperHelpers.ts
|
|
4483
|
-
var
|
|
4484
|
+
var vn = {
|
|
4484
4485
|
三号: 21,
|
|
4485
4486
|
小三: 20,
|
|
4486
4487
|
四号: 19,
|
|
@@ -4488,24 +4489,24 @@ var _n = {
|
|
|
4488
4489
|
五号: 14,
|
|
4489
4490
|
小五: 12
|
|
4490
4491
|
};
|
|
4491
|
-
function vn(e) {
|
|
4492
|
-
return _n[e] ?? 14;
|
|
4493
|
-
}
|
|
4494
4492
|
function yn(e) {
|
|
4495
|
-
|
|
4493
|
+
return vn[e] ?? 14;
|
|
4494
|
+
}
|
|
4495
|
+
function bn(e) {
|
|
4496
|
+
for (let [t, n] of Object.entries(vn)) if (n === e) return t;
|
|
4496
4497
|
return "五号";
|
|
4497
4498
|
}
|
|
4498
4499
|
function Z(e) {
|
|
4499
|
-
return typeof e.fontSize == "number" ? e.fontSize :
|
|
4500
|
+
return typeof e.fontSize == "number" ? e.fontSize : yn(e.fontSize || "五号");
|
|
4500
4501
|
}
|
|
4501
4502
|
function Q(e) {
|
|
4502
4503
|
return e.lineSpacing ?? 1.5;
|
|
4503
4504
|
}
|
|
4504
|
-
function
|
|
4505
|
+
function xn(e, t) {
|
|
4505
4506
|
return Math.round(e * t * 35 / (14 * 1.5));
|
|
4506
4507
|
}
|
|
4507
4508
|
function $(e, t) {
|
|
4508
|
-
let n =
|
|
4509
|
+
let n = xn(e, t);
|
|
4509
4510
|
return {
|
|
4510
4511
|
lines: [{
|
|
4511
4512
|
elements: [{
|
|
@@ -4521,15 +4522,15 @@ function $(e, t) {
|
|
|
4521
4522
|
height: n
|
|
4522
4523
|
};
|
|
4523
4524
|
}
|
|
4524
|
-
function
|
|
4525
|
-
let a =
|
|
4525
|
+
function Sn(e, t, n, r, i = 0) {
|
|
4526
|
+
let a = xn(t, n), o = r && r > 0 ? it(e, r, a, i) : [rt(e, a)];
|
|
4526
4527
|
return {
|
|
4527
4528
|
lines: o,
|
|
4528
4529
|
y: 0,
|
|
4529
4530
|
height: o.reduce((e, t) => e + t.lineHeight, 0) + 4
|
|
4530
4531
|
};
|
|
4531
4532
|
}
|
|
4532
|
-
function
|
|
4533
|
+
function Cn(e) {
|
|
4533
4534
|
let t = e.paragraphs.length;
|
|
4534
4535
|
for (; t > 0;) {
|
|
4535
4536
|
let n = e.paragraphs[t - 1];
|
|
@@ -4538,14 +4539,14 @@ function Sn(e) {
|
|
|
4538
4539
|
}
|
|
4539
4540
|
return t;
|
|
4540
4541
|
}
|
|
4541
|
-
var
|
|
4542
|
-
function
|
|
4542
|
+
var wn = 0, Tn = 0;
|
|
4543
|
+
function En(e) {
|
|
4543
4544
|
return e.type === "question" ? (e.metadata?.questionNo || "").length > 2 ? 26.25 : 17.5 : e.type === "sub-question" ? 26.25 : 0;
|
|
4544
4545
|
}
|
|
4545
|
-
function
|
|
4546
|
-
return t -
|
|
4546
|
+
function Dn(e, t) {
|
|
4547
|
+
return t - En(e);
|
|
4547
4548
|
}
|
|
4548
|
-
function
|
|
4549
|
+
function On(e) {
|
|
4549
4550
|
let t = [], n = 0;
|
|
4550
4551
|
for (; n < e.length;) {
|
|
4551
4552
|
if (e[n] === "\\" && e.substring(n, n + 2) === "\\(") {
|
|
@@ -4576,9 +4577,9 @@ function Dn(e) {
|
|
|
4576
4577
|
}
|
|
4577
4578
|
return t;
|
|
4578
4579
|
}
|
|
4579
|
-
function
|
|
4580
|
-
let n = [], r =
|
|
4581
|
-
for (let e of r) if (e.type === "text") n.push(
|
|
4580
|
+
function kn(e, t) {
|
|
4581
|
+
let n = [], r = On(e);
|
|
4582
|
+
for (let e of r) if (e.type === "text") n.push(An(e.value, t, !1, "\"Times New Roman\", SimSun,'Cambria Math'", "#000"));
|
|
4582
4583
|
else if (e.type === "formula") {
|
|
4583
4584
|
let { svg: t, width: r, height: i } = G(e.value);
|
|
4584
4585
|
n.push({
|
|
@@ -4590,7 +4591,7 @@ function On(e, t) {
|
|
|
4590
4591
|
});
|
|
4591
4592
|
} else e.type === "blank" && n.push({
|
|
4592
4593
|
type: "underline",
|
|
4593
|
-
id: `ul-${++
|
|
4594
|
+
id: `ul-${++Tn}`,
|
|
4594
4595
|
width: 80,
|
|
4595
4596
|
height: 20,
|
|
4596
4597
|
placeholder: "空",
|
|
@@ -4599,7 +4600,7 @@ function On(e, t) {
|
|
|
4599
4600
|
});
|
|
4600
4601
|
return n;
|
|
4601
4602
|
}
|
|
4602
|
-
function
|
|
4603
|
+
function An(e, t, n, r, i) {
|
|
4603
4604
|
let a = e.split(""), o = B(e, t, r);
|
|
4604
4605
|
return {
|
|
4605
4606
|
type: "text",
|
|
@@ -4614,14 +4615,14 @@ function kn(e, t, n, r, i) {
|
|
|
4614
4615
|
xPositions: o
|
|
4615
4616
|
};
|
|
4616
4617
|
}
|
|
4617
|
-
function
|
|
4618
|
+
function jn(e, t, n, r, i, a, o = !1) {
|
|
4618
4619
|
let s = [];
|
|
4619
4620
|
for (let e = 0; e < n.length; e++) {
|
|
4620
|
-
let t =
|
|
4621
|
-
s.push(
|
|
4621
|
+
let t = kn(n[e], r);
|
|
4622
|
+
s.push(Sn(t, r, i, a && a > 0 ? a : void 0));
|
|
4622
4623
|
}
|
|
4623
4624
|
for (let e = 0; e < 2; e++) s.push($(r, i));
|
|
4624
|
-
let c = s.reduce((e, t) => e + (t.height || 26), 0), l = `topic-${e.replace(".", "")}-${++
|
|
4625
|
+
let c = s.reduce((e, t) => e + (t.height || 26), 0), l = `topic-${e.replace(".", "")}-${++wn}`;
|
|
4625
4626
|
return {
|
|
4626
4627
|
id: `q-${e.replace(".", "")}-${Date.now()}-${Math.random().toString(36).slice(2, 6)}`,
|
|
4627
4628
|
type: "question",
|
|
@@ -4637,10 +4638,10 @@ function An(e, t, n, r, i, a, o = !1) {
|
|
|
4637
4638
|
}
|
|
4638
4639
|
};
|
|
4639
4640
|
}
|
|
4640
|
-
function
|
|
4641
|
+
function Mn(e, t, n, r, i, a, o = !1) {
|
|
4641
4642
|
let s = [], c = `group-${e.replace(".", "")}`, l = [], u = 0, d = (n, u) => {
|
|
4642
4643
|
if (l.length === 0) return;
|
|
4643
|
-
let d = l.map((e) =>
|
|
4644
|
+
let d = l.map((e) => Sn(kn(e, r), r, i, a && a > 0 ? a : void 0));
|
|
4644
4645
|
if (!n) for (let e = 0; e < 2; e++) d.push($(r, i));
|
|
4645
4646
|
let f = d.reduce((e, t) => e + (t.height || 26), 0), p = `${c}-${n ? "header" : `sub${u}`}`;
|
|
4646
4647
|
s.push({
|
|
@@ -4666,7 +4667,7 @@ function jn(e, t, n, r, i, a, o = !1) {
|
|
|
4666
4667
|
}
|
|
4667
4668
|
return d(s.length === 0, u), s;
|
|
4668
4669
|
}
|
|
4669
|
-
function
|
|
4670
|
+
function Nn(e) {
|
|
4670
4671
|
let t = [];
|
|
4671
4672
|
for (let n of e.paragraphs) {
|
|
4672
4673
|
if (n.lines.length > 0 && n.lines.every((e) => e.elements.length > 0 && e.elements.every((e) => e.type === "enter"))) continue;
|
|
@@ -4680,18 +4681,18 @@ function Mn(e) {
|
|
|
4680
4681
|
}
|
|
4681
4682
|
return t.join("\n");
|
|
4682
4683
|
}
|
|
4683
|
-
function
|
|
4684
|
+
function Pn(e) {
|
|
4684
4685
|
return e.metadata?.questionNo ? `第${e.metadata.questionNo.replace(".", "")}题` : e.metadata?.subLabel ? e.metadata.subLabel : e.metadata?.label || e.id;
|
|
4685
4686
|
}
|
|
4686
4687
|
//#endregion
|
|
4687
4688
|
//#region src/composables/usePaperBlockOps.ts
|
|
4688
|
-
function
|
|
4689
|
+
function Fn(e) {
|
|
4689
4690
|
let { blocks: t, settings: n, pages: r, isDirty: i, layoutEngine: a, svgRenderer: o, paperName: s, schoolName: c, qrCodeContent: l, qrCodeImage: u, totalScore: d, selectedBlockId: f, findInlineImageById: p, findUnderlineById: m, relayout: h } = e;
|
|
4690
4691
|
function g() {
|
|
4691
4692
|
let e = Z(n.value), r = Q(n.value), s = a.value.columnWidth;
|
|
4692
4693
|
s <= 0 || (t.value = t.value.map((t) => {
|
|
4693
4694
|
if (!t.paragraphs || t.paragraphs.length === 0) return t;
|
|
4694
|
-
let n =
|
|
4695
|
+
let n = Dn(t, s), i = [], a = !1;
|
|
4695
4696
|
for (let o = 0; o < t.paragraphs.length; o++) {
|
|
4696
4697
|
let s = t.paragraphs[o];
|
|
4697
4698
|
if (s.lines.length > 0 && s.lines.every((e) => e.elements.length > 0 && e.elements.every((e) => e.type === "enter"))) {
|
|
@@ -4702,7 +4703,7 @@ function Pn(e) {
|
|
|
4702
4703
|
for (let e of s.lines) for (let t of e.elements) if (t.type === "text") {
|
|
4703
4704
|
let e = t, n = e.value.split("");
|
|
4704
4705
|
for (let t = 0; t < n.length; t++) {
|
|
4705
|
-
let r =
|
|
4706
|
+
let r = In(n[t], e.fontSize, e.fontFamily, e.bold, e.italic);
|
|
4706
4707
|
c.push({
|
|
4707
4708
|
...e,
|
|
4708
4709
|
value: n[t],
|
|
@@ -4724,20 +4725,20 @@ function Pn(e) {
|
|
|
4724
4725
|
} else c.push(t);
|
|
4725
4726
|
} else c.push(t);
|
|
4726
4727
|
let l;
|
|
4727
|
-
if (a) l =
|
|
4728
|
+
if (a) l = Sn(c, e, r, n > 0 ? n : void 0, 0);
|
|
4728
4729
|
else {
|
|
4729
4730
|
let i = t.metadata?.score || "", o = i ? se(`(${i}分)`, e, "SimSun, STSong, serif") : 0;
|
|
4730
|
-
l =
|
|
4731
|
+
l = Sn(c, e, r, n > 0 ? n : void 0, o), a = !0;
|
|
4731
4732
|
}
|
|
4732
4733
|
t.paragraphs[o].justification && (l.justification = t.paragraphs[o].justification), i.push(l);
|
|
4733
4734
|
}
|
|
4734
4735
|
let c = 0;
|
|
4735
|
-
t.options && t.options.length > 0 && (c = o.value.getOptionsHeight(t.options,
|
|
4736
|
+
t.options && t.options.length > 0 && (c = o.value.getOptionsHeight(t.options, Dn(t, s)));
|
|
4736
4737
|
let l = t.metadata?.customHeight;
|
|
4737
4738
|
if (l) {
|
|
4738
4739
|
let t = i.reduce((e, t) => e + (t.height || 26), 0) + c;
|
|
4739
4740
|
if (l > t) {
|
|
4740
|
-
let n = l - t, a =
|
|
4741
|
+
let n = l - t, a = xn(e, r) + 4, o = Math.round(n / a);
|
|
4741
4742
|
for (let t = 0; t < o; t++) i.push($(e, r));
|
|
4742
4743
|
}
|
|
4743
4744
|
}
|
|
@@ -4795,7 +4796,7 @@ function Pn(e) {
|
|
|
4795
4796
|
function S(e, r) {
|
|
4796
4797
|
let a = t.value.findIndex((t) => t.id === e);
|
|
4797
4798
|
if (a === -1) return;
|
|
4798
|
-
let o = t.value[a], s = Z(n.value), c = Q(n.value), l = Math.max(0, o.paragraphs.length -
|
|
4799
|
+
let o = t.value[a], s = Z(n.value), c = Q(n.value), l = Math.max(0, o.paragraphs.length - Cn(o)), u = [...r];
|
|
4799
4800
|
for (let e = 0; e < l; e++) u.push($(s, c));
|
|
4800
4801
|
let d = u.reduce((e, t) => e + (t.height || 26), 0);
|
|
4801
4802
|
t.value = t.value.map((e, t) => t === a ? {
|
|
@@ -4843,9 +4844,9 @@ function Pn(e) {
|
|
|
4843
4844
|
function D(e, r) {
|
|
4844
4845
|
let s = t.value.findIndex((t) => t.id === e);
|
|
4845
4846
|
if (s === -1) return;
|
|
4846
|
-
let c = t.value[s], l = Z(n.value), u = Q(n.value), d =
|
|
4847
|
-
c.options && c.options.length > 0 && (f = o.value.getOptionsHeight(c.options,
|
|
4848
|
-
let p =
|
|
4847
|
+
let c = t.value[s], l = Z(n.value), u = Q(n.value), d = xn(l, u) + 4, f = 0;
|
|
4848
|
+
c.options && c.options.length > 0 && (f = o.value.getOptionsHeight(c.options, Dn(c, a.value.columnWidth)));
|
|
4849
|
+
let p = Cn(c), m = c.paragraphs.slice(0, p), g = m.reduce((e, t) => e + (t.height || 26), 0) + f, _ = Math.max(0, r - g), v = Math.round(_ / d), y = [];
|
|
4849
4850
|
for (let e = 0; e < v; e++) y.push($(l, u));
|
|
4850
4851
|
let b = [...m, ...y], x = b.reduce((e, t) => e + (t.height || 26), 0);
|
|
4851
4852
|
t.value = t.value.map((e, t) => t === s ? {
|
|
@@ -4908,29 +4909,38 @@ function Pn(e) {
|
|
|
4908
4909
|
} : e), i.value = !0;
|
|
4909
4910
|
}
|
|
4910
4911
|
function j(e) {
|
|
4911
|
-
let n = new Map(
|
|
4912
|
+
let n = /* @__PURE__ */ new Map();
|
|
4913
|
+
for (let t of e) {
|
|
4914
|
+
let e = n.get(t.id) || [];
|
|
4915
|
+
e.push(t.metadata), n.set(t.id, e);
|
|
4916
|
+
}
|
|
4917
|
+
let r = /* @__PURE__ */ new Map();
|
|
4912
4918
|
t.value = t.value.map((e) => {
|
|
4913
4919
|
let t = n.get(e.id);
|
|
4914
|
-
|
|
4920
|
+
if (!t) return e;
|
|
4921
|
+
let i = r.get(e.id) || 0;
|
|
4922
|
+
r.set(e.id, i + 1);
|
|
4923
|
+
let a = t[i] || t[t.length - 1];
|
|
4924
|
+
return {
|
|
4915
4925
|
...e,
|
|
4916
4926
|
metadata: {
|
|
4917
4927
|
...e.metadata,
|
|
4918
|
-
...
|
|
4928
|
+
...a
|
|
4919
4929
|
}
|
|
4920
|
-
}
|
|
4930
|
+
};
|
|
4921
4931
|
}), i.value = !0;
|
|
4922
4932
|
}
|
|
4923
4933
|
function M() {
|
|
4924
4934
|
let e = 0, n = 0, r = [];
|
|
4925
4935
|
for (let i of t.value) if (i.type === "title") {
|
|
4926
4936
|
e++;
|
|
4927
|
-
let t = i.metadata?.title ||
|
|
4937
|
+
let t = i.metadata?.title || zt(i.metadata?.label || "") || "题组";
|
|
4928
4938
|
r.push({
|
|
4929
4939
|
id: i.id,
|
|
4930
4940
|
metadata: {
|
|
4931
4941
|
title: t,
|
|
4932
4942
|
ordinal: e,
|
|
4933
|
-
label:
|
|
4943
|
+
label: Rt(t, e)
|
|
4934
4944
|
}
|
|
4935
4945
|
});
|
|
4936
4946
|
} else if (i.type === "question") {
|
|
@@ -4953,16 +4963,16 @@ function Pn(e) {
|
|
|
4953
4963
|
let o = e.content.split("\n").filter((e) => e.trim());
|
|
4954
4964
|
o.length === 0 && o.push("");
|
|
4955
4965
|
let s = e.score ? `(${e.score}分)` : "", c = o.some((e) => /^\(\d+\)\s*/.test(e)), l = Z(n.value), u = Q(n.value), d = a.value.columnWidth, p;
|
|
4956
|
-
if (c) p =
|
|
4966
|
+
if (c) p = Mn(e.no, s, o, l, u, d - 26.25, r);
|
|
4957
4967
|
else {
|
|
4958
4968
|
let t = e.no.length > 2 ? 26.25 : 17.5;
|
|
4959
|
-
p = [
|
|
4969
|
+
p = [jn(e.no, s, o, l, u, d - t, r)];
|
|
4960
4970
|
}
|
|
4961
4971
|
for (let e of p) t.value = [...t.value, e];
|
|
4962
4972
|
p.length > 0 && (f.value = p[p.length - 1].id), M(), i.value = !0, g();
|
|
4963
4973
|
}
|
|
4964
4974
|
function F(e, r, o, s = !1) {
|
|
4965
|
-
let c = Z(n.value), l = Q(n.value), u = a.value.columnWidth, d = (r?.length || 0) > 2 ? 26.25 : 17.5, p =
|
|
4975
|
+
let c = Z(n.value), l = Q(n.value), u = a.value.columnWidth, d = (r?.length || 0) > 2 ? 26.25 : 17.5, p = St(e, {
|
|
4966
4976
|
questionNo: r || "",
|
|
4967
4977
|
score: o || "",
|
|
4968
4978
|
contentWidth: u - d,
|
|
@@ -4980,7 +4990,7 @@ function Pn(e) {
|
|
|
4980
4990
|
} catch {
|
|
4981
4991
|
throw Error("JSON 格式错误,请检查");
|
|
4982
4992
|
}
|
|
4983
|
-
let m =
|
|
4993
|
+
let m = Nt(p, {
|
|
4984
4994
|
questionNo: r || "",
|
|
4985
4995
|
score: o || "",
|
|
4986
4996
|
contentWidth: u - d,
|
|
@@ -4994,7 +5004,7 @@ function Pn(e) {
|
|
|
4994
5004
|
function ne(e, t, n) {
|
|
4995
5005
|
let r = p(e);
|
|
4996
5006
|
if (!r) return;
|
|
4997
|
-
let o =
|
|
5007
|
+
let o = Dn(r.block, a.value.columnWidth), s = Math.max(20, Math.min(Math.round(t), Math.max(20, o)));
|
|
4998
5008
|
r.image.width = s, n !== void 0 && (r.image.height = Math.max(12, Math.round(n))), i.value = !0, g();
|
|
4999
5009
|
}
|
|
5000
5010
|
function I(e) {
|
|
@@ -5018,10 +5028,10 @@ function Pn(e) {
|
|
|
5018
5028
|
}
|
|
5019
5029
|
function ie(e, t, r, i) {
|
|
5020
5030
|
let o = t ?? Z(n.value), s = r ?? Q(n.value), c = i ?? a.value.columnWidth - 17.5, l = e.split("\n").filter((e) => e.trim());
|
|
5021
|
-
return l.length === 0 && l.push(""), l.map((e) =>
|
|
5031
|
+
return l.length === 0 && l.push(""), l.map((e) => Sn(kn(e, o), o, s, c > 0 ? c : void 0));
|
|
5022
5032
|
}
|
|
5023
5033
|
function ae() {
|
|
5024
|
-
return
|
|
5034
|
+
return gt(t.value, n.value, {
|
|
5025
5035
|
paperName: s.value,
|
|
5026
5036
|
schoolName: c.value,
|
|
5027
5037
|
qrCodeContent: l.value,
|
|
@@ -5032,8 +5042,8 @@ function Pn(e) {
|
|
|
5032
5042
|
});
|
|
5033
5043
|
}
|
|
5034
5044
|
function R(e, r) {
|
|
5035
|
-
let o =
|
|
5036
|
-
t.value = o.blocks, o.settings && typeof o.settings.fontSize == "string" && (o.settings.fontSize =
|
|
5045
|
+
let o = _t(e);
|
|
5046
|
+
t.value = o.blocks, o.settings && typeof o.settings.fontSize == "string" && (o.settings.fontSize = yn(o.settings.fontSize)), n.value = {
|
|
5037
5047
|
...n.value,
|
|
5038
5048
|
...o.settings
|
|
5039
5049
|
}, a.value.updateSettings(o.settings), o.paperName && (s.value = o.paperName), o.schoolName && (c.value = o.schoolName), o.qrCodeContent && (l.value = o.qrCodeContent), o.qrCodeImage && (u.value = o.qrCodeImage), M(), r ? h() : g(), i.value = !1;
|
|
@@ -5068,15 +5078,15 @@ function Pn(e) {
|
|
|
5068
5078
|
parseTextToParagraphs: ie,
|
|
5069
5079
|
saveDocument: ae,
|
|
5070
5080
|
loadDocument: R,
|
|
5071
|
-
getBlockPlainText:
|
|
5072
|
-
getBlockLabel:
|
|
5073
|
-
getBlockAvailableWidth:
|
|
5081
|
+
getBlockPlainText: Nn,
|
|
5082
|
+
getBlockLabel: Pn,
|
|
5083
|
+
getBlockAvailableWidth: Dn
|
|
5074
5084
|
};
|
|
5075
5085
|
}
|
|
5076
|
-
var
|
|
5086
|
+
var In = z;
|
|
5077
5087
|
//#endregion
|
|
5078
5088
|
//#region src/composables/usePaperCore.ts
|
|
5079
|
-
function
|
|
5089
|
+
function Ln(e = {}) {
|
|
5080
5090
|
let n = f(e.renderMode ?? "edit"), r = m(new te()), i = m(new Ce({ renderMode: n.value })), a = m([]), o = f([]), s = f({ ...r.value.settings }), c = f(""), l = f(""), u = f(""), d = f(""), p = f(!1), h = f(0), g = t(() => {
|
|
5081
5091
|
let e = 0, t = /* @__PURE__ */ new Set();
|
|
5082
5092
|
for (let n of a.value) {
|
|
@@ -5091,7 +5101,7 @@ function In(e = {}) {
|
|
|
5091
5101
|
a && (e += parseInt(a[1]));
|
|
5092
5102
|
}
|
|
5093
5103
|
return e;
|
|
5094
|
-
}), _ =
|
|
5104
|
+
}), _ = _n(a), y = Fn({
|
|
5095
5105
|
blocks: a,
|
|
5096
5106
|
settings: s,
|
|
5097
5107
|
pages: o,
|
|
@@ -5113,7 +5123,7 @@ function In(e = {}) {
|
|
|
5113
5123
|
d.value = "";
|
|
5114
5124
|
return;
|
|
5115
5125
|
}
|
|
5116
|
-
d.value = await
|
|
5126
|
+
d.value = await gn(e);
|
|
5117
5127
|
}, { immediate: !0 });
|
|
5118
5128
|
function b(e) {
|
|
5119
5129
|
n.value = e, i.value.setRenderMode(e);
|
|
@@ -5212,8 +5222,8 @@ function In(e = {}) {
|
|
|
5212
5222
|
}
|
|
5213
5223
|
//#endregion
|
|
5214
5224
|
//#region src/composables/usePageSvgRenderer.ts
|
|
5215
|
-
var
|
|
5216
|
-
function
|
|
5225
|
+
var Rn = "<defs><g id=\"enter\"><path d=\"M810.667 213.333a42.667 42.667 0 0 1 42.368 37.675l0.298 4.992v274.304c0 79.275-50.944 147.499-120.49 152.107l-7.51 0.256H273.707l97.792 97.834a42.667 42.667 0 0 1-56.32 63.872l-4.011-3.541-170.667-170.667a42.667 42.667 0 0 1 0-60.33l170.667-170.667a42.667 42.667 0 0 1 63.872 56.32l-3.541 4.01-97.792 97.835h451.626c19.584 0 39.936-24.618 42.411-59.861l0.256-7.168V256a42.667 42.667 0 0 1 42.667-42.667z\" fill=\"currentColor\"/></g></defs>";
|
|
5226
|
+
function zn(e, n = {}) {
|
|
5217
5227
|
return t(() => {
|
|
5218
5228
|
e.renderMode.value;
|
|
5219
5229
|
let t = e.pages.value;
|
|
@@ -5228,13 +5238,13 @@ function Rn(e, n = {}) {
|
|
|
5228
5238
|
schoolName: e.schoolName.value,
|
|
5229
5239
|
qrCodeImage: e.qrCodeImage.value
|
|
5230
5240
|
}, t.length);
|
|
5231
|
-
return `<svg xmlns="http://www.w3.org/2000/svg" width="${r * o}" height="${i * o}" viewBox="0 0 ${r} ${i}" class="paper-page">\n${
|
|
5241
|
+
return `<svg xmlns="http://www.w3.org/2000/svg" width="${r * o}" height="${i * o}" viewBox="0 0 ${r} ${i}" class="paper-page">\n${Rn}\n${l}</svg>`;
|
|
5232
5242
|
});
|
|
5233
5243
|
});
|
|
5234
5244
|
}
|
|
5235
5245
|
//#endregion
|
|
5236
5246
|
//#region src/composables/useTableRenderer.ts
|
|
5237
|
-
async function
|
|
5247
|
+
async function Bn(e, t, n = 2) {
|
|
5238
5248
|
let r = [];
|
|
5239
5249
|
for (let t = 0; t < e.length; t++) {
|
|
5240
5250
|
let n = e[t];
|
|
@@ -5261,7 +5271,7 @@ async function zn(e, t, n = 2) {
|
|
|
5261
5271
|
if (r.length !== 0) for (let i = 0; i < r.length; i++) {
|
|
5262
5272
|
let a = r[i];
|
|
5263
5273
|
try {
|
|
5264
|
-
let r = await
|
|
5274
|
+
let r = await Vn(a.rawHtml, t, n);
|
|
5265
5275
|
if (r) {
|
|
5266
5276
|
let t = e[a.blockIdx].paragraphs[a.paraIdx].lines[a.lineIdx].elements[a.elemIdx];
|
|
5267
5277
|
t.src = r, delete t.rawHtml;
|
|
@@ -5271,7 +5281,7 @@ async function zn(e, t, n = 2) {
|
|
|
5271
5281
|
}
|
|
5272
5282
|
}
|
|
5273
5283
|
}
|
|
5274
|
-
async function
|
|
5284
|
+
async function Vn(e, t, n) {
|
|
5275
5285
|
let r = document.createElement("div");
|
|
5276
5286
|
r.innerHTML = e, r.style.position = "absolute", r.style.left = "-9999px", r.style.top = "0", r.style.width = "auto", r.style.height = "auto";
|
|
5277
5287
|
let i = document.createElement("style");
|
|
@@ -5292,7 +5302,7 @@ async function Bn(e, t, n) {
|
|
|
5292
5302
|
document.body.removeChild(r);
|
|
5293
5303
|
}
|
|
5294
5304
|
}
|
|
5295
|
-
function
|
|
5305
|
+
function Hn(e) {
|
|
5296
5306
|
for (let t of e) if (t.paragraphs) {
|
|
5297
5307
|
for (let e of t.paragraphs) if (e.lines) {
|
|
5298
5308
|
for (let t of e.lines) if (t.elements) {
|
|
@@ -5307,7 +5317,7 @@ function Vn(e) {
|
|
|
5307
5317
|
}
|
|
5308
5318
|
//#endregion
|
|
5309
5319
|
//#region src/composables/usePaperCursor.ts
|
|
5310
|
-
function
|
|
5320
|
+
function Un(e, t, n, r) {
|
|
5311
5321
|
let i = f({
|
|
5312
5322
|
blockId: null,
|
|
5313
5323
|
paraIndex: 0,
|
|
@@ -5375,7 +5385,7 @@ function Hn(e, t, n, r) {
|
|
|
5375
5385
|
}];
|
|
5376
5386
|
}
|
|
5377
5387
|
function p(e) {
|
|
5378
|
-
let n = Z(t.value), r = Q(t.value), i =
|
|
5388
|
+
let n = Z(t.value), r = Q(t.value), i = xn(n, r);
|
|
5379
5389
|
return e.length === 0 || e.length === 1 && e[0].type === "enter" ? $(n, r) : {
|
|
5380
5390
|
lines: [{
|
|
5381
5391
|
elements: e,
|
|
@@ -5777,7 +5787,7 @@ function Hn(e, t, n, r) {
|
|
|
5777
5787
|
}
|
|
5778
5788
|
//#endregion
|
|
5779
5789
|
//#region src/components/PaperEditor.vue?vue&type=script&setup=true&lang.ts
|
|
5780
|
-
var
|
|
5790
|
+
var Wn = { class: "pe-root" }, Gn = { class: "pe-main" }, Kn = { class: "pe-editor" }, qn = { class: "pe-editor-pages" }, Jn = ["onClick"], Yn = ["innerHTML"], Xn = { class: "pe-editor-controllers" }, Zn = /*@__PURE__*/ a({
|
|
5781
5791
|
__name: "PaperEditor",
|
|
5782
5792
|
props: {
|
|
5783
5793
|
initialData: {},
|
|
@@ -5798,7 +5808,7 @@ var Un = { class: "pe-root" }, Wn = { class: "pe-main" }, Gn = { class: "pe-edit
|
|
|
5798
5808
|
"loaded"
|
|
5799
5809
|
],
|
|
5800
5810
|
setup(a, { expose: m, emit: h }) {
|
|
5801
|
-
let x = a, S = h, C =
|
|
5811
|
+
let x = a, S = h, C = Ln({ renderMode: x.renderMode }), w = Un(C.blocks, C.settings, () => {
|
|
5802
5812
|
C.reflowAllBlocks(), o(() => O.value?.focus());
|
|
5803
5813
|
}, () => {
|
|
5804
5814
|
C.isDirty.value = !0;
|
|
@@ -5817,7 +5827,7 @@ var Un = { class: "pe-root" }, Wn = { class: "pe-main" }, Gn = { class: "pe-edit
|
|
|
5817
5827
|
top: A.value.top + "px",
|
|
5818
5828
|
height: A.value.height + "px",
|
|
5819
5829
|
transform: "skewX(0deg)"
|
|
5820
|
-
})), N =
|
|
5830
|
+
})), N = zn(C, {
|
|
5821
5831
|
zoom: T,
|
|
5822
5832
|
selectedBlockId: null
|
|
5823
5833
|
});
|
|
@@ -6486,7 +6496,7 @@ var Un = { class: "pe-root" }, Wn = { class: "pe-main" }, Gn = { class: "pe-edit
|
|
|
6486
6496
|
qrCodeImage: C.qrCodeImage.value,
|
|
6487
6497
|
showScore: C.settings.value.showScore
|
|
6488
6498
|
}))
|
|
6489
|
-
}), (t, a) => (d(), r("div",
|
|
6499
|
+
}), (t, a) => (d(), r("div", Wn, [i("div", Gn, [i("div", Kn, [i("div", {
|
|
6490
6500
|
class: "pe-editor-surface",
|
|
6491
6501
|
ref_key: "saberEditorRef",
|
|
6492
6502
|
ref: ee
|
|
@@ -6495,7 +6505,7 @@ var Un = { class: "pe-root" }, Wn = { class: "pe-main" }, Gn = { class: "pe-edit
|
|
|
6495
6505
|
d: "M810.667 213.333a42.667 42.667 0 0 1 42.368 37.675l0.298 4.992v274.304c0 79.275-50.944 147.499-120.49 152.107l-7.51 0.256H273.707l97.792 97.834a42.667 42.667 0 0 1-56.32 63.872l-4.011-3.541-170.667-170.667a42.667 42.667 0 0 1 0-60.33l170.667-170.667a42.667 42.667 0 0 1 63.872 56.32l-3.541 4.01-97.792 97.835h451.626c19.584 0 39.936-24.618 42.411-59.861l0.256-7.168V256a42.667 42.667 0 0 1 42.667-42.667z",
|
|
6496
6506
|
fill: "currentColor"
|
|
6497
6507
|
})])])], -1),
|
|
6498
|
-
i("div",
|
|
6508
|
+
i("div", qn, [(d(!0), r(e, null, p(g(N), (e, t) => (d(), r("div", {
|
|
6499
6509
|
key: t,
|
|
6500
6510
|
class: s(["pe-editor-page", { active: t === E.value }]),
|
|
6501
6511
|
onClick: b((e) => E.value = t, ["stop"])
|
|
@@ -6504,8 +6514,8 @@ var Un = { class: "pe-root" }, Wn = { class: "pe-main" }, Gn = { class: "pe-edit
|
|
|
6504
6514
|
innerHTML: e,
|
|
6505
6515
|
onClick: ie,
|
|
6506
6516
|
onFocusout: ae
|
|
6507
|
-
}, null, 40,
|
|
6508
|
-
i("div",
|
|
6517
|
+
}, null, 40, Yn)], 10, Jn))), 128))]),
|
|
6518
|
+
i("div", Xn, [
|
|
6509
6519
|
R.value ? (d(), r("div", {
|
|
6510
6520
|
key: 0,
|
|
6511
6521
|
class: "pe-ctrl-block",
|
|
@@ -6612,17 +6622,17 @@ var Un = { class: "pe-root" }, Wn = { class: "pe-main" }, Gn = { class: "pe-edit
|
|
|
6612
6622
|
}, null, 4), [[_, D.value]])
|
|
6613
6623
|
], 512)])])]));
|
|
6614
6624
|
}
|
|
6615
|
-
}),
|
|
6625
|
+
}), Qn = (e, t) => {
|
|
6616
6626
|
let n = e.__vccOpts || e;
|
|
6617
6627
|
for (let [e, r] of t) n[e] = r;
|
|
6618
6628
|
return n;
|
|
6619
|
-
},
|
|
6629
|
+
}, $n = /*#__PURE__*/ Qn(Zn, [["__scopeId", "data-v-62a78c32"]]), er = { class: "pe-preview__pages" }, tr = ["innerHTML"], nr = {
|
|
6620
6630
|
key: 0,
|
|
6621
6631
|
class: "pe-preview__helpers"
|
|
6622
|
-
},
|
|
6632
|
+
}, rr = {
|
|
6623
6633
|
key: 1,
|
|
6624
6634
|
class: "pe-preview__page-num"
|
|
6625
|
-
},
|
|
6635
|
+
}, ir = /*#__PURE__*/ Qn(/* @__PURE__ */ a({
|
|
6626
6636
|
__name: "PaperPreview",
|
|
6627
6637
|
props: {
|
|
6628
6638
|
document: {},
|
|
@@ -6649,14 +6659,14 @@ var Un = { class: "pe-root" }, Wn = { class: "pe-main" }, Gn = { class: "pe-edit
|
|
|
6649
6659
|
}
|
|
6650
6660
|
},
|
|
6651
6661
|
setup(a) {
|
|
6652
|
-
let o = a, m =
|
|
6662
|
+
let o = a, m = Ln();
|
|
6653
6663
|
function _() {
|
|
6654
6664
|
o.document && m.loadDocument(o.document);
|
|
6655
6665
|
}
|
|
6656
6666
|
_(), v(() => o.document, _), v(() => o.pureMode, (e) => {
|
|
6657
6667
|
m.setRenderMode(e ? "view" : "edit");
|
|
6658
6668
|
}, { immediate: !0 });
|
|
6659
|
-
let y =
|
|
6669
|
+
let y = zn(m, { selectedBlockId: null }), b = f(), x = f(0), S = null;
|
|
6660
6670
|
l(() => {
|
|
6661
6671
|
x.value = b.value?.clientWidth ?? 0, S = new ResizeObserver((e) => {
|
|
6662
6672
|
for (let t of e) x.value = Math.floor(t.contentRect.width);
|
|
@@ -6822,7 +6832,7 @@ var Un = { class: "pe-root" }, Wn = { class: "pe-main" }, Gn = { class: "pe-edit
|
|
|
6822
6832
|
class: s(["pe-preview", { "pe-preview--print": a.mode === "print" }]),
|
|
6823
6833
|
ref_key: "previewRef",
|
|
6824
6834
|
ref: b
|
|
6825
|
-
}, [i("div",
|
|
6835
|
+
}, [i("div", er, [(d(!0), r(e, null, p(g(y), (t, o) => (d(), r("div", {
|
|
6826
6836
|
key: o,
|
|
6827
6837
|
class: "pe-preview__page",
|
|
6828
6838
|
style: c(O(o))
|
|
@@ -6836,8 +6846,8 @@ var Un = { class: "pe-root" }, Wn = { class: "pe-main" }, Gn = { class: "pe-edit
|
|
|
6836
6846
|
width: "100%",
|
|
6837
6847
|
height: "100%"
|
|
6838
6848
|
}
|
|
6839
|
-
}, null, 8,
|
|
6840
|
-
a.showHelpers ? (d(), r("div",
|
|
6849
|
+
}, null, 8, tr)], 4),
|
|
6850
|
+
a.showHelpers ? (d(), r("div", nr, [a.showCornerMarks ? (d(!0), r(e, { key: 0 }, p(D(o), (e, t) => (d(), r("span", {
|
|
6841
6851
|
key: "cm-" + t,
|
|
6842
6852
|
class: s(["pe-preview__helper-box", e.className]),
|
|
6843
6853
|
style: c(M(e))
|
|
@@ -6846,9 +6856,9 @@ var Un = { class: "pe-root" }, Wn = { class: "pe-main" }, Gn = { class: "pe-edit
|
|
|
6846
6856
|
class: s(["pe-preview__helper-box", e.className]),
|
|
6847
6857
|
style: c(M(e))
|
|
6848
6858
|
}, null, 6))), 128)) : n("", !0)])) : n("", !0),
|
|
6849
|
-
a.showPageNumbers ? (d(), r("div",
|
|
6859
|
+
a.showPageNumbers ? (d(), r("div", rr, h(o + 1) + " / " + h(g(m).pages.value.length), 1)) : n("", !0)
|
|
6850
6860
|
], 4))), 128))])], 2));
|
|
6851
6861
|
}
|
|
6852
6862
|
}), [["__scopeId", "data-v-1b638e19"]]);
|
|
6853
6863
|
//#endregion
|
|
6854
|
-
export {
|
|
6864
|
+
export { vn as FONT_SIZE_MAP, k as PAPER_DIMENSIONS, A as PAPER_MM, $n as PaperEditor, te as PaperLayout, ir as PaperPreview, Ce as SvgRenderer, Vt as buildPaperHtml, B as calcCharPositions, se as calcTextWidth, De as clearFormulaCache, le as clearWidthCache, _t as deserializeDocument, zt as extractBaseTitle, yn as fontSizeLabelToPx, bn as fontSizePxToLabel, Rt as formatSectionTitle, z as getCharWidth, M as getPaperPreset, Hn as hasTablePlaceholder, G as latexToSvg, Me as latexToSvgBatch, St as parseQuestionHtml, Nt as parseQuestionJson, Bn as renderTablePlaceholders, gt as serializeDocument, P as toBBox, Lt as toChineseOrdinal, zn as usePageSvgRenderer, Ln as usePaperCore };
|