@drghaliasri/butex 7.2.1 → 7.2.2
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 +1 -0
- package/dist/document.d.mts +8 -0
- package/dist/document.d.ts +8 -0
- package/dist/document.js +37 -2
- package/dist/document.js.map +1 -1
- package/dist/document.mjs +37 -2
- package/dist/document.mjs.map +1 -1
- package/dist/document2-cli.js +106 -2
- package/dist/document2-cli.js.map +1 -1
- package/dist/document2.d.mts +8 -0
- package/dist/document2.d.ts +8 -0
- package/dist/document2.js +106 -2
- package/dist/document2.js.map +1 -1
- package/dist/document2.mjs +106 -2
- package/dist/document2.mjs.map +1 -1
- package/dist/index.d.mts +19 -1
- package/dist/index.d.ts +19 -1
- package/dist/index.global.js +108 -11
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +108 -11
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +108 -11
- package/dist/index.mjs.map +1 -1
- package/dist/react-document.d.mts +2 -0
- package/dist/react-document.d.ts +2 -0
- package/dist/react-document.js +229 -40
- package/dist/react-document.js.map +1 -1
- package/dist/react-document.mjs +229 -40
- package/dist/react-document.mjs.map +1 -1
- package/dist/react-document2-preview.d.mts +2 -0
- package/dist/react-document2-preview.d.ts +2 -0
- package/dist/react-document2-preview.js +90 -0
- package/dist/react-document2-preview.js.map +1 -1
- package/dist/react-document2-preview.mjs +90 -0
- package/dist/react-document2-preview.mjs.map +1 -1
- package/dist/react-document2.d.mts +8 -0
- package/dist/react-document2.d.ts +8 -0
- package/dist/react-document2.js +229 -40
- package/dist/react-document2.js.map +1 -1
- package/dist/react-document2.mjs +229 -40
- package/dist/react-document2.mjs.map +1 -1
- package/dist/react.d.mts +16 -0
- package/dist/react.d.ts +16 -0
- package/dist/react.js +229 -40
- package/dist/react.js.map +1 -1
- package/dist/react.mjs +229 -40
- package/dist/react.mjs.map +1 -1
- package/package.json +1 -1
|
@@ -17,6 +17,7 @@ var BaseAstNode = class {
|
|
|
17
17
|
superscript;
|
|
18
18
|
subscript;
|
|
19
19
|
nodeType;
|
|
20
|
+
sourceLatex;
|
|
20
21
|
constructor(state = null) {
|
|
21
22
|
if (state === null) {
|
|
22
23
|
state = new State();
|
|
@@ -25,6 +26,7 @@ var BaseAstNode = class {
|
|
|
25
26
|
this.superscript = null;
|
|
26
27
|
this.subscript = null;
|
|
27
28
|
this.nodeType = this.constructor.name;
|
|
29
|
+
this.sourceLatex = null;
|
|
28
30
|
}
|
|
29
31
|
latex() {
|
|
30
32
|
throw new Error("NotImplementedError");
|
|
@@ -213,6 +215,7 @@ ${this.closing}`;
|
|
|
213
215
|
}
|
|
214
216
|
};
|
|
215
217
|
function parseScripts(node, json, mode) {
|
|
218
|
+
node.sourceLatex = typeof json.source_latex === "string" && json.source_latex.length > 0 ? json.source_latex : null;
|
|
216
219
|
if (json.superscript) {
|
|
217
220
|
node.superscript = parseChain(json.superscript, mode);
|
|
218
221
|
}
|
|
@@ -1932,6 +1935,15 @@ var ATOMIC_OPERATOR_COMMANDS = {
|
|
|
1932
1935
|
title: "\u0627\u0644\u0644\u0627\u0646\u0647\u0627\u064A\u0629",
|
|
1933
1936
|
svg_path: null
|
|
1934
1937
|
},
|
|
1938
|
+
top: {
|
|
1939
|
+
id: "top",
|
|
1940
|
+
category: "operators1",
|
|
1941
|
+
Tex: "\\top",
|
|
1942
|
+
mirror: false,
|
|
1943
|
+
Label: "\u22A4",
|
|
1944
|
+
title: "\u0627\u0644\u0645\u0646\u0642\u0648\u0644",
|
|
1945
|
+
svg_path: null
|
|
1946
|
+
},
|
|
1935
1947
|
times: {
|
|
1936
1948
|
id: "times",
|
|
1937
1949
|
category: "operators1",
|
|
@@ -2669,6 +2681,7 @@ function cloneEditorSession(session) {
|
|
|
2669
2681
|
forceSplitNextLeaf: session.forceSplitNextLeaf,
|
|
2670
2682
|
arabicReverseNumberTyping: session.arabicReverseNumberTyping,
|
|
2671
2683
|
currentCharacterFont: session.currentCharacterFont ?? "default",
|
|
2684
|
+
currentCharacterWrapper: session.currentCharacterWrapper ?? null,
|
|
2672
2685
|
currentDigitForm: session.currentDigitForm ?? "western",
|
|
2673
2686
|
caret: { ...session.caret },
|
|
2674
2687
|
selection: session.selection ? { ...session.selection } : null,
|
|
@@ -2741,6 +2754,7 @@ function createEditorSession(englishTree, arabicTree, activeSide = "arabic") {
|
|
|
2741
2754
|
forceSplitNextLeaf: false,
|
|
2742
2755
|
arabicReverseNumberTyping: true,
|
|
2743
2756
|
currentCharacterFont: "default",
|
|
2757
|
+
currentCharacterWrapper: null,
|
|
2744
2758
|
currentDigitForm: "western",
|
|
2745
2759
|
caret: {
|
|
2746
2760
|
chainId: englishTree.id,
|
|
@@ -2977,6 +2991,14 @@ function renderNodeEnglish(node, options) {
|
|
|
2977
2991
|
return `${node.expr}${latinScripts(node, options)}`;
|
|
2978
2992
|
}
|
|
2979
2993
|
if (node.kind === "char") {
|
|
2994
|
+
if (node.sourceLatex) {
|
|
2995
|
+
return `${node.sourceLatex}${latinScripts(node, options)}`;
|
|
2996
|
+
}
|
|
2997
|
+
if (node.wrapperCommand) {
|
|
2998
|
+
const expr = formatDigits(node.expr, selectedDigitForm(options));
|
|
2999
|
+
const wrapper = node.wrapperCommand === "\\boldarabic" ? "\\mathbf" : node.wrapperCommand;
|
|
3000
|
+
return `${wrapper}{${escapeText(expr)}}${latinScripts(node, options)}`;
|
|
3001
|
+
}
|
|
2980
3002
|
return `${renderCharContent(node, options)}${latinScripts(node, options)}`;
|
|
2981
3003
|
}
|
|
2982
3004
|
if (node.kind === "operator" && isDivideOperatorExpr(node.expr)) {
|
|
@@ -3030,6 +3052,10 @@ function renderNodeArabic(node, options) {
|
|
|
3030
3052
|
if (node.kind === "char") {
|
|
3031
3053
|
const expr = formatDigits(node.expr, selectedDigitForm(options));
|
|
3032
3054
|
const content = renderCharContent(node, options);
|
|
3055
|
+
if (node.wrapperCommand) {
|
|
3056
|
+
const wrapper = node.wrapperCommand === "\\mathbf" ? "\\boldarabic" : node.wrapperCommand;
|
|
3057
|
+
return arabicScripts(node, `${wrapper}{${content}}`, options);
|
|
3058
|
+
}
|
|
3033
3059
|
return arabicScripts(node, (node.characterFont ?? "default") === "default" ? `\\text{${escapeText(expr)}}` : content, options);
|
|
3034
3060
|
}
|
|
3035
3061
|
if (node.kind === "operator" && isDivideOperatorExpr(node.expr)) {
|
|
@@ -3628,6 +3654,11 @@ ${BUTEX_FONT_FACE_CSS}
|
|
|
3628
3654
|
|
|
3629
3655
|
${CHARACTER_FONT_CSS}
|
|
3630
3656
|
|
|
3657
|
+
.node-value--bold {
|
|
3658
|
+
font-family: var(--font-display-ar, Amiri), "Noto Serif Arabic", serif;
|
|
3659
|
+
font-weight: 700;
|
|
3660
|
+
}
|
|
3661
|
+
|
|
3631
3662
|
.chain {
|
|
3632
3663
|
display: inline-flex;
|
|
3633
3664
|
align-items: center;
|
|
@@ -3896,6 +3927,9 @@ function cloneChainWithFreshIds(chain) {
|
|
|
3896
3927
|
return structuredClone(chain);
|
|
3897
3928
|
}
|
|
3898
3929
|
function attachScripts(astNode, editorNode) {
|
|
3930
|
+
if (astNode.sourceLatex) {
|
|
3931
|
+
editorNode.sourceLatex = astNode.sourceLatex;
|
|
3932
|
+
}
|
|
3899
3933
|
if (astNode.superscript) {
|
|
3900
3934
|
const sup = chainToEditorChain(astNode.superscript);
|
|
3901
3935
|
if (!sup.editable) {
|
|
@@ -4022,6 +4056,49 @@ function charFromTextLikeCommand(node) {
|
|
|
4022
4056
|
const scripts = attachScripts(node, editorNode);
|
|
4023
4057
|
return scripts ?? { editable: true, node: editorNode };
|
|
4024
4058
|
}
|
|
4059
|
+
function singleCommandChar(node) {
|
|
4060
|
+
if (node.optionalArgs.length > 0 || node.mandatoryArgs.length !== 1) {
|
|
4061
|
+
return null;
|
|
4062
|
+
}
|
|
4063
|
+
const arg = node.mandatoryArgs[0];
|
|
4064
|
+
if (arg.chain.length !== 1 || !(arg.chain[0] instanceof CharNode)) {
|
|
4065
|
+
return null;
|
|
4066
|
+
}
|
|
4067
|
+
return arg.chain[0];
|
|
4068
|
+
}
|
|
4069
|
+
function wrappedAtomicCommandId(node) {
|
|
4070
|
+
if (node.name !== "\\mathbb" && node.name !== "\\mathrm") {
|
|
4071
|
+
return null;
|
|
4072
|
+
}
|
|
4073
|
+
const child = singleCommandChar(node);
|
|
4074
|
+
if (!child) {
|
|
4075
|
+
return null;
|
|
4076
|
+
}
|
|
4077
|
+
return commandIdForTex(`${node.name}{${child.expr}}`);
|
|
4078
|
+
}
|
|
4079
|
+
function editableWrapperCommand(node) {
|
|
4080
|
+
if (node.name !== "\\mathtt" && node.name !== "\\mathsf" && node.name !== "\\unit" && node.name !== "\\mathbf" && node.name !== "\\boldarabic") {
|
|
4081
|
+
return null;
|
|
4082
|
+
}
|
|
4083
|
+
const child = singleCommandChar(node);
|
|
4084
|
+
if (!child) {
|
|
4085
|
+
return null;
|
|
4086
|
+
}
|
|
4087
|
+
const normalized = normalizeCharImportExpr(child.expr);
|
|
4088
|
+
const editorNode = createEditorNode("char", normalized.expr);
|
|
4089
|
+
if (normalized.characterFont !== "default") {
|
|
4090
|
+
editorNode.characterFont = normalized.characterFont;
|
|
4091
|
+
}
|
|
4092
|
+
editorNode.wrapperCommand = node.name === "\\mathtt" ? "\\mathtt" : node.name === "\\mathbf" ? "\\mathbf" : node.name === "\\boldarabic" ? "\\boldarabic" : "\\unit";
|
|
4093
|
+
const scripts = attachScripts(node, editorNode);
|
|
4094
|
+
if (scripts) {
|
|
4095
|
+
return scripts;
|
|
4096
|
+
}
|
|
4097
|
+
if (!editorNode.sourceLatex && node.name === "\\mathsf") {
|
|
4098
|
+
editorNode.sourceLatex = `\\mathsf{${child.expr}}`;
|
|
4099
|
+
}
|
|
4100
|
+
return { editable: true, node: editorNode };
|
|
4101
|
+
}
|
|
4025
4102
|
function commandToEditorNode(node) {
|
|
4026
4103
|
if (node.name === "\\frac" && node.mandatoryArgs.length >= 2) {
|
|
4027
4104
|
const frac = createFracNode();
|
|
@@ -4111,6 +4188,19 @@ function commandToEditorNode(node) {
|
|
|
4111
4188
|
}
|
|
4112
4189
|
return { editable: true, node: accent };
|
|
4113
4190
|
}
|
|
4191
|
+
const wrappedAtomicId = wrappedAtomicCommandId(node);
|
|
4192
|
+
if (wrappedAtomicId) {
|
|
4193
|
+
const atomic = createEditorNode("atomicCommand", wrappedAtomicId);
|
|
4194
|
+
const scripts = attachScripts(node, atomic);
|
|
4195
|
+
if (scripts) {
|
|
4196
|
+
return scripts;
|
|
4197
|
+
}
|
|
4198
|
+
return { editable: true, node: atomic };
|
|
4199
|
+
}
|
|
4200
|
+
const wrapper = editableWrapperCommand(node);
|
|
4201
|
+
if (wrapper) {
|
|
4202
|
+
return wrapper;
|
|
4203
|
+
}
|
|
4114
4204
|
const atomicId = commandIdForTex(node.name);
|
|
4115
4205
|
if (atomicId && node.optionalArgs.length === 0 && node.mandatoryArgs.length === 0) {
|
|
4116
4206
|
const atomic = createEditorNode("atomicCommand", atomicId);
|