@drghaliasri/butex 8.0.3 → 8.1.1
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/README.md +7 -7
- package/dist/document-cli.js +278 -113
- package/dist/document-cli.js.map +1 -1
- package/dist/document.d.mts +80 -4
- package/dist/document.d.ts +80 -4
- package/dist/document.js +380 -129
- package/dist/document.js.map +1 -1
- package/dist/document.mjs +369 -129
- package/dist/document.mjs.map +1 -1
- package/dist/react-document-preview.d.mts +32 -5
- package/dist/react-document-preview.d.ts +32 -5
- package/dist/react-document-preview.js +132 -80
- package/dist/react-document-preview.js.map +1 -1
- package/dist/react-document-preview.mjs +132 -80
- package/dist/react-document-preview.mjs.map +1 -1
- package/dist/react-document.d.mts +40 -4
- package/dist/react-document.d.ts +40 -4
- package/dist/react-document.js +444 -187
- package/dist/react-document.js.map +1 -1
- package/dist/react-document.mjs +444 -187
- package/dist/react-document.mjs.map +1 -1
- package/package.json +1 -1
package/dist/react-document.mjs
CHANGED
|
@@ -838,82 +838,85 @@ function refTokenLatex(keys, refCommand) {
|
|
|
838
838
|
const command = refCommand === "eqref" ? "\\eqref" : "\\ref";
|
|
839
839
|
return `${command}{${keys.join(",")}}`;
|
|
840
840
|
}
|
|
841
|
-
function
|
|
842
|
-
const
|
|
841
|
+
function implicitObjectKey(kind, ownerId, unitId) {
|
|
842
|
+
const hex = (value) => Array.from(new TextEncoder().encode(value), (byte) => byte.toString(16).padStart(2, "0")).join("");
|
|
843
|
+
const scope = unitId === void 0 ? "a" : "u" + hex(unitId);
|
|
844
|
+
return kind + ":butex-auto-" + scope + "-" + hex(ownerId);
|
|
845
|
+
}
|
|
846
|
+
function implicitReferenceKey(kind, ownerId, unitId) {
|
|
847
|
+
return implicitObjectKey(kind, ownerId, unitId);
|
|
848
|
+
}
|
|
849
|
+
function implicitHeadingReferenceKey(kind, ownerId, unitId) {
|
|
850
|
+
return implicitObjectKey(kind, ownerId, unitId);
|
|
851
|
+
}
|
|
852
|
+
function supportsSingleEquationNumbering(token) {
|
|
853
|
+
return token.display && (token.opening === "\\[" || token.opening === String.fromCharCode(36, 36) || token.opening === "\\begin{equation}" || token.opening === "\\begin{equation*}");
|
|
854
|
+
}
|
|
855
|
+
function isNumberedEquation(token) {
|
|
856
|
+
if (!supportsSingleEquationNumbering(token)) return false;
|
|
857
|
+
if (typeof token.numbered === "boolean") return token.numbered;
|
|
858
|
+
return token.opening === "\\begin{equation}" || Boolean(token.labelEnabled) && Boolean(token.label?.trim());
|
|
859
|
+
}
|
|
860
|
+
function isNumberedFloat(block) {
|
|
861
|
+
return block.captionEnabled && block.caption.trim().length > 0 || block.labelEnabled && block.label.trim().length > 0;
|
|
862
|
+
}
|
|
863
|
+
function collectDocumentReferenceTargets(document2) {
|
|
864
|
+
const targets = [];
|
|
843
865
|
const counters = { fig: 0, tab: 0, eq: 0 };
|
|
844
|
-
function
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
866
|
+
function append(kind, ownerId, caption, numbered, manualKey = "") {
|
|
867
|
+
if (numbered) counters[kind] += 1;
|
|
868
|
+
targets.push({
|
|
869
|
+
key: implicitReferenceKey(kind, ownerId),
|
|
870
|
+
kind,
|
|
871
|
+
ownerId,
|
|
872
|
+
caption,
|
|
873
|
+
number: numbered ? counters[kind] : null,
|
|
874
|
+
...manualKey.trim() ? { manualKey: manualKey.trim() } : {}
|
|
875
|
+
});
|
|
876
|
+
}
|
|
877
|
+
function visitField(field) {
|
|
878
|
+
for (const token of field.tokens) {
|
|
879
|
+
if (token.kind === "math" && supportsSingleEquationNumbering(token)) {
|
|
880
|
+
append("eq", token.id, "", isNumberedEquation(token), token.labelEnabled ? token.label ?? "" : "");
|
|
858
881
|
}
|
|
859
882
|
}
|
|
860
883
|
}
|
|
861
884
|
function walk(blocks) {
|
|
862
885
|
for (const block of blocks) {
|
|
863
|
-
if (block.kind === "image") {
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
if (block.captionEnabled) {
|
|
875
|
-
pushEqFromField(block.captionField.tokens);
|
|
876
|
-
}
|
|
877
|
-
}
|
|
878
|
-
if (block.kind === "table") {
|
|
879
|
-
if (block.labelEnabled && block.label.trim().length > 0) {
|
|
880
|
-
counters.tab += 1;
|
|
881
|
-
entries.push({
|
|
882
|
-
key: block.label.trim(),
|
|
883
|
-
kind: "tab",
|
|
884
|
-
caption: block.captionEnabled ? block.caption : "",
|
|
885
|
-
ownerId: block.id,
|
|
886
|
-
number: counters.tab
|
|
887
|
-
});
|
|
888
|
-
}
|
|
889
|
-
if (block.captionEnabled) {
|
|
890
|
-
pushEqFromField(block.captionField.tokens);
|
|
891
|
-
}
|
|
892
|
-
for (const row of block.rows) {
|
|
893
|
-
for (const cell of row) {
|
|
894
|
-
pushEqFromField(cell.tokens);
|
|
895
|
-
}
|
|
886
|
+
if (block.kind === "image" || block.kind === "table") {
|
|
887
|
+
append(
|
|
888
|
+
block.kind === "image" ? "fig" : "tab",
|
|
889
|
+
block.id,
|
|
890
|
+
block.captionEnabled ? block.caption : "",
|
|
891
|
+
isNumberedFloat(block),
|
|
892
|
+
block.labelEnabled ? block.label : ""
|
|
893
|
+
);
|
|
894
|
+
if (block.captionEnabled) visitField(block.captionField);
|
|
895
|
+
if (block.kind === "table") {
|
|
896
|
+
for (const row of block.rows) for (const cell of row) visitField(cell);
|
|
896
897
|
}
|
|
897
|
-
}
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
}
|
|
901
|
-
if (block.kind === "list") {
|
|
898
|
+
} else if (block.kind === "textBlock") {
|
|
899
|
+
visitField(block.field);
|
|
900
|
+
} else if (block.kind === "list") {
|
|
902
901
|
for (const item of block.items) {
|
|
903
|
-
|
|
902
|
+
visitField(item.field);
|
|
904
903
|
walk(item.blocks);
|
|
905
904
|
}
|
|
906
905
|
}
|
|
907
906
|
}
|
|
908
907
|
}
|
|
909
908
|
walk(document2.blocks);
|
|
910
|
-
return
|
|
909
|
+
return targets;
|
|
910
|
+
}
|
|
911
|
+
function collectDocumentLabels(document2) {
|
|
912
|
+
return collectDocumentReferenceTargets(document2).filter((target) => target.number !== null && Boolean(target.manualKey)).map(({ manualKey, kind, caption, ownerId, number }) => ({ key: manualKey, kind, caption, ownerId, number }));
|
|
911
913
|
}
|
|
912
914
|
function labelNumberMap(document2) {
|
|
913
915
|
const map = /* @__PURE__ */ new Map();
|
|
914
|
-
for (const
|
|
915
|
-
if (
|
|
916
|
-
|
|
916
|
+
for (const target of collectDocumentReferenceTargets(document2)) {
|
|
917
|
+
if (target.number === null) continue;
|
|
918
|
+
for (const key of [target.key, target.manualKey]) {
|
|
919
|
+
if (key && !map.has(key)) map.set(key, { kind: target.kind, number: target.number });
|
|
917
920
|
}
|
|
918
921
|
}
|
|
919
922
|
return map;
|
|
@@ -967,8 +970,12 @@ function stripDisplayMathDelimiters(source) {
|
|
|
967
970
|
if (trimmed.startsWith("$$") && trimmed.endsWith("$$")) {
|
|
968
971
|
return trimmed.slice(2, -2).trim();
|
|
969
972
|
}
|
|
970
|
-
|
|
971
|
-
|
|
973
|
+
for (const environment of ["equation", "equation*"]) {
|
|
974
|
+
const opening = `\\begin{${environment}}`;
|
|
975
|
+
const closing = `\\end{${environment}}`;
|
|
976
|
+
if (trimmed.startsWith(opening) && trimmed.endsWith(closing)) {
|
|
977
|
+
return trimmed.slice(opening.length, -closing.length).trim();
|
|
978
|
+
}
|
|
972
979
|
}
|
|
973
980
|
return trimmed;
|
|
974
981
|
}
|
|
@@ -1361,7 +1368,8 @@ function createInlineField(value = "", mathObjects = [], options = {}, path = "$
|
|
|
1361
1368
|
editable: true,
|
|
1362
1369
|
sourceOwner: structuredMathJson.source_owner === "editor" ? "editor" : "imported-structured",
|
|
1363
1370
|
...typeof structuredMathJson.label_enabled === "boolean" ? { labelEnabled: structuredMathJson.label_enabled } : {},
|
|
1364
|
-
...typeof structuredMathJson.label === "string" ? { label: structuredMathJson.label } : {}
|
|
1371
|
+
...typeof structuredMathJson.label === "string" ? { label: structuredMathJson.label } : {},
|
|
1372
|
+
...typeof structuredMathJson.numbered === "boolean" ? { numbered: structuredMathJson.numbered } : {}
|
|
1365
1373
|
});
|
|
1366
1374
|
} else {
|
|
1367
1375
|
tokens.push({
|
|
@@ -1376,7 +1384,8 @@ function createInlineField(value = "", mathObjects = [], options = {}, path = "$
|
|
|
1376
1384
|
reason: "\u0647\u0630\u0647 \u0627\u0644\u0645\u0639\u0627\u062F\u0644\u0629 \u0645\u062D\u0641\u0648\u0638\u0629 \u0643\u0646\u0635 \u062E\u0627\u0645 \u0641\u0642\u0637 \u062D\u0627\u0644\u064A\u0627",
|
|
1377
1385
|
sourceOwner: "raw",
|
|
1378
1386
|
...mathJson?.node_type === "RawMathObject" && typeof mathJson.label_enabled === "boolean" ? { labelEnabled: mathJson.label_enabled } : {},
|
|
1379
|
-
...mathJson?.node_type === "RawMathObject" && typeof mathJson.label === "string" ? { label: mathJson.label } : {}
|
|
1387
|
+
...mathJson?.node_type === "RawMathObject" && typeof mathJson.label === "string" ? { label: mathJson.label } : {},
|
|
1388
|
+
...mathJson?.node_type === "RawMathObject" && typeof mathJson.numbered === "boolean" ? { numbered: mathJson.numbered } : {}
|
|
1380
1389
|
});
|
|
1381
1390
|
}
|
|
1382
1391
|
index = span.end;
|
|
@@ -1473,6 +1482,7 @@ function parseTextBlock(json, options, path, diagnostics, identities) {
|
|
|
1473
1482
|
identities
|
|
1474
1483
|
),
|
|
1475
1484
|
...metadataFromJson(json.metadata),
|
|
1485
|
+
...typeof json.label === "string" && json.command !== "\\paragraph" ? { label: json.label } : {},
|
|
1476
1486
|
...json.centered === true ? { centered: true } : {}
|
|
1477
1487
|
};
|
|
1478
1488
|
}
|
|
@@ -9452,6 +9462,9 @@ function replaceMathTokenFromSession(document2, tokenId, session, opening, closi
|
|
|
9452
9462
|
if (current.label !== void 0) {
|
|
9453
9463
|
replaced.label = current.label;
|
|
9454
9464
|
}
|
|
9465
|
+
if (current.numbered !== void 0) {
|
|
9466
|
+
replaced.numbered = current.numbered;
|
|
9467
|
+
}
|
|
9455
9468
|
field.tokens[index] = replaced;
|
|
9456
9469
|
return true;
|
|
9457
9470
|
});
|
|
@@ -9488,6 +9501,24 @@ function updateDocumentTextBlockCentered(document2, blockId, centered) {
|
|
|
9488
9501
|
visit(next.blocks);
|
|
9489
9502
|
return next;
|
|
9490
9503
|
}
|
|
9504
|
+
function updateDocumentHeadingLabel(document2, blockId, label) {
|
|
9505
|
+
const next = cloneDocument(document2);
|
|
9506
|
+
function visit(blocks) {
|
|
9507
|
+
for (const block of blocks) {
|
|
9508
|
+
if (block.id === blockId && block.kind === "textBlock" && block.command !== "\\paragraph") {
|
|
9509
|
+
if (label.trim()) block.label = label.trim();
|
|
9510
|
+
else delete block.label;
|
|
9511
|
+
return true;
|
|
9512
|
+
}
|
|
9513
|
+
if (block.kind === "list") {
|
|
9514
|
+
for (const item of block.items) if (visit(item.blocks)) return true;
|
|
9515
|
+
}
|
|
9516
|
+
}
|
|
9517
|
+
return false;
|
|
9518
|
+
}
|
|
9519
|
+
visit(next.blocks);
|
|
9520
|
+
return next;
|
|
9521
|
+
}
|
|
9491
9522
|
function newListBlock(ordered) {
|
|
9492
9523
|
const command = ordered ? "\\begin{enumerate}" : "\\begin{itemize}";
|
|
9493
9524
|
const closing = ordered ? "\\end{enumerate}" : "\\end{itemize}";
|
|
@@ -9671,6 +9702,9 @@ function updateMathTokenLabel(document2, tokenId, patch) {
|
|
|
9671
9702
|
if (typeof patch.label === "string") {
|
|
9672
9703
|
token.label = patch.label;
|
|
9673
9704
|
}
|
|
9705
|
+
if (typeof patch.numbered === "boolean") {
|
|
9706
|
+
token.numbered = patch.numbered;
|
|
9707
|
+
}
|
|
9674
9708
|
return true;
|
|
9675
9709
|
});
|
|
9676
9710
|
return next;
|
|
@@ -9988,12 +10022,13 @@ function serializeField(field) {
|
|
|
9988
10022
|
}
|
|
9989
10023
|
value += token.source;
|
|
9990
10024
|
if (!token.math || token.sourceOwner === "raw") {
|
|
9991
|
-
if (token.labelEnabled !== void 0 || token.label !== void 0) {
|
|
10025
|
+
if (token.labelEnabled !== void 0 || token.label !== void 0 || token.numbered !== void 0) {
|
|
9992
10026
|
hasPersistedMath = true;
|
|
9993
10027
|
mathObjects.push({
|
|
9994
10028
|
node_type: "RawMathObject",
|
|
9995
10029
|
...token.labelEnabled !== void 0 ? { label_enabled: token.labelEnabled } : {},
|
|
9996
|
-
...token.label !== void 0 ? { label: token.label } : {}
|
|
10030
|
+
...token.label !== void 0 ? { label: token.label } : {},
|
|
10031
|
+
...token.numbered !== void 0 ? { numbered: token.numbered } : {}
|
|
9997
10032
|
});
|
|
9998
10033
|
} else {
|
|
9999
10034
|
mathObjects.push(null);
|
|
@@ -10006,7 +10041,8 @@ function serializeField(field) {
|
|
|
10006
10041
|
...token.sourceSide ? { source_side: token.sourceSide } : {},
|
|
10007
10042
|
source_owner: token.sourceOwner,
|
|
10008
10043
|
...token.labelEnabled !== void 0 ? { label_enabled: token.labelEnabled } : {},
|
|
10009
|
-
...token.label !== void 0 ? { label: token.label } : {}
|
|
10044
|
+
...token.label !== void 0 ? { label: token.label } : {},
|
|
10045
|
+
...token.numbered !== void 0 ? { numbered: token.numbered } : {}
|
|
10010
10046
|
});
|
|
10011
10047
|
}
|
|
10012
10048
|
return { value, formats, mathObjects, hasPersistedMath, inlineIds: inlineIdsFromField(field) };
|
|
@@ -10046,6 +10082,7 @@ function blockJson(block) {
|
|
|
10046
10082
|
id: block.id,
|
|
10047
10083
|
command: block.command,
|
|
10048
10084
|
...fieldJson(block.field),
|
|
10085
|
+
...block.command !== "\\paragraph" && block.label ? { label: block.label } : {},
|
|
10049
10086
|
...block.metadata ? { metadata: { ...block.metadata } } : {},
|
|
10050
10087
|
...block.command === "\\paragraph" ? { centered: block.centered === true } : {}
|
|
10051
10088
|
};
|
|
@@ -10437,7 +10474,7 @@ function refTokenLatexForDocument(token, labelKinds, previousToken) {
|
|
|
10437
10474
|
}
|
|
10438
10475
|
return `${semanticRefPrefix(kind)}~${reference}`;
|
|
10439
10476
|
}
|
|
10440
|
-
function tokenLatex(token, labelKinds, previousToken) {
|
|
10477
|
+
function tokenLatex(token, labelKinds, previousToken, unitId) {
|
|
10441
10478
|
if (token.kind === "text") {
|
|
10442
10479
|
return styledTextLatex(token.text, token.style);
|
|
10443
10480
|
}
|
|
@@ -10447,12 +10484,15 @@ function tokenLatex(token, labelKinds, previousToken) {
|
|
|
10447
10484
|
if (token.kind === "ref") {
|
|
10448
10485
|
return refTokenLatexForDocument(token, labelKinds, previousToken);
|
|
10449
10486
|
}
|
|
10450
|
-
if (token
|
|
10487
|
+
if (isNumberedEquation(token)) {
|
|
10451
10488
|
const body = mathBodyLatex(token);
|
|
10452
|
-
|
|
10453
|
-
|
|
10454
|
-
|
|
10455
|
-
\\end{equation}
|
|
10489
|
+
const autoKey = implicitReferenceKey("eq", token.id, unitId);
|
|
10490
|
+
const aliases = [autoKey];
|
|
10491
|
+
if (token.labelEnabled && token.label?.trim() && token.label.trim() !== autoKey) aliases.push(token.label.trim());
|
|
10492
|
+
return "\\begin{equation}\n" + body + "\n" + aliases.map((key) => "\\label{" + key + "}").join("\n") + "\n\\end{equation}";
|
|
10493
|
+
}
|
|
10494
|
+
if (token.display && token.numbered === false && token.opening === "\\begin{equation}") {
|
|
10495
|
+
return "\\[" + mathBodyLatex(token) + "\\]";
|
|
10456
10496
|
}
|
|
10457
10497
|
if (token.sourceOwner === "editor") {
|
|
10458
10498
|
return editorMathLatexForCompile(token);
|
|
@@ -10462,13 +10502,18 @@ ${body}
|
|
|
10462
10502
|
}
|
|
10463
10503
|
return renderMathNodeLatex(token.math);
|
|
10464
10504
|
}
|
|
10465
|
-
function inlineFieldLatexWithLabelKinds(field, labelKinds) {
|
|
10466
|
-
return field.tokens.map((token, index) => tokenLatex(token, labelKinds, field.tokens[index - 1])).join("");
|
|
10505
|
+
function inlineFieldLatexWithLabelKinds(field, labelKinds, unitId) {
|
|
10506
|
+
return field.tokens.map((token, index) => tokenLatex(token, labelKinds, field.tokens[index - 1], unitId)).join("");
|
|
10467
10507
|
}
|
|
10468
|
-
function textBlockLatex(block, labelKinds) {
|
|
10469
|
-
const content = inlineFieldLatexWithLabelKinds(block.field, labelKinds);
|
|
10508
|
+
function textBlockLatex(block, labelKinds, unitId) {
|
|
10509
|
+
const content = inlineFieldLatexWithLabelKinds(block.field, labelKinds, unitId);
|
|
10470
10510
|
const body = block.command === "\\paragraph" ? `\\par
|
|
10471
10511
|
${content}` : `${block.command}{${content}}`;
|
|
10512
|
+
if (block.command !== "\\paragraph") {
|
|
10513
|
+
const keys = unitId ? [implicitHeadingReferenceKey(block.command.slice(1), block.id, unitId)] : [];
|
|
10514
|
+
if (block.label?.trim() && !keys.includes(block.label.trim())) keys.push(block.label.trim());
|
|
10515
|
+
return [body, ...keys.map((key) => `\\label{${key}}`)].join("\n");
|
|
10516
|
+
}
|
|
10472
10517
|
if (block.command === "\\paragraph" && block.centered) {
|
|
10473
10518
|
return `\\begin{center}
|
|
10474
10519
|
${body}
|
|
@@ -10479,10 +10524,10 @@ ${body}
|
|
|
10479
10524
|
function indent(value) {
|
|
10480
10525
|
return value.split("\n").map((line) => ` ${line}`).join("\n");
|
|
10481
10526
|
}
|
|
10482
|
-
function listBlockLatex(block, references, labelKinds, fixedFloats) {
|
|
10527
|
+
function listBlockLatex(block, references, labelKinds, fixedFloats, unitId) {
|
|
10483
10528
|
const items = block.items.map((item) => {
|
|
10484
|
-
const nested = item.blocks.map((child) => "\n" + indent(blockLatex(child, references, labelKinds, fixedFloats))).join("");
|
|
10485
|
-
return ` \\item ${inlineFieldLatexWithLabelKinds(item.field, labelKinds)}${nested}`;
|
|
10529
|
+
const nested = item.blocks.map((child) => "\n" + indent(blockLatex(child, references, labelKinds, fixedFloats, unitId))).join("");
|
|
10530
|
+
return ` \\item ${inlineFieldLatexWithLabelKinds(item.field, labelKinds, unitId)}${nested}`;
|
|
10486
10531
|
}).join("\n");
|
|
10487
10532
|
return `${block.command}
|
|
10488
10533
|
${items}
|
|
@@ -10496,9 +10541,9 @@ function defaultGridColumnSpec(block) {
|
|
|
10496
10541
|
}
|
|
10497
10542
|
return `|${compact.split("").join("|")}|`;
|
|
10498
10543
|
}
|
|
10499
|
-
function tabularInnerLatex(block, labelKinds) {
|
|
10544
|
+
function tabularInnerLatex(block, labelKinds, unitId) {
|
|
10500
10545
|
const rows = block.rows.map(
|
|
10501
|
-
(row) => ` ${row.map((cell) => inlineFieldLatexWithLabelKinds(cell, labelKinds)).join(" & ")}`
|
|
10546
|
+
(row) => ` ${row.map((cell) => inlineFieldLatexWithLabelKinds(cell, labelKinds, unitId)).join(" & ")}`
|
|
10502
10547
|
);
|
|
10503
10548
|
const gridColumns = defaultGridColumnSpec(block);
|
|
10504
10549
|
if (gridColumns) {
|
|
@@ -10512,29 +10557,30 @@ ${block.closing}`;
|
|
|
10512
10557
|
${rows.join(" \\\\\n")}
|
|
10513
10558
|
${block.closing}`;
|
|
10514
10559
|
}
|
|
10515
|
-
function floatCaptionLabelLines(block, counter, labelKinds) {
|
|
10560
|
+
function floatCaptionLabelLines(block, counter, labelKinds, unitId) {
|
|
10516
10561
|
const lines = [];
|
|
10517
|
-
const caption = inlineFieldLatexWithLabelKinds(block.captionField, labelKinds).trim();
|
|
10562
|
+
const caption = inlineFieldLatexWithLabelKinds(block.captionField, labelKinds, unitId).trim();
|
|
10518
10563
|
const hasCaption = block.captionEnabled && caption.length > 0;
|
|
10519
10564
|
if (hasCaption) {
|
|
10520
10565
|
lines.push(` \\caption{${caption}}`);
|
|
10521
10566
|
}
|
|
10522
|
-
|
|
10523
|
-
|
|
10524
|
-
|
|
10525
|
-
|
|
10526
|
-
lines.push(
|
|
10567
|
+
const hasManualLabel = block.labelEnabled && block.label.trim().length > 0;
|
|
10568
|
+
if (hasCaption || hasManualLabel) {
|
|
10569
|
+
if (!hasCaption) lines.push(" \\refstepcounter{" + counter + "}");
|
|
10570
|
+
const autoKey = implicitReferenceKey(counter === "figure" ? "fig" : "tab", block.id, unitId);
|
|
10571
|
+
lines.push(" \\label{" + autoKey + "}");
|
|
10572
|
+
if (hasManualLabel && block.label.trim() !== autoKey) lines.push(" \\label{" + block.label.trim() + "}");
|
|
10527
10573
|
}
|
|
10528
10574
|
return lines;
|
|
10529
10575
|
}
|
|
10530
|
-
function tableBlockLatex(block, labelKinds, fixedFloats) {
|
|
10576
|
+
function tableBlockLatex(block, labelKinds, fixedFloats, unitId) {
|
|
10531
10577
|
const placement = fixedFloats ? "H" : "htbp";
|
|
10532
10578
|
const lines = [`\\begin{table}[${placement}]`];
|
|
10533
10579
|
if (block.centered) {
|
|
10534
10580
|
lines.push(" \\centering");
|
|
10535
10581
|
}
|
|
10536
|
-
lines.push(...floatCaptionLabelLines(block, "table", labelKinds));
|
|
10537
|
-
lines.push(indent(tabularInnerLatex(block, labelKinds)));
|
|
10582
|
+
lines.push(...floatCaptionLabelLines(block, "table", labelKinds, unitId));
|
|
10583
|
+
lines.push(indent(tabularInnerLatex(block, labelKinds, unitId)));
|
|
10538
10584
|
lines.push("\\end{table}");
|
|
10539
10585
|
return lines.join("\n");
|
|
10540
10586
|
}
|
|
@@ -10553,29 +10599,29 @@ function imageOptionsLatex(block, constrainToColumn) {
|
|
|
10553
10599
|
}
|
|
10554
10600
|
return `[${entries.map(([key, value]) => `${key}=${value}`).join(",")}]`;
|
|
10555
10601
|
}
|
|
10556
|
-
function imageBlockLatex(block, labelKinds, fixedFloats) {
|
|
10602
|
+
function imageBlockLatex(block, labelKinds, fixedFloats, unitId) {
|
|
10557
10603
|
const placement = fixedFloats ? "H" : "htbp";
|
|
10558
10604
|
const lines = [`\\begin{figure}[${placement}]`];
|
|
10559
10605
|
if (block.centered) {
|
|
10560
10606
|
lines.push(" \\centering");
|
|
10561
10607
|
}
|
|
10562
10608
|
lines.push(` ${block.command}${imageOptionsLatex(block, true)}{${block.value}}`);
|
|
10563
|
-
lines.push(...floatCaptionLabelLines(block, "figure", labelKinds));
|
|
10609
|
+
lines.push(...floatCaptionLabelLines(block, "figure", labelKinds, unitId));
|
|
10564
10610
|
lines.push("\\end{figure}");
|
|
10565
10611
|
return lines.join("\n");
|
|
10566
10612
|
}
|
|
10567
|
-
function blockLatex(block, references, labelKinds, fixedFloats) {
|
|
10613
|
+
function blockLatex(block, references, labelKinds, fixedFloats, unitId) {
|
|
10568
10614
|
if (block.kind === "textBlock") {
|
|
10569
|
-
return textBlockLatex(block, labelKinds);
|
|
10615
|
+
return textBlockLatex(block, labelKinds, unitId);
|
|
10570
10616
|
}
|
|
10571
10617
|
if (block.kind === "list") {
|
|
10572
|
-
return listBlockLatex(block, references, labelKinds, fixedFloats);
|
|
10618
|
+
return listBlockLatex(block, references, labelKinds, fixedFloats, unitId);
|
|
10573
10619
|
}
|
|
10574
10620
|
if (block.kind === "table") {
|
|
10575
|
-
return tableBlockLatex(block, labelKinds, fixedFloats);
|
|
10621
|
+
return tableBlockLatex(block, labelKinds, fixedFloats, unitId);
|
|
10576
10622
|
}
|
|
10577
10623
|
if (block.kind === "image") {
|
|
10578
|
-
return imageBlockLatex(block, labelKinds, fixedFloats);
|
|
10624
|
+
return imageBlockLatex(block, labelKinds, fixedFloats, unitId);
|
|
10579
10625
|
}
|
|
10580
10626
|
if (block.kind === "bibliography") {
|
|
10581
10627
|
const width = String(Math.max(references.length, 9));
|
|
@@ -10619,10 +10665,8 @@ ${meta.abstract.trim()}
|
|
|
10619
10665
|
}
|
|
10620
10666
|
function documentLabelKindMap(document2) {
|
|
10621
10667
|
const map = /* @__PURE__ */ new Map();
|
|
10622
|
-
for (const entry of
|
|
10623
|
-
|
|
10624
|
-
map.set(entry.key, entry.kind);
|
|
10625
|
-
}
|
|
10668
|
+
for (const [key, entry] of labelNumberMap(document2)) {
|
|
10669
|
+
map.set(key, entry.kind);
|
|
10626
10670
|
}
|
|
10627
10671
|
return map;
|
|
10628
10672
|
}
|
|
@@ -10631,6 +10675,17 @@ function closingHamdalaLatex() {
|
|
|
10631
10675
|
\\maghribi{${BUTEX_CLOSING_HAMDALA}}
|
|
10632
10676
|
\\end{center}`;
|
|
10633
10677
|
}
|
|
10678
|
+
function documentContentLatex(document2, context) {
|
|
10679
|
+
if (!context?.unitId?.trim()) throw new Error("book-content export requires a stable unitId");
|
|
10680
|
+
const labelKinds = documentLabelKindMap(document2);
|
|
10681
|
+
for (const target of context?.targets ?? []) {
|
|
10682
|
+
if (target.kind === "fig" || target.kind === "tab" || target.kind === "eq") {
|
|
10683
|
+
labelKinds.set(target.key, target.kind);
|
|
10684
|
+
if (target.manualKey) labelKinds.set(target.manualKey, target.kind);
|
|
10685
|
+
}
|
|
10686
|
+
}
|
|
10687
|
+
return document2.blocks.filter((block) => block.kind !== "bibliography").map((block) => blockLatex(block, document2.references, labelKinds, false, context?.unitId)).filter((part) => part.length > 0).join("\n\n");
|
|
10688
|
+
}
|
|
10634
10689
|
function documentLatex(document2, options = {}) {
|
|
10635
10690
|
const meta = document2.meta ?? emptyDocumentMeta();
|
|
10636
10691
|
const twocolumn = options.twocolumn === true;
|
|
@@ -10662,6 +10717,65 @@ ${body}
|
|
|
10662
10717
|
`;
|
|
10663
10718
|
}
|
|
10664
10719
|
|
|
10720
|
+
// src/document/bookContent.ts
|
|
10721
|
+
function bookContextReferences(context) {
|
|
10722
|
+
return (context?.references ?? []).map((entry, index) => ({
|
|
10723
|
+
...referenceFromJson(entry),
|
|
10724
|
+
id: "book-ref-" + String(index)
|
|
10725
|
+
}));
|
|
10726
|
+
}
|
|
10727
|
+
function bookContentTargets(document2, context) {
|
|
10728
|
+
const local = collectDocumentReferenceTargets(document2).map((target) => {
|
|
10729
|
+
const key = implicitReferenceKey(target.kind, target.ownerId, context.unitId);
|
|
10730
|
+
const projection = context.targets?.find((entry) => entry.unitId === context.unitId && (entry.ownerId === target.ownerId || entry.key === key));
|
|
10731
|
+
return {
|
|
10732
|
+
...target,
|
|
10733
|
+
key,
|
|
10734
|
+
...projection?.displayLabel ? { displayLabel: projection.displayLabel } : {}
|
|
10735
|
+
};
|
|
10736
|
+
});
|
|
10737
|
+
const headings = document2.blocks.flatMap((block) => {
|
|
10738
|
+
if (block.kind !== "textBlock" || block.command === "\\paragraph") return [];
|
|
10739
|
+
const kind = block.command.slice(1);
|
|
10740
|
+
const caption = block.field.tokens.filter((token) => token.kind === "text").map((token) => token.text).join("");
|
|
10741
|
+
return [{
|
|
10742
|
+
unitId: context.unitId,
|
|
10743
|
+
ownerId: block.id,
|
|
10744
|
+
kind,
|
|
10745
|
+
key: implicitHeadingReferenceKey(kind, block.id, context.unitId),
|
|
10746
|
+
caption,
|
|
10747
|
+
number: null,
|
|
10748
|
+
displayLabel: context.targets?.find((target) => target.unitId === context.unitId && target.ownerId === block.id)?.displayLabel ?? (caption || kind),
|
|
10749
|
+
...block.label ? { manualKey: block.label } : {}
|
|
10750
|
+
}];
|
|
10751
|
+
});
|
|
10752
|
+
const external = (context.targets ?? []).filter((target) => target.unitId !== context.unitId).map((target) => ({
|
|
10753
|
+
...target,
|
|
10754
|
+
caption: target.caption ?? "",
|
|
10755
|
+
number: null
|
|
10756
|
+
}));
|
|
10757
|
+
return [...local, ...headings, ...external];
|
|
10758
|
+
}
|
|
10759
|
+
function formatBookReferenceLabel(keys, document2, command, context, options = {}) {
|
|
10760
|
+
const targets = context.targets ?? [];
|
|
10761
|
+
return keys.map((key) => {
|
|
10762
|
+
const target = targets.find((entry) => entry.key === key || entry.manualKey === key);
|
|
10763
|
+
if (target?.displayLabel) return target.displayLabel;
|
|
10764
|
+
const local = collectDocumentReferenceTargets(document2).find((entry) => entry.manualKey === key || implicitReferenceKey(entry.kind, entry.ownerId, context.unitId) === key);
|
|
10765
|
+
if (local) return formatRefLabel([local.manualKey || local.key], document2, command, options);
|
|
10766
|
+
const heading = document2.blocks.find((block) => block.kind === "textBlock" && block.command !== "\\paragraph" && (block.label === key || implicitHeadingReferenceKey(
|
|
10767
|
+
block.command.slice(1),
|
|
10768
|
+
block.id,
|
|
10769
|
+
context.unitId
|
|
10770
|
+
) === key));
|
|
10771
|
+
if (heading?.kind === "textBlock") {
|
|
10772
|
+
const caption = heading.field.tokens.filter((token) => token.kind === "text").map((token) => token.text).join("").trim();
|
|
10773
|
+
return caption || heading.command.slice(1);
|
|
10774
|
+
}
|
|
10775
|
+
return command === "eqref" ? "(?)" : "?";
|
|
10776
|
+
}).join(options.documentDirection === "ltr" ? ", " : "\u060C");
|
|
10777
|
+
}
|
|
10778
|
+
|
|
10665
10779
|
// src/document/validation.ts
|
|
10666
10780
|
var XELATEX_UNSUPPORTED_EMOJI_PATTERN = /[\p{Emoji_Presentation}\p{Emoji_Modifier}\p{Regional_Indicator}\uFE0F\u20E3]/u;
|
|
10667
10781
|
function hasXeLatexUnsupportedEmoji(value) {
|
|
@@ -10721,10 +10835,17 @@ function validateToken(context, token, path, blockId) {
|
|
|
10721
10835
|
return;
|
|
10722
10836
|
}
|
|
10723
10837
|
validateTextValue(context, token.source, `${path}.source`, blockId, token.id);
|
|
10838
|
+
if (token.numbered === true && !supportsSingleEquationNumbering(token)) {
|
|
10839
|
+
addIssue(context, "invalid_equation_label", `${path}.numbered`, blockId, token.id);
|
|
10840
|
+
}
|
|
10724
10841
|
if (!token.labelEnabled) {
|
|
10725
10842
|
return;
|
|
10726
10843
|
}
|
|
10727
|
-
if (!token
|
|
10844
|
+
if (!supportsSingleEquationNumbering(token)) {
|
|
10845
|
+
addIssue(context, "invalid_equation_label", `${path}.label`, blockId, token.id);
|
|
10846
|
+
return;
|
|
10847
|
+
}
|
|
10848
|
+
if (!isNumberedEquation(token)) {
|
|
10728
10849
|
addIssue(context, "invalid_equation_label", `${path}.label`, blockId, token.id);
|
|
10729
10850
|
return;
|
|
10730
10851
|
}
|
|
@@ -10738,6 +10859,13 @@ function validateInlineField(context, field, path, blockId) {
|
|
|
10738
10859
|
function validateBlock(context, block, path) {
|
|
10739
10860
|
if (block.kind === "textBlock") {
|
|
10740
10861
|
validateInlineField(context, block.field, `${path}.field`, block.id);
|
|
10862
|
+
if (block.command !== "\\paragraph") {
|
|
10863
|
+
const kind = block.command.slice(1);
|
|
10864
|
+
if (block.label) registerKey(context, block.label, `${path}.label`, kind, block.id);
|
|
10865
|
+
if (context.bookMode && context.bookContext) {
|
|
10866
|
+
context.labelKinds.set(implicitHeadingReferenceKey(kind, block.id, context.bookContext.unitId), kind);
|
|
10867
|
+
}
|
|
10868
|
+
}
|
|
10741
10869
|
return;
|
|
10742
10870
|
}
|
|
10743
10871
|
if (block.kind === "list") {
|
|
@@ -10787,6 +10915,10 @@ function validateBlock(context, block, path) {
|
|
|
10787
10915
|
}
|
|
10788
10916
|
return;
|
|
10789
10917
|
}
|
|
10918
|
+
if (block.kind === "bibliography" && context.bookMode) {
|
|
10919
|
+
addIssue(context, "book_local_bibliography", path, block.id);
|
|
10920
|
+
return;
|
|
10921
|
+
}
|
|
10790
10922
|
if (block.kind === "raw") {
|
|
10791
10923
|
validateTextValue(context, block.value, `${path}.value`, block.id);
|
|
10792
10924
|
}
|
|
@@ -10809,7 +10941,7 @@ function validateDuplicateKeys(context) {
|
|
|
10809
10941
|
}
|
|
10810
10942
|
function validatePendingReferences(context) {
|
|
10811
10943
|
for (const pending of context.pendingCitations) {
|
|
10812
|
-
if (pending.token.keys.some((key) => !isValidDocumentKey(normalizeDocumentKey(key)))) {
|
|
10944
|
+
if (pending.token.keys.some((key) => !isValidDocumentKey(normalizeDocumentKey(key)) || context.citationKeys !== void 0 && !context.citationKeys.has(normalizeDocumentKey(key)))) {
|
|
10813
10945
|
addIssue(
|
|
10814
10946
|
context,
|
|
10815
10947
|
"missing_citation",
|
|
@@ -10822,7 +10954,7 @@ function validatePendingReferences(context) {
|
|
|
10822
10954
|
for (const pending of context.pendingReferences) {
|
|
10823
10955
|
for (const key of pending.token.keys) {
|
|
10824
10956
|
const normalized = normalizeDocumentKey(key);
|
|
10825
|
-
if (!isValidDocumentKey(normalized)) {
|
|
10957
|
+
if (!isValidDocumentKey(normalized) || !context.labelKinds.has(normalized)) {
|
|
10826
10958
|
addIssue(
|
|
10827
10959
|
context,
|
|
10828
10960
|
"missing_reference",
|
|
@@ -10891,7 +11023,7 @@ function resolveDocument(document2) {
|
|
|
10891
11023
|
return null;
|
|
10892
11024
|
}
|
|
10893
11025
|
}
|
|
10894
|
-
function validateDocument(document2) {
|
|
11026
|
+
function validateDocument(document2, options = {}) {
|
|
10895
11027
|
const resolved = resolveDocument(document2);
|
|
10896
11028
|
if (!resolved) {
|
|
10897
11029
|
return {
|
|
@@ -10903,6 +11035,9 @@ function validateDocument(document2) {
|
|
|
10903
11035
|
issues: [],
|
|
10904
11036
|
keyOwners: [],
|
|
10905
11037
|
labelKinds: /* @__PURE__ */ new Map(),
|
|
11038
|
+
bookMode: options.mode === "book-content",
|
|
11039
|
+
bookContext: options.bookContext,
|
|
11040
|
+
...options.mode === "book-content" && options.bookContext?.references ? { citationKeys: new Set(options.bookContext.references.map((entry) => normalizeDocumentKey(entry.key))) } : {},
|
|
10906
11041
|
pendingCitations: [],
|
|
10907
11042
|
pendingReferences: []
|
|
10908
11043
|
};
|
|
@@ -10921,6 +11056,28 @@ function validateDocument(document2) {
|
|
|
10921
11056
|
resolved.blocks.forEach((block, index) => {
|
|
10922
11057
|
validateBlock(context, block, `$.blocks[${String(index)}]`);
|
|
10923
11058
|
});
|
|
11059
|
+
for (const target of collectDocumentReferenceTargets(resolved)) {
|
|
11060
|
+
const autoKey = context.bookMode && context.bookContext ? implicitReferenceKey(target.kind, target.ownerId, context.bookContext.unitId) : target.key;
|
|
11061
|
+
if (target.number !== null && target.manualKey !== autoKey) {
|
|
11062
|
+
registerKey(
|
|
11063
|
+
context,
|
|
11064
|
+
autoKey,
|
|
11065
|
+
"$.automatic_labels",
|
|
11066
|
+
target.kind,
|
|
11067
|
+
target.kind === "eq" ? void 0 : target.ownerId,
|
|
11068
|
+
target.kind === "eq" ? target.ownerId : void 0
|
|
11069
|
+
);
|
|
11070
|
+
}
|
|
11071
|
+
}
|
|
11072
|
+
if (context.bookMode) {
|
|
11073
|
+
for (const target of context.bookContext?.targets ?? []) {
|
|
11074
|
+
context.labelKinds.set(normalizeDocumentKey(target.key), target.kind);
|
|
11075
|
+
if (target.manualKey) context.labelKinds.set(normalizeDocumentKey(target.manualKey), target.kind);
|
|
11076
|
+
}
|
|
11077
|
+
}
|
|
11078
|
+
if (context.bookMode && !context.bookContext?.unitId?.trim()) {
|
|
11079
|
+
addIssue(context, "book_context_required", "$.book_context");
|
|
11080
|
+
}
|
|
10924
11081
|
for (const diagnostic of resolved.diagnostics) {
|
|
10925
11082
|
addIssue(context, "parser_diagnostic", diagnostic.path);
|
|
10926
11083
|
}
|
|
@@ -10931,9 +11088,6 @@ function validateDocument(document2) {
|
|
|
10931
11088
|
issues: context.issues
|
|
10932
11089
|
};
|
|
10933
11090
|
}
|
|
10934
|
-
function isDocumentValid(document2) {
|
|
10935
|
-
return validateDocument(document2).valid;
|
|
10936
|
-
}
|
|
10937
11091
|
|
|
10938
11092
|
// src/document/history.ts
|
|
10939
11093
|
var DEFAULT_DOCUMENT_HISTORY_MAX_DEPTH = 100;
|
|
@@ -11043,7 +11197,7 @@ function previewInlines(field, islands, output, equationSide, document2, preview
|
|
|
11043
11197
|
kind: "cite",
|
|
11044
11198
|
id: token.id,
|
|
11045
11199
|
keys: [...token.keys],
|
|
11046
|
-
label: formatCiteLabel(token.keys, document2.references, {
|
|
11200
|
+
label: formatCiteLabel(token.keys, previewOptions.mode === "book-content" ? bookContextReferences(previewOptions.bookContext) : document2.references, {
|
|
11047
11201
|
documentDirection: previewOptions.documentDirection,
|
|
11048
11202
|
digitForm: previewOptions.digitForm
|
|
11049
11203
|
})
|
|
@@ -11055,12 +11209,16 @@ function previewInlines(field, islands, output, equationSide, document2, preview
|
|
|
11055
11209
|
id: token.id,
|
|
11056
11210
|
keys: [...token.keys],
|
|
11057
11211
|
refCommand: token.refCommand,
|
|
11058
|
-
label:
|
|
11212
|
+
label: previewOptions.mode === "book-content" && previewOptions.bookContext ? formatBookReferenceLabel(token.keys, document2, token.refCommand, previewOptions.bookContext, {
|
|
11213
|
+
documentDirection: previewOptions.documentDirection,
|
|
11214
|
+
digitForm: previewOptions.digitForm
|
|
11215
|
+
}) : formatRefLabel(token.keys, document2, token.refCommand, {
|
|
11059
11216
|
documentDirection: previewOptions.documentDirection,
|
|
11060
11217
|
digitForm: previewOptions.digitForm
|
|
11061
11218
|
})
|
|
11062
11219
|
};
|
|
11063
11220
|
}
|
|
11221
|
+
const number = collectDocumentReferenceTargets(document2).find((target) => target.kind === "eq" && target.ownerId === token.id)?.number;
|
|
11064
11222
|
const island = {
|
|
11065
11223
|
id: token.id,
|
|
11066
11224
|
tex: mathTex(token, equationSide, previewOptions.digitForm),
|
|
@@ -11068,8 +11226,12 @@ function previewInlines(field, islands, output, equationSide, document2, preview
|
|
|
11068
11226
|
output,
|
|
11069
11227
|
editable: token.editable
|
|
11070
11228
|
};
|
|
11229
|
+
const numberLabel = number == null ? void 0 : formatBibliographyNumber(number, {
|
|
11230
|
+
documentDirection: previewOptions.documentDirection,
|
|
11231
|
+
digitForm: previewOptions.digitForm
|
|
11232
|
+
});
|
|
11071
11233
|
islands.push(island);
|
|
11072
|
-
return { kind: "math", ...island };
|
|
11234
|
+
return { kind: "math", ...island, ...numberLabel ? { numberLabel } : {} };
|
|
11073
11235
|
});
|
|
11074
11236
|
}
|
|
11075
11237
|
function textBlockPreview(block, islands, output, equationSide, document2, previewOptions) {
|
|
@@ -11092,12 +11254,9 @@ function textBlockPreview(block, islands, output, equationSide, document2, previ
|
|
|
11092
11254
|
...block.centered ? { centered: true } : {}
|
|
11093
11255
|
};
|
|
11094
11256
|
}
|
|
11095
|
-
function floatNumberLabel(document2,
|
|
11096
|
-
|
|
11097
|
-
|
|
11098
|
-
}
|
|
11099
|
-
const hit = labelNumberMap(document2).get(key.trim());
|
|
11100
|
-
if (!hit || hit.kind !== "fig" && hit.kind !== "tab") {
|
|
11257
|
+
function floatNumberLabel(document2, ownerId, previewOptions) {
|
|
11258
|
+
const hit = collectDocumentReferenceTargets(document2).find((target) => target.ownerId === ownerId);
|
|
11259
|
+
if (!hit || hit.number === null || hit.kind !== "fig" && hit.kind !== "tab") {
|
|
11101
11260
|
return void 0;
|
|
11102
11261
|
}
|
|
11103
11262
|
return formatFloatCaptionTitle(hit.kind, hit.number, {
|
|
@@ -11139,7 +11298,8 @@ function blockPreview(block, islands, output, equationSide, document2, previewOp
|
|
|
11139
11298
|
id: block.id,
|
|
11140
11299
|
rows: block.rows.map((row) => row.map((cell) => previewInlines(cell, islands, output, equationSide, document2, previewOptions))),
|
|
11141
11300
|
...captionPreview(block, islands, output, equationSide, document2, previewOptions),
|
|
11142
|
-
...label.length > 0 ? { label
|
|
11301
|
+
...label.length > 0 ? { label } : {},
|
|
11302
|
+
...floatNumberLabel(document2, block.id, previewOptions) ? { numberLabel: floatNumberLabel(document2, block.id, previewOptions) } : {},
|
|
11143
11303
|
...block.metadata ? { metadata: { ...block.metadata } } : {}
|
|
11144
11304
|
};
|
|
11145
11305
|
}
|
|
@@ -11153,7 +11313,8 @@ function blockPreview(block, islands, output, equationSide, document2, previewOp
|
|
|
11153
11313
|
options: block.options,
|
|
11154
11314
|
centered: block.centered,
|
|
11155
11315
|
...captionPreview(block, islands, output, equationSide, document2, previewOptions),
|
|
11156
|
-
...label.length > 0 ? { label
|
|
11316
|
+
...label.length > 0 ? { label } : {},
|
|
11317
|
+
...floatNumberLabel(document2, block.id, previewOptions) ? { numberLabel: floatNumberLabel(document2, block.id, previewOptions) } : {},
|
|
11157
11318
|
...block.metadata ? { metadata: { ...block.metadata } } : {}
|
|
11158
11319
|
};
|
|
11159
11320
|
}
|
|
@@ -11207,14 +11368,16 @@ function documentPreview(document2, output = "svg", equationSide = "arabic", pre
|
|
|
11207
11368
|
const options = {
|
|
11208
11369
|
documentDirection: previewOptions.documentDirection ?? "rtl",
|
|
11209
11370
|
digitForm: previewOptions.digitForm ?? (previewOptions.documentDirection === "ltr" ? "western" : "arabicIndic"),
|
|
11210
|
-
uiLocale: previewOptions.uiLocale ?? "ar"
|
|
11371
|
+
uiLocale: previewOptions.uiLocale ?? "ar",
|
|
11372
|
+
mode: previewOptions.mode ?? "article",
|
|
11373
|
+
bookContext: previewOptions.bookContext
|
|
11211
11374
|
};
|
|
11212
|
-
const body = document2.blocks.map((block) => blockPreview(block, mathIslands, output, equationSide, document2, options));
|
|
11375
|
+
const body = document2.blocks.filter((block) => options.mode !== "book-content" || block.kind !== "bibliography").map((block) => blockPreview(block, mathIslands, output, equationSide, document2, options));
|
|
11213
11376
|
return {
|
|
11214
11377
|
blocks: [
|
|
11215
|
-
...articleChromePreview(document2, options.uiLocale ?? "ar", options),
|
|
11378
|
+
...options.mode === "book-content" ? [] : articleChromePreview(document2, options.uiLocale ?? "ar", options),
|
|
11216
11379
|
...body,
|
|
11217
|
-
{ kind: "closing", id: "article-closing", text: BUTEX_CLOSING_HAMDALA, tex: butexMaghribiDisplayTex(BUTEX_CLOSING_HAMDALA) }
|
|
11380
|
+
...options.mode === "book-content" ? [] : [{ kind: "closing", id: "article-closing", text: BUTEX_CLOSING_HAMDALA, tex: butexMaghribiDisplayTex(BUTEX_CLOSING_HAMDALA) }]
|
|
11218
11381
|
],
|
|
11219
11382
|
mathIslands
|
|
11220
11383
|
};
|
|
@@ -12447,6 +12610,7 @@ import { jsx as jsx5, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
|
12447
12610
|
function RefChip({
|
|
12448
12611
|
token,
|
|
12449
12612
|
document: document2,
|
|
12613
|
+
bookContext,
|
|
12450
12614
|
documentDirection = "rtl",
|
|
12451
12615
|
digitForm,
|
|
12452
12616
|
editable = true,
|
|
@@ -12458,7 +12622,7 @@ function RefChip({
|
|
|
12458
12622
|
onRequestTextFocus
|
|
12459
12623
|
}) {
|
|
12460
12624
|
const messages = documentMessages(uiLocale);
|
|
12461
|
-
const label = formatRefLabel(token.keys, document2, token.refCommand, { documentDirection, digitForm });
|
|
12625
|
+
const label = bookContext ? formatBookReferenceLabel(token.keys, document2, token.refCommand, bookContext, { documentDirection, digitForm }) : formatRefLabel(token.keys, document2, token.refCommand, { documentDirection, digitForm });
|
|
12462
12626
|
const forwardArrowKey = documentDirection === "rtl" ? "ArrowLeft" : "ArrowRight";
|
|
12463
12627
|
const backwardArrowKey = documentDirection === "rtl" ? "ArrowRight" : "ArrowLeft";
|
|
12464
12628
|
if (!editable) {
|
|
@@ -12536,6 +12700,7 @@ function InlineField({
|
|
|
12536
12700
|
blockId,
|
|
12537
12701
|
references = [],
|
|
12538
12702
|
documentNode,
|
|
12703
|
+
bookContext,
|
|
12539
12704
|
documentDirection = "rtl",
|
|
12540
12705
|
digitForm,
|
|
12541
12706
|
mathOutput = "svg",
|
|
@@ -12772,6 +12937,7 @@ function InlineField({
|
|
|
12772
12937
|
return /* @__PURE__ */ jsx6(
|
|
12773
12938
|
RefChip,
|
|
12774
12939
|
{
|
|
12940
|
+
bookContext,
|
|
12775
12941
|
token,
|
|
12776
12942
|
document: documentNode,
|
|
12777
12943
|
documentDirection,
|
|
@@ -13254,7 +13420,9 @@ function BlockEditor({
|
|
|
13254
13420
|
onParagraphCenteredChange,
|
|
13255
13421
|
onAddListItem,
|
|
13256
13422
|
onRemoveListItem,
|
|
13257
|
-
onManageReferences
|
|
13423
|
+
onManageReferences,
|
|
13424
|
+
bookContext,
|
|
13425
|
+
onHeadingLabelChange
|
|
13258
13426
|
}) {
|
|
13259
13427
|
const messages = documentMessages(uiLocale);
|
|
13260
13428
|
const labels = documentNode ? collectDocumentLabels(documentNode) : [];
|
|
@@ -13269,6 +13437,7 @@ function BlockEditor({
|
|
|
13269
13437
|
blockId: block.id,
|
|
13270
13438
|
references,
|
|
13271
13439
|
documentNode,
|
|
13440
|
+
bookContext,
|
|
13272
13441
|
documentDirection,
|
|
13273
13442
|
digitForm,
|
|
13274
13443
|
mathOutput,
|
|
@@ -13346,6 +13515,18 @@ function BlockEditor({
|
|
|
13346
13515
|
return /* @__PURE__ */ jsxs6("section", { className: chromeClass, "data-butex-block-source": block.metadata?.source, children: [
|
|
13347
13516
|
header,
|
|
13348
13517
|
/* @__PURE__ */ jsx7(InlineField, { field: block.field, ...fieldProps }),
|
|
13518
|
+
bookContext && block.command !== "\\paragraph" ? /* @__PURE__ */ jsxs6("label", { className: "butex-document-widget__refs-field", children: [
|
|
13519
|
+
/* @__PURE__ */ jsx7("span", { children: messages.floatLabel }),
|
|
13520
|
+
/* @__PURE__ */ jsx7(
|
|
13521
|
+
"input",
|
|
13522
|
+
{
|
|
13523
|
+
type: "text",
|
|
13524
|
+
dir: "ltr",
|
|
13525
|
+
value: block.label ?? "",
|
|
13526
|
+
onChange: (event) => onHeadingLabelChange?.(block.id, event.currentTarget.value)
|
|
13527
|
+
}
|
|
13528
|
+
)
|
|
13529
|
+
] }) : null,
|
|
13349
13530
|
block.command === "\\paragraph" ? /* @__PURE__ */ jsx7("div", { className: "butex-document-widget__float-meta butex-document-widget__float-meta--compact", children: /* @__PURE__ */ jsxs6("label", { className: "butex-document-widget__float-meta-toggle", children: [
|
|
13350
13531
|
/* @__PURE__ */ jsx7(
|
|
13351
13532
|
"input",
|
|
@@ -13405,7 +13586,9 @@ function BlockEditor({
|
|
|
13405
13586
|
onParagraphCenteredChange,
|
|
13406
13587
|
onAddListItem,
|
|
13407
13588
|
onRemoveListItem,
|
|
13408
|
-
onManageReferences
|
|
13589
|
+
onManageReferences,
|
|
13590
|
+
bookContext,
|
|
13591
|
+
onHeadingLabelChange
|
|
13409
13592
|
},
|
|
13410
13593
|
child.id
|
|
13411
13594
|
))
|
|
@@ -13765,6 +13948,7 @@ function digitFormLabel(digitForm) {
|
|
|
13765
13948
|
return "456";
|
|
13766
13949
|
}
|
|
13767
13950
|
function DocumentInsertToolbar({
|
|
13951
|
+
mode = "article",
|
|
13768
13952
|
canUndo,
|
|
13769
13953
|
canRedo,
|
|
13770
13954
|
editableEquations = true,
|
|
@@ -13954,7 +14138,7 @@ function DocumentInsertToolbar({
|
|
|
13954
14138
|
)
|
|
13955
14139
|
] }),
|
|
13956
14140
|
/* @__PURE__ */ jsxs9("div", { className: "butex-document-widget__toolbar-group", role: "group", "aria-label": messages.structure, children: [
|
|
13957
|
-
/* @__PURE__ */ jsx10(
|
|
14141
|
+
mode === "article" ? /* @__PURE__ */ jsx10(
|
|
13958
14142
|
"button",
|
|
13959
14143
|
{
|
|
13960
14144
|
type: "button",
|
|
@@ -13964,7 +14148,7 @@ function DocumentInsertToolbar({
|
|
|
13964
14148
|
onClick: onOpenArticleMeta,
|
|
13965
14149
|
children: "\u2726"
|
|
13966
14150
|
}
|
|
13967
|
-
),
|
|
14151
|
+
) : null,
|
|
13968
14152
|
/* @__PURE__ */ jsx10("button", { type: "button", className: "butex-document-widget__icon-btn butex-document-widget__icon-btn--h1", title: messages.addSection, "aria-label": messages.addSection, onClick: onAddSection, children: messages.sectionGlyph }),
|
|
13969
14153
|
/* @__PURE__ */ jsx10("button", { type: "button", className: "butex-document-widget__icon-btn butex-document-widget__icon-btn--h2", title: messages.addSubsection, "aria-label": messages.addSubsection, onClick: onAddSubsection, children: messages.subsectionGlyph }),
|
|
13970
14154
|
/* @__PURE__ */ jsx10("button", { type: "button", className: "butex-document-widget__icon-btn butex-document-widget__icon-btn--h3", title: messages.addSubsubsection, "aria-label": messages.addSubsubsection, onClick: onAddSubsubsection, children: messages.subsubsectionGlyph }),
|
|
@@ -14039,14 +14223,14 @@ function DocumentInsertToolbar({
|
|
|
14039
14223
|
/* @__PURE__ */ jsx10("span", { "aria-hidden": "true", children: "\xA7" }),
|
|
14040
14224
|
/* @__PURE__ */ jsx10("span", { children: messages.insertInternalRef })
|
|
14041
14225
|
] }),
|
|
14042
|
-
/* @__PURE__ */ jsxs9("button", { type: "button", role: "menuitem", title: messages.insertBibliography, onClick: () => runReferenceAction(onInsertBibliography), children: [
|
|
14226
|
+
mode === "article" ? /* @__PURE__ */ jsxs9("button", { type: "button", role: "menuitem", title: messages.insertBibliography, onClick: () => runReferenceAction(onInsertBibliography), children: [
|
|
14043
14227
|
/* @__PURE__ */ jsx10("span", { className: "butex-document-widget__icon-bibliography", "aria-hidden": "true", children: /* @__PURE__ */ jsx10("svg", { viewBox: "0 0 16 16", width: "14", height: "14", focusable: "false", children: /* @__PURE__ */ jsx10("path", { fill: "currentColor", d: "M2.2 2.4h7.2c.9 0 1.6.7 1.6 1.6v9.2c0 .5-.6.8-1 .5l-2.2-1.6H2.2c-.9 0-1.6-.7-1.6-1.6V4c0-.9.7-1.6 1.6-1.6zm0 1.2c-.2 0-.4.2-.4.4v6.5c0 .2.2.4.4.4h6.1l1.5 1.1V4c0-.2-.2-.4-.4-.4H2.2zM3.4 5.2h5.2v1H3.4zm0 2.1h4.2v1H3.4zm0 2.1h3.4v1H3.4zM11.4 4.1h2.2c.8 0 1.4.6 1.4 1.4v7.1c0 .4-.5.7-.8.4l-1.7-1.3h-1.1V4.1zm1.2 1.2v5.4l.7.5V5.5c0-.1-.1-.2-.2-.2h-.5z" }) }) }),
|
|
14044
14228
|
/* @__PURE__ */ jsx10("span", { children: messages.insertBibliography })
|
|
14045
|
-
] }),
|
|
14046
|
-
/* @__PURE__ */ jsxs9("button", { type: "button", role: "menuitem", title: messages.manageReferences, onClick: () => runReferenceAction(onManageReferences), children: [
|
|
14229
|
+
] }) : null,
|
|
14230
|
+
mode === "article" ? /* @__PURE__ */ jsxs9("button", { type: "button", role: "menuitem", title: messages.manageReferences, onClick: () => runReferenceAction(onManageReferences), children: [
|
|
14047
14231
|
/* @__PURE__ */ jsx10("span", { "aria-hidden": "true", children: "\u2630" }),
|
|
14048
14232
|
/* @__PURE__ */ jsx10("span", { children: messages.manageReferences })
|
|
14049
|
-
] }),
|
|
14233
|
+
] }) : null,
|
|
14050
14234
|
/* @__PURE__ */ jsxs9("button", { type: "button", role: "menuitem", title: messages.manageLabels, onClick: () => runReferenceAction(onManageLabels), children: [
|
|
14051
14235
|
/* @__PURE__ */ jsx10("span", { "aria-hidden": "true", children: "\u2317" }),
|
|
14052
14236
|
/* @__PURE__ */ jsx10("span", { children: messages.manageLabels })
|
|
@@ -14078,6 +14262,7 @@ function digitFormLabel2(digitForm) {
|
|
|
14078
14262
|
return "456";
|
|
14079
14263
|
}
|
|
14080
14264
|
function DocumentMobileToolbar({
|
|
14265
|
+
mode = "article",
|
|
14081
14266
|
mobileView,
|
|
14082
14267
|
canUndo,
|
|
14083
14268
|
canRedo,
|
|
@@ -14262,7 +14447,7 @@ function DocumentMobileToolbar({
|
|
|
14262
14447
|
/* @__PURE__ */ jsxs10("section", { className: "butex-document-widget__command-group", "aria-labelledby": `${titleId}-structure`, children: [
|
|
14263
14448
|
/* @__PURE__ */ jsx11("h3", { id: `${titleId}-structure`, children: messages.structure }),
|
|
14264
14449
|
/* @__PURE__ */ jsxs10("div", { className: "butex-document-widget__command-grid", children: [
|
|
14265
|
-
/* @__PURE__ */ jsx11("button", { type: "button", onClick: () => runAction(onOpenArticleMeta), children: messages.articleMetaTitle }),
|
|
14450
|
+
mode === "article" ? /* @__PURE__ */ jsx11("button", { type: "button", onClick: () => runAction(onOpenArticleMeta), children: messages.articleMetaTitle }) : null,
|
|
14266
14451
|
/* @__PURE__ */ jsx11("button", { type: "button", onClick: () => runAction(onAddSection), children: messages.addSection }),
|
|
14267
14452
|
/* @__PURE__ */ jsx11("button", { type: "button", onClick: () => runAction(onAddSubsection), children: messages.addSubsection }),
|
|
14268
14453
|
/* @__PURE__ */ jsx11("button", { type: "button", onClick: () => runAction(onAddSubsubsection), children: messages.addSubsubsection }),
|
|
@@ -14303,8 +14488,8 @@ function DocumentMobileToolbar({
|
|
|
14303
14488
|
/* @__PURE__ */ jsxs10("div", { className: "butex-document-widget__command-grid", children: [
|
|
14304
14489
|
/* @__PURE__ */ jsx11("button", { type: "button", onClick: () => runAction(onInsertCitation, false), children: messages.insertCitation }),
|
|
14305
14490
|
/* @__PURE__ */ jsx11("button", { type: "button", onClick: () => runAction(onInsertInternalRef, false), children: messages.insertInternalRef }),
|
|
14306
|
-
/* @__PURE__ */ jsx11("button", { type: "button", onClick: () => runAction(onInsertBibliography), children: messages.insertBibliography }),
|
|
14307
|
-
/* @__PURE__ */ jsx11("button", { type: "button", onClick: () => runAction(() => onManageReferences(triggerRef.current), false), children: messages.manageReferences }),
|
|
14491
|
+
mode === "article" ? /* @__PURE__ */ jsx11("button", { type: "button", onClick: () => runAction(onInsertBibliography), children: messages.insertBibliography }) : null,
|
|
14492
|
+
mode === "article" ? /* @__PURE__ */ jsx11("button", { type: "button", onClick: () => runAction(() => onManageReferences(triggerRef.current), false), children: messages.manageReferences }) : null,
|
|
14308
14493
|
/* @__PURE__ */ jsx11("button", { type: "button", onClick: () => runAction(() => onManageLabels(triggerRef.current), false), children: messages.manageLabels })
|
|
14309
14494
|
] })
|
|
14310
14495
|
] }),
|
|
@@ -14375,7 +14560,14 @@ function PreviewInlines({ inlines, output }) {
|
|
|
14375
14560
|
if (inline.kind === "ref") {
|
|
14376
14561
|
return /* @__PURE__ */ jsx12("span", { className: "butex-document-widget__preview-cite butex-document-widget__preview-ref", children: contextualRefLabel(inlines, index, inline.label) }, inline.id);
|
|
14377
14562
|
}
|
|
14378
|
-
return /* @__PURE__ */
|
|
14563
|
+
return /* @__PURE__ */ jsxs11("span", { className: "butex-document-widget__preview-math-numbered", children: [
|
|
14564
|
+
/* @__PURE__ */ jsx12(MathIsland, { id: inline.id, tex: inline.tex, display: inline.display, output }),
|
|
14565
|
+
inline.numberLabel ? /* @__PURE__ */ jsxs11("span", { className: "butex-document-widget__preview-equation-number", children: [
|
|
14566
|
+
"(",
|
|
14567
|
+
inline.numberLabel,
|
|
14568
|
+
")"
|
|
14569
|
+
] }) : null
|
|
14570
|
+
] }, inline.id);
|
|
14379
14571
|
}) });
|
|
14380
14572
|
}
|
|
14381
14573
|
function isBodyPreviewBlock(block) {
|
|
@@ -18439,6 +18631,8 @@ function EquationDrawer({
|
|
|
18439
18631
|
responsiveMode = "auto",
|
|
18440
18632
|
labelEnabled = false,
|
|
18441
18633
|
label = "",
|
|
18634
|
+
numbered = false,
|
|
18635
|
+
onNumberedChange,
|
|
18442
18636
|
labels = [],
|
|
18443
18637
|
references = [],
|
|
18444
18638
|
ownerId = "",
|
|
@@ -18528,6 +18722,10 @@ function EquationDrawer({
|
|
|
18528
18722
|
] })
|
|
18529
18723
|
] }),
|
|
18530
18724
|
mathMode === "display" ? /* @__PURE__ */ jsxs14("div", { className: "butex-document-widget__float-meta", children: [
|
|
18725
|
+
/* @__PURE__ */ jsxs14("label", { className: "butex-document-widget__float-meta-toggle", children: [
|
|
18726
|
+
/* @__PURE__ */ jsx15("input", { type: "checkbox", checked: numbered, onChange: (event) => onNumberedChange?.(event.currentTarget.checked) }),
|
|
18727
|
+
/* @__PURE__ */ jsx15("span", { children: uiLocale === "ar" ? "\u062A\u0631\u0642\u064A\u0645 \u0627\u0644\u0645\u0639\u0627\u062F\u0644\u0629" : "Number equation" })
|
|
18728
|
+
] }),
|
|
18531
18729
|
/* @__PURE__ */ jsxs14("label", { className: "butex-document-widget__float-meta-toggle", children: [
|
|
18532
18730
|
/* @__PURE__ */ jsx15(
|
|
18533
18731
|
"input",
|
|
@@ -19051,13 +19249,14 @@ import { useEffect as useEffect12, useRef as useRef14, useState as useState13 }
|
|
|
19051
19249
|
import { jsx as jsx18, jsxs as jsxs17 } from "react/jsx-runtime";
|
|
19052
19250
|
function RefPickerPopover({
|
|
19053
19251
|
open,
|
|
19054
|
-
|
|
19252
|
+
targets,
|
|
19055
19253
|
initialKeys = [],
|
|
19056
19254
|
initialRefCommand = "ref",
|
|
19057
19255
|
uiLocale = "ar",
|
|
19058
19256
|
digitForm = "arabicIndic",
|
|
19059
19257
|
onClose,
|
|
19060
19258
|
onConfirm,
|
|
19259
|
+
onNumberEquation,
|
|
19061
19260
|
onManageLabels
|
|
19062
19261
|
}) {
|
|
19063
19262
|
const messages = documentMessages(uiLocale);
|
|
@@ -19094,22 +19293,19 @@ function RefPickerPopover({
|
|
|
19094
19293
|
/* @__PURE__ */ jsx18("strong", { children: messages.refPickerTitle }),
|
|
19095
19294
|
/* @__PURE__ */ jsx18("button", { type: "button", "data-dialog-initial-focus": true, className: "butex-document-widget__icon-btn", title: messages.close, "aria-label": messages.close, onClick: onClose, children: "\xD7" })
|
|
19096
19295
|
] }),
|
|
19097
|
-
/* @__PURE__ */ jsx18("div", { className: "butex-document-widget__dialog-body", children:
|
|
19098
|
-
const checked = selected.includes(entry.key);
|
|
19099
|
-
const title = formatFloatCaptionTitle(entry.kind, entry.number, {
|
|
19296
|
+
/* @__PURE__ */ jsx18("div", { className: "butex-document-widget__dialog-body", children: targets.length === 0 ? /* @__PURE__ */ jsx18("p", { className: "butex-document-widget__cite-picker-empty", children: messages.noLabelsYet }) : /* @__PURE__ */ jsx18("ul", { className: "butex-document-widget__cite-picker-list", children: targets.filter((entry) => entry.number !== null || Boolean(entry.displayLabel) || entry.kind === "eq").map((entry) => {
|
|
19297
|
+
const checked = selected.includes(entry.key) || Boolean(entry.manualKey && selected.includes(entry.manualKey));
|
|
19298
|
+
const title = entry.displayLabel ?? (entry.number === null ? uiLocale === "ar" ? "\u0645\u0639\u0627\u062F\u0644\u0629 \u063A\u064A\u0631 \u0645\u0631\u0642\u0645\u0629" : "Unnumbered equation" : formatFloatCaptionTitle(entry.kind, entry.number, {
|
|
19100
19299
|
uiLocale,
|
|
19101
19300
|
digitForm,
|
|
19102
19301
|
documentDirection
|
|
19103
|
-
});
|
|
19302
|
+
}));
|
|
19104
19303
|
return /* @__PURE__ */ jsx18("li", { children: /* @__PURE__ */ jsxs17("label", { className: "butex-document-widget__cite-picker-item", children: [
|
|
19105
|
-
/* @__PURE__ */ jsx18("input", { type: "radio", name: "butex-ref-key", checked, onChange: () => selectKey(entry.key, entry.kind) }),
|
|
19304
|
+
/* @__PURE__ */ jsx18("input", { type: "radio", name: "butex-ref-key", checked, disabled: entry.number === null && !entry.displayLabel, onChange: () => selectKey(entry.key, entry.kind) }),
|
|
19106
19305
|
/* @__PURE__ */ jsxs17("span", { children: [
|
|
19107
|
-
/* @__PURE__ */
|
|
19108
|
-
|
|
19109
|
-
|
|
19110
|
-
/* @__PURE__ */ jsx18("span", { className: "butex-document-widget__refs-item-key", children: entry.key })
|
|
19111
|
-
] }),
|
|
19112
|
-
entry.caption ? /* @__PURE__ */ jsx18("span", { className: "butex-document-widget__cite-picker-meta", children: entry.caption }) : null
|
|
19306
|
+
/* @__PURE__ */ jsx18("strong", { children: entry.kind === "eq" && entry.number !== null ? title.replace(/(\d+|[٠-٩]+)$/, "($1)") : title }),
|
|
19307
|
+
entry.caption ? /* @__PURE__ */ jsx18("span", { className: "butex-document-widget__cite-picker-meta", children: entry.caption }) : null,
|
|
19308
|
+
entry.kind === "eq" && entry.number === null && onNumberEquation ? /* @__PURE__ */ jsx18("button", { type: "button", onClick: () => onNumberEquation(entry.ownerId), children: uiLocale === "ar" ? "\u0631\u0642\u0651\u0645 \u0627\u0644\u0645\u0639\u0627\u062F\u0644\u0629 \u0623\u0648\u0644\u0627\u064B" : "Number equation first" }) : null
|
|
19113
19309
|
] })
|
|
19114
19310
|
] }) }, `${entry.kind}:${entry.ownerId}`);
|
|
19115
19311
|
}) }) }),
|
|
@@ -21754,6 +21950,8 @@ var ButexDocumentEditor = forwardRef2(
|
|
|
21754
21950
|
function ButexDocumentEditor2({
|
|
21755
21951
|
initialDocument,
|
|
21756
21952
|
documentMeta,
|
|
21953
|
+
mode = "article",
|
|
21954
|
+
bookContext,
|
|
21757
21955
|
className,
|
|
21758
21956
|
debug = false,
|
|
21759
21957
|
documentDirection = "rtl",
|
|
@@ -21802,6 +22000,27 @@ var ButexDocumentEditor = forwardRef2(
|
|
|
21802
22000
|
return setCurrentDigitForm(session, digitForm);
|
|
21803
22001
|
}
|
|
21804
22002
|
const historyRef = useRef15(createDocumentHistory());
|
|
22003
|
+
const selectedMathRef = useRef15(selectedMath);
|
|
22004
|
+
selectedMathRef.current = selectedMath;
|
|
22005
|
+
const imagePickCountRef = useRef15(0);
|
|
22006
|
+
const documentGenerationRef = useRef15(0);
|
|
22007
|
+
useEffect13(() => {
|
|
22008
|
+
documentGenerationRef.current += 1;
|
|
22009
|
+
return () => {
|
|
22010
|
+
documentGenerationRef.current += 1;
|
|
22011
|
+
};
|
|
22012
|
+
}, [initialDocument]);
|
|
22013
|
+
const safeRequestImagePick = useCallback2(async (ctx) => {
|
|
22014
|
+
if (!onRequestImagePick) return null;
|
|
22015
|
+
const generation = documentGenerationRef.current;
|
|
22016
|
+
imagePickCountRef.current += 1;
|
|
22017
|
+
try {
|
|
22018
|
+
const picked = await onRequestImagePick(ctx);
|
|
22019
|
+
return generation === documentGenerationRef.current ? picked : null;
|
|
22020
|
+
} finally {
|
|
22021
|
+
imagePickCountRef.current -= 1;
|
|
22022
|
+
}
|
|
22023
|
+
}, [onRequestImagePick]);
|
|
21805
22024
|
const documentRef = useRef15(documentNode);
|
|
21806
22025
|
const editorFocusRef = useRef15(editorFocus);
|
|
21807
22026
|
const textSnapshotArmedRef = useRef15(false);
|
|
@@ -21826,16 +22045,26 @@ var ButexDocumentEditor = forwardRef2(
|
|
|
21826
22045
|
}
|
|
21827
22046
|
documentRef.current = documentNode;
|
|
21828
22047
|
editorFocusRef.current = editorFocus;
|
|
21829
|
-
const latex = documentLatex(documentNode, { digitForm });
|
|
22048
|
+
const latex = mode === "book-content" ? documentContentLatex(documentNode, bookContext) : documentLatex(documentNode, { digitForm });
|
|
21830
22049
|
const documentJson = useMemo2(() => toDocumentJson(documentNode), [documentNode]);
|
|
21831
22050
|
const documentLabels = useMemo2(() => collectDocumentLabels(documentNode), [documentNode]);
|
|
22051
|
+
const displayReferences = useMemo2(
|
|
22052
|
+
() => mode === "book-content" ? bookContextReferences(bookContext) : documentNode.references,
|
|
22053
|
+
[mode, bookContext, documentNode]
|
|
22054
|
+
);
|
|
22055
|
+
const referenceTargets = useMemo2(
|
|
22056
|
+
() => mode === "book-content" && bookContext ? bookContentTargets(documentNode, bookContext) : collectDocumentReferenceTargets(documentNode),
|
|
22057
|
+
[mode, bookContext, documentNode]
|
|
22058
|
+
);
|
|
21832
22059
|
const preview = useMemo2(
|
|
21833
22060
|
() => documentPreview(documentNode, mathOutput, equationSide, {
|
|
21834
22061
|
documentDirection,
|
|
21835
22062
|
digitForm,
|
|
21836
|
-
uiLocale
|
|
22063
|
+
uiLocale,
|
|
22064
|
+
mode,
|
|
22065
|
+
bookContext
|
|
21837
22066
|
}),
|
|
21838
|
-
[documentNode, documentDirection, digitForm, equationSide, mathOutput, uiLocale]
|
|
22067
|
+
[documentNode, documentDirection, digitForm, equationSide, mathOutput, uiLocale, mode, bookContext]
|
|
21839
22068
|
);
|
|
21840
22069
|
const debugEnabled = useMemo2(() => {
|
|
21841
22070
|
if (debug) {
|
|
@@ -21962,11 +22191,11 @@ var ButexDocumentEditor = forwardRef2(
|
|
|
21962
22191
|
setHistoryTick((tick) => tick + 1);
|
|
21963
22192
|
}, []);
|
|
21964
22193
|
const applyDocument = useCallback2(
|
|
21965
|
-
(next,
|
|
21966
|
-
if (
|
|
22194
|
+
(next, mode2 = "immediate") => {
|
|
22195
|
+
if (mode2 === "immediate") {
|
|
21967
22196
|
pushDocumentSnapshot(historyRef.current, documentRef.current);
|
|
21968
22197
|
bumpHistoryUi();
|
|
21969
|
-
} else if (
|
|
22198
|
+
} else if (mode2 === "text") {
|
|
21970
22199
|
if (!textSnapshotArmedRef.current) {
|
|
21971
22200
|
pushDocumentSnapshot(historyRef.current, documentRef.current);
|
|
21972
22201
|
textSnapshotArmedRef.current = true;
|
|
@@ -22005,6 +22234,9 @@ var ButexDocumentEditor = forwardRef2(
|
|
|
22005
22234
|
},
|
|
22006
22235
|
getDocumentJson() {
|
|
22007
22236
|
return toDocumentJson(documentRef.current);
|
|
22237
|
+
},
|
|
22238
|
+
hasPendingChildTransaction() {
|
|
22239
|
+
return selectedMathRef.current !== null || imagePickCountRef.current > 0;
|
|
22008
22240
|
}
|
|
22009
22241
|
}),
|
|
22010
22242
|
[applyDocument, insertImageBlock]
|
|
@@ -22142,7 +22374,7 @@ var ButexDocumentEditor = forwardRef2(
|
|
|
22142
22374
|
function onFieldBlur() {
|
|
22143
22375
|
textSnapshotArmedRef.current = false;
|
|
22144
22376
|
}
|
|
22145
|
-
function openNewEquation(
|
|
22377
|
+
function openNewEquation(mode2) {
|
|
22146
22378
|
if (!editableEquations) {
|
|
22147
22379
|
return;
|
|
22148
22380
|
}
|
|
@@ -22160,11 +22392,12 @@ var ButexDocumentEditor = forwardRef2(
|
|
|
22160
22392
|
fieldId: target?.fieldId ?? null,
|
|
22161
22393
|
textTokenId: target?.textTokenId ?? null,
|
|
22162
22394
|
insertAt: target?.caretOffset ?? 0,
|
|
22163
|
-
mathMode:
|
|
22395
|
+
mathMode: mode2,
|
|
22164
22396
|
session: equationSessionWithDocumentDigits(createEmptyEquationSession(equationSide)),
|
|
22165
22397
|
reason: null,
|
|
22166
22398
|
labelEnabled: false,
|
|
22167
|
-
label: ""
|
|
22399
|
+
label: "",
|
|
22400
|
+
numbered: false
|
|
22168
22401
|
});
|
|
22169
22402
|
}
|
|
22170
22403
|
function openMath(token, origin) {
|
|
@@ -22178,18 +22411,19 @@ var ButexDocumentEditor = forwardRef2(
|
|
|
22178
22411
|
editorFocus: { ...editorFocusRef.current }
|
|
22179
22412
|
};
|
|
22180
22413
|
const result = mathTokenToEditorSession(token.math, equationSide);
|
|
22181
|
-
const
|
|
22414
|
+
const mode2 = token.display ? "display" : "inline";
|
|
22182
22415
|
if (!result.editable) {
|
|
22183
22416
|
setSelectedMath({
|
|
22184
22417
|
tokenId: token.id,
|
|
22185
22418
|
fieldId: null,
|
|
22186
22419
|
insertAt: 0,
|
|
22187
22420
|
textTokenId: null,
|
|
22188
|
-
mathMode:
|
|
22421
|
+
mathMode: mode2,
|
|
22189
22422
|
session: equationSessionWithDocumentDigits(createEmptyEquationSession(equationSide)),
|
|
22190
22423
|
reason: result.reason,
|
|
22191
22424
|
labelEnabled: Boolean(token.labelEnabled),
|
|
22192
|
-
label: token.label ?? ""
|
|
22425
|
+
label: token.label ?? "",
|
|
22426
|
+
numbered: isNumberedEquation(token)
|
|
22193
22427
|
});
|
|
22194
22428
|
return;
|
|
22195
22429
|
}
|
|
@@ -22198,11 +22432,12 @@ var ButexDocumentEditor = forwardRef2(
|
|
|
22198
22432
|
fieldId: null,
|
|
22199
22433
|
insertAt: 0,
|
|
22200
22434
|
textTokenId: null,
|
|
22201
|
-
mathMode:
|
|
22435
|
+
mathMode: mode2,
|
|
22202
22436
|
session: equationSessionWithDocumentDigits(result.session),
|
|
22203
22437
|
reason: null,
|
|
22204
22438
|
labelEnabled: Boolean(token.labelEnabled),
|
|
22205
|
-
label: token.label ?? ""
|
|
22439
|
+
label: token.label ?? "",
|
|
22440
|
+
numbered: isNumberedEquation(token)
|
|
22206
22441
|
});
|
|
22207
22442
|
}
|
|
22208
22443
|
function selectMobileView(view) {
|
|
@@ -22293,10 +22528,11 @@ var ButexDocumentEditor = forwardRef2(
|
|
|
22293
22528
|
if (selectedMath.mathMode === "display") {
|
|
22294
22529
|
next2 = updateMathTokenLabel(next2, selectedMath.tokenId, {
|
|
22295
22530
|
labelEnabled: selectedMath.labelEnabled,
|
|
22296
|
-
label: selectedMath.label
|
|
22531
|
+
label: selectedMath.label,
|
|
22532
|
+
numbered: selectedMath.numbered
|
|
22297
22533
|
});
|
|
22298
22534
|
} else {
|
|
22299
|
-
next2 = updateMathTokenLabel(next2, selectedMath.tokenId, { labelEnabled: false, label: "" });
|
|
22535
|
+
next2 = updateMathTokenLabel(next2, selectedMath.tokenId, { labelEnabled: false, label: "", numbered: false });
|
|
22300
22536
|
}
|
|
22301
22537
|
pendingFocusRef.current = { kind: "math", tokenId: selectedMath.tokenId };
|
|
22302
22538
|
applyDocument(next2, "immediate");
|
|
@@ -22341,10 +22577,11 @@ var ButexDocumentEditor = forwardRef2(
|
|
|
22341
22577
|
0,
|
|
22342
22578
|
fieldAfter.tokens.findIndex((token) => token.id === trailingTextTokenId) - 1
|
|
22343
22579
|
)]?.id : null : fieldAfter?.tokens.filter((token) => token.kind === "math").at(-1)?.id ?? null;
|
|
22344
|
-
if (insertedMathId && selectedMath.mathMode === "display"
|
|
22580
|
+
if (insertedMathId && selectedMath.mathMode === "display") {
|
|
22345
22581
|
next = updateMathTokenLabel(next, insertedMathId, {
|
|
22346
|
-
labelEnabled:
|
|
22347
|
-
label: selectedMath.label
|
|
22582
|
+
labelEnabled: selectedMath.labelEnabled,
|
|
22583
|
+
label: selectedMath.label,
|
|
22584
|
+
numbered: selectedMath.numbered
|
|
22348
22585
|
});
|
|
22349
22586
|
}
|
|
22350
22587
|
if (insertedMathId) {
|
|
@@ -22520,6 +22757,7 @@ var ButexDocumentEditor = forwardRef2(
|
|
|
22520
22757
|
/* @__PURE__ */ jsx19(
|
|
22521
22758
|
DocumentInsertToolbar,
|
|
22522
22759
|
{
|
|
22760
|
+
mode,
|
|
22523
22761
|
canUndo,
|
|
22524
22762
|
canRedo,
|
|
22525
22763
|
editableEquations,
|
|
@@ -22558,6 +22796,7 @@ var ButexDocumentEditor = forwardRef2(
|
|
|
22558
22796
|
/* @__PURE__ */ jsx19(
|
|
22559
22797
|
DocumentMobileToolbar,
|
|
22560
22798
|
{
|
|
22799
|
+
mode,
|
|
22561
22800
|
mobileView,
|
|
22562
22801
|
canUndo,
|
|
22563
22802
|
canRedo,
|
|
@@ -22629,7 +22868,7 @@ var ButexDocumentEditor = forwardRef2(
|
|
|
22629
22868
|
"aria-label": messages.documentEditor,
|
|
22630
22869
|
"aria-hidden": !showEditorPanel,
|
|
22631
22870
|
children: /* @__PURE__ */ jsxs18("div", { className: "butex-document-widget__blocks", children: [
|
|
22632
|
-
/* @__PURE__ */ jsx19(
|
|
22871
|
+
mode === "article" ? /* @__PURE__ */ jsx19(
|
|
22633
22872
|
ArticleMetaPanel,
|
|
22634
22873
|
{
|
|
22635
22874
|
meta: documentNode.meta ?? emptyDocumentMeta(),
|
|
@@ -22641,13 +22880,16 @@ var ButexDocumentEditor = forwardRef2(
|
|
|
22641
22880
|
applyDocument(updateDocumentMeta(documentRef.current, patch), "text");
|
|
22642
22881
|
}
|
|
22643
22882
|
}
|
|
22644
|
-
),
|
|
22883
|
+
) : null,
|
|
22884
|
+
mode === "book-content" && documentNode.blocks.some((block) => block.kind === "bibliography") ? /* @__PURE__ */ jsx19("p", { role: "alert", className: "butex-document-widget__error", children: uiLocale === "ar" ? "\u062A\u0633\u062A\u062E\u062F\u0645 \u0641\u0635\u0648\u0644 \u0627\u0644\u0643\u062A\u0627\u0628 \u0642\u0627\u0626\u0645\u0629 \u0645\u0631\u0627\u062C\u0639 \u0645\u0634\u062A\u0631\u0643\u0629\u061B \u0623\u0632\u0644 \u0642\u0627\u0626\u0645\u0629 \u0627\u0644\u0645\u0631\u0627\u062C\u0639 \u0627\u0644\u0645\u062D\u0644\u064A\u0629 \u0645\u0646 \u0627\u0644\u0641\u0635\u0644." : "Book chapters use the shared bibliography. Remove the local bibliography block." }) : null,
|
|
22645
22885
|
documentNode.blocks.map((block, blockIndex) => /* @__PURE__ */ jsx19(
|
|
22646
22886
|
BlockEditor,
|
|
22647
22887
|
{
|
|
22648
22888
|
block,
|
|
22649
|
-
references:
|
|
22889
|
+
references: displayReferences,
|
|
22650
22890
|
documentNode,
|
|
22891
|
+
bookContext: mode === "book-content" ? bookContext : void 0,
|
|
22892
|
+
onHeadingLabelChange: (blockId, label) => applyDocument(updateDocumentHeadingLabel(documentRef.current, blockId, label), "text"),
|
|
22651
22893
|
documentDirection,
|
|
22652
22894
|
digitForm,
|
|
22653
22895
|
mathOutput,
|
|
@@ -22686,7 +22928,7 @@ var ButexDocumentEditor = forwardRef2(
|
|
|
22686
22928
|
applyDocument(clearDocumentImageAsset(documentRef.current, blockId), "immediate");
|
|
22687
22929
|
},
|
|
22688
22930
|
resolveImageUrl,
|
|
22689
|
-
onRequestImagePick,
|
|
22931
|
+
onRequestImagePick: onRequestImagePick ? safeRequestImagePick : void 0,
|
|
22690
22932
|
listImageAssets,
|
|
22691
22933
|
renderImageBlockEditor,
|
|
22692
22934
|
onFloatMetaChange: (blockId, kind, patch) => {
|
|
@@ -22708,7 +22950,7 @@ var ButexDocumentEditor = forwardRef2(
|
|
|
22708
22950
|
clearBlockSelection();
|
|
22709
22951
|
applyDocument(removeDocumentListItem(documentRef.current, listBlockId, itemId), "immediate");
|
|
22710
22952
|
},
|
|
22711
|
-
onManageReferences: () => openReferencesManager()
|
|
22953
|
+
onManageReferences: mode === "article" ? () => openReferencesManager() : void 0
|
|
22712
22954
|
},
|
|
22713
22955
|
block.id
|
|
22714
22956
|
))
|
|
@@ -22796,12 +23038,14 @@ var ButexDocumentEditor = forwardRef2(
|
|
|
22796
23038
|
responsiveMode,
|
|
22797
23039
|
labelEnabled: selectedMath.labelEnabled,
|
|
22798
23040
|
label: selectedMath.label,
|
|
23041
|
+
numbered: selectedMath.numbered,
|
|
23042
|
+
onNumberedChange: (numbered) => setSelectedMath((current) => current ? { ...current, numbered } : current),
|
|
22799
23043
|
labels: documentLabels,
|
|
22800
|
-
references:
|
|
23044
|
+
references: displayReferences,
|
|
22801
23045
|
ownerId: selectedMath.tokenId ?? void 0,
|
|
22802
|
-
onLabelEnabledChange: (enabled) => setSelectedMath((current) => current ? { ...current, labelEnabled: enabled } : current),
|
|
23046
|
+
onLabelEnabledChange: (enabled) => setSelectedMath((current) => current ? { ...current, labelEnabled: enabled, numbered: enabled || current.numbered } : current),
|
|
22803
23047
|
onLabelChange: (nextLabel) => setSelectedMath((current) => current ? { ...current, label: nextLabel } : current),
|
|
22804
|
-
onMathModeChange: (
|
|
23048
|
+
onMathModeChange: (mode2) => setSelectedMath((current) => current ? { ...current, mathMode: mode2 } : current),
|
|
22805
23049
|
onClose: closeEquationAndRestoreOrigin,
|
|
22806
23050
|
onSave: saveEquation,
|
|
22807
23051
|
onDelete: deleteSelectedEquation
|
|
@@ -22811,36 +23055,39 @@ var ButexDocumentEditor = forwardRef2(
|
|
|
22811
23055
|
CitePickerPopover,
|
|
22812
23056
|
{
|
|
22813
23057
|
open: citePicker !== null,
|
|
22814
|
-
references:
|
|
23058
|
+
references: displayReferences,
|
|
22815
23059
|
initialKeys: citePicker?.keys ?? [],
|
|
22816
23060
|
uiLocale,
|
|
22817
23061
|
digitForm,
|
|
22818
23062
|
onClose: () => setCitePicker(null),
|
|
22819
23063
|
onConfirm: confirmCiteKeys,
|
|
22820
|
-
onManageReferences: () => {
|
|
23064
|
+
onManageReferences: mode === "article" ? () => {
|
|
22821
23065
|
setCitePicker(null);
|
|
22822
23066
|
openReferencesManager();
|
|
22823
|
-
}
|
|
23067
|
+
} : void 0
|
|
22824
23068
|
}
|
|
22825
23069
|
) : null,
|
|
22826
23070
|
!previewOnly ? /* @__PURE__ */ jsx19(
|
|
22827
23071
|
RefPickerPopover,
|
|
22828
23072
|
{
|
|
22829
23073
|
open: refPicker !== null,
|
|
22830
|
-
|
|
23074
|
+
targets: referenceTargets,
|
|
22831
23075
|
initialKeys: refPicker?.keys ?? [],
|
|
22832
23076
|
initialRefCommand: refPicker?.refCommand ?? "ref",
|
|
22833
23077
|
uiLocale,
|
|
22834
23078
|
digitForm,
|
|
22835
23079
|
onClose: () => setRefPicker(null),
|
|
22836
23080
|
onConfirm: confirmRefKeys,
|
|
23081
|
+
onNumberEquation: (tokenId) => {
|
|
23082
|
+
applyDocument(updateMathTokenLabel(documentRef.current, tokenId, { numbered: true }), "immediate");
|
|
23083
|
+
},
|
|
22837
23084
|
onManageLabels: () => {
|
|
22838
23085
|
setRefPicker(null);
|
|
22839
23086
|
openLabelsManager();
|
|
22840
23087
|
}
|
|
22841
23088
|
}
|
|
22842
23089
|
) : null,
|
|
22843
|
-
!previewOnly ? /* @__PURE__ */ jsx19(
|
|
23090
|
+
!previewOnly && mode === "article" ? /* @__PURE__ */ jsx19(
|
|
22844
23091
|
ReferencesPanel,
|
|
22845
23092
|
{
|
|
22846
23093
|
open: referencesOpen,
|
|
@@ -22861,7 +23108,7 @@ var ButexDocumentEditor = forwardRef2(
|
|
|
22861
23108
|
{
|
|
22862
23109
|
open: labelsOpen,
|
|
22863
23110
|
labels: documentLabels,
|
|
22864
|
-
references:
|
|
23111
|
+
references: displayReferences,
|
|
22865
23112
|
uiLocale,
|
|
22866
23113
|
digitForm,
|
|
22867
23114
|
returnFocusRef: managerFocusOriginRef,
|
|
@@ -22898,6 +23145,8 @@ var ButexDocumentEditor3 = forwardRef3(
|
|
|
22898
23145
|
function ValidatedButexDocumentEditor({
|
|
22899
23146
|
initialDocument,
|
|
22900
23147
|
uiLocale = "ar",
|
|
23148
|
+
mode = "article",
|
|
23149
|
+
bookContext,
|
|
22901
23150
|
onDocumentChange,
|
|
22902
23151
|
onValidityChange,
|
|
22903
23152
|
renderImageBlockEditor,
|
|
@@ -22926,10 +23175,10 @@ var ButexDocumentEditor3 = forwardRef3(
|
|
|
22926
23175
|
(document2) => {
|
|
22927
23176
|
const validationTarget = initialDocument !== void 0 && (malformedInitialDocument || awaitingInitialResolutionRef.current) ? initialDocument : document2;
|
|
22928
23177
|
awaitingInitialResolutionRef.current = false;
|
|
22929
|
-
emitValidity(
|
|
23178
|
+
emitValidity(validateDocument(validationTarget, { mode, bookContext }).valid);
|
|
22930
23179
|
onDocumentChange?.(document2);
|
|
22931
23180
|
},
|
|
22932
|
-
[emitValidity, initialDocument, malformedInitialDocument, onDocumentChange]
|
|
23181
|
+
[emitValidity, initialDocument, malformedInitialDocument, onDocumentChange, mode, bookContext]
|
|
22933
23182
|
);
|
|
22934
23183
|
const handleImageBlockEditor = useCallback3(
|
|
22935
23184
|
(ctx) => {
|
|
@@ -22966,6 +23215,8 @@ var ButexDocumentEditor3 = forwardRef3(
|
|
|
22966
23215
|
...rest,
|
|
22967
23216
|
initialDocument,
|
|
22968
23217
|
uiLocale,
|
|
23218
|
+
mode,
|
|
23219
|
+
bookContext,
|
|
22969
23220
|
onDocumentChange: handleDocumentChange,
|
|
22970
23221
|
renderImageBlockEditor: handleImageBlockEditor
|
|
22971
23222
|
}
|
|
@@ -23008,6 +23259,8 @@ function resolvePreviewDocument(input, uiLocale = "ar") {
|
|
|
23008
23259
|
}
|
|
23009
23260
|
}
|
|
23010
23261
|
function ButexDocumentPreview({
|
|
23262
|
+
mode = "article",
|
|
23263
|
+
bookContext,
|
|
23011
23264
|
document: document2,
|
|
23012
23265
|
className,
|
|
23013
23266
|
documentDirection = "rtl",
|
|
@@ -23026,7 +23279,9 @@ function ButexDocumentPreview({
|
|
|
23026
23279
|
preview: documentPreview(resolved.document, mathOutput, equationSide, {
|
|
23027
23280
|
documentDirection,
|
|
23028
23281
|
digitForm: resolvedDigitForm,
|
|
23029
|
-
uiLocale
|
|
23282
|
+
uiLocale,
|
|
23283
|
+
mode,
|
|
23284
|
+
bookContext
|
|
23030
23285
|
}),
|
|
23031
23286
|
error: resolved.error
|
|
23032
23287
|
};
|
|
@@ -23036,12 +23291,14 @@ function ButexDocumentPreview({
|
|
|
23036
23291
|
preview: documentPreview(createEmptyDocument(), mathOutput, equationSide, {
|
|
23037
23292
|
documentDirection,
|
|
23038
23293
|
digitForm: resolvedDigitForm,
|
|
23039
|
-
uiLocale
|
|
23294
|
+
uiLocale,
|
|
23295
|
+
mode,
|
|
23296
|
+
bookContext
|
|
23040
23297
|
}),
|
|
23041
23298
|
error: `${messages.loadDocumentError}: ${detail}`
|
|
23042
23299
|
};
|
|
23043
23300
|
}
|
|
23044
|
-
}, [documentDirection, equationSide, mathOutput, messages.loadDocumentError, resolved, resolvedDigitForm, uiLocale]);
|
|
23301
|
+
}, [bookContext, mode, documentDirection, equationSide, mathOutput, messages.loadDocumentError, resolved, resolvedDigitForm, uiLocale]);
|
|
23045
23302
|
useEffect14(() => {
|
|
23046
23303
|
injectBuTeXDocumentStyles();
|
|
23047
23304
|
}, []);
|