@drghaliasri/butex 5.3.3 → 5.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/document.d.mts +4 -1
- package/dist/document.d.ts +4 -1
- package/dist/document.js +310 -0
- package/dist/document.js.map +1 -1
- package/dist/document.mjs +310 -0
- package/dist/document.mjs.map +1 -1
- package/dist/document2.d.mts +4 -1
- package/dist/document2.d.ts +4 -1
- package/dist/document2.js +429 -2
- package/dist/document2.js.map +1 -1
- package/dist/document2.mjs +429 -2
- package/dist/document2.mjs.map +1 -1
- package/dist/index.d.mts +188 -3
- package/dist/index.d.ts +188 -3
- package/dist/index.global.js +848 -3
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +848 -3
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +848 -3
- package/dist/index.mjs.map +1 -1
- package/dist/react-document.js +1037 -4
- package/dist/react-document.js.map +1 -1
- package/dist/react-document.mjs +1037 -4
- package/dist/react-document.mjs.map +1 -1
- package/dist/react-document2.d.mts +4 -1
- package/dist/react-document2.d.ts +4 -1
- package/dist/react-document2.js +1039 -6
- package/dist/react-document2.js.map +1 -1
- package/dist/react-document2.mjs +1039 -6
- package/dist/react-document2.mjs.map +1 -1
- package/dist/react.d.mts +141 -1
- package/dist/react.d.ts +141 -1
- package/dist/react.js +919 -4
- package/dist/react.js.map +1 -1
- package/dist/react.mjs +919 -4
- package/dist/react.mjs.map +1 -1
- package/package.json +1 -1
package/dist/document2.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
type EditorSide = 'english' | 'arabic';
|
|
2
|
-
type EditorNodeKind = 'char' | 'number' | 'operator' | 'delimiter' | 'frac' | 'sqrt' | 'env' | 'atomicCommand' | 'atomicOperatorCommand';
|
|
2
|
+
type EditorNodeKind = 'char' | 'number' | 'operator' | 'delimiter' | 'frac' | 'sqrt' | 'overset' | 'underset' | 'accent' | 'env' | 'atomicCommand' | 'atomicOperatorCommand';
|
|
3
3
|
type MatrixEnvStyle = 'matrix' | 'pmatrix' | 'bmatrix' | 'Bmatrix' | 'vmatrix' | 'Vmatrix';
|
|
4
4
|
type GridEnvName = MatrixEnvStyle | 'array' | 'aligned';
|
|
5
5
|
type EnvColumnAlignment = 'l' | 'c' | 'r';
|
|
@@ -24,6 +24,9 @@ type EditorNode = {
|
|
|
24
24
|
denominator: EditorChain | null;
|
|
25
25
|
radicand: EditorChain | null;
|
|
26
26
|
rootIndex: EditorChain | null;
|
|
27
|
+
overExpr: EditorChain | null;
|
|
28
|
+
underExpr: EditorChain | null;
|
|
29
|
+
baseExpr: EditorChain | null;
|
|
27
30
|
envName: GridEnvName | null;
|
|
28
31
|
matrixStyle: MatrixEnvStyle | null;
|
|
29
32
|
matrixRows: EditorChain[][] | null;
|
package/dist/document2.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
type EditorSide = 'english' | 'arabic';
|
|
2
|
-
type EditorNodeKind = 'char' | 'number' | 'operator' | 'delimiter' | 'frac' | 'sqrt' | 'env' | 'atomicCommand' | 'atomicOperatorCommand';
|
|
2
|
+
type EditorNodeKind = 'char' | 'number' | 'operator' | 'delimiter' | 'frac' | 'sqrt' | 'overset' | 'underset' | 'accent' | 'env' | 'atomicCommand' | 'atomicOperatorCommand';
|
|
3
3
|
type MatrixEnvStyle = 'matrix' | 'pmatrix' | 'bmatrix' | 'Bmatrix' | 'vmatrix' | 'Vmatrix';
|
|
4
4
|
type GridEnvName = MatrixEnvStyle | 'array' | 'aligned';
|
|
5
5
|
type EnvColumnAlignment = 'l' | 'c' | 'r';
|
|
@@ -24,6 +24,9 @@ type EditorNode = {
|
|
|
24
24
|
denominator: EditorChain | null;
|
|
25
25
|
radicand: EditorChain | null;
|
|
26
26
|
rootIndex: EditorChain | null;
|
|
27
|
+
overExpr: EditorChain | null;
|
|
28
|
+
underExpr: EditorChain | null;
|
|
29
|
+
baseExpr: EditorChain | null;
|
|
27
30
|
envName: GridEnvName | null;
|
|
28
31
|
matrixStyle: MatrixEnvStyle | null;
|
|
29
32
|
matrixRows: EditorChain[][] | null;
|
package/dist/document2.js
CHANGED
|
@@ -1501,6 +1501,155 @@ function createEmptyDocument2() {
|
|
|
1501
1501
|
};
|
|
1502
1502
|
}
|
|
1503
1503
|
|
|
1504
|
+
// src/editor/accentCommands.ts
|
|
1505
|
+
var ACCENT_COMMANDS = {
|
|
1506
|
+
vec: {
|
|
1507
|
+
id: "vec",
|
|
1508
|
+
englishTex: "\\vec",
|
|
1509
|
+
arabicTex: "\\arabvec",
|
|
1510
|
+
placement: "over",
|
|
1511
|
+
label: "\u20D7",
|
|
1512
|
+
title: "\u0633\u0647\u0645 \u0641\u0648\u0642"
|
|
1513
|
+
},
|
|
1514
|
+
hat: {
|
|
1515
|
+
id: "hat",
|
|
1516
|
+
englishTex: "\\hat",
|
|
1517
|
+
arabicTex: "\\hat",
|
|
1518
|
+
placement: "over",
|
|
1519
|
+
label: "\u02C6",
|
|
1520
|
+
title: "\u0642\u0628\u0639\u0629"
|
|
1521
|
+
},
|
|
1522
|
+
tilde: {
|
|
1523
|
+
id: "tilde",
|
|
1524
|
+
englishTex: "\\tilde",
|
|
1525
|
+
arabicTex: "\\tilde",
|
|
1526
|
+
placement: "over",
|
|
1527
|
+
label: "\u02DC",
|
|
1528
|
+
title: "\u0645\u062F\u0629"
|
|
1529
|
+
},
|
|
1530
|
+
dot: {
|
|
1531
|
+
id: "dot",
|
|
1532
|
+
englishTex: "\\dot",
|
|
1533
|
+
arabicTex: "\\dot",
|
|
1534
|
+
placement: "over",
|
|
1535
|
+
label: "\u02D9",
|
|
1536
|
+
title: "\u0646\u0642\u0637\u0629 \u0641\u0648\u0642"
|
|
1537
|
+
},
|
|
1538
|
+
ddot: {
|
|
1539
|
+
id: "ddot",
|
|
1540
|
+
englishTex: "\\ddot",
|
|
1541
|
+
arabicTex: "\\ddot",
|
|
1542
|
+
placement: "over",
|
|
1543
|
+
label: "\xA8",
|
|
1544
|
+
title: "\u0646\u0642\u0637\u062A\u0627\u0646 \u0641\u0648\u0642"
|
|
1545
|
+
},
|
|
1546
|
+
dddot: {
|
|
1547
|
+
id: "dddot",
|
|
1548
|
+
englishTex: "\\dddot",
|
|
1549
|
+
arabicTex: "\\dddot",
|
|
1550
|
+
placement: "over",
|
|
1551
|
+
label: "\u20DB",
|
|
1552
|
+
title: "\u062B\u0644\u0627\u062B \u0646\u0642\u0627\u0637 \u0641\u0648\u0642"
|
|
1553
|
+
},
|
|
1554
|
+
bar: {
|
|
1555
|
+
id: "bar",
|
|
1556
|
+
englishTex: "\\bar",
|
|
1557
|
+
arabicTex: "\\bar",
|
|
1558
|
+
placement: "over",
|
|
1559
|
+
label: "\xAF",
|
|
1560
|
+
title: "\u062E\u0637 \u0641\u0648\u0642"
|
|
1561
|
+
},
|
|
1562
|
+
check: {
|
|
1563
|
+
id: "check",
|
|
1564
|
+
englishTex: "\\check",
|
|
1565
|
+
arabicTex: "\\check",
|
|
1566
|
+
placement: "over",
|
|
1567
|
+
label: "\u02C7",
|
|
1568
|
+
title: "\u0639\u0644\u0627\u0645\u0629 \u062A\u062D\u0642\u0642"
|
|
1569
|
+
},
|
|
1570
|
+
breve: {
|
|
1571
|
+
id: "breve",
|
|
1572
|
+
englishTex: "\\breve",
|
|
1573
|
+
arabicTex: "\\breve",
|
|
1574
|
+
placement: "over",
|
|
1575
|
+
label: "\u02D8",
|
|
1576
|
+
title: "\u0642\u0648\u0633 \u0642\u0635\u064A\u0631"
|
|
1577
|
+
},
|
|
1578
|
+
acute: {
|
|
1579
|
+
id: "acute",
|
|
1580
|
+
englishTex: "\\acute",
|
|
1581
|
+
arabicTex: "\\grave",
|
|
1582
|
+
placement: "over",
|
|
1583
|
+
label: "\xB4",
|
|
1584
|
+
title: "\u0646\u0628\u0631\u0629 \u062D\u0627\u062F\u0629"
|
|
1585
|
+
},
|
|
1586
|
+
grave: {
|
|
1587
|
+
id: "grave",
|
|
1588
|
+
englishTex: "\\grave",
|
|
1589
|
+
arabicTex: "\\acute",
|
|
1590
|
+
placement: "over",
|
|
1591
|
+
label: "`",
|
|
1592
|
+
title: "\u0646\u0628\u0631\u0629 \u062B\u0642\u064A\u0644\u0629"
|
|
1593
|
+
},
|
|
1594
|
+
overline: {
|
|
1595
|
+
id: "overline",
|
|
1596
|
+
englishTex: "\\overline",
|
|
1597
|
+
arabicTex: "\\overline",
|
|
1598
|
+
placement: "over",
|
|
1599
|
+
label: "\u203E",
|
|
1600
|
+
title: "\u062E\u0637 \u0639\u0644\u0648\u064A \u0645\u0645\u062A\u062F"
|
|
1601
|
+
},
|
|
1602
|
+
underline: {
|
|
1603
|
+
id: "underline",
|
|
1604
|
+
englishTex: "\\underline",
|
|
1605
|
+
arabicTex: "\\underline",
|
|
1606
|
+
placement: "under",
|
|
1607
|
+
label: "_",
|
|
1608
|
+
title: "\u062E\u0637 \u0633\u0641\u0644\u064A"
|
|
1609
|
+
},
|
|
1610
|
+
overleftarrow: {
|
|
1611
|
+
id: "overleftarrow",
|
|
1612
|
+
englishTex: "\\overleftarrow",
|
|
1613
|
+
arabicTex: "\\overrightarrow",
|
|
1614
|
+
placement: "over",
|
|
1615
|
+
label: "\u2190",
|
|
1616
|
+
title: "\u0633\u0647\u0645 \u0639\u0644\u0648\u064A \u0625\u0644\u0649 \u0627\u0644\u064A\u0633\u0627\u0631"
|
|
1617
|
+
},
|
|
1618
|
+
overrightarrow: {
|
|
1619
|
+
id: "overrightarrow",
|
|
1620
|
+
englishTex: "\\overrightarrow",
|
|
1621
|
+
arabicTex: "\\overleftarrow",
|
|
1622
|
+
placement: "over",
|
|
1623
|
+
label: "\u2192",
|
|
1624
|
+
title: "\u0633\u0647\u0645 \u0639\u0644\u0648\u064A \u0625\u0644\u0649 \u0627\u0644\u064A\u0645\u064A\u0646"
|
|
1625
|
+
},
|
|
1626
|
+
overleftrightarrow: {
|
|
1627
|
+
id: "overleftrightarrow",
|
|
1628
|
+
englishTex: "\\overleftrightarrow",
|
|
1629
|
+
arabicTex: "\\overleftrightarrow",
|
|
1630
|
+
placement: "over",
|
|
1631
|
+
label: "\u2194",
|
|
1632
|
+
title: "\u0633\u0647\u0645 \u0639\u0644\u0648\u064A \u0645\u0632\u062F\u0648\u062C \u0627\u0644\u0627\u062A\u062C\u0627\u0647"
|
|
1633
|
+
}
|
|
1634
|
+
};
|
|
1635
|
+
function accentCommandSpec(id) {
|
|
1636
|
+
return Object.prototype.hasOwnProperty.call(ACCENT_COMMANDS, id) ? ACCENT_COMMANDS[id] : null;
|
|
1637
|
+
}
|
|
1638
|
+
function accentCommandIdFromTex(tex) {
|
|
1639
|
+
const normalized = tex.startsWith("\\") ? tex : `\\${tex}`;
|
|
1640
|
+
for (const spec of Object.values(ACCENT_COMMANDS)) {
|
|
1641
|
+
if (spec.englishTex === normalized) {
|
|
1642
|
+
return spec.id;
|
|
1643
|
+
}
|
|
1644
|
+
}
|
|
1645
|
+
for (const spec of Object.values(ACCENT_COMMANDS)) {
|
|
1646
|
+
if (spec.arabicTex === normalized) {
|
|
1647
|
+
return spec.id;
|
|
1648
|
+
}
|
|
1649
|
+
}
|
|
1650
|
+
return null;
|
|
1651
|
+
}
|
|
1652
|
+
|
|
1504
1653
|
// src/editor/atomicCommands.ts
|
|
1505
1654
|
var ATOMIC_COMMANDS = {
|
|
1506
1655
|
///////////////////////// Functions ////////////////////////////////
|
|
@@ -2406,6 +2555,9 @@ function createEditorNode(kind, expr) {
|
|
|
2406
2555
|
denominator: null,
|
|
2407
2556
|
radicand: null,
|
|
2408
2557
|
rootIndex: null,
|
|
2558
|
+
overExpr: null,
|
|
2559
|
+
underExpr: null,
|
|
2560
|
+
baseExpr: null,
|
|
2409
2561
|
envName: null,
|
|
2410
2562
|
matrixStyle: null,
|
|
2411
2563
|
matrixRows: null,
|
|
@@ -2434,6 +2586,26 @@ function createSqrtNode() {
|
|
|
2434
2586
|
rootIndex: createEditorChain()
|
|
2435
2587
|
};
|
|
2436
2588
|
}
|
|
2589
|
+
function createOversetNode() {
|
|
2590
|
+
return {
|
|
2591
|
+
...createEditorNode("overset", ""),
|
|
2592
|
+
overExpr: createEditorChain(),
|
|
2593
|
+
baseExpr: createEditorChain()
|
|
2594
|
+
};
|
|
2595
|
+
}
|
|
2596
|
+
function createUndersetNode() {
|
|
2597
|
+
return {
|
|
2598
|
+
...createEditorNode("underset", ""),
|
|
2599
|
+
underExpr: createEditorChain(),
|
|
2600
|
+
baseExpr: createEditorChain()
|
|
2601
|
+
};
|
|
2602
|
+
}
|
|
2603
|
+
function createAccentNode(accentId) {
|
|
2604
|
+
return {
|
|
2605
|
+
...createEditorNode("accent", accentId),
|
|
2606
|
+
baseExpr: createEditorChain()
|
|
2607
|
+
};
|
|
2608
|
+
}
|
|
2437
2609
|
function createGridEnvNode(envName, rows, columns, columnAlignments) {
|
|
2438
2610
|
const safeRows = Math.max(1, Math.min(12, Math.trunc(rows)));
|
|
2439
2611
|
const safeColumns = Math.max(1, Math.min(12, Math.trunc(columns)));
|
|
@@ -2492,6 +2664,15 @@ function collectNodeIds(chain, ids) {
|
|
|
2492
2664
|
if (node.radicand) {
|
|
2493
2665
|
collectNodeIds(node.radicand, ids);
|
|
2494
2666
|
}
|
|
2667
|
+
if (node.overExpr) {
|
|
2668
|
+
collectNodeIds(node.overExpr, ids);
|
|
2669
|
+
}
|
|
2670
|
+
if (node.underExpr) {
|
|
2671
|
+
collectNodeIds(node.underExpr, ids);
|
|
2672
|
+
}
|
|
2673
|
+
if (node.baseExpr) {
|
|
2674
|
+
collectNodeIds(node.baseExpr, ids);
|
|
2675
|
+
}
|
|
2495
2676
|
if (node.matrixRows) {
|
|
2496
2677
|
for (const row of node.matrixRows) {
|
|
2497
2678
|
for (const cell of row) {
|
|
@@ -2622,6 +2803,22 @@ function renderMatrixRowsArabic(node, options) {
|
|
|
2622
2803
|
}
|
|
2623
2804
|
return `\\begin{${envName}}${rows.join(" \\\\\n")}\\end{${envName}}`;
|
|
2624
2805
|
}
|
|
2806
|
+
function renderAccentEnglish(command, accent, base, options) {
|
|
2807
|
+
const baseTex = base ? renderChainEnglish(base, options) : "";
|
|
2808
|
+
const accentTex = accent ? renderChainEnglish(accent, options) : "";
|
|
2809
|
+
if (accentTex === "") {
|
|
2810
|
+
return baseTex;
|
|
2811
|
+
}
|
|
2812
|
+
return `\\${command}{${accentTex}}{${baseTex}}`;
|
|
2813
|
+
}
|
|
2814
|
+
function renderAccentArabic(command, accent, base, options) {
|
|
2815
|
+
const baseTex = base ? renderChainArabic(base, options) : "";
|
|
2816
|
+
const accentTex = accent ? renderChainArabic(accent, options) : "";
|
|
2817
|
+
if (accentTex === "") {
|
|
2818
|
+
return baseTex;
|
|
2819
|
+
}
|
|
2820
|
+
return `\\${command}{${accentTex}}{${baseTex}}`;
|
|
2821
|
+
}
|
|
2625
2822
|
function escapeText(s) {
|
|
2626
2823
|
return s.replace(/\\/g, "\\textbackslash{}").replace(/[{}]/g, "\\$&");
|
|
2627
2824
|
}
|
|
@@ -2651,6 +2848,19 @@ function renderNodeEnglish(node, options) {
|
|
|
2651
2848
|
const body = `\\sqrt${optionalRootIndexEnglish(node, options)}{${renderChainEnglish(node.radicand, options)}}`;
|
|
2652
2849
|
return `${body}${latinScripts(node, options)}`;
|
|
2653
2850
|
}
|
|
2851
|
+
if (node.kind === "overset" && node.baseExpr) {
|
|
2852
|
+
const body = renderAccentEnglish("overset", node.overExpr, node.baseExpr, options);
|
|
2853
|
+
return `${body}${latinScripts(node, options)}`;
|
|
2854
|
+
}
|
|
2855
|
+
if (node.kind === "underset" && node.baseExpr) {
|
|
2856
|
+
const body = renderAccentEnglish("underset", node.underExpr, node.baseExpr, options);
|
|
2857
|
+
return `${body}${latinScripts(node, options)}`;
|
|
2858
|
+
}
|
|
2859
|
+
if (node.kind === "accent" && node.baseExpr) {
|
|
2860
|
+
const cmd = accentCommandSpec(node.expr)?.englishTex ?? `\\${node.expr}`;
|
|
2861
|
+
const body = `${cmd}{${renderChainEnglish(node.baseExpr, options)}}`;
|
|
2862
|
+
return `${body}${latinScripts(node, options)}`;
|
|
2863
|
+
}
|
|
2654
2864
|
if (node.kind === "env") {
|
|
2655
2865
|
return `${renderMatrixRowsEnglish(node, options)}${latinScripts(node, options)}`;
|
|
2656
2866
|
}
|
|
@@ -2683,6 +2893,19 @@ function renderNodeArabic(node, options) {
|
|
|
2683
2893
|
const content = `\\arabsqrt${optionalRootIndexArabic(node, options)}{${renderChainArabic(node.radicand, options)}}`;
|
|
2684
2894
|
return arabicScripts(node, content, options);
|
|
2685
2895
|
}
|
|
2896
|
+
if (node.kind === "overset" && node.baseExpr) {
|
|
2897
|
+
const content = renderAccentArabic("overset", node.overExpr, node.baseExpr, options);
|
|
2898
|
+
return arabicScripts(node, content, options);
|
|
2899
|
+
}
|
|
2900
|
+
if (node.kind === "underset" && node.baseExpr) {
|
|
2901
|
+
const content = renderAccentArabic("underset", node.underExpr, node.baseExpr, options);
|
|
2902
|
+
return arabicScripts(node, content, options);
|
|
2903
|
+
}
|
|
2904
|
+
if (node.kind === "accent" && node.baseExpr) {
|
|
2905
|
+
const cmd = accentCommandSpec(node.expr)?.arabicTex ?? `\\${node.expr}`;
|
|
2906
|
+
const content = `${cmd}{${renderChainArabic(node.baseExpr, options)}}`;
|
|
2907
|
+
return arabicScripts(node, content, options);
|
|
2908
|
+
}
|
|
2686
2909
|
if (node.kind === "env") {
|
|
2687
2910
|
return arabicScripts(node, renderMatrixRowsArabic(node, options), options);
|
|
2688
2911
|
}
|
|
@@ -2887,6 +3110,109 @@ var SQRT_CSS = `
|
|
|
2887
3110
|
}
|
|
2888
3111
|
`.trim();
|
|
2889
3112
|
|
|
3113
|
+
// src/editor/display/overset.ts
|
|
3114
|
+
var OVERSET_CSS = `
|
|
3115
|
+
.overset {
|
|
3116
|
+
display: inline-flex;
|
|
3117
|
+
flex-direction: column;
|
|
3118
|
+
align-items: center;
|
|
3119
|
+
justify-content: center;
|
|
3120
|
+
vertical-align: middle;
|
|
3121
|
+
margin: 0 2px;
|
|
3122
|
+
min-width: 1.2em;
|
|
3123
|
+
}
|
|
3124
|
+
|
|
3125
|
+
.overset-over {
|
|
3126
|
+
display: inline-flex;
|
|
3127
|
+
justify-content: center;
|
|
3128
|
+
align-items: center;
|
|
3129
|
+
min-height: 0.85em;
|
|
3130
|
+
padding: 0 2px;
|
|
3131
|
+
font-size: 0.72em;
|
|
3132
|
+
line-height: 1.1;
|
|
3133
|
+
}
|
|
3134
|
+
|
|
3135
|
+
.overset-base {
|
|
3136
|
+
display: inline-flex;
|
|
3137
|
+
justify-content: center;
|
|
3138
|
+
align-items: center;
|
|
3139
|
+
min-height: 1.05em;
|
|
3140
|
+
padding: 0 2px;
|
|
3141
|
+
}
|
|
3142
|
+
`.trim();
|
|
3143
|
+
|
|
3144
|
+
// src/editor/display/underset.ts
|
|
3145
|
+
var UNDERSET_CSS = `
|
|
3146
|
+
.underset {
|
|
3147
|
+
display: inline-flex;
|
|
3148
|
+
flex-direction: column;
|
|
3149
|
+
align-items: center;
|
|
3150
|
+
justify-content: center;
|
|
3151
|
+
vertical-align: middle;
|
|
3152
|
+
margin: 0 2px;
|
|
3153
|
+
min-width: 1.2em;
|
|
3154
|
+
}
|
|
3155
|
+
|
|
3156
|
+
.underset-base {
|
|
3157
|
+
display: inline-flex;
|
|
3158
|
+
justify-content: center;
|
|
3159
|
+
align-items: center;
|
|
3160
|
+
min-height: 1.05em;
|
|
3161
|
+
padding: 0 2px;
|
|
3162
|
+
}
|
|
3163
|
+
|
|
3164
|
+
.underset-under {
|
|
3165
|
+
display: inline-flex;
|
|
3166
|
+
justify-content: center;
|
|
3167
|
+
align-items: center;
|
|
3168
|
+
min-height: 0.85em;
|
|
3169
|
+
padding: 0 2px;
|
|
3170
|
+
font-size: 0.72em;
|
|
3171
|
+
line-height: 1.1;
|
|
3172
|
+
}
|
|
3173
|
+
`.trim();
|
|
3174
|
+
|
|
3175
|
+
// src/editor/display/accent.ts
|
|
3176
|
+
var ACCENT_CSS = `
|
|
3177
|
+
.math-accent {
|
|
3178
|
+
display: inline-flex;
|
|
3179
|
+
flex-direction: column;
|
|
3180
|
+
align-items: center;
|
|
3181
|
+
justify-content: center;
|
|
3182
|
+
vertical-align: middle;
|
|
3183
|
+
margin: 0 2px;
|
|
3184
|
+
min-width: 1.1em;
|
|
3185
|
+
}
|
|
3186
|
+
|
|
3187
|
+
.math-accent-chrome {
|
|
3188
|
+
display: inline-flex;
|
|
3189
|
+
justify-content: center;
|
|
3190
|
+
align-items: center;
|
|
3191
|
+
min-height: 0.7em;
|
|
3192
|
+
padding: 0 2px;
|
|
3193
|
+
font-size: 0.85em;
|
|
3194
|
+
line-height: 1;
|
|
3195
|
+
color: var(--butex-script-color, #475569);
|
|
3196
|
+
user-select: none;
|
|
3197
|
+
}
|
|
3198
|
+
|
|
3199
|
+
.math-accent-base {
|
|
3200
|
+
display: inline-flex;
|
|
3201
|
+
justify-content: center;
|
|
3202
|
+
align-items: center;
|
|
3203
|
+
min-height: 1.05em;
|
|
3204
|
+
padding: 0 2px;
|
|
3205
|
+
}
|
|
3206
|
+
|
|
3207
|
+
.math-accent--under .math-accent-chrome {
|
|
3208
|
+
min-height: 0.45em;
|
|
3209
|
+
border-top: 1.5px solid currentColor;
|
|
3210
|
+
width: 100%;
|
|
3211
|
+
font-size: 0;
|
|
3212
|
+
color: var(--butex-surface-fg, #0f172a);
|
|
3213
|
+
}
|
|
3214
|
+
`.trim();
|
|
3215
|
+
|
|
2890
3216
|
// src/editor/display/env.ts
|
|
2891
3217
|
var MATRIX_ENV_CSS = `
|
|
2892
3218
|
.matrix-env {
|
|
@@ -3274,6 +3600,12 @@ ${FRAC_CSS}
|
|
|
3274
3600
|
|
|
3275
3601
|
${SQRT_CSS}
|
|
3276
3602
|
|
|
3603
|
+
${OVERSET_CSS}
|
|
3604
|
+
|
|
3605
|
+
${UNDERSET_CSS}
|
|
3606
|
+
|
|
3607
|
+
${ACCENT_CSS}
|
|
3608
|
+
|
|
3277
3609
|
${MATRIX_ENV_CSS}
|
|
3278
3610
|
|
|
3279
3611
|
${ATOMIC_COMMAND_CSS}
|
|
@@ -3556,6 +3888,56 @@ function commandToEditorNode(node) {
|
|
|
3556
3888
|
}
|
|
3557
3889
|
return { editable: true, node: sqrt };
|
|
3558
3890
|
}
|
|
3891
|
+
if (node.name === "\\overset" && node.mandatoryArgs.length >= 2) {
|
|
3892
|
+
const overset = createOversetNode();
|
|
3893
|
+
const overExpr = chainToEditorChain(node.mandatoryArgs[0]);
|
|
3894
|
+
const baseExpr = chainToEditorChain(node.mandatoryArgs[1]);
|
|
3895
|
+
if (!overExpr.editable) {
|
|
3896
|
+
return overExpr;
|
|
3897
|
+
}
|
|
3898
|
+
if (!baseExpr.editable) {
|
|
3899
|
+
return baseExpr;
|
|
3900
|
+
}
|
|
3901
|
+
overset.overExpr = overExpr.chain;
|
|
3902
|
+
overset.baseExpr = baseExpr.chain;
|
|
3903
|
+
const scripts = attachScripts(node, overset);
|
|
3904
|
+
if (scripts) {
|
|
3905
|
+
return scripts;
|
|
3906
|
+
}
|
|
3907
|
+
return { editable: true, node: overset };
|
|
3908
|
+
}
|
|
3909
|
+
if (node.name === "\\underset" && node.mandatoryArgs.length >= 2) {
|
|
3910
|
+
const underset = createUndersetNode();
|
|
3911
|
+
const underExpr = chainToEditorChain(node.mandatoryArgs[0]);
|
|
3912
|
+
const baseExpr = chainToEditorChain(node.mandatoryArgs[1]);
|
|
3913
|
+
if (!underExpr.editable) {
|
|
3914
|
+
return underExpr;
|
|
3915
|
+
}
|
|
3916
|
+
if (!baseExpr.editable) {
|
|
3917
|
+
return baseExpr;
|
|
3918
|
+
}
|
|
3919
|
+
underset.underExpr = underExpr.chain;
|
|
3920
|
+
underset.baseExpr = baseExpr.chain;
|
|
3921
|
+
const scripts = attachScripts(node, underset);
|
|
3922
|
+
if (scripts) {
|
|
3923
|
+
return scripts;
|
|
3924
|
+
}
|
|
3925
|
+
return { editable: true, node: underset };
|
|
3926
|
+
}
|
|
3927
|
+
const accentId = accentCommandIdFromTex(node.name);
|
|
3928
|
+
if (accentId && node.mandatoryArgs.length >= 1) {
|
|
3929
|
+
const accent = createAccentNode(accentId);
|
|
3930
|
+
const baseExpr = chainToEditorChain(node.mandatoryArgs[0]);
|
|
3931
|
+
if (!baseExpr.editable) {
|
|
3932
|
+
return baseExpr;
|
|
3933
|
+
}
|
|
3934
|
+
accent.baseExpr = baseExpr.chain;
|
|
3935
|
+
const scripts = attachScripts(node, accent);
|
|
3936
|
+
if (scripts) {
|
|
3937
|
+
return scripts;
|
|
3938
|
+
}
|
|
3939
|
+
return { editable: true, node: accent };
|
|
3940
|
+
}
|
|
3559
3941
|
const atomicId = commandIdForTex(node.name);
|
|
3560
3942
|
if (atomicId && node.optionalArgs.length === 0 && node.mandatoryArgs.length === 0) {
|
|
3561
3943
|
const atomic = createEditorNode("atomicCommand", atomicId);
|
|
@@ -3692,6 +4074,21 @@ function editorEnvToAstNode(node) {
|
|
|
3692
4074
|
const scripts = attachAstScripts(node, env);
|
|
3693
4075
|
return scripts ?? { ok: true, node: env };
|
|
3694
4076
|
}
|
|
4077
|
+
function accentChainForExport(accent) {
|
|
4078
|
+
if (!accent) {
|
|
4079
|
+
return { ok: true, chain: new ChainNode([]) };
|
|
4080
|
+
}
|
|
4081
|
+
return editorChainToAstChain(accent);
|
|
4082
|
+
}
|
|
4083
|
+
function nodeFromAccentBase(command, accent, base) {
|
|
4084
|
+
if (accent.chain.length > 0) {
|
|
4085
|
+
return new CommandNode(command, [], [accent, base]);
|
|
4086
|
+
}
|
|
4087
|
+
if (base.chain.length === 1) {
|
|
4088
|
+
return base.chain[0];
|
|
4089
|
+
}
|
|
4090
|
+
return new DelimiterNode("", base, "");
|
|
4091
|
+
}
|
|
3695
4092
|
function editorNodeToAstNode(node) {
|
|
3696
4093
|
let astNode;
|
|
3697
4094
|
if (node.kind === "char") {
|
|
@@ -3730,6 +4127,36 @@ function editorNodeToAstNode(node) {
|
|
|
3730
4127
|
optionalArgs.push(rootIndex.chain);
|
|
3731
4128
|
}
|
|
3732
4129
|
astNode = new CommandNode("\\sqrt", optionalArgs, [radicand.chain]);
|
|
4130
|
+
} else if (node.kind === "overset" && node.baseExpr) {
|
|
4131
|
+
const accent = accentChainForExport(node.overExpr);
|
|
4132
|
+
if (!accent.ok) {
|
|
4133
|
+
return accent;
|
|
4134
|
+
}
|
|
4135
|
+
const baseExpr = editorChainToAstChain(node.baseExpr);
|
|
4136
|
+
if (!baseExpr.ok) {
|
|
4137
|
+
return baseExpr;
|
|
4138
|
+
}
|
|
4139
|
+
astNode = nodeFromAccentBase("\\overset", accent.chain, baseExpr.chain);
|
|
4140
|
+
} else if (node.kind === "underset" && node.baseExpr) {
|
|
4141
|
+
const accent = accentChainForExport(node.underExpr);
|
|
4142
|
+
if (!accent.ok) {
|
|
4143
|
+
return accent;
|
|
4144
|
+
}
|
|
4145
|
+
const baseExpr = editorChainToAstChain(node.baseExpr);
|
|
4146
|
+
if (!baseExpr.ok) {
|
|
4147
|
+
return baseExpr;
|
|
4148
|
+
}
|
|
4149
|
+
astNode = nodeFromAccentBase("\\underset", accent.chain, baseExpr.chain);
|
|
4150
|
+
} else if (node.kind === "accent" && node.baseExpr) {
|
|
4151
|
+
const tex = accentCommandSpec(node.expr)?.englishTex;
|
|
4152
|
+
if (!tex) {
|
|
4153
|
+
return { ok: false, reason: `\u0644\u0643\u0646\u0629 \u0631\u064A\u0627\u0636\u064A\u0629 \u063A\u064A\u0631 \u0645\u062F\u0639\u0648\u0645\u0629 \u062D\u0627\u0644\u064A\u0627: ${node.expr}` };
|
|
4154
|
+
}
|
|
4155
|
+
const baseExpr = editorChainToAstChain(node.baseExpr);
|
|
4156
|
+
if (!baseExpr.ok) {
|
|
4157
|
+
return baseExpr;
|
|
4158
|
+
}
|
|
4159
|
+
astNode = new CommandNode(tex, [], [baseExpr.chain]);
|
|
3733
4160
|
} else if (node.kind === "atomicCommand") {
|
|
3734
4161
|
const tex = atomicCommandSpec(node.expr)?.englishTex;
|
|
3735
4162
|
if (!tex) {
|
|
@@ -4579,7 +5006,6 @@ function arabicXeLatexPreamblePkg(twocolumn = false) {
|
|
|
4579
5006
|
\usepackage{polyglossia} % For Arabic support
|
|
4580
5007
|
\usepackage{array}
|
|
4581
5008
|
\usepackage{cancel}
|
|
4582
|
-
\usepackage{bidi} % For bidirectional text handling
|
|
4583
5009
|
\usepackage{multirow}
|
|
4584
5010
|
\usepackage{booktabs}
|
|
4585
5011
|
\usepackage{graphicx} % For \reflectbox
|
|
@@ -4587,7 +5013,8 @@ function arabicXeLatexPreamblePkg(twocolumn = false) {
|
|
|
4587
5013
|
\usepackage{tikz}
|
|
4588
5014
|
\usepackage{tcolorbox} % For tcolorbox environment
|
|
4589
5015
|
\usepackage{textcomp} % For \textrightarrow command
|
|
4590
|
-
|
|
5016
|
+
\usepackage{url}
|
|
5017
|
+
\usepackage{bidi}
|
|
4591
5018
|
|
|
4592
5019
|
% visit : https://www.symbolcopy.com/punctuation-symbol.html
|
|
4593
5020
|
% for inversed punctuation
|