@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
package/dist/react-document.mjs
CHANGED
|
@@ -1964,6 +1964,12 @@ function createDelimiterNode(leftDelimExpr2, rightDelimExpr2) {
|
|
|
1964
1964
|
innerExpr: createEditorChain()
|
|
1965
1965
|
};
|
|
1966
1966
|
}
|
|
1967
|
+
function createBoxedNode() {
|
|
1968
|
+
return {
|
|
1969
|
+
...createEditorNode("boxed", ""),
|
|
1970
|
+
innerExpr: createEditorChain()
|
|
1971
|
+
};
|
|
1972
|
+
}
|
|
1967
1973
|
function createFracNode() {
|
|
1968
1974
|
return {
|
|
1969
1975
|
...createEditorNode("frac", ""),
|
|
@@ -2187,8 +2193,9 @@ function characterFontSpec(fontId) {
|
|
|
2187
2193
|
// src/editor/divideOperator.ts
|
|
2188
2194
|
var DIVIDE_OPERATOR_EN = "/";
|
|
2189
2195
|
var DIVIDE_OPERATOR_AR = "\\";
|
|
2196
|
+
var DIVIDE_OPERATOR_AR_LATEX = "\\backslash";
|
|
2190
2197
|
function isDivideOperatorExpr(expr) {
|
|
2191
|
-
return expr === DIVIDE_OPERATOR_EN || expr === DIVIDE_OPERATOR_AR;
|
|
2198
|
+
return expr === DIVIDE_OPERATOR_EN || expr === DIVIDE_OPERATOR_AR || expr === DIVIDE_OPERATOR_AR_LATEX;
|
|
2192
2199
|
}
|
|
2193
2200
|
function divideOperatorSurfaceExpr(expr, side) {
|
|
2194
2201
|
if (!isDivideOperatorExpr(expr)) {
|
|
@@ -2337,6 +2344,10 @@ function renderNodeEnglish(node, options) {
|
|
|
2337
2344
|
if (node.kind === "delimiter" && node.innerExpr) {
|
|
2338
2345
|
return `${node.leftDelimExpr}${renderChainEnglish(node.innerExpr, options)}${node.rightDelimExpr}${latinScripts(node, options)}`;
|
|
2339
2346
|
}
|
|
2347
|
+
if (node.kind === "boxed" && node.innerExpr) {
|
|
2348
|
+
const body = `\\boxed{${renderChainEnglish(node.innerExpr, options)}}`;
|
|
2349
|
+
return `${body}${latinScripts(node, options)}`;
|
|
2350
|
+
}
|
|
2340
2351
|
if (node.kind === "frac" && node.numerator && node.denominator) {
|
|
2341
2352
|
const body = `\\frac{${renderChainEnglish(node.numerator, options)}}{${renderChainEnglish(node.denominator, options)}}`;
|
|
2342
2353
|
return `${body}${latinScripts(node, options)}`;
|
|
@@ -2393,6 +2404,10 @@ function renderNodeArabic(node, options) {
|
|
|
2393
2404
|
const content = `${node.leftDelimExpr}${renderChainArabic(node.innerExpr, options)}${node.rightDelimExpr}`;
|
|
2394
2405
|
return arabicScripts(node, content, options);
|
|
2395
2406
|
}
|
|
2407
|
+
if (node.kind === "boxed" && node.innerExpr) {
|
|
2408
|
+
const content = `\\boxed{${renderChainArabic(node.innerExpr, options)}}`;
|
|
2409
|
+
return arabicScripts(node, content, options);
|
|
2410
|
+
}
|
|
2396
2411
|
if (node.kind === "frac" && node.numerator && node.denominator) {
|
|
2397
2412
|
const content = `\\frac{${renderChainArabic(node.numerator, options)}}{${renderChainArabic(node.denominator, options)}}`;
|
|
2398
2413
|
return arabicScripts(node, content, options);
|
|
@@ -5130,6 +5145,10 @@ function buildBaseNodeBody(node, digitForm = "western", side = "english") {
|
|
|
5130
5145
|
if (node.wrapperCommand === "\\boldarabic" || node.wrapperCommand === "\\mathbf") {
|
|
5131
5146
|
value.classList.add("node-value--bold");
|
|
5132
5147
|
}
|
|
5148
|
+
if (node.wrapperCommand === "\\unit") {
|
|
5149
|
+
value.classList.add("node-value--unit");
|
|
5150
|
+
value.title = "\u0648\u062D\u062F\u0629 (unit)";
|
|
5151
|
+
}
|
|
5133
5152
|
}
|
|
5134
5153
|
const surfaceExpr = node.kind === "operator" ? divideOperatorSurfaceExpr(node.expr, side) : node.expr;
|
|
5135
5154
|
value.textContent = surfaceExpr === "" ? "\u25A1" : formatDigits(surfaceExpr, digitForm);
|
|
@@ -5225,6 +5244,29 @@ function buildDelimiterNodeBody(node, buildChain) {
|
|
|
5225
5244
|
return pair;
|
|
5226
5245
|
}
|
|
5227
5246
|
|
|
5247
|
+
// src/editor/display/boxed.ts
|
|
5248
|
+
var BOXED_CSS = `
|
|
5249
|
+
.boxed-command {
|
|
5250
|
+
display: inline-flex;
|
|
5251
|
+
align-items: center;
|
|
5252
|
+
border: 1.5px solid currentColor;
|
|
5253
|
+
padding: 0.12em 0.22em;
|
|
5254
|
+
min-height: 1.25em;
|
|
5255
|
+
}
|
|
5256
|
+
|
|
5257
|
+
.boxed-command > .chain {
|
|
5258
|
+
min-height: auto;
|
|
5259
|
+
}
|
|
5260
|
+
`.trim();
|
|
5261
|
+
function buildBoxedNodeBody(node, buildChain) {
|
|
5262
|
+
const box = document.createElement("span");
|
|
5263
|
+
box.className = "boxed-command";
|
|
5264
|
+
if (node.innerExpr) {
|
|
5265
|
+
box.appendChild(buildChain(node.innerExpr));
|
|
5266
|
+
}
|
|
5267
|
+
return box;
|
|
5268
|
+
}
|
|
5269
|
+
|
|
5228
5270
|
// src/editor/display/frac.ts
|
|
5229
5271
|
var FRAC_CSS = `
|
|
5230
5272
|
.frac {
|
|
@@ -5979,6 +6021,9 @@ function buildNodeBody(node, buildChain, side, digitForm = "western", uiLocale =
|
|
|
5979
6021
|
if (node.kind === "delimiter") {
|
|
5980
6022
|
return buildDelimiterNodeBody(node, buildChain);
|
|
5981
6023
|
}
|
|
6024
|
+
if (node.kind === "boxed") {
|
|
6025
|
+
return buildBoxedNodeBody(node, buildChain);
|
|
6026
|
+
}
|
|
5982
6027
|
if (node.kind === "frac") {
|
|
5983
6028
|
return buildFracNodeBody(node, buildChain);
|
|
5984
6029
|
}
|
|
@@ -6055,6 +6100,13 @@ ${CHARACTER_FONT_CSS}
|
|
|
6055
6100
|
font-weight: 700;
|
|
6056
6101
|
}
|
|
6057
6102
|
|
|
6103
|
+
.node-value--unit {
|
|
6104
|
+
font-style: normal;
|
|
6105
|
+
text-decoration-line: underline;
|
|
6106
|
+
text-decoration-style: dotted;
|
|
6107
|
+
text-underline-offset: 0.2em;
|
|
6108
|
+
}
|
|
6109
|
+
|
|
6058
6110
|
.chain {
|
|
6059
6111
|
display: inline-flex;
|
|
6060
6112
|
align-items: center;
|
|
@@ -6208,6 +6260,8 @@ ${CHARACTER_FONT_CSS}
|
|
|
6208
6260
|
|
|
6209
6261
|
${DELIMITER_CSS}
|
|
6210
6262
|
|
|
6263
|
+
${BOXED_CSS}
|
|
6264
|
+
|
|
6211
6265
|
${FRAC_CSS}
|
|
6212
6266
|
|
|
6213
6267
|
${SQRT_CSS}
|
|
@@ -7487,6 +7541,16 @@ function commandToEditorNode(node) {
|
|
|
7487
7541
|
}
|
|
7488
7542
|
return { editable: true, node: sqrt };
|
|
7489
7543
|
}
|
|
7544
|
+
if (node.name === "\\boxed" && node.optionalArgs.length === 0 && node.mandatoryArgs.length === 1) {
|
|
7545
|
+
const boxed = createBoxedNode();
|
|
7546
|
+
const inner = chainToEditorChain(node.mandatoryArgs[0]);
|
|
7547
|
+
if (!inner.editable) {
|
|
7548
|
+
return inner;
|
|
7549
|
+
}
|
|
7550
|
+
boxed.innerExpr = inner.chain;
|
|
7551
|
+
const scripts = attachScripts(node, boxed);
|
|
7552
|
+
return scripts ?? { editable: true, node: boxed };
|
|
7553
|
+
}
|
|
7490
7554
|
if (node.name === "\\overset" && node.mandatoryArgs.length >= 2) {
|
|
7491
7555
|
const overset = createOversetNode();
|
|
7492
7556
|
const overExpr = chainToEditorChain(node.mandatoryArgs[0]);
|
|
@@ -7770,6 +7834,12 @@ function editorNodeToAstNode(node) {
|
|
|
7770
7834
|
return inner;
|
|
7771
7835
|
}
|
|
7772
7836
|
astNode = new DelimiterNode(node.leftDelimExpr, inner.chain, node.rightDelimExpr);
|
|
7837
|
+
} else if (node.kind === "boxed" && node.innerExpr) {
|
|
7838
|
+
const inner = editorChainToAstChain(node.innerExpr);
|
|
7839
|
+
if (!inner.ok) {
|
|
7840
|
+
return inner;
|
|
7841
|
+
}
|
|
7842
|
+
astNode = new CommandNode("\\boxed", [], [inner.chain]);
|
|
7773
7843
|
} else if (node.kind === "frac" && node.numerator && node.denominator) {
|
|
7774
7844
|
const numerator = editorChainToAstChain(node.numerator);
|
|
7775
7845
|
const denominator = editorChainToAstChain(node.denominator);
|