@sw7d/paper-renderer 0.2.4 → 0.3.0

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.
@@ -21,13 +21,13 @@ var x = Object.create, S = Object.defineProperty, C = Object.getOwnPropertyDescr
21
21
  label: "A3"
22
22
  },
23
23
  "8K": {
24
- width: 1085,
25
- height: 1559,
24
+ width: 1559,
25
+ height: 1085,
26
26
  label: "8K"
27
27
  },
28
28
  "16K": {
29
- width: 1092,
30
- height: 779,
29
+ width: 779,
30
+ height: 1092,
31
31
  label: "16K"
32
32
  }
33
33
  }, j = {
@@ -40,12 +40,12 @@ var x = Object.create, S = Object.defineProperty, C = Object.getOwnPropertyDescr
40
40
  h: 297
41
41
  },
42
42
  "8K": {
43
- w: 260,
44
- h: 370
43
+ w: 370,
44
+ h: 260
45
45
  },
46
46
  "16K": {
47
- w: 260,
48
- h: 184
47
+ w: 184,
48
+ h: 260
49
49
  }
50
50
  }, M = {
51
51
  A4: {
@@ -195,8 +195,20 @@ var te = class {
195
195
  renderedRegions: []
196
196
  }), o = a(), s = null;
197
197
  for (let a = 0; a < e.length; a++) {
198
- let c = e[a], l = c.paragraphs.reduce((e, t) => e + (t.height || this.measureParagraph(t)), 0), u = c.options && c.options.length > 0 ? this.measureOptionsHeight(c) : 0, d = l > 0 ? l + u : c.height || this.measureBlock(c);
199
- if (s && s.keepNext && r === 0 && (i > 0 || n > 0)) {
198
+ let c = e[a], l = 0;
199
+ if (c.options && c.options.length > 0) {
200
+ let e = c.options.reduce((e, t) => e + t.paragraphs.length, 0), t = 0;
201
+ for (let e = c.paragraphs.length - 1; e >= 0; e--) {
202
+ let n = c.paragraphs[e];
203
+ if (n.lines.length > 0 && n.lines.every((e) => e.elements.length > 0 && e.elements.every((e) => e.type === "enter"))) t++;
204
+ else break;
205
+ }
206
+ let n = c.paragraphs.length - e - t;
207
+ for (let e = 0; e < n; e++) l += c.paragraphs[e].height || this.measureParagraph(c.paragraphs[e]);
208
+ l += this.calcOptionsLayoutHeight(c);
209
+ for (let e = c.paragraphs.length - t; e < c.paragraphs.length; e++) l += c.paragraphs[e].height || this.measureParagraph(c.paragraphs[e]);
210
+ } else l = c.paragraphs.length === 0 ? c.height || 40 : c.paragraphs.reduce((e, t) => e + (t.height || this.measureParagraph(t)), 0);
211
+ if (c.height = l, s && s.keepNext && r === 0 && (i > 0 || n > 0)) {
200
212
  let e = s.height, a = !1, c = o.blocks.findIndex((e) => e.blockId === s.id);
201
213
  if (c >= 0 && (o.blocks.splice(c, 1), a = !0), !a) for (let e = t.length - 1; e >= 0; e--) {
202
214
  let r = t[e], i = r.blocks.findIndex((e) => e.blockId === s.id);
@@ -205,81 +217,141 @@ var te = class {
205
217
  break;
206
218
  }
207
219
  }
208
- a && (i = 0, r = 0, n > 0 && t.length > 0 && (n = Math.min(n - 1, t.length - 1), o = t[n]), this.placeBlockFragments(s, e, 0, o, t, r, i, n, (e, t, a, s) => {
220
+ a && (i = 0, r = 0, n > 0 && t.length > 0 && (n = Math.min(n - 1, t.length - 1), o = t[n]), this.placeBlockFragments(s, e, o, t, r, i, n, (e, t, a, s) => {
209
221
  o = e, r = t, i = a, n = s;
210
222
  }));
211
223
  }
212
- this.placeBlockFragments(c, d, u, o, t, r, i, n, (e, t, a, s) => {
224
+ this.placeBlockFragments(c, l, o, t, r, i, n, (e, t, a, s) => {
213
225
  o = e, r = t, i = a, n = s;
214
226
  }), s = c;
215
227
  }
216
228
  return o.blocks.length > 0 && !t.includes(o) && t.push(o), t.length === 0 && t.push(a()), t;
217
229
  }
218
- placeBlockFragments(e, t, n, r, i, a, o, s, c) {
219
- let l = t, u = 0, d = r, f = a, p = o, m = s;
220
- for (; l > 0;) {
221
- let r = m % 2 == 0 ? this.settings.bodyTopEven : this.settings.bodyTopOdd, a = this.footerTop - r, o = a - f;
222
- if (o <= 0) {
223
- p < this.settings.columns - 1 ? (p += 1, f = 0) : (this.finalizePage(d, i), m++, d = {
224
- index: m,
230
+ computeOptionParaRanges(e) {
231
+ if (!e.options || e.options.length === 0) return [];
232
+ let t = e.options.reduce((e, t) => e + t.paragraphs.length, 0), n = 0;
233
+ for (let t = e.paragraphs.length - 1; t >= 0; t--) {
234
+ let r = e.paragraphs[t];
235
+ if (r.lines.length > 0 && r.lines.every((e) => e.elements.length > 0 && e.elements.every((e) => e.type === "enter"))) n++;
236
+ else break;
237
+ }
238
+ let r = e.paragraphs.length - t - n, i = [];
239
+ for (let t of e.options) {
240
+ let n = r, a = t.paragraphs.length, o = 0;
241
+ for (let t = 0; t < a; t++) o += e.paragraphs[n + t]?.height || 26;
242
+ i.push({
243
+ startPara: n,
244
+ paraCount: a,
245
+ height: o
246
+ }), r += a;
247
+ }
248
+ return i;
249
+ }
250
+ isHorizontalLayout(e, t) {
251
+ if (!e.options || e.options.length === 0) return !0;
252
+ let n = e.type === "question" && e.metadata?.questionNo || "", r = e.type === "question" ? n.length > 2 ? 26.25 : 17.5 : 26.25, i = this.columnWidth - r;
253
+ for (let n of t) {
254
+ let r = 0;
255
+ for (let t = 0; t < n.paraCount; t++) {
256
+ let i = e.paragraphs[n.startPara + t];
257
+ if (i) for (let e of i.lines) {
258
+ let t = 0;
259
+ for (let n of e.elements) t += n.width;
260
+ r = Math.max(r, t);
261
+ }
262
+ }
263
+ if ((20 + Math.min(r, i - 20)) * t.length > i) return !1;
264
+ }
265
+ return !0;
266
+ }
267
+ placeBlockFragments(e, t, n, r, i, a, o, s) {
268
+ let c = t, l = 0, u = n, d = i, f = a, p = o, m = this.computeOptionParaRanges(e), h = m.length > 0 ? this.isHorizontalLayout(e, m) : !1;
269
+ for (; c > 0;) {
270
+ let n = p % 2 == 0 ? this.settings.bodyTopEven : this.settings.bodyTopOdd, i = this.footerTop - n, a = i - d;
271
+ if (a <= 0) {
272
+ f < this.settings.columns - 1 ? (f += 1, d = 0) : (this.finalizePage(u, r), p++, u = {
273
+ index: p,
225
274
  width: this.pageWidth,
226
275
  height: this.pageHeight,
227
276
  blocks: [],
228
277
  cornerMarks: this.createCornerMarks(),
229
278
  renderedRegions: []
230
- }, f = 0, p = 0);
279
+ }, d = 0, f = 0);
231
280
  continue;
232
281
  }
233
- let s = 0, c = 0;
234
- for (let t = u; t < e.paragraphs.length; t++) {
235
- let r = e.paragraphs[t].height || 26, i = t === e.paragraphs.length - 1 ? n : 0;
236
- if (c + r + i > o) {
237
- if (s > 0) break;
282
+ let o = 0, s = 0;
283
+ for (let t = l; t < e.paragraphs.length; t++) {
284
+ let n = e.paragraphs[t].height || 26;
285
+ if (m.find((e) => e.startPara === t)) if (h) {
286
+ let e = Math.max(...m.map((e) => e.height)), n = 0;
287
+ for (let e of m) n += e.paraCount;
288
+ if (s + e > a) {
289
+ if (o > 0) break;
290
+ break;
291
+ }
292
+ s += e, o += n, t += n - 1;
293
+ continue;
294
+ } else {
295
+ let e = !1, n = 0;
296
+ for (let r of m) {
297
+ if (r.startPara < t) {
298
+ n += r.paraCount;
299
+ continue;
300
+ }
301
+ if (s + r.height > a) break;
302
+ s += r.height, o += r.paraCount, n += r.paraCount, e = !0;
303
+ }
304
+ if (e) {
305
+ t += n - 1;
306
+ continue;
307
+ }
308
+ if (o > 0) break;
238
309
  break;
239
310
  }
240
- c += r, s++;
311
+ if (s + n > a) {
312
+ if (o > 0) break;
313
+ break;
314
+ }
315
+ s += n, o++;
241
316
  }
242
- if (s === 0 && u < e.paragraphs.length) {
243
- if (f > 0) {
244
- p < this.settings.columns - 1 ? (p += 1, f = 0) : (this.finalizePage(d, i), m++, d = {
245
- index: m,
317
+ if (o === 0 && l < e.paragraphs.length) {
318
+ if (d > 0) {
319
+ f < this.settings.columns - 1 ? (f += 1, d = 0) : (this.finalizePage(u, r), p++, u = {
320
+ index: p,
246
321
  width: this.pageWidth,
247
322
  height: this.pageHeight,
248
323
  blocks: [],
249
324
  cornerMarks: this.createCornerMarks(),
250
325
  renderedRegions: []
251
- }, f = 0, p = 0);
326
+ }, d = 0, f = 0);
252
327
  continue;
253
328
  }
254
- s = 1, c = Math.min(e.paragraphs[u].height || 26, o);
329
+ o = 1, s = Math.min(e.paragraphs[l].height || 26, a);
255
330
  }
256
- s === 0 && (c = t + n);
257
- let h = u + s >= e.paragraphs.length, g = c + (h && s > 0 ? n : 0);
258
- if (d.blocks.push({
331
+ if (o === 0 && (s = t), u.blocks.push({
259
332
  blockId: e.id,
260
333
  blockType: e.type,
261
- paragraphStart: u,
262
- paragraphCount: s,
263
- x: this.getColumnX(p),
264
- y: f,
334
+ paragraphStart: l,
335
+ paragraphCount: o,
336
+ x: this.getColumnX(f),
337
+ y: d,
265
338
  width: this.columnWidth,
266
- height: g
267
- }), u += s, l -= c, f += g, u >= e.paragraphs.length) {
268
- let e = l - n;
269
- e > 0 && d.blocks.length > 0 && (d.blocks[d.blocks.length - 1].height += e);
339
+ height: s
340
+ }), l += o, c -= s, d += s, l >= e.paragraphs.length) {
341
+ u.blocks.length > 0 && c !== 0 && (d += c, u.blocks[u.blocks.length - 1].height += c);
270
342
  break;
271
343
  }
272
- let _ = a - f;
273
- (e.paragraphs[u]?.height || 26) > _ && (p < this.settings.columns - 1 ? (p += 1, f = 0) : (this.finalizePage(d, i), m++, d = {
274
- index: m,
344
+ let g = i - d;
345
+ (e.paragraphs[l]?.height || 26) > g && (f < this.settings.columns - 1 ? (f += 1, d = 0) : (this.finalizePage(u, r), p++, u = {
346
+ index: p,
275
347
  width: this.pageWidth,
276
348
  height: this.pageHeight,
277
349
  blocks: [],
278
350
  cornerMarks: this.createCornerMarks(),
279
351
  renderedRegions: []
280
- }, f = 0, p = 0));
352
+ }, d = 0, f = 0));
281
353
  }
282
- c(d, f, p, m);
354
+ s(u, d, f, p);
283
355
  }
284
356
  finalizePage(e, t) {
285
357
  e.blocks.length > 0 && !t.includes(e) && t.push(e);
@@ -287,9 +359,14 @@ var te = class {
287
359
  measureBlock(e) {
288
360
  let t = 0;
289
361
  for (let n of e.paragraphs) t += n.height || this.measureParagraph(n);
290
- return e.options && e.options.length > 0 && (t += this.measureOptionsHeight(e)), t;
362
+ return t;
291
363
  }
292
- measureOptionsHeight(e) {
364
+ measureParagraph(e) {
365
+ let t = 0;
366
+ for (let n of e.lines) t += n.lineHeight || 24;
367
+ return t;
368
+ }
369
+ calcOptionsLayoutHeight(e) {
293
370
  if (!e.options || e.options.length === 0) return 0;
294
371
  let t = (e.metadata?.questionNo?.length || 0) > 2 ? 26.25 : 17.5, n = this.columnWidth - t, r = e.options.map((e) => {
295
372
  let t = 0;
@@ -299,13 +376,8 @@ var te = class {
299
376
  t = Math.max(t, n);
300
377
  }
301
378
  return 20 + Math.min(t, n - 20);
302
- }), i = e.options.map((e) => e.paragraphs.reduce((e, t) => e + (t.height || 26), 0)), a = e.options.length;
303
- return Math.max(...r) * a <= n ? Math.max(...i) : i.reduce((e, t) => e + t, 0);
304
- }
305
- measureParagraph(e) {
306
- let t = 0;
307
- for (let n of e.lines) t += n.lineHeight || 24;
308
- return t;
379
+ }), i = e.options.map((e) => e.paragraphs.reduce((e, t) => e + (t.height || 26), 0));
380
+ return Math.max(...r) * e.options.length <= n ? Math.max(...i) : i.reduce((e, t) => e + t, 0);
309
381
  }
310
382
  createCornerMarks() {
311
383
  let e = 26.46;
@@ -349,7 +421,7 @@ var te = class {
349
421
  ];
350
422
  }
351
423
  }, ne = null, I = /* @__PURE__ */ new Map(), L = 5e3;
352
- function re() {
424
+ function R() {
353
425
  if (ne) return ne;
354
426
  try {
355
427
  if (typeof document > "u") return null;
@@ -359,29 +431,29 @@ function re() {
359
431
  return null;
360
432
  }
361
433
  }
362
- function ie(e, t, n, r) {
434
+ function re(e, t, n, r) {
363
435
  return `${r ? "italic" : "normal"} ${n ? "bold" : "normal"} ${t}px ${e.split(",").map((e) => {
364
436
  let t = e.trim();
365
437
  return t.includes(" ") && !t.includes("\"") && !t.includes("'") ? `"${t}"` : t;
366
438
  }).join(", ")}`;
367
439
  }
368
- function ae(e) {
440
+ function ie(e) {
369
441
  let t = e.charCodeAt(0);
370
442
  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;
371
443
  }
372
- function R(e) {
444
+ function z(e) {
373
445
  let t = e.charCodeAt(0);
374
446
  return t >= 65281 && t <= 65376 || t >= 65504 && t <= 65510;
375
447
  }
376
- function oe(e, t) {
377
- return ae(e) || R(e) || e === " " ? t : e === " " ? t * .25 : t * .6;
448
+ function ae(e, t) {
449
+ return ie(e) || z(e) || e === " " ? t : e === " " ? t * .25 : t * .6;
378
450
  }
379
- function z(e, t, n, r, i) {
380
- let a = re();
451
+ function B(e, t, n, r, i) {
452
+ let a = R();
381
453
  if (a) {
382
454
  let o = n || "\"Times New Roman\", SimSun, STSong, serif", s = `${e}|${o}|${t}|${r}|${i}`, c = I.get(s);
383
455
  if (c !== void 0) return c;
384
- a.font = ie(o, t, !!r, !!i);
456
+ a.font = re(o, t, !!r, !!i);
385
457
  let l = a.measureText(e).width;
386
458
  if (I.size > L) {
387
459
  let e = Array.from(I.keys()).slice(0, L / 2);
@@ -389,14 +461,14 @@ function z(e, t, n, r, i) {
389
461
  }
390
462
  return I.set(s, l), l;
391
463
  }
392
- return oe(e, t);
464
+ return ae(e, t);
393
465
  }
394
- function se(e, t, n, r, i) {
395
- let a = re();
466
+ function V(e, t, n, r, i) {
467
+ let a = R();
396
468
  if (a) {
397
469
  let o = n || "\"Times New Roman\", SimSun, STSong, serif", s = `T|${e}|${o}|${t}|${r}|${i}`, c = I.get(s);
398
470
  if (c !== void 0) return c;
399
- a.font = ie(o, t, !!r, !!i);
471
+ a.font = re(o, t, !!r, !!i);
400
472
  let l = a.measureText(e).width;
401
473
  if (I.size > L) {
402
474
  let e = Array.from(I.keys()).slice(0, L / 2);
@@ -405,18 +477,18 @@ function se(e, t, n, r, i) {
405
477
  return I.set(s, l), l;
406
478
  }
407
479
  let o = 0;
408
- for (let n of e) o += oe(n, t);
480
+ for (let n of e) o += ae(n, t);
409
481
  return o;
410
482
  }
411
- function B(e, t, n, r, i) {
483
+ function H(e, t, n, r, i) {
412
484
  let a = [], o = 0;
413
- for (let s of e) a.push(o), o += z(s, t, n, r, i);
485
+ for (let s of e) a.push(o), o += B(s, t, n, r, i);
414
486
  return a;
415
487
  }
416
- function ce(e, t, n, r, i) {
417
- let a = re();
488
+ function oe(e, t, n, r, i) {
489
+ let a = R();
418
490
  if (a) {
419
- a.font = ie(n || "\"Times New Roman\", SimSun, STSong, serif", t, !!r, !!i);
491
+ a.font = re(n || "\"Times New Roman\", SimSun, STSong, serif", t, !!r, !!i);
420
492
  let o = a.measureText(e);
421
493
  return {
422
494
  ascent: o.actualBoundingBoxAscent,
@@ -430,39 +502,39 @@ function ce(e, t, n, r, i) {
430
502
  height: t
431
503
  };
432
504
  }
433
- function le() {
505
+ function se() {
434
506
  I.clear();
435
507
  }
436
508
  //#endregion
437
509
  //#region src/engine/svg/headerRenderer.ts
438
- function V(e) {
510
+ function U(e) {
439
511
  return e.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&apos;");
440
512
  }
441
- function H(e, t, n, r, i, a, o, s) {
513
+ function ce(e, t, n, r, i, a, o, s) {
442
514
  let c = "", l = 0;
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;
515
+ return c += le(t, i, n, l, o, s), l += 30, c += W(e, r, l, s), l += 40, c += ue(e, l, a), c;
444
516
  }
445
- function ue(e, t, n, r, i, a) {
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";
517
+ function le(e, t, n, r, i, a) {
518
+ let o = i && n > 0 ? `满分: ${n} 分` : "", s = o ? `<span class="swed-score" data-region="score">${U(o)}</span>` : "", { contentWidth: c, contentX: l } = e, u = a === "edit";
447
519
  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">
448
520
  <div class="swed-header-school-info">
449
- <div contenteditable="${u ? "true" : "false"}" class="swed-headerDesc${u ? " swed-editable-dashed" : ""}" data-editable="schoolName">${V(t)}</div>
521
+ <div contenteditable="${u ? "true" : "false"}" class="swed-headerDesc${u ? " swed-editable-dashed" : ""}" data-editable="schoolName">${U(t)}</div>
450
522
  ${s}
451
523
  </div>
452
524
  </foreignObject>\n`;
453
525
  }
454
- function de(e, t, n, r) {
526
+ function W(e, t, n, r) {
455
527
  let { contentWidth: i, contentX: a } = e, o = r === "edit";
456
528
  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">
457
529
  <div class="swed-header-paper-name">
458
530
  <div class="swed-input-box">
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>
531
+ <label class="swed-input-box__label">${U(t)}</label>
532
+ <div class="swed-input-box__input swed-textarea${o ? " swed-editable-dashed" : ""}" id="paperName" contenteditable="${o ? "true" : "false"}" data-editable="paperName">${U(t)}</div>
461
533
  </div>
462
534
  </div>
463
535
  </foreignObject>\n`;
464
536
  }
465
- function U(e, t, n) {
537
+ function ue(e, t, n) {
466
538
  let { contentWidth: r, contentX: i } = e;
467
539
  return ` <foreignObject class="swed-header-block swed-header-block--student-info" transform="translate(${i}, ${t})" width="${r}" height="100" opacity="1">
468
540
  <div class="swed-header-student-info">
@@ -479,45 +551,52 @@ function U(e, t, n) {
479
551
  </div>
480
552
  </foreignObject>\n`;
481
553
  }
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`;
554
+ function de(e, t, n, r, i, a) {
555
+ let o = i && t > 0 ? `满分: ${t} 分` : "", s = o ? `<span class="swed-score" data-region="score">${U(o)}</span>` : "", { contentWidth: c, contentX: l } = e, u = a === "edit";
556
+ 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">${U(n)}</div>\n ${s}\n </div>\n </foreignObject>\n`;
485
557
  }
486
- function pe() {
558
+ function fe() {
487
559
  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";
488
560
  }
489
- function me() {
561
+ function pe() {
490
562
  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";
491
563
  }
492
564
  //#endregion
493
565
  //#region src/engine/svg/optionsRenderer.ts
494
- function he(e, t, n, r, i) {
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);
496
- if (l > 0 && u * l <= t) {
497
- let n = t / l, a = n - 20;
498
- for (let t = 0; t < l; t++) {
499
- let s = n * t;
500
- o += ` <g class="swed-option-item" transform="translate(${s}, 0)">\n`;
501
- let c = e[t].paragraphs[0]?.lines[0]?.baseline || r * 1.56;
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";
503
- let l = 0;
504
- for (let n of e[t].paragraphs) o += be(n, a, l, !1, "", r, i, 20), l += n.height || 26;
505
- o += " </g>\n", o += " </g>\n";
506
- }
507
- return o += " </g>\n", o;
508
- }
509
- let d = 0;
510
- for (let t = 0; t < l; t++) {
511
- o += ` <g class="swed-option-item" transform="translate(0, ${d})">\n`;
566
+ function me(e, t, n, r, i, a = 0, o) {
567
+ let s = t - 20, c = e.map((e) => he(e, 20, s)), l = e.map((e) => e.paragraphs.reduce((e, t) => e + (t.height || 26), 0)), u = e.length, d = Math.max(...c);
568
+ if (u > 0 && d * u <= t) {
569
+ let s = t / u, c = s - 20, l = ` <g class="swed-option" transform="translate(${a}, ${n})">\n`;
570
+ for (let t = 0; t < u; t++) {
571
+ let n = s * t;
572
+ l += ` <g class="swed-option-item" transform="translate(${n}, 0)">\n`;
573
+ let a = e[t].paragraphs[0]?.lines[0]?.baseline || r * 1.56;
574
+ l += ` <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="${a.toFixed(3)}">${U(e[t].label)}.</text>\n`, l += " <g>\n";
575
+ let u = 0;
576
+ for (let n = 0; n < e[t].paragraphs.length; n++) {
577
+ let a = e[t].paragraphs[n], s = o?.[t]?.[n];
578
+ l += be(a, c, u, !1, "", r, i, 20, s), u += a.height || 26;
579
+ }
580
+ l += " </g>\n", l += " </g>\n";
581
+ }
582
+ return l += " </g>\n", l;
583
+ }
584
+ let f = "", p = n;
585
+ for (let t = 0; t < u; t++) {
586
+ if (o && o[t].length === 0) continue;
587
+ f += ` <g class="swed-option" transform="translate(${a}, ${p})">\n`, f += " <g class=\"swed-option-item\" transform=\"translate(0, 0)\">\n";
512
588
  let n = e[t].paragraphs[0]?.lines[0]?.baseline || r * 1.56;
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";
514
- let s = 0;
515
- for (let n of e[t].paragraphs) o += be(n, a, s, !1, "", r, i, 20), s += n.height || 26;
516
- o += " </g>\n", o += " </g>\n", d += c[t];
589
+ f += ` <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)}">${U(e[t].label)}.</text>\n`, f += " <g>\n";
590
+ let c = 0;
591
+ for (let n = 0; n < e[t].paragraphs.length; n++) {
592
+ let a = e[t].paragraphs[n], l = o?.[t]?.[n];
593
+ f += be(a, s, c, !1, "", r, i, 20, l), c += a.height || 26;
594
+ }
595
+ f += " </g>\n", f += " </g>\n", f += " </g>\n", p += l[t];
517
596
  }
518
- return o += " </g>\n", o;
597
+ return f;
519
598
  }
520
- function ge(e, t, n) {
599
+ function he(e, t, n) {
521
600
  let r = 0;
522
601
  for (let t of e.paragraphs) for (let e of t.lines) {
523
602
  let t = 0;
@@ -526,46 +605,139 @@ function ge(e, t, n) {
526
605
  }
527
606
  return t + Math.min(r, n);
528
607
  }
529
- function _e(e, t) {
608
+ function ge(e, t) {
530
609
  if (e.length === 0) return 0;
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;
610
+ let n = e.map((e) => he(e, 20, t)), r = e.map((e) => e.paragraphs.reduce((e, t) => e + (t.height || 26), 0)), i = e.length;
532
611
  return Math.max(...n) * i <= t ? Math.max(...r) : r.reduce((e, t) => e + t, 0);
533
612
  }
613
+ function G(e, t, n, r) {
614
+ let i = e.paragraphs, a = e.type === "question" && e.metadata?.questionNo || "", o = 0;
615
+ o = e.type === "question" ? a.length > 2 ? 26.25 : 17.5 : (e.type, 26.25);
616
+ let s = r - o;
617
+ if (!e.options || e.options.length === 0) {
618
+ let e = 0;
619
+ for (let r = t; r < n && r < i.length; r++) {
620
+ let t = i[r];
621
+ e += t.height || t.lines.reduce((e, t) => e + t.lineHeight, 0) || 26;
622
+ }
623
+ return e;
624
+ }
625
+ let c = e.options.reduce((e, t) => e + t.paragraphs.length, 0), l = 0;
626
+ for (let e = i.length - 1; e >= 0; e--) {
627
+ let t = i[e];
628
+ if (t.lines.length > 0 && t.lines.every((e) => e.elements.length > 0 && e.elements.every((e) => e.type === "enter"))) l++;
629
+ else break;
630
+ }
631
+ let u = i.length - c - l, d = [], f = u;
632
+ for (let t of e.options) {
633
+ let e = f, n = t.paragraphs.length, r = 0;
634
+ for (let t = 0; t < n; t++) r += i[e + t]?.height || 26;
635
+ d.push({
636
+ startPara: e,
637
+ paraCount: n,
638
+ height: r
639
+ }), f += n;
640
+ }
641
+ let p = [];
642
+ for (let e = 0; e < d.length; e++) {
643
+ let r = d[e];
644
+ r.startPara >= t && r.startPara < n && p.push(e);
645
+ }
646
+ if (p.length === 0) {
647
+ let e = 0;
648
+ for (let r = t; r < n && r < i.length; r++) {
649
+ let t = i[r];
650
+ e += t.height || t.lines.reduce((e, t) => e + t.lineHeight, 0) || 26;
651
+ }
652
+ return e;
653
+ }
654
+ let m = 0;
655
+ for (let e = t; e < u && e < n; e++) {
656
+ let t = i[e];
657
+ m += t.height || t.lines.reduce((e, t) => e + t.lineHeight, 0) || 26;
658
+ }
659
+ let h = e.options.map((e) => {
660
+ let t = 0;
661
+ for (let n of e.paragraphs) for (let e of n.lines) {
662
+ let n = 0;
663
+ for (let t of e.elements) n += t.width;
664
+ t = Math.max(t, n);
665
+ }
666
+ return 20 + Math.min(t, s - 20);
667
+ }), g = Math.max(...h), _ = d.map((e) => e.height);
668
+ if (g * e.options.length <= s) m += Math.max(...p.map((e) => _[e]));
669
+ else for (let e of p) m += _[e];
670
+ let v = u + c;
671
+ for (let e = Math.max(v, t); e < n && e < i.length; e++) {
672
+ let t = i[e];
673
+ m += t.height || t.lines.reduce((e, t) => e + t.lineHeight, 0) || 26;
674
+ }
675
+ return m;
676
+ }
534
677
  //#endregion
535
678
  //#region src/engine/svg/questionRenderer.ts
536
- function ve(e, t) {
679
+ function _e(e, t) {
537
680
  return e.baseline > 0 ? e.baseline : t * 1.56;
538
681
  }
539
- function W(e, t, n, r, i, a, o, s, c, l) {
682
+ function ve(e, t, n, r, i, a, o, s, c, l) {
540
683
  let u = t.metadata?.topicId || t.id, d = e.width || 333.5, f = e.height || 100, p = "";
541
684
  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;
685
+ let m = t.type === "question" && t.metadata?.questionNo || "", h = t.paragraphs[0]?.lines[0], g = h ? _e(h, s) : 20, _ = 0;
543
686
  t.type === "question" ? _ = m.length > 2 ? 26.25 : 17.5 : t.type === "sub-question" && (_ = 26.25);
544
- let v = e.paragraphStart, y = Math.min(v + e.paragraphCount, t.paragraphs.length), b = 0;
545
- for (let e = v; e < y; e++) {
546
- let n = t.paragraphs[e];
547
- b += n.height || n.lines.reduce((e, t) => e + t.lineHeight, 0) || 26;
548
- }
549
- let x = 0;
550
- t.options && t.options.length > 0 && o && (x = _e(t.options, d - _), b += x);
551
- let S = Math.max(b, e.height), C = (t.type === "question" || t.type === "sub-question") && e.paragraphCount > 0;
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`;
553
- let w = a && c && t.metadata?.score || "", T = 0, E = !1;
554
- for (let e = v; e < y; e++) {
555
- let n = t.paragraphs[e], r = !(n.lines.length > 0 && n.lines.every((e) => e.elements.length > 0 && e.elements.every((e) => e.type === "enter"))) && !E;
556
- p += be(n, d - _, T, r, w, s, l), r && (E = !0), T += n.height || n.lines.reduce((e, t) => e + t.lineHeight, 0) || 26;
557
- }
558
- if (t.options && t.options.length > 0 && o) {
559
- let e = d - _;
560
- p += he(t.options, e, T, s, l), T += x;
561
- }
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) {
687
+ let v = e.paragraphStart, y = Math.min(v + e.paragraphCount, t.paragraphs.length), b = d - _, x = [], S = t.paragraphs.length, C = 0;
688
+ if (t.options && t.options.length > 0) {
689
+ C = t.options.reduce((e, t) => e + t.paragraphs.length, 0);
690
+ let e = 0;
691
+ for (let n = t.paragraphs.length - 1; n >= 0; n--) {
692
+ let r = t.paragraphs[n];
693
+ if (r.lines.length > 0 && r.lines.every((e) => e.elements.length > 0 && e.elements.every((e) => e.type === "enter"))) e++;
694
+ else break;
695
+ }
696
+ S = t.paragraphs.length - C - e;
697
+ let n = S;
698
+ for (let e of t.options) x.push({
699
+ startPara: n,
700
+ paraCount: e.paragraphs.length
701
+ }), n += e.paragraphs.length;
702
+ }
703
+ let w = [];
704
+ if (t.options && t.options.length > 0) for (let e = 0; e < x.length; e++) {
705
+ let t = x[e];
706
+ t.startPara >= v && t.startPara < y && w.push(e);
707
+ }
708
+ let T = G(t, v, y, d), E = (t.type === "question" || t.type === "sub-question") && e.paragraphCount > 0;
709
+ E && l === "edit" && (p += ` <rect class="swed-question-hitarea" x="0" y="0" width="${d}" height="${T}" fill="transparent" />\n`), p += ` <g class="swed-question-stem" transform="translate(${_}, 0)">\n`;
710
+ let D = a && c && t.metadata?.score || "", O = 0, k = !1, A = Math.min(S, y);
711
+ for (let e = v; e < A; e++) {
712
+ let n = t.paragraphs[e], r = !(n.lines.length > 0 && n.lines.every((e) => e.elements.length > 0 && e.elements.every((e) => e.type === "enter"))) && !k;
713
+ p += be(n, b, O, r, D, s, l, 0, e), r && (k = !0), O += n.height || n.lines.reduce((e, t) => e + t.lineHeight, 0) || 26;
714
+ }
715
+ if (p += " </g>\n", t.options && t.options.length > 0 && w.length > 0) {
716
+ let e = [];
717
+ for (let n = 0; n < t.options.length; n++) if (w.includes(n)) {
718
+ let t = x[n], r = [];
719
+ for (let e = 0; e < t.paraCount; e++) t.startPara + e < y && r.push(t.startPara + e);
720
+ e.push(r);
721
+ } else e.push([]);
722
+ p += me(t.options, b, O, s, l, _, e);
723
+ }
724
+ if (E && l === "edit" && (p += ` <path class="swed-question-border" d="M 0.5 0 L ${d - .5} 0 L ${d - .5} ${T} L 0.5 ${T} Z" stroke="#231815" stroke-dasharray="2,5" transform="translate(0.5, 0)" stroke-width="0.5" fill="none" pointer-events="none"></path>\n`), t.options && t.options.length > 0 && C > 0) {
725
+ let e = ge(t.options, b), n = O + e;
726
+ p += ` <g class="swed-question-stem" transform="translate(${_}, ${n})">\n`;
727
+ let r = 0;
728
+ for (let e = A + C; e < y; e++) {
729
+ let n = t.paragraphs[e];
730
+ p += be(n, b, r, !1, "", s, l, 0, e), r += n.height || n.lines.reduce((e, t) => e + t.lineHeight, 0) || 26;
731
+ }
732
+ p += " </g>\n";
733
+ }
734
+ if (a) {
563
735
  if (m) {
564
736
  let e = m.length > 2;
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`;
737
+ 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">${U(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`;
566
738
  }
567
739
  let e = t.metadata?.subLabel || "";
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`);
740
+ 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)})">${U(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`);
569
741
  }
570
742
  return p += " </g>\n", p;
571
743
  }
@@ -573,28 +745,29 @@ function ye(e, t, n, r = 0, i = !0, a = !1, o = "edit") {
573
745
  let s = e.metadata?.label || "", c = e.height || 40;
574
746
  if (!s) return "";
575
747
  let l = i && e.metadata?.score || "", u = "";
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="">
748
+ 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="${U(s)}" topicgroupinfo="">
577
749
  <div class="swed-title-content">
578
- <span class="swed-title-text">${V(s)}</span>
579
- ${l ? `<span class="swed-title-score">(${V(l)})</span>` : ""}
750
+ <span class="swed-title-text">${U(s)}</span>
751
+ ${l ? `<span class="swed-title-score">(${U(l)})</span>` : ""}
580
752
  </div>
581
753
  </div>
582
754
  </foreignObject>\n`, u;
583
755
  }
584
- function be(e, t, n, r, i = "", a, o, s = 0) {
585
- let c = "", l = 0;
756
+ function be(e, t, n, r, i = "", a, o, s = 0, c) {
757
+ let l = "", u = 0, d = 0;
758
+ r && i && (d = V(`(${i}分)`, a, "SimSun, STSong, serif"));
586
759
  for (let n = 0; n < e.lines.length; n++) {
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;
588
- c += ` <g class="swed-line" transform="translate(0, ${l})" baseline="${u.toFixed(2)}">\n`;
760
+ let s = e.lines[n], c = _e(s, a), d = r && n === 0, f = s.elements.length > 0 && s.elements.every((e) => e.type === "enter"), p = s.lineHeight;
761
+ l += ` <g class="swed-line" transform="translate(0, ${u})" baseline="${c.toFixed(2)}">\n`;
589
762
  let m = 0;
590
763
  if (d && i) {
591
- let e = `(${i}分)`, t = u - a;
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");
764
+ let e = `(${i}分)`, t = c - a;
765
+ l += ` <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}">${U(e)}</text>\n`, m += V(e, a, "SimSun, STSong, serif");
593
766
  }
594
767
  if (f) {
595
768
  if (o === "edit") {
596
769
  let e = p.toFixed(1);
597
- c += ` <line x1="0" y1="${e}" x2="${t.toFixed(2)}" y2="${e}" stroke="#d9d9d9" stroke-width="0.5" stroke-dasharray="4,4" opacity="0.5"></line>\n`, c += ` <g class="swed-enter" transform="translate(2, ${(u - 10).toFixed(2)})">\n`, c += " <use href=\"#enter\" transform=\"scale(0.013)\" fill=\"#c8c8c8\" opacity=\"0.5\"></use>\n", c += " </g>\n";
770
+ l += ` <line x1="0" y1="${e}" x2="${t.toFixed(2)}" y2="${e}" stroke="#d9d9d9" stroke-width="0.5" stroke-dasharray="4,4" opacity="0.5"></line>\n`, l += ` <g class="swed-enter" transform="translate(2, ${(c - 10).toFixed(2)})">\n`, l += " <use href=\"#enter\" transform=\"scale(0.013)\" fill=\"#c8c8c8\" opacity=\"0.5\"></use>\n", l += " </g>\n";
598
771
  }
599
772
  } else {
600
773
  let r = 0;
@@ -603,29 +776,29 @@ function be(e, t, n, r, i = "", a, o, s = 0) {
603
776
  e.justification === "center" ? r = Math.max(0, (i - n) / 2) : e.justification === "right" && (r = Math.max(0, i - n));
604
777
  }
605
778
  let i = s.elements.length > 0 && s.elements.every((e) => e.type === "image");
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;
779
+ for (let e of s.elements) l += xe(e, m + r + (s.offsetX || 0), c, s.lineHeight, f, o, a, e.type === "image" ? e.id : void 0, e.type === "image" ? i : void 0), m += e.width;
607
780
  if (o === "edit" && n === e.lines.length - 1) {
608
781
  let e = m + r + (s.offsetX || 0) + 2;
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";
782
+ l += ` <g class="swed-enter" transform="translate(${e.toFixed(2)}, ${(c - 10).toFixed(2)})">\n`, l += " <use href=\"#enter\" transform=\"scale(0.013)\" fill=\"#c8c8c8\" opacity=\"0.5\"></use>\n", l += " </g>\n";
610
783
  }
611
784
  }
612
- c += ` <line x1="0" y1="${p.toFixed(2)}" x2="${t.toFixed(2)}" y2="${p.toFixed(2)}" style="fill:#000;stroke-width:1;stroke:#000;" opacity="0"></line>\n`, c += " </g>\n", l += p;
785
+ l += ` <line x1="0" y1="${p.toFixed(2)}" x2="${t.toFixed(2)}" y2="${p.toFixed(2)}" style="fill:#000;stroke-width:1;stroke:#000;" opacity="0"></line>\n`, l += " </g>\n", u += p;
613
786
  }
614
- return ` <g class="swed-paragraph" transform="translate(${s}, ${n})">\n${c} </g>\n`;
787
+ return ` <g class="swed-paragraph"${`${c === void 0 ? "" : ` data-para="${c}"`}${d > 0 ? ` data-score-width="${d.toFixed(2)}"` : ""}`} transform="translate(${s}, ${n})">\n${l} </g>\n`;
615
788
  }
616
789
  function xe(e, t, n, r, i, a, o, s, c) {
617
790
  switch (e.type) {
618
791
  case "text": {
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 = "";
792
+ 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(" ") : H(r.value, r.fontSize, r.fontFamily, r.bold, r.italic).map((e) => (e + t).toFixed(2)).join(" "), l = "";
620
793
  if (r.backgroundColor) {
621
794
  let e = o + r.fontSize * .1, n = r.fontSize * 1.1;
622
795
  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`;
623
796
  }
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) {
797
+ let u = r.italic ? -r.fontSize * .02 : 0, d = r.fontFamily ? U(r.fontFamily) : "&quot;Times New Roman&quot;, SimSun";
798
+ 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">${U(r.value)}</text>\n`, r.dotAbove) {
626
799
  let e = Math.max(1.5, r.fontSize * .1), n = o + r.fontSize * .9 + e;
627
800
  for (let i = 0; i < s.length; i++) {
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;
801
+ 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;
629
802
  l += ` <circle cx="${a.toFixed(2)}" cy="${n.toFixed(2)}" r="${e.toFixed(2)}" fill="${r.color}"></circle>\n`;
630
803
  }
631
804
  }
@@ -642,7 +815,7 @@ function xe(e, t, n, r, i, a, o, s, c) {
642
815
  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`;
643
816
  }
644
817
  if (r.strikethrough) {
645
- let e = o + ce(r.value, r.fontSize, r.fontFamily, r.bold, r.italic).ascent * .5;
818
+ let e = o + oe(r.value, r.fontSize, r.fontFamily, r.bold, r.italic).ascent * .5;
646
819
  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`;
647
820
  }
648
821
  return l;
@@ -659,7 +832,7 @@ function xe(e, t, n, r, i, a, o, s, c) {
659
832
  case "underline": {
660
833
  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";
661
834
  if (d) {
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` : "";
835
+ 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}">${U(r.placeholder)}</text>\n` : "";
663
836
  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";
664
837
  }
665
838
  if (r.isSplitPart && (r.isEmpty || r.blankType) && a === "edit") {
@@ -727,7 +900,7 @@ var Se = class {
727
900
  renderAllPages(e, t, n, r) {
728
901
  if (e.length === 0) return "";
729
902
  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`;
730
- p += me();
903
+ p += pe();
731
904
  for (let r = 0; r < e.length; r++) {
732
905
  let u = e[r], f = r % 2 == 0 ? n.bodyTopEven ?? 173 : n.bodyTopOdd ?? 50, m = r * d;
733
906
  p += `<g class="swed-page" transform="translate(0, ${m})">\n`, p += this.renderPageContent(u, t, f, n, r, e.length, {
@@ -748,7 +921,7 @@ var Se = class {
748
921
  paperName: ""
749
922
  }, a = 1, o = !0) {
750
923
  let { totalScore: s = 0, paperName: c = "", schoolName: l = "", qrCodeImage: u = "", qrCodeImages: d } = i, f = "";
751
- return o && (f += me()), f += this.renderPageContent(e, t, n, r, e.index, a, {
924
+ return o && (f += pe()), f += this.renderPageContent(e, t, n, r, e.index, a, {
752
925
  ...i,
753
926
  totalScore: s,
754
927
  paperName: c,
@@ -776,20 +949,10 @@ var Se = class {
776
949
  });
777
950
  continue;
778
951
  }
779
- let o = r.paragraphStart, s = Math.min(o + r.paragraphCount, e.paragraphs.length), c = 0;
780
- for (let t = o; t < s; t++) {
781
- let n = e.paragraphs[t];
782
- c += n.height || (n.lines ? n.lines.reduce((e, t) => e + (t.lineHeight || 26), 0) : 0) || 26;
783
- }
784
- let u = o + r.paragraphCount >= e.paragraphs.length;
785
- if (e.options && e.options.length > 0 && u) {
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;
787
- c += _e(e.options, t - i);
788
- }
789
- let d = Math.max(c, r.height);
952
+ let o = r.paragraphStart, s = G(e, o, Math.min(o + r.paragraphCount, e.paragraphs.length), p);
790
953
  g.push({
791
954
  type: "question-border",
792
- bbox: P(i, a, r.width, d),
955
+ bbox: P(i, a, r.width, s),
793
956
  meta: {
794
957
  blockId: r.blockId,
795
958
  blockType: r.blockType
@@ -818,12 +981,12 @@ var Se = class {
818
981
  }
819
982
  let a = 0, l = !p && u === 0;
820
983
  for (let t of n.lines) {
821
- let u = ve(t, h), d = 0;
984
+ let u = _e(t, h), d = 0;
822
985
  if (l && r.showScore && !p) {
823
986
  let t = e.metadata?.score || "";
824
987
  if (t) {
825
988
  let e = `(${t}分)`;
826
- d += se(e, h, "SimSun, STSong, serif");
989
+ d += V(e, h, "SimSun, STSong, serif");
827
990
  }
828
991
  p = !0, l = !1;
829
992
  }
@@ -877,7 +1040,7 @@ var Se = class {
877
1040
  }
878
1041
  }
879
1042
  getOptionsHeight(e, t) {
880
- return _e(e, t);
1043
+ return 0;
881
1044
  }
882
1045
  renderPageContent(e, t, n, r, i, a, o) {
883
1046
  let [s, c, l, u] = r.margins || [
@@ -892,9 +1055,9 @@ var Se = class {
892
1055
  contentWidth: p,
893
1056
  contentX: 0
894
1057
  };
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";
1058
+ 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 += ce(S, C, o.totalScore ?? 0, o.paperName || "", o.schoolName || "", x, r.showScore ?? !0, this.renderMode) : b += de(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";
896
1059
  let w = `${i + 1}/${a}`, T = p / 2 - w.length * 6, E = w.split("").map((e, t) => (T + t * 12).toFixed(2)).join(" ");
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";
1060
+ 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">${U(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 += fe(), b += " </g>\n", b += " </g>\n", b += " <g class=\"swed-layout\">\n";
898
1061
  for (let t of e.cornerMarks) b += this.renderCornerMark(t);
899
1062
  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";
900
1063
  let D = this.groupBlocksByColumn(e.blocks);
@@ -905,7 +1068,7 @@ var Se = class {
905
1068
  let e = t.find((e) => e.id === n.blockId);
906
1069
  if (!e || e.type === "title") continue;
907
1070
  let i = n.blockId === o.selectedBlockId, a = n.paragraphStart === 0, s = n.paragraphStart + n.paragraphCount >= e.paragraphs.length;
908
- b += W(n, e, n.y, o.showBBoxes, i, a, s, y, r.showScore ?? !0, this.renderMode);
1071
+ b += ve(n, e, n.y, o.showBBoxes, i, a, s, y, r.showScore ?? !0, this.renderMode);
909
1072
  }
910
1073
  b += " </g>\n";
911
1074
  }
@@ -932,20 +1095,20 @@ var Se = class {
932
1095
  let [t, n, r, i] = e.bbox;
933
1096
  return ` <rect fill="black" x="${t}" y="${n}" width="${r}" height="${i}"></rect>\n`;
934
1097
  }
935
- }, G = /* @__PURE__ */ new Map(), Ce = 500;
1098
+ }, K = /* @__PURE__ */ new Map(), Ce = 500;
936
1099
  function we(e, t, n) {
937
- let r = `${t}:${n}:${e}`, i = G.get(r);
938
- return i && (G.delete(r), G.set(r, i)), i;
1100
+ let r = `${t}:${n}:${e}`, i = K.get(r);
1101
+ return i && (K.delete(r), K.set(r, i)), i;
939
1102
  }
940
1103
  function Te(e, t, n, r) {
941
1104
  let i = `${t}:${n}:${e}`;
942
- if (G.set(i, r), G.size > Ce) {
943
- let e = G.keys().next().value;
944
- e && G.delete(e);
1105
+ if (K.set(i, r), K.size > Ce) {
1106
+ let e = K.keys().next().value;
1107
+ e && K.delete(e);
945
1108
  }
946
1109
  }
947
1110
  function Ee() {
948
- G.clear();
1111
+ K.clear();
949
1112
  }
950
1113
  function De(e, t = 14, n = !1) {
951
1114
  let r = we(e, t, n);
@@ -987,13 +1150,13 @@ function Oe(e, t = 14, n = !1) {
987
1150
  function ke(e) {
988
1151
  return e.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
989
1152
  }
990
- var K = /* @__PURE__ */ new Map(), Ae = 200;
1153
+ var q = /* @__PURE__ */ new Map(), Ae = 200;
991
1154
  function je(e, t = 14, n = !1) {
992
1155
  let r = e;
993
1156
  try {
994
1157
  r = decodeURIComponent(e);
995
1158
  } catch {}
996
- let i = `${t}:${n}:${r}`, a = K.get(i);
1159
+ let i = `${t}:${n}:${r}`, a = q.get(i);
997
1160
  if (a) return a;
998
1161
  try {
999
1162
  let e = window.MathJax;
@@ -1017,9 +1180,9 @@ function je(e, t = 14, n = !1) {
1017
1180
  width: s,
1018
1181
  height: c
1019
1182
  };
1020
- if (K.set(i, d), K.size > Ae) {
1021
- let e = K.keys().next().value;
1022
- e && K.delete(e);
1183
+ if (q.set(i, d), q.size > Ae) {
1184
+ let e = q.keys().next().value;
1185
+ e && q.delete(e);
1023
1186
  }
1024
1187
  return d;
1025
1188
  } catch {
@@ -1133,11 +1296,11 @@ function Re(e) {
1133
1296
  }
1134
1297
  };
1135
1298
  }
1136
- function q(e) {
1299
+ function ze(e) {
1137
1300
  let t = e.startsWith("sw-") ? e.slice(3) : e, n = t.lastIndexOf("-");
1138
1301
  return n > 0 && /^\d+$/.test(t.slice(n + 1)) && (t = t.slice(0, n)), t;
1139
1302
  }
1140
- function ze(e) {
1303
+ function Be(e) {
1141
1304
  let t = /* @__PURE__ */ new Map();
1142
1305
  for (let n of e) {
1143
1306
  t.set(n.id, n);
@@ -1146,7 +1309,7 @@ function ze(e) {
1146
1309
  }
1147
1310
  return t;
1148
1311
  }
1149
- function Be(e) {
1312
+ function J(e) {
1150
1313
  let t = e?.questionType;
1151
1314
  if (t) {
1152
1315
  if (t.includes("chose")) return "choice";
@@ -1158,27 +1321,27 @@ function Be(e) {
1158
1321
  function Ve(e) {
1159
1322
  return e.replace(/-([a-z])/g, (e, t) => t.toUpperCase());
1160
1323
  }
1161
- function J(e) {
1324
+ function He(e) {
1162
1325
  return /_Block_\d+$/.test(e) || /-sub\d+$/.test(e);
1163
1326
  }
1164
- function He(e) {
1327
+ function Ue(e) {
1165
1328
  let t = e.match(/^(.+)_Block_\d+$/);
1166
1329
  if (t) return t[1];
1167
1330
  let n = e.match(/^(.+)-sub\d+$/);
1168
1331
  return n ? `${n[1]}-header` : "";
1169
1332
  }
1170
- function Ue(e) {
1333
+ function We(e) {
1171
1334
  let t = [];
1172
1335
  for (let n of e.paragraphs) for (let e of n.lines) for (let n of e.elements) n.type === "text" && t.push(n.value);
1173
1336
  let n = t.join("").trim();
1174
1337
  return !n && e.metadata?.label ? e.metadata.label : n;
1175
1338
  }
1176
- function We(e) {
1339
+ function Ge(e) {
1177
1340
  let t = [], n = null;
1178
1341
  for (let r of e) {
1179
1342
  if (r.type === "title") {
1180
1343
  n &&= (t.push(n), null);
1181
- let e = Ue(r);
1344
+ let e = We(r);
1182
1345
  t.push({
1183
1346
  type: "title-section",
1184
1347
  name: e || "题目",
@@ -1197,7 +1360,7 @@ function We(e) {
1197
1360
  }
1198
1361
  //#endregion
1199
1362
  //#region src/utils/serialization/buildQuestions.ts
1200
- function Ge(e, t) {
1363
+ function Ke(e, t) {
1201
1364
  if (e.type === "title" || e.type === "info-line") return null;
1202
1365
  let n = e.type === "sub-question" ? Le : Ie, r = A[t.paperSize], [, , i, a] = t.margins || [
1203
1366
  50,
@@ -1236,15 +1399,24 @@ function Ge(e, t) {
1236
1399
  let t = { ...e.metadata };
1237
1400
  return delete t.score, delete t.questionNo, delete t.subLabel, delete t.topicId, delete t.topicLabel, delete t.qid, Object.keys(t).length > 0 ? JSON.stringify(t) : void 0;
1238
1401
  })()
1239
- }, f = {
1402
+ }, f = e.options ? e.options.reduce((e, t) => e + t.paragraphs.length, 0) : 0, p = 0;
1403
+ if (e.options && e.options.length > 0) for (let t = e.paragraphs.length - 1; t >= 0; t--) {
1404
+ let n = e.paragraphs[t];
1405
+ if (n.lines.length > 0 && n.lines.every((e) => e.elements.length > 0 && e.elements.every((e) => e.type === "enter"))) p++;
1406
+ else break;
1407
+ }
1408
+ let m = e.paragraphs.length - f - p, h = {
1240
1409
  type: "question-stem",
1241
- children: e.paragraphs.map((e) => qe(e)),
1410
+ children: e.paragraphs.slice(0, m).filter((e) => {
1411
+ let t = e.lines[0]?.elements[0];
1412
+ return !(t?.type === "text" && t.isLabel);
1413
+ }).map((e) => Je(e)),
1242
1414
  props: {
1243
1415
  split: !0,
1244
1416
  anchorOverflow: !1,
1245
1417
  topicId: e.metadata?.topicId || e.id
1246
1418
  }
1247
- }, p = {
1419
+ }, g = {
1248
1420
  type: "correction-box",
1249
1421
  children: [{
1250
1422
  type: "text",
@@ -1266,14 +1438,30 @@ function Ge(e, t) {
1266
1438
  topicId: e.metadata?.topicId || e.id,
1267
1439
  isLongScoreBar: !0
1268
1440
  }
1269
- }, m = [f];
1270
- return e.options && e.options.length > 0 && m.push(Ke(e.options, e.metadata?.topicId || e.id)), m.push(p), (e.questionType === "single_chose" || e.questionType === "multi_chose") && (d.choiceMarkingType = e.questionType === "single_chose" ? 2 : 3), {
1441
+ }, _ = [h], v = Xe(e, m, m + f);
1442
+ v.length > 0 && _.push(qe(v, e.metadata?.topicId || e.id));
1443
+ let y = m + f;
1444
+ if (p > 0 && y < e.paragraphs.length) {
1445
+ let t = [];
1446
+ for (let n = y; n < e.paragraphs.length; n++) t.push(Je(e.paragraphs[n]));
1447
+ let n = {
1448
+ type: "question-stem",
1449
+ children: t,
1450
+ props: {
1451
+ split: !0,
1452
+ anchorOverflow: !1,
1453
+ topicId: e.metadata?.topicId || e.id
1454
+ }
1455
+ };
1456
+ _.push(n);
1457
+ }
1458
+ return _.push(g), (e.questionType === "single_chose" || e.questionType === "multi_chose") && (d.choiceMarkingType = e.questionType === "single_chose" ? 2 : 3), {
1271
1459
  type: "question",
1272
1460
  props: d,
1273
- children: m
1461
+ children: _
1274
1462
  };
1275
1463
  }
1276
- function Ke(e, t) {
1464
+ function qe(e, t) {
1277
1465
  return {
1278
1466
  type: "option",
1279
1467
  props: {
@@ -1282,7 +1470,7 @@ function Ke(e, t) {
1282
1470
  keepNext: !1
1283
1471
  },
1284
1472
  children: e.map((e, t) => {
1285
- let n = e.paragraphs.map((e) => qe(e));
1473
+ let n = e.paragraphs.map((e) => Je(e));
1286
1474
  return {
1287
1475
  type: "option-item",
1288
1476
  props: {
@@ -1296,10 +1484,10 @@ function Ke(e, t) {
1296
1484
  })
1297
1485
  };
1298
1486
  }
1299
- function qe(e) {
1487
+ function Je(e) {
1300
1488
  let t = [];
1301
1489
  for (let n of e.lines) for (let e of n.elements) {
1302
- let r = Je(e, n);
1490
+ let r = Ye(e, n);
1303
1491
  r && t.push(r);
1304
1492
  }
1305
1493
  return {
@@ -1315,7 +1503,7 @@ function qe(e) {
1315
1503
  children: t
1316
1504
  };
1317
1505
  }
1318
- function Je(e, t) {
1506
+ function Ye(e, t) {
1319
1507
  switch (e.type) {
1320
1508
  case "text": {
1321
1509
  let t = e;
@@ -1478,9 +1666,29 @@ function Je(e, t) {
1478
1666
  default: return null;
1479
1667
  }
1480
1668
  }
1669
+ function Xe(e, t, n) {
1670
+ let r = [], i = "", a = [], o = t ?? 0, s = n ?? e.paragraphs.length;
1671
+ for (let t = o; t < s && t < e.paragraphs.length; t++) {
1672
+ let n = e.paragraphs[t], o = n.lines[0]?.elements[0];
1673
+ if (o?.type === "text" && o.isLabel) {
1674
+ i && r.push({
1675
+ label: i,
1676
+ contentHtml: "",
1677
+ paragraphs: a
1678
+ }), i = o.value.replace(/\.\s*$/g, ""), a = [];
1679
+ let e = JSON.parse(JSON.stringify(n));
1680
+ e.lines[0] && (e.lines[0].elements = e.lines[0].elements.filter((e) => !(e.type === "text" && e.isLabel))), a.push(e);
1681
+ } else i && a.push(JSON.parse(JSON.stringify(n)));
1682
+ }
1683
+ return i && r.push({
1684
+ label: i,
1685
+ contentHtml: "",
1686
+ paragraphs: a
1687
+ }), r;
1688
+ }
1481
1689
  //#endregion
1482
1690
  //#region src/utils/serialization/buildBody.ts
1483
- function Ye(e, t) {
1691
+ function Ze(e, t) {
1484
1692
  let n = A[t.paperSize], [r, i, a, o] = t.margins || [
1485
1693
  50,
1486
1694
  56,
@@ -1526,7 +1734,7 @@ function Ye(e, t) {
1526
1734
  colorType: "rgb",
1527
1735
  colorValue: "7030A0"
1528
1736
  } } }
1529
- }, u = Xe(e, t);
1737
+ }, u = Qe(e, t);
1530
1738
  return {
1531
1739
  type: "document",
1532
1740
  props: l,
@@ -1543,16 +1751,16 @@ function Ye(e, t) {
1543
1751
  }]
1544
1752
  };
1545
1753
  }
1546
- function Xe(e, t) {
1547
- let n = [], r = We(e);
1548
- for (let e of r) if (e.type === "title-section") n.push(Ze(e.name, e.blocks));
1754
+ function Qe(e, t) {
1755
+ let n = [], r = Ge(e);
1756
+ for (let e of r) if (e.type === "title-section") n.push($e(e.name, e.blocks));
1549
1757
  else for (let r of e.blocks) {
1550
- let e = Ge(r, t);
1758
+ let e = Ke(r, t);
1551
1759
  e && n.push(e);
1552
1760
  }
1553
1761
  return n;
1554
1762
  }
1555
- function Ze(e, t) {
1763
+ function $e(e, t) {
1556
1764
  let n = t.filter((e) => e.metadata?.score).map((e) => parseInt(e.metadata.score) || 0).reduce((e, t) => e + t, 0), r = t[0], i = r?.metadata?.title || e, a = r?.metadata?.label || e;
1557
1765
  return {
1558
1766
  type: "vueplug",
@@ -1583,7 +1791,7 @@ function Ze(e, t) {
1583
1791
  }
1584
1792
  //#endregion
1585
1793
  //#region src/utils/serialization/buildPagesExport.ts
1586
- var Qe = new Set([
1794
+ var et = new Set([
1587
1795
  "header-desc",
1588
1796
  "score",
1589
1797
  "paper-name",
@@ -1593,12 +1801,12 @@ var Qe = new Set([
1593
1801
  "student-code",
1594
1802
  "student-code-filler"
1595
1803
  ]);
1596
- function $e(e, t, n = !0) {
1597
- let r = ze(t), i = /* @__PURE__ */ new Map();
1804
+ function tt(e, t, n = !0) {
1805
+ let r = Be(t), i = /* @__PURE__ */ new Map();
1598
1806
  for (let e of t) {
1599
1807
  let t = e.metadata?.blockGroup;
1600
1808
  if (t && e.type === "question") {
1601
- let n = q(e.id);
1809
+ let n = ze(e.id);
1602
1810
  i.set(t, {
1603
1811
  topicId: n,
1604
1812
  qid: e.metadata?.qid
@@ -1607,16 +1815,16 @@ function $e(e, t, n = !0) {
1607
1815
  }
1608
1816
  let a = /* @__PURE__ */ new Set(), o = /* @__PURE__ */ new Set();
1609
1817
  for (let t of e) for (let e of t.renderedRegions || []) {
1610
- let t = q(e.meta?.blockId || e.meta?.topicId || "");
1818
+ let t = ze(e.meta?.blockId || e.meta?.topicId || "");
1611
1819
  t && e.type === "question-border" && a.add(t);
1612
1820
  }
1613
- for (let e of a) J(e) && o.add(He(e));
1821
+ for (let e of a) He(e) && o.add(Ue(e));
1614
1822
  for (let e of t) if (e.type === "sub-question") {
1615
1823
  let t = e.metadata?.topicId || (e.id.startsWith("sw-") ? e.id.slice(3) : e.id);
1616
1824
  if (e.metadata?.blockGroup) {
1617
1825
  let t = i.get(e.metadata.blockGroup);
1618
1826
  t && o.add(t.topicId);
1619
- } else J(t) && o.add(He(t));
1827
+ } else He(t) && o.add(Ue(t));
1620
1828
  }
1621
1829
  let s = /* @__PURE__ */ new Map(), c = 0;
1622
1830
  for (let e of t) {
@@ -1624,7 +1832,7 @@ function $e(e, t, n = !0) {
1624
1832
  s.has(t) || s.set(t, c++);
1625
1833
  }
1626
1834
  for (let t of e) for (let e of t.renderedRegions || []) {
1627
- let t = q(e.meta?.blockId || e.meta?.topicId || "");
1835
+ let t = ze(e.meta?.blockId || e.meta?.topicId || "");
1628
1836
  t && e.type === "question-border" && !s.has(t) && s.set(t, c++);
1629
1837
  }
1630
1838
  return e.map((t) => {
@@ -1639,7 +1847,7 @@ function $e(e, t, n = !0) {
1639
1847
  questions: []
1640
1848
  }, l = {}, u = [], d, f = /* @__PURE__ */ new Map();
1641
1849
  for (let e of a) {
1642
- if (Qe.has(e.type)) {
1850
+ if (et.has(e.type)) {
1643
1851
  if (e.type === "score" && !n) continue;
1644
1852
  l[Ve(e.type)] = e.bbox;
1645
1853
  continue;
@@ -1656,7 +1864,7 @@ function $e(e, t, n = !0) {
1656
1864
  continue;
1657
1865
  }
1658
1866
  if (e.type === "column-separator") continue;
1659
- let t = q(e.meta?.blockId || e.meta?.topicId || "");
1867
+ let t = ze(e.meta?.blockId || e.meta?.topicId || "");
1660
1868
  if (!t) continue;
1661
1869
  f.has(t) || f.set(t, {
1662
1870
  borders: [],
@@ -1672,10 +1880,10 @@ function $e(e, t, n = !0) {
1672
1880
  });
1673
1881
  for (let [t, n] of p) {
1674
1882
  if (n.borders.length === 0) continue;
1675
- let a = r.get(t), l = a?.metadata?.questionNo || a?.metadata?.subLabel || "", u = a?.metadata?.score, d = o.has(t), f = J(t) || a?.type === "sub-question", p = n.borders.map((e) => e.bbox), m = {
1883
+ let a = r.get(t), l = a?.metadata?.questionNo || a?.metadata?.subLabel || "", u = a?.metadata?.score, d = o.has(t), f = He(t) || a?.type === "sub-question", p = n.borders.map((e) => e.bbox), m = {
1676
1884
  topicId: t,
1677
1885
  questionNo: l,
1678
- questionType: Be(a),
1886
+ questionType: J(a),
1679
1887
  sortIndex: s.get(t) ?? 9999,
1680
1888
  bbox: p[0]
1681
1889
  };
@@ -1686,13 +1894,13 @@ function $e(e, t, n = !0) {
1686
1894
  if (f) if (a?.metadata?.blockGroup) {
1687
1895
  let e = i.get(a.metadata.blockGroup);
1688
1896
  e && (m.parentTopicId = e.topicId, e.qid && (m.pqid = e.qid));
1689
- } else m.parentTopicId = He(t);
1897
+ } else m.parentTopicId = Ue(t);
1690
1898
  d && (m.hasSubQuestions = !0), n.underlines.length > 0 && (m.underlines = n.underlines.map((e) => {
1691
1899
  let t = { bbox: e.bbox }, n = e.meta;
1692
1900
  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;
1693
1901
  })), e.filter((e) => e.renderedRegions.some((e) => {
1694
1902
  let n = e.meta?.blockId || e.meta?.topicId || "";
1695
- return n && q(n) === t;
1903
+ return n && ze(n) === t;
1696
1904
  })).length > 1 && (m.isCrossPage = !0), c.questions.push(m);
1697
1905
  }
1698
1906
  return c;
@@ -1700,8 +1908,8 @@ function $e(e, t, n = !0) {
1700
1908
  }
1701
1909
  //#endregion
1702
1910
  //#region src/utils/textWrap.ts
1703
- var et = ",。、;:?!…)】》'\"'\"…·", tt = "(【《'\"'\"";
1704
- function nt(e, t) {
1911
+ var nt = ",。、;:?!…)】》'\"'\"…·", rt = "(【《'\"'\"";
1912
+ function it(e, t) {
1705
1913
  let n = t, r = t * .5;
1706
1914
  for (let t of e) if (t.type === "formula") {
1707
1915
  let e = t, i = e.svgContent.match(/vertical-align:\s*([-\d.]+)(px|ex)/), a;
@@ -1724,7 +1932,7 @@ function nt(e, t) {
1724
1932
  y: 0
1725
1933
  };
1726
1934
  }
1727
- function rt(e, t, n, r = 0) {
1935
+ function at(e, t, n, r = 0) {
1728
1936
  let i = [], a = [], o = 0;
1729
1937
  for (let n = 0; n < e.length; n++) {
1730
1938
  let s = e[n];
@@ -1790,12 +1998,12 @@ function rt(e, t, n, r = 0) {
1790
1998
  continue;
1791
1999
  }
1792
2000
  }
1793
- let u = s.type === "text" && et.includes(s.value) && a.length > 0 && o + s.width <= l;
2001
+ let u = s.type === "text" && nt.includes(s.value) && a.length > 0 && o + s.width <= l;
1794
2002
  if (o + s.width > l && a.length > 0 && !u) {
1795
2003
  let e = a.length;
1796
2004
  if (a.length > 0) {
1797
2005
  let t = a[a.length - 1];
1798
- t.type === "text" && tt.includes(t.value) && a.length > 1 && (e = a.length - 1);
2006
+ t.type === "text" && rt.includes(t.value) && a.length > 1 && (e = a.length - 1);
1799
2007
  }
1800
2008
  i.push(a.slice(0, e)), a = [...a.slice(e), s], o = a.reduce((e, t) => e + t.width, 0);
1801
2009
  } else a.push(s), o += s.width;
@@ -1803,26 +2011,26 @@ function rt(e, t, n, r = 0) {
1803
2011
  return a.length > 0 && i.push(a), i.length > 0 ? i.map((e, i) => {
1804
2012
  let a = t;
1805
2013
  return i === 0 && r > 0 && (a -= r), {
1806
- ...nt(e, n),
2014
+ ...it(e, n),
1807
2015
  availableWidth: a
1808
2016
  };
1809
2017
  }) : [{
1810
- ...nt(e, n),
2018
+ ...it(e, n),
1811
2019
  availableWidth: t
1812
2020
  }];
1813
2021
  }
1814
- function it(e, t, n) {
1815
- return rt(e, t, n, 0);
2022
+ function ot(e, t, n) {
2023
+ return at(e, t, n, 0);
1816
2024
  }
1817
2025
  //#endregion
1818
2026
  //#region src/utils/deserialization/parseInlines.ts
1819
- var at = 0;
1820
- function ot(e) {
2027
+ var st = 0;
2028
+ function ct(e) {
1821
2029
  switch (e.type) {
1822
2030
  case "text": {
1823
2031
  let t = e;
1824
2032
  if (!t.text) return null;
1825
- 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 = {
2033
+ 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 = H(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 = {
1826
2034
  type: "text",
1827
2035
  value: t.text,
1828
2036
  fontFamily: r,
@@ -1861,7 +2069,7 @@ function ot(e) {
1861
2069
  let t = e, n = t.props.rect?.width || 80;
1862
2070
  return {
1863
2071
  type: "underline",
1864
- id: t.props.ulId || `ul-${++at}`,
2072
+ id: t.props.ulId || `ul-${++st}`,
1865
2073
  width: n,
1866
2074
  height: 20,
1867
2075
  placeholder: t.props.placeholder || "空",
@@ -1931,88 +2139,126 @@ function ot(e) {
1931
2139
  }
1932
2140
  //#endregion
1933
2141
  //#region src/utils/deserialization/parseQuestions.ts
1934
- var st = 0;
1935
- function ct(e, t, n, r) {
1936
- let i = [], a = e.props, o = e.children.find((e) => e.type === "question-stem");
1937
- if (!o) return i;
2142
+ var lt = 0;
2143
+ function ut(e, t, n, r) {
2144
+ let i = [], a = e.props, o = e.children.filter((e) => e.type === "question-stem");
2145
+ if (o.length === 0) return i;
1938
2146
  let s = a.topicId.includes("_Block_"), c = t ? t - (s ? Le : Ie) : void 0, l = [];
1939
- for (let e of o.children) e.type === "paragraph" && l.push(ut(e, c, n, r));
1940
- st++;
2147
+ for (let e of o[0].children) e.type === "paragraph" && l.push(ft(e, c, n, r));
2148
+ lt++;
1941
2149
  let u = {
1942
- id: `sw-${a.topicId}-${st}`,
2150
+ id: `sw-${a.topicId}-${lt}`,
1943
2151
  type: s ? "sub-question" : "question",
1944
2152
  paragraphs: l,
1945
2153
  height: l.reduce((e, t) => e + (t.height || 26), 0),
1946
2154
  metadata: {
1947
2155
  questionNo: s ? "" : a.topicIndex,
1948
2156
  subLabel: s ? a.topicIndex : "",
1949
- score: lt(e),
2157
+ score: dt(e),
1950
2158
  topicId: a.topicId,
1951
2159
  label: a.topicIndex,
1952
2160
  blockGroup: a.isMaterial ? a.topicId.split("_Block_")[0] : void 0,
1953
2161
  qid: a.qid
1954
2162
  }
1955
2163
  }, d = e.children.find((e) => e.type === "option");
1956
- if (d && d.children && d.children.length > 0 && (u.questionType = a.choiceMarkingType === 2 ? "single_chose" : "multi_chose", u.options = d.children.map((e) => {
1957
- let t = [];
1958
- for (let i of e.children) i.type === "paragraph" && t.push(ut(i, c, n, r));
1959
- return {
1960
- label: e.props.oriLabel || e.props.label?.replace(".", "") || "",
1961
- contentHtml: "",
1962
- paragraphs: t
1963
- };
1964
- })), a.keepNext !== void 0 && (u.keepNext = a.keepNext), a.blockQuestionType && (u.questionType = a.blockQuestionType), a.blockHeight && a.blockHeight > 0 && (u.height = a.blockHeight), a.blockMeta) try {
2164
+ if (d && d.children && d.children.length > 0) {
2165
+ u.questionType = a.choiceMarkingType === 2 ? "single_chose" : "multi_chose";
2166
+ let e = c ? c - 20 : void 0;
2167
+ u.options = d.children.map((t) => {
2168
+ let i = [];
2169
+ for (let a of t.children) a.type === "paragraph" && i.push(ft(a, e, n, r));
2170
+ return {
2171
+ label: t.props.oriLabel || t.props.label?.replace(".", "") || "",
2172
+ contentHtml: "",
2173
+ paragraphs: i
2174
+ };
2175
+ });
2176
+ for (let e of u.options) {
2177
+ if (e.paragraphs.length > 0) {
2178
+ let t = e.paragraphs[0], r = `${e.label}. `, i = V(r, n || 16, "\"Times New Roman\", SimSun"), a = {
2179
+ type: "text",
2180
+ value: r,
2181
+ fontFamily: "\"Times New Roman\", SimSun",
2182
+ fontSize: n || 16,
2183
+ bold: !1,
2184
+ italic: !1,
2185
+ color: "#000",
2186
+ width: i,
2187
+ height: (n || 16) * 1.4,
2188
+ xPositions: [],
2189
+ isLabel: !0
2190
+ };
2191
+ t.lines.length > 0 ? t.lines[0].elements.unshift(a) : t.lines.push({
2192
+ elements: [a],
2193
+ baseline: 20,
2194
+ lineHeight: 20,
2195
+ y: 0
2196
+ });
2197
+ }
2198
+ u.paragraphs.push(...e.paragraphs);
2199
+ }
2200
+ }
2201
+ for (let e = 1; e < o.length; e++) for (let t of o[e].children) t.type === "paragraph" && u.paragraphs.push(ft(t, c, n, r));
2202
+ if (a.keepNext !== void 0 && (u.keepNext = a.keepNext), a.blockQuestionType && (u.questionType = a.blockQuestionType), a.blockHeight && a.blockHeight > 0 && (u.height = a.blockHeight), a.blockMeta) try {
1965
2203
  let e = JSON.parse(a.blockMeta);
1966
2204
  Object.assign(u.metadata, e);
1967
2205
  } catch {}
1968
2206
  return i.push(u), i;
1969
2207
  }
1970
- function lt(e) {
2208
+ function dt(e) {
1971
2209
  for (let t of e.children) if (t.type === "question-stem") {
1972
2210
  for (let e of t.children) for (let t of e.children) if (t.type === "question-score") return `${t.props.score}`;
1973
2211
  }
1974
2212
  for (let t of e.children) if (t.type === "correction-box") return `${t.props.score}`;
1975
2213
  return "";
1976
2214
  }
1977
- function ut(e, t, n, r) {
2215
+ function ft(e, t, n, r) {
1978
2216
  let i = [];
1979
2217
  for (let t of e.children) {
1980
- let e = ot(t);
2218
+ let e = ct(t);
1981
2219
  e && i.push(e);
1982
2220
  }
1983
- i.length === 0 && i.push({
2221
+ if (i.length === 0 && i.push({
1984
2222
  type: "enter",
1985
2223
  width: 20,
1986
2224
  height: 20
1987
- });
1988
- let a = r ?? Math.round((n ?? 14) * 1.5 * 35 / (14 * 1.5));
2225
+ }), t && t > 0) {
2226
+ for (let e of i) if (e.type === "image") {
2227
+ let n = e;
2228
+ if (n.width > t && !n.rawHtml) {
2229
+ let e = n.height / n.width;
2230
+ n.width = t, n.height = Math.round(t * e);
2231
+ }
2232
+ }
2233
+ }
2234
+ let a = r ?? Math.round((n ?? 14) * 1.5 * 35 / (14 * 1.5)), o = i.length === 1 && i[0].type === "enter";
1989
2235
  if (t && t > 0 && i.length > 0) {
1990
- let n = it(i, t, a), r = n.reduce((e, t) => e + t.lineHeight, 0) + 4, o = e.props?.justification, s = e.props?.split;
2236
+ let n = ot(i, t, a), r = n.reduce((e, t) => e + t.lineHeight, 0) + (o ? 0 : 4), s = e.props?.justification, c = e.props?.split;
1991
2237
  return {
1992
2238
  lines: n,
1993
2239
  y: 0,
1994
2240
  height: r,
1995
- justification: o && o !== "left" ? o : void 0,
1996
- split: s
2241
+ justification: s && s !== "left" ? s : void 0,
2242
+ split: c
1997
2243
  };
1998
2244
  }
1999
- let o = {
2245
+ let s = {
2000
2246
  elements: i,
2001
2247
  baseline: a * .5,
2002
2248
  lineHeight: a,
2003
2249
  y: 0
2004
- }, s = e.props?.justification, c = e.props?.split;
2250
+ }, c = e.props?.justification, l = e.props?.split;
2005
2251
  return {
2006
- lines: [o],
2252
+ lines: [s],
2007
2253
  y: 0,
2008
- height: a + 4,
2009
- justification: s && s !== "left" ? s : void 0,
2010
- split: c
2254
+ height: o ? a : a + 4,
2255
+ justification: c && c !== "left" ? c : void 0,
2256
+ split: l
2011
2257
  };
2012
2258
  }
2013
2259
  //#endregion
2014
2260
  //#region src/utils/deserialization/parseDocument.ts
2015
- function dt(e) {
2261
+ function pt(e) {
2016
2262
  let t;
2017
2263
  try {
2018
2264
  t = JSON.parse(e);
@@ -2023,9 +2269,9 @@ function dt(e) {
2023
2269
  if (!t.body || typeof t.body != "object") throw Error("[documentSerializer] 文档格式错误: 缺少 body 字段");
2024
2270
  if (!t.body.props || !t.body.props.paper) throw Error("[documentSerializer] 文档格式错误: 缺少 body.props.paper");
2025
2271
  if (!Array.isArray(t.body.children)) throw Error("[documentSerializer] 文档格式错误: body.children 应为数组");
2026
- return delete t._pages, delete t._regions, ft(t);
2272
+ return delete t._pages, delete t._regions, mt(t);
2027
2273
  }
2028
- function ft(e) {
2274
+ function mt(e) {
2029
2275
  let t = e.body, n = t.props.paper, r = n.padding || {
2030
2276
  top: 50,
2031
2277
  right: 56,
@@ -2059,10 +2305,10 @@ function ft(e) {
2059
2305
  }
2060
2306
  let m = n.width - n.padding.left - n.padding.right, h = i.columns > 1 ? a.columnGap || 16 : 0, g = i.columns > 1 ? (m - h * (i.columns - 1)) / i.columns : m, _ = [];
2061
2307
  for (let e of t.children) for (let t of e.children) if (t.type === "vueplug") {
2062
- let e = pt(t);
2308
+ let e = ht(t);
2063
2309
  e && _.push(e);
2064
2310
  } else if (t.type === "question") {
2065
- let e = ct(t, g, o, c);
2311
+ let e = ut(t, g, o, c);
2066
2312
  _.push(...e);
2067
2313
  }
2068
2314
  return {
@@ -2075,7 +2321,7 @@ function ft(e) {
2075
2321
  totalScore: p
2076
2322
  };
2077
2323
  }
2078
- function pt(e) {
2324
+ function ht(e) {
2079
2325
  let t = e.props?.bind || {}, n = t?.topicTitle || t?.title || t?.input || "";
2080
2326
  if (!n) return null;
2081
2327
  let r = {
@@ -2083,7 +2329,7 @@ function pt(e) {
2083
2329
  isTitle: !0
2084
2330
  };
2085
2331
  return t.topicTitle && (r.title = String(t.title || "")), {
2086
- id: `title-${e.props.id}-${++mt}`,
2332
+ id: `title-${e.props.id}-${++gt}`,
2087
2333
  type: "title",
2088
2334
  paragraphs: [],
2089
2335
  height: e.props.rect?.height || 40,
@@ -2091,11 +2337,11 @@ function pt(e) {
2091
2337
  keepNext: e.props.keepNext ?? !1
2092
2338
  };
2093
2339
  }
2094
- var mt = 0;
2340
+ var gt = 0;
2095
2341
  //#endregion
2096
2342
  //#region src/utils/documentSerializer.ts
2097
- function ht(e, t, n = {}) {
2098
- let r = Ye(e, t), i = {
2343
+ function _t(e, t, n = {}) {
2344
+ let r = Ze(e, t), i = {
2099
2345
  info: {
2100
2346
  author: "",
2101
2347
  created: "",
@@ -2354,16 +2600,16 @@ function ht(e, t, n = {}) {
2354
2600
  mode: 1,
2355
2601
  lastUpdateTime: Date.now()
2356
2602
  };
2357
- return n.pages && n.pages.length > 0 && (i._pages = $e(n.pages, n.blocks || [], t.showScore)), JSON.stringify(i, null, 2);
2603
+ return n.pages && n.pages.length > 0 && (i._pages = tt(n.pages, n.blocks || [], t.showScore)), JSON.stringify(i, null, 2);
2358
2604
  }
2359
- function gt(e) {
2360
- return dt(e);
2605
+ function vt(e) {
2606
+ return pt(e);
2361
2607
  }
2362
2608
  //#endregion
2363
2609
  //#region src/utils/questionHtmlParser.ts
2364
- var _t = 0, vt = 0, yt = 0, bt = .5;
2365
- function xt(e, t = {}) {
2366
- 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([
2610
+ var yt = 0, bt = 0, xt = 0, St = .5;
2611
+ function Ct(e, t = {}) {
2612
+ let { questionNo: n = "", score: r = "", contentWidth: i = 600, fontSize: a = 16, lineSpacing: o = 1, protectContent: s = !1, inlineOnly: c = !1 } = t, l = new DOMParser().parseFromString(e, "text/html"), u = [], d = Math.round(a * o * 1.67), f = n.length > 2 ? 26.25 : 17.5, p = new Set([
2367
2613
  "p",
2368
2614
  "h1",
2369
2615
  "h2",
@@ -2381,7 +2627,7 @@ function xt(e, t = {}) {
2381
2627
  if (t.nodeType !== Node.ELEMENT_NODE) continue;
2382
2628
  let n = t, r = n.tagName.toLowerCase();
2383
2629
  if (r === "table") {
2384
- let e = Mt(n, i, d), t = e.reduce((e, t) => e + t.lineHeight, 0) + 4;
2630
+ let e = Pt(n, i, d), t = e.reduce((e, t) => e + t.lineHeight, 0) + 4;
2385
2631
  u.push({
2386
2632
  lines: e,
2387
2633
  y: 0,
@@ -2392,7 +2638,7 @@ function xt(e, t = {}) {
2392
2638
  if (r === "figure") {
2393
2639
  let e = n.querySelector("table");
2394
2640
  if (e) {
2395
- let t = Mt(e, i, d), n = t.reduce((e, t) => e + t.lineHeight, 0) + 4;
2641
+ let t = Pt(e, i, d), n = t.reduce((e, t) => e + t.lineHeight, 0) + 4;
2396
2642
  u.push({
2397
2643
  lines: t,
2398
2644
  y: 0,
@@ -2406,50 +2652,36 @@ function xt(e, t = {}) {
2406
2652
  let e = Array.from(n.children).filter((e) => e.tagName.toLowerCase() === "p");
2407
2653
  if (e.length > 0) {
2408
2654
  for (let t of e) {
2409
- let e = t.getAttribute("style") || "", n = Y(t, a, e, i, f);
2655
+ let e = t.getAttribute("style") || "", n = Y(t, a, e, i, f, c);
2410
2656
  if (n.length === 0) continue;
2411
- let r = rt(n, i, d), o = r.reduce((e, t) => e + t.lineHeight, 0) + 4;
2657
+ let r = at(n, i, d), o = r.reduce((e, t) => e + t.lineHeight, 0) + 4;
2412
2658
  u.push({
2413
2659
  lines: r,
2414
2660
  y: 0,
2415
2661
  height: o,
2416
- justification: Ct(n, e)
2662
+ justification: Tt(n, e, c)
2417
2663
  });
2418
2664
  }
2419
2665
  continue;
2420
2666
  }
2421
2667
  }
2422
- let o = n, s = o.getAttribute("style") || "", c = Y(o, a, s, i, f);
2423
- if (c.length === 0) continue;
2424
- let m = rt(c, i, d), h = m.reduce((e, t) => e + t.lineHeight, 0) + 4;
2668
+ let o = n, s = o.getAttribute("style") || "", m = Y(o, a, s, i, f, c);
2669
+ if (m.length === 0) continue;
2670
+ let h = at(m, i, d), g = h.reduce((e, t) => e + t.lineHeight, 0) + 4;
2425
2671
  u.push({
2426
- lines: m,
2672
+ lines: h,
2427
2673
  y: 0,
2428
- height: h,
2429
- justification: Ct(c, s)
2674
+ height: g,
2675
+ justification: Tt(m, s, c)
2430
2676
  });
2431
2677
  }
2432
- if (!s) for (let e = 0; e < 2; e++) u.push({
2433
- lines: [{
2434
- elements: [{
2435
- type: "enter",
2436
- width: 20,
2437
- height: 20
2438
- }],
2439
- baseline: d * .5,
2440
- lineHeight: d,
2441
- y: 0
2442
- }],
2443
- y: 0,
2444
- height: d + 4
2445
- });
2446
- let m = u.reduce((e, t) => e + (t.height || 26), 0), h = `topic-html-${++vt}`;
2678
+ let m = u.reduce((e, t) => e + (t.height || 26), 0), h = `topic-html-${++bt}`;
2447
2679
  return [{
2448
2680
  id: `q-html-${Date.now()}-${Math.random().toString(36).slice(2, 6)}`,
2449
2681
  type: "question",
2450
2682
  paragraphs: u,
2451
2683
  height: m,
2452
- protectContent: c,
2684
+ protectContent: s,
2453
2685
  metadata: {
2454
2686
  questionNo: n,
2455
2687
  score: r,
@@ -2459,34 +2691,34 @@ function xt(e, t = {}) {
2459
2691
  }
2460
2692
  }];
2461
2693
  }
2462
- function Y(e, t, n, r, i) {
2463
- let a = [];
2464
- for (let o = 0; o < e.childNodes.length; o++) {
2465
- let s = e.childNodes[o];
2466
- if (s.nodeType === Node.TEXT_NODE) {
2467
- let e = s.textContent || "";
2694
+ function Y(e, t, n, r, i, a = !1) {
2695
+ let o = [];
2696
+ for (let s = 0; s < e.childNodes.length; s++) {
2697
+ let c = e.childNodes[s];
2698
+ if (c.nodeType === Node.TEXT_NODE) {
2699
+ let e = c.textContent || "";
2468
2700
  if (!e || e === "\n") continue;
2469
2701
  let r = e.replace(/\u00A0/g, " ").replace(/\n/g, "").replace(/\s+/g, " ");
2470
2702
  if (!r.trim()) {
2471
- if (a.length > 0) {
2472
- let e = Et(n) || t, r = Dt(n) || "\"Times New Roman\", SimSun", i = Ot(n) || "#000", o = /font-style:\s*(italic|oblique)/.test(n);
2473
- a.push(wt("\xA0", e, r, !1, i, o));
2703
+ if (o.length > 0) {
2704
+ let e = Ot(n) || t, r = kt(n) || "\"Times New Roman\", SimSun", i = At(n) || "#000", a = /font-style:\s*(italic|oblique)/.test(n);
2705
+ o.push(Et("\xA0", e, r, !1, i, a));
2474
2706
  }
2475
2707
  continue;
2476
2708
  }
2477
- 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);
2478
- a.push(wt(l, u, d, p, f, m));
2709
+ let i = r.startsWith(" ") && o.length > 0, a = r.endsWith(" "), s = r.trim(), l = (i ? "\xA0" : "") + s + (a ? "\xA0" : ""), u = Ot(n) || t, d = kt(n) || "\"Times New Roman\", SimSun", f = At(n) || "#000", p = /font-weight:\s*(bold|700|[89]\d\d)/.test(n), m = /font-style:\s*(italic|oblique)/.test(n);
2710
+ o.push(Et(l, u, d, p, f, m));
2479
2711
  continue;
2480
2712
  }
2481
- if (s.nodeType !== Node.ELEMENT_NODE) continue;
2482
- let c = s, l = c.tagName.toLowerCase(), u = c.getAttribute("style") || "", d = c.getAttribute("class") || "";
2483
- if (l === "img" && (d.includes("Wirisformula") || c.hasAttribute("data-latex") || c.hasAttribute("data-mathml"))) {
2484
- let e = c.getAttribute("data-latex") || "", t = e, n, r;
2713
+ if (c.nodeType !== Node.ELEMENT_NODE) continue;
2714
+ let l = c, u = l.tagName.toLowerCase(), d = l.getAttribute("style") || "", f = l.getAttribute("class") || "";
2715
+ if (u === "img" && (f.includes("Wirisformula") || l.hasAttribute("data-latex") || l.hasAttribute("data-mathml"))) {
2716
+ let e = l.getAttribute("data-latex") || "", t = e, n, r;
2485
2717
  if (e) {
2486
2718
  let n = e.replace(/\\style\{[^}]*\}\{/, "{").replace(/^\\style\{[^}]*\}/, "") || e;
2487
2719
  t = n, r = De(n);
2488
2720
  } else {
2489
- let e = c.getAttribute("data-mathml") || "";
2721
+ let e = l.getAttribute("data-mathml") || "";
2490
2722
  if (e) {
2491
2723
  r = je(e), t = "";
2492
2724
  try {
@@ -2496,7 +2728,7 @@ function Y(e, t, n, r, i) {
2496
2728
  }
2497
2729
  } else continue;
2498
2730
  }
2499
- a.push({
2731
+ o.push({
2500
2732
  type: "formula",
2501
2733
  width: r.width,
2502
2734
  height: r.height,
@@ -2506,33 +2738,37 @@ function Y(e, t, n, r, i) {
2506
2738
  });
2507
2739
  continue;
2508
2740
  }
2509
- if (l === "img") {
2510
- let e = c.getAttribute("src") || "";
2741
+ if (u === "img") {
2742
+ let e = l.getAttribute("src") || "";
2511
2743
  if (!e) continue;
2512
- let t = parseInt(c.getAttribute("width") || "") || 0, n = parseInt(c.getAttribute("height") || "") || 0, i = parseInt(u.match(/width:\s*(\d+)px/)?.[1] || "0"), o = parseInt(u.match(/height:\s*(\d+)px/)?.[1] || "0"), s = u.match(/width:\s*([\d.]+)%/), l = i || t || 100, d = o || n || 60;
2744
+ let t = parseInt(l.getAttribute("width") || "") || 0, n = parseInt(l.getAttribute("height") || "") || 0, i = parseInt(d.match(/width:\s*(\d+)px/)?.[1] || "0"), a = parseInt(d.match(/height:\s*(\d+)px/)?.[1] || "0"), s = d.match(/width:\s*([\d.]+)%/), c = i || t || 100, u = a || n || 60;
2513
2745
  if (s) {
2514
2746
  let e = parseFloat(s[1]);
2515
- l = Math.round(e / 100 * r), d = Math.round(t && n ? l * n / t : l * .6);
2747
+ c = Math.round(e / 100 * r), u = Math.round(t && n ? c * n / t : c * .6);
2516
2748
  }
2517
- a.push({
2749
+ if (c > r) {
2750
+ let e = u / c;
2751
+ c = r, u = Math.round(c * e);
2752
+ }
2753
+ o.push({
2518
2754
  type: "image",
2519
- id: `inline-img-${++yt}`,
2755
+ id: `inline-img-${++xt}`,
2520
2756
  src: e,
2521
- width: l,
2522
- height: d
2757
+ width: c,
2758
+ height: u
2523
2759
  });
2524
2760
  continue;
2525
2761
  }
2526
- let f = St(d);
2527
- if (l === "span" && f) {
2528
- let e = c.textContent || "", { blankType: t, isEmpty: n } = f, r;
2762
+ let p = wt(f);
2763
+ if (u === "span" && p) {
2764
+ let e = l.textContent || "", { blankType: t, isEmpty: n } = p, r;
2529
2765
  if (t === "tiankong") {
2530
2766
  let t = (e.match(/\s/g) || []).length;
2531
2767
  r = e.trim() ? Math.max(80, e.length * 14) : Math.max(80, t * 12);
2532
2768
  } else r = Math.max(40, e.length * 14 + 10);
2533
- a.push({
2769
+ o.push({
2534
2770
  type: "underline",
2535
- id: `ul-html-${++_t}`,
2771
+ id: `ul-html-${++yt}`,
2536
2772
  width: r,
2537
2773
  height: 20,
2538
2774
  placeholder: t === "tiankong" ? "空" : t === "xuanze" ? "选" : "判",
@@ -2543,24 +2779,24 @@ function Y(e, t, n, r, i) {
2543
2779
  });
2544
2780
  continue;
2545
2781
  }
2546
- if (l === "span" && d.includes("under-point")) {
2547
- let e = c.textContent || "";
2782
+ if (u === "span" && f.includes("under-point")) {
2783
+ let e = l.textContent || "";
2548
2784
  if (e.trim()) {
2549
- 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);
2550
- c.dotAbove = !0, a.push(c);
2785
+ let r = Ot(d) || Ot(n) || t, i = kt(d) || kt(n) || "\"Times New Roman\", SimSun", a = At(d) || At(n) || "#000", s = /font-style:\s*(italic|oblique)/.test(d) || /font-style:\s*(italic|oblique)/.test(n), c = Et(e.trim(), r, i, !1, a, s);
2786
+ c.dotAbove = !0, o.push(c);
2551
2787
  }
2552
2788
  continue;
2553
2789
  }
2554
- if (l === "span" && d.includes("wavy-line")) {
2555
- let e = c.textContent || "";
2790
+ if (u === "span" && f.includes("wavy-line")) {
2791
+ let e = l.textContent || "";
2556
2792
  if (e.trim()) {
2557
- 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);
2558
- c.wavyLine = !0, a.push(c);
2793
+ let r = Ot(d) || Ot(n) || t, i = kt(d) || kt(n) || "\"Times New Roman\", SimSun", a = At(d) || At(n) || "#000", s = /font-style:\s*(italic|oblique)/.test(d) || /font-style:\s*(italic|oblique)/.test(n), c = Et(e.trim(), r, i, !1, a, s);
2794
+ c.wavyLine = !0, o.push(c);
2559
2795
  }
2560
2796
  continue;
2561
2797
  }
2562
- if (l === "br") {
2563
- a.push({
2798
+ if (u === "br") {
2799
+ o.push({
2564
2800
  type: "enter",
2565
2801
  width: 0,
2566
2802
  height: 0,
@@ -2568,98 +2804,98 @@ function Y(e, t, n, r, i) {
2568
2804
  });
2569
2805
  continue;
2570
2806
  }
2571
- if (l === "strong" || l === "b") {
2572
- let e = Y(c, t, u ? u + ";font-weight:bold" : "font-weight:bold", r, i);
2573
- a.push(...e);
2807
+ if (u === "strong" || u === "b") {
2808
+ let e = Y(l, t, d ? d + ";font-weight:bold" : "font-weight:bold", r, i, a);
2809
+ o.push(...e);
2574
2810
  continue;
2575
2811
  }
2576
- if (l === "em" || l === "i") {
2577
- let e = Y(c, t, u ? u + ";font-style:italic" : "font-style:italic", r, i);
2578
- a.push(...e);
2812
+ if (u === "em" || u === "i") {
2813
+ let e = Y(l, t, d ? d + ";font-style:italic" : "font-style:italic", r, i, a);
2814
+ o.push(...e);
2579
2815
  continue;
2580
2816
  }
2581
- if (l === "u" || l === "ins") {
2582
- let e = Y(c, t, u || n, r, i);
2817
+ if (u === "u" || u === "ins") {
2818
+ let e = Y(l, t, d || n, r, i, a);
2583
2819
  for (let t of e) t.type === "text" && (t.underline = !0);
2584
- a.push(...e);
2820
+ o.push(...e);
2585
2821
  continue;
2586
2822
  }
2587
- if (l === "s" || l === "strike" || l === "del") {
2588
- let e = Y(c, t, u || n, r, i);
2823
+ if (u === "s" || u === "strike" || u === "del") {
2824
+ let e = Y(l, t, d || n, r, i, a);
2589
2825
  for (let t of e) t.type === "text" && (t.strikethrough = !0);
2590
- a.push(...e);
2826
+ o.push(...e);
2591
2827
  continue;
2592
2828
  }
2593
- if (l === "table") {
2594
- let e = c.outerHTML, t = parseInt(u.match(/width:\s*(\d+)px/)?.[1] || "0"), n = u.match(/width:\s*([\d.]+)%/), i = c.querySelectorAll("tr").length, o = Math.max(60, i * 30 + 40), s = n ? Math.round(parseFloat(n[1]) / 100 * r) : t || r;
2595
- a.push({
2829
+ if (u === "table") {
2830
+ let e = l.outerHTML, t = parseInt(d.match(/width:\s*(\d+)px/)?.[1] || "0"), n = d.match(/width:\s*([\d.]+)%/), i = l.querySelectorAll("tr").length, a = Math.max(60, i * 30 + 40), s = n ? Math.round(parseFloat(n[1]) / 100 * r) : t || r;
2831
+ o.push({
2596
2832
  type: "image",
2597
- id: `inline-img-${++yt}`,
2833
+ id: `inline-img-${++xt}`,
2598
2834
  src: "",
2599
2835
  width: Math.min(s, r),
2600
- height: o,
2836
+ height: a,
2601
2837
  rawHtml: e
2602
2838
  });
2603
2839
  continue;
2604
2840
  }
2605
- if (l === "figure") {
2606
- let e = c.querySelector("table");
2841
+ if (u === "figure") {
2842
+ let e = l.querySelector("table");
2607
2843
  if (e) {
2608
- let t = e.outerHTML, n = e.getAttribute("style") || "", i = parseInt(n.match(/width:\s*(\d+)px/)?.[1] || "0"), o = n.match(/width:\s*([\d.]+)%/), s = e.querySelectorAll("tr").length, c = Math.max(60, s * 30 + 40), l = o ? Math.round(parseFloat(o[1]) / 100 * r) : i || r;
2609
- a.push({
2844
+ let t = e.outerHTML, n = e.getAttribute("style") || "", i = parseInt(n.match(/width:\s*(\d+)px/)?.[1] || "0"), a = n.match(/width:\s*([\d.]+)%/), s = e.querySelectorAll("tr").length, c = Math.max(60, s * 30 + 40), l = a ? Math.round(parseFloat(a[1]) / 100 * r) : i || r;
2845
+ o.push({
2610
2846
  type: "image",
2611
- id: `inline-img-${++yt}`,
2847
+ id: `inline-img-${++xt}`,
2612
2848
  src: "",
2613
2849
  width: Math.min(l, r),
2614
2850
  height: c,
2615
2851
  rawHtml: t
2616
2852
  });
2617
2853
  } else {
2618
- let e = Y(c, t, u || n, r, i);
2619
- a.push(...e);
2854
+ let e = Y(l, t, d || n, r, i, a);
2855
+ o.push(...e);
2620
2856
  }
2621
2857
  continue;
2622
2858
  }
2623
- if (l === "sub" || l === "sup") {
2624
- let e = Math.round(t * bt), o = Y(c, e, (u || n).replace(/font-size:\s*[^;]+;?/, "") + `;font-size:${e}px`, r, i), s = Math.round(l === "sub" ? t * .52 : -t * .25);
2625
- for (let e of o) e.type === "text" && (e.verticalAlign = s);
2626
- a.push(...o);
2859
+ if (u === "sub" || u === "sup") {
2860
+ let e = Math.round(t * St), s = Y(l, e, (d || n).replace(/font-size:\s*[^;]+;?/, "") + `;font-size:${e}px`, r, i, a), c = Math.round(u === "sub" ? t * .52 : -t * .25);
2861
+ for (let e of s) e.type === "text" && (e.verticalAlign = c);
2862
+ o.push(...s);
2627
2863
  continue;
2628
2864
  }
2629
- if (l === "span" || l === "a" || l === "div" || l === "font") {
2630
- let e = u || n, o = /font-weight:\s*(bold|700|[89]\d\d)/.test(u), s = /font-style:\s*(italic|oblique)/.test(u);
2631
- o && !/font-weight/.test(e) && (e += ";font-weight:bold"), s && !/font-style/.test(e) && (e += ";font-style:italic");
2632
- let l = Y(c, t, e, r, i), d = u.match(/text-decoration:\s*([^;]+)/);
2633
- if (d) {
2634
- let e = d[1];
2635
- for (let t of l) if (t.type === "text") {
2865
+ if (u === "span" || u === "a" || u === "div" || u === "font") {
2866
+ let e = d || n, s = /font-weight:\s*(bold|700|[89]\d\d)/.test(d), c = /font-style:\s*(italic|oblique)/.test(d);
2867
+ s && !/font-weight/.test(e) && (e += ";font-weight:bold"), c && !/font-style/.test(e) && (e += ";font-style:italic");
2868
+ let u = Y(l, t, e, r, i, a), f = d.match(/text-decoration:\s*([^;]+)/);
2869
+ if (f) {
2870
+ let e = f[1];
2871
+ for (let t of u) if (t.type === "text") {
2636
2872
  let n = t;
2637
2873
  e.includes("underline") && (n.underline = !0), e.includes("line-through") && (n.strikethrough = !0);
2638
2874
  }
2639
2875
  }
2640
- let f = u.match(/background-color:\s*([^;]+)/);
2641
- if (f && f[1] && f[1] !== "transparent") {
2642
- let e = jt(f[1]);
2643
- if (e) for (let t of l) t.type === "text" && (t.backgroundColor = e);
2876
+ let p = d.match(/background-color:\s*([^;]+)/);
2877
+ if (p && p[1] && p[1] !== "transparent") {
2878
+ let e = Nt(p[1]);
2879
+ if (e) for (let t of u) t.type === "text" && (t.backgroundColor = e);
2644
2880
  }
2645
- a.push(...l);
2881
+ o.push(...u);
2646
2882
  continue;
2647
2883
  }
2648
- if (l === "p") {
2649
- let e = Y(c, t, u || n, r, i);
2650
- if (e.length > 0 && e.every((e) => e.type === "image" && !e.rawHtml)) for (let t of e) {
2884
+ if (u === "p") {
2885
+ let e = Y(l, t, d || n, r, i, a);
2886
+ if (!a && e.length > 0 && e.every((e) => e.type === "image" && !e.rawHtml)) for (let t of e) {
2651
2887
  let e = t, n = e.height / e.width || .6;
2652
2888
  e.width = r, e.height = Math.round(r * n);
2653
2889
  }
2654
- a.push(...e);
2890
+ o.push(...e);
2655
2891
  continue;
2656
2892
  }
2657
- let p = Y(c, t, u || n, r, i);
2658
- a.push(...p);
2893
+ let m = Y(l, t, d || n, r, i);
2894
+ o.push(...m);
2659
2895
  }
2660
- return a;
2896
+ return o;
2661
2897
  }
2662
- function St(e) {
2898
+ function wt(e) {
2663
2899
  return e.includes("blank-tiankong") || e.includes("blank_tiankong") ? {
2664
2900
  blankType: "tiankong",
2665
2901
  isEmpty: !0
@@ -2671,13 +2907,13 @@ function St(e) {
2671
2907
  isEmpty: !1
2672
2908
  } : null;
2673
2909
  }
2674
- function Ct(e, t) {
2675
- if (e.length > 0 && e.every((e) => e.type === "image" && !e.rawHtml)) return "right";
2676
- let n = Tt(t);
2677
- return n === "center" ? "center" : n === "right" ? "right" : void 0;
2910
+ function Tt(e, t, n = !1) {
2911
+ if (!n && e.length > 0 && e.every((e) => e.type === "image" && !e.rawHtml)) return "right";
2912
+ let r = Dt(t);
2913
+ return r === "center" ? "center" : r === "right" ? "right" : void 0;
2678
2914
  }
2679
- function wt(e, t, n, r, i, a) {
2680
- 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;
2915
+ function Et(e, t, n, r, i, a) {
2916
+ let o = e.split(""), s = H(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;
2681
2917
  return {
2682
2918
  type: "text",
2683
2919
  value: e,
@@ -2691,19 +2927,19 @@ function wt(e, t, n, r, i, a) {
2691
2927
  xPositions: s
2692
2928
  };
2693
2929
  }
2694
- function Tt(e) {
2930
+ function Dt(e) {
2695
2931
  let t = e.match(/text-align:\s*(right|center|left)/);
2696
2932
  return t ? t[1] : "left";
2697
2933
  }
2698
- function Et(e) {
2934
+ function Ot(e) {
2699
2935
  let t = e.match(/font-size:\s*(\d+)px/);
2700
2936
  return t ? parseInt(t[1]) : null;
2701
2937
  }
2702
- function Dt(e) {
2938
+ function kt(e) {
2703
2939
  let t = e.match(/font-family:\s*([^;]+)/);
2704
2940
  return t ? t[1].trim().replace(/["']/g, "") : null;
2705
2941
  }
2706
- function Ot(e) {
2942
+ function At(e) {
2707
2943
  let t = e.match(/color:\s*rgb\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)/);
2708
2944
  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")}`;
2709
2945
  let n = e.match(/color:\s*rgba\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,[^)]+\)/);
@@ -2711,9 +2947,9 @@ function Ot(e) {
2711
2947
  let r = e.match(/color:\s*(#[0-9a-fA-F]{3,6})/);
2712
2948
  if (r) return r[1];
2713
2949
  let i = e.match(/color:\s*([a-zA-Z]+)/);
2714
- return i && At(i[1]) || null;
2950
+ return i && Mt(i[1]) || null;
2715
2951
  }
2716
- var kt = {
2952
+ var jt = {
2717
2953
  red: "#ff0000",
2718
2954
  green: "#008000",
2719
2955
  blue: "#0000ff",
@@ -2740,24 +2976,24 @@ var kt = {
2740
2976
  lightgrey: "#d3d3d3",
2741
2977
  transparent: "#000000"
2742
2978
  };
2743
- function At(e) {
2744
- return kt[e.toLowerCase()];
2979
+ function Mt(e) {
2980
+ return jt[e.toLowerCase()];
2745
2981
  }
2746
- function jt(e) {
2982
+ function Nt(e) {
2747
2983
  let t = e.trim(), n = t.match(/^#[0-9a-fA-F]{3,6}$/);
2748
2984
  if (n) return n[0];
2749
2985
  let r = t.match(/^rgb\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)$/);
2750
- 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;
2986
+ 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")}` : Mt(t) || null;
2751
2987
  }
2752
- function Mt(e, t, n) {
2988
+ function Pt(e, t, n) {
2753
2989
  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;
2754
2990
  return u <= 0 || d <= 0 ? [{
2755
- ...nt([], n),
2991
+ ...it([], n),
2756
2992
  availableWidth: t
2757
2993
  }] : [{
2758
- ...nt([{
2994
+ ...it([{
2759
2995
  type: "image",
2760
- id: `inline-img-${++yt}`,
2996
+ id: `inline-img-${++xt}`,
2761
2997
  src: "",
2762
2998
  width: u,
2763
2999
  height: d,
@@ -2768,16 +3004,16 @@ function Mt(e, t, n) {
2768
3004
  }
2769
3005
  //#endregion
2770
3006
  //#region src/utils/questionJsonParser.ts
2771
- function Nt(e, t = {}) {
3007
+ function Ft(e, t = {}) {
2772
3008
  let { questionNo: n = "", score: r = "", contentWidth: i = 600, fontSize: a = 16, lineSpacing: o = 1, protectContent: s = !1 } = t;
2773
- return e.children && e.children.length > 0 ? Ft(e, {
3009
+ return e.children && e.children.length > 0 ? Lt(e, {
2774
3010
  questionNo: n,
2775
3011
  score: r,
2776
3012
  contentWidth: i,
2777
3013
  fontSize: a,
2778
3014
  lineSpacing: o,
2779
3015
  protectContent: s
2780
- }) : Pt(e, {
3016
+ }) : It(e, {
2781
3017
  questionNo: n,
2782
3018
  score: r,
2783
3019
  contentWidth: i,
@@ -2786,26 +3022,25 @@ function Nt(e, t = {}) {
2786
3022
  protectContent: s
2787
3023
  });
2788
3024
  }
2789
- function Pt(e, t) {
2790
- 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, {
3025
+ function It(e, t) {
3026
+ 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 = Ct(e.question, {
2791
3027
  questionNo: n,
2792
3028
  score: r,
2793
3029
  contentWidth: i,
2794
3030
  fontSize: a,
2795
3031
  lineSpacing: o,
2796
- skipAnswerArea: !0,
2797
3032
  protectContent: s
2798
3033
  });
2799
- if (d.length === 0) return [];
2800
- let f = d[0], p = {
2801
- id: f.id,
3034
+ if (u.length === 0) return [];
3035
+ let d = u[0], f = {
3036
+ id: d.id,
2802
3037
  type: "question",
2803
- paragraphs: [...f.paragraphs],
3038
+ paragraphs: [...d.paragraphs],
2804
3039
  height: 0,
2805
3040
  protectContent: s,
2806
3041
  questionType: c,
2807
3042
  metadata: {
2808
- ...f.metadata,
3043
+ ...d.metadata,
2809
3044
  qid: e.qid,
2810
3045
  questType: c,
2811
3046
  answer: e.extra_json?.answer || e.answer || "",
@@ -2814,22 +3049,46 @@ function Pt(e, t) {
2814
3049
  tags: e.tags
2815
3050
  }
2816
3051
  };
2817
- 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));
2818
- else for (let e = 0; e < 2; e++) p.paragraphs.push(Lt(u));
2819
- return p.height = p.paragraphs.reduce((e, t) => e + (t.height || 26), 0), [p];
3052
+ if (l && e.extra_json?.options && e.extra_json.options.length > 0) {
3053
+ let t = Rt(e.extra_json.options, i, a, o), n = "\"Times New Roman\", SimSun";
3054
+ for (let e of t) {
3055
+ if (e.paragraphs.length > 0) {
3056
+ let t = e.paragraphs[0], r = `${e.label}. `, i = {
3057
+ type: "text",
3058
+ value: r,
3059
+ fontFamily: n,
3060
+ fontSize: a,
3061
+ bold: !1,
3062
+ italic: !1,
3063
+ color: "#000",
3064
+ width: V(r, a, n),
3065
+ height: a * 1.4,
3066
+ xPositions: [],
3067
+ isLabel: !0
3068
+ };
3069
+ t.lines.length > 0 ? t.lines[0].elements.unshift(i) : t.lines.push({
3070
+ elements: [i],
3071
+ baseline: 20,
3072
+ lineHeight: 20,
3073
+ y: 0
3074
+ });
3075
+ }
3076
+ f.paragraphs.push(...e.paragraphs);
3077
+ }
3078
+ }
3079
+ return f.height = f.paragraphs.reduce((e, t) => e + (t.height || 26), 0), [f];
2820
3080
  }
2821
- function Ft(e, t) {
2822
- 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, {
3081
+ function Lt(e, t) {
3082
+ let { questionNo: n, score: r, contentWidth: i, fontSize: a, lineSpacing: o, protectContent: s } = t, c = "answer_question", l = Date.now(), u = Math.random().toString(36).slice(2, 8), d = e.id ? `group-${e.id}-${l}-${u}` : `group-${e.qid || l}-${u}`, f = Math.max(100, i - 26.25), p = [], m = Ct(e.question, {
2823
3083
  questionNo: n,
2824
3084
  score: r || "",
2825
3085
  contentWidth: i,
2826
3086
  fontSize: a,
2827
3087
  lineSpacing: o,
2828
- skipAnswerArea: !0,
2829
3088
  protectContent: s
2830
3089
  });
2831
- if (h.length > 0) {
2832
- let t = h[0];
3090
+ if (m.length > 0) {
3091
+ let t = m[0];
2833
3092
  t.type = "question", t.metadata = {
2834
3093
  ...t.metadata,
2835
3094
  qid: e.qid,
@@ -2837,50 +3096,45 @@ function Ft(e, t) {
2837
3096
  answer: e.extra_json?.answer || e.answer || "",
2838
3097
  tenantId: e.tenant_id,
2839
3098
  tags: e.tags,
2840
- blockGroup: f,
3099
+ blockGroup: d,
2841
3100
  hasSubQuestions: !0,
2842
3101
  score: r || ""
2843
- }, t.keepNext = !0;
2844
- for (let e = 0; e < 2; e++) t.paragraphs.push(Lt(l));
2845
- t.height = t.paragraphs.reduce((e, t) => e + (t.height || 26), 0), m.push(t);
3102
+ }, t.keepNext = !0, t.height = t.paragraphs.reduce((e, t) => e + (t.height || 26), 0), p.push(t);
2846
3103
  }
2847
3104
  if (e.children) for (let t = 0; t < e.children.length; t++) {
2848
- let n = e.children[t], r = `(${t + 1})`, i = xt(n.question, {
2849
- contentWidth: p,
3105
+ let n = e.children[t], r = `(${t + 1})`, i = Ct(n.question, {
3106
+ contentWidth: f,
2850
3107
  fontSize: a,
2851
3108
  lineSpacing: o,
2852
- skipAnswerArea: !0,
2853
3109
  protectContent: s
2854
3110
  });
2855
3111
  if (i.length === 0) continue;
2856
- let u = i[0];
2857
- u.type = "sub-question", u.metadata = {
2858
- ...u.metadata,
3112
+ let l = i[0];
3113
+ l.type = "sub-question", l.metadata = {
3114
+ ...l.metadata,
2859
3115
  questionNo: "",
2860
3116
  subLabel: r,
2861
3117
  label: `子题${r}`,
2862
- topicId: `${f}-sub${t + 1}`,
2863
- blockGroup: f,
3118
+ topicId: `${d}-sub${t + 1}`,
3119
+ blockGroup: d,
2864
3120
  qid: n.qid,
2865
3121
  answer: n.answer || n.extra_json?.answer || "",
2866
3122
  questType: c,
2867
3123
  tenantId: n.tenant_id,
2868
3124
  tags: n.tags,
2869
3125
  score: ""
2870
- };
2871
- for (let e = 0; e < 2; e++) u.paragraphs.push(Lt(l));
2872
- u.height = u.paragraphs.reduce((e, t) => e + (t.height || 26), 0), m.push(u);
3126
+ }, l.height = l.paragraphs.reduce((e, t) => e + (t.height || 26), 0), p.push(l);
2873
3127
  }
2874
- return m;
3128
+ return p;
2875
3129
  }
2876
- function It(e, t, n, r) {
3130
+ function Rt(e, t, n, r) {
2877
3131
  let i = Math.max(100, t - 20);
2878
3132
  return e.map((e) => {
2879
- let t = xt(e.content, {
3133
+ let t = Ct(/<\s*(p|div|h[1-6]|blockquote|ol|ul|li|table|figure)/i.test(e.content) ? e.content : `<p>${e.content}</p>`, {
2880
3134
  contentWidth: i,
2881
3135
  fontSize: n,
2882
3136
  lineSpacing: r,
2883
- skipAnswerArea: !0
3137
+ inlineOnly: !0
2884
3138
  }), a = [];
2885
3139
  if (t.length > 0 && a.push(...t[0].paragraphs), a.length === 0) {
2886
3140
  let e = Math.round(n * r * 1.67);
@@ -2902,25 +3156,9 @@ function It(e, t, n, r) {
2902
3156
  };
2903
3157
  });
2904
3158
  }
2905
- function Lt(e) {
2906
- return {
2907
- lines: [{
2908
- elements: [{
2909
- type: "enter",
2910
- width: 20,
2911
- height: 20
2912
- }],
2913
- baseline: e * .5,
2914
- lineHeight: e,
2915
- y: 0
2916
- }],
2917
- y: 0,
2918
- height: e + 4
2919
- };
2920
- }
2921
3159
  //#endregion
2922
3160
  //#region src/utils/chineseNumber.ts
2923
- var Rt = [
3161
+ var zt = [
2924
3162
  "",
2925
3163
  "一",
2926
3164
  "二",
@@ -2933,34 +3171,34 @@ var Rt = [
2933
3171
  "九",
2934
3172
  "十"
2935
3173
  ];
2936
- function zt(e) {
3174
+ function Bt(e) {
2937
3175
  if (e <= 0) return "";
2938
- if (e <= 10) return Rt[e];
3176
+ if (e <= 10) return zt[e];
2939
3177
  if (e < 20) {
2940
3178
  let t = e % 10;
2941
- return "十" + (t > 0 ? Rt[t] : "");
3179
+ return "十" + (t > 0 ? zt[t] : "");
2942
3180
  }
2943
3181
  if (e < 100) {
2944
3182
  let t = Math.floor(e / 10), n = e % 10;
2945
- return Rt[t] + "十" + (n > 0 ? Rt[n] : "");
3183
+ return zt[t] + "十" + (n > 0 ? zt[n] : "");
2946
3184
  }
2947
3185
  if (e < 1e3) {
2948
- let t = Math.floor(e / 100), n = e % 100, r = Rt[t] + "百";
2949
- return n === 0 ? r : n < 10 ? r + "零" + Rt[n] : r + zt(n);
3186
+ let t = Math.floor(e / 100), n = e % 100, r = zt[t] + "百";
3187
+ return n === 0 ? r : n < 10 ? r + "零" + zt[n] : r + Bt(n);
2950
3188
  }
2951
3189
  return String(e);
2952
3190
  }
2953
- function Bt(e, t) {
2954
- let n = zt(t);
3191
+ function Vt(e, t) {
3192
+ let n = Bt(t);
2955
3193
  return n ? n + "、" + e : e;
2956
3194
  }
2957
- function Vt(e) {
3195
+ function Ht(e) {
2958
3196
  let t = e.match(/^[一二三四五六七八九十百零]+、(.+)$/);
2959
3197
  return t ? t[1] : e;
2960
3198
  }
2961
3199
  //#endregion
2962
3200
  //#region src/utils/paperHtmlBuilder.ts
2963
- function Ht(e) {
3201
+ function Ut(e) {
2964
3202
  let t = j[e];
2965
3203
  return `
2966
3204
  /* ---------- Reset & Base ---------- */
@@ -3072,7 +3310,7 @@ text.swed-question-score {
3072
3310
  }
3073
3311
  .swed-title_wrapper .swed-title-content .swed-title-text {
3074
3312
  font-size: 15px;
3075
- font-weight: 600;
3313
+ font-weight: 400;
3076
3314
  line-height: 32px;
3077
3315
  color: #231f20;
3078
3316
  white-space: nowrap;
@@ -3289,7 +3527,7 @@ text.swed-question-score {
3289
3527
  }
3290
3528
  `;
3291
3529
  }
3292
- function Ut(e) {
3530
+ function Wt(e) {
3293
3531
  let { svgs: t, paperName: n = "试卷", paperSize: r = "A4" } = e, i = t.map((e) => {
3294
3532
  let t = e.match(/viewBox="0 0 (\d+(?:\.\d+)?)\s+(\d+(?:\.\d+)?)"/), [, n, r] = t ? [
3295
3533
  null,
@@ -3309,24 +3547,121 @@ function Ut(e) {
3309
3547
  <head>
3310
3548
  <meta charset="UTF-8">
3311
3549
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
3312
- <title>${Wt(n)}</title>
3313
- <style>${Ht(r)}</style>
3550
+ <title>${Gt(n)}</title>
3551
+ <style>${Ut(r)}</style>
3314
3552
  </head>
3315
3553
  <body>
3316
3554
  ${i}
3317
3555
  </body>
3318
3556
  </html>`;
3319
3557
  }
3320
- function Wt(e) {
3558
+ function Gt(e) {
3321
3559
  return e.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
3322
3560
  }
3323
3561
  //#endregion
3324
- //#region ../node_modules/qrcode/lib/can-promise.js
3325
- var Gt = /* @__PURE__ */ D(((e, t) => {
3562
+ //#region src/utils/buildAnswerHtml.ts
3563
+ function Kt(e) {
3564
+ let { blocks: t, paperName: n = "参考答案" } = e, r = Yt(t), i = "";
3565
+ for (let e of r) {
3566
+ if (e.type === "title-section") {
3567
+ i && (i += " <div class=\"section-break\"></div>\n"), i += ` <div class="section-title">${X(e.name)}</div>\n`;
3568
+ continue;
3569
+ }
3570
+ for (let t of e.blocks) {
3571
+ let e = qt(t);
3572
+ e && (i += e);
3573
+ }
3574
+ }
3575
+ return i ||= " <div class=\"no-answer\">当前试卷无参考答案</div>\n", `<!DOCTYPE html>
3576
+ <html lang="zh-CN">
3577
+ <head>
3578
+ <meta charset="UTF-8">
3579
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
3580
+ <title>${X(n)} - 参考答案</title>
3581
+ <style>${Zt}</style>
3582
+ </head>
3583
+ <body>
3584
+ <div class="answer-container">
3585
+ <div class="answer-header">
3586
+ <h1>${X(n)}</h1>
3587
+ <div class="answer-subtitle">参考答案</div>
3588
+ </div>
3589
+ <div class="answer-body">
3590
+ ${i} </div>
3591
+ </div>
3592
+ </body>
3593
+ </html>`;
3594
+ }
3595
+ function qt(e) {
3596
+ if (e.type === "title" || e.type === "info-line") return "";
3597
+ let t = e.metadata?.questionNo || e.metadata?.subLabel || "", n = t ? `<span class="q-label">${X(t)}</span>` : "", r = e.metadata?.answer || "", i = e.metadata?.subAnswers || {}, a = Jt(e), o = r.includes("<") && r.includes(">");
3598
+ if (!(r || Object.keys(i).length > 0 || a.length > 0)) return "";
3599
+ let s = ` <div class="answer-item">\n ${n}\n`;
3600
+ if (r && (o ? s += ` <div class="answer-content answer-content--html">${r}</div>\n` : s += ` <div class="answer-content">${X(r)}</div>\n`), Object.keys(i).length > 0) {
3601
+ s += " <div class=\"sub-answers\">\n";
3602
+ for (let [e, t] of Object.entries(i)) t && (s += ` <div class="sub-answer-item"><span class="sub-label">${X(e)}</span><span class="sub-answer-text">${X(t)}</span></div>\n`);
3603
+ s += " </div>\n";
3604
+ }
3605
+ if (a.length > 0 && !(!o && r)) {
3606
+ s += " <div class=\"underline-answers\">\n";
3607
+ for (let e of a) {
3608
+ let t = a.length > 1 ? `<span class="blank-index">第${e.index}空</span>` : "";
3609
+ s += ` <div class="underline-item">${t}<span class="blank-answer">${X(e.answer)}</span></div>\n`;
3610
+ }
3611
+ s += " </div>\n";
3612
+ }
3613
+ return s += " </div>\n", s;
3614
+ }
3615
+ function Jt(e) {
3616
+ let t = [], n = /* @__PURE__ */ new Set();
3617
+ for (let r of e.paragraphs) for (let e of r.lines) for (let r of e.elements) if (r.type === "underline") {
3618
+ let e = r;
3619
+ if (e.correctAnswer) {
3620
+ let r = e.index ?? 1;
3621
+ n.has(r) || (n.add(r), t.push({
3622
+ index: r,
3623
+ answer: e.correctAnswer
3624
+ }));
3625
+ }
3626
+ }
3627
+ return t.sort((e, t) => e.index - t.index), t;
3628
+ }
3629
+ function Yt(e) {
3630
+ let t = [], n = null;
3631
+ for (let r of e) {
3632
+ if (r.type === "title") {
3633
+ n &&= (t.push(n), null);
3634
+ let e = Xt(r);
3635
+ t.push({
3636
+ type: "title-section",
3637
+ name: e || "题目",
3638
+ blocks: [r]
3639
+ });
3640
+ continue;
3641
+ }
3642
+ let e = r.metadata?.blockGroup;
3643
+ e && n?.type === "question-section" && n.name === e ? n.blocks.push(r) : (n && t.push(n), n = {
3644
+ type: "question-section",
3645
+ name: e || r.metadata?.questionNo || "default",
3646
+ blocks: [r]
3647
+ });
3648
+ }
3649
+ return n && t.push(n), t;
3650
+ }
3651
+ function Xt(e) {
3652
+ let t = [];
3653
+ for (let n of e.paragraphs) for (let e of n.lines) for (let n of e.elements) n.type === "text" && t.push(n.value);
3654
+ let n = t.join("").trim();
3655
+ return !n && e.metadata?.label ? e.metadata.label : !n && e.metadata?.title ? e.metadata.title : n;
3656
+ }
3657
+ function X(e) {
3658
+ return e.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
3659
+ }
3660
+ var Zt = (/* @__PURE__ */ "*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }(html, body { width: 100%; background: #fff; font-family: \"SimSun\", \"Times New Roman\", serif; color: #000; line-height: 1.6; }(.answer-container { max-width: 800px; margin: 0 auto; background: #fff; }(.answer-header { text-align: center; padding: 24px 40px 16px; border-bottom: 1px solid #000; }(.answer-header h1 { font-size: 22px; font-weight: 700; color: #000; margin-bottom: 4px; }(.answer-subtitle { font-size: 14px; color: #333; font-weight: 500; letter-spacing: 2px; }(.answer-body { padding: 16px 40px; }(.section-title { font-size: 16px; font-weight: 700; color: #000; padding: 10px 0 6px; margin-bottom: 6px; }(.answer-item { display: flex; align-items: baseline; gap: 8px; padding: 4px 0; }(.answer-item:last-child { border-bottom: none; }(.q-label { flex-shrink: 0; font-size: 14px; font-weight: 600; color: #000; min-width: 40px; }(.answer-content { font-size: 15px; color: #000; line-height: 1.6; }(.answer-content--html { font-family: \"Times New Roman\", SimSun, serif; }(.answer-content--html img { vertical-align: middle; }(.answer-content--html img.Wirisformula { height: 0.8em; width: auto; vertical-align: middle; opacity: 0.85; }(.answer-content--html p { margin: 4px 0; }(.answer-content--html .sw-quest-block { display: inline; }(.sub-answers { display: flex; flex-direction: column; gap: 4px; }(.sub-answer-item { display: flex; align-items: baseline; gap: 6px; }(.sub-label { font-size: 13px; font-weight: 600; color: #333; flex-shrink: 0; }(.sub-answer-text { font-size: 14px; color: #000; }(.underline-answers { display: flex; flex-wrap: wrap; gap: 6px 12px; }(.underline-item { display: flex; align-items: baseline; gap: 4px; }(.blank-index { font-size: 12px; color: #666; }(.blank-answer { font-size: 14px; color: #000; font-weight: 500; padding: 1px 6px; border: 1px solid #ccc; border-radius: 2px; }(.no-answer { text-align: center; padding: 40px 0; font-size: 14px; color: #999; }(@media print { html, body { background: #fff; } .answer-container { max-width: 100%; margin: 0; } .answer-header { padding: 16px 40px 12px; } .answer-body { padding: 12px 40px; } }".split("(")).join("\n"), Qt = /* @__PURE__ */ D(((e, t) => {
3326
3661
  t.exports = function() {
3327
3662
  return typeof Promise == "function" && Promise.prototype && Promise.prototype.then;
3328
3663
  };
3329
- })), X = /* @__PURE__ */ D(((e) => {
3664
+ })), $t = /* @__PURE__ */ D(((e) => {
3330
3665
  var t, n = [
3331
3666
  0,
3332
3667
  26,
@@ -3388,7 +3723,7 @@ var Gt = /* @__PURE__ */ D(((e, t) => {
3388
3723
  }, e.toSJIS = function(e) {
3389
3724
  return t(e);
3390
3725
  };
3391
- })), Kt = /* @__PURE__ */ D(((e) => {
3726
+ })), en = /* @__PURE__ */ D(((e) => {
3392
3727
  e.L = { bit: 1 }, e.M = { bit: 0 }, e.Q = { bit: 3 }, e.H = { bit: 2 };
3393
3728
  function t(t) {
3394
3729
  if (typeof t != "string") throw Error("Param is not a string");
@@ -3414,7 +3749,7 @@ var Gt = /* @__PURE__ */ D(((e, t) => {
3414
3749
  return r;
3415
3750
  }
3416
3751
  };
3417
- })), qt = /* @__PURE__ */ D(((e, t) => {
3752
+ })), tn = /* @__PURE__ */ D(((e, t) => {
3418
3753
  function n() {
3419
3754
  this.buffer = [], this.length = 0;
3420
3755
  }
@@ -3434,7 +3769,7 @@ var Gt = /* @__PURE__ */ D(((e, t) => {
3434
3769
  this.buffer.length <= t && this.buffer.push(0), e && (this.buffer[t] |= 128 >>> this.length % 8), this.length++;
3435
3770
  }
3436
3771
  }, t.exports = n;
3437
- })), Jt = /* @__PURE__ */ D(((e, t) => {
3772
+ })), nn = /* @__PURE__ */ D(((e, t) => {
3438
3773
  function n(e) {
3439
3774
  if (!e || e < 1) throw Error("BitMatrix size must be defined and greater than 0");
3440
3775
  this.size = e, this.data = new Uint8Array(e * e), this.reservedBit = new Uint8Array(e * e);
@@ -3449,8 +3784,8 @@ var Gt = /* @__PURE__ */ D(((e, t) => {
3449
3784
  }, n.prototype.isReserved = function(e, t) {
3450
3785
  return this.reservedBit[e * this.size + t];
3451
3786
  }, t.exports = n;
3452
- })), Yt = /* @__PURE__ */ D(((e) => {
3453
- var t = X().getSymbolSize;
3787
+ })), rn = /* @__PURE__ */ D(((e) => {
3788
+ var t = $t().getSymbolSize;
3454
3789
  e.getRowColCoords = function(e) {
3455
3790
  if (e === 1) return [];
3456
3791
  let n = Math.floor(e / 7) + 2, r = t(e), i = r === 145 ? 26 : Math.ceil((r - 13) / (2 * n - 2)) * 2, a = [r - 7];
@@ -3461,8 +3796,8 @@ var Gt = /* @__PURE__ */ D(((e, t) => {
3461
3796
  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]]);
3462
3797
  return n;
3463
3798
  };
3464
- })), Xt = /* @__PURE__ */ D(((e) => {
3465
- var t = X().getSymbolSize, n = 7;
3799
+ })), an = /* @__PURE__ */ D(((e) => {
3800
+ var t = $t().getSymbolSize, n = 7;
3466
3801
  e.getPositions = function(e) {
3467
3802
  let r = t(e);
3468
3803
  return [
@@ -3471,7 +3806,7 @@ var Gt = /* @__PURE__ */ D(((e, t) => {
3471
3806
  [0, r - n]
3472
3807
  ];
3473
3808
  };
3474
- })), Zt = /* @__PURE__ */ D(((e) => {
3809
+ })), on = /* @__PURE__ */ D(((e) => {
3475
3810
  e.Patterns = {
3476
3811
  PATTERN000: 0,
3477
3812
  PATTERN001: 1,
@@ -3547,8 +3882,8 @@ var Gt = /* @__PURE__ */ D(((e, t) => {
3547
3882
  }
3548
3883
  return i;
3549
3884
  };
3550
- })), Qt = /* @__PURE__ */ D(((e) => {
3551
- var t = Kt(), n = [
3885
+ })), sn = /* @__PURE__ */ D(((e) => {
3886
+ var t = en(), n = [
3552
3887
  1,
3553
3888
  1,
3554
3889
  1,
@@ -3888,7 +4223,7 @@ var Gt = /* @__PURE__ */ D(((e, t) => {
3888
4223
  default: return;
3889
4224
  }
3890
4225
  };
3891
- })), $t = /* @__PURE__ */ D(((e) => {
4226
+ })), cn = /* @__PURE__ */ D(((e) => {
3892
4227
  var t = new Uint8Array(512), n = new Uint8Array(256);
3893
4228
  (function() {
3894
4229
  let e = 1;
@@ -3902,8 +4237,8 @@ var Gt = /* @__PURE__ */ D(((e, t) => {
3902
4237
  }, e.mul = function(e, r) {
3903
4238
  return e === 0 || r === 0 ? 0 : t[n[e] + n[r]];
3904
4239
  };
3905
- })), en = /* @__PURE__ */ D(((e) => {
3906
- var t = $t();
4240
+ })), ln = /* @__PURE__ */ D(((e) => {
4241
+ var t = cn();
3907
4242
  e.mul = function(e, n) {
3908
4243
  let r = new Uint8Array(e.length + n.length - 1);
3909
4244
  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]);
@@ -3923,8 +4258,8 @@ var Gt = /* @__PURE__ */ D(((e, t) => {
3923
4258
  for (let i = 0; i < n; i++) r = e.mul(r, new Uint8Array([1, t.exp(i)]));
3924
4259
  return r;
3925
4260
  };
3926
- })), tn = /* @__PURE__ */ D(((e, t) => {
3927
- var n = en();
4261
+ })), un = /* @__PURE__ */ D(((e, t) => {
4262
+ var n = ln();
3928
4263
  function r(e) {
3929
4264
  this.genPoly = void 0, this.degree = e, this.degree && this.initialize(this.degree);
3930
4265
  }
@@ -3941,11 +4276,11 @@ var Gt = /* @__PURE__ */ D(((e, t) => {
3941
4276
  }
3942
4277
  return r;
3943
4278
  }, t.exports = r;
3944
- })), nn = /* @__PURE__ */ D(((e) => {
4279
+ })), dn = /* @__PURE__ */ D(((e) => {
3945
4280
  e.isValid = function(e) {
3946
4281
  return !isNaN(e) && e >= 1 && e <= 40;
3947
4282
  };
3948
- })), rn = /* @__PURE__ */ D(((e) => {
4283
+ })), fn = /* @__PURE__ */ D(((e) => {
3949
4284
  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])+";
3950
4285
  r = r.replace(/u/g, "\\u");
3951
4286
  var i = "(?:(?![A-Z0-9 $%*+\\-./:]|" + r + ")(?:.|[\r\n]))+";
@@ -3958,8 +4293,8 @@ var Gt = /* @__PURE__ */ D(((e, t) => {
3958
4293
  }, e.testAlphanumeric = function(e) {
3959
4294
  return s.test(e);
3960
4295
  };
3961
- })), an = /* @__PURE__ */ D(((e) => {
3962
- var t = nn(), n = rn();
4296
+ })), pn = /* @__PURE__ */ D(((e) => {
4297
+ var t = dn(), n = fn();
3963
4298
  e.NUMERIC = {
3964
4299
  id: "Numeric",
3965
4300
  bit: 1,
@@ -4022,8 +4357,8 @@ var Gt = /* @__PURE__ */ D(((e, t) => {
4022
4357
  return n;
4023
4358
  }
4024
4359
  };
4025
- })), on = /* @__PURE__ */ D(((e) => {
4026
- var t = X(), n = Qt(), r = Kt(), i = an(), a = nn(), o = 7973, s = t.getBCHDigit(o);
4360
+ })), mn = /* @__PURE__ */ D(((e) => {
4361
+ var t = $t(), n = sn(), r = en(), i = pn(), a = dn(), o = 7973, s = t.getBCHDigit(o);
4027
4362
  function c(t, n, r) {
4028
4363
  for (let i = 1; i <= 40; i++) if (n <= e.getCapacity(i, r, t)) return i;
4029
4364
  }
@@ -4069,15 +4404,15 @@ var Gt = /* @__PURE__ */ D(((e, t) => {
4069
4404
  for (; t.getBCHDigit(n) - s >= 0;) n ^= o << t.getBCHDigit(n) - s;
4070
4405
  return e << 12 | n;
4071
4406
  };
4072
- })), sn = /* @__PURE__ */ D(((e) => {
4073
- var t = X(), n = 1335, r = 21522, i = t.getBCHDigit(n);
4407
+ })), hn = /* @__PURE__ */ D(((e) => {
4408
+ var t = $t(), n = 1335, r = 21522, i = t.getBCHDigit(n);
4074
4409
  e.getEncodedBits = function(e, a) {
4075
4410
  let o = e.bit << 3 | a, s = o << 10;
4076
4411
  for (; t.getBCHDigit(s) - i >= 0;) s ^= n << t.getBCHDigit(s) - i;
4077
4412
  return (o << 10 | s) ^ r;
4078
4413
  };
4079
- })), cn = /* @__PURE__ */ D(((e, t) => {
4080
- var n = an();
4414
+ })), gn = /* @__PURE__ */ D(((e, t) => {
4415
+ var n = pn();
4081
4416
  function r(e) {
4082
4417
  this.mode = n.NUMERIC, this.data = e.toString();
4083
4418
  }
@@ -4093,8 +4428,8 @@ var Gt = /* @__PURE__ */ D(((e, t) => {
4093
4428
  let i = this.data.length - t;
4094
4429
  i > 0 && (n = this.data.substr(t), r = parseInt(n, 10), e.put(r, i * 3 + 1));
4095
4430
  }, t.exports = r;
4096
- })), ln = /* @__PURE__ */ D(((e, t) => {
4097
- var n = an(), r = /* @__PURE__ */ "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:".split("");
4431
+ })), _n = /* @__PURE__ */ D(((e, t) => {
4432
+ var n = pn(), r = /* @__PURE__ */ "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:".split("");
4098
4433
  function i(e) {
4099
4434
  this.mode = n.ALPHANUMERIC, this.data = e;
4100
4435
  }
@@ -4112,8 +4447,8 @@ var Gt = /* @__PURE__ */ D(((e, t) => {
4112
4447
  }
4113
4448
  this.data.length % 2 && e.put(r.indexOf(this.data[t]), 6);
4114
4449
  }, t.exports = i;
4115
- })), un = /* @__PURE__ */ D(((e, t) => {
4116
- var n = an();
4450
+ })), vn = /* @__PURE__ */ D(((e, t) => {
4451
+ var n = pn();
4117
4452
  function r(e) {
4118
4453
  this.mode = n.BYTE, typeof e == "string" ? this.data = new TextEncoder().encode(e) : this.data = new Uint8Array(e);
4119
4454
  }
@@ -4126,8 +4461,8 @@ var Gt = /* @__PURE__ */ D(((e, t) => {
4126
4461
  }, r.prototype.write = function(e) {
4127
4462
  for (let t = 0, n = this.data.length; t < n; t++) e.put(this.data[t], 8);
4128
4463
  }, t.exports = r;
4129
- })), dn = /* @__PURE__ */ D(((e, t) => {
4130
- var n = an(), r = X();
4464
+ })), yn = /* @__PURE__ */ D(((e, t) => {
4465
+ var n = pn(), r = $t();
4131
4466
  function i(e) {
4132
4467
  this.mode = n.KANJI, this.data = e;
4133
4468
  }
@@ -4147,7 +4482,7 @@ var Gt = /* @__PURE__ */ D(((e, t) => {
4147
4482
  n = (n >>> 8 & 255) * 192 + (n & 255), e.put(n, 13);
4148
4483
  }
4149
4484
  }, t.exports = i;
4150
- })), fn = /* @__PURE__ */ D(((e, t) => {
4485
+ })), bn = /* @__PURE__ */ D(((e, t) => {
4151
4486
  var n = {
4152
4487
  single_source_shortest_paths: function(e, t, r) {
4153
4488
  var i = {}, a = {};
@@ -4200,8 +4535,8 @@ var Gt = /* @__PURE__ */ D(((e, t) => {
4200
4535
  }
4201
4536
  };
4202
4537
  t !== void 0 && (t.exports = n);
4203
- })), pn = /* @__PURE__ */ D(((e) => {
4204
- var t = an(), n = cn(), r = ln(), i = un(), a = dn(), o = rn(), s = X(), c = fn();
4538
+ })), xn = /* @__PURE__ */ D(((e) => {
4539
+ var t = pn(), n = gn(), r = _n(), i = vn(), a = yn(), o = fn(), s = $t(), c = bn();
4205
4540
  function l(e) {
4206
4541
  return unescape(encodeURIComponent(e)).length;
4207
4542
  }
@@ -4328,8 +4663,8 @@ var Gt = /* @__PURE__ */ D(((e, t) => {
4328
4663
  }, e.rawSplit = function(t) {
4329
4664
  return e.fromArray(d(t, s.isKanjiModeEnabled()));
4330
4665
  };
4331
- })), mn = /* @__PURE__ */ D(((e) => {
4332
- 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();
4666
+ })), Sn = /* @__PURE__ */ D(((e) => {
4667
+ var t = $t(), n = en(), r = tn(), i = nn(), a = rn(), o = an(), s = on(), c = sn(), l = un(), u = mn(), d = hn(), f = pn(), p = xn();
4333
4668
  function m(e, t) {
4334
4669
  let n = e.size, r = o.getPositions(t);
4335
4670
  for (let t = 0; t < r.length; t++) {
@@ -4424,7 +4759,7 @@ var Gt = /* @__PURE__ */ D(((e, t) => {
4424
4759
  let i = n.M, a, o;
4425
4760
  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);
4426
4761
  };
4427
- })), hn = /* @__PURE__ */ D(((e) => {
4762
+ })), Cn = /* @__PURE__ */ D(((e) => {
4428
4763
  function t(e) {
4429
4764
  if (typeof e == "number" && (e = e.toString()), typeof e != "string") throw Error("Color should be defined as hex string");
4430
4765
  let t = e.slice().replace("#", "").split("");
@@ -4471,8 +4806,8 @@ var Gt = /* @__PURE__ */ D(((e, t) => {
4471
4806
  t[u++] = d.r, t[u++] = d.g, t[u++] = d.b, t[u] = d.a;
4472
4807
  }
4473
4808
  };
4474
- })), gn = /* @__PURE__ */ D(((e) => {
4475
- var t = hn();
4809
+ })), wn = /* @__PURE__ */ D(((e) => {
4810
+ var t = Cn();
4476
4811
  function n(e, t, n) {
4477
4812
  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";
4478
4813
  }
@@ -4494,8 +4829,8 @@ var Gt = /* @__PURE__ */ D(((e, t) => {
4494
4829
  let a = e.render(t, n, i), o = i.type || "image/png", s = i.rendererOpts || {};
4495
4830
  return a.toDataURL(o, s.quality);
4496
4831
  };
4497
- })), _n = /* @__PURE__ */ D(((e) => {
4498
- var t = hn();
4832
+ })), Tn = /* @__PURE__ */ D(((e) => {
4833
+ var t = Cn();
4499
4834
  function n(e, t) {
4500
4835
  let n = e.a / 255, r = t + "=\"" + e.hex + "\"";
4501
4836
  return n < 1 ? r + " " + t + "-opacity=\"" + n.toFixed(2).slice(1) + "\"" : r;
@@ -4516,8 +4851,8 @@ var Gt = /* @__PURE__ */ D(((e, t) => {
4516
4851
  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";
4517
4852
  return typeof a == "function" && a(null, p), p;
4518
4853
  };
4519
- })), vn = /* @__PURE__ */ k((/* @__PURE__ */ D(((e) => {
4520
- var t = Gt(), n = mn(), r = gn(), i = _n();
4854
+ })), En = /* @__PURE__ */ k((/* @__PURE__ */ D(((e) => {
4855
+ var t = Qt(), n = Sn(), r = wn(), i = Tn();
4521
4856
  function a(e, r, i, a, o) {
4522
4857
  let s = [].slice.call(arguments, 1), c = s.length, l = typeof s[c - 1] == "function";
4523
4858
  if (!l && !t()) throw Error("Callback required as last argument");
@@ -4545,10 +4880,10 @@ var Gt = /* @__PURE__ */ D(((e, t) => {
4545
4880
  return i.render(e, n);
4546
4881
  });
4547
4882
  })))(), 1);
4548
- async function yn(e, t = 200) {
4883
+ async function Dn(e, t = 200) {
4549
4884
  if (!e || e.trim() === "") return "";
4550
4885
  try {
4551
- return await vn.toDataURL(e, {
4886
+ return await En.toDataURL(e, {
4552
4887
  width: t,
4553
4888
  margin: 1,
4554
4889
  color: {
@@ -4563,7 +4898,7 @@ async function yn(e, t = 200) {
4563
4898
  }
4564
4899
  //#endregion
4565
4900
  //#region src/composables/usePaperSelection.ts
4566
- function bn(e) {
4901
+ function On(e) {
4567
4902
  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);
4568
4903
  function c(e) {
4569
4904
  n.value = e, e && (r.value = null, i.value = null);
@@ -4628,7 +4963,7 @@ function bn(e) {
4628
4963
  }
4629
4964
  //#endregion
4630
4965
  //#region src/composables/paperHelpers.ts
4631
- var xn = {
4966
+ var kn = {
4632
4967
  三号: 21,
4633
4968
  小三: 20,
4634
4969
  四号: 19,
@@ -4636,24 +4971,24 @@ var xn = {
4636
4971
  五号: 14,
4637
4972
  小五: 12
4638
4973
  };
4639
- function Sn(e) {
4640
- return xn[e] ?? 16;
4974
+ function An(e) {
4975
+ return kn[e] ?? 16;
4641
4976
  }
4642
- function Cn(e) {
4643
- for (let [t, n] of Object.entries(xn)) if (n === e) return t;
4977
+ function jn(e) {
4978
+ for (let [t, n] of Object.entries(kn)) if (n === e) return t;
4644
4979
  return "五号";
4645
4980
  }
4646
4981
  function Z(e) {
4647
- return typeof e.fontSize == "number" ? e.fontSize : Sn(e.fontSize || "小四");
4982
+ return typeof e.fontSize == "number" ? e.fontSize : An(e.fontSize || "小四");
4648
4983
  }
4649
4984
  function Q(e) {
4650
4985
  return e.lineSpacing ?? 1;
4651
4986
  }
4652
- function wn(e, t) {
4987
+ function Mn(e, t) {
4653
4988
  return Math.round(e * t * 35 / (14 * 1.5));
4654
4989
  }
4655
4990
  function $(e, t) {
4656
- let n = wn(e, t);
4991
+ let n = Mn(e, t);
4657
4992
  return {
4658
4993
  lines: [{
4659
4994
  elements: [{
@@ -4669,15 +5004,15 @@ function $(e, t) {
4669
5004
  height: n
4670
5005
  };
4671
5006
  }
4672
- function Tn(e, t, n, r, i = 0) {
4673
- let a = wn(t, n), o = r && r > 0 ? rt(e, r, a, i) : [nt(e, a)];
5007
+ function Nn(e, t, n, r, i = 0) {
5008
+ let a = Mn(t, n), o = r && r > 0 ? at(e, r, a, i) : [it(e, a)];
4674
5009
  return {
4675
5010
  lines: o,
4676
5011
  y: 0,
4677
5012
  height: o.reduce((e, t) => e + t.lineHeight, 0) + 4
4678
5013
  };
4679
5014
  }
4680
- function En(e) {
5015
+ function Pn(e) {
4681
5016
  let t = e.paragraphs.length;
4682
5017
  for (; t > 0;) {
4683
5018
  let n = e.paragraphs[t - 1];
@@ -4686,14 +5021,14 @@ function En(e) {
4686
5021
  }
4687
5022
  return t;
4688
5023
  }
4689
- var Dn = 0, On = 0;
4690
- function kn(e) {
5024
+ var Fn = 0, In = 0;
5025
+ function Ln(e) {
4691
5026
  return e.type === "question" ? (e.metadata?.questionNo || "").length > 2 ? 26.25 : 17.5 : e.type === "sub-question" ? 26.25 : 0;
4692
5027
  }
4693
- function An(e, t) {
4694
- return t - kn(e);
5028
+ function Rn(e, t) {
5029
+ return t - Ln(e);
4695
5030
  }
4696
- function jn(e) {
5031
+ function zn(e) {
4697
5032
  let t = [], n = 0;
4698
5033
  for (; n < e.length;) {
4699
5034
  if (e[n] === "\\" && e.substring(n, n + 2) === "\\(") {
@@ -4724,9 +5059,9 @@ function jn(e) {
4724
5059
  }
4725
5060
  return t;
4726
5061
  }
4727
- function Mn(e, t) {
4728
- let n = [], r = jn(e);
4729
- for (let e of r) if (e.type === "text") n.push(Nn(e.value, t, !1, "\"Times New Roman\", SimSun,'Cambria Math'", "#000"));
5062
+ function Bn(e, t) {
5063
+ let n = [], r = zn(e);
5064
+ for (let e of r) if (e.type === "text") n.push(Vn(e.value, t, !1, "\"Times New Roman\", SimSun,'Cambria Math'", "#000"));
4730
5065
  else if (e.type === "formula") {
4731
5066
  let { svg: t, width: r, height: i } = De(e.value);
4732
5067
  n.push({
@@ -4738,7 +5073,7 @@ function Mn(e, t) {
4738
5073
  });
4739
5074
  } else e.type === "blank" && n.push({
4740
5075
  type: "underline",
4741
- id: `ul-${++On}`,
5076
+ id: `ul-${++In}`,
4742
5077
  width: 80,
4743
5078
  height: 20,
4744
5079
  placeholder: "空",
@@ -4747,8 +5082,8 @@ function Mn(e, t) {
4747
5082
  });
4748
5083
  return n;
4749
5084
  }
4750
- function Nn(e, t, n, r, i) {
4751
- let a = e.split(""), o = B(e, t, r);
5085
+ function Vn(e, t, n, r, i) {
5086
+ let a = e.split(""), o = H(e, t, r);
4752
5087
  return {
4753
5088
  type: "text",
4754
5089
  value: e,
@@ -4757,19 +5092,18 @@ function Nn(e, t, n, r, i) {
4757
5092
  bold: n,
4758
5093
  italic: !1,
4759
5094
  color: i,
4760
- width: o.length > 0 ? o[o.length - 1] + z(a[a.length - 1], t, r) : 0,
5095
+ width: o.length > 0 ? o[o.length - 1] + B(a[a.length - 1], t, r) : 0,
4761
5096
  height: t * 1.4,
4762
5097
  xPositions: o
4763
5098
  };
4764
5099
  }
4765
- function Pn(e, t, n, r, i, a, o = !1) {
5100
+ function Hn(e, t, n, r, i, a, o = !1) {
4766
5101
  let s = [];
4767
5102
  for (let e = 0; e < n.length; e++) {
4768
- let t = Mn(n[e], r);
4769
- s.push(Tn(t, r, i, a && a > 0 ? a : void 0));
5103
+ let t = Bn(n[e], r);
5104
+ s.push(Nn(t, r, i, a && a > 0 ? a : void 0));
4770
5105
  }
4771
- for (let e = 0; e < 2; e++) s.push($(r, i));
4772
- let c = s.reduce((e, t) => e + (t.height || 26), 0), l = `topic-${e.replace(".", "")}-${++Dn}`;
5106
+ let c = s.reduce((e, t) => e + (t.height || 26), 0), l = `topic-${e.replace(".", "")}-${++Fn}`;
4773
5107
  return {
4774
5108
  id: `q-${e.replace(".", "")}-${Date.now()}-${Math.random().toString(36).slice(2, 6)}`,
4775
5109
  type: "question",
@@ -4785,12 +5119,10 @@ function Pn(e, t, n, r, i, a, o = !1) {
4785
5119
  }
4786
5120
  };
4787
5121
  }
4788
- function Fn(e, t, n, r, i, a, o = !1) {
5122
+ function Un(e, t, n, r, i, a, o = !1) {
4789
5123
  let s = [], c = `group-${e.replace(".", "")}-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`, l = [], u = 0, d = (n, u) => {
4790
5124
  if (l.length === 0) return;
4791
- let d = l.map((e) => Tn(Mn(e, r), r, i, a && a > 0 ? a : void 0));
4792
- if (!n) for (let e = 0; e < 2; e++) d.push($(r, i));
4793
- let f = d.reduce((e, t) => e + (t.height || 26), 0), p = `${c}-${n ? "header" : `sub${u}`}`;
5125
+ let d = l.map((e) => Nn(Bn(e, r), r, i, a && a > 0 ? a : void 0)), f = d.reduce((e, t) => e + (t.height || 26), 0), p = `${c}-${n ? "header" : `sub${u}`}`;
4794
5126
  s.push({
4795
5127
  id: `${p}-${Date.now()}-${Math.random().toString(36).slice(2, 6)}`,
4796
5128
  type: n ? "question" : "sub-question",
@@ -4814,7 +5146,7 @@ function Fn(e, t, n, r, i, a, o = !1) {
4814
5146
  }
4815
5147
  return d(s.length === 0, u), s;
4816
5148
  }
4817
- function In(e) {
5149
+ function Wn(e) {
4818
5150
  let t = [];
4819
5151
  for (let n of e.paragraphs) {
4820
5152
  if (n.lines.length > 0 && n.lines.every((e) => e.elements.length > 0 && e.elements.every((e) => e.type === "enter"))) continue;
@@ -4828,24 +5160,24 @@ function In(e) {
4828
5160
  }
4829
5161
  return t.join("\n");
4830
5162
  }
4831
- function Ln(e) {
5163
+ function Gn(e) {
4832
5164
  return e.metadata?.questionNo ? `第${e.metadata.questionNo.replace(".", "")}题` : e.metadata?.subLabel ? e.metadata.subLabel : e.metadata?.label || e.id;
4833
5165
  }
4834
5166
  //#endregion
4835
5167
  //#region src/composables/usePaperBlockOps.ts
4836
- function Rn(e) {
5168
+ function Kn(e) {
4837
5169
  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;
4838
5170
  function b() {
4839
- y || (_.push(H()), v.value = !0, i.value = !0);
5171
+ y || (_.push(W()), v.value = !0, i.value = !0);
4840
5172
  }
4841
5173
  function x() {
4842
5174
  _.length !== 0 && (y = !0, ue(_.pop()), y = !1, v.value = _.length > 0);
4843
5175
  }
4844
5176
  function S() {
4845
- let e = Z(n.value), r = Q(n.value), s = a.value.columnWidth;
4846
- s <= 0 || (t.value = t.value.map((t) => {
5177
+ let e = Z(n.value), r = Q(n.value), o = a.value.columnWidth;
5178
+ o <= 0 || (t.value = t.value.map((t) => {
4847
5179
  if (!t.paragraphs || t.paragraphs.length === 0) return t;
4848
- let n = An(t, s), i = [], a = !1;
5180
+ let n = Rn(t, o), i = [], a = !1;
4849
5181
  for (let o = 0; o < t.paragraphs.length; o++) {
4850
5182
  let s = t.paragraphs[o];
4851
5183
  if (s.lines.length > 0 && s.lines.every((e) => e.elements.length > 0 && e.elements.every((e) => e.type === "enter"))) {
@@ -4856,7 +5188,7 @@ function Rn(e) {
4856
5188
  for (let t of s.lines) for (let n of t.elements) if (n.type === "text") {
4857
5189
  let t = n, r = t.value.split("");
4858
5190
  for (let n = 0; n < r.length; n++) {
4859
- let i = zn(r[n], e, t.fontFamily, t.bold, t.italic);
5191
+ let i = qn(r[n], e, t.fontFamily, t.bold, t.italic);
4860
5192
  c.push({
4861
5193
  ...t,
4862
5194
  value: r[n],
@@ -4878,28 +5210,28 @@ function Rn(e) {
4878
5210
  } else c.push(n);
4879
5211
  } else c.push(n);
4880
5212
  let l;
4881
- if (a) l = Tn(c, e, r, n > 0 ? n : void 0, 0);
5213
+ if (a) l = Nn(c, e, r, n > 0 ? n : void 0, 0);
4882
5214
  else {
4883
- let i = t.metadata?.score || "", o = i ? se(`(${i}分)`, e, "SimSun, STSong, serif") : 0;
4884
- l = Tn(c, e, r, n > 0 ? n : void 0, o), a = !0;
5215
+ let i = t.metadata?.score || "", o = i ? V(`(${i}分)`, e, "SimSun, STSong, serif") : 0;
5216
+ l = Nn(c, e, r, n > 0 ? n : void 0, o), a = !0;
4885
5217
  }
4886
5218
  t.paragraphs[o].justification && (l.justification = t.paragraphs[o].justification), i.push(l);
4887
5219
  }
4888
- let c = 0;
4889
- t.options && t.options.length > 0 && (c = o.value.getOptionsHeight(t.options, An(t, s)));
4890
- let l = t.metadata?.customHeight;
4891
- if (l) {
4892
- let t = i.reduce((e, t) => e + (t.height || 26), 0) + c;
4893
- if (l > t) {
4894
- let n = l - t, a = wn(e, r) + 4, o = Math.round(n / a);
5220
+ let s = C(i);
5221
+ s.length > 0 ? t.options = s : delete t.options;
5222
+ let c = t.metadata?.customHeight;
5223
+ if (c) {
5224
+ let t = i.reduce((e, t) => e + (t.height || 26), 0);
5225
+ if (c > t) {
5226
+ let n = c - t, a = Mn(e, r), o = Math.floor(n / a);
4895
5227
  for (let t = 0; t < o; t++) i.push($(e, r));
4896
5228
  }
4897
5229
  }
4898
- let u = i.reduce((e, t) => e + (t.height || 26), 0);
5230
+ let l = i.reduce((e, t) => e + (t.height || 26), 0);
4899
5231
  return {
4900
5232
  ...t,
4901
5233
  paragraphs: i,
4902
- height: u,
5234
+ height: l,
4903
5235
  metadata: {
4904
5236
  ...t.metadata,
4905
5237
  originalContentWidth: n
@@ -4908,9 +5240,49 @@ function Rn(e) {
4908
5240
  }), i.value = !0, g());
4909
5241
  }
4910
5242
  function C(e) {
4911
- b(), t.value = [...t.value, e], I(), i.value = !0, g();
5243
+ let t = [], n = "", r = [];
5244
+ for (let i of e) {
5245
+ let e = i?.lines[0]?.elements[0];
5246
+ if (e?.type === "text" && e.isLabel) {
5247
+ n && t.push({
5248
+ label: n,
5249
+ contentHtml: "",
5250
+ paragraphs: r
5251
+ }), n = e.value.replace(/\.\s*$/g, ""), r = [];
5252
+ let a = JSON.parse(JSON.stringify(i));
5253
+ a.lines[0] && (a.lines[0].elements = a.lines[0].elements.filter((e) => !(e.type === "text" && e.isLabel))), r.push(a);
5254
+ } else if (n) {
5255
+ if (i.lines.every((e) => e.elements.length > 0 && e.elements.every((e) => e.type === "enter"))) break;
5256
+ r.push(JSON.parse(JSON.stringify(i)));
5257
+ }
5258
+ }
5259
+ return n && r.length > 0 && t.push({
5260
+ label: n,
5261
+ contentHtml: "",
5262
+ paragraphs: r
5263
+ }), t;
4912
5264
  }
4913
- function w(e, n) {
5265
+ function w(e, t, n) {
5266
+ if (!t.options || t.options.length === 0) return e;
5267
+ let r = t.options.map((e) => {
5268
+ let t = 0;
5269
+ for (let n of e.paragraphs) for (let e of n.lines) {
5270
+ let n = 0;
5271
+ for (let t of e.elements) n += t.width;
5272
+ t = Math.max(t, n);
5273
+ }
5274
+ return 20 + Math.min(t, n - 20);
5275
+ });
5276
+ if (Math.max(...r) * t.options.length <= n) {
5277
+ let n = t.options.map((e) => e.paragraphs.reduce((e, t) => e + (t.height || 26), 0)), r = n.reduce((e, t) => e + t, 0), i = Math.max(...n);
5278
+ return e - r + i;
5279
+ }
5280
+ return e;
5281
+ }
5282
+ function T(e) {
5283
+ b(), t.value = [...t.value, e], R(), i.value = !0, g();
5284
+ }
5285
+ function E(e, n) {
4914
5286
  b();
4915
5287
  let r = {
4916
5288
  id: `title-${Date.now()}-${Math.random().toString(36).slice(2, 6)}`,
@@ -4931,17 +5303,17 @@ function Rn(e) {
4931
5303
  ...t.value.slice(e)
4932
5304
  ] : t.value = [...t.value, r];
4933
5305
  } else t.value = [...t.value, r];
4934
- i.value = !0, I(), g();
5306
+ i.value = !0, R(), g();
4935
5307
  }
4936
- function T(e) {
5308
+ function D(e) {
4937
5309
  b();
4938
5310
  let n = new Map(t.value.map((e) => [e.id, e])), r = e.map((e) => n.get(e)).filter((e) => !!e);
4939
- r.length === t.value.length && (t.value = r, I(), i.value = !0, g());
5311
+ r.length === t.value.length && (t.value = r, R(), i.value = !0, g());
4940
5312
  }
4941
- function E(e) {
4942
- b(), t.value = t.value.filter((t) => t.id !== e), p.value === e && (p.value = null), I(), i.value = !0, g();
5313
+ function O(e) {
5314
+ b(), t.value = t.value.filter((t) => t.id !== e), p.value === e && (p.value = null), R(), i.value = !0, g();
4943
5315
  }
4944
- function D(e, n) {
5316
+ function k(e, n) {
4945
5317
  b();
4946
5318
  let r = t.value.find((t) => t.id === e);
4947
5319
  r && (r.metadata = {
@@ -4949,11 +5321,11 @@ function Rn(e) {
4949
5321
  label: n
4950
5322
  }, i.value = !0, g());
4951
5323
  }
4952
- function O(e, r) {
5324
+ function A(e, r) {
4953
5325
  b();
4954
5326
  let a = t.value.findIndex((t) => t.id === e);
4955
5327
  if (a === -1) return;
4956
- let o = t.value[a], s = Z(n.value), c = Q(n.value), l = Math.max(0, o.paragraphs.length - En(o)), u = [...r];
5328
+ let o = t.value[a], s = Z(n.value), c = Q(n.value), l = Math.max(0, o.paragraphs.length - Pn(o)), u = [...r];
4957
5329
  for (let e = 0; e < l; e++) u.push($(s, c));
4958
5330
  let d = u.reduce((e, t) => e + (t.height || 26), 0);
4959
5331
  t.value = t.value.map((e, t) => t === a ? {
@@ -4962,7 +5334,7 @@ function Rn(e) {
4962
5334
  height: d
4963
5335
  } : e), i.value = !0, g();
4964
5336
  }
4965
- function k(e, n) {
5337
+ function j(e, n) {
4966
5338
  b();
4967
5339
  let r = t.value.findIndex((t) => t.id === e);
4968
5340
  r !== -1 && (t.value = t.value.map((e, t) => t === r ? {
@@ -4973,7 +5345,7 @@ function Rn(e) {
4973
5345
  }
4974
5346
  } : e), i.value = !0, g());
4975
5347
  }
4976
- function A(e) {
5348
+ function M(e) {
4977
5349
  b();
4978
5350
  let n = t.value.findIndex((t) => t.id === e);
4979
5351
  if (n === -1) return;
@@ -4983,13 +5355,13 @@ function Rn(e) {
4983
5355
  protectContent: !r
4984
5356
  } : e), i.value = !0, g();
4985
5357
  }
4986
- function j(e) {
5358
+ function ee(e) {
4987
5359
  b(), n.value = {
4988
5360
  ...n.value,
4989
5361
  showScore: e
4990
5362
  }, i.value = !0, g();
4991
5363
  }
4992
- function M(e, n) {
5364
+ function N(e, n) {
4993
5365
  b();
4994
5366
  let r = t.value.findIndex((t) => t.id === e);
4995
5367
  r !== -1 && (t.value = t.value.map((e, t) => {
@@ -5001,26 +5373,29 @@ function Rn(e) {
5001
5373
  };
5002
5374
  }), i.value = !0);
5003
5375
  }
5004
- function ee(e, r) {
5376
+ function P(e, r) {
5005
5377
  b();
5006
- let s = t.value.findIndex((t) => t.id === e);
5007
- if (s === -1) return;
5008
- let c = t.value[s], l = Z(n.value), u = Q(n.value), d = wn(l, u) + 4, f = 0;
5009
- c.options && c.options.length > 0 && (f = o.value.getOptionsHeight(c.options, An(c, a.value.columnWidth)));
5010
- 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 = [];
5011
- for (let e = 0; e < v; e++) y.push($(l, u));
5012
- let x = [...m, ...y], S = x.reduce((e, t) => e + (t.height || 26), 0);
5013
- t.value = t.value.map((e, t) => t === s ? {
5378
+ let o = t.value.findIndex((t) => t.id === e);
5379
+ if (o === -1) return;
5380
+ let s = t.value[o], c = Z(n.value), l = Q(n.value), u = Mn(c, l), d = Pn(s), f = s.paragraphs.slice(0, d), p = f.reduce((e, t) => e + (t.height || 26), 0), m = a.value.columnWidth;
5381
+ if (m > 0) {
5382
+ let e = Rn(s, m);
5383
+ p = w(p, s, e);
5384
+ }
5385
+ let h = Math.max(0, r - p), _ = Math.round(h / u), v = [];
5386
+ for (let e = 0; e < _; e++) v.push($(c, l));
5387
+ let y = [...f, ...v], x = y.reduce((e, t) => e + (t.height || 26), 0);
5388
+ t.value = t.value.map((e, t) => t === o ? {
5014
5389
  ...e,
5015
- paragraphs: x,
5016
- height: S,
5390
+ paragraphs: y,
5391
+ height: x,
5017
5392
  metadata: {
5018
5393
  ...e.metadata,
5019
- customHeight: S
5394
+ customHeight: x
5020
5395
  }
5021
5396
  } : e), i.value = !0, g();
5022
5397
  }
5023
- function N(e, n) {
5398
+ function F(e, n) {
5024
5399
  b();
5025
5400
  let r = t.value.findIndex((t) => t.id === e);
5026
5401
  r !== -1 && (t.value = t.value.map((e, t) => t === r ? {
@@ -5028,7 +5403,7 @@ function Rn(e) {
5028
5403
  questionType: n
5029
5404
  } : e), i.value = !0);
5030
5405
  }
5031
- function P(e, n) {
5406
+ function te(e, n) {
5032
5407
  b();
5033
5408
  let r = t.value.findIndex((t) => t.id === e);
5034
5409
  r !== -1 && (t.value = t.value.map((e, t) => {
@@ -5043,7 +5418,7 @@ function Rn(e) {
5043
5418
  };
5044
5419
  }), i.value = !0, g());
5045
5420
  }
5046
- function F(e, n) {
5421
+ function ne(e, n) {
5047
5422
  b();
5048
5423
  let r = t.value.findIndex((t) => t.id === e);
5049
5424
  r !== -1 && (t.value = t.value.map((e, t) => t === r ? {
@@ -5051,7 +5426,7 @@ function Rn(e) {
5051
5426
  keepNext: n
5052
5427
  } : e), i.value = !0, g());
5053
5428
  }
5054
- function te(e, n) {
5429
+ function I(e, n) {
5055
5430
  let r = t.value.findIndex((t) => t.id === e);
5056
5431
  if (r === -1) {
5057
5432
  console.warn(`[usePaperCore] patchBlock: block ${e} not found`);
@@ -5072,7 +5447,7 @@ function Rn(e) {
5072
5447
  ...n
5073
5448
  } : e), i.value = !0;
5074
5449
  }
5075
- function ne(e) {
5450
+ function L(e) {
5076
5451
  let n = /* @__PURE__ */ new Map();
5077
5452
  for (let t of e) {
5078
5453
  let e = n.get(t.id) || [];
@@ -5094,17 +5469,17 @@ function Rn(e) {
5094
5469
  };
5095
5470
  }), i.value = !0;
5096
5471
  }
5097
- function I() {
5472
+ function R() {
5098
5473
  let e = 0, n = 0, r = [];
5099
5474
  for (let i of t.value) if (i.type === "title") {
5100
5475
  e++;
5101
- let t = i.metadata?.title ?? (Vt(i.metadata?.label || "") || "题组");
5476
+ let t = i.metadata?.title ?? (Ht(i.metadata?.label || "") || "题组");
5102
5477
  r.push({
5103
5478
  id: i.id,
5104
5479
  metadata: {
5105
5480
  title: t,
5106
5481
  ordinal: e,
5107
- label: Bt(t, e)
5482
+ label: Vt(t, e)
5108
5483
  }
5109
5484
  });
5110
5485
  } else if (i.type === "question") {
@@ -5118,27 +5493,27 @@ function Rn(e) {
5118
5493
  }
5119
5494
  });
5120
5495
  }
5121
- ne(r);
5496
+ L(r);
5122
5497
  }
5123
- function L(e, t) {
5124
- b(), te(e, { metadata: { title: t } }), I(), i.value = !0, g();
5498
+ function re(e, t) {
5499
+ b(), I(e, { metadata: { title: t } }), R(), i.value = !0, g();
5125
5500
  }
5126
- function re(e, r = !1) {
5501
+ function ie(e, r = !1) {
5127
5502
  b();
5128
5503
  let o = e.content.split("\n").filter((e) => e.trim());
5129
5504
  o.length === 0 && o.push("");
5130
5505
  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;
5131
- if (c) f = Fn(e.no, s, o, l, u, d - 26.25, r);
5506
+ if (c) f = Un(e.no, s, o, l, u, d - 26.25, r);
5132
5507
  else {
5133
5508
  let t = e.no.length > 2 ? 26.25 : 17.5;
5134
- f = [Pn(e.no, s, o, l, u, d - t, r)];
5509
+ f = [Hn(e.no, s, o, l, u, d - t, r)];
5135
5510
  }
5136
5511
  for (let e of f) t.value = [...t.value, e];
5137
- f.length > 0 && (p.value = f[f.length - 1].id), I(), i.value = !0, S();
5512
+ f.length > 0 && (p.value = f[f.length - 1].id), R(), i.value = !0, S();
5138
5513
  }
5139
- function ie(e, r, o, s = !1) {
5514
+ function z(e, r, o, s = !1) {
5140
5515
  b();
5141
- 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, {
5516
+ let c = Z(n.value), l = Q(n.value), u = a.value.columnWidth, d = (r?.length || 0) > 2 ? 26.25 : 17.5, f = Ct(e, {
5142
5517
  questionNo: r || "",
5143
5518
  score: o || "",
5144
5519
  contentWidth: u - d,
@@ -5147,7 +5522,7 @@ function Rn(e) {
5147
5522
  protectContent: s
5148
5523
  });
5149
5524
  for (let e of f) t.value = [...t.value, e];
5150
- f.length > 0 && (p.value = f[f.length - 1].id), I(), i.value = !0, S();
5525
+ f.length > 0 && (p.value = f[f.length - 1].id), R(), i.value = !0, S();
5151
5526
  }
5152
5527
  function ae(e, r, o, s = !1) {
5153
5528
  b();
@@ -5157,7 +5532,7 @@ function Rn(e) {
5157
5532
  } catch {
5158
5533
  throw Error("JSON 格式错误,请检查");
5159
5534
  }
5160
- let m = Nt(f, {
5535
+ let m = Ft(f, {
5161
5536
  questionNo: r || "",
5162
5537
  score: o || "",
5163
5538
  contentWidth: u - d,
@@ -5166,35 +5541,34 @@ function Rn(e) {
5166
5541
  protectContent: s
5167
5542
  });
5168
5543
  for (let e of m) t.value = [...t.value, e];
5169
- m.length > 0 && (p.value = m[m.length - 1].id), I(), i.value = !0, S();
5544
+ m.length > 0 && (p.value = m[m.length - 1].id), R(), i.value = !0, S();
5170
5545
  }
5171
- function R(e) {
5546
+ function B(e) {
5172
5547
  b();
5173
- let r = t.value.filter((t) => t.metadata?.blockGroup === e);
5174
- if (r.length < 2) return;
5175
- let a = r.find((e) => e.type === "question") || r[0], o = Z(n.value), s = Q(n.value), c = [];
5176
- for (let e of r) {
5177
- let t = En(e);
5178
- c.push(...e.paragraphs.slice(0, t));
5179
- }
5180
- for (let e = 0; e < 2; e++) c.push($(o, s));
5181
- let l = c.reduce((e, t) => e + (t.height || 26), 0), u = {}, d = a.metadata?.answer || "";
5182
- for (let e of r) if (e.type === "sub-question" && e.metadata?.answer) {
5548
+ let n = t.value.filter((t) => t.metadata?.blockGroup === e);
5549
+ if (n.length < 2) return;
5550
+ let r = n.find((e) => e.type === "question") || n[0], a = [];
5551
+ for (let e of n) {
5552
+ let t = Pn(e);
5553
+ a.push(...e.paragraphs.slice(0, t));
5554
+ }
5555
+ let o = a.reduce((e, t) => e + (t.height || 26), 0), s = {}, c = r.metadata?.answer || "";
5556
+ for (let e of n) if (e.type === "sub-question" && e.metadata?.answer) {
5183
5557
  let t = e.metadata.subLabel || "", n = e.metadata.answer;
5184
- t && (u[t] = n, d += (d ? "\n" : "") + t + n);
5558
+ t && (s[t] = n, c += (c ? "\n" : "") + t + n);
5185
5559
  }
5186
- let f = {
5187
- ...a,
5560
+ let l = {
5561
+ ...r,
5188
5562
  id: `merged-${Date.now()}-${Math.random().toString(36).slice(2, 6)}`,
5189
- paragraphs: c,
5190
- height: l,
5563
+ paragraphs: a,
5564
+ height: o,
5191
5565
  metadata: {
5192
- ...a.metadata,
5193
- answer: d || a.metadata?.answer,
5566
+ ...r.metadata,
5567
+ answer: c || r.metadata?.answer,
5194
5568
  blockGroup: void 0,
5195
5569
  hasSubQuestions: !0,
5196
- subAnswers: Object.keys(u).length > 0 ? u : void 0,
5197
- _splitBackup: JSON.stringify(r.map((e) => ({
5570
+ subAnswers: Object.keys(s).length > 0 ? s : void 0,
5571
+ _splitBackup: JSON.stringify(n.map((e) => ({
5198
5572
  ...e,
5199
5573
  paragraphs: e.paragraphs.map((e) => ({
5200
5574
  ...e,
@@ -5205,19 +5579,19 @@ function Rn(e) {
5205
5579
  }))
5206
5580
  })))
5207
5581
  }
5208
- }, p = new Set(r.map((e) => e.id)), m = t.value.findIndex((e) => p.has(e.id));
5209
- if (m === -1) t.value = [...t.value.filter((e) => !p.has(e.id)), f];
5582
+ }, u = new Set(n.map((e) => e.id)), d = t.value.findIndex((e) => u.has(e.id));
5583
+ if (d === -1) t.value = [...t.value.filter((e) => !u.has(e.id)), l];
5210
5584
  else {
5211
- let e = t.value.slice(0, m), n = t.value.slice(m).filter((e) => !p.has(e.id));
5585
+ let e = t.value.slice(0, d), n = t.value.slice(d).filter((e) => !u.has(e.id));
5212
5586
  t.value = [
5213
5587
  ...e,
5214
- f,
5588
+ l,
5215
5589
  ...n
5216
5590
  ];
5217
5591
  }
5218
- I(), i.value = !0, S();
5592
+ R(), i.value = !0, S();
5219
5593
  }
5220
- function oe(e) {
5594
+ function H(e) {
5221
5595
  let n = t.value.find((t) => t.id === e);
5222
5596
  if (n?.metadata?._splitBackup) {
5223
5597
  b();
@@ -5228,20 +5602,20 @@ function Rn(e) {
5228
5602
  ...t.value.slice(0, a),
5229
5603
  ...r,
5230
5604
  ...t.value.slice(a + 1)
5231
- ], I(), i.value = !0, S();
5605
+ ], R(), i.value = !0, S();
5232
5606
  } catch (e) {
5233
5607
  console.warn("[splitMergedBlock] _splitBackup 解析失败", e);
5234
5608
  }
5235
5609
  }
5236
5610
  }
5237
- function z(e, t, n) {
5611
+ function oe(e, t, n) {
5238
5612
  b();
5239
5613
  let r = m(e);
5240
5614
  if (!r) return;
5241
- let o = An(r.block, a.value.columnWidth), s = Math.max(20, Math.min(Math.round(t), Math.max(20, o)));
5242
- r.image.width = s, n !== void 0 && (r.image.height = Math.max(12, Math.round(n))), i.value = !0, S();
5615
+ let o = Rn(r.block, a.value.columnWidth), s = r.optionIdx === void 0 ? o : o - 20, c = Math.max(20, Math.min(Math.round(t), Math.max(20, s)));
5616
+ r.image.width = c, n !== void 0 && (r.image.height = Math.max(12, Math.round(n))), i.value = !0, S();
5243
5617
  }
5244
- function B(e) {
5618
+ function se(e) {
5245
5619
  let t = m(e);
5246
5620
  if (!t) return null;
5247
5621
  let n = t.block.paragraphs[t.paraIdx];
@@ -5250,24 +5624,24 @@ function Rn(e) {
5250
5624
  alignment: n.justification || "left"
5251
5625
  };
5252
5626
  }
5253
- function ce(e, t) {
5627
+ function U(e, t) {
5254
5628
  b();
5255
5629
  let n = m(e);
5256
5630
  if (!n) return;
5257
5631
  let r = n.block.paragraphs[n.paraIdx];
5258
5632
  r.justification = t === "left" ? void 0 : t, i.value = !0, g();
5259
5633
  }
5260
- function le(e, t) {
5634
+ function ce(e, t) {
5261
5635
  b();
5262
5636
  let n = Math.max(30, Math.min(500, Math.round(t))), r = h(e);
5263
5637
  r && (r.underline.width = n, S());
5264
5638
  }
5265
- function V(e, t, r, i) {
5639
+ function le(e, t, r, i) {
5266
5640
  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());
5267
- return l.length === 0 && l.push(""), l.map((e) => Tn(Mn(e, o), o, s, c > 0 ? c : void 0));
5641
+ return l.length === 0 && l.push(""), l.map((e) => Nn(Bn(e, o), o, s, c > 0 ? c : void 0));
5268
5642
  }
5269
- function H() {
5270
- return ht(t.value, n.value, {
5643
+ function W() {
5644
+ return _t(t.value, n.value, {
5271
5645
  paperName: s.value,
5272
5646
  schoolName: c.value,
5273
5647
  qrCodeContent: l.value,
@@ -5278,56 +5652,56 @@ function Rn(e) {
5278
5652
  });
5279
5653
  }
5280
5654
  function ue(e, r) {
5281
- let o = gt(e);
5282
- t.value = o.blocks, o.settings && typeof o.settings.fontSize == "string" && (o.settings.fontSize = Sn(o.settings.fontSize)), n.value = {
5655
+ let o = vt(e);
5656
+ t.value = o.blocks, o.settings && typeof o.settings.fontSize == "string" && (o.settings.fontSize = An(o.settings.fontSize)), n.value = {
5283
5657
  ...n.value,
5284
5658
  ...o.settings
5285
- }, 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;
5659
+ }, 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), R(), r ? g() : S(), i.value = !1;
5286
5660
  }
5287
5661
  return {
5288
5662
  reflowAllBlocks: S,
5289
5663
  saveUndoSnapshot: b,
5290
5664
  undo: x,
5291
5665
  canUndo: v,
5292
- addBlock: C,
5293
- addTitleBlock: w,
5294
- reorderBlocks: T,
5295
- removeBlock: E,
5296
- updateBlockLabel: D,
5297
- updateBlockContent: O,
5298
- updateBlockScore: k,
5299
- toggleContentProtection: A,
5300
- updateShowScore: j,
5301
- updateBlockQid: M,
5302
- updateBlockHeight: ee,
5303
- updateBlockQuestionType: N,
5304
- updateBlockSplit: P,
5305
- updateBlockKeepNext: F,
5306
- patchBlock: te,
5307
- patchBlocksMeta: ne,
5308
- recalculateNumbering: I,
5309
- updateSectionTitle: L,
5310
- addNewQuestion: re,
5311
- addQuestionFromHtml: ie,
5666
+ addBlock: T,
5667
+ addTitleBlock: E,
5668
+ reorderBlocks: D,
5669
+ removeBlock: O,
5670
+ updateBlockLabel: k,
5671
+ updateBlockContent: A,
5672
+ updateBlockScore: j,
5673
+ toggleContentProtection: M,
5674
+ updateShowScore: ee,
5675
+ updateBlockQid: N,
5676
+ updateBlockHeight: P,
5677
+ updateBlockQuestionType: F,
5678
+ updateBlockSplit: te,
5679
+ updateBlockKeepNext: ne,
5680
+ patchBlock: I,
5681
+ patchBlocksMeta: L,
5682
+ recalculateNumbering: R,
5683
+ updateSectionTitle: re,
5684
+ addNewQuestion: ie,
5685
+ addQuestionFromHtml: z,
5312
5686
  addQuestionFromJson: ae,
5313
- updateInlineImageSize: z,
5314
- getImageParagraphInfo: B,
5315
- updateImageAlignment: ce,
5316
- updateUnderlineWidth: le,
5317
- parseTextToParagraphs: V,
5318
- saveDocument: H,
5687
+ updateInlineImageSize: oe,
5688
+ getImageParagraphInfo: se,
5689
+ updateImageAlignment: U,
5690
+ updateUnderlineWidth: ce,
5691
+ parseTextToParagraphs: le,
5692
+ saveDocument: W,
5319
5693
  loadDocument: ue,
5320
- getBlockPlainText: In,
5321
- getBlockLabel: Ln,
5322
- getBlockAvailableWidth: An,
5323
- mergeSubQuestionGroup: R,
5324
- splitMergedBlock: oe
5694
+ getBlockPlainText: Wn,
5695
+ getBlockLabel: Gn,
5696
+ getBlockAvailableWidth: Rn,
5697
+ mergeSubQuestionGroup: B,
5698
+ splitMergedBlock: H
5325
5699
  };
5326
5700
  }
5327
- var zn = z;
5701
+ var qn = B;
5328
5702
  //#endregion
5329
5703
  //#region src/composables/usePaperCore.ts
5330
- function Bn(e = {}) {
5704
+ function Jn(e = {}) {
5331
5705
  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(() => {
5332
5706
  let e = 0, t = /* @__PURE__ */ new Set();
5333
5707
  for (let n of a.value) {
@@ -5342,7 +5716,7 @@ function Bn(e = {}) {
5342
5716
  a && (e += parseInt(a[1]));
5343
5717
  }
5344
5718
  return e;
5345
- }), y = bn(a), b = Rn({
5719
+ }), y = On(a), b = Kn({
5346
5720
  blocks: a,
5347
5721
  settings: s,
5348
5722
  pages: o,
@@ -5366,7 +5740,7 @@ function Bn(e = {}) {
5366
5740
  d.value = [];
5367
5741
  return;
5368
5742
  }
5369
- d.value = await Promise.all(Array.from({ length: t }, (t, n) => yn(e + String(n))));
5743
+ d.value = await Promise.all(Array.from({ length: t }, (t, n) => Dn(e + String(n))));
5370
5744
  }, { immediate: !0 });
5371
5745
  function x(e) {
5372
5746
  n.value = e, i.value.setRenderMode(e);
@@ -5471,8 +5845,8 @@ function Bn(e = {}) {
5471
5845
  }
5472
5846
  //#endregion
5473
5847
  //#region src/composables/usePageSvgRenderer.ts
5474
- 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>";
5475
- function Hn(e, n = {}) {
5848
+ var Yn = "<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>";
5849
+ function Xn(e, n = {}) {
5476
5850
  return t(() => {
5477
5851
  e.renderMode.value;
5478
5852
  let t = e.pages.value;
@@ -5488,13 +5862,13 @@ function Hn(e, n = {}) {
5488
5862
  qrCodeImage: e.qrCodeImage.value,
5489
5863
  qrCodeImages: e.qrCodeImages.value
5490
5864
  }, t.length);
5491
- 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>`;
5865
+ return `<svg xmlns="http://www.w3.org/2000/svg" width="${r * o}" height="${i * o}" viewBox="0 0 ${r} ${i}" class="paper-page">\n${Yn}\n${l}</svg>`;
5492
5866
  });
5493
5867
  });
5494
5868
  }
5495
5869
  //#endregion
5496
5870
  //#region src/composables/useTableRenderer.ts
5497
- async function Un(e, t, n = 2) {
5871
+ async function Zn(e, t, n = 2) {
5498
5872
  let r = [];
5499
5873
  for (let t = 0; t < e.length; t++) {
5500
5874
  let n = e[t];
@@ -5521,7 +5895,7 @@ async function Un(e, t, n = 2) {
5521
5895
  if (r.length !== 0) for (let i = 0; i < r.length; i++) {
5522
5896
  let a = r[i];
5523
5897
  try {
5524
- let r = await Wn(a.rawHtml, t, n);
5898
+ let r = await Qn(a.rawHtml, t, n);
5525
5899
  if (r) {
5526
5900
  let t = e[a.blockIdx].paragraphs[a.paraIdx].lines[a.lineIdx].elements[a.elemIdx];
5527
5901
  t.src = r, delete t.rawHtml;
@@ -5531,7 +5905,7 @@ async function Un(e, t, n = 2) {
5531
5905
  }
5532
5906
  }
5533
5907
  }
5534
- async function Wn(e, t, n) {
5908
+ async function Qn(e, t, n) {
5535
5909
  let r = document.createElement("div");
5536
5910
  r.innerHTML = e, r.style.position = "absolute", r.style.left = "-9999px", r.style.top = "0", r.style.width = "auto", r.style.height = "auto";
5537
5911
  let i = document.createElement("style");
@@ -5552,7 +5926,7 @@ async function Wn(e, t, n) {
5552
5926
  document.body.removeChild(r);
5553
5927
  }
5554
5928
  }
5555
- function Gn(e) {
5929
+ function $n(e) {
5556
5930
  for (let t of e) if (t.paragraphs) {
5557
5931
  for (let e of t.paragraphs) if (e.lines) {
5558
5932
  for (let t of e.lines) if (t.elements) {
@@ -5567,7 +5941,7 @@ function Gn(e) {
5567
5941
  }
5568
5942
  //#endregion
5569
5943
  //#region src/composables/usePaperCursor.ts
5570
- function Kn(e, t, n, r) {
5944
+ function er(e, t, n, r) {
5571
5945
  let i = f({
5572
5946
  blockId: null,
5573
5947
  paraIndex: 0,
@@ -5620,7 +5994,7 @@ function Kn(e, t, n, r) {
5620
5994
  }
5621
5995
  function d(e, t) {
5622
5996
  if (!e) return [];
5623
- 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;
5997
+ let n = e.split(""), r = H(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;
5624
5998
  return [{
5625
5999
  type: "text",
5626
6000
  value: e,
@@ -5635,7 +6009,7 @@ function Kn(e, t, n, r) {
5635
6009
  }];
5636
6010
  }
5637
6011
  function p(e) {
5638
- let n = Z(t.value), r = Q(t.value), i = wn(n, r);
6012
+ let n = Z(t.value), r = Q(t.value), i = Mn(n, r);
5639
6013
  return e.length === 0 || e.length === 1 && e[0].type === "enter" ? $(n, r) : {
5640
6014
  lines: [{
5641
6015
  elements: e,
@@ -5679,7 +6053,7 @@ function Kn(e, t, n, r) {
5679
6053
  else {
5680
6054
  let e = t - i, c = o.value.substring(0, e), l = o.value.substring(e);
5681
6055
  if (c) {
5682
- 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;
6056
+ let e = H(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;
5683
6057
  n.push({
5684
6058
  ...o,
5685
6059
  value: c,
@@ -5688,7 +6062,7 @@ function Kn(e, t, n, r) {
5688
6062
  });
5689
6063
  }
5690
6064
  if (l) {
5691
- 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;
6065
+ let e = H(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;
5692
6066
  r.push({
5693
6067
  ...o,
5694
6068
  value: l,
@@ -5698,7 +6072,7 @@ function Kn(e, t, n, r) {
5698
6072
  }
5699
6073
  i += s, a = !0;
5700
6074
  }
5701
- } else i <= t ? n.push(e) : (r.push(e), a = !0);
6075
+ } else i < t ? n.push(e) : (r.push(e), a = !0);
5702
6076
  }
5703
6077
  return [n, r];
5704
6078
  }
@@ -5731,7 +6105,7 @@ function Kn(e, t, n, r) {
5731
6105
  let e = r[a], n = e.value.substring(0, s) + e.value.substring(s + 1);
5732
6106
  for (let t = 0; t < r.length; t++) if (t === a) {
5733
6107
  if (n) {
5734
- 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;
6108
+ let t = H(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;
5735
6109
  c.push({
5736
6110
  ...e,
5737
6111
  value: n,
@@ -5769,7 +6143,7 @@ function Kn(e, t, n, r) {
5769
6143
  let e = n[i], r = e.value.substring(0, o) + e.value.substring(o + 1), a = [];
5770
6144
  for (let t = 0; t < n.length; t++) if (t === i) {
5771
6145
  if (r) {
5772
- 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;
6146
+ let t = H(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;
5773
6147
  a.push({
5774
6148
  ...e,
5775
6149
  value: r,
@@ -5826,11 +6200,15 @@ function Kn(e, t, n, r) {
5826
6200
  if (a.paragraphs.length <= 1) return !1;
5827
6201
  let o = Math.max(0, t.paraIndex - 1), c = s(a.paragraphs[o]), l = e.value.findIndex((e) => e.id === t.blockId);
5828
6202
  if (l === -1) return !1;
5829
- let u = a.paragraphs.filter((e, n) => n !== t.paraIndex);
6203
+ let u = a.paragraphs.filter((e, n) => n !== t.paraIndex), d = u.reduce((e, t) => e + (t.height || 26), 0);
5830
6204
  return e.value = e.value.map((e, t) => t === l ? {
5831
6205
  ...e,
5832
6206
  paragraphs: u,
5833
- height: u.reduce((e, t) => e + (t.height || 26), 0)
6207
+ height: d,
6208
+ metadata: {
6209
+ ...e.metadata,
6210
+ customHeight: d
6211
+ }
5834
6212
  } : e), i.value = {
5835
6213
  blockId: t.blockId,
5836
6214
  paraIndex: o,
@@ -5881,11 +6259,15 @@ function Kn(e, t, n, r) {
5881
6259
  if (a.paragraphs.length <= 1) return !1;
5882
6260
  let o = Math.min(t.paraIndex, a.paragraphs.length - 2), s = e.value.findIndex((e) => e.id === t.blockId);
5883
6261
  if (s === -1) return !1;
5884
- let c = a.paragraphs.filter((e, n) => n !== t.paraIndex);
6262
+ let c = a.paragraphs.filter((e, n) => n !== t.paraIndex), l = c.reduce((e, t) => e + (t.height || 26), 0);
5885
6263
  return e.value = e.value.map((e, t) => t === s ? {
5886
6264
  ...e,
5887
6265
  paragraphs: c,
5888
- height: c.reduce((e, t) => e + (t.height || 26), 0)
6266
+ height: l,
6267
+ metadata: {
6268
+ ...e.metadata,
6269
+ customHeight: l
6270
+ }
5889
6271
  } : e), i.value = {
5890
6272
  blockId: t.blockId,
5891
6273
  paraIndex: o,
@@ -6037,13 +6419,13 @@ function Kn(e, t, n, r) {
6037
6419
  }
6038
6420
  //#endregion
6039
6421
  //#region src/components/PaperEditor.vue?vue&type=script&setup=true&lang.ts
6040
- 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 = {
6422
+ var tr = { class: "pe-root" }, nr = { class: "pe-main" }, rr = { class: "pe-editor" }, ir = { class: "pe-editor-pages" }, ar = ["onClick"], or = ["innerHTML"], sr = { class: "pe-editor-controllers" }, cr = {
6041
6423
  key: 0,
6042
6424
  class: "pe-ctrl-sub"
6043
- }, tr = {
6425
+ }, lr = {
6044
6426
  key: 1,
6045
6427
  class: "pe-ctrl-sub"
6046
- }, nr = /*@__PURE__*/ a({
6428
+ }, ur = /*@__PURE__*/ a({
6047
6429
  __name: "PaperEditor",
6048
6430
  props: {
6049
6431
  initialData: {},
@@ -6064,7 +6446,7 @@ var qn = { class: "pe-root" }, Jn = { class: "pe-main" }, Yn = { class: "pe-edit
6064
6446
  "loaded"
6065
6447
  ],
6066
6448
  setup(a, { expose: m, emit: h }) {
6067
- let x = a, S = h, C = Bn({ renderMode: x.renderMode }), w = Kn(C.blocks, C.settings, () => {
6449
+ let x = a, S = h, C = Jn({ renderMode: x.renderMode }), w = er(C.blocks, C.settings, () => {
6068
6450
  C.reflowAllBlocks(), o(() => k.value?.focus());
6069
6451
  }, () => {
6070
6452
  C.isDirty.value = !0;
@@ -6083,7 +6465,7 @@ var qn = { class: "pe-root" }, Jn = { class: "pe-main" }, Yn = { class: "pe-edit
6083
6465
  top: j.value.top + "px",
6084
6466
  height: j.value.height + "px",
6085
6467
  transform: "skewX(0deg)"
6086
- })), N = Hn(C, {
6468
+ })), N = Xn(C, {
6087
6469
  zoom: T,
6088
6470
  selectedBlockId: C.selectedBlockId
6089
6471
  });
@@ -6137,7 +6519,7 @@ var qn = { class: "pe-root" }, Jn = { class: "pe-main" }, Yn = { class: "pe-edit
6137
6519
  });
6138
6520
  });
6139
6521
  }
6140
- function re(e, t, n, r) {
6522
+ function R(e, t, n, r) {
6141
6523
  let i = C.blocks.value.find((t) => t.id === e);
6142
6524
  if (!i || !n) return;
6143
6525
  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];
@@ -6156,66 +6538,94 @@ var qn = { class: "pe-root" }, Jn = { class: "pe-main" }, Yn = { class: "pe-edit
6156
6538
  i < e && (e = i, f = t);
6157
6539
  }
6158
6540
  }
6159
- let p = (i.metadata?.questionNo?.length || 0) > 2 || i.type === "sub-question" ? 26.25 : 17.5, m = C.settings.value.margins[3] ?? 56, h = s - (d + f.y), g = f.paragraphStart, _ = Math.min(g + f.paragraphCount, i.paragraphs.length), v = [];
6160
- for (let e = g; e < _; e++) v.push(e);
6161
- let y = 0, b = -1;
6162
- for (let e of v) {
6163
- let t = i.paragraphs[e].height || 26;
6164
- if (h >= y - 2 && h < y + t + 2) {
6165
- b = e;
6166
- break;
6541
+ let p = C.settings.value.margins[3] ?? 56, m = t.target, h = m.closest(".swed-paragraph");
6542
+ if (!h) {
6543
+ let e = m.closest(".swed-option-item");
6544
+ e && (h = e.querySelector(".swed-paragraph"));
6545
+ }
6546
+ if (!h) return;
6547
+ let g = h.getAttribute("data-para");
6548
+ if (g === null) return;
6549
+ let _ = parseInt(g, 10);
6550
+ if (isNaN(_) || _ >= i.paragraphs.length) return;
6551
+ let v = 0, y = 0, b = h;
6552
+ for (; b && b.getAttribute("class") !== "swed-question";) {
6553
+ let e = b.getAttribute("transform");
6554
+ if (e) {
6555
+ let t = e.match(/translate\(([\d.]+),\s*([\d.]+)\)/);
6556
+ t && (v += parseFloat(t[1]), y += parseFloat(t[2]));
6167
6557
  }
6168
- y += t;
6558
+ b = b.parentElement;
6169
6559
  }
6170
- b === -1 && (b = v[v.length - 1] ?? g);
6171
- 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;
6560
+ let x = i.paragraphs[_], S = 0, k = f.x + v, M = w.getTextStyle(x).fontSize, ee = (x.lines[0]?.lineHeight || x.height || 21) * .5, N = f.y + y + ee, P = M;
6172
6561
  if (!w.isEmptyParagraph(x)) {
6173
- let e = o - m - f.x - p, t = h - y, n = 0, r = -1;
6174
- for (let e = 0; e < x.lines.length; e++) {
6175
- let i = x.lines[e].lineHeight || 20;
6176
- if (t >= n - 2 && t < n + i + 2) {
6177
- r = e;
6178
- break;
6562
+ let e = m.closest(".swed-text, .swed-image, .swed-formula"), t = m.closest(".swed-line");
6563
+ if (e) try {
6564
+ let n = e.getBBox(), r = 0;
6565
+ if (e.classList.contains("swed-text")) {
6566
+ let t = Array.from(h.querySelectorAll(".swed-text"));
6567
+ for (let n of t) {
6568
+ if (n === e) break;
6569
+ r += (n.textContent || "").length;
6570
+ }
6179
6571
  }
6180
- n += i;
6181
- }
6182
- r === -1 && (r = x.lines.length - 1, n = x.lines.reduce((e, t, n) => n < r ? e + (t.lineHeight || 20) : e, 0));
6183
- let a = 0;
6184
- for (let e = 0; e < r; e++) for (let t of x.lines[e].elements) t.type === "text" && (a += t.value.length);
6185
- let s = x.lines[r], c = s.offsetX || 0, l = 0;
6186
- if (f.paragraphStart === 0 && i.metadata?.score && r === 0 && b === (v[0] ?? 0)) {
6187
- let e = C.settings.value.fontSize, t = typeof e == "number" ? e : 14;
6188
- l = se(`(${i.metadata.score}分)`, t, "SimSun, STSong, serif");
6189
- }
6190
- let u = l, d = !1;
6191
- for (let t of s.elements) {
6192
- if (t.type === "text") {
6193
- let r = t.xPositions;
6194
- for (let i = 0; i < t.value.length; i++) {
6195
- let o = u + c + r[i];
6196
- if (e < o + (i < r.length - 1 ? r[i + 1] - r[i] : t.width - r[i]) / 2) {
6197
- S = a, k = f.x + p + o, N = f.y + y + n + s.lineHeight * .5, P = M, d = !0;
6572
+ let i = o - p - f.x - v, a = n.x + n.width * .5, s = e.classList.contains("swed-text") ? (e.textContent || "").length : 1;
6573
+ i > a ? (S = r + s, k = f.x + v + n.x + n.width) : (S = r, k = f.x + v + n.x);
6574
+ let c = t || e.closest(".swed-line");
6575
+ if (c) {
6576
+ let e = c.getAttribute("transform")?.match(/translate\([^,]+,\s*([\d.]+)\)/), t = e ? parseFloat(e[1]) : 0, n = x.lines[0]?.lineHeight || M;
6577
+ N = f.y + y + t + n * .5;
6578
+ } else N = f.y + y + n.y + n.height * .5;
6579
+ P = M;
6580
+ } catch {}
6581
+ else {
6582
+ let e = o - p - f.x - v, t = s - (d + f.y) - y, n = 0, r = -1;
6583
+ for (let e = 0; e < x.lines.length; e++) {
6584
+ let i = x.lines[e].lineHeight || 20;
6585
+ if (t >= n - 2 && t < n + i + 2) {
6586
+ r = e;
6587
+ break;
6588
+ }
6589
+ n += i;
6590
+ }
6591
+ r === -1 && (r = x.lines.length - 1, n = x.lines.reduce((e, t, n) => n < r ? e + (t.lineHeight || 20) : e, 0));
6592
+ let i = 0;
6593
+ for (let e = 0; e < r; e++) for (let t of x.lines[e].elements) t.type === "text" && !t.isLabel && (i += t.value.length);
6594
+ let a = x.lines[r], c = a.offsetX || 0, l = parseFloat(h.getAttribute("data-score-width") || "0"), u = !1;
6595
+ for (let t of a.elements) if (!(t.type === "text" && t.isLabel)) {
6596
+ if (t.type === "text" && !t.isLabel) {
6597
+ let r = t.xPositions;
6598
+ for (let o = 0; o < t.value.length; o++) {
6599
+ let s = l + c + r[o];
6600
+ if (e < s + (o < r.length - 1 ? r[o + 1] - r[o] : t.width - r[o]) / 2) {
6601
+ S = i, k = f.x + v + s, N = f.y + y + n + a.lineHeight * .5, P = M, u = !0;
6602
+ break;
6603
+ }
6604
+ i++;
6605
+ }
6606
+ l += t.width;
6607
+ } else {
6608
+ let r = t.width || 12;
6609
+ if (e < l + c + r / 2) {
6610
+ S = i, k = f.x + v + l + c, N = f.y + y + n + a.lineHeight * .5, P = M, u = !0;
6198
6611
  break;
6199
6612
  }
6200
- a++;
6613
+ l += r;
6201
6614
  }
6202
- u += t.width;
6203
- } else {
6204
- let r = t.width || 12;
6205
- if (e < u + c + r / 2) {
6206
- S = a, k = f.x + p + u + c, N = f.y + y + n + s.lineHeight * .5, P = M, d = !0;
6207
- break;
6208
- }
6209
- u += r;
6615
+ if (u) break;
6616
+ }
6617
+ if (!u) {
6618
+ let e = a.elements.length > 0 ? 4 : 0;
6619
+ S = i, k = f.x + v + l + c - e, N = f.y + y + n + a.lineHeight * .5, P = M;
6210
6620
  }
6211
- if (d) break;
6212
6621
  }
6213
- d || (S = a, k = f.x + p + u + c, N = f.y + y + n + s.lineHeight * .5, P = M);
6214
6622
  }
6215
- w.setCursor(e, b, S);
6623
+ if (x) for (let e of x.lines[0]?.elements || []) if (e.type === "text" && e.isLabel) S += e.value.length;
6624
+ else break;
6625
+ w.setCursor(e, _, S);
6216
6626
  let F = O.value, te = document.querySelectorAll(".pe-editor-page")[c]?.querySelector("svg.paper-page");
6217
6627
  if (F && te && l) {
6218
- 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;
6628
+ let e = te.getBoundingClientRect(), t = F.getBoundingClientRect(), n = l.width, r = l.height, i = k + p, 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;
6219
6629
  j.value = {
6220
6630
  left: o,
6221
6631
  top: s,
@@ -6226,7 +6636,7 @@ var qn = { class: "pe-root" }, Jn = { class: "pe-main" }, Yn = { class: "pe-edit
6226
6636
  }, D.value = !0;
6227
6637
  }
6228
6638
  }
6229
- function ie(e) {
6639
+ function re(e) {
6230
6640
  let t = e.target, n = e.currentTarget, r = n.closest(".pe-editor-page"), i = E.value;
6231
6641
  if (r) {
6232
6642
  let e = r.parentElement?.querySelectorAll(":scope > .pe-editor-page");
@@ -6254,7 +6664,7 @@ var qn = { class: "pe-root" }, Jn = { class: "pe-main" }, Yn = { class: "pe-edit
6254
6664
  if (c) {
6255
6665
  let t = c.getAttribute("data-block-id");
6256
6666
  if (t) {
6257
- C.selectBlock(t), n && re(t, e, n, i), o(() => k.value?.focus());
6667
+ C.selectBlock(t), n && R(t, e, n, i), o(() => k.value?.focus());
6258
6668
  let r = C.blocks.value.find((e) => e.id === t);
6259
6669
  r && S("block-click", {
6260
6670
  blockId: t,
@@ -6263,18 +6673,18 @@ var qn = { class: "pe-root" }, Jn = { class: "pe-main" }, Yn = { class: "pe-edit
6263
6673
  }
6264
6674
  } else C.selectBlock(null), C.selectUnderline(null), C.selectImage(null), D.value = !1, w.clearCursor(), S("empty-click");
6265
6675
  }
6266
- function ae(e) {
6676
+ function ie(e) {
6267
6677
  let t = e.target;
6268
6678
  if (!t) return;
6269
6679
  let n = t.getAttribute("data-editable");
6270
6680
  n && (C.saveUndoSnapshot(), n === "schoolName" ? C.schoolName.value = t.innerHTML : n === "paperName" && (C.paperName.value = t.textContent || ""));
6271
6681
  }
6272
- let R = f(null), oe = t(() => R.value ? {
6682
+ let z = f(null), ae = t(() => z.value ? {
6273
6683
  position: "absolute",
6274
- left: R.value.left + "px",
6275
- top: R.value.top + "px",
6276
- width: R.value.width + "px",
6277
- height: R.value.height + "px",
6684
+ left: z.value.left + "px",
6685
+ top: z.value.top + "px",
6686
+ width: z.value.width + "px",
6687
+ height: z.value.height + "px",
6278
6688
  pointerEvents: "none",
6279
6689
  border: "1.5px solid #409eff",
6280
6690
  borderRadius: "2px",
@@ -6283,172 +6693,172 @@ var qn = { class: "pe-root" }, Jn = { class: "pe-main" }, Yn = { class: "pe-edit
6283
6693
  display: "none",
6284
6694
  position: "absolute"
6285
6695
  });
6286
- function z() {
6696
+ function B() {
6287
6697
  let e = C.selectedBlockId.value;
6288
6698
  if (!e) {
6289
- R.value = null;
6699
+ z.value = null;
6290
6700
  return;
6291
6701
  }
6292
6702
  let t = C.blocks.value.find((t) => t.id === e);
6293
6703
  if (!t || t.type === "title") {
6294
- R.value = null;
6704
+ z.value = null;
6295
6705
  return;
6296
6706
  }
6297
6707
  let n = document.querySelector(".pe-editor-page.active");
6298
6708
  if (!n) {
6299
- R.value = null;
6709
+ z.value = null;
6300
6710
  return;
6301
6711
  }
6302
6712
  let r = n.querySelector("svg.paper-page");
6303
6713
  if (!r) {
6304
- R.value = null;
6714
+ z.value = null;
6305
6715
  return;
6306
6716
  }
6307
6717
  let i = C.pages.value.find((e) => e.index === E.value);
6308
6718
  if (!i) {
6309
- R.value = null;
6719
+ z.value = null;
6310
6720
  return;
6311
6721
  }
6312
6722
  let a = i.blocks.find((t) => t.blockId === e);
6313
6723
  if (!a) {
6314
- R.value = null;
6724
+ z.value = null;
6315
6725
  return;
6316
6726
  }
6317
6727
  let o = n.closest(".pe-editor-surface");
6318
6728
  if (!o) {
6319
- R.value = null;
6729
+ z.value = null;
6320
6730
  return;
6321
6731
  }
6322
6732
  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();
6323
- R.value = {
6733
+ z.value = {
6324
6734
  left: f.left - p.left + o.scrollLeft + u / s * f.width,
6325
6735
  top: f.top - p.top + o.scrollTop + d / c * f.height,
6326
6736
  width: a.width / s * f.width,
6327
6737
  height: a.height / c * f.height
6328
6738
  };
6329
6739
  }
6330
- let B = t(() => {
6740
+ let V = t(() => {
6331
6741
  let e = C.selectedBlockId.value;
6332
6742
  return e && C.blocks.value.find((t) => t.id === e)?.metadata?.blockGroup || "";
6333
- }), ce = t(() => {
6743
+ }), H = t(() => {
6334
6744
  let e = C.selectedBlockId.value;
6335
6745
  return e ? !!C.blocks.value.find((t) => t.id === e)?.metadata?._splitBackup : !1;
6336
6746
  });
6337
- function le() {
6338
- let e = B.value;
6747
+ function oe() {
6748
+ let e = V.value;
6339
6749
  e && (C.mergeSubQuestionGroup(e), S("change"));
6340
6750
  }
6341
- function V() {
6751
+ function se() {
6342
6752
  let e = C.selectedBlockId.value;
6343
6753
  e && (C.splitMergedBlock(e), S("change"));
6344
6754
  }
6345
- let H = f(null), ue = t(() => H.value ? {
6755
+ let U = f(null), ce = t(() => U.value ? {
6346
6756
  position: "absolute",
6347
- left: H.value.left + "px",
6348
- top: H.value.top + "px",
6349
- width: H.value.width + "px",
6350
- height: H.value.height + "px",
6757
+ left: U.value.left + "px",
6758
+ top: U.value.top + "px",
6759
+ width: U.value.width + "px",
6760
+ height: U.value.height + "px",
6351
6761
  pointerEvents: "auto"
6352
6762
  } : {
6353
6763
  display: "none",
6354
6764
  position: "absolute"
6355
6765
  });
6356
- function de() {
6766
+ function le() {
6357
6767
  let e = C.selectedUnderlineId.value;
6358
6768
  if (!e) {
6359
- H.value = null;
6769
+ U.value = null;
6360
6770
  return;
6361
6771
  }
6362
6772
  let t = document.querySelector(".pe-editor-page.active");
6363
6773
  if (!t) {
6364
- H.value = null;
6774
+ U.value = null;
6365
6775
  return;
6366
6776
  }
6367
6777
  let n = t.querySelector(`[data-underline-id="${CSS.escape(e)}"]`);
6368
6778
  if (!n) {
6369
- H.value = null;
6779
+ U.value = null;
6370
6780
  return;
6371
6781
  }
6372
6782
  let r = t.closest(".pe-editor-surface");
6373
6783
  if (!r) {
6374
- H.value = null;
6784
+ U.value = null;
6375
6785
  return;
6376
6786
  }
6377
6787
  let i = n.getBoundingClientRect(), a = r.getBoundingClientRect();
6378
- H.value = {
6788
+ U.value = {
6379
6789
  left: i.left - a.left + r.scrollLeft,
6380
6790
  top: i.top - a.top + r.scrollTop,
6381
6791
  width: i.width,
6382
6792
  height: i.height
6383
6793
  };
6384
6794
  }
6385
- let U = f(null), fe = t(() => U.value ? {
6795
+ let W = f(null), ue = t(() => W.value ? {
6386
6796
  position: "absolute",
6387
- left: U.value.left + "px",
6388
- top: U.value.top + "px",
6389
- width: U.value.width + "px",
6390
- height: U.value.height + "px",
6797
+ left: W.value.left + "px",
6798
+ top: W.value.top + "px",
6799
+ width: W.value.width + "px",
6800
+ height: W.value.height + "px",
6391
6801
  pointerEvents: "auto"
6392
6802
  } : {
6393
6803
  display: "none",
6394
6804
  position: "absolute"
6395
6805
  });
6396
- function pe() {
6806
+ function de() {
6397
6807
  let e = C.selectedImageId.value;
6398
6808
  if (!e) {
6399
- U.value = null;
6809
+ W.value = null;
6400
6810
  return;
6401
6811
  }
6402
6812
  let t = document.querySelector(".pe-editor-page.active");
6403
6813
  if (!t) {
6404
- U.value = null;
6814
+ W.value = null;
6405
6815
  return;
6406
6816
  }
6407
6817
  let n = t.querySelector(`[data-image-id="${CSS.escape(e)}"]`);
6408
6818
  if (!n) {
6409
- U.value = null;
6819
+ W.value = null;
6410
6820
  return;
6411
6821
  }
6412
6822
  let r = n.querySelector("image") || n, i = t.closest(".pe-editor-surface");
6413
6823
  if (!i) {
6414
- U.value = null;
6824
+ W.value = null;
6415
6825
  return;
6416
6826
  }
6417
6827
  let a = r.getBoundingClientRect(), o = i.getBoundingClientRect();
6418
- U.value = {
6828
+ W.value = {
6419
6829
  left: a.left - o.left + i.scrollLeft,
6420
6830
  top: a.top - o.top + i.scrollTop,
6421
6831
  width: a.width,
6422
6832
  height: a.height
6423
6833
  };
6424
6834
  }
6425
- let me = t(() => C.selectedImageId.value ? C.getImageParagraphInfo(C.selectedImageId.value) : null), he = t(() => !!(me.value?.isStandalone && U.value)), ge = t(() => U.value ? {
6426
- left: U.value.left + "px",
6427
- top: U.value.top + U.value.height + 4 + "px",
6835
+ let fe = t(() => C.selectedImageId.value ? C.getImageParagraphInfo(C.selectedImageId.value) : null), pe = t(() => !!(fe.value?.isStandalone && W.value)), me = t(() => W.value ? {
6836
+ left: W.value.left + "px",
6837
+ top: W.value.top + W.value.height + 4 + "px",
6428
6838
  pointerEvents: "auto"
6429
6839
  } : null);
6430
- function _e(e) {
6840
+ function he(e) {
6431
6841
  let t = C.selectedImageId.value;
6432
- t && (C.updateImageAlignment(t, e), o(() => W()));
6842
+ t && (C.updateImageAlignment(t, e), o(() => G()));
6433
6843
  }
6434
- let ve = 0;
6435
- function W() {
6436
- ve && cancelAnimationFrame(ve), ve = requestAnimationFrame(() => {
6437
- ve = 0, z(), de(), pe();
6844
+ let ge = 0;
6845
+ function G() {
6846
+ ge && cancelAnimationFrame(ge), ge = requestAnimationFrame(() => {
6847
+ ge = 0, B(), le(), de();
6438
6848
  });
6439
6849
  }
6440
6850
  v(() => C.selectedBlockId.value, async () => {
6441
- await o(), W();
6851
+ await o(), G();
6442
6852
  }), v(() => T.value, async () => {
6443
- await o(), W();
6853
+ await o(), G();
6444
6854
  }), v(() => E.value, async () => {
6445
- await o(), W(), S("page-change", E.value);
6855
+ await o(), G(), S("page-change", E.value);
6446
6856
  }), v(() => C.layoutVersion.value, () => {
6447
- L(), o(() => W());
6857
+ L(), o(() => G());
6448
6858
  }), v(() => C.selectedUnderlineId.value, async () => {
6449
- await o(), W();
6859
+ await o(), G();
6450
6860
  }), v(() => C.selectedImageId.value, async () => {
6451
- await o(), W();
6861
+ await o(), G();
6452
6862
  }), v(() => [
6453
6863
  C.paperName.value,
6454
6864
  C.schoolName.value,
@@ -6456,62 +6866,62 @@ var qn = { class: "pe-root" }, Jn = { class: "pe-main" }, Yn = { class: "pe-edit
6456
6866
  ], () => {
6457
6867
  L();
6458
6868
  });
6459
- let ye = f(!1), be = f(null), xe = f(0), Se = f(0);
6460
- function G(e) {
6869
+ let _e = f(!1), ve = f(null), ye = f(0), be = f(0);
6870
+ function xe(e) {
6461
6871
  let t = C.selectedBlockId.value;
6462
6872
  if (!t) return;
6463
6873
  let n = C.blocks.value.find((e) => e.id === t);
6464
- 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));
6874
+ n && (e.stopPropagation(), _e.value = !0, ve.value = t, ye.value = e.clientY, be.value = n.height, document.body.style.cursor = "ns-resize", document.body.style.userSelect = "none", document.addEventListener("mousemove", Se), document.addEventListener("mouseup", K));
6465
6875
  }
6466
- function Ce(e) {
6467
- if (!ye.value || !be.value) return;
6468
- let t = (e.clientY - xe.value) / T.value;
6469
- C.updateBlockHeight(be.value, Se.value + t), o(() => z());
6876
+ function Se(e) {
6877
+ if (!_e.value || !ve.value) return;
6878
+ let t = (e.clientY - ye.value) / T.value;
6879
+ C.updateBlockHeight(ve.value, be.value + t), o(() => B());
6470
6880
  }
6471
- function we(e) {
6472
- ye.value = !1, be.value = null, document.body.style.cursor = "", document.body.style.userSelect = "", document.removeEventListener("mousemove", Ce), document.removeEventListener("mouseup", we), L();
6881
+ function K(e) {
6882
+ _e.value = !1, ve.value = null, document.body.style.cursor = "", document.body.style.userSelect = "", document.removeEventListener("mousemove", Se), document.removeEventListener("mouseup", K), L();
6473
6883
  }
6474
- let Te = f(!1), Ee = f(null), De = f(0), Oe = f(0);
6475
- function ke(e, t) {
6884
+ let Ce = f(!1), we = f(null), Te = f(0), Ee = f(0);
6885
+ function De(e, t) {
6476
6886
  let n = C.selectedUnderlineId.value;
6477
6887
  if (!n) return;
6478
6888
  let r = C.findUnderlineById(n);
6479
- r && (t.stopPropagation(), Te.value = !0, Ee.value = e, De.value = t.clientX, Oe.value = r.underline.width, document.body.style.cursor = "ew-resize", document.body.style.userSelect = "none", document.addEventListener("mousemove", K), document.addEventListener("mouseup", Ae));
6889
+ r && (t.stopPropagation(), Ce.value = !0, we.value = e, Te.value = t.clientX, Ee.value = r.underline.width, document.body.style.cursor = "ew-resize", document.body.style.userSelect = "none", document.addEventListener("mousemove", Oe), document.addEventListener("mouseup", ke));
6480
6890
  }
6481
- function K(e) {
6482
- if (!Te.value || !Ee.value) return;
6891
+ function Oe(e) {
6892
+ if (!Ce.value || !we.value) return;
6483
6893
  let t = C.selectedUnderlineId.value;
6484
6894
  if (!t) return;
6485
- let n = (e.clientX - De.value) / T.value, r = Ee.value === "right" ? n : -n;
6486
- C.updateUnderlineWidth(t, Oe.value + r), o(() => de());
6895
+ let n = (e.clientX - Te.value) / T.value, r = we.value === "right" ? n : -n;
6896
+ C.updateUnderlineWidth(t, Ee.value + r), o(() => le());
6487
6897
  }
6488
- function Ae(e) {
6489
- Te.value = !1, Ee.value = null, document.body.style.cursor = "", document.body.style.userSelect = "", document.removeEventListener("mousemove", K), document.removeEventListener("mouseup", Ae), L();
6898
+ function ke(e) {
6899
+ Ce.value = !1, we.value = null, document.body.style.cursor = "", document.body.style.userSelect = "", document.removeEventListener("mousemove", Oe), document.removeEventListener("mouseup", ke), L();
6490
6900
  }
6491
- let je = f(!1), Me = f(null), Ne = f(0), Pe = f(0), Fe = f(0), Ie = f(0);
6492
- function Le(e, t) {
6901
+ let q = f(!1), Ae = f(null), je = f(0), Me = f(0), Ne = f(0), Pe = f(0);
6902
+ function Fe(e, t) {
6493
6903
  if (t.button !== 0) return;
6494
6904
  let n = C.selectedImageId.value;
6495
6905
  if (!n) return;
6496
6906
  let r = C.findInlineImageById(n);
6497
- r && (t.stopPropagation(), je.value = !0, Me.value = e, Ne.value = t.clientX, Pe.value = t.clientY, Fe.value = r.image.width, Ie.value = r.image.height, document.body.style.userSelect = "none", document.addEventListener("mousemove", Re), document.addEventListener("mouseup", q));
6907
+ r && (t.stopPropagation(), q.value = !0, Ae.value = e, je.value = t.clientX, Me.value = t.clientY, Ne.value = r.image.width, Pe.value = r.image.height, document.body.style.userSelect = "none", document.addEventListener("mousemove", Ie), document.addEventListener("mouseup", Le));
6498
6908
  }
6499
- function Re(e) {
6500
- if (!je.value || !Me.value) return;
6909
+ function Ie(e) {
6910
+ if (!q.value || !Ae.value) return;
6501
6911
  let t = C.selectedImageId.value;
6502
6912
  if (!t) return;
6503
- let n = (e.clientX - Ne.value) / T.value, r = Me.value, i = Fe.value;
6913
+ let n = (e.clientX - je.value) / T.value, r = Ae.value, i = Ne.value;
6504
6914
  if (r.includes("e") ? i += n : r.includes("w") && (i -= n), !C.findInlineImageById(t)) return;
6505
- let a = Ie.value / Math.max(1, Fe.value), s = Math.max(12, Math.round(i * a));
6506
- C.updateInlineImageSize(t, i, s), o(() => pe());
6915
+ let a = Pe.value / Math.max(1, Ne.value), s = Math.max(12, Math.round(i * a));
6916
+ C.updateInlineImageSize(t, i, s), o(() => de());
6507
6917
  }
6508
- function q(e) {
6509
- je.value = !1, Me.value = null, document.body.style.userSelect = "", document.removeEventListener("mousemove", Re), document.removeEventListener("mouseup", q), L();
6918
+ function Le(e) {
6919
+ q.value = !1, Ae.value = null, document.body.style.userSelect = "", document.removeEventListener("mousemove", Ie), document.removeEventListener("mouseup", Le), L();
6510
6920
  }
6511
- function ze(e) {
6921
+ function Re(e) {
6512
6922
  C.loadDocument(e), L(), S("loaded"), S("change");
6513
6923
  }
6514
- function Be(e) {
6924
+ function ze(e) {
6515
6925
  let t = -1;
6516
6926
  for (let n = 0; n < C.pages.value.length; n++) if (C.pages.value[n].blocks.some((t) => t.blockId === e)) {
6517
6927
  t = n;
@@ -6525,7 +6935,7 @@ var qn = { class: "pe-root" }, Jn = { class: "pe-main" }, Yn = { class: "pe-edit
6525
6935
  }
6526
6936
  }));
6527
6937
  }
6528
- let Ve = f(!1);
6938
+ let Be = f(!1);
6529
6939
  function J() {
6530
6940
  let e = w.cursor.value;
6531
6941
  if (!e.blockId) return;
@@ -6548,63 +6958,73 @@ var qn = { class: "pe-root" }, Jn = { class: "pe-main" }, Yn = { class: "pe-edit
6548
6958
  }
6549
6959
  if (a || (i = C.pages.value[E.value], a = i?.blocks.find((e) => e.blockId === t), o = E.value % 2 == 0 ? C.settings.value.bodyTopEven ?? 173 : C.settings.value.bodyTopOdd ?? 50, c = E.value), !a || !i) return;
6550
6960
  c !== E.value && (E.value = c);
6551
- let l = (e.metadata?.questionNo?.length || 0) > 2 || e.type === "sub-question" ? 26.25 : 17.5, u = a.paragraphStart, d = Math.min(u + a.paragraphCount, e.paragraphs.length), f = [];
6552
- for (let e = u; e < d; e++) f.push(e);
6553
- let p = 0;
6554
- for (let t of f) {
6555
- if (t === n) break;
6556
- p += e.paragraphs[t].height || 26;
6557
- }
6558
- let m = e.paragraphs[n];
6559
- if (!m) return;
6560
- let h = w.getTextStyle(m).fontSize, g = m.lines[0]?.lineHeight || m.height || 21, _ = a.x + l, v = a.y + p + g * .5, y = h;
6561
- if (!w.isEmptyParagraph(m)) {
6562
- let t = 0, i = 0;
6563
- for (let e = 0; e < m.lines.length; e++) {
6564
- let n = 0;
6565
- for (let t of m.lines[e].elements) t.type === "text" && (n += t.value.length);
6566
- if (t + n >= r) {
6567
- i = e;
6568
- break;
6569
- }
6570
- t += n, e === m.lines.length - 1 && (i = e);
6961
+ let l = document.querySelectorAll(".pe-editor-page")[c]?.querySelector("svg.paper-page");
6962
+ if (!l) return;
6963
+ let u = Array.from(l.querySelectorAll(`[data-block-id="${t}"]`)), d = null;
6964
+ for (let e of u) {
6965
+ let t = e.querySelector(`[data-para="${n}"]`);
6966
+ if (t) {
6967
+ d = t;
6968
+ break;
6571
6969
  }
6572
- let o = 0;
6573
- for (let e = 0; e < i; e++) o += m.lines[e].lineHeight || 20;
6574
- let s = m.lines[i], c = s.offsetX || 0, u = 0;
6575
- if (a.paragraphStart === 0 && e.metadata?.score && i === 0 && n === (f[0] ?? 0)) {
6576
- let t = C.settings.value.fontSize, n = typeof t == "number" ? t : 14;
6577
- u = se(`(${e.metadata.score}分)`, n, "SimSun, STSong, serif");
6970
+ }
6971
+ if (!d) return;
6972
+ let f = 0, p = 0, m = d;
6973
+ for (; m && m.getAttribute("class") !== "swed-question";) {
6974
+ let e = m.getAttribute("transform");
6975
+ if (e) {
6976
+ let t = e.match(/translate\(([\d.]+),\s*([\d.]+)\)/);
6977
+ t && (f += parseFloat(t[1]), p += parseFloat(t[2]));
6578
6978
  }
6579
- let d = u, h = !1;
6580
- for (let e of s.elements) {
6581
- if (t >= r) {
6582
- _ = a.x + l + d + c, v = a.y + p + o + s.lineHeight * .5, h = !0;
6979
+ m = m.parentElement;
6980
+ }
6981
+ let h = e.paragraphs[n];
6982
+ if (!h) return;
6983
+ let g = w.getTextStyle(h).fontSize, _ = h.lines[0]?.lineHeight || h.height || 21, v = a.x + f, y = a.y + p + _ * .5, b = g;
6984
+ if (!w.isEmptyParagraph(h)) {
6985
+ let e = 0;
6986
+ for (let t of h?.lines[0]?.elements || []) if (t.type === "text" && t.isLabel) e += t.value.length;
6987
+ else break;
6988
+ let t = r - e, n = 0, i = !1, o = Array.from(d.querySelectorAll(".swed-text"));
6989
+ for (let e of o) {
6990
+ let r = (e.textContent || "").length;
6991
+ if (n + r > t) {
6992
+ i = !0;
6993
+ try {
6994
+ let t = e.getBBox();
6995
+ v = a.x + f + t.x;
6996
+ let n = e.closest(".swed-line");
6997
+ if (n) {
6998
+ let e = n.getAttribute("transform")?.match(/translate\([^,]+,\s*([\d.]+)\)/), t = e ? parseFloat(e[1]) : 0, r = h.lines[0]?.lineHeight || g;
6999
+ y = a.y + p + t + r * .5;
7000
+ }
7001
+ b = g;
7002
+ } catch {}
6583
7003
  break;
6584
7004
  }
6585
- if (e.type === "text") {
6586
- let n = e.xPositions;
6587
- for (let i = 0; i < e.value.length; i++) {
6588
- if (t === r) {
6589
- let e = d + c + n[i];
6590
- _ = a.x + l + e, v = a.y + p + o + s.lineHeight * .5, h = !0;
6591
- break;
6592
- }
6593
- t++;
7005
+ n += r;
7006
+ }
7007
+ if (!i && o.length > 0) {
7008
+ let e = o[o.length - 1];
7009
+ try {
7010
+ let t = e.getBBox();
7011
+ v = a.x + f + t.x + t.width;
7012
+ let n = e.closest(".swed-line");
7013
+ if (n) {
7014
+ let e = n.getAttribute("transform")?.match(/translate\([^,]+,\s*([\d.]+)\)/), t = e ? parseFloat(e[1]) : 0, r = h.lines[0]?.lineHeight || g;
7015
+ y = a.y + p + t + r * .5;
6594
7016
  }
6595
- if (h) break;
6596
- d += e.width;
6597
- } else d += e.width || 12;
7017
+ b = g;
7018
+ } catch {}
6598
7019
  }
6599
- h || (_ = a.x + l + d + c, v = a.y + p + o + s.lineHeight * .5);
6600
7020
  }
6601
- let b = O.value, x = document.querySelectorAll(".pe-editor-page")[c]?.querySelector("svg.paper-page");
6602
- if (b && x && i) {
6603
- let e = x.getBoundingClientRect(), t = b.getBoundingClientRect(), n = i.width, r = i.height, a = _ + s, c = v + o, l = e.left - t.left + b.scrollLeft + a / n * e.width, u = e.top - t.top + b.scrollTop + c / r * e.height;
7021
+ let x = O.value, S = document.querySelectorAll(".pe-editor-page")[c]?.querySelector("svg.paper-page");
7022
+ if (x && S && i) {
7023
+ let e = S.getBoundingClientRect(), t = x.getBoundingClientRect(), n = i.width, r = i.height, a = v + s, c = y + o, l = e.left - t.left + x.scrollLeft + a / n * e.width, u = e.top - t.top + x.scrollTop + c / r * e.height;
6604
7024
  j.value = {
6605
7025
  left: l,
6606
7026
  top: u,
6607
- height: y * T.value
7027
+ height: b * T.value
6608
7028
  }, A.value = {
6609
7029
  left: l,
6610
7030
  top: u
@@ -6614,8 +7034,8 @@ var qn = { class: "pe-root" }, Jn = { class: "pe-main" }, Yn = { class: "pe-edit
6614
7034
  });
6615
7035
  });
6616
7036
  }
6617
- function He(e) {
6618
- if (w.cursor.value.blockId && !(Ve.value && e.key === "Enter")) switch (e.key) {
7037
+ function Ve(e) {
7038
+ if (w.cursor.value.blockId && !(Be.value && e.key === "Enter")) switch (e.key) {
6619
7039
  case "Enter":
6620
7040
  e.preventDefault(), C.saveUndoSnapshot(), w.splitAtCursor(), J();
6621
7041
  break;
@@ -6639,16 +7059,16 @@ var qn = { class: "pe-root" }, Jn = { class: "pe-main" }, Yn = { class: "pe-edit
6639
7059
  break;
6640
7060
  }
6641
7061
  }
6642
- function Ue(e) {
6643
- if (Ve.value) return;
7062
+ function He(e) {
7063
+ if (Be.value) return;
6644
7064
  let t = e.target, n = t.value;
6645
7065
  n && w.cursor.value.blockId && (C.saveUndoSnapshot(), w.insertText(n), t.value = "", J());
6646
7066
  }
6647
- function We() {
6648
- Ve.value = !0;
7067
+ function Ue() {
7068
+ Be.value = !0;
6649
7069
  }
6650
- function Ge(e) {
6651
- Ve.value = !1;
7070
+ function We(e) {
7071
+ Be.value = !1;
6652
7072
  let t = k.value;
6653
7073
  if (t) {
6654
7074
  let e = t.value;
@@ -6656,15 +7076,15 @@ var qn = { class: "pe-root" }, Jn = { class: "pe-main" }, Yn = { class: "pe-edit
6656
7076
  }
6657
7077
  }
6658
7078
  return l(() => {
6659
- 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");
7079
+ x.initialData ? Re(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");
6660
7080
  }), u(() => {
6661
- document.removeEventListener("mousemove", Ce), document.removeEventListener("mouseup", we), document.removeEventListener("mousemove", K), document.removeEventListener("mouseup", Ae), document.removeEventListener("mousemove", Re), document.removeEventListener("mouseup", q);
7081
+ document.removeEventListener("mousemove", Se), document.removeEventListener("mouseup", K), document.removeEventListener("mousemove", Oe), document.removeEventListener("mouseup", ke), document.removeEventListener("mousemove", Ie), document.removeEventListener("mouseup", Le);
6662
7082
  }), v(() => x.qrCodeContent, (e) => {
6663
7083
  C.qrCodeContent.value = e || "";
6664
7084
  }), m({
6665
7085
  document: {
6666
7086
  save: () => C.saveDocument(),
6667
- load: (e) => ze(e),
7087
+ load: (e) => Re(e),
6668
7088
  getBlocks: () => C.blocks.value,
6669
7089
  isDirty: () => C.isDirty.value
6670
7090
  },
@@ -6758,7 +7178,7 @@ var qn = { class: "pe-root" }, Jn = { class: "pe-main" }, Yn = { class: "pe-edit
6758
7178
  goToPage: (e) => {
6759
7179
  E.value = e;
6760
7180
  },
6761
- scrollToBlock: (e) => Be(e)
7181
+ scrollToBlock: (e) => ze(e)
6762
7182
  },
6763
7183
  render: {
6764
7184
  getPageSvgs: () => N.value,
@@ -6782,7 +7202,7 @@ var qn = { class: "pe-root" }, Jn = { class: "pe-main" }, Yn = { class: "pe-edit
6782
7202
  selectedImageId: C.selectedImageId.value,
6783
7203
  selectedUnderlineInfo: C.selectedUnderlineInfo.value,
6784
7204
  selectedImageInfo: C.selectedImageInfo.value,
6785
- selectedImageAlignment: me.value,
7205
+ selectedImageAlignment: fe.value,
6786
7206
  totalScore: C.totalScore.value,
6787
7207
  zoom: T.value,
6788
7208
  currentPage: E.value,
@@ -6795,7 +7215,7 @@ var qn = { class: "pe-root" }, Jn = { class: "pe-main" }, Yn = { class: "pe-edit
6795
7215
  qrCodeImages: C.qrCodeImages.value,
6796
7216
  showScore: C.settings.value.showScore
6797
7217
  }))
6798
- }), (t, a) => (d(), r("div", qn, [i("div", Jn, [i("div", Yn, [i("div", {
7218
+ }), (t, a) => (d(), r("div", tr, [i("div", nr, [i("div", rr, [i("div", {
6799
7219
  class: "pe-editor-surface",
6800
7220
  ref_key: "saberEditorRef",
6801
7221
  ref: O
@@ -6804,25 +7224,25 @@ var qn = { class: "pe-root" }, Jn = { class: "pe-main" }, Yn = { class: "pe-edit
6804
7224
  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",
6805
7225
  fill: "currentColor"
6806
7226
  })])])], -1),
6807
- i("div", Xn, [(d(!0), r(e, null, p(g(N), (e, t) => (d(), r("div", {
7227
+ i("div", ir, [(d(!0), r(e, null, p(g(N), (e, t) => (d(), r("div", {
6808
7228
  key: t,
6809
7229
  class: s(["pe-editor-page", { active: t === E.value }]),
6810
7230
  onClick: b((e) => E.value = t, ["stop"])
6811
7231
  }, [i("div", {
6812
7232
  class: "pe-editor-viewport",
6813
7233
  innerHTML: e,
6814
- onClick: ie,
6815
- onFocusout: ae
6816
- }, null, 40, Qn)], 10, Zn))), 128))]),
6817
- i("div", $n, [
6818
- R.value ? (d(), r("div", {
7234
+ onClick: re,
7235
+ onFocusout: ie
7236
+ }, null, 40, or)], 10, ar))), 128))]),
7237
+ i("div", sr, [
7238
+ z.value ? (d(), r("div", {
6819
7239
  key: 0,
6820
7240
  class: "pe-ctrl-block",
6821
- style: c(oe.value)
7241
+ style: c(ae.value)
6822
7242
  }, [
6823
7243
  i("div", {
6824
7244
  class: "pe-ctrl-height",
6825
- onMousedown: b(G, ["prevent"])
7245
+ onMousedown: b(xe, ["prevent"])
6826
7246
  }, [...a[9] ||= [i("svg", {
6827
7247
  xmlns: "http://www.w3.org/2000/svg",
6828
7248
  width: "16",
@@ -6833,22 +7253,22 @@ var qn = { class: "pe-root" }, Jn = { class: "pe-main" }, Yn = { class: "pe-edit
6833
7253
  "fill-rule": "evenodd",
6834
7254
  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"
6835
7255
  })], -1)]], 32),
6836
- B.value ? (d(), r("div", er, [i("button", {
7256
+ V.value ? (d(), r("div", cr, [i("button", {
6837
7257
  class: "pe-merge-btn",
6838
- onMousedown: b(le, ["stop"])
7258
+ onMousedown: b(oe, ["stop"])
6839
7259
  }, "合并子题", 32)])) : n("", !0),
6840
- ce.value ? (d(), r("div", tr, [i("button", {
7260
+ H.value ? (d(), r("div", lr, [i("button", {
6841
7261
  class: "pe-split-btn",
6842
- onMousedown: b(V, ["stop"])
7262
+ onMousedown: b(se, ["stop"])
6843
7263
  }, "拆分子题", 32)])) : n("", !0)
6844
7264
  ], 4)) : n("", !0),
6845
- H.value ? (d(), r("div", {
7265
+ U.value ? (d(), r("div", {
6846
7266
  key: 1,
6847
7267
  class: "pe-ctrlUnderline",
6848
- style: c(ue.value)
7268
+ style: c(ce.value)
6849
7269
  }, [i("div", {
6850
7270
  class: "pe-ctrl-ul-left",
6851
- onMousedown: a[0] ||= b((e) => ke("left", e), ["prevent"])
7271
+ onMousedown: a[0] ||= b((e) => De("left", e), ["prevent"])
6852
7272
  }, [...a[10] ||= [i("svg", {
6853
7273
  xmlns: "http://www.w3.org/2000/svg",
6854
7274
  width: "12",
@@ -6859,7 +7279,7 @@ var qn = { class: "pe-root" }, Jn = { class: "pe-main" }, Yn = { class: "pe-edit
6859
7279
  d: "M10.5 4L7.5 8l3 4H2V4z"
6860
7280
  })], -1)]], 32), i("div", {
6861
7281
  class: "pe-ctrl-ul-right",
6862
- onMousedown: a[1] ||= b((e) => ke("right", e), ["prevent"])
7282
+ onMousedown: a[1] ||= b((e) => De("right", e), ["prevent"])
6863
7283
  }, [...a[11] ||= [i("svg", {
6864
7284
  xmlns: "http://www.w3.org/2000/svg",
6865
7285
  width: "12",
@@ -6869,46 +7289,46 @@ var qn = { class: "pe-root" }, Jn = { class: "pe-main" }, Yn = { class: "pe-edit
6869
7289
  fill: "currentColor",
6870
7290
  d: "M5.5 4L8.5 8l-3 4H14V4z"
6871
7291
  })], -1)]], 32)], 4)) : n("", !0),
6872
- U.value ? (d(), r("div", {
7292
+ W.value ? (d(), r("div", {
6873
7293
  key: 2,
6874
7294
  class: "pe-ctrlAnchor",
6875
- style: c(fe.value)
7295
+ style: c(ue.value)
6876
7296
  }, [
6877
7297
  i("div", {
6878
7298
  class: "pe-resize-se",
6879
- onMousedown: a[2] ||= b((e) => Le("se", e), ["prevent", "stop"])
7299
+ onMousedown: a[2] ||= b((e) => Fe("se", e), ["prevent", "stop"])
6880
7300
  }, null, 32),
6881
7301
  i("div", {
6882
7302
  class: "pe-resize-sw",
6883
- onMousedown: a[3] ||= b((e) => Le("sw", e), ["prevent", "stop"])
7303
+ onMousedown: a[3] ||= b((e) => Fe("sw", e), ["prevent", "stop"])
6884
7304
  }, null, 32),
6885
7305
  i("div", {
6886
7306
  class: "pe-resize-ne",
6887
- onMousedown: a[4] ||= b((e) => Le("ne", e), ["prevent", "stop"])
7307
+ onMousedown: a[4] ||= b((e) => Fe("ne", e), ["prevent", "stop"])
6888
7308
  }, null, 32),
6889
7309
  i("div", {
6890
7310
  class: "pe-resize-nw",
6891
- onMousedown: a[5] ||= b((e) => Le("nw", e), ["prevent", "stop"])
7311
+ onMousedown: a[5] ||= b((e) => Fe("nw", e), ["prevent", "stop"])
6892
7312
  }, null, 32)
6893
7313
  ], 4)) : n("", !0),
6894
- he.value ? (d(), r("div", {
7314
+ pe.value ? (d(), r("div", {
6895
7315
  key: 3,
6896
7316
  class: "pe-img-align-bar",
6897
- style: c(ge.value)
7317
+ style: c(me.value)
6898
7318
  }, [
6899
7319
  i("button", {
6900
- class: s(["pe-align-btn", { active: me.value?.alignment === "left" }]),
6901
- onClick: a[6] ||= (e) => _e("left"),
7320
+ class: s(["pe-align-btn", { active: fe.value?.alignment === "left" }]),
7321
+ onClick: a[6] ||= (e) => he("left"),
6902
7322
  title: "左对齐"
6903
7323
  }, "左", 2),
6904
7324
  i("button", {
6905
- class: s(["pe-align-btn", { active: me.value?.alignment === "center" }]),
6906
- onClick: a[7] ||= (e) => _e("center"),
7325
+ class: s(["pe-align-btn", { active: fe.value?.alignment === "center" }]),
7326
+ onClick: a[7] ||= (e) => he("center"),
6907
7327
  title: "居中对齐"
6908
7328
  }, "中", 2),
6909
7329
  i("button", {
6910
- class: s(["pe-align-btn", { active: me.value?.alignment === "right" }]),
6911
- onClick: a[8] ||= (e) => _e("right"),
7330
+ class: s(["pe-align-btn", { active: fe.value?.alignment === "right" }]),
7331
+ onClick: a[8] ||= (e) => he("right"),
6912
7332
  title: "右对齐"
6913
7333
  }, "右", 2)
6914
7334
  ], 4)) : n("", !0)
@@ -6920,10 +7340,10 @@ var qn = { class: "pe-root" }, Jn = { class: "pe-main" }, Yn = { class: "pe-edit
6920
7340
  class: "pe-editor-virtual-input",
6921
7341
  ref_key: "virtualInputRef",
6922
7342
  ref: k,
6923
- onKeydown: He,
6924
- onInput: Ue,
6925
- onCompositionstart: We,
6926
- onCompositionend: Ge
7343
+ onKeydown: Ve,
7344
+ onInput: He,
7345
+ onCompositionstart: Ue,
7346
+ onCompositionend: We
6927
7347
  }, null, 544)], 4),
6928
7348
  y(i("div", {
6929
7349
  class: "pe-editor-cursor",
@@ -6931,17 +7351,17 @@ var qn = { class: "pe-root" }, Jn = { class: "pe-main" }, Yn = { class: "pe-edit
6931
7351
  }, null, 4), [[_, D.value]])
6932
7352
  ], 512)])])]));
6933
7353
  }
6934
- }), rr = (e, t) => {
7354
+ }), dr = (e, t) => {
6935
7355
  let n = e.__vccOpts || e;
6936
7356
  for (let [e, r] of t) n[e] = r;
6937
7357
  return n;
6938
- }, ir = /*#__PURE__*/ rr(nr, [["__scopeId", "data-v-b29566da"]]), ar = { class: "pe-preview__pages" }, or = ["innerHTML"], sr = {
7358
+ }, fr = /*#__PURE__*/ dr(ur, [["__scopeId", "data-v-5812f1ed"]]), pr = { class: "pe-preview__pages" }, mr = ["innerHTML"], hr = {
6939
7359
  key: 0,
6940
7360
  class: "pe-preview__helpers"
6941
- }, cr = {
7361
+ }, gr = {
6942
7362
  key: 1,
6943
7363
  class: "pe-preview__page-num"
6944
- }, lr = /*#__PURE__*/ rr(/* @__PURE__ */ a({
7364
+ }, _r = /*#__PURE__*/ dr(/* @__PURE__ */ a({
6945
7365
  __name: "PaperPreview",
6946
7366
  props: {
6947
7367
  document: {},
@@ -6968,14 +7388,14 @@ var qn = { class: "pe-root" }, Jn = { class: "pe-main" }, Yn = { class: "pe-edit
6968
7388
  }
6969
7389
  },
6970
7390
  setup(a) {
6971
- let o = a, m = Bn();
7391
+ let o = a, m = Jn();
6972
7392
  function _() {
6973
7393
  o.document && m.loadDocument(o.document);
6974
7394
  }
6975
7395
  _(), v(() => o.document, _), v(() => o.pureMode, (e) => {
6976
7396
  m.setRenderMode(e ? "view" : "edit");
6977
7397
  }, { immediate: !0 });
6978
- let y = Hn(m, { selectedBlockId: null }), b = f(), x = f(0), S = null;
7398
+ let y = Xn(m, { selectedBlockId: null }), b = f(), x = f(0), S = null;
6979
7399
  l(() => {
6980
7400
  x.value = b.value?.clientWidth ?? 0, S = new ResizeObserver((e) => {
6981
7401
  for (let t of e) x.value = Math.floor(t.contentRect.width);
@@ -7143,7 +7563,7 @@ var qn = { class: "pe-root" }, Jn = { class: "pe-main" }, Yn = { class: "pe-edit
7143
7563
  class: s(["pe-preview", { "pe-preview--print": a.mode === "print" }]),
7144
7564
  ref_key: "previewRef",
7145
7565
  ref: b
7146
- }, [i("div", ar, [(d(!0), r(e, null, p(g(y), (t, o) => (d(), r("div", {
7566
+ }, [i("div", pr, [(d(!0), r(e, null, p(g(y), (t, o) => (d(), r("div", {
7147
7567
  key: o,
7148
7568
  class: "pe-preview__page",
7149
7569
  style: c(k(o))
@@ -7157,8 +7577,8 @@ var qn = { class: "pe-root" }, Jn = { class: "pe-main" }, Yn = { class: "pe-edit
7157
7577
  width: "100%",
7158
7578
  height: "100%"
7159
7579
  }
7160
- }, null, 8, or)], 4),
7161
- a.showHelpers ? (d(), r("div", sr, [a.showCornerMarks ? (d(!0), r(e, { key: 0 }, p(D(o), (e, t) => (d(), r("span", {
7580
+ }, null, 8, mr)], 4),
7581
+ a.showHelpers ? (d(), r("div", hr, [a.showCornerMarks ? (d(!0), r(e, { key: 0 }, p(D(o), (e, t) => (d(), r("span", {
7162
7582
  key: "cm-" + t,
7163
7583
  class: s(["pe-preview__helper-box", e.className]),
7164
7584
  style: c(ee(e))
@@ -7167,9 +7587,9 @@ var qn = { class: "pe-root" }, Jn = { class: "pe-main" }, Yn = { class: "pe-edit
7167
7587
  class: s(["pe-preview__helper-box", e.className]),
7168
7588
  style: c(ee(e))
7169
7589
  }, null, 6))), 128)) : n("", !0)])) : n("", !0),
7170
- a.showPageNumbers ? (d(), r("div", cr, h(o + 1) + " / " + h(g(m).pages.value.length), 1)) : n("", !0)
7590
+ a.showPageNumbers ? (d(), r("div", gr, h(o + 1) + " / " + h(g(m).pages.value.length), 1)) : n("", !0)
7171
7591
  ], 4))), 128))])], 2));
7172
7592
  }
7173
7593
  }), [["__scopeId", "data-v-e8f833b5"]]);
7174
7594
  //#endregion
7175
- 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, De as latexToSvg, Me 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 };
7595
+ export { kn as FONT_SIZE_MAP, A as PAPER_DIMENSIONS, j as PAPER_MM, fr as PaperEditor, te as PaperLayout, _r as PaperPreview, Se as SvgRenderer, Kt as buildAnswerHtml, Wt as buildPaperHtml, H as calcCharPositions, V as calcTextWidth, Ee as clearFormulaCache, se as clearWidthCache, vt as deserializeDocument, Ht as extractBaseTitle, An as fontSizeLabelToPx, jn as fontSizePxToLabel, Vt as formatSectionTitle, B as getCharWidth, ee as getPaperPreset, $n as hasTablePlaceholder, De as latexToSvg, Me as latexToSvgBatch, Ct as parseQuestionHtml, Ft as parseQuestionJson, Zn as renderTablePlaceholders, _t as serializeDocument, P as toBBox, Bt as toChineseOrdinal, Xn as usePageSvgRenderer, Jn as usePaperCore };