@sw7d/paper-renderer 0.2.3 → 0.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/paper-renderer.js
CHANGED
|
@@ -947,13 +947,13 @@ function Te(e, t, n, r) {
|
|
|
947
947
|
function Ee() {
|
|
948
948
|
G.clear();
|
|
949
949
|
}
|
|
950
|
-
function
|
|
950
|
+
function De(e, t = 14, n = !1) {
|
|
951
951
|
let r = we(e, t, n);
|
|
952
952
|
if (r) return r;
|
|
953
|
-
let i =
|
|
953
|
+
let i = Oe(e, t, n);
|
|
954
954
|
return Te(e, t, n, i), i;
|
|
955
955
|
}
|
|
956
|
-
function
|
|
956
|
+
function Oe(e, t = 14, n = !1) {
|
|
957
957
|
try {
|
|
958
958
|
let r = window.MathJax;
|
|
959
959
|
if (!r?.tex2svg) throw Error("MathJax 尚未加载完成");
|
|
@@ -978,22 +978,22 @@ function De(e, t = 14, n = !1) {
|
|
|
978
978
|
};
|
|
979
979
|
} catch {
|
|
980
980
|
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">${
|
|
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">${ke(e)}</text></svg>`,
|
|
982
982
|
width: 50,
|
|
983
983
|
height: 20
|
|
984
984
|
};
|
|
985
985
|
}
|
|
986
986
|
}
|
|
987
|
-
function
|
|
987
|
+
function ke(e) {
|
|
988
988
|
return e.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
989
989
|
}
|
|
990
|
-
var
|
|
991
|
-
function
|
|
990
|
+
var K = /* @__PURE__ */ new Map(), Ae = 200;
|
|
991
|
+
function je(e, t = 14, n = !1) {
|
|
992
992
|
let r = e;
|
|
993
993
|
try {
|
|
994
994
|
r = decodeURIComponent(e);
|
|
995
995
|
} catch {}
|
|
996
|
-
let i = `${t}:${n}:${r}`, a =
|
|
996
|
+
let i = `${t}:${n}:${r}`, a = K.get(i);
|
|
997
997
|
if (a) return a;
|
|
998
998
|
try {
|
|
999
999
|
let e = window.MathJax;
|
|
@@ -1017,9 +1017,9 @@ function Ae(e, t = 14, n = !1) {
|
|
|
1017
1017
|
width: s,
|
|
1018
1018
|
height: c
|
|
1019
1019
|
};
|
|
1020
|
-
if (
|
|
1021
|
-
let e =
|
|
1022
|
-
e &&
|
|
1020
|
+
if (K.set(i, d), K.size > Ae) {
|
|
1021
|
+
let e = K.keys().next().value;
|
|
1022
|
+
e && K.delete(e);
|
|
1023
1023
|
}
|
|
1024
1024
|
return d;
|
|
1025
1025
|
} catch {
|
|
@@ -1030,14 +1030,14 @@ function Ae(e, t = 14, n = !1) {
|
|
|
1030
1030
|
};
|
|
1031
1031
|
}
|
|
1032
1032
|
}
|
|
1033
|
-
function
|
|
1033
|
+
function Me(e, t = 20) {
|
|
1034
1034
|
return new Promise((n) => {
|
|
1035
1035
|
let r = Array(e.length), i = 0;
|
|
1036
1036
|
function a() {
|
|
1037
1037
|
let o = Math.min(i + t, e.length);
|
|
1038
1038
|
for (; i < o; i++) {
|
|
1039
1039
|
let t = e[i];
|
|
1040
|
-
r[i] =
|
|
1040
|
+
r[i] = De(t.latex, t.fontSize ?? 14, t.display ?? !1);
|
|
1041
1041
|
}
|
|
1042
1042
|
i < e.length ? requestAnimationFrame(a) : n(r);
|
|
1043
1043
|
}
|
|
@@ -1046,7 +1046,7 @@ function je(e, t = 20) {
|
|
|
1046
1046
|
}
|
|
1047
1047
|
//#endregion
|
|
1048
1048
|
//#region src/utils/serialization/shared.ts
|
|
1049
|
-
var
|
|
1049
|
+
var Ne = {
|
|
1050
1050
|
clrScheme: {
|
|
1051
1051
|
accent1: "4472C4",
|
|
1052
1052
|
accent2: "ED7D31",
|
|
@@ -1103,9 +1103,9 @@ var Me = {
|
|
|
1103
1103
|
latin: "等线"
|
|
1104
1104
|
}
|
|
1105
1105
|
}
|
|
1106
|
-
},
|
|
1107
|
-
function
|
|
1108
|
-
let t =
|
|
1106
|
+
}, Pe = { docDefaults: { textPropsDefault: { runfonts: { hint: "eastAsia" } } } }, Fe = 26.46, Ie = 17.5, Le = 26.25;
|
|
1107
|
+
function Re(e) {
|
|
1108
|
+
let t = Fe;
|
|
1109
1109
|
return {
|
|
1110
1110
|
tl: {
|
|
1111
1111
|
top: t,
|
|
@@ -1133,7 +1133,7 @@ function Le(e) {
|
|
|
1133
1133
|
}
|
|
1134
1134
|
};
|
|
1135
1135
|
}
|
|
1136
|
-
function
|
|
1136
|
+
function q(e) {
|
|
1137
1137
|
let t = e.startsWith("sw-") ? e.slice(3) : e, n = t.lastIndexOf("-");
|
|
1138
1138
|
return n > 0 && /^\d+$/.test(t.slice(n + 1)) && (t = t.slice(0, n)), t;
|
|
1139
1139
|
}
|
|
@@ -1159,11 +1159,13 @@ function Ve(e) {
|
|
|
1159
1159
|
return e.replace(/-([a-z])/g, (e, t) => t.toUpperCase());
|
|
1160
1160
|
}
|
|
1161
1161
|
function J(e) {
|
|
1162
|
-
return /_Block_\d+$/.test(e);
|
|
1162
|
+
return /_Block_\d+$/.test(e) || /-sub\d+$/.test(e);
|
|
1163
1163
|
}
|
|
1164
1164
|
function He(e) {
|
|
1165
1165
|
let t = e.match(/^(.+)_Block_\d+$/);
|
|
1166
|
-
|
|
1166
|
+
if (t) return t[1];
|
|
1167
|
+
let n = e.match(/^(.+)-sub\d+$/);
|
|
1168
|
+
return n ? `${n[1]}-header` : "";
|
|
1167
1169
|
}
|
|
1168
1170
|
function Ue(e) {
|
|
1169
1171
|
let t = [];
|
|
@@ -1197,7 +1199,7 @@ function We(e) {
|
|
|
1197
1199
|
//#region src/utils/serialization/buildQuestions.ts
|
|
1198
1200
|
function Ge(e, t) {
|
|
1199
1201
|
if (e.type === "title" || e.type === "info-line") return null;
|
|
1200
|
-
let n = e.type === "sub-question" ?
|
|
1202
|
+
let n = e.type === "sub-question" ? Le : Ie, r = A[t.paperSize], [, , i, a] = t.margins || [
|
|
1201
1203
|
50,
|
|
1202
1204
|
56,
|
|
1203
1205
|
50,
|
|
@@ -1497,7 +1499,7 @@ function Ye(e, t) {
|
|
|
1497
1499
|
bottom: a,
|
|
1498
1500
|
left: o
|
|
1499
1501
|
},
|
|
1500
|
-
point:
|
|
1502
|
+
point: Re(n),
|
|
1501
1503
|
headerTop: t.headerTop ?? 18,
|
|
1502
1504
|
footerBottom: 13.2,
|
|
1503
1505
|
showScore: t.showScore,
|
|
@@ -1592,23 +1594,41 @@ var Qe = new Set([
|
|
|
1592
1594
|
"student-code-filler"
|
|
1593
1595
|
]);
|
|
1594
1596
|
function $e(e, t, n = !0) {
|
|
1595
|
-
let r = ze(t), i = /* @__PURE__ */ new
|
|
1597
|
+
let r = ze(t), i = /* @__PURE__ */ new Map();
|
|
1598
|
+
for (let e of t) {
|
|
1599
|
+
let t = e.metadata?.blockGroup;
|
|
1600
|
+
if (t && e.type === "question") {
|
|
1601
|
+
let n = q(e.id);
|
|
1602
|
+
i.set(t, {
|
|
1603
|
+
topicId: n,
|
|
1604
|
+
qid: e.metadata?.qid
|
|
1605
|
+
});
|
|
1606
|
+
}
|
|
1607
|
+
}
|
|
1608
|
+
let a = /* @__PURE__ */ new Set(), o = /* @__PURE__ */ new Set();
|
|
1596
1609
|
for (let t of e) for (let e of t.renderedRegions || []) {
|
|
1597
|
-
let t =
|
|
1598
|
-
t && e.type === "question-border" &&
|
|
1610
|
+
let t = q(e.meta?.blockId || e.meta?.topicId || "");
|
|
1611
|
+
t && e.type === "question-border" && a.add(t);
|
|
1599
1612
|
}
|
|
1600
|
-
for (let e of
|
|
1601
|
-
let
|
|
1613
|
+
for (let e of a) J(e) && o.add(He(e));
|
|
1614
|
+
for (let e of t) if (e.type === "sub-question") {
|
|
1615
|
+
let t = e.metadata?.topicId || (e.id.startsWith("sw-") ? e.id.slice(3) : e.id);
|
|
1616
|
+
if (e.metadata?.blockGroup) {
|
|
1617
|
+
let t = i.get(e.metadata.blockGroup);
|
|
1618
|
+
t && o.add(t.topicId);
|
|
1619
|
+
} else J(t) && o.add(He(t));
|
|
1620
|
+
}
|
|
1621
|
+
let s = /* @__PURE__ */ new Map(), c = 0;
|
|
1602
1622
|
for (let e of t) {
|
|
1603
1623
|
let t = e.metadata?.topicId || (e.id.startsWith("sw-") ? e.id.slice(3) : e.id);
|
|
1604
|
-
|
|
1624
|
+
s.has(t) || s.set(t, c++);
|
|
1605
1625
|
}
|
|
1606
1626
|
for (let t of e) for (let e of t.renderedRegions || []) {
|
|
1607
|
-
let t =
|
|
1608
|
-
t && e.type === "question-border" && !
|
|
1627
|
+
let t = q(e.meta?.blockId || e.meta?.topicId || "");
|
|
1628
|
+
t && e.type === "question-border" && !s.has(t) && s.set(t, c++);
|
|
1609
1629
|
}
|
|
1610
1630
|
return e.map((t) => {
|
|
1611
|
-
let
|
|
1631
|
+
let a = t.renderedRegions || [], c = {
|
|
1612
1632
|
pageIndex: t.index,
|
|
1613
1633
|
pageWidth: t.width,
|
|
1614
1634
|
pageHeight: t.height,
|
|
@@ -1617,61 +1637,65 @@ function $e(e, t, n = !0) {
|
|
|
1617
1637
|
bbox: e.bbox
|
|
1618
1638
|
})),
|
|
1619
1639
|
questions: []
|
|
1620
|
-
},
|
|
1621
|
-
for (let e of
|
|
1640
|
+
}, l = {}, u = [], d, f = /* @__PURE__ */ new Map();
|
|
1641
|
+
for (let e of a) {
|
|
1622
1642
|
if (Qe.has(e.type)) {
|
|
1623
1643
|
if (e.type === "score" && !n) continue;
|
|
1624
|
-
|
|
1644
|
+
l[Ve(e.type)] = e.bbox;
|
|
1625
1645
|
continue;
|
|
1626
1646
|
}
|
|
1627
1647
|
if (e.type === "page-number") {
|
|
1628
|
-
|
|
1648
|
+
d = e.bbox;
|
|
1629
1649
|
continue;
|
|
1630
1650
|
}
|
|
1631
1651
|
if (e.type === "title-embed") {
|
|
1632
|
-
|
|
1652
|
+
u.push({
|
|
1633
1653
|
label: e.meta?.label || "unknown",
|
|
1634
1654
|
bbox: e.bbox
|
|
1635
1655
|
});
|
|
1636
1656
|
continue;
|
|
1637
1657
|
}
|
|
1638
1658
|
if (e.type === "column-separator") continue;
|
|
1639
|
-
let t =
|
|
1659
|
+
let t = q(e.meta?.blockId || e.meta?.topicId || "");
|
|
1640
1660
|
if (!t) continue;
|
|
1641
|
-
|
|
1661
|
+
f.has(t) || f.set(t, {
|
|
1642
1662
|
borders: [],
|
|
1643
1663
|
underlines: []
|
|
1644
1664
|
});
|
|
1645
|
-
let r =
|
|
1665
|
+
let r = f.get(t);
|
|
1646
1666
|
e.type === "question-border" ? r.borders.push(e) : e.type === "underline" && r.underlines.push(e);
|
|
1647
1667
|
}
|
|
1648
|
-
Object.keys(
|
|
1649
|
-
let
|
|
1650
|
-
let i =
|
|
1668
|
+
Object.keys(l).length > 0 && (c.header = l), u.length > 0 && (c.sectionTitles = u), d && (c.footer = { pageNumber: d });
|
|
1669
|
+
let p = Array.from(f.entries()).sort(([e, t], [n, r]) => {
|
|
1670
|
+
let i = s.get(e) ?? 9999, a = s.get(n) ?? 9999;
|
|
1651
1671
|
return i === a ? (t.borders[0]?.bbox[1] ?? 0) - (r.borders[0]?.bbox[1] ?? 0) : i - a;
|
|
1652
1672
|
});
|
|
1653
|
-
for (let [t, n] of
|
|
1673
|
+
for (let [t, n] of p) {
|
|
1654
1674
|
if (n.borders.length === 0) continue;
|
|
1655
|
-
let
|
|
1675
|
+
let a = r.get(t), l = a?.metadata?.questionNo || a?.metadata?.subLabel || "", u = a?.metadata?.score, d = o.has(t), f = J(t) || a?.type === "sub-question", p = n.borders.map((e) => e.bbox), m = {
|
|
1656
1676
|
topicId: t,
|
|
1657
|
-
questionNo:
|
|
1658
|
-
questionType: Be(
|
|
1659
|
-
sortIndex:
|
|
1660
|
-
bbox:
|
|
1677
|
+
questionNo: l,
|
|
1678
|
+
questionType: Be(a),
|
|
1679
|
+
sortIndex: s.get(t) ?? 9999,
|
|
1680
|
+
bbox: p[0]
|
|
1661
1681
|
};
|
|
1662
|
-
if (
|
|
1663
|
-
let e = parseFloat(String(
|
|
1664
|
-
isNaN(e) || (
|
|
1682
|
+
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) {
|
|
1683
|
+
let e = parseFloat(String(u));
|
|
1684
|
+
isNaN(e) || (m.score = e);
|
|
1665
1685
|
}
|
|
1666
|
-
|
|
1686
|
+
if (f) if (a?.metadata?.blockGroup) {
|
|
1687
|
+
let e = i.get(a.metadata.blockGroup);
|
|
1688
|
+
e && (m.parentTopicId = e.topicId, e.qid && (m.pqid = e.qid));
|
|
1689
|
+
} else m.parentTopicId = He(t);
|
|
1690
|
+
d && (m.hasSubQuestions = !0), n.underlines.length > 0 && (m.underlines = n.underlines.map((e) => {
|
|
1667
1691
|
let t = { bbox: e.bbox }, n = e.meta;
|
|
1668
1692
|
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
1693
|
})), e.filter((e) => e.renderedRegions.some((e) => {
|
|
1670
1694
|
let n = e.meta?.blockId || e.meta?.topicId || "";
|
|
1671
|
-
return n &&
|
|
1672
|
-
})).length > 1 && (
|
|
1695
|
+
return n && q(n) === t;
|
|
1696
|
+
})).length > 1 && (m.isCrossPage = !0), c.questions.push(m);
|
|
1673
1697
|
}
|
|
1674
|
-
return
|
|
1698
|
+
return c;
|
|
1675
1699
|
});
|
|
1676
1700
|
}
|
|
1677
1701
|
//#endregion
|
|
@@ -1813,7 +1837,7 @@ function ot(e) {
|
|
|
1813
1837
|
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
1838
|
}
|
|
1815
1839
|
case "latex": {
|
|
1816
|
-
let t = e, n = t.value || t.props.raw || "", { svg: r, width: i, height: a } =
|
|
1840
|
+
let t = e, n = t.value || t.props.raw || "", { svg: r, width: i, height: a } = De(n);
|
|
1817
1841
|
return {
|
|
1818
1842
|
type: "formula",
|
|
1819
1843
|
width: i,
|
|
@@ -1823,7 +1847,7 @@ function ot(e) {
|
|
|
1823
1847
|
};
|
|
1824
1848
|
}
|
|
1825
1849
|
case "mathml": {
|
|
1826
|
-
let t = e, n = t.value || t.props.raw || "", { svg: r, width: i, height: a } =
|
|
1850
|
+
let t = e, n = t.value || t.props.raw || "", { svg: r, width: i, height: a } = je(n);
|
|
1827
1851
|
return {
|
|
1828
1852
|
type: "formula",
|
|
1829
1853
|
width: i,
|
|
@@ -1911,7 +1935,7 @@ var st = 0;
|
|
|
1911
1935
|
function ct(e, t, n, r) {
|
|
1912
1936
|
let i = [], a = e.props, o = e.children.find((e) => e.type === "question-stem");
|
|
1913
1937
|
if (!o) return i;
|
|
1914
|
-
let s = a.topicId.includes("_Block_"), c = t ? t - (s ?
|
|
1938
|
+
let s = a.topicId.includes("_Block_"), c = t ? t - (s ? Le : Ie) : void 0, l = [];
|
|
1915
1939
|
for (let e of o.children) e.type === "paragraph" && l.push(ut(e, c, n, r));
|
|
1916
1940
|
st++;
|
|
1917
1941
|
let u = {
|
|
@@ -2324,8 +2348,8 @@ function ht(e, t, n = {}) {
|
|
|
2324
2348
|
}]
|
|
2325
2349
|
}
|
|
2326
2350
|
},
|
|
2327
|
-
theme:
|
|
2328
|
-
styles:
|
|
2351
|
+
theme: Ne,
|
|
2352
|
+
styles: Pe,
|
|
2329
2353
|
version: "1.3",
|
|
2330
2354
|
mode: 1,
|
|
2331
2355
|
lastUpdateTime: Date.now()
|
|
@@ -2460,11 +2484,11 @@ function Y(e, t, n, r, i) {
|
|
|
2460
2484
|
let e = c.getAttribute("data-latex") || "", t = e, n, r;
|
|
2461
2485
|
if (e) {
|
|
2462
2486
|
let n = e.replace(/\\style\{[^}]*\}\{/, "{").replace(/^\\style\{[^}]*\}/, "") || e;
|
|
2463
|
-
t = n, r =
|
|
2487
|
+
t = n, r = De(n);
|
|
2464
2488
|
} else {
|
|
2465
2489
|
let e = c.getAttribute("data-mathml") || "";
|
|
2466
2490
|
if (e) {
|
|
2467
|
-
r =
|
|
2491
|
+
r = je(e), t = "";
|
|
2468
2492
|
try {
|
|
2469
2493
|
n = decodeURIComponent(e);
|
|
2470
2494
|
} catch {
|
|
@@ -4704,7 +4728,7 @@ function Mn(e, t) {
|
|
|
4704
4728
|
let n = [], r = jn(e);
|
|
4705
4729
|
for (let e of r) if (e.type === "text") n.push(Nn(e.value, t, !1, "\"Times New Roman\", SimSun,'Cambria Math'", "#000"));
|
|
4706
4730
|
else if (e.type === "formula") {
|
|
4707
|
-
let { svg: t, width: r, height: i } =
|
|
4731
|
+
let { svg: t, width: r, height: i } = De(e.value);
|
|
4708
4732
|
n.push({
|
|
4709
4733
|
type: "formula",
|
|
4710
4734
|
width: r,
|
|
@@ -6447,42 +6471,42 @@ var qn = { class: "pe-root" }, Jn = { class: "pe-main" }, Yn = { class: "pe-edit
|
|
|
6447
6471
|
function we(e) {
|
|
6448
6472
|
ye.value = !1, be.value = null, document.body.style.cursor = "", document.body.style.userSelect = "", document.removeEventListener("mousemove", Ce), document.removeEventListener("mouseup", we), L();
|
|
6449
6473
|
}
|
|
6450
|
-
let Te = f(!1), Ee = f(null),
|
|
6451
|
-
function
|
|
6474
|
+
let Te = f(!1), Ee = f(null), De = f(0), Oe = f(0);
|
|
6475
|
+
function ke(e, t) {
|
|
6452
6476
|
let n = C.selectedUnderlineId.value;
|
|
6453
6477
|
if (!n) return;
|
|
6454
6478
|
let r = C.findUnderlineById(n);
|
|
6455
|
-
r && (t.stopPropagation(), Te.value = !0, Ee.value = e,
|
|
6479
|
+
r && (t.stopPropagation(), Te.value = !0, Ee.value = e, De.value = t.clientX, Oe.value = r.underline.width, document.body.style.cursor = "ew-resize", document.body.style.userSelect = "none", document.addEventListener("mousemove", K), document.addEventListener("mouseup", Ae));
|
|
6456
6480
|
}
|
|
6457
|
-
function
|
|
6481
|
+
function K(e) {
|
|
6458
6482
|
if (!Te.value || !Ee.value) return;
|
|
6459
6483
|
let t = C.selectedUnderlineId.value;
|
|
6460
6484
|
if (!t) return;
|
|
6461
|
-
let n = (e.clientX -
|
|
6462
|
-
C.updateUnderlineWidth(t,
|
|
6485
|
+
let n = (e.clientX - De.value) / T.value, r = Ee.value === "right" ? n : -n;
|
|
6486
|
+
C.updateUnderlineWidth(t, Oe.value + r), o(() => de());
|
|
6463
6487
|
}
|
|
6464
|
-
function
|
|
6465
|
-
Te.value = !1, Ee.value = null, document.body.style.cursor = "", document.body.style.userSelect = "", document.removeEventListener("mousemove",
|
|
6488
|
+
function Ae(e) {
|
|
6489
|
+
Te.value = !1, Ee.value = null, document.body.style.cursor = "", document.body.style.userSelect = "", document.removeEventListener("mousemove", K), document.removeEventListener("mouseup", Ae), L();
|
|
6466
6490
|
}
|
|
6467
|
-
let
|
|
6468
|
-
function
|
|
6491
|
+
let je = f(!1), Me = f(null), Ne = f(0), Pe = f(0), Fe = f(0), Ie = f(0);
|
|
6492
|
+
function Le(e, t) {
|
|
6469
6493
|
if (t.button !== 0) return;
|
|
6470
6494
|
let n = C.selectedImageId.value;
|
|
6471
6495
|
if (!n) return;
|
|
6472
6496
|
let r = C.findInlineImageById(n);
|
|
6473
|
-
r && (t.stopPropagation(),
|
|
6497
|
+
r && (t.stopPropagation(), je.value = !0, Me.value = e, Ne.value = t.clientX, Pe.value = t.clientY, Fe.value = r.image.width, Ie.value = r.image.height, document.body.style.userSelect = "none", document.addEventListener("mousemove", Re), document.addEventListener("mouseup", q));
|
|
6474
6498
|
}
|
|
6475
|
-
function
|
|
6476
|
-
if (!
|
|
6499
|
+
function Re(e) {
|
|
6500
|
+
if (!je.value || !Me.value) return;
|
|
6477
6501
|
let t = C.selectedImageId.value;
|
|
6478
6502
|
if (!t) return;
|
|
6479
|
-
let n = (e.clientX -
|
|
6503
|
+
let n = (e.clientX - Ne.value) / T.value, r = Me.value, i = Fe.value;
|
|
6480
6504
|
if (r.includes("e") ? i += n : r.includes("w") && (i -= n), !C.findInlineImageById(t)) return;
|
|
6481
|
-
let a =
|
|
6505
|
+
let a = Ie.value / Math.max(1, Fe.value), s = Math.max(12, Math.round(i * a));
|
|
6482
6506
|
C.updateInlineImageSize(t, i, s), o(() => pe());
|
|
6483
6507
|
}
|
|
6484
|
-
function
|
|
6485
|
-
|
|
6508
|
+
function q(e) {
|
|
6509
|
+
je.value = !1, Me.value = null, document.body.style.userSelect = "", document.removeEventListener("mousemove", Re), document.removeEventListener("mouseup", q), L();
|
|
6486
6510
|
}
|
|
6487
6511
|
function ze(e) {
|
|
6488
6512
|
C.loadDocument(e), L(), S("loaded"), S("change");
|
|
@@ -6634,7 +6658,7 @@ var qn = { class: "pe-root" }, Jn = { class: "pe-main" }, Yn = { class: "pe-edit
|
|
|
6634
6658
|
return l(() => {
|
|
6635
6659
|
x.initialData ? ze(x.initialData) : C.relayout(), x.paperName && (C.paperName.value = x.paperName), x.schoolName && (C.schoolName.value = x.schoolName), x.qrCodeContent && (C.qrCodeContent.value = x.qrCodeContent), S("ready");
|
|
6636
6660
|
}), u(() => {
|
|
6637
|
-
document.removeEventListener("mousemove", Ce), document.removeEventListener("mouseup", we), document.removeEventListener("mousemove",
|
|
6661
|
+
document.removeEventListener("mousemove", Ce), document.removeEventListener("mouseup", we), document.removeEventListener("mousemove", K), document.removeEventListener("mouseup", Ae), document.removeEventListener("mousemove", Re), document.removeEventListener("mouseup", q);
|
|
6638
6662
|
}), v(() => x.qrCodeContent, (e) => {
|
|
6639
6663
|
C.qrCodeContent.value = e || "";
|
|
6640
6664
|
}), m({
|
|
@@ -6824,7 +6848,7 @@ var qn = { class: "pe-root" }, Jn = { class: "pe-main" }, Yn = { class: "pe-edit
|
|
|
6824
6848
|
style: c(ue.value)
|
|
6825
6849
|
}, [i("div", {
|
|
6826
6850
|
class: "pe-ctrl-ul-left",
|
|
6827
|
-
onMousedown: a[0] ||= b((e) =>
|
|
6851
|
+
onMousedown: a[0] ||= b((e) => ke("left", e), ["prevent"])
|
|
6828
6852
|
}, [...a[10] ||= [i("svg", {
|
|
6829
6853
|
xmlns: "http://www.w3.org/2000/svg",
|
|
6830
6854
|
width: "12",
|
|
@@ -6835,7 +6859,7 @@ var qn = { class: "pe-root" }, Jn = { class: "pe-main" }, Yn = { class: "pe-edit
|
|
|
6835
6859
|
d: "M10.5 4L7.5 8l3 4H2V4z"
|
|
6836
6860
|
})], -1)]], 32), i("div", {
|
|
6837
6861
|
class: "pe-ctrl-ul-right",
|
|
6838
|
-
onMousedown: a[1] ||= b((e) =>
|
|
6862
|
+
onMousedown: a[1] ||= b((e) => ke("right", e), ["prevent"])
|
|
6839
6863
|
}, [...a[11] ||= [i("svg", {
|
|
6840
6864
|
xmlns: "http://www.w3.org/2000/svg",
|
|
6841
6865
|
width: "12",
|
|
@@ -6852,19 +6876,19 @@ var qn = { class: "pe-root" }, Jn = { class: "pe-main" }, Yn = { class: "pe-edit
|
|
|
6852
6876
|
}, [
|
|
6853
6877
|
i("div", {
|
|
6854
6878
|
class: "pe-resize-se",
|
|
6855
|
-
onMousedown: a[2] ||= b((e) =>
|
|
6879
|
+
onMousedown: a[2] ||= b((e) => Le("se", e), ["prevent", "stop"])
|
|
6856
6880
|
}, null, 32),
|
|
6857
6881
|
i("div", {
|
|
6858
6882
|
class: "pe-resize-sw",
|
|
6859
|
-
onMousedown: a[3] ||= b((e) =>
|
|
6883
|
+
onMousedown: a[3] ||= b((e) => Le("sw", e), ["prevent", "stop"])
|
|
6860
6884
|
}, null, 32),
|
|
6861
6885
|
i("div", {
|
|
6862
6886
|
class: "pe-resize-ne",
|
|
6863
|
-
onMousedown: a[4] ||= b((e) =>
|
|
6887
|
+
onMousedown: a[4] ||= b((e) => Le("ne", e), ["prevent", "stop"])
|
|
6864
6888
|
}, null, 32),
|
|
6865
6889
|
i("div", {
|
|
6866
6890
|
class: "pe-resize-nw",
|
|
6867
|
-
onMousedown: a[5] ||= b((e) =>
|
|
6891
|
+
onMousedown: a[5] ||= b((e) => Le("nw", e), ["prevent", "stop"])
|
|
6868
6892
|
}, null, 32)
|
|
6869
6893
|
], 4)) : n("", !0),
|
|
6870
6894
|
he.value ? (d(), r("div", {
|
|
@@ -7148,4 +7172,4 @@ var qn = { class: "pe-root" }, Jn = { class: "pe-main" }, Yn = { class: "pe-edit
|
|
|
7148
7172
|
}
|
|
7149
7173
|
}), [["__scopeId", "data-v-e8f833b5"]]);
|
|
7150
7174
|
//#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,
|
|
7175
|
+
export { xn as FONT_SIZE_MAP, A as PAPER_DIMENSIONS, j as PAPER_MM, ir as PaperEditor, te as PaperLayout, lr as PaperPreview, Se as SvgRenderer, Ut as buildPaperHtml, B as calcCharPositions, se as calcTextWidth, Ee as clearFormulaCache, le as clearWidthCache, gt as deserializeDocument, Vt as extractBaseTitle, Sn as fontSizeLabelToPx, Cn as fontSizePxToLabel, Bt as formatSectionTitle, z as getCharWidth, ee as getPaperPreset, Gn as hasTablePlaceholder, De as latexToSvg, Me as latexToSvgBatch, xt as parseQuestionHtml, Nt as parseQuestionJson, Un as renderTablePlaceholders, ht as serializeDocument, P as toBBox, zt as toChineseOrdinal, Hn as usePageSvgRenderer, Bn as usePaperCore };
|
|
@@ -48,9 +48,13 @@ export declare function buildBlockLookup(blocks: ContentBlock[]): Map<string, Co
|
|
|
48
48
|
export declare function resolveQuestionType(block: ContentBlock | undefined): string;
|
|
49
49
|
/** 'student-name' → 'studentName' */
|
|
50
50
|
export declare function camelKey(s: string): string;
|
|
51
|
-
/** 检测 topicId 是否为子题(含 _Block_ 后缀) */
|
|
51
|
+
/** 检测 topicId 是否为子题(含 _Block_ 或 -sub 后缀) */
|
|
52
52
|
export declare function isSubQuestion(topicId: string): boolean;
|
|
53
|
-
/**
|
|
53
|
+
/**
|
|
54
|
+
* 从子题 topicId 提取父题 topicId
|
|
55
|
+
* - _Block_N 模式:去掉 _Block_N 后缀
|
|
56
|
+
* - -subN 模式:替换 -subN 为 -header
|
|
57
|
+
*/
|
|
54
58
|
export declare function extractParentTopicId(topicId: string): string;
|
|
55
59
|
export declare function extractPlainText(block: ContentBlock): string;
|
|
56
60
|
export interface BlockSection {
|