@drghaliasri/butex 4.3.0 → 5.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +27 -1
- package/dist/document2.d.mts +191 -80
- package/dist/document2.d.ts +191 -80
- package/dist/document2.js +683 -101
- package/dist/document2.js.map +1 -1
- package/dist/document2.mjs +660 -101
- package/dist/document2.mjs.map +1 -1
- package/dist/index.global.js +8 -0
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +8 -0
- package/dist/index.mjs.map +1 -1
- package/dist/react-document2.d.mts +160 -83
- package/dist/react-document2.d.ts +160 -83
- package/dist/react-document2.js +2063 -729
- package/dist/react-document2.js.map +1 -1
- package/dist/react-document2.mjs +2026 -692
- package/dist/react-document2.mjs.map +1 -1
- package/package.json +1 -1
package/dist/react-document2.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// src/react-document2/ButexDocumentEditor2.tsx
|
|
2
|
-
import { useCallback as useCallback2, useEffect as
|
|
2
|
+
import { useCallback as useCallback2, useEffect as useEffect6, useMemo, useRef as useRef6, useState as useState7 } from "react";
|
|
3
3
|
|
|
4
4
|
// src/document2/ids.ts
|
|
5
5
|
var nextId = 1;
|
|
@@ -9,6 +9,100 @@ function document2Id(prefix) {
|
|
|
9
9
|
return id;
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
+
// src/editor/digits.ts
|
|
13
|
+
var WESTERN = "0123456789";
|
|
14
|
+
var ARABIC_INDIC = "\u0660\u0661\u0662\u0663\u0664\u0665\u0666\u0667\u0668\u0669";
|
|
15
|
+
var PERSIAN_INDIC = "\u06F0\u06F1\u06F2\u06F3\u06F4\u06F5\u06F6\u06F7\u06F8\u06F9";
|
|
16
|
+
var digitSets = {
|
|
17
|
+
western: WESTERN,
|
|
18
|
+
arabicIndic: ARABIC_INDIC,
|
|
19
|
+
persianIndic: PERSIAN_INDIC
|
|
20
|
+
};
|
|
21
|
+
function digitValue(char) {
|
|
22
|
+
const western = WESTERN.indexOf(char);
|
|
23
|
+
if (western >= 0) {
|
|
24
|
+
return western;
|
|
25
|
+
}
|
|
26
|
+
const arabicIndic = ARABIC_INDIC.indexOf(char);
|
|
27
|
+
if (arabicIndic >= 0) {
|
|
28
|
+
return arabicIndic;
|
|
29
|
+
}
|
|
30
|
+
return PERSIAN_INDIC.indexOf(char);
|
|
31
|
+
}
|
|
32
|
+
function formatDigits(value, digitForm = "western") {
|
|
33
|
+
const target = digitSets[digitForm];
|
|
34
|
+
return Array.from(value, (char) => {
|
|
35
|
+
const value2 = digitValue(char);
|
|
36
|
+
return value2 >= 0 ? target[value2] : char;
|
|
37
|
+
}).join("");
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// src/document2/citations.ts
|
|
41
|
+
function referenceNumberMap(references) {
|
|
42
|
+
const map = /* @__PURE__ */ new Map();
|
|
43
|
+
references.forEach((reference, index) => {
|
|
44
|
+
if (!map.has(reference.key)) {
|
|
45
|
+
map.set(reference.key, index + 1);
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
return map;
|
|
49
|
+
}
|
|
50
|
+
function resolveCiteNumbers(keys, references) {
|
|
51
|
+
const map = referenceNumberMap(references);
|
|
52
|
+
return keys.map((key) => map.get(key) ?? null);
|
|
53
|
+
}
|
|
54
|
+
function formatCiteLabel(keys, references, options = {}) {
|
|
55
|
+
const documentDirection = options.documentDirection ?? "rtl";
|
|
56
|
+
const digitForm = options.digitForm ?? (documentDirection === "rtl" ? "arabicIndic" : "western");
|
|
57
|
+
const numbers = resolveCiteNumbers(keys, references).map((value) => value === null ? "?" : String(value));
|
|
58
|
+
const display = documentDirection === "rtl" ? [...numbers].reverse() : numbers;
|
|
59
|
+
const separator = documentDirection === "rtl" ? "\u060C" : ", ";
|
|
60
|
+
const body = display.map((part) => formatDigits(part, digitForm)).join(separator);
|
|
61
|
+
return `[${body}]`;
|
|
62
|
+
}
|
|
63
|
+
function formatBibliographyNumber(index, options = {}) {
|
|
64
|
+
const documentDirection = options.documentDirection ?? "rtl";
|
|
65
|
+
const digitForm = options.digitForm ?? (documentDirection === "rtl" ? "arabicIndic" : "western");
|
|
66
|
+
return formatDigits(String(index), digitForm);
|
|
67
|
+
}
|
|
68
|
+
function parseCiteKeys(source) {
|
|
69
|
+
const match = /^\\cite\{([^}]*)\}$/.exec(source.trim());
|
|
70
|
+
if (!match) {
|
|
71
|
+
return [];
|
|
72
|
+
}
|
|
73
|
+
return (match[1] ?? "").split(",").map((key) => key.trim()).filter((key) => key.length > 0);
|
|
74
|
+
}
|
|
75
|
+
function citeTokenLatex(keys) {
|
|
76
|
+
return `\\cite{${keys.join(",")}}`;
|
|
77
|
+
}
|
|
78
|
+
function referenceFromJson(json) {
|
|
79
|
+
return {
|
|
80
|
+
id: document2Id("ref"),
|
|
81
|
+
key: json.key,
|
|
82
|
+
authors: typeof json.authors === "string" ? json.authors : "",
|
|
83
|
+
title: typeof json.title === "string" ? json.title : "",
|
|
84
|
+
year: typeof json.year === "string" ? json.year : "",
|
|
85
|
+
url: typeof json.url === "string" ? json.url : "",
|
|
86
|
+
venue: typeof json.venue === "string" ? json.venue : ""
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
function createEmptyReference2(partial = {}) {
|
|
90
|
+
return referenceFromJson({
|
|
91
|
+
key: partial.key ?? `ref${String(Date.now()).slice(-4)}`,
|
|
92
|
+
authors: partial.authors,
|
|
93
|
+
title: partial.title,
|
|
94
|
+
year: partial.year,
|
|
95
|
+
url: partial.url,
|
|
96
|
+
venue: partial.venue
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
function bibliographyEntryLatex(reference) {
|
|
100
|
+
const parts = [reference.authors, reference.title, reference.venue, reference.year].filter((part) => part.trim().length > 0);
|
|
101
|
+
const body = parts.join(", ");
|
|
102
|
+
const url = reference.url.trim().length > 0 ? ` \\url{${reference.url}}` : "";
|
|
103
|
+
return `\\bibitem{${reference.key}} ${body}${url}`.trim();
|
|
104
|
+
}
|
|
105
|
+
|
|
12
106
|
// src/ast/commands/index.ts
|
|
13
107
|
function renderCommandCore(context) {
|
|
14
108
|
const optional = context.optionalArgs.map((arg) => `[${context.renderChain(arg)}]`).join("");
|
|
@@ -427,53 +521,84 @@ function environmentSpan(value, start) {
|
|
|
427
521
|
const end = closingStart + closing.length;
|
|
428
522
|
return { start, end, source: value.slice(start, end), opening, closing, display: true };
|
|
429
523
|
}
|
|
430
|
-
function
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
524
|
+
function citeSpan(value, start) {
|
|
525
|
+
if (!value.startsWith("\\cite{", start) || isEscaped(value, start)) {
|
|
526
|
+
return null;
|
|
527
|
+
}
|
|
528
|
+
const openBrace = start + "\\cite".length;
|
|
529
|
+
if (value[openBrace] !== "{") {
|
|
530
|
+
return null;
|
|
531
|
+
}
|
|
532
|
+
let depth = 0;
|
|
533
|
+
for (let i = openBrace; i < value.length; i += 1) {
|
|
534
|
+
const char = value[i];
|
|
535
|
+
if (char === "{" && !isEscaped(value, i)) {
|
|
536
|
+
depth += 1;
|
|
537
|
+
continue;
|
|
441
538
|
}
|
|
442
|
-
if (
|
|
443
|
-
|
|
444
|
-
if (
|
|
445
|
-
const end =
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
continue;
|
|
539
|
+
if (char === "}" && !isEscaped(value, i)) {
|
|
540
|
+
depth -= 1;
|
|
541
|
+
if (depth === 0) {
|
|
542
|
+
const end = i + 1;
|
|
543
|
+
const source = value.slice(start, end);
|
|
544
|
+
return { kind: "cite", start, end, source, keys: parseCiteKeys(source) };
|
|
449
545
|
}
|
|
450
546
|
}
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
547
|
+
}
|
|
548
|
+
return null;
|
|
549
|
+
}
|
|
550
|
+
function mathSpanAt(value, i) {
|
|
551
|
+
if (value.startsWith("\\begin{", i)) {
|
|
552
|
+
return environmentSpan(value, i);
|
|
553
|
+
}
|
|
554
|
+
if (value.startsWith("\\(", i)) {
|
|
555
|
+
const close = value.indexOf("\\)", i + 2);
|
|
556
|
+
if (close >= 0) {
|
|
557
|
+
const end = close + 2;
|
|
558
|
+
return { start: i, end, source: value.slice(i, end), opening: "\\(", closing: "\\)", display: false };
|
|
459
559
|
}
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
continue;
|
|
467
|
-
}
|
|
560
|
+
}
|
|
561
|
+
if (value.startsWith("\\[", i)) {
|
|
562
|
+
const close = value.indexOf("\\]", i + 2);
|
|
563
|
+
if (close >= 0) {
|
|
564
|
+
const end = close + 2;
|
|
565
|
+
return { start: i, end, source: value.slice(i, end), opening: "\\[", closing: "\\]", display: true };
|
|
468
566
|
}
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
567
|
+
}
|
|
568
|
+
if (value.startsWith("$$", i) && !isEscaped(value, i)) {
|
|
569
|
+
const close = value.indexOf("$$", i + 2);
|
|
570
|
+
if (close >= 0) {
|
|
571
|
+
const end = close + 2;
|
|
572
|
+
return { start: i, end, source: value.slice(i, end), opening: "$$", closing: "$$", display: true };
|
|
573
|
+
}
|
|
574
|
+
}
|
|
575
|
+
if (value[i] === "$" && !isEscaped(value, i)) {
|
|
576
|
+
const close = findClosingDollar(value, i + 1);
|
|
577
|
+
if (close >= 0) {
|
|
578
|
+
const end = close + 1;
|
|
579
|
+
return { start: i, end, source: value.slice(i, end), opening: "$", closing: "$", display: false };
|
|
580
|
+
}
|
|
581
|
+
}
|
|
582
|
+
return null;
|
|
583
|
+
}
|
|
584
|
+
function detectMathSpans2(value) {
|
|
585
|
+
return detectInlineSpans2(value).filter((span) => span.kind === "math").map(({ kind: _kind, ...span }) => span);
|
|
586
|
+
}
|
|
587
|
+
function detectInlineSpans2(value) {
|
|
588
|
+
const spans = [];
|
|
589
|
+
let i = 0;
|
|
590
|
+
while (i < value.length) {
|
|
591
|
+
const cite = citeSpan(value, i);
|
|
592
|
+
if (cite) {
|
|
593
|
+
spans.push(cite);
|
|
594
|
+
i = cite.end;
|
|
595
|
+
continue;
|
|
596
|
+
}
|
|
597
|
+
const math = mathSpanAt(value, i);
|
|
598
|
+
if (math) {
|
|
599
|
+
spans.push({ kind: "math", ...math });
|
|
600
|
+
i = math.end;
|
|
601
|
+
continue;
|
|
477
602
|
}
|
|
478
603
|
i += 1;
|
|
479
604
|
}
|
|
@@ -510,19 +635,53 @@ function pushDiagnostic(diagnostics, options, path, message) {
|
|
|
510
635
|
}
|
|
511
636
|
diagnostics.push({ code: "math_alignment", message, path });
|
|
512
637
|
}
|
|
638
|
+
function parseReferences(json) {
|
|
639
|
+
if (!Array.isArray(json)) {
|
|
640
|
+
return [];
|
|
641
|
+
}
|
|
642
|
+
const references = [];
|
|
643
|
+
for (const entry of json) {
|
|
644
|
+
if (!isObject2(entry) || typeof entry.key !== "string" || entry.key.trim().length === 0) {
|
|
645
|
+
continue;
|
|
646
|
+
}
|
|
647
|
+
references.push(
|
|
648
|
+
referenceFromJson({
|
|
649
|
+
key: entry.key.trim(),
|
|
650
|
+
authors: typeof entry.authors === "string" ? entry.authors : void 0,
|
|
651
|
+
title: typeof entry.title === "string" ? entry.title : void 0,
|
|
652
|
+
year: typeof entry.year === "string" ? entry.year : void 0,
|
|
653
|
+
url: typeof entry.url === "string" ? entry.url : void 0,
|
|
654
|
+
venue: typeof entry.venue === "string" ? entry.venue : void 0
|
|
655
|
+
})
|
|
656
|
+
);
|
|
657
|
+
}
|
|
658
|
+
return references;
|
|
659
|
+
}
|
|
513
660
|
function createInlineField2(value = "", mathObjects = [], options = {}, path = "$", diagnostics = []) {
|
|
514
661
|
const mode = options.mode ?? "english";
|
|
515
|
-
const spans =
|
|
662
|
+
const spans = detectInlineSpans2(value);
|
|
663
|
+
const mathSpans = spans.filter((span) => span.kind === "math");
|
|
516
664
|
const tokens = [];
|
|
517
665
|
let index = 0;
|
|
518
|
-
|
|
519
|
-
|
|
666
|
+
let mathObjectIndex = 0;
|
|
667
|
+
if (mathObjects.length > 0 && mathObjects.length !== mathSpans.length) {
|
|
668
|
+
pushDiagnostic(diagnostics, options, path, `math_objects count mismatch: detected ${String(mathSpans.length)}, got ${String(mathObjects.length)}`);
|
|
520
669
|
}
|
|
521
|
-
|
|
670
|
+
for (const span of spans) {
|
|
522
671
|
if (span.start > index) {
|
|
523
672
|
tokens.push({ id: document2Id("text"), kind: "text", text: value.slice(index, span.start) });
|
|
524
673
|
}
|
|
525
|
-
|
|
674
|
+
if (span.kind === "cite") {
|
|
675
|
+
tokens.push({
|
|
676
|
+
id: document2Id("cite"),
|
|
677
|
+
kind: "cite",
|
|
678
|
+
keys: span.keys.length > 0 ? span.keys : []
|
|
679
|
+
});
|
|
680
|
+
index = span.end;
|
|
681
|
+
continue;
|
|
682
|
+
}
|
|
683
|
+
const mathJson = mathObjects[mathObjectIndex];
|
|
684
|
+
mathObjectIndex += 1;
|
|
526
685
|
if (mathJson && (mathJson.math_mode !== span.opening || mathJson.closing !== span.closing)) {
|
|
527
686
|
pushDiagnostic(diagnostics, options, path, "math_objects order mismatch");
|
|
528
687
|
}
|
|
@@ -554,7 +713,7 @@ function createInlineField2(value = "", mathObjects = [], options = {}, path = "
|
|
|
554
713
|
});
|
|
555
714
|
}
|
|
556
715
|
index = span.end;
|
|
557
|
-
}
|
|
716
|
+
}
|
|
558
717
|
if (index < value.length || tokens.length === 0) {
|
|
559
718
|
tokens.push({ id: document2Id("text"), kind: "text", text: value.slice(index) });
|
|
560
719
|
}
|
|
@@ -626,11 +785,14 @@ function parseTableBlock(json, options, path, diagnostics) {
|
|
|
626
785
|
};
|
|
627
786
|
}
|
|
628
787
|
function parseImageBlock(json) {
|
|
788
|
+
const assetId = typeof json.asset_id === "string" && json.asset_id.length > 0 ? json.asset_id : void 0;
|
|
789
|
+
const value = assetId !== void 0 ? typeof json.value === "string" ? json.value : "" : requireString(json.value, "\\includegraphics requires string value");
|
|
629
790
|
return {
|
|
630
791
|
id: document2Id("block"),
|
|
631
792
|
kind: "image",
|
|
632
793
|
command: "\\includegraphics",
|
|
633
|
-
value
|
|
794
|
+
value,
|
|
795
|
+
...assetId !== void 0 ? { assetId } : {},
|
|
634
796
|
options: isRecordOfStrings(json.options) ? json.options : {}
|
|
635
797
|
};
|
|
636
798
|
}
|
|
@@ -642,6 +804,14 @@ function parseRawBlock(json) {
|
|
|
642
804
|
value: typeof json.value === "string" ? json.value : ""
|
|
643
805
|
};
|
|
644
806
|
}
|
|
807
|
+
function parseBibliographyBlock() {
|
|
808
|
+
return {
|
|
809
|
+
id: document2Id("block"),
|
|
810
|
+
kind: "bibliography",
|
|
811
|
+
command: "\\begin{thebibliography}",
|
|
812
|
+
closing: "\\end{thebibliography}"
|
|
813
|
+
};
|
|
814
|
+
}
|
|
645
815
|
function parseBlock(json, options, path, diagnostics) {
|
|
646
816
|
if (TEXT_COMMANDS.has(json.command)) {
|
|
647
817
|
return parseTextBlock(json, options, path, diagnostics);
|
|
@@ -655,6 +825,9 @@ function parseBlock(json, options, path, diagnostics) {
|
|
|
655
825
|
if (json.command === "\\includegraphics") {
|
|
656
826
|
return parseImageBlock(json);
|
|
657
827
|
}
|
|
828
|
+
if (json.command === "\\begin{thebibliography}" || json.command === "\\bibliography") {
|
|
829
|
+
return parseBibliographyBlock();
|
|
830
|
+
}
|
|
658
831
|
if (json.command === "\\raw") {
|
|
659
832
|
return parseRawBlock(json);
|
|
660
833
|
}
|
|
@@ -675,12 +848,13 @@ function fromDocumentJson2(json, options = {}) {
|
|
|
675
848
|
const diagnostics = [];
|
|
676
849
|
return {
|
|
677
850
|
nodeType: "DocumentObject",
|
|
851
|
+
references: parseReferences(json.references),
|
|
678
852
|
blocks: json.blocks.map((block, index) => parseBlock(asBlockJson(block), options, `$.blocks[${String(index)}]`, diagnostics)),
|
|
679
853
|
diagnostics
|
|
680
854
|
};
|
|
681
855
|
}
|
|
682
856
|
function createEmptyDocument2() {
|
|
683
|
-
return { nodeType: "DocumentObject", blocks: [], diagnostics: [] };
|
|
857
|
+
return { nodeType: "DocumentObject", references: [], blocks: [], diagnostics: [] };
|
|
684
858
|
}
|
|
685
859
|
|
|
686
860
|
// src/editor/atomicCommands.ts
|
|
@@ -1784,34 +1958,6 @@ function renderDivideOperatorLatex(side) {
|
|
|
1784
1958
|
return side === "arabic" ? "\\backslash" : DIVIDE_OPERATOR_EN;
|
|
1785
1959
|
}
|
|
1786
1960
|
|
|
1787
|
-
// src/editor/digits.ts
|
|
1788
|
-
var WESTERN = "0123456789";
|
|
1789
|
-
var ARABIC_INDIC = "\u0660\u0661\u0662\u0663\u0664\u0665\u0666\u0667\u0668\u0669";
|
|
1790
|
-
var PERSIAN_INDIC = "\u06F0\u06F1\u06F2\u06F3\u06F4\u06F5\u06F6\u06F7\u06F8\u06F9";
|
|
1791
|
-
var digitSets = {
|
|
1792
|
-
western: WESTERN,
|
|
1793
|
-
arabicIndic: ARABIC_INDIC,
|
|
1794
|
-
persianIndic: PERSIAN_INDIC
|
|
1795
|
-
};
|
|
1796
|
-
function digitValue(char) {
|
|
1797
|
-
const western = WESTERN.indexOf(char);
|
|
1798
|
-
if (western >= 0) {
|
|
1799
|
-
return western;
|
|
1800
|
-
}
|
|
1801
|
-
const arabicIndic = ARABIC_INDIC.indexOf(char);
|
|
1802
|
-
if (arabicIndic >= 0) {
|
|
1803
|
-
return arabicIndic;
|
|
1804
|
-
}
|
|
1805
|
-
return PERSIAN_INDIC.indexOf(char);
|
|
1806
|
-
}
|
|
1807
|
-
function formatDigits(value, digitForm = "western") {
|
|
1808
|
-
const target = digitSets[digitForm];
|
|
1809
|
-
return Array.from(value, (char) => {
|
|
1810
|
-
const value2 = digitValue(char);
|
|
1811
|
-
return value2 >= 0 ? target[value2] : char;
|
|
1812
|
-
}).join("");
|
|
1813
|
-
}
|
|
1814
|
-
|
|
1815
1961
|
// src/editor/render.ts
|
|
1816
1962
|
function selectedDigitForm(options) {
|
|
1817
1963
|
return options?.digitForm ?? "western";
|
|
@@ -6370,6 +6516,7 @@ function cloneBlock(block) {
|
|
|
6370
6516
|
function cloneDocument(document2) {
|
|
6371
6517
|
return {
|
|
6372
6518
|
nodeType: "DocumentObject",
|
|
6519
|
+
references: document2.references.map((reference) => ({ ...reference })),
|
|
6373
6520
|
blocks: document2.blocks.map(cloneBlock),
|
|
6374
6521
|
diagnostics: document2.diagnostics.map((diagnostic) => ({ ...diagnostic }))
|
|
6375
6522
|
};
|
|
@@ -6652,12 +6799,335 @@ function removeDocument2ListItem(document2, listBlockId, itemId) {
|
|
|
6652
6799
|
});
|
|
6653
6800
|
return next;
|
|
6654
6801
|
}
|
|
6802
|
+
function citeTokenFromKeys(keys) {
|
|
6803
|
+
return { id: document2Id("cite"), kind: "cite", keys: [...keys] };
|
|
6804
|
+
}
|
|
6805
|
+
function insertCiteTokenAtCaret(document2, fieldId, textTokenId, caretOffset, keys) {
|
|
6806
|
+
if (keys.length === 0) {
|
|
6807
|
+
return document2;
|
|
6808
|
+
}
|
|
6809
|
+
const next = cloneDocument(document2);
|
|
6810
|
+
const citeToken = citeTokenFromKeys(keys);
|
|
6811
|
+
visitFields(next.blocks, (field) => {
|
|
6812
|
+
if (field.id !== fieldId) {
|
|
6813
|
+
return false;
|
|
6814
|
+
}
|
|
6815
|
+
const textIndex = textTokenId ? field.tokens.findIndex((token) => token.id === textTokenId && token.kind === "text") : field.tokens.findIndex((token) => token.kind === "text");
|
|
6816
|
+
if (textIndex < 0) {
|
|
6817
|
+
field.tokens.push(citeToken);
|
|
6818
|
+
field.tokens.push({ id: document2Id("text"), kind: "text", text: "" });
|
|
6819
|
+
return true;
|
|
6820
|
+
}
|
|
6821
|
+
const current = field.tokens[textIndex];
|
|
6822
|
+
const [before, after] = splitTextTokenAt(current, caretOffset);
|
|
6823
|
+
const parts = [...field.tokens.slice(0, textIndex)];
|
|
6824
|
+
if (before.text.length > 0) {
|
|
6825
|
+
parts.push(before);
|
|
6826
|
+
}
|
|
6827
|
+
parts.push(citeToken);
|
|
6828
|
+
parts.push(after);
|
|
6829
|
+
parts.push(...field.tokens.slice(textIndex + 1));
|
|
6830
|
+
field.tokens = normalizeFieldTokens(parts);
|
|
6831
|
+
return true;
|
|
6832
|
+
});
|
|
6833
|
+
return next;
|
|
6834
|
+
}
|
|
6835
|
+
function updateCiteTokenKeys(document2, tokenId, keys) {
|
|
6836
|
+
if (keys.length === 0) {
|
|
6837
|
+
return document2;
|
|
6838
|
+
}
|
|
6839
|
+
const next = cloneDocument(document2);
|
|
6840
|
+
visitFields(next.blocks, (field) => {
|
|
6841
|
+
const token = field.tokens.find((entry) => entry.id === tokenId && entry.kind === "cite");
|
|
6842
|
+
if (!token) {
|
|
6843
|
+
return false;
|
|
6844
|
+
}
|
|
6845
|
+
token.keys = [...keys];
|
|
6846
|
+
return true;
|
|
6847
|
+
});
|
|
6848
|
+
return next;
|
|
6849
|
+
}
|
|
6850
|
+
function removeCiteTokenById(document2, tokenId) {
|
|
6851
|
+
const next = cloneDocument(document2);
|
|
6852
|
+
visitFields(next.blocks, (field) => {
|
|
6853
|
+
const index = field.tokens.findIndex((token) => token.id === tokenId && token.kind === "cite");
|
|
6854
|
+
if (index < 0) {
|
|
6855
|
+
return false;
|
|
6856
|
+
}
|
|
6857
|
+
field.tokens = normalizeFieldTokens(stitchTextAroundRemovedToken(field.tokens, index));
|
|
6858
|
+
return true;
|
|
6859
|
+
});
|
|
6860
|
+
return next;
|
|
6861
|
+
}
|
|
6862
|
+
function ensureDocument2BibliographyBlock(document2, afterBlockId) {
|
|
6863
|
+
if (document2.blocks.some((block2) => block2.kind === "bibliography")) {
|
|
6864
|
+
return document2;
|
|
6865
|
+
}
|
|
6866
|
+
const block = {
|
|
6867
|
+
id: document2Id("block"),
|
|
6868
|
+
kind: "bibliography",
|
|
6869
|
+
command: "\\begin{thebibliography}",
|
|
6870
|
+
closing: "\\end{thebibliography}"
|
|
6871
|
+
};
|
|
6872
|
+
return insertDocument2BlockAfter(document2, afterBlockId ?? null, block);
|
|
6873
|
+
}
|
|
6874
|
+
function addDocument2Reference(document2, partial = {}) {
|
|
6875
|
+
const next = cloneDocument(document2);
|
|
6876
|
+
next.references.push(createEmptyReference2(partial));
|
|
6877
|
+
return next;
|
|
6878
|
+
}
|
|
6879
|
+
function updateDocument2Reference(document2, referenceId, patch) {
|
|
6880
|
+
const next = cloneDocument(document2);
|
|
6881
|
+
const reference = next.references.find((entry) => entry.id === referenceId);
|
|
6882
|
+
if (!reference) {
|
|
6883
|
+
return document2;
|
|
6884
|
+
}
|
|
6885
|
+
if (typeof patch.key === "string" && patch.key.trim().length > 0) {
|
|
6886
|
+
reference.key = patch.key.trim();
|
|
6887
|
+
}
|
|
6888
|
+
if (typeof patch.authors === "string") {
|
|
6889
|
+
reference.authors = patch.authors;
|
|
6890
|
+
}
|
|
6891
|
+
if (typeof patch.title === "string") {
|
|
6892
|
+
reference.title = patch.title;
|
|
6893
|
+
}
|
|
6894
|
+
if (typeof patch.year === "string") {
|
|
6895
|
+
reference.year = patch.year;
|
|
6896
|
+
}
|
|
6897
|
+
if (typeof patch.url === "string") {
|
|
6898
|
+
reference.url = patch.url;
|
|
6899
|
+
}
|
|
6900
|
+
if (typeof patch.venue === "string") {
|
|
6901
|
+
reference.venue = patch.venue;
|
|
6902
|
+
}
|
|
6903
|
+
return next;
|
|
6904
|
+
}
|
|
6905
|
+
function removeDocument2Reference(document2, referenceId) {
|
|
6906
|
+
const next = cloneDocument(document2);
|
|
6907
|
+
next.references = next.references.filter((reference) => reference.id !== referenceId);
|
|
6908
|
+
return next;
|
|
6909
|
+
}
|
|
6910
|
+
function moveDocument2Reference(document2, referenceId, direction) {
|
|
6911
|
+
const next = cloneDocument(document2);
|
|
6912
|
+
const index = next.references.findIndex((reference2) => reference2.id === referenceId);
|
|
6913
|
+
const targetIndex = index + direction;
|
|
6914
|
+
if (index < 0 || targetIndex < 0 || targetIndex >= next.references.length) {
|
|
6915
|
+
return document2;
|
|
6916
|
+
}
|
|
6917
|
+
const [reference] = next.references.splice(index, 1);
|
|
6918
|
+
if (!reference) {
|
|
6919
|
+
return document2;
|
|
6920
|
+
}
|
|
6921
|
+
next.references.splice(targetIndex, 0, reference);
|
|
6922
|
+
return next;
|
|
6923
|
+
}
|
|
6924
|
+
|
|
6925
|
+
// src/document2/arabicPreamble.ts
|
|
6926
|
+
function arabicXeLatexPreamblePkg() {
|
|
6927
|
+
return String.raw`
|
|
6928
|
+
\documentclass[12pt,a4paper]{article}
|
|
6929
|
+
\usepackage{amsmath,amsfonts,amssymb,mathrsfs,tikz,fancyhdr, mathtools}
|
|
6930
|
+
\usepackage{fontspec} % For loading OpenType fonts
|
|
6931
|
+
\usepackage{unicode-math} % For setting the math font
|
|
6932
|
+
\usepackage{polyglossia} % For Arabic support
|
|
6933
|
+
\usepackage{array}
|
|
6934
|
+
\usepackage{cancel}
|
|
6935
|
+
\usepackage{bidi} % For bidirectional text handling
|
|
6936
|
+
\usepackage{multirow}
|
|
6937
|
+
\usepackage{booktabs}
|
|
6938
|
+
\usepackage{graphicx} % For \reflectbox
|
|
6939
|
+
\usepackage{xcolor}
|
|
6940
|
+
\usepackage{tikz}
|
|
6941
|
+
\usepackage{tcolorbox} % For tcolorbox environment
|
|
6942
|
+
\usepackage{textcomp} % For \textrightarrow command
|
|
6943
|
+
|
|
6944
|
+
|
|
6945
|
+
% visit : https://www.symbolcopy.com/punctuation-symbol.html
|
|
6946
|
+
% for inversed punctuation
|
|
6947
|
+
|
|
6948
|
+
% save inverted comma for use - copy paste -> ،
|
|
6949
|
+
% save back tick for use - copy paste -> ` + "`";
|
|
6950
|
+
}
|
|
6951
|
+
function arabicXeLatexPreambleFont(digitsMapping = "arabicdigits") {
|
|
6952
|
+
return `
|
|
6953
|
+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
6954
|
+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
6955
|
+
% Toggle between eastern and western digits by changing the Mapping in the below fonts (inside math font as well) between "arabicdigits" and "digits"
|
|
6956
|
+
\\setdefaultlanguage[calendar=gregorian]{arabic} % from polyglossia
|
|
6957
|
+
\\setmainfont[Script=Arabic , Mapping=${digitsMapping}]{Amiri}
|
|
6958
|
+
\\newfontfamily\\diwani[Script=Arabic,Mapping=${digitsMapping}]{Diwani Letter}
|
|
6959
|
+
\\newfontfamily\\diwanioutlineshaded[Script=Arabic,Mapping=${digitsMapping}]{Diwani Outline Shaded}
|
|
6960
|
+
\\newfontfamily\\takween[Script=Arabic,Mapping=${digitsMapping}]{Takween}
|
|
6961
|
+
\\newfontfamily\\boldarabic[Script=Arabic,Mapping=${digitsMapping}]{Amiri Bold}
|
|
6962
|
+
\\newfontfamily\\italicarabic[Script=Arabic,Mapping=${digitsMapping}]{Amiri Italic}
|
|
6963
|
+
|
|
6964
|
+
% Explicitly set math font to XITS Math
|
|
6965
|
+
% Remove "Script=Arabic" to cancel reflected symbols and other RTL symbols
|
|
6966
|
+
\\setmathfont[Script=Arabic , Mapping=${digitsMapping}]{XITS Math} % Ensure XITS Math is correctly installed and available
|
|
6967
|
+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
6968
|
+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
6969
|
+
`;
|
|
6970
|
+
}
|
|
6971
|
+
function arabicXeLatexPreambleCmd() {
|
|
6972
|
+
return String.raw`
|
|
6973
|
+
% Run with XeLaTeX compiler
|
|
6974
|
+
\newcommand{\butextakween}[1]{\text{\takween{#1}}}
|
|
6975
|
+
\newcommand{\butexdiwani}[1]{\text{\diwani{#1}}}
|
|
6976
|
+
\newcommand{\butexdiwanioutline}[1]{\text{\diwanioutlineshaded{#1}}}
|
|
6977
|
+
|
|
6978
|
+
\newcommand{\arabN}{\text{\diwanioutlineshaded{ط}}}
|
|
6979
|
+
\newcommand{\arabZ}{\text{\diwanioutlineshaded{ص}}}
|
|
6980
|
+
\newcommand{\arabQ}{\text{\diwanioutlineshaded{ن}}}
|
|
6981
|
+
\newcommand{\arabR}{\text{\diwanioutlineshaded{ح}}}
|
|
6982
|
+
\newcommand{\arabC}{\text{\diwanioutlineshaded{ع}}}
|
|
6983
|
+
\newcommand{\arabH}{\text{\diwanioutlineshaded{ر}}}
|
|
6984
|
+
|
|
6985
|
+
|
|
6986
|
+
\newcommand{\lowerscript}[1]{\raisebox{-4pt}{\scriptsize #1}}
|
|
6987
|
+
\newcommand{\llowerscript}[1]{\raisebox{-8pt}{\scriptsize #1}}
|
|
6988
|
+
\newcommand{\lllowerscript}[2]{\raisebox{#2pt}{\scriptsize #1}}
|
|
6989
|
+
|
|
6990
|
+
\newcommand{\arabdsub}[3]{\prescript{}{#1}{\prescript{}{#2}{#3}}} % arabic double subscript
|
|
6991
|
+
\newcommand{\arabsub}[2]{\prescript{}{#1}{#2}} % arabic single subscript
|
|
6992
|
+
|
|
6993
|
+
|
|
6994
|
+
|
|
6995
|
+
\newcommand{\upperscript}[1]{\raisebox{8pt}{\scriptsize #1}}
|
|
6996
|
+
\newcommand{\uupperscript}[2]{\raisebox{#2pt}{\scriptsize #1}}
|
|
6997
|
+
\newcommand{\vertbar}{\rule[-1ex]{0.5pt}{2.5ex}}
|
|
6998
|
+
\newcommand{\horzbar}{\rule[.5ex]{2.5ex}{0.5pt}}
|
|
6999
|
+
|
|
7000
|
+
\newcommand{\arabsqrt}[2]{\reflectbox{\(\sqrt[\reflectbox{\(#1\)}]{\reflectbox{\(#2\)}}\)}}
|
|
7001
|
+
\newcommand{\arabvec}[1]{\reflectbox{$\vec{\reflectbox{$#1$}}$}}
|
|
7002
|
+
|
|
7003
|
+
\newcommand{\arabexp}[1]{{}^{#1}\!\raisebox{-4.5pt}{\text{\diwani{ه}}}}
|
|
7004
|
+
\newcommand{\arablog}[2]{\left(\text{#2}\right)\!\prescript{}{\text{#1}}{\text{\diwani{لو}}}}
|
|
7005
|
+
\newcommand{\arabnlog}[1]{\left(\text{#1}\right)\!\prescript{}{\text{\diwani{ه}}}{\text{\diwani{لو}}}}
|
|
7006
|
+
|
|
7007
|
+
\newcommand{\arabcos}[1]{\left(#1\right)\!\!\raisebox{-2.5pt}{\text{\diwani{جتا}}}}
|
|
7008
|
+
\newcommand{\arabsin}[1]{\left(#1\right)\!\!\raisebox{-2.5pt}{\text{\diwani{جا}}}}
|
|
7009
|
+
\newcommand{\arabtan}[1]{\left(#1\right)\!\!\raisebox{-2.5pt}{\text{\diwani{ظا}}}}
|
|
7010
|
+
\newcommand{\arabcot}[1]{\left(#1\right)\!\!\raisebox{-2.5pt}{\text{\diwani{ظتا}}}}
|
|
7011
|
+
\newcommand{\arabsec}[1]{\left(#1\right)\!\!\raisebox{-2.5pt}{\text{\diwani{قا}}}}
|
|
7012
|
+
\newcommand{\arabcsc}[1]{\left(#1\right)\!\!\raisebox{-2.5pt}{\text{\diwani{قتا}}}}
|
|
7013
|
+
|
|
7014
|
+
\newcommand{\arabacos}[1]{\left(#1\right)\!\!\raisebox{-2.5pt}{\text{\diwani{قجتا}}}}
|
|
7015
|
+
\newcommand{\arabasin}[1]{\left(#1\right)\!\!\raisebox{-2.5pt}{\text{\diwani{قجا}}}}
|
|
7016
|
+
\newcommand{\arabatan}[1]{\left(#1\right)\!\!\raisebox{-2.5pt}{\text{\diwani{قظا}}}}
|
|
7017
|
+
\newcommand{\arabacot}[1]{\left(#1\right)\!\!\raisebox{-2.5pt}{\text{\diwani{قظتا}}}}
|
|
7018
|
+
\newcommand{\arabasec}[1]{\left(#1\right)\!\!\raisebox{-2.5pt}{\text{\diwani{ققا}}}}
|
|
7019
|
+
\newcommand{\arabacsc}[1]{\left(#1\right)\!\!\raisebox{-2.5pt}{\text{\diwani{ققتا}}}}
|
|
7020
|
+
|
|
7021
|
+
|
|
7022
|
+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
7023
|
+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
7024
|
+
% summation
|
|
7025
|
+
\newcommand{\arablim}[2]{\underset{#2 \leftarrow #1}{\text{نـــــها}}}
|
|
7026
|
+
\newcommand{\arabsum}[2]{\underset{#1}{\overset{#2}{\text{مجـــ}}}}
|
|
7027
|
+
\newcommand{\arabprod}[2]{\underset{#1}{\overset{#2}{\text{جـــذ}}}}
|
|
7028
|
+
\newcommand{\arabint}[2]{\prescript{#2}{#1\!\!\!}\int}
|
|
7029
|
+
|
|
7030
|
+
|
|
7031
|
+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
7032
|
+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
7033
|
+
% we define this command to make it ease for change of notation later
|
|
7034
|
+
\newcommand{\ad}[0]{\text{ء}} % "ad" for arabic differentiation or derivative (ء" لإشتقاق")
|
|
7035
|
+
\newcommand{\arpi}[0]{\!\text{\diwani{ط}}}
|
|
7036
|
+
|
|
7037
|
+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
7038
|
+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
7039
|
+
% differentials
|
|
7040
|
+
|
|
7041
|
+
\newcommand{\arabdiff}[2]{\frac{#1\ad}{#2\ad}} % arabic differential
|
|
7042
|
+
\newcommand{\arabddiff}[2]{\frac{#1{}^{2}\ad}{{}^{2}#2\ad}} % arabic second differential
|
|
7043
|
+
|
|
7044
|
+
\newcommand{\arabode}[2][-5pt]{\stackrel{\raisebox{#1}{$\cdot$}}{\text{#2}}}
|
|
7045
|
+
\newcommand{\arabodde}[2][-5pt]{\stackrel{\raisebox{#1}{$\vcenter{\hbox{$\cdot\!\cdot$}}$}}{\text{#2}}}
|
|
7046
|
+
\newcommand{\araboddde}[2][-5pt]{\stackrel{\raisebox{#1}{$\vcenter{\hbox{$\cdot\!\cdot\!\cdot$}}$}}{\text{#2}}}
|
|
7047
|
+
\newcommand{\arabpde}[1]{\prescript{}{#1\!\!}{\nabla}} % arabic partial differential equation (PDE)
|
|
7048
|
+
|
|
7049
|
+
\newcommand{\arabprime}[0]{\reflectbox{$\prime$}\!} % arabic prime notation
|
|
7050
|
+
\newcommand{\arabpprime}[0]{\reflectbox{$\prime$}\reflectbox{$\prime$}\!} % arabic prime notation
|
|
7051
|
+
\newcommand{\arabppprime}[0]{\reflectbox{$\prime$}\reflectbox{$\prime$}\reflectbox{$\prime$}\!} % arabic prime notation
|
|
7052
|
+
|
|
7053
|
+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
7054
|
+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
7055
|
+
% probability
|
|
7056
|
+
\newcommand{\ap}[0]{\!\text{\diwani{حـ}}} % arabic Probability - used a lot so short form
|
|
7057
|
+
\newcommand{\arabExpct}[0]{\text{\diwani{توقـ}}} % arabic Expectation
|
|
7058
|
+
\newcommand{\arabVar}[0]{\!\text{\diwani{با}}} % arabic Variance
|
|
7059
|
+
\newcommand{\arabCov}[0]{\!\text{\diwani{ت}}} % arabic Covariance
|
|
7060
|
+
|
|
7061
|
+
|
|
7062
|
+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
7063
|
+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
7064
|
+
% custom commands specific to lesson
|
|
7065
|
+
\newcommand{\lagrange}[2]{\left(#2\right)\!\prescript{}{#1}{\text{\diwani{لا}}}}
|
|
7066
|
+
\newcommand{\xii}[0]{\left(\prescript{}{\text{يـ}}{\text{س}}\right)\!}
|
|
7067
|
+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
7068
|
+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
7069
|
+
|
|
7070
|
+
|
|
7071
|
+
\newcommand{\arsqrt}[2][]{\reflectbox{\(\sqrt[\reflectbox{\(#1\)}]{\reflectbox{\(#2\)}}\)}}
|
|
7072
|
+
\newcommand{\arexp}[0]{\!\raisebox{-4.5pt}{\text{\diwani{ه}}}}
|
|
7073
|
+
\newcommand{\arlog}[0]{\!\!\text{\diwani{لو}}}
|
|
7074
|
+
\newcommand{\arln}[0]{\!\!\prescript{}{\text{\diwani{ه}}}{\text{\diwani{لو}}}}
|
|
7075
|
+
\newcommand{\ardet}[0]{\!\!\text{\diwani{محدد}}}
|
|
7076
|
+
|
|
7077
|
+
\newcommand{\arsum}[0]{\text{مجـــ}}
|
|
7078
|
+
\newcommand{\arprod}[0]{\text{جـــذ}}
|
|
7079
|
+
|
|
7080
|
+
\newcommand{\arlim}[0]{\text{نـــــها}}
|
|
7081
|
+
\newcommand{\armax}[0]{\text{أكبر}}
|
|
7082
|
+
\newcommand{\armin}[0]{\text{أصغر}}
|
|
7083
|
+
\newcommand{\arsup}[0]{\text{أعلى}}
|
|
7084
|
+
\newcommand{\arinf}[0]{\text{أدنى}}
|
|
7085
|
+
|
|
7086
|
+
\newcommand{\arsin}[0]{\!\!\raisebox{-2.5pt}{\text{\diwani{جا}}}}
|
|
7087
|
+
\newcommand{\arcos}[0]{\!\!\raisebox{-2.5pt}{\text{\diwani{جتا}}}}
|
|
7088
|
+
\newcommand{\artan}[0]{\!\!\raisebox{-2.5pt}{\text{\diwani{ظا}}}}
|
|
7089
|
+
\newcommand{\arcot}[0]{\!\!\raisebox{-2.5pt}{\text{\diwani{ظتا}}}}
|
|
7090
|
+
\newcommand{\arsec}[0]{\!\!\raisebox{-2.5pt}{\text{\diwani{قا}}}}
|
|
7091
|
+
\newcommand{\arcsc}[0]{\!\!\raisebox{-2.5pt}{\text{\diwani{قتا}}}}
|
|
7092
|
+
|
|
7093
|
+
\newcommand{\arasin}[0]{\!\!\raisebox{-2.5pt}{\text{\diwani{قجا}}}}
|
|
7094
|
+
\newcommand{\aracos}[0]{\!\!\raisebox{-2.5pt}{\text{\diwani{قجتا}}}}
|
|
7095
|
+
\newcommand{\aratan}[0]{\!\!\raisebox{-2.5pt}{\text{\diwani{قظا}}}}
|
|
7096
|
+
\newcommand{\aracot}[0]{\!\!\raisebox{-2.5pt}{\text{\diwani{قظتا}}}}
|
|
7097
|
+
\newcommand{\arasec}[0]{\!\!\raisebox{-2.5pt}{\text{\diwani{ققا}}}}
|
|
7098
|
+
\newcommand{\aracsc}[0]{\!\!\raisebox{-2.5pt}{\text{\diwani{ققتا}}}}
|
|
7099
|
+
|
|
7100
|
+
\newcommand{\arsinh}[0]{\!\!\raisebox{-2.5pt}{\text{\diwani{جزا}}}}
|
|
7101
|
+
\newcommand{\arcosh}[0]{\!\!\raisebox{-2.5pt}{\text{\diwani{جتزا}}}}
|
|
7102
|
+
\newcommand{\artanh}[0]{\!\!\raisebox{-2.5pt}{\text{\diwani{ظزا}}}}
|
|
7103
|
+
\newcommand{\arcoth}[0]{\!\!\raisebox{-2.5pt}{\text{\diwani{ظتزا}}}}
|
|
7104
|
+
\newcommand{\arsech}[0]{\!\!\raisebox{-2.5pt}{\text{\diwani{قزا}}}}
|
|
7105
|
+
\newcommand{\arcsch}[0]{\!\!\raisebox{-2.5pt}{\text{\diwani{قتزا}}}}
|
|
7106
|
+
|
|
7107
|
+
\newcommand{\arasinh}[0]{\!\!\raisebox{-2.5pt}{\text{\diwani{قجزا}}}}
|
|
7108
|
+
\newcommand{\aracosh}[0]{\!\!\raisebox{-2.5pt}{\text{\diwani{قجتزا}}}}
|
|
7109
|
+
\newcommand{\aratanh}[0]{\!\!\raisebox{-2.5pt}{\text{\diwani{قظزا}}}}
|
|
7110
|
+
\newcommand{\aracoth}[0]{\!\!\raisebox{-2.5pt}{\text{\diwani{قظتزا}}}}
|
|
7111
|
+
\newcommand{\arasech}[0]{\!\!\raisebox{-2.5pt}{\text{\diwani{ققزا}}}}
|
|
7112
|
+
\newcommand{\aracsch}[0]{\!\!\raisebox{-2.5pt}{\text{\diwani{ققتزا}}}}
|
|
7113
|
+
|
|
7114
|
+
\newcommand{\unit}[1]{\text{#1}}
|
|
7115
|
+
\newcommand{\idx}[1]{#1}
|
|
7116
|
+
\newcommand{\arbinom}[2]{\left(\begin{array}{c} #1 \\ #2 \end{array} \right)}
|
|
7117
|
+
`;
|
|
7118
|
+
}
|
|
7119
|
+
function getArabicXeLatexPreamble(digitsMapping = "arabicdigits") {
|
|
7120
|
+
return arabicXeLatexPreamblePkg() + arabicXeLatexPreambleFont(digitsMapping) + arabicXeLatexPreambleCmd();
|
|
7121
|
+
}
|
|
6655
7122
|
|
|
6656
7123
|
// src/document2/exportLatex.ts
|
|
6657
7124
|
function tokenLatex(token) {
|
|
6658
7125
|
if (token.kind === "text") {
|
|
6659
7126
|
return token.text;
|
|
6660
7127
|
}
|
|
7128
|
+
if (token.kind === "cite") {
|
|
7129
|
+
return citeTokenLatex(token.keys);
|
|
7130
|
+
}
|
|
6661
7131
|
if (!token.math || token.sourceOwner === "raw" || token.sourceOwner === "editor") {
|
|
6662
7132
|
return token.source;
|
|
6663
7133
|
}
|
|
@@ -6672,9 +7142,9 @@ function textBlockLatex(block) {
|
|
|
6672
7142
|
function indent(value) {
|
|
6673
7143
|
return value.split("\n").map((line) => ` ${line}`).join("\n");
|
|
6674
7144
|
}
|
|
6675
|
-
function listBlockLatex(block) {
|
|
7145
|
+
function listBlockLatex(block, references) {
|
|
6676
7146
|
const items = block.items.map((item) => {
|
|
6677
|
-
const nested = item.blocks.map((child) => "\n" + indent(blockLatex(child))).join("");
|
|
7147
|
+
const nested = item.blocks.map((child) => "\n" + indent(blockLatex(child, references))).join("");
|
|
6678
7148
|
return ` \\item ${inlineFieldLatex(item.field)}${nested}`;
|
|
6679
7149
|
}).join("\n");
|
|
6680
7150
|
return `${block.command}
|
|
@@ -6694,12 +7164,12 @@ function imageOptionsLatex(block) {
|
|
|
6694
7164
|
}
|
|
6695
7165
|
return `[${entries.map(([key, value]) => `${key}=${value}`).join(",")}]`;
|
|
6696
7166
|
}
|
|
6697
|
-
function blockLatex(block) {
|
|
7167
|
+
function blockLatex(block, references) {
|
|
6698
7168
|
if (block.kind === "textBlock") {
|
|
6699
7169
|
return textBlockLatex(block);
|
|
6700
7170
|
}
|
|
6701
7171
|
if (block.kind === "list") {
|
|
6702
|
-
return listBlockLatex(block);
|
|
7172
|
+
return listBlockLatex(block, references);
|
|
6703
7173
|
}
|
|
6704
7174
|
if (block.kind === "table") {
|
|
6705
7175
|
return tableBlockLatex(block);
|
|
@@ -6707,10 +7177,29 @@ function blockLatex(block) {
|
|
|
6707
7177
|
if (block.kind === "image") {
|
|
6708
7178
|
return `${block.command}${imageOptionsLatex(block)}{${block.value}}`;
|
|
6709
7179
|
}
|
|
7180
|
+
if (block.kind === "bibliography") {
|
|
7181
|
+
const width = String(Math.max(references.length, 9));
|
|
7182
|
+
const items = references.map((reference) => ` ${bibliographyEntryLatex(reference)}`).join("\n");
|
|
7183
|
+
return `${block.command}{${width}}
|
|
7184
|
+
${items}
|
|
7185
|
+
${block.closing}`;
|
|
7186
|
+
}
|
|
6710
7187
|
return block.value;
|
|
6711
7188
|
}
|
|
6712
|
-
function document2Latex(document2) {
|
|
6713
|
-
|
|
7189
|
+
function document2Latex(document2, options = {}) {
|
|
7190
|
+
const body = document2.blocks.map((block) => blockLatex(block, document2.references)).join("\n\n");
|
|
7191
|
+
const wrapDocument = options.wrapDocument !== false;
|
|
7192
|
+
if (!wrapDocument) {
|
|
7193
|
+
return body;
|
|
7194
|
+
}
|
|
7195
|
+
const preamble = getArabicXeLatexPreamble(options.digitsMapping ?? "arabicdigits");
|
|
7196
|
+
return `${preamble}
|
|
7197
|
+
\\begin{document}
|
|
7198
|
+
|
|
7199
|
+
${body}
|
|
7200
|
+
|
|
7201
|
+
\\end{document}
|
|
7202
|
+
`;
|
|
6714
7203
|
}
|
|
6715
7204
|
|
|
6716
7205
|
// src/document2/history.ts
|
|
@@ -6748,16 +7237,24 @@ function document2HistoryCanRedo(stacks) {
|
|
|
6748
7237
|
|
|
6749
7238
|
// src/document2/previewModel.ts
|
|
6750
7239
|
function mathTex(token, equationSide) {
|
|
6751
|
-
if (token.kind === "text") {
|
|
6752
|
-
return token.text;
|
|
6753
|
-
}
|
|
6754
7240
|
return mathTokenSourceForSide(token, equationSide);
|
|
6755
7241
|
}
|
|
6756
|
-
function previewInlines(field, islands, output, equationSide) {
|
|
7242
|
+
function previewInlines(field, islands, output, equationSide, document2, previewOptions) {
|
|
6757
7243
|
return field.tokens.map((token) => {
|
|
6758
7244
|
if (token.kind === "text") {
|
|
6759
7245
|
return { kind: "text", text: token.text };
|
|
6760
7246
|
}
|
|
7247
|
+
if (token.kind === "cite") {
|
|
7248
|
+
return {
|
|
7249
|
+
kind: "cite",
|
|
7250
|
+
id: token.id,
|
|
7251
|
+
keys: [...token.keys],
|
|
7252
|
+
label: formatCiteLabel(token.keys, document2.references, {
|
|
7253
|
+
documentDirection: previewOptions.documentDirection,
|
|
7254
|
+
digitForm: previewOptions.digitForm
|
|
7255
|
+
})
|
|
7256
|
+
};
|
|
7257
|
+
}
|
|
6761
7258
|
const island = {
|
|
6762
7259
|
id: token.id,
|
|
6763
7260
|
tex: mathTex(token, equationSide),
|
|
@@ -6769,21 +7266,22 @@ function previewInlines(field, islands, output, equationSide) {
|
|
|
6769
7266
|
return { kind: "math", ...island };
|
|
6770
7267
|
});
|
|
6771
7268
|
}
|
|
6772
|
-
function textBlockPreview(block, islands, output, equationSide) {
|
|
7269
|
+
function textBlockPreview(block, islands, output, equationSide, document2, previewOptions) {
|
|
7270
|
+
const inlines = previewInlines(block.field, islands, output, equationSide, document2, previewOptions);
|
|
6773
7271
|
if (block.command === "\\section") {
|
|
6774
|
-
return { kind: "heading", id: block.id, level: 1, inlines
|
|
7272
|
+
return { kind: "heading", id: block.id, level: 1, inlines };
|
|
6775
7273
|
}
|
|
6776
7274
|
if (block.command === "\\subsection") {
|
|
6777
|
-
return { kind: "heading", id: block.id, level: 2, inlines
|
|
7275
|
+
return { kind: "heading", id: block.id, level: 2, inlines };
|
|
6778
7276
|
}
|
|
6779
7277
|
if (block.command === "\\subsubsection") {
|
|
6780
|
-
return { kind: "heading", id: block.id, level: 3, inlines
|
|
7278
|
+
return { kind: "heading", id: block.id, level: 3, inlines };
|
|
6781
7279
|
}
|
|
6782
|
-
return { kind: "paragraph", id: block.id, inlines
|
|
7280
|
+
return { kind: "paragraph", id: block.id, inlines };
|
|
6783
7281
|
}
|
|
6784
|
-
function blockPreview(block, islands, output, equationSide) {
|
|
7282
|
+
function blockPreview(block, islands, output, equationSide, document2, previewOptions) {
|
|
6785
7283
|
if (block.kind === "textBlock") {
|
|
6786
|
-
return textBlockPreview(block, islands, output, equationSide);
|
|
7284
|
+
return textBlockPreview(block, islands, output, equationSide, document2, previewOptions);
|
|
6787
7285
|
}
|
|
6788
7286
|
if (block.kind === "list") {
|
|
6789
7287
|
return {
|
|
@@ -6792,23 +7290,56 @@ function blockPreview(block, islands, output, equationSide) {
|
|
|
6792
7290
|
ordered: block.command === "\\begin{enumerate}",
|
|
6793
7291
|
items: block.items.map((item) => ({
|
|
6794
7292
|
id: item.id,
|
|
6795
|
-
inlines: previewInlines(item.field, islands, output, equationSide),
|
|
6796
|
-
blocks: item.blocks.map((child) => blockPreview(child, islands, output, equationSide))
|
|
7293
|
+
inlines: previewInlines(item.field, islands, output, equationSide, document2, previewOptions),
|
|
7294
|
+
blocks: item.blocks.map((child) => blockPreview(child, islands, output, equationSide, document2, previewOptions))
|
|
6797
7295
|
}))
|
|
6798
7296
|
};
|
|
6799
7297
|
}
|
|
6800
7298
|
if (block.kind === "table") {
|
|
6801
|
-
return {
|
|
7299
|
+
return {
|
|
7300
|
+
kind: "table",
|
|
7301
|
+
id: block.id,
|
|
7302
|
+
rows: block.rows.map((row) => row.map((cell) => previewInlines(cell, islands, output, equationSide, document2, previewOptions)))
|
|
7303
|
+
};
|
|
6802
7304
|
}
|
|
6803
7305
|
if (block.kind === "image") {
|
|
6804
|
-
return {
|
|
7306
|
+
return {
|
|
7307
|
+
kind: "image",
|
|
7308
|
+
id: block.id,
|
|
7309
|
+
src: block.value,
|
|
7310
|
+
...block.assetId !== void 0 ? { assetId: block.assetId } : {},
|
|
7311
|
+
options: block.options
|
|
7312
|
+
};
|
|
7313
|
+
}
|
|
7314
|
+
if (block.kind === "bibliography") {
|
|
7315
|
+
return {
|
|
7316
|
+
kind: "bibliography",
|
|
7317
|
+
id: block.id,
|
|
7318
|
+
items: document2.references.map((reference, index) => ({
|
|
7319
|
+
id: reference.id,
|
|
7320
|
+
numberLabel: formatBibliographyNumber(index + 1, {
|
|
7321
|
+
documentDirection: previewOptions.documentDirection,
|
|
7322
|
+
digitForm: previewOptions.digitForm
|
|
7323
|
+
}),
|
|
7324
|
+
key: reference.key,
|
|
7325
|
+
authors: reference.authors,
|
|
7326
|
+
title: reference.title,
|
|
7327
|
+
year: reference.year,
|
|
7328
|
+
url: reference.url,
|
|
7329
|
+
venue: reference.venue
|
|
7330
|
+
}))
|
|
7331
|
+
};
|
|
6805
7332
|
}
|
|
6806
7333
|
return { kind: "omit", id: block.id };
|
|
6807
7334
|
}
|
|
6808
|
-
function document2Preview(document2, output = "svg", equationSide = "arabic") {
|
|
7335
|
+
function document2Preview(document2, output = "svg", equationSide = "arabic", previewOptions = {}) {
|
|
6809
7336
|
const mathIslands = [];
|
|
7337
|
+
const options = {
|
|
7338
|
+
documentDirection: previewOptions.documentDirection ?? "rtl",
|
|
7339
|
+
digitForm: previewOptions.digitForm ?? (previewOptions.documentDirection === "ltr" ? "western" : "arabicIndic")
|
|
7340
|
+
};
|
|
6810
7341
|
return {
|
|
6811
|
-
blocks: document2.blocks.map((block) => blockPreview(block, mathIslands, output, equationSide)),
|
|
7342
|
+
blocks: document2.blocks.map((block) => blockPreview(block, mathIslands, output, equationSide, document2, options)),
|
|
6812
7343
|
mathIslands
|
|
6813
7344
|
};
|
|
6814
7345
|
}
|
|
@@ -6816,20 +7347,283 @@ function document2Preview(document2, output = "svg", equationSide = "arabic") {
|
|
|
6816
7347
|
// src/react-document2/InlineField.tsx
|
|
6817
7348
|
import { useRef as useRef2 } from "react";
|
|
6818
7349
|
|
|
6819
|
-
// src/react-document2/
|
|
6820
|
-
|
|
6821
|
-
|
|
6822
|
-
|
|
6823
|
-
|
|
6824
|
-
|
|
6825
|
-
|
|
6826
|
-
|
|
6827
|
-
|
|
6828
|
-
|
|
6829
|
-
|
|
6830
|
-
|
|
6831
|
-
|
|
6832
|
-
|
|
7350
|
+
// src/react-document2/uiMessages.ts
|
|
7351
|
+
var DOCUMENT2_MESSAGES = {
|
|
7352
|
+
ar: {
|
|
7353
|
+
undoRedo: "\u062A\u0631\u0627\u062C\u0639 \u0648\u0625\u0639\u0627\u062F\u0629",
|
|
7354
|
+
undo: "\u062A\u0631\u0627\u062C\u0639",
|
|
7355
|
+
redo: "\u0625\u0639\u0627\u062F\u0629",
|
|
7356
|
+
structure: "\u0647\u064A\u0643\u0644",
|
|
7357
|
+
content: "\u0645\u062D\u062A\u0648\u0649",
|
|
7358
|
+
addSection: "\u0625\u0636\u0627\u0641\u0629 \u0642\u0633\u0645",
|
|
7359
|
+
addSubsection: "\u0625\u0636\u0627\u0641\u0629 \u0641\u0631\u0639",
|
|
7360
|
+
addSubsubsection: "\u0625\u0636\u0627\u0641\u0629 \u0641\u0631\u0639 \u0635\u063A\u064A\u0631",
|
|
7361
|
+
addParagraph: "\u0625\u0636\u0627\u0641\u0629 \u0641\u0642\u0631\u0629",
|
|
7362
|
+
inlineEquation: "\u0645\u0639\u0627\u062F\u0644\u0629 \u062F\u0627\u062E\u0644 \u0627\u0644\u0633\u0637\u0631",
|
|
7363
|
+
displayEquation: "\u0645\u0639\u0627\u062F\u0644\u0629 \u0645\u0639\u0631\u0648\u0636\u0629",
|
|
7364
|
+
bulletedList: "\u0642\u0627\u0626\u0645\u0629 \u0646\u0642\u0637\u064A\u0629",
|
|
7365
|
+
numberedList: "\u0642\u0627\u0626\u0645\u0629 \u0645\u0631\u0642\u0645\u0629",
|
|
7366
|
+
insertImage: "\u0625\u062F\u0631\u0627\u062C \u0635\u0648\u0631\u0629",
|
|
7367
|
+
insertTable: "\u0625\u062F\u0631\u0627\u062C \u062C\u062F\u0648\u0644",
|
|
7368
|
+
tableSize: "\u062D\u062C\u0645 \u0627\u0644\u062C\u062F\u0648\u0644",
|
|
7369
|
+
rows: "\u0635\u0641\u0648\u0641",
|
|
7370
|
+
columns: "\u0623\u0639\u0645\u062F\u0629",
|
|
7371
|
+
insert: "\u0625\u062F\u0631\u0627\u062C",
|
|
7372
|
+
panels: "\u0627\u0644\u0644\u0648\u062D\u0627\u062A",
|
|
7373
|
+
hideEditor: "\u0625\u062E\u0641\u0627\u0621 \u0627\u0644\u062A\u062D\u0631\u064A\u0631",
|
|
7374
|
+
editor: "\u062A\u062D\u0631\u064A\u0631",
|
|
7375
|
+
hidePreview: "\u0625\u062E\u0641\u0627\u0621 \u0627\u0644\u0645\u0639\u0627\u064A\u0646\u0629",
|
|
7376
|
+
preview: "\u0645\u0639\u0627\u064A\u0646\u0629",
|
|
7377
|
+
collapseBlocks: "\u0637\u064A \u0627\u0644\u0643\u062A\u0644",
|
|
7378
|
+
collapseAll: "\u0637\u064A \u0627\u0644\u0643\u0644",
|
|
7379
|
+
openAll: "\u0641\u062A\u062D \u0627\u0644\u0643\u0644",
|
|
7380
|
+
documentEditor: "\u062A\u062D\u0631\u064A\u0631 \u0627\u0644\u0645\u0633\u062A\u0646\u062F",
|
|
7381
|
+
documentPreview: "\u0645\u0639\u0627\u064A\u0646\u0629 \u0627\u0644\u0645\u0633\u062A\u0646\u062F",
|
|
7382
|
+
importWarnings: "\u062A\u0646\u0628\u064A\u0647\u0627\u062A \u0627\u0644\u0627\u0633\u062A\u064A\u0631\u0627\u062F (\u0648\u0636\u0639 \u0627\u0644\u062A\u0637\u0648\u064A\u0631)",
|
|
7383
|
+
emptyDocument: "\u0627\u0644\u0645\u0633\u062A\u0646\u062F \u0641\u0627\u0631\u063A",
|
|
7384
|
+
text: "\u0646\u0635",
|
|
7385
|
+
editEquation: "\u062A\u062D\u0631\u064A\u0631 \u0627\u0644\u0645\u0639\u0627\u062F\u0644\u0629",
|
|
7386
|
+
rawEquation: "\u0645\u0639\u0627\u062F\u0644\u0629 \u062E\u0627\u0645",
|
|
7387
|
+
deleteEquation: "\u062D\u0630\u0641 \u0627\u0644\u0645\u0639\u0627\u062F\u0644\u0629",
|
|
7388
|
+
equationUnavailable: "\u0647\u0630\u0647 \u0627\u0644\u0645\u0639\u0627\u062F\u0644\u0629 \u063A\u064A\u0631 \u0645\u062A\u0627\u062D\u0629 \u0644\u0644\u062A\u062D\u0631\u064A\u0631 \u062D\u0627\u0644\u064A\u0627",
|
|
7389
|
+
closeEquationDialog: "\u0625\u063A\u0644\u0627\u0642 \u0646\u0627\u0641\u0630\u0629 \u0627\u0644\u0645\u0639\u0627\u062F\u0644\u0629",
|
|
7390
|
+
equationEditorTitle: "\u062A\u062D\u0631\u064A\u0631 \u0627\u0644\u0645\u0639\u0627\u062F\u0644\u0629",
|
|
7391
|
+
close: "\u0625\u063A\u0644\u0627\u0642",
|
|
7392
|
+
equationType: "\u0646\u0648\u0639 \u0627\u0644\u0645\u0639\u0627\u062F\u0644\u0629",
|
|
7393
|
+
inline: "\u062F\u0627\u062E\u0644 \u0627\u0644\u0633\u0637\u0631",
|
|
7394
|
+
displayed: "\u0645\u0639\u0631\u0648\u0636\u0629",
|
|
7395
|
+
saveEquation: "\u062D\u0641\u0638 \u0627\u0644\u0645\u0639\u0627\u062F\u0644\u0629",
|
|
7396
|
+
section: "\u0642\u0633\u0645",
|
|
7397
|
+
subsection: "\u0641\u0631\u0639",
|
|
7398
|
+
subsubsection: "\u0641\u0631\u0639 \u0635\u063A\u064A\u0631",
|
|
7399
|
+
paragraph: "\u0641\u0642\u0631\u0629",
|
|
7400
|
+
list: "\u0642\u0627\u0626\u0645\u0629",
|
|
7401
|
+
table: "\u062C\u062F\u0648\u0644",
|
|
7402
|
+
image: "\u0635\u0648\u0631\u0629",
|
|
7403
|
+
raw: "\u062E\u0627\u0645",
|
|
7404
|
+
bibliography: "\u0627\u0644\u0645\u0631\u0627\u062C\u0639",
|
|
7405
|
+
openBlock: "\u0641\u062A\u062D \u0627\u0644\u0643\u062A\u0644\u0629",
|
|
7406
|
+
collapseBlock: "\u0637\u064A \u0627\u0644\u0643\u062A\u0644\u0629",
|
|
7407
|
+
moveUp: "\u0646\u0642\u0644 \u0644\u0623\u0639\u0644\u0649",
|
|
7408
|
+
moveDown: "\u0646\u0642\u0644 \u0644\u0623\u0633\u0641\u0644",
|
|
7409
|
+
deleteBlock: "\u062D\u0630\u0641 \u0627\u0644\u0643\u062A\u0644\u0629",
|
|
7410
|
+
item: "\u0639\u0646\u0635\u0631",
|
|
7411
|
+
deleteItem: "\u062D\u0630\u0641 \u0627\u0644\u0639\u0646\u0635\u0631",
|
|
7412
|
+
addItem: "\u0639\u0646\u0635\u0631",
|
|
7413
|
+
imagePath: "\u0645\u0633\u0627\u0631 \u0627\u0644\u0645\u0644\u0641 (\\includegraphics)",
|
|
7414
|
+
imagePathLabel: "\u0645\u0633\u0627\u0631 \u0627\u0644\u0635\u0648\u0631\u0629",
|
|
7415
|
+
loadDocumentError: "\u062A\u0639\u0630\u0631 \u062A\u062D\u0645\u064A\u0644 \u0627\u0644\u0645\u0633\u062A\u0646\u062F",
|
|
7416
|
+
importOrderMismatch: "\u062A\u0631\u062A\u064A\u0628 \u0623\u0648 \u0623\u0646\u0648\u0627\u0639 \u0627\u0644\u0645\u062D\u062F\u062F\u0627\u062A \u0641\u064A math_objects \u0644\u0627 \u062A\u0637\u0627\u0628\u0642 \u0645\u0627 \u0648\u0631\u062F \u0641\u064A \u0627\u0644\u0646\u0635.",
|
|
7417
|
+
importCountMismatch: "\u0639\u062F\u0645 \u062A\u0637\u0627\u0628\u0642 \u0628\u064A\u0646 \u0627\u0644\u0645\u0648\u0627\u0636\u0639 \u0627\u0644\u0631\u064A\u0627\u0636\u064A\u0629 \u0627\u0644\u0645\u0633\u062A\u062E\u0631\u062C\u0629 \u0645\u0646 \u0627\u0644\u0646\u0635 \u0648\u0639\u062F\u062F \u0639\u0646\u0627\u0635\u0631 math_objects.",
|
|
7418
|
+
importWarning: "\u062A\u0646\u0628\u064A\u0647 \u0627\u0644\u0627\u0633\u062A\u064A\u0631\u0627\u062F",
|
|
7419
|
+
path: "\u0627\u0644\u0645\u0633\u0627\u0631",
|
|
7420
|
+
sectionGlyph: "\u0642",
|
|
7421
|
+
subsectionGlyph: "\u0641",
|
|
7422
|
+
subsubsectionGlyph: "\u0635",
|
|
7423
|
+
paragraphGlyph: "\u0623\u0628\u062C",
|
|
7424
|
+
insertCitation: "\u0625\u062F\u0631\u0627\u062C \u0627\u0642\u062A\u0628\u0627\u0633",
|
|
7425
|
+
insertBibliography: "\u0625\u062F\u0631\u0627\u062C \u0642\u0627\u0626\u0645\u0629 \u0627\u0644\u0645\u0631\u0627\u062C\u0639",
|
|
7426
|
+
manageReferences: "\u0625\u062F\u0627\u0631\u0629 \u0627\u0644\u0645\u0631\u0627\u062C\u0639",
|
|
7427
|
+
citePickerTitle: "\u0627\u062E\u062A\u064A\u0627\u0631 \u0627\u0644\u0645\u0631\u0627\u062C\u0639",
|
|
7428
|
+
noReferencesYet: "\u0644\u0627 \u062A\u0648\u062C\u062F \u0645\u0631\u0627\u062C\u0639 \u0628\u0639\u062F. \u0623\u0636\u0641 \u0645\u0631\u062C\u0639\u0627\u064B \u0623\u0648\u0644\u0627\u064B.",
|
|
7429
|
+
editCitation: "\u062A\u062D\u0631\u064A\u0631 \u0627\u0644\u0627\u0642\u062A\u0628\u0627\u0633",
|
|
7430
|
+
deleteCitation: "\u062D\u0630\u0641 \u0627\u0644\u0627\u0642\u062A\u0628\u0627\u0633",
|
|
7431
|
+
referencesTitle: "\u0627\u0644\u0645\u0631\u0627\u062C\u0639",
|
|
7432
|
+
addReference: "\u0625\u0636\u0627\u0641\u0629 \u0645\u0631\u062C\u0639",
|
|
7433
|
+
deleteReference: "\u062D\u0630\u0641 \u0627\u0644\u0645\u0631\u062C\u0639",
|
|
7434
|
+
referenceKey: "\u0627\u0644\u0645\u0641\u062A\u0627\u062D",
|
|
7435
|
+
referenceAuthors: "\u0627\u0644\u0645\u0624\u0644\u0641\u0648\u0646",
|
|
7436
|
+
referenceTitle: "\u0627\u0644\u0639\u0646\u0648\u0627\u0646",
|
|
7437
|
+
referenceYear: "\u0627\u0644\u0633\u0646\u0629",
|
|
7438
|
+
referenceVenue: "\u0627\u0644\u0645\u062C\u0644\u0629 / \u0627\u0644\u0645\u0624\u062A\u0645\u0631",
|
|
7439
|
+
referenceUrl: "\u0627\u0644\u0631\u0627\u0628\u0637",
|
|
7440
|
+
chooseDigitForm: "\u0634\u0643\u0644 \u0627\u0644\u0623\u0631\u0642\u0627\u0645",
|
|
7441
|
+
westernDigits: "\u0623\u0631\u0642\u0627\u0645 \u063A\u0631\u0628\u064A\u0629",
|
|
7442
|
+
arabicIndicDigits: "\u0623\u0631\u0642\u0627\u0645 \u0639\u0631\u0628\u064A\u0629 \u0647\u0646\u062F\u064A\u0629",
|
|
7443
|
+
persianIndicDigits: "\u0623\u0631\u0642\u0627\u0645 \u0641\u0627\u0631\u0633\u064A\u0629"
|
|
7444
|
+
},
|
|
7445
|
+
en: {
|
|
7446
|
+
undoRedo: "Undo and redo",
|
|
7447
|
+
undo: "Undo",
|
|
7448
|
+
redo: "Redo",
|
|
7449
|
+
structure: "Structure",
|
|
7450
|
+
content: "Content",
|
|
7451
|
+
addSection: "Add section",
|
|
7452
|
+
addSubsection: "Add subsection",
|
|
7453
|
+
addSubsubsection: "Add subsubsection",
|
|
7454
|
+
addParagraph: "Add paragraph",
|
|
7455
|
+
inlineEquation: "Inline equation",
|
|
7456
|
+
displayEquation: "Display equation",
|
|
7457
|
+
bulletedList: "Bulleted list",
|
|
7458
|
+
numberedList: "Numbered list",
|
|
7459
|
+
insertImage: "Insert image",
|
|
7460
|
+
insertTable: "Insert table",
|
|
7461
|
+
tableSize: "Table size",
|
|
7462
|
+
rows: "Rows",
|
|
7463
|
+
columns: "Columns",
|
|
7464
|
+
insert: "Insert",
|
|
7465
|
+
panels: "Panels",
|
|
7466
|
+
hideEditor: "Hide editor",
|
|
7467
|
+
editor: "Editor",
|
|
7468
|
+
hidePreview: "Hide preview",
|
|
7469
|
+
preview: "Preview",
|
|
7470
|
+
collapseBlocks: "Collapse blocks",
|
|
7471
|
+
collapseAll: "Collapse all",
|
|
7472
|
+
openAll: "Open all",
|
|
7473
|
+
documentEditor: "Document editor",
|
|
7474
|
+
documentPreview: "Document preview",
|
|
7475
|
+
importWarnings: "Import warnings (development mode)",
|
|
7476
|
+
emptyDocument: "The document is empty",
|
|
7477
|
+
text: "Text",
|
|
7478
|
+
editEquation: "Edit equation",
|
|
7479
|
+
rawEquation: "Raw equation",
|
|
7480
|
+
deleteEquation: "Delete equation",
|
|
7481
|
+
equationUnavailable: "This equation is not currently available for editing",
|
|
7482
|
+
closeEquationDialog: "Close equation dialog",
|
|
7483
|
+
equationEditorTitle: "Edit equation",
|
|
7484
|
+
close: "Close",
|
|
7485
|
+
equationType: "Equation type",
|
|
7486
|
+
inline: "Inline",
|
|
7487
|
+
displayed: "Displayed",
|
|
7488
|
+
saveEquation: "Save equation",
|
|
7489
|
+
section: "Section",
|
|
7490
|
+
subsection: "Subsection",
|
|
7491
|
+
subsubsection: "Subsubsection",
|
|
7492
|
+
paragraph: "Paragraph",
|
|
7493
|
+
list: "List",
|
|
7494
|
+
table: "Table",
|
|
7495
|
+
image: "Image",
|
|
7496
|
+
raw: "Raw",
|
|
7497
|
+
bibliography: "Bibliography",
|
|
7498
|
+
openBlock: "Open block",
|
|
7499
|
+
collapseBlock: "Collapse block",
|
|
7500
|
+
moveUp: "Move up",
|
|
7501
|
+
moveDown: "Move down",
|
|
7502
|
+
deleteBlock: "Delete block",
|
|
7503
|
+
item: "Item",
|
|
7504
|
+
deleteItem: "Delete item",
|
|
7505
|
+
addItem: "Item",
|
|
7506
|
+
imagePath: "File path (\\includegraphics)",
|
|
7507
|
+
imagePathLabel: "Image path",
|
|
7508
|
+
loadDocumentError: "Could not load document",
|
|
7509
|
+
importOrderMismatch: "The math_objects delimiter order or types do not match the document text.",
|
|
7510
|
+
importCountMismatch: "The detected math positions do not match the number of math_objects entries.",
|
|
7511
|
+
importWarning: "Import warning",
|
|
7512
|
+
path: "Path",
|
|
7513
|
+
sectionGlyph: "H1",
|
|
7514
|
+
subsectionGlyph: "H2",
|
|
7515
|
+
subsubsectionGlyph: "H3",
|
|
7516
|
+
paragraphGlyph: "P",
|
|
7517
|
+
insertCitation: "Insert citation",
|
|
7518
|
+
insertBibliography: "Insert bibliography",
|
|
7519
|
+
manageReferences: "Manage references",
|
|
7520
|
+
citePickerTitle: "Select references",
|
|
7521
|
+
noReferencesYet: "No references yet. Add a reference first.",
|
|
7522
|
+
editCitation: "Edit citation",
|
|
7523
|
+
deleteCitation: "Delete citation",
|
|
7524
|
+
referencesTitle: "References",
|
|
7525
|
+
addReference: "Add reference",
|
|
7526
|
+
deleteReference: "Delete reference",
|
|
7527
|
+
referenceKey: "Key",
|
|
7528
|
+
referenceAuthors: "Authors",
|
|
7529
|
+
referenceTitle: "Title",
|
|
7530
|
+
referenceYear: "Year",
|
|
7531
|
+
referenceVenue: "Journal / conference",
|
|
7532
|
+
referenceUrl: "URL",
|
|
7533
|
+
chooseDigitForm: "Digit form",
|
|
7534
|
+
westernDigits: "Western digits",
|
|
7535
|
+
arabicIndicDigits: "Arabic-Indic digits",
|
|
7536
|
+
persianIndicDigits: "Persian digits"
|
|
7537
|
+
}
|
|
7538
|
+
};
|
|
7539
|
+
function document2Messages(locale) {
|
|
7540
|
+
return DOCUMENT2_MESSAGES[locale];
|
|
7541
|
+
}
|
|
7542
|
+
|
|
7543
|
+
// src/react-document2/CiteChip.tsx
|
|
7544
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7545
|
+
function CiteChip({
|
|
7546
|
+
token,
|
|
7547
|
+
references,
|
|
7548
|
+
documentDirection = "rtl",
|
|
7549
|
+
digitForm,
|
|
7550
|
+
editable = true,
|
|
7551
|
+
uiLocale = "ar",
|
|
7552
|
+
buttonRef,
|
|
7553
|
+
onOpen,
|
|
7554
|
+
onDelete,
|
|
7555
|
+
onFocus,
|
|
7556
|
+
onRequestTextFocus
|
|
7557
|
+
}) {
|
|
7558
|
+
const messages = document2Messages(uiLocale);
|
|
7559
|
+
const label = formatCiteLabel(token.keys, references, { documentDirection, digitForm });
|
|
7560
|
+
const forwardArrowKey = documentDirection === "rtl" ? "ArrowLeft" : "ArrowRight";
|
|
7561
|
+
const backwardArrowKey = documentDirection === "rtl" ? "ArrowRight" : "ArrowLeft";
|
|
7562
|
+
if (!editable) {
|
|
7563
|
+
return /* @__PURE__ */ jsx("span", { className: "butex-document2-widget__cite-chip-wrap", children: /* @__PURE__ */ jsx("span", { className: "butex-document2-widget__cite-chip", "data-editable": "false", children: label }) });
|
|
7564
|
+
}
|
|
7565
|
+
return /* @__PURE__ */ jsxs("span", { className: "butex-document2-widget__cite-chip-wrap", children: [
|
|
7566
|
+
/* @__PURE__ */ jsx(
|
|
7567
|
+
"button",
|
|
7568
|
+
{
|
|
7569
|
+
type: "button",
|
|
7570
|
+
className: "butex-document2-widget__cite-chip",
|
|
7571
|
+
"data-editable": "true",
|
|
7572
|
+
"data-cite-token-id": token.id,
|
|
7573
|
+
ref: buttonRef,
|
|
7574
|
+
title: messages.editCitation,
|
|
7575
|
+
onClick: () => onOpen(token),
|
|
7576
|
+
onFocus: () => onFocus?.(token.id),
|
|
7577
|
+
onKeyDown: (event) => {
|
|
7578
|
+
if (event.key === "Enter") {
|
|
7579
|
+
event.preventDefault();
|
|
7580
|
+
onOpen(token);
|
|
7581
|
+
return;
|
|
7582
|
+
}
|
|
7583
|
+
if (event.key === forwardArrowKey) {
|
|
7584
|
+
event.preventDefault();
|
|
7585
|
+
onRequestTextFocus?.(token.id, 1);
|
|
7586
|
+
return;
|
|
7587
|
+
}
|
|
7588
|
+
if (event.key === backwardArrowKey) {
|
|
7589
|
+
event.preventDefault();
|
|
7590
|
+
onRequestTextFocus?.(token.id, -1);
|
|
7591
|
+
}
|
|
7592
|
+
},
|
|
7593
|
+
children: label
|
|
7594
|
+
}
|
|
7595
|
+
),
|
|
7596
|
+
onDelete ? /* @__PURE__ */ jsx(
|
|
7597
|
+
"button",
|
|
7598
|
+
{
|
|
7599
|
+
type: "button",
|
|
7600
|
+
className: "butex-document2-widget__cite-chip-delete",
|
|
7601
|
+
title: messages.deleteCitation,
|
|
7602
|
+
"aria-label": messages.deleteCitation,
|
|
7603
|
+
onClick: (event) => {
|
|
7604
|
+
event.stopPropagation();
|
|
7605
|
+
onDelete(token.id);
|
|
7606
|
+
},
|
|
7607
|
+
children: "\xD7"
|
|
7608
|
+
}
|
|
7609
|
+
) : null
|
|
7610
|
+
] });
|
|
7611
|
+
}
|
|
7612
|
+
|
|
7613
|
+
// src/react-document2/MathIsland.tsx
|
|
7614
|
+
import { useEffect, useRef, useState } from "react";
|
|
7615
|
+
|
|
7616
|
+
// src/mathjax/svgPatcher.ts
|
|
7617
|
+
var SVG_ARABSQRT_SELECTOR = 'mjx-container[jax="SVG"] svg .mjx-rtl-mirror[data-mjx-rtl-root="true"]';
|
|
7618
|
+
var ARABSQRT_SELECTOR = '.mjx-rtl-mirror[data-mjx-rtl-root="true"]';
|
|
7619
|
+
var PATCHED_ATTR = "data-butex-svg-arabsqrt";
|
|
7620
|
+
var ROOT_INDEX_SCALE = 0.72;
|
|
7621
|
+
var ROOT_INDEX_GAP_FACTOR = 0.08;
|
|
7622
|
+
var ROOT_INDEX_MIN_GAP = 2;
|
|
7623
|
+
var ROOT_INDEX_Y_RAISE = 18;
|
|
7624
|
+
var ROOT_INDEX_LEFT_SHIFT = 360;
|
|
7625
|
+
var VIEWBOX_PADDING = 20;
|
|
7626
|
+
function closestArabSqrtRoot(element) {
|
|
6833
7627
|
return element.closest('.mjx-rtl-mirror[data-mjx-rtl-root="true"]');
|
|
6834
7628
|
}
|
|
6835
7629
|
function rootDepth(root) {
|
|
@@ -7178,7 +7972,7 @@ async function renderBuTeXMathIsland(tex, options = {}) {
|
|
|
7178
7972
|
}
|
|
7179
7973
|
|
|
7180
7974
|
// src/react-document2/MathIsland.tsx
|
|
7181
|
-
import { jsx } from "react/jsx-runtime";
|
|
7975
|
+
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
7182
7976
|
function MathIsland({ id, tex, display, output = "svg" }) {
|
|
7183
7977
|
const ref = useRef(null);
|
|
7184
7978
|
const version = useRef(0);
|
|
@@ -7229,7 +8023,7 @@ function MathIsland({ id, tex, display, output = "svg" }) {
|
|
|
7229
8023
|
cancelled = true;
|
|
7230
8024
|
};
|
|
7231
8025
|
}, [display, output, tex]);
|
|
7232
|
-
return /* @__PURE__ */
|
|
8026
|
+
return /* @__PURE__ */ jsx2(
|
|
7233
8027
|
"span",
|
|
7234
8028
|
{
|
|
7235
8029
|
ref,
|
|
@@ -7243,159 +8037,8 @@ function MathIsland({ id, tex, display, output = "svg" }) {
|
|
|
7243
8037
|
);
|
|
7244
8038
|
}
|
|
7245
8039
|
|
|
7246
|
-
// src/react-document2/uiMessages.ts
|
|
7247
|
-
var DOCUMENT2_MESSAGES = {
|
|
7248
|
-
ar: {
|
|
7249
|
-
undoRedo: "\u062A\u0631\u0627\u062C\u0639 \u0648\u0625\u0639\u0627\u062F\u0629",
|
|
7250
|
-
undo: "\u062A\u0631\u0627\u062C\u0639",
|
|
7251
|
-
redo: "\u0625\u0639\u0627\u062F\u0629",
|
|
7252
|
-
structure: "\u0647\u064A\u0643\u0644",
|
|
7253
|
-
content: "\u0645\u062D\u062A\u0648\u0649",
|
|
7254
|
-
addSection: "\u0625\u0636\u0627\u0641\u0629 \u0642\u0633\u0645",
|
|
7255
|
-
addSubsection: "\u0625\u0636\u0627\u0641\u0629 \u0641\u0631\u0639",
|
|
7256
|
-
addSubsubsection: "\u0625\u0636\u0627\u0641\u0629 \u0641\u0631\u0639 \u0635\u063A\u064A\u0631",
|
|
7257
|
-
addParagraph: "\u0625\u0636\u0627\u0641\u0629 \u0641\u0642\u0631\u0629",
|
|
7258
|
-
inlineEquation: "\u0645\u0639\u0627\u062F\u0644\u0629 \u062F\u0627\u062E\u0644 \u0627\u0644\u0633\u0637\u0631",
|
|
7259
|
-
displayEquation: "\u0645\u0639\u0627\u062F\u0644\u0629 \u0645\u0639\u0631\u0648\u0636\u0629",
|
|
7260
|
-
bulletedList: "\u0642\u0627\u0626\u0645\u0629 \u0646\u0642\u0637\u064A\u0629",
|
|
7261
|
-
numberedList: "\u0642\u0627\u0626\u0645\u0629 \u0645\u0631\u0642\u0645\u0629",
|
|
7262
|
-
insertImage: "\u0625\u062F\u0631\u0627\u062C \u0635\u0648\u0631\u0629",
|
|
7263
|
-
insertTable: "\u0625\u062F\u0631\u0627\u062C \u062C\u062F\u0648\u0644",
|
|
7264
|
-
tableSize: "\u062D\u062C\u0645 \u0627\u0644\u062C\u062F\u0648\u0644",
|
|
7265
|
-
rows: "\u0635\u0641\u0648\u0641",
|
|
7266
|
-
columns: "\u0623\u0639\u0645\u062F\u0629",
|
|
7267
|
-
insert: "\u0625\u062F\u0631\u0627\u062C",
|
|
7268
|
-
panels: "\u0627\u0644\u0644\u0648\u062D\u0627\u062A",
|
|
7269
|
-
hideEditor: "\u0625\u062E\u0641\u0627\u0621 \u0627\u0644\u062A\u062D\u0631\u064A\u0631",
|
|
7270
|
-
editor: "\u062A\u062D\u0631\u064A\u0631",
|
|
7271
|
-
hidePreview: "\u0625\u062E\u0641\u0627\u0621 \u0627\u0644\u0645\u0639\u0627\u064A\u0646\u0629",
|
|
7272
|
-
preview: "\u0645\u0639\u0627\u064A\u0646\u0629",
|
|
7273
|
-
collapseBlocks: "\u0637\u064A \u0627\u0644\u0643\u062A\u0644",
|
|
7274
|
-
collapseAll: "\u0637\u064A \u0627\u0644\u0643\u0644",
|
|
7275
|
-
openAll: "\u0641\u062A\u062D \u0627\u0644\u0643\u0644",
|
|
7276
|
-
documentEditor: "\u062A\u062D\u0631\u064A\u0631 \u0627\u0644\u0645\u0633\u062A\u0646\u062F",
|
|
7277
|
-
documentPreview: "\u0645\u0639\u0627\u064A\u0646\u0629 \u0627\u0644\u0645\u0633\u062A\u0646\u062F",
|
|
7278
|
-
importWarnings: "\u062A\u0646\u0628\u064A\u0647\u0627\u062A \u0627\u0644\u0627\u0633\u062A\u064A\u0631\u0627\u062F (\u0648\u0636\u0639 \u0627\u0644\u062A\u0637\u0648\u064A\u0631)",
|
|
7279
|
-
emptyDocument: "\u0627\u0644\u0645\u0633\u062A\u0646\u062F \u0641\u0627\u0631\u063A",
|
|
7280
|
-
text: "\u0646\u0635",
|
|
7281
|
-
editEquation: "\u062A\u062D\u0631\u064A\u0631 \u0627\u0644\u0645\u0639\u0627\u062F\u0644\u0629",
|
|
7282
|
-
rawEquation: "\u0645\u0639\u0627\u062F\u0644\u0629 \u062E\u0627\u0645",
|
|
7283
|
-
deleteEquation: "\u062D\u0630\u0641 \u0627\u0644\u0645\u0639\u0627\u062F\u0644\u0629",
|
|
7284
|
-
equationUnavailable: "\u0647\u0630\u0647 \u0627\u0644\u0645\u0639\u0627\u062F\u0644\u0629 \u063A\u064A\u0631 \u0645\u062A\u0627\u062D\u0629 \u0644\u0644\u062A\u062D\u0631\u064A\u0631 \u062D\u0627\u0644\u064A\u0627",
|
|
7285
|
-
closeEquationDialog: "\u0625\u063A\u0644\u0627\u0642 \u0646\u0627\u0641\u0630\u0629 \u0627\u0644\u0645\u0639\u0627\u062F\u0644\u0629",
|
|
7286
|
-
equationEditorTitle: "\u062A\u062D\u0631\u064A\u0631 \u0627\u0644\u0645\u0639\u0627\u062F\u0644\u0629",
|
|
7287
|
-
close: "\u0625\u063A\u0644\u0627\u0642",
|
|
7288
|
-
equationType: "\u0646\u0648\u0639 \u0627\u0644\u0645\u0639\u0627\u062F\u0644\u0629",
|
|
7289
|
-
inline: "\u062F\u0627\u062E\u0644 \u0627\u0644\u0633\u0637\u0631",
|
|
7290
|
-
displayed: "\u0645\u0639\u0631\u0648\u0636\u0629",
|
|
7291
|
-
saveEquation: "\u062D\u0641\u0638 \u0627\u0644\u0645\u0639\u0627\u062F\u0644\u0629",
|
|
7292
|
-
section: "\u0642\u0633\u0645",
|
|
7293
|
-
subsection: "\u0641\u0631\u0639",
|
|
7294
|
-
subsubsection: "\u0641\u0631\u0639 \u0635\u063A\u064A\u0631",
|
|
7295
|
-
paragraph: "\u0641\u0642\u0631\u0629",
|
|
7296
|
-
list: "\u0642\u0627\u0626\u0645\u0629",
|
|
7297
|
-
table: "\u062C\u062F\u0648\u0644",
|
|
7298
|
-
image: "\u0635\u0648\u0631\u0629",
|
|
7299
|
-
raw: "\u062E\u0627\u0645",
|
|
7300
|
-
openBlock: "\u0641\u062A\u062D \u0627\u0644\u0643\u062A\u0644\u0629",
|
|
7301
|
-
collapseBlock: "\u0637\u064A \u0627\u0644\u0643\u062A\u0644\u0629",
|
|
7302
|
-
moveUp: "\u0646\u0642\u0644 \u0644\u0623\u0639\u0644\u0649",
|
|
7303
|
-
moveDown: "\u0646\u0642\u0644 \u0644\u0623\u0633\u0641\u0644",
|
|
7304
|
-
deleteBlock: "\u062D\u0630\u0641 \u0627\u0644\u0643\u062A\u0644\u0629",
|
|
7305
|
-
item: "\u0639\u0646\u0635\u0631",
|
|
7306
|
-
deleteItem: "\u062D\u0630\u0641 \u0627\u0644\u0639\u0646\u0635\u0631",
|
|
7307
|
-
addItem: "\u0639\u0646\u0635\u0631",
|
|
7308
|
-
imagePath: "\u0645\u0633\u0627\u0631 \u0627\u0644\u0645\u0644\u0641 (\\includegraphics)",
|
|
7309
|
-
imagePathLabel: "\u0645\u0633\u0627\u0631 \u0627\u0644\u0635\u0648\u0631\u0629",
|
|
7310
|
-
loadDocumentError: "\u062A\u0639\u0630\u0631 \u062A\u062D\u0645\u064A\u0644 \u0627\u0644\u0645\u0633\u062A\u0646\u062F",
|
|
7311
|
-
importOrderMismatch: "\u062A\u0631\u062A\u064A\u0628 \u0623\u0648 \u0623\u0646\u0648\u0627\u0639 \u0627\u0644\u0645\u062D\u062F\u062F\u0627\u062A \u0641\u064A math_objects \u0644\u0627 \u062A\u0637\u0627\u0628\u0642 \u0645\u0627 \u0648\u0631\u062F \u0641\u064A \u0627\u0644\u0646\u0635.",
|
|
7312
|
-
importCountMismatch: "\u0639\u062F\u0645 \u062A\u0637\u0627\u0628\u0642 \u0628\u064A\u0646 \u0627\u0644\u0645\u0648\u0627\u0636\u0639 \u0627\u0644\u0631\u064A\u0627\u0636\u064A\u0629 \u0627\u0644\u0645\u0633\u062A\u062E\u0631\u062C\u0629 \u0645\u0646 \u0627\u0644\u0646\u0635 \u0648\u0639\u062F\u062F \u0639\u0646\u0627\u0635\u0631 math_objects.",
|
|
7313
|
-
importWarning: "\u062A\u0646\u0628\u064A\u0647 \u0627\u0644\u0627\u0633\u062A\u064A\u0631\u0627\u062F",
|
|
7314
|
-
path: "\u0627\u0644\u0645\u0633\u0627\u0631",
|
|
7315
|
-
sectionGlyph: "\u0642",
|
|
7316
|
-
subsectionGlyph: "\u0641",
|
|
7317
|
-
subsubsectionGlyph: "\u0635",
|
|
7318
|
-
paragraphGlyph: "\u0623\u0628\u062C"
|
|
7319
|
-
},
|
|
7320
|
-
en: {
|
|
7321
|
-
undoRedo: "Undo and redo",
|
|
7322
|
-
undo: "Undo",
|
|
7323
|
-
redo: "Redo",
|
|
7324
|
-
structure: "Structure",
|
|
7325
|
-
content: "Content",
|
|
7326
|
-
addSection: "Add section",
|
|
7327
|
-
addSubsection: "Add subsection",
|
|
7328
|
-
addSubsubsection: "Add subsubsection",
|
|
7329
|
-
addParagraph: "Add paragraph",
|
|
7330
|
-
inlineEquation: "Inline equation",
|
|
7331
|
-
displayEquation: "Display equation",
|
|
7332
|
-
bulletedList: "Bulleted list",
|
|
7333
|
-
numberedList: "Numbered list",
|
|
7334
|
-
insertImage: "Insert image",
|
|
7335
|
-
insertTable: "Insert table",
|
|
7336
|
-
tableSize: "Table size",
|
|
7337
|
-
rows: "Rows",
|
|
7338
|
-
columns: "Columns",
|
|
7339
|
-
insert: "Insert",
|
|
7340
|
-
panels: "Panels",
|
|
7341
|
-
hideEditor: "Hide editor",
|
|
7342
|
-
editor: "Editor",
|
|
7343
|
-
hidePreview: "Hide preview",
|
|
7344
|
-
preview: "Preview",
|
|
7345
|
-
collapseBlocks: "Collapse blocks",
|
|
7346
|
-
collapseAll: "Collapse all",
|
|
7347
|
-
openAll: "Open all",
|
|
7348
|
-
documentEditor: "Document editor",
|
|
7349
|
-
documentPreview: "Document preview",
|
|
7350
|
-
importWarnings: "Import warnings (development mode)",
|
|
7351
|
-
emptyDocument: "The document is empty",
|
|
7352
|
-
text: "Text",
|
|
7353
|
-
editEquation: "Edit equation",
|
|
7354
|
-
rawEquation: "Raw equation",
|
|
7355
|
-
deleteEquation: "Delete equation",
|
|
7356
|
-
equationUnavailable: "This equation is not currently available for editing",
|
|
7357
|
-
closeEquationDialog: "Close equation dialog",
|
|
7358
|
-
equationEditorTitle: "Edit equation",
|
|
7359
|
-
close: "Close",
|
|
7360
|
-
equationType: "Equation type",
|
|
7361
|
-
inline: "Inline",
|
|
7362
|
-
displayed: "Displayed",
|
|
7363
|
-
saveEquation: "Save equation",
|
|
7364
|
-
section: "Section",
|
|
7365
|
-
subsection: "Subsection",
|
|
7366
|
-
subsubsection: "Subsubsection",
|
|
7367
|
-
paragraph: "Paragraph",
|
|
7368
|
-
list: "List",
|
|
7369
|
-
table: "Table",
|
|
7370
|
-
image: "Image",
|
|
7371
|
-
raw: "Raw",
|
|
7372
|
-
openBlock: "Open block",
|
|
7373
|
-
collapseBlock: "Collapse block",
|
|
7374
|
-
moveUp: "Move up",
|
|
7375
|
-
moveDown: "Move down",
|
|
7376
|
-
deleteBlock: "Delete block",
|
|
7377
|
-
item: "Item",
|
|
7378
|
-
deleteItem: "Delete item",
|
|
7379
|
-
addItem: "Item",
|
|
7380
|
-
imagePath: "File path (\\includegraphics)",
|
|
7381
|
-
imagePathLabel: "Image path",
|
|
7382
|
-
loadDocumentError: "Could not load document",
|
|
7383
|
-
importOrderMismatch: "The math_objects delimiter order or types do not match the document text.",
|
|
7384
|
-
importCountMismatch: "The detected math positions do not match the number of math_objects entries.",
|
|
7385
|
-
importWarning: "Import warning",
|
|
7386
|
-
path: "Path",
|
|
7387
|
-
sectionGlyph: "H1",
|
|
7388
|
-
subsectionGlyph: "H2",
|
|
7389
|
-
subsubsectionGlyph: "H3",
|
|
7390
|
-
paragraphGlyph: "P"
|
|
7391
|
-
}
|
|
7392
|
-
};
|
|
7393
|
-
function document2Messages(locale) {
|
|
7394
|
-
return DOCUMENT2_MESSAGES[locale];
|
|
7395
|
-
}
|
|
7396
|
-
|
|
7397
8040
|
// src/react-document2/MathChip.tsx
|
|
7398
|
-
import { jsx as
|
|
8041
|
+
import { jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
7399
8042
|
function MathChip({
|
|
7400
8043
|
token,
|
|
7401
8044
|
output = "svg",
|
|
@@ -7414,12 +8057,12 @@ function MathChip({
|
|
|
7414
8057
|
const tex = mathTokenSourceForSide(token, equationSide);
|
|
7415
8058
|
const forwardArrowKey = documentDirection === "rtl" ? "ArrowLeft" : "ArrowRight";
|
|
7416
8059
|
const backwardArrowKey = documentDirection === "rtl" ? "ArrowRight" : "ArrowLeft";
|
|
7417
|
-
const island = /* @__PURE__ */
|
|
8060
|
+
const island = /* @__PURE__ */ jsx3(MathIsland, { id: token.id, tex, display: token.display, output });
|
|
7418
8061
|
if (!editable) {
|
|
7419
|
-
return /* @__PURE__ */
|
|
8062
|
+
return /* @__PURE__ */ jsx3("span", { className: "butex-document2-widget__math-chip-wrap", "data-display": token.display ? "true" : "false", children: /* @__PURE__ */ jsx3("span", { className: "butex-document2-widget__math-chip", "data-editable": "false", "data-display": token.display ? "true" : "false", children: island }) });
|
|
7420
8063
|
}
|
|
7421
|
-
return /* @__PURE__ */
|
|
7422
|
-
/* @__PURE__ */
|
|
8064
|
+
return /* @__PURE__ */ jsxs2("span", { className: "butex-document2-widget__math-chip-wrap", "data-display": token.display ? "true" : "false", children: [
|
|
8065
|
+
/* @__PURE__ */ jsx3(
|
|
7423
8066
|
"button",
|
|
7424
8067
|
{
|
|
7425
8068
|
type: "button",
|
|
@@ -7461,7 +8104,7 @@ function MathChip({
|
|
|
7461
8104
|
children: island
|
|
7462
8105
|
}
|
|
7463
8106
|
),
|
|
7464
|
-
onDelete ? /* @__PURE__ */
|
|
8107
|
+
onDelete ? /* @__PURE__ */ jsx3(
|
|
7465
8108
|
"button",
|
|
7466
8109
|
{
|
|
7467
8110
|
type: "button",
|
|
@@ -7479,7 +8122,7 @@ function MathChip({
|
|
|
7479
8122
|
}
|
|
7480
8123
|
|
|
7481
8124
|
// src/react-document2/InlineField.tsx
|
|
7482
|
-
import { jsx as
|
|
8125
|
+
import { jsx as jsx4 } from "react/jsx-runtime";
|
|
7483
8126
|
function rememberCaret(element, blockId, fieldId, tokenId, onFieldFocus) {
|
|
7484
8127
|
if (!blockId || !onFieldFocus) {
|
|
7485
8128
|
return;
|
|
@@ -7498,21 +8141,28 @@ function fitTextareaHeight(element) {
|
|
|
7498
8141
|
function InlineField({
|
|
7499
8142
|
field,
|
|
7500
8143
|
blockId,
|
|
8144
|
+
references = [],
|
|
7501
8145
|
documentDirection = "rtl",
|
|
8146
|
+
digitForm,
|
|
7502
8147
|
mathOutput = "svg",
|
|
7503
8148
|
equationSide = "arabic",
|
|
7504
8149
|
editableEquations = true,
|
|
8150
|
+
editableCitations = true,
|
|
7505
8151
|
uiLocale = "ar",
|
|
7506
8152
|
onTextChange,
|
|
7507
8153
|
onOpenMath,
|
|
7508
8154
|
onDeleteMath,
|
|
8155
|
+
onOpenCite,
|
|
8156
|
+
onDeleteCite,
|
|
7509
8157
|
onFieldFocus,
|
|
7510
8158
|
onMathFocus,
|
|
8159
|
+
onCiteFocus,
|
|
7511
8160
|
onFieldBlur
|
|
7512
8161
|
}) {
|
|
7513
8162
|
const messages = document2Messages(uiLocale);
|
|
7514
8163
|
const textRefs = useRef2(/* @__PURE__ */ new Map());
|
|
7515
8164
|
const mathRefs = useRef2(/* @__PURE__ */ new Map());
|
|
8165
|
+
const citeRefs = useRef2(/* @__PURE__ */ new Map());
|
|
7516
8166
|
function textTokenOffset(tokenId, fallback) {
|
|
7517
8167
|
const token = field.tokens.find((entry) => entry.id === tokenId && entry.kind === "text");
|
|
7518
8168
|
if (!token || token.kind !== "text") {
|
|
@@ -7538,6 +8188,11 @@ function InlineField({
|
|
|
7538
8188
|
mathRefs.current.get(tokenId)?.focus();
|
|
7539
8189
|
});
|
|
7540
8190
|
}
|
|
8191
|
+
function focusCiteToken(tokenId) {
|
|
8192
|
+
requestAnimationFrame(() => {
|
|
8193
|
+
citeRefs.current.get(tokenId)?.focus();
|
|
8194
|
+
});
|
|
8195
|
+
}
|
|
7541
8196
|
function adjacentTokenId(tokenId, direction, kind) {
|
|
7542
8197
|
const index = field.tokens.findIndex((token) => token.id === tokenId);
|
|
7543
8198
|
if (index < 0) {
|
|
@@ -7551,7 +8206,20 @@ function InlineField({
|
|
|
7551
8206
|
}
|
|
7552
8207
|
return null;
|
|
7553
8208
|
}
|
|
7554
|
-
function
|
|
8209
|
+
function adjacentIslandId(tokenId, direction) {
|
|
8210
|
+
const index = field.tokens.findIndex((token) => token.id === tokenId);
|
|
8211
|
+
if (index < 0) {
|
|
8212
|
+
return null;
|
|
8213
|
+
}
|
|
8214
|
+
for (let i = index + direction; i >= 0 && i < field.tokens.length; i += direction) {
|
|
8215
|
+
const token = field.tokens[i];
|
|
8216
|
+
if (token?.kind === "math" || token?.kind === "cite") {
|
|
8217
|
+
return { kind: token.kind, id: token.id };
|
|
8218
|
+
}
|
|
8219
|
+
}
|
|
8220
|
+
return null;
|
|
8221
|
+
}
|
|
8222
|
+
function focusTextNearIsland(tokenId, direction) {
|
|
7555
8223
|
const fallbackDirection = direction === 1 ? -1 : 1;
|
|
7556
8224
|
const textTokenId = adjacentTokenId(tokenId, direction, "text") ?? adjacentTokenId(tokenId, fallbackDirection, "text");
|
|
7557
8225
|
if (!textTokenId) {
|
|
@@ -7576,60 +8244,100 @@ function InlineField({
|
|
|
7576
8244
|
}
|
|
7577
8245
|
const forwardArrowKey = documentDirection === "rtl" ? "ArrowLeft" : "ArrowRight";
|
|
7578
8246
|
const backwardArrowKey = documentDirection === "rtl" ? "ArrowRight" : "ArrowLeft";
|
|
7579
|
-
return /* @__PURE__ */
|
|
7580
|
-
(token
|
|
7581
|
-
|
|
7582
|
-
|
|
7583
|
-
|
|
7584
|
-
|
|
7585
|
-
|
|
7586
|
-
|
|
7587
|
-
|
|
7588
|
-
|
|
7589
|
-
|
|
7590
|
-
|
|
7591
|
-
|
|
7592
|
-
|
|
7593
|
-
|
|
7594
|
-
|
|
7595
|
-
|
|
7596
|
-
|
|
7597
|
-
},
|
|
7598
|
-
onChange: (event) => {
|
|
7599
|
-
onTextChange(field.id, token.id, event.currentTarget.value);
|
|
7600
|
-
fitTextareaHeight(event.currentTarget);
|
|
7601
|
-
},
|
|
7602
|
-
onKeyDown: (event) => {
|
|
7603
|
-
const element = event.currentTarget;
|
|
7604
|
-
const collapsed = element.selectionStart === element.selectionEnd;
|
|
7605
|
-
if (!collapsed) {
|
|
7606
|
-
return;
|
|
7607
|
-
}
|
|
7608
|
-
if (editableEquations && event.key === forwardArrowKey && element.selectionStart === element.value.length) {
|
|
7609
|
-
const nextMathId = adjacentTokenId(token.id, 1, "math");
|
|
7610
|
-
if (nextMathId) {
|
|
7611
|
-
event.preventDefault();
|
|
7612
|
-
focusMathToken(nextMathId);
|
|
8247
|
+
return /* @__PURE__ */ jsx4("div", { className: "butex-document2-widget__inline-field", dir: documentDirection, "data-document-direction": documentDirection, children: field.tokens.map((token) => {
|
|
8248
|
+
if (token.kind === "text") {
|
|
8249
|
+
return /* @__PURE__ */ jsx4(
|
|
8250
|
+
"textarea",
|
|
8251
|
+
{
|
|
8252
|
+
className: "butex-document2-widget__inline-text",
|
|
8253
|
+
value: token.text,
|
|
8254
|
+
dir: documentDirection,
|
|
8255
|
+
"aria-label": messages.text,
|
|
8256
|
+
rows: 1,
|
|
8257
|
+
"data-field-id": field.id,
|
|
8258
|
+
"data-text-token-id": token.id,
|
|
8259
|
+
ref: (element) => {
|
|
8260
|
+
if (element) {
|
|
8261
|
+
textRefs.current.set(token.id, element);
|
|
8262
|
+
fitTextareaHeight(element);
|
|
8263
|
+
} else {
|
|
8264
|
+
textRefs.current.delete(token.id);
|
|
7613
8265
|
}
|
|
7614
|
-
}
|
|
7615
|
-
|
|
7616
|
-
|
|
7617
|
-
|
|
7618
|
-
|
|
8266
|
+
},
|
|
8267
|
+
onChange: (event) => {
|
|
8268
|
+
onTextChange(field.id, token.id, event.currentTarget.value);
|
|
8269
|
+
fitTextareaHeight(event.currentTarget);
|
|
8270
|
+
},
|
|
8271
|
+
onKeyDown: (event) => {
|
|
8272
|
+
const element = event.currentTarget;
|
|
8273
|
+
const collapsed = element.selectionStart === element.selectionEnd;
|
|
8274
|
+
if (!collapsed) {
|
|
8275
|
+
return;
|
|
7619
8276
|
}
|
|
7620
|
-
|
|
8277
|
+
if (event.key === forwardArrowKey && element.selectionStart === element.value.length) {
|
|
8278
|
+
const next = adjacentIslandId(token.id, 1);
|
|
8279
|
+
if (next) {
|
|
8280
|
+
event.preventDefault();
|
|
8281
|
+
if (next.kind === "math") {
|
|
8282
|
+
focusMathToken(next.id);
|
|
8283
|
+
} else {
|
|
8284
|
+
focusCiteToken(next.id);
|
|
8285
|
+
}
|
|
8286
|
+
}
|
|
8287
|
+
} else if (event.key === backwardArrowKey && element.selectionStart === 0) {
|
|
8288
|
+
const previous = adjacentIslandId(token.id, -1);
|
|
8289
|
+
if (previous) {
|
|
8290
|
+
event.preventDefault();
|
|
8291
|
+
if (previous.kind === "math") {
|
|
8292
|
+
focusMathToken(previous.id);
|
|
8293
|
+
} else {
|
|
8294
|
+
focusCiteToken(previous.id);
|
|
8295
|
+
}
|
|
8296
|
+
}
|
|
8297
|
+
}
|
|
8298
|
+
},
|
|
8299
|
+
onFocus: (event) => rememberCaret(event.currentTarget, blockId, field.id, token.id, onFieldFocus),
|
|
8300
|
+
onClick: (event) => rememberCaret(event.currentTarget, blockId, field.id, token.id, onFieldFocus),
|
|
8301
|
+
onKeyUp: (event) => {
|
|
8302
|
+
rememberCaret(event.currentTarget, blockId, field.id, token.id, onFieldFocus);
|
|
8303
|
+
fitTextareaHeight(event.currentTarget);
|
|
8304
|
+
},
|
|
8305
|
+
onSelect: (event) => rememberCaret(event.currentTarget, blockId, field.id, token.id, onFieldFocus),
|
|
8306
|
+
onBlur: () => onFieldBlur?.()
|
|
7621
8307
|
},
|
|
7622
|
-
|
|
7623
|
-
|
|
7624
|
-
|
|
7625
|
-
|
|
7626
|
-
|
|
8308
|
+
token.id
|
|
8309
|
+
);
|
|
8310
|
+
}
|
|
8311
|
+
if (token.kind === "cite") {
|
|
8312
|
+
return /* @__PURE__ */ jsx4(
|
|
8313
|
+
CiteChip,
|
|
8314
|
+
{
|
|
8315
|
+
token,
|
|
8316
|
+
references,
|
|
8317
|
+
documentDirection,
|
|
8318
|
+
digitForm,
|
|
8319
|
+
editable: editableCitations,
|
|
8320
|
+
uiLocale,
|
|
8321
|
+
buttonRef: (element) => {
|
|
8322
|
+
if (element) {
|
|
8323
|
+
citeRefs.current.set(token.id, element);
|
|
8324
|
+
} else {
|
|
8325
|
+
citeRefs.current.delete(token.id);
|
|
8326
|
+
}
|
|
8327
|
+
},
|
|
8328
|
+
onOpen: (citeToken) => onOpenCite?.(citeToken),
|
|
8329
|
+
onDelete: editableCitations ? onDeleteCite : void 0,
|
|
8330
|
+
onFocus: (tokenId) => {
|
|
8331
|
+
if (blockId && onCiteFocus) {
|
|
8332
|
+
onCiteFocus(blockId, field.id, tokenId);
|
|
8333
|
+
}
|
|
8334
|
+
},
|
|
8335
|
+
onRequestTextFocus: focusTextNearIsland
|
|
7627
8336
|
},
|
|
7628
|
-
|
|
7629
|
-
|
|
7630
|
-
|
|
7631
|
-
|
|
7632
|
-
) : /* @__PURE__ */ jsx3(
|
|
8337
|
+
token.id
|
|
8338
|
+
);
|
|
8339
|
+
}
|
|
8340
|
+
return /* @__PURE__ */ jsx4(
|
|
7633
8341
|
MathChip,
|
|
7634
8342
|
{
|
|
7635
8343
|
token,
|
|
@@ -7652,16 +8360,16 @@ function InlineField({
|
|
|
7652
8360
|
onMathFocus(blockId, field.id, tokenId);
|
|
7653
8361
|
}
|
|
7654
8362
|
},
|
|
7655
|
-
onRequestTextFocus:
|
|
8363
|
+
onRequestTextFocus: focusTextNearIsland,
|
|
7656
8364
|
onTextInputFromFocus: typeFromMath
|
|
7657
8365
|
},
|
|
7658
8366
|
token.id
|
|
7659
|
-
)
|
|
7660
|
-
) });
|
|
8367
|
+
);
|
|
8368
|
+
}) });
|
|
7661
8369
|
}
|
|
7662
8370
|
|
|
7663
8371
|
// src/react-document2/BlockEditor.tsx
|
|
7664
|
-
import { Fragment, jsx as
|
|
8372
|
+
import { Fragment, jsx as jsx5, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
7665
8373
|
function blockChromeClass(block) {
|
|
7666
8374
|
const root = "butex-document2-widget__block";
|
|
7667
8375
|
if (block.kind === "textBlock") {
|
|
@@ -7685,6 +8393,9 @@ function blockChromeClass(block) {
|
|
|
7685
8393
|
if (block.kind === "image") {
|
|
7686
8394
|
return `${root} ${root}--image`;
|
|
7687
8395
|
}
|
|
8396
|
+
if (block.kind === "bibliography") {
|
|
8397
|
+
return `${root} ${root}--bibliography`;
|
|
8398
|
+
}
|
|
7688
8399
|
return `${root} ${root}--raw`;
|
|
7689
8400
|
}
|
|
7690
8401
|
function blockLabel(block, messages) {
|
|
@@ -7709,6 +8420,9 @@ function blockLabel(block, messages) {
|
|
|
7709
8420
|
if (block.kind === "image") {
|
|
7710
8421
|
return messages.image;
|
|
7711
8422
|
}
|
|
8423
|
+
if (block.kind === "bibliography") {
|
|
8424
|
+
return messages.bibliography;
|
|
8425
|
+
}
|
|
7712
8426
|
return messages.raw;
|
|
7713
8427
|
}
|
|
7714
8428
|
function truncateSummary(value) {
|
|
@@ -7723,10 +8437,18 @@ function truncateSummary(value) {
|
|
|
7723
8437
|
}
|
|
7724
8438
|
function inlineFieldSummary(field) {
|
|
7725
8439
|
return truncateSummary(
|
|
7726
|
-
field.tokens.map((token) =>
|
|
8440
|
+
field.tokens.map((token) => {
|
|
8441
|
+
if (token.kind === "text") {
|
|
8442
|
+
return token.text;
|
|
8443
|
+
}
|
|
8444
|
+
if (token.kind === "cite") {
|
|
8445
|
+
return " [cite] ";
|
|
8446
|
+
}
|
|
8447
|
+
return " [math] ";
|
|
8448
|
+
}).join("")
|
|
7727
8449
|
);
|
|
7728
8450
|
}
|
|
7729
|
-
function blockSummary(block) {
|
|
8451
|
+
function blockSummary(block, referenceCount) {
|
|
7730
8452
|
if (block.kind === "textBlock") {
|
|
7731
8453
|
return inlineFieldSummary(block.field);
|
|
7732
8454
|
}
|
|
@@ -7739,6 +8461,9 @@ function blockSummary(block) {
|
|
|
7739
8461
|
if (block.kind === "image") {
|
|
7740
8462
|
return truncateSummary(block.value || "empty image path");
|
|
7741
8463
|
}
|
|
8464
|
+
if (block.kind === "bibliography") {
|
|
8465
|
+
return `${String(referenceCount)} ref${referenceCount === 1 ? "" : "s"}`;
|
|
8466
|
+
}
|
|
7742
8467
|
return truncateSummary(block.value);
|
|
7743
8468
|
}
|
|
7744
8469
|
function BlockEditor({
|
|
@@ -7746,46 +8471,59 @@ function BlockEditor({
|
|
|
7746
8471
|
depth = 0,
|
|
7747
8472
|
blockIndex = 0,
|
|
7748
8473
|
blockCount = 1,
|
|
8474
|
+
references = [],
|
|
7749
8475
|
documentDirection = "rtl",
|
|
8476
|
+
digitForm,
|
|
7750
8477
|
mathOutput = "svg",
|
|
7751
8478
|
equationSide = "arabic",
|
|
7752
8479
|
editableEquations = true,
|
|
8480
|
+
editableCitations = true,
|
|
7753
8481
|
uiLocale = "ar",
|
|
7754
8482
|
isCollapsed = false,
|
|
7755
8483
|
onTextChange,
|
|
7756
8484
|
onOpenMath,
|
|
7757
8485
|
onDeleteMath,
|
|
8486
|
+
onOpenCite,
|
|
8487
|
+
onDeleteCite,
|
|
7758
8488
|
onRemoveBlock,
|
|
7759
8489
|
onMoveBlock,
|
|
7760
8490
|
onToggleCollapse,
|
|
7761
8491
|
onBlockFocus,
|
|
7762
8492
|
onFieldFocus,
|
|
7763
8493
|
onMathFocus,
|
|
8494
|
+
onCiteFocus,
|
|
7764
8495
|
onFieldBlur,
|
|
7765
8496
|
onImageSrcChange,
|
|
7766
8497
|
onAddListItem,
|
|
7767
|
-
onRemoveListItem
|
|
8498
|
+
onRemoveListItem,
|
|
8499
|
+
onManageReferences
|
|
7768
8500
|
}) {
|
|
7769
8501
|
const messages = document2Messages(uiLocale);
|
|
7770
8502
|
const showChrome = depth === 0;
|
|
7771
8503
|
const chromeClass = [blockChromeClass(block), isCollapsed ? "butex-document2-widget__block--collapsed" : ""].filter(Boolean).join(" ");
|
|
7772
8504
|
const fieldProps = {
|
|
7773
8505
|
blockId: block.id,
|
|
8506
|
+
references,
|
|
7774
8507
|
documentDirection,
|
|
8508
|
+
digitForm,
|
|
7775
8509
|
mathOutput,
|
|
7776
8510
|
equationSide,
|
|
7777
8511
|
editableEquations,
|
|
8512
|
+
editableCitations,
|
|
7778
8513
|
uiLocale,
|
|
7779
8514
|
onTextChange,
|
|
7780
8515
|
onOpenMath,
|
|
7781
8516
|
onDeleteMath,
|
|
8517
|
+
onOpenCite,
|
|
8518
|
+
onDeleteCite,
|
|
7782
8519
|
onFieldFocus,
|
|
7783
8520
|
onMathFocus,
|
|
8521
|
+
onCiteFocus,
|
|
7784
8522
|
onFieldBlur
|
|
7785
8523
|
};
|
|
7786
|
-
const header = showChrome ? /* @__PURE__ */
|
|
7787
|
-
/* @__PURE__ */
|
|
7788
|
-
onToggleCollapse ? /* @__PURE__ */
|
|
8524
|
+
const header = showChrome ? /* @__PURE__ */ jsxs3("div", { className: "butex-document2-widget__block-header", onClick: () => onBlockFocus?.(block.id), children: [
|
|
8525
|
+
/* @__PURE__ */ jsxs3("span", { className: "butex-document2-widget__block-title", children: [
|
|
8526
|
+
onToggleCollapse ? /* @__PURE__ */ jsx5(
|
|
7789
8527
|
"button",
|
|
7790
8528
|
{
|
|
7791
8529
|
type: "button",
|
|
@@ -7799,78 +8537,85 @@ function BlockEditor({
|
|
|
7799
8537
|
children: isCollapsed ? "+" : "-"
|
|
7800
8538
|
}
|
|
7801
8539
|
) : null,
|
|
7802
|
-
/* @__PURE__ */
|
|
8540
|
+
/* @__PURE__ */ jsx5("span", { children: blockLabel(block, messages) })
|
|
7803
8541
|
] }),
|
|
7804
|
-
/* @__PURE__ */
|
|
7805
|
-
onMoveBlock ? /* @__PURE__ */
|
|
7806
|
-
/* @__PURE__ */
|
|
7807
|
-
/* @__PURE__ */
|
|
8542
|
+
/* @__PURE__ */ jsxs3("span", { className: "butex-document2-widget__block-actions", children: [
|
|
8543
|
+
onMoveBlock ? /* @__PURE__ */ jsxs3(Fragment, { children: [
|
|
8544
|
+
/* @__PURE__ */ jsx5("button", { type: "button", title: messages.moveUp, "aria-label": messages.moveUp, disabled: blockIndex <= 0, onClick: () => onMoveBlock(block.id, -1), children: "\u2191" }),
|
|
8545
|
+
/* @__PURE__ */ jsx5("button", { type: "button", title: messages.moveDown, "aria-label": messages.moveDown, disabled: blockIndex >= blockCount - 1, onClick: () => onMoveBlock(block.id, 1), children: "\u2193" })
|
|
7808
8546
|
] }) : null,
|
|
7809
|
-
onRemoveBlock ? /* @__PURE__ */
|
|
8547
|
+
onRemoveBlock ? /* @__PURE__ */ jsx5("button", { type: "button", className: "butex-document2-widget__button--danger", onClick: () => onRemoveBlock(block.id), children: messages.deleteBlock }) : null
|
|
7810
8548
|
] })
|
|
7811
8549
|
] }) : null;
|
|
7812
8550
|
if (isCollapsed && showChrome) {
|
|
7813
|
-
return /* @__PURE__ */
|
|
8551
|
+
return /* @__PURE__ */ jsxs3("section", { className: chromeClass, children: [
|
|
7814
8552
|
header,
|
|
7815
|
-
/* @__PURE__ */
|
|
8553
|
+
/* @__PURE__ */ jsx5("div", { className: "butex-document2-widget__block-summary", children: blockSummary(block, references.length) })
|
|
7816
8554
|
] });
|
|
7817
8555
|
}
|
|
7818
8556
|
if (block.kind === "textBlock") {
|
|
7819
|
-
return /* @__PURE__ */
|
|
8557
|
+
return /* @__PURE__ */ jsxs3("section", { className: chromeClass, children: [
|
|
7820
8558
|
header,
|
|
7821
|
-
/* @__PURE__ */
|
|
8559
|
+
/* @__PURE__ */ jsx5(InlineField, { field: block.field, ...fieldProps })
|
|
7822
8560
|
] });
|
|
7823
8561
|
}
|
|
7824
8562
|
if (block.kind === "list") {
|
|
7825
|
-
return /* @__PURE__ */
|
|
8563
|
+
return /* @__PURE__ */ jsxs3("section", { className: chromeClass, children: [
|
|
7826
8564
|
header,
|
|
7827
|
-
block.items.map((item, index) => /* @__PURE__ */
|
|
7828
|
-
/* @__PURE__ */
|
|
7829
|
-
/* @__PURE__ */
|
|
7830
|
-
/* @__PURE__ */
|
|
7831
|
-
item.blocks.map((child) => /* @__PURE__ */
|
|
8565
|
+
block.items.map((item, index) => /* @__PURE__ */ jsxs3("div", { className: "butex-document2-widget__field", dir: "rtl", children: [
|
|
8566
|
+
/* @__PURE__ */ jsx5("span", { className: "butex-document2-widget__toolbar-label", children: block.command === "\\begin{enumerate}" ? `${messages.item} ${String(index + 1)}` : messages.item }),
|
|
8567
|
+
/* @__PURE__ */ jsxs3("div", { className: "butex-document2-widget__list-item-content", dir: documentDirection, children: [
|
|
8568
|
+
/* @__PURE__ */ jsx5(InlineField, { field: item.field, ...fieldProps }),
|
|
8569
|
+
item.blocks.map((child) => /* @__PURE__ */ jsx5(
|
|
7832
8570
|
BlockEditor,
|
|
7833
8571
|
{
|
|
7834
8572
|
block: child,
|
|
7835
8573
|
depth: depth + 1,
|
|
8574
|
+
references,
|
|
7836
8575
|
documentDirection,
|
|
8576
|
+
digitForm,
|
|
7837
8577
|
mathOutput,
|
|
7838
8578
|
equationSide,
|
|
7839
8579
|
editableEquations,
|
|
8580
|
+
editableCitations,
|
|
7840
8581
|
uiLocale,
|
|
7841
8582
|
onTextChange,
|
|
7842
8583
|
onOpenMath,
|
|
7843
8584
|
onDeleteMath,
|
|
8585
|
+
onOpenCite,
|
|
8586
|
+
onDeleteCite,
|
|
7844
8587
|
onFieldFocus,
|
|
7845
8588
|
onMathFocus,
|
|
8589
|
+
onCiteFocus,
|
|
7846
8590
|
onFieldBlur,
|
|
7847
8591
|
onImageSrcChange,
|
|
7848
8592
|
onAddListItem,
|
|
7849
|
-
onRemoveListItem
|
|
8593
|
+
onRemoveListItem,
|
|
8594
|
+
onManageReferences
|
|
7850
8595
|
},
|
|
7851
8596
|
child.id
|
|
7852
8597
|
))
|
|
7853
8598
|
] }),
|
|
7854
|
-
onRemoveListItem && block.items.length > 1 ? /* @__PURE__ */
|
|
8599
|
+
onRemoveListItem && block.items.length > 1 ? /* @__PURE__ */ jsx5("div", { className: "butex-document2-widget__list-item-actions", children: /* @__PURE__ */ jsx5("button", { type: "button", className: "butex-document2-widget__button--danger", onClick: () => onRemoveListItem(block.id, item.id), children: messages.deleteItem }) }) : null
|
|
7855
8600
|
] }, item.id)),
|
|
7856
|
-
onAddListItem ? /* @__PURE__ */
|
|
8601
|
+
onAddListItem ? /* @__PURE__ */ jsx5("div", { className: "butex-document2-widget__list-footer", children: /* @__PURE__ */ jsxs3("button", { type: "button", onClick: () => onAddListItem(block.id), children: [
|
|
7857
8602
|
"+ ",
|
|
7858
8603
|
messages.addItem
|
|
7859
8604
|
] }) }) : null
|
|
7860
8605
|
] });
|
|
7861
8606
|
}
|
|
7862
8607
|
if (block.kind === "table") {
|
|
7863
|
-
return /* @__PURE__ */
|
|
8608
|
+
return /* @__PURE__ */ jsxs3("section", { className: chromeClass, children: [
|
|
7864
8609
|
header,
|
|
7865
|
-
block.rows.map((row, rowIndex) => /* @__PURE__ */
|
|
8610
|
+
block.rows.map((row, rowIndex) => /* @__PURE__ */ jsx5("div", { className: "butex-document2-widget__row", dir: documentDirection, children: row.map((cell) => /* @__PURE__ */ jsx5("div", { className: "butex-document2-widget__table-cell", dir: documentDirection, children: /* @__PURE__ */ jsx5(InlineField, { field: cell, ...fieldProps }) }, cell.id)) }, rowIndex))
|
|
7866
8611
|
] });
|
|
7867
8612
|
}
|
|
7868
8613
|
if (block.kind === "image") {
|
|
7869
8614
|
const imageFieldId = `butex-d2-img-${block.id}`;
|
|
7870
|
-
return /* @__PURE__ */
|
|
8615
|
+
return /* @__PURE__ */ jsxs3("section", { className: chromeClass, children: [
|
|
7871
8616
|
header,
|
|
7872
|
-
/* @__PURE__ */
|
|
7873
|
-
/* @__PURE__ */
|
|
8617
|
+
/* @__PURE__ */ jsx5("label", { className: "butex-document2-widget__image-src-label", htmlFor: imageFieldId, children: messages.imagePath }),
|
|
8618
|
+
/* @__PURE__ */ jsx5(
|
|
7874
8619
|
"textarea",
|
|
7875
8620
|
{
|
|
7876
8621
|
id: imageFieldId,
|
|
@@ -7895,22 +8640,112 @@ function BlockEditor({
|
|
|
7895
8640
|
)
|
|
7896
8641
|
] });
|
|
7897
8642
|
}
|
|
7898
|
-
|
|
8643
|
+
if (block.kind === "bibliography") {
|
|
8644
|
+
return /* @__PURE__ */ jsxs3("section", { className: chromeClass, children: [
|
|
8645
|
+
header,
|
|
8646
|
+
/* @__PURE__ */ jsx5("ol", { className: "butex-document2-widget__bibliography-editor", dir: documentDirection, children: references.map((reference, index) => /* @__PURE__ */ jsxs3("li", { children: [
|
|
8647
|
+
/* @__PURE__ */ jsxs3("strong", { children: [
|
|
8648
|
+
"[",
|
|
8649
|
+
index + 1,
|
|
8650
|
+
"] ",
|
|
8651
|
+
reference.key
|
|
8652
|
+
] }),
|
|
8653
|
+
/* @__PURE__ */ jsx5("span", { children: [reference.authors, reference.title, reference.venue, reference.year].filter(Boolean).join(" \u2014 ") })
|
|
8654
|
+
] }, reference.id)) }),
|
|
8655
|
+
onManageReferences ? /* @__PURE__ */ jsx5("button", { type: "button", onClick: onManageReferences, children: messages.manageReferences }) : null
|
|
8656
|
+
] });
|
|
8657
|
+
}
|
|
8658
|
+
return /* @__PURE__ */ jsxs3("section", { className: chromeClass, children: [
|
|
7899
8659
|
header,
|
|
7900
|
-
/* @__PURE__ */
|
|
8660
|
+
/* @__PURE__ */ jsx5("pre", { className: "butex-document2-widget__raw", children: block.value })
|
|
7901
8661
|
] });
|
|
7902
8662
|
}
|
|
7903
8663
|
|
|
8664
|
+
// src/react-document2/CitePickerPopover.tsx
|
|
8665
|
+
import { useEffect as useEffect2, useState as useState2 } from "react";
|
|
8666
|
+
import { jsx as jsx6, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
8667
|
+
function CitePickerPopover({
|
|
8668
|
+
open,
|
|
8669
|
+
references,
|
|
8670
|
+
initialKeys = [],
|
|
8671
|
+
uiLocale = "ar",
|
|
8672
|
+
onClose,
|
|
8673
|
+
onConfirm,
|
|
8674
|
+
onManageReferences
|
|
8675
|
+
}) {
|
|
8676
|
+
const messages = document2Messages(uiLocale);
|
|
8677
|
+
const [selected, setSelected] = useState2(initialKeys);
|
|
8678
|
+
useEffect2(() => {
|
|
8679
|
+
if (open) {
|
|
8680
|
+
setSelected(initialKeys);
|
|
8681
|
+
}
|
|
8682
|
+
}, [open, initialKeys]);
|
|
8683
|
+
if (!open) {
|
|
8684
|
+
return null;
|
|
8685
|
+
}
|
|
8686
|
+
function toggleKey(key) {
|
|
8687
|
+
setSelected((current) => current.includes(key) ? current.filter((entry) => entry !== key) : [...current, key]);
|
|
8688
|
+
}
|
|
8689
|
+
return /* @__PURE__ */ jsx6("div", { className: "butex-document2-widget__cite-picker-backdrop", role: "presentation", onClick: onClose, children: /* @__PURE__ */ jsxs4(
|
|
8690
|
+
"div",
|
|
8691
|
+
{
|
|
8692
|
+
className: "butex-document2-widget__cite-picker",
|
|
8693
|
+
role: "dialog",
|
|
8694
|
+
"aria-label": messages.citePickerTitle,
|
|
8695
|
+
onClick: (event) => event.stopPropagation(),
|
|
8696
|
+
children: [
|
|
8697
|
+
/* @__PURE__ */ jsxs4("header", { className: "butex-document2-widget__cite-picker-header", children: [
|
|
8698
|
+
/* @__PURE__ */ jsx6("strong", { children: messages.citePickerTitle }),
|
|
8699
|
+
/* @__PURE__ */ jsx6("button", { type: "button", className: "butex-document2-widget__icon-btn", title: messages.close, "aria-label": messages.close, onClick: onClose, children: "\xD7" })
|
|
8700
|
+
] }),
|
|
8701
|
+
references.length === 0 ? /* @__PURE__ */ jsx6("p", { className: "butex-document2-widget__cite-picker-empty", children: messages.noReferencesYet }) : /* @__PURE__ */ jsx6("ul", { className: "butex-document2-widget__cite-picker-list", children: references.map((reference, index) => {
|
|
8702
|
+
const checked = selected.includes(reference.key);
|
|
8703
|
+
const subtitle = [reference.authors, reference.title].filter(Boolean).join(" \u2014 ");
|
|
8704
|
+
return /* @__PURE__ */ jsx6("li", { children: /* @__PURE__ */ jsxs4("label", { className: "butex-document2-widget__cite-picker-item", children: [
|
|
8705
|
+
/* @__PURE__ */ jsx6("input", { type: "checkbox", checked, onChange: () => toggleKey(reference.key) }),
|
|
8706
|
+
/* @__PURE__ */ jsxs4("span", { children: [
|
|
8707
|
+
/* @__PURE__ */ jsxs4("strong", { children: [
|
|
8708
|
+
"[",
|
|
8709
|
+
index + 1,
|
|
8710
|
+
"] ",
|
|
8711
|
+
reference.key
|
|
8712
|
+
] }),
|
|
8713
|
+
subtitle ? /* @__PURE__ */ jsx6("span", { className: "butex-document2-widget__cite-picker-meta", children: subtitle }) : null
|
|
8714
|
+
] })
|
|
8715
|
+
] }) }, reference.id);
|
|
8716
|
+
}) }),
|
|
8717
|
+
/* @__PURE__ */ jsxs4("footer", { className: "butex-document2-widget__cite-picker-footer", children: [
|
|
8718
|
+
onManageReferences ? /* @__PURE__ */ jsx6("button", { type: "button", onClick: onManageReferences, children: messages.manageReferences }) : null,
|
|
8719
|
+
/* @__PURE__ */ jsx6("button", { type: "button", onClick: onClose, children: messages.close }),
|
|
8720
|
+
/* @__PURE__ */ jsx6(
|
|
8721
|
+
"button",
|
|
8722
|
+
{
|
|
8723
|
+
type: "button",
|
|
8724
|
+
className: "butex-document2-widget__primary-btn",
|
|
8725
|
+
disabled: selected.length === 0,
|
|
8726
|
+
onClick: () => onConfirm(selected),
|
|
8727
|
+
children: messages.insertCitation
|
|
8728
|
+
}
|
|
8729
|
+
)
|
|
8730
|
+
] })
|
|
8731
|
+
]
|
|
8732
|
+
}
|
|
8733
|
+
) });
|
|
8734
|
+
}
|
|
8735
|
+
|
|
8736
|
+
// src/react-document2/DocumentInsertToolbar.tsx
|
|
8737
|
+
import { useState as useState4 } from "react";
|
|
8738
|
+
|
|
7904
8739
|
// src/react-document2/TableInsertPopover.tsx
|
|
7905
|
-
import { useEffect as
|
|
7906
|
-
import { jsx as
|
|
8740
|
+
import { useEffect as useEffect3, useRef as useRef3, useState as useState3 } from "react";
|
|
8741
|
+
import { jsx as jsx7, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
7907
8742
|
function TableInsertPopover({ uiLocale = "ar", onConfirm }) {
|
|
7908
8743
|
const messages = document2Messages(uiLocale);
|
|
7909
|
-
const [open, setOpen] =
|
|
7910
|
-
const [rows, setRows] =
|
|
7911
|
-
const [cols, setCols] =
|
|
8744
|
+
const [open, setOpen] = useState3(false);
|
|
8745
|
+
const [rows, setRows] = useState3("3");
|
|
8746
|
+
const [cols, setCols] = useState3("3");
|
|
7912
8747
|
const rootRef = useRef3(null);
|
|
7913
|
-
|
|
8748
|
+
useEffect3(() => {
|
|
7914
8749
|
if (!open) {
|
|
7915
8750
|
return;
|
|
7916
8751
|
}
|
|
@@ -7928,8 +8763,8 @@ function TableInsertPopover({ uiLocale = "ar", onConfirm }) {
|
|
|
7928
8763
|
onConfirm(rowCount, colCount);
|
|
7929
8764
|
setOpen(false);
|
|
7930
8765
|
}
|
|
7931
|
-
return /* @__PURE__ */
|
|
7932
|
-
/* @__PURE__ */
|
|
8766
|
+
return /* @__PURE__ */ jsxs5("div", { className: "butex-document2-widget__table-popover", ref: rootRef, children: [
|
|
8767
|
+
/* @__PURE__ */ jsx7(
|
|
7933
8768
|
"button",
|
|
7934
8769
|
{
|
|
7935
8770
|
type: "button",
|
|
@@ -7942,27 +8777,38 @@ function TableInsertPopover({ uiLocale = "ar", onConfirm }) {
|
|
|
7942
8777
|
children: "\u229E"
|
|
7943
8778
|
}
|
|
7944
8779
|
),
|
|
7945
|
-
open ? /* @__PURE__ */
|
|
7946
|
-
/* @__PURE__ */
|
|
8780
|
+
open ? /* @__PURE__ */ jsxs5("div", { className: "butex-document2-widget__table-popover-panel", role: "dialog", "aria-label": messages.tableSize, children: [
|
|
8781
|
+
/* @__PURE__ */ jsxs5("label", { children: [
|
|
7947
8782
|
messages.rows,
|
|
7948
|
-
/* @__PURE__ */
|
|
8783
|
+
/* @__PURE__ */ jsx7("input", { type: "number", min: 1, max: 20, value: rows, onChange: (event) => setRows(event.currentTarget.value) })
|
|
7949
8784
|
] }),
|
|
7950
|
-
/* @__PURE__ */
|
|
8785
|
+
/* @__PURE__ */ jsxs5("label", { children: [
|
|
7951
8786
|
messages.columns,
|
|
7952
|
-
/* @__PURE__ */
|
|
8787
|
+
/* @__PURE__ */ jsx7("input", { type: "number", min: 1, max: 10, value: cols, onChange: (event) => setCols(event.currentTarget.value) })
|
|
7953
8788
|
] }),
|
|
7954
|
-
/* @__PURE__ */
|
|
8789
|
+
/* @__PURE__ */ jsx7("button", { type: "button", onClick: confirm, children: messages.insert })
|
|
7955
8790
|
] }) : null
|
|
7956
8791
|
] });
|
|
7957
8792
|
}
|
|
7958
8793
|
|
|
7959
8794
|
// src/react-document2/DocumentInsertToolbar.tsx
|
|
7960
|
-
import { jsx as
|
|
8795
|
+
import { jsx as jsx8, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
8796
|
+
var DIGIT_FORMS = ["western", "arabicIndic", "persianIndic"];
|
|
8797
|
+
function digitFormLabel(digitForm) {
|
|
8798
|
+
if (digitForm === "arabicIndic") {
|
|
8799
|
+
return "\u0664\u0665\u0666";
|
|
8800
|
+
}
|
|
8801
|
+
if (digitForm === "persianIndic") {
|
|
8802
|
+
return "\u06F4\u06F5\u06F6";
|
|
8803
|
+
}
|
|
8804
|
+
return "456";
|
|
8805
|
+
}
|
|
7961
8806
|
function DocumentInsertToolbar({
|
|
7962
8807
|
canUndo,
|
|
7963
8808
|
canRedo,
|
|
7964
8809
|
editableEquations = true,
|
|
7965
8810
|
uiLocale = "ar",
|
|
8811
|
+
digitForm = "western",
|
|
7966
8812
|
onUndo,
|
|
7967
8813
|
onRedo,
|
|
7968
8814
|
onAddSection,
|
|
@@ -7974,61 +8820,135 @@ function DocumentInsertToolbar({
|
|
|
7974
8820
|
onAddTable,
|
|
7975
8821
|
onAddList,
|
|
7976
8822
|
onAddEnumerate,
|
|
7977
|
-
onAddFigure
|
|
8823
|
+
onAddFigure,
|
|
8824
|
+
onInsertCitation,
|
|
8825
|
+
onInsertBibliography,
|
|
8826
|
+
onManageReferences,
|
|
8827
|
+
onDigitFormChange
|
|
7978
8828
|
}) {
|
|
7979
8829
|
const messages = document2Messages(uiLocale);
|
|
7980
|
-
|
|
7981
|
-
|
|
7982
|
-
|
|
7983
|
-
|
|
8830
|
+
const [digitMenuOpen, setDigitMenuOpen] = useState4(false);
|
|
8831
|
+
function digitTitle(id) {
|
|
8832
|
+
if (id === "arabicIndic") {
|
|
8833
|
+
return messages.arabicIndicDigits;
|
|
8834
|
+
}
|
|
8835
|
+
if (id === "persianIndic") {
|
|
8836
|
+
return messages.persianIndicDigits;
|
|
8837
|
+
}
|
|
8838
|
+
return messages.westernDigits;
|
|
8839
|
+
}
|
|
8840
|
+
return /* @__PURE__ */ jsxs6("div", { className: "butex-document2-widget__toolbar-insert", children: [
|
|
8841
|
+
/* @__PURE__ */ jsxs6("div", { className: "butex-document2-widget__toolbar-group", role: "group", "aria-label": messages.undoRedo, children: [
|
|
8842
|
+
/* @__PURE__ */ jsx8("button", { type: "button", className: "butex-document2-widget__icon-btn", title: `${messages.undo} (Ctrl+Z)`, "aria-label": messages.undo, disabled: !canUndo, onClick: onUndo, children: "\u21B6" }),
|
|
8843
|
+
/* @__PURE__ */ jsx8("button", { type: "button", className: "butex-document2-widget__icon-btn", title: `${messages.redo} (Ctrl+Shift+Z)`, "aria-label": messages.redo, disabled: !canRedo, onClick: onRedo, children: "\u21B7" })
|
|
7984
8844
|
] }),
|
|
7985
|
-
/* @__PURE__ */
|
|
7986
|
-
/* @__PURE__ */
|
|
7987
|
-
/* @__PURE__ */
|
|
7988
|
-
/* @__PURE__ */
|
|
7989
|
-
/* @__PURE__ */
|
|
8845
|
+
/* @__PURE__ */ jsxs6("div", { className: "butex-document2-widget__toolbar-group", role: "group", "aria-label": messages.structure, children: [
|
|
8846
|
+
/* @__PURE__ */ jsx8("button", { type: "button", className: "butex-document2-widget__icon-btn butex-document2-widget__icon-btn--h1", title: messages.addSection, "aria-label": messages.addSection, onClick: onAddSection, children: messages.sectionGlyph }),
|
|
8847
|
+
/* @__PURE__ */ jsx8("button", { type: "button", className: "butex-document2-widget__icon-btn butex-document2-widget__icon-btn--h2", title: messages.addSubsection, "aria-label": messages.addSubsection, onClick: onAddSubsection, children: messages.subsectionGlyph }),
|
|
8848
|
+
/* @__PURE__ */ jsx8("button", { type: "button", className: "butex-document2-widget__icon-btn butex-document2-widget__icon-btn--h3", title: messages.addSubsubsection, "aria-label": messages.addSubsubsection, onClick: onAddSubsubsection, children: messages.subsubsectionGlyph }),
|
|
8849
|
+
/* @__PURE__ */ jsx8("button", { type: "button", className: "butex-document2-widget__icon-btn", title: messages.addParagraph, "aria-label": messages.addParagraph, onClick: onAddParagraph, children: messages.paragraphGlyph })
|
|
7990
8850
|
] }),
|
|
7991
|
-
/* @__PURE__ */
|
|
7992
|
-
/* @__PURE__ */
|
|
7993
|
-
/* @__PURE__ */
|
|
7994
|
-
/* @__PURE__ */
|
|
7995
|
-
/* @__PURE__ */
|
|
7996
|
-
/* @__PURE__ */
|
|
7997
|
-
/* @__PURE__ */
|
|
8851
|
+
/* @__PURE__ */ jsxs6("div", { className: "butex-document2-widget__toolbar-group", role: "group", "aria-label": messages.content, children: [
|
|
8852
|
+
/* @__PURE__ */ jsx8("button", { type: "button", className: "butex-document2-widget__icon-btn", title: `${messages.inlineEquation} ($\u2026$)`, "aria-label": messages.inlineEquation, disabled: !editableEquations, onClick: onAddInlineEquation, children: /* @__PURE__ */ jsx8("span", { className: "butex-document2-widget__icon-math-inline", "aria-hidden": "true", children: "$=$" }) }),
|
|
8853
|
+
/* @__PURE__ */ jsx8("button", { type: "button", className: "butex-document2-widget__icon-btn", title: `${messages.displayEquation} (\\[\u2026\\])`, "aria-label": messages.displayEquation, disabled: !editableEquations, onClick: onAddDisplayEquation, children: /* @__PURE__ */ jsx8("span", { className: "butex-document2-widget__icon-math-display", "aria-hidden": "true", children: "\\[\xF7\\]" }) }),
|
|
8854
|
+
/* @__PURE__ */ jsx8("button", { type: "button", className: "butex-document2-widget__icon-btn", title: messages.insertCitation, "aria-label": messages.insertCitation, onClick: onInsertCitation, children: "[]" }),
|
|
8855
|
+
/* @__PURE__ */ jsx8("button", { type: "button", className: "butex-document2-widget__icon-btn", title: messages.insertBibliography, "aria-label": messages.insertBibliography, onClick: onInsertBibliography, children: "Ref" }),
|
|
8856
|
+
/* @__PURE__ */ jsx8("button", { type: "button", className: "butex-document2-widget__icon-btn", title: messages.manageReferences, "aria-label": messages.manageReferences, onClick: onManageReferences, children: "\u2630" }),
|
|
8857
|
+
/* @__PURE__ */ jsx8(TableInsertPopover, { uiLocale, onConfirm: onAddTable }),
|
|
8858
|
+
/* @__PURE__ */ jsx8("button", { type: "button", className: "butex-document2-widget__icon-btn", title: messages.bulletedList, "aria-label": messages.bulletedList, onClick: onAddList, children: "\u2022\u2261" }),
|
|
8859
|
+
/* @__PURE__ */ jsx8("button", { type: "button", className: "butex-document2-widget__icon-btn", title: messages.numberedList, "aria-label": messages.numberedList, onClick: onAddEnumerate, children: "1." }),
|
|
8860
|
+
/* @__PURE__ */ jsx8("button", { type: "button", className: "butex-document2-widget__icon-btn", title: messages.insertImage, "aria-label": messages.insertImage, onClick: onAddFigure, children: "\u{1F5BC}" }),
|
|
8861
|
+
/* @__PURE__ */ jsxs6("div", { className: "butex-document2-widget__digit-form-menu", children: [
|
|
8862
|
+
/* @__PURE__ */ jsx8(
|
|
8863
|
+
"button",
|
|
8864
|
+
{
|
|
8865
|
+
type: "button",
|
|
8866
|
+
className: "butex-document2-widget__icon-btn",
|
|
8867
|
+
title: messages.chooseDigitForm,
|
|
8868
|
+
"aria-label": messages.chooseDigitForm,
|
|
8869
|
+
"aria-expanded": digitMenuOpen,
|
|
8870
|
+
onClick: () => setDigitMenuOpen((open) => !open),
|
|
8871
|
+
children: digitFormLabel(digitForm)
|
|
8872
|
+
}
|
|
8873
|
+
),
|
|
8874
|
+
digitMenuOpen ? /* @__PURE__ */ jsx8("div", { className: "butex-document2-widget__digit-form-options", role: "listbox", "aria-label": messages.chooseDigitForm, children: DIGIT_FORMS.map((id) => /* @__PURE__ */ jsx8(
|
|
8875
|
+
"button",
|
|
8876
|
+
{
|
|
8877
|
+
type: "button",
|
|
8878
|
+
role: "option",
|
|
8879
|
+
"aria-selected": digitForm === id,
|
|
8880
|
+
title: digitTitle(id),
|
|
8881
|
+
className: "butex-document2-widget__digit-form-option",
|
|
8882
|
+
onClick: () => {
|
|
8883
|
+
onDigitFormChange(id);
|
|
8884
|
+
setDigitMenuOpen(false);
|
|
8885
|
+
},
|
|
8886
|
+
children: digitFormLabel(id)
|
|
8887
|
+
},
|
|
8888
|
+
id
|
|
8889
|
+
)) }) : null
|
|
8890
|
+
] })
|
|
7998
8891
|
] })
|
|
7999
8892
|
] });
|
|
8000
8893
|
}
|
|
8001
8894
|
|
|
8002
8895
|
// src/react-document2/DocumentPreview.tsx
|
|
8003
|
-
import { Fragment as Fragment2, jsx as
|
|
8896
|
+
import { Fragment as Fragment2, jsx as jsx9, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
8004
8897
|
function PreviewInlines({ inlines, output }) {
|
|
8005
|
-
return /* @__PURE__ */
|
|
8006
|
-
(inline
|
|
8007
|
-
|
|
8898
|
+
return /* @__PURE__ */ jsx9(Fragment2, { children: inlines.map((inline, index) => {
|
|
8899
|
+
if (inline.kind === "text") {
|
|
8900
|
+
return /* @__PURE__ */ jsx9("span", { children: inline.text }, index);
|
|
8901
|
+
}
|
|
8902
|
+
if (inline.kind === "cite") {
|
|
8903
|
+
return /* @__PURE__ */ jsx9("span", { className: "butex-document2-widget__preview-cite", children: inline.label }, inline.id);
|
|
8904
|
+
}
|
|
8905
|
+
return /* @__PURE__ */ jsx9(MathIsland, { id: inline.id, tex: inline.tex, display: inline.display, output }, inline.id);
|
|
8906
|
+
}) });
|
|
8008
8907
|
}
|
|
8009
|
-
function PreviewBlock({
|
|
8908
|
+
function PreviewBlock({
|
|
8909
|
+
block,
|
|
8910
|
+
output,
|
|
8911
|
+
resolveImageUrl
|
|
8912
|
+
}) {
|
|
8010
8913
|
if (block.kind === "heading") {
|
|
8011
8914
|
const Tag = block.level === 1 ? "h1" : block.level === 2 ? "h2" : "h3";
|
|
8012
|
-
return /* @__PURE__ */
|
|
8915
|
+
return /* @__PURE__ */ jsx9(Tag, { children: /* @__PURE__ */ jsx9(PreviewInlines, { inlines: block.inlines, output }) });
|
|
8013
8916
|
}
|
|
8014
8917
|
if (block.kind === "paragraph") {
|
|
8015
|
-
return /* @__PURE__ */
|
|
8918
|
+
return /* @__PURE__ */ jsx9("p", { children: /* @__PURE__ */ jsx9(PreviewInlines, { inlines: block.inlines, output }) });
|
|
8016
8919
|
}
|
|
8017
8920
|
if (block.kind === "list") {
|
|
8018
8921
|
const Tag = block.ordered ? "ol" : "ul";
|
|
8019
|
-
return /* @__PURE__ */
|
|
8020
|
-
/* @__PURE__ */
|
|
8021
|
-
item.blocks.map((child) => /* @__PURE__ */
|
|
8922
|
+
return /* @__PURE__ */ jsx9(Tag, { children: block.items.map((item) => /* @__PURE__ */ jsxs7("li", { children: [
|
|
8923
|
+
/* @__PURE__ */ jsx9(PreviewInlines, { inlines: item.inlines, output }),
|
|
8924
|
+
item.blocks.map((child) => /* @__PURE__ */ jsx9(PreviewBlock, { block: child, output, resolveImageUrl }, child.id))
|
|
8022
8925
|
] }, item.id)) });
|
|
8023
8926
|
}
|
|
8024
8927
|
if (block.kind === "omit") {
|
|
8025
8928
|
return null;
|
|
8026
8929
|
}
|
|
8027
8930
|
if (block.kind === "table") {
|
|
8028
|
-
return /* @__PURE__ */
|
|
8931
|
+
return /* @__PURE__ */ jsx9("table", { children: /* @__PURE__ */ jsx9("tbody", { children: block.rows.map((row, rowIndex) => /* @__PURE__ */ jsx9("tr", { children: row.map((cell, columnIndex) => /* @__PURE__ */ jsx9("td", { children: /* @__PURE__ */ jsx9(PreviewInlines, { inlines: cell, output }) }, columnIndex)) }, rowIndex)) }) });
|
|
8029
8932
|
}
|
|
8030
8933
|
if (block.kind === "image") {
|
|
8031
|
-
|
|
8934
|
+
const src = resolveImageUrl ? resolveImageUrl({ assetId: block.assetId, value: block.src }) : block.src;
|
|
8935
|
+
return /* @__PURE__ */ jsx9("img", { src, alt: "" });
|
|
8936
|
+
}
|
|
8937
|
+
if (block.kind === "bibliography") {
|
|
8938
|
+
return /* @__PURE__ */ jsx9("ol", { className: "butex-document2-widget__preview-bibliography", children: block.items.map((item) => /* @__PURE__ */ jsxs7("li", { children: [
|
|
8939
|
+
/* @__PURE__ */ jsxs7("span", { className: "butex-document2-widget__preview-bib-number", children: [
|
|
8940
|
+
item.numberLabel,
|
|
8941
|
+
"."
|
|
8942
|
+
] }),
|
|
8943
|
+
" ",
|
|
8944
|
+
/* @__PURE__ */ jsxs7("span", { children: [
|
|
8945
|
+
[item.authors, item.title, item.venue, item.year].filter(Boolean).join(", "),
|
|
8946
|
+
item.url ? /* @__PURE__ */ jsxs7(Fragment2, { children: [
|
|
8947
|
+
" ",
|
|
8948
|
+
/* @__PURE__ */ jsx9("a", { href: item.url, target: "_blank", rel: "noreferrer", children: item.url })
|
|
8949
|
+
] }) : null
|
|
8950
|
+
] })
|
|
8951
|
+
] }, item.id)) });
|
|
8032
8952
|
}
|
|
8033
8953
|
return null;
|
|
8034
8954
|
}
|
|
@@ -8036,23 +8956,24 @@ function DocumentPreview({
|
|
|
8036
8956
|
blocks,
|
|
8037
8957
|
output,
|
|
8038
8958
|
documentDirection = "rtl",
|
|
8039
|
-
uiLocale = "ar"
|
|
8959
|
+
uiLocale = "ar",
|
|
8960
|
+
resolveImageUrl
|
|
8040
8961
|
}) {
|
|
8041
8962
|
const messages = document2Messages(uiLocale);
|
|
8042
|
-
return /* @__PURE__ */
|
|
8963
|
+
return /* @__PURE__ */ jsx9("div", { className: "butex-document2-widget__preview", dir: documentDirection, children: blocks.length === 0 ? /* @__PURE__ */ jsx9("p", { children: messages.emptyDocument }) : blocks.map((block) => /* @__PURE__ */ jsx9(PreviewBlock, { block, output, resolveImageUrl }, block.id)) });
|
|
8043
8964
|
}
|
|
8044
8965
|
|
|
8045
8966
|
// src/react-document2/EquationDrawer.tsx
|
|
8046
|
-
import { useEffect as
|
|
8967
|
+
import { useEffect as useEffect5, useRef as useRef5 } from "react";
|
|
8047
8968
|
|
|
8048
8969
|
// src/react/ButexEditor.tsx
|
|
8049
8970
|
import {
|
|
8050
8971
|
forwardRef,
|
|
8051
8972
|
useCallback,
|
|
8052
|
-
useEffect as
|
|
8973
|
+
useEffect as useEffect4,
|
|
8053
8974
|
useImperativeHandle,
|
|
8054
8975
|
useRef as useRef4,
|
|
8055
|
-
useState as
|
|
8976
|
+
useState as useState5
|
|
8056
8977
|
} from "react";
|
|
8057
8978
|
|
|
8058
8979
|
// src/react/widgetChromeCss.ts
|
|
@@ -8986,7 +9907,7 @@ function uiLocaleDirection(locale) {
|
|
|
8986
9907
|
}
|
|
8987
9908
|
|
|
8988
9909
|
// src/react/ButexEditor.tsx
|
|
8989
|
-
import { Fragment as Fragment3, jsx as
|
|
9910
|
+
import { Fragment as Fragment3, jsx as jsx10, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
8990
9911
|
var DIGIT_FORM_OPTIONS = [
|
|
8991
9912
|
{ id: "western", label: "456" },
|
|
8992
9913
|
{ id: "arabicIndic", label: "\u0664\u0665\u0666" },
|
|
@@ -9028,7 +9949,7 @@ function matrixSizeLabel(rows, columns, messages) {
|
|
|
9028
9949
|
function clampMatrixSize(value) {
|
|
9029
9950
|
return Math.max(1, Math.min(12, Math.trunc(value)));
|
|
9030
9951
|
}
|
|
9031
|
-
function
|
|
9952
|
+
function digitFormLabel2(digitForm) {
|
|
9032
9953
|
return DIGIT_FORM_OPTIONS.find((option) => option.id === digitForm)?.label ?? "456";
|
|
9033
9954
|
}
|
|
9034
9955
|
function characterFontOption(fontId) {
|
|
@@ -9069,16 +9990,16 @@ function renderArabicCommandLabel(command) {
|
|
|
9069
9990
|
if (command.id !== "ln") {
|
|
9070
9991
|
return command.arabicLabel;
|
|
9071
9992
|
}
|
|
9072
|
-
return /* @__PURE__ */
|
|
9073
|
-
/* @__PURE__ */
|
|
9074
|
-
/* @__PURE__ */
|
|
9993
|
+
return /* @__PURE__ */ jsxs8("span", { className: "function-command-label-with-sub", "aria-hidden": "true", children: [
|
|
9994
|
+
/* @__PURE__ */ jsx10("span", { className: "function-command-label-with-sub__base", children: command.arabicLabel }),
|
|
9995
|
+
/* @__PURE__ */ jsx10("span", { className: "function-command-label-with-sub__sub", children: "\u0647\u0640" })
|
|
9075
9996
|
] });
|
|
9076
9997
|
}
|
|
9077
9998
|
function renderOperatorCommandLabel(command) {
|
|
9078
9999
|
if (!command.svg_path) {
|
|
9079
10000
|
return command.Label;
|
|
9080
10001
|
}
|
|
9081
|
-
return /* @__PURE__ */
|
|
10002
|
+
return /* @__PURE__ */ jsx10(
|
|
9082
10003
|
"span",
|
|
9083
10004
|
{
|
|
9084
10005
|
className: "operator-command-svg-label",
|
|
@@ -9094,7 +10015,7 @@ function renderOperatorMenuButtonLabel(command, fallback) {
|
|
|
9094
10015
|
if (!command) {
|
|
9095
10016
|
return fallback;
|
|
9096
10017
|
}
|
|
9097
|
-
return /* @__PURE__ */
|
|
10018
|
+
return /* @__PURE__ */ jsx10("span", { className: shouldMirrorOperatorDisplay(command) ? "operator-command-label operator-command-label--mirror" : "operator-command-label", children: renderOperatorCommandLabel(command) });
|
|
9098
10019
|
}
|
|
9099
10020
|
function passiveTreeText(session, messages) {
|
|
9100
10021
|
const passive = session.activeSide === "arabic" ? session.englishTree : session.arabicTree;
|
|
@@ -9129,32 +10050,32 @@ var ButexEditor = forwardRef(
|
|
|
9129
10050
|
const onSessionChangeRef = useRef4(onSessionChange);
|
|
9130
10051
|
onSessionChangeRef.current = onSessionChange;
|
|
9131
10052
|
const debugBodyHiddenRef = useRef4(false);
|
|
9132
|
-
const [debugBodyHidden, setDebugBodyHidden] =
|
|
10053
|
+
const [debugBodyHidden, setDebugBodyHidden] = useState5(false);
|
|
9133
10054
|
debugBodyHiddenRef.current = debugBodyHidden;
|
|
9134
|
-
const [digitMenuOpen, setDigitMenuOpen] =
|
|
9135
|
-
const [characterFontMenuOpen, setCharacterFontMenuOpen] =
|
|
9136
|
-
const [delimiterMenuOpen, setDelimiterMenuOpen] =
|
|
9137
|
-
const [matrixMenuOpen, setMatrixMenuOpen] =
|
|
9138
|
-
const [spacingMenuOpen, setSpacingMenuOpen] =
|
|
9139
|
-
const [functionMenuOpen, setFunctionMenuOpen] =
|
|
9140
|
-
const [limitsSeriesMenuOpen, setLimitsSeriesMenuOpen] =
|
|
9141
|
-
const [function2MenuOpen, setFunction2MenuOpen] =
|
|
9142
|
-
const [derivativeMenuOpen, setDerivativeMenuOpen] =
|
|
9143
|
-
const [groupMenuOpen, setGroupMenuOpen] =
|
|
9144
|
-
const [operatorMenuOpen, setOperatorMenuOpen] =
|
|
9145
|
-
const [operator2MenuOpen, setOperator2MenuOpen] =
|
|
9146
|
-
const [operator3MenuOpen, setOperator3MenuOpen] =
|
|
9147
|
-
const [dotMenuOpen, setDotMenuOpen] =
|
|
9148
|
-
const [integralMenuOpen, setIntegralMenuOpen] =
|
|
9149
|
-
const [selectedDigitForm2, setSelectedDigitForm] =
|
|
9150
|
-
const [selectedCharacterFont, setSelectedCharacterFont] =
|
|
9151
|
-
const [activeEditorSide, setActiveEditorSide] =
|
|
9152
|
-
const [envPaletteMode, setEnvPaletteMode] =
|
|
9153
|
-
const [matrixStyle, setMatrixStyle] =
|
|
9154
|
-
const [matrixRows, setMatrixRows] =
|
|
9155
|
-
const [matrixColumns, setMatrixColumns] =
|
|
9156
|
-
const [matrixHover, setMatrixHover] =
|
|
9157
|
-
const [arrayAlignmentColumn, setArrayAlignmentColumn] =
|
|
10055
|
+
const [digitMenuOpen, setDigitMenuOpen] = useState5(false);
|
|
10056
|
+
const [characterFontMenuOpen, setCharacterFontMenuOpen] = useState5(false);
|
|
10057
|
+
const [delimiterMenuOpen, setDelimiterMenuOpen] = useState5(false);
|
|
10058
|
+
const [matrixMenuOpen, setMatrixMenuOpen] = useState5(false);
|
|
10059
|
+
const [spacingMenuOpen, setSpacingMenuOpen] = useState5(false);
|
|
10060
|
+
const [functionMenuOpen, setFunctionMenuOpen] = useState5(false);
|
|
10061
|
+
const [limitsSeriesMenuOpen, setLimitsSeriesMenuOpen] = useState5(false);
|
|
10062
|
+
const [function2MenuOpen, setFunction2MenuOpen] = useState5(false);
|
|
10063
|
+
const [derivativeMenuOpen, setDerivativeMenuOpen] = useState5(false);
|
|
10064
|
+
const [groupMenuOpen, setGroupMenuOpen] = useState5(false);
|
|
10065
|
+
const [operatorMenuOpen, setOperatorMenuOpen] = useState5(false);
|
|
10066
|
+
const [operator2MenuOpen, setOperator2MenuOpen] = useState5(false);
|
|
10067
|
+
const [operator3MenuOpen, setOperator3MenuOpen] = useState5(false);
|
|
10068
|
+
const [dotMenuOpen, setDotMenuOpen] = useState5(false);
|
|
10069
|
+
const [integralMenuOpen, setIntegralMenuOpen] = useState5(false);
|
|
10070
|
+
const [selectedDigitForm2, setSelectedDigitForm] = useState5("western");
|
|
10071
|
+
const [selectedCharacterFont, setSelectedCharacterFont] = useState5("default");
|
|
10072
|
+
const [activeEditorSide, setActiveEditorSide] = useState5("arabic");
|
|
10073
|
+
const [envPaletteMode, setEnvPaletteMode] = useState5("matrix");
|
|
10074
|
+
const [matrixStyle, setMatrixStyle] = useState5("pmatrix");
|
|
10075
|
+
const [matrixRows, setMatrixRows] = useState5(2);
|
|
10076
|
+
const [matrixColumns, setMatrixColumns] = useState5(2);
|
|
10077
|
+
const [matrixHover, setMatrixHover] = useState5(null);
|
|
10078
|
+
const [arrayAlignmentColumn, setArrayAlignmentColumn] = useState5(1);
|
|
9158
10079
|
useImperativeHandle(ref, () => ({
|
|
9159
10080
|
getRuntime: () => runtimeRef.current
|
|
9160
10081
|
}));
|
|
@@ -9210,7 +10131,7 @@ ${arabic || currentMessages.empty}`;
|
|
|
9210
10131
|
}, []);
|
|
9211
10132
|
const updatePreviewRef = useRef4(updatePreview);
|
|
9212
10133
|
updatePreviewRef.current = updatePreview;
|
|
9213
|
-
|
|
10134
|
+
useEffect4(() => {
|
|
9214
10135
|
injectWidgetChromeCss();
|
|
9215
10136
|
injectBuTeXEditorStyles(typeof document !== "undefined" ? document : void 0);
|
|
9216
10137
|
const surfaceEl = surfaceRef.current;
|
|
@@ -9266,7 +10187,7 @@ ${arabic || currentMessages.empty}`;
|
|
|
9266
10187
|
runtimeRef.current = null;
|
|
9267
10188
|
};
|
|
9268
10189
|
}, []);
|
|
9269
|
-
|
|
10190
|
+
useEffect4(() => {
|
|
9270
10191
|
runtimeRef.current?.setUiLocale(uiLocale);
|
|
9271
10192
|
const session = runtimeRef.current?.getSession();
|
|
9272
10193
|
if (session) {
|
|
@@ -9285,24 +10206,24 @@ ${arabic || currentMessages.empty}`;
|
|
|
9285
10206
|
runtimeRef.current?.insertMatrixEnv(matrixStyle, rows, columns);
|
|
9286
10207
|
}
|
|
9287
10208
|
}
|
|
9288
|
-
return /* @__PURE__ */
|
|
10209
|
+
return /* @__PURE__ */ jsx10(
|
|
9289
10210
|
"div",
|
|
9290
10211
|
{
|
|
9291
10212
|
ref: wrapperRef,
|
|
9292
10213
|
className: `butex-widget ${className ?? ""}`.trim(),
|
|
9293
10214
|
dir: uiLocaleDirection(uiLocale),
|
|
9294
10215
|
lang: uiLocale,
|
|
9295
|
-
children: /* @__PURE__ */
|
|
9296
|
-
/* @__PURE__ */
|
|
9297
|
-
/* @__PURE__ */
|
|
9298
|
-
/* @__PURE__ */
|
|
9299
|
-
/* @__PURE__ */
|
|
9300
|
-
/* @__PURE__ */
|
|
10216
|
+
children: /* @__PURE__ */ jsxs8("div", { className: "butex-widget-layout", children: [
|
|
10217
|
+
/* @__PURE__ */ jsxs8("section", { className: "panel", children: [
|
|
10218
|
+
/* @__PURE__ */ jsxs8("div", { className: "toolbar", children: [
|
|
10219
|
+
/* @__PURE__ */ jsxs8("div", { className: "toolbar-group toolbar-history", role: "group", "aria-label": messages.undoRedo, children: [
|
|
10220
|
+
/* @__PURE__ */ jsx10("button", { ref: undoBtnRef, id: "btn-undo", type: "button", className: "icon-btn", title: messages.undo, "aria-label": messages.undo, children: "\u21B7" }),
|
|
10221
|
+
/* @__PURE__ */ jsx10("button", { ref: redoBtnRef, id: "btn-redo", type: "button", className: "icon-btn", title: messages.redo, "aria-label": messages.redo, children: "\u21B6" })
|
|
9301
10222
|
] }),
|
|
9302
|
-
/* @__PURE__ */
|
|
9303
|
-
/* @__PURE__ */
|
|
9304
|
-
/* @__PURE__ */
|
|
9305
|
-
/* @__PURE__ */
|
|
10223
|
+
/* @__PURE__ */ jsxs8("div", { className: "toolbar-group toolbar-clipboard", role: "group", "aria-label": messages.clipboard, children: [
|
|
10224
|
+
/* @__PURE__ */ jsx10("button", { ref: copyBtnRef, id: "btn-copy", type: "button", className: "icon-btn", title: messages.copy, "aria-label": messages.copy, disabled: true, children: "\u29C9" }),
|
|
10225
|
+
/* @__PURE__ */ jsx10("button", { ref: cutBtnRef, id: "btn-cut", type: "button", className: "icon-btn", title: messages.cut, "aria-label": messages.cut, disabled: true, children: "\u2702" }),
|
|
10226
|
+
/* @__PURE__ */ jsx10(
|
|
9306
10227
|
"button",
|
|
9307
10228
|
{
|
|
9308
10229
|
id: "btn-paste",
|
|
@@ -9319,9 +10240,9 @@ ${arabic || currentMessages.empty}`;
|
|
|
9319
10240
|
}
|
|
9320
10241
|
)
|
|
9321
10242
|
] }),
|
|
9322
|
-
/* @__PURE__ */
|
|
9323
|
-
/* @__PURE__ */
|
|
9324
|
-
/* @__PURE__ */
|
|
10243
|
+
/* @__PURE__ */ jsx10("div", { className: "toolbar-group toolbar-settings", role: "group", "aria-label": messages.editorSettings, children: /* @__PURE__ */ jsx10("button", { className: "icon-btn accent", type: "button", title: messages.toggleSide, "aria-label": messages.toggleSide, onClick: () => runtimeRef.current?.toggleSide(), children: "\u21C4" }) }),
|
|
10244
|
+
/* @__PURE__ */ jsxs8("div", { className: "toolbar-group toolbar-structures", role: "group", "aria-label": messages.structures, children: [
|
|
10245
|
+
/* @__PURE__ */ jsxs8(
|
|
9325
10246
|
"div",
|
|
9326
10247
|
{
|
|
9327
10248
|
className: "delimiter-command-menu",
|
|
@@ -9332,7 +10253,7 @@ ${arabic || currentMessages.empty}`;
|
|
|
9332
10253
|
}
|
|
9333
10254
|
},
|
|
9334
10255
|
children: [
|
|
9335
|
-
/* @__PURE__ */
|
|
10256
|
+
/* @__PURE__ */ jsx10(
|
|
9336
10257
|
"button",
|
|
9337
10258
|
{
|
|
9338
10259
|
className: "icon-btn delimiter-command-btn",
|
|
@@ -9345,8 +10266,8 @@ ${arabic || currentMessages.empty}`;
|
|
|
9345
10266
|
children: "()"
|
|
9346
10267
|
}
|
|
9347
10268
|
),
|
|
9348
|
-
/* @__PURE__ */
|
|
9349
|
-
/* @__PURE__ */
|
|
10269
|
+
/* @__PURE__ */ jsxs8("div", { className: "delimiter-command-options", role: "listbox", "aria-label": messages.insertDelimiters, hidden: !delimiterMenuOpen, children: [
|
|
10270
|
+
/* @__PURE__ */ jsx10(
|
|
9350
10271
|
"button",
|
|
9351
10272
|
{
|
|
9352
10273
|
className: "delimiter-command-option",
|
|
@@ -9364,7 +10285,7 @@ ${arabic || currentMessages.empty}`;
|
|
|
9364
10285
|
children: "()"
|
|
9365
10286
|
}
|
|
9366
10287
|
),
|
|
9367
|
-
/* @__PURE__ */
|
|
10288
|
+
/* @__PURE__ */ jsx10(
|
|
9368
10289
|
"button",
|
|
9369
10290
|
{
|
|
9370
10291
|
className: "delimiter-command-option",
|
|
@@ -9382,7 +10303,7 @@ ${arabic || currentMessages.empty}`;
|
|
|
9382
10303
|
children: "[]"
|
|
9383
10304
|
}
|
|
9384
10305
|
),
|
|
9385
|
-
/* @__PURE__ */
|
|
10306
|
+
/* @__PURE__ */ jsx10(
|
|
9386
10307
|
"button",
|
|
9387
10308
|
{
|
|
9388
10309
|
className: "delimiter-command-option",
|
|
@@ -9404,19 +10325,19 @@ ${arabic || currentMessages.empty}`;
|
|
|
9404
10325
|
]
|
|
9405
10326
|
}
|
|
9406
10327
|
),
|
|
9407
|
-
/* @__PURE__ */
|
|
10328
|
+
/* @__PURE__ */ jsx10("button", { id: "insert-frac", className: "icon-btn frac-icon-btn", type: "button", title: messages.insertFraction, "aria-label": messages.insertFraction, onClick: () => {
|
|
9408
10329
|
runtimeRef.current?.insertFraction();
|
|
9409
10330
|
focusSurface();
|
|
9410
|
-
}, children: /* @__PURE__ */
|
|
9411
|
-
/* @__PURE__ */
|
|
9412
|
-
/* @__PURE__ */
|
|
10331
|
+
}, children: /* @__PURE__ */ jsxs8("span", { className: "toolbar-frac-icon", "aria-hidden": "true", children: [
|
|
10332
|
+
/* @__PURE__ */ jsx10("span", { children: "\u0623" }),
|
|
10333
|
+
/* @__PURE__ */ jsx10("span", { children: "\u0628" })
|
|
9413
10334
|
] }) }),
|
|
9414
|
-
/* @__PURE__ */
|
|
10335
|
+
/* @__PURE__ */ jsx10("button", { id: "insert-sqrt", className: "icon-btn", type: "button", title: messages.insertRoot, "aria-label": messages.insertRoot, onClick: () => {
|
|
9415
10336
|
runtimeRef.current?.insertSqrt();
|
|
9416
10337
|
focusSurface();
|
|
9417
|
-
}, children: /* @__PURE__ */
|
|
10338
|
+
}, children: /* @__PURE__ */ jsx10("span", { className: "toolbar-sqrt-icon", "aria-hidden": "true", children: "\u221A" }) })
|
|
9418
10339
|
] }),
|
|
9419
|
-
/* @__PURE__ */
|
|
10340
|
+
/* @__PURE__ */ jsx10("div", { className: "toolbar-group toolbar-environments", role: "group", "aria-label": messages.environments, children: /* @__PURE__ */ jsxs8(
|
|
9420
10341
|
"div",
|
|
9421
10342
|
{
|
|
9422
10343
|
className: "matrix-command-menu",
|
|
@@ -9427,7 +10348,7 @@ ${arabic || currentMessages.empty}`;
|
|
|
9427
10348
|
}
|
|
9428
10349
|
},
|
|
9429
10350
|
children: [
|
|
9430
|
-
/* @__PURE__ */
|
|
10351
|
+
/* @__PURE__ */ jsx10(
|
|
9431
10352
|
"button",
|
|
9432
10353
|
{
|
|
9433
10354
|
className: "icon-btn matrix-command-btn",
|
|
@@ -9437,20 +10358,20 @@ ${arabic || currentMessages.empty}`;
|
|
|
9437
10358
|
"aria-haspopup": "dialog",
|
|
9438
10359
|
"aria-expanded": matrixMenuOpen,
|
|
9439
10360
|
onClick: () => setMatrixMenuOpen((open) => !open),
|
|
9440
|
-
children: /* @__PURE__ */
|
|
9441
|
-
/* @__PURE__ */
|
|
9442
|
-
/* @__PURE__ */
|
|
9443
|
-
/* @__PURE__ */
|
|
9444
|
-
/* @__PURE__ */
|
|
10361
|
+
children: /* @__PURE__ */ jsxs8("span", { className: "toolbar-matrix-icon", "aria-hidden": "true", children: [
|
|
10362
|
+
/* @__PURE__ */ jsx10("span", {}),
|
|
10363
|
+
/* @__PURE__ */ jsx10("span", {}),
|
|
10364
|
+
/* @__PURE__ */ jsx10("span", {}),
|
|
10365
|
+
/* @__PURE__ */ jsx10("span", {})
|
|
9445
10366
|
] })
|
|
9446
10367
|
}
|
|
9447
10368
|
),
|
|
9448
|
-
/* @__PURE__ */
|
|
9449
|
-
/* @__PURE__ */
|
|
10369
|
+
/* @__PURE__ */ jsxs8("div", { className: "matrix-command-popover", role: "dialog", "aria-label": messages.insertEnvironment, hidden: !matrixMenuOpen, children: [
|
|
10370
|
+
/* @__PURE__ */ jsx10("div", { className: "matrix-style-options", role: "listbox", "aria-label": messages.environmentType, children: [
|
|
9450
10371
|
{ id: "matrix", label: messages.matrix },
|
|
9451
10372
|
{ id: "array", label: messages.array },
|
|
9452
10373
|
{ id: "aligned", label: messages.aligned }
|
|
9453
|
-
].map((option) => /* @__PURE__ */
|
|
10374
|
+
].map((option) => /* @__PURE__ */ jsx10(
|
|
9454
10375
|
"button",
|
|
9455
10376
|
{
|
|
9456
10377
|
type: "button",
|
|
@@ -9468,7 +10389,7 @@ ${arabic || currentMessages.empty}`;
|
|
|
9468
10389
|
},
|
|
9469
10390
|
option.id
|
|
9470
10391
|
)) }),
|
|
9471
|
-
envPaletteMode === "matrix" ? /* @__PURE__ */
|
|
10392
|
+
envPaletteMode === "matrix" ? /* @__PURE__ */ jsx10("div", { className: "matrix-style-options", role: "listbox", "aria-label": messages.matrixType, children: MATRIX_STYLES.map((style) => /* @__PURE__ */ jsx10(
|
|
9472
10393
|
"button",
|
|
9473
10394
|
{
|
|
9474
10395
|
type: "button",
|
|
@@ -9484,15 +10405,15 @@ ${arabic || currentMessages.empty}`;
|
|
|
9484
10405
|
},
|
|
9485
10406
|
style.id
|
|
9486
10407
|
)) }) : null,
|
|
9487
|
-
/* @__PURE__ */
|
|
9488
|
-
/* @__PURE__ */
|
|
10408
|
+
/* @__PURE__ */ jsx10("div", { className: "matrix-size-readout", children: matrixHover ? matrixSizeLabel(matrixHover.rows, matrixHover.columns, messages) : matrixSizeLabel(matrixRows, matrixColumns, messages) }),
|
|
10409
|
+
/* @__PURE__ */ jsx10("div", { className: "matrix-grid-picker", "aria-label": messages.chooseEnvironmentSize, children: Array.from(
|
|
9489
10410
|
{ length: 8 },
|
|
9490
10411
|
(_, rowIndex) => Array.from({ length: 8 }, (_2, columnIndex) => {
|
|
9491
10412
|
const rows = rowIndex + 1;
|
|
9492
10413
|
const columns = columnIndex + 1;
|
|
9493
10414
|
const activeRows = matrixHover?.rows ?? matrixRows;
|
|
9494
10415
|
const activeColumns = matrixHover?.columns ?? matrixColumns;
|
|
9495
|
-
return /* @__PURE__ */
|
|
10416
|
+
return /* @__PURE__ */ jsx10(
|
|
9496
10417
|
"button",
|
|
9497
10418
|
{
|
|
9498
10419
|
type: "button",
|
|
@@ -9514,10 +10435,10 @@ ${arabic || currentMessages.empty}`;
|
|
|
9514
10435
|
);
|
|
9515
10436
|
})
|
|
9516
10437
|
) }),
|
|
9517
|
-
/* @__PURE__ */
|
|
9518
|
-
/* @__PURE__ */
|
|
10438
|
+
/* @__PURE__ */ jsxs8("div", { className: "matrix-custom-size", children: [
|
|
10439
|
+
/* @__PURE__ */ jsxs8("label", { children: [
|
|
9519
10440
|
messages.row,
|
|
9520
|
-
/* @__PURE__ */
|
|
10441
|
+
/* @__PURE__ */ jsx10(
|
|
9521
10442
|
"input",
|
|
9522
10443
|
{
|
|
9523
10444
|
type: "number",
|
|
@@ -9528,9 +10449,9 @@ ${arabic || currentMessages.empty}`;
|
|
|
9528
10449
|
}
|
|
9529
10450
|
)
|
|
9530
10451
|
] }),
|
|
9531
|
-
/* @__PURE__ */
|
|
10452
|
+
/* @__PURE__ */ jsxs8("label", { children: [
|
|
9532
10453
|
messages.column,
|
|
9533
|
-
/* @__PURE__ */
|
|
10454
|
+
/* @__PURE__ */ jsx10(
|
|
9534
10455
|
"input",
|
|
9535
10456
|
{
|
|
9536
10457
|
type: "number",
|
|
@@ -9541,7 +10462,7 @@ ${arabic || currentMessages.empty}`;
|
|
|
9541
10462
|
}
|
|
9542
10463
|
)
|
|
9543
10464
|
] }),
|
|
9544
|
-
/* @__PURE__ */
|
|
10465
|
+
/* @__PURE__ */ jsx10(
|
|
9545
10466
|
"button",
|
|
9546
10467
|
{
|
|
9547
10468
|
type: "button",
|
|
@@ -9559,12 +10480,12 @@ ${arabic || currentMessages.empty}`;
|
|
|
9559
10480
|
}
|
|
9560
10481
|
)
|
|
9561
10482
|
] }),
|
|
9562
|
-
/* @__PURE__ */
|
|
9563
|
-
envPaletteMode === "matrix" ? /* @__PURE__ */
|
|
9564
|
-
envPaletteMode === "array" ? /* @__PURE__ */
|
|
9565
|
-
/* @__PURE__ */
|
|
10483
|
+
/* @__PURE__ */ jsxs8("div", { className: "matrix-edit-actions", "aria-label": messages.editSelectedEnvironment, children: [
|
|
10484
|
+
envPaletteMode === "matrix" ? /* @__PURE__ */ jsx10("button", { type: "button", title: messages.applySelectedMatrixStyle, onMouseDown: (event) => event.preventDefault(), onClick: () => runtimeRef.current?.setMatrixEnvStyle(matrixStyle), children: messages.applyStyle }) : null,
|
|
10485
|
+
envPaletteMode === "array" ? /* @__PURE__ */ jsxs8(Fragment3, { children: [
|
|
10486
|
+
/* @__PURE__ */ jsxs8("label", { children: [
|
|
9566
10487
|
messages.column,
|
|
9567
|
-
/* @__PURE__ */
|
|
10488
|
+
/* @__PURE__ */ jsx10(
|
|
9568
10489
|
"input",
|
|
9569
10490
|
{
|
|
9570
10491
|
type: "number",
|
|
@@ -9575,7 +10496,7 @@ ${arabic || currentMessages.empty}`;
|
|
|
9575
10496
|
}
|
|
9576
10497
|
)
|
|
9577
10498
|
] }),
|
|
9578
|
-
ARRAY_ALIGNMENTS.map((alignment) => /* @__PURE__ */
|
|
10499
|
+
ARRAY_ALIGNMENTS.map((alignment) => /* @__PURE__ */ jsx10(
|
|
9579
10500
|
"button",
|
|
9580
10501
|
{
|
|
9581
10502
|
type: "button",
|
|
@@ -9587,19 +10508,19 @@ ${arabic || currentMessages.empty}`;
|
|
|
9587
10508
|
alignment.id
|
|
9588
10509
|
))
|
|
9589
10510
|
] }) : null,
|
|
9590
|
-
/* @__PURE__ */
|
|
10511
|
+
/* @__PURE__ */ jsxs8("button", { type: "button", title: messages.addRow, onMouseDown: (event) => event.preventDefault(), onClick: () => runtimeRef.current?.addMatrixRow(), children: [
|
|
9591
10512
|
"+",
|
|
9592
10513
|
messages.row
|
|
9593
10514
|
] }),
|
|
9594
|
-
/* @__PURE__ */
|
|
10515
|
+
/* @__PURE__ */ jsxs8("button", { type: "button", title: messages.removeRow, onMouseDown: (event) => event.preventDefault(), onClick: () => runtimeRef.current?.removeMatrixRow(), children: [
|
|
9595
10516
|
"-",
|
|
9596
10517
|
messages.row
|
|
9597
10518
|
] }),
|
|
9598
|
-
/* @__PURE__ */
|
|
10519
|
+
/* @__PURE__ */ jsxs8("button", { type: "button", title: messages.addColumn, onMouseDown: (event) => event.preventDefault(), onClick: () => runtimeRef.current?.addMatrixColumn(), children: [
|
|
9599
10520
|
"+",
|
|
9600
10521
|
messages.column
|
|
9601
10522
|
] }),
|
|
9602
|
-
/* @__PURE__ */
|
|
10523
|
+
/* @__PURE__ */ jsxs8("button", { type: "button", title: messages.removeColumn, onMouseDown: (event) => event.preventDefault(), onClick: () => runtimeRef.current?.removeMatrixColumn(), children: [
|
|
9603
10524
|
"-",
|
|
9604
10525
|
messages.column
|
|
9605
10526
|
] })
|
|
@@ -9608,7 +10529,7 @@ ${arabic || currentMessages.empty}`;
|
|
|
9608
10529
|
]
|
|
9609
10530
|
}
|
|
9610
10531
|
) }),
|
|
9611
|
-
/* @__PURE__ */
|
|
10532
|
+
/* @__PURE__ */ jsx10("div", { className: "toolbar-group toolbar-settings", role: "group", "aria-label": messages.spaces, children: /* @__PURE__ */ jsxs8(
|
|
9612
10533
|
"div",
|
|
9613
10534
|
{
|
|
9614
10535
|
className: `spacing-command-menu spacing-command-menu--${activeEditorSide}`,
|
|
@@ -9619,7 +10540,7 @@ ${arabic || currentMessages.empty}`;
|
|
|
9619
10540
|
}
|
|
9620
10541
|
},
|
|
9621
10542
|
children: [
|
|
9622
|
-
/* @__PURE__ */
|
|
10543
|
+
/* @__PURE__ */ jsx10(
|
|
9623
10544
|
"button",
|
|
9624
10545
|
{
|
|
9625
10546
|
className: "icon-btn spacing-command-btn",
|
|
@@ -9629,13 +10550,13 @@ ${arabic || currentMessages.empty}`;
|
|
|
9629
10550
|
"aria-haspopup": "listbox",
|
|
9630
10551
|
"aria-expanded": spacingMenuOpen,
|
|
9631
10552
|
onClick: () => setSpacingMenuOpen((open) => !open),
|
|
9632
|
-
children: /* @__PURE__ */
|
|
9633
|
-
/* @__PURE__ */
|
|
9634
|
-
/* @__PURE__ */
|
|
10553
|
+
children: /* @__PURE__ */ jsxs8("span", { className: "spacing-command-glyph spacing-command-glyph--positive spacing-command-glyph--level-2", "aria-hidden": "true", children: [
|
|
10554
|
+
/* @__PURE__ */ jsx10("span", { className: "spacing-command-glyph__bar" }),
|
|
10555
|
+
/* @__PURE__ */ jsx10("span", { className: "spacing-command-glyph__arrow", children: activeEditorSide === "arabic" ? "\u2190" : "\u2192" })
|
|
9635
10556
|
] })
|
|
9636
10557
|
}
|
|
9637
10558
|
),
|
|
9638
|
-
/* @__PURE__ */
|
|
10559
|
+
/* @__PURE__ */ jsx10("div", { className: "spacing-command-options", role: "listbox", "aria-label": messages.insertSpace, hidden: !spacingMenuOpen, children: SPACING_COMMANDS.map((command) => /* @__PURE__ */ jsxs8(
|
|
9639
10560
|
"button",
|
|
9640
10561
|
{
|
|
9641
10562
|
type: "button",
|
|
@@ -9649,12 +10570,12 @@ ${arabic || currentMessages.empty}`;
|
|
|
9649
10570
|
focusSurface();
|
|
9650
10571
|
},
|
|
9651
10572
|
children: [
|
|
9652
|
-
/* @__PURE__ */
|
|
9653
|
-
command.spacing.direction === "negative" ? /* @__PURE__ */
|
|
9654
|
-
/* @__PURE__ */
|
|
9655
|
-
command.spacing.direction === "positive" ? /* @__PURE__ */
|
|
10573
|
+
/* @__PURE__ */ jsxs8("span", { className: `spacing-command-glyph spacing-command-glyph--${command.spacing.direction} spacing-command-glyph--level-${String(command.spacing.level)}`, "aria-hidden": "true", children: [
|
|
10574
|
+
command.spacing.direction === "negative" ? /* @__PURE__ */ jsx10("span", { className: "spacing-command-glyph__arrow", children: spacingArrow(command, activeEditorSide) }) : null,
|
|
10575
|
+
/* @__PURE__ */ jsx10("span", { className: "spacing-command-glyph__bar" }),
|
|
10576
|
+
command.spacing.direction === "positive" ? /* @__PURE__ */ jsx10("span", { className: "spacing-command-glyph__arrow", children: spacingArrow(command, activeEditorSide) }) : null
|
|
9656
10577
|
] }),
|
|
9657
|
-
/* @__PURE__ */
|
|
10578
|
+
/* @__PURE__ */ jsx10("span", { className: "spacing-command-option__name", children: atomicCommandTitle(command, uiLocale) })
|
|
9658
10579
|
]
|
|
9659
10580
|
},
|
|
9660
10581
|
command.id
|
|
@@ -9662,8 +10583,8 @@ ${arabic || currentMessages.empty}`;
|
|
|
9662
10583
|
]
|
|
9663
10584
|
}
|
|
9664
10585
|
) }),
|
|
9665
|
-
/* @__PURE__ */
|
|
9666
|
-
/* @__PURE__ */
|
|
10586
|
+
/* @__PURE__ */ jsxs8("div", { className: "toolbar-group toolbar-functions", role: "group", "aria-label": messages.functions, children: [
|
|
10587
|
+
/* @__PURE__ */ jsxs8(
|
|
9667
10588
|
"div",
|
|
9668
10589
|
{
|
|
9669
10590
|
className: "function-command-menu",
|
|
@@ -9674,7 +10595,7 @@ ${arabic || currentMessages.empty}`;
|
|
|
9674
10595
|
}
|
|
9675
10596
|
},
|
|
9676
10597
|
children: [
|
|
9677
|
-
/* @__PURE__ */
|
|
10598
|
+
/* @__PURE__ */ jsx10(
|
|
9678
10599
|
"button",
|
|
9679
10600
|
{
|
|
9680
10601
|
className: "icon-btn function-command-btn",
|
|
@@ -9687,7 +10608,7 @@ ${arabic || currentMessages.empty}`;
|
|
|
9687
10608
|
children: FUNCTION_COMMANDS[0]?.arabicLabel ?? "\u062F"
|
|
9688
10609
|
}
|
|
9689
10610
|
),
|
|
9690
|
-
/* @__PURE__ */
|
|
10611
|
+
/* @__PURE__ */ jsx10("div", { className: "function-command-options", role: "listbox", "aria-label": messages.insertFunction, hidden: !functionMenuOpen, children: FUNCTION_COMMANDS.map((command) => /* @__PURE__ */ jsx10(
|
|
9691
10612
|
"button",
|
|
9692
10613
|
{
|
|
9693
10614
|
className: "function-command-option",
|
|
@@ -9708,7 +10629,7 @@ ${arabic || currentMessages.empty}`;
|
|
|
9708
10629
|
]
|
|
9709
10630
|
}
|
|
9710
10631
|
),
|
|
9711
|
-
/* @__PURE__ */
|
|
10632
|
+
/* @__PURE__ */ jsxs8(
|
|
9712
10633
|
"div",
|
|
9713
10634
|
{
|
|
9714
10635
|
className: "function-command-menu function-command-menu--limits-series",
|
|
@@ -9719,7 +10640,7 @@ ${arabic || currentMessages.empty}`;
|
|
|
9719
10640
|
}
|
|
9720
10641
|
},
|
|
9721
10642
|
children: [
|
|
9722
|
-
/* @__PURE__ */
|
|
10643
|
+
/* @__PURE__ */ jsx10(
|
|
9723
10644
|
"button",
|
|
9724
10645
|
{
|
|
9725
10646
|
className: "icon-btn function-command-btn",
|
|
@@ -9732,7 +10653,7 @@ ${arabic || currentMessages.empty}`;
|
|
|
9732
10653
|
children: LIMITS_SERIES_COMMANDS[0]?.arabicLabel ?? "\u062D\u062F"
|
|
9733
10654
|
}
|
|
9734
10655
|
),
|
|
9735
|
-
/* @__PURE__ */
|
|
10656
|
+
/* @__PURE__ */ jsx10("div", { className: "function-command-options", role: "listbox", "aria-label": messages.insertLimitsSeries, hidden: !limitsSeriesMenuOpen, children: LIMITS_SERIES_COMMANDS.map((command) => /* @__PURE__ */ jsx10(
|
|
9736
10657
|
"button",
|
|
9737
10658
|
{
|
|
9738
10659
|
className: "function-command-option",
|
|
@@ -9753,7 +10674,7 @@ ${arabic || currentMessages.empty}`;
|
|
|
9753
10674
|
]
|
|
9754
10675
|
}
|
|
9755
10676
|
),
|
|
9756
|
-
/* @__PURE__ */
|
|
10677
|
+
/* @__PURE__ */ jsxs8(
|
|
9757
10678
|
"div",
|
|
9758
10679
|
{
|
|
9759
10680
|
className: "function-command-menu function-command-menu--function2",
|
|
@@ -9764,7 +10685,7 @@ ${arabic || currentMessages.empty}`;
|
|
|
9764
10685
|
}
|
|
9765
10686
|
},
|
|
9766
10687
|
children: [
|
|
9767
|
-
/* @__PURE__ */
|
|
10688
|
+
/* @__PURE__ */ jsx10(
|
|
9768
10689
|
"button",
|
|
9769
10690
|
{
|
|
9770
10691
|
className: "icon-btn function-command-btn",
|
|
@@ -9777,7 +10698,7 @@ ${arabic || currentMessages.empty}`;
|
|
|
9777
10698
|
children: FUNCTION2_COMMANDS[0]?.arabicLabel ?? "\u062F"
|
|
9778
10699
|
}
|
|
9779
10700
|
),
|
|
9780
|
-
/* @__PURE__ */
|
|
10701
|
+
/* @__PURE__ */ jsx10("div", { className: "function-command-options", role: "listbox", "aria-label": messages.insertAdditionalFunctions, hidden: !function2MenuOpen, children: FUNCTION2_COMMANDS.map((command) => /* @__PURE__ */ jsx10(
|
|
9781
10702
|
"button",
|
|
9782
10703
|
{
|
|
9783
10704
|
className: "function-command-option",
|
|
@@ -9798,7 +10719,7 @@ ${arabic || currentMessages.empty}`;
|
|
|
9798
10719
|
]
|
|
9799
10720
|
}
|
|
9800
10721
|
),
|
|
9801
|
-
/* @__PURE__ */
|
|
10722
|
+
/* @__PURE__ */ jsxs8(
|
|
9802
10723
|
"div",
|
|
9803
10724
|
{
|
|
9804
10725
|
className: "function-command-menu function-command-menu--derivative",
|
|
@@ -9809,7 +10730,7 @@ ${arabic || currentMessages.empty}`;
|
|
|
9809
10730
|
}
|
|
9810
10731
|
},
|
|
9811
10732
|
children: [
|
|
9812
|
-
/* @__PURE__ */
|
|
10733
|
+
/* @__PURE__ */ jsx10(
|
|
9813
10734
|
"button",
|
|
9814
10735
|
{
|
|
9815
10736
|
className: "icon-btn function-command-btn",
|
|
@@ -9822,8 +10743,8 @@ ${arabic || currentMessages.empty}`;
|
|
|
9822
10743
|
children: DERIVATIVE_COMMANDS[0]?.arabicLabel ?? "\u0621"
|
|
9823
10744
|
}
|
|
9824
10745
|
),
|
|
9825
|
-
/* @__PURE__ */
|
|
9826
|
-
DERIVATIVE_COMMANDS.map((command) => /* @__PURE__ */
|
|
10746
|
+
/* @__PURE__ */ jsxs8("div", { className: "function-command-options", role: "listbox", "aria-label": messages.insertDerivative, hidden: !derivativeMenuOpen, children: [
|
|
10747
|
+
DERIVATIVE_COMMANDS.map((command) => /* @__PURE__ */ jsx10(
|
|
9827
10748
|
"button",
|
|
9828
10749
|
{
|
|
9829
10750
|
className: "function-command-option",
|
|
@@ -9841,7 +10762,7 @@ ${arabic || currentMessages.empty}`;
|
|
|
9841
10762
|
},
|
|
9842
10763
|
command.id
|
|
9843
10764
|
)),
|
|
9844
|
-
/* @__PURE__ */
|
|
10765
|
+
/* @__PURE__ */ jsx10(
|
|
9845
10766
|
"button",
|
|
9846
10767
|
{
|
|
9847
10768
|
className: "function-command-option",
|
|
@@ -9858,7 +10779,7 @@ ${arabic || currentMessages.empty}`;
|
|
|
9858
10779
|
children: "\u0621/\u0633"
|
|
9859
10780
|
}
|
|
9860
10781
|
),
|
|
9861
|
-
/* @__PURE__ */
|
|
10782
|
+
/* @__PURE__ */ jsx10(
|
|
9862
10783
|
"button",
|
|
9863
10784
|
{
|
|
9864
10785
|
className: "function-command-option",
|
|
@@ -9879,7 +10800,7 @@ ${arabic || currentMessages.empty}`;
|
|
|
9879
10800
|
]
|
|
9880
10801
|
}
|
|
9881
10802
|
),
|
|
9882
|
-
/* @__PURE__ */
|
|
10803
|
+
/* @__PURE__ */ jsxs8(
|
|
9883
10804
|
"div",
|
|
9884
10805
|
{
|
|
9885
10806
|
className: "function-command-menu function-command-menu--groups",
|
|
@@ -9890,7 +10811,7 @@ ${arabic || currentMessages.empty}`;
|
|
|
9890
10811
|
}
|
|
9891
10812
|
},
|
|
9892
10813
|
children: [
|
|
9893
|
-
/* @__PURE__ */
|
|
10814
|
+
/* @__PURE__ */ jsx10(
|
|
9894
10815
|
"button",
|
|
9895
10816
|
{
|
|
9896
10817
|
className: "icon-btn function-command-btn",
|
|
@@ -9903,7 +10824,7 @@ ${arabic || currentMessages.empty}`;
|
|
|
9903
10824
|
children: GROUP_COMMANDS[0]?.arabicLabel ?? "\u0645"
|
|
9904
10825
|
}
|
|
9905
10826
|
),
|
|
9906
|
-
/* @__PURE__ */
|
|
10827
|
+
/* @__PURE__ */ jsx10("div", { className: "function-command-options", role: "listbox", "aria-label": messages.insertNumberSets, hidden: !groupMenuOpen, children: GROUP_COMMANDS.map((command) => /* @__PURE__ */ jsx10(
|
|
9907
10828
|
"button",
|
|
9908
10829
|
{
|
|
9909
10830
|
className: "function-command-option",
|
|
@@ -9925,8 +10846,8 @@ ${arabic || currentMessages.empty}`;
|
|
|
9925
10846
|
}
|
|
9926
10847
|
)
|
|
9927
10848
|
] }),
|
|
9928
|
-
/* @__PURE__ */
|
|
9929
|
-
/* @__PURE__ */
|
|
10849
|
+
/* @__PURE__ */ jsxs8("div", { className: "toolbar-group toolbar-operators", role: "group", "aria-label": messages.operations, children: [
|
|
10850
|
+
/* @__PURE__ */ jsxs8(
|
|
9930
10851
|
"div",
|
|
9931
10852
|
{
|
|
9932
10853
|
className: "function-command-menu operator-command-menu",
|
|
@@ -9937,7 +10858,7 @@ ${arabic || currentMessages.empty}`;
|
|
|
9937
10858
|
}
|
|
9938
10859
|
},
|
|
9939
10860
|
children: [
|
|
9940
|
-
/* @__PURE__ */
|
|
10861
|
+
/* @__PURE__ */ jsx10(
|
|
9941
10862
|
"button",
|
|
9942
10863
|
{
|
|
9943
10864
|
className: "icon-btn function-command-btn operator-command-btn",
|
|
@@ -9950,7 +10871,7 @@ ${arabic || currentMessages.empty}`;
|
|
|
9950
10871
|
children: renderOperatorMenuButtonLabel(OPERATOR_COMMANDS[0], "\u2217")
|
|
9951
10872
|
}
|
|
9952
10873
|
),
|
|
9953
|
-
/* @__PURE__ */
|
|
10874
|
+
/* @__PURE__ */ jsx10("div", { className: "function-command-options operator-command-options", role: "listbox", "aria-label": messages.insertOperation, hidden: !operatorMenuOpen, children: OPERATOR_COMMANDS.map((command) => /* @__PURE__ */ jsx10(
|
|
9954
10875
|
"button",
|
|
9955
10876
|
{
|
|
9956
10877
|
className: "function-command-option operator-command-option",
|
|
@@ -9964,14 +10885,14 @@ ${arabic || currentMessages.empty}`;
|
|
|
9964
10885
|
setOperatorMenuOpen(false);
|
|
9965
10886
|
focusSurface();
|
|
9966
10887
|
},
|
|
9967
|
-
children: /* @__PURE__ */
|
|
10888
|
+
children: /* @__PURE__ */ jsx10("span", { className: shouldMirrorOperatorDisplay(command) ? "operator-command-label operator-command-label--mirror" : "operator-command-label", children: renderOperatorCommandLabel(command) })
|
|
9968
10889
|
},
|
|
9969
10890
|
command.id
|
|
9970
10891
|
)) })
|
|
9971
10892
|
]
|
|
9972
10893
|
}
|
|
9973
10894
|
),
|
|
9974
|
-
/* @__PURE__ */
|
|
10895
|
+
/* @__PURE__ */ jsxs8(
|
|
9975
10896
|
"div",
|
|
9976
10897
|
{
|
|
9977
10898
|
className: "function-command-menu operator-command-menu",
|
|
@@ -9982,7 +10903,7 @@ ${arabic || currentMessages.empty}`;
|
|
|
9982
10903
|
}
|
|
9983
10904
|
},
|
|
9984
10905
|
children: [
|
|
9985
|
-
/* @__PURE__ */
|
|
10906
|
+
/* @__PURE__ */ jsx10(
|
|
9986
10907
|
"button",
|
|
9987
10908
|
{
|
|
9988
10909
|
className: "icon-btn function-command-btn operator-command-btn",
|
|
@@ -9995,7 +10916,7 @@ ${arabic || currentMessages.empty}`;
|
|
|
9995
10916
|
children: "\u2229"
|
|
9996
10917
|
}
|
|
9997
10918
|
),
|
|
9998
|
-
/* @__PURE__ */
|
|
10919
|
+
/* @__PURE__ */ jsx10("div", { className: "function-command-options operator-command-options", role: "listbox", "aria-label": messages.insertRelationsSets, hidden: !operator2MenuOpen, children: OPERATOR2_COMMANDS.map((command) => /* @__PURE__ */ jsx10(
|
|
9999
10920
|
"button",
|
|
10000
10921
|
{
|
|
10001
10922
|
className: "function-command-option operator-command-option",
|
|
@@ -10009,14 +10930,14 @@ ${arabic || currentMessages.empty}`;
|
|
|
10009
10930
|
setOperator2MenuOpen(false);
|
|
10010
10931
|
focusSurface();
|
|
10011
10932
|
},
|
|
10012
|
-
children: /* @__PURE__ */
|
|
10933
|
+
children: /* @__PURE__ */ jsx10("span", { className: shouldMirrorOperatorDisplay(command) ? "operator-command-label operator-command-label--mirror" : "operator-command-label", children: renderOperatorCommandLabel(command) })
|
|
10013
10934
|
},
|
|
10014
10935
|
command.id
|
|
10015
10936
|
)) })
|
|
10016
10937
|
]
|
|
10017
10938
|
}
|
|
10018
10939
|
),
|
|
10019
|
-
/* @__PURE__ */
|
|
10940
|
+
/* @__PURE__ */ jsxs8(
|
|
10020
10941
|
"div",
|
|
10021
10942
|
{
|
|
10022
10943
|
className: "function-command-menu operator-command-menu",
|
|
@@ -10027,7 +10948,7 @@ ${arabic || currentMessages.empty}`;
|
|
|
10027
10948
|
}
|
|
10028
10949
|
},
|
|
10029
10950
|
children: [
|
|
10030
|
-
/* @__PURE__ */
|
|
10951
|
+
/* @__PURE__ */ jsx10(
|
|
10031
10952
|
"button",
|
|
10032
10953
|
{
|
|
10033
10954
|
className: "icon-btn function-command-btn operator-command-btn",
|
|
@@ -10040,7 +10961,7 @@ ${arabic || currentMessages.empty}`;
|
|
|
10040
10961
|
children: renderOperatorMenuButtonLabel(OPERATOR3_COMMANDS[0], "\u21D2")
|
|
10041
10962
|
}
|
|
10042
10963
|
),
|
|
10043
|
-
/* @__PURE__ */
|
|
10964
|
+
/* @__PURE__ */ jsx10("div", { className: "function-command-options operator-command-options", role: "listbox", "aria-label": messages.insertArrows, hidden: !operator3MenuOpen, children: OPERATOR3_COMMANDS.map((command) => /* @__PURE__ */ jsx10(
|
|
10044
10965
|
"button",
|
|
10045
10966
|
{
|
|
10046
10967
|
className: "function-command-option operator-command-option",
|
|
@@ -10054,14 +10975,14 @@ ${arabic || currentMessages.empty}`;
|
|
|
10054
10975
|
setOperator3MenuOpen(false);
|
|
10055
10976
|
focusSurface();
|
|
10056
10977
|
},
|
|
10057
|
-
children: /* @__PURE__ */
|
|
10978
|
+
children: /* @__PURE__ */ jsx10("span", { className: shouldMirrorOperatorDisplay(command) ? "operator-command-label operator-command-label--mirror" : "operator-command-label", children: renderOperatorCommandLabel(command) })
|
|
10058
10979
|
},
|
|
10059
10980
|
command.id
|
|
10060
10981
|
)) })
|
|
10061
10982
|
]
|
|
10062
10983
|
}
|
|
10063
10984
|
),
|
|
10064
|
-
/* @__PURE__ */
|
|
10985
|
+
/* @__PURE__ */ jsxs8(
|
|
10065
10986
|
"div",
|
|
10066
10987
|
{
|
|
10067
10988
|
className: "function-command-menu operator-command-menu",
|
|
@@ -10072,7 +10993,7 @@ ${arabic || currentMessages.empty}`;
|
|
|
10072
10993
|
}
|
|
10073
10994
|
},
|
|
10074
10995
|
children: [
|
|
10075
|
-
/* @__PURE__ */
|
|
10996
|
+
/* @__PURE__ */ jsx10(
|
|
10076
10997
|
"button",
|
|
10077
10998
|
{
|
|
10078
10999
|
className: "icon-btn function-command-btn operator-command-btn",
|
|
@@ -10085,7 +11006,7 @@ ${arabic || currentMessages.empty}`;
|
|
|
10085
11006
|
children: renderOperatorMenuButtonLabel(DOT_COMMANDS[0], "\u2026")
|
|
10086
11007
|
}
|
|
10087
11008
|
),
|
|
10088
|
-
/* @__PURE__ */
|
|
11009
|
+
/* @__PURE__ */ jsx10("div", { className: "function-command-options operator-command-options", role: "listbox", "aria-label": messages.insertDots, hidden: !dotMenuOpen, children: DOT_COMMANDS.map((command) => /* @__PURE__ */ jsx10(
|
|
10089
11010
|
"button",
|
|
10090
11011
|
{
|
|
10091
11012
|
className: "function-command-option operator-command-option",
|
|
@@ -10099,14 +11020,14 @@ ${arabic || currentMessages.empty}`;
|
|
|
10099
11020
|
setDotMenuOpen(false);
|
|
10100
11021
|
focusSurface();
|
|
10101
11022
|
},
|
|
10102
|
-
children: /* @__PURE__ */
|
|
11023
|
+
children: /* @__PURE__ */ jsx10("span", { className: shouldMirrorOperatorDisplay(command) ? "operator-command-label operator-command-label--mirror" : "operator-command-label", children: renderOperatorCommandLabel(command) })
|
|
10103
11024
|
},
|
|
10104
11025
|
command.id
|
|
10105
11026
|
)) })
|
|
10106
11027
|
]
|
|
10107
11028
|
}
|
|
10108
11029
|
),
|
|
10109
|
-
/* @__PURE__ */
|
|
11030
|
+
/* @__PURE__ */ jsxs8(
|
|
10110
11031
|
"div",
|
|
10111
11032
|
{
|
|
10112
11033
|
className: "function-command-menu operator-command-menu",
|
|
@@ -10117,7 +11038,7 @@ ${arabic || currentMessages.empty}`;
|
|
|
10117
11038
|
}
|
|
10118
11039
|
},
|
|
10119
11040
|
children: [
|
|
10120
|
-
/* @__PURE__ */
|
|
11041
|
+
/* @__PURE__ */ jsx10(
|
|
10121
11042
|
"button",
|
|
10122
11043
|
{
|
|
10123
11044
|
className: "icon-btn function-command-btn operator-command-btn",
|
|
@@ -10130,7 +11051,7 @@ ${arabic || currentMessages.empty}`;
|
|
|
10130
11051
|
children: renderOperatorMenuButtonLabel(INTEGRAL_COMMANDS[0], "\u222B")
|
|
10131
11052
|
}
|
|
10132
11053
|
),
|
|
10133
|
-
/* @__PURE__ */
|
|
11054
|
+
/* @__PURE__ */ jsx10("div", { className: "function-command-options operator-command-options", role: "listbox", "aria-label": messages.insertIntegrals, hidden: !integralMenuOpen, children: INTEGRAL_COMMANDS.map((command) => /* @__PURE__ */ jsx10(
|
|
10134
11055
|
"button",
|
|
10135
11056
|
{
|
|
10136
11057
|
className: "function-command-option operator-command-option",
|
|
@@ -10144,7 +11065,7 @@ ${arabic || currentMessages.empty}`;
|
|
|
10144
11065
|
setIntegralMenuOpen(false);
|
|
10145
11066
|
focusSurface();
|
|
10146
11067
|
},
|
|
10147
|
-
children: /* @__PURE__ */
|
|
11068
|
+
children: /* @__PURE__ */ jsx10("span", { className: shouldMirrorOperatorDisplay(command) ? "operator-command-label operator-command-label--mirror" : "operator-command-label", children: renderOperatorCommandLabel(command) })
|
|
10148
11069
|
},
|
|
10149
11070
|
command.id
|
|
10150
11071
|
)) })
|
|
@@ -10152,28 +11073,28 @@ ${arabic || currentMessages.empty}`;
|
|
|
10152
11073
|
}
|
|
10153
11074
|
)
|
|
10154
11075
|
] }),
|
|
10155
|
-
/* @__PURE__ */
|
|
10156
|
-
/* @__PURE__ */
|
|
10157
|
-
/* @__PURE__ */
|
|
10158
|
-
/* @__PURE__ */
|
|
11076
|
+
/* @__PURE__ */ jsxs8("div", { className: "toolbar-group toolbar-scripts", role: "group", "aria-label": messages.scripts, children: [
|
|
11077
|
+
/* @__PURE__ */ jsx10("button", { className: "icon-btn script-icon-btn", type: "button", title: messages.addSuperscript, "aria-label": messages.addSuperscript, onClick: () => runtimeRef.current?.addSup(), children: /* @__PURE__ */ jsxs8("span", { className: "toolbar-script-icon toolbar-script-icon--sup", "aria-hidden": "true", children: [
|
|
11078
|
+
/* @__PURE__ */ jsx10("span", { children: "\u0646" }),
|
|
11079
|
+
/* @__PURE__ */ jsx10("span", { children: "\u0633" })
|
|
10159
11080
|
] }) }),
|
|
10160
|
-
/* @__PURE__ */
|
|
10161
|
-
/* @__PURE__ */
|
|
10162
|
-
/* @__PURE__ */
|
|
11081
|
+
/* @__PURE__ */ jsx10("button", { className: "icon-btn script-icon-btn", type: "button", title: messages.addSubscript, "aria-label": messages.addSubscript, onClick: () => runtimeRef.current?.addSub(), children: /* @__PURE__ */ jsxs8("span", { className: "toolbar-script-icon toolbar-script-icon--sub", "aria-hidden": "true", children: [
|
|
11082
|
+
/* @__PURE__ */ jsx10("span", { children: "\u0646" }),
|
|
11083
|
+
/* @__PURE__ */ jsx10("span", { children: "\u0633" })
|
|
10163
11084
|
] }) }),
|
|
10164
|
-
/* @__PURE__ */
|
|
10165
|
-
/* @__PURE__ */
|
|
10166
|
-
/* @__PURE__ */
|
|
11085
|
+
/* @__PURE__ */ jsx10("button", { className: "icon-btn script-icon-btn remove-script-btn", type: "button", title: messages.removeSuperscript, "aria-label": messages.removeSuperscript, onClick: () => runtimeRef.current?.removeSup(), children: /* @__PURE__ */ jsxs8("span", { className: "toolbar-remove-script-icon toolbar-remove-script-icon--sup", "aria-hidden": "true", children: [
|
|
11086
|
+
/* @__PURE__ */ jsx10("span", { children: "\u0646" }),
|
|
11087
|
+
/* @__PURE__ */ jsx10("span", { children: "\xD7" })
|
|
10167
11088
|
] }) }),
|
|
10168
|
-
/* @__PURE__ */
|
|
10169
|
-
/* @__PURE__ */
|
|
10170
|
-
/* @__PURE__ */
|
|
11089
|
+
/* @__PURE__ */ jsx10("button", { className: "icon-btn script-icon-btn remove-script-btn", type: "button", title: messages.removeSubscript, "aria-label": messages.removeSubscript, onClick: () => runtimeRef.current?.removeSub(), children: /* @__PURE__ */ jsxs8("span", { className: "toolbar-remove-script-icon toolbar-remove-script-icon--sub", "aria-hidden": "true", children: [
|
|
11090
|
+
/* @__PURE__ */ jsx10("span", { children: "\u0646" }),
|
|
11091
|
+
/* @__PURE__ */ jsx10("span", { children: "\xD7" })
|
|
10171
11092
|
] }) })
|
|
10172
11093
|
] }),
|
|
10173
|
-
/* @__PURE__ */
|
|
10174
|
-
/* @__PURE__ */
|
|
10175
|
-
/* @__PURE__ */
|
|
10176
|
-
/* @__PURE__ */
|
|
11094
|
+
/* @__PURE__ */ jsxs8("div", { className: "toolbar-group toolbar-settings", role: "group", "aria-label": messages.inputStyles, children: [
|
|
11095
|
+
/* @__PURE__ */ jsx10("button", { className: "icon-btn delete-node-btn", type: "button", title: messages.deleteSelectedStructure, "aria-label": messages.deleteSelectedStructure, onClick: () => runtimeRef.current?.deleteStructure(), children: "\xD7" }),
|
|
11096
|
+
/* @__PURE__ */ jsx10("button", { ref: splitTypingBtnRef, id: "toggle-split-leaf-typing", className: "icon-btn ligature-btn", type: "button", title: messages.toggleLetterMerging, "aria-label": messages.toggleLetterMerging, onClick: () => runtimeRef.current?.toggleSplitLeafTyping(), children: "\u0633\u0635\u0639" }),
|
|
11097
|
+
/* @__PURE__ */ jsxs8(
|
|
10177
11098
|
"div",
|
|
10178
11099
|
{
|
|
10179
11100
|
className: "character-font-menu",
|
|
@@ -10184,7 +11105,7 @@ ${arabic || currentMessages.empty}`;
|
|
|
10184
11105
|
}
|
|
10185
11106
|
},
|
|
10186
11107
|
children: [
|
|
10187
|
-
/* @__PURE__ */
|
|
11108
|
+
/* @__PURE__ */ jsx10(
|
|
10188
11109
|
"button",
|
|
10189
11110
|
{
|
|
10190
11111
|
ref: characterFontBtnRef,
|
|
@@ -10199,7 +11120,7 @@ ${arabic || currentMessages.empty}`;
|
|
|
10199
11120
|
children: characterFontOption(selectedCharacterFont).label
|
|
10200
11121
|
}
|
|
10201
11122
|
),
|
|
10202
|
-
/* @__PURE__ */
|
|
11123
|
+
/* @__PURE__ */ jsx10("div", { className: "character-font-options", role: "listbox", "aria-label": messages.chooseWritingFont, hidden: !characterFontMenuOpen, children: CHARACTER_FONT_OPTIONS.map((option) => /* @__PURE__ */ jsx10(
|
|
10203
11124
|
"button",
|
|
10204
11125
|
{
|
|
10205
11126
|
type: "button",
|
|
@@ -10221,7 +11142,7 @@ ${arabic || currentMessages.empty}`;
|
|
|
10221
11142
|
]
|
|
10222
11143
|
}
|
|
10223
11144
|
),
|
|
10224
|
-
/* @__PURE__ */
|
|
11145
|
+
/* @__PURE__ */ jsxs8(
|
|
10225
11146
|
"div",
|
|
10226
11147
|
{
|
|
10227
11148
|
className: "digit-form-menu",
|
|
@@ -10232,7 +11153,7 @@ ${arabic || currentMessages.empty}`;
|
|
|
10232
11153
|
}
|
|
10233
11154
|
},
|
|
10234
11155
|
children: [
|
|
10235
|
-
/* @__PURE__ */
|
|
11156
|
+
/* @__PURE__ */ jsx10(
|
|
10236
11157
|
"button",
|
|
10237
11158
|
{
|
|
10238
11159
|
ref: digitFormBtnRef,
|
|
@@ -10244,10 +11165,10 @@ ${arabic || currentMessages.empty}`;
|
|
|
10244
11165
|
"aria-haspopup": "listbox",
|
|
10245
11166
|
"aria-expanded": digitMenuOpen,
|
|
10246
11167
|
onClick: () => setDigitMenuOpen((open) => !open),
|
|
10247
|
-
children:
|
|
11168
|
+
children: digitFormLabel2(selectedDigitForm2)
|
|
10248
11169
|
}
|
|
10249
11170
|
),
|
|
10250
|
-
/* @__PURE__ */
|
|
11171
|
+
/* @__PURE__ */ jsx10("div", { className: "digit-form-options", role: "listbox", "aria-label": messages.chooseDigitForm, hidden: !digitMenuOpen, children: DIGIT_FORM_OPTIONS.map((option) => /* @__PURE__ */ jsx10(
|
|
10251
11172
|
"button",
|
|
10252
11173
|
{
|
|
10253
11174
|
type: "button",
|
|
@@ -10271,7 +11192,7 @@ ${arabic || currentMessages.empty}`;
|
|
|
10271
11192
|
)
|
|
10272
11193
|
] })
|
|
10273
11194
|
] }),
|
|
10274
|
-
/* @__PURE__ */
|
|
11195
|
+
/* @__PURE__ */ jsx10(
|
|
10275
11196
|
"div",
|
|
10276
11197
|
{
|
|
10277
11198
|
ref: surfaceRef,
|
|
@@ -10281,18 +11202,18 @@ ${arabic || currentMessages.empty}`;
|
|
|
10281
11202
|
"aria-label": messages.equationEditor
|
|
10282
11203
|
}
|
|
10283
11204
|
),
|
|
10284
|
-
/* @__PURE__ */
|
|
11205
|
+
/* @__PURE__ */ jsx10("div", { ref: renderErrorRef, className: "error", hidden: true })
|
|
10285
11206
|
] }),
|
|
10286
|
-
/* @__PURE__ */
|
|
10287
|
-
debug ? /* @__PURE__ */
|
|
10288
|
-
/* @__PURE__ */
|
|
10289
|
-
/* @__PURE__ */
|
|
10290
|
-
/* @__PURE__ */
|
|
10291
|
-
/* @__PURE__ */
|
|
11207
|
+
/* @__PURE__ */ jsx10("section", { className: "panel panel-preview", "aria-label": messages.renderPreview, children: /* @__PURE__ */ jsx10("div", { ref: mathOutputRef, className: "preview-box" }) }),
|
|
11208
|
+
debug ? /* @__PURE__ */ jsxs8("section", { className: "panel", children: [
|
|
11209
|
+
/* @__PURE__ */ jsxs8("div", { className: "dev-strip", children: [
|
|
11210
|
+
/* @__PURE__ */ jsx10("span", { className: "dev-badge", children: messages.development }),
|
|
11211
|
+
/* @__PURE__ */ jsx10("div", { ref: latexLinesRef, className: "ascii" }),
|
|
11212
|
+
/* @__PURE__ */ jsx10("div", { ref: passivePreviewRef, className: "passive-preview-text" })
|
|
10292
11213
|
] }),
|
|
10293
|
-
/* @__PURE__ */
|
|
10294
|
-
/* @__PURE__ */
|
|
10295
|
-
/* @__PURE__ */
|
|
11214
|
+
/* @__PURE__ */ jsxs8("div", { style: { marginTop: 12 }, children: [
|
|
11215
|
+
/* @__PURE__ */ jsxs8("div", { className: "debug-head", children: [
|
|
11216
|
+
/* @__PURE__ */ jsx10(
|
|
10296
11217
|
"button",
|
|
10297
11218
|
{
|
|
10298
11219
|
type: "button",
|
|
@@ -10312,7 +11233,7 @@ ${arabic || currentMessages.empty}`;
|
|
|
10312
11233
|
children: debugBodyHidden ? messages.showDebugLog : messages.hideDebugLog
|
|
10313
11234
|
}
|
|
10314
11235
|
),
|
|
10315
|
-
/* @__PURE__ */
|
|
11236
|
+
/* @__PURE__ */ jsx10(
|
|
10316
11237
|
"button",
|
|
10317
11238
|
{
|
|
10318
11239
|
type: "button",
|
|
@@ -10327,7 +11248,7 @@ ${arabic || currentMessages.empty}`;
|
|
|
10327
11248
|
}
|
|
10328
11249
|
)
|
|
10329
11250
|
] }),
|
|
10330
|
-
/* @__PURE__ */
|
|
11251
|
+
/* @__PURE__ */ jsx10("div", { ref: debugLogRef, className: "debug-log" })
|
|
10331
11252
|
] })
|
|
10332
11253
|
] }) : null
|
|
10333
11254
|
] })
|
|
@@ -10338,7 +11259,7 @@ ${arabic || currentMessages.empty}`;
|
|
|
10338
11259
|
ButexEditor.displayName = "ButexEditor";
|
|
10339
11260
|
|
|
10340
11261
|
// src/react-document2/EquationDrawer.tsx
|
|
10341
|
-
import { jsx as
|
|
11262
|
+
import { jsx as jsx11, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
10342
11263
|
function EquationDrawer({
|
|
10343
11264
|
session,
|
|
10344
11265
|
reason,
|
|
@@ -10353,7 +11274,7 @@ function EquationDrawer({
|
|
|
10353
11274
|
}) {
|
|
10354
11275
|
const messages = document2Messages(uiLocale);
|
|
10355
11276
|
const latestSession = useRef5(session);
|
|
10356
|
-
|
|
11277
|
+
useEffect5(() => {
|
|
10357
11278
|
const onKeyDown = (event) => {
|
|
10358
11279
|
if (event.key === "Escape") {
|
|
10359
11280
|
onClose();
|
|
@@ -10362,8 +11283,8 @@ function EquationDrawer({
|
|
|
10362
11283
|
window.addEventListener("keydown", onKeyDown);
|
|
10363
11284
|
return () => window.removeEventListener("keydown", onKeyDown);
|
|
10364
11285
|
}, [onClose]);
|
|
10365
|
-
return /* @__PURE__ */
|
|
10366
|
-
/* @__PURE__ */
|
|
11286
|
+
return /* @__PURE__ */ jsxs9("div", { className: "butex-document2-widget__equation-modal", role: "presentation", children: [
|
|
11287
|
+
/* @__PURE__ */ jsx11(
|
|
10367
11288
|
"button",
|
|
10368
11289
|
{
|
|
10369
11290
|
type: "button",
|
|
@@ -10372,7 +11293,7 @@ function EquationDrawer({
|
|
|
10372
11293
|
onClick: onClose
|
|
10373
11294
|
}
|
|
10374
11295
|
),
|
|
10375
|
-
/* @__PURE__ */
|
|
11296
|
+
/* @__PURE__ */ jsxs9(
|
|
10376
11297
|
"div",
|
|
10377
11298
|
{
|
|
10378
11299
|
className: "butex-document2-widget__equation-modal-panel",
|
|
@@ -10382,22 +11303,22 @@ function EquationDrawer({
|
|
|
10382
11303
|
dir: uiLocaleDirection(uiLocale),
|
|
10383
11304
|
lang: uiLocale,
|
|
10384
11305
|
children: [
|
|
10385
|
-
/* @__PURE__ */
|
|
10386
|
-
/* @__PURE__ */
|
|
10387
|
-
/* @__PURE__ */
|
|
11306
|
+
/* @__PURE__ */ jsxs9("div", { className: "butex-document2-widget__row", children: [
|
|
11307
|
+
/* @__PURE__ */ jsx11("strong", { id: "butex-document2-equation-modal-title", children: messages.equationEditorTitle }),
|
|
11308
|
+
/* @__PURE__ */ jsx11("button", { type: "button", onClick: onClose, children: messages.close })
|
|
10388
11309
|
] }),
|
|
10389
|
-
/* @__PURE__ */
|
|
10390
|
-
/* @__PURE__ */
|
|
11310
|
+
/* @__PURE__ */ jsxs9("div", { className: "butex-document2-widget__row", role: "group", "aria-label": messages.equationType, children: [
|
|
11311
|
+
/* @__PURE__ */ jsxs9("button", { type: "button", "aria-pressed": mathMode === "inline", onClick: () => onMathModeChange("inline"), children: [
|
|
10391
11312
|
messages.inline,
|
|
10392
11313
|
" ($)"
|
|
10393
11314
|
] }),
|
|
10394
|
-
/* @__PURE__ */
|
|
11315
|
+
/* @__PURE__ */ jsxs9("button", { type: "button", "aria-pressed": mathMode === "display", onClick: () => onMathModeChange("display"), children: [
|
|
10395
11316
|
messages.displayed,
|
|
10396
11317
|
" (\\\\[)"
|
|
10397
11318
|
] })
|
|
10398
11319
|
] }),
|
|
10399
|
-
reason ? /* @__PURE__ */
|
|
10400
|
-
/* @__PURE__ */
|
|
11320
|
+
reason ? /* @__PURE__ */ jsx11("p", { className: "butex-document2-widget__error", children: uiLocale === "en" ? messages.equationUnavailable : reason }) : null,
|
|
11321
|
+
/* @__PURE__ */ jsx11(
|
|
10401
11322
|
ButexEditor,
|
|
10402
11323
|
{
|
|
10403
11324
|
debug: false,
|
|
@@ -10409,9 +11330,9 @@ function EquationDrawer({
|
|
|
10409
11330
|
}
|
|
10410
11331
|
}
|
|
10411
11332
|
),
|
|
10412
|
-
/* @__PURE__ */
|
|
10413
|
-
canDelete && onDelete ? /* @__PURE__ */
|
|
10414
|
-
/* @__PURE__ */
|
|
11333
|
+
/* @__PURE__ */ jsxs9("div", { className: "butex-document2-widget__row", children: [
|
|
11334
|
+
canDelete && onDelete ? /* @__PURE__ */ jsx11("button", { type: "button", className: "butex-document2-widget__button--danger", onClick: onDelete, children: messages.deleteEquation }) : null,
|
|
11335
|
+
/* @__PURE__ */ jsx11("button", { type: "button", onClick: () => onSave({ ...latestSession.current, activeSide: equationSide }), children: messages.saveEquation })
|
|
10415
11336
|
] })
|
|
10416
11337
|
]
|
|
10417
11338
|
}
|
|
@@ -10419,6 +11340,108 @@ function EquationDrawer({
|
|
|
10419
11340
|
] });
|
|
10420
11341
|
}
|
|
10421
11342
|
|
|
11343
|
+
// src/react-document2/ReferencesPanel.tsx
|
|
11344
|
+
import { useState as useState6 } from "react";
|
|
11345
|
+
import { jsx as jsx12, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
11346
|
+
var EMPTY_DRAFT = { key: "", authors: "", title: "", year: "", url: "", venue: "" };
|
|
11347
|
+
function ReferencesPanel({
|
|
11348
|
+
open,
|
|
11349
|
+
references,
|
|
11350
|
+
uiLocale = "ar",
|
|
11351
|
+
onClose,
|
|
11352
|
+
onAdd,
|
|
11353
|
+
onUpdate,
|
|
11354
|
+
onRemove,
|
|
11355
|
+
onMove
|
|
11356
|
+
}) {
|
|
11357
|
+
const messages = document2Messages(uiLocale);
|
|
11358
|
+
const [draft, setDraft] = useState6(EMPTY_DRAFT);
|
|
11359
|
+
if (!open) {
|
|
11360
|
+
return null;
|
|
11361
|
+
}
|
|
11362
|
+
return /* @__PURE__ */ jsx12("div", { className: "butex-document2-widget__refs-backdrop", role: "presentation", onClick: onClose, children: /* @__PURE__ */ jsxs10("div", { className: "butex-document2-widget__refs-panel", role: "dialog", "aria-label": messages.referencesTitle, onClick: (event) => event.stopPropagation(), children: [
|
|
11363
|
+
/* @__PURE__ */ jsxs10("header", { className: "butex-document2-widget__refs-header", children: [
|
|
11364
|
+
/* @__PURE__ */ jsx12("strong", { children: messages.referencesTitle }),
|
|
11365
|
+
/* @__PURE__ */ jsx12("button", { type: "button", className: "butex-document2-widget__icon-btn", title: messages.close, "aria-label": messages.close, onClick: onClose, children: "\xD7" })
|
|
11366
|
+
] }),
|
|
11367
|
+
/* @__PURE__ */ jsxs10("div", { className: "butex-document2-widget__refs-add", children: [
|
|
11368
|
+
/* @__PURE__ */ jsx12("h3", { children: messages.addReference }),
|
|
11369
|
+
/* @__PURE__ */ jsx12("div", { className: "butex-document2-widget__refs-grid", children: [
|
|
11370
|
+
["key", messages.referenceKey],
|
|
11371
|
+
["authors", messages.referenceAuthors],
|
|
11372
|
+
["title", messages.referenceTitle],
|
|
11373
|
+
["year", messages.referenceYear],
|
|
11374
|
+
["venue", messages.referenceVenue],
|
|
11375
|
+
["url", messages.referenceUrl]
|
|
11376
|
+
].map(([field, label]) => /* @__PURE__ */ jsxs10("label", { className: "butex-document2-widget__refs-field", children: [
|
|
11377
|
+
/* @__PURE__ */ jsx12("span", { children: label }),
|
|
11378
|
+
/* @__PURE__ */ jsx12(
|
|
11379
|
+
"input",
|
|
11380
|
+
{
|
|
11381
|
+
value: draft[field] ?? "",
|
|
11382
|
+
onChange: (event) => setDraft((current) => ({ ...current, [field]: event.currentTarget.value }))
|
|
11383
|
+
}
|
|
11384
|
+
)
|
|
11385
|
+
] }, field)) }),
|
|
11386
|
+
/* @__PURE__ */ jsx12(
|
|
11387
|
+
"button",
|
|
11388
|
+
{
|
|
11389
|
+
type: "button",
|
|
11390
|
+
className: "butex-document2-widget__primary-btn",
|
|
11391
|
+
disabled: !draft.key?.trim(),
|
|
11392
|
+
onClick: () => {
|
|
11393
|
+
onAdd(draft);
|
|
11394
|
+
setDraft(EMPTY_DRAFT);
|
|
11395
|
+
},
|
|
11396
|
+
children: messages.addReference
|
|
11397
|
+
}
|
|
11398
|
+
)
|
|
11399
|
+
] }),
|
|
11400
|
+
/* @__PURE__ */ jsx12("ul", { className: "butex-document2-widget__refs-list", children: references.map((reference, index) => /* @__PURE__ */ jsxs10("li", { className: "butex-document2-widget__refs-item", children: [
|
|
11401
|
+
/* @__PURE__ */ jsxs10("div", { className: "butex-document2-widget__refs-item-head", children: [
|
|
11402
|
+
/* @__PURE__ */ jsxs10("strong", { children: [
|
|
11403
|
+
"[",
|
|
11404
|
+
index + 1,
|
|
11405
|
+
"] ",
|
|
11406
|
+
reference.key
|
|
11407
|
+
] }),
|
|
11408
|
+
/* @__PURE__ */ jsxs10("div", { className: "butex-document2-widget__refs-item-actions", children: [
|
|
11409
|
+
/* @__PURE__ */ jsx12("button", { type: "button", title: messages.moveUp, "aria-label": messages.moveUp, disabled: index === 0, onClick: () => onMove(reference.id, -1), children: "\u2191" }),
|
|
11410
|
+
/* @__PURE__ */ jsx12(
|
|
11411
|
+
"button",
|
|
11412
|
+
{
|
|
11413
|
+
type: "button",
|
|
11414
|
+
title: messages.moveDown,
|
|
11415
|
+
"aria-label": messages.moveDown,
|
|
11416
|
+
disabled: index === references.length - 1,
|
|
11417
|
+
onClick: () => onMove(reference.id, 1),
|
|
11418
|
+
children: "\u2193"
|
|
11419
|
+
}
|
|
11420
|
+
),
|
|
11421
|
+
/* @__PURE__ */ jsx12("button", { type: "button", title: messages.deleteReference, "aria-label": messages.deleteReference, onClick: () => onRemove(reference.id), children: "\xD7" })
|
|
11422
|
+
] })
|
|
11423
|
+
] }),
|
|
11424
|
+
/* @__PURE__ */ jsx12("div", { className: "butex-document2-widget__refs-grid", children: [
|
|
11425
|
+
["key", messages.referenceKey],
|
|
11426
|
+
["authors", messages.referenceAuthors],
|
|
11427
|
+
["title", messages.referenceTitle],
|
|
11428
|
+
["year", messages.referenceYear],
|
|
11429
|
+
["venue", messages.referenceVenue],
|
|
11430
|
+
["url", messages.referenceUrl]
|
|
11431
|
+
].map(([field, label]) => /* @__PURE__ */ jsxs10("label", { className: "butex-document2-widget__refs-field", children: [
|
|
11432
|
+
/* @__PURE__ */ jsx12("span", { children: label }),
|
|
11433
|
+
/* @__PURE__ */ jsx12(
|
|
11434
|
+
"input",
|
|
11435
|
+
{
|
|
11436
|
+
value: reference[field],
|
|
11437
|
+
onChange: (event) => onUpdate(reference.id, { [field]: event.currentTarget.value })
|
|
11438
|
+
}
|
|
11439
|
+
)
|
|
11440
|
+
] }, field)) })
|
|
11441
|
+
] }, reference.id)) })
|
|
11442
|
+
] }) });
|
|
11443
|
+
}
|
|
11444
|
+
|
|
10422
11445
|
// src/react-document2/editorFocus.ts
|
|
10423
11446
|
function createEmptyDocument2EditorFocus() {
|
|
10424
11447
|
return { blockId: null, fieldId: null, textTokenId: null, caretOffset: 0 };
|
|
@@ -10925,24 +11948,11 @@ var DOCUMENT2_WIDGET_CSS = `
|
|
|
10925
11948
|
grid-template-columns: minmax(0, 1fr) minmax(280px, 0.9fr);
|
|
10926
11949
|
}
|
|
10927
11950
|
|
|
10928
|
-
|
|
10929
|
-
|
|
10930
|
-
|
|
10931
|
-
|
|
10932
|
-
.butex-document2-widget__layout--editor-closed.butex-document2-widget__layout--preview-open {
|
|
10933
|
-
grid-template-columns: minmax(0, 0fr) minmax(0, 1fr);
|
|
10934
|
-
}
|
|
10935
|
-
|
|
11951
|
+
/* One visible panel: a single track so the panel fills the widget (previewOnly / hide editor / hide preview). */
|
|
11952
|
+
.butex-document2-widget__layout--editor-open.butex-document2-widget__layout--preview-closed,
|
|
11953
|
+
.butex-document2-widget__layout--editor-closed.butex-document2-widget__layout--preview-open,
|
|
10936
11954
|
.butex-document2-widget__layout--editor-closed.butex-document2-widget__layout--preview-closed {
|
|
10937
|
-
grid-template-columns: minmax(0, 1fr)
|
|
10938
|
-
}
|
|
10939
|
-
|
|
10940
|
-
.butex-document2-widget__layout--preview-open {
|
|
10941
|
-
grid-template-columns: minmax(0, 1fr) minmax(280px, 0.9fr);
|
|
10942
|
-
}
|
|
10943
|
-
|
|
10944
|
-
.butex-document2-widget__layout--preview-closed {
|
|
10945
|
-
grid-template-columns: minmax(0, 1fr) minmax(0, 0fr);
|
|
11955
|
+
grid-template-columns: minmax(0, 1fr);
|
|
10946
11956
|
}
|
|
10947
11957
|
|
|
10948
11958
|
.butex-document2-widget__editor-panel,
|
|
@@ -10960,24 +11970,16 @@ var DOCUMENT2_WIDGET_CSS = `
|
|
|
10960
11970
|
box-shadow 0.22s ease;
|
|
10961
11971
|
}
|
|
10962
11972
|
|
|
10963
|
-
|
|
10964
|
-
|
|
10965
|
-
|
|
10966
|
-
|
|
10967
|
-
|
|
10968
|
-
pointer-events: none;
|
|
10969
|
-
transform: translateX(10px);
|
|
10970
|
-
visibility: hidden;
|
|
11973
|
+
/* When previewOnly (or display:none) leaves a lone panel, span the full grid. */
|
|
11974
|
+
.butex-document2-widget__editor-panel:only-child,
|
|
11975
|
+
.butex-document2-widget__preview-panel:only-child {
|
|
11976
|
+
grid-column: 1 / -1;
|
|
11977
|
+
width: 100%;
|
|
10971
11978
|
}
|
|
10972
11979
|
|
|
11980
|
+
.butex-document2-widget__layout--editor-closed .butex-document2-widget__editor-panel,
|
|
10973
11981
|
.butex-document2-widget__layout--preview-closed .butex-document2-widget__preview-panel {
|
|
10974
|
-
|
|
10975
|
-
box-shadow: none;
|
|
10976
|
-
opacity: 0;
|
|
10977
|
-
padding-inline: 0;
|
|
10978
|
-
pointer-events: none;
|
|
10979
|
-
transform: translateX(-10px);
|
|
10980
|
-
visibility: hidden;
|
|
11982
|
+
display: none;
|
|
10981
11983
|
}
|
|
10982
11984
|
|
|
10983
11985
|
.butex-document2-widget__inline-field {
|
|
@@ -11151,6 +12153,13 @@ var DOCUMENT2_WIDGET_CSS = `
|
|
|
11151
12153
|
vertical-align: middle;
|
|
11152
12154
|
}
|
|
11153
12155
|
|
|
12156
|
+
/* Guard against host CSS resets (e.g. Tailwind Preflight's \`svg { display: block }\`).
|
|
12157
|
+
* MathJax v4 inline line-breaking emits an equation as several sibling <svg> chunks;
|
|
12158
|
+
* a block-level svg reset stacks them vertically inside the island. */
|
|
12159
|
+
.butex-document2-widget mjx-container svg {
|
|
12160
|
+
display: inline;
|
|
12161
|
+
}
|
|
12162
|
+
|
|
11154
12163
|
.butex-document2-widget__math-chip .butex-document2-widget__math-island {
|
|
11155
12164
|
margin: 0;
|
|
11156
12165
|
}
|
|
@@ -11312,18 +12321,13 @@ var DOCUMENT2_WIDGET_CSS = `
|
|
|
11312
12321
|
}
|
|
11313
12322
|
|
|
11314
12323
|
@media (max-width: 900px) {
|
|
11315
|
-
.butex-document2-widget__layout
|
|
11316
|
-
|
|
11317
|
-
|
|
11318
|
-
|
|
11319
|
-
.butex-document2-widget__layout--
|
|
11320
|
-
|
|
11321
|
-
}
|
|
11322
|
-
|
|
11323
|
-
.butex-document2-widget__layout--editor-closed .butex-document2-widget__editor-panel {
|
|
11324
|
-
display: none;
|
|
12324
|
+
.butex-document2-widget__layout,
|
|
12325
|
+
.butex-document2-widget__layout--editor-open.butex-document2-widget__layout--preview-open,
|
|
12326
|
+
.butex-document2-widget__layout--editor-open.butex-document2-widget__layout--preview-closed,
|
|
12327
|
+
.butex-document2-widget__layout--editor-closed.butex-document2-widget__layout--preview-open,
|
|
12328
|
+
.butex-document2-widget__layout--editor-closed.butex-document2-widget__layout--preview-closed {
|
|
12329
|
+
grid-template-columns: minmax(0, 1fr);
|
|
11325
12330
|
}
|
|
11326
|
-
|
|
11327
12331
|
}
|
|
11328
12332
|
|
|
11329
12333
|
@media (prefers-reduced-motion: reduce) {
|
|
@@ -11333,6 +12337,223 @@ var DOCUMENT2_WIDGET_CSS = `
|
|
|
11333
12337
|
transition: none;
|
|
11334
12338
|
}
|
|
11335
12339
|
}
|
|
12340
|
+
|
|
12341
|
+
.butex-document2-widget__cite-chip-wrap {
|
|
12342
|
+
align-items: center;
|
|
12343
|
+
display: inline-flex;
|
|
12344
|
+
gap: 2px;
|
|
12345
|
+
margin-inline: 2px;
|
|
12346
|
+
max-width: 100%;
|
|
12347
|
+
vertical-align: baseline;
|
|
12348
|
+
}
|
|
12349
|
+
|
|
12350
|
+
.butex-document2-widget__cite-chip {
|
|
12351
|
+
background: color-mix(in srgb, var(--butex-document2-accent) 8%, var(--butex-document2-panel));
|
|
12352
|
+
border: 1.5px solid color-mix(in srgb, var(--butex-document2-accent) 45%, var(--butex-document2-border));
|
|
12353
|
+
border-radius: 6px;
|
|
12354
|
+
color: inherit;
|
|
12355
|
+
cursor: pointer;
|
|
12356
|
+
display: inline-flex;
|
|
12357
|
+
font: inherit;
|
|
12358
|
+
font-variant-numeric: tabular-nums;
|
|
12359
|
+
line-height: 1.3;
|
|
12360
|
+
min-height: 28px;
|
|
12361
|
+
padding: 2px 8px;
|
|
12362
|
+
}
|
|
12363
|
+
|
|
12364
|
+
.butex-document2-widget__cite-chip[data-editable="false"] {
|
|
12365
|
+
border-style: dashed;
|
|
12366
|
+
cursor: default;
|
|
12367
|
+
}
|
|
12368
|
+
|
|
12369
|
+
.butex-document2-widget__cite-chip:hover,
|
|
12370
|
+
.butex-document2-widget__cite-chip:focus-visible {
|
|
12371
|
+
background: color-mix(in srgb, var(--butex-document2-accent) 14%, var(--butex-document2-panel));
|
|
12372
|
+
border-color: var(--butex-document2-accent);
|
|
12373
|
+
}
|
|
12374
|
+
|
|
12375
|
+
.butex-document2-widget__cite-chip-delete {
|
|
12376
|
+
background: transparent;
|
|
12377
|
+
border: none;
|
|
12378
|
+
color: var(--butex-document2-muted);
|
|
12379
|
+
cursor: pointer;
|
|
12380
|
+
font: inherit;
|
|
12381
|
+
line-height: 1;
|
|
12382
|
+
padding: 0 4px;
|
|
12383
|
+
}
|
|
12384
|
+
|
|
12385
|
+
.butex-document2-widget__preview-cite {
|
|
12386
|
+
color: inherit;
|
|
12387
|
+
font-variant-numeric: tabular-nums;
|
|
12388
|
+
white-space: nowrap;
|
|
12389
|
+
}
|
|
12390
|
+
|
|
12391
|
+
.butex-document2-widget__preview-bibliography,
|
|
12392
|
+
.butex-document2-widget__bibliography-editor {
|
|
12393
|
+
display: grid;
|
|
12394
|
+
gap: 0.5rem;
|
|
12395
|
+
list-style: none;
|
|
12396
|
+
margin: 0;
|
|
12397
|
+
padding: 0;
|
|
12398
|
+
}
|
|
12399
|
+
|
|
12400
|
+
.butex-document2-widget__preview-bibliography li,
|
|
12401
|
+
.butex-document2-widget__bibliography-editor li {
|
|
12402
|
+
display: grid;
|
|
12403
|
+
gap: 0.25rem;
|
|
12404
|
+
grid-template-columns: auto 1fr;
|
|
12405
|
+
}
|
|
12406
|
+
|
|
12407
|
+
.butex-document2-widget__preview-bib-number {
|
|
12408
|
+
font-variant-numeric: tabular-nums;
|
|
12409
|
+
}
|
|
12410
|
+
|
|
12411
|
+
.butex-document2-widget__block--bibliography {
|
|
12412
|
+
border-color: color-mix(in srgb, var(--butex-document2-accent) 35%, var(--butex-document2-border));
|
|
12413
|
+
}
|
|
12414
|
+
|
|
12415
|
+
.butex-document2-widget__digit-form-menu {
|
|
12416
|
+
position: relative;
|
|
12417
|
+
}
|
|
12418
|
+
|
|
12419
|
+
.butex-document2-widget__digit-form-options {
|
|
12420
|
+
background: var(--butex-document2-panel);
|
|
12421
|
+
border: 1px solid var(--butex-document2-border);
|
|
12422
|
+
border-radius: 8px;
|
|
12423
|
+
box-shadow: 0 8px 24px color-mix(in srgb, #000 16%, transparent);
|
|
12424
|
+
display: grid;
|
|
12425
|
+
gap: 2px;
|
|
12426
|
+
inset-inline-start: 0;
|
|
12427
|
+
margin-top: 4px;
|
|
12428
|
+
padding: 4px;
|
|
12429
|
+
position: absolute;
|
|
12430
|
+
top: 100%;
|
|
12431
|
+
z-index: 5;
|
|
12432
|
+
}
|
|
12433
|
+
|
|
12434
|
+
.butex-document2-widget__digit-form-option {
|
|
12435
|
+
background: transparent;
|
|
12436
|
+
border: none;
|
|
12437
|
+
border-radius: 6px;
|
|
12438
|
+
color: inherit;
|
|
12439
|
+
cursor: pointer;
|
|
12440
|
+
font: inherit;
|
|
12441
|
+
padding: 6px 10px;
|
|
12442
|
+
text-align: start;
|
|
12443
|
+
}
|
|
12444
|
+
|
|
12445
|
+
.butex-document2-widget__digit-form-option[aria-selected="true"],
|
|
12446
|
+
.butex-document2-widget__digit-form-option:hover {
|
|
12447
|
+
background: color-mix(in srgb, var(--butex-document2-accent) 12%, var(--butex-document2-panel));
|
|
12448
|
+
}
|
|
12449
|
+
|
|
12450
|
+
.butex-document2-widget__cite-picker-backdrop,
|
|
12451
|
+
.butex-document2-widget__refs-backdrop {
|
|
12452
|
+
align-items: center;
|
|
12453
|
+
background: color-mix(in srgb, #000 35%, transparent);
|
|
12454
|
+
display: flex;
|
|
12455
|
+
inset: 0;
|
|
12456
|
+
justify-content: center;
|
|
12457
|
+
padding: 1rem;
|
|
12458
|
+
position: fixed;
|
|
12459
|
+
z-index: 40;
|
|
12460
|
+
}
|
|
12461
|
+
|
|
12462
|
+
.butex-document2-widget__cite-picker,
|
|
12463
|
+
.butex-document2-widget__refs-panel {
|
|
12464
|
+
background: var(--butex-document2-panel);
|
|
12465
|
+
border: 1px solid var(--butex-document2-border);
|
|
12466
|
+
border-radius: 12px;
|
|
12467
|
+
box-shadow: 0 16px 40px color-mix(in srgb, #000 22%, transparent);
|
|
12468
|
+
display: grid;
|
|
12469
|
+
gap: 0.75rem;
|
|
12470
|
+
max-height: min(80vh, 640px);
|
|
12471
|
+
max-width: 560px;
|
|
12472
|
+
overflow: auto;
|
|
12473
|
+
padding: 1rem;
|
|
12474
|
+
width: min(100%, 560px);
|
|
12475
|
+
}
|
|
12476
|
+
|
|
12477
|
+
.butex-document2-widget__cite-picker-header,
|
|
12478
|
+
.butex-document2-widget__refs-header,
|
|
12479
|
+
.butex-document2-widget__cite-picker-footer,
|
|
12480
|
+
.butex-document2-widget__refs-item-head {
|
|
12481
|
+
align-items: center;
|
|
12482
|
+
display: flex;
|
|
12483
|
+
gap: 0.5rem;
|
|
12484
|
+
justify-content: space-between;
|
|
12485
|
+
}
|
|
12486
|
+
|
|
12487
|
+
.butex-document2-widget__cite-picker-list,
|
|
12488
|
+
.butex-document2-widget__refs-list {
|
|
12489
|
+
display: grid;
|
|
12490
|
+
gap: 0.5rem;
|
|
12491
|
+
list-style: none;
|
|
12492
|
+
margin: 0;
|
|
12493
|
+
padding: 0;
|
|
12494
|
+
}
|
|
12495
|
+
|
|
12496
|
+
.butex-document2-widget__cite-picker-item,
|
|
12497
|
+
.butex-document2-widget__refs-field {
|
|
12498
|
+
display: grid;
|
|
12499
|
+
gap: 0.25rem;
|
|
12500
|
+
}
|
|
12501
|
+
|
|
12502
|
+
.butex-document2-widget__cite-picker-item {
|
|
12503
|
+
align-items: start;
|
|
12504
|
+
grid-template-columns: auto 1fr;
|
|
12505
|
+
}
|
|
12506
|
+
|
|
12507
|
+
.butex-document2-widget__cite-picker-meta,
|
|
12508
|
+
.butex-document2-widget__cite-picker-empty {
|
|
12509
|
+
color: var(--butex-document2-muted);
|
|
12510
|
+
display: block;
|
|
12511
|
+
font-size: 0.92em;
|
|
12512
|
+
}
|
|
12513
|
+
|
|
12514
|
+
.butex-document2-widget__refs-grid {
|
|
12515
|
+
display: grid;
|
|
12516
|
+
gap: 0.5rem;
|
|
12517
|
+
grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
|
|
12518
|
+
}
|
|
12519
|
+
|
|
12520
|
+
.butex-document2-widget__refs-field input {
|
|
12521
|
+
background: var(--butex-document2-input-bg, var(--butex-document2-panel));
|
|
12522
|
+
border: 1px solid var(--butex-document2-border);
|
|
12523
|
+
border-radius: 6px;
|
|
12524
|
+
color: inherit;
|
|
12525
|
+
font: inherit;
|
|
12526
|
+
padding: 0.4rem 0.55rem;
|
|
12527
|
+
width: 100%;
|
|
12528
|
+
}
|
|
12529
|
+
|
|
12530
|
+
.butex-document2-widget__refs-item {
|
|
12531
|
+
border: 1px solid var(--butex-document2-border);
|
|
12532
|
+
border-radius: 10px;
|
|
12533
|
+
display: grid;
|
|
12534
|
+
gap: 0.5rem;
|
|
12535
|
+
padding: 0.75rem;
|
|
12536
|
+
}
|
|
12537
|
+
|
|
12538
|
+
.butex-document2-widget__refs-item-actions {
|
|
12539
|
+
display: inline-flex;
|
|
12540
|
+
gap: 0.25rem;
|
|
12541
|
+
}
|
|
12542
|
+
|
|
12543
|
+
.butex-document2-widget__primary-btn {
|
|
12544
|
+
background: var(--butex-document2-accent);
|
|
12545
|
+
border: none;
|
|
12546
|
+
border-radius: 8px;
|
|
12547
|
+
color: #fff;
|
|
12548
|
+
cursor: pointer;
|
|
12549
|
+
font: inherit;
|
|
12550
|
+
padding: 0.45rem 0.8rem;
|
|
12551
|
+
}
|
|
12552
|
+
|
|
12553
|
+
.butex-document2-widget__primary-btn:disabled {
|
|
12554
|
+
cursor: not-allowed;
|
|
12555
|
+
opacity: 0.55;
|
|
12556
|
+
}
|
|
11336
12557
|
`;
|
|
11337
12558
|
function injectBuTeXDocument2Styles(doc) {
|
|
11338
12559
|
const d = doc ?? (typeof document !== "undefined" ? document : void 0);
|
|
@@ -11350,7 +12571,7 @@ function injectBuTeXDocument2Styles(doc) {
|
|
|
11350
12571
|
}
|
|
11351
12572
|
|
|
11352
12573
|
// src/react-document2/ButexDocumentEditor2.tsx
|
|
11353
|
-
import { Fragment as Fragment4, jsx as
|
|
12574
|
+
import { Fragment as Fragment4, jsx as jsx13, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
11354
12575
|
function mathDelimiters(mode) {
|
|
11355
12576
|
return mode === "inline" ? { opening: "$", closing: "$" } : { opening: "\\[", closing: "\\]" };
|
|
11356
12577
|
}
|
|
@@ -11531,19 +12752,26 @@ function ButexDocumentEditor2({
|
|
|
11531
12752
|
previewOnly = false,
|
|
11532
12753
|
uiLocale = "ar",
|
|
11533
12754
|
mathOutput = "svg",
|
|
12755
|
+
digitForm: digitFormProp,
|
|
12756
|
+
onDigitFormChange,
|
|
12757
|
+
resolveImageUrl,
|
|
11534
12758
|
onDocumentChange,
|
|
11535
12759
|
onLatexChange
|
|
11536
12760
|
}) {
|
|
11537
12761
|
const messages = document2Messages(uiLocale);
|
|
11538
12762
|
const initialState = useMemo(() => resolveInitialDocument2(initialDocument, uiLocale), [initialDocument]);
|
|
11539
|
-
const [documentNode, setDocumentNode] =
|
|
11540
|
-
const [error, setError] =
|
|
11541
|
-
const [editorOpen, setEditorOpen] =
|
|
11542
|
-
const [previewOpen, setPreviewOpen] =
|
|
11543
|
-
const [selectedMath, setSelectedMath] =
|
|
11544
|
-
const [
|
|
11545
|
-
const [
|
|
11546
|
-
const [
|
|
12763
|
+
const [documentNode, setDocumentNode] = useState7(initialState.document);
|
|
12764
|
+
const [error, setError] = useState7(initialState.error);
|
|
12765
|
+
const [editorOpen, setEditorOpen] = useState7(true);
|
|
12766
|
+
const [previewOpen, setPreviewOpen] = useState7(true);
|
|
12767
|
+
const [selectedMath, setSelectedMath] = useState7(null);
|
|
12768
|
+
const [citePicker, setCitePicker] = useState7(null);
|
|
12769
|
+
const [referencesOpen, setReferencesOpen] = useState7(false);
|
|
12770
|
+
const [digitFormState, setDigitFormState] = useState7(null);
|
|
12771
|
+
const [editorFocus, setEditorFocus] = useState7(createEmptyDocument2EditorFocus());
|
|
12772
|
+
const [collapsedBlockIds, setCollapsedBlockIds] = useState7(() => /* @__PURE__ */ new Set());
|
|
12773
|
+
const [historyTick, setHistoryTick] = useState7(0);
|
|
12774
|
+
const digitForm = digitFormProp ?? digitFormState ?? (documentDirection === "rtl" ? "arabicIndic" : "western");
|
|
11547
12775
|
const historyRef = useRef6(createDocument2History());
|
|
11548
12776
|
const documentRef = useRef6(documentNode);
|
|
11549
12777
|
const textSnapshotArmedRef = useRef6(false);
|
|
@@ -11553,8 +12781,11 @@ function ButexDocumentEditor2({
|
|
|
11553
12781
|
documentRef.current = documentNode;
|
|
11554
12782
|
const latex = document2Latex(documentNode);
|
|
11555
12783
|
const preview = useMemo(
|
|
11556
|
-
() => document2Preview(documentNode, mathOutput, equationSide
|
|
11557
|
-
|
|
12784
|
+
() => document2Preview(documentNode, mathOutput, equationSide, {
|
|
12785
|
+
documentDirection,
|
|
12786
|
+
digitForm
|
|
12787
|
+
}),
|
|
12788
|
+
[documentNode, documentDirection, digitForm, equationSide, mathOutput]
|
|
11558
12789
|
);
|
|
11559
12790
|
const debugEnabled = useMemo(() => {
|
|
11560
12791
|
if (debug) {
|
|
@@ -11567,15 +12798,15 @@ function ButexDocumentEditor2({
|
|
|
11567
12798
|
}, [debug]);
|
|
11568
12799
|
const canUndo = useMemo(() => document2HistoryCanUndo(historyRef.current), [historyTick, documentNode]);
|
|
11569
12800
|
const canRedo = useMemo(() => document2HistoryCanRedo(historyRef.current), [historyTick, documentNode]);
|
|
11570
|
-
|
|
12801
|
+
useEffect6(() => {
|
|
11571
12802
|
injectBuTeXDocument2Styles();
|
|
11572
12803
|
}, []);
|
|
11573
|
-
|
|
12804
|
+
useEffect6(() => {
|
|
11574
12805
|
if (!editableEquations || previewOnly) {
|
|
11575
12806
|
setSelectedMath(null);
|
|
11576
12807
|
}
|
|
11577
12808
|
}, [editableEquations, previewOnly]);
|
|
11578
|
-
|
|
12809
|
+
useEffect6(() => {
|
|
11579
12810
|
const next = resolveInitialDocument2(initialDocument, uiLocale);
|
|
11580
12811
|
setDocumentNode(next.document);
|
|
11581
12812
|
setError(next.error);
|
|
@@ -11584,13 +12815,13 @@ function ButexDocumentEditor2({
|
|
|
11584
12815
|
historyRef.current = createDocument2History();
|
|
11585
12816
|
setHistoryTick((tick) => tick + 1);
|
|
11586
12817
|
}, [initialDocument]);
|
|
11587
|
-
|
|
12818
|
+
useEffect6(() => {
|
|
11588
12819
|
onDocumentChange?.(documentNode);
|
|
11589
12820
|
}, [documentNode, onDocumentChange]);
|
|
11590
|
-
|
|
12821
|
+
useEffect6(() => {
|
|
11591
12822
|
onLatexChange?.(latex);
|
|
11592
12823
|
}, [latex, onLatexChange]);
|
|
11593
|
-
|
|
12824
|
+
useEffect6(() => {
|
|
11594
12825
|
const pending = pendingFocusRef.current;
|
|
11595
12826
|
const root = widgetRef.current;
|
|
11596
12827
|
if (!pending || !root) {
|
|
@@ -11605,6 +12836,13 @@ function ButexDocumentEditor2({
|
|
|
11605
12836
|
mathButton?.focus();
|
|
11606
12837
|
return;
|
|
11607
12838
|
}
|
|
12839
|
+
if (pending.kind === "cite") {
|
|
12840
|
+
const citeButton = Array.from(root.querySelectorAll("[data-cite-token-id]")).find(
|
|
12841
|
+
(button) => button.dataset.citeTokenId === pending.tokenId
|
|
12842
|
+
);
|
|
12843
|
+
citeButton?.focus();
|
|
12844
|
+
return;
|
|
12845
|
+
}
|
|
11608
12846
|
const textarea = Array.from(root.querySelectorAll("textarea[data-field-id][data-text-token-id]")).find(
|
|
11609
12847
|
(element) => element.dataset.fieldId === pending.fieldId && element.dataset.textTokenId === pending.textTokenId
|
|
11610
12848
|
);
|
|
@@ -11690,7 +12928,7 @@ function ButexDocumentEditor2({
|
|
|
11690
12928
|
function openAllBlocks() {
|
|
11691
12929
|
setCollapsedBlockIds(/* @__PURE__ */ new Set());
|
|
11692
12930
|
}
|
|
11693
|
-
|
|
12931
|
+
useEffect6(() => {
|
|
11694
12932
|
const root = widgetRef.current;
|
|
11695
12933
|
if (!root) {
|
|
11696
12934
|
return;
|
|
@@ -11863,24 +13101,70 @@ function ButexDocumentEditor2({
|
|
|
11863
13101
|
pendingFocusRef.current = focusAfterDeletedMath(current, next, tokenId);
|
|
11864
13102
|
applyDocument(next, "immediate");
|
|
11865
13103
|
}
|
|
13104
|
+
function openCitePickerForInsert() {
|
|
13105
|
+
const target = resolveInsertField(documentRef.current, editorFocus);
|
|
13106
|
+
setCitePicker({
|
|
13107
|
+
tokenId: null,
|
|
13108
|
+
fieldId: target?.fieldId ?? null,
|
|
13109
|
+
textTokenId: target?.textTokenId ?? editorFocus.textTokenId,
|
|
13110
|
+
caretOffset: target?.caretOffset ?? editorFocus.caretOffset,
|
|
13111
|
+
keys: []
|
|
13112
|
+
});
|
|
13113
|
+
}
|
|
13114
|
+
function openCite(token) {
|
|
13115
|
+
setCitePicker({
|
|
13116
|
+
tokenId: token.id,
|
|
13117
|
+
fieldId: null,
|
|
13118
|
+
textTokenId: null,
|
|
13119
|
+
caretOffset: 0,
|
|
13120
|
+
keys: [...token.keys]
|
|
13121
|
+
});
|
|
13122
|
+
}
|
|
13123
|
+
function confirmCiteKeys(keys) {
|
|
13124
|
+
if (!citePicker || keys.length === 0) {
|
|
13125
|
+
setCitePicker(null);
|
|
13126
|
+
return;
|
|
13127
|
+
}
|
|
13128
|
+
if (citePicker.tokenId) {
|
|
13129
|
+
applyDocument(updateCiteTokenKeys(documentRef.current, citePicker.tokenId, keys), "immediate");
|
|
13130
|
+
pendingFocusRef.current = { kind: "cite", tokenId: citePicker.tokenId };
|
|
13131
|
+
setCitePicker(null);
|
|
13132
|
+
return;
|
|
13133
|
+
}
|
|
13134
|
+
const target = resolveInsertField(documentRef.current, editorFocus);
|
|
13135
|
+
const fieldId = citePicker.fieldId ?? target?.fieldId;
|
|
13136
|
+
if (!fieldId) {
|
|
13137
|
+
setCitePicker(null);
|
|
13138
|
+
return;
|
|
13139
|
+
}
|
|
13140
|
+
const textTokenId = citePicker.textTokenId ?? target?.textTokenId ?? null;
|
|
13141
|
+
const caretOffset = citePicker.caretOffset ?? target?.caretOffset ?? 0;
|
|
13142
|
+
const next = insertCiteTokenAtCaret(documentRef.current, fieldId, textTokenId, caretOffset, keys);
|
|
13143
|
+
applyDocument(next, "immediate");
|
|
13144
|
+
setCitePicker(null);
|
|
13145
|
+
}
|
|
13146
|
+
function deleteCiteToken(tokenId) {
|
|
13147
|
+
applyDocument(removeCiteTokenById(documentRef.current, tokenId), "immediate");
|
|
13148
|
+
}
|
|
11866
13149
|
const showEditorPanel = !previewOnly && editorOpen;
|
|
11867
13150
|
const showPreviewPanel = previewOnly || previewOpen;
|
|
11868
|
-
return /* @__PURE__ */
|
|
13151
|
+
return /* @__PURE__ */ jsx13(
|
|
11869
13152
|
"div",
|
|
11870
13153
|
{
|
|
11871
13154
|
ref: widgetRef,
|
|
11872
13155
|
className: ["butex-document2-widget", className].filter(Boolean).join(" "),
|
|
11873
13156
|
dir: uiLocaleDirection(uiLocale),
|
|
11874
13157
|
lang: uiLocale,
|
|
11875
|
-
children: /* @__PURE__ */
|
|
11876
|
-
!previewOnly ? /* @__PURE__ */
|
|
11877
|
-
/* @__PURE__ */
|
|
13158
|
+
children: /* @__PURE__ */ jsxs11("div", { className: "butex-document2-widget__shell", children: [
|
|
13159
|
+
!previewOnly ? /* @__PURE__ */ jsxs11("div", { className: "butex-document2-widget__toolbar", children: [
|
|
13160
|
+
/* @__PURE__ */ jsx13(
|
|
11878
13161
|
DocumentInsertToolbar,
|
|
11879
13162
|
{
|
|
11880
13163
|
canUndo,
|
|
11881
13164
|
canRedo,
|
|
11882
13165
|
editableEquations,
|
|
11883
13166
|
uiLocale,
|
|
13167
|
+
digitForm,
|
|
11884
13168
|
onUndo: undoDocument,
|
|
11885
13169
|
onRedo: redoDocument,
|
|
11886
13170
|
onAddSection: () => applyDocument(addDocument2TextBlock(documentRef.current, "\\section", afterBlockId()), "immediate"),
|
|
@@ -11892,45 +13176,57 @@ function ButexDocumentEditor2({
|
|
|
11892
13176
|
onAddTable: (rowCount, colCount) => applyDocument(addDocument2TableBlock(documentRef.current, "l".repeat(colCount), rowCount, colCount, afterBlockId()), "immediate"),
|
|
11893
13177
|
onAddList: () => applyDocument(addDocument2ListBlock(documentRef.current, false, afterBlockId()), "immediate"),
|
|
11894
13178
|
onAddEnumerate: () => applyDocument(addDocument2ListBlock(documentRef.current, true, afterBlockId()), "immediate"),
|
|
11895
|
-
onAddFigure: () => applyDocument(addDocument2ImageBlock(documentRef.current, "", afterBlockId()), "immediate")
|
|
13179
|
+
onAddFigure: () => applyDocument(addDocument2ImageBlock(documentRef.current, "", afterBlockId()), "immediate"),
|
|
13180
|
+
onInsertCitation: openCitePickerForInsert,
|
|
13181
|
+
onInsertBibliography: () => applyDocument(ensureDocument2BibliographyBlock(documentRef.current, afterBlockId()), "immediate"),
|
|
13182
|
+
onManageReferences: () => setReferencesOpen(true),
|
|
13183
|
+
onDigitFormChange: (next) => {
|
|
13184
|
+
setDigitFormState(next);
|
|
13185
|
+
onDigitFormChange?.(next);
|
|
13186
|
+
}
|
|
11896
13187
|
}
|
|
11897
13188
|
),
|
|
11898
|
-
/* @__PURE__ */
|
|
11899
|
-
/* @__PURE__ */
|
|
11900
|
-
/* @__PURE__ */
|
|
13189
|
+
/* @__PURE__ */ jsxs11("div", { className: "butex-document2-widget__toolbar-group", role: "group", "aria-label": messages.panels, children: [
|
|
13190
|
+
/* @__PURE__ */ jsx13("button", { type: "button", "aria-pressed": editorOpen, onClick: toggleEditorPanel, children: editorOpen ? messages.hideEditor : messages.editor }),
|
|
13191
|
+
/* @__PURE__ */ jsx13("button", { type: "button", "aria-pressed": previewOpen, onClick: togglePreviewPanel, children: previewOpen ? messages.hidePreview : messages.preview })
|
|
11901
13192
|
] }),
|
|
11902
|
-
/* @__PURE__ */
|
|
11903
|
-
/* @__PURE__ */
|
|
11904
|
-
/* @__PURE__ */
|
|
13193
|
+
/* @__PURE__ */ jsxs11("div", { className: "butex-document2-widget__toolbar-group", role: "group", "aria-label": messages.collapseBlocks, children: [
|
|
13194
|
+
/* @__PURE__ */ jsx13("button", { type: "button", onClick: collapseAllBlocks, children: messages.collapseAll }),
|
|
13195
|
+
/* @__PURE__ */ jsx13("button", { type: "button", onClick: openAllBlocks, children: messages.openAll })
|
|
11905
13196
|
] })
|
|
11906
13197
|
] }) : null,
|
|
11907
|
-
error ? /* @__PURE__ */
|
|
11908
|
-
/* @__PURE__ */
|
|
13198
|
+
error ? /* @__PURE__ */ jsx13("p", { className: "butex-document2-widget__error", children: error }) : null,
|
|
13199
|
+
/* @__PURE__ */ jsxs11(
|
|
11909
13200
|
"div",
|
|
11910
13201
|
{
|
|
11911
13202
|
className: `butex-document2-widget__layout butex-document2-widget__layout--editor-${showEditorPanel ? "open" : "closed"} butex-document2-widget__layout--preview-${showPreviewPanel ? "open" : "closed"}`,
|
|
11912
13203
|
children: [
|
|
11913
|
-
!previewOnly ? /* @__PURE__ */
|
|
13204
|
+
!previewOnly ? /* @__PURE__ */ jsx13(
|
|
11914
13205
|
"section",
|
|
11915
13206
|
{
|
|
11916
13207
|
className: "butex-document2-widget__panel butex-document2-widget__editor-panel",
|
|
11917
13208
|
"aria-label": messages.documentEditor,
|
|
11918
13209
|
"aria-hidden": !showEditorPanel,
|
|
11919
|
-
children: /* @__PURE__ */
|
|
13210
|
+
children: /* @__PURE__ */ jsx13("div", { className: "butex-document2-widget__blocks", children: documentNode.blocks.map((block, blockIndex) => /* @__PURE__ */ jsx13(
|
|
11920
13211
|
BlockEditor,
|
|
11921
13212
|
{
|
|
11922
13213
|
block,
|
|
11923
13214
|
blockIndex,
|
|
11924
13215
|
blockCount: documentNode.blocks.length,
|
|
13216
|
+
references: documentNode.references,
|
|
11925
13217
|
documentDirection,
|
|
13218
|
+
digitForm,
|
|
11926
13219
|
mathOutput,
|
|
11927
13220
|
equationSide,
|
|
11928
13221
|
editableEquations,
|
|
13222
|
+
editableCitations: !previewOnly,
|
|
11929
13223
|
uiLocale,
|
|
11930
13224
|
isCollapsed: collapsedBlockIds.has(block.id),
|
|
11931
13225
|
onTextChange: (fieldId, tokenId, text) => applyDocument(updateTextToken(documentRef.current, fieldId, tokenId, text), "text"),
|
|
11932
13226
|
onOpenMath: openMath,
|
|
11933
13227
|
onDeleteMath: editableEquations ? deleteMathToken : void 0,
|
|
13228
|
+
onOpenCite: openCite,
|
|
13229
|
+
onDeleteCite: deleteCiteToken,
|
|
11934
13230
|
onRemoveBlock: (blockId) => applyDocument(removeDocument2BlockById(documentRef.current, blockId), "immediate"),
|
|
11935
13231
|
onMoveBlock: (blockId, direction) => applyDocument(moveDocument2BlockById(documentRef.current, blockId, direction), "immediate"),
|
|
11936
13232
|
onToggleCollapse: toggleBlockCollapse,
|
|
@@ -11940,35 +13236,45 @@ function ButexDocumentEditor2({
|
|
|
11940
13236
|
onFieldBlur,
|
|
11941
13237
|
onImageSrcChange: (blockId, value) => applyDocument(updateDocument2ImageValue(documentRef.current, blockId, value), "text"),
|
|
11942
13238
|
onAddListItem: (listBlockId) => applyDocument(addDocument2ListItem(documentRef.current, listBlockId), "immediate"),
|
|
11943
|
-
onRemoveListItem: (listBlockId, itemId) => applyDocument(removeDocument2ListItem(documentRef.current, listBlockId, itemId), "immediate")
|
|
13239
|
+
onRemoveListItem: (listBlockId, itemId) => applyDocument(removeDocument2ListItem(documentRef.current, listBlockId, itemId), "immediate"),
|
|
13240
|
+
onManageReferences: () => setReferencesOpen(true)
|
|
11944
13241
|
},
|
|
11945
13242
|
block.id
|
|
11946
13243
|
)) })
|
|
11947
13244
|
}
|
|
11948
13245
|
) : null,
|
|
11949
|
-
/* @__PURE__ */
|
|
13246
|
+
/* @__PURE__ */ jsx13(
|
|
11950
13247
|
"section",
|
|
11951
13248
|
{
|
|
11952
13249
|
className: "butex-document2-widget__panel butex-document2-widget__preview-panel",
|
|
11953
13250
|
"aria-label": messages.documentPreview,
|
|
11954
13251
|
"aria-hidden": !showPreviewPanel,
|
|
11955
|
-
children: /* @__PURE__ */
|
|
13252
|
+
children: /* @__PURE__ */ jsx13(
|
|
13253
|
+
DocumentPreview,
|
|
13254
|
+
{
|
|
13255
|
+
blocks: preview.blocks,
|
|
13256
|
+
output: mathOutput,
|
|
13257
|
+
documentDirection,
|
|
13258
|
+
uiLocale,
|
|
13259
|
+
resolveImageUrl
|
|
13260
|
+
}
|
|
13261
|
+
)
|
|
11956
13262
|
}
|
|
11957
13263
|
)
|
|
11958
13264
|
]
|
|
11959
13265
|
}
|
|
11960
13266
|
),
|
|
11961
|
-
debugEnabled ? /* @__PURE__ */
|
|
11962
|
-
debugEnabled && documentNode.diagnostics.length > 0 ? /* @__PURE__ */
|
|
11963
|
-
/* @__PURE__ */
|
|
11964
|
-
documentNode.diagnostics.map((diagnostic) => /* @__PURE__ */
|
|
13267
|
+
debugEnabled ? /* @__PURE__ */ jsxs11("div", { className: "butex-document2-widget__dev", children: [
|
|
13268
|
+
debugEnabled && documentNode.diagnostics.length > 0 ? /* @__PURE__ */ jsxs11(Fragment4, { children: [
|
|
13269
|
+
/* @__PURE__ */ jsx13("strong", { children: messages.importWarnings }),
|
|
13270
|
+
documentNode.diagnostics.map((diagnostic) => /* @__PURE__ */ jsx13("p", { className: "butex-document2-widget__dev-diagnostic", children: formatDocument2Diagnostic(diagnostic, messages) }, `${diagnostic.path}-${diagnostic.message}`))
|
|
11965
13271
|
] }) : null,
|
|
11966
|
-
/* @__PURE__ */
|
|
11967
|
-
/* @__PURE__ */
|
|
11968
|
-
/* @__PURE__ */
|
|
11969
|
-
/* @__PURE__ */
|
|
13272
|
+
/* @__PURE__ */ jsx13("strong", { children: "LaTeX" }),
|
|
13273
|
+
/* @__PURE__ */ jsx13("pre", { children: latex }),
|
|
13274
|
+
/* @__PURE__ */ jsx13("strong", { children: "AST" }),
|
|
13275
|
+
/* @__PURE__ */ jsx13("pre", { children: JSON.stringify(documentNode, null, 2) })
|
|
11970
13276
|
] }) : null,
|
|
11971
|
-
!previewOnly && selectedMath ? /* @__PURE__ */
|
|
13277
|
+
!previewOnly && selectedMath ? /* @__PURE__ */ jsx13(
|
|
11972
13278
|
EquationDrawer,
|
|
11973
13279
|
{
|
|
11974
13280
|
session: selectedMath.session,
|
|
@@ -11982,6 +13288,34 @@ function ButexDocumentEditor2({
|
|
|
11982
13288
|
onSave: saveEquation,
|
|
11983
13289
|
onDelete: deleteSelectedEquation
|
|
11984
13290
|
}
|
|
13291
|
+
) : null,
|
|
13292
|
+
!previewOnly ? /* @__PURE__ */ jsx13(
|
|
13293
|
+
CitePickerPopover,
|
|
13294
|
+
{
|
|
13295
|
+
open: citePicker !== null,
|
|
13296
|
+
references: documentNode.references,
|
|
13297
|
+
initialKeys: citePicker?.keys ?? [],
|
|
13298
|
+
uiLocale,
|
|
13299
|
+
onClose: () => setCitePicker(null),
|
|
13300
|
+
onConfirm: confirmCiteKeys,
|
|
13301
|
+
onManageReferences: () => {
|
|
13302
|
+
setCitePicker(null);
|
|
13303
|
+
setReferencesOpen(true);
|
|
13304
|
+
}
|
|
13305
|
+
}
|
|
13306
|
+
) : null,
|
|
13307
|
+
!previewOnly ? /* @__PURE__ */ jsx13(
|
|
13308
|
+
ReferencesPanel,
|
|
13309
|
+
{
|
|
13310
|
+
open: referencesOpen,
|
|
13311
|
+
references: documentNode.references,
|
|
13312
|
+
uiLocale,
|
|
13313
|
+
onClose: () => setReferencesOpen(false),
|
|
13314
|
+
onAdd: (partial) => applyDocument(addDocument2Reference(documentRef.current, partial), "immediate"),
|
|
13315
|
+
onUpdate: (referenceId, patch) => applyDocument(updateDocument2Reference(documentRef.current, referenceId, patch), "immediate"),
|
|
13316
|
+
onRemove: (referenceId) => applyDocument(removeDocument2Reference(documentRef.current, referenceId), "immediate"),
|
|
13317
|
+
onMove: (referenceId, direction) => applyDocument(moveDocument2Reference(documentRef.current, referenceId, direction), "immediate")
|
|
13318
|
+
}
|
|
11985
13319
|
) : null
|
|
11986
13320
|
] })
|
|
11987
13321
|
}
|