@sw7d/paper-renderer 0.1.8 → 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.
@@ -299,17 +299,8 @@ var te = class {
299
299
  t = Math.max(t, n);
300
300
  }
301
301
  return 20 + Math.min(t, n - 20);
302
- }), i = e.options.map((e) => e.paragraphs.reduce((e, t) => e + (t.height || 26), 0)), a = 0, o = 0, s = 0, c = 0;
303
- for (let t = 0; t < e.options.length; t++) {
304
- let e = r[t], l = i[t];
305
- if (a > 0) {
306
- let i = t - c, l = n - r.slice(c, t).reduce((e, t) => e + t, 0) - e, u = i > 0 ? Math.max(8, l / i) : 8;
307
- a + e + u > n && (a = 0, o += s, s = 0, c = t);
308
- }
309
- let u = t - c + 1, d = r.slice(c, t + 1).reduce((e, t) => e + t, 0), f = u > 1 ? Math.max(8, (n - d) / u) : 16;
310
- a += e + f, s = Math.max(s, l);
311
- }
312
- return o + s;
302
+ }), i = e.options.map((e) => e.paragraphs.reduce((e, t) => e + (t.height || 26), 0)), a = e.options.length;
303
+ return Math.max(...r) * a <= n ? Math.max(...i) : i.reduce((e, t) => e + t, 0);
313
304
  }
