@drghaliasri/butex 4.0.1 → 4.2.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 +4 -2
- package/dist/document.js +37 -1
- package/dist/document.js.map +1 -1
- package/dist/document.mjs +37 -1
- package/dist/document.mjs.map +1 -1
- package/dist/document2.js +160 -2
- package/dist/document2.js.map +1 -1
- package/dist/document2.mjs +160 -2
- package/dist/document2.mjs.map +1 -1
- package/dist/index.d.mts +20 -2
- package/dist/index.d.ts +20 -2
- package/dist/index.global.js +223 -4
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +223 -4
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +223 -4
- package/dist/index.mjs.map +1 -1
- package/dist/react-document.js +437 -6
- package/dist/react-document.js.map +1 -1
- package/dist/react-document.mjs +437 -6
- package/dist/react-document.mjs.map +1 -1
- package/dist/react-document2.js +437 -6
- package/dist/react-document2.js.map +1 -1
- package/dist/react-document2.mjs +437 -6
- package/dist/react-document2.mjs.map +1 -1
- package/dist/react.d.mts +11 -0
- package/dist/react.d.ts +11 -0
- package/dist/react.js +303 -4
- package/dist/react.js.map +1 -1
- package/dist/react.mjs +303 -4
- package/dist/react.mjs.map +1 -1
- package/package.json +1 -1
package/dist/react.mjs
CHANGED
|
@@ -357,6 +357,16 @@ var ATOMIC_COMMANDS = {
|
|
|
357
357
|
arabicLabel: "\u0645\u062D\u062F\u062F",
|
|
358
358
|
title: "\u0645\u062D\u062F\u062F"
|
|
359
359
|
},
|
|
360
|
+
////////////////////// Derivatives ////////////////////////////////
|
|
361
|
+
ad: {
|
|
362
|
+
id: "ad",
|
|
363
|
+
category: "derivative",
|
|
364
|
+
englishTex: "\\mathrm{d}",
|
|
365
|
+
englishLabel: "d",
|
|
366
|
+
arabicTex: "\\ad",
|
|
367
|
+
arabicLabel: "\u0621",
|
|
368
|
+
title: "\u0639\u0644\u0627\u0645\u0629 \u0627\u0644\u0627\u0634\u062A\u0642\u0627\u0642"
|
|
369
|
+
},
|
|
360
370
|
////////////////////// Groups /////////////////////////////////
|
|
361
371
|
N: {
|
|
362
372
|
id: "N",
|
|
@@ -1017,6 +1027,22 @@ function atomicOperatorCommandSpec(id) {
|
|
|
1017
1027
|
return Object.prototype.hasOwnProperty.call(ATOMIC_OPERATOR_COMMANDS, id) ? ATOMIC_OPERATOR_COMMANDS[id] : null;
|
|
1018
1028
|
}
|
|
1019
1029
|
|
|
1030
|
+
// src/editor/divideOperator.ts
|
|
1031
|
+
var DIVIDE_OPERATOR_EN = "/";
|
|
1032
|
+
var DIVIDE_OPERATOR_AR = "\\";
|
|
1033
|
+
function isDivideOperatorExpr(expr) {
|
|
1034
|
+
return expr === DIVIDE_OPERATOR_EN || expr === DIVIDE_OPERATOR_AR;
|
|
1035
|
+
}
|
|
1036
|
+
function divideOperatorSurfaceExpr(expr, side) {
|
|
1037
|
+
if (!isDivideOperatorExpr(expr)) {
|
|
1038
|
+
return expr;
|
|
1039
|
+
}
|
|
1040
|
+
return side === "arabic" ? DIVIDE_OPERATOR_AR : DIVIDE_OPERATOR_EN;
|
|
1041
|
+
}
|
|
1042
|
+
function renderDivideOperatorLatex(side) {
|
|
1043
|
+
return side === "arabic" ? "\\backslash" : DIVIDE_OPERATOR_EN;
|
|
1044
|
+
}
|
|
1045
|
+
|
|
1020
1046
|
// src/editor/digits.ts
|
|
1021
1047
|
var WESTERN = "0123456789";
|
|
1022
1048
|
var ARABIC_INDIC = "\u0660\u0661\u0662\u0663\u0664\u0665\u0666\u0667\u0668\u0669";
|
|
@@ -1165,6 +1191,9 @@ function renderNodeEnglish(node, options) {
|
|
|
1165
1191
|
if (node.kind === "char") {
|
|
1166
1192
|
return `${renderCharContent(node, options)}${latinScripts(node, options)}`;
|
|
1167
1193
|
}
|
|
1194
|
+
if (node.kind === "operator" && isDivideOperatorExpr(node.expr)) {
|
|
1195
|
+
return `${renderDivideOperatorLatex("english")}${latinScripts(node, options)}`;
|
|
1196
|
+
}
|
|
1168
1197
|
return `${formatDigits(node.expr, selectedDigitForm(options))}${latinScripts(node, options)}`;
|
|
1169
1198
|
}
|
|
1170
1199
|
function renderNodeArabic(node, options) {
|
|
@@ -1199,6 +1228,9 @@ function renderNodeArabic(node, options) {
|
|
|
1199
1228
|
const content = renderCharContent(node, options);
|
|
1200
1229
|
return arabicScripts(node, (node.characterFont ?? "default") === "default" ? `\\text{${escapeText(expr)}}` : content, options);
|
|
1201
1230
|
}
|
|
1231
|
+
if (node.kind === "operator" && isDivideOperatorExpr(node.expr)) {
|
|
1232
|
+
return arabicScripts(node, renderDivideOperatorLatex("arabic"), options);
|
|
1233
|
+
}
|
|
1202
1234
|
return arabicScripts(node, formatDigits(node.expr, selectedDigitForm(options)), options);
|
|
1203
1235
|
}
|
|
1204
1236
|
function renderChainEnglish(chain, options) {
|
|
@@ -1722,6 +1754,128 @@ function undoRedoCanRedo(stacks) {
|
|
|
1722
1754
|
return stacks.future.length > 0;
|
|
1723
1755
|
}
|
|
1724
1756
|
|
|
1757
|
+
// src/editor/derivativeTemplates.ts
|
|
1758
|
+
var ARABIC_VAR = "\u0633";
|
|
1759
|
+
var ENGLISH_VAR = "x";
|
|
1760
|
+
function mirroredAd() {
|
|
1761
|
+
const english = createAtomicCommandNode("ad");
|
|
1762
|
+
const arabic = createAtomicCommandNode("ad");
|
|
1763
|
+
arabic.id = english.id;
|
|
1764
|
+
return { english, arabic };
|
|
1765
|
+
}
|
|
1766
|
+
function mirroredVar() {
|
|
1767
|
+
const english = createEditorNode("char", ENGLISH_VAR);
|
|
1768
|
+
const arabic = createEditorNode("char", ARABIC_VAR);
|
|
1769
|
+
arabic.id = english.id;
|
|
1770
|
+
return { english, arabic };
|
|
1771
|
+
}
|
|
1772
|
+
function withMirroredSuperscript2(english, arabic) {
|
|
1773
|
+
const englishSup = createEditorChain([createEditorNode("number", "2")]);
|
|
1774
|
+
const arabicSup = createEditorChain([createEditorNode("number", "2")]);
|
|
1775
|
+
arabicSup.id = englishSup.id;
|
|
1776
|
+
arabicSup.nodes[0].id = englishSup.nodes[0].id;
|
|
1777
|
+
english.superscript = englishSup;
|
|
1778
|
+
arabic.superscript = arabicSup;
|
|
1779
|
+
}
|
|
1780
|
+
function syncChainIds(english, arabic) {
|
|
1781
|
+
arabic.id = english.id;
|
|
1782
|
+
const limit = Math.min(english.nodes.length, arabic.nodes.length);
|
|
1783
|
+
for (let index = 0; index < limit; index += 1) {
|
|
1784
|
+
arabic.nodes[index].id = english.nodes[index].id;
|
|
1785
|
+
}
|
|
1786
|
+
}
|
|
1787
|
+
function syncFracIds(englishFrac, arabicFrac) {
|
|
1788
|
+
arabicFrac.id = englishFrac.id;
|
|
1789
|
+
if (englishFrac.numerator && arabicFrac.numerator) {
|
|
1790
|
+
syncChainIds(englishFrac.numerator, arabicFrac.numerator);
|
|
1791
|
+
}
|
|
1792
|
+
if (englishFrac.denominator && arabicFrac.denominator) {
|
|
1793
|
+
syncChainIds(englishFrac.denominator, arabicFrac.denominator);
|
|
1794
|
+
}
|
|
1795
|
+
}
|
|
1796
|
+
function buildAdVarChain() {
|
|
1797
|
+
const ad = mirroredAd();
|
|
1798
|
+
const variable = mirroredVar();
|
|
1799
|
+
const english = createEditorChain([ad.english, variable.english]);
|
|
1800
|
+
const arabic = createEditorChain([ad.arabic, variable.arabic]);
|
|
1801
|
+
syncChainIds(english, arabic);
|
|
1802
|
+
return { english, arabic };
|
|
1803
|
+
}
|
|
1804
|
+
function mirroredEmptyDelimiter() {
|
|
1805
|
+
const english = createDelimiterNode("", "");
|
|
1806
|
+
const arabic = createDelimiterNode("", "");
|
|
1807
|
+
arabic.id = english.id;
|
|
1808
|
+
if (english.innerExpr && arabic.innerExpr) {
|
|
1809
|
+
syncChainIds(english.innerExpr, arabic.innerExpr);
|
|
1810
|
+
}
|
|
1811
|
+
return { english, arabic };
|
|
1812
|
+
}
|
|
1813
|
+
function setMirroredDelimiterInner(english, arabic, pairs) {
|
|
1814
|
+
const englishInner = createEditorChain(pairs.map((pair) => pair.english));
|
|
1815
|
+
const arabicInner = createEditorChain(pairs.map((pair) => pair.arabic));
|
|
1816
|
+
syncChainIds(englishInner, arabicInner);
|
|
1817
|
+
english.innerExpr = englishInner;
|
|
1818
|
+
arabic.innerExpr = arabicInner;
|
|
1819
|
+
}
|
|
1820
|
+
function buildFirstDerivativeFrac() {
|
|
1821
|
+
const englishFrac = createFracNode();
|
|
1822
|
+
const arabicFrac = createFracNode();
|
|
1823
|
+
syncFracIds(englishFrac, arabicFrac);
|
|
1824
|
+
const numerator = buildAdVarChain();
|
|
1825
|
+
const denominator = buildAdVarChain();
|
|
1826
|
+
englishFrac.numerator = numerator.english;
|
|
1827
|
+
englishFrac.denominator = denominator.english;
|
|
1828
|
+
arabicFrac.numerator = numerator.arabic;
|
|
1829
|
+
arabicFrac.denominator = denominator.arabic;
|
|
1830
|
+
return { english: englishFrac, arabic: arabicFrac };
|
|
1831
|
+
}
|
|
1832
|
+
function buildSecondDerivativeFrac() {
|
|
1833
|
+
const englishFrac = createFracNode();
|
|
1834
|
+
const arabicFrac = createFracNode();
|
|
1835
|
+
syncFracIds(englishFrac, arabicFrac);
|
|
1836
|
+
const numAd = mirroredAd();
|
|
1837
|
+
const numVar = mirroredVar();
|
|
1838
|
+
withMirroredSuperscript2(numAd.english, numAd.arabic);
|
|
1839
|
+
const englishNumerator = createEditorChain([numAd.english, numVar.english]);
|
|
1840
|
+
const arabicNumerator = createEditorChain([numAd.arabic, numVar.arabic]);
|
|
1841
|
+
syncChainIds(englishNumerator, arabicNumerator);
|
|
1842
|
+
englishFrac.numerator = englishNumerator;
|
|
1843
|
+
arabicFrac.numerator = arabicNumerator;
|
|
1844
|
+
const denGroup = mirroredEmptyDelimiter();
|
|
1845
|
+
const denInnerAd = mirroredAd();
|
|
1846
|
+
const denInnerVar = mirroredVar();
|
|
1847
|
+
setMirroredDelimiterInner(denGroup.english, denGroup.arabic, [
|
|
1848
|
+
{ english: denInnerAd.english, arabic: denInnerAd.arabic },
|
|
1849
|
+
{ english: denInnerVar.english, arabic: denInnerVar.arabic }
|
|
1850
|
+
]);
|
|
1851
|
+
withMirroredSuperscript2(denGroup.english, denGroup.arabic);
|
|
1852
|
+
englishFrac.denominator = createEditorChain([denGroup.english]);
|
|
1853
|
+
arabicFrac.denominator = createEditorChain([denGroup.arabic]);
|
|
1854
|
+
syncChainIds(englishFrac.denominator, arabicFrac.denominator);
|
|
1855
|
+
return { english: englishFrac, arabic: arabicFrac };
|
|
1856
|
+
}
|
|
1857
|
+
var DERIVATIVE_TEMPLATE_VAR_CARET_INDEX = 1;
|
|
1858
|
+
function derivativeTemplateInitialCaret(englishFrac) {
|
|
1859
|
+
const denominator = englishFrac.denominator;
|
|
1860
|
+
if (!denominator) {
|
|
1861
|
+
return {
|
|
1862
|
+
chainId: englishFrac.numerator?.id ?? "",
|
|
1863
|
+
index: DERIVATIVE_TEMPLATE_VAR_CARET_INDEX
|
|
1864
|
+
};
|
|
1865
|
+
}
|
|
1866
|
+
const loneDelimiter = denominator.nodes.length === 1 && denominator.nodes[0]?.kind === "delimiter" && denominator.nodes[0].innerExpr;
|
|
1867
|
+
if (loneDelimiter) {
|
|
1868
|
+
return {
|
|
1869
|
+
chainId: denominator.nodes[0].innerExpr.id,
|
|
1870
|
+
index: DERIVATIVE_TEMPLATE_VAR_CARET_INDEX
|
|
1871
|
+
};
|
|
1872
|
+
}
|
|
1873
|
+
return {
|
|
1874
|
+
chainId: denominator.id,
|
|
1875
|
+
index: DERIVATIVE_TEMPLATE_VAR_CARET_INDEX
|
|
1876
|
+
};
|
|
1877
|
+
}
|
|
1878
|
+
|
|
1725
1879
|
// src/editor/uiLocale.ts
|
|
1726
1880
|
var ENGLISH_COMMAND_TITLES = {
|
|
1727
1881
|
cos: "Cosine",
|
|
@@ -1752,6 +1906,7 @@ var ENGLISH_COMMAND_TITLES = {
|
|
|
1752
1906
|
ln: "Natural logarithm",
|
|
1753
1907
|
log: "Logarithm",
|
|
1754
1908
|
det: "Determinant",
|
|
1909
|
+
ad: "Derivative (d / ad)",
|
|
1755
1910
|
N: "Natural numbers",
|
|
1756
1911
|
Z: "Integers",
|
|
1757
1912
|
Q: "Rational numbers",
|
|
@@ -1863,6 +2018,10 @@ var EQUATION_EDITOR_MESSAGES = {
|
|
|
1863
2018
|
insertFunction: "\u0625\u062F\u0631\u0627\u062C \u062F\u0627\u0644\u0629",
|
|
1864
2019
|
insertLimitsSeries: "\u0625\u062F\u0631\u0627\u062C \u062D\u062F\u0648\u062F \u0648\u0645\u062A\u0633\u0644\u0633\u0644\u0627\u062A",
|
|
1865
2020
|
insertAdditionalFunctions: "\u0625\u062F\u0631\u0627\u062C \u062F\u0648\u0627\u0644 \u0625\u0636\u0627\u0641\u064A\u0629",
|
|
2021
|
+
derivatives: "\u0627\u0644\u0627\u0634\u062A\u0642\u0627\u0642",
|
|
2022
|
+
insertDerivative: "\u0625\u062F\u0631\u0627\u062C \u0639\u0644\u0627\u0645\u0629 \u0627\u0634\u062A\u0642\u0627\u0642",
|
|
2023
|
+
insertFirstDerivative: "\u0625\u062F\u0631\u0627\u062C \u0627\u0634\u062A\u0642\u0627\u0642 \u0623\u0648\u0644",
|
|
2024
|
+
insertSecondDerivative: "\u0625\u062F\u0631\u0627\u062C \u0627\u0634\u062A\u0642\u0627\u0642 \u062B\u0627\u0646\u064A",
|
|
1866
2025
|
insertNumberSets: "\u0625\u062F\u0631\u0627\u062C \u0645\u062C\u0645\u0648\u0639\u0627\u062A \u0623\u0639\u062F\u0627\u062F",
|
|
1867
2026
|
operations: "\u0627\u0644\u0639\u0645\u0644\u064A\u0627\u062A",
|
|
1868
2027
|
insertOperation: "\u0625\u062F\u0631\u0627\u062C \u0631\u0645\u0632 \u0639\u0645\u0644\u064A\u0629",
|
|
@@ -1966,6 +2125,10 @@ var EQUATION_EDITOR_MESSAGES = {
|
|
|
1966
2125
|
insertFunction: "Insert function",
|
|
1967
2126
|
insertLimitsSeries: "Insert limits and series",
|
|
1968
2127
|
insertAdditionalFunctions: "Insert additional functions",
|
|
2128
|
+
derivatives: "Derivatives",
|
|
2129
|
+
insertDerivative: "Insert derivative marker",
|
|
2130
|
+
insertFirstDerivative: "Insert first derivative",
|
|
2131
|
+
insertSecondDerivative: "Insert second derivative",
|
|
1969
2132
|
insertNumberSets: "Insert number sets",
|
|
1970
2133
|
operations: "Operators",
|
|
1971
2134
|
insertOperation: "Insert operator",
|
|
@@ -2673,10 +2836,27 @@ function insertNumber(session, expr) {
|
|
|
2673
2836
|
inserted.forceSplitNextLeaf = false;
|
|
2674
2837
|
return inserted;
|
|
2675
2838
|
}
|
|
2839
|
+
function insertDivideOperator(session) {
|
|
2840
|
+
const base = replaceSelectionFirst(session);
|
|
2841
|
+
const next = cloneEditorSession(base);
|
|
2842
|
+
const englishNode = createEditorNode("operator", DIVIDE_OPERATOR_EN);
|
|
2843
|
+
const arabicNode = createEditorNode("operator", DIVIDE_OPERATOR_AR);
|
|
2844
|
+
arabicNode.id = englishNode.id;
|
|
2845
|
+
insertMirroredNode(next, next.caret.chainId, next.caret.index, englishNode, arabicNode);
|
|
2846
|
+
markExprSync(next, englishNode.id);
|
|
2847
|
+
next.caret.index += 1;
|
|
2848
|
+
next.selectedStructureNodeId = null;
|
|
2849
|
+
syncSelectionToCaret(next);
|
|
2850
|
+
appendDebug(next, "insertDivideOperator", "");
|
|
2851
|
+
return next;
|
|
2852
|
+
}
|
|
2676
2853
|
function insertOperator(session, expr) {
|
|
2677
2854
|
if (expr === "." && !session.splitLeafTyping && precedingIsExtendableNumber(session)) {
|
|
2678
2855
|
return insertNumber(session, ".");
|
|
2679
2856
|
}
|
|
2857
|
+
if (expr === DIVIDE_OPERATOR_EN || expr === DIVIDE_OPERATOR_AR) {
|
|
2858
|
+
return insertDivideOperator(session);
|
|
2859
|
+
}
|
|
2680
2860
|
const base = replaceSelectionFirst(session);
|
|
2681
2861
|
return insertLeaf(base, "operator", expr);
|
|
2682
2862
|
}
|
|
@@ -2747,6 +2927,24 @@ function insertFraction(session) {
|
|
|
2747
2927
|
appendDebug(next, "insertFraction", "");
|
|
2748
2928
|
return next;
|
|
2749
2929
|
}
|
|
2930
|
+
function insertDerivativeFrac(session, build, debugLabel) {
|
|
2931
|
+
const base = replaceSelectionFirst(session);
|
|
2932
|
+
const next = cloneEditorSession(base);
|
|
2933
|
+
const { english, arabic } = build();
|
|
2934
|
+
insertMirroredNode(next, next.caret.chainId, next.caret.index, english, arabic);
|
|
2935
|
+
syncSubtreeRecursive(next, english, arabic);
|
|
2936
|
+
next.caret = derivativeTemplateInitialCaret(english);
|
|
2937
|
+
next.selectedStructureNodeId = null;
|
|
2938
|
+
syncSelectionToCaret(next);
|
|
2939
|
+
appendDebug(next, debugLabel, "");
|
|
2940
|
+
return next;
|
|
2941
|
+
}
|
|
2942
|
+
function insertFirstDerivative(session) {
|
|
2943
|
+
return insertDerivativeFrac(session, buildFirstDerivativeFrac, "insertFirstDerivative");
|
|
2944
|
+
}
|
|
2945
|
+
function insertSecondDerivative(session) {
|
|
2946
|
+
return insertDerivativeFrac(session, buildSecondDerivativeFrac, "insertSecondDerivative");
|
|
2947
|
+
}
|
|
2750
2948
|
function insertSqrt(session) {
|
|
2751
2949
|
const base = replaceSelectionFirst(session);
|
|
2752
2950
|
const next = cloneEditorSession(base);
|
|
@@ -3217,6 +3415,11 @@ function pasteText(session, text) {
|
|
|
3217
3415
|
i += 1;
|
|
3218
3416
|
continue;
|
|
3219
3417
|
}
|
|
3418
|
+
if (ch === DIVIDE_OPERATOR_AR) {
|
|
3419
|
+
s = insertDivideOperator(s);
|
|
3420
|
+
i += 1;
|
|
3421
|
+
continue;
|
|
3422
|
+
}
|
|
3220
3423
|
s = insertChar(s, ch);
|
|
3221
3424
|
i += 1;
|
|
3222
3425
|
}
|
|
@@ -3224,7 +3427,7 @@ function pasteText(session, text) {
|
|
|
3224
3427
|
}
|
|
3225
3428
|
|
|
3226
3429
|
// src/editor/display/base.ts
|
|
3227
|
-
function buildBaseNodeBody(node, digitForm = "western") {
|
|
3430
|
+
function buildBaseNodeBody(node, digitForm = "western", side = "english") {
|
|
3228
3431
|
const value = document.createElement("span");
|
|
3229
3432
|
value.className = "node-value";
|
|
3230
3433
|
if (node.kind === "char" && node.characterFont === "takween") {
|
|
@@ -3234,7 +3437,8 @@ function buildBaseNodeBody(node, digitForm = "western") {
|
|
|
3234
3437
|
} else if (node.kind === "char" && node.characterFont === "diwaniOutline") {
|
|
3235
3438
|
value.classList.add("node-value--diwani-outline");
|
|
3236
3439
|
}
|
|
3237
|
-
|
|
3440
|
+
const surfaceExpr = node.kind === "operator" ? divideOperatorSurfaceExpr(node.expr, side) : node.expr;
|
|
3441
|
+
value.textContent = surfaceExpr === "" ? "\u25A1" : formatDigits(surfaceExpr, digitForm);
|
|
3238
3442
|
return value;
|
|
3239
3443
|
}
|
|
3240
3444
|
|
|
@@ -3755,7 +3959,7 @@ function buildFunctionAtomicCommandBody(node, side, spec) {
|
|
|
3755
3959
|
value.appendChild(label);
|
|
3756
3960
|
return value;
|
|
3757
3961
|
}
|
|
3758
|
-
value.textContent = side === "arabic" ? spec?.arabicLabel ?? node.expr : spec?.englishTex.replace(
|
|
3962
|
+
value.textContent = side === "arabic" ? spec?.arabicLabel ?? node.expr : spec?.englishLabel ?? spec?.englishTex.replace(/^\\/, "") ?? node.expr;
|
|
3759
3963
|
return value;
|
|
3760
3964
|
}
|
|
3761
3965
|
function buildSpacingAtomicCommandBody(spec, side, uiLocale) {
|
|
@@ -3881,7 +4085,7 @@ function buildNodeBody(node, buildChain, side, digitForm = "western", uiLocale =
|
|
|
3881
4085
|
if (node.kind === "atomicOperatorCommand") {
|
|
3882
4086
|
return buildAtomicOperatorCommandNodeBody(node, side, uiLocale);
|
|
3883
4087
|
}
|
|
3884
|
-
return buildBaseNodeBody(node, digitForm);
|
|
4088
|
+
return buildBaseNodeBody(node, digitForm, side);
|
|
3885
4089
|
}
|
|
3886
4090
|
|
|
3887
4091
|
// src/editor/styles.ts
|
|
@@ -4599,6 +4803,10 @@ function createEditorRuntime(options) {
|
|
|
4599
4803
|
applyStructural((prev) => insertNumber(prev, char));
|
|
4600
4804
|
return;
|
|
4601
4805
|
}
|
|
4806
|
+
if (char === "\\") {
|
|
4807
|
+
applyStructural((prev) => insertDivideOperator(prev));
|
|
4808
|
+
return;
|
|
4809
|
+
}
|
|
4602
4810
|
if (isOperator(char)) {
|
|
4603
4811
|
applyStructural((prev) => insertOperator(prev, char));
|
|
4604
4812
|
return;
|
|
@@ -4762,6 +4970,14 @@ function createEditorRuntime(options) {
|
|
|
4762
4970
|
applyStructural((prev) => insertFraction(prev));
|
|
4763
4971
|
surfaceEl.focus();
|
|
4764
4972
|
},
|
|
4973
|
+
insertFirstDerivative: () => {
|
|
4974
|
+
applyStructural((prev) => insertFirstDerivative(prev));
|
|
4975
|
+
surfaceEl.focus();
|
|
4976
|
+
},
|
|
4977
|
+
insertSecondDerivative: () => {
|
|
4978
|
+
applyStructural((prev) => insertSecondDerivative(prev));
|
|
4979
|
+
surfaceEl.focus();
|
|
4980
|
+
},
|
|
4765
4981
|
insertMatrixEnv: (style, rows, columns) => {
|
|
4766
4982
|
applyStructural((prev) => insertMatrixEnv(prev, style, rows, columns));
|
|
4767
4983
|
surfaceEl.focus();
|
|
@@ -6133,6 +6349,7 @@ var CHARACTER_FONT_OPTIONS = [
|
|
|
6133
6349
|
var FUNCTION_COMMANDS = atomicCommandsByCategory("function");
|
|
6134
6350
|
var LIMITS_SERIES_COMMANDS = atomicCommandsByCategory("limits_series");
|
|
6135
6351
|
var FUNCTION2_COMMANDS = atomicCommandsByCategory("function2");
|
|
6352
|
+
var DERIVATIVE_COMMANDS = atomicCommandsByCategory("derivative");
|
|
6136
6353
|
var GROUP_COMMANDS = atomicCommandsByCategory("groups");
|
|
6137
6354
|
var SPACING_COMMANDS = atomicCommandsByCategory("spacing").filter(isSpacingCommandSpec);
|
|
6138
6355
|
var OPERATOR_COMMANDS = atomicOperatorCommandsByCategory("operators1");
|
|
@@ -6270,6 +6487,7 @@ var ButexEditor = forwardRef(
|
|
|
6270
6487
|
const [functionMenuOpen, setFunctionMenuOpen] = useState(false);
|
|
6271
6488
|
const [limitsSeriesMenuOpen, setLimitsSeriesMenuOpen] = useState(false);
|
|
6272
6489
|
const [function2MenuOpen, setFunction2MenuOpen] = useState(false);
|
|
6490
|
+
const [derivativeMenuOpen, setDerivativeMenuOpen] = useState(false);
|
|
6273
6491
|
const [groupMenuOpen, setGroupMenuOpen] = useState(false);
|
|
6274
6492
|
const [operatorMenuOpen, setOperatorMenuOpen] = useState(false);
|
|
6275
6493
|
const [operator2MenuOpen, setOperator2MenuOpen] = useState(false);
|
|
@@ -6928,6 +7146,87 @@ ${arabic || currentMessages.empty}`;
|
|
|
6928
7146
|
]
|
|
6929
7147
|
}
|
|
6930
7148
|
),
|
|
7149
|
+
/* @__PURE__ */ jsxs(
|
|
7150
|
+
"div",
|
|
7151
|
+
{
|
|
7152
|
+
className: "function-command-menu function-command-menu--derivative",
|
|
7153
|
+
onBlur: (event) => {
|
|
7154
|
+
const nextFocus = event.relatedTarget;
|
|
7155
|
+
if (!(nextFocus instanceof Node) || !event.currentTarget.contains(nextFocus)) {
|
|
7156
|
+
setDerivativeMenuOpen(false);
|
|
7157
|
+
}
|
|
7158
|
+
},
|
|
7159
|
+
children: [
|
|
7160
|
+
/* @__PURE__ */ jsx(
|
|
7161
|
+
"button",
|
|
7162
|
+
{
|
|
7163
|
+
className: "icon-btn function-command-btn",
|
|
7164
|
+
type: "button",
|
|
7165
|
+
title: messages.insertDerivative,
|
|
7166
|
+
"aria-label": messages.insertDerivative,
|
|
7167
|
+
"aria-haspopup": "listbox",
|
|
7168
|
+
"aria-expanded": derivativeMenuOpen,
|
|
7169
|
+
onClick: () => setDerivativeMenuOpen((open) => !open),
|
|
7170
|
+
children: DERIVATIVE_COMMANDS[0]?.arabicLabel ?? "\u0621"
|
|
7171
|
+
}
|
|
7172
|
+
),
|
|
7173
|
+
/* @__PURE__ */ jsxs("div", { className: "function-command-options", role: "listbox", "aria-label": messages.insertDerivative, hidden: !derivativeMenuOpen, children: [
|
|
7174
|
+
DERIVATIVE_COMMANDS.map((command) => /* @__PURE__ */ jsx(
|
|
7175
|
+
"button",
|
|
7176
|
+
{
|
|
7177
|
+
className: "function-command-option",
|
|
7178
|
+
type: "button",
|
|
7179
|
+
role: "option",
|
|
7180
|
+
title: atomicCommandTitle(command, uiLocale),
|
|
7181
|
+
"aria-label": atomicCommandTitle(command, uiLocale),
|
|
7182
|
+
onMouseDown: (event) => event.preventDefault(),
|
|
7183
|
+
onClick: () => {
|
|
7184
|
+
runtimeRef.current?.insertAtomicCommand(command.id);
|
|
7185
|
+
setDerivativeMenuOpen(false);
|
|
7186
|
+
focusSurface();
|
|
7187
|
+
},
|
|
7188
|
+
children: command.arabicLabel
|
|
7189
|
+
},
|
|
7190
|
+
command.id
|
|
7191
|
+
)),
|
|
7192
|
+
/* @__PURE__ */ jsx(
|
|
7193
|
+
"button",
|
|
7194
|
+
{
|
|
7195
|
+
className: "function-command-option",
|
|
7196
|
+
type: "button",
|
|
7197
|
+
role: "option",
|
|
7198
|
+
title: messages.insertFirstDerivative,
|
|
7199
|
+
"aria-label": messages.insertFirstDerivative,
|
|
7200
|
+
onMouseDown: (event) => event.preventDefault(),
|
|
7201
|
+
onClick: () => {
|
|
7202
|
+
runtimeRef.current?.insertFirstDerivative();
|
|
7203
|
+
setDerivativeMenuOpen(false);
|
|
7204
|
+
focusSurface();
|
|
7205
|
+
},
|
|
7206
|
+
children: "\u0621/\u0633"
|
|
7207
|
+
}
|
|
7208
|
+
),
|
|
7209
|
+
/* @__PURE__ */ jsx(
|
|
7210
|
+
"button",
|
|
7211
|
+
{
|
|
7212
|
+
className: "function-command-option",
|
|
7213
|
+
type: "button",
|
|
7214
|
+
role: "option",
|
|
7215
|
+
title: messages.insertSecondDerivative,
|
|
7216
|
+
"aria-label": messages.insertSecondDerivative,
|
|
7217
|
+
onMouseDown: (event) => event.preventDefault(),
|
|
7218
|
+
onClick: () => {
|
|
7219
|
+
runtimeRef.current?.insertSecondDerivative();
|
|
7220
|
+
setDerivativeMenuOpen(false);
|
|
7221
|
+
focusSurface();
|
|
7222
|
+
},
|
|
7223
|
+
children: "\u0621\xB2/\u0633\xB2"
|
|
7224
|
+
}
|
|
7225
|
+
)
|
|
7226
|
+
] })
|
|
7227
|
+
]
|
|
7228
|
+
}
|
|
7229
|
+
),
|
|
6931
7230
|
/* @__PURE__ */ jsxs(
|
|
6932
7231
|
"div",
|
|
6933
7232
|
{
|