@sw7d/paper-renderer 0.2.3 → 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,28 +1095,28 @@ 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
- function K(e, t = 14, n = !1) {
1113
+ function De(e, t = 14, n = !1) {
951
1114
  let r = we(e, t, n);
952
1115
  if (r) return r;
953
- let i = De(e, t, n);
1116
+ let i = Oe(e, t, n);
954
1117
  return Te(e, t, n, i), i;
955
1118
  }
956
- function De(e, t = 14, n = !1) {
1119
+ function Oe(e, t = 14, n = !1) {
957
1120
  try {
958
1121
  let r = window.MathJax;
959
1122
  if (!r?.tex2svg) throw Error("MathJax 尚未加载完成");
@@ -978,17 +1141,17 @@ function De(e, t = 14, n = !1) {
978
1141
  };
979
1142
  } catch {
980
1143
  return {
981
- svg: `<svg xmlns="http://www.w3.org/2000/svg" width="50" height="20" viewBox="0 0 50 20"><text x="2" y="16" font-size="11" font-family="Times New Roman,serif" fill="#999">${Oe(e)}</text></svg>`,
1144
+ svg: `<svg xmlns="http://www.w3.org/2000/svg" width="50" height="20" viewBox="0 0 50 20"><text x="2" y="16" font-size="11" font-family="Times New Roman,serif" fill="#999">${ke(e)}</text></svg>`,
982
1145
  width: 50,
983
1146
  height: 20
984
1147
  };
985
1148
  }
986
1149
  }
987
- function Oe(e) {
1150
+ function ke(e) {
988
1151
  return e.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
989
1152
  }
990
- var q = /* @__PURE__ */ new Map(), ke = 200;
991
- function Ae(e, t = 14, n = !1) {
1153
+ var q = /* @__PURE__ */ new Map(), Ae = 200;
1154
+ function je(e, t = 14, n = !1) {
992
1155
  let r = e;
993
1156
  try {
994
1157
  r = decodeURIComponent(e);
@@ -1017,7 +1180,7 @@ function Ae(e, t = 14, n = !1) {
1017
1180
  width: s,
1018
1181
  height: c
1019
1182
  };
1020
- if (q.set(i, d), q.size > ke) {
1183
+ if (q.set(i, d), q.size > Ae) {
1021
1184
  let e = q.keys().next().value;
1022
1185
  e && q.delete(e);
1023
1186
  }
@@ -1030,14 +1193,14 @@ function Ae(e, t = 14, n = !1) {
1030
1193
  };
1031
1194
  }
1032
1195
  }
1033
- function je(e, t = 20) {
1196
+ function Me(e, t = 20) {
1034
1197
  return new Promise((n) => {
1035
1198
  let r = Array(e.length), i = 0;
1036
1199
  function a() {
1037
1200
  let o = Math.min(i + t, e.length);
1038
1201
  for (; i < o; i++) {
1039
1202
  let t = e[i];
1040
- r[i] = K(t.latex, t.fontSize ?? 14, t.display ?? !1);
1203
+ r[i] = De(t.latex, t.fontSize ?? 14, t.display ?? !1);
1041
1204
  }
1042
1205
  i < e.length ? requestAnimationFrame(a) : n(r);
1043
1206
  }
@@ -1046,7 +1209,7 @@ function je(e, t = 20) {
1046
1209
  }
1047
1210
  //#endregion
1048
1211
  //#region src/utils/serialization/shared.ts
1049
- var Me = {
1212
+ var Ne = {
1050
1213
  clrScheme: {
1051
1214
  accent1: "4472C4",
1052
1215
  accent2: "ED7D31",
@@ -1103,9 +1266,9 @@ var Me = {
1103
1266
  latin: "等线"
1104
1267
  }
1105
1268
  }
1106
- }, Ne = { docDefaults: { textPropsDefault: { runfonts: { hint: "eastAsia" } } } }, Pe = 26.46, Fe = 17.5, Ie = 26.25;
1107
- function Le(e) {
1108
- let t = Pe;
1269
+ }, Pe = { docDefaults: { textPropsDefault: { runfonts: { hint: "eastAsia" } } } }, Fe = 26.46, Ie = 17.5, Le = 26.25;
1270
+ function Re(e) {
1271
+ let t = Fe;
1109
1272
  return {
1110
1273
  tl: {
1111
1274
  top: t,
@@ -1133,11 +1296,11 @@ function Le(e) {
1133
1296
  }
1134
1297
  };
1135
1298
  }
1136
- function Re(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,25 +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) {
1162
- return /_Block_\d+$/.test(e);
1163
- }
1164
1324
  function He(e) {
1165
- let t = e.match(/^(.+)_Block_\d+$/);
1166
- return t ? t[1] : "";
1325
+ return /_Block_\d+$/.test(e) || /-sub\d+$/.test(e);
1167
1326
  }
1168
1327
  function Ue(e) {
1328
+ let t = e.match(/^(.+)_Block_\d+$/);
1329
+ if (t) return t[1];
1330
+ let n = e.match(/^(.+)-sub\d+$/);
1331
+ return n ? `${n[1]}-header` : "";
1332
+ }
1333
+ function We(e) {
1169
1334
  let t = [];
1170
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);
1171
1336
  let n = t.join("").trim();
1172
1337
  return !n && e.metadata?.label ? e.metadata.label : n;
1173
1338
  }
1174
- function We(e) {
1339
+ function Ge(e) {
1175
1340
  let t = [], n = null;
1176
1341
  for (let r of e) {
1177
1342
  if (r.type === "title") {
1178
1343
  n &&= (t.push(n), null);
1179
- let e = Ue(r);
1344
+ let e = We(r);
1180
1345
  t.push({
1181
1346
  type: "title-section",
1182
1347
  name: e || "题目",
@@ -1195,9 +1360,9 @@ function We(e) {
1195
1360
  }
1196
1361
  //#endregion
1197
1362
  //#region src/utils/serialization/buildQuestions.ts
1198
- function Ge(e, t) {
1363
+ function Ke(e, t) {
1199
1364
  if (e.type === "title" || e.type === "info-line") return null;
1200
- let n = e.type === "sub-question" ? Ie : Fe, r = A[t.paperSize], [, , i, a] = t.margins || [
1365
+ let n = e.type === "sub-question" ? Le : Ie, r = A[t.paperSize], [, , i, a] = t.margins || [
1201
1366
  50,
1202
1367
  56,
1203
1368
  50,
@@ -1234,15 +1399,24 @@ function Ge(e, t) {
1234
1399
  let t = { ...e.metadata };
1235
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;
1236
1401
  })()
1237
- }, 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 = {
1238
1409
  type: "question-stem",
1239
- 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)),
1240
1414
  props: {
1241
1415
  split: !0,
1242
1416
  anchorOverflow: !1,
1243
1417
  topicId: e.metadata?.topicId || e.id
1244
1418
  }
1245
- }, p = {
1419
+ }, g = {
1246
1420
  type: "correction-box",
1247
1421
  children: [{
1248
1422
  type: "text",
@@ -1264,14 +1438,30 @@ function Ge(e, t) {
1264
1438
  topicId: e.metadata?.topicId || e.id,
1265
1439
  isLongScoreBar: !0
1266
1440
  }
1267
- }, m = [f];
1268
- 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), {
1269
1459
  type: "question",
1270
1460
  props: d,
1271
- children: m
1461
+ children: _
1272
1462
  };
1273
1463
  }
1274
- function Ke(e, t) {
1464
+ function qe(e, t) {
1275
1465
  return {
1276
1466
  type: "option",
1277
1467
  props: {
@@ -1280,7 +1470,7 @@ function Ke(e, t) {
1280
1470
  keepNext: !1
1281
1471
  },
1282
1472
  children: e.map((e, t) => {
1283
- let n = e.paragraphs.map((e) => qe(e));
1473
+ let n = e.paragraphs.map((e) => Je(e));
1284
1474
  return {
1285
1475
  type: "option-item",
1286
1476
  props: {
@@ -1294,10 +1484,10 @@ function Ke(e, t) {
1294
1484
  })
1295
1485
  };
1296
1486
  }
1297
- function qe(e) {
1487
+ function Je(e) {
1298
1488
  let t = [];
1299
1489
  for (let n of e.lines) for (let e of n.elements) {
1300
- let r = Je(e, n);
1490
+ let r = Ye(e, n);
1301
1491
  r && t.push(r);
1302
1492
  }
1303
1493
  return {
@@ -1313,7 +1503,7 @@ function qe(e) {
1313
1503
  children: t
1314
1504
  };
1315
1505
  }
1316
- function Je(e, t) {
1506
+ function Ye(e, t) {
1317
1507
  switch (e.type) {
1318
1508
  case "text": {
1319
1509
  let t = e;
@@ -1476,9 +1666,29 @@ function Je(e, t) {
1476
1666
  default: return null;
1477
1667
  }
1478
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
+ }
1479
1689
  //#endregion
1480
1690
  //#region src/utils/serialization/buildBody.ts
1481
- function Ye(e, t) {
1691
+ function Ze(e, t) {
1482
1692
  let n = A[t.paperSize], [r, i, a, o] = t.margins || [
1483
1693
  50,
1484
1694
  56,
@@ -1497,7 +1707,7 @@ function Ye(e, t) {
1497
1707
  bottom: a,
1498
1708
  left: o
1499
1709
  },
1500
- point: Le(n),
1710
+ point: Re(n),
1501
1711
  headerTop: t.headerTop ?? 18,
1502
1712
  footerBottom: 13.2,
1503
1713
  showScore: t.showScore,
@@ -1524,7 +1734,7 @@ function Ye(e, t) {
1524
1734
  colorType: "rgb",
1525
1735
  colorValue: "7030A0"
1526
1736
  } } }
1527
- }, u = Xe(e, t);
1737
+ }, u = Qe(e, t);
1528
1738
  return {
1529
1739
  type: "document",
1530
1740
  props: l,
@@ -1541,16 +1751,16 @@ function Ye(e, t) {
1541
1751
  }]
1542
1752
  };
1543
1753
  }
1544
- function Xe(e, t) {
1545
- let n = [], r = We(e);
1546
- 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));
1547
1757
  else for (let r of e.blocks) {
1548
- let e = Ge(r, t);
1758
+ let e = Ke(r, t);
1549
1759
  e && n.push(e);
1550
1760
  }
1551
1761
  return n;
1552
1762
  }
1553
- function Ze(e, t) {
1763
+ function $e(e, t) {
1554
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;
1555
1765
  return {
1556
1766
  type: "vueplug",
@@ -1581,7 +1791,7 @@ function Ze(e, t) {
1581
1791
  }
1582
1792
  //#endregion
1583
1793
  //#region src/utils/serialization/buildPagesExport.ts
1584
- var Qe = new Set([
1794
+ var et = new Set([
1585
1795
  "header-desc",
1586
1796
  "score",
1587
1797
  "paper-name",
@@ -1591,24 +1801,42 @@ var Qe = new Set([
1591
1801
  "student-code",
1592
1802
  "student-code-filler"
1593
1803
  ]);
1594
- function $e(e, t, n = !0) {
1595
- let r = ze(t), i = /* @__PURE__ */ new Set(), a = /* @__PURE__ */ new Set();
1804
+ function tt(e, t, n = !0) {
1805
+ let r = Be(t), i = /* @__PURE__ */ new Map();
1806
+ for (let e of t) {
1807
+ let t = e.metadata?.blockGroup;
1808
+ if (t && e.type === "question") {
1809
+ let n = ze(e.id);
1810
+ i.set(t, {
1811
+ topicId: n,
1812
+ qid: e.metadata?.qid
1813
+ });
1814
+ }
1815
+ }
1816
+ let a = /* @__PURE__ */ new Set(), o = /* @__PURE__ */ new Set();
1596
1817
  for (let t of e) for (let e of t.renderedRegions || []) {
1597
- let t = Re(e.meta?.blockId || e.meta?.topicId || "");
1598
- t && e.type === "question-border" && i.add(t);
1818
+ let t = ze(e.meta?.blockId || e.meta?.topicId || "");
1819
+ t && e.type === "question-border" && a.add(t);
1820
+ }
1821
+ for (let e of a) He(e) && o.add(Ue(e));
1822
+ for (let e of t) if (e.type === "sub-question") {
1823
+ let t = e.metadata?.topicId || (e.id.startsWith("sw-") ? e.id.slice(3) : e.id);
1824
+ if (e.metadata?.blockGroup) {
1825
+ let t = i.get(e.metadata.blockGroup);
1826
+ t && o.add(t.topicId);
1827
+ } else He(t) && o.add(Ue(t));
1599
1828
  }
1600
- for (let e of i) J(e) && a.add(He(e));
1601
- let o = /* @__PURE__ */ new Map(), s = 0;
1829
+ let s = /* @__PURE__ */ new Map(), c = 0;
1602
1830
  for (let e of t) {
1603
1831
  let t = e.metadata?.topicId || (e.id.startsWith("sw-") ? e.id.slice(3) : e.id);
1604
- o.has(t) || o.set(t, s++);
1832
+ s.has(t) || s.set(t, c++);
1605
1833
  }
1606
1834
  for (let t of e) for (let e of t.renderedRegions || []) {
1607
- let t = Re(e.meta?.blockId || e.meta?.topicId || "");
1608
- t && e.type === "question-border" && !o.has(t) && o.set(t, s++);
1835
+ let t = ze(e.meta?.blockId || e.meta?.topicId || "");
1836
+ t && e.type === "question-border" && !s.has(t) && s.set(t, c++);
1609
1837
  }
1610
1838
  return e.map((t) => {
1611
- let i = t.renderedRegions || [], s = {
1839
+ let a = t.renderedRegions || [], c = {
1612
1840
  pageIndex: t.index,
1613
1841
  pageWidth: t.width,
1614
1842
  pageHeight: t.height,
@@ -1617,67 +1845,71 @@ function $e(e, t, n = !0) {
1617
1845
  bbox: e.bbox
1618
1846
  })),
1619
1847
  questions: []
1620
- }, c = {}, l = [], u, d = /* @__PURE__ */ new Map();
1621
- for (let e of i) {
1622
- if (Qe.has(e.type)) {
1848
+ }, l = {}, u = [], d, f = /* @__PURE__ */ new Map();
1849
+ for (let e of a) {
1850
+ if (et.has(e.type)) {
1623
1851
  if (e.type === "score" && !n) continue;
1624
- c[Ve(e.type)] = e.bbox;
1852
+ l[Ve(e.type)] = e.bbox;
1625
1853
  continue;
1626
1854
  }
1627
1855
  if (e.type === "page-number") {
1628
- u = e.bbox;
1856
+ d = e.bbox;
1629
1857
  continue;
1630
1858
  }
1631
1859
  if (e.type === "title-embed") {
1632
- l.push({
1860
+ u.push({
1633
1861
  label: e.meta?.label || "unknown",
1634
1862
  bbox: e.bbox
1635
1863
  });
1636
1864
  continue;
1637
1865
  }
1638
1866
  if (e.type === "column-separator") continue;
1639
- let t = Re(e.meta?.blockId || e.meta?.topicId || "");
1867
+ let t = ze(e.meta?.blockId || e.meta?.topicId || "");
1640
1868
  if (!t) continue;
1641
- d.has(t) || d.set(t, {
1869
+ f.has(t) || f.set(t, {
1642
1870
  borders: [],
1643
1871
  underlines: []
1644
1872
  });
1645
- let r = d.get(t);
1873
+ let r = f.get(t);
1646
1874
  e.type === "question-border" ? r.borders.push(e) : e.type === "underline" && r.underlines.push(e);
1647
1875
  }
1648
- Object.keys(c).length > 0 && (s.header = c), l.length > 0 && (s.sectionTitles = l), u && (s.footer = { pageNumber: u });
1649
- let f = Array.from(d.entries()).sort(([e, t], [n, r]) => {
1650
- let i = o.get(e) ?? 9999, a = o.get(n) ?? 9999;
1876
+ Object.keys(l).length > 0 && (c.header = l), u.length > 0 && (c.sectionTitles = u), d && (c.footer = { pageNumber: d });
1877
+ let p = Array.from(f.entries()).sort(([e, t], [n, r]) => {
1878
+ let i = s.get(e) ?? 9999, a = s.get(n) ?? 9999;
1651
1879
  return i === a ? (t.borders[0]?.bbox[1] ?? 0) - (r.borders[0]?.bbox[1] ?? 0) : i - a;
1652
1880
  });
1653
- for (let [t, n] of f) {
1881
+ for (let [t, n] of p) {
1654
1882
  if (n.borders.length === 0) continue;
1655
- let i = r.get(t), c = i?.metadata?.questionNo || i?.metadata?.subLabel || "", l = i?.metadata?.score, u = a.has(t), d = n.borders.map((e) => e.bbox), f = {
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 = {
1656
1884
  topicId: t,
1657
- questionNo: c,
1658
- questionType: Be(i),
1659
- sortIndex: o.get(t) ?? 9999,
1660
- bbox: d[0]
1885
+ questionNo: l,
1886
+ questionType: J(a),
1887
+ sortIndex: s.get(t) ?? 9999,
1888
+ bbox: p[0]
1661
1889
  };
1662
- if (d.length > 1 && (f.bboxes = d), i?.metadata?.qid && (f.qid = i.metadata.qid), i?.metadata?.answer && (f.answer = i.metadata.answer), i?.metadata?.subAnswers && (f.subAnswers = i.metadata.subAnswers), l !== void 0 && l !== "" && l !== null) {
1663
- let e = parseFloat(String(l));
1664
- isNaN(e) || (f.score = e);
1890
+ if (p.length > 1 && (m.bboxes = p), a?.metadata?.qid && (m.qid = a.metadata.qid), a?.metadata?.answer && (m.answer = a.metadata.answer), a?.metadata?.subAnswers && (m.subAnswers = a.metadata.subAnswers), u !== void 0 && u !== "" && u !== null) {
1891
+ let e = parseFloat(String(u));
1892
+ isNaN(e) || (m.score = e);
1665
1893
  }
1666
- J(t) && (f.parentTopicId = He(t)), u && (f.hasSubQuestions = !0), n.underlines.length > 0 && (f.underlines = n.underlines.map((e) => {
1894
+ if (f) if (a?.metadata?.blockGroup) {
1895
+ let e = i.get(a.metadata.blockGroup);
1896
+ e && (m.parentTopicId = e.topicId, e.qid && (m.pqid = e.qid));
1897
+ } else m.parentTopicId = Ue(t);
1898
+ d && (m.hasSubQuestions = !0), n.underlines.length > 0 && (m.underlines = n.underlines.map((e) => {
1667
1899
  let t = { bbox: e.bbox }, n = e.meta;
1668
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;
1669
1901
  })), e.filter((e) => e.renderedRegions.some((e) => {
1670
1902
  let n = e.meta?.blockId || e.meta?.topicId || "";
1671
- return n && Re(n) === t;
1672
- })).length > 1 && (f.isCrossPage = !0), s.questions.push(f);
1903
+ return n && ze(n) === t;
1904
+ })).length > 1 && (m.isCrossPage = !0), c.questions.push(m);
1673
1905
  }
1674
- return s;
1906
+ return c;
1675
1907
  });
1676
1908
  }
1677
1909
  //#endregion
1678
1910
  //#region src/utils/textWrap.ts
1679
- var et = ",。、;:?!…)】》'\"'\"…·", tt = "(【《'\"'\"";
1680
- function nt(e, t) {
1911
+ var nt = ",。、;:?!…)】》'\"'\"…·", rt = "(【《'\"'\"";
1912
+ function it(e, t) {
1681
1913
  let n = t, r = t * .5;
1682
1914
  for (let t of e) if (t.type === "formula") {
1683
1915
  let e = t, i = e.svgContent.match(/vertical-align:\s*([-\d.]+)(px|ex)/), a;
@@ -1700,7 +1932,7 @@ function nt(e, t) {
1700
1932
  y: 0
1701
1933
  };
1702
1934
  }
1703
- function rt(e, t, n, r = 0) {
1935
+ function at(e, t, n, r = 0) {
1704
1936
  let i = [], a = [], o = 0;
1705
1937
  for (let n = 0; n < e.length; n++) {
1706
1938
  let s = e[n];
@@ -1766,12 +1998,12 @@ function rt(e, t, n, r = 0) {
1766
1998
  continue;
1767
1999
  }
1768
2000
  }
1769
- 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;
1770
2002
  if (o + s.width > l && a.length > 0 && !u) {
1771
2003
  let e = a.length;
1772
2004
  if (a.length > 0) {
1773
2005
  let t = a[a.length - 1];
1774
- 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);
1775
2007
  }
1776
2008
  i.push(a.slice(0, e)), a = [...a.slice(e), s], o = a.reduce((e, t) => e + t.width, 0);
1777
2009
  } else a.push(s), o += s.width;
@@ -1779,26 +2011,26 @@ function rt(e, t, n, r = 0) {
1779
2011
  return a.length > 0 && i.push(a), i.length > 0 ? i.map((e, i) => {
1780
2012
  let a = t;
1781
2013
  return i === 0 && r > 0 && (a -= r), {
1782
- ...nt(e, n),
2014
+ ...it(e, n),
1783
2015
  availableWidth: a
1784
2016
  };
1785
2017
  }) : [{
1786
- ...nt(e, n),
2018
+ ...it(e, n),
1787
2019
  availableWidth: t
1788
2020
  }];
1789
2021
  }
1790
- function it(e, t, n) {
1791
- return rt(e, t, n, 0);
2022
+ function ot(e, t, n) {
2023
+ return at(e, t, n, 0);
1792
2024
  }
1793
2025
  //#endregion
1794
2026
  //#region src/utils/deserialization/parseInlines.ts
1795
- var at = 0;
1796
- function ot(e) {
2027
+ var st = 0;
2028
+ function ct(e) {
1797
2029
  switch (e.type) {
1798
2030
  case "text": {
1799
2031
  let t = e;
1800
2032
  if (!t.text) return null;
1801
- let n = t.props.fontSize || 14, r = t.props.fontFamily || t.props.runfonts?.eastAsia || "SimSun", i = t.props.bold === "bold", a = t.props.italic === "italic", o = B(t.text, n, r, i, a), s = o.length > 0 ? o[o.length - 1] + z(t.text[t.text.length - 1], n, r, i, a) : 0, c = {
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 = {
1802
2034
  type: "text",
1803
2035
  value: t.text,
1804
2036
  fontFamily: r,
@@ -1813,7 +2045,7 @@ function ot(e) {
1813
2045
  return t.props.dotAbove && (c.dotAbove = !0), t.props.wavyLine && (c.wavyLine = !0), t.props.underline && (c.underline = !0), t.props.strikethrough && (c.strikethrough = !0), t.props.backgroundColor && (c.backgroundColor = t.props.backgroundColor), t.props.verticalAlign !== void 0 && t.props.verticalAlign !== 0 && (c.verticalAlign = t.props.verticalAlign), t.props.color?.val && (c.color = t.props.color.val), c;
1814
2046
  }
1815
2047
  case "latex": {
1816
- let t = e, n = t.value || t.props.raw || "", { svg: r, width: i, height: a } = K(n);
2048
+ let t = e, n = t.value || t.props.raw || "", { svg: r, width: i, height: a } = De(n);
1817
2049
  return {
1818
2050
  type: "formula",
1819
2051
  width: i,
@@ -1823,7 +2055,7 @@ function ot(e) {
1823
2055
  };
1824
2056
  }
1825
2057
  case "mathml": {
1826
- let t = e, n = t.value || t.props.raw || "", { svg: r, width: i, height: a } = Ae(n);
2058
+ let t = e, n = t.value || t.props.raw || "", { svg: r, width: i, height: a } = je(n);
1827
2059
  return {
1828
2060
  type: "formula",
1829
2061
  width: i,
@@ -1837,7 +2069,7 @@ function ot(e) {
1837
2069
  let t = e, n = t.props.rect?.width || 80;
1838
2070
  return {
1839
2071
  type: "underline",
1840
- id: t.props.ulId || `ul-${++at}`,
2072
+ id: t.props.ulId || `ul-${++st}`,
1841
2073
  width: n,
1842
2074
  height: 20,
1843
2075
  placeholder: t.props.placeholder || "空",
@@ -1907,88 +2139,126 @@ function ot(e) {
1907
2139
  }
1908
2140
  //#endregion
1909
2141
  //#region src/utils/deserialization/parseQuestions.ts
1910
- var st = 0;
1911
- function ct(e, t, n, r) {
1912
- let i = [], a = e.props, o = e.children.find((e) => e.type === "question-stem");
1913
- if (!o) return i;
1914
- let s = a.topicId.includes("_Block_"), c = t ? t - (s ? Ie : Fe) : void 0, l = [];
1915
- for (let e of o.children) e.type === "paragraph" && l.push(ut(e, c, n, r));
1916
- st++;
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;
2146
+ let s = a.topicId.includes("_Block_"), c = t ? t - (s ? Le : Ie) : void 0, l = [];
2147
+ for (let e of o[0].children) e.type === "paragraph" && l.push(ft(e, c, n, r));
2148
+ lt++;
1917
2149
  let u = {
1918
- id: `sw-${a.topicId}-${st}`,
2150
+ id: `sw-${a.topicId}-${lt}`,
1919
2151
  type: s ? "sub-question" : "question",
1920
2152
  paragraphs: l,
1921
2153
  height: l.reduce((e, t) => e + (t.height || 26), 0),
1922
2154
  metadata: {
1923
2155
  questionNo: s ? "" : a.topicIndex,
1924
2156
  subLabel: s ? a.topicIndex : "",
1925
- score: lt(e),
2157
+ score: dt(e),
1926
2158
  topicId: a.topicId,
1927
2159
  label: a.topicIndex,
1928
2160
  blockGroup: a.isMaterial ? a.topicId.split("_Block_")[0] : void 0,
1929
2161
  qid: a.qid
1930
2162
  }
1931
2163
  }, d = e.children.find((e) => e.type === "option");
1932
- if (d && d.children && d.children.length > 0 && (u.questionType = a.choiceMarkingType === 2 ? "single_chose" : "multi_chose", u.options = d.children.map((e) => {
1933
- let t = [];
1934
- for (let i of e.children) i.type === "paragraph" && t.push(ut(i, c, n, r));
1935
- return {
1936
- label: e.props.oriLabel || e.props.label?.replace(".", "") || "",
1937
- contentHtml: "",
1938
- paragraphs: t
1939
- };
1940
- })), 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 {
1941
2203
  let e = JSON.parse(a.blockMeta);
1942
2204
  Object.assign(u.metadata, e);
1943
2205
  } catch {}
1944
2206
  return i.push(u), i;
1945
2207
  }
1946
- function lt(e) {
2208
+ function dt(e) {
1947
2209
  for (let t of e.children) if (t.type === "question-stem") {
1948
2210
  for (let e of t.children) for (let t of e.children) if (t.type === "question-score") return `${t.props.score}`;
1949
2211
  }
1950
2212
  for (let t of e.children) if (t.type === "correction-box") return `${t.props.score}`;
1951
2213
  return "";
1952
2214
  }
1953
- function ut(e, t, n, r) {
2215
+ function ft(e, t, n, r) {
1954
2216
  let i = [];
1955
2217
  for (let t of e.children) {
1956
- let e = ot(t);
2218
+ let e = ct(t);
1957
2219
  e && i.push(e);
1958
2220
  }
1959
- i.length === 0 && i.push({
2221
+ if (i.length === 0 && i.push({
1960
2222
  type: "enter",
1961
2223
  width: 20,
1962
2224
  height: 20
1963
- });
1964
- 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";
1965
2235
  if (t && t > 0 && i.length > 0) {
1966
- 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;
1967
2237
  return {
1968
2238
  lines: n,
1969
2239
  y: 0,
1970
2240
  height: r,
1971
- justification: o && o !== "left" ? o : void 0,
1972
- split: s
2241
+ justification: s && s !== "left" ? s : void 0,
2242
+ split: c
1973
2243
  };
1974
2244
  }
1975
- let o = {
2245
+ let s = {
1976
2246
  elements: i,
1977
2247
  baseline: a * .5,
1978
2248
  lineHeight: a,
1979
2249
  y: 0
1980
- }, s = e.props?.justification, c = e.props?.split;
2250
+ }, c = e.props?.justification, l = e.props?.split;
1981
2251
  return {
1982
- lines: [o],
2252
+ lines: [s],
1983
2253
  y: 0,
1984
- height: a + 4,
1985
- justification: s && s !== "left" ? s : void 0,
1986
- split: c
2254
+ height: o ? a : a + 4,
2255
+ justification: c && c !== "left" ? c : void 0,
2256
+ split: l
1987
2257
  };
1988
2258
  }
1989
2259
  //#endregion
1990
2260
  //#region src/utils/deserialization/parseDocument.ts
1991
- function dt(e) {
2261
+ function pt(e) {
1992
2262
  let t;
1993
2263
  try {
1994
2264
  t = JSON.parse(e);
@@ -1999,9 +2269,9 @@ function dt(e) {
1999
2269
  if (!t.body || typeof t.body != "object") throw Error("[documentSerializer] 文档格式错误: 缺少 body 字段");
2000
2270
  if (!t.body.props || !t.body.props.paper) throw Error("[documentSerializer] 文档格式错误: 缺少 body.props.paper");
2001
2271
  if (!Array.isArray(t.body.children)) throw Error("[documentSerializer] 文档格式错误: body.children 应为数组");
2002
- return delete t._pages, delete t._regions, ft(t);
2272
+ return delete t._pages, delete t._regions, mt(t);
2003
2273
  }
2004
- function ft(e) {
2274
+ function mt(e) {
2005
2275
  let t = e.body, n = t.props.paper, r = n.padding || {
2006
2276
  top: 50,
2007
2277
  right: 56,
@@ -2035,10 +2305,10 @@ function ft(e) {
2035
2305
  }
2036
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, _ = [];
2037
2307
  for (let e of t.children) for (let t of e.children) if (t.type === "vueplug") {
2038
- let e = pt(t);
2308
+ let e = ht(t);
2039
2309
  e && _.push(e);
2040
2310
  } else if (t.type === "question") {
2041
- let e = ct(t, g, o, c);
2311
+ let e = ut(t, g, o, c);
2042
2312
  _.push(...e);
2043
2313
  }
2044
2314
  return {
@@ -2051,7 +2321,7 @@ function ft(e) {
2051
2321
  totalScore: p
2052
2322
  };
2053
2323
  }
2054
- function pt(e) {
2324
+ function ht(e) {
2055
2325
  let t = e.props?.bind || {}, n = t?.topicTitle || t?.title || t?.input || "";
2056
2326
  if (!n) return null;
2057
2327
  let r = {
@@ -2059,7 +2329,7 @@ function pt(e) {
2059
2329
  isTitle: !0
2060
2330
  };
2061
2331
  return t.topicTitle && (r.title = String(t.title || "")), {
2062
- id: `title-${e.props.id}-${++mt}`,
2332
+ id: `title-${e.props.id}-${++gt}`,
2063
2333
  type: "title",
2064
2334
  paragraphs: [],
2065
2335
  height: e.props.rect?.height || 40,
@@ -2067,11 +2337,11 @@ function pt(e) {
2067
2337
  keepNext: e.props.keepNext ?? !1
2068
2338
  };
2069
2339
  }
2070
- var mt = 0;
2340
+ var gt = 0;
2071
2341
  //#endregion
2072
2342
  //#region src/utils/documentSerializer.ts
2073
- function ht(e, t, n = {}) {
2074
- let r = Ye(e, t), i = {
2343
+ function _t(e, t, n = {}) {
2344
+ let r = Ze(e, t), i = {
2075
2345
  info: {
2076
2346
  author: "",
2077
2347
  created: "",
@@ -2324,22 +2594,22 @@ function ht(e, t, n = {}) {
2324
2594
  }]
2325
2595
  }
2326
2596
  },
2327
- theme: Me,
2328
- styles: Ne,
2597
+ theme: Ne,
2598
+ styles: Pe,
2329
2599
  version: "1.3",
2330
2600
  mode: 1,
2331
2601
  lastUpdateTime: Date.now()
2332
2602
  };
2333
- 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);
2334
2604
  }
2335
- function gt(e) {
2336
- return dt(e);
2605
+ function vt(e) {
2606
+ return pt(e);
2337
2607
  }
2338
2608
  //#endregion
2339
2609
  //#region src/utils/questionHtmlParser.ts
2340
- var _t = 0, vt = 0, yt = 0, bt = .5;
2341
- function xt(e, t = {}) {
2342
- let { questionNo: n = "", score: r = "", contentWidth: i = 600, fontSize: a = 16, lineSpacing: o = 1, skipAnswerArea: s = !1, protectContent: c = !1 } = t, l = new DOMParser().parseFromString(e, "text/html"), u = [], d = Math.round(a * o * 1.67), f = n.length > 2 ? 26.25 : 17.5, p = new Set([
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([
2343
2613
  "p",
2344
2614
  "h1",
2345
2615
  "h2",
@@ -2357,7 +2627,7 @@ function xt(e, t = {}) {
2357
2627
  if (t.nodeType !== Node.ELEMENT_NODE) continue;
2358
2628
  let n = t, r = n.tagName.toLowerCase();
2359
2629
  if (r === "table") {
2360
- 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;
2361
2631
  u.push({
2362
2632
  lines: e,
2363
2633
  y: 0,
@@ -2368,7 +2638,7 @@ function xt(e, t = {}) {
2368
2638
  if (r === "figure") {
2369
2639
  let e = n.querySelector("table");
2370
2640
  if (e) {
2371
- 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;
2372
2642
  u.push({
2373
2643
  lines: t,
2374
2644
  y: 0,
@@ -2382,50 +2652,36 @@ function xt(e, t = {}) {
2382
2652
  let e = Array.from(n.children).filter((e) => e.tagName.toLowerCase() === "p");
2383
2653
  if (e.length > 0) {
2384
2654
  for (let t of e) {
2385
- 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);
2386
2656
  if (n.length === 0) continue;
2387
- 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;
2388
2658
  u.push({
2389
2659
  lines: r,
2390
2660
  y: 0,
2391
2661
  height: o,
2392
- justification: Ct(n, e)
2662
+ justification: Tt(n, e, c)
2393
2663
  });
2394
2664
  }
2395
2665
  continue;
2396
2666
  }
2397
2667
  }
2398
- let o = n, s = o.getAttribute("style") || "", c = Y(o, a, s, i, f);
2399
- if (c.length === 0) continue;
2400
- 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;
2401
2671
  u.push({
2402
- lines: m,
2672
+ lines: h,
2403
2673
  y: 0,
2404
- height: h,
2405
- justification: Ct(c, s)
2674
+ height: g,
2675
+ justification: Tt(m, s, c)
2406
2676
  });
2407
2677
  }
2408
- if (!s) for (let e = 0; e < 2; e++) u.push({
2409
- lines: [{
2410
- elements: [{
2411
- type: "enter",
2412
- width: 20,
2413
- height: 20
2414
- }],
2415
- baseline: d * .5,
2416
- lineHeight: d,
2417
- y: 0
2418
- }],
2419
- y: 0,
2420
- height: d + 4
2421
- });
2422
- 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}`;
2423
2679
  return [{
2424
2680
  id: `q-html-${Date.now()}-${Math.random().toString(36).slice(2, 6)}`,
2425
2681
  type: "question",
2426
2682
  paragraphs: u,
2427
2683
  height: m,
2428
- protectContent: c,
2684
+ protectContent: s,
2429
2685
  metadata: {
2430
2686
  questionNo: n,
2431
2687
  score: r,
@@ -2435,36 +2691,36 @@ function xt(e, t = {}) {
2435
2691
  }
2436
2692
  }];
2437
2693
  }
2438
- function Y(e, t, n, r, i) {
2439
- let a = [];
2440
- for (let o = 0; o < e.childNodes.length; o++) {
2441
- let s = e.childNodes[o];
2442
- if (s.nodeType === Node.TEXT_NODE) {
2443
- 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 || "";
2444
2700
  if (!e || e === "\n") continue;
2445
2701
  let r = e.replace(/\u00A0/g, " ").replace(/\n/g, "").replace(/\s+/g, " ");
2446
2702
  if (!r.trim()) {
2447
- if (a.length > 0) {
2448
- let e = Et(n) || t, r = Dt(n) || "\"Times New Roman\", SimSun", i = Ot(n) || "#000", o = /font-style:\s*(italic|oblique)/.test(n);
2449
- a.push(wt("\xA0", e, r, !1, i, o));
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));
2450
2706
  }
2451
2707
  continue;
2452
2708
  }
2453
- let i = r.startsWith(" ") && a.length > 0, o = r.endsWith(" "), c = r.trim(), l = (i ? "\xA0" : "") + c + (o ? "\xA0" : ""), u = Et(n) || t, d = Dt(n) || "\"Times New Roman\", SimSun", f = Ot(n) || "#000", p = /font-weight:\s*(bold|700|[89]\d\d)/.test(n), m = /font-style:\s*(italic|oblique)/.test(n);
2454
- a.push(wt(l, u, d, p, f, m));
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));
2455
2711
  continue;
2456
2712
  }
2457
- if (s.nodeType !== Node.ELEMENT_NODE) continue;
2458
- let c = s, l = c.tagName.toLowerCase(), u = c.getAttribute("style") || "", d = c.getAttribute("class") || "";
2459
- if (l === "img" && (d.includes("Wirisformula") || c.hasAttribute("data-latex") || c.hasAttribute("data-mathml"))) {
2460
- 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;
2461
2717
  if (e) {
2462
2718
  let n = e.replace(/\\style\{[^}]*\}\{/, "{").replace(/^\\style\{[^}]*\}/, "") || e;
2463
- t = n, r = K(n);
2719
+ t = n, r = De(n);
2464
2720
  } else {
2465
- let e = c.getAttribute("data-mathml") || "";
2721
+ let e = l.getAttribute("data-mathml") || "";
2466
2722
  if (e) {
2467
- r = Ae(e), t = "";
2723
+ r = je(e), t = "";
2468
2724
  try {
2469
2725
  n = decodeURIComponent(e);
2470
2726
  } catch {
@@ -2472,7 +2728,7 @@ function Y(e, t, n, r, i) {
2472
2728
  }
2473
2729
  } else continue;
2474
2730
  }
2475
- a.push({
2731
+ o.push({
2476
2732
  type: "formula",
2477
2733
  width: r.width,
2478
2734
  height: r.height,
@@ -2482,33 +2738,37 @@ function Y(e, t, n, r, i) {
2482
2738
  });
2483
2739
  continue;
2484
2740
  }
2485
- if (l === "img") {
2486
- let e = c.getAttribute("src") || "";
2741
+ if (u === "img") {
2742
+ let e = l.getAttribute("src") || "";
2487
2743
  if (!e) continue;
2488
- 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;
2489
2745
  if (s) {
2490
2746
  let e = parseFloat(s[1]);
2491
- 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);
2492
2748
  }
2493
- a.push({
2749
+ if (c > r) {
2750
+ let e = u / c;
2751
+ c = r, u = Math.round(c * e);
2752
+ }
2753
+ o.push({
2494
2754
  type: "image",
2495
- id: `inline-img-${++yt}`,
2755
+ id: `inline-img-${++xt}`,
2496
2756
  src: e,
2497
- width: l,
2498
- height: d
2757
+ width: c,
2758
+ height: u
2499
2759
  });
2500
2760
  continue;
2501
2761
  }
2502
- let f = St(d);
2503
- if (l === "span" && f) {
2504
- 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;
2505
2765
  if (t === "tiankong") {
2506
2766
  let t = (e.match(/\s/g) || []).length;
2507
2767
  r = e.trim() ? Math.max(80, e.length * 14) : Math.max(80, t * 12);
2508
2768
  } else r = Math.max(40, e.length * 14 + 10);
2509
- a.push({
2769
+ o.push({
2510
2770
  type: "underline",
2511
- id: `ul-html-${++_t}`,
2771
+ id: `ul-html-${++yt}`,
2512
2772
  width: r,
2513
2773
  height: 20,
2514
2774
  placeholder: t === "tiankong" ? "空" : t === "xuanze" ? "选" : "判",
@@ -2519,24 +2779,24 @@ function Y(e, t, n, r, i) {
2519
2779
  });
2520
2780
  continue;
2521
2781
  }
2522
- if (l === "span" && d.includes("under-point")) {
2523
- let e = c.textContent || "";
2782
+ if (u === "span" && f.includes("under-point")) {
2783
+ let e = l.textContent || "";
2524
2784
  if (e.trim()) {
2525
- let r = Et(u) || Et(n) || t, i = Dt(u) || Dt(n) || "\"Times New Roman\", SimSun", o = Ot(u) || Ot(n) || "#000", s = /font-style:\s*(italic|oblique)/.test(u) || /font-style:\s*(italic|oblique)/.test(n), c = wt(e.trim(), r, i, !1, o, s);
2526
- 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);
2527
2787
  }
2528
2788
  continue;
2529
2789
  }
2530
- if (l === "span" && d.includes("wavy-line")) {
2531
- let e = c.textContent || "";
2790
+ if (u === "span" && f.includes("wavy-line")) {
2791
+ let e = l.textContent || "";
2532
2792
  if (e.trim()) {
2533
- let r = Et(u) || Et(n) || t, i = Dt(u) || Dt(n) || "\"Times New Roman\", SimSun", o = Ot(u) || Ot(n) || "#000", s = /font-style:\s*(italic|oblique)/.test(u) || /font-style:\s*(italic|oblique)/.test(n), c = wt(e.trim(), r, i, !1, o, s);
2534
- 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);
2535
2795
  }
2536
2796
  continue;
2537
2797
  }
2538
- if (l === "br") {
2539
- a.push({
2798
+ if (u === "br") {
2799
+ o.push({
2540
2800
  type: "enter",
2541
2801
  width: 0,
2542
2802
  height: 0,
@@ -2544,98 +2804,98 @@ function Y(e, t, n, r, i) {
2544
2804
  });
2545
2805
  continue;
2546
2806
  }
2547
- if (l === "strong" || l === "b") {
2548
- let e = Y(c, t, u ? u + ";font-weight:bold" : "font-weight:bold", r, i);
2549
- 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);
2550
2810
  continue;
2551
2811
  }
2552
- if (l === "em" || l === "i") {
2553
- let e = Y(c, t, u ? u + ";font-style:italic" : "font-style:italic", r, i);
2554
- 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);
2555
2815
  continue;
2556
2816
  }
2557
- if (l === "u" || l === "ins") {
2558
- 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);
2559
2819
  for (let t of e) t.type === "text" && (t.underline = !0);
2560
- a.push(...e);
2820
+ o.push(...e);
2561
2821
  continue;
2562
2822
  }
2563
- if (l === "s" || l === "strike" || l === "del") {
2564
- 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);
2565
2825
  for (let t of e) t.type === "text" && (t.strikethrough = !0);
2566
- a.push(...e);
2826
+ o.push(...e);
2567
2827
  continue;
2568
2828
  }
2569
- if (l === "table") {
2570
- 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;
2571
- 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({
2572
2832
  type: "image",
2573
- id: `inline-img-${++yt}`,
2833
+ id: `inline-img-${++xt}`,
2574
2834
  src: "",
2575
2835
  width: Math.min(s, r),
2576
- height: o,
2836
+ height: a,
2577
2837
  rawHtml: e
2578
2838
  });
2579
2839
  continue;
2580
2840
  }
2581
- if (l === "figure") {
2582
- let e = c.querySelector("table");
2841
+ if (u === "figure") {
2842
+ let e = l.querySelector("table");
2583
2843
  if (e) {
2584
- 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;
2585
- 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({
2586
2846
  type: "image",
2587
- id: `inline-img-${++yt}`,
2847
+ id: `inline-img-${++xt}`,
2588
2848
  src: "",
2589
2849
  width: Math.min(l, r),
2590
2850
  height: c,
2591
2851
  rawHtml: t
2592
2852
  });
2593
2853
  } else {
2594
- let e = Y(c, t, u || n, r, i);
2595
- a.push(...e);
2854
+ let e = Y(l, t, d || n, r, i, a);
2855
+ o.push(...e);
2596
2856
  }
2597
2857
  continue;
2598
2858
  }
2599
- if (l === "sub" || l === "sup") {
2600
- 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);
2601
- for (let e of o) e.type === "text" && (e.verticalAlign = s);
2602
- 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);
2603
2863
  continue;
2604
2864
  }
2605
- if (l === "span" || l === "a" || l === "div" || l === "font") {
2606
- let e = u || n, o = /font-weight:\s*(bold|700|[89]\d\d)/.test(u), s = /font-style:\s*(italic|oblique)/.test(u);
2607
- o && !/font-weight/.test(e) && (e += ";font-weight:bold"), s && !/font-style/.test(e) && (e += ";font-style:italic");
2608
- let l = Y(c, t, e, r, i), d = u.match(/text-decoration:\s*([^;]+)/);
2609
- if (d) {
2610
- let e = d[1];
2611
- 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") {
2612
2872
  let n = t;
2613
2873
  e.includes("underline") && (n.underline = !0), e.includes("line-through") && (n.strikethrough = !0);
2614
2874
  }
2615
2875
  }
2616
- let f = u.match(/background-color:\s*([^;]+)/);
2617
- if (f && f[1] && f[1] !== "transparent") {
2618
- let e = jt(f[1]);
2619
- 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);
2620
2880
  }
2621
- a.push(...l);
2881
+ o.push(...u);
2622
2882
  continue;
2623
2883
  }
2624
- if (l === "p") {
2625
- let e = Y(c, t, u || n, r, i);
2626
- if (e.length > 0 && e.every((e) => e.type === "image" && !e.rawHtml)) for (let t of e) {
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) {
2627
2887
  let e = t, n = e.height / e.width || .6;
2628
2888
  e.width = r, e.height = Math.round(r * n);
2629
2889
  }
2630
- a.push(...e);
2890
+ o.push(...e);
2631
2891
  continue;
2632
2892
  }
2633
- let p = Y(c, t, u || n, r, i);
2634
- a.push(...p);
2893
+ let m = Y(l, t, d || n, r, i);
2894
+ o.push(...m);
2635
2895
  }
2636
- return a;
2896
+ return o;
2637
2897
  }
2638
- function St(e) {
2898
+ function wt(e) {
2639
2899
  return e.includes("blank-tiankong") || e.includes("blank_tiankong") ? {
2640
2900
  blankType: "tiankong",
2641
2901
  isEmpty: !0
@@ -2647,13 +2907,13 @@ function St(e) {
2647
2907
  isEmpty: !1
2648
2908
  } : null;
2649
2909
  }
2650
- function Ct(e, t) {
2651
- if (e.length > 0 && e.every((e) => e.type === "image" && !e.rawHtml)) return "right";
2652
- let n = Tt(t);
2653
- return n === "center" ? "center" : n === "right" ? "right" : void 0;
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;
2654
2914
  }
2655
- function wt(e, t, n, r, i, a) {
2656
- let o = e.split(""), s = B(e, t, n, r, a || !1), c = s.length > 0 ? s[s.length - 1] + z(o[o.length - 1], t, n, r, a || !1) : 0;
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;
2657
2917
  return {
2658
2918
  type: "text",
2659
2919
  value: e,
@@ -2667,19 +2927,19 @@ function wt(e, t, n, r, i, a) {
2667
2927
  xPositions: s
2668
2928
  };
2669
2929
  }
2670
- function Tt(e) {
2930
+ function Dt(e) {
2671
2931
  let t = e.match(/text-align:\s*(right|center|left)/);
2672
2932
  return t ? t[1] : "left";
2673
2933
  }
2674
- function Et(e) {
2934
+ function Ot(e) {
2675
2935
  let t = e.match(/font-size:\s*(\d+)px/);
2676
2936
  return t ? parseInt(t[1]) : null;
2677
2937
  }
2678
- function Dt(e) {
2938
+ function kt(e) {
2679
2939
  let t = e.match(/font-family:\s*([^;]+)/);
2680
2940
  return t ? t[1].trim().replace(/["']/g, "") : null;
2681
2941
  }
2682
- function Ot(e) {
2942
+ function At(e) {
2683
2943
  let t = e.match(/color:\s*rgb\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)/);
2684
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")}`;
2685
2945
  let n = e.match(/color:\s*rgba\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,[^)]+\)/);
@@ -2687,9 +2947,9 @@ function Ot(e) {
2687
2947
  let r = e.match(/color:\s*(#[0-9a-fA-F]{3,6})/);
2688
2948
  if (r) return r[1];
2689
2949
  let i = e.match(/color:\s*([a-zA-Z]+)/);
2690
- return i && At(i[1]) || null;
2950
+ return i && Mt(i[1]) || null;
2691
2951
  }
2692
- var kt = {
2952
+ var jt = {
2693
2953
  red: "#ff0000",
2694
2954
  green: "#008000",
2695
2955
  blue: "#0000ff",
@@ -2716,24 +2976,24 @@ var kt = {
2716
2976
  lightgrey: "#d3d3d3",
2717
2977
  transparent: "#000000"
2718
2978
  };
2719
- function At(e) {
2720
- return kt[e.toLowerCase()];
2979
+ function Mt(e) {
2980
+ return jt[e.toLowerCase()];
2721
2981
  }
2722
- function jt(e) {
2982
+ function Nt(e) {
2723
2983
  let t = e.trim(), n = t.match(/^#[0-9a-fA-F]{3,6}$/);
2724
2984
  if (n) return n[0];
2725
2985
  let r = t.match(/^rgb\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)$/);
2726
- return r ? `#${parseInt(r[1]).toString(16).padStart(2, "0")}${parseInt(r[2]).toString(16).padStart(2, "0")}${parseInt(r[3]).toString(16).padStart(2, "0")}` : At(t) || null;
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;
2727
2987
  }
2728
- function Mt(e, t, n) {
2988
+ function Pt(e, t, n) {
2729
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;
2730
2990
  return u <= 0 || d <= 0 ? [{
2731
- ...nt([], n),
2991
+ ...it([], n),
2732
2992
  availableWidth: t
2733
2993
  }] : [{
2734
- ...nt([{
2994
+ ...it([{
2735
2995
  type: "image",
2736
- id: `inline-img-${++yt}`,
2996
+ id: `inline-img-${++xt}`,
2737
2997
  src: "",
2738
2998
  width: u,
2739
2999
  height: d,
@@ -2744,16 +3004,16 @@ function Mt(e, t, n) {
2744
3004
  }
2745
3005
  //#endregion
2746
3006
  //#region src/utils/questionJsonParser.ts
2747
- function Nt(e, t = {}) {
3007
+ function Ft(e, t = {}) {
2748
3008
  let { questionNo: n = "", score: r = "", contentWidth: i = 600, fontSize: a = 16, lineSpacing: o = 1, protectContent: s = !1 } = t;
2749
- return e.children && e.children.length > 0 ? Ft(e, {
3009
+ return e.children && e.children.length > 0 ? Lt(e, {
2750
3010
  questionNo: n,
2751
3011
  score: r,
2752
3012
  contentWidth: i,
2753
3013
  fontSize: a,
2754
3014
  lineSpacing: o,
2755
3015
  protectContent: s
2756
- }) : Pt(e, {
3016
+ }) : It(e, {
2757
3017
  questionNo: n,
2758
3018
  score: r,
2759
3019
  contentWidth: i,
@@ -2762,26 +3022,25 @@ function Nt(e, t = {}) {
2762
3022
  protectContent: s
2763
3023
  });
2764
3024
  }
2765
- function Pt(e, t) {
2766
- let { questionNo: n, score: r, contentWidth: i, fontSize: a, lineSpacing: o, protectContent: s } = t, c = e.extra_json?.quest_type || "answer_question", l = c === "single_chose" || c === "multi_chose", u = Math.round(a * o * 1.67), d = xt(e.question, {
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, {
2767
3027
  questionNo: n,
2768
3028
  score: r,
2769
3029
  contentWidth: i,
2770
3030
  fontSize: a,
2771
3031
  lineSpacing: o,
2772
- skipAnswerArea: !0,
2773
3032
  protectContent: s
2774
3033
  });
2775
- if (d.length === 0) return [];
2776
- let f = d[0], p = {
2777
- id: f.id,
3034
+ if (u.length === 0) return [];
3035
+ let d = u[0], f = {
3036
+ id: d.id,
2778
3037
  type: "question",
2779
- paragraphs: [...f.paragraphs],
3038
+ paragraphs: [...d.paragraphs],
2780
3039
  height: 0,
2781
3040
  protectContent: s,
2782
3041
  questionType: c,
2783
3042
  metadata: {
2784
- ...f.metadata,
3043
+ ...d.metadata,
2785
3044
  qid: e.qid,
2786
3045
  questType: c,
2787
3046
  answer: e.extra_json?.answer || e.answer || "",
@@ -2790,22 +3049,46 @@ function Pt(e, t) {
2790
3049
  tags: e.tags
2791
3050
  }
2792
3051
  };
2793
- if (l && e.extra_json?.options && e.extra_json.options.length > 0) p.options = It(e.extra_json.options, i, a, o), p.paragraphs.push(Lt(u));
2794
- else for (let e = 0; e < 2; e++) p.paragraphs.push(Lt(u));
2795
- 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];
2796
3080
  }
2797
- function Ft(e, t) {
2798
- let { questionNo: n, score: r, contentWidth: i, fontSize: a, lineSpacing: o, protectContent: s } = t, c = "answer_question", l = Math.round(a * o * 1.67), u = Date.now(), d = Math.random().toString(36).slice(2, 8), f = e.id ? `group-${e.id}-${u}-${d}` : `group-${e.qid || u}-${d}`, p = Math.max(100, i - 26.25), m = [], h = xt(e.question, {
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, {
2799
3083
  questionNo: n,
2800
3084
  score: r || "",
2801
3085
  contentWidth: i,
2802
3086
  fontSize: a,
2803
3087
  lineSpacing: o,
2804
- skipAnswerArea: !0,
2805
3088
  protectContent: s
2806
3089
  });
2807
- if (h.length > 0) {
2808
- let t = h[0];
3090
+ if (m.length > 0) {
3091
+ let t = m[0];
2809
3092
  t.type = "question", t.metadata = {
2810
3093
  ...t.metadata,
2811
3094
  qid: e.qid,
@@ -2813,50 +3096,45 @@ function Ft(e, t) {
2813
3096
  answer: e.extra_json?.answer || e.answer || "",
2814
3097
  tenantId: e.tenant_id,
2815
3098
  tags: e.tags,
2816
- blockGroup: f,
3099
+ blockGroup: d,
2817
3100
  hasSubQuestions: !0,
2818
3101
  score: r || ""
2819
- }, t.keepNext = !0;
2820
- for (let e = 0; e < 2; e++) t.paragraphs.push(Lt(l));
2821
- t.height = t.paragraphs.reduce((e, t) => e + (t.height || 26), 0), m.push(t);
3102
+ }, t.keepNext = !0, t.height = t.paragraphs.reduce((e, t) => e + (t.height || 26), 0), p.push(t);
2822
3103
  }
2823
3104
  if (e.children) for (let t = 0; t < e.children.length; t++) {
2824
- let n = e.children[t], r = `(${t + 1})`, i = xt(n.question, {
2825
- contentWidth: p,
3105
+ let n = e.children[t], r = `(${t + 1})`, i = Ct(n.question, {
3106
+ contentWidth: f,
2826
3107
  fontSize: a,
2827
3108
  lineSpacing: o,
2828
- skipAnswerArea: !0,
2829
3109
  protectContent: s
2830
3110
  });
2831
3111
  if (i.length === 0) continue;
2832
- let u = i[0];
2833
- u.type = "sub-question", u.metadata = {
2834
- ...u.metadata,
3112
+ let l = i[0];
3113
+ l.type = "sub-question", l.metadata = {
3114
+ ...l.metadata,
2835
3115
  questionNo: "",
2836
3116
  subLabel: r,
2837
3117
  label: `子题${r}`,
2838
- topicId: `${f}-sub${t + 1}`,
2839
- blockGroup: f,
3118
+ topicId: `${d}-sub${t + 1}`,
3119
+ blockGroup: d,
2840
3120
  qid: n.qid,
2841
3121
  answer: n.answer || n.extra_json?.answer || "",
2842
3122
  questType: c,
2843
3123
  tenantId: n.tenant_id,
2844
3124
  tags: n.tags,
2845
3125
  score: ""
2846
- };
2847
- for (let e = 0; e < 2; e++) u.paragraphs.push(Lt(l));
2848
- u.height = u.paragraphs.reduce((e, t) => e + (t.height || 26), 0), m.push(u);
3126
+ }, l.height = l.paragraphs.reduce((e, t) => e + (t.height || 26), 0), p.push(l);
2849
3127
  }
2850
- return m;
3128
+ return p;
2851
3129
  }
2852
- function It(e, t, n, r) {
3130
+ function Rt(e, t, n, r) {
2853
3131
  let i = Math.max(100, t - 20);
2854
3132
  return e.map((e) => {
2855
- 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>`, {
2856
3134
  contentWidth: i,
2857
3135
  fontSize: n,
2858
3136
  lineSpacing: r,
2859
- skipAnswerArea: !0
3137
+ inlineOnly: !0
2860
3138
  }), a = [];
2861
3139
  if (t.length > 0 && a.push(...t[0].paragraphs), a.length === 0) {
2862
3140
  let e = Math.round(n * r * 1.67);
@@ -2878,25 +3156,9 @@ function It(e, t, n, r) {
2878
3156
  };
2879
3157
  });
2880
3158
  }
2881
- function Lt(e) {
2882
- return {
2883
- lines: [{
2884
- elements: [{
2885
- type: "enter",
2886
- width: 20,
2887
- height: 20
2888
- }],
2889
- baseline: e * .5,
2890
- lineHeight: e,
2891
- y: 0
2892
- }],
2893
- y: 0,
2894
- height: e + 4
2895
- };
2896
- }
2897
3159
  //#endregion
2898
3160
  //#region src/utils/chineseNumber.ts
2899
- var Rt = [
3161
+ var zt = [
2900
3162
  "",
2901
3163
  "一",
2902
3164
  "二",
@@ -2909,34 +3171,34 @@ var Rt = [
2909
3171
  "九",
2910
3172
  "十"
2911
3173
  ];
2912
- function zt(e) {
3174
+ function Bt(e) {
2913
3175
  if (e <= 0) return "";
2914
- if (e <= 10) return Rt[e];
3176
+ if (e <= 10) return zt[e];
2915
3177
  if (e < 20) {
2916
3178
  let t = e % 10;
2917
- return "十" + (t > 0 ? Rt[t] : "");
3179
+ return "十" + (t > 0 ? zt[t] : "");
2918
3180
  }
2919
3181
  if (e < 100) {
2920
3182
  let t = Math.floor(e / 10), n = e % 10;
2921
- return Rt[t] + "十" + (n > 0 ? Rt[n] : "");
3183
+ return zt[t] + "十" + (n > 0 ? zt[n] : "");
2922
3184
  }
2923
3185
  if (e < 1e3) {
2924
- let t = Math.floor(e / 100), n = e % 100, r = Rt[t] + "百";
2925
- return n === 0 ? r : n < 10 ? r + "零" + Rt[n] : r + zt(n);
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);
2926
3188
  }
2927
3189
  return String(e);
2928
3190
  }
2929
- function Bt(e, t) {
2930
- let n = zt(t);
3191
+ function Vt(e, t) {
3192
+ let n = Bt(t);
2931
3193
  return n ? n + "、" + e : e;
2932
3194
  }
2933
- function Vt(e) {
3195
+ function Ht(e) {
2934
3196
  let t = e.match(/^[一二三四五六七八九十百零]+、(.+)$/);
2935
3197
  return t ? t[1] : e;
2936
3198
  }
2937
3199
  //#endregion
2938
3200
  //#region src/utils/paperHtmlBuilder.ts
2939
- function Ht(e) {
3201
+ function Ut(e) {
2940
3202
  let t = j[e];
2941
3203
  return `
2942
3204
  /* ---------- Reset & Base ---------- */
@@ -3048,7 +3310,7 @@ text.swed-question-score {
3048
3310
  }
3049
3311
  .swed-title_wrapper .swed-title-content .swed-title-text {
3050
3312
  font-size: 15px;
3051
- font-weight: 600;
3313
+ font-weight: 400;
3052
3314
  line-height: 32px;
3053
3315
  color: #231f20;
3054
3316
  white-space: nowrap;
@@ -3265,7 +3527,7 @@ text.swed-question-score {
3265
3527
  }
3266
3528
  `;
3267
3529
  }
3268
- function Ut(e) {
3530
+ function Wt(e) {
3269
3531
  let { svgs: t, paperName: n = "试卷", paperSize: r = "A4" } = e, i = t.map((e) => {
3270
3532
  let t = e.match(/viewBox="0 0 (\d+(?:\.\d+)?)\s+(\d+(?:\.\d+)?)"/), [, n, r] = t ? [
3271
3533
  null,
@@ -3285,24 +3547,121 @@ function Ut(e) {
3285
3547
  <head>
3286
3548
  <meta charset="UTF-8">
3287
3549
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
3288
- <title>${Wt(n)}</title>
3289
- <style>${Ht(r)}</style>
3550
+ <title>${Gt(n)}</title>
3551
+ <style>${Ut(r)}</style>
3290
3552
  </head>
3291
3553
  <body>
3292
3554
  ${i}
3293
3555
  </body>
3294
3556
  </html>`;
3295
3557
  }
3296
- function Wt(e) {
3558
+ function Gt(e) {
3297
3559
  return e.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
3298
3560
  }
3299
3561
  //#endregion
3300
- //#region ../node_modules/qrcode/lib/can-promise.js
3301
- 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) => {
3302
3661
  t.exports = function() {
3303
3662
  return typeof Promise == "function" && Promise.prototype && Promise.prototype.then;
3304
3663
  };
3305
- })), X = /* @__PURE__ */ D(((e) => {
3664
+ })), $t = /* @__PURE__ */ D(((e) => {
3306
3665
  var t, n = [
3307
3666
  0,
3308
3667
  26,
@@ -3364,7 +3723,7 @@ var Gt = /* @__PURE__ */ D(((e, t) => {
3364
3723
  }, e.toSJIS = function(e) {
3365
3724
  return t(e);
3366
3725
  };
3367
- })), Kt = /* @__PURE__ */ D(((e) => {
3726
+ })), en = /* @__PURE__ */ D(((e) => {
3368
3727
  e.L = { bit: 1 }, e.M = { bit: 0 }, e.Q = { bit: 3 }, e.H = { bit: 2 };
3369
3728
  function t(t) {
3370
3729
  if (typeof t != "string") throw Error("Param is not a string");
@@ -3390,7 +3749,7 @@ var Gt = /* @__PURE__ */ D(((e, t) => {
3390
3749
  return r;
3391
3750
  }
3392
3751
  };
3393
- })), qt = /* @__PURE__ */ D(((e, t) => {
3752
+ })), tn = /* @__PURE__ */ D(((e, t) => {
3394
3753
  function n() {
3395
3754
  this.buffer = [], this.length = 0;
3396
3755
  }
@@ -3410,7 +3769,7 @@ var Gt = /* @__PURE__ */ D(((e, t) => {
3410
3769
  this.buffer.length <= t && this.buffer.push(0), e && (this.buffer[t] |= 128 >>> this.length % 8), this.length++;
3411
3770
  }
3412
3771
  }, t.exports = n;
3413
- })), Jt = /* @__PURE__ */ D(((e, t) => {
3772
+ })), nn = /* @__PURE__ */ D(((e, t) => {
3414
3773
  function n(e) {
3415
3774
  if (!e || e < 1) throw Error("BitMatrix size must be defined and greater than 0");
3416
3775
  this.size = e, this.data = new Uint8Array(e * e), this.reservedBit = new Uint8Array(e * e);
@@ -3425,8 +3784,8 @@ var Gt = /* @__PURE__ */ D(((e, t) => {
3425
3784
  }, n.prototype.isReserved = function(e, t) {
3426
3785
  return this.reservedBit[e * this.size + t];
3427
3786
  }, t.exports = n;
3428
- })), Yt = /* @__PURE__ */ D(((e) => {
3429
- var t = X().getSymbolSize;
3787
+ })), rn = /* @__PURE__ */ D(((e) => {
3788
+ var t = $t().getSymbolSize;
3430
3789
  e.getRowColCoords = function(e) {
3431
3790
  if (e === 1) return [];
3432
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];
@@ -3437,8 +3796,8 @@ var Gt = /* @__PURE__ */ D(((e, t) => {
3437
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]]);
3438
3797
  return n;
3439
3798
  };
3440
- })), Xt = /* @__PURE__ */ D(((e) => {
3441
- var t = X().getSymbolSize, n = 7;
3799
+ })), an = /* @__PURE__ */ D(((e) => {
3800
+ var t = $t().getSymbolSize, n = 7;
3442
3801
  e.getPositions = function(e) {
3443
3802
  let r = t(e);
3444
3803
  return [
@@ -3447,7 +3806,7 @@ var Gt = /* @__PURE__ */ D(((e, t) => {
3447
3806
  [0, r - n]
3448
3807
  ];
3449
3808
  };
3450
- })), Zt = /* @__PURE__ */ D(((e) => {
3809
+ })), on = /* @__PURE__ */ D(((e) => {
3451
3810
  e.Patterns = {
3452
3811
  PATTERN000: 0,
3453
3812
  PATTERN001: 1,
@@ -3523,8 +3882,8 @@ var Gt = /* @__PURE__ */ D(((e, t) => {
3523
3882
  }
3524
3883
  return i;
3525
3884
  };
3526
- })), Qt = /* @__PURE__ */ D(((e) => {
3527
- var t = Kt(), n = [
3885
+ })), sn = /* @__PURE__ */ D(((e) => {
3886
+ var t = en(), n = [
3528
3887
  1,
3529
3888
  1,
3530
3889
  1,
@@ -3864,7 +4223,7 @@ var Gt = /* @__PURE__ */ D(((e, t) => {
3864
4223
  default: return;
3865
4224
  }
3866
4225
  };
3867
- })), $t = /* @__PURE__ */ D(((e) => {
4226
+ })), cn = /* @__PURE__ */ D(((e) => {
3868
4227
  var t = new Uint8Array(512), n = new Uint8Array(256);
3869
4228
  (function() {
3870
4229
  let e = 1;
@@ -3878,8 +4237,8 @@ var Gt = /* @__PURE__ */ D(((e, t) => {
3878
4237
  }, e.mul = function(e, r) {
3879
4238
  return e === 0 || r === 0 ? 0 : t[n[e] + n[r]];
3880
4239
  };
3881
- })), en = /* @__PURE__ */ D(((e) => {
3882
- var t = $t();
4240
+ })), ln = /* @__PURE__ */ D(((e) => {
4241
+ var t = cn();
3883
4242
  e.mul = function(e, n) {
3884
4243
  let r = new Uint8Array(e.length + n.length - 1);
3885
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]);
@@ -3899,8 +4258,8 @@ var Gt = /* @__PURE__ */ D(((e, t) => {
3899
4258
  for (let i = 0; i < n; i++) r = e.mul(r, new Uint8Array([1, t.exp(i)]));
3900
4259
  return r;
3901
4260
  };
3902
- })), tn = /* @__PURE__ */ D(((e, t) => {
3903
- var n = en();
4261
+ })), un = /* @__PURE__ */ D(((e, t) => {
4262
+ var n = ln();
3904
4263
  function r(e) {
3905
4264
  this.genPoly = void 0, this.degree = e, this.degree && this.initialize(this.degree);
3906
4265
  }
@@ -3917,11 +4276,11 @@ var Gt = /* @__PURE__ */ D(((e, t) => {
3917
4276
  }
3918
4277
  return r;
3919
4278
  }, t.exports = r;
3920
- })), nn = /* @__PURE__ */ D(((e) => {
4279
+ })), dn = /* @__PURE__ */ D(((e) => {
3921
4280
  e.isValid = function(e) {
3922
4281
  return !isNaN(e) && e >= 1 && e <= 40;
3923
4282
  };
3924
- })), rn = /* @__PURE__ */ D(((e) => {
4283
+ })), fn = /* @__PURE__ */ D(((e) => {
3925
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])+";
3926
4285
  r = r.replace(/u/g, "\\u");
3927
4286
  var i = "(?:(?![A-Z0-9 $%*+\\-./:]|" + r + ")(?:.|[\r\n]))+";
@@ -3934,8 +4293,8 @@ var Gt = /* @__PURE__ */ D(((e, t) => {
3934
4293
  }, e.testAlphanumeric = function(e) {
3935
4294
  return s.test(e);
3936
4295
  };
3937
- })), an = /* @__PURE__ */ D(((e) => {
3938
- var t = nn(), n = rn();
4296
+ })), pn = /* @__PURE__ */ D(((e) => {
4297
+ var t = dn(), n = fn();
3939
4298
  e.NUMERIC = {
3940
4299
  id: "Numeric",
3941
4300
  bit: 1,
@@ -3998,8 +4357,8 @@ var Gt = /* @__PURE__ */ D(((e, t) => {
3998
4357
  return n;
3999
4358
  }
4000
4359
  };
4001
- })), on = /* @__PURE__ */ D(((e) => {
4002
- 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);
4003
4362
  function c(t, n, r) {
4004
4363
  for (let i = 1; i <= 40; i++) if (n <= e.getCapacity(i, r, t)) return i;
4005
4364
  }
@@ -4045,15 +4404,15 @@ var Gt = /* @__PURE__ */ D(((e, t) => {
4045
4404
  for (; t.getBCHDigit(n) - s >= 0;) n ^= o << t.getBCHDigit(n) - s;
4046
4405
  return e << 12 | n;
4047
4406
  };
4048
- })), sn = /* @__PURE__ */ D(((e) => {
4049
- 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);
4050
4409
  e.getEncodedBits = function(e, a) {
4051
4410
  let o = e.bit << 3 | a, s = o << 10;
4052
4411
  for (; t.getBCHDigit(s) - i >= 0;) s ^= n << t.getBCHDigit(s) - i;
4053
4412
  return (o << 10 | s) ^ r;
4054
4413
  };
4055
- })), cn = /* @__PURE__ */ D(((e, t) => {
4056
- var n = an();
4414
+ })), gn = /* @__PURE__ */ D(((e, t) => {
4415
+ var n = pn();
4057
4416
  function r(e) {
4058
4417
  this.mode = n.NUMERIC, this.data = e.toString();
4059
4418
  }
@@ -4069,8 +4428,8 @@ var Gt = /* @__PURE__ */ D(((e, t) => {
4069
4428
  let i = this.data.length - t;
4070
4429
  i > 0 && (n = this.data.substr(t), r = parseInt(n, 10), e.put(r, i * 3 + 1));
4071
4430
  }, t.exports = r;
4072
- })), ln = /* @__PURE__ */ D(((e, t) => {
4073
- var n = an(), r = /* @__PURE__ */ "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:".split("");
4431
+ })), _n = /* @__PURE__ */ D(((e, t) => {
4432
+ var n = pn(), r = /* @__PURE__ */ "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:".split("");
4074
4433
  function i(e) {
4075
4434
  this.mode = n.ALPHANUMERIC, this.data = e;
4076
4435
  }
@@ -4088,8 +4447,8 @@ var Gt = /* @__PURE__ */ D(((e, t) => {
4088
4447
  }
4089
4448
  this.data.length % 2 && e.put(r.indexOf(this.data[t]), 6);
4090
4449
  }, t.exports = i;
4091
- })), un = /* @__PURE__ */ D(((e, t) => {
4092
- var n = an();
4450
+ })), vn = /* @__PURE__ */ D(((e, t) => {
4451
+ var n = pn();
4093
4452
  function r(e) {
4094
4453
  this.mode = n.BYTE, typeof e == "string" ? this.data = new TextEncoder().encode(e) : this.data = new Uint8Array(e);
4095
4454
  }
@@ -4102,8 +4461,8 @@ var Gt = /* @__PURE__ */ D(((e, t) => {
4102
4461
  }, r.prototype.write = function(e) {
4103
4462
  for (let t = 0, n = this.data.length; t < n; t++) e.put(this.data[t], 8);
4104
4463
  }, t.exports = r;
4105
- })), dn = /* @__PURE__ */ D(((e, t) => {
4106
- var n = an(), r = X();
4464
+ })), yn = /* @__PURE__ */ D(((e, t) => {
4465
+ var n = pn(), r = $t();
4107
4466
  function i(e) {
4108
4467
  this.mode = n.KANJI, this.data = e;
4109
4468
  }
@@ -4123,7 +4482,7 @@ var Gt = /* @__PURE__ */ D(((e, t) => {
4123
4482
  n = (n >>> 8 & 255) * 192 + (n & 255), e.put(n, 13);
4124
4483
  }
4125
4484
  }, t.exports = i;
4126
- })), fn = /* @__PURE__ */ D(((e, t) => {
4485
+ })), bn = /* @__PURE__ */ D(((e, t) => {
4127
4486
  var n = {
4128
4487
  single_source_shortest_paths: function(e, t, r) {
4129
4488
  var i = {}, a = {};
@@ -4176,8 +4535,8 @@ var Gt = /* @__PURE__ */ D(((e, t) => {
4176
4535
  }
4177
4536
  };
4178
4537
  t !== void 0 && (t.exports = n);
4179
- })), pn = /* @__PURE__ */ D(((e) => {
4180
- 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();
4181
4540
  function l(e) {
4182
4541
  return unescape(encodeURIComponent(e)).length;
4183
4542
  }
@@ -4304,8 +4663,8 @@ var Gt = /* @__PURE__ */ D(((e, t) => {
4304
4663
  }, e.rawSplit = function(t) {
4305
4664
  return e.fromArray(d(t, s.isKanjiModeEnabled()));
4306
4665
  };
4307
- })), mn = /* @__PURE__ */ D(((e) => {
4308
- var t = X(), n = Kt(), r = qt(), i = Jt(), a = Yt(), o = Xt(), s = Zt(), c = Qt(), l = tn(), u = on(), d = sn(), f = an(), p = pn();
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();
4309
4668
  function m(e, t) {
4310
4669
  let n = e.size, r = o.getPositions(t);
4311
4670
  for (let t = 0; t < r.length; t++) {
@@ -4400,7 +4759,7 @@ var Gt = /* @__PURE__ */ D(((e, t) => {
4400
4759
  let i = n.M, a, o;
4401
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);
4402
4761
  };
4403
- })), hn = /* @__PURE__ */ D(((e) => {
4762
+ })), Cn = /* @__PURE__ */ D(((e) => {
4404
4763
  function t(e) {
4405
4764
  if (typeof e == "number" && (e = e.toString()), typeof e != "string") throw Error("Color should be defined as hex string");
4406
4765
  let t = e.slice().replace("#", "").split("");
@@ -4447,8 +4806,8 @@ var Gt = /* @__PURE__ */ D(((e, t) => {
4447
4806
  t[u++] = d.r, t[u++] = d.g, t[u++] = d.b, t[u] = d.a;
4448
4807
  }
4449
4808
  };
4450
- })), gn = /* @__PURE__ */ D(((e) => {
4451
- var t = hn();
4809
+ })), wn = /* @__PURE__ */ D(((e) => {
4810
+ var t = Cn();
4452
4811
  function n(e, t, n) {
4453
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";
4454
4813
  }
@@ -4470,8 +4829,8 @@ var Gt = /* @__PURE__ */ D(((e, t) => {
4470
4829
  let a = e.render(t, n, i), o = i.type || "image/png", s = i.rendererOpts || {};
4471
4830
  return a.toDataURL(o, s.quality);
4472
4831
  };
4473
- })), _n = /* @__PURE__ */ D(((e) => {
4474
- var t = hn();
4832
+ })), Tn = /* @__PURE__ */ D(((e) => {
4833
+ var t = Cn();
4475
4834
  function n(e, t) {
4476
4835
  let n = e.a / 255, r = t + "=\"" + e.hex + "\"";
4477
4836
  return n < 1 ? r + " " + t + "-opacity=\"" + n.toFixed(2).slice(1) + "\"" : r;
@@ -4492,8 +4851,8 @@ var Gt = /* @__PURE__ */ D(((e, t) => {
4492
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";
4493
4852
  return typeof a == "function" && a(null, p), p;
4494
4853
  };
4495
- })), vn = /* @__PURE__ */ k((/* @__PURE__ */ D(((e) => {
4496
- 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();
4497
4856
  function a(e, r, i, a, o) {
4498
4857
  let s = [].slice.call(arguments, 1), c = s.length, l = typeof s[c - 1] == "function";
4499
4858
  if (!l && !t()) throw Error("Callback required as last argument");
@@ -4521,10 +4880,10 @@ var Gt = /* @__PURE__ */ D(((e, t) => {
4521
4880
  return i.render(e, n);
4522
4881
  });
4523
4882
  })))(), 1);
4524
- async function yn(e, t = 200) {
4883
+ async function Dn(e, t = 200) {
4525
4884
  if (!e || e.trim() === "") return "";
4526
4885
  try {
4527
- return await vn.toDataURL(e, {
4886
+ return await En.toDataURL(e, {
4528
4887
  width: t,
4529
4888
  margin: 1,
4530
4889
  color: {
@@ -4539,7 +4898,7 @@ async function yn(e, t = 200) {
4539
4898
  }
4540
4899
  //#endregion
4541
4900
  //#region src/composables/usePaperSelection.ts
4542
- function bn(e) {
4901
+ function On(e) {
4543
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);
4544
4903
  function c(e) {
4545
4904
  n.value = e, e && (r.value = null, i.value = null);
@@ -4604,7 +4963,7 @@ function bn(e) {
4604
4963
  }
4605
4964
  //#endregion
4606
4965
  //#region src/composables/paperHelpers.ts
4607
- var xn = {
4966
+ var kn = {
4608
4967
  三号: 21,
4609
4968
  小三: 20,
4610
4969
  四号: 19,
@@ -4612,24 +4971,24 @@ var xn = {
4612
4971
  五号: 14,
4613
4972
  小五: 12
4614
4973
  };
4615
- function Sn(e) {
4616
- return xn[e] ?? 16;
4974
+ function An(e) {
4975
+ return kn[e] ?? 16;
4617
4976
  }
4618
- function Cn(e) {
4619
- 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;
4620
4979
  return "五号";
4621
4980
  }
4622
4981
  function Z(e) {
4623
- return typeof e.fontSize == "number" ? e.fontSize : Sn(e.fontSize || "小四");
4982
+ return typeof e.fontSize == "number" ? e.fontSize : An(e.fontSize || "小四");
4624
4983
  }
4625
4984
  function Q(e) {
4626
4985
  return e.lineSpacing ?? 1;
4627
4986
  }
4628
- function wn(e, t) {
4987
+ function Mn(e, t) {
4629
4988
  return Math.round(e * t * 35 / (14 * 1.5));
4630
4989
  }
4631
4990
  function $(e, t) {
4632
- let n = wn(e, t);
4991
+ let n = Mn(e, t);
4633
4992
  return {
4634
4993
  lines: [{
4635
4994
  elements: [{
@@ -4645,15 +5004,15 @@ function $(e, t) {
4645
5004
  height: n
4646
5005
  };
4647
5006
  }
4648
- function Tn(e, t, n, r, i = 0) {
4649
- let a = wn(t, n), o = r && r > 0 ? rt(e, r, a, i) : [nt(e, a)];
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)];
4650
5009
  return {
4651
5010
  lines: o,
4652
5011
  y: 0,
4653
5012
  height: o.reduce((e, t) => e + t.lineHeight, 0) + 4
4654
5013
  };
4655
5014
  }
4656
- function En(e) {
5015
+ function Pn(e) {
4657
5016
  let t = e.paragraphs.length;
4658
5017
  for (; t > 0;) {
4659
5018
  let n = e.paragraphs[t - 1];
@@ -4662,14 +5021,14 @@ function En(e) {
4662
5021
  }
4663
5022
  return t;
4664
5023
  }
4665
- var Dn = 0, On = 0;
4666
- function kn(e) {
5024
+ var Fn = 0, In = 0;
5025
+ function Ln(e) {
4667
5026
  return e.type === "question" ? (e.metadata?.questionNo || "").length > 2 ? 26.25 : 17.5 : e.type === "sub-question" ? 26.25 : 0;
4668
5027
  }
4669
- function An(e, t) {
4670
- return t - kn(e);
5028
+ function Rn(e, t) {
5029
+ return t - Ln(e);
4671
5030
  }
4672
- function jn(e) {
5031
+ function zn(e) {
4673
5032
  let t = [], n = 0;
4674
5033
  for (; n < e.length;) {
4675
5034
  if (e[n] === "\\" && e.substring(n, n + 2) === "\\(") {
@@ -4700,11 +5059,11 @@ function jn(e) {
4700
5059
  }
4701
5060
  return t;
4702
5061
  }
4703
- function Mn(e, t) {
4704
- let n = [], r = jn(e);
4705
- for (let e of r) if (e.type === "text") n.push(Nn(e.value, t, !1, "\"Times New Roman\", SimSun,'Cambria Math'", "#000"));
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"));
4706
5065
  else if (e.type === "formula") {
4707
- let { svg: t, width: r, height: i } = K(e.value);
5066
+ let { svg: t, width: r, height: i } = De(e.value);
4708
5067
  n.push({
4709
5068
  type: "formula",
4710
5069
  width: r,
@@ -4714,7 +5073,7 @@ function Mn(e, t) {
4714
5073
  });
4715
5074
  } else e.type === "blank" && n.push({
4716
5075
  type: "underline",
4717
- id: `ul-${++On}`,
5076
+ id: `ul-${++In}`,
4718
5077
  width: 80,
4719
5078
  height: 20,
4720
5079
  placeholder: "空",
@@ -4723,8 +5082,8 @@ function Mn(e, t) {
4723
5082
  });
4724
5083
  return n;
4725
5084
  }
4726
- function Nn(e, t, n, r, i) {
4727
- 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);
4728
5087
  return {
4729
5088
  type: "text",
4730
5089
  value: e,
@@ -4733,19 +5092,18 @@ function Nn(e, t, n, r, i) {
4733
5092
  bold: n,
4734
5093
  italic: !1,
4735
5094
  color: i,
4736
- 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,
4737
5096
  height: t * 1.4,
4738
5097
  xPositions: o
4739
5098
  };
4740
5099
  }
4741
- function Pn(e, t, n, r, i, a, o = !1) {
5100
+ function Hn(e, t, n, r, i, a, o = !1) {
4742
5101
  let s = [];
4743
5102
  for (let e = 0; e < n.length; e++) {
4744
- let t = Mn(n[e], r);
4745
- 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));
4746
5105
  }
4747
- for (let e = 0; e < 2; e++) s.push($(r, i));
4748
- 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}`;
4749
5107
  return {
4750
5108
  id: `q-${e.replace(".", "")}-${Date.now()}-${Math.random().toString(36).slice(2, 6)}`,
4751
5109
  type: "question",
@@ -4761,12 +5119,10 @@ function Pn(e, t, n, r, i, a, o = !1) {
4761
5119
  }
4762
5120
  };
4763
5121
  }
4764
- function Fn(e, t, n, r, i, a, o = !1) {
5122
+ function Un(e, t, n, r, i, a, o = !1) {
4765
5123
  let s = [], c = `group-${e.replace(".", "")}-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`, l = [], u = 0, d = (n, u) => {
4766
5124
  if (l.length === 0) return;
4767
- let d = l.map((e) => Tn(Mn(e, r), r, i, a && a > 0 ? a : void 0));
4768
- if (!n) for (let e = 0; e < 2; e++) d.push($(r, i));
4769
- 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}`}`;
4770
5126
  s.push({
4771
5127
  id: `${p}-${Date.now()}-${Math.random().toString(36).slice(2, 6)}`,
4772
5128
  type: n ? "question" : "sub-question",
@@ -4790,7 +5146,7 @@ function Fn(e, t, n, r, i, a, o = !1) {
4790
5146
  }
4791
5147
  return d(s.length === 0, u), s;
4792
5148
  }
4793
- function In(e) {
5149
+ function Wn(e) {
4794
5150
  let t = [];
4795
5151
  for (let n of e.paragraphs) {
4796
5152
  if (n.lines.length > 0 && n.lines.every((e) => e.elements.length > 0 && e.elements.every((e) => e.type === "enter"))) continue;
@@ -4804,24 +5160,24 @@ function In(e) {
4804
5160
  }
4805
5161
  return t.join("\n");
4806
5162
  }
4807
- function Ln(e) {
5163
+ function Gn(e) {
4808
5164
  return e.metadata?.questionNo ? `第${e.metadata.questionNo.replace(".", "")}题` : e.metadata?.subLabel ? e.metadata.subLabel : e.metadata?.label || e.id;
4809
5165
  }
4810
5166
  //#endregion
4811
5167
  //#region src/composables/usePaperBlockOps.ts
4812
- function Rn(e) {
5168
+ function Kn(e) {
4813
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;
4814
5170
  function b() {
4815
- y || (_.push(H()), v.value = !0, i.value = !0);
5171
+ y || (_.push(W()), v.value = !0, i.value = !0);
4816
5172
  }
4817
5173
  function x() {
4818
5174
  _.length !== 0 && (y = !0, ue(_.pop()), y = !1, v.value = _.length > 0);
4819
5175
  }
4820
5176
  function S() {
4821
- let e = Z(n.value), r = Q(n.value), s = a.value.columnWidth;
4822
- 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) => {
4823
5179
  if (!t.paragraphs || t.paragraphs.length === 0) return t;
4824
- let n = An(t, s), i = [], a = !1;
5180
+ let n = Rn(t, o), i = [], a = !1;
4825
5181
  for (let o = 0; o < t.paragraphs.length; o++) {
4826
5182
  let s = t.paragraphs[o];
4827
5183
  if (s.lines.length > 0 && s.lines.every((e) => e.elements.length > 0 && e.elements.every((e) => e.type === "enter"))) {
@@ -4832,7 +5188,7 @@ function Rn(e) {
4832
5188
  for (let t of s.lines) for (let n of t.elements) if (n.type === "text") {
4833
5189
  let t = n, r = t.value.split("");
4834
5190
  for (let n = 0; n < r.length; n++) {
4835
- 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);
4836
5192
  c.push({
4837
5193
  ...t,
4838
5194
  value: r[n],
@@ -4854,28 +5210,28 @@ function Rn(e) {
4854
5210
  } else c.push(n);
4855
5211
  } else c.push(n);
4856
5212
  let l;
4857
- 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);
4858
5214
  else {
4859
- let i = t.metadata?.score || "", o = i ? se(`(${i}分)`, e, "SimSun, STSong, serif") : 0;
4860
- l = Tn(c, e, r, n > 0 ? n : void 0, o), a = !0;
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;
4861
5217
  }
4862
5218
  t.paragraphs[o].justification && (l.justification = t.paragraphs[o].justification), i.push(l);
4863
5219
  }
4864
- let c = 0;
4865
- t.options && t.options.length > 0 && (c = o.value.getOptionsHeight(t.options, An(t, s)));
4866
- let l = t.metadata?.customHeight;
4867
- if (l) {
4868
- let t = i.reduce((e, t) => e + (t.height || 26), 0) + c;
4869
- if (l > t) {
4870
- 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);
4871
5227
  for (let t = 0; t < o; t++) i.push($(e, r));
4872
5228
  }
4873
5229
  }
4874
- let u = i.reduce((e, t) => e + (t.height || 26), 0);
5230
+ let l = i.reduce((e, t) => e + (t.height || 26), 0);
4875
5231
  return {
4876
5232
  ...t,
4877
5233
  paragraphs: i,
4878
- height: u,
5234
+ height: l,
4879
5235
  metadata: {
4880
5236
  ...t.metadata,
4881
5237
  originalContentWidth: n
@@ -4884,9 +5240,49 @@ function Rn(e) {
4884
5240
  }), i.value = !0, g());
4885
5241
  }
4886
5242
  function C(e) {
4887
- 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;
5264
+ }
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();
4888
5284
  }
4889
- function w(e, n) {
5285
+ function E(e, n) {
4890
5286
  b();
4891
5287
  let r = {
4892
5288
  id: `title-${Date.now()}-${Math.random().toString(36).slice(2, 6)}`,
@@ -4907,17 +5303,17 @@ function Rn(e) {
4907
5303
  ...t.value.slice(e)
4908
5304
  ] : t.value = [...t.value, r];
4909
5305
  } else t.value = [...t.value, r];
4910
- i.value = !0, I(), g();
5306
+ i.value = !0, R(), g();
4911
5307
  }
4912
- function T(e) {
5308
+ function D(e) {
4913
5309
  b();
4914
5310
  let n = new Map(t.value.map((e) => [e.id, e])), r = e.map((e) => n.get(e)).filter((e) => !!e);
4915
- 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());
4916
5312
  }
4917
- function E(e) {
4918
- b(), t.value = t.value.filter((t) => t.id !== e), p.value === e && (p.value = null), I(), i.value = !0, g();
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();
4919
5315
  }
4920
- function D(e, n) {
5316
+ function k(e, n) {
4921
5317
  b();
4922
5318
  let r = t.value.find((t) => t.id === e);
4923
5319
  r && (r.metadata = {
@@ -4925,11 +5321,11 @@ function Rn(e) {
4925
5321
  label: n
4926
5322
  }, i.value = !0, g());
4927
5323
  }
4928
- function O(e, r) {
5324
+ function A(e, r) {
4929
5325
  b();
4930
5326
  let a = t.value.findIndex((t) => t.id === e);
4931
5327
  if (a === -1) return;
4932
- let o = t.value[a], s = Z(n.value), c = Q(n.value), l = Math.max(0, o.paragraphs.length - En(o)), u = [...r];
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];
4933
5329
  for (let e = 0; e < l; e++) u.push($(s, c));
4934
5330
  let d = u.reduce((e, t) => e + (t.height || 26), 0);
4935
5331
  t.value = t.value.map((e, t) => t === a ? {
@@ -4938,7 +5334,7 @@ function Rn(e) {
4938
5334
  height: d
4939
5335
  } : e), i.value = !0, g();
4940
5336
  }
4941
- function k(e, n) {
5337
+ function j(e, n) {
4942
5338
  b();
4943
5339
  let r = t.value.findIndex((t) => t.id === e);
4944
5340
  r !== -1 && (t.value = t.value.map((e, t) => t === r ? {
@@ -4949,7 +5345,7 @@ function Rn(e) {
4949
5345
  }
4950
5346
  } : e), i.value = !0, g());
4951
5347
  }
4952
- function A(e) {
5348
+ function M(e) {
4953
5349
  b();
4954
5350
  let n = t.value.findIndex((t) => t.id === e);
4955
5351
  if (n === -1) return;
@@ -4959,13 +5355,13 @@ function Rn(e) {
4959
5355
  protectContent: !r
4960
5356
  } : e), i.value = !0, g();
4961
5357
  }
4962
- function j(e) {
5358
+ function ee(e) {
4963
5359
  b(), n.value = {
4964
5360
  ...n.value,
4965
5361
  showScore: e
4966
5362
  }, i.value = !0, g();
4967
5363
  }
4968
- function M(e, n) {
5364
+ function N(e, n) {
4969
5365
  b();
4970
5366
  let r = t.value.findIndex((t) => t.id === e);
4971
5367
  r !== -1 && (t.value = t.value.map((e, t) => {
@@ -4977,26 +5373,29 @@ function Rn(e) {
4977
5373
  };
4978
5374
  }), i.value = !0);
4979
5375
  }
4980
- function ee(e, r) {
5376
+ function P(e, r) {
4981
5377
  b();
4982
- let s = t.value.findIndex((t) => t.id === e);
4983
- if (s === -1) return;
4984
- let c = t.value[s], l = Z(n.value), u = Q(n.value), d = wn(l, u) + 4, f = 0;
4985
- c.options && c.options.length > 0 && (f = o.value.getOptionsHeight(c.options, An(c, a.value.columnWidth)));
4986
- let p = En(c), m = c.paragraphs.slice(0, p), h = m.reduce((e, t) => e + (t.height || 26), 0) + f, _ = Math.max(0, r - h), v = Math.round(_ / d), y = [];
4987
- for (let e = 0; e < v; e++) y.push($(l, u));
4988
- let x = [...m, ...y], S = x.reduce((e, t) => e + (t.height || 26), 0);
4989
- 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 ? {
4990
5389
  ...e,
4991
- paragraphs: x,
4992
- height: S,
5390
+ paragraphs: y,
5391
+ height: x,
4993
5392
  metadata: {
4994
5393
  ...e.metadata,
4995
- customHeight: S
5394
+ customHeight: x
4996
5395
  }
4997
5396
  } : e), i.value = !0, g();
4998
5397
  }
4999
- function N(e, n) {
5398
+ function F(e, n) {
5000
5399
  b();
5001
5400
  let r = t.value.findIndex((t) => t.id === e);
5002
5401
  r !== -1 && (t.value = t.value.map((e, t) => t === r ? {
@@ -5004,7 +5403,7 @@ function Rn(e) {
5004
5403
  questionType: n
5005
5404
  } : e), i.value = !0);
5006
5405
  }
5007
- function P(e, n) {
5406
+ function te(e, n) {
5008
5407
  b();
5009
5408
  let r = t.value.findIndex((t) => t.id === e);
5010
5409
  r !== -1 && (t.value = t.value.map((e, t) => {
@@ -5019,7 +5418,7 @@ function Rn(e) {
5019
5418
  };
5020
5419
  }), i.value = !0, g());
5021
5420
  }
5022
- function F(e, n) {
5421
+ function ne(e, n) {
5023
5422
  b();
5024
5423
  let r = t.value.findIndex((t) => t.id === e);
5025
5424
  r !== -1 && (t.value = t.value.map((e, t) => t === r ? {
@@ -5027,7 +5426,7 @@ function Rn(e) {
5027
5426
  keepNext: n
5028
5427
  } : e), i.value = !0, g());
5029
5428
  }
5030
- function te(e, n) {
5429
+ function I(e, n) {
5031
5430
  let r = t.value.findIndex((t) => t.id === e);
5032
5431
  if (r === -1) {
5033
5432
  console.warn(`[usePaperCore] patchBlock: block ${e} not found`);
@@ -5048,7 +5447,7 @@ function Rn(e) {
5048
5447
  ...n
5049
5448
  } : e), i.value = !0;
5050
5449
  }
5051
- function ne(e) {
5450
+ function L(e) {
5052
5451
  let n = /* @__PURE__ */ new Map();
5053
5452
  for (let t of e) {
5054
5453
  let e = n.get(t.id) || [];
@@ -5070,17 +5469,17 @@ function Rn(e) {
5070
5469
  };
5071
5470
  }), i.value = !0;
5072
5471
  }
5073
- function I() {
5472
+ function R() {
5074
5473
  let e = 0, n = 0, r = [];
5075
5474
  for (let i of t.value) if (i.type === "title") {
5076
5475
  e++;
5077
- let t = i.metadata?.title ?? (Vt(i.metadata?.label || "") || "题组");
5476
+ let t = i.metadata?.title ?? (Ht(i.metadata?.label || "") || "题组");
5078
5477
  r.push({
5079
5478
  id: i.id,
5080
5479
  metadata: {
5081
5480
  title: t,
5082
5481
  ordinal: e,
5083
- label: Bt(t, e)
5482
+ label: Vt(t, e)
5084
5483
  }
5085
5484
  });
5086
5485
  } else if (i.type === "question") {
@@ -5094,27 +5493,27 @@ function Rn(e) {
5094
5493
  }
5095
5494
  });
5096
5495
  }
5097
- ne(r);
5496
+ L(r);
5098
5497
  }
5099
- function L(e, t) {
5100
- 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();
5101
5500
  }
5102
- function re(e, r = !1) {
5501
+ function ie(e, r = !1) {
5103
5502
  b();
5104
5503
  let o = e.content.split("\n").filter((e) => e.trim());
5105
5504
  o.length === 0 && o.push("");
5106
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;
5107
- 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);
5108
5507
  else {
5109
5508
  let t = e.no.length > 2 ? 26.25 : 17.5;
5110
- f = [Pn(e.no, s, o, l, u, d - t, r)];
5509
+ f = [Hn(e.no, s, o, l, u, d - t, r)];
5111
5510
  }
5112
5511
  for (let e of f) t.value = [...t.value, e];
5113
- f.length > 0 && (p.value = f[f.length - 1].id), I(), i.value = !0, S();
5512
+ f.length > 0 && (p.value = f[f.length - 1].id), R(), i.value = !0, S();
5114
5513
  }
5115
- function ie(e, r, o, s = !1) {
5514
+ function z(e, r, o, s = !1) {
5116
5515
  b();
5117
- let c = Z(n.value), l = Q(n.value), u = a.value.columnWidth, d = (r?.length || 0) > 2 ? 26.25 : 17.5, f = xt(e, {
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, {
5118
5517
  questionNo: r || "",
5119
5518
  score: o || "",
5120
5519
  contentWidth: u - d,
@@ -5123,7 +5522,7 @@ function Rn(e) {
5123
5522
  protectContent: s
5124
5523
  });
5125
5524
  for (let e of f) t.value = [...t.value, e];
5126
- f.length > 0 && (p.value = f[f.length - 1].id), I(), i.value = !0, S();
5525
+ f.length > 0 && (p.value = f[f.length - 1].id), R(), i.value = !0, S();
5127
5526
  }
5128
5527
  function ae(e, r, o, s = !1) {
5129
5528
  b();
@@ -5133,7 +5532,7 @@ function Rn(e) {
5133
5532
  } catch {
5134
5533
  throw Error("JSON 格式错误,请检查");
5135
5534
  }
5136
- let m = Nt(f, {
5535
+ let m = Ft(f, {
5137
5536
  questionNo: r || "",
5138
5537
  score: o || "",
5139
5538
  contentWidth: u - d,
@@ -5142,35 +5541,34 @@ function Rn(e) {
5142
5541
  protectContent: s
5143
5542
  });
5144
5543
  for (let e of m) t.value = [...t.value, e];
5145
- 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();
5146
5545
  }
5147
- function R(e) {
5546
+ function B(e) {
5148
5547
  b();
5149
- let r = t.value.filter((t) => t.metadata?.blockGroup === e);
5150
- if (r.length < 2) return;
5151
- let a = r.find((e) => e.type === "question") || r[0], o = Z(n.value), s = Q(n.value), c = [];
5152
- for (let e of r) {
5153
- let t = En(e);
5154
- c.push(...e.paragraphs.slice(0, t));
5155
- }
5156
- for (let e = 0; e < 2; e++) c.push($(o, s));
5157
- let l = c.reduce((e, t) => e + (t.height || 26), 0), u = {}, d = a.metadata?.answer || "";
5158
- for (let e of r) if (e.type === "sub-question" && e.metadata?.answer) {
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) {
5159
5557
  let t = e.metadata.subLabel || "", n = e.metadata.answer;
5160
- t && (u[t] = n, d += (d ? "\n" : "") + t + n);
5558
+ t && (s[t] = n, c += (c ? "\n" : "") + t + n);
5161
5559
  }
5162
- let f = {
5163
- ...a,
5560
+ let l = {
5561
+ ...r,
5164
5562
  id: `merged-${Date.now()}-${Math.random().toString(36).slice(2, 6)}`,
5165
- paragraphs: c,
5166
- height: l,
5563
+ paragraphs: a,
5564
+ height: o,
5167
5565
  metadata: {
5168
- ...a.metadata,
5169
- answer: d || a.metadata?.answer,
5566
+ ...r.metadata,
5567
+ answer: c || r.metadata?.answer,
5170
5568
  blockGroup: void 0,
5171
5569
  hasSubQuestions: !0,
5172
- subAnswers: Object.keys(u).length > 0 ? u : void 0,
5173
- _splitBackup: JSON.stringify(r.map((e) => ({
5570
+ subAnswers: Object.keys(s).length > 0 ? s : void 0,
5571
+ _splitBackup: JSON.stringify(n.map((e) => ({
5174
5572
  ...e,
5175
5573
  paragraphs: e.paragraphs.map((e) => ({
5176
5574
  ...e,
@@ -5181,19 +5579,19 @@ function Rn(e) {
5181
5579
  }))
5182
5580
  })))
5183
5581
  }
5184
- }, p = new Set(r.map((e) => e.id)), m = t.value.findIndex((e) => p.has(e.id));
5185
- if (m === -1) t.value = [...t.value.filter((e) => !p.has(e.id)), f];
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];
5186
5584
  else {
5187
- 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));
5188
5586
  t.value = [
5189
5587
  ...e,
5190
- f,
5588
+ l,
5191
5589
  ...n
5192
5590
  ];
5193
5591
  }
5194
- I(), i.value = !0, S();
5592
+ R(), i.value = !0, S();
5195
5593
  }
5196
- function oe(e) {
5594
+ function H(e) {
5197
5595
  let n = t.value.find((t) => t.id === e);
5198
5596
  if (n?.metadata?._splitBackup) {
5199
5597
  b();
@@ -5204,20 +5602,20 @@ function Rn(e) {
5204
5602
  ...t.value.slice(0, a),
5205
5603
  ...r,
5206
5604
  ...t.value.slice(a + 1)
5207
- ], I(), i.value = !0, S();
5605
+ ], R(), i.value = !0, S();
5208
5606
  } catch (e) {
5209
5607
  console.warn("[splitMergedBlock] _splitBackup 解析失败", e);
5210
5608
  }
5211
5609
  }
5212
5610
  }
5213
- function z(e, t, n) {
5611
+ function oe(e, t, n) {
5214
5612
  b();
5215
5613
  let r = m(e);
5216
5614
  if (!r) return;
5217
- let o = An(r.block, a.value.columnWidth), s = Math.max(20, Math.min(Math.round(t), Math.max(20, o)));
5218
- r.image.width = s, n !== void 0 && (r.image.height = Math.max(12, Math.round(n))), i.value = !0, S();
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();
5219
5617
  }
5220
- function B(e) {
5618
+ function se(e) {
5221
5619
  let t = m(e);
5222
5620
  if (!t) return null;
5223
5621
  let n = t.block.paragraphs[t.paraIdx];
@@ -5226,24 +5624,24 @@ function Rn(e) {
5226
5624
  alignment: n.justification || "left"
5227
5625
  };
5228
5626
  }
5229
- function ce(e, t) {
5627
+ function U(e, t) {
5230
5628
  b();
5231
5629
  let n = m(e);
5232
5630
  if (!n) return;
5233
5631
  let r = n.block.paragraphs[n.paraIdx];
5234
5632
  r.justification = t === "left" ? void 0 : t, i.value = !0, g();
5235
5633
  }
5236
- function le(e, t) {
5634
+ function ce(e, t) {
5237
5635
  b();
5238
5636
  let n = Math.max(30, Math.min(500, Math.round(t))), r = h(e);
5239
5637
  r && (r.underline.width = n, S());
5240
5638
  }
5241
- function V(e, t, r, i) {
5639
+ function le(e, t, r, i) {
5242
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());
5243
- 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));
5244
5642
  }
5245
- function H() {
5246
- return ht(t.value, n.value, {
5643
+ function W() {
5644
+ return _t(t.value, n.value, {
5247
5645
  paperName: s.value,
5248
5646
  schoolName: c.value,
5249
5647
  qrCodeContent: l.value,
@@ -5254,56 +5652,56 @@ function Rn(e) {
5254
5652
  });
5255
5653
  }
5256
5654
  function ue(e, r) {
5257
- let o = gt(e);
5258
- 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 = {
5259
5657
  ...n.value,
5260
5658
  ...o.settings
5261
- }, a.value.updateSettings(o.settings), o.paperName && (s.value = o.paperName), o.schoolName && (c.value = o.schoolName), o.qrCodeContent && (l.value = o.qrCodeContent), o.qrCodeImage && (u.value = o.qrCodeImage), I(), r ? g() : S(), i.value = !1;
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;
5262
5660
  }
5263
5661
  return {
5264
5662
  reflowAllBlocks: S,
5265
5663
  saveUndoSnapshot: b,
5266
5664
  undo: x,
5267
5665
  canUndo: v,
5268
- addBlock: C,
5269
- addTitleBlock: w,
5270
- reorderBlocks: T,
5271
- removeBlock: E,
5272
- updateBlockLabel: D,
5273
- updateBlockContent: O,
5274
- updateBlockScore: k,
5275
- toggleContentProtection: A,
5276
- updateShowScore: j,
5277
- updateBlockQid: M,
5278
- updateBlockHeight: ee,
5279
- updateBlockQuestionType: N,
5280
- updateBlockSplit: P,
5281
- updateBlockKeepNext: F,
5282
- patchBlock: te,
5283
- patchBlocksMeta: ne,
5284
- recalculateNumbering: I,
5285
- updateSectionTitle: L,
5286
- addNewQuestion: re,
5287
- addQuestionFromHtml: ie,
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,
5288
5686
  addQuestionFromJson: ae,
5289
- updateInlineImageSize: z,
5290
- getImageParagraphInfo: B,
5291
- updateImageAlignment: ce,
5292
- updateUnderlineWidth: le,
5293
- parseTextToParagraphs: V,
5294
- saveDocument: H,
5687
+ updateInlineImageSize: oe,
5688
+ getImageParagraphInfo: se,
5689
+ updateImageAlignment: U,
5690
+ updateUnderlineWidth: ce,
5691
+ parseTextToParagraphs: le,
5692
+ saveDocument: W,
5295
5693
  loadDocument: ue,
5296
- getBlockPlainText: In,
5297
- getBlockLabel: Ln,
5298
- getBlockAvailableWidth: An,
5299
- mergeSubQuestionGroup: R,
5300
- splitMergedBlock: oe
5694
+ getBlockPlainText: Wn,
5695
+ getBlockLabel: Gn,
5696
+ getBlockAvailableWidth: Rn,
5697
+ mergeSubQuestionGroup: B,
5698
+ splitMergedBlock: H
5301
5699
  };
5302
5700
  }
5303
- var zn = z;
5701
+ var qn = B;
5304
5702
  //#endregion
5305
5703
  //#region src/composables/usePaperCore.ts
5306
- function Bn(e = {}) {
5704
+ function Jn(e = {}) {
5307
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(() => {
5308
5706
  let e = 0, t = /* @__PURE__ */ new Set();
5309
5707
  for (let n of a.value) {
@@ -5318,7 +5716,7 @@ function Bn(e = {}) {
5318
5716
  a && (e += parseInt(a[1]));
5319
5717
  }
5320
5718
  return e;
5321
- }), y = bn(a), b = Rn({
5719
+ }), y = On(a), b = Kn({
5322
5720
  blocks: a,
5323
5721
  settings: s,
5324
5722
  pages: o,
@@ -5342,7 +5740,7 @@ function Bn(e = {}) {
5342
5740
  d.value = [];
5343
5741
  return;
5344
5742
  }
5345
- 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))));
5346
5744
  }, { immediate: !0 });
5347
5745
  function x(e) {
5348
5746
  n.value = e, i.value.setRenderMode(e);
@@ -5447,8 +5845,8 @@ function Bn(e = {}) {
5447
5845
  }
5448
5846
  //#endregion
5449
5847
  //#region src/composables/usePageSvgRenderer.ts
5450
- var Vn = "<defs><g id=\"enter\"><path d=\"M810.667 213.333a42.667 42.667 0 0 1 42.368 37.675l0.298 4.992v274.304c0 79.275-50.944 147.499-120.49 152.107l-7.51 0.256H273.707l97.792 97.834a42.667 42.667 0 0 1-56.32 63.872l-4.011-3.541-170.667-170.667a42.667 42.667 0 0 1 0-60.33l170.667-170.667a42.667 42.667 0 0 1 63.872 56.32l-3.541 4.01-97.792 97.835h451.626c19.584 0 39.936-24.618 42.411-59.861l0.256-7.168V256a42.667 42.667 0 0 1 42.667-42.667z\" fill=\"currentColor\"/></g></defs>";
5451
- function Hn(e, n = {}) {
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 = {}) {
5452
5850
  return t(() => {
5453
5851
  e.renderMode.value;
5454
5852
  let t = e.pages.value;
@@ -5464,13 +5862,13 @@ function Hn(e, n = {}) {
5464
5862
  qrCodeImage: e.qrCodeImage.value,
5465
5863
  qrCodeImages: e.qrCodeImages.value
5466
5864
  }, t.length);
5467
- return `<svg xmlns="http://www.w3.org/2000/svg" width="${r * o}" height="${i * o}" viewBox="0 0 ${r} ${i}" class="paper-page">\n${Vn}\n${l}</svg>`;
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>`;
5468
5866
  });
5469
5867
  });
5470
5868
  }
5471
5869
  //#endregion
5472
5870
  //#region src/composables/useTableRenderer.ts
5473
- async function Un(e, t, n = 2) {
5871
+ async function Zn(e, t, n = 2) {
5474
5872
  let r = [];
5475
5873
  for (let t = 0; t < e.length; t++) {
5476
5874
  let n = e[t];
@@ -5497,7 +5895,7 @@ async function Un(e, t, n = 2) {
5497
5895
  if (r.length !== 0) for (let i = 0; i < r.length; i++) {
5498
5896
  let a = r[i];
5499
5897
  try {
5500
- let r = await Wn(a.rawHtml, t, n);
5898
+ let r = await Qn(a.rawHtml, t, n);
5501
5899
  if (r) {
5502
5900
  let t = e[a.blockIdx].paragraphs[a.paraIdx].lines[a.lineIdx].elements[a.elemIdx];
5503
5901
  t.src = r, delete t.rawHtml;
@@ -5507,7 +5905,7 @@ async function Un(e, t, n = 2) {
5507
5905
  }
5508
5906
  }
5509
5907
  }
5510
- async function Wn(e, t, n) {
5908
+ async function Qn(e, t, n) {
5511
5909
  let r = document.createElement("div");
5512
5910
  r.innerHTML = e, r.style.position = "absolute", r.style.left = "-9999px", r.style.top = "0", r.style.width = "auto", r.style.height = "auto";
5513
5911
  let i = document.createElement("style");
@@ -5528,7 +5926,7 @@ async function Wn(e, t, n) {
5528
5926
  document.body.removeChild(r);
5529
5927
  }
5530
5928
  }
5531
- function Gn(e) {
5929
+ function $n(e) {
5532
5930
  for (let t of e) if (t.paragraphs) {
5533
5931
  for (let e of t.paragraphs) if (e.lines) {
5534
5932
  for (let t of e.lines) if (t.elements) {
@@ -5543,7 +5941,7 @@ function Gn(e) {
5543
5941
  }
5544
5942
  //#endregion
5545
5943
  //#region src/composables/usePaperCursor.ts
5546
- function Kn(e, t, n, r) {
5944
+ function er(e, t, n, r) {
5547
5945
  let i = f({
5548
5946
  blockId: null,
5549
5947
  paraIndex: 0,
@@ -5596,7 +5994,7 @@ function Kn(e, t, n, r) {
5596
5994
  }
5597
5995
  function d(e, t) {
5598
5996
  if (!e) return [];
5599
- let n = e.split(""), r = B(e, t.fontSize, t.fontFamily, t.bold, t.italic), i = r.length > 0 ? r[r.length - 1] + z(n[n.length - 1], t.fontSize, t.fontFamily, t.bold, t.italic) : 0;
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;
5600
5998
  return [{
5601
5999
  type: "text",
5602
6000
  value: e,
@@ -5611,7 +6009,7 @@ function Kn(e, t, n, r) {
5611
6009
  }];
5612
6010
  }
5613
6011
  function p(e) {
5614
- 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);
5615
6013
  return e.length === 0 || e.length === 1 && e[0].type === "enter" ? $(n, r) : {
5616
6014
  lines: [{
5617
6015
  elements: e,
@@ -5655,7 +6053,7 @@ function Kn(e, t, n, r) {
5655
6053
  else {
5656
6054
  let e = t - i, c = o.value.substring(0, e), l = o.value.substring(e);
5657
6055
  if (c) {
5658
- let e = B(c, o.fontSize, o.fontFamily, o.bold, o.italic), t = e.length > 0 ? e[e.length - 1] + z(c[c.length - 1], o.fontSize, o.fontFamily, o.bold, o.italic) : 0;
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;
5659
6057
  n.push({
5660
6058
  ...o,
5661
6059
  value: c,
@@ -5664,7 +6062,7 @@ function Kn(e, t, n, r) {
5664
6062
  });
5665
6063
  }
5666
6064
  if (l) {
5667
- let e = B(l, o.fontSize, o.fontFamily, o.bold, o.italic), t = e.length > 0 ? e[e.length - 1] + z(l[l.length - 1], o.fontSize, o.fontFamily, o.bold, o.italic) : 0;
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;
5668
6066
  r.push({
5669
6067
  ...o,
5670
6068
  value: l,
@@ -5674,7 +6072,7 @@ function Kn(e, t, n, r) {
5674
6072
  }
5675
6073
  i += s, a = !0;
5676
6074
  }
5677
- } else i <= t ? n.push(e) : (r.push(e), a = !0);
6075
+ } else i < t ? n.push(e) : (r.push(e), a = !0);
5678
6076
  }
5679
6077
  return [n, r];
5680
6078
  }
@@ -5707,7 +6105,7 @@ function Kn(e, t, n, r) {
5707
6105
  let e = r[a], n = e.value.substring(0, s) + e.value.substring(s + 1);
5708
6106
  for (let t = 0; t < r.length; t++) if (t === a) {
5709
6107
  if (n) {
5710
- let t = B(n, e.fontSize, e.fontFamily, e.bold, e.italic), r = t.length > 0 ? t[t.length - 1] + z(n[n.length - 1], e.fontSize, e.fontFamily, e.bold, e.italic) : 0;
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;
5711
6109
  c.push({
5712
6110
  ...e,
5713
6111
  value: n,
@@ -5745,7 +6143,7 @@ function Kn(e, t, n, r) {
5745
6143
  let e = n[i], r = e.value.substring(0, o) + e.value.substring(o + 1), a = [];
5746
6144
  for (let t = 0; t < n.length; t++) if (t === i) {
5747
6145
  if (r) {
5748
- let t = B(r, e.fontSize, e.fontFamily, e.bold, e.italic), n = t.length > 0 ? t[t.length - 1] + z(r[r.length - 1], e.fontSize, e.fontFamily, e.bold, e.italic) : 0;
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;
5749
6147
  a.push({
5750
6148
  ...e,
5751
6149
  value: r,
@@ -5802,11 +6200,15 @@ function Kn(e, t, n, r) {
5802
6200
  if (a.paragraphs.length <= 1) return !1;
5803
6201
  let o = Math.max(0, t.paraIndex - 1), c = s(a.paragraphs[o]), l = e.value.findIndex((e) => e.id === t.blockId);
5804
6202
  if (l === -1) return !1;
5805
- 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);
5806
6204
  return e.value = e.value.map((e, t) => t === l ? {
5807
6205
  ...e,
5808
6206
  paragraphs: u,
5809
- height: u.reduce((e, t) => e + (t.height || 26), 0)
6207
+ height: d,
6208
+ metadata: {
6209
+ ...e.metadata,
6210
+ customHeight: d
6211
+ }
5810
6212
  } : e), i.value = {
5811
6213
  blockId: t.blockId,
5812
6214
  paraIndex: o,
@@ -5857,11 +6259,15 @@ function Kn(e, t, n, r) {
5857
6259
  if (a.paragraphs.length <= 1) return !1;
5858
6260
  let o = Math.min(t.paraIndex, a.paragraphs.length - 2), s = e.value.findIndex((e) => e.id === t.blockId);
5859
6261
  if (s === -1) return !1;
5860
- 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);
5861
6263
  return e.value = e.value.map((e, t) => t === s ? {
5862
6264
  ...e,
5863
6265
  paragraphs: c,
5864
- height: c.reduce((e, t) => e + (t.height || 26), 0)
6266
+ height: l,
6267
+ metadata: {
6268
+ ...e.metadata,
6269
+ customHeight: l
6270
+ }
5865
6271
  } : e), i.value = {
5866
6272
  blockId: t.blockId,
5867
6273
  paraIndex: o,
@@ -6013,13 +6419,13 @@ function Kn(e, t, n, r) {
6013
6419
  }
6014
6420
  //#endregion
6015
6421
  //#region src/components/PaperEditor.vue?vue&type=script&setup=true&lang.ts
6016
- var qn = { class: "pe-root" }, Jn = { class: "pe-main" }, Yn = { class: "pe-editor" }, Xn = { class: "pe-editor-pages" }, Zn = ["onClick"], Qn = ["innerHTML"], $n = { class: "pe-editor-controllers" }, er = {
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 = {
6017
6423
  key: 0,
6018
6424
  class: "pe-ctrl-sub"
6019
- }, tr = {
6425
+ }, lr = {
6020
6426
  key: 1,
6021
6427
  class: "pe-ctrl-sub"
6022
- }, nr = /*@__PURE__*/ a({
6428
+ }, ur = /*@__PURE__*/ a({
6023
6429
  __name: "PaperEditor",
6024
6430
  props: {
6025
6431
  initialData: {},
@@ -6040,7 +6446,7 @@ var qn = { class: "pe-root" }, Jn = { class: "pe-main" }, Yn = { class: "pe-edit
6040
6446
  "loaded"
6041
6447
  ],
6042
6448
  setup(a, { expose: m, emit: h }) {
6043
- 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, () => {
6044
6450
  C.reflowAllBlocks(), o(() => k.value?.focus());
6045
6451
  }, () => {
6046
6452
  C.isDirty.value = !0;
@@ -6059,7 +6465,7 @@ var qn = { class: "pe-root" }, Jn = { class: "pe-main" }, Yn = { class: "pe-edit
6059
6465
  top: j.value.top + "px",
6060
6466
  height: j.value.height + "px",
6061
6467
  transform: "skewX(0deg)"
6062
- })), N = Hn(C, {
6468
+ })), N = Xn(C, {
6063
6469
  zoom: T,
6064
6470
  selectedBlockId: C.selectedBlockId
6065
6471
  });
@@ -6113,7 +6519,7 @@ var qn = { class: "pe-root" }, Jn = { class: "pe-main" }, Yn = { class: "pe-edit
6113
6519
  });
6114
6520
  });
6115
6521
  }
6116
- function re(e, t, n, r) {
6522
+ function R(e, t, n, r) {
6117
6523
  let i = C.blocks.value.find((t) => t.id === e);
6118
6524
  if (!i || !n) return;
6119
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];
@@ -6132,66 +6538,94 @@ var qn = { class: "pe-root" }, Jn = { class: "pe-main" }, Yn = { class: "pe-edit
6132
6538
  i < e && (e = i, f = t);
6133
6539
  }
6134
6540
  }
6135
- 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 = [];
6136
- for (let e = g; e < _; e++) v.push(e);
6137
- let y = 0, b = -1;
6138
- for (let e of v) {
6139
- let t = i.paragraphs[e].height || 26;
6140
- if (h >= y - 2 && h < y + t + 2) {
6141
- b = e;
6142
- 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]));
6143
6557
  }
6144
- y += t;
6558
+ b = b.parentElement;
6145
6559
  }
6146
- b === -1 && (b = v[v.length - 1] ?? g);
6147
- let x = i.paragraphs[b], S = 0, k = f.x + p, M = w.getTextStyle(x).fontSize, ee = (x.lines[0]?.lineHeight || x.height || 21) * .5, N = f.y + y + ee, P = M;
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;
6148
6561
  if (!w.isEmptyParagraph(x)) {
6149
- let e = o - m - f.x - p, t = h - y, n = 0, r = -1;
6150
- for (let e = 0; e < x.lines.length; e++) {
6151
- let i = x.lines[e].lineHeight || 20;
6152
- if (t >= n - 2 && t < n + i + 2) {
6153
- r = e;
6154
- 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
+ }
6155
6571
  }
6156
- n += i;
6157
- }
6158
- r === -1 && (r = x.lines.length - 1, n = x.lines.reduce((e, t, n) => n < r ? e + (t.lineHeight || 20) : e, 0));
6159
- let a = 0;
6160
- for (let e = 0; e < r; e++) for (let t of x.lines[e].elements) t.type === "text" && (a += t.value.length);
6161
- let s = x.lines[r], c = s.offsetX || 0, l = 0;
6162
- if (f.paragraphStart === 0 && i.metadata?.score && r === 0 && b === (v[0] ?? 0)) {
6163
- let e = C.settings.value.fontSize, t = typeof e == "number" ? e : 14;
6164
- l = se(`(${i.metadata.score}分)`, t, "SimSun, STSong, serif");
6165
- }
6166
- let u = l, d = !1;
6167
- for (let t of s.elements) {
6168
- if (t.type === "text") {
6169
- let r = t.xPositions;
6170
- for (let i = 0; i < t.value.length; i++) {
6171
- let o = u + c + r[i];
6172
- if (e < o + (i < r.length - 1 ? r[i + 1] - r[i] : t.width - r[i]) / 2) {
6173
- 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;
6174
6611
  break;
6175
6612
  }
6176
- a++;
6613
+ l += r;
6177
6614
  }
6178
- u += t.width;
6179
- } else {
6180
- let r = t.width || 12;
6181
- if (e < u + c + r / 2) {
6182
- S = a, k = f.x + p + u + c, N = f.y + y + n + s.lineHeight * .5, P = M, d = !0;
6183
- break;
6184
- }
6185
- 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;
6186
6620
  }
6187
- if (d) break;
6188
6621
  }
6189
- d || (S = a, k = f.x + p + u + c, N = f.y + y + n + s.lineHeight * .5, P = M);
6190
6622
  }
6191
- 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);
6192
6626
  let F = O.value, te = document.querySelectorAll(".pe-editor-page")[c]?.querySelector("svg.paper-page");
6193
6627
  if (F && te && l) {
6194
- let e = te.getBoundingClientRect(), t = F.getBoundingClientRect(), n = l.width, r = l.height, i = k + m, a = N + d, o = e.left - t.left + F.scrollLeft + i / n * e.width, s = e.top - t.top + F.scrollTop + a / r * e.height;
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;
6195
6629
  j.value = {
6196
6630
  left: o,
6197
6631
  top: s,
@@ -6202,7 +6636,7 @@ var qn = { class: "pe-root" }, Jn = { class: "pe-main" }, Yn = { class: "pe-edit
6202
6636
  }, D.value = !0;
6203
6637
  }
6204
6638
  }
6205
- function ie(e) {
6639
+ function re(e) {
6206
6640
  let t = e.target, n = e.currentTarget, r = n.closest(".pe-editor-page"), i = E.value;
6207
6641
  if (r) {
6208
6642
  let e = r.parentElement?.querySelectorAll(":scope > .pe-editor-page");
@@ -6230,7 +6664,7 @@ var qn = { class: "pe-root" }, Jn = { class: "pe-main" }, Yn = { class: "pe-edit
6230
6664
  if (c) {
6231
6665
  let t = c.getAttribute("data-block-id");
6232
6666
  if (t) {
6233
- 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());
6234
6668
  let r = C.blocks.value.find((e) => e.id === t);
6235
6669
  r && S("block-click", {
6236
6670
  blockId: t,
@@ -6239,18 +6673,18 @@ var qn = { class: "pe-root" }, Jn = { class: "pe-main" }, Yn = { class: "pe-edit
6239
6673
  }
6240
6674
  } else C.selectBlock(null), C.selectUnderline(null), C.selectImage(null), D.value = !1, w.clearCursor(), S("empty-click");
6241
6675
  }
6242
- function ae(e) {
6676
+ function ie(e) {
6243
6677
  let t = e.target;
6244
6678
  if (!t) return;
6245
6679
  let n = t.getAttribute("data-editable");
6246
6680
  n && (C.saveUndoSnapshot(), n === "schoolName" ? C.schoolName.value = t.innerHTML : n === "paperName" && (C.paperName.value = t.textContent || ""));
6247
6681
  }
6248
- let R = f(null), oe = t(() => R.value ? {
6682
+ let z = f(null), ae = t(() => z.value ? {
6249
6683
  position: "absolute",
6250
- left: R.value.left + "px",
6251
- top: R.value.top + "px",
6252
- width: R.value.width + "px",
6253
- 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",
6254
6688
  pointerEvents: "none",
6255
6689
  border: "1.5px solid #409eff",
6256
6690
  borderRadius: "2px",
@@ -6259,172 +6693,172 @@ var qn = { class: "pe-root" }, Jn = { class: "pe-main" }, Yn = { class: "pe-edit
6259
6693
  display: "none",
6260
6694
  position: "absolute"
6261
6695
  });
6262
- function z() {
6696
+ function B() {
6263
6697
  let e = C.selectedBlockId.value;
6264
6698
  if (!e) {
6265
- R.value = null;
6699
+ z.value = null;
6266
6700
  return;
6267
6701
  }
6268
6702
  let t = C.blocks.value.find((t) => t.id === e);
6269
6703
  if (!t || t.type === "title") {
6270
- R.value = null;
6704
+ z.value = null;
6271
6705
  return;
6272
6706
  }
6273
6707
  let n = document.querySelector(".pe-editor-page.active");
6274
6708
  if (!n) {
6275
- R.value = null;
6709
+ z.value = null;
6276
6710
  return;
6277
6711
  }
6278
6712
  let r = n.querySelector("svg.paper-page");
6279
6713
  if (!r) {
6280
- R.value = null;
6714
+ z.value = null;
6281
6715
  return;
6282
6716
  }
6283
6717
  let i = C.pages.value.find((e) => e.index === E.value);
6284
6718
  if (!i) {
6285
- R.value = null;
6719
+ z.value = null;
6286
6720
  return;
6287
6721
  }
6288
6722
  let a = i.blocks.find((t) => t.blockId === e);
6289
6723
  if (!a) {
6290
- R.value = null;
6724
+ z.value = null;
6291
6725
  return;
6292
6726
  }
6293
6727
  let o = n.closest(".pe-editor-surface");
6294
6728
  if (!o) {
6295
- R.value = null;
6729
+ z.value = null;
6296
6730
  return;
6297
6731
  }
6298
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();
6299
- R.value = {
6733
+ z.value = {
6300
6734
  left: f.left - p.left + o.scrollLeft + u / s * f.width,
6301
6735
  top: f.top - p.top + o.scrollTop + d / c * f.height,
6302
6736
  width: a.width / s * f.width,
6303
6737
  height: a.height / c * f.height
6304
6738
  };
6305
6739
  }
6306
- let B = t(() => {
6740
+ let V = t(() => {
6307
6741
  let e = C.selectedBlockId.value;
6308
6742
  return e && C.blocks.value.find((t) => t.id === e)?.metadata?.blockGroup || "";
6309
- }), ce = t(() => {
6743
+ }), H = t(() => {
6310
6744
  let e = C.selectedBlockId.value;
6311
6745
  return e ? !!C.blocks.value.find((t) => t.id === e)?.metadata?._splitBackup : !1;
6312
6746
  });
6313
- function le() {
6314
- let e = B.value;
6747
+ function oe() {
6748
+ let e = V.value;
6315
6749
  e && (C.mergeSubQuestionGroup(e), S("change"));
6316
6750
  }
6317
- function V() {
6751
+ function se() {
6318
6752
  let e = C.selectedBlockId.value;
6319
6753
  e && (C.splitMergedBlock(e), S("change"));
6320
6754
  }
6321
- let H = f(null), ue = t(() => H.value ? {
6755
+ let U = f(null), ce = t(() => U.value ? {
6322
6756
  position: "absolute",
6323
- left: H.value.left + "px",
6324
- top: H.value.top + "px",
6325
- width: H.value.width + "px",
6326
- 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",
6327
6761
  pointerEvents: "auto"
6328
6762
  } : {
6329
6763
  display: "none",
6330
6764
  position: "absolute"
6331
6765
  });
6332
- function de() {
6766
+ function le() {
6333
6767
  let e = C.selectedUnderlineId.value;
6334
6768
  if (!e) {
6335
- H.value = null;
6769
+ U.value = null;
6336
6770
  return;
6337
6771
  }
6338
6772
  let t = document.querySelector(".pe-editor-page.active");
6339
6773
  if (!t) {
6340
- H.value = null;
6774
+ U.value = null;
6341
6775
  return;
6342
6776
  }
6343
6777
  let n = t.querySelector(`[data-underline-id="${CSS.escape(e)}"]`);
6344
6778
  if (!n) {
6345
- H.value = null;
6779
+ U.value = null;
6346
6780
  return;
6347
6781
  }
6348
6782
  let r = t.closest(".pe-editor-surface");
6349
6783
  if (!r) {
6350
- H.value = null;
6784
+ U.value = null;
6351
6785
  return;
6352
6786
  }
6353
6787
  let i = n.getBoundingClientRect(), a = r.getBoundingClientRect();
6354
- H.value = {
6788
+ U.value = {
6355
6789
  left: i.left - a.left + r.scrollLeft,
6356
6790
  top: i.top - a.top + r.scrollTop,
6357
6791
  width: i.width,
6358
6792
  height: i.height
6359
6793
  };
6360
6794
  }
6361
- let U = f(null), fe = t(() => U.value ? {
6795
+ let W = f(null), ue = t(() => W.value ? {
6362
6796
  position: "absolute",
6363
- left: U.value.left + "px",
6364
- top: U.value.top + "px",
6365
- width: U.value.width + "px",
6366
- 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",
6367
6801
  pointerEvents: "auto"
6368
6802
  } : {
6369
6803
  display: "none",
6370
6804
  position: "absolute"
6371
6805
  });
6372
- function pe() {
6806
+ function de() {
6373
6807
  let e = C.selectedImageId.value;
6374
6808
  if (!e) {
6375
- U.value = null;
6809
+ W.value = null;
6376
6810
  return;
6377
6811
  }
6378
6812
  let t = document.querySelector(".pe-editor-page.active");
6379
6813
  if (!t) {
6380
- U.value = null;
6814
+ W.value = null;
6381
6815
  return;
6382
6816
  }
6383
6817
  let n = t.querySelector(`[data-image-id="${CSS.escape(e)}"]`);
6384
6818
  if (!n) {
6385
- U.value = null;
6819
+ W.value = null;
6386
6820
  return;
6387
6821
  }
6388
6822
  let r = n.querySelector("image") || n, i = t.closest(".pe-editor-surface");
6389
6823
  if (!i) {
6390
- U.value = null;
6824
+ W.value = null;
6391
6825
  return;
6392
6826
  }
6393
6827
  let a = r.getBoundingClientRect(), o = i.getBoundingClientRect();
6394
- U.value = {
6828
+ W.value = {
6395
6829
  left: a.left - o.left + i.scrollLeft,
6396
6830
  top: a.top - o.top + i.scrollTop,
6397
6831
  width: a.width,
6398
6832
  height: a.height
6399
6833
  };
6400
6834
  }
6401
- let me = t(() => C.selectedImageId.value ? C.getImageParagraphInfo(C.selectedImageId.value) : null), he = t(() => !!(me.value?.isStandalone && U.value)), ge = t(() => U.value ? {
6402
- left: U.value.left + "px",
6403
- top: U.value.top + U.value.height + 4 + "px",
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",
6404
6838
  pointerEvents: "auto"
6405
6839
  } : null);
6406
- function _e(e) {
6840
+ function he(e) {
6407
6841
  let t = C.selectedImageId.value;
6408
- t && (C.updateImageAlignment(t, e), o(() => W()));
6842
+ t && (C.updateImageAlignment(t, e), o(() => G()));
6409
6843
  }
6410
- let ve = 0;
6411
- function W() {
6412
- ve && cancelAnimationFrame(ve), ve = requestAnimationFrame(() => {
6413
- ve = 0, z(), de(), pe();
6844
+ let ge = 0;
6845
+ function G() {
6846
+ ge && cancelAnimationFrame(ge), ge = requestAnimationFrame(() => {
6847
+ ge = 0, B(), le(), de();
6414
6848
  });
6415
6849
  }
6416
6850
  v(() => C.selectedBlockId.value, async () => {
6417
- await o(), W();
6851
+ await o(), G();
6418
6852
  }), v(() => T.value, async () => {
6419
- await o(), W();
6853
+ await o(), G();
6420
6854
  }), v(() => E.value, async () => {
6421
- await o(), W(), S("page-change", E.value);
6855
+ await o(), G(), S("page-change", E.value);
6422
6856
  }), v(() => C.layoutVersion.value, () => {
6423
- L(), o(() => W());
6857
+ L(), o(() => G());
6424
6858
  }), v(() => C.selectedUnderlineId.value, async () => {
6425
- await o(), W();
6859
+ await o(), G();
6426
6860
  }), v(() => C.selectedImageId.value, async () => {
6427
- await o(), W();
6861
+ await o(), G();
6428
6862
  }), v(() => [
6429
6863
  C.paperName.value,
6430
6864
  C.schoolName.value,
@@ -6432,62 +6866,62 @@ var qn = { class: "pe-root" }, Jn = { class: "pe-main" }, Yn = { class: "pe-edit
6432
6866
  ], () => {
6433
6867
  L();
6434
6868
  });
6435
- let ye = f(!1), be = f(null), xe = f(0), Se = f(0);
6436
- function G(e) {
6869
+ let _e = f(!1), ve = f(null), ye = f(0), be = f(0);
6870
+ function xe(e) {
6437
6871
  let t = C.selectedBlockId.value;
6438
6872
  if (!t) return;
6439
6873
  let n = C.blocks.value.find((e) => e.id === t);
6440
- n && (e.stopPropagation(), ye.value = !0, be.value = t, xe.value = e.clientY, Se.value = n.height, document.body.style.cursor = "ns-resize", document.body.style.userSelect = "none", document.addEventListener("mousemove", Ce), document.addEventListener("mouseup", we));
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));
6441
6875
  }
6442
- function Ce(e) {
6443
- if (!ye.value || !be.value) return;
6444
- let t = (e.clientY - xe.value) / T.value;
6445
- C.updateBlockHeight(be.value, Se.value + t), o(() => z());
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());
6446
6880
  }
6447
- function we(e) {
6448
- ye.value = !1, be.value = null, document.body.style.cursor = "", document.body.style.userSelect = "", document.removeEventListener("mousemove", Ce), document.removeEventListener("mouseup", we), L();
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();
6449
6883
  }
6450
- let Te = f(!1), Ee = f(null), K = f(0), De = f(0);
6451
- function Oe(e, t) {
6884
+ let Ce = f(!1), we = f(null), Te = f(0), Ee = f(0);
6885
+ function De(e, t) {
6452
6886
  let n = C.selectedUnderlineId.value;
6453
6887
  if (!n) return;
6454
6888
  let r = C.findUnderlineById(n);
6455
- r && (t.stopPropagation(), Te.value = !0, Ee.value = e, K.value = t.clientX, De.value = r.underline.width, document.body.style.cursor = "ew-resize", document.body.style.userSelect = "none", document.addEventListener("mousemove", q), document.addEventListener("mouseup", ke));
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));
6456
6890
  }
6457
- function q(e) {
6458
- if (!Te.value || !Ee.value) return;
6891
+ function Oe(e) {
6892
+ if (!Ce.value || !we.value) return;
6459
6893
  let t = C.selectedUnderlineId.value;
6460
6894
  if (!t) return;
6461
- let n = (e.clientX - K.value) / T.value, r = Ee.value === "right" ? n : -n;
6462
- C.updateUnderlineWidth(t, De.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());
6463
6897
  }
6464
6898
  function ke(e) {
6465
- Te.value = !1, Ee.value = null, document.body.style.cursor = "", document.body.style.userSelect = "", document.removeEventListener("mousemove", q), document.removeEventListener("mouseup", ke), L();
6899
+ Ce.value = !1, we.value = null, document.body.style.cursor = "", document.body.style.userSelect = "", document.removeEventListener("mousemove", Oe), document.removeEventListener("mouseup", ke), L();
6466
6900
  }
6467
- let Ae = f(!1), je = f(null), Me = f(0), Ne = f(0), Pe = f(0), Fe = f(0);
6468
- function Ie(e, t) {
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) {
6469
6903
  if (t.button !== 0) return;
6470
6904
  let n = C.selectedImageId.value;
6471
6905
  if (!n) return;
6472
6906
  let r = C.findInlineImageById(n);
6473
- r && (t.stopPropagation(), Ae.value = !0, je.value = e, Me.value = t.clientX, Ne.value = t.clientY, Pe.value = r.image.width, Fe.value = r.image.height, document.body.style.userSelect = "none", document.addEventListener("mousemove", Le), document.addEventListener("mouseup", Re));
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));
6474
6908
  }
6475
- function Le(e) {
6476
- if (!Ae.value || !je.value) return;
6909
+ function Ie(e) {
6910
+ if (!q.value || !Ae.value) return;
6477
6911
  let t = C.selectedImageId.value;
6478
6912
  if (!t) return;
6479
- let n = (e.clientX - Me.value) / T.value, r = je.value, i = Pe.value;
6913
+ let n = (e.clientX - je.value) / T.value, r = Ae.value, i = Ne.value;
6480
6914
  if (r.includes("e") ? i += n : r.includes("w") && (i -= n), !C.findInlineImageById(t)) return;
6481
- let a = Fe.value / Math.max(1, Pe.value), s = Math.max(12, Math.round(i * a));
6482
- C.updateInlineImageSize(t, i, s), o(() => pe());
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());
6483
6917
  }
6484
- function Re(e) {
6485
- Ae.value = !1, je.value = null, document.body.style.userSelect = "", document.removeEventListener("mousemove", Le), document.removeEventListener("mouseup", Re), 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();
6486
6920
  }
6487
- function ze(e) {
6921
+ function Re(e) {
6488
6922
  C.loadDocument(e), L(), S("loaded"), S("change");
6489
6923
  }
6490
- function Be(e) {
6924
+ function ze(e) {
6491
6925
  let t = -1;
6492
6926
  for (let n = 0; n < C.pages.value.length; n++) if (C.pages.value[n].blocks.some((t) => t.blockId === e)) {
6493
6927
  t = n;
@@ -6501,7 +6935,7 @@ var qn = { class: "pe-root" }, Jn = { class: "pe-main" }, Yn = { class: "pe-edit
6501
6935
  }
6502
6936
  }));
6503
6937
  }
6504
- let Ve = f(!1);
6938
+ let Be = f(!1);
6505
6939
  function J() {
6506
6940
  let e = w.cursor.value;
6507
6941
  if (!e.blockId) return;
@@ -6524,63 +6958,73 @@ var qn = { class: "pe-root" }, Jn = { class: "pe-main" }, Yn = { class: "pe-edit
6524
6958
  }
6525
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;
6526
6960
  c !== E.value && (E.value = c);
6527
- 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 = [];
6528
- for (let e = u; e < d; e++) f.push(e);
6529
- let p = 0;
6530
- for (let t of f) {
6531
- if (t === n) break;
6532
- p += e.paragraphs[t].height || 26;
6533
- }
6534
- let m = e.paragraphs[n];
6535
- if (!m) return;
6536
- 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;
6537
- if (!w.isEmptyParagraph(m)) {
6538
- let t = 0, i = 0;
6539
- for (let e = 0; e < m.lines.length; e++) {
6540
- let n = 0;
6541
- for (let t of m.lines[e].elements) t.type === "text" && (n += t.value.length);
6542
- if (t + n >= r) {
6543
- i = e;
6544
- break;
6545
- }
6546
- 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;
6547
6969
  }
6548
- let o = 0;
6549
- for (let e = 0; e < i; e++) o += m.lines[e].lineHeight || 20;
6550
- let s = m.lines[i], c = s.offsetX || 0, u = 0;
6551
- if (a.paragraphStart === 0 && e.metadata?.score && i === 0 && n === (f[0] ?? 0)) {
6552
- let t = C.settings.value.fontSize, n = typeof t == "number" ? t : 14;
6553
- 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]));
6554
6978
  }
6555
- let d = u, h = !1;
6556
- for (let e of s.elements) {
6557
- if (t >= r) {
6558
- _ = 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 {}
6559
7003
  break;
6560
7004
  }
6561
- if (e.type === "text") {
6562
- let n = e.xPositions;
6563
- for (let i = 0; i < e.value.length; i++) {
6564
- if (t === r) {
6565
- let e = d + c + n[i];
6566
- _ = a.x + l + e, v = a.y + p + o + s.lineHeight * .5, h = !0;
6567
- break;
6568
- }
6569
- 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;
6570
7016
  }
6571
- if (h) break;
6572
- d += e.width;
6573
- } else d += e.width || 12;
7017
+ b = g;
7018
+ } catch {}
6574
7019
  }
6575
- h || (_ = a.x + l + d + c, v = a.y + p + o + s.lineHeight * .5);
6576
7020
  }
6577
- let b = O.value, x = document.querySelectorAll(".pe-editor-page")[c]?.querySelector("svg.paper-page");
6578
- if (b && x && i) {
6579
- 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;
6580
7024
  j.value = {
6581
7025
  left: l,
6582
7026
  top: u,
6583
- height: y * T.value
7027
+ height: b * T.value
6584
7028
  }, A.value = {
6585
7029
  left: l,
6586
7030
  top: u
@@ -6590,8 +7034,8 @@ var qn = { class: "pe-root" }, Jn = { class: "pe-main" }, Yn = { class: "pe-edit
6590
7034
  });
6591
7035
  });
6592
7036
  }
6593
- function He(e) {
6594
- 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) {
6595
7039
  case "Enter":
6596
7040
  e.preventDefault(), C.saveUndoSnapshot(), w.splitAtCursor(), J();
6597
7041
  break;
@@ -6615,16 +7059,16 @@ var qn = { class: "pe-root" }, Jn = { class: "pe-main" }, Yn = { class: "pe-edit
6615
7059
  break;
6616
7060
  }
6617
7061
  }
6618
- function Ue(e) {
6619
- if (Ve.value) return;
7062
+ function He(e) {
7063
+ if (Be.value) return;
6620
7064
  let t = e.target, n = t.value;
6621
7065
  n && w.cursor.value.blockId && (C.saveUndoSnapshot(), w.insertText(n), t.value = "", J());
6622
7066
  }
6623
- function We() {
6624
- Ve.value = !0;
7067
+ function Ue() {
7068
+ Be.value = !0;
6625
7069
  }
6626
- function Ge(e) {
6627
- Ve.value = !1;
7070
+ function We(e) {
7071
+ Be.value = !1;
6628
7072
  let t = k.value;
6629
7073
  if (t) {
6630
7074
  let e = t.value;
@@ -6632,15 +7076,15 @@ var qn = { class: "pe-root" }, Jn = { class: "pe-main" }, Yn = { class: "pe-edit
6632
7076
  }
6633
7077
  }
6634
7078
  return l(() => {
6635
- x.initialData ? ze(x.initialData) : C.relayout(), x.paperName && (C.paperName.value = x.paperName), x.schoolName && (C.schoolName.value = x.schoolName), x.qrCodeContent && (C.qrCodeContent.value = x.qrCodeContent), S("ready");
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");
6636
7080
  }), u(() => {
6637
- document.removeEventListener("mousemove", Ce), document.removeEventListener("mouseup", we), document.removeEventListener("mousemove", q), document.removeEventListener("mouseup", ke), document.removeEventListener("mousemove", Le), document.removeEventListener("mouseup", Re);
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);
6638
7082
  }), v(() => x.qrCodeContent, (e) => {
6639
7083
  C.qrCodeContent.value = e || "";
6640
7084
  }), m({
6641
7085
  document: {
6642
7086
  save: () => C.saveDocument(),
6643
- load: (e) => ze(e),
7087
+ load: (e) => Re(e),
6644
7088
  getBlocks: () => C.blocks.value,
6645
7089
  isDirty: () => C.isDirty.value
6646
7090
  },
@@ -6734,7 +7178,7 @@ var qn = { class: "pe-root" }, Jn = { class: "pe-main" }, Yn = { class: "pe-edit
6734
7178
  goToPage: (e) => {
6735
7179
  E.value = e;
6736
7180
  },
6737
- scrollToBlock: (e) => Be(e)
7181
+ scrollToBlock: (e) => ze(e)
6738
7182
  },
6739
7183
  render: {
6740
7184
  getPageSvgs: () => N.value,
@@ -6758,7 +7202,7 @@ var qn = { class: "pe-root" }, Jn = { class: "pe-main" }, Yn = { class: "pe-edit
6758
7202
  selectedImageId: C.selectedImageId.value,
6759
7203
  selectedUnderlineInfo: C.selectedUnderlineInfo.value,
6760
7204
  selectedImageInfo: C.selectedImageInfo.value,
6761
- selectedImageAlignment: me.value,
7205
+ selectedImageAlignment: fe.value,
6762
7206
  totalScore: C.totalScore.value,
6763
7207
  zoom: T.value,
6764
7208
  currentPage: E.value,
@@ -6771,7 +7215,7 @@ var qn = { class: "pe-root" }, Jn = { class: "pe-main" }, Yn = { class: "pe-edit
6771
7215
  qrCodeImages: C.qrCodeImages.value,
6772
7216
  showScore: C.settings.value.showScore
6773
7217
  }))
6774
- }), (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", {
6775
7219
  class: "pe-editor-surface",
6776
7220
  ref_key: "saberEditorRef",
6777
7221
  ref: O
@@ -6780,25 +7224,25 @@ var qn = { class: "pe-root" }, Jn = { class: "pe-main" }, Yn = { class: "pe-edit
6780
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",
6781
7225
  fill: "currentColor"
6782
7226
  })])])], -1),
6783
- 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", {
6784
7228
  key: t,
6785
7229
  class: s(["pe-editor-page", { active: t === E.value }]),
6786
7230
  onClick: b((e) => E.value = t, ["stop"])
6787
7231
  }, [i("div", {
6788
7232
  class: "pe-editor-viewport",
6789
7233
  innerHTML: e,
6790
- onClick: ie,
6791
- onFocusout: ae
6792
- }, null, 40, Qn)], 10, Zn))), 128))]),
6793
- i("div", $n, [
6794
- 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", {
6795
7239
  key: 0,
6796
7240
  class: "pe-ctrl-block",
6797
- style: c(oe.value)
7241
+ style: c(ae.value)
6798
7242
  }, [
6799
7243
  i("div", {
6800
7244
  class: "pe-ctrl-height",
6801
- onMousedown: b(G, ["prevent"])
7245
+ onMousedown: b(xe, ["prevent"])
6802
7246
  }, [...a[9] ||= [i("svg", {
6803
7247
  xmlns: "http://www.w3.org/2000/svg",
6804
7248
  width: "16",
@@ -6809,22 +7253,22 @@ var qn = { class: "pe-root" }, Jn = { class: "pe-main" }, Yn = { class: "pe-edit
6809
7253
  "fill-rule": "evenodd",
6810
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"
6811
7255
  })], -1)]], 32),
6812
- B.value ? (d(), r("div", er, [i("button", {
7256
+ V.value ? (d(), r("div", cr, [i("button", {
6813
7257
  class: "pe-merge-btn",
6814
- onMousedown: b(le, ["stop"])
7258
+ onMousedown: b(oe, ["stop"])
6815
7259
  }, "合并子题", 32)])) : n("", !0),
6816
- ce.value ? (d(), r("div", tr, [i("button", {
7260
+ H.value ? (d(), r("div", lr, [i("button", {
6817
7261
  class: "pe-split-btn",
6818
- onMousedown: b(V, ["stop"])
7262
+ onMousedown: b(se, ["stop"])
6819
7263
  }, "拆分子题", 32)])) : n("", !0)
6820
7264
  ], 4)) : n("", !0),
6821
- H.value ? (d(), r("div", {
7265
+ U.value ? (d(), r("div", {
6822
7266
  key: 1,
6823
7267
  class: "pe-ctrlUnderline",
6824
- style: c(ue.value)
7268
+ style: c(ce.value)
6825
7269
  }, [i("div", {
6826
7270
  class: "pe-ctrl-ul-left",
6827
- onMousedown: a[0] ||= b((e) => Oe("left", e), ["prevent"])
7271
+ onMousedown: a[0] ||= b((e) => De("left", e), ["prevent"])
6828
7272
  }, [...a[10] ||= [i("svg", {
6829
7273
  xmlns: "http://www.w3.org/2000/svg",
6830
7274
  width: "12",
@@ -6835,7 +7279,7 @@ var qn = { class: "pe-root" }, Jn = { class: "pe-main" }, Yn = { class: "pe-edit
6835
7279
  d: "M10.5 4L7.5 8l3 4H2V4z"
6836
7280
  })], -1)]], 32), i("div", {
6837
7281
  class: "pe-ctrl-ul-right",
6838
- onMousedown: a[1] ||= b((e) => Oe("right", e), ["prevent"])
7282
+ onMousedown: a[1] ||= b((e) => De("right", e), ["prevent"])
6839
7283
  }, [...a[11] ||= [i("svg", {
6840
7284
  xmlns: "http://www.w3.org/2000/svg",
6841
7285
  width: "12",
@@ -6845,46 +7289,46 @@ var qn = { class: "pe-root" }, Jn = { class: "pe-main" }, Yn = { class: "pe-edit
6845
7289
  fill: "currentColor",
6846
7290
  d: "M5.5 4L8.5 8l-3 4H14V4z"
6847
7291
  })], -1)]], 32)], 4)) : n("", !0),
6848
- U.value ? (d(), r("div", {
7292
+ W.value ? (d(), r("div", {
6849
7293
  key: 2,
6850
7294
  class: "pe-ctrlAnchor",
6851
- style: c(fe.value)
7295
+ style: c(ue.value)
6852
7296
  }, [
6853
7297
  i("div", {
6854
7298
  class: "pe-resize-se",
6855
- onMousedown: a[2] ||= b((e) => Ie("se", e), ["prevent", "stop"])
7299
+ onMousedown: a[2] ||= b((e) => Fe("se", e), ["prevent", "stop"])
6856
7300
  }, null, 32),
6857
7301
  i("div", {
6858
7302
  class: "pe-resize-sw",
6859
- onMousedown: a[3] ||= b((e) => Ie("sw", e), ["prevent", "stop"])
7303
+ onMousedown: a[3] ||= b((e) => Fe("sw", e), ["prevent", "stop"])
6860
7304
  }, null, 32),
6861
7305
  i("div", {
6862
7306
  class: "pe-resize-ne",
6863
- onMousedown: a[4] ||= b((e) => Ie("ne", e), ["prevent", "stop"])
7307
+ onMousedown: a[4] ||= b((e) => Fe("ne", e), ["prevent", "stop"])
6864
7308
  }, null, 32),
6865
7309
  i("div", {
6866
7310
  class: "pe-resize-nw",
6867
- onMousedown: a[5] ||= b((e) => Ie("nw", e), ["prevent", "stop"])
7311
+ onMousedown: a[5] ||= b((e) => Fe("nw", e), ["prevent", "stop"])
6868
7312
  }, null, 32)
6869
7313
  ], 4)) : n("", !0),
6870
- he.value ? (d(), r("div", {
7314
+ pe.value ? (d(), r("div", {
6871
7315
  key: 3,
6872
7316
  class: "pe-img-align-bar",
6873
- style: c(ge.value)
7317
+ style: c(me.value)
6874
7318
  }, [
6875
7319
  i("button", {
6876
- class: s(["pe-align-btn", { active: me.value?.alignment === "left" }]),
6877
- onClick: a[6] ||= (e) => _e("left"),
7320
+ class: s(["pe-align-btn", { active: fe.value?.alignment === "left" }]),
7321
+ onClick: a[6] ||= (e) => he("left"),
6878
7322
  title: "左对齐"
6879
7323
  }, "左", 2),
6880
7324
  i("button", {
6881
- class: s(["pe-align-btn", { active: me.value?.alignment === "center" }]),
6882
- onClick: a[7] ||= (e) => _e("center"),
7325
+ class: s(["pe-align-btn", { active: fe.value?.alignment === "center" }]),
7326
+ onClick: a[7] ||= (e) => he("center"),
6883
7327
  title: "居中对齐"
6884
7328
  }, "中", 2),
6885
7329
  i("button", {
6886
- class: s(["pe-align-btn", { active: me.value?.alignment === "right" }]),
6887
- onClick: a[8] ||= (e) => _e("right"),
7330
+ class: s(["pe-align-btn", { active: fe.value?.alignment === "right" }]),
7331
+ onClick: a[8] ||= (e) => he("right"),
6888
7332
  title: "右对齐"
6889
7333
  }, "右", 2)
6890
7334
  ], 4)) : n("", !0)
@@ -6896,10 +7340,10 @@ var qn = { class: "pe-root" }, Jn = { class: "pe-main" }, Yn = { class: "pe-edit
6896
7340
  class: "pe-editor-virtual-input",
6897
7341
  ref_key: "virtualInputRef",
6898
7342
  ref: k,
6899
- onKeydown: He,
6900
- onInput: Ue,
6901
- onCompositionstart: We,
6902
- onCompositionend: Ge
7343
+ onKeydown: Ve,
7344
+ onInput: He,
7345
+ onCompositionstart: Ue,
7346
+ onCompositionend: We
6903
7347
  }, null, 544)], 4),
6904
7348
  y(i("div", {
6905
7349
  class: "pe-editor-cursor",
@@ -6907,17 +7351,17 @@ var qn = { class: "pe-root" }, Jn = { class: "pe-main" }, Yn = { class: "pe-edit
6907
7351
  }, null, 4), [[_, D.value]])
6908
7352
  ], 512)])])]));
6909
7353
  }
6910
- }), rr = (e, t) => {
7354
+ }), dr = (e, t) => {
6911
7355
  let n = e.__vccOpts || e;
6912
7356
  for (let [e, r] of t) n[e] = r;
6913
7357
  return n;
6914
- }, 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 = {
6915
7359
  key: 0,
6916
7360
  class: "pe-preview__helpers"
6917
- }, cr = {
7361
+ }, gr = {
6918
7362
  key: 1,
6919
7363
  class: "pe-preview__page-num"
6920
- }, lr = /*#__PURE__*/ rr(/* @__PURE__ */ a({
7364
+ }, _r = /*#__PURE__*/ dr(/* @__PURE__ */ a({
6921
7365
  __name: "PaperPreview",
6922
7366
  props: {
6923
7367
  document: {},
@@ -6944,14 +7388,14 @@ var qn = { class: "pe-root" }, Jn = { class: "pe-main" }, Yn = { class: "pe-edit
6944
7388
  }
6945
7389
  },
6946
7390
  setup(a) {
6947
- let o = a, m = Bn();
7391
+ let o = a, m = Jn();
6948
7392
  function _() {
6949
7393
  o.document && m.loadDocument(o.document);
6950
7394
  }
6951
7395
  _(), v(() => o.document, _), v(() => o.pureMode, (e) => {
6952
7396
  m.setRenderMode(e ? "view" : "edit");
6953
7397
  }, { immediate: !0 });
6954
- 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;
6955
7399
  l(() => {
6956
7400
  x.value = b.value?.clientWidth ?? 0, S = new ResizeObserver((e) => {
6957
7401
  for (let t of e) x.value = Math.floor(t.contentRect.width);
@@ -7119,7 +7563,7 @@ var qn = { class: "pe-root" }, Jn = { class: "pe-main" }, Yn = { class: "pe-edit
7119
7563
  class: s(["pe-preview", { "pe-preview--print": a.mode === "print" }]),
7120
7564
  ref_key: "previewRef",
7121
7565
  ref: b
7122
- }, [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", {
7123
7567
  key: o,
7124
7568
  class: "pe-preview__page",
7125
7569
  style: c(k(o))
@@ -7133,8 +7577,8 @@ var qn = { class: "pe-root" }, Jn = { class: "pe-main" }, Yn = { class: "pe-edit
7133
7577
  width: "100%",
7134
7578
  height: "100%"
7135
7579
  }
7136
- }, null, 8, or)], 4),
7137
- a.showHelpers ? (d(), r("div", sr, [a.showCornerMarks ? (d(!0), r(e, { key: 0 }, p(D(o), (e, t) => (d(), r("span", {
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", {
7138
7582
  key: "cm-" + t,
7139
7583
  class: s(["pe-preview__helper-box", e.className]),
7140
7584
  style: c(ee(e))
@@ -7143,9 +7587,9 @@ var qn = { class: "pe-root" }, Jn = { class: "pe-main" }, Yn = { class: "pe-edit
7143
7587
  class: s(["pe-preview__helper-box", e.className]),
7144
7588
  style: c(ee(e))
7145
7589
  }, null, 6))), 128)) : n("", !0)])) : n("", !0),
7146
- 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)
7147
7591
  ], 4))), 128))])], 2));
7148
7592
  }
7149
7593
  }), [["__scopeId", "data-v-e8f833b5"]]);
7150
7594
  //#endregion
7151
- export { xn as FONT_SIZE_MAP, A as PAPER_DIMENSIONS, j as PAPER_MM, ir as PaperEditor, te as PaperLayout, lr as PaperPreview, Se as SvgRenderer, Ut as buildPaperHtml, B as calcCharPositions, se as calcTextWidth, Ee as clearFormulaCache, le as clearWidthCache, gt as deserializeDocument, Vt as extractBaseTitle, Sn as fontSizeLabelToPx, Cn as fontSizePxToLabel, Bt as formatSectionTitle, z as getCharWidth, ee as getPaperPreset, Gn as hasTablePlaceholder, K as latexToSvg, je as latexToSvgBatch, xt as parseQuestionHtml, Nt as parseQuestionJson, Un as renderTablePlaceholders, ht as serializeDocument, P as toBBox, zt as toChineseOrdinal, Hn as usePageSvgRenderer, Bn as usePaperCore };
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 };