314
305
  measureParagraph(e) {
315
306
  let t = 0;
@@ -503,21 +494,28 @@ function ge() {
503
494
  //#endregion
504
495
  //#region src/engine/svg/optionsRenderer.ts
505
496
  function H(e, t, n, r, i) {
506
- let a = t - 20, o = ` <g class="swed-option" transform="translate(0, ${n})">\n`, s = e.map((e) => _e(e, 20, a)), c = e.map((e) => e.paragraphs.reduce((e, t) => e + (t.height || 26), 0)), l = 0, u = 0, d = 0, f = 0;
507
- for (let n = 0; n < e.length; n++) {
508
- let p = s[n], m = c[n];
509
- if (l > 0) {
510
- let e = n - f, r = t - s.slice(f, n).reduce((e, t) => e + t, 0) - p, i = e > 0 ? Math.max(8, r / e) : 8;
511
- l + p + i > t && (l = 0, u += d, d = 0, f = n);
512
- }
513
- o += ` <g class="swed-option-item" transform="translate(${l}, ${u})">\n`;
514
- let h = e[n].paragraphs[0]?.lines[0]?.baseline || r * 1.56;
515
- o += ` <text class="swed-text" xml:space="preserve" font-size="${r}" font-weight="normal" font-family="Times New Roman" font-style="normal" fill="#000000" fill-opacity="1" y="${h.toFixed(3)}">${V(e[n].label)}.</text>\n`, o += " <g>\n";
516
- let g = 0;
517
- for (let t of e[n].paragraphs) o += xe(t, a, g, !1, "", r, i, 20), g += t.height || 26;
518
- o += " </g>\n", o += " </g>\n";
519
- let _ = n - f + 1, v = s.slice(f, n + 1).reduce((e, t) => e + t, 0), y = _ > 1 ? Math.max(8, (t - v) / _) : 16;
520
- l += p + y, d = Math.max(d, m);
497
+ let a = t - 20, o = ` <g class="swed-option" transform="translate(0, ${n})">\n`, s = e.map((e) => _e(e, 20, a)), c = e.map((e) => e.paragraphs.reduce((e, t) => e + (t.height || 26), 0)), l = e.length, u = Math.max(...s);
498
+ if (l > 0 && u * l <= t) {
499
+ let n = t / l, a = n - 20;
500
+ for (let t = 0; t < l; t++) {
501
+ let s = n * t;
502
+ o += ` <g class="swed-option-item" transform="translate(${s}, 0)">\n`;
503
+ let c = e[t].paragraphs[0]?.lines[0]?.baseline || r * 1.56;
504
+ o += ` <text class="swed-text" xml:space="preserve" font-size="${r}" font-weight="normal" font-family="Times New Roman" font-style="normal" fill="#000000" fill-opacity="1" y="${c.toFixed(3)}">${V(e[t].label)}.</text>\n`, o += " <g>\n";
505
+ let l = 0;
506
+ for (let n of e[t].paragraphs) o += xe(n, a, l, !1, "", r, i, 20), l += n.height || 26;
507
+ o += " </g>\n", o += " </g>\n";
508
+ }
509
+ return o += " </g>\n", o;
510
+ }
511
+ let d = 0;
512
+ for (let t = 0; t < l; t++) {
513
+ o += ` <g class="swed-option-item" transform="translate(0, ${d})">\n`;
514
+ let n = e[t].paragraphs[0]?.lines[0]?.baseline || r * 1.56;
515
+ o += ` <text class="swed-text" xml:space="preserve" font-size="${r}" font-weight="normal" font-family="Times New Roman" font-style="normal" fill="#000000" fill-opacity="1" y="${n.toFixed(3)}">${V(e[t].label)}.</text>\n`, o += " <g>\n";
516
+ let s = 0;
517
+ for (let n of e[t].paragraphs) o += xe(n, a, s, !1, "", r, i, 20), s += n.height || 26;
518
+ o += " </g>\n", o += " </g>\n", d += c[t];
521
519
  }
522
520
  return o += " </g>\n", o;
523
521
  }
@@ -532,17 +530,8 @@ function _e(e, t, n) {
532
530
  }
533
531
  function U(e, t) {
534
532
  if (e.length === 0) return 0;
535
- let n = e.map((e) => _e(e, 20, t)), r = e.map((e) => e.paragraphs.reduce((e, t) => e + (t.height || 26), 0)), i = 0, a = 0, o = 0, s = 0;
536
- for (let c = 0; c < e.length; c++) {
537
- let e = n[c], l = r[c];
538
- if (i > 0) {
539
- let r = c - s, l = t - n.slice(s, c).reduce((e, t) => e + t, 0) - e, u = r > 0 ? Math.max(8, l / r) : 8;
540
- i + e + u > t && (i = 0, a += o, o = 0, s = c);
541
- }
542
- let u = c - s + 1, d = n.slice(s, c + 1).reduce((e, t) => e + t, 0), f = u > 1 ? Math.max(8, (t - d) / u) : 16;
543
- i += e + f, o = Math.max(o, l);
544
- }
545
- return a + o;
533
+ let n = e.map((e) => _e(e, 20, t)), r = e.map((e) => e.paragraphs.reduce((e, t) => e + (t.height || 26), 0)), i = e.length;
534
+ return Math.max(...n) * i <= t ? Math.max(...r) : r.reduce((e, t) => e + t, 0);
546
535
  }
547
536
  //#endregion
548
537
  //#region src/engine/svg/questionRenderer.ts
@@ -2059,7 +2048,7 @@ function mt(e) {
2059
2048
  isTitle: !0
2060
2049
  };
2061
2050
  return t.topicTitle && (r.title = String(t.title || "")), {
2062
- id: `title-${e.props.id}`,
2051
+ id: `title-${e.props.id}-${++ht}`,
2063
2052
  type: "title",
2064
2053
  paragraphs: [],
2065
2054
  height: e.props.rect?.height || 40,
@@ -2067,9 +2056,10 @@ function mt(e) {
2067
2056
  keepNext: e.props.keepNext ?? !1
2068
2057
  };
2069
2058
  }
2059
+ var ht = 0;
2070
2060
  //#endregion
2071
2061
  //#region src/utils/documentSerializer.ts
2072
- function ht(e, t, n = {}) {
2062
+ function gt(e, t, n = {}) {
2073
2063
  let r = Xe(e, t), i = {
2074
2064
  info: {
2075
2065
  author: "",
@@ -2331,13 +2321,13 @@ function ht(e, t, n = {}) {
2331
2321
  };
2332
2322
  return n.pages && n.pages.length > 0 && (i._pages = et(n.pages, n.blocks || [], t.showScore)), JSON.stringify(i, null, 2);
2333
2323
  }
2334
- function gt(e) {
2324
+ function _t(e) {
2335
2325
  return ft(e);
2336
2326
  }
2337
2327
  //#endregion
2338
2328
  //#region src/utils/questionHtmlParser.ts
2339
- var _t = 0, vt = 0, yt = 0, bt = .5;
2340
- function xt(e, t = {}) {
2329
+ var vt = 0, yt = 0, bt = 0, xt = .5;
2330
+ function St(e, t = {}) {
2341
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([
2342
2332
  "p",
2343
2333
  "h1",
@@ -2356,7 +2346,7 @@ function xt(e, t = {}) {
2356
2346
  if (t.nodeType !== Node.ELEMENT_NODE) continue;
2357
2347
  let n = t, r = n.tagName.toLowerCase();
2358
2348
  if (r === "table") {
2359
- let e = jt(n, i, d), t = e.reduce((e, t) => e + t.lineHeight, 0) + 4;
2349
+ let e = Mt(n, i, d), t = e.reduce((e, t) => e + t.lineHeight, 0) + 4;
2360
2350
  u.push({
2361
2351
  lines: e,
2362
2352
  y: 0,
@@ -2367,7 +2357,7 @@ function xt(e, t = {}) {
2367
2357
  if (r === "figure") {
2368
2358
  let e = n.querySelector("table");
2369
2359
  if (e) {
2370
- let t = jt(e, i, d), n = t.reduce((e, t) => e + t.lineHeight, 0) + 4;
2360
+ let t = Mt(e, i, d), n = t.reduce((e, t) => e + t.lineHeight, 0) + 4;
2371
2361
  u.push({
2372
2362
  lines: t,
2373
2363
  y: 0,
@@ -2379,7 +2369,7 @@ function xt(e, t = {}) {
2379
2369
  if (!p.has(r)) continue;
2380
2370
  let o = n, s = o.getAttribute("style") || "", c = J(o, a, s, i, f);
2381
2371
  if (c.length === 0) continue;
2382
- let m = it(c, i, d), h = m.reduce((e, t) => e + t.lineHeight, 0) + 4, g = wt(s), _ = g === "center" ? "center" : g === "right" ? "right" : void 0;
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;
2383
2373
  u.push({
2384
2374
  lines: m,
2385
2375
  y: 0,
@@ -2401,7 +2391,7 @@ function xt(e, t = {}) {
2401
2391
  y: 0,
2402
2392
  height: d + 4
2403
2393
  });
2404
- let m = u.reduce((e, t) => e + (t.height || 26), 0), h = `topic-html-${++vt}`;
2394
+ let m = u.reduce((e, t) => e + (t.height || 26), 0), h = `topic-html-${++yt}`;
2405
2395
  return [{
2406
2396
  id: `q-html-${Date.now()}-${Math.random().toString(36).slice(2, 6)}`,
2407
2397
  type: "question",
@@ -2427,13 +2417,13 @@ function J(e, t, n, r, i) {
2427
2417
  let r = e.replace(/\u00A0/g, " ").replace(/\n/g, "").replace(/\s+/g, " ");
2428
2418
  if (!r.trim()) {
2429
2419
  if (a.length > 0) {
2430
- let e = Tt(n) || t, r = Et(n) || "\"Times New Roman\", SimSun", i = Dt(n) || "#000", o = /font-style:\s*(italic|oblique)/.test(n);
2431
- a.push(Ct("\xA0", e, r, !1, i, o));
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));
2432
2422
  }
2433
2423
  continue;
2434
2424
  }
2435
- let i = r.startsWith(" ") && a.length > 0, o = r.endsWith(" "), c = r.trim(), l = (i ? "\xA0" : "") + c + (o ? "\xA0" : ""), u = Tt(n) || t, d = Et(n) || "\"Times New Roman\", SimSun", f = Dt(n) || "#000", p = /font-weight:\s*(bold|700|[89]\d\d)/.test(n), m = /font-style:\s*(italic|oblique)/.test(n);
2436
- a.push(Ct(l, u, d, p, f, m));
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));
2437
2427
  continue;
2438
2428
  }
2439
2429
  if (s.nodeType !== Node.ELEMENT_NODE) continue;
@@ -2474,14 +2464,14 @@ function J(e, t, n, r, i) {
2474
2464
  }
2475
2465
  a.push({
2476
2466
  type: "image",
2477
- id: `inline-img-${++yt}`,
2467
+ id: `inline-img-${++bt}`,
2478
2468
  src: e,
2479
2469
  width: l,
2480
2470
  height: d
2481
2471
  });
2482
2472
  continue;
2483
2473
  }
2484
- let f = St(d);
2474
+ let f = Ct(d);
2485
2475
  if (l === "span" && f) {
2486
2476
  let e = c.textContent || "", { blankType: t, isEmpty: n } = f, r;
2487
2477
  if (t === "tiankong") {
@@ -2490,7 +2480,7 @@ function J(e, t, n, r, i) {
2490
2480
  } else r = Math.max(40, e.length * 14 + 10);
2491
2481
  a.push({
2492
2482
  type: "underline",
2493
- id: `ul-html-${++_t}`,
2483
+ id: `ul-html-${++vt}`,
2494
2484
  width: r,
2495
2485
  height: 20,
2496
2486
  placeholder: t === "tiankong" ? "空" : t === "xuanze" ? "选" : "判",
@@ -2504,7 +2494,7 @@ function J(e, t, n, r, i) {
2504
2494
  if (l === "span" && d.includes("under-point")) {
2505
2495
  let e = c.textContent || "";
2506
2496
  if (e.trim()) {
2507
- let r = Tt(u) || Tt(n) || t, i = Et(u) || Et(n) || "\"Times New Roman\", SimSun", o = Dt(u) || Dt(n) || "#000", s = /font-style:\s*(italic|oblique)/.test(u) || /font-style:\s*(italic|oblique)/.test(n), c = Ct(e.trim(), r, i, !1, o, s);
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);
2508
2498
  c.dotAbove = !0, a.push(c);
2509
2499
  }
2510
2500
  continue;
@@ -2512,7 +2502,7 @@ function J(e, t, n, r, i) {
2512
2502
  if (l === "span" && d.includes("wavy-line")) {
2513
2503
  let e = c.textContent || "";
2514
2504
  if (e.trim()) {
2515
- let r = Tt(u) || Tt(n) || t, i = Et(u) || Et(n) || "\"Times New Roman\", SimSun", o = Dt(u) || Dt(n) || "#000", s = /font-style:\s*(italic|oblique)/.test(u) || /font-style:\s*(italic|oblique)/.test(n), c = Ct(e.trim(), r, i, !1, o, s);
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);
2516
2506
  c.wavyLine = !0, a.push(c);
2517
2507
  }
2518
2508
  continue;
@@ -2552,7 +2542,7 @@ function J(e, t, n, r, i) {
2552
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;
2553
2543
  a.push({
2554
2544
  type: "image",
2555
- id: `inline-img-${++yt}`,
2545
+ id: `inline-img-${++bt}`,
2556
2546
  src: "",
2557
2547
  width: Math.min(s, r),
2558
2548
  height: o,
@@ -2566,7 +2556,7 @@ function J(e, t, n, r, i) {
2566
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;
2567
2557
  a.push({
2568
2558
  type: "image",
2569
- id: `inline-img-${++yt}`,
2559
+ id: `inline-img-${++bt}`,
2570
2560
  src: "",
2571
2561
  width: Math.min(l, r),
2572
2562
  height: c,
@@ -2579,7 +2569,7 @@ function J(e, t, n, r, i) {
2579
2569
  continue;
2580
2570
  }
2581
2571
  if (l === "sub" || l === "sup") {
2582
- let e = Math.round(t * bt), 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
+ 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);
2583
2573
  for (let e of o) e.type === "text" && (e.verticalAlign = s);
2584
2574
  a.push(...o);
2585
2575
  continue;
@@ -2597,7 +2587,7 @@ function J(e, t, n, r, i) {
2597
2587
  }
2598
2588
  let f = u.match(/background-color:\s*([^;]+)/);
2599
2589
  if (f && f[1] && f[1] !== "transparent") {
2600
- let e = At(f[1]);
2590
+ let e = jt(f[1]);
2601
2591
  if (e) for (let t of l) t.type === "text" && (t.backgroundColor = e);
2602
2592
  }
2603
2593
  a.push(...l);
@@ -2608,7 +2598,7 @@ function J(e, t, n, r, i) {
2608
2598
  }
2609
2599
  return a;
2610
2600
  }
2611
- function St(e) {
2601
+ function Ct(e) {
2612
2602
  return e.includes("blank-tiankong") || e.includes("blank_tiankong") ? {
2613
2603
  blankType: "tiankong",
2614
2604
  isEmpty: !0
@@ -2620,7 +2610,7 @@ function St(e) {
2620
2610
  isEmpty: !1
2621
2611
  } : null;
2622
2612
  }
2623
- function Ct(e, t, n, r, i, a) {
2613
+ function wt(e, t, n, r, i, a) {
2624
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;
2625
2615
  return {
2626
2616
  type: "text",
@@ -2635,19 +2625,19 @@ function Ct(e, t, n, r, i, a) {
2635
2625
  xPositions: s
2636
2626
  };
2637
2627
  }
2638
- function wt(e) {
2628
+ function Tt(e) {
2639
2629
  let t = e.match(/text-align:\s*(right|center|left)/);
2640
2630
  return t ? t[1] : "left";
2641
2631
  }
2642
- function Tt(e) {
2632
+ function Et(e) {
2643
2633
  let t = e.match(/font-size:\s*(\d+)px/);
2644
2634
  return t ? parseInt(t[1]) : null;
2645
2635
  }
2646
- function Et(e) {
2636
+ function Dt(e) {
2647
2637
  let t = e.match(/font-family:\s*([^;]+)/);
2648
2638
  return t ? t[1].trim().replace(/["']/g, "") : null;
2649
2639
  }
2650
- function Dt(e) {
2640
+ function Ot(e) {
2651
2641
  let t = e.match(/color:\s*rgb\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)/);
2652
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")}`;
2653
2643
  let n = e.match(/color:\s*rgba\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,[^)]+\)/);
@@ -2655,9 +2645,9 @@ function Dt(e) {
2655
2645
  let r = e.match(/color:\s*(#[0-9a-fA-F]{3,6})/);
2656
2646
  if (r) return r[1];
2657
2647
  let i = e.match(/color:\s*([a-zA-Z]+)/);
2658
- return i && kt(i[1]) || null;
2648
+ return i && At(i[1]) || null;
2659
2649
  }
2660
- var Ot = {
2650
+ var kt = {
2661
2651
  red: "#ff0000",
2662
2652
  green: "#008000",
2663
2653
  blue: "#0000ff",
@@ -2684,16 +2674,16 @@ var Ot = {
2684
2674
  lightgrey: "#d3d3d3",
2685
2675
  transparent: "#000000"
2686
2676
  };
2687
- function kt(e) {
2688
- return Ot[e.toLowerCase()];
2689
- }
2690
2677
  function At(e) {
2678
+ return kt[e.toLowerCase()];
2679
+ }
2680
+ function jt(e) {
2691
2681
  let t = e.trim(), n = t.match(/^#[0-9a-fA-F]{3,6}$/);
2692
2682
  if (n) return n[0];
2693
2683
  let r = t.match(/^rgb\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)$/);
2694
- 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")}` : kt(t) || null;
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;
2695
2685
  }
2696
- function jt(e, t, n) {
2686
+ function Mt(e, t, n) {
2697
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;
2698
2688
  return u <= 0 || d <= 0 ? [{
2699
2689
  ...rt([], n),
@@ -2701,7 +2691,7 @@ function jt(e, t, n) {
2701
2691
  }] : [{
2702
2692
  ...rt([{
2703
2693
  type: "image",
2704
- id: `inline-img-${++yt}`,
2694
+ id: `inline-img-${++bt}`,
2705
2695
  src: "",
2706
2696
  width: u,
2707
2697
  height: d,
@@ -2712,8 +2702,8 @@ function jt(e, t, n) {
2712
2702
  }
2713
2703
  //#endregion
2714
2704
  //#region src/utils/questionJsonParser.ts
2715
- function Mt(e, t = {}) {
2716
- 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 = xt(e.question, {
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, {
2717
2707
  questionNo: n,
2718
2708
  score: r,
2719
2709
  contentWidth: i,
@@ -2740,14 +2730,14 @@ function Mt(e, t = {}) {
2740
2730
  tags: e.tags
2741
2731
  }
2742
2732
  };
2743
- if (l && e.extra_json?.options && e.extra_json.options.length > 0) p.options = Nt(e.extra_json.options, i, a, o), p.paragraphs.push(Pt(u));
2744
- else for (let e = 0; e < 2; e++) p.paragraphs.push(Pt(u));
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));
2745
2735
  return p.height = p.paragraphs.reduce((e, t) => e + (t.height || 26), 0), [p];
2746
2736
  }
2747
- function Nt(e, t, n, r) {
2737
+ function Pt(e, t, n, r) {
2748
2738
  let i = Math.max(100, t - 20);
2749
2739
  return e.map((e) => {
2750
- let t = xt(e.content, {
2740
+ let t = St(e.content, {
2751
2741
  contentWidth: i,
2752
2742
  fontSize: n,
2753
2743
  lineSpacing: r,
@@ -2773,7 +2763,7 @@ function Nt(e, t, n, r) {
2773
2763
  };
2774
2764
  });
2775
2765
  }
2776
- function Pt(e) {
2766
+ function Ft(e) {
2777
2767
  return {
2778
2768
  lines: [{
2779
2769
  elements: [{
@@ -2791,7 +2781,7 @@ function Pt(e) {
2791
2781
  }
2792
2782
  //#endregion
2793
2783
  //#region src/utils/chineseNumber.ts
2794
- var Ft = [
2784
+ var It = [
2795
2785
  "",
2796
2786
  "一",
2797
2787
  "二",
@@ -2804,34 +2794,34 @@ var Ft = [
2804
2794
  "九",
2805
2795
  "十"
2806
2796
  ];
2807
- function It(e) {
2797
+ function Lt(e) {
2808
2798
  if (e <= 0) return "";
2809
- if (e <= 10) return Ft[e];
2799
+ if (e <= 10) return It[e];
2810
2800
  if (e < 20) {
2811
2801
  let t = e % 10;
2812
- return "十" + (t > 0 ? Ft[t] : "");
2802
+ return "十" + (t > 0 ? It[t] : "");
2813
2803
  }
2814
2804
  if (e < 100) {
2815
2805
  let t = Math.floor(e / 10), n = e % 10;
2816
- return Ft[t] + "十" + (n > 0 ? Ft[n] : "");
2806
+ return It[t] + "十" + (n > 0 ? It[n] : "");
2817
2807
  }
2818
2808
  if (e < 1e3) {
2819
- let t = Math.floor(e / 100), n = e % 100, r = Ft[t] + "百";
2820
- return n === 0 ? r : n < 10 ? r + "零" + Ft[n] : r + It(n);
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);
2821
2811
  }
2822
2812
  return String(e);
2823
2813
  }
2824
- function Lt(e, t) {
2825
- let n = It(t);
2814
+ function Rt(e, t) {
2815
+ let n = Lt(t);
2826
2816
  return n ? n + "、" + e : e;
2827
2817
  }
2828
- function Rt(e) {
2818
+ function zt(e) {
2829
2819
  let t = e.match(/^[一二三四五六七八九十百零]+、(.+)$/);
2830
2820
  return t ? t[1] : e;
2831
2821
  }
2832
2822
  //#endregion
2833
2823
  //#region src/utils/paperHtmlBuilder.ts
2834
- function zt(e) {
2824
+ function Bt(e) {
2835
2825
  let t = A[e];
2836
2826
  return `
2837
2827
  /* ---------- Reset & Base ---------- */
@@ -3152,7 +3142,7 @@ text.swed-question-score {
3152
3142
  }
3153
3143
  `;
3154
3144
  }
3155
- function Bt(e) {
3145
+ function Vt(e) {
3156
3146
  let { svgs: t, paperName: n = "试卷", paperSize: r = "A4" } = e, i = t.map((e) => {
3157
3147
  let t = e.match(/viewBox="0 0 (\d+(?:\.\d+)?)\s+(\d+(?:\.\d+)?)"/), [, n, r] = t ? [
3158
3148
  null,
@@ -3172,20 +3162,20 @@ function Bt(e) {
3172
3162
  <head>
3173
3163
  <meta charset="UTF-8">
3174
3164
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
3175
- <title>${Vt(n)}</title>
3176
- <style>${zt(r)}</style>
3165
+ <title>${Ht(n)}</title>
3166
+ <style>${Bt(r)}</style>
3177
3167
  </head>
3178
3168
  <body>
3179
3169
  ${i}
3180
3170
  </body>
3181
3171
  </html>`;
3182
3172
  }
3183
- function Vt(e) {
3173
+ function Ht(e) {
3184
3174
  return e.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
3185
3175
  }
3186
3176
  //#endregion
3187
3177
  //#region ../node_modules/qrcode/lib/can-promise.js
3188
- var Ht = /* @__PURE__ */ D(((e, t) => {
3178
+ var Ut = /* @__PURE__ */ D(((e, t) => {
3189
3179
  t.exports = function() {
3190
3180
  return typeof Promise == "function" && Promise.prototype && Promise.prototype.then;
3191
3181
  };
@@ -3251,7 +3241,7 @@ var Ht = /* @__PURE__ */ D(((e, t) => {
3251
3241
  }, e.toSJIS = function(e) {
3252
3242
  return t(e);
3253
3243
  };
3254
- })), Ut = /* @__PURE__ */ D(((e) => {
3244
+ })), Wt = /* @__PURE__ */ D(((e) => {
3255
3245
  e.L = { bit: 1 }, e.M = { bit: 0 }, e.Q = { bit: 3 }, e.H = { bit: 2 };
3256
3246
  function t(t) {
3257
3247
  if (typeof t != "string") throw Error("Param is not a string");
@@ -3277,7 +3267,7 @@ var Ht = /* @__PURE__ */ D(((e, t) => {
3277
3267
  return r;
3278
3268
  }
3279
3269
  };
3280
- })), Wt = /* @__PURE__ */ D(((e, t) => {
3270
+ })), Gt = /* @__PURE__ */ D(((e, t) => {
3281
3271
  function n() {
3282
3272
  this.buffer = [], this.length = 0;
3283
3273
  }
@@ -3297,7 +3287,7 @@ var Ht = /* @__PURE__ */ D(((e, t) => {
3297
3287
  this.buffer.length <= t && this.buffer.push(0), e && (this.buffer[t] |= 128 >>> this.length % 8), this.length++;
3298
3288
  }
3299
3289
  }, t.exports = n;
3300
- })), Gt = /* @__PURE__ */ D(((e, t) => {
3290
+ })), Kt = /* @__PURE__ */ D(((e, t) => {
3301
3291
  function n(e) {
3302
3292
  if (!e || e < 1) throw Error("BitMatrix size must be defined and greater than 0");
3303
3293
  this.size = e, this.data = new Uint8Array(e * e), this.reservedBit = new Uint8Array(e * e);
@@ -3312,7 +3302,7 @@ var Ht = /* @__PURE__ */ D(((e, t) => {
3312
3302
  }, n.prototype.isReserved = function(e, t) {
3313
3303
  return this.reservedBit[e * this.size + t];
3314
3304
  }, t.exports = n;
3315
- })), Kt = /* @__PURE__ */ D(((e) => {
3305
+ })), qt = /* @__PURE__ */ D(((e) => {
3316
3306
  var t = Y().getSymbolSize;
3317
3307
  e.getRowColCoords = function(e) {
3318
3308
  if (e === 1) return [];
@@ -3324,7 +3314,7 @@ var Ht = /* @__PURE__ */ D(((e, t) => {
3324
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]]);
3325
3315
  return n;
3326
3316
  };
3327
- })), qt = /* @__PURE__ */ D(((e) => {
3317
+ })), Jt = /* @__PURE__ */ D(((e) => {
3328
3318
  var t = Y().getSymbolSize, n = 7;
3329
3319
  e.getPositions = function(e) {
3330
3320
  let r = t(e);
@@ -3334,7 +3324,7 @@ var Ht = /* @__PURE__ */ D(((e, t) => {
3334
3324
  [0, r - n]
3335
3325
  ];
3336
3326
  };
3337
- })), Jt = /* @__PURE__ */ D(((e) => {
3327
+ })), Yt = /* @__PURE__ */ D(((e) => {
3338
3328
  e.Patterns = {
3339
3329
  PATTERN000: 0,
3340
3330
  PATTERN001: 1,
@@ -3410,8 +3400,8 @@ var Ht = /* @__PURE__ */ D(((e, t) => {
3410
3400
  }
3411
3401
  return i;
3412
3402
  };
3413
- })), Yt = /* @__PURE__ */ D(((e) => {
3414
- var t = Ut(), n = [
3403
+ })), Xt = /* @__PURE__ */ D(((e) => {
3404
+ var t = Wt(), n = [
3415
3405
  1,
3416
3406
  1,
3417
3407
  1,
@@ -3751,7 +3741,7 @@ var Ht = /* @__PURE__ */ D(((e, t) => {
3751
3741
  default: return;
3752
3742
  }
3753
3743
  };
3754
- })), Xt = /* @__PURE__ */ D(((e) => {
3744
+ })), Zt = /* @__PURE__ */ D(((e) => {
3755
3745
  var t = new Uint8Array(512), n = new Uint8Array(256);
3756
3746
  (function() {
3757
3747
  let e = 1;
@@ -3765,8 +3755,8 @@ var Ht = /* @__PURE__ */ D(((e, t) => {
3765
3755
  }, e.mul = function(e, r) {
3766
3756
  return e === 0 || r === 0 ? 0 : t[n[e] + n[r]];
3767
3757
  };
3768
- })), Zt = /* @__PURE__ */ D(((e) => {
3769
- var t = Xt();
3758
+ })), Qt = /* @__PURE__ */ D(((e) => {
3759
+ var t = Zt();
3770
3760
  e.mul = function(e, n) {
3771
3761
  let r = new Uint8Array(e.length + n.length - 1);
3772
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]);
@@ -3786,8 +3776,8 @@ var Ht = /* @__PURE__ */ D(((e, t) => {
3786
3776
  for (let i = 0; i < n; i++) r = e.mul(r, new Uint8Array([1, t.exp(i)]));
3787
3777
  return r;
3788
3778
  };
3789
- })), Qt = /* @__PURE__ */ D(((e, t) => {
3790
- var n = Zt();
3779
+ })), $t = /* @__PURE__ */ D(((e, t) => {
3780
+ var n = Qt();
3791
3781
  function r(e) {
3792
3782
  this.genPoly = void 0, this.degree = e, this.degree && this.initialize(this.degree);
3793
3783
  }
@@ -3804,11 +3794,11 @@ var Ht = /* @__PURE__ */ D(((e, t) => {
3804
3794
  }
3805
3795
  return r;
3806
3796
  }, t.exports = r;
3807
- })), $t = /* @__PURE__ */ D(((e) => {
3797
+ })), en = /* @__PURE__ */ D(((e) => {
3808
3798
  e.isValid = function(e) {
3809
3799
  return !isNaN(e) && e >= 1 && e <= 40;
3810
3800
  };
3811
- })), en = /* @__PURE__ */ D(((e) => {
3801
+ })), tn = /* @__PURE__ */ D(((e) => {
3812
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])+";
3813
3803
  r = r.replace(/u/g, "\\u");
3814
3804
  var i = "(?:(?![A-Z0-9 $%*+\\-./:]|" + r + ")(?:.|[\r\n]))+";
@@ -3822,7 +3812,7 @@ var Ht = /* @__PURE__ */ D(((e, t) => {
3822
3812
  return s.test(e);
3823
3813
  };
3824
3814
  })), X = /* @__PURE__ */ D(((e) => {
3825
- var t = $t(), n = en();
3815
+ var t = en(), n = tn();
3826
3816
  e.NUMERIC = {
3827
3817
  id: "Numeric",
3828
3818
  bit: 1,
@@ -3885,8 +3875,8 @@ var Ht = /* @__PURE__ */ D(((e, t) => {
3885
3875
  return n;
3886
3876
  }
3887
3877
  };
3888
- })), tn = /* @__PURE__ */ D(((e) => {
3889
- var t = Y(), n = Yt(), r = Ut(), i = X(), a = $t(), o = 7973, s = t.getBCHDigit(o);
3878
+ })), nn = /* @__PURE__ */ D(((e) => {
3879
+ var t = Y(), n = Xt(), r = Wt(), i = X(), a = en(), o = 7973, s = t.getBCHDigit(o);
3890
3880
  function c(t, n, r) {
3891
3881
  for (let i = 1; i <= 40; i++) if (n <= e.getCapacity(i, r, t)) return i;
3892
3882
  }
@@ -3932,14 +3922,14 @@ var Ht = /* @__PURE__ */ D(((e, t) => {
3932
3922
  for (; t.getBCHDigit(n) - s >= 0;) n ^= o << t.getBCHDigit(n) - s;
3933
3923
  return e << 12 | n;
3934
3924
  };
3935
- })), nn = /* @__PURE__ */ D(((e) => {
3925
+ })), rn = /* @__PURE__ */ D(((e) => {
3936
3926
  var t = Y(), n = 1335, r = 21522, i = t.getBCHDigit(n);
3937
3927
  e.getEncodedBits = function(e, a) {
3938
3928
  let o = e.bit << 3 | a, s = o << 10;
3939
3929
  for (; t.getBCHDigit(s) - i >= 0;) s ^= n << t.getBCHDigit(s) - i;
3940
3930
  return (o << 10 | s) ^ r;
3941
3931
  };
3942
- })), rn = /* @__PURE__ */ D(((e, t) => {
3932
+ })), an = /* @__PURE__ */ D(((e, t) => {
3943
3933
  var n = X();
3944
3934
  function r(e) {
3945
3935
  this.mode = n.NUMERIC, this.data = e.toString();
@@ -3956,7 +3946,7 @@ var Ht = /* @__PURE__ */ D(((e, t) => {
3956
3946
  let i = this.data.length - t;
3957
3947
  i > 0 && (n = this.data.substr(t), r = parseInt(n, 10), e.put(r, i * 3 + 1));
3958
3948
  }, t.exports = r;
3959
- })), an = /* @__PURE__ */ D(((e, t) => {
3949
+ })), on = /* @__PURE__ */ D(((e, t) => {
3960
3950
  var n = X(), r = /* @__PURE__ */ "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:".split("");
3961
3951
  function i(e) {
3962
3952
  this.mode = n.ALPHANUMERIC, this.data = e;
@@ -3975,7 +3965,7 @@ var Ht = /* @__PURE__ */ D(((e, t) => {
3975
3965
  }
3976
3966
  this.data.length % 2 && e.put(r.indexOf(this.data[t]), 6);
3977
3967
  }, t.exports = i;
3978
- })), on = /* @__PURE__ */ D(((e, t) => {
3968
+ })), sn = /* @__PURE__ */ D(((e, t) => {
3979
3969
  var n = X();
3980
3970
  function r(e) {
3981
3971
  this.mode = n.BYTE, typeof e == "string" ? this.data = new TextEncoder().encode(e) : this.data = new Uint8Array(e);
@@ -3989,7 +3979,7 @@ var Ht = /* @__PURE__ */ D(((e, t) => {
3989
3979
  }, r.prototype.write = function(e) {
3990
3980
  for (let t = 0, n = this.data.length; t < n; t++) e.put(this.data[t], 8);
3991
3981
  }, t.exports = r;
3992
- })), sn = /* @__PURE__ */ D(((e, t) => {
3982
+ })), cn = /* @__PURE__ */ D(((e, t) => {
3993
3983
  var n = X(), r = Y();
3994
3984
  function i(e) {
3995
3985
  this.mode = n.KANJI, this.data = e;
@@ -4010,7 +4000,7 @@ var Ht = /* @__PURE__ */ D(((e, t) => {
4010
4000
  n = (n >>> 8 & 255) * 192 + (n & 255), e.put(n, 13);
4011
4001
  }
4012
4002
  }, t.exports = i;
4013
- })), cn = /* @__PURE__ */ D(((e, t) => {
4003
+ })), ln = /* @__PURE__ */ D(((e, t) => {
4014
4004
  var n = {
4015
4005
  single_source_shortest_paths: function(e, t, r) {
4016
4006
  var i = {}, a = {};
@@ -4063,8 +4053,8 @@ var Ht = /* @__PURE__ */ D(((e, t) => {
4063
4053
  }
4064
4054
  };
4065
4055
  t !== void 0 && (t.exports = n);
4066
- })), ln = /* @__PURE__ */ D(((e) => {
4067
- var t = X(), n = rn(), r = an(), i = on(), a = sn(), o = en(), s = Y(), c = cn();
4056
+ })), un = /* @__PURE__ */ D(((e) => {
4057
+ var t = X(), n = an(), r = on(), i = sn(), a = cn(), o = tn(), s = Y(), c = ln();
4068
4058
  function l(e) {
4069
4059
  return unescape(encodeURIComponent(e)).length;
4070
4060
  }
@@ -4191,8 +4181,8 @@ var Ht = /* @__PURE__ */ D(((e, t) => {
4191
4181
  }, e.rawSplit = function(t) {
4192
4182
  return e.fromArray(d(t, s.isKanjiModeEnabled()));
4193
4183
  };
4194
- })), un = /* @__PURE__ */ D(((e) => {
4195
- var t = Y(), n = Ut(), r = Wt(), i = Gt(), a = Kt(), o = qt(), s = Jt(), c = Yt(), l = Qt(), u = tn(), d = nn(), f = X(), p = ln();
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();
4196
4186
  function m(e, t) {
4197
4187
  let n = e.size, r = o.getPositions(t);
4198
4188
  for (let t = 0; t < r.length; t++) {
@@ -4287,7 +4277,7 @@ var Ht = /* @__PURE__ */ D(((e, t) => {
4287
4277
  let i = n.M, a, o;
4288
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);
4289
4279
  };
4290
- })), dn = /* @__PURE__ */ D(((e) => {
4280
+ })), fn = /* @__PURE__ */ D(((e) => {
4291
4281
  function t(e) {
4292
4282
  if (typeof e == "number" && (e = e.toString()), typeof e != "string") throw Error("Color should be defined as hex string");
4293
4283
  let t = e.slice().replace("#", "").split("");
@@ -4334,8 +4324,8 @@ var Ht = /* @__PURE__ */ D(((e, t) => {
4334
4324
  t[u++] = d.r, t[u++] = d.g, t[u++] = d.b, t[u] = d.a;
4335
4325
  }
4336
4326
  };
4337
- })), fn = /* @__PURE__ */ D(((e) => {
4338
- var t = dn();
4327
+ })), pn = /* @__PURE__ */ D(((e) => {
4328
+ var t = fn();
4339
4329
  function n(e, t, n) {
4340
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";
4341
4331
  }
@@ -4357,8 +4347,8 @@ var Ht = /* @__PURE__ */ D(((e, t) => {
4357
4347
  let a = e.render(t, n, i), o = i.type || "image/png", s = i.rendererOpts || {};
4358
4348
  return a.toDataURL(o, s.quality);
4359
4349
  };
4360
- })), pn = /* @__PURE__ */ D(((e) => {
4361
- var t = dn();
4350
+ })), mn = /* @__PURE__ */ D(((e) => {
4351
+ var t = fn();
4362
4352
  function n(e, t) {
4363
4353
  let n = e.a / 255, r = t + "=\"" + e.hex + "\"";
4364
4354
  return n < 1 ? r + " " + t + "-opacity=\"" + n.toFixed(2).slice(1) + "\"" : r;
@@ -4379,8 +4369,8 @@ var Ht = /* @__PURE__ */ D(((e, t) => {
4379
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";
4380
4370
  return typeof a == "function" && a(null, p), p;
4381
4371
  };
4382
- })), mn = /* @__PURE__ */ O((/* @__PURE__ */ D(((e) => {
4383
- var t = Ht(), n = un(), r = fn(), i = pn();
4372
+ })), hn = /* @__PURE__ */ O((/* @__PURE__ */ D(((e) => {
4373
+ var t = Ut(), n = dn(), r = pn(), i = mn();
4384
4374
  function a(e, r, i, a, o) {
4385
4375
  let s = [].slice.call(arguments, 1), c = s.length, l = typeof s[c - 1] == "function";
4386
4376
  if (!l && !t()) throw Error("Callback required as last argument");
@@ -4408,10 +4398,10 @@ var Ht = /* @__PURE__ */ D(((e, t) => {
4408
4398
  return i.render(e, n);
4409
4399
  });
4410
4400
  })))(), 1);
4411
- async function hn(e, t = 200) {
4401
+ async function gn(e, t = 200) {
4412
4402
  if (!e || e.trim() === "") return "";
4413
4403
  try {
4414
- return await mn.toDataURL(e, {
4404
+ return await hn.toDataURL(e, {
4415
4405
  width: t,
4416
4406
  margin: 1,
4417
4407
  color: {
@@ -4426,7 +4416,7 @@ async function hn(e, t = 200) {
4426
4416
  }
4427
4417
  //#endregion
4428
4418
  //#region src/composables/usePaperSelection.ts
4429
- function gn(e) {
4419
+ function _n(e) {
4430
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);
4431
4421
  function c(e) {
4432
4422
  n.value = e, e && (r.value = null);
@@ -4491,7 +4481,7 @@ function gn(e) {
4491
4481
  }
4492
4482
  //#endregion
4493
4483
  //#region src/composables/paperHelpers.ts
4494
- var _n = {
4484
+ var vn = {
4495
4485
  三号: 21,
4496
4486
  小三: 20,
4497
4487
  四号: 19,
@@ -4499,24 +4489,24 @@ var _n = {
4499
4489
  五号: 14,
4500
4490
  小五: 12
4501
4491
  };
4502
- function vn(e) {
4503
- return _n[e] ?? 14;
4504
- }
4505
4492
  function yn(e) {
4506
- for (let [t, n] of Object.entries(_n)) if (n === e) return t;
4493
+ return vn[e] ?? 14;
4494
+ }
4495
+ function bn(e) {
4496
+ for (let [t, n] of Object.entries(vn)) if (n === e) return t;
4507
4497
  return "五号";
4508
4498
  }
4509
4499
  function Z(e) {
4510
- return typeof e.fontSize == "number" ? e.fontSize : vn(e.fontSize || "五号");
4500
+ return typeof e.fontSize == "number" ? e.fontSize : yn(e.fontSize || "五号");
4511
4501
  }
4512
4502
  function Q(e) {
4513
4503
  return e.lineSpacing ?? 1.5;
4514
4504
  }
4515
- function bn(e, t) {
4505
+ function xn(e, t) {
4516
4506
  return Math.round(e * t * 35 / (14 * 1.5));
4517
4507
  }
4518
4508
  function $(e, t) {
4519
- let n = bn(e, t);
4509
+ let n = xn(e, t);
4520
4510
  return {
4521
4511
  lines: [{
4522
4512
  elements: [{
@@ -4532,15 +4522,15 @@ function $(e, t) {
4532
4522
  height: n
4533
4523
  };
4534
4524
  }
4535
- function xn(e, t, n, r, i = 0) {
4536
- let a = bn(t, n), o = r && r > 0 ? it(e, r, a, i) : [rt(e, 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)];
4537
4527
  return {
4538
4528
  lines: o,
4539
4529
  y: 0,
4540
4530
  height: o.reduce((e, t) => e + t.lineHeight, 0) + 4
4541
4531
  };
4542
4532
  }
4543
- function Sn(e) {
4533
+ function Cn(e) {
4544
4534
  let t = e.paragraphs.length;
4545
4535
  for (; t > 0;) {
4546
4536
  let n = e.paragraphs[t - 1];
@@ -4549,14 +4539,14 @@ function Sn(e) {
4549
4539
  }
4550
4540
  return t;
4551
4541
  }
4552
- var Cn = 0, wn = 0;
4553
- function Tn(e) {
4542
+ var wn = 0, Tn = 0;
4543
+ function En(e) {
4554
4544
  return e.type === "question" ? (e.metadata?.questionNo || "").length > 2 ? 26.25 : 17.5 : e.type === "sub-question" ? 26.25 : 0;
4555
4545
  }
4556
- function En(e, t) {
4557
- return t - Tn(e);
4546
+ function Dn(e, t) {
4547
+ return t - En(e);
4558
4548
  }
4559
- function Dn(e) {
4549
+ function On(e) {
4560
4550
  let t = [], n = 0;
4561
4551
  for (; n < e.length;) {
4562
4552
  if (e[n] === "\\" && e.substring(n, n + 2) === "\\(") {
@@ -4587,9 +4577,9 @@ function Dn(e) {
4587
4577
  }
4588
4578
  return t;
4589
4579
  }
4590
- function On(e, t) {
4591
- let n = [], r = Dn(e);
4592
- for (let e of r) if (e.type === "text") n.push(kn(e.value, t, !1, "\"Times New Roman\", SimSun,'Cambria Math'", "#000"));
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"));
4593
4583
  else if (e.type === "formula") {
4594
4584
  let { svg: t, width: r, height: i } = G(e.value);
4595
4585
  n.push({
@@ -4601,7 +4591,7 @@ function On(e, t) {
4601
4591
  });
4602
4592
  } else e.type === "blank" && n.push({
4603
4593
  type: "underline",
4604
- id: `ul-${++wn}`,
4594
+ id: `ul-${++Tn}`,
4605
4595
  width: 80,
4606
4596
  height: 20,
4607
4597
  placeholder: "空",
@@ -4610,7 +4600,7 @@ function On(e, t) {
4610
4600
  });
4611
4601
  return n;
4612
4602
  }
4613
- function kn(e, t, n, r, i) {
4603
+ function An(e, t, n, r, i) {
4614
4604
  let a = e.split(""), o = B(e, t, r);
4615
4605
  return {
4616
4606
  type: "text",
@@ -4625,14 +4615,14 @@ function kn(e, t, n, r, i) {
4625
4615
  xPositions: o
4626
4616
  };
4627
4617
  }
4628
- function An(e, t, n, r, i, a, o = !1) {
4618
+ function jn(e, t, n, r, i, a, o = !1) {
4629
4619
  let s = [];
4630
4620
  for (let e = 0; e < n.length; e++) {
4631
- let t = On(n[e], r);
4632
- s.push(xn(t, r, i, a && a > 0 ? a : void 0));
4621
+ let t = kn(n[e], r);
4622
+ s.push(Sn(t, r, i, a && a > 0 ? a : void 0));
4633
4623
  }
4634
4624
  for (let e = 0; e < 2; e++) s.push($(r, i));
4635
- let c = s.reduce((e, t) => e + (t.height || 26), 0), l = `topic-${e.replace(".", "")}-${++Cn}`;
4625
+ let c = s.reduce((e, t) => e + (t.height || 26), 0), l = `topic-${e.replace(".", "")}-${++wn}`;
4636
4626
  return {
4637
4627
  id: `q-${e.replace(".", "")}-${Date.now()}-${Math.random().toString(36).slice(2, 6)}`,
4638
4628
  type: "question",
@@ -4648,10 +4638,10 @@ function An(e, t, n, r, i, a, o = !1) {
4648
4638
  }
4649
4639
  };
4650
4640
  }
4651
- function jn(e, t, n, r, i, a, o = !1) {
4641
+ function Mn(e, t, n, r, i, a, o = !1) {
4652
4642
  let s = [], c = `group-${e.replace(".", "")}`, l = [], u = 0, d = (n, u) => {
4653
4643
  if (l.length === 0) return;
4654
- let d = l.map((e) => xn(On(e, r), r, i, a && a > 0 ? a : void 0));
4644
+ let d = l.map((e) => Sn(kn(e, r), r, i, a && a > 0 ? a : void 0));
4655
4645
  if (!n) for (let e = 0; e < 2; e++) d.push($(r, i));
4656
4646
  let f = d.reduce((e, t) => e + (t.height || 26), 0), p = `${c}-${n ? "header" : `sub${u}`}`;
4657
4647
  s.push({
@@ -4677,7 +4667,7 @@ function jn(e, t, n, r, i, a, o = !1) {
4677
4667
  }
4678
4668
  return d(s.length === 0, u), s;
4679
4669
  }
4680
- function Mn(e) {
4670
+ function Nn(e) {
4681
4671
  let t = [];
4682
4672
  for (let n of e.paragraphs) {
4683
4673
  if (n.lines.length > 0 && n.lines.every((e) => e.elements.length > 0 && e.elements.every((e) => e.type === "enter"))) continue;
@@ -4691,18 +4681,18 @@ function Mn(e) {
4691
4681
  }
4692
4682
  return t.join("\n");
4693
4683
  }
4694
- function Nn(e) {
4684
+ function Pn(e) {
4695
4685
  return e.metadata?.questionNo ? `第${e.metadata.questionNo.replace(".", "")}题` : e.metadata?.subLabel ? e.metadata.subLabel : e.metadata?.label || e.id;
4696
4686
  }
4697
4687
  //#endregion
4698
4688
  //#region src/composables/usePaperBlockOps.ts
4699
- function Pn(e) {
4689
+ function Fn(e) {
4700
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;
4701
4691
  function g() {
4702
4692
  let e = Z(n.value), r = Q(n.value), s = a.value.columnWidth;
4703
4693
  s <= 0 || (t.value = t.value.map((t) => {
4704
4694
  if (!t.paragraphs || t.paragraphs.length === 0) return t;
4705
- let n = En(t, s), i = [], a = !1;
4695
+ let n = Dn(t, s), i = [], a = !1;
4706
4696
  for (let o = 0; o < t.paragraphs.length; o++) {
4707
4697
  let s = t.paragraphs[o];
4708
4698
  if (s.lines.length > 0 && s.lines.every((e) => e.elements.length > 0 && e.elements.every((e) => e.type === "enter"))) {
@@ -4713,7 +4703,7 @@ function Pn(e) {
4713
4703
  for (let e of s.lines) for (let t of e.elements) if (t.type === "text") {
4714
4704
  let e = t, n = e.value.split("");
4715
4705
  for (let t = 0; t < n.length; t++) {
4716
- let r = Fn(n[t], e.fontSize, e.fontFamily, e.bold, e.italic);
4706
+ let r = In(n[t], e.fontSize, e.fontFamily, e.bold, e.italic);
4717
4707
  c.push({
4718
4708
  ...e,
4719
4709
  value: n[t],
@@ -4735,20 +4725,20 @@ function Pn(e) {
4735
4725
  } else c.push(t);
4736
4726
  } else c.push(t);
4737
4727
  let l;
4738
- if (a) l = xn(c, e, r, n > 0 ? n : void 0, 0);
4728
+ if (a) l = Sn(c, e, r, n > 0 ? n : void 0, 0);
4739
4729
  else {
4740
4730
  let i = t.metadata?.score || "", o = i ? se(`(${i}分)`, e, "SimSun, STSong, serif") : 0;
4741
- l = xn(c, e, r, n > 0 ? n : void 0, o), a = !0;
4731
+ l = Sn(c, e, r, n > 0 ? n : void 0, o), a = !0;
4742
4732
  }
4743
4733
  t.paragraphs[o].justification && (l.justification = t.paragraphs[o].justification), i.push(l);
4744
4734
  }
4745
4735
  let c = 0;
4746
- t.options && t.options.length > 0 && (c = o.value.getOptionsHeight(t.options, En(t, s)));
4736
+ t.options && t.options.length > 0 && (c = o.value.getOptionsHeight(t.options, Dn(t, s)));
4747
4737
  let l = t.metadata?.customHeight;
4748
4738
  if (l) {
4749
4739
  let t = i.reduce((e, t) => e + (t.height || 26), 0) + c;
4750
4740
  if (l > t) {
4751
- let n = l - t, a = bn(e, r) + 4, o = Math.round(n / a);
4741
+ let n = l - t, a = xn(e, r) + 4, o = Math.round(n / a);
4752
4742
  for (let t = 0; t < o; t++) i.push($(e, r));
4753
4743
  }
4754
4744
  }
@@ -4806,7 +4796,7 @@ function Pn(e) {
4806
4796
  function S(e, r) {
4807
4797
  let a = t.value.findIndex((t) => t.id === e);
4808
4798
  if (a === -1) return;
4809
- let o = t.value[a], s = Z(n.value), c = Q(n.value), l = Math.max(0, o.paragraphs.length - Sn(o)), u = [...r];
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];
4810
4800
  for (let e = 0; e < l; e++) u.push($(s, c));
4811
4801
  let d = u.reduce((e, t) => e + (t.height || 26), 0);
4812
4802
  t.value = t.value.map((e, t) => t === a ? {
@@ -4854,9 +4844,9 @@ function Pn(e) {
4854
4844
  function D(e, r) {
4855
4845
  let s = t.value.findIndex((t) => t.id === e);
4856
4846
  if (s === -1) return;
4857
- let c = t.value[s], l = Z(n.value), u = Q(n.value), d = bn(l, u) + 4, f = 0;
4858
- c.options && c.options.length > 0 && (f = o.value.getOptionsHeight(c.options, En(c, a.value.columnWidth)));
4859
- let p = Sn(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 = [];
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 = [];
4860
4850
  for (let e = 0; e < v; e++) y.push($(l, u));
4861
4851
  let b = [...m, ...y], x = b.reduce((e, t) => e + (t.height || 26), 0);
4862
4852
  t.value = t.value.map((e, t) => t === s ? {
@@ -4919,29 +4909,38 @@ function Pn(e) {
4919
4909
  } : e), i.value = !0;
4920
4910
  }
4921
4911
  function j(e) {
4922
- let n = new Map(e.map((e) => [e.id, e.metadata]));
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();
4923
4918
  t.value = t.value.map((e) => {
4924
4919
  let t = n.get(e.id);
4925
- return t ? {
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 {
4926
4925
  ...e,
4927
4926
  metadata: {
4928
4927
  ...e.metadata,
4929
- ...t
4928
+ ...a
4930
4929
  }
4931
- } : e;
4930
+ };
4932
4931
  }), i.value = !0;
4933
4932
  }
4934
4933
  function M() {
4935
4934
  let e = 0, n = 0, r = [];
4936
4935
  for (let i of t.value) if (i.type === "title") {
4937
4936
  e++;
4938
- let t = i.metadata?.title || Rt(i.metadata?.label || "") || "题组";
4937
+ let t = i.metadata?.title || zt(i.metadata?.label || "") || "题组";
4939
4938
  r.push({
4940
4939
  id: i.id,
4941
4940
  metadata: {
4942
4941
  title: t,
4943
4942
  ordinal: e,
4944
- label: Lt(t, e)
4943
+ label: Rt(t, e)
4945
4944
  }
4946
4945
  });
4947
4946
  } else if (i.type === "question") {
@@ -4964,16 +4963,16 @@ function Pn(e) {
4964
4963
  let o = e.content.split("\n").filter((e) => e.trim());
4965
4964
  o.length === 0 && o.push("");
4966
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;
4967
- if (c) p = jn(e.no, s, o, l, u, d - 26.25, r);
4966
+ if (c) p = Mn(e.no, s, o, l, u, d - 26.25, r);
4968
4967
  else {
4969
4968
  let t = e.no.length > 2 ? 26.25 : 17.5;
4970
- p = [An(e.no, s, o, l, u, d - t, r)];
4969
+ p = [jn(e.no, s, o, l, u, d - t, r)];
4971
4970
  }
4972
4971
  for (let e of p) t.value = [...t.value, e];
4973
4972
  p.length > 0 && (f.value = p[p.length - 1].id), M(), i.value = !0, g();
4974
4973
  }
4975
4974
  function F(e, r, o, s = !1) {
4976
- let c = Z(n.value), l = Q(n.value), u = a.value.columnWidth, d = (r?.length || 0) > 2 ? 26.25 : 17.5, p = xt(e, {
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, {
4977
4976
  questionNo: r || "",
4978
4977
  score: o || "",
4979
4978
  contentWidth: u - d,
@@ -4991,7 +4990,7 @@ function Pn(e) {
4991
4990
  } catch {
4992
4991
  throw Error("JSON 格式错误,请检查");
4993
4992
  }
4994
- let m = Mt(p, {
4993
+ let m = Nt(p, {
4995
4994
  questionNo: r || "",
4996
4995
  score: o || "",
4997
4996
  contentWidth: u - d,
@@ -5005,7 +5004,7 @@ function Pn(e) {
5005
5004
  function ne(e, t, n) {
5006
5005
  let r = p(e);
5007
5006
  if (!r) return;
5008
- let o = En(r.block, a.value.columnWidth), s = Math.max(20, Math.min(Math.round(t), Math.max(20, o)));
5007
+ let o = Dn(r.block, a.value.columnWidth), s = Math.max(20, Math.min(Math.round(t), Math.max(20, o)));
5009
5008
  r.image.width = s, n !== void 0 && (r.image.height = Math.max(12, Math.round(n))), i.value = !0, g();
5010
5009
  }
5011
5010
  function I(e) {
@@ -5029,10 +5028,10 @@ function Pn(e) {
5029
5028
  }
5030
5029
  function ie(e, t, r, i) {
5031
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());
5032
- return l.length === 0 && l.push(""), l.map((e) => xn(On(e, o), o, s, c > 0 ? c : void 0));
5031
+ return l.length === 0 && l.push(""), l.map((e) => Sn(kn(e, o), o, s, c > 0 ? c : void 0));
5033
5032
  }
5034
5033
  function ae() {
5035
- return ht(t.value, n.value, {
5034
+ return gt(t.value, n.value, {
5036
5035
  paperName: s.value,
5037
5036
  schoolName: c.value,
5038
5037
  qrCodeContent: l.value,
@@ -5043,8 +5042,8 @@ function Pn(e) {
5043
5042
  });
5044
5043
  }
5045
5044
  function R(e, r) {
5046
- let o = gt(e);
5047
- t.value = o.blocks, o.settings && typeof o.settings.fontSize == "string" && (o.settings.fontSize = vn(o.settings.fontSize)), n.value = {
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 = {
5048
5047
  ...n.value,
5049
5048
  ...o.settings
5050
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;
@@ -5079,15 +5078,15 @@ function Pn(e) {
5079
5078
  parseTextToParagraphs: ie,
5080
5079
  saveDocument: ae,
5081
5080
  loadDocument: R,
5082
- getBlockPlainText: Mn,
5083
- getBlockLabel: Nn,
5084
- getBlockAvailableWidth: En
5081
+ getBlockPlainText: Nn,
5082
+ getBlockLabel: Pn,
5083
+ getBlockAvailableWidth: Dn
5085
5084
  };
5086
5085
  }
5087
- var Fn = z;
5086
+ var In = z;
5088
5087
  //#endregion
5089
5088
  //#region src/composables/usePaperCore.ts
5090
- function In(e = {}) {
5089
+ function Ln(e = {}) {
5091
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(() => {
5092
5091
  let e = 0, t = /* @__PURE__ */ new Set();
5093
5092
  for (let n of a.value) {
@@ -5102,7 +5101,7 @@ function In(e = {}) {
5102
5101
  a && (e += parseInt(a[1]));
5103
5102
  }
5104
5103
  return e;
5105
- }), _ = gn(a), y = Pn({
5104
+ }), _ = _n(a), y = Fn({
5106
5105
  blocks: a,
5107
5106
  settings: s,
5108
5107
  pages: o,
@@ -5124,7 +5123,7 @@ function In(e = {}) {
5124
5123
  d.value = "";
5125
5124
  return;
5126
5125
  }
5127
- d.value = await hn(e);
5126
+ d.value = await gn(e);
5128
5127
  }, { immediate: !0 });
5129
5128
  function b(e) {
5130
5129
  n.value = e, i.value.setRenderMode(e);
@@ -5223,8 +5222,8 @@ function In(e = {}) {
5223
5222
  }
5224
5223
  //#endregion
5225
5224
  //#region src/composables/usePageSvgRenderer.ts
5226
- var Ln = "<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>";
5227
- function Rn(e, n = {}) {
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 = {}) {
5228
5227
  return t(() => {
5229
5228
  e.renderMode.value;
5230
5229
  let t = e.pages.value;
@@ -5239,13 +5238,13 @@ function Rn(e, n = {}) {
5239
5238
  schoolName: e.schoolName.value,
5240
5239
  qrCodeImage: e.qrCodeImage.value
5241
5240
  }, t.length);
5242
- return `<svg xmlns="http://www.w3.org/2000/svg" width="${r * o}" height="${i * o}" viewBox="0 0 ${r} ${i}" class="paper-page">\n${Ln}\n${l}</svg>`;
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>`;
5243
5242
  });
5244
5243
  });
5245
5244
  }
5246
5245
  //#endregion
5247
5246
  //#region src/composables/useTableRenderer.ts
5248
- async function zn(e, t, n = 2) {
5247
+ async function Bn(e, t, n = 2) {
5249
5248
  let r = [];
5250
5249
  for (let t = 0; t < e.length; t++) {
5251
5250
  let n = e[t];
@@ -5272,7 +5271,7 @@ async function zn(e, t, n = 2) {
5272
5271
  if (r.length !== 0) for (let i = 0; i < r.length; i++) {
5273
5272
  let a = r[i];
5274
5273
  try {
5275
- let r = await Bn(a.rawHtml, t, n);
5274
+ let r = await Vn(a.rawHtml, t, n);
5276
5275
  if (r) {
5277
5276
  let t = e[a.blockIdx].paragraphs[a.paraIdx].lines[a.lineIdx].elements[a.elemIdx];
5278
5277
  t.src = r, delete t.rawHtml;
@@ -5282,7 +5281,7 @@ async function zn(e, t, n = 2) {
5282
5281
  }
5283
5282
  }
5284
5283
  }
5285
- async function Bn(e, t, n) {
5284
+ async function Vn(e, t, n) {
5286
5285
  let r = document.createElement("div");
5287
5286
  r.innerHTML = e, r.style.position = "absolute", r.style.left = "-9999px", r.style.top = "0", r.style.width = "auto", r.style.height = "auto";
5288
5287
  let i = document.createElement("style");
@@ -5303,7 +5302,7 @@ async function Bn(e, t, n) {
5303
5302
  document.body.removeChild(r);
5304
5303
  }
5305
5304
  }
5306
- function Vn(e) {
5305
+ function Hn(e) {
5307
5306
  for (let t of e) if (t.paragraphs) {
5308
5307
  for (let e of t.paragraphs) if (e.lines) {
5309
5308
  for (let t of e.lines) if (t.elements) {
@@ -5318,7 +5317,7 @@ function Vn(e) {
5318
5317
  }
5319
5318
  //#endregion
5320
5319
  //#region src/composables/usePaperCursor.ts
5321
- function Hn(e, t, n, r) {
5320
+ function Un(e, t, n, r) {
5322
5321
  let i = f({
5323
5322
  blockId: null,
5324
5323
  paraIndex: 0,
@@ -5386,7 +5385,7 @@ function Hn(e, t, n, r) {
5386
5385
  }];
5387
5386
  }
5388
5387
  function p(e) {
5389
- let n = Z(t.value), r = Q(t.value), i = bn(n, r);
5388
+ let n = Z(t.value), r = Q(t.value), i = xn(n, r);
5390
5389
  return e.length === 0 || e.length === 1 && e[0].type === "enter" ? $(n, r) : {
5391
5390
  lines: [{
5392
5391
  elements: e,
@@ -5788,7 +5787,7 @@ function Hn(e, t, n, r) {
5788
5787
  }
5789
5788
  //#endregion
5790
5789
  //#region src/components/PaperEditor.vue?vue&type=script&setup=true&lang.ts
5791
- var Un = { class: "pe-root" }, Wn = { class: "pe-main" }, Gn = { class: "pe-editor" }, Kn = { class: "pe-editor-pages" }, qn = ["onClick"], Jn = ["innerHTML"], Yn = { class: "pe-editor-controllers" }, Xn = /*@__PURE__*/ a({
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({
5792
5791
  __name: "PaperEditor",
5793
5792
  props: {
5794
5793
  initialData: {},
@@ -5809,7 +5808,7 @@ var Un = { class: "pe-root" }, Wn = { class: "pe-main" }, Gn = { class: "pe-edit
5809
5808
  "loaded"
5810
5809
  ],
5811
5810
  setup(a, { expose: m, emit: h }) {
5812
- let x = a, S = h, C = In({ renderMode: x.renderMode }), w = Hn(C.blocks, C.settings, () => {
5811
+ let x = a, S = h, C = Ln({ renderMode: x.renderMode }), w = Un(C.blocks, C.settings, () => {
5813
5812
  C.reflowAllBlocks(), o(() => O.value?.focus());
5814
5813
  }, () => {
5815
5814
  C.isDirty.value = !0;
@@ -5828,7 +5827,7 @@ var Un = { class: "pe-root" }, Wn = { class: "pe-main" }, Gn = { class: "pe-edit
5828
5827
  top: A.value.top + "px",
5829
5828
  height: A.value.height + "px",
5830
5829
  transform: "skewX(0deg)"
5831
- })), N = Rn(C, {
5830
+ })), N = zn(C, {
5832
5831
  zoom: T,
5833
5832
  selectedBlockId: null
5834
5833
  });
@@ -6497,7 +6496,7 @@ var Un = { class: "pe-root" }, Wn = { class: "pe-main" }, Gn = { class: "pe-edit
6497
6496
  qrCodeImage: C.qrCodeImage.value,
6498
6497
  showScore: C.settings.value.showScore
6499
6498
  }))
6500
- }), (t, a) => (d(), r("div", Un, [i("div", Wn, [i("div", Gn, [i("div", {
6499
+ }), (t, a) => (d(), r("div", Wn, [i("div", Gn, [i("div", Kn, [i("div", {
6501
6500
  class: "pe-editor-surface",
6502
6501
  ref_key: "saberEditorRef",
6503
6502
  ref: ee
@@ -6506,7 +6505,7 @@ var Un = { class: "pe-root" }, Wn = { class: "pe-main" }, Gn = { class: "pe-edit
6506
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",
6507
6506
  fill: "currentColor"
6508
6507
  })])])], -1),
6509
- i("div", Kn, [(d(!0), r(e, null, p(g(N), (e, t) => (d(), r("div", {
6508
+ i("div", qn, [(d(!0), r(e, null, p(g(N), (e, t) => (d(), r("div", {
6510
6509
  key: t,
6511
6510
  class: s(["pe-editor-page", { active: t === E.value }]),
6512
6511
  onClick: b((e) => E.value = t, ["stop"])
@@ -6515,8 +6514,8 @@ var Un = { class: "pe-root" }, Wn = { class: "pe-main" }, Gn = { class: "pe-edit
6515
6514
  innerHTML: e,
6516
6515
  onClick: ie,
6517
6516
  onFocusout: ae
6518
- }, null, 40, Jn)], 10, qn))), 128))]),
6519
- i("div", Yn, [
6517
+ }, null, 40, Yn)], 10, Jn))), 128))]),
6518
+ i("div", Xn, [
6520
6519
  R.value ? (d(), r("div", {
6521
6520
  key: 0,
6522
6521
  class: "pe-ctrl-block",
@@ -6623,17 +6622,17 @@ var Un = { class: "pe-root" }, Wn = { class: "pe-main" }, Gn = { class: "pe-edit
6623
6622
  }, null, 4), [[_, D.value]])
6624
6623
  ], 512)])])]));
6625
6624
  }
6626
- }), Zn = (e, t) => {
6625
+ }), Qn = (e, t) => {
6627
6626
  let n = e.__vccOpts || e;
6628
6627
  for (let [e, r] of t) n[e] = r;
6629
6628
  return n;
6630
- }, Qn = /*#__PURE__*/ Zn(Xn, [["__scopeId", "data-v-62a78c32"]]), $n = { class: "pe-preview__pages" }, er = ["innerHTML"], tr = {
6629
+ }, $n = /*#__PURE__*/ Qn(Zn, [["__scopeId", "data-v-62a78c32"]]), er = { class: "pe-preview__pages" }, tr = ["innerHTML"], nr = {
6631
6630
  key: 0,
6632
6631
  class: "pe-preview__helpers"
6633
- }, nr = {
6632
+ }, rr = {
6634
6633
  key: 1,
6635
6634
  class: "pe-preview__page-num"
6636
- }, rr = /*#__PURE__*/ Zn(/* @__PURE__ */ a({
6635
+ }, ir = /*#__PURE__*/ Qn(/* @__PURE__ */ a({
6637
6636
  __name: "PaperPreview",
6638
6637
  props: {
6639
6638
  document: {},
@@ -6660,14 +6659,14 @@ var Un = { class: "pe-root" }, Wn = { class: "pe-main" }, Gn = { class: "pe-edit
6660
6659
  }
6661
6660
  },
6662
6661
  setup(a) {
6663
- let o = a, m = In();
6662
+ let o = a, m = Ln();
6664
6663
  function _() {
6665
6664
  o.document && m.loadDocument(o.document);
6666
6665
  }
6667
6666
  _(), v(() => o.document, _), v(() => o.pureMode, (e) => {
6668
6667
  m.setRenderMode(e ? "view" : "edit");
6669
6668
  }, { immediate: !0 });
6670
- let y = Rn(m, { selectedBlockId: null }), b = f(), x = f(0), S = null;
6669
+ let y = zn(m, { selectedBlockId: null }), b = f(), x = f(0), S = null;
6671
6670
  l(() => {
6672
6671
  x.value = b.value?.clientWidth ?? 0, S = new ResizeObserver((e) => {
6673
6672
  for (let t of e) x.value = Math.floor(t.contentRect.width);
@@ -6833,7 +6832,7 @@ var Un = { class: "pe-root" }, Wn = { class: "pe-main" }, Gn = { class: "pe-edit
6833
6832
  class: s(["pe-preview", { "pe-preview--print": a.mode === "print" }]),
6834
6833
  ref_key: "previewRef",
6835
6834
  ref: b
6836
- }, [i("div", $n, [(d(!0), r(e, null, p(g(y), (t, o) => (d(), r("div", {
6835
+ }, [i("div", er, [(d(!0), r(e, null, p(g(y), (t, o) => (d(), r("div", {
6837
6836
  key: o,
6838
6837
  class: "pe-preview__page",
6839
6838
  style: c(O(o))
@@ -6847,8 +6846,8 @@ var Un = { class: "pe-root" }, Wn = { class: "pe-main" }, Gn = { class: "pe-edit
6847
6846
  width: "100%",
6848
6847
  height: "100%"
6849
6848
  }
6850
- }, null, 8, er)], 4),
6851
- a.showHelpers ? (d(), r("div", tr, [a.showCornerMarks ? (d(!0), r(e, { key: 0 }, p(D(o), (e, t) => (d(), r("span", {
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", {
6852
6851
  key: "cm-" + t,
6853
6852
  class: s(["pe-preview__helper-box", e.className]),
6854
6853
  style: c(M(e))
@@ -6857,9 +6856,9 @@ var Un = { class: "pe-root" }, Wn = { class: "pe-main" }, Gn = { class: "pe-edit
6857
6856
  class: s(["pe-preview__helper-box", e.className]),
6858
6857
  style: c(M(e))
6859
6858
  }, null, 6))), 128)) : n("", !0)])) : n("", !0),
6860
- a.showPageNumbers ? (d(), r("div", nr, h(o + 1) + " / " + h(g(m).pages.value.length), 1)) : n("", !0)
6859
+ a.showPageNumbers ? (d(), r("div", rr, h(o + 1) + " / " + h(g(m).pages.value.length), 1)) : n("", !0)
6861
6860
  ], 4))), 128))])], 2));
6862
6861
  }
6863
6862
  }), [["__scopeId", "data-v-1b638e19"]]);
6864
6863
  //#endregion
6865
- export { _n as FONT_SIZE_MAP, k as PAPER_DIMENSIONS, A as PAPER_MM, Qn as PaperEditor, te as PaperLayout, rr as PaperPreview, Ce as SvgRenderer, Bt as buildPaperHtml, B as calcCharPositions, se as calcTextWidth, De as clearFormulaCache, le as clearWidthCache, gt as deserializeDocument, Rt as extractBaseTitle, vn as fontSizeLabelToPx, yn as fontSizePxToLabel, Lt as formatSectionTitle, z as getCharWidth, M as getPaperPreset, Vn as hasTablePlaceholder, G as latexToSvg, Me as latexToSvgBatch, xt as parseQuestionHtml, Mt as parseQuestionJson, zn as renderTablePlaceholders, ht as serializeDocument, P as toBBox, It as toChineseOrdinal, Rn as usePageSvgRenderer, In as usePaperCore };
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 };
@@ -42,8 +42,11 @@ export declare class PaperLayout {
42
42
  */
43
43
  measureBlock(block: ContentBlock): number;
44
44
  /**
45
- * 测量选项区域总高度(autoLayout 自动换行)
46
- * 与 SvgRenderer.calcOptionsHeight 使用相同的动态间距算法,确保布局预留高度 = 实际渲染高度
45
+ * 测量选项区域总高度
46
+ *
47
+ * 与 calcOptionsHeight 使用相同的布局策略,确保布局预留高度 = 实际渲染高度:
48
+ * - 一行等分排列 → 返回最高选项高度
49
+ * - 每个选项单独一行 → 返回高度之和
47
50
  */
48
51
  private measureOptionsHeight;
49
52
  measureParagraph(p: {
@@ -7,10 +7,10 @@ import type { OptionItem, RenderMode } from '../../types/paper';
7
7
  /**
8
8
  * 渲染选择题选项区域 (g.option)
9
9
  *
10
- * 布局策略(autoLayout):
10
+ * 布局策略:
11
11
  * - 计算每个选项内容宽度
12
- * - 能同行放下 → 水平排列(translate X 偏移)
13
- * - 放不下 → 换行(translate Y 偏移)
12
+ * - 如果所有选项能在一行等分放下 → 一行等分排列(slotWidth = stemWidth / n)
13
+ * - 否则 → 每个选项单独一行(垂直排列)
14
14
  */
15
15
  export declare function renderOptions(options: OptionItem[], stemWidth: number, startY: number, fontSize: number, renderMode: RenderMode): string;
16
16
  /**
@@ -19,5 +19,9 @@ export declare function renderOptions(options: OptionItem[], stemWidth: number,
19
19
  export declare function calcOptionItemWidth(opt: OptionItem, labelWidth: number, maxContentWidth: number): number;
20
20
  /**
21
21
  * 计算选项区域总高度
22
+ *
23
+ * 与 renderOptions 布局策略保持一致:
24
+ * - 一行等分排列 → 返回最高选项高度
25
+ * - 每个选项单独一行 → 返回高度之和
22
26
  */
23
27
  export declare function calcOptionsHeight(options: OptionItem[], stemWidth: number): number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sw7d/paper-renderer",
3
- "version": "0.1.8",
3
+ "version": "0.1.10",
4
4
  "description": "题卡设计器核心组件 - 纯编辑表面",
5
5
  "type": "module",
6
6
  "main": "./dist/paper-renderer.js",