@drghaliasri/butex 7.2.0 → 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 +38 -2
- package/dist/document.js.map +1 -1
- package/dist/document.mjs +38 -2
- package/dist/document.mjs.map +1 -1
- package/dist/document2-cli.js +107 -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 +107 -2
- package/dist/document2.js.map +1 -1
- package/dist/document2.mjs +107 -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 +109 -11
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +109 -11
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +109 -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 +230 -40
- package/dist/react-document.js.map +1 -1
- package/dist/react-document.mjs +230 -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 +91 -0
- package/dist/react-document2-preview.js.map +1 -1
- package/dist/react-document2-preview.mjs +91 -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 +230 -40
- package/dist/react-document2.js.map +1 -1
- package/dist/react-document2.mjs +230 -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 +230 -40
- package/dist/react.js.map +1 -1
- package/dist/react.mjs +230 -40
- package/dist/react.mjs.map +1 -1
- package/package.json +1 -1
|
@@ -14,6 +14,7 @@ type ArabicNodeJson = {
|
|
|
14
14
|
opening?: string;
|
|
15
15
|
closing?: string;
|
|
16
16
|
lines?: ChainJson[];
|
|
17
|
+
source_latex?: string;
|
|
17
18
|
};
|
|
18
19
|
type ChainJson = {
|
|
19
20
|
node_type: 'ChainClass';
|
|
@@ -26,6 +27,7 @@ declare class BaseAstNode {
|
|
|
26
27
|
superscript: ChainNode | null;
|
|
27
28
|
subscript: ChainNode | null;
|
|
28
29
|
nodeType: string;
|
|
30
|
+
sourceLatex: string | null;
|
|
29
31
|
constructor(state?: State | null);
|
|
30
32
|
latex(): string;
|
|
31
33
|
arabicLatex(): string;
|
|
@@ -14,6 +14,7 @@ type ArabicNodeJson = {
|
|
|
14
14
|
opening?: string;
|
|
15
15
|
closing?: string;
|
|
16
16
|
lines?: ChainJson[];
|
|
17
|
+
source_latex?: string;
|
|
17
18
|
};
|
|
18
19
|
type ChainJson = {
|
|
19
20
|
node_type: 'ChainClass';
|
|
@@ -26,6 +27,7 @@ declare class BaseAstNode {
|
|
|
26
27
|
superscript: ChainNode | null;
|
|
27
28
|
subscript: ChainNode | null;
|
|
28
29
|
nodeType: string;
|
|
30
|
+
sourceLatex: string | null;
|
|
29
31
|
constructor(state?: State | null);
|
|
30
32
|
latex(): string;
|
|
31
33
|
arabicLatex(): string;
|
|
@@ -46,6 +46,7 @@ var BaseAstNode = class {
|
|
|
46
46
|
superscript;
|
|
47
47
|
subscript;
|
|
48
48
|
nodeType;
|
|
49
|
+
sourceLatex;
|
|
49
50
|
constructor(state = null) {
|
|
50
51
|
if (state === null) {
|
|
51
52
|
state = new State();
|
|
@@ -54,6 +55,7 @@ var BaseAstNode = class {
|
|
|
54
55
|
this.superscript = null;
|
|
55
56
|
this.subscript = null;
|
|
56
57
|
this.nodeType = this.constructor.name;
|
|
58
|
+
this.sourceLatex = null;
|
|
57
59
|
}
|
|
58
60
|
latex() {
|
|
59
61
|
throw new Error("NotImplementedError");
|
|
@@ -242,6 +244,7 @@ ${this.closing}`;
|
|
|
242
244
|
}
|
|
243
245
|
};
|
|
244
246
|
function parseScripts(node, json, mode) {
|
|
247
|
+
node.sourceLatex = typeof json.source_latex === "string" && json.source_latex.length > 0 ? json.source_latex : null;
|
|
245
248
|
if (json.superscript) {
|
|
246
249
|
node.superscript = parseChain(json.superscript, mode);
|
|
247
250
|
}
|
|
@@ -1961,6 +1964,15 @@ var ATOMIC_OPERATOR_COMMANDS = {
|
|
|
1961
1964
|
title: "\u0627\u0644\u0644\u0627\u0646\u0647\u0627\u064A\u0629",
|
|
1962
1965
|
svg_path: null
|
|
1963
1966
|
},
|
|
1967
|
+
top: {
|
|
1968
|
+
id: "top",
|
|
1969
|
+
category: "operators1",
|
|
1970
|
+
Tex: "\\top",
|
|
1971
|
+
mirror: false,
|
|
1972
|
+
Label: "\u22A4",
|
|
1973
|
+
title: "\u0627\u0644\u0645\u0646\u0642\u0648\u0644",
|
|
1974
|
+
svg_path: null
|
|
1975
|
+
},
|
|
1964
1976
|
times: {
|
|
1965
1977
|
id: "times",
|
|
1966
1978
|
category: "operators1",
|
|
@@ -2698,6 +2710,7 @@ function cloneEditorSession(session) {
|
|
|
2698
2710
|
forceSplitNextLeaf: session.forceSplitNextLeaf,
|
|
2699
2711
|
arabicReverseNumberTyping: session.arabicReverseNumberTyping,
|
|
2700
2712
|
currentCharacterFont: session.currentCharacterFont ?? "default",
|
|
2713
|
+
currentCharacterWrapper: session.currentCharacterWrapper ?? null,
|
|
2701
2714
|
currentDigitForm: session.currentDigitForm ?? "western",
|
|
2702
2715
|
caret: { ...session.caret },
|
|
2703
2716
|
selection: session.selection ? { ...session.selection } : null,
|
|
@@ -2770,6 +2783,7 @@ function createEditorSession(englishTree, arabicTree, activeSide = "arabic") {
|
|
|
2770
2783
|
forceSplitNextLeaf: false,
|
|
2771
2784
|
arabicReverseNumberTyping: true,
|
|
2772
2785
|
currentCharacterFont: "default",
|
|
2786
|
+
currentCharacterWrapper: null,
|
|
2773
2787
|
currentDigitForm: "western",
|
|
2774
2788
|
caret: {
|
|
2775
2789
|
chainId: englishTree.id,
|
|
@@ -2839,6 +2853,7 @@ var CHARACTER_FONT_SPECS = [
|
|
|
2839
2853
|
latexFontCommand: "\\maghribi",
|
|
2840
2854
|
latexFontFamily: "Almaghribi Warsh Quran",
|
|
2841
2855
|
browserFontStack: '"Almaghribi Warsh Quran", Amiri, "Segoe UI", Tahoma, sans-serif',
|
|
2856
|
+
importAliases: ["\\maghribi"],
|
|
2842
2857
|
svgLayoutKey: "maghribi"
|
|
2843
2858
|
}
|
|
2844
2859
|
];
|
|
@@ -3005,6 +3020,14 @@ function renderNodeEnglish(node, options) {
|
|
|
3005
3020
|
return `${node.expr}${latinScripts(node, options)}`;
|
|
3006
3021
|
}
|
|
3007
3022
|
if (node.kind === "char") {
|
|
3023
|
+
if (node.sourceLatex) {
|
|
3024
|
+
return `${node.sourceLatex}${latinScripts(node, options)}`;
|
|
3025
|
+
}
|
|
3026
|
+
if (node.wrapperCommand) {
|
|
3027
|
+
const expr = formatDigits(node.expr, selectedDigitForm(options));
|
|
3028
|
+
const wrapper = node.wrapperCommand === "\\boldarabic" ? "\\mathbf" : node.wrapperCommand;
|
|
3029
|
+
return `${wrapper}{${escapeText(expr)}}${latinScripts(node, options)}`;
|
|
3030
|
+
}
|
|
3008
3031
|
return `${renderCharContent(node, options)}${latinScripts(node, options)}`;
|
|
3009
3032
|
}
|
|
3010
3033
|
if (node.kind === "operator" && isDivideOperatorExpr(node.expr)) {
|
|
@@ -3058,6 +3081,10 @@ function renderNodeArabic(node, options) {
|
|
|
3058
3081
|
if (node.kind === "char") {
|
|
3059
3082
|
const expr = formatDigits(node.expr, selectedDigitForm(options));
|
|
3060
3083
|
const content = renderCharContent(node, options);
|
|
3084
|
+
if (node.wrapperCommand) {
|
|
3085
|
+
const wrapper = node.wrapperCommand === "\\mathbf" ? "\\boldarabic" : node.wrapperCommand;
|
|
3086
|
+
return arabicScripts(node, `${wrapper}{${content}}`, options);
|
|
3087
|
+
}
|
|
3061
3088
|
return arabicScripts(node, (node.characterFont ?? "default") === "default" ? `\\text{${escapeText(expr)}}` : content, options);
|
|
3062
3089
|
}
|
|
3063
3090
|
if (node.kind === "operator" && isDivideOperatorExpr(node.expr)) {
|
|
@@ -3656,6 +3683,11 @@ ${BUTEX_FONT_FACE_CSS}
|
|
|
3656
3683
|
|
|
3657
3684
|
${CHARACTER_FONT_CSS}
|
|
3658
3685
|
|
|
3686
|
+
.node-value--bold {
|
|
3687
|
+
font-family: var(--font-display-ar, Amiri), "Noto Serif Arabic", serif;
|
|
3688
|
+
font-weight: 700;
|
|
3689
|
+
}
|
|
3690
|
+
|
|
3659
3691
|
.chain {
|
|
3660
3692
|
display: inline-flex;
|
|
3661
3693
|
align-items: center;
|
|
@@ -3924,6 +3956,9 @@ function cloneChainWithFreshIds(chain) {
|
|
|
3924
3956
|
return structuredClone(chain);
|
|
3925
3957
|
}
|
|
3926
3958
|
function attachScripts(astNode, editorNode) {
|
|
3959
|
+
if (astNode.sourceLatex) {
|
|
3960
|
+
editorNode.sourceLatex = astNode.sourceLatex;
|
|
3961
|
+
}
|
|
3927
3962
|
if (astNode.superscript) {
|
|
3928
3963
|
const sup = chainToEditorChain(astNode.superscript);
|
|
3929
3964
|
if (!sup.editable) {
|
|
@@ -4050,6 +4085,49 @@ function charFromTextLikeCommand(node) {
|
|
|
4050
4085
|
const scripts = attachScripts(node, editorNode);
|
|
4051
4086
|
return scripts ?? { editable: true, node: editorNode };
|
|
4052
4087
|
}
|
|
4088
|
+
function singleCommandChar(node) {
|
|
4089
|
+
if (node.optionalArgs.length > 0 || node.mandatoryArgs.length !== 1) {
|
|
4090
|
+
return null;
|
|
4091
|
+
}
|
|
4092
|
+
const arg = node.mandatoryArgs[0];
|
|
4093
|
+
if (arg.chain.length !== 1 || !(arg.chain[0] instanceof CharNode)) {
|
|
4094
|
+
return null;
|
|
4095
|
+
}
|
|
4096
|
+
return arg.chain[0];
|
|
4097
|
+
}
|
|
4098
|
+
function wrappedAtomicCommandId(node) {
|
|
4099
|
+
if (node.name !== "\\mathbb" && node.name !== "\\mathrm") {
|
|
4100
|
+
return null;
|
|
4101
|
+
}
|
|
4102
|
+
const child = singleCommandChar(node);
|
|
4103
|
+
if (!child) {
|
|
4104
|
+
return null;
|
|
4105
|
+
}
|
|
4106
|
+
return commandIdForTex(`${node.name}{${child.expr}}`);
|
|
4107
|
+
}
|
|
4108
|
+
function editableWrapperCommand(node) {
|
|
4109
|
+
if (node.name !== "\\mathtt" && node.name !== "\\mathsf" && node.name !== "\\unit" && node.name !== "\\mathbf" && node.name !== "\\boldarabic") {
|
|
4110
|
+
return null;
|
|
4111
|
+
}
|
|
4112
|
+
const child = singleCommandChar(node);
|
|
4113
|
+
if (!child) {
|
|
4114
|
+
return null;
|
|
4115
|
+
}
|
|
4116
|
+
const normalized = normalizeCharImportExpr(child.expr);
|
|
4117
|
+
const editorNode = createEditorNode("char", normalized.expr);
|
|
4118
|
+
if (normalized.characterFont !== "default") {
|
|
4119
|
+
editorNode.characterFont = normalized.characterFont;
|
|
4120
|
+
}
|
|
4121
|
+
editorNode.wrapperCommand = node.name === "\\mathtt" ? "\\mathtt" : node.name === "\\mathbf" ? "\\mathbf" : node.name === "\\boldarabic" ? "\\boldarabic" : "\\unit";
|
|
4122
|
+
const scripts = attachScripts(node, editorNode);
|
|
4123
|
+
if (scripts) {
|
|
4124
|
+
return scripts;
|
|
4125
|
+
}
|
|
4126
|
+
if (!editorNode.sourceLatex && node.name === "\\mathsf") {
|
|
4127
|
+
editorNode.sourceLatex = `\\mathsf{${child.expr}}`;
|
|
4128
|
+
}
|
|
4129
|
+
return { editable: true, node: editorNode };
|
|
4130
|
+
}
|
|
4053
4131
|
function commandToEditorNode(node) {
|
|
4054
4132
|
if (node.name === "\\frac" && node.mandatoryArgs.length >= 2) {
|
|
4055
4133
|
const frac = createFracNode();
|
|
@@ -4139,6 +4217,19 @@ function commandToEditorNode(node) {
|
|
|
4139
4217
|
}
|
|
4140
4218
|
return { editable: true, node: accent };
|
|
4141
4219
|
}
|
|
4220
|
+
const wrappedAtomicId = wrappedAtomicCommandId(node);
|
|
4221
|
+
if (wrappedAtomicId) {
|
|
4222
|
+
const atomic = createEditorNode("atomicCommand", wrappedAtomicId);
|
|
4223
|
+
const scripts = attachScripts(node, atomic);
|
|
4224
|
+
if (scripts) {
|
|
4225
|
+
return scripts;
|
|
4226
|
+
}
|
|
4227
|
+
return { editable: true, node: atomic };
|
|
4228
|
+
}
|
|
4229
|
+
const wrapper = editableWrapperCommand(node);
|
|
4230
|
+
if (wrapper) {
|
|
4231
|
+
return wrapper;
|
|
4232
|
+
}
|
|
4142
4233
|
const atomicId = commandIdForTex(node.name);
|
|
4143
4234
|
if (atomicId && node.optionalArgs.length === 0 && node.mandatoryArgs.length === 0) {
|
|
4144
4235
|
const atomic = createEditorNode("atomicCommand", atomicId);
|