@sw7d/paper-renderer 0.2.2 → 0.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -49,7 +49,7 @@ var x = Object.create, S = Object.defineProperty, C = Object.getOwnPropertyDescr
49
49
  }
50
50
  }, M = {
51
51
  A4: {
52
- columns: 1,
52
+ columns: 2,
53
53
  margins: [
54
54
  50,
55
55
  56,
@@ -101,13 +101,13 @@ var x = Object.create, S = Object.defineProperty, C = Object.getOwnPropertyDescr
101
101
  bodyTopOdd: 50
102
102
  }
103
103
  };
104
- function N(e) {
104
+ function ee(e) {
105
105
  return M[e];
106
106
  }
107
- function P(e) {
107
+ function N(e) {
108
108
  if (!e) return {
109
109
  size: "A4",
110
- columns: 1
110
+ columns: 2
111
111
  };
112
112
  let t = e.match(/_(\d+)$/), n = t ? parseInt(t[1]) : 1, r = t ? e.replace(/_\d+$/, "") : e;
113
113
  return {
@@ -120,20 +120,20 @@ function P(e) {
120
120
  columns: n
121
121
  };
122
122
  }
123
- function F(e, t, n, r) {
123
+ function P(e, t, n, r) {
124
124
  return [
125
- I(e),
126
- I(t),
127
- I(n),
128
- I(r)
125
+ F(e),
126
+ F(t),
127
+ F(n),
128
+ F(r)
129
129
  ];
130
130
  }
131
- function I(e) {
131
+ function F(e) {
132
132
  return Math.round(e * 100) / 100;
133
133
  }
134
134
  //#endregion
135
135
  //#region src/engine/PaperLayout.ts
136
- var ee = class {
136
+ var te = class {
137
137
  settings;
138
138
  pageWidth = 0;
139
139
  pageHeight = 0;
@@ -155,9 +155,9 @@ var ee = class {
155
155
  getDefaultSettings() {
156
156
  return {
157
157
  paperSize: "A4",
158
- columns: 1,
159
- fontSize: 14,
160
- lineSpacing: 1.5,
158
+ columns: 2,
159
+ fontSize: 16,
160
+ lineSpacing: 1,
161
161
  margins: [
162
162
  50,
163
163
  56,
@@ -348,72 +348,75 @@ var ee = class {
348
348
  }
349
349
  ];
350
350
  }
351
- }, te = null, L = /* @__PURE__ */ new Map(), R = 5e3;
352
- function ne() {
353
- if (te) return te;
351
+ }, ne = null, I = /* @__PURE__ */ new Map(), L = 5e3;
352
+ function re() {
353
+ if (ne) return ne;
354
354
  try {
355
355
  if (typeof document > "u") return null;
356
356
  let e = document.createElement("canvas");
357
- return e.width = 1, e.height = 1, te = e.getContext("2d"), te;
357
+ return e.width = 1, e.height = 1, ne = e.getContext("2d"), ne;
358
358
  } catch {
359
359
  return null;
360
360
  }
361
361
  }
362
- function re(e, t, n, r) {
363
- return `${r ? "italic" : "normal"} ${n ? "bold" : "normal"} ${t}px ${e.includes(" ") && !e.includes("\"") && !e.includes("'") ? `"${e}"` : e}`;
362
+ function ie(e, t, n, r) {
363
+ return `${r ? "italic" : "normal"} ${n ? "bold" : "normal"} ${t}px ${e.split(",").map((e) => {
364
+ let t = e.trim();
365
+ return t.includes(" ") && !t.includes("\"") && !t.includes("'") ? `"${t}"` : t;
366
+ }).join(", ")}`;
364
367
  }
365
- function ie(e) {
368
+ function ae(e) {
366
369
  let t = e.charCodeAt(0);
367
370
  return t >= 19968 && t <= 40959 || t >= 13312 && t <= 19903 || t >= 63744 && t <= 64255 || t >= 194560 && t <= 195103 || t >= 11904 && t <= 12031 || t >= 12288 && t <= 12351;
368
371
  }
369
- function z(e) {
372
+ function R(e) {
370
373
  let t = e.charCodeAt(0);
371
374
  return t >= 65281 && t <= 65376 || t >= 65504 && t <= 65510;
372
375
  }
373
- function ae(e, t) {
374
- return ie(e) || z(e) || e === " " ? t : e === " " ? t * .25 : t * .6;
376
+ function oe(e, t) {
377
+ return ae(e) || R(e) || e === " " ? t : e === " " ? t * .25 : t * .6;
375
378
  }
376
- function B(e, t, n, r, i) {
377
- let a = ne();
379
+ function z(e, t, n, r, i) {
380
+ let a = re();
378
381
  if (a) {
379
- let o = n || "\"Times New Roman\", SimSun, STSong, serif", s = `${e}|${o}|${t}|${r}|${i}`, c = L.get(s);
382
+ let o = n || "\"Times New Roman\", SimSun, STSong, serif", s = `${e}|${o}|${t}|${r}|${i}`, c = I.get(s);
380
383
  if (c !== void 0) return c;
381
- a.font = re(o, t, !!r, !!i);
384
+ a.font = ie(o, t, !!r, !!i);
382
385
  let l = a.measureText(e).width;
383
- if (L.size > R) {
384
- let e = Array.from(L.keys()).slice(0, R / 2);
385
- for (let t of e) L.delete(t);
386
+ if (I.size > L) {
387
+ let e = Array.from(I.keys()).slice(0, L / 2);
388
+ for (let t of e) I.delete(t);
386
389
  }
387
- return L.set(s, l), l;
390
+ return I.set(s, l), l;
388
391
  }
389
- return ae(e, t);
392
+ return oe(e, t);
390
393
  }
391
- function oe(e, t, n, r, i) {
392
- let a = ne();
394
+ function se(e, t, n, r, i) {
395
+ let a = re();
393
396
  if (a) {
394
- let o = n || "\"Times New Roman\", SimSun, STSong, serif", s = `T|${e}|${o}|${t}|${r}|${i}`, c = L.get(s);
397
+ let o = n || "\"Times New Roman\", SimSun, STSong, serif", s = `T|${e}|${o}|${t}|${r}|${i}`, c = I.get(s);
395
398
  if (c !== void 0) return c;
396
- a.font = re(o, t, !!r, !!i);
399
+ a.font = ie(o, t, !!r, !!i);
397
400
  let l = a.measureText(e).width;
398
- if (L.size > R) {
399
- let e = Array.from(L.keys()).slice(0, R / 2);
400
- for (let t of e) L.delete(t);
401
+ if (I.size > L) {
402
+ let e = Array.from(I.keys()).slice(0, L / 2);
403
+ for (let t of e) I.delete(t);
401
404
  }
402
- return L.set(s, l), l;
405
+ return I.set(s, l), l;
403
406
  }
404
407
  let o = 0;
405
- for (let n of e) o += ae(n, t);
408
+ for (let n of e) o += oe(n, t);
406
409
  return o;
407
410
  }
408
- function V(e, t, n, r, i) {
411
+ function B(e, t, n, r, i) {
409
412
  let a = [], o = 0;
410
- for (let s of e) a.push(o), o += B(s, t, n, r, i);
413
+ for (let s of e) a.push(o), o += z(s, t, n, r, i);
411
414
  return a;
412
415
  }
413
- function se(e, t, n, r, i) {
414
- let a = ne();
416
+ function ce(e, t, n, r, i) {
417
+ let a = re();
415
418
  if (a) {
416
- a.font = re(n || "\"Times New Roman\", SimSun, STSong, serif", t, !!r, !!i);
419
+ a.font = ie(n || "\"Times New Roman\", SimSun, STSong, serif", t, !!r, !!i);
417
420
  let o = a.measureText(e);
418
421
  return {
419
422
  ascent: o.actualBoundingBoxAscent,
@@ -427,23 +430,23 @@ function se(e, t, n, r, i) {
427
430
  height: t
428
431
  };
429
432
  }
430
- function ce() {
431
- L.clear();
433
+ function le() {
434
+ I.clear();
432
435
  }
433
436
  //#endregion
434
437
  //#region src/engine/svg/headerRenderer.ts
435
- function H(e) {
438
+ function V(e) {
436
439
  return e.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&apos;");
437
440
  }
438
- function le(e, t, n, r, i, a, o, s) {
441
+ function H(e, t, n, r, i, a, o, s) {
439
442
  let c = "", l = 0;
440
- return c += ue(t, i, n, l, o, s), l += 30, c += de(e, r, l, s), l += 40, c += fe(e, l, a), c;
443
+ return c += ue(t, i, n, l, o, s), l += 30, c += de(e, r, l, s), l += 40, c += U(e, l, a), c;
441
444
  }
442
445
  function ue(e, t, n, r, i, a) {
443
- let o = i && n > 0 ? `满分: ${n} 分` : "", s = o ? `<span class="swed-score" data-region="score">${H(o)}</span>` : "", { contentWidth: c, contentX: l } = e, u = a === "edit";
446
+ let o = i && n > 0 ? `满分: ${n} 分` : "", s = o ? `<span class="swed-score" data-region="score">${V(o)}</span>` : "", { contentWidth: c, contentX: l } = e, u = a === "edit";
444
447
  return ` <foreignObject class="swed-header-block swed-header-block--school-info" transform="translate(${l}, ${r})" width="${c}" height="30" data-region="header-desc" opacity="1">
445
448
  <div class="swed-header-school-info">
446
- <div contenteditable="${u ? "true" : "false"}" class="swed-headerDesc${u ? " swed-editable-dashed" : ""}" data-editable="schoolName">${H(t)}</div>
449
+ <div contenteditable="${u ? "true" : "false"}" class="swed-headerDesc${u ? " swed-editable-dashed" : ""}" data-editable="schoolName">${V(t)}</div>
447
450
  ${s}
448
451
  </div>
449
452
  </foreignObject>\n`;
@@ -453,13 +456,13 @@ function de(e, t, n, r) {
453
456
  return ` <foreignObject class="swed-header-block swed-header-block--paper-name" transform="translate(${a}, ${n})" width="${i}" height="40" data-region="paper-name" opacity="1">
454
457
  <div class="swed-header-paper-name">
455
458
  <div class="swed-input-box">
456
- <label class="swed-input-box__label">${H(t)}</label>
457
- <div class="swed-input-box__input swed-textarea${o ? " swed-editable-dashed" : ""}" id="paperName" contenteditable="${o ? "true" : "false"}" data-editable="paperName">${H(t)}</div>
459
+ <label class="swed-input-box__label">${V(t)}</label>
460
+ <div class="swed-input-box__input swed-textarea${o ? " swed-editable-dashed" : ""}" id="paperName" contenteditable="${o ? "true" : "false"}" data-editable="paperName">${V(t)}</div>
458
461
  </div>
459
462
  </div>
460
463
  </foreignObject>\n`;
461
464
  }
462
- function fe(e, t, n) {
465
+ function U(e, t, n) {
463
466
  let { contentWidth: r, contentX: i } = e;
464
467
  return ` <foreignObject class="swed-header-block swed-header-block--student-info" transform="translate(${i}, ${t})" width="${r}" height="100" opacity="1">
465
468
  <div class="swed-header-student-info">
@@ -471,24 +474,24 @@ function fe(e, t, n) {
471
474
  <div class="swed-student-field" data-region="student-name"><span class="swed-label">姓名:</span><div class="swed-underline swed-studentName"></div></div>
472
475
  <div class="swed-student-field" data-region="student-class"><span class="swed-label">班级:</span><div class="swed-underline swed-clazzName"></div></div>
473
476
  </div>
474
- <div class="swed-student-code" data-region="student-code">准考证号: <table student-code-num="8" class="swed-student-code-table studyNo"><tbody><tr>${"<td class=\"swed-student-code-cell\"></td>".repeat(8)}</tr></tbody></table></div>
477
+ <div class="swed-student-code"><span data-region="student-code">准考证号: <table student-code-num="8" class="swed-student-code-table studyNo"><tbody><tr>${"<td class=\"swed-student-code-cell\"></td>".repeat(8)}</tr></tbody></table></span><div class="swed-student-code-filler" data-region="student-code-filler"></div></div>
475
478
  </div>
476
479
  </div>
477
480
  </foreignObject>\n`;
478
481
  }
479
- function pe(e, t, n, r, i, a) {
480
- let o = i && t > 0 ? `满分: ${t} 分` : "", s = o ? `<span class="swed-score" data-region="score">${H(o)}</span>` : "", { contentWidth: c, contentX: l } = e, u = a === "edit";
481
- return ` <foreignObject transform="translate(${l}, 0)" width="30" height="30" opacity="1">\n <img src="${r || "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='30' height='30'%3E%3Crect width='30' height='30' fill='%23ddd'/%3E%3Ctext x='15' y='20' text-anchor='middle' font-size='8' fill='%23999'%3EQR%3C/text%3E%3C/svg%3E"}" style="width:30px;height:30px;border:1px solid #000;display:block;" />\n </foreignObject>\n <foreignObject class="swed-header-block swed-header-block--school-info" transform="translate(${l + 30 + 5}, 0)" width="${c - 30 - 5}" height="30" opacity="1">\n <div class="swed-header-school-info swed-header-school-info--simple">\n <div contenteditable="${u ? "true" : "false"}" class="swed-headerDesc${u ? " swed-editable-dashed" : ""}" data-editable="schoolName" data-region="header-desc">${H(n)}</div>\n ${s}\n </div>\n </foreignObject>\n`;
482
+ function fe(e, t, n, r, i, a) {
483
+ let o = i && t > 0 ? `满分: ${t} 分` : "", s = o ? `<span class="swed-score" data-region="score">${V(o)}</span>` : "", { contentWidth: c, contentX: l } = e, u = a === "edit";
484
+ return ` <foreignObject transform="translate(${l}, 0)" width="30" height="30" opacity="1">\n <img src="${r || "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='30' height='30'%3E%3Crect width='30' height='30' fill='%23ddd'/%3E%3Ctext x='15' y='20' text-anchor='middle' font-size='8' fill='%23999'%3EQR%3C/text%3E%3C/svg%3E"}" style="width:30px;height:30px;border:1px solid #000;display:block;" />\n </foreignObject>\n <foreignObject class="swed-header-block swed-header-block--school-info" transform="translate(${l + 30 + 5}, 0)" width="${c - 30 - 5}" height="30" opacity="1">\n <div class="swed-header-school-info swed-header-school-info--simple">\n <div contenteditable="${u ? "true" : "false"}" class="swed-headerDesc${u ? " swed-editable-dashed" : ""}" data-editable="schoolName" data-region="header-desc">${V(n)}</div>\n ${s}\n </div>\n </foreignObject>\n`;
482
485
  }
483
- function me() {
486
+ function pe() {
484
487
  return " <foreignObject class=\"swed-vueplug\" transform=\"translate(0, 0)\" width=\"681\" height=\"50\">\n <div class=\"swed-tail-time-wrapper\">\n <div class=\"swed-answer-wrapper\" style=\"display:none;\">\n <div class=\"swed-tail-col\"><p class=\"swed-text\">作答时长</p><p class=\"swed-text swed-text-second\">请在框内填涂</p></div>\n <div class=\"swed-tail-col swed-center-col\">\n <i class=\"swed-el-icon swed-tail-label swed-triangle\"><svg viewBox=\"0 0 1024 1024\" xmlns=\"http://www.w3.org/2000/svg\" style=\"width:14px;height:14px;\"><path fill=\"currentColor\" d=\"M384 192v640l384-320.064z\"></path></svg></i>\n <div class=\"swed-rect swed-rect-fill swed-text-second\"></div>\n </div>\n <div class=\"swed-tail-col swed-center-col swed-tail-col-item\"><p class=\"swed-tail-label swed-text\">10分钟以内</p><div class=\"swed-rect swed-rect-stroke swed-text-second swed-tail-time\" time=\"0\"></div></div>\n <div class=\"swed-tail-col swed-center-col swed-tail-col-item\"><p class=\"swed-tail-label swed-text\">10-20分钟</p><div class=\"swed-rect swed-rect-stroke swed-text-second swed-tail-time\" time=\"10\"></div></div>\n <div class=\"swed-tail-col swed-center-col swed-tail-col-item\"><p class=\"swed-tail-label swed-text\">20-30分钟</p><div class=\"swed-rect swed-rect-stroke swed-text-second swed-tail-time\" time=\"20\"></div></div>\n <div class=\"swed-tail-col swed-center-col swed-tail-col-item\"><p class=\"swed-tail-label swed-text\">&gt;30分钟</p><div class=\"swed-rect swed-rect-stroke swed-text-second swed-tail-time\" time=\"30\"></div></div>\n </div>\n <div class=\"swed-tail-col swed-revise-wrapper\" style=\"display:none;\">\n <p class=\"swed-text\">订正情况</p>\n <i class=\"swed-el-icon swed-triangle\" style=\"font-size:14px;margin:0 8px;\"><svg viewBox=\"0 0 1024 1024\" xmlns=\"http://www.w3.org/2000/svg\" style=\"width:14px;height:14px;\"><path fill=\"currentColor\" d=\"M384 192v640l384-320.064z\"></path></svg></i>\n <div class=\"swed-revise-area swed-center-col\"><p class=\"swed-revise-area-label\">已订正</p><div class=\"swed-revise-area-rect\"></div></div>\n </div>\n </div>\n </foreignObject>\n";
485
488
  }
486
- function he() {
489
+ function me() {
487
490
  return "<defs>\n<polygon id=\"break\" fill=\"#6B8AB8\" points=\"12 0 12 60 0 52 15.5 90 30 52 18 60 18 0\"></polygon>\n<polygon id=\"enter\" fill=\"#6B8AB8\" points=\"44 0 52 0 52 45 16 45 29 62 25.5 66 0 41 25.5 17 29 20.5 16 37 44 37\"></polygon>\n</defs>\n";
488
491
  }
489
492
  //#endregion
490
493
  //#region src/engine/svg/optionsRenderer.ts
491
- function U(e, t, n, r, i) {
494
+ function he(e, t, n, r, i) {
492
495
  let a = t - 20, o = ` <g class="swed-option" transform="translate(0, ${n})">\n`, s = e.map((e) => ge(e, 20, a)), c = e.map((e) => e.paragraphs.reduce((e, t) => e + (t.height || 26), 0)), l = e.length, u = Math.max(...s);
493
496
  if (l > 0 && u * l <= t) {
494
497
  let n = t / l, a = n - 20;
@@ -496,7 +499,7 @@ function U(e, t, n, r, i) {
496
499
  let s = n * t;
497
500
  o += ` <g class="swed-option-item" transform="translate(${s}, 0)">\n`;
498
501
  let c = e[t].paragraphs[0]?.lines[0]?.baseline || r * 1.56;
499
- 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)}">${H(e[t].label)}.</text>\n`, o += " <g>\n";
502
+ 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";
500
503
  let l = 0;
501
504
  for (let n of e[t].paragraphs) o += be(n, a, l, !1, "", r, i, 20), l += n.height || 26;
502
505
  o += " </g>\n", o += " </g>\n";
@@ -507,7 +510,7 @@ function U(e, t, n, r, i) {
507
510
  for (let t = 0; t < l; t++) {
508
511
  o += ` <g class="swed-option-item" transform="translate(0, ${d})">\n`;
509
512
  let n = e[t].paragraphs[0]?.lines[0]?.baseline || r * 1.56;
510
- 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)}">${H(e[t].label)}.</text>\n`, o += " <g>\n";
513
+ 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";
511
514
  let s = 0;
512
515
  for (let n of e[t].paragraphs) o += be(n, a, s, !1, "", r, i, 20), s += n.height || 26;
513
516
  o += " </g>\n", o += " </g>\n", d += c[t];
@@ -523,20 +526,20 @@ function ge(e, t, n) {
523
526
  }
524
527
  return t + Math.min(r, n);
525
528
  }
526
- function W(e, t) {
529
+ function _e(e, t) {
527
530
  if (e.length === 0) return 0;
528
531
  let n = e.map((e) => ge(e, 20, t)), r = e.map((e) => e.paragraphs.reduce((e, t) => e + (t.height || 26), 0)), i = e.length;
529
532
  return Math.max(...n) * i <= t ? Math.max(...r) : r.reduce((e, t) => e + t, 0);
530
533
  }
531
534
  //#endregion
532
535
  //#region src/engine/svg/questionRenderer.ts
533
- function _e(e, t) {
536
+ function ve(e, t) {
534
537
  return e.baseline > 0 ? e.baseline : t * 1.56;
535
538
  }
536
- function ve(e, t, n, r, i, a, o, s, c, l) {
539
+ function W(e, t, n, r, i, a, o, s, c, l) {
537
540
  let u = t.metadata?.topicId || t.id, d = e.width || 333.5, f = e.height || 100, p = "";
538
- r && (p += ` <rect x="0.5" y="${n - .5}" width="${d}" height="${f}" fill="none" stroke="rgba(85,165,255,0.4)" stroke-width="0.5" stroke-dasharray="4,4" />\n`), i && l === "edit" && (p += ` <rect x="0" y="${n - 1}" width="${d + 2}" height="${f + 2}" fill="none" stroke="#409eff" stroke-width="1.5" rx="2" />\n`), p += ` <g class="swed-question" transform="translate(0, ${n})" topicid="${u}" data-block-id="${t.id}">\n`;
539
- let m = t.type === "question" && t.metadata?.questionNo || "", h = t.paragraphs[0]?.lines[0], g = h ? _e(h, s) : 20, _ = 0;
541
+ r && (p += ` <rect x="0.5" y="${n - .5}" width="${d}" height="${f}" fill="none" stroke="rgba(85,165,255,0.4)" stroke-width="0.5" stroke-dasharray="4,4" />\n`), p += ` <g class="swed-question" transform="translate(0, ${n})" topicid="${u}" data-block-id="${t.id}">\n`;
542
+ let m = t.type === "question" && t.metadata?.questionNo || "", h = t.paragraphs[0]?.lines[0], g = h ? ve(h, s) : 20, _ = 0;
540
543
  t.type === "question" ? _ = m.length > 2 ? 26.25 : 17.5 : t.type === "sub-question" && (_ = 26.25);
541
544
  let v = e.paragraphStart, y = Math.min(v + e.paragraphCount, t.paragraphs.length), b = 0;
542
545
  for (let e = v; e < y; e++) {
@@ -544,7 +547,7 @@ function ve(e, t, n, r, i, a, o, s, c, l) {
544
547
  b += n.height || n.lines.reduce((e, t) => e + t.lineHeight, 0) || 26;
545
548
  }
546
549
  let x = 0;
547
- t.options && t.options.length > 0 && o && (x = W(t.options, d - _), b += x);
550
+ t.options && t.options.length > 0 && o && (x = _e(t.options, d - _), b += x);
548
551
  let S = Math.max(b, e.height), C = (t.type === "question" || t.type === "sub-question") && e.paragraphCount > 0;
549
552
  C && l === "edit" && (p += ` <rect class="swed-question-hitarea" x="0" y="0" width="${d}" height="${S}" fill="transparent" />\n`), p += " <g>\n", p += ` <g class="swed-question-stem" transform="translate(${_}, 0)">\n`;
550
553
  let w = a && c && t.metadata?.score || "", T = 0, E = !1;
@@ -554,15 +557,15 @@ function ve(e, t, n, r, i, a, o, s, c, l) {
554
557
  }
555
558
  if (t.options && t.options.length > 0 && o) {
556
559
  let e = d - _;
557
- p += U(t.options, e, T, s, l), T += x;
560
+ p += he(t.options, e, T, s, l), T += x;
558
561
  }
559
562
  if (p += " </g>\n", p += " </g>\n", C && l === "edit" && (p += ` <path class="swed-question-border" d="M 0.5 0 L ${d - .5} 0 L ${d - .5} ${S} L 0.5 ${S} Z" stroke="#231815" stroke-dasharray="2,5" transform="translate(0.5, 0)" stroke-width="0.5" fill="none" pointer-events="none"></path>\n`), a) {
560
563
  if (m) {
561
564
  let e = m.length > 2;
562
- p += ` <text class="swed-topic-no" font-size="14" font-weight="normal" font-family="SimSun,STSong" font-style="normal" fill="#000000" fill-opacity="1" transform="translate(0, ${g.toFixed(2)})" x="4">${H(m)}</text>\n`, e ? p += ` <text class="swed-topic-no" font-size="14" font-weight="normal" font-family="SimSun,STSong" font-style="normal" fill="#000000" fill-opacity="1" transform="translate(20.25, ${g.toFixed(2)})"></text>\n` : p += ` <text class="swed-topic-no" font-size="14" font-weight="normal" font-family="SimSun,STSong" font-style="normal" fill="#000000" fill-opacity="1" transform="translate(11.5, ${g.toFixed(2)})"></text>\n`;
565
+ p += ` <text class="swed-topic-no" font-size="${s}" font-weight="normal" font-family="SimSun,STSong" font-style="normal" fill="#000000" fill-opacity="1" transform="translate(0, ${g.toFixed(2)})" x="4">${V(m)}</text>\n`, e ? p += ` <text class="swed-topic-no" font-size="${s}" font-weight="normal" font-family="SimSun,STSong" font-style="normal" fill="#000000" fill-opacity="1" transform="translate(20.25, ${g.toFixed(2)})"></text>\n` : p += ` <text class="swed-topic-no" font-size="${s}" font-weight="normal" font-family="SimSun,STSong" font-style="normal" fill="#000000" fill-opacity="1" transform="translate(11.5, ${g.toFixed(2)})"></text>\n`;
563
566
  }
564
567
  let e = t.metadata?.subLabel || "";
565
- e && (p += ` <text class="swed-topic-no" font-size="14" font-weight="normal" font-family="SimSun,STSong" font-style="normal" fill="#000000" fill-opacity="1" transform="translate(4, ${g.toFixed(2)})">${H(e)}</text>\n`, p += ` <text class="swed-topic-no" font-size="14" font-weight="normal" font-family="SimSun,STSong" font-style="normal" fill="#000000" fill-opacity="1" transform="translate(20.25, ${g.toFixed(2)})"></text>\n`);
568
+ e && (p += ` <text class="swed-topic-no" font-size="${s}" font-weight="normal" font-family="SimSun,STSong" font-style="normal" fill="#000000" fill-opacity="1" transform="translate(4, ${g.toFixed(2)})">${V(e)}</text>\n`, p += ` <text class="swed-topic-no" font-size="${s}" font-weight="normal" font-family="SimSun,STSong" font-style="normal" fill="#000000" fill-opacity="1" transform="translate(20.25, ${g.toFixed(2)})"></text>\n`);
566
569
  }
567
570
  return p += " </g>\n", p;
568
571
  }
@@ -570,10 +573,10 @@ function ye(e, t, n, r = 0, i = !0, a = !1, o = "edit") {
570
573
  let s = e.metadata?.label || "", c = e.height || 40;
571
574
  if (!s) return "";
572
575
  let l = i && e.metadata?.score || "", u = "";
573
- return a && o === "edit" && (u += ` <rect x="${r}" y="${t}" width="${n.toFixed(1)}" height="${c}" fill="none" stroke="#409eff" stroke-width="1.5" rx="2" />\n`), u += ` <foreignObject class="swed-vueplug" data-block-id="${e.id}" transform="translate(${r}, ${t})" width="${n.toFixed(1)}" height="${c}" rendered="true" opacity="1">\n <div class="swed-title_wrapper" topictitle="${H(s)}" topicgroupinfo="">
576
+ return a && o === "edit" && (u += ` <rect x="${r}" y="${t}" width="${n.toFixed(1)}" height="${c}" fill="none" stroke="#409eff" stroke-width="1.5" rx="2" />\n`), u += ` <foreignObject class="swed-vueplug" data-block-id="${e.id}" transform="translate(${r}, ${t})" width="${n.toFixed(1)}" height="${c}" rendered="true" opacity="1">\n <div class="swed-title_wrapper" topictitle="${V(s)}" topicgroupinfo="">
574
577
  <div class="swed-title-content">
575
- <span class="swed-title-text">${H(s)}</span>
576
- ${l ? `<span class="swed-title-score">(${H(l)})</span>` : ""}
578
+ <span class="swed-title-text">${V(s)}</span>
579
+ ${l ? `<span class="swed-title-score">(${V(l)})</span>` : ""}
577
580
  </div>
578
581
  </div>
579
582
  </foreignObject>\n`, u;
@@ -581,12 +584,12 @@ function ye(e, t, n, r = 0, i = !0, a = !1, o = "edit") {
581
584
  function be(e, t, n, r, i = "", a, o, s = 0) {
582
585
  let c = "", l = 0;
583
586
  for (let n = 0; n < e.lines.length; n++) {
584
- let s = e.lines[n], u = _e(s, a), d = r && n === 0, f = s.elements.length > 0 && s.elements.every((e) => e.type === "enter"), p = s.lineHeight;
587
+ let s = e.lines[n], u = ve(s, a), d = r && n === 0, f = s.elements.length > 0 && s.elements.every((e) => e.type === "enter"), p = s.lineHeight;
585
588
  c += ` <g class="swed-line" transform="translate(0, ${l})" baseline="${u.toFixed(2)}">\n`;
586
589
  let m = 0;
587
590
  if (d && i) {
588
591
  let e = `(${i}分)`, t = u - a;
589
- c += ` <text class="swed-question-score" font-size="${a}" font-weight="normal" font-family="SimSun, STSong, serif" font-style="normal" fill="#000000" fill-opacity="1" transform="translate(0, ${t.toFixed(2)})" y="${a}">${H(e)}</text>\n`, m += oe(e, a, "SimSun, STSong, serif");
592
+ c += ` <text class="swed-question-score" font-size="${a}" font-weight="normal" font-family="SimSun, STSong, serif" font-style="normal" fill="#000000" fill-opacity="1" transform="translate(0, ${t.toFixed(2)})" y="${a}">${V(e)}</text>\n`, m += se(e, a, "SimSun, STSong, serif");
590
593
  }
591
594
  if (f) {
592
595
  if (o === "edit") {
@@ -600,7 +603,7 @@ function be(e, t, n, r, i = "", a, o, s = 0) {
600
603
  e.justification === "center" ? r = Math.max(0, (i - n) / 2) : e.justification === "right" && (r = Math.max(0, i - n));
601
604
  }
602
605
  let i = s.elements.length > 0 && s.elements.every((e) => e.type === "image");
603
- for (let e of s.elements) c += xe(e, m + r + (s.offsetX || 0), u, s.lineHeight, f, o, e.type === "image" ? e.id : void 0, e.type === "image" ? i : void 0), m += e.width;
606
+ for (let e of s.elements) c += xe(e, m + r + (s.offsetX || 0), u, s.lineHeight, f, o, a, e.type === "image" ? e.id : void 0, e.type === "image" ? i : void 0), m += e.width;
604
607
  if (o === "edit" && n === e.lines.length - 1) {
605
608
  let e = m + r + (s.offsetX || 0) + 2;
606
609
  c += ` <g class="swed-enter" transform="translate(${e.toFixed(2)}, ${(u - 10).toFixed(2)})">\n`, c += " <use href=\"#enter\" transform=\"scale(0.013)\" fill=\"#c8c8c8\" opacity=\"0.5\"></use>\n", c += " </g>\n";
@@ -610,19 +613,19 @@ function be(e, t, n, r, i = "", a, o, s = 0) {
610
613
  }
611
614
  return ` <g class="swed-paragraph" transform="translate(${s}, ${n})">\n${c} </g>\n`;
612
615
  }
613
- function xe(e, t, n, r, i, a, o, s) {
616
+ function xe(e, t, n, r, i, a, o, s, c) {
614
617
  switch (e.type) {
615
618
  case "text": {
616
- let r = e, i = r.italic ? "italic" : "normal", a = r.bold ? "bold" : "normal", o = n + (r.verticalAlign || 0), s = r.value.split(""), c = r.xPositions.length === s.length ? r.xPositions.map((e) => (e + t).toFixed(2)).join(" ") : V(r.value, r.fontSize, r.fontFamily, r.bold, r.italic).map((e) => (e + t).toFixed(2)).join(" "), l = "";
619
+ let r = e, i = r.italic ? "italic" : "normal", a = r.bold ? "bold" : "normal", o = n + (r.verticalAlign || 0), s = r.value.split(""), c = r.xPositions.length === s.length ? r.xPositions.map((e) => (e + t).toFixed(2)).join(" ") : B(r.value, r.fontSize, r.fontFamily, r.bold, r.italic).map((e) => (e + t).toFixed(2)).join(" "), l = "";
617
620
  if (r.backgroundColor) {
618
621
  let e = o + r.fontSize * .1, n = r.fontSize * 1.1;
619
622
  l += ` <rect x="${t.toFixed(2)}" y="${e.toFixed(2)}" width="${r.width.toFixed(2)}" height="${n.toFixed(2)}" fill="${r.backgroundColor}" fill-opacity="0.3"></rect>\n`;
620
623
  }
621
- let u = r.italic ? -r.fontSize * .02 : 0, d = r.fontFamily ? H(r.fontFamily) : "&quot;Times New Roman&quot;, SimSun";
622
- if (l += ` <text class="swed-text" xml:space="preserve" font-size="${r.fontSize}" font-weight="${a}" font-family="${d}" font-style="${i}" fill="${r.color}" fill-opacity="1" x="${c}" y="${(o + u).toFixed(2)}" dominant-baseline="hanging">${H(r.value)}</text>\n`, r.dotAbove) {
624
+ let u = r.italic ? -r.fontSize * .02 : 0, d = r.fontFamily ? V(r.fontFamily) : "&quot;Times New Roman&quot;, SimSun";
625
+ if (l += ` <text class="swed-text" xml:space="preserve" font-size="${r.fontSize}" font-weight="${a}" font-family="${d}" font-style="${i}" fill="${r.color}" fill-opacity="1" x="${c}" y="${(o + u).toFixed(2)}" dominant-baseline="hanging">${V(r.value)}</text>\n`, r.dotAbove) {
623
626
  let e = Math.max(1.5, r.fontSize * .1), n = o + r.fontSize * .9 + e;
624
627
  for (let i = 0; i < s.length; i++) {
625
- let a = r.xPositions.length === s.length ? r.xPositions[i] + t + B(s[i], r.fontSize, r.fontFamily, r.bold, r.italic) / 2 : t + i * r.fontSize * .6 + r.fontSize * .3;
628
+ let a = r.xPositions.length === s.length ? r.xPositions[i] + t + z(s[i], r.fontSize, r.fontFamily, r.bold, r.italic) / 2 : t + i * r.fontSize * .6 + r.fontSize * .3;
626
629
  l += ` <circle cx="${a.toFixed(2)}" cy="${n.toFixed(2)}" r="${e.toFixed(2)}" fill="${r.color}"></circle>\n`;
627
630
  }
628
631
  }
@@ -639,19 +642,24 @@ function xe(e, t, n, r, i, a, o, s) {
639
642
  l += ` <line x1="${t.toFixed(2)}" y1="${e.toFixed(2)}" x2="${(t + r.width).toFixed(2)}" y2="${e.toFixed(2)}" style="stroke:${r.color};stroke-width:0.8"></line>\n`;
640
643
  }
641
644
  if (r.strikethrough) {
642
- let e = o + se(r.value, r.fontSize, r.fontFamily, r.bold, r.italic).ascent * .5;
645
+ let e = o + ce(r.value, r.fontSize, r.fontFamily, r.bold, r.italic).ascent * .5;
643
646
  l += ` <line x1="${t.toFixed(2)}" y1="${e.toFixed(2)}" x2="${(t + r.width).toFixed(2)}" y2="${e.toFixed(2)}" style="stroke:${r.color};stroke-width:0.8"></line>\n`;
644
647
  }
645
648
  return l;
646
649
  }
647
650
  case "formula": {
648
- let r = e, i = r.svgContent.match(/vertical-align:\s*([-\d.]+)ex/), a = i ? parseFloat(i[1]) * 7 : -(r.height || 20), o = Math.round(n + a);
651
+ let r = e, i = r.svgContent.match(/vertical-align:\s*([-\d.]+)(px|ex)/), a;
652
+ if (i) {
653
+ let e = parseFloat(i[1]);
654
+ a = i[2] === "ex" ? e * 7 : e;
655
+ } else a = -(r.height || 20);
656
+ let o = Math.round(n + a);
649
657
  return ` <g class="swed-formula" transform="translate(${t.toFixed(2)}, ${o})">\n${r.svgContent} </g>\n`;
650
658
  }
651
659
  case "underline": {
652
660
  let r = e, i = (n - 30 / 2).toFixed(2), o = 30 .toFixed(2), s = r.topicId ? ` topicid="${r.topicId}" real-index="${r.realIndex ?? 0}" id="${r.topicId}-${r.realIndex ?? 0}"` : "", c = r.id ? ` data-underline-id="${r.id}"` : "", l = r.blankType ? ` data-blank-type="${r.blankType}"` : "", u = a === "edit" ? `<rect class="swed-underline-hitarea" x="0" y="0" width="${r.width.toFixed(2)}" height="30" fill="transparent" opacity="0"></rect>\n` : "", d = (r.isEmpty || !!r.blankType) && !r.isSplitPart, f = !r.blankType || r.blankType === "tiankong";
653
661
  if (d) {
654
- let e = (42 / 2).toFixed(2), n = a === "edit" ? `<rect x="0" y="0" width="${r.width.toFixed(2)}" height="30" fill="rgb(245,245,245)" opacity="1"></rect>\n` : "", d = a === "edit" ? `<text font-size="12" text-anchor="middle" font-family="'Times New Roman',SimSun,STSong" fill="#aaa" fill-opacity="1" x="${(r.width / 2).toFixed(2)}" y="${e}">${H(r.placeholder)}</text>\n` : "";
662
+ let e = (42 / 2).toFixed(2), n = a === "edit" ? `<rect x="0" y="0" width="${r.width.toFixed(2)}" height="30" fill="rgb(245,245,245)" opacity="1"></rect>\n` : "", d = a === "edit" ? `<text font-size="12" text-anchor="middle" font-family="'Times New Roman',SimSun,STSong" fill="#aaa" fill-opacity="1" x="${(r.width / 2).toFixed(2)}" y="${e}">${V(r.placeholder)}</text>\n` : "";
655
663
  return ` <g class="swed-underline" transform="translate(${t.toFixed(2)}, ${i})"${s}${c}${l}>\n ${u} ${n} ${d}` + (f ? ` <line x1="2" y1="${o}" x2="${(r.width - 2).toFixed(2)}" y2="${o}" style="stroke:#000;stroke-width:0.7"></line>\n` : "") + " </g>\n";
656
664
  }
657
665
  if (r.isSplitPart && (r.isEmpty || r.blankType) && a === "edit") {
@@ -663,11 +671,11 @@ function xe(e, t, n, r, i, a, o, s) {
663
671
  case "image": {
664
672
  let r = e;
665
673
  if (r.rawHtml && !r.src) {
666
- let e = o ? ` data-image-id="${o}"` : "", i = (r.width / 2).toFixed(2), a = (r.height / 2).toFixed(2), c = s ? "0" : (n - r.height / 2).toFixed(2);
667
- return ` <g class="swed-image swed-image-placeholder" transform="translate(${t.toFixed(2)}, ${c})"${e}>\n <rect x="0" y="0" width="${r.width}" height="${r.height}" fill="#f5f5f5" stroke="#999" stroke-width="1" stroke-dasharray="4,3" rx="4" ry="4" />\n <text x="${i}" y="${a}" text-anchor="middle" dominant-baseline="central" font-size="13" fill="#999">[表格加载中…]</text>\n </g>\n`;
674
+ let e = s ? ` data-image-id="${s}"` : "", i = (r.width / 2).toFixed(2), a = (r.height / 2).toFixed(2), o = c ? "0" : (n - r.height / 2).toFixed(2);
675
+ return ` <g class="swed-image swed-image-placeholder" transform="translate(${t.toFixed(2)}, ${o})"${e}>\n <rect x="0" y="0" width="${r.width}" height="${r.height}" fill="#f5f5f5" stroke="#999" stroke-width="1" stroke-dasharray="4,3" rx="4" ry="4" />\n <text x="${i}" y="${a}" text-anchor="middle" dominant-baseline="central" font-size="13" fill="#999">[表格加载中…]</text>\n </g>\n`;
668
676
  }
669
- let i = s ? "0" : (n - r.height / 2).toFixed(2), c = o ? ` data-image-id="${o}"` : "", l = a === "edit" ? " style=\"cursor:move\"" : "";
670
- return ` <g class="swed-image" transform="translate(${t.toFixed(2)}, ${i})"${c}${l}>\n <image href="${r.src}" width="${r.width}" height="${r.height}" preserveAspectRatio="xMidYMid meet" />\n </g>\n`;
677
+ let i = c ? "0" : (n - r.height / 2).toFixed(2), o = s ? ` data-image-id="${s}"` : "", l = a === "edit" ? " style=\"cursor:move\"" : "";
678
+ return ` <g class="swed-image" transform="translate(${t.toFixed(2)}, ${i})"${o}${l}>\n <image href="${r.src}" width="${r.width}" height="${r.height}" preserveAspectRatio="xMidYMid meet" />\n </g>\n`;
671
679
  }
672
680
  case "enter": {
673
681
  let r = e, i = .013;
@@ -719,7 +727,7 @@ var Se = class {
719
727
  renderAllPages(e, t, n, r) {
720
728
  if (e.length === 0) return "";
721
729
  let { showBBoxes: i = !1, selectedBlockId: a = null, totalScore: o = 0, paperName: s = "", qrCodeImage: c = "", qrCodeImages: l } = r || {}, u = e[0].width, d = e[0].height, f = e.length * d, p = `<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="${u}" height="${f}" viewBox="0 0 ${u} ${f}">\n`;
722
- p += he();
730
+ p += me();
723
731
  for (let r = 0; r < e.length; r++) {
724
732
  let u = e[r], f = r % 2 == 0 ? n.bodyTopEven ?? 173 : n.bodyTopOdd ?? 50, m = r * d;
725
733
  p += `<g class="swed-page" transform="translate(0, ${m})">\n`, p += this.renderPageContent(u, t, f, n, r, e.length, {
@@ -740,7 +748,7 @@ var Se = class {
740
748
  paperName: ""
741
749
  }, a = 1, o = !0) {
742
750
  let { totalScore: s = 0, paperName: c = "", schoolName: l = "", qrCodeImage: u = "", qrCodeImages: d } = i, f = "";
743
- return o && (f += he()), f += this.renderPageContent(e, t, n, r, e.index, a, {
751
+ return o && (f += me()), f += this.renderPageContent(e, t, n, r, e.index, a, {
744
752
  ...i,
745
753
  totalScore: s,
746
754
  paperName: c,
@@ -755,7 +763,7 @@ var Se = class {
755
763
  55.5,
756
764
  56,
757
765
  56
758
- ], l = c, u = e.width - l - o, d = r.columnGap ?? 15.5, f = r.columns || 1, p = f > 1 ? (u - d * (f - 1)) / f : u, m = e.height - s - this.FOOTER_EXTRA_GAP, h = typeof r.fontSize == "number" ? r.fontSize : 14, g = [], _ = this.groupBlocksByColumn(e.blocks);
766
+ ], l = c, u = e.width - l - o, d = r.columnGap ?? 15.5, f = r.columns || 1, p = f > 1 ? (u - d * (f - 1)) / f : u, m = e.height - s - this.FOOTER_EXTRA_GAP, h = typeof r.fontSize == "number" ? r.fontSize : 16, g = [], _ = this.groupBlocksByColumn(e.blocks);
759
767
  for (let e = 0; e < _.length; e++) for (let r of _[e]) {
760
768
  let e = t.find((e) => e.id === r.blockId);
761
769
  if (!e) continue;
@@ -763,7 +771,7 @@ var Se = class {
763
771
  if (e.type === "title") {
764
772
  g.push({
765
773
  type: "title-embed",
766
- bbox: F(i, a, r.width || p, e.height || 40),
774
+ bbox: P(i, a, r.width || p, e.height || 40),
767
775
  meta: { label: e.metadata?.label }
768
776
  });
769
777
  continue;
@@ -776,25 +784,25 @@ var Se = class {
776
784
  let u = o + r.paragraphCount >= e.paragraphs.length;
777
785
  if (e.options && e.options.length > 0 && u) {
778
786
  let t = r.width || p, n = e.type === "question" && e.metadata?.questionNo || "", i = e.type === "question" ? n.length > 2 ? 26.25 : 17.5 : 26.25;
779
- c += W(e.options, t - i);
787
+ c += _e(e.options, t - i);
780
788
  }
781
789
  let d = Math.max(c, r.height);
782
790
  g.push({
783
791
  type: "question-border",
784
- bbox: F(i, a, r.width, d),
792
+ bbox: P(i, a, r.width, d),
785
793
  meta: {
786
794
  blockId: r.blockId,
787
795
  blockType: r.blockType
788
796
  }
789
797
  });
790
798
  }
791
- if (_.length > 1) {
799
+ if (f > 1) {
792
800
  let e = m - n;
793
- for (let t = 1; t < _.length; t++) {
801
+ for (let t = 1; t < f; t++) {
794
802
  let r = t * (p + d) - d / 2;
795
803
  g.push({
796
804
  type: "column-separator",
797
- bbox: F(c + r, n, .5, e)
805
+ bbox: P(c + r, n, .5, e)
798
806
  });
799
807
  }
800
808
  }
@@ -810,12 +818,12 @@ var Se = class {
810
818
  }
811
819
  let a = 0, l = !p && u === 0;
812
820
  for (let t of n.lines) {
813
- let u = _e(t, h), d = 0;
821
+ let u = ve(t, h), d = 0;
814
822
  if (l && r.showScore && !p) {
815
823
  let t = e.metadata?.score || "";
816
824
  if (t) {
817
825
  let e = `(${t}分)`;
818
- d += oe(e, h, "SimSun, STSong, serif");
826
+ d += se(e, h, "SimSun, STSong, serif");
819
827
  }
820
828
  p = !0, l = !1;
821
829
  }
@@ -829,7 +837,7 @@ var Se = class {
829
837
  let n = e;
830
838
  g.push({
831
839
  type: "underline",
832
- bbox: F(s + m + (t.offsetX || 0) + d, c + f + a + u - 30 / 2, n.width, 30),
840
+ bbox: P(s + m + (t.offsetX || 0) + d, c + f + a + u - 30 / 2, n.width, 30),
833
841
  meta: {
834
842
  placeholder: n.placeholder,
835
843
  isEmpty: n.isEmpty,
@@ -864,12 +872,12 @@ var Se = class {
864
872
  let t = e.getAttribute("data-region"), r = e.getBoundingClientRect();
865
873
  n.push({
866
874
  type: t,
867
- bbox: F((r.left - a.left) * c, (r.top - a.top) * l, r.width * c, r.height * l)
875
+ bbox: P((r.left - a.left) * c, (r.top - a.top) * l, r.width * c, r.height * l)
868
876
  });
869
877
  }
870
878
  }
871
879
  getOptionsHeight(e, t) {
872
- return W(e, t);
880
+ return _e(e, t);
873
881
  }
874
882
  renderPageContent(e, t, n, r, i, a, o) {
875
883
  let [s, c, l, u] = r.margins || [
@@ -877,16 +885,16 @@ var Se = class {
877
885
  55.5,
878
886
  56,
879
887
  56
880
- ], d = u, f = c, p = e.width - d - f, m = r.columnGap ?? 15.5, h = r.columns || 1, g = h > 1 ? (p - m * (h - 1)) / h : p, _ = e.height - l - this.FOOTER_EXTRA_GAP, v = r.fontSize, y = typeof v == "number" ? v : 14, b = "";
888
+ ], d = u, f = c, p = e.width - d - f, m = r.columnGap ?? 15.5, h = r.columns || 1, g = h > 1 ? (p - m * (h - 1)) / h : p, _ = e.height - l - this.FOOTER_EXTRA_GAP, v = r.fontSize, y = typeof v == "number" ? v : 16, b = "";
881
889
  b += " <g class=\"swed-background\"></g>\n";
882
890
  let x = o.qrCodeImages?.[i] || o.qrCodeImage || "", S = this.computeHeaderLayout(r, e), C = {
883
891
  mode: "portrait",
884
892
  contentWidth: p,
885
893
  contentX: 0
886
894
  };
887
- b += ` <g class="swed-header" transform="translate(${d}, ${r.headerTop ?? 18})">\n`, b += " <g class=\"swed-header-content\"></g>\n", b += " <g class=\"swed-header-embeds\">\n", i % 2 == 0 ? b += le(S, C, o.totalScore ?? 0, o.paperName || "", o.schoolName || "", x, r.showScore ?? !0, this.renderMode) : b += pe(C, o.totalScore ?? 0, o.schoolName || "", x, r.showScore ?? !0, this.renderMode), b += " </g>\n", b += " </g>\n", b += ` <g class="swed-footer" transform="translate(${d}, ${_.toFixed(2)})">\n`, b += " <g class=\"swed-footer-content\">\n", b += " <g class=\"swed-anchor\" transform=\"translate(0, 0)\"></g>\n", b += " <g class=\"swed-paragraph\" transform=\"translate(0, 0)\">\n", b += " <g class=\"swed-line\" transform=\"translate(0, 0)\" baseline=\"19.6\">\n";
895
+ b += ` <g class="swed-header" transform="translate(${d}, ${r.headerTop ?? 18})">\n`, b += " <g class=\"swed-header-content\"></g>\n", b += " <g class=\"swed-header-embeds\">\n", i % 2 == 0 ? b += H(S, C, o.totalScore ?? 0, o.paperName || "", o.schoolName || "", x, r.showScore ?? !0, this.renderMode) : b += fe(C, o.totalScore ?? 0, o.schoolName || "", x, r.showScore ?? !0, this.renderMode), b += " </g>\n", b += " </g>\n", b += ` <g class="swed-footer" transform="translate(${d}, ${_.toFixed(2)})">\n`, b += " <g class=\"swed-footer-content\">\n", b += " <g class=\"swed-anchor\" transform=\"translate(0, 0)\"></g>\n", b += " <g class=\"swed-paragraph\" transform=\"translate(0, 0)\">\n", b += " <g class=\"swed-line\" transform=\"translate(0, 0)\" baseline=\"19.6\">\n";
888
896
  let w = `${i + 1}/${a}`, T = p / 2 - w.length * 6, E = w.split("").map((e, t) => (T + t * 12).toFixed(2)).join(" ");
889
- b += ` <text class="swed-text" data-region="page-number" xml:space="preserve" font-size="12" font-weight="bold" font-family="&quot;Times New Roman&quot;, SimSun,'Cambria Math'" font-style="normal" fill="#898989" fill-opacity="1" x="${E}" y="19.6">${H(w)}</text>\n`, b += ` <line x1="0" y1="28.2" x2="${p.toFixed(2)}" y2="28.2" style="fill:#000;stroke-width:1;stroke:#000;" opacity="0"></line>\n`, b += " </g>\n", b += " </g>\n", b += " </g>\n", b += " <g class=\"swed-footer-embeds\">\n", b += me(), b += " </g>\n", b += " </g>\n", b += " <g class=\"swed-layout\">\n";
897
+ b += ` <text class="swed-text" data-region="page-number" xml:space="preserve" font-size="12" font-weight="bold" font-family="&quot;Times New Roman&quot;, SimSun,'Cambria Math'" font-style="normal" fill="#898989" fill-opacity="1" x="${E}" y="19.6">${V(w)}</text>\n`, b += ` <line x1="0" y1="28.2" x2="${p.toFixed(2)}" y2="28.2" style="fill:#000;stroke-width:1;stroke:#000;" opacity="0"></line>\n`, b += " </g>\n", b += " </g>\n", b += " </g>\n", b += " <g class=\"swed-footer-embeds\">\n", b += pe(), b += " </g>\n", b += " </g>\n", b += " <g class=\"swed-layout\">\n";
890
898
  for (let t of e.cornerMarks) b += this.renderCornerMark(t);
891
899
  b += " </g>\n", b += ` <g class="swed-body" transform="translate(${d}, ${n})">\n`, b += " <g class=\"swed-content\">\n", b += " <g class=\"swed-column\" transform=\"translate(0, 0)\">\n";
892
900
  let D = this.groupBlocksByColumn(e.blocks);
@@ -897,13 +905,13 @@ var Se = class {
897
905
  let e = t.find((e) => e.id === n.blockId);
898
906
  if (!e || e.type === "title") continue;
899
907
  let i = n.blockId === o.selectedBlockId, a = n.paragraphStart === 0, s = n.paragraphStart + n.paragraphCount >= e.paragraphs.length;
900
- b += ve(n, e, n.y, o.showBBoxes, i, a, s, y, r.showScore ?? !0, this.renderMode);
908
+ b += W(n, e, n.y, o.showBBoxes, i, a, s, y, r.showScore ?? !0, this.renderMode);
901
909
  }
902
910
  b += " </g>\n";
903
911
  }
904
- if (D.length > 1) {
912
+ if (h > 1) {
905
913
  let e = (_ - n).toFixed(1);
906
- for (let t = 1; t < D.length; t++) {
914
+ for (let t = 1; t < h; t++) {
907
915
  let n = t * (g + m) - m / 2;
908
916
  b += ` <path fill="none" stroke="#D1D3D4" stroke-width="0.5" stroke-dasharray="8,8" d="M ${n.toFixed(1)} 0 L ${n.toFixed(1)} ${e}"></path>\n`;
909
917
  }
@@ -1096,7 +1104,7 @@ var Me = {
1096
1104
  }
1097
1105
  }
1098
1106
  }, Ne = { docDefaults: { textPropsDefault: { runfonts: { hint: "eastAsia" } } } }, Pe = 26.46, Fe = 17.5, Ie = 26.25;
1099
- function J(e) {
1107
+ function Le(e) {
1100
1108
  let t = Pe;
1101
1109
  return {
1102
1110
  tl: {
@@ -1125,11 +1133,11 @@ function J(e) {
1125
1133
  }
1126
1134
  };
1127
1135
  }
1128
- function Le(e) {
1136
+ function Re(e) {
1129
1137
  let t = e.startsWith("sw-") ? e.slice(3) : e, n = t.lastIndexOf("-");
1130
1138
  return n > 0 && /^\d+$/.test(t.slice(n + 1)) && (t = t.slice(0, n)), t;
1131
1139
  }
1132
- function Re(e) {
1140
+ function ze(e) {
1133
1141
  let t = /* @__PURE__ */ new Map();
1134
1142
  for (let n of e) {
1135
1143
  t.set(n.id, n);
@@ -1138,7 +1146,7 @@ function Re(e) {
1138
1146
  }
1139
1147
  return t;
1140
1148
  }
1141
- function ze(e) {
1149
+ function Be(e) {
1142
1150
  let t = e?.questionType;
1143
1151
  if (t) {
1144
1152
  if (t.includes("chose")) return "choice";
@@ -1147,10 +1155,10 @@ function ze(e) {
1147
1155
  }
1148
1156
  return e?.options?.length ? "choice" : "fill";
1149
1157
  }
1150
- function Be(e) {
1158
+ function Ve(e) {
1151
1159
  return e.replace(/-([a-z])/g, (e, t) => t.toUpperCase());
1152
1160
  }
1153
- function Ve(e) {
1161
+ function J(e) {
1154
1162
  return /_Block_\d+$/.test(e);
1155
1163
  }
1156
1164
  function He(e) {
@@ -1489,7 +1497,7 @@ function Ye(e, t) {
1489
1497
  bottom: a,
1490
1498
  left: o
1491
1499
  },
1492
- point: J(n),
1500
+ point: Le(n),
1493
1501
  headerTop: t.headerTop ?? 18,
1494
1502
  footerBottom: 13.2,
1495
1503
  showScore: t.showScore,
@@ -1580,22 +1588,23 @@ var Qe = new Set([
1580
1588
  "qr-code",
1581
1589
  "student-name",
1582
1590
  "student-class",
1583
- "student-code"
1591
+ "student-code",
1592
+ "student-code-filler"
1584
1593
  ]);
1585
1594
  function $e(e, t, n = !0) {
1586
- let r = Re(t), i = /* @__PURE__ */ new Set(), a = /* @__PURE__ */ new Set();
1595
+ let r = ze(t), i = /* @__PURE__ */ new Set(), a = /* @__PURE__ */ new Set();
1587
1596
  for (let t of e) for (let e of t.renderedRegions || []) {
1588
- let t = Le(e.meta?.blockId || e.meta?.topicId || "");
1597
+ let t = Re(e.meta?.blockId || e.meta?.topicId || "");
1589
1598
  t && e.type === "question-border" && i.add(t);
1590
1599
  }
1591
- for (let e of i) Ve(e) && a.add(He(e));
1600
+ for (let e of i) J(e) && a.add(He(e));
1592
1601
  let o = /* @__PURE__ */ new Map(), s = 0;
1593
1602
  for (let e of t) {
1594
1603
  let t = e.metadata?.topicId || (e.id.startsWith("sw-") ? e.id.slice(3) : e.id);
1595
1604
  o.has(t) || o.set(t, s++);
1596
1605
  }
1597
1606
  for (let t of e) for (let e of t.renderedRegions || []) {
1598
- let t = Le(e.meta?.blockId || e.meta?.topicId || "");
1607
+ let t = Re(e.meta?.blockId || e.meta?.topicId || "");
1599
1608
  t && e.type === "question-border" && !o.has(t) && o.set(t, s++);
1600
1609
  }
1601
1610
  return e.map((t) => {
@@ -1612,7 +1621,7 @@ function $e(e, t, n = !0) {
1612
1621
  for (let e of i) {
1613
1622
  if (Qe.has(e.type)) {
1614
1623
  if (e.type === "score" && !n) continue;
1615
- c[Be(e.type)] = e.bbox;
1624
+ c[Ve(e.type)] = e.bbox;
1616
1625
  continue;
1617
1626
  }
1618
1627
  if (e.type === "page-number") {
@@ -1627,7 +1636,7 @@ function $e(e, t, n = !0) {
1627
1636
  continue;
1628
1637
  }
1629
1638
  if (e.type === "column-separator") continue;
1630
- let t = Le(e.meta?.blockId || e.meta?.topicId || "");
1639
+ let t = Re(e.meta?.blockId || e.meta?.topicId || "");
1631
1640
  if (!t) continue;
1632
1641
  d.has(t) || d.set(t, {
1633
1642
  borders: [],
@@ -1646,20 +1655,20 @@ function $e(e, t, n = !0) {
1646
1655
  let i = r.get(t), c = i?.metadata?.questionNo || i?.metadata?.subLabel || "", l = i?.metadata?.score, u = a.has(t), d = n.borders.map((e) => e.bbox), f = {
1647
1656
  topicId: t,
1648
1657
  questionNo: c,
1649
- questionType: ze(i),
1658
+ questionType: Be(i),
1650
1659
  sortIndex: o.get(t) ?? 9999,
1651
1660
  bbox: d[0]
1652
1661
  };
1653
- if (d.length > 1 && (f.bboxes = d), i?.metadata?.qid && (f.qid = i.metadata.qid), i?.metadata?.answer && (f.answer = i.metadata.answer), l !== void 0 && l !== "" && l !== null) {
1662
+ if (d.length > 1 && (f.bboxes = d), i?.metadata?.qid && (f.qid = i.metadata.qid), i?.metadata?.answer && (f.answer = i.metadata.answer), i?.metadata?.subAnswers && (f.subAnswers = i.metadata.subAnswers), l !== void 0 && l !== "" && l !== null) {
1654
1663
  let e = parseFloat(String(l));
1655
1664
  isNaN(e) || (f.score = e);
1656
1665
  }
1657
- Ve(t) && (f.parentTopicId = He(t)), u && (f.hasSubQuestions = !0), n.underlines.length > 0 && (f.underlines = n.underlines.map((e) => {
1666
+ J(t) && (f.parentTopicId = He(t)), u && (f.hasSubQuestions = !0), n.underlines.length > 0 && (f.underlines = n.underlines.map((e) => {
1658
1667
  let t = { bbox: e.bbox }, n = e.meta;
1659
1668
  return n?.correctAnswer && (t.correctAnswer = n.correctAnswer), n?.blankType && (t.blankType = n.blankType), n?.index != null && (t.index = n.index), n?.underlineId && (t.underlineId = n.underlineId), n?.isSplitPart && (t.isSplitPart = n.isSplitPart), t;
1660
1669
  })), e.filter((e) => e.renderedRegions.some((e) => {
1661
1670
  let n = e.meta?.blockId || e.meta?.topicId || "";
1662
- return n && Le(n) === t;
1671
+ return n && Re(n) === t;
1663
1672
  })).length > 1 && (f.isCrossPage = !0), s.questions.push(f);
1664
1673
  }
1665
1674
  return s;
@@ -1671,7 +1680,12 @@ var et = ",。、;:?!…)】》'\"'\"…·", tt = "(【《'\"'\"";
1671
1680
  function nt(e, t) {
1672
1681
  let n = t, r = t * .5;
1673
1682
  for (let t of e) if (t.type === "formula") {
1674
- let e = t, i = e.svgContent.match(/vertical-align:\s*([-\d.]+)ex/), a = i ? parseFloat(i[1]) * 7 : -(e.height || 20), o = e.height || 20, s = r + a + o;
1683
+ let e = t, i = e.svgContent.match(/vertical-align:\s*([-\d.]+)(px|ex)/), a;
1684
+ if (i) {
1685
+ let e = parseFloat(i[1]);
1686
+ a = i[2] === "ex" ? e * 7 : e;
1687
+ } else a = -(e.height || 20);
1688
+ let o = e.height || 20, s = r + a + o;
1675
1689
  s > n && (n = s);
1676
1690
  let c = r + a;
1677
1691
  c < 0 && (n = Math.max(n, s - c));
@@ -1784,7 +1798,7 @@ function ot(e) {
1784
1798
  case "text": {
1785
1799
  let t = e;
1786
1800
  if (!t.text) return null;
1787
- let n = t.props.fontSize || 14, r = t.props.fontFamily || t.props.runfonts?.eastAsia || "SimSun", i = t.props.bold === "bold", a = t.props.italic === "italic", o = V(t.text, n, r, i, a), s = o.length > 0 ? o[o.length - 1] + B(t.text[t.text.length - 1], n, r, i, a) : 0, c = {
1801
+ let n = t.props.fontSize || 14, r = t.props.fontFamily || t.props.runfonts?.eastAsia || "SimSun", i = t.props.bold === "bold", a = t.props.italic === "italic", o = B(t.text, n, r, i, a), s = o.length > 0 ? o[o.length - 1] + z(t.text[t.text.length - 1], n, r, i, a) : 0, c = {
1788
1802
  type: "text",
1789
1803
  value: t.text,
1790
1804
  fontFamily: r,
@@ -1993,11 +2007,11 @@ function ft(e) {
1993
2007
  right: 56,
1994
2008
  bottom: 50,
1995
2009
  left: 56
1996
- }, i = P(n.type), a = {
2010
+ }, i = N(n.type), a = {
1997
2011
  paperSize: i.size,
1998
2012
  columns: i.columns,
1999
- fontSize: n.fontSize ?? 14,
2000
- lineSpacing: n.lineSpacing ?? 1.5,
2013
+ fontSize: n.fontSize ?? 16,
2014
+ lineSpacing: n.lineSpacing ?? 1,
2001
2015
  margins: [
2002
2016
  r.top ?? 50,
2003
2017
  r.right ?? 56,
@@ -2325,7 +2339,7 @@ function gt(e) {
2325
2339
  //#region src/utils/questionHtmlParser.ts
2326
2340
  var _t = 0, vt = 0, yt = 0, bt = .5;
2327
2341
  function xt(e, t = {}) {
2328
- 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
+ let { questionNo: n = "", score: r = "", contentWidth: i = 600, fontSize: a = 16, lineSpacing: o = 1, 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([
2329
2343
  "p",
2330
2344
  "h1",
2331
2345
  "h2",
@@ -2343,7 +2357,7 @@ function xt(e, t = {}) {
2343
2357
  if (t.nodeType !== Node.ELEMENT_NODE) continue;
2344
2358
  let n = t, r = n.tagName.toLowerCase();
2345
2359
  if (r === "table") {
2346
- let e = jt(n, i, d), t = e.reduce((e, t) => e + t.lineHeight, 0) + 4;
2360
+ let e = Mt(n, i, d), t = e.reduce((e, t) => e + t.lineHeight, 0) + 4;
2347
2361
  u.push({
2348
2362
  lines: e,
2349
2363
  y: 0,
@@ -2354,7 +2368,7 @@ function xt(e, t = {}) {
2354
2368
  if (r === "figure") {
2355
2369
  let e = n.querySelector("table");
2356
2370
  if (e) {
2357
- let t = jt(e, i, d), n = t.reduce((e, t) => e + t.lineHeight, 0) + 4;
2371
+ let t = Mt(e, i, d), n = t.reduce((e, t) => e + t.lineHeight, 0) + 4;
2358
2372
  u.push({
2359
2373
  lines: t,
2360
2374
  y: 0,
@@ -2364,14 +2378,31 @@ function xt(e, t = {}) {
2364
2378
  continue;
2365
2379
  }
2366
2380
  if (!p.has(r)) continue;
2381
+ if (r === "div") {
2382
+ let e = Array.from(n.children).filter((e) => e.tagName.toLowerCase() === "p");
2383
+ if (e.length > 0) {
2384
+ for (let t of e) {
2385
+ let e = t.getAttribute("style") || "", n = Y(t, a, e, i, f);
2386
+ if (n.length === 0) continue;
2387
+ let r = rt(n, i, d), o = r.reduce((e, t) => e + t.lineHeight, 0) + 4;
2388
+ u.push({
2389
+ lines: r,
2390
+ y: 0,
2391
+ height: o,
2392
+ justification: Ct(n, e)
2393
+ });
2394
+ }
2395
+ continue;
2396
+ }
2397
+ }
2367
2398
  let o = n, s = o.getAttribute("style") || "", c = Y(o, a, s, i, f);
2368
2399
  if (c.length === 0) continue;
2369
- let m = rt(c, i, d), h = m.reduce((e, t) => e + t.lineHeight, 0) + 4, g = wt(s), _ = g === "center" ? "center" : g === "right" ? "right" : void 0;
2400
+ let m = rt(c, i, d), h = m.reduce((e, t) => e + t.lineHeight, 0) + 4;
2370
2401
  u.push({
2371
2402
  lines: m,
2372
2403
  y: 0,
2373
2404
  height: h,
2374
- justification: _
2405
+ justification: Ct(c, s)
2375
2406
  });
2376
2407
  }
2377
2408
  if (!s) for (let e = 0; e < 2; e++) u.push({
@@ -2414,13 +2445,13 @@ function Y(e, t, n, r, i) {
2414
2445
  let r = e.replace(/\u00A0/g, " ").replace(/\n/g, "").replace(/\s+/g, " ");
2415
2446
  if (!r.trim()) {
2416
2447
  if (a.length > 0) {
2417
- let e = Tt(n) || t, r = Et(n) || "\"Times New Roman\", SimSun", i = Dt(n) || "#000", o = /font-style:\s*(italic|oblique)/.test(n);
2418
- a.push(Ct("\xA0", e, r, !1, i, o));
2448
+ let e = Et(n) || t, r = Dt(n) || "\"Times New Roman\", SimSun", i = Ot(n) || "#000", o = /font-style:\s*(italic|oblique)/.test(n);
2449
+ a.push(wt("\xA0", e, r, !1, i, o));
2419
2450
  }
2420
2451
  continue;
2421
2452
  }
2422
- 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);
2423
- a.push(Ct(l, u, d, p, f, m));
2453
+ 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);
2454
+ a.push(wt(l, u, d, p, f, m));
2424
2455
  continue;
2425
2456
  }
2426
2457
  if (s.nodeType !== Node.ELEMENT_NODE) continue;
@@ -2491,7 +2522,7 @@ function Y(e, t, n, r, i) {
2491
2522
  if (l === "span" && d.includes("under-point")) {
2492
2523
  let e = c.textContent || "";
2493
2524
  if (e.trim()) {
2494
- 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);
2525
+ 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);
2495
2526
  c.dotAbove = !0, a.push(c);
2496
2527
  }
2497
2528
  continue;
@@ -2499,7 +2530,7 @@ function Y(e, t, n, r, i) {
2499
2530
  if (l === "span" && d.includes("wavy-line")) {
2500
2531
  let e = c.textContent || "";
2501
2532
  if (e.trim()) {
2502
- 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);
2533
+ 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);
2503
2534
  c.wavyLine = !0, a.push(c);
2504
2535
  }
2505
2536
  continue;
@@ -2584,12 +2615,21 @@ function Y(e, t, n, r, i) {
2584
2615
  }
2585
2616
  let f = u.match(/background-color:\s*([^;]+)/);
2586
2617
  if (f && f[1] && f[1] !== "transparent") {
2587
- let e = At(f[1]);
2618
+ let e = jt(f[1]);
2588
2619
  if (e) for (let t of l) t.type === "text" && (t.backgroundColor = e);
2589
2620
  }
2590
2621
  a.push(...l);
2591
2622
  continue;
2592
2623
  }
2624
+ if (l === "p") {
2625
+ let e = Y(c, t, u || n, r, i);
2626
+ if (e.length > 0 && e.every((e) => e.type === "image" && !e.rawHtml)) for (let t of e) {
2627
+ let e = t, n = e.height / e.width || .6;
2628
+ e.width = r, e.height = Math.round(r * n);
2629
+ }
2630
+ a.push(...e);
2631
+ continue;
2632
+ }
2593
2633
  let p = Y(c, t, u || n, r, i);
2594
2634
  a.push(...p);
2595
2635
  }
@@ -2607,8 +2647,13 @@ function St(e) {
2607
2647
  isEmpty: !1
2608
2648
  } : null;
2609
2649
  }
2610
- function Ct(e, t, n, r, i, a) {
2611
- let o = e.split(""), s = V(e, t, n, r, a || !1), c = s.length > 0 ? s[s.length - 1] + B(o[o.length - 1], t, n, r, a || !1) : 0;
2650
+ function Ct(e, t) {
2651
+ if (e.length > 0 && e.every((e) => e.type === "image" && !e.rawHtml)) return "right";
2652
+ let n = Tt(t);
2653
+ return n === "center" ? "center" : n === "right" ? "right" : void 0;
2654
+ }
2655
+ function wt(e, t, n, r, i, a) {
2656
+ 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;
2612
2657
  return {
2613
2658
  type: "text",
2614
2659
  value: e,
@@ -2622,19 +2667,19 @@ function Ct(e, t, n, r, i, a) {
2622
2667
  xPositions: s
2623
2668
  };
2624
2669
  }
2625
- function wt(e) {
2670
+ function Tt(e) {
2626
2671
  let t = e.match(/text-align:\s*(right|center|left)/);
2627
2672
  return t ? t[1] : "left";
2628
2673
  }
2629
- function Tt(e) {
2674
+ function Et(e) {
2630
2675
  let t = e.match(/font-size:\s*(\d+)px/);
2631
2676
  return t ? parseInt(t[1]) : null;
2632
2677
  }
2633
- function Et(e) {
2678
+ function Dt(e) {
2634
2679
  let t = e.match(/font-family:\s*([^;]+)/);
2635
2680
  return t ? t[1].trim().replace(/["']/g, "") : null;
2636
2681
  }
2637
- function Dt(e) {
2682
+ function Ot(e) {
2638
2683
  let t = e.match(/color:\s*rgb\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)/);
2639
2684
  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")}`;
2640
2685
  let n = e.match(/color:\s*rgba\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,[^)]+\)/);
@@ -2642,9 +2687,9 @@ function Dt(e) {
2642
2687
  let r = e.match(/color:\s*(#[0-9a-fA-F]{3,6})/);
2643
2688
  if (r) return r[1];
2644
2689
  let i = e.match(/color:\s*([a-zA-Z]+)/);
2645
- return i && kt(i[1]) || null;
2690
+ return i && At(i[1]) || null;
2646
2691
  }
2647
- var Ot = {
2692
+ var kt = {
2648
2693
  red: "#ff0000",
2649
2694
  green: "#008000",
2650
2695
  blue: "#0000ff",
@@ -2671,16 +2716,16 @@ var Ot = {
2671
2716
  lightgrey: "#d3d3d3",
2672
2717
  transparent: "#000000"
2673
2718
  };
2674
- function kt(e) {
2675
- return Ot[e.toLowerCase()];
2676
- }
2677
2719
  function At(e) {
2720
+ return kt[e.toLowerCase()];
2721
+ }
2722
+ function jt(e) {
2678
2723
  let t = e.trim(), n = t.match(/^#[0-9a-fA-F]{3,6}$/);
2679
2724
  if (n) return n[0];
2680
2725
  let r = t.match(/^rgb\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)$/);
2681
- 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;
2726
+ 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;
2682
2727
  }
2683
- function jt(e, t, n) {
2728
+ function Mt(e, t, n) {
2684
2729
  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;
2685
2730
  return u <= 0 || d <= 0 ? [{
2686
2731
  ...nt([], n),
@@ -2699,8 +2744,26 @@ function jt(e, t, n) {
2699
2744
  }
2700
2745
  //#endregion
2701
2746
  //#region src/utils/questionJsonParser.ts
2702
- function Mt(e, t = {}) {
2703
- 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, {
2747
+ function Nt(e, t = {}) {
2748
+ let { questionNo: n = "", score: r = "", contentWidth: i = 600, fontSize: a = 16, lineSpacing: o = 1, protectContent: s = !1 } = t;
2749
+ return e.children && e.children.length > 0 ? Ft(e, {
2750
+ questionNo: n,
2751
+ score: r,
2752
+ contentWidth: i,
2753
+ fontSize: a,
2754
+ lineSpacing: o,
2755
+ protectContent: s
2756
+ }) : Pt(e, {
2757
+ questionNo: n,
2758
+ score: r,
2759
+ contentWidth: i,
2760
+ fontSize: a,
2761
+ lineSpacing: o,
2762
+ protectContent: s
2763
+ });
2764
+ }
2765
+ function Pt(e, t) {
2766
+ let { questionNo: n, score: r, contentWidth: i, fontSize: a, lineSpacing: o, protectContent: s } = 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, {
2704
2767
  questionNo: n,
2705
2768
  score: r,
2706
2769
  contentWidth: i,
@@ -2727,11 +2790,66 @@ function Mt(e, t = {}) {
2727
2790
  tags: e.tags
2728
2791
  }
2729
2792
  };
2730
- 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));
2731
- else for (let e = 0; e < 2; e++) p.paragraphs.push(Pt(u));
2793
+ if (l && e.extra_json?.options && e.extra_json.options.length > 0) p.options = It(e.extra_json.options, i, a, o), p.paragraphs.push(Lt(u));
2794
+ else for (let e = 0; e < 2; e++) p.paragraphs.push(Lt(u));
2732
2795
  return p.height = p.paragraphs.reduce((e, t) => e + (t.height || 26), 0), [p];
2733
2796
  }
2734
- function Nt(e, t, n, r) {
2797
+ function Ft(e, t) {
2798
+ let { questionNo: n, score: r, contentWidth: i, fontSize: a, lineSpacing: o, protectContent: s } = t, c = "answer_question", l = Math.round(a * o * 1.67), u = Date.now(), d = Math.random().toString(36).slice(2, 8), f = e.id ? `group-${e.id}-${u}-${d}` : `group-${e.qid || u}-${d}`, p = Math.max(100, i - 26.25), m = [], h = xt(e.question, {
2799
+ questionNo: n,
2800
+ score: r || "",
2801
+ contentWidth: i,
2802
+ fontSize: a,
2803
+ lineSpacing: o,
2804
+ skipAnswerArea: !0,
2805
+ protectContent: s
2806
+ });
2807
+ if (h.length > 0) {
2808
+ let t = h[0];
2809
+ t.type = "question", t.metadata = {
2810
+ ...t.metadata,
2811
+ qid: e.qid,
2812
+ questType: c,
2813
+ answer: e.extra_json?.answer || e.answer || "",
2814
+ tenantId: e.tenant_id,
2815
+ tags: e.tags,
2816
+ blockGroup: f,
2817
+ hasSubQuestions: !0,
2818
+ score: r || ""
2819
+ }, t.keepNext = !0;
2820
+ for (let e = 0; e < 2; e++) t.paragraphs.push(Lt(l));
2821
+ t.height = t.paragraphs.reduce((e, t) => e + (t.height || 26), 0), m.push(t);
2822
+ }
2823
+ if (e.children) for (let t = 0; t < e.children.length; t++) {
2824
+ let n = e.children[t], r = `(${t + 1})`, i = xt(n.question, {
2825
+ contentWidth: p,
2826
+ fontSize: a,
2827
+ lineSpacing: o,
2828
+ skipAnswerArea: !0,
2829
+ protectContent: s
2830
+ });
2831
+ if (i.length === 0) continue;
2832
+ let u = i[0];
2833
+ u.type = "sub-question", u.metadata = {
2834
+ ...u.metadata,
2835
+ questionNo: "",
2836
+ subLabel: r,
2837
+ label: `子题${r}`,
2838
+ topicId: `${f}-sub${t + 1}`,
2839
+ blockGroup: f,
2840
+ qid: n.qid,
2841
+ answer: n.answer || n.extra_json?.answer || "",
2842
+ questType: c,
2843
+ tenantId: n.tenant_id,
2844
+ tags: n.tags,
2845
+ score: ""
2846
+ };
2847
+ for (let e = 0; e < 2; e++) u.paragraphs.push(Lt(l));
2848
+ u.height = u.paragraphs.reduce((e, t) => e + (t.height || 26), 0), m.push(u);
2849
+ }
2850
+ return m;
2851
+ }
2852
+ function It(e, t, n, r) {
2735
2853
  let i = Math.max(100, t - 20);
2736
2854
  return e.map((e) => {
2737
2855
  let t = xt(e.content, {
@@ -2760,7 +2878,7 @@ function Nt(e, t, n, r) {
2760
2878
  };
2761
2879
  });
2762
2880
  }
2763
- function Pt(e) {
2881
+ function Lt(e) {
2764
2882
  return {
2765
2883
  lines: [{
2766
2884
  elements: [{
@@ -2778,7 +2896,7 @@ function Pt(e) {
2778
2896
  }
2779
2897
  //#endregion
2780
2898
  //#region src/utils/chineseNumber.ts
2781
- var Ft = [
2899
+ var Rt = [
2782
2900
  "",
2783
2901
  "一",
2784
2902
  "二",
@@ -2791,34 +2909,34 @@ var Ft = [
2791
2909
  "九",
2792
2910
  "十"
2793
2911
  ];
2794
- function It(e) {
2912
+ function zt(e) {
2795
2913
  if (e <= 0) return "";
2796
- if (e <= 10) return Ft[e];
2914
+ if (e <= 10) return Rt[e];
2797
2915
  if (e < 20) {
2798
2916
  let t = e % 10;
2799
- return "十" + (t > 0 ? Ft[t] : "");
2917
+ return "十" + (t > 0 ? Rt[t] : "");
2800
2918
  }
2801
2919
  if (e < 100) {
2802
2920
  let t = Math.floor(e / 10), n = e % 10;
2803
- return Ft[t] + "十" + (n > 0 ? Ft[n] : "");
2921
+ return Rt[t] + "十" + (n > 0 ? Rt[n] : "");
2804
2922
  }
2805
2923
  if (e < 1e3) {
2806
- let t = Math.floor(e / 100), n = e % 100, r = Ft[t] + "百";
2807
- return n === 0 ? r : n < 10 ? r + "零" + Ft[n] : r + It(n);
2924
+ let t = Math.floor(e / 100), n = e % 100, r = Rt[t] + "百";
2925
+ return n === 0 ? r : n < 10 ? r + "零" + Rt[n] : r + zt(n);
2808
2926
  }
2809
2927
  return String(e);
2810
2928
  }
2811
- function Lt(e, t) {
2812
- let n = It(t);
2929
+ function Bt(e, t) {
2930
+ let n = zt(t);
2813
2931
  return n ? n + "、" + e : e;
2814
2932
  }
2815
- function Rt(e) {
2933
+ function Vt(e) {
2816
2934
  let t = e.match(/^[一二三四五六七八九十百零]+、(.+)$/);
2817
2935
  return t ? t[1] : e;
2818
2936
  }
2819
2937
  //#endregion
2820
2938
  //#region src/utils/paperHtmlBuilder.ts
2821
- function zt(e) {
2939
+ function Ht(e) {
2822
2940
  let t = j[e];
2823
2941
  return `
2824
2942
  /* ---------- Reset & Base ---------- */
@@ -3051,6 +3169,7 @@ text.swed-question-score {
3051
3169
  color: #000;
3052
3170
  display: flex;
3053
3171
  align-items: center;
3172
+ width: 100%;
3054
3173
  }
3055
3174
  .swed-student-code-table {
3056
3175
  border-collapse: collapse;
@@ -3065,6 +3184,13 @@ text.swed-question-score {
3065
3184
  text-align: center;
3066
3185
  font-size: 14px;
3067
3186
  }
3187
+ .swed-student-code-filler {
3188
+ height: 30px;
3189
+ border: 1px solid #000;
3190
+ margin-left: 8px;
3191
+ flex: 1;
3192
+ min-width: 20px;
3193
+ }
3068
3194
 
3069
3195
  /* ---------- foreignObject 尾部样式 ---------- */
3070
3196
  .swed-tail-time-wrapper {
@@ -3139,7 +3265,7 @@ text.swed-question-score {
3139
3265
  }
3140
3266
  `;
3141
3267
  }
3142
- function Bt(e) {
3268
+ function Ut(e) {
3143
3269
  let { svgs: t, paperName: n = "试卷", paperSize: r = "A4" } = e, i = t.map((e) => {
3144
3270
  let t = e.match(/viewBox="0 0 (\d+(?:\.\d+)?)\s+(\d+(?:\.\d+)?)"/), [, n, r] = t ? [
3145
3271
  null,
@@ -3159,20 +3285,20 @@ function Bt(e) {
3159
3285
  <head>
3160
3286
  <meta charset="UTF-8">
3161
3287
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
3162
- <title>${Vt(n)}</title>
3163
- <style>${zt(r)}</style>
3288
+ <title>${Wt(n)}</title>
3289
+ <style>${Ht(r)}</style>
3164
3290
  </head>
3165
3291
  <body>
3166
3292
  ${i}
3167
3293
  </body>
3168
3294
  </html>`;
3169
3295
  }
3170
- function Vt(e) {
3296
+ function Wt(e) {
3171
3297
  return e.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
3172
3298
  }
3173
3299
  //#endregion
3174
3300
  //#region ../node_modules/qrcode/lib/can-promise.js
3175
- var Ht = /* @__PURE__ */ D(((e, t) => {
3301
+ var Gt = /* @__PURE__ */ D(((e, t) => {
3176
3302
  t.exports = function() {
3177
3303
  return typeof Promise == "function" && Promise.prototype && Promise.prototype.then;
3178
3304
  };
@@ -3238,7 +3364,7 @@ var Ht = /* @__PURE__ */ D(((e, t) => {
3238
3364
  }, e.toSJIS = function(e) {
3239
3365
  return t(e);
3240
3366
  };
3241
- })), Ut = /* @__PURE__ */ D(((e) => {
3367
+ })), Kt = /* @__PURE__ */ D(((e) => {
3242
3368
  e.L = { bit: 1 }, e.M = { bit: 0 }, e.Q = { bit: 3 }, e.H = { bit: 2 };
3243
3369
  function t(t) {
3244
3370
  if (typeof t != "string") throw Error("Param is not a string");
@@ -3264,7 +3390,7 @@ var Ht = /* @__PURE__ */ D(((e, t) => {
3264
3390
  return r;
3265
3391
  }
3266
3392
  };
3267
- })), Wt = /* @__PURE__ */ D(((e, t) => {
3393
+ })), qt = /* @__PURE__ */ D(((e, t) => {
3268
3394
  function n() {
3269
3395
  this.buffer = [], this.length = 0;
3270
3396
  }
@@ -3284,7 +3410,7 @@ var Ht = /* @__PURE__ */ D(((e, t) => {
3284
3410
  this.buffer.length <= t && this.buffer.push(0), e && (this.buffer[t] |= 128 >>> this.length % 8), this.length++;
3285
3411
  }
3286
3412
  }, t.exports = n;
3287
- })), Gt = /* @__PURE__ */ D(((e, t) => {
3413
+ })), Jt = /* @__PURE__ */ D(((e, t) => {
3288
3414
  function n(e) {
3289
3415
  if (!e || e < 1) throw Error("BitMatrix size must be defined and greater than 0");
3290
3416
  this.size = e, this.data = new Uint8Array(e * e), this.reservedBit = new Uint8Array(e * e);
@@ -3299,7 +3425,7 @@ var Ht = /* @__PURE__ */ D(((e, t) => {
3299
3425
  }, n.prototype.isReserved = function(e, t) {
3300
3426
  return this.reservedBit[e * this.size + t];
3301
3427
  }, t.exports = n;
3302
- })), Kt = /* @__PURE__ */ D(((e) => {
3428
+ })), Yt = /* @__PURE__ */ D(((e) => {
3303
3429
  var t = X().getSymbolSize;
3304
3430
  e.getRowColCoords = function(e) {
3305
3431
  if (e === 1) return [];
@@ -3311,7 +3437,7 @@ var Ht = /* @__PURE__ */ D(((e, t) => {
3311
3437
  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]]);
3312
3438
  return n;
3313
3439
  };
3314
- })), qt = /* @__PURE__ */ D(((e) => {
3440
+ })), Xt = /* @__PURE__ */ D(((e) => {
3315
3441
  var t = X().getSymbolSize, n = 7;
3316
3442
  e.getPositions = function(e) {
3317
3443
  let r = t(e);
@@ -3321,7 +3447,7 @@ var Ht = /* @__PURE__ */ D(((e, t) => {
3321
3447
  [0, r - n]
3322
3448
  ];
3323
3449
  };
3324
- })), Jt = /* @__PURE__ */ D(((e) => {
3450
+ })), Zt = /* @__PURE__ */ D(((e) => {
3325
3451
  e.Patterns = {
3326
3452
  PATTERN000: 0,
3327
3453
  PATTERN001: 1,
@@ -3397,8 +3523,8 @@ var Ht = /* @__PURE__ */ D(((e, t) => {
3397
3523
  }
3398
3524
  return i;
3399
3525
  };
3400
- })), Yt = /* @__PURE__ */ D(((e) => {
3401
- var t = Ut(), n = [
3526
+ })), Qt = /* @__PURE__ */ D(((e) => {
3527
+ var t = Kt(), n = [
3402
3528
  1,
3403
3529
  1,
3404
3530
  1,
@@ -3738,7 +3864,7 @@ var Ht = /* @__PURE__ */ D(((e, t) => {
3738
3864
  default: return;
3739
3865
  }
3740
3866
  };
3741
- })), Xt = /* @__PURE__ */ D(((e) => {
3867
+ })), $t = /* @__PURE__ */ D(((e) => {
3742
3868
  var t = new Uint8Array(512), n = new Uint8Array(256);
3743
3869
  (function() {
3744
3870
  let e = 1;
@@ -3752,8 +3878,8 @@ var Ht = /* @__PURE__ */ D(((e, t) => {
3752
3878
  }, e.mul = function(e, r) {
3753
3879
  return e === 0 || r === 0 ? 0 : t[n[e] + n[r]];
3754
3880
  };
3755
- })), Zt = /* @__PURE__ */ D(((e) => {
3756
- var t = Xt();
3881
+ })), en = /* @__PURE__ */ D(((e) => {
3882
+ var t = $t();
3757
3883
  e.mul = function(e, n) {
3758
3884
  let r = new Uint8Array(e.length + n.length - 1);
3759
3885
  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]);
@@ -3773,8 +3899,8 @@ var Ht = /* @__PURE__ */ D(((e, t) => {
3773
3899
  for (let i = 0; i < n; i++) r = e.mul(r, new Uint8Array([1, t.exp(i)]));
3774
3900
  return r;
3775
3901
  };
3776
- })), Qt = /* @__PURE__ */ D(((e, t) => {
3777
- var n = Zt();
3902
+ })), tn = /* @__PURE__ */ D(((e, t) => {
3903
+ var n = en();
3778
3904
  function r(e) {
3779
3905
  this.genPoly = void 0, this.degree = e, this.degree && this.initialize(this.degree);
3780
3906
  }
@@ -3791,11 +3917,11 @@ var Ht = /* @__PURE__ */ D(((e, t) => {
3791
3917
  }
3792
3918
  return r;
3793
3919
  }, t.exports = r;
3794
- })), $t = /* @__PURE__ */ D(((e) => {
3920
+ })), nn = /* @__PURE__ */ D(((e) => {
3795
3921
  e.isValid = function(e) {
3796
3922
  return !isNaN(e) && e >= 1 && e <= 40;
3797
3923
  };
3798
- })), en = /* @__PURE__ */ D(((e) => {
3924
+ })), rn = /* @__PURE__ */ D(((e) => {
3799
3925
  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])+";
3800
3926
  r = r.replace(/u/g, "\\u");
3801
3927
  var i = "(?:(?![A-Z0-9 $%*+\\-./:]|" + r + ")(?:.|[\r\n]))+";
@@ -3808,8 +3934,8 @@ var Ht = /* @__PURE__ */ D(((e, t) => {
3808
3934
  }, e.testAlphanumeric = function(e) {
3809
3935
  return s.test(e);
3810
3936
  };
3811
- })), tn = /* @__PURE__ */ D(((e) => {
3812
- var t = $t(), n = en();
3937
+ })), an = /* @__PURE__ */ D(((e) => {
3938
+ var t = nn(), n = rn();
3813
3939
  e.NUMERIC = {
3814
3940
  id: "Numeric",
3815
3941
  bit: 1,
@@ -3872,8 +3998,8 @@ var Ht = /* @__PURE__ */ D(((e, t) => {
3872
3998
  return n;
3873
3999
  }
3874
4000
  };
3875
- })), nn = /* @__PURE__ */ D(((e) => {
3876
- var t = X(), n = Yt(), r = Ut(), i = tn(), a = $t(), o = 7973, s = t.getBCHDigit(o);
4001
+ })), on = /* @__PURE__ */ D(((e) => {
4002
+ var t = X(), n = Qt(), r = Kt(), i = an(), a = nn(), o = 7973, s = t.getBCHDigit(o);
3877
4003
  function c(t, n, r) {
3878
4004
  for (let i = 1; i <= 40; i++) if (n <= e.getCapacity(i, r, t)) return i;
3879
4005
  }
@@ -3919,15 +4045,15 @@ var Ht = /* @__PURE__ */ D(((e, t) => {
3919
4045
  for (; t.getBCHDigit(n) - s >= 0;) n ^= o << t.getBCHDigit(n) - s;
3920
4046
  return e << 12 | n;
3921
4047
  };
3922
- })), rn = /* @__PURE__ */ D(((e) => {
4048
+ })), sn = /* @__PURE__ */ D(((e) => {
3923
4049
  var t = X(), n = 1335, r = 21522, i = t.getBCHDigit(n);
3924
4050
  e.getEncodedBits = function(e, a) {
3925
4051
  let o = e.bit << 3 | a, s = o << 10;
3926
4052
  for (; t.getBCHDigit(s) - i >= 0;) s ^= n << t.getBCHDigit(s) - i;
3927
4053
  return (o << 10 | s) ^ r;
3928
4054
  };
3929
- })), an = /* @__PURE__ */ D(((e, t) => {
3930
- var n = tn();
4055
+ })), cn = /* @__PURE__ */ D(((e, t) => {
4056
+ var n = an();
3931
4057
  function r(e) {
3932
4058
  this.mode = n.NUMERIC, this.data = e.toString();
3933
4059
  }
@@ -3943,8 +4069,8 @@ var Ht = /* @__PURE__ */ D(((e, t) => {
3943
4069
  let i = this.data.length - t;
3944
4070
  i > 0 && (n = this.data.substr(t), r = parseInt(n, 10), e.put(r, i * 3 + 1));
3945
4071
  }, t.exports = r;
3946
- })), on = /* @__PURE__ */ D(((e, t) => {
3947
- var n = tn(), r = /* @__PURE__ */ "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:".split("");
4072
+ })), ln = /* @__PURE__ */ D(((e, t) => {
4073
+ var n = an(), r = /* @__PURE__ */ "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:".split("");
3948
4074
  function i(e) {
3949
4075
  this.mode = n.ALPHANUMERIC, this.data = e;
3950
4076
  }
@@ -3962,8 +4088,8 @@ var Ht = /* @__PURE__ */ D(((e, t) => {
3962
4088
  }
3963
4089
  this.data.length % 2 && e.put(r.indexOf(this.data[t]), 6);
3964
4090
  }, t.exports = i;
3965
- })), sn = /* @__PURE__ */ D(((e, t) => {
3966
- var n = tn();
4091
+ })), un = /* @__PURE__ */ D(((e, t) => {
4092
+ var n = an();
3967
4093
  function r(e) {
3968
4094
  this.mode = n.BYTE, typeof e == "string" ? this.data = new TextEncoder().encode(e) : this.data = new Uint8Array(e);
3969
4095
  }
@@ -3976,8 +4102,8 @@ var Ht = /* @__PURE__ */ D(((e, t) => {
3976
4102
  }, r.prototype.write = function(e) {
3977
4103
  for (let t = 0, n = this.data.length; t < n; t++) e.put(this.data[t], 8);
3978
4104
  }, t.exports = r;
3979
- })), cn = /* @__PURE__ */ D(((e, t) => {
3980
- var n = tn(), r = X();
4105
+ })), dn = /* @__PURE__ */ D(((e, t) => {
4106
+ var n = an(), r = X();
3981
4107
  function i(e) {
3982
4108
  this.mode = n.KANJI, this.data = e;
3983
4109
  }
@@ -3997,7 +4123,7 @@ var Ht = /* @__PURE__ */ D(((e, t) => {
3997
4123
  n = (n >>> 8 & 255) * 192 + (n & 255), e.put(n, 13);
3998
4124
  }
3999
4125
  }, t.exports = i;
4000
- })), ln = /* @__PURE__ */ D(((e, t) => {
4126
+ })), fn = /* @__PURE__ */ D(((e, t) => {
4001
4127
  var n = {
4002
4128
  single_source_shortest_paths: function(e, t, r) {
4003
4129
  var i = {}, a = {};
@@ -4050,8 +4176,8 @@ var Ht = /* @__PURE__ */ D(((e, t) => {
4050
4176
  }
4051
4177
  };
4052
4178
  t !== void 0 && (t.exports = n);
4053
- })), un = /* @__PURE__ */ D(((e) => {
4054
- var t = tn(), n = an(), r = on(), i = sn(), a = cn(), o = en(), s = X(), c = ln();
4179
+ })), pn = /* @__PURE__ */ D(((e) => {
4180
+ var t = an(), n = cn(), r = ln(), i = un(), a = dn(), o = rn(), s = X(), c = fn();
4055
4181
  function l(e) {
4056
4182
  return unescape(encodeURIComponent(e)).length;
4057
4183
  }
@@ -4178,8 +4304,8 @@ var Ht = /* @__PURE__ */ D(((e, t) => {
4178
4304
  }, e.rawSplit = function(t) {
4179
4305
  return e.fromArray(d(t, s.isKanjiModeEnabled()));
4180
4306
  };
4181
- })), dn = /* @__PURE__ */ D(((e) => {
4182
- var t = X(), n = Ut(), r = Wt(), i = Gt(), a = Kt(), o = qt(), s = Jt(), c = Yt(), l = Qt(), u = nn(), d = rn(), f = tn(), p = un();
4307
+ })), mn = /* @__PURE__ */ D(((e) => {
4308
+ var t = X(), n = Kt(), r = qt(), i = Jt(), a = Yt(), o = Xt(), s = Zt(), c = Qt(), l = tn(), u = on(), d = sn(), f = an(), p = pn();
4183
4309
  function m(e, t) {
4184
4310
  let n = e.size, r = o.getPositions(t);
4185
4311
  for (let t = 0; t < r.length; t++) {
@@ -4274,7 +4400,7 @@ var Ht = /* @__PURE__ */ D(((e, t) => {
4274
4400
  let i = n.M, a, o;
4275
4401
  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);
4276
4402
  };
4277
- })), fn = /* @__PURE__ */ D(((e) => {
4403
+ })), hn = /* @__PURE__ */ D(((e) => {
4278
4404
  function t(e) {
4279
4405
  if (typeof e == "number" && (e = e.toString()), typeof e != "string") throw Error("Color should be defined as hex string");
4280
4406
  let t = e.slice().replace("#", "").split("");
@@ -4321,8 +4447,8 @@ var Ht = /* @__PURE__ */ D(((e, t) => {
4321
4447
  t[u++] = d.r, t[u++] = d.g, t[u++] = d.b, t[u] = d.a;
4322
4448
  }
4323
4449
  };
4324
- })), pn = /* @__PURE__ */ D(((e) => {
4325
- var t = fn();
4450
+ })), gn = /* @__PURE__ */ D(((e) => {
4451
+ var t = hn();
4326
4452
  function n(e, t, n) {
4327
4453
  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";
4328
4454
  }
@@ -4344,8 +4470,8 @@ var Ht = /* @__PURE__ */ D(((e, t) => {
4344
4470
  let a = e.render(t, n, i), o = i.type || "image/png", s = i.rendererOpts || {};
4345
4471
  return a.toDataURL(o, s.quality);
4346
4472
  };
4347
- })), mn = /* @__PURE__ */ D(((e) => {
4348
- var t = fn();
4473
+ })), _n = /* @__PURE__ */ D(((e) => {
4474
+ var t = hn();
4349
4475
  function n(e, t) {
4350
4476
  let n = e.a / 255, r = t + "=\"" + e.hex + "\"";
4351
4477
  return n < 1 ? r + " " + t + "-opacity=\"" + n.toFixed(2).slice(1) + "\"" : r;
@@ -4366,8 +4492,8 @@ var Ht = /* @__PURE__ */ D(((e, t) => {
4366
4492
  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";
4367
4493
  return typeof a == "function" && a(null, p), p;
4368
4494
  };
4369
- })), hn = /* @__PURE__ */ k((/* @__PURE__ */ D(((e) => {
4370
- var t = Ht(), n = dn(), r = pn(), i = mn();
4495
+ })), vn = /* @__PURE__ */ k((/* @__PURE__ */ D(((e) => {
4496
+ var t = Gt(), n = mn(), r = gn(), i = _n();
4371
4497
  function a(e, r, i, a, o) {
4372
4498
  let s = [].slice.call(arguments, 1), c = s.length, l = typeof s[c - 1] == "function";
4373
4499
  if (!l && !t()) throw Error("Callback required as last argument");
@@ -4395,10 +4521,10 @@ var Ht = /* @__PURE__ */ D(((e, t) => {
4395
4521
  return i.render(e, n);
4396
4522
  });
4397
4523
  })))(), 1);
4398
- async function gn(e, t = 200) {
4524
+ async function yn(e, t = 200) {
4399
4525
  if (!e || e.trim() === "") return "";
4400
4526
  try {
4401
- return await hn.toDataURL(e, {
4527
+ return await vn.toDataURL(e, {
4402
4528
  width: t,
4403
4529
  margin: 1,
4404
4530
  color: {
@@ -4413,13 +4539,13 @@ async function gn(e, t = 200) {
4413
4539
  }
4414
4540
  //#endregion
4415
4541
  //#region src/composables/usePaperSelection.ts
4416
- function _n(e) {
4542
+ function bn(e) {
4417
4543
  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);
4418
4544
  function c(e) {
4419
- n.value = e, e && (r.value = null);
4545
+ n.value = e, e && (r.value = null, i.value = null);
4420
4546
  }
4421
4547
  function l(e) {
4422
- r.value = e, e && (n.value = null);
4548
+ r.value = e, e && (n.value = null, i.value = null);
4423
4549
  }
4424
4550
  function u(e) {
4425
4551
  i.value = e, e && (n.value = null, r.value = null);
@@ -4478,7 +4604,7 @@ function _n(e) {
4478
4604
  }
4479
4605
  //#endregion
4480
4606
  //#region src/composables/paperHelpers.ts
4481
- var vn = {
4607
+ var xn = {
4482
4608
  三号: 21,
4483
4609
  小三: 20,
4484
4610
  四号: 19,
@@ -4486,24 +4612,24 @@ var vn = {
4486
4612
  五号: 14,
4487
4613
  小五: 12
4488
4614
  };
4489
- function yn(e) {
4490
- return vn[e] ?? 14;
4615
+ function Sn(e) {
4616
+ return xn[e] ?? 16;
4491
4617
  }
4492
- function bn(e) {
4493
- for (let [t, n] of Object.entries(vn)) if (n === e) return t;
4618
+ function Cn(e) {
4619
+ for (let [t, n] of Object.entries(xn)) if (n === e) return t;
4494
4620
  return "五号";
4495
4621
  }
4496
4622
  function Z(e) {
4497
- return typeof e.fontSize == "number" ? e.fontSize : yn(e.fontSize || "五号");
4623
+ return typeof e.fontSize == "number" ? e.fontSize : Sn(e.fontSize || "小四");
4498
4624
  }
4499
4625
  function Q(e) {
4500
- return e.lineSpacing ?? 1.5;
4626
+ return e.lineSpacing ?? 1;
4501
4627
  }
4502
- function xn(e, t) {
4628
+ function wn(e, t) {
4503
4629
  return Math.round(e * t * 35 / (14 * 1.5));
4504
4630
  }
4505
4631
  function $(e, t) {
4506
- let n = xn(e, t);
4632
+ let n = wn(e, t);
4507
4633
  return {
4508
4634
  lines: [{
4509
4635
  elements: [{
@@ -4519,15 +4645,15 @@ function $(e, t) {
4519
4645
  height: n
4520
4646
  };
4521
4647
  }
4522
- function Sn(e, t, n, r, i = 0) {
4523
- let a = xn(t, n), o = r && r > 0 ? rt(e, r, a, i) : [nt(e, a)];
4648
+ function Tn(e, t, n, r, i = 0) {
4649
+ let a = wn(t, n), o = r && r > 0 ? rt(e, r, a, i) : [nt(e, a)];
4524
4650
  return {
4525
4651
  lines: o,
4526
4652
  y: 0,
4527
4653
  height: o.reduce((e, t) => e + t.lineHeight, 0) + 4
4528
4654
  };
4529
4655
  }
4530
- function Cn(e) {
4656
+ function En(e) {
4531
4657
  let t = e.paragraphs.length;
4532
4658
  for (; t > 0;) {
4533
4659
  let n = e.paragraphs[t - 1];
@@ -4536,14 +4662,14 @@ function Cn(e) {
4536
4662
  }
4537
4663
  return t;
4538
4664
  }
4539
- var wn = 0, Tn = 0;
4540
- function En(e) {
4665
+ var Dn = 0, On = 0;
4666
+ function kn(e) {
4541
4667
  return e.type === "question" ? (e.metadata?.questionNo || "").length > 2 ? 26.25 : 17.5 : e.type === "sub-question" ? 26.25 : 0;
4542
4668
  }
4543
- function Dn(e, t) {
4544
- return t - En(e);
4669
+ function An(e, t) {
4670
+ return t - kn(e);
4545
4671
  }
4546
- function On(e) {
4672
+ function jn(e) {
4547
4673
  let t = [], n = 0;
4548
4674
  for (; n < e.length;) {
4549
4675
  if (e[n] === "\\" && e.substring(n, n + 2) === "\\(") {
@@ -4574,9 +4700,9 @@ function On(e) {
4574
4700
  }
4575
4701
  return t;
4576
4702
  }
4577
- function kn(e, t) {
4578
- let n = [], r = On(e);
4579
- for (let e of r) if (e.type === "text") n.push(An(e.value, t, !1, "\"Times New Roman\", SimSun,'Cambria Math'", "#000"));
4703
+ function Mn(e, t) {
4704
+ let n = [], r = jn(e);
4705
+ for (let e of r) if (e.type === "text") n.push(Nn(e.value, t, !1, "\"Times New Roman\", SimSun,'Cambria Math'", "#000"));
4580
4706
  else if (e.type === "formula") {
4581
4707
  let { svg: t, width: r, height: i } = K(e.value);
4582
4708
  n.push({
@@ -4588,7 +4714,7 @@ function kn(e, t) {
4588
4714
  });
4589
4715
  } else e.type === "blank" && n.push({
4590
4716
  type: "underline",
4591
- id: `ul-${++Tn}`,
4717
+ id: `ul-${++On}`,
4592
4718
  width: 80,
4593
4719
  height: 20,
4594
4720
  placeholder: "空",
@@ -4597,8 +4723,8 @@ function kn(e, t) {
4597
4723
  });
4598
4724
  return n;
4599
4725
  }
4600
- function An(e, t, n, r, i) {
4601
- let a = e.split(""), o = V(e, t, r);
4726
+ function Nn(e, t, n, r, i) {
4727
+ let a = e.split(""), o = B(e, t, r);
4602
4728
  return {
4603
4729
  type: "text",
4604
4730
  value: e,
@@ -4607,19 +4733,19 @@ function An(e, t, n, r, i) {
4607
4733
  bold: n,
4608
4734
  italic: !1,
4609
4735
  color: i,
4610
- width: o.length > 0 ? o[o.length - 1] + B(a[a.length - 1], t, r) : 0,
4736
+ width: o.length > 0 ? o[o.length - 1] + z(a[a.length - 1], t, r) : 0,
4611
4737
  height: t * 1.4,
4612
4738
  xPositions: o
4613
4739
  };
4614
4740
  }
4615
- function jn(e, t, n, r, i, a, o = !1) {
4741
+ function Pn(e, t, n, r, i, a, o = !1) {
4616
4742
  let s = [];
4617
4743
  for (let e = 0; e < n.length; e++) {
4618
- let t = kn(n[e], r);
4619
- s.push(Sn(t, r, i, a && a > 0 ? a : void 0));
4744
+ let t = Mn(n[e], r);
4745
+ s.push(Tn(t, r, i, a && a > 0 ? a : void 0));
4620
4746
  }
4621
4747
  for (let e = 0; e < 2; e++) s.push($(r, i));
4622
- let c = s.reduce((e, t) => e + (t.height || 26), 0), l = `topic-${e.replace(".", "")}-${++wn}`;
4748
+ let c = s.reduce((e, t) => e + (t.height || 26), 0), l = `topic-${e.replace(".", "")}-${++Dn}`;
4623
4749
  return {
4624
4750
  id: `q-${e.replace(".", "")}-${Date.now()}-${Math.random().toString(36).slice(2, 6)}`,
4625
4751
  type: "question",
@@ -4635,10 +4761,10 @@ function jn(e, t, n, r, i, a, o = !1) {
4635
4761
  }
4636
4762
  };
4637
4763
  }
4638
- function Mn(e, t, n, r, i, a, o = !1) {
4639
- let s = [], c = `group-${e.replace(".", "")}`, l = [], u = 0, d = (n, u) => {
4764
+ function Fn(e, t, n, r, i, a, o = !1) {
4765
+ let s = [], c = `group-${e.replace(".", "")}-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`, l = [], u = 0, d = (n, u) => {
4640
4766
  if (l.length === 0) return;
4641
- let d = l.map((e) => Sn(kn(e, r), r, i, a && a > 0 ? a : void 0));
4767
+ let d = l.map((e) => Tn(Mn(e, r), r, i, a && a > 0 ? a : void 0));
4642
4768
  if (!n) for (let e = 0; e < 2; e++) d.push($(r, i));
4643
4769
  let f = d.reduce((e, t) => e + (t.height || 26), 0), p = `${c}-${n ? "header" : `sub${u}`}`;
4644
4770
  s.push({
@@ -4664,7 +4790,7 @@ function Mn(e, t, n, r, i, a, o = !1) {
4664
4790
  }
4665
4791
  return d(s.length === 0, u), s;
4666
4792
  }
4667
- function Nn(e) {
4793
+ function In(e) {
4668
4794
  let t = [];
4669
4795
  for (let n of e.paragraphs) {
4670
4796
  if (n.lines.length > 0 && n.lines.every((e) => e.elements.length > 0 && e.elements.every((e) => e.type === "enter"))) continue;
@@ -4678,18 +4804,24 @@ function Nn(e) {
4678
4804
  }
4679
4805
  return t.join("\n");
4680
4806
  }
4681
- function Pn(e) {
4807
+ function Ln(e) {
4682
4808
  return e.metadata?.questionNo ? `第${e.metadata.questionNo.replace(".", "")}题` : e.metadata?.subLabel ? e.metadata.subLabel : e.metadata?.label || e.id;
4683
4809
  }
4684
4810
  //#endregion
4685
4811
  //#region src/composables/usePaperBlockOps.ts
4686
- function Fn(e) {
4687
- 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;
4688
- function g() {
4812
+ function Rn(e) {
4813
+ let { blocks: t, settings: n, pages: r, isDirty: i, layoutEngine: a, svgRenderer: o, paperName: s, schoolName: c, qrCodeContent: l, qrCodeImage: u, totalScore: d, selectedBlockId: p, findInlineImageById: m, findUnderlineById: h, relayout: g } = e, _ = [], v = f(!1), y = !1;
4814
+ function b() {
4815
+ y || (_.push(H()), v.value = !0, i.value = !0);
4816
+ }
4817
+ function x() {
4818
+ _.length !== 0 && (y = !0, ue(_.pop()), y = !1, v.value = _.length > 0);
4819
+ }
4820
+ function S() {
4689
4821
  let e = Z(n.value), r = Q(n.value), s = a.value.columnWidth;
4690
4822
  s <= 0 || (t.value = t.value.map((t) => {
4691
4823
  if (!t.paragraphs || t.paragraphs.length === 0) return t;
4692
- let n = Dn(t, s), i = [], a = !1;
4824
+ let n = An(t, s), i = [], a = !1;
4693
4825
  for (let o = 0; o < t.paragraphs.length; o++) {
4694
4826
  let s = t.paragraphs[o];
4695
4827
  if (s.lines.length > 0 && s.lines.every((e) => e.elements.length > 0 && e.elements.every((e) => e.type === "enter"))) {
@@ -4697,21 +4829,21 @@ function Fn(e) {
4697
4829
  continue;
4698
4830
  }
4699
4831
  let c = [];
4700
- for (let e of s.lines) for (let t of e.elements) if (t.type === "text") {
4701
- let e = t, n = e.value.split("");
4702
- for (let t = 0; t < n.length; t++) {
4703
- let r = In(n[t], e.fontSize, e.fontFamily, e.bold, e.italic);
4832
+ for (let t of s.lines) for (let n of t.elements) if (n.type === "text") {
4833
+ let t = n, r = t.value.split("");
4834
+ for (let n = 0; n < r.length; n++) {
4835
+ let i = zn(r[n], e, t.fontFamily, t.bold, t.italic);
4704
4836
  c.push({
4705
- ...e,
4706
- value: n[t],
4707
- fontSize: e.fontSize,
4708
- width: r,
4709
- height: e.fontSize * 1.4,
4837
+ ...t,
4838
+ value: r[n],
4839
+ fontSize: e,
4840
+ width: i,
4841
+ height: e * 1.4,
4710
4842
  xPositions: [0]
4711
4843
  });
4712
4844
  }
4713
- } else if (t.type === "underline") {
4714
- let e = t;
4845
+ } else if (n.type === "underline") {
4846
+ let e = n;
4715
4847
  if (e.id) {
4716
4848
  let t = c.find((t) => t.type === "underline" && t.id === e.id);
4717
4849
  if (t) t.width += e.width;
@@ -4719,23 +4851,23 @@ function Fn(e) {
4719
4851
  let t = { ...e };
4720
4852
  delete t.isSplitPart, c.push(t);
4721
4853
  }
4722
- } else c.push(t);
4723
- } else c.push(t);
4854
+ } else c.push(n);
4855
+ } else c.push(n);
4724
4856
  let l;
4725
- if (a) l = Sn(c, e, r, n > 0 ? n : void 0, 0);
4857
+ if (a) l = Tn(c, e, r, n > 0 ? n : void 0, 0);
4726
4858
  else {
4727
- let i = t.metadata?.score || "", o = i ? oe(`(${i}分)`, e, "SimSun, STSong, serif") : 0;
4728
- l = Sn(c, e, r, n > 0 ? n : void 0, o), a = !0;
4859
+ let i = t.metadata?.score || "", o = i ? se(`(${i}分)`, e, "SimSun, STSong, serif") : 0;
4860
+ l = Tn(c, e, r, n > 0 ? n : void 0, o), a = !0;
4729
4861
  }
4730
4862
  t.paragraphs[o].justification && (l.justification = t.paragraphs[o].justification), i.push(l);
4731
4863
  }
4732
4864
  let c = 0;
4733
- t.options && t.options.length > 0 && (c = o.value.getOptionsHeight(t.options, Dn(t, s)));
4865
+ t.options && t.options.length > 0 && (c = o.value.getOptionsHeight(t.options, An(t, s)));
4734
4866
  let l = t.metadata?.customHeight;
4735
4867
  if (l) {
4736
4868
  let t = i.reduce((e, t) => e + (t.height || 26), 0) + c;
4737
4869
  if (l > t) {
4738
- let n = l - t, a = xn(e, r) + 4, o = Math.round(n / a);
4870
+ let n = l - t, a = wn(e, r) + 4, o = Math.round(n / a);
4739
4871
  for (let t = 0; t < o; t++) i.push($(e, r));
4740
4872
  }
4741
4873
  }
@@ -4749,12 +4881,13 @@ function Fn(e) {
4749
4881
  originalContentWidth: n
4750
4882
  }
4751
4883
  };
4752
- }), i.value = !0, h());
4884
+ }), i.value = !0, g());
4753
4885
  }
4754
- function _(e) {
4755
- t.value = [...t.value, e], N(), i.value = !0, h();
4886
+ function C(e) {
4887
+ b(), t.value = [...t.value, e], I(), i.value = !0, g();
4756
4888
  }
4757
- function v(e, n) {
4889
+ function w(e, n) {
4890
+ b();
4758
4891
  let r = {
4759
4892
  id: `title-${Date.now()}-${Math.random().toString(36).slice(2, 6)}`,
4760
4893
  type: "title",
@@ -4774,35 +4907,39 @@ function Fn(e) {
4774
4907
  ...t.value.slice(e)
4775
4908
  ] : t.value = [...t.value, r];
4776
4909
  } else t.value = [...t.value, r];
4777
- i.value = !0, N(), h();
4910
+ i.value = !0, I(), g();
4778
4911
  }
4779
- function y(e) {
4912
+ function T(e) {
4913
+ b();
4780
4914
  let n = new Map(t.value.map((e) => [e.id, e])), r = e.map((e) => n.get(e)).filter((e) => !!e);
4781
- r.length === t.value.length && (t.value = r, N(), i.value = !0, h());
4915
+ r.length === t.value.length && (t.value = r, I(), i.value = !0, g());
4782
4916
  }
4783
- function b(e) {
4784
- t.value = t.value.filter((t) => t.id !== e), f.value === e && (f.value = null), N(), i.value = !0, h();
4917
+ function E(e) {
4918
+ b(), t.value = t.value.filter((t) => t.id !== e), p.value === e && (p.value = null), I(), i.value = !0, g();
4785
4919
  }
4786
- function x(e, n) {
4920
+ function D(e, n) {
4921
+ b();
4787
4922
  let r = t.value.find((t) => t.id === e);
4788
4923
  r && (r.metadata = {
4789
4924
  ...r.metadata,
4790
4925
  label: n
4791
- }, i.value = !0, h());
4926
+ }, i.value = !0, g());
4792
4927
  }
4793
- function S(e, r) {
4928
+ function O(e, r) {
4929
+ b();
4794
4930
  let a = t.value.findIndex((t) => t.id === e);
4795
4931
  if (a === -1) return;
4796
- let o = t.value[a], s = Z(n.value), c = Q(n.value), l = Math.max(0, o.paragraphs.length - Cn(o)), u = [...r];
4932
+ let o = t.value[a], s = Z(n.value), c = Q(n.value), l = Math.max(0, o.paragraphs.length - En(o)), u = [...r];
4797
4933
  for (let e = 0; e < l; e++) u.push($(s, c));
4798
4934
  let d = u.reduce((e, t) => e + (t.height || 26), 0);
4799
4935
  t.value = t.value.map((e, t) => t === a ? {
4800
4936
  ...e,
4801
4937
  paragraphs: u,
4802
4938
  height: d
4803
- } : e), i.value = !0, h();
4939
+ } : e), i.value = !0, g();
4804
4940
  }
4805
- function C(e, n) {
4941
+ function k(e, n) {
4942
+ b();
4806
4943
  let r = t.value.findIndex((t) => t.id === e);
4807
4944
  r !== -1 && (t.value = t.value.map((e, t) => t === r ? {
4808
4945
  ...e,
@@ -4810,24 +4947,26 @@ function Fn(e) {
4810
4947
  ...e.metadata,
4811
4948
  score: n
4812
4949
  }
4813
- } : e), i.value = !0, h());
4950
+ } : e), i.value = !0, g());
4814
4951
  }
4815
- function w(e) {
4952
+ function A(e) {
4953
+ b();
4816
4954
  let n = t.value.findIndex((t) => t.id === e);
4817
4955
  if (n === -1) return;
4818
4956
  let r = t.value[n].protectContent === !0;
4819
4957
  t.value = t.value.map((e, t) => t === n ? {
4820
4958
  ...e,
4821
4959
  protectContent: !r
4822
- } : e), i.value = !0, h();
4960
+ } : e), i.value = !0, g();
4823
4961
  }
4824
- function T(e) {
4825
- n.value = {
4962
+ function j(e) {
4963
+ b(), n.value = {
4826
4964
  ...n.value,
4827
4965
  showScore: e
4828
- }, i.value = !0, h();
4966
+ }, i.value = !0, g();
4829
4967
  }
4830
- function E(e, n) {
4968
+ function M(e, n) {
4969
+ b();
4831
4970
  let r = t.value.findIndex((t) => t.id === e);
4832
4971
  r !== -1 && (t.value = t.value.map((e, t) => {
4833
4972
  if (t !== r) return e;
@@ -4838,32 +4977,35 @@ function Fn(e) {
4838
4977
  };
4839
4978
  }), i.value = !0);
4840
4979
  }
4841
- function D(e, r) {
4980
+ function ee(e, r) {
4981
+ b();
4842
4982
  let s = t.value.findIndex((t) => t.id === e);
4843
4983
  if (s === -1) return;
4844
- let c = t.value[s], l = Z(n.value), u = Q(n.value), d = xn(l, u) + 4, f = 0;
4845
- c.options && c.options.length > 0 && (f = o.value.getOptionsHeight(c.options, Dn(c, a.value.columnWidth)));
4846
- 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 = [];
4984
+ let c = t.value[s], l = Z(n.value), u = Q(n.value), d = wn(l, u) + 4, f = 0;
4985
+ c.options && c.options.length > 0 && (f = o.value.getOptionsHeight(c.options, An(c, a.value.columnWidth)));
4986
+ let p = En(c), m = c.paragraphs.slice(0, p), h = m.reduce((e, t) => e + (t.height || 26), 0) + f, _ = Math.max(0, r - h), v = Math.round(_ / d), y = [];
4847
4987
  for (let e = 0; e < v; e++) y.push($(l, u));
4848
- let b = [...m, ...y], x = b.reduce((e, t) => e + (t.height || 26), 0);
4988
+ let x = [...m, ...y], S = x.reduce((e, t) => e + (t.height || 26), 0);
4849
4989
  t.value = t.value.map((e, t) => t === s ? {
4850
4990
  ...e,
4851
- paragraphs: b,
4852
- height: x,
4991
+ paragraphs: x,
4992
+ height: S,
4853
4993
  metadata: {
4854
4994
  ...e.metadata,
4855
- customHeight: x
4995
+ customHeight: S
4856
4996
  }
4857
- } : e), i.value = !0, h();
4997
+ } : e), i.value = !0, g();
4858
4998
  }
4859
- function O(e, n) {
4999
+ function N(e, n) {
5000
+ b();
4860
5001
  let r = t.value.findIndex((t) => t.id === e);
4861
5002
  r !== -1 && (t.value = t.value.map((e, t) => t === r ? {
4862
5003
  ...e,
4863
5004
  questionType: n
4864
5005
  } : e), i.value = !0);
4865
5006
  }
4866
- function k(e, n) {
5007
+ function P(e, n) {
5008
+ b();
4867
5009
  let r = t.value.findIndex((t) => t.id === e);
4868
5010
  r !== -1 && (t.value = t.value.map((e, t) => {
4869
5011
  if (t !== r) return e;
@@ -4875,16 +5017,17 @@ function Fn(e) {
4875
5017
  ...e,
4876
5018
  paragraphs: i
4877
5019
  };
4878
- }), i.value = !0, h());
5020
+ }), i.value = !0, g());
4879
5021
  }
4880
- function A(e, n) {
5022
+ function F(e, n) {
5023
+ b();
4881
5024
  let r = t.value.findIndex((t) => t.id === e);
4882
5025
  r !== -1 && (t.value = t.value.map((e, t) => t === r ? {
4883
5026
  ...e,
4884
5027
  keepNext: n
4885
- } : e), i.value = !0, h());
5028
+ } : e), i.value = !0, g());
4886
5029
  }
4887
- function j(e, n) {
5030
+ function te(e, n) {
4888
5031
  let r = t.value.findIndex((t) => t.id === e);
4889
5032
  if (r === -1) {
4890
5033
  console.warn(`[usePaperCore] patchBlock: block ${e} not found`);
@@ -4905,7 +5048,7 @@ function Fn(e) {
4905
5048
  ...n
4906
5049
  } : e), i.value = !0;
4907
5050
  }
4908
- function M(e) {
5051
+ function ne(e) {
4909
5052
  let n = /* @__PURE__ */ new Map();
4910
5053
  for (let t of e) {
4911
5054
  let e = n.get(t.id) || [];
@@ -4927,17 +5070,17 @@ function Fn(e) {
4927
5070
  };
4928
5071
  }), i.value = !0;
4929
5072
  }
4930
- function N() {
5073
+ function I() {
4931
5074
  let e = 0, n = 0, r = [];
4932
5075
  for (let i of t.value) if (i.type === "title") {
4933
5076
  e++;
4934
- let t = i.metadata?.title || Rt(i.metadata?.label || "") || "题组";
5077
+ let t = i.metadata?.title ?? (Vt(i.metadata?.label || "") || "题组");
4935
5078
  r.push({
4936
5079
  id: i.id,
4937
5080
  metadata: {
4938
5081
  title: t,
4939
5082
  ordinal: e,
4940
- label: Lt(t, e)
5083
+ label: Bt(t, e)
4941
5084
  }
4942
5085
  });
4943
5086
  } else if (i.type === "question") {
@@ -4951,25 +5094,27 @@ function Fn(e) {
4951
5094
  }
4952
5095
  });
4953
5096
  }
4954
- M(r);
5097
+ ne(r);
4955
5098
  }
4956
- function P(e, t) {
4957
- j(e, { metadata: { title: t } }), N(), i.value = !0, h();
5099
+ function L(e, t) {
5100
+ b(), te(e, { metadata: { title: t } }), I(), i.value = !0, g();
4958
5101
  }
4959
- function F(e, r = !1) {
5102
+ function re(e, r = !1) {
5103
+ b();
4960
5104
  let o = e.content.split("\n").filter((e) => e.trim());
4961
5105
  o.length === 0 && o.push("");
4962
- 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;
4963
- if (c) p = Mn(e.no, s, o, l, u, d - 26.25, r);
5106
+ 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, f;
5107
+ if (c) f = Fn(e.no, s, o, l, u, d - 26.25, r);
4964
5108
  else {
4965
5109
  let t = e.no.length > 2 ? 26.25 : 17.5;
4966
- p = [jn(e.no, s, o, l, u, d - t, r)];
5110
+ f = [Pn(e.no, s, o, l, u, d - t, r)];
4967
5111
  }
4968
- for (let e of p) t.value = [...t.value, e];
4969
- p.length > 0 && (f.value = p[p.length - 1].id), N(), i.value = !0, g();
5112
+ for (let e of f) t.value = [...t.value, e];
5113
+ f.length > 0 && (p.value = f[f.length - 1].id), I(), i.value = !0, S();
4970
5114
  }
4971
- function I(e, r, o, s = !1) {
4972
- 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, {
5115
+ function ie(e, r, o, s = !1) {
5116
+ b();
5117
+ let c = Z(n.value), l = Q(n.value), u = a.value.columnWidth, d = (r?.length || 0) > 2 ? 26.25 : 17.5, f = xt(e, {
4973
5118
  questionNo: r || "",
4974
5119
  score: o || "",
4975
5120
  contentWidth: u - d,
@@ -4977,17 +5122,18 @@ function Fn(e) {
4977
5122
  lineSpacing: l,
4978
5123
  protectContent: s
4979
5124
  });
4980
- for (let e of p) t.value = [...t.value, e];
4981
- p.length > 0 && (f.value = p[p.length - 1].id), N(), i.value = !0, g();
5125
+ for (let e of f) t.value = [...t.value, e];
5126
+ f.length > 0 && (p.value = f[f.length - 1].id), I(), i.value = !0, S();
4982
5127
  }
4983
- function ee(e, r, o, s = !1) {
4984
- let c = Z(n.value), l = Q(n.value), u = a.value.columnWidth, d = (r?.length || 0) > 2 ? 26.25 : 17.5, p;
5128
+ function ae(e, r, o, s = !1) {
5129
+ b();
5130
+ let c = Z(n.value), l = Q(n.value), u = a.value.columnWidth, d = (r?.length || 0) > 2 ? 26.25 : 17.5, f;
4985
5131
  try {
4986
- p = JSON.parse(e);
5132
+ f = JSON.parse(e);
4987
5133
  } catch {
4988
5134
  throw Error("JSON 格式错误,请检查");
4989
5135
  }
4990
- let m = Mt(p, {
5136
+ let m = Nt(f, {
4991
5137
  questionNo: r || "",
4992
5138
  score: o || "",
4993
5139
  contentWidth: u - d,
@@ -4996,16 +5142,83 @@ function Fn(e) {
4996
5142
  protectContent: s
4997
5143
  });
4998
5144
  for (let e of m) t.value = [...t.value, e];
4999
- m.length > 0 && (f.value = m[m.length - 1].id), N(), i.value = !0, g();
5145
+ m.length > 0 && (p.value = m[m.length - 1].id), I(), i.value = !0, S();
5146
+ }
5147
+ function R(e) {
5148
+ b();
5149
+ let r = t.value.filter((t) => t.metadata?.blockGroup === e);
5150
+ if (r.length < 2) return;
5151
+ let a = r.find((e) => e.type === "question") || r[0], o = Z(n.value), s = Q(n.value), c = [];
5152
+ for (let e of r) {
5153
+ let t = En(e);
5154
+ c.push(...e.paragraphs.slice(0, t));
5155
+ }
5156
+ for (let e = 0; e < 2; e++) c.push($(o, s));
5157
+ let l = c.reduce((e, t) => e + (t.height || 26), 0), u = {}, d = a.metadata?.answer || "";
5158
+ for (let e of r) if (e.type === "sub-question" && e.metadata?.answer) {
5159
+ let t = e.metadata.subLabel || "", n = e.metadata.answer;
5160
+ t && (u[t] = n, d += (d ? "\n" : "") + t + n);
5161
+ }
5162
+ let f = {
5163
+ ...a,
5164
+ id: `merged-${Date.now()}-${Math.random().toString(36).slice(2, 6)}`,
5165
+ paragraphs: c,
5166
+ height: l,
5167
+ metadata: {
5168
+ ...a.metadata,
5169
+ answer: d || a.metadata?.answer,
5170
+ blockGroup: void 0,
5171
+ hasSubQuestions: !0,
5172
+ subAnswers: Object.keys(u).length > 0 ? u : void 0,
5173
+ _splitBackup: JSON.stringify(r.map((e) => ({
5174
+ ...e,
5175
+ paragraphs: e.paragraphs.map((e) => ({
5176
+ ...e,
5177
+ lines: e.lines.map((e) => ({
5178
+ ...e,
5179
+ elements: e.elements.map((e) => ({ ...e }))
5180
+ }))
5181
+ }))
5182
+ })))
5183
+ }
5184
+ }, p = new Set(r.map((e) => e.id)), m = t.value.findIndex((e) => p.has(e.id));
5185
+ if (m === -1) t.value = [...t.value.filter((e) => !p.has(e.id)), f];
5186
+ else {
5187
+ let e = t.value.slice(0, m), n = t.value.slice(m).filter((e) => !p.has(e.id));
5188
+ t.value = [
5189
+ ...e,
5190
+ f,
5191
+ ...n
5192
+ ];
5193
+ }
5194
+ I(), i.value = !0, S();
5000
5195
  }
5001
- function te(e, t, n) {
5002
- let r = p(e);
5196
+ function oe(e) {
5197
+ let n = t.value.find((t) => t.id === e);
5198
+ if (n?.metadata?._splitBackup) {
5199
+ b();
5200
+ try {
5201
+ let r = JSON.parse(n.metadata._splitBackup), a = t.value.findIndex((t) => t.id === e);
5202
+ if (a === -1) return;
5203
+ t.value = [
5204
+ ...t.value.slice(0, a),
5205
+ ...r,
5206
+ ...t.value.slice(a + 1)
5207
+ ], I(), i.value = !0, S();
5208
+ } catch (e) {
5209
+ console.warn("[splitMergedBlock] _splitBackup 解析失败", e);
5210
+ }
5211
+ }
5212
+ }
5213
+ function z(e, t, n) {
5214
+ b();
5215
+ let r = m(e);
5003
5216
  if (!r) return;
5004
- let o = Dn(r.block, a.value.columnWidth), s = Math.max(20, Math.min(Math.round(t), Math.max(20, o)));
5005
- r.image.width = s, n !== void 0 && (r.image.height = Math.max(12, Math.round(n))), i.value = !0, g();
5217
+ let o = An(r.block, a.value.columnWidth), s = Math.max(20, Math.min(Math.round(t), Math.max(20, o)));
5218
+ r.image.width = s, n !== void 0 && (r.image.height = Math.max(12, Math.round(n))), i.value = !0, S();
5006
5219
  }
5007
- function L(e) {
5008
- let t = p(e);
5220
+ function B(e) {
5221
+ let t = m(e);
5009
5222
  if (!t) return null;
5010
5223
  let n = t.block.paragraphs[t.paraIdx];
5011
5224
  return {
@@ -5013,21 +5226,23 @@ function Fn(e) {
5013
5226
  alignment: n.justification || "left"
5014
5227
  };
5015
5228
  }
5016
- function R(e, t) {
5017
- let n = p(e);
5229
+ function ce(e, t) {
5230
+ b();
5231
+ let n = m(e);
5018
5232
  if (!n) return;
5019
5233
  let r = n.block.paragraphs[n.paraIdx];
5020
- r.justification = t === "left" ? void 0 : t, i.value = !0, h();
5234
+ r.justification = t === "left" ? void 0 : t, i.value = !0, g();
5021
5235
  }
5022
- function ne(e, t) {
5023
- let n = Math.max(30, Math.min(500, Math.round(t))), r = m(e);
5024
- r && (r.underline.width = n, g());
5236
+ function le(e, t) {
5237
+ b();
5238
+ let n = Math.max(30, Math.min(500, Math.round(t))), r = h(e);
5239
+ r && (r.underline.width = n, S());
5025
5240
  }
5026
- function re(e, t, r, i) {
5241
+ function V(e, t, r, i) {
5027
5242
  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());
5028
- return l.length === 0 && l.push(""), l.map((e) => Sn(kn(e, o), o, s, c > 0 ? c : void 0));
5243
+ return l.length === 0 && l.push(""), l.map((e) => Tn(Mn(e, o), o, s, c > 0 ? c : void 0));
5029
5244
  }
5030
- function ie() {
5245
+ function H() {
5031
5246
  return ht(t.value, n.value, {
5032
5247
  paperName: s.value,
5033
5248
  schoolName: c.value,
@@ -5038,53 +5253,58 @@ function Fn(e) {
5038
5253
  blocks: t.value
5039
5254
  });
5040
5255
  }
5041
- function z(e, r) {
5256
+ function ue(e, r) {
5042
5257
  let o = gt(e);
5043
- t.value = o.blocks, o.settings && typeof o.settings.fontSize == "string" && (o.settings.fontSize = yn(o.settings.fontSize)), n.value = {
5258
+ t.value = o.blocks, o.settings && typeof o.settings.fontSize == "string" && (o.settings.fontSize = Sn(o.settings.fontSize)), n.value = {
5044
5259
  ...n.value,
5045
5260
  ...o.settings
5046
- }, 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), N(), r ? h() : g(), i.value = !1;
5261
+ }, 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), I(), r ? g() : S(), i.value = !1;
5047
5262
  }
5048
5263
  return {
5049
- reflowAllBlocks: g,
5050
- addBlock: _,
5051
- addTitleBlock: v,
5052
- reorderBlocks: y,
5053
- removeBlock: b,
5054
- updateBlockLabel: x,
5055
- updateBlockContent: S,
5056
- updateBlockScore: C,
5057
- toggleContentProtection: w,
5058
- updateShowScore: T,
5059
- updateBlockQid: E,
5060
- updateBlockHeight: D,
5061
- updateBlockQuestionType: O,
5062
- updateBlockSplit: k,
5063
- updateBlockKeepNext: A,
5064
- patchBlock: j,
5065
- patchBlocksMeta: M,
5066
- recalculateNumbering: N,
5067
- updateSectionTitle: P,
5068
- addNewQuestion: F,
5069
- addQuestionFromHtml: I,
5070
- addQuestionFromJson: ee,
5071
- updateInlineImageSize: te,
5072
- getImageParagraphInfo: L,
5073
- updateImageAlignment: R,
5074
- updateUnderlineWidth: ne,
5075
- parseTextToParagraphs: re,
5076
- saveDocument: ie,
5077
- loadDocument: z,
5078
- getBlockPlainText: Nn,
5079
- getBlockLabel: Pn,
5080
- getBlockAvailableWidth: Dn
5264
+ reflowAllBlocks: S,
5265
+ saveUndoSnapshot: b,
5266
+ undo: x,
5267
+ canUndo: v,
5268
+ addBlock: C,
5269
+ addTitleBlock: w,
5270
+ reorderBlocks: T,
5271
+ removeBlock: E,
5272
+ updateBlockLabel: D,
5273
+ updateBlockContent: O,
5274
+ updateBlockScore: k,
5275
+ toggleContentProtection: A,
5276
+ updateShowScore: j,
5277
+ updateBlockQid: M,
5278
+ updateBlockHeight: ee,
5279
+ updateBlockQuestionType: N,
5280
+ updateBlockSplit: P,
5281
+ updateBlockKeepNext: F,
5282
+ patchBlock: te,
5283
+ patchBlocksMeta: ne,
5284
+ recalculateNumbering: I,
5285
+ updateSectionTitle: L,
5286
+ addNewQuestion: re,
5287
+ addQuestionFromHtml: ie,
5288
+ addQuestionFromJson: ae,
5289
+ updateInlineImageSize: z,
5290
+ getImageParagraphInfo: B,
5291
+ updateImageAlignment: ce,
5292
+ updateUnderlineWidth: le,
5293
+ parseTextToParagraphs: V,
5294
+ saveDocument: H,
5295
+ loadDocument: ue,
5296
+ getBlockPlainText: In,
5297
+ getBlockLabel: Ln,
5298
+ getBlockAvailableWidth: An,
5299
+ mergeSubQuestionGroup: R,
5300
+ splitMergedBlock: oe
5081
5301
  };
5082
5302
  }
5083
- var In = B;
5303
+ var zn = z;
5084
5304
  //#endregion
5085
5305
  //#region src/composables/usePaperCore.ts
5086
- function Ln(e = {}) {
5087
- let n = f(e.renderMode ?? "edit"), r = m(new ee()), i = m(new Se({ renderMode: n.value })), a = m([]), o = f([]), s = f({ ...r.value.settings }), c = f(""), l = f(""), u = f(""), d = f([]), p = t(() => d.value[0] || ""), h = f(!1), g = f(0), _ = t(() => {
5306
+ function Bn(e = {}) {
5307
+ let n = f(e.renderMode ?? "edit"), r = m(new te()), i = m(new Se({ renderMode: n.value })), a = m([]), o = f([]), s = f({ ...r.value.settings }), c = f(""), l = f(""), u = f(""), d = f([]), p = t(() => d.value[0] || ""), h = f(!1), g = f(0), _ = t(() => {
5088
5308
  let e = 0, t = /* @__PURE__ */ new Set();
5089
5309
  for (let n of a.value) {
5090
5310
  let r = n.metadata?.score || "";
@@ -5098,7 +5318,7 @@ function Ln(e = {}) {
5098
5318
  a && (e += parseInt(a[1]));
5099
5319
  }
5100
5320
  return e;
5101
- }), y = _n(a), b = Fn({
5321
+ }), y = bn(a), b = Rn({
5102
5322
  blocks: a,
5103
5323
  settings: s,
5104
5324
  pages: o,
@@ -5122,7 +5342,7 @@ function Ln(e = {}) {
5122
5342
  d.value = [];
5123
5343
  return;
5124
5344
  }
5125
- d.value = await Promise.all(Array.from({ length: t }, (t, n) => gn(e + String(n))));
5345
+ d.value = await Promise.all(Array.from({ length: t }, (t, n) => yn(e + String(n))));
5126
5346
  }, { immediate: !0 });
5127
5347
  function x(e) {
5128
5348
  n.value = e, i.value.setRenderMode(e);
@@ -5136,7 +5356,7 @@ function Ln(e = {}) {
5136
5356
  g.value++;
5137
5357
  }
5138
5358
  function C(e) {
5139
- Object.assign(s.value, e), r.value.updateSettings(e), b.reflowAllBlocks();
5359
+ b.saveUndoSnapshot(), Object.assign(s.value, e), r.value.updateSettings(e), b.reflowAllBlocks();
5140
5360
  }
5141
5361
  function w(e) {
5142
5362
  C({ paperSize: e });
@@ -5175,6 +5395,9 @@ function Ln(e = {}) {
5175
5395
  setRenderMode: x,
5176
5396
  relayout: S,
5177
5397
  reflowAllBlocks: b.reflowAllBlocks,
5398
+ saveUndoSnapshot: b.saveUndoSnapshot,
5399
+ undo: b.undo,
5400
+ canUndo: b.canUndo,
5178
5401
  updateSettings: C,
5179
5402
  setPaperSize: w,
5180
5403
  setColumns: T,
@@ -5214,6 +5437,8 @@ function Ln(e = {}) {
5214
5437
  updateSectionTitle: b.updateSectionTitle,
5215
5438
  patchBlock: b.patchBlock,
5216
5439
  patchBlocksMeta: b.patchBlocksMeta,
5440
+ mergeSubQuestionGroup: b.mergeSubQuestionGroup,
5441
+ splitMergedBlock: b.splitMergedBlock,
5217
5442
  saveDocument: b.saveDocument,
5218
5443
  loadDocument: b.loadDocument,
5219
5444
  layoutEngine: r,
@@ -5222,8 +5447,8 @@ function Ln(e = {}) {
5222
5447
  }
5223
5448
  //#endregion
5224
5449
  //#region src/composables/usePageSvgRenderer.ts
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 = {}) {
5450
+ var Vn = "<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>";
5451
+ function Hn(e, n = {}) {
5227
5452
  return t(() => {
5228
5453
  e.renderMode.value;
5229
5454
  let t = e.pages.value;
@@ -5239,13 +5464,13 @@ function zn(e, n = {}) {
5239
5464
  qrCodeImage: e.qrCodeImage.value,
5240
5465
  qrCodeImages: e.qrCodeImages.value
5241
5466
  }, 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${Rn}\n${l}</svg>`;
5467
+ return `<svg xmlns="http://www.w3.org/2000/svg" width="${r * o}" height="${i * o}" viewBox="0 0 ${r} ${i}" class="paper-page">\n${Vn}\n${l}</svg>`;
5243
5468
  });
5244
5469
  });
5245
5470
  }
5246
5471
  //#endregion
5247
5472
  //#region src/composables/useTableRenderer.ts
5248
- async function Bn(e, t, n = 2) {
5473
+ async function Un(e, t, n = 2) {
5249
5474
  let r = [];
5250
5475
  for (let t = 0; t < e.length; t++) {
5251
5476
  let n = e[t];
@@ -5272,7 +5497,7 @@ async function Bn(e, t, n = 2) {
5272
5497
  if (r.length !== 0) for (let i = 0; i < r.length; i++) {
5273
5498
  let a = r[i];
5274
5499
  try {
5275
- let r = await Vn(a.rawHtml, t, n);
5500
+ let r = await Wn(a.rawHtml, t, n);
5276
5501
  if (r) {
5277
5502
  let t = e[a.blockIdx].paragraphs[a.paraIdx].lines[a.lineIdx].elements[a.elemIdx];
5278
5503
  t.src = r, delete t.rawHtml;
@@ -5282,7 +5507,7 @@ async function Bn(e, t, n = 2) {
5282
5507
  }
5283
5508
  }
5284
5509
  }
5285
- async function Vn(e, t, n) {
5510
+ async function Wn(e, t, n) {
5286
5511
  let r = document.createElement("div");
5287
5512
  r.innerHTML = e, r.style.position = "absolute", r.style.left = "-9999px", r.style.top = "0", r.style.width = "auto", r.style.height = "auto";
5288
5513
  let i = document.createElement("style");
@@ -5303,7 +5528,7 @@ async function Vn(e, t, n) {
5303
5528
  document.body.removeChild(r);
5304
5529
  }
5305
5530
  }
5306
- function Hn(e) {
5531
+ function Gn(e) {
5307
5532
  for (let t of e) if (t.paragraphs) {
5308
5533
  for (let e of t.paragraphs) if (e.lines) {
5309
5534
  for (let t of e.lines) if (t.elements) {
@@ -5318,7 +5543,7 @@ function Hn(e) {
5318
5543
  }
5319
5544
  //#endregion
5320
5545
  //#region src/composables/usePaperCursor.ts
5321
- function Un(e, t, n, r) {
5546
+ function Kn(e, t, n, r) {
5322
5547
  let i = f({
5323
5548
  blockId: null,
5324
5549
  paraIndex: 0,
@@ -5371,7 +5596,7 @@ function Un(e, t, n, r) {
5371
5596
  }
5372
5597
  function d(e, t) {
5373
5598
  if (!e) return [];
5374
- let n = e.split(""), r = V(e, t.fontSize, t.fontFamily, t.bold, t.italic), i = r.length > 0 ? r[r.length - 1] + B(n[n.length - 1], t.fontSize, t.fontFamily, t.bold, t.italic) : 0;
5599
+ let n = e.split(""), r = B(e, t.fontSize, t.fontFamily, t.bold, t.italic), i = r.length > 0 ? r[r.length - 1] + z(n[n.length - 1], t.fontSize, t.fontFamily, t.bold, t.italic) : 0;
5375
5600
  return [{
5376
5601
  type: "text",
5377
5602
  value: e,
@@ -5386,7 +5611,7 @@ function Un(e, t, n, r) {
5386
5611
  }];
5387
5612
  }
5388
5613
  function p(e) {
5389
- let n = Z(t.value), r = Q(t.value), i = xn(n, r);
5614
+ let n = Z(t.value), r = Q(t.value), i = wn(n, r);
5390
5615
  return e.length === 0 || e.length === 1 && e[0].type === "enter" ? $(n, r) : {
5391
5616
  lines: [{
5392
5617
  elements: e,
@@ -5430,7 +5655,7 @@ function Un(e, t, n, r) {
5430
5655
  else {
5431
5656
  let e = t - i, c = o.value.substring(0, e), l = o.value.substring(e);
5432
5657
  if (c) {
5433
- let e = V(c, o.fontSize, o.fontFamily, o.bold, o.italic), t = e.length > 0 ? e[e.length - 1] + B(c[c.length - 1], o.fontSize, o.fontFamily, o.bold, o.italic) : 0;
5658
+ let e = B(c, o.fontSize, o.fontFamily, o.bold, o.italic), t = e.length > 0 ? e[e.length - 1] + z(c[c.length - 1], o.fontSize, o.fontFamily, o.bold, o.italic) : 0;
5434
5659
  n.push({
5435
5660
  ...o,
5436
5661
  value: c,
@@ -5439,7 +5664,7 @@ function Un(e, t, n, r) {
5439
5664
  });
5440
5665
  }
5441
5666
  if (l) {
5442
- let e = V(l, o.fontSize, o.fontFamily, o.bold, o.italic), t = e.length > 0 ? e[e.length - 1] + B(l[l.length - 1], o.fontSize, o.fontFamily, o.bold, o.italic) : 0;
5667
+ let e = B(l, o.fontSize, o.fontFamily, o.bold, o.italic), t = e.length > 0 ? e[e.length - 1] + z(l[l.length - 1], o.fontSize, o.fontFamily, o.bold, o.italic) : 0;
5443
5668
  r.push({
5444
5669
  ...o,
5445
5670
  value: l,
@@ -5482,7 +5707,7 @@ function Un(e, t, n, r) {
5482
5707
  let e = r[a], n = e.value.substring(0, s) + e.value.substring(s + 1);
5483
5708
  for (let t = 0; t < r.length; t++) if (t === a) {
5484
5709
  if (n) {
5485
- let t = V(n, e.fontSize, e.fontFamily, e.bold, e.italic), r = t.length > 0 ? t[t.length - 1] + B(n[n.length - 1], e.fontSize, e.fontFamily, e.bold, e.italic) : 0;
5710
+ let t = B(n, e.fontSize, e.fontFamily, e.bold, e.italic), r = t.length > 0 ? t[t.length - 1] + z(n[n.length - 1], e.fontSize, e.fontFamily, e.bold, e.italic) : 0;
5486
5711
  c.push({
5487
5712
  ...e,
5488
5713
  value: n,
@@ -5520,7 +5745,7 @@ function Un(e, t, n, r) {
5520
5745
  let e = n[i], r = e.value.substring(0, o) + e.value.substring(o + 1), a = [];
5521
5746
  for (let t = 0; t < n.length; t++) if (t === i) {
5522
5747
  if (r) {
5523
- let t = V(r, e.fontSize, e.fontFamily, e.bold, e.italic), n = t.length > 0 ? t[t.length - 1] + B(r[r.length - 1], e.fontSize, e.fontFamily, e.bold, e.italic) : 0;
5748
+ let t = B(r, e.fontSize, e.fontFamily, e.bold, e.italic), n = t.length > 0 ? t[t.length - 1] + z(r[r.length - 1], e.fontSize, e.fontFamily, e.bold, e.italic) : 0;
5524
5749
  a.push({
5525
5750
  ...e,
5526
5751
  value: r,
@@ -5788,7 +6013,13 @@ function Un(e, t, n, r) {
5788
6013
  }
5789
6014
  //#endregion
5790
6015
  //#region src/components/PaperEditor.vue?vue&type=script&setup=true&lang.ts
5791
- 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({
6016
+ var qn = { class: "pe-root" }, Jn = { class: "pe-main" }, Yn = { class: "pe-editor" }, Xn = { class: "pe-editor-pages" }, Zn = ["onClick"], Qn = ["innerHTML"], $n = { class: "pe-editor-controllers" }, er = {
6017
+ key: 0,
6018
+ class: "pe-ctrl-sub"
6019
+ }, tr = {
6020
+ key: 1,
6021
+ class: "pe-ctrl-sub"
6022
+ }, nr = /*@__PURE__*/ a({
5792
6023
  __name: "PaperEditor",
5793
6024
  props: {
5794
6025
  initialData: {},
@@ -5809,7 +6040,7 @@ var Wn = { class: "pe-root" }, Gn = { class: "pe-main" }, Kn = { class: "pe-edit
5809
6040
  "loaded"
5810
6041
  ],
5811
6042
  setup(a, { expose: m, emit: h }) {
5812
- let x = a, S = h, C = Ln({ renderMode: x.renderMode }), w = Un(C.blocks, C.settings, () => {
6043
+ let x = a, S = h, C = Bn({ renderMode: x.renderMode }), w = Kn(C.blocks, C.settings, () => {
5813
6044
  C.reflowAllBlocks(), o(() => k.value?.focus());
5814
6045
  }, () => {
5815
6046
  C.isDirty.value = !0;
@@ -5823,16 +6054,16 @@ var Wn = { class: "pe-root" }, Gn = { class: "pe-main" }, Kn = { class: "pe-edit
5823
6054
  }), M = t(() => ({
5824
6055
  left: A.value.left + "px",
5825
6056
  top: A.value.top + "px"
5826
- })), N = t(() => ({
6057
+ })), ee = t(() => ({
5827
6058
  left: j.value.left + "px",
5828
6059
  top: j.value.top + "px",
5829
6060
  height: j.value.height + "px",
5830
6061
  transform: "skewX(0deg)"
5831
- })), P = zn(C, {
6062
+ })), N = Hn(C, {
5832
6063
  zoom: T,
5833
- selectedBlockId: null
6064
+ selectedBlockId: C.selectedBlockId
5834
6065
  });
5835
- function F() {
6066
+ function P() {
5836
6067
  if (C.pages.value.length === 0) return [];
5837
6068
  let e = C.pages.value[0].width, t = C.pages.value[0].height;
5838
6069
  return C.svgRenderer.value.withRenderMode("view", () => C.pages.value.map((n, r) => {
@@ -5848,16 +6079,16 @@ var Wn = { class: "pe-root" }, Gn = { class: "pe-main" }, Kn = { class: "pe-edit
5848
6079
  }, C.pages.value.length)}</svg>`;
5849
6080
  }));
5850
6081
  }
5851
- let I = t(() => C.svgRenderer.value.renderAllPages(C.pages.value, C.blocks.value, C.settings.value, {
6082
+ let F = t(() => C.svgRenderer.value.renderAllPages(C.pages.value, C.blocks.value, C.settings.value, {
5852
6083
  totalScore: C.totalScore.value,
5853
6084
  paperName: C.paperName.value,
5854
6085
  schoolName: C.schoolName.value,
5855
6086
  qrCodeImages: C.qrCodeImages.value
5856
6087
  }));
5857
- function ee() {
5858
- C.relayout(), E.value >= C.pages.value.length && (E.value = Math.max(0, C.pages.value.length - 1)), R();
6088
+ function te() {
6089
+ C.relayout(), E.value >= C.pages.value.length && (E.value = Math.max(0, C.pages.value.length - 1)), L();
5859
6090
  }
5860
- let te = new Set([
6091
+ let ne = new Set([
5861
6092
  "header-desc",
5862
6093
  "paper-name",
5863
6094
  "qr-code",
@@ -5867,22 +6098,22 @@ var Wn = { class: "pe-root" }, Gn = { class: "pe-main" }, Kn = { class: "pe-edit
5867
6098
  "score",
5868
6099
  "page-number"
5869
6100
  ]);
5870
- function L() {
6101
+ function I() {
5871
6102
  for (let e = 0; e < C.pages.value.length; e++) {
5872
6103
  let t = C.pages.value[e];
5873
- t.renderedRegions ||= [], t.renderedRegions = t.renderedRegions.filter((e) => !te.has(e.type)), C.svgRenderer.value.measureRegionsFromDOM(e, t, t.renderedRegions);
6104
+ t.renderedRegions ||= [], t.renderedRegions = t.renderedRegions.filter((e) => !ne.has(e.type)), C.svgRenderer.value.measureRegionsFromDOM(e, t, t.renderedRegions);
5874
6105
  }
5875
6106
  }
5876
- function R() {
6107
+ function L() {
5877
6108
  o(() => {
5878
6109
  o(() => {
5879
6110
  requestAnimationFrame(() => {
5880
- L();
6111
+ I();
5881
6112
  });
5882
6113
  });
5883
6114
  });
5884
6115
  }
5885
- function ne(e, t, n, r) {
6116
+ function re(e, t, n, r) {
5886
6117
  let i = C.blocks.value.find((t) => t.id === e);
5887
6118
  if (!i || !n) return;
5888
6119
  let a = n.getBoundingClientRect(), o = (t.clientX - a.left) / T.value, s = (t.clientY - a.top) / T.value, c = r ?? E.value, l = C.pages.value[c];
@@ -5913,7 +6144,7 @@ var Wn = { class: "pe-root" }, Gn = { class: "pe-main" }, Kn = { class: "pe-edit
5913
6144
  y += t;
5914
6145
  }
5915
6146
  b === -1 && (b = v[v.length - 1] ?? g);
5916
- let x = i.paragraphs[b], S = 0, k = f.x + p, M = w.getTextStyle(x).fontSize, N = (x.lines[0]?.lineHeight || x.height || 21) * .5, P = f.y + y + N, F = M;
6147
+ let x = i.paragraphs[b], S = 0, k = f.x + p, M = w.getTextStyle(x).fontSize, ee = (x.lines[0]?.lineHeight || x.height || 21) * .5, N = f.y + y + ee, P = M;
5917
6148
  if (!w.isEmptyParagraph(x)) {
5918
6149
  let e = o - m - f.x - p, t = h - y, n = 0, r = -1;
5919
6150
  for (let e = 0; e < x.lines.length; e++) {
@@ -5930,7 +6161,7 @@ var Wn = { class: "pe-root" }, Gn = { class: "pe-main" }, Kn = { class: "pe-edit
5930
6161
  let s = x.lines[r], c = s.offsetX || 0, l = 0;
5931
6162
  if (f.paragraphStart === 0 && i.metadata?.score && r === 0 && b === (v[0] ?? 0)) {
5932
6163
  let e = C.settings.value.fontSize, t = typeof e == "number" ? e : 14;
5933
- l = oe(`(${i.metadata.score}分)`, t, "SimSun, STSong, serif");
6164
+ l = se(`(${i.metadata.score}分)`, t, "SimSun, STSong, serif");
5934
6165
  }
5935
6166
  let u = l, d = !1;
5936
6167
  for (let t of s.elements) {
@@ -5939,7 +6170,7 @@ var Wn = { class: "pe-root" }, Gn = { class: "pe-main" }, Kn = { class: "pe-edit
5939
6170
  for (let i = 0; i < t.value.length; i++) {
5940
6171
  let o = u + c + r[i];
5941
6172
  if (e < o + (i < r.length - 1 ? r[i + 1] - r[i] : t.width - r[i]) / 2) {
5942
- S = a, k = f.x + p + o, P = f.y + y + n + s.lineHeight * .5, F = M, d = !0;
6173
+ S = a, k = f.x + p + o, N = f.y + y + n + s.lineHeight * .5, P = M, d = !0;
5943
6174
  break;
5944
6175
  }
5945
6176
  a++;
@@ -5948,30 +6179,30 @@ var Wn = { class: "pe-root" }, Gn = { class: "pe-main" }, Kn = { class: "pe-edit
5948
6179
  } else {
5949
6180
  let r = t.width || 12;
5950
6181
  if (e < u + c + r / 2) {
5951
- S = a, k = f.x + p + u + c, P = f.y + y + n + s.lineHeight * .5, F = M, d = !0;
6182
+ S = a, k = f.x + p + u + c, N = f.y + y + n + s.lineHeight * .5, P = M, d = !0;
5952
6183
  break;
5953
6184
  }
5954
6185
  u += r;
5955
6186
  }
5956
6187
  if (d) break;
5957
6188
  }
5958
- d || (S = a, k = f.x + p + u + c, P = f.y + y + n + s.lineHeight * .5, F = M);
6189
+ d || (S = a, k = f.x + p + u + c, N = f.y + y + n + s.lineHeight * .5, P = M);
5959
6190
  }
5960
6191
  w.setCursor(e, b, S);
5961
- let I = O.value, ee = document.querySelectorAll(".pe-editor-page")[c]?.querySelector("svg.paper-page");
5962
- if (I && ee && l) {
5963
- let e = ee.getBoundingClientRect(), t = I.getBoundingClientRect(), n = l.width, r = l.height, i = k + m, a = P + d, o = e.left - t.left + I.scrollLeft + i / n * e.width, s = e.top - t.top + I.scrollTop + a / r * e.height;
6192
+ let F = O.value, te = document.querySelectorAll(".pe-editor-page")[c]?.querySelector("svg.paper-page");
6193
+ if (F && te && l) {
6194
+ let e = te.getBoundingClientRect(), t = F.getBoundingClientRect(), n = l.width, r = l.height, i = k + m, a = N + d, o = e.left - t.left + F.scrollLeft + i / n * e.width, s = e.top - t.top + F.scrollTop + a / r * e.height;
5964
6195
  j.value = {
5965
6196
  left: o,
5966
6197
  top: s,
5967
- height: F * T.value
6198
+ height: P * T.value
5968
6199
  }, A.value = {
5969
6200
  left: o,
5970
6201
  top: s
5971
6202
  }, D.value = !0;
5972
6203
  }
5973
6204
  }
5974
- function re(e) {
6205
+ function ie(e) {
5975
6206
  let t = e.target, n = e.currentTarget, r = n.closest(".pe-editor-page"), i = E.value;
5976
6207
  if (r) {
5977
6208
  let e = r.parentElement?.querySelectorAll(":scope > .pe-editor-page");
@@ -5999,27 +6230,27 @@ var Wn = { class: "pe-root" }, Gn = { class: "pe-main" }, Kn = { class: "pe-edit
5999
6230
  if (c) {
6000
6231
  let t = c.getAttribute("data-block-id");
6001
6232
  if (t) {
6002
- C.selectBlock(t), n && ne(t, e, n, i), o(() => k.value?.focus());
6233
+ C.selectBlock(t), n && re(t, e, n, i), o(() => k.value?.focus());
6003
6234
  let r = C.blocks.value.find((e) => e.id === t);
6004
6235
  r && S("block-click", {
6005
6236
  blockId: t,
6006
6237
  block: r
6007
6238
  });
6008
6239
  }
6009
- } else C.selectBlock(null), C.selectUnderline(null), D.value = !1, w.clearCursor(), S("empty-click");
6240
+ } else C.selectBlock(null), C.selectUnderline(null), C.selectImage(null), D.value = !1, w.clearCursor(), S("empty-click");
6010
6241
  }
6011
- function ie(e) {
6242
+ function ae(e) {
6012
6243
  let t = e.target;
6013
6244
  if (!t) return;
6014
6245
  let n = t.getAttribute("data-editable");
6015
- n && (n === "schoolName" ? C.schoolName.value = t.innerHTML : n === "paperName" && (C.paperName.value = t.textContent || ""));
6246
+ n && (C.saveUndoSnapshot(), n === "schoolName" ? C.schoolName.value = t.innerHTML : n === "paperName" && (C.paperName.value = t.textContent || ""));
6016
6247
  }
6017
- let z = f(null), ae = t(() => z.value ? {
6248
+ let R = f(null), oe = t(() => R.value ? {
6018
6249
  position: "absolute",
6019
- left: z.value.left + "px",
6020
- top: z.value.top + "px",
6021
- width: z.value.width + "px",
6022
- height: z.value.height + "px",
6250
+ left: R.value.left + "px",
6251
+ top: R.value.top + "px",
6252
+ width: R.value.width + "px",
6253
+ height: R.value.height + "px",
6023
6254
  pointerEvents: "none",
6024
6255
  border: "1.5px solid #409eff",
6025
6256
  borderRadius: "2px",
@@ -6028,220 +6259,249 @@ var Wn = { class: "pe-root" }, Gn = { class: "pe-main" }, Kn = { class: "pe-edit
6028
6259
  display: "none",
6029
6260
  position: "absolute"
6030
6261
  });
6031
- function B() {
6262
+ function z() {
6032
6263
  let e = C.selectedBlockId.value;
6033
6264
  if (!e) {
6034
- z.value = null;
6265
+ R.value = null;
6035
6266
  return;
6036
6267
  }
6037
6268
  let t = C.blocks.value.find((t) => t.id === e);
6038
6269
  if (!t || t.type === "title") {
6039
- z.value = null;
6270
+ R.value = null;
6040
6271
  return;
6041
6272
  }
6042
6273
  let n = document.querySelector(".pe-editor-page.active");
6043
6274
  if (!n) {
6044
- z.value = null;
6275
+ R.value = null;
6045
6276
  return;
6046
6277
  }
6047
6278
  let r = n.querySelector("svg.paper-page");
6048
6279
  if (!r) {
6049
- z.value = null;
6280
+ R.value = null;
6050
6281
  return;
6051
6282
  }
6052
6283
  let i = C.pages.value.find((e) => e.index === E.value);
6053
6284
  if (!i) {
6054
- z.value = null;
6285
+ R.value = null;
6055
6286
  return;
6056
6287
  }
6057
6288
  let a = i.blocks.find((t) => t.blockId === e);
6058
6289
  if (!a) {
6059
- z.value = null;
6290
+ R.value = null;
6060
6291
  return;
6061
6292
  }
6062
6293
  let o = n.closest(".pe-editor-surface");
6063
6294
  if (!o) {
6064
- z.value = null;
6295
+ R.value = null;
6065
6296
  return;
6066
6297
  }
6067
6298
  let s = i.width, c = i.height, l = E.value % 2 == 0 ? C.settings.value.bodyTopEven ?? 173 : C.settings.value.bodyTopOdd ?? 50, u = (C.settings.value.margins[3] ?? 56) + a.x, d = l + a.y, f = r.getBoundingClientRect(), p = o.getBoundingClientRect();
6068
- z.value = {
6299
+ R.value = {
6069
6300
  left: f.left - p.left + o.scrollLeft + u / s * f.width,
6070
6301
  top: f.top - p.top + o.scrollTop + d / c * f.height,
6071
6302
  width: a.width / s * f.width,
6072
6303
  height: a.height / c * f.height
6073
6304
  };
6074
6305
  }
6075
- let V = f(null), se = t(() => V.value ? {
6306
+ let B = t(() => {
6307
+ let e = C.selectedBlockId.value;
6308
+ return e && C.blocks.value.find((t) => t.id === e)?.metadata?.blockGroup || "";
6309
+ }), ce = t(() => {
6310
+ let e = C.selectedBlockId.value;
6311
+ return e ? !!C.blocks.value.find((t) => t.id === e)?.metadata?._splitBackup : !1;
6312
+ });
6313
+ function le() {
6314
+ let e = B.value;
6315
+ e && (C.mergeSubQuestionGroup(e), S("change"));
6316
+ }
6317
+ function V() {
6318
+ let e = C.selectedBlockId.value;
6319
+ e && (C.splitMergedBlock(e), S("change"));
6320
+ }
6321
+ let H = f(null), ue = t(() => H.value ? {
6076
6322
  position: "absolute",
6077
- left: V.value.left + "px",
6078
- top: V.value.top + "px",
6079
- width: V.value.width + "px",
6080
- height: V.value.height + "px",
6323
+ left: H.value.left + "px",
6324
+ top: H.value.top + "px",
6325
+ width: H.value.width + "px",
6326
+ height: H.value.height + "px",
6081
6327
  pointerEvents: "auto"
6082
6328
  } : {
6083
6329
  display: "none",
6084
6330
  position: "absolute"
6085
6331
  });
6086
- function ce() {
6332
+ function de() {
6087
6333
  let e = C.selectedUnderlineId.value;
6088
6334
  if (!e) {
6089
- V.value = null;
6335
+ H.value = null;
6090
6336
  return;
6091
6337
  }
6092
6338
  let t = document.querySelector(".pe-editor-page.active");
6093
6339
  if (!t) {
6094
- V.value = null;
6340
+ H.value = null;
6095
6341
  return;
6096
6342
  }
6097
6343
  let n = t.querySelector(`[data-underline-id="${CSS.escape(e)}"]`);
6098
6344
  if (!n) {
6099
- V.value = null;
6345
+ H.value = null;
6100
6346
  return;
6101
6347
  }
6102
6348
  let r = t.closest(".pe-editor-surface");
6103
6349
  if (!r) {
6104
- V.value = null;
6350
+ H.value = null;
6105
6351
  return;
6106
6352
  }
6107
6353
  let i = n.getBoundingClientRect(), a = r.getBoundingClientRect();
6108
- V.value = {
6354
+ H.value = {
6109
6355
  left: i.left - a.left + r.scrollLeft,
6110
6356
  top: i.top - a.top + r.scrollTop,
6111
6357
  width: i.width,
6112
6358
  height: i.height
6113
6359
  };
6114
6360
  }
6115
- let H = f(null), le = t(() => H.value ? {
6361
+ let U = f(null), fe = t(() => U.value ? {
6116
6362
  position: "absolute",
6117
- left: H.value.left + "px",
6118
- top: H.value.top + "px",
6119
- width: H.value.width + "px",
6120
- height: H.value.height + "px",
6363
+ left: U.value.left + "px",
6364
+ top: U.value.top + "px",
6365
+ width: U.value.width + "px",
6366
+ height: U.value.height + "px",
6121
6367
  pointerEvents: "auto"
6122
6368
  } : {
6123
6369
  display: "none",
6124
6370
  position: "absolute"
6125
6371
  });
6126
- function ue() {
6372
+ function pe() {
6127
6373
  let e = C.selectedImageId.value;
6128
6374
  if (!e) {
6129
- H.value = null;
6375
+ U.value = null;
6130
6376
  return;
6131
6377
  }
6132
6378
  let t = document.querySelector(".pe-editor-page.active");
6133
6379
  if (!t) {
6134
- H.value = null;
6380
+ U.value = null;
6135
6381
  return;
6136
6382
  }
6137
6383
  let n = t.querySelector(`[data-image-id="${CSS.escape(e)}"]`);
6138
6384
  if (!n) {
6139
- H.value = null;
6385
+ U.value = null;
6140
6386
  return;
6141
6387
  }
6142
6388
  let r = n.querySelector("image") || n, i = t.closest(".pe-editor-surface");
6143
6389
  if (!i) {
6144
- H.value = null;
6390
+ U.value = null;
6145
6391
  return;
6146
6392
  }
6147
6393
  let a = r.getBoundingClientRect(), o = i.getBoundingClientRect();
6148
- H.value = {
6394
+ U.value = {
6149
6395
  left: a.left - o.left + i.scrollLeft,
6150
6396
  top: a.top - o.top + i.scrollTop,
6151
6397
  width: a.width,
6152
6398
  height: a.height
6153
6399
  };
6154
6400
  }
6155
- let de = t(() => C.selectedImageId.value ? C.getImageParagraphInfo(C.selectedImageId.value) : null), fe = t(() => !!(de.value?.isStandalone && H.value)), pe = t(() => H.value ? {
6156
- left: H.value.left + "px",
6157
- top: H.value.top + H.value.height + 4 + "px",
6401
+ let me = t(() => C.selectedImageId.value ? C.getImageParagraphInfo(C.selectedImageId.value) : null), he = t(() => !!(me.value?.isStandalone && U.value)), ge = t(() => U.value ? {
6402
+ left: U.value.left + "px",
6403
+ top: U.value.top + U.value.height + 4 + "px",
6158
6404
  pointerEvents: "auto"
6159
6405
  } : null);
6160
- function me(e) {
6406
+ function _e(e) {
6161
6407
  let t = C.selectedImageId.value;
6162
- t && (C.updateImageAlignment(t, e), o(() => U()));
6408
+ t && (C.updateImageAlignment(t, e), o(() => W()));
6163
6409
  }
6164
- let he = 0;
6165
- function U() {
6166
- he && cancelAnimationFrame(he), he = requestAnimationFrame(() => {
6167
- he = 0, B(), ce(), ue();
6410
+ let ve = 0;
6411
+ function W() {
6412
+ ve && cancelAnimationFrame(ve), ve = requestAnimationFrame(() => {
6413
+ ve = 0, z(), de(), pe();
6168
6414
  });
6169
6415
  }
6170
6416
  v(() => C.selectedBlockId.value, async () => {
6171
- await o(), U();
6417
+ await o(), W();
6172
6418
  }), v(() => T.value, async () => {
6173
- await o(), U();
6419
+ await o(), W();
6174
6420
  }), v(() => E.value, async () => {
6175
- await o(), U(), S("page-change", E.value);
6421
+ await o(), W(), S("page-change", E.value);
6176
6422
  }), v(() => C.layoutVersion.value, () => {
6177
- R(), o(() => U());
6423
+ L(), o(() => W());
6178
6424
  }), v(() => C.selectedUnderlineId.value, async () => {
6179
- await o(), U();
6425
+ await o(), W();
6180
6426
  }), v(() => C.selectedImageId.value, async () => {
6181
- await o(), U();
6427
+ await o(), W();
6182
6428
  }), v(() => [
6183
6429
  C.paperName.value,
6184
6430
  C.schoolName.value,
6185
6431
  C.totalScore.value
6186
6432
  ], () => {
6187
- R();
6433
+ L();
6188
6434
  });
6189
- let ge = f(!1), W = f(null), _e = f(0), ve = f(0);
6190
- function ye(e) {
6435
+ let ye = f(!1), be = f(null), xe = f(0), Se = f(0);
6436
+ function G(e) {
6191
6437
  let t = C.selectedBlockId.value;
6192
6438
  if (!t) return;
6193
6439
  let n = C.blocks.value.find((e) => e.id === t);
6194
- n && (e.stopPropagation(), ge.value = !0, W.value = t, _e.value = e.clientY, ve.value = n.height, document.body.style.cursor = "ns-resize", document.body.style.userSelect = "none", document.addEventListener("mousemove", be), document.addEventListener("mouseup", xe));
6440
+ n && (e.stopPropagation(), ye.value = !0, be.value = t, xe.value = e.clientY, Se.value = n.height, document.body.style.cursor = "ns-resize", document.body.style.userSelect = "none", document.addEventListener("mousemove", Ce), document.addEventListener("mouseup", we));
6195
6441
  }
6196
- function be(e) {
6197
- if (!ge.value || !W.value) return;
6198
- let t = (e.clientY - _e.value) / T.value;
6199
- C.updateBlockHeight(W.value, ve.value + t), o(() => B());
6442
+ function Ce(e) {
6443
+ if (!ye.value || !be.value) return;
6444
+ let t = (e.clientY - xe.value) / T.value;
6445
+ C.updateBlockHeight(be.value, Se.value + t), o(() => z());
6200
6446
  }
6201
- function xe(e) {
6202
- ge.value = !1, W.value = null, document.body.style.cursor = "", document.body.style.userSelect = "", document.removeEventListener("mousemove", be), document.removeEventListener("mouseup", xe), R();
6447
+ function we(e) {
6448
+ ye.value = !1, be.value = null, document.body.style.cursor = "", document.body.style.userSelect = "", document.removeEventListener("mousemove", Ce), document.removeEventListener("mouseup", we), L();
6203
6449
  }
6204
- let Se = f(!1), G = f(null), Ce = f(0), we = f(0);
6205
- function Te(e, t) {
6450
+ let Te = f(!1), Ee = f(null), K = f(0), De = f(0);
6451
+ function Oe(e, t) {
6206
6452
  let n = C.selectedUnderlineId.value;
6207
6453
  if (!n) return;
6208
6454
  let r = C.findUnderlineById(n);
6209
- r && (t.stopPropagation(), Se.value = !0, G.value = e, Ce.value = t.clientX, we.value = r.underline.width, document.body.style.cursor = "ew-resize", document.body.style.userSelect = "none", document.addEventListener("mousemove", Ee), document.addEventListener("mouseup", K));
6455
+ r && (t.stopPropagation(), Te.value = !0, Ee.value = e, K.value = t.clientX, De.value = r.underline.width, document.body.style.cursor = "ew-resize", document.body.style.userSelect = "none", document.addEventListener("mousemove", q), document.addEventListener("mouseup", ke));
6210
6456
  }
6211
- function Ee(e) {
6212
- if (!Se.value || !G.value) return;
6457
+ function q(e) {
6458
+ if (!Te.value || !Ee.value) return;
6213
6459
  let t = C.selectedUnderlineId.value;
6214
6460
  if (!t) return;
6215
- let n = (e.clientX - Ce.value) / T.value, r = G.value === "right" ? n : -n;
6216
- C.updateUnderlineWidth(t, we.value + r), o(() => ce());
6461
+ let n = (e.clientX - K.value) / T.value, r = Ee.value === "right" ? n : -n;
6462
+ C.updateUnderlineWidth(t, De.value + r), o(() => de());
6217
6463
  }
6218
- function K(e) {
6219
- Se.value = !1, G.value = null, document.body.style.cursor = "", document.body.style.userSelect = "", document.removeEventListener("mousemove", Ee), document.removeEventListener("mouseup", K), R();
6464
+ function ke(e) {
6465
+ Te.value = !1, Ee.value = null, document.body.style.cursor = "", document.body.style.userSelect = "", document.removeEventListener("mousemove", q), document.removeEventListener("mouseup", ke), L();
6220
6466
  }
6221
- let De = f(!1), Oe = f(null), q = f(0), ke = f(0), Ae = f(0), je = f(0);
6222
- function Me(e, t) {
6467
+ let Ae = f(!1), je = f(null), Me = f(0), Ne = f(0), Pe = f(0), Fe = f(0);
6468
+ function Ie(e, t) {
6223
6469
  if (t.button !== 0) return;
6224
6470
  let n = C.selectedImageId.value;
6225
6471
  if (!n) return;
6226
6472
  let r = C.findInlineImageById(n);
6227
- r && (t.stopPropagation(), De.value = !0, Oe.value = e, q.value = t.clientX, ke.value = t.clientY, Ae.value = r.image.width, je.value = r.image.height, document.body.style.userSelect = "none", document.addEventListener("mousemove", Ne), document.addEventListener("mouseup", Pe));
6473
+ r && (t.stopPropagation(), Ae.value = !0, je.value = e, Me.value = t.clientX, Ne.value = t.clientY, Pe.value = r.image.width, Fe.value = r.image.height, document.body.style.userSelect = "none", document.addEventListener("mousemove", Le), document.addEventListener("mouseup", Re));
6228
6474
  }
6229
- function Ne(e) {
6230
- if (!De.value || !Oe.value) return;
6475
+ function Le(e) {
6476
+ if (!Ae.value || !je.value) return;
6231
6477
  let t = C.selectedImageId.value;
6232
6478
  if (!t) return;
6233
- let n = (e.clientX - q.value) / T.value, r = Oe.value, i = Ae.value;
6479
+ let n = (e.clientX - Me.value) / T.value, r = je.value, i = Pe.value;
6234
6480
  if (r.includes("e") ? i += n : r.includes("w") && (i -= n), !C.findInlineImageById(t)) return;
6235
- let a = je.value / Math.max(1, Ae.value), s = Math.max(12, Math.round(i * a));
6236
- C.updateInlineImageSize(t, i, s), o(() => ue());
6481
+ let a = Fe.value / Math.max(1, Pe.value), s = Math.max(12, Math.round(i * a));
6482
+ C.updateInlineImageSize(t, i, s), o(() => pe());
6237
6483
  }
6238
- function Pe(e) {
6239
- De.value = !1, Oe.value = null, document.body.style.userSelect = "", document.removeEventListener("mousemove", Ne), document.removeEventListener("mouseup", Pe), R();
6484
+ function Re(e) {
6485
+ Ae.value = !1, je.value = null, document.body.style.userSelect = "", document.removeEventListener("mousemove", Le), document.removeEventListener("mouseup", Re), L();
6240
6486
  }
6241
- function Fe(e) {
6242
- C.loadDocument(e), R(), S("loaded"), S("change");
6487
+ function ze(e) {
6488
+ C.loadDocument(e), L(), S("loaded"), S("change");
6243
6489
  }
6244
- let Ie = f(!1);
6490
+ function Be(e) {
6491
+ let t = -1;
6492
+ for (let n = 0; n < C.pages.value.length; n++) if (C.pages.value[n].blocks.some((t) => t.blockId === e)) {
6493
+ t = n;
6494
+ break;
6495
+ }
6496
+ t < 0 || (E.value = t, o(() => {
6497
+ let e = document.querySelectorAll(".pe-editor-page")[t];
6498
+ if (e && O.value) {
6499
+ let t = O.value, n = t.getBoundingClientRect(), r = e.getBoundingClientRect();
6500
+ t.scrollTop += r.top - n.top - 20;
6501
+ }
6502
+ }));
6503
+ }
6504
+ let Ve = f(!1);
6245
6505
  function J() {
6246
6506
  let e = w.cursor.value;
6247
6507
  if (!e.blockId) return;
@@ -6290,7 +6550,7 @@ var Wn = { class: "pe-root" }, Gn = { class: "pe-main" }, Kn = { class: "pe-edit
6290
6550
  let s = m.lines[i], c = s.offsetX || 0, u = 0;
6291
6551
  if (a.paragraphStart === 0 && e.metadata?.score && i === 0 && n === (f[0] ?? 0)) {
6292
6552
  let t = C.settings.value.fontSize, n = typeof t == "number" ? t : 14;
6293
- u = oe(`(${e.metadata.score}分)`, n, "SimSun, STSong, serif");
6553
+ u = se(`(${e.metadata.score}分)`, n, "SimSun, STSong, serif");
6294
6554
  }
6295
6555
  let d = u, h = !1;
6296
6556
  for (let e of s.elements) {
@@ -6330,16 +6590,16 @@ var Wn = { class: "pe-root" }, Gn = { class: "pe-main" }, Kn = { class: "pe-edit
6330
6590
  });
6331
6591
  });
6332
6592
  }
6333
- function Le(e) {
6334
- if (w.cursor.value.blockId && !(Ie.value && e.key === "Enter")) switch (e.key) {
6593
+ function He(e) {
6594
+ if (w.cursor.value.blockId && !(Ve.value && e.key === "Enter")) switch (e.key) {
6335
6595
  case "Enter":
6336
- e.preventDefault(), w.splitAtCursor(), J();
6596
+ e.preventDefault(), C.saveUndoSnapshot(), w.splitAtCursor(), J();
6337
6597
  break;
6338
6598
  case "Backspace":
6339
- e.preventDefault(), w.backspace(), J();
6599
+ e.preventDefault(), C.saveUndoSnapshot(), w.backspace(), J();
6340
6600
  break;
6341
6601
  case "Delete":
6342
- e.preventDefault(), w.deleteForward(), J();
6602
+ e.preventDefault(), C.saveUndoSnapshot(), w.deleteForward(), J();
6343
6603
  break;
6344
6604
  case "ArrowLeft":
6345
6605
  e.preventDefault(), w.moveCursorLeft(), J();
@@ -6355,32 +6615,32 @@ var Wn = { class: "pe-root" }, Gn = { class: "pe-main" }, Kn = { class: "pe-edit
6355
6615
  break;
6356
6616
  }
6357
6617
  }
6358
- function Re(e) {
6359
- if (Ie.value) return;
6618
+ function Ue(e) {
6619
+ if (Ve.value) return;
6360
6620
  let t = e.target, n = t.value;
6361
- n && w.cursor.value.blockId && (w.insertText(n), t.value = "", J());
6621
+ n && w.cursor.value.blockId && (C.saveUndoSnapshot(), w.insertText(n), t.value = "", J());
6362
6622
  }
6363
- function ze() {
6364
- Ie.value = !0;
6623
+ function We() {
6624
+ Ve.value = !0;
6365
6625
  }
6366
- function Be(e) {
6367
- Ie.value = !1;
6626
+ function Ge(e) {
6627
+ Ve.value = !1;
6368
6628
  let t = k.value;
6369
6629
  if (t) {
6370
6630
  let e = t.value;
6371
- e && w.cursor.value.blockId && (w.insertText(e), t.value = "", J());
6631
+ e && w.cursor.value.blockId && (C.saveUndoSnapshot(), w.insertText(e), t.value = "", J());
6372
6632
  }
6373
6633
  }
6374
6634
  return l(() => {
6375
- x.initialData ? Fe(x.initialData) : C.relayout(), x.paperName && (C.paperName.value = x.paperName), x.schoolName && (C.schoolName.value = x.schoolName), x.qrCodeContent && (C.qrCodeContent.value = x.qrCodeContent), S("ready");
6635
+ x.initialData ? ze(x.initialData) : C.relayout(), x.paperName && (C.paperName.value = x.paperName), x.schoolName && (C.schoolName.value = x.schoolName), x.qrCodeContent && (C.qrCodeContent.value = x.qrCodeContent), S("ready");
6376
6636
  }), u(() => {
6377
- document.removeEventListener("mousemove", be), document.removeEventListener("mouseup", xe), document.removeEventListener("mousemove", Ee), document.removeEventListener("mouseup", K), document.removeEventListener("mousemove", Ne), document.removeEventListener("mouseup", Pe);
6637
+ document.removeEventListener("mousemove", Ce), document.removeEventListener("mouseup", we), document.removeEventListener("mousemove", q), document.removeEventListener("mouseup", ke), document.removeEventListener("mousemove", Le), document.removeEventListener("mouseup", Re);
6378
6638
  }), v(() => x.qrCodeContent, (e) => {
6379
6639
  C.qrCodeContent.value = e || "";
6380
6640
  }), m({
6381
6641
  document: {
6382
6642
  save: () => C.saveDocument(),
6383
- load: (e) => Fe(e),
6643
+ load: (e) => ze(e),
6384
6644
  getBlocks: () => C.blocks.value,
6385
6645
  isDirty: () => C.isDirty.value
6386
6646
  },
@@ -6436,25 +6696,31 @@ var Wn = { class: "pe-root" }, Gn = { class: "pe-main" }, Kn = { class: "pe-edit
6436
6696
  },
6437
6697
  updateSplit: (e, t) => {
6438
6698
  C.updateBlockSplit(e, t), S("change");
6699
+ },
6700
+ mergeGroup: (e) => {
6701
+ C.mergeSubQuestionGroup(e), S("change");
6702
+ },
6703
+ splitBlock: (e) => {
6704
+ C.splitMergedBlock(e), S("change");
6439
6705
  }
6440
6706
  },
6441
6707
  layout: {
6442
6708
  setPaperSize: (e) => {
6443
- C.updateSettings({ paperSize: e }), R();
6709
+ C.updateSettings({ paperSize: e }), L();
6444
6710
  },
6445
6711
  setColumns: (e) => {
6446
- C.updateSettings({ columns: e }), R();
6712
+ C.updateSettings({ columns: e }), L();
6447
6713
  },
6448
6714
  setFontSize: (e) => {
6449
- C.updateSettings({ fontSize: e }), R();
6715
+ C.updateSettings({ fontSize: e }), L();
6450
6716
  },
6451
6717
  setLineSpacing: (e) => {
6452
- C.updateSettings({ lineSpacing: e }), R();
6718
+ C.updateSettings({ lineSpacing: e }), L();
6453
6719
  },
6454
6720
  updateSettings: (e) => {
6455
- C.updateSettings(e), R();
6721
+ C.updateSettings(e), L();
6456
6722
  },
6457
- reflow: () => ee()
6723
+ reflow: () => te()
6458
6724
  },
6459
6725
  selection: {
6460
6726
  selectBlock: (e) => C.selectBlock(e),
@@ -6467,16 +6733,21 @@ var Wn = { class: "pe-root" }, Gn = { class: "pe-main" }, Kn = { class: "pe-edit
6467
6733
  },
6468
6734
  goToPage: (e) => {
6469
6735
  E.value = e;
6470
- }
6736
+ },
6737
+ scrollToBlock: (e) => Be(e)
6471
6738
  },
6472
6739
  render: {
6473
- getPageSvgs: () => P.value,
6474
- getCleanPageSvgs: () => F(),
6475
- getAllPagesSvg: () => I.value
6740
+ getPageSvgs: () => N.value,
6741
+ getCleanPageSvgs: () => P(),
6742
+ getAllPagesSvg: () => F.value
6476
6743
  },
6477
6744
  setQRCode: (e) => {
6478
6745
  C.qrCodeContent.value = e;
6479
6746
  },
6747
+ canUndo: C.canUndo,
6748
+ undo: () => {
6749
+ C.undo(), S("change");
6750
+ },
6480
6751
  state: t(() => ({
6481
6752
  blocks: C.blocks.value,
6482
6753
  pages: C.pages.value,
@@ -6487,7 +6758,7 @@ var Wn = { class: "pe-root" }, Gn = { class: "pe-main" }, Kn = { class: "pe-edit
6487
6758
  selectedImageId: C.selectedImageId.value,
6488
6759
  selectedUnderlineInfo: C.selectedUnderlineInfo.value,
6489
6760
  selectedImageInfo: C.selectedImageInfo.value,
6490
- selectedImageAlignment: de.value,
6761
+ selectedImageAlignment: me.value,
6491
6762
  totalScore: C.totalScore.value,
6492
6763
  zoom: T.value,
6493
6764
  currentPage: E.value,
@@ -6500,7 +6771,7 @@ var Wn = { class: "pe-root" }, Gn = { class: "pe-main" }, Kn = { class: "pe-edit
6500
6771
  qrCodeImages: C.qrCodeImages.value,
6501
6772
  showScore: C.settings.value.showScore
6502
6773
  }))
6503
- }), (t, a) => (d(), r("div", Wn, [i("div", Gn, [i("div", Kn, [i("div", {
6774
+ }), (t, a) => (d(), r("div", qn, [i("div", Jn, [i("div", Yn, [i("div", {
6504
6775
  class: "pe-editor-surface",
6505
6776
  ref_key: "saberEditorRef",
6506
6777
  ref: O
@@ -6509,41 +6780,51 @@ var Wn = { class: "pe-root" }, Gn = { class: "pe-main" }, Kn = { class: "pe-edit
6509
6780
  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",
6510
6781
  fill: "currentColor"
6511
6782
  })])])], -1),
6512
- i("div", qn, [(d(!0), r(e, null, p(g(P), (e, t) => (d(), r("div", {
6783
+ i("div", Xn, [(d(!0), r(e, null, p(g(N), (e, t) => (d(), r("div", {
6513
6784
  key: t,
6514
6785
  class: s(["pe-editor-page", { active: t === E.value }]),
6515
6786
  onClick: b((e) => E.value = t, ["stop"])
6516
6787
  }, [i("div", {
6517
6788
  class: "pe-editor-viewport",
6518
6789
  innerHTML: e,
6519
- onClick: re,
6520
- onFocusout: ie
6521
- }, null, 40, Yn)], 10, Jn))), 128))]),
6522
- i("div", Xn, [
6523
- z.value ? (d(), r("div", {
6790
+ onClick: ie,
6791
+ onFocusout: ae
6792
+ }, null, 40, Qn)], 10, Zn))), 128))]),
6793
+ i("div", $n, [
6794
+ R.value ? (d(), r("div", {
6524
6795
  key: 0,
6525
6796
  class: "pe-ctrl-block",
6526
- style: c(ae.value)
6527
- }, [i("div", {
6528
- class: "pe-ctrl-height",
6529
- onMousedown: b(ye, ["prevent"])
6530
- }, [...a[9] ||= [i("svg", {
6531
- xmlns: "http://www.w3.org/2000/svg",
6532
- width: "16",
6533
- height: "16",
6534
- viewBox: "0 0 16 16"
6535
- }, [i("path", {
6536
- fill: "currentColor",
6537
- "fill-rule": "evenodd",
6538
- d: "M14 8a.75.75 0 0 1-.75.75h-4.5V12h1.75l-2.519 3L5.5 12l1.75-.001v-3.25l-4.5.001a.75.75 0 1 1 0-1.5l4.5-.001v-3.25L5.5 4l2.519-3L10.5 4H8.75v3.25h4.5A.75.75 0 0 1 14 8"
6539
- })], -1)]], 32)], 4)) : n("", !0),
6540
- V.value ? (d(), r("div", {
6797
+ style: c(oe.value)
6798
+ }, [
6799
+ i("div", {
6800
+ class: "pe-ctrl-height",
6801
+ onMousedown: b(G, ["prevent"])
6802
+ }, [...a[9] ||= [i("svg", {
6803
+ xmlns: "http://www.w3.org/2000/svg",
6804
+ width: "16",
6805
+ height: "16",
6806
+ viewBox: "0 0 16 16"
6807
+ }, [i("path", {
6808
+ fill: "currentColor",
6809
+ "fill-rule": "evenodd",
6810
+ d: "M14 8a.75.75 0 0 1-.75.75h-4.5V12h1.75l-2.519 3L5.5 12l1.75-.001v-3.25l-4.5.001a.75.75 0 1 1 0-1.5l4.5-.001v-3.25L5.5 4l2.519-3L10.5 4H8.75v3.25h4.5A.75.75 0 0 1 14 8"
6811
+ })], -1)]], 32),
6812
+ B.value ? (d(), r("div", er, [i("button", {
6813
+ class: "pe-merge-btn",
6814
+ onMousedown: b(le, ["stop"])
6815
+ }, "合并子题", 32)])) : n("", !0),
6816
+ ce.value ? (d(), r("div", tr, [i("button", {
6817
+ class: "pe-split-btn",
6818
+ onMousedown: b(V, ["stop"])
6819
+ }, "拆分子题", 32)])) : n("", !0)
6820
+ ], 4)) : n("", !0),
6821
+ H.value ? (d(), r("div", {
6541
6822
  key: 1,
6542
6823
  class: "pe-ctrlUnderline",
6543
- style: c(se.value)
6824
+ style: c(ue.value)
6544
6825
  }, [i("div", {
6545
6826
  class: "pe-ctrl-ul-left",
6546
- onMousedown: a[0] ||= b((e) => Te("left", e), ["prevent"])
6827
+ onMousedown: a[0] ||= b((e) => Oe("left", e), ["prevent"])
6547
6828
  }, [...a[10] ||= [i("svg", {
6548
6829
  xmlns: "http://www.w3.org/2000/svg",
6549
6830
  width: "12",
@@ -6554,7 +6835,7 @@ var Wn = { class: "pe-root" }, Gn = { class: "pe-main" }, Kn = { class: "pe-edit
6554
6835
  d: "M10.5 4L7.5 8l3 4H2V4z"
6555
6836
  })], -1)]], 32), i("div", {
6556
6837
  class: "pe-ctrl-ul-right",
6557
- onMousedown: a[1] ||= b((e) => Te("right", e), ["prevent"])
6838
+ onMousedown: a[1] ||= b((e) => Oe("right", e), ["prevent"])
6558
6839
  }, [...a[11] ||= [i("svg", {
6559
6840
  xmlns: "http://www.w3.org/2000/svg",
6560
6841
  width: "12",
@@ -6564,46 +6845,46 @@ var Wn = { class: "pe-root" }, Gn = { class: "pe-main" }, Kn = { class: "pe-edit
6564
6845
  fill: "currentColor",
6565
6846
  d: "M5.5 4L8.5 8l-3 4H14V4z"
6566
6847
  })], -1)]], 32)], 4)) : n("", !0),
6567
- H.value ? (d(), r("div", {
6848
+ U.value ? (d(), r("div", {
6568
6849
  key: 2,
6569
6850
  class: "pe-ctrlAnchor",
6570
- style: c(le.value)
6851
+ style: c(fe.value)
6571
6852
  }, [
6572
6853
  i("div", {
6573
6854
  class: "pe-resize-se",
6574
- onMousedown: a[2] ||= b((e) => Me("se", e), ["prevent", "stop"])
6855
+ onMousedown: a[2] ||= b((e) => Ie("se", e), ["prevent", "stop"])
6575
6856
  }, null, 32),
6576
6857
  i("div", {
6577
6858
  class: "pe-resize-sw",
6578
- onMousedown: a[3] ||= b((e) => Me("sw", e), ["prevent", "stop"])
6859
+ onMousedown: a[3] ||= b((e) => Ie("sw", e), ["prevent", "stop"])
6579
6860
  }, null, 32),
6580
6861
  i("div", {
6581
6862
  class: "pe-resize-ne",
6582
- onMousedown: a[4] ||= b((e) => Me("ne", e), ["prevent", "stop"])
6863
+ onMousedown: a[4] ||= b((e) => Ie("ne", e), ["prevent", "stop"])
6583
6864
  }, null, 32),
6584
6865
  i("div", {
6585
6866
  class: "pe-resize-nw",
6586
- onMousedown: a[5] ||= b((e) => Me("nw", e), ["prevent", "stop"])
6867
+ onMousedown: a[5] ||= b((e) => Ie("nw", e), ["prevent", "stop"])
6587
6868
  }, null, 32)
6588
6869
  ], 4)) : n("", !0),
6589
- fe.value ? (d(), r("div", {
6870
+ he.value ? (d(), r("div", {
6590
6871
  key: 3,
6591
6872
  class: "pe-img-align-bar",
6592
- style: c(pe.value)
6873
+ style: c(ge.value)
6593
6874
  }, [
6594
6875
  i("button", {
6595
- class: s(["pe-align-btn", { active: de.value?.alignment === "left" }]),
6596
- onClick: a[6] ||= (e) => me("left"),
6876
+ class: s(["pe-align-btn", { active: me.value?.alignment === "left" }]),
6877
+ onClick: a[6] ||= (e) => _e("left"),
6597
6878
  title: "左对齐"
6598
6879
  }, "左", 2),
6599
6880
  i("button", {
6600
- class: s(["pe-align-btn", { active: de.value?.alignment === "center" }]),
6601
- onClick: a[7] ||= (e) => me("center"),
6881
+ class: s(["pe-align-btn", { active: me.value?.alignment === "center" }]),
6882
+ onClick: a[7] ||= (e) => _e("center"),
6602
6883
  title: "居中对齐"
6603
6884
  }, "中", 2),
6604
6885
  i("button", {
6605
- class: s(["pe-align-btn", { active: de.value?.alignment === "right" }]),
6606
- onClick: a[8] ||= (e) => me("right"),
6886
+ class: s(["pe-align-btn", { active: me.value?.alignment === "right" }]),
6887
+ onClick: a[8] ||= (e) => _e("right"),
6607
6888
  title: "右对齐"
6608
6889
  }, "右", 2)
6609
6890
  ], 4)) : n("", !0)
@@ -6615,28 +6896,28 @@ var Wn = { class: "pe-root" }, Gn = { class: "pe-main" }, Kn = { class: "pe-edit
6615
6896
  class: "pe-editor-virtual-input",
6616
6897
  ref_key: "virtualInputRef",
6617
6898
  ref: k,
6618
- onKeydown: Le,
6619
- onInput: Re,
6620
- onCompositionstart: ze,
6621
- onCompositionend: Be
6899
+ onKeydown: He,
6900
+ onInput: Ue,
6901
+ onCompositionstart: We,
6902
+ onCompositionend: Ge
6622
6903
  }, null, 544)], 4),
6623
6904
  y(i("div", {
6624
6905
  class: "pe-editor-cursor",
6625
- style: c(N.value)
6906
+ style: c(ee.value)
6626
6907
  }, null, 4), [[_, D.value]])
6627
6908
  ], 512)])])]));
6628
6909
  }
6629
- }), Qn = (e, t) => {
6910
+ }), rr = (e, t) => {
6630
6911
  let n = e.__vccOpts || e;
6631
6912
  for (let [e, r] of t) n[e] = r;
6632
6913
  return n;
6633
- }, $n = /*#__PURE__*/ Qn(Zn, [["__scopeId", "data-v-152f108d"]]), er = { class: "pe-preview__pages" }, tr = ["innerHTML"], nr = {
6914
+ }, ir = /*#__PURE__*/ rr(nr, [["__scopeId", "data-v-b29566da"]]), ar = { class: "pe-preview__pages" }, or = ["innerHTML"], sr = {
6634
6915
  key: 0,
6635
6916
  class: "pe-preview__helpers"
6636
- }, rr = {
6917
+ }, cr = {
6637
6918
  key: 1,
6638
6919
  class: "pe-preview__page-num"
6639
- }, ir = /*#__PURE__*/ Qn(/* @__PURE__ */ a({
6920
+ }, lr = /*#__PURE__*/ rr(/* @__PURE__ */ a({
6640
6921
  __name: "PaperPreview",
6641
6922
  props: {
6642
6923
  document: {},
@@ -6663,14 +6944,14 @@ var Wn = { class: "pe-root" }, Gn = { class: "pe-main" }, Kn = { class: "pe-edit
6663
6944
  }
6664
6945
  },
6665
6946
  setup(a) {
6666
- let o = a, m = Ln();
6947
+ let o = a, m = Bn();
6667
6948
  function _() {
6668
6949
  o.document && m.loadDocument(o.document);
6669
6950
  }
6670
6951
  _(), v(() => o.document, _), v(() => o.pureMode, (e) => {
6671
6952
  m.setRenderMode(e ? "view" : "edit");
6672
6953
  }, { immediate: !0 });
6673
- let y = zn(m, { selectedBlockId: null }), b = f(), x = f(0), S = null;
6954
+ let y = Hn(m, { selectedBlockId: null }), b = f(), x = f(0), S = null;
6674
6955
  l(() => {
6675
6956
  x.value = b.value?.clientWidth ?? 0, S = new ResizeObserver((e) => {
6676
6957
  for (let t of e) x.value = Math.floor(t.contentRect.width);
@@ -6703,6 +6984,7 @@ var Wn = { class: "pe-root" }, Gn = { class: "pe-main" }, Kn = { class: "pe-edit
6703
6984
  "student-name": "#3498db",
6704
6985
  "student-class": "#3498db",
6705
6986
  "student-code": "#3498db",
6987
+ "student-code-filler": "#e67e22",
6706
6988
  score: "#e74c3c",
6707
6989
  "page-number": "#95a5a6",
6708
6990
  "question-border": "#e74c3c",
@@ -6716,6 +6998,7 @@ var Wn = { class: "pe-root" }, Gn = { class: "pe-main" }, Kn = { class: "pe-edit
6716
6998
  studentName: "student-name",
6717
6999
  studentClass: "student-class",
6718
7000
  studentCode: "student-code",
7001
+ studentCodeFiller: "student-code-filler",
6719
7002
  score: "score"
6720
7003
  };
6721
7004
  function D(e) {
@@ -6820,7 +7103,7 @@ var Wn = { class: "pe-root" }, Gn = { class: "pe-main" }, Kn = { class: "pe-edit
6820
7103
  height: `${(n * w.value.y).toFixed(1)}mm`
6821
7104
  };
6822
7105
  }
6823
- function N(e) {
7106
+ function ee(e) {
6824
7107
  return {
6825
7108
  position: "absolute",
6826
7109
  outline: `1px solid ${e.color}`,
@@ -6836,7 +7119,7 @@ var Wn = { class: "pe-root" }, Gn = { class: "pe-main" }, Kn = { class: "pe-edit
6836
7119
  class: s(["pe-preview", { "pe-preview--print": a.mode === "print" }]),
6837
7120
  ref_key: "previewRef",
6838
7121
  ref: b
6839
- }, [i("div", er, [(d(!0), r(e, null, p(g(y), (t, o) => (d(), r("div", {
7122
+ }, [i("div", ar, [(d(!0), r(e, null, p(g(y), (t, o) => (d(), r("div", {
6840
7123
  key: o,
6841
7124
  class: "pe-preview__page",
6842
7125
  style: c(k(o))
@@ -6850,19 +7133,19 @@ var Wn = { class: "pe-root" }, Gn = { class: "pe-main" }, Kn = { class: "pe-edit
6850
7133
  width: "100%",
6851
7134
  height: "100%"
6852
7135
  }
6853
- }, null, 8, tr)], 4),
6854
- a.showHelpers ? (d(), r("div", nr, [a.showCornerMarks ? (d(!0), r(e, { key: 0 }, p(D(o), (e, t) => (d(), r("span", {
7136
+ }, null, 8, or)], 4),
7137
+ a.showHelpers ? (d(), r("div", sr, [a.showCornerMarks ? (d(!0), r(e, { key: 0 }, p(D(o), (e, t) => (d(), r("span", {
6855
7138
  key: "cm-" + t,
6856
7139
  class: s(["pe-preview__helper-box", e.className]),
6857
- style: c(N(e))
7140
+ style: c(ee(e))
6858
7141
  }, null, 6))), 128)) : n("", !0), a.showRegionBoxes ? (d(!0), r(e, { key: 1 }, p(O(o), (e, t) => (d(), r("span", {
6859
7142
  key: "rg-" + t,
6860
7143
  class: s(["pe-preview__helper-box", e.className]),
6861
- style: c(N(e))
7144
+ style: c(ee(e))
6862
7145
  }, null, 6))), 128)) : n("", !0)])) : n("", !0),
6863
- a.showPageNumbers ? (d(), r("div", rr, h(o + 1) + " / " + h(g(m).pages.value.length), 1)) : n("", !0)
7146
+ a.showPageNumbers ? (d(), r("div", cr, h(o + 1) + " / " + h(g(m).pages.value.length), 1)) : n("", !0)
6864
7147
  ], 4))), 128))])], 2));
6865
7148
  }
6866
- }), [["__scopeId", "data-v-1b638e19"]]);
7149
+ }), [["__scopeId", "data-v-e8f833b5"]]);
6867
7150
  //#endregion
6868
- export { vn as FONT_SIZE_MAP, A as PAPER_DIMENSIONS, j as PAPER_MM, $n as PaperEditor, ee as PaperLayout, ir as PaperPreview, Se as SvgRenderer, Bt as buildPaperHtml, V as calcCharPositions, oe as calcTextWidth, Ee as clearFormulaCache, ce as clearWidthCache, gt as deserializeDocument, Rt as extractBaseTitle, yn as fontSizeLabelToPx, bn as fontSizePxToLabel, Lt as formatSectionTitle, B as getCharWidth, N as getPaperPreset, Hn as hasTablePlaceholder, K as latexToSvg, je as latexToSvgBatch, xt as parseQuestionHtml, Mt as parseQuestionJson, Bn as renderTablePlaceholders, ht as serializeDocument, F as toBBox, It as toChineseOrdinal, zn as usePageSvgRenderer, Ln as usePaperCore };
7151
+ export { xn as FONT_SIZE_MAP, A as PAPER_DIMENSIONS, j as PAPER_MM, ir as PaperEditor, te as PaperLayout, lr as PaperPreview, Se as SvgRenderer, Ut as buildPaperHtml, B as calcCharPositions, se as calcTextWidth, Ee as clearFormulaCache, le as clearWidthCache, gt as deserializeDocument, Vt as extractBaseTitle, Sn as fontSizeLabelToPx, Cn as fontSizePxToLabel, Bt as formatSectionTitle, z as getCharWidth, ee as getPaperPreset, Gn as hasTablePlaceholder, K as latexToSvg, je as latexToSvgBatch, xt as parseQuestionHtml, Nt as parseQuestionJson, Un as renderTablePlaceholders, ht as serializeDocument, P as toBBox, zt as toChineseOrdinal, Hn as usePageSvgRenderer, Bn as usePaperCore };