@drghaliasri/butex 7.3.0 → 7.3.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/dist/document.d.mts +1 -1
- package/dist/document.d.ts +1 -1
- package/dist/document.js +36 -1
- package/dist/document.js.map +1 -1
- package/dist/document.mjs +36 -1
- package/dist/document.mjs.map +1 -1
- package/dist/document2-cli.js +56 -1
- 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 +56 -1
- package/dist/document2.js.map +1 -1
- package/dist/document2.mjs +56 -1
- package/dist/document2.mjs.map +1 -1
- package/dist/index.d.mts +7 -2
- package/dist/index.d.ts +7 -2
- package/dist/index.global.js +75 -2
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +75 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +75 -2
- package/dist/index.mjs.map +1 -1
- package/dist/react-document.js +71 -1
- package/dist/react-document.js.map +1 -1
- package/dist/react-document.mjs +71 -1
- package/dist/react-document.mjs.map +1 -1
- package/dist/react-document2-preview.js +50 -1
- package/dist/react-document2-preview.js.map +1 -1
- package/dist/react-document2-preview.mjs +50 -1
- 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 +71 -1
- package/dist/react-document2.js.map +1 -1
- package/dist/react-document2.mjs +71 -1
- 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 +71 -1
- package/dist/react.js.map +1 -1
- package/dist/react.mjs +71 -1
- package/dist/react.mjs.map +1 -1
- package/package.json +1 -1
|
@@ -3,7 +3,7 @@ import { ReactNode } from 'react';
|
|
|
3
3
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
4
4
|
|
|
5
5
|
type EditorSide = 'english' | 'arabic';
|
|
6
|
-
type EditorNodeKind = 'char' | 'number' | 'operator' | 'delimiter' | 'frac' | 'sqrt' | 'overset' | 'underset' | 'accent' | 'env' | 'atomicCommand' | 'atomicOperatorCommand' | 'standardCommand';
|
|
6
|
+
type EditorNodeKind = 'char' | 'number' | 'operator' | 'delimiter' | 'boxed' | 'frac' | 'sqrt' | 'overset' | 'underset' | 'accent' | 'env' | 'atomicCommand' | 'atomicOperatorCommand' | 'standardCommand';
|
|
7
7
|
type MatrixEnvStyle = 'matrix' | 'pmatrix' | 'bmatrix' | 'Bmatrix' | 'vmatrix' | 'Vmatrix';
|
|
8
8
|
type GridEnvName = MatrixEnvStyle | 'array' | 'aligned';
|
|
9
9
|
type EnvColumnAlignment = 'l' | 'c' | 'r';
|
|
@@ -3,7 +3,7 @@ import { ReactNode } from 'react';
|
|
|
3
3
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
4
4
|
|
|
5
5
|
type EditorSide = 'english' | 'arabic';
|
|
6
|
-
type EditorNodeKind = 'char' | 'number' | 'operator' | 'delimiter' | 'frac' | 'sqrt' | 'overset' | 'underset' | 'accent' | 'env' | 'atomicCommand' | 'atomicOperatorCommand' | 'standardCommand';
|
|
6
|
+
type EditorNodeKind = 'char' | 'number' | 'operator' | 'delimiter' | 'boxed' | 'frac' | 'sqrt' | 'overset' | 'underset' | 'accent' | 'env' | 'atomicCommand' | 'atomicOperatorCommand' | 'standardCommand';
|
|
7
7
|
type MatrixEnvStyle = 'matrix' | 'pmatrix' | 'bmatrix' | 'Bmatrix' | 'vmatrix' | 'Vmatrix';
|
|
8
8
|
type GridEnvName = MatrixEnvStyle | 'array' | 'aligned';
|
|
9
9
|
type EnvColumnAlignment = 'l' | 'c' | 'r';
|
package/dist/react-document2.js
CHANGED
|
@@ -2951,6 +2951,12 @@ function createDelimiterNode(leftDelimExpr2, rightDelimExpr2) {
|
|
|
2951
2951
|
innerExpr: createEditorChain()
|
|
2952
2952
|
};
|
|
2953
2953
|
}
|
|
2954
|
+
function createBoxedNode() {
|
|
2955
|
+
return {
|
|
2956
|
+
...createEditorNode("boxed", ""),
|
|
2957
|
+
innerExpr: createEditorChain()
|
|
2958
|
+
};
|
|
2959
|
+
}
|
|
2954
2960
|
function createFracNode() {
|
|
2955
2961
|
return {
|
|
2956
2962
|
...createEditorNode("frac", ""),
|
|
@@ -3174,8 +3180,9 @@ function characterFontSpec(fontId) {
|
|
|
3174
3180
|
// src/editor/divideOperator.ts
|
|
3175
3181
|
var DIVIDE_OPERATOR_EN = "/";
|
|
3176
3182
|
var DIVIDE_OPERATOR_AR = "\\";
|
|
3183
|
+
var DIVIDE_OPERATOR_AR_LATEX = "\\backslash";
|
|
3177
3184
|
function isDivideOperatorExpr(expr) {
|
|
3178
|
-
return expr === DIVIDE_OPERATOR_EN || expr === DIVIDE_OPERATOR_AR;
|
|
3185
|
+
return expr === DIVIDE_OPERATOR_EN || expr === DIVIDE_OPERATOR_AR || expr === DIVIDE_OPERATOR_AR_LATEX;
|
|
3179
3186
|
}
|
|
3180
3187
|
function divideOperatorSurfaceExpr(expr, side) {
|
|
3181
3188
|
if (!isDivideOperatorExpr(expr)) {
|
|
@@ -3296,6 +3303,10 @@ function renderNodeEnglish(node, options) {
|
|
|
3296
3303
|
if (node.kind === "delimiter" && node.innerExpr) {
|
|
3297
3304
|
return `${node.leftDelimExpr}${renderChainEnglish(node.innerExpr, options)}${node.rightDelimExpr}${latinScripts(node, options)}`;
|
|
3298
3305
|
}
|
|
3306
|
+
if (node.kind === "boxed" && node.innerExpr) {
|
|
3307
|
+
const body = `\\boxed{${renderChainEnglish(node.innerExpr, options)}}`;
|
|
3308
|
+
return `${body}${latinScripts(node, options)}`;
|
|
3309
|
+
}
|
|
3299
3310
|
if (node.kind === "frac" && node.numerator && node.denominator) {
|
|
3300
3311
|
const body = `\\frac{${renderChainEnglish(node.numerator, options)}}{${renderChainEnglish(node.denominator, options)}}`;
|
|
3301
3312
|
return `${body}${latinScripts(node, options)}`;
|
|
@@ -3352,6 +3363,10 @@ function renderNodeArabic(node, options) {
|
|
|
3352
3363
|
const content = `${node.leftDelimExpr}${renderChainArabic(node.innerExpr, options)}${node.rightDelimExpr}`;
|
|
3353
3364
|
return arabicScripts(node, content, options);
|
|
3354
3365
|
}
|
|
3366
|
+
if (node.kind === "boxed" && node.innerExpr) {
|
|
3367
|
+
const content = `\\boxed{${renderChainArabic(node.innerExpr, options)}}`;
|
|
3368
|
+
return arabicScripts(node, content, options);
|
|
3369
|
+
}
|
|
3355
3370
|
if (node.kind === "frac" && node.numerator && node.denominator) {
|
|
3356
3371
|
const content = `\\frac{${renderChainArabic(node.numerator, options)}}{${renderChainArabic(node.denominator, options)}}`;
|
|
3357
3372
|
return arabicScripts(node, content, options);
|
|
@@ -6089,6 +6104,10 @@ function buildBaseNodeBody(node, digitForm = "western", side = "english") {
|
|
|
6089
6104
|
if (node.wrapperCommand === "\\boldarabic" || node.wrapperCommand === "\\mathbf") {
|
|
6090
6105
|
value.classList.add("node-value--bold");
|
|
6091
6106
|
}
|
|
6107
|
+
if (node.wrapperCommand === "\\unit") {
|
|
6108
|
+
value.classList.add("node-value--unit");
|
|
6109
|
+
value.title = "\u0648\u062D\u062F\u0629 (unit)";
|
|
6110
|
+
}
|
|
6092
6111
|
}
|
|
6093
6112
|
const surfaceExpr = node.kind === "operator" ? divideOperatorSurfaceExpr(node.expr, side) : node.expr;
|
|
6094
6113
|
value.textContent = surfaceExpr === "" ? "\u25A1" : formatDigits(surfaceExpr, digitForm);
|
|
@@ -6184,6 +6203,29 @@ function buildDelimiterNodeBody(node, buildChain) {
|
|
|
6184
6203
|
return pair;
|
|
6185
6204
|
}
|
|
6186
6205
|
|
|
6206
|
+
// src/editor/display/boxed.ts
|
|
6207
|
+
var BOXED_CSS = `
|
|
6208
|
+
.boxed-command {
|
|
6209
|
+
display: inline-flex;
|
|
6210
|
+
align-items: center;
|
|
6211
|
+
border: 1.5px solid currentColor;
|
|
6212
|
+
padding: 0.12em 0.22em;
|
|
6213
|
+
min-height: 1.25em;
|
|
6214
|
+
}
|
|
6215
|
+
|
|
6216
|
+
.boxed-command > .chain {
|
|
6217
|
+
min-height: auto;
|
|
6218
|
+
}
|
|
6219
|
+
`.trim();
|
|
6220
|
+
function buildBoxedNodeBody(node, buildChain) {
|
|
6221
|
+
const box = document.createElement("span");
|
|
6222
|
+
box.className = "boxed-command";
|
|
6223
|
+
if (node.innerExpr) {
|
|
6224
|
+
box.appendChild(buildChain(node.innerExpr));
|
|
6225
|
+
}
|
|
6226
|
+
return box;
|
|
6227
|
+
}
|
|
6228
|
+
|
|
6187
6229
|
// src/editor/display/frac.ts
|
|
6188
6230
|
var FRAC_CSS = `
|
|
6189
6231
|
.frac {
|
|
@@ -6938,6 +6980,9 @@ function buildNodeBody(node, buildChain, side, digitForm = "western", uiLocale =
|
|
|
6938
6980
|
if (node.kind === "delimiter") {
|
|
6939
6981
|
return buildDelimiterNodeBody(node, buildChain);
|
|
6940
6982
|
}
|
|
6983
|
+
if (node.kind === "boxed") {
|
|
6984
|
+
return buildBoxedNodeBody(node, buildChain);
|
|
6985
|
+
}
|
|
6941
6986
|
if (node.kind === "frac") {
|
|
6942
6987
|
return buildFracNodeBody(node, buildChain);
|
|
6943
6988
|
}
|
|
@@ -7014,6 +7059,13 @@ ${CHARACTER_FONT_CSS}
|
|
|
7014
7059
|
font-weight: 700;
|
|
7015
7060
|
}
|
|
7016
7061
|
|
|
7062
|
+
.node-value--unit {
|
|
7063
|
+
font-style: normal;
|
|
7064
|
+
text-decoration-line: underline;
|
|
7065
|
+
text-decoration-style: dotted;
|
|
7066
|
+
text-underline-offset: 0.2em;
|
|
7067
|
+
}
|
|
7068
|
+
|
|
7017
7069
|
.chain {
|
|
7018
7070
|
display: inline-flex;
|
|
7019
7071
|
align-items: center;
|
|
@@ -7167,6 +7219,8 @@ ${CHARACTER_FONT_CSS}
|
|
|
7167
7219
|
|
|
7168
7220
|
${DELIMITER_CSS}
|
|
7169
7221
|
|
|
7222
|
+
${BOXED_CSS}
|
|
7223
|
+
|
|
7170
7224
|
${FRAC_CSS}
|
|
7171
7225
|
|
|
7172
7226
|
${SQRT_CSS}
|
|
@@ -8446,6 +8500,16 @@ function commandToEditorNode(node) {
|
|
|
8446
8500
|
}
|
|
8447
8501
|
return { editable: true, node: sqrt };
|
|
8448
8502
|
}
|
|
8503
|
+
if (node.name === "\\boxed" && node.optionalArgs.length === 0 && node.mandatoryArgs.length === 1) {
|
|
8504
|
+
const boxed = createBoxedNode();
|
|
8505
|
+
const inner = chainToEditorChain(node.mandatoryArgs[0]);
|
|
8506
|
+
if (!inner.editable) {
|
|
8507
|
+
return inner;
|
|
8508
|
+
}
|
|
8509
|
+
boxed.innerExpr = inner.chain;
|
|
8510
|
+
const scripts = attachScripts(node, boxed);
|
|
8511
|
+
return scripts ?? { editable: true, node: boxed };
|
|
8512
|
+
}
|
|
8449
8513
|
if (node.name === "\\overset" && node.mandatoryArgs.length >= 2) {
|
|
8450
8514
|
const overset = createOversetNode();
|
|
8451
8515
|
const overExpr = chainToEditorChain(node.mandatoryArgs[0]);
|
|
@@ -8729,6 +8793,12 @@ function editorNodeToAstNode(node) {
|
|
|
8729
8793
|
return inner;
|
|
8730
8794
|
}
|
|
8731
8795
|
astNode = new DelimiterNode(node.leftDelimExpr, inner.chain, node.rightDelimExpr);
|
|
8796
|
+
} else if (node.kind === "boxed" && node.innerExpr) {
|
|
8797
|
+
const inner = editorChainToAstChain(node.innerExpr);
|
|
8798
|
+
if (!inner.ok) {
|
|
8799
|
+
return inner;
|
|
8800
|
+
}
|
|
8801
|
+
astNode = new CommandNode("\\boxed", [], [inner.chain]);
|
|
8732
8802
|
} else if (node.kind === "frac" && node.numerator && node.denominator) {
|
|
8733
8803
|
const numerator = editorChainToAstChain(node.numerator);
|
|
8734
8804
|
const denominator = editorChainToAstChain(node.denominator);
|