@drghaliasri/butex 7.1.4 → 7.2.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 +1 -2
- package/dist/document.d.ts +1 -2
- package/dist/document.js +56 -0
- package/dist/document.js.map +1 -1
- package/dist/document.mjs +56 -0
- package/dist/document.mjs.map +1 -1
- package/dist/document2-cli.js +298 -4
- package/dist/document2-cli.js.map +1 -1
- package/dist/document2.d.mts +1 -1
- package/dist/document2.d.ts +1 -1
- package/dist/document2.js +67 -0
- package/dist/document2.js.map +1 -1
- package/dist/document2.mjs +67 -0
- package/dist/document2.mjs.map +1 -1
- package/dist/index.d.mts +129 -2
- package/dist/index.d.ts +129 -2
- package/dist/index.global.js +99 -0
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +99 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +99 -0
- package/dist/index.mjs.map +1 -1
- package/dist/react-document.js +78 -0
- package/dist/react-document.js.map +1 -1
- package/dist/react-document.mjs +78 -0
- package/dist/react-document.mjs.map +1 -1
- package/dist/react-document2-preview.js +62 -0
- package/dist/react-document2-preview.js.map +1 -1
- package/dist/react-document2-preview.mjs +62 -0
- package/dist/react-document2-preview.mjs.map +1 -1
- package/dist/react-document2.d.mts +1 -1
- package/dist/react-document2.d.ts +1 -1
- package/dist/react-document2.js +119 -0
- package/dist/react-document2.js.map +1 -1
- package/dist/react-document2.mjs +119 -0
- package/dist/react-document2.mjs.map +1 -1
- package/dist/react.d.mts +1 -1
- package/dist/react.d.ts +1 -1
- package/dist/react.js +78 -0
- package/dist/react.js.map +1 -1
- package/dist/react.mjs +78 -0
- package/dist/react.mjs.map +1 -1
- package/package.json +1 -1
package/dist/react-document2.mjs
CHANGED
|
@@ -2795,6 +2795,67 @@ function atomicOperatorCommandSpec(id) {
|
|
|
2795
2795
|
return Object.prototype.hasOwnProperty.call(ATOMIC_OPERATOR_COMMANDS, id) ? ATOMIC_OPERATOR_COMMANDS[id] : null;
|
|
2796
2796
|
}
|
|
2797
2797
|
|
|
2798
|
+
// src/editor/standardCommands.ts
|
|
2799
|
+
var STANDARD_COMMANDS = {
|
|
2800
|
+
"\\alpha": { tex: "\\alpha", label: "\u03B1", title: "alpha" },
|
|
2801
|
+
"\\beta": { tex: "\\beta", label: "\u03B2", title: "beta" },
|
|
2802
|
+
"\\gamma": { tex: "\\gamma", label: "\u03B3", title: "gamma" },
|
|
2803
|
+
"\\delta": { tex: "\\delta", label: "\u03B4", title: "delta" },
|
|
2804
|
+
"\\epsilon": { tex: "\\epsilon", label: "\u03B5", title: "epsilon" },
|
|
2805
|
+
"\\eta": { tex: "\\eta", label: "\u03B7", title: "eta" },
|
|
2806
|
+
"\\theta": { tex: "\\theta", label: "\u03B8", title: "theta" },
|
|
2807
|
+
"\\lambda": { tex: "\\lambda", label: "\u03BB", title: "lambda" },
|
|
2808
|
+
"\\mu": { tex: "\\mu", label: "\u03BC", title: "mu" },
|
|
2809
|
+
"\\rho": { tex: "\\rho", label: "\u03C1", title: "rho" },
|
|
2810
|
+
"\\sigma": { tex: "\\sigma", label: "\u03C3", title: "sigma" },
|
|
2811
|
+
"\\tau": { tex: "\\tau", label: "\u03C4", title: "tau" },
|
|
2812
|
+
"\\phi": { tex: "\\phi", label: "\u03C6", title: "phi" },
|
|
2813
|
+
"\\chi": { tex: "\\chi", label: "\u03C7", title: "chi" },
|
|
2814
|
+
"\\psi": { tex: "\\psi", label: "\u03C8", title: "psi" },
|
|
2815
|
+
"\\omega": { tex: "\\omega", label: "\u03C9", title: "omega" },
|
|
2816
|
+
"\\zeta": { tex: "\\zeta", label: "\u03B6", title: "zeta" },
|
|
2817
|
+
"\\nabla": { tex: "\\nabla", label: "\u2207", title: "nabla" },
|
|
2818
|
+
"\\Delta": { tex: "\\Delta", label: "\u0394", title: "Delta" },
|
|
2819
|
+
"\\partial": { tex: "\\partial", label: "\u2202", title: "partial derivative" },
|
|
2820
|
+
"\\Longleftrightarrow": { tex: "\\Longleftrightarrow", label: "\u27FA", title: "long equivalence arrow" },
|
|
2821
|
+
"\\backslash": { tex: "\\backslash", label: "\u2216", title: "reverse solidus" }
|
|
2822
|
+
};
|
|
2823
|
+
function standardCommandSpec(tex) {
|
|
2824
|
+
return Object.prototype.hasOwnProperty.call(STANDARD_COMMANDS, tex) ? STANDARD_COMMANDS[tex] : null;
|
|
2825
|
+
}
|
|
2826
|
+
function isStandardCommandTex(tex) {
|
|
2827
|
+
return standardCommandSpec(tex) !== null;
|
|
2828
|
+
}
|
|
2829
|
+
function chainHasStandardCommands(chain) {
|
|
2830
|
+
for (const node of chain.nodes) {
|
|
2831
|
+
if (node.kind === "standardCommand") {
|
|
2832
|
+
return true;
|
|
2833
|
+
}
|
|
2834
|
+
const childChains = [
|
|
2835
|
+
node.superscript,
|
|
2836
|
+
node.subscript,
|
|
2837
|
+
node.innerExpr,
|
|
2838
|
+
node.numerator,
|
|
2839
|
+
node.denominator,
|
|
2840
|
+
node.radicand,
|
|
2841
|
+
node.rootIndex,
|
|
2842
|
+
node.overExpr,
|
|
2843
|
+
node.underExpr,
|
|
2844
|
+
node.baseExpr
|
|
2845
|
+
];
|
|
2846
|
+
if (childChains.some((child) => child && chainHasStandardCommands(child))) {
|
|
2847
|
+
return true;
|
|
2848
|
+
}
|
|
2849
|
+
if (node.matrixRows?.some((row) => row.some(chainHasStandardCommands))) {
|
|
2850
|
+
return true;
|
|
2851
|
+
}
|
|
2852
|
+
}
|
|
2853
|
+
return false;
|
|
2854
|
+
}
|
|
2855
|
+
function sessionHasStandardCommands(session) {
|
|
2856
|
+
return chainHasStandardCommands(session.englishTree) || chainHasStandardCommands(session.arabicTree);
|
|
2857
|
+
}
|
|
2858
|
+
|
|
2798
2859
|
// src/editor/factory.ts
|
|
2799
2860
|
var nextId2 = 1;
|
|
2800
2861
|
function makeId(prefix) {
|
|
@@ -3046,6 +3107,7 @@ var CHARACTER_FONT_SPECS = [
|
|
|
3046
3107
|
latexFontCommand: "\\maghribi",
|
|
3047
3108
|
latexFontFamily: "Almaghribi Warsh Quran",
|
|
3048
3109
|
browserFontStack: '"Almaghribi Warsh Quran", Amiri, "Segoe UI", Tahoma, sans-serif',
|
|
3110
|
+
importAliases: ["\\maghribi"],
|
|
3049
3111
|
svgLayoutKey: "maghribi"
|
|
3050
3112
|
}
|
|
3051
3113
|
];
|
|
@@ -3214,6 +3276,9 @@ function renderNodeEnglish(node, options) {
|
|
|
3214
3276
|
const body = atomicOperatorCommandSpec(node.expr)?.Tex ?? node.expr;
|
|
3215
3277
|
return `${body}${latinScripts(node, options)}`;
|
|
3216
3278
|
}
|
|
3279
|
+
if (node.kind === "standardCommand") {
|
|
3280
|
+
return `${node.expr}${latinScripts(node, options)}`;
|
|
3281
|
+
}
|
|
3217
3282
|
if (node.kind === "char") {
|
|
3218
3283
|
return `${renderCharContent(node, options)}${latinScripts(node, options)}`;
|
|
3219
3284
|
}
|
|
@@ -3262,6 +3327,9 @@ function renderNodeArabic(node, options) {
|
|
|
3262
3327
|
const content = spec?.mirror ? `\\butexmirror{${tex}}` : tex;
|
|
3263
3328
|
return arabicScripts(node, content, options);
|
|
3264
3329
|
}
|
|
3330
|
+
if (node.kind === "standardCommand") {
|
|
3331
|
+
return arabicScripts(node, node.expr, options);
|
|
3332
|
+
}
|
|
3265
3333
|
if (node.kind === "char") {
|
|
3266
3334
|
const expr = formatDigits(node.expr, selectedDigitForm(options));
|
|
3267
3335
|
const content = renderCharContent(node, options);
|
|
@@ -6718,6 +6786,27 @@ function buildAtomicOperatorCommandNodeBody(node, side, uiLocale = "ar") {
|
|
|
6718
6786
|
return value;
|
|
6719
6787
|
}
|
|
6720
6788
|
|
|
6789
|
+
// src/editor/display/standardCommand.ts
|
|
6790
|
+
var STANDARD_COMMAND_CSS = `
|
|
6791
|
+
.standard-command {
|
|
6792
|
+
display: inline-flex;
|
|
6793
|
+
align-items: center;
|
|
6794
|
+
justify-content: center;
|
|
6795
|
+
min-width: 0.9em;
|
|
6796
|
+
font-family: "Cambria Math", "Times New Roman", serif;
|
|
6797
|
+
font-size: 1.05em;
|
|
6798
|
+
line-height: 1;
|
|
6799
|
+
}
|
|
6800
|
+
`.trim();
|
|
6801
|
+
function buildStandardCommandNodeBody(node) {
|
|
6802
|
+
const spec = standardCommandSpec(node.expr);
|
|
6803
|
+
const value = document.createElement("span");
|
|
6804
|
+
value.className = "standard-command";
|
|
6805
|
+
value.title = spec?.title ?? node.expr;
|
|
6806
|
+
value.textContent = spec?.label ?? node.expr;
|
|
6807
|
+
return value;
|
|
6808
|
+
}
|
|
6809
|
+
|
|
6721
6810
|
// src/editor/display/scripts.ts
|
|
6722
6811
|
function buildNodeScripts(node, buildChain) {
|
|
6723
6812
|
const hasScripts = Boolean(node.superscript) || Boolean(node.subscript);
|
|
@@ -6777,6 +6866,9 @@ function buildNodeBody(node, buildChain, side, digitForm = "western", uiLocale =
|
|
|
6777
6866
|
if (node.kind === "atomicOperatorCommand") {
|
|
6778
6867
|
return buildAtomicOperatorCommandNodeBody(node, side, uiLocale);
|
|
6779
6868
|
}
|
|
6869
|
+
if (node.kind === "standardCommand") {
|
|
6870
|
+
return buildStandardCommandNodeBody(node);
|
|
6871
|
+
}
|
|
6780
6872
|
return buildBaseNodeBody(node, digitForm, side);
|
|
6781
6873
|
}
|
|
6782
6874
|
|
|
@@ -6989,6 +7081,8 @@ ${MATRIX_ENV_CSS}
|
|
|
6989
7081
|
${ATOMIC_COMMAND_CSS}
|
|
6990
7082
|
|
|
6991
7083
|
${ATOMIC_OPERATOR_COMMAND_CSS}
|
|
7084
|
+
|
|
7085
|
+
${STANDARD_COMMAND_CSS}
|
|
6992
7086
|
`.trim();
|
|
6993
7087
|
function injectBuTeXEditorStyles(doc) {
|
|
6994
7088
|
const d = doc ?? (typeof document !== "undefined" ? document : void 0);
|
|
@@ -8265,6 +8359,14 @@ function commandToEditorNode(node) {
|
|
|
8265
8359
|
}
|
|
8266
8360
|
return { editable: true, node: atomicOperator };
|
|
8267
8361
|
}
|
|
8362
|
+
if (isStandardCommandTex(node.name) && node.optionalArgs.length === 0 && node.mandatoryArgs.length === 0) {
|
|
8363
|
+
const standard = createEditorNode("standardCommand", node.name);
|
|
8364
|
+
const scripts = attachScripts(node, standard);
|
|
8365
|
+
if (scripts) {
|
|
8366
|
+
return scripts;
|
|
8367
|
+
}
|
|
8368
|
+
return { editable: true, node: standard };
|
|
8369
|
+
}
|
|
8268
8370
|
const textLike = charFromTextLikeCommand(node);
|
|
8269
8371
|
if (textLike) {
|
|
8270
8372
|
return textLike;
|
|
@@ -8525,6 +8627,11 @@ function editorNodeToAstNode(node) {
|
|
|
8525
8627
|
return { ok: false, reason: `\u0631\u0645\u0632 \u0631\u064A\u0627\u0636\u064A \u063A\u064A\u0631 \u0645\u062F\u0639\u0648\u0645 \u062D\u0627\u0644\u064A\u0627: ${node.expr}` };
|
|
8526
8628
|
}
|
|
8527
8629
|
astNode = new CommandNode(tex);
|
|
8630
|
+
} else if (node.kind === "standardCommand") {
|
|
8631
|
+
if (!isStandardCommandTex(node.expr)) {
|
|
8632
|
+
return { ok: false, reason: `\u0623\u0645\u0631 \u0631\u064A\u0627\u0636\u064A \u0642\u064A\u0627\u0633\u064A \u063A\u064A\u0631 \u0645\u062F\u0639\u0648\u0645 \u062D\u0627\u0644\u064A\u0627: ${node.expr}` };
|
|
8633
|
+
}
|
|
8634
|
+
astNode = new CommandNode(node.expr);
|
|
8528
8635
|
} else if (node.kind === "env") {
|
|
8529
8636
|
return editorEnvToAstNode(node);
|
|
8530
8637
|
} else {
|
|
@@ -17857,6 +17964,9 @@ function keyErrorMessage2(error, messages) {
|
|
|
17857
17964
|
}
|
|
17858
17965
|
return null;
|
|
17859
17966
|
}
|
|
17967
|
+
function standardCommandWarning(uiLocale) {
|
|
17968
|
+
return uiLocale === "en" ? "This equation contains standard non-Arabic math commands. Review them and replace them with the Arabic-oriented equivalent where appropriate." : "\u062A\u062D\u062A\u0648\u064A \u0647\u0630\u0647 \u0627\u0644\u0645\u0639\u0627\u062F\u0644\u0629 \u0639\u0644\u0649 \u0631\u0645\u0648\u0632 \u0623\u0648 \u0623\u0648\u0627\u0645\u0631 \u0631\u064A\u0627\u0636\u064A\u0629 \u0642\u064A\u0627\u0633\u064A\u0629 \u063A\u064A\u0631 \u0645\u0639\u0631\u0651\u0628\u0629. \u064A\u064F\u0631\u062C\u0649 \u0645\u0631\u0627\u062C\u0639\u062A\u0647\u0627 \u0648\u0627\u0633\u062A\u0628\u062F\u0627\u0644\u0647\u0627 \u0628\u0627\u0644\u0645\u0642\u0627\u0628\u0644 \u0627\u0644\u0639\u0631\u0628\u064A \u0639\u0646\u062F \u0627\u0644\u062D\u0627\u062C\u0629.";
|
|
17969
|
+
}
|
|
17860
17970
|
function EquationDrawer({
|
|
17861
17971
|
debug = false,
|
|
17862
17972
|
session,
|
|
@@ -17884,6 +17994,9 @@ function EquationDrawer({
|
|
|
17884
17994
|
const dialogRef = useRef11(null);
|
|
17885
17995
|
const titleId = useId5();
|
|
17886
17996
|
const [labelOverride, setLabelOverride] = useState10(null);
|
|
17997
|
+
const [hasStandardCommandWarning, setHasStandardCommandWarning] = useState10(
|
|
17998
|
+
() => sessionHasStandardCommands(session)
|
|
17999
|
+
);
|
|
17887
18000
|
const displayedLabel = labelOverride ?? label;
|
|
17888
18001
|
const labelError = labelEnabled && mathMode === "display" ? document2KeyError(displayedLabel, {
|
|
17889
18002
|
references,
|
|
@@ -17893,6 +18006,10 @@ function EquationDrawer({
|
|
|
17893
18006
|
useEffect11(() => {
|
|
17894
18007
|
setLabelOverride(null);
|
|
17895
18008
|
}, [ownerId, label]);
|
|
18009
|
+
useEffect11(() => {
|
|
18010
|
+
latestSession.current = session;
|
|
18011
|
+
setHasStandardCommandWarning(sessionHasStandardCommands(session));
|
|
18012
|
+
}, [session]);
|
|
17896
18013
|
useDialogFocus({ open: true, dialogRef, onClose });
|
|
17897
18014
|
useEffect11(() => observeVisibleViewport(window, ({ snapshot }) => {
|
|
17898
18015
|
const modal = modalRef.current;
|
|
@@ -17990,6 +18107,7 @@ function EquationDrawer({
|
|
|
17990
18107
|
] }) : null
|
|
17991
18108
|
] }) : null,
|
|
17992
18109
|
reason ? /* @__PURE__ */ jsx15("p", { className: "butex-document2-widget__error", children: uiLocale === "en" ? messages.equationUnavailable : reason }) : null,
|
|
18110
|
+
hasStandardCommandWarning && !reason ? /* @__PURE__ */ jsx15("p", { className: "butex-document2-widget__standard-command-warning", role: "status", children: standardCommandWarning(uiLocale) }) : null,
|
|
17993
18111
|
/* @__PURE__ */ jsx15(
|
|
17994
18112
|
ButexEditor,
|
|
17995
18113
|
{
|
|
@@ -18001,6 +18119,7 @@ function EquationDrawer({
|
|
|
18001
18119
|
initialSession: session,
|
|
18002
18120
|
onSessionChange: (nextSession) => {
|
|
18003
18121
|
latestSession.current = nextSession;
|
|
18122
|
+
setHasStandardCommandWarning(sessionHasStandardCommands(nextSession));
|
|
18004
18123
|
}
|
|
18005
18124
|
}
|
|
18006
18125
|
)
|