@drghaliasri/butex 7.3.1 → 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.
Files changed (43) hide show
  1. package/dist/document.d.mts +1 -1
  2. package/dist/document.d.ts +1 -1
  3. package/dist/document.js +27 -0
  4. package/dist/document.js.map +1 -1
  5. package/dist/document.mjs +27 -0
  6. package/dist/document.mjs.map +1 -1
  7. package/dist/document2-cli.js +47 -0
  8. package/dist/document2-cli.js.map +1 -1
  9. package/dist/document2.d.mts +1 -1
  10. package/dist/document2.d.ts +1 -1
  11. package/dist/document2.js +47 -0
  12. package/dist/document2.js.map +1 -1
  13. package/dist/document2.mjs +47 -0
  14. package/dist/document2.mjs.map +1 -1
  15. package/dist/index.d.mts +7 -2
  16. package/dist/index.d.ts +7 -2
  17. package/dist/index.global.js +44 -0
  18. package/dist/index.global.js.map +1 -1
  19. package/dist/index.js +44 -0
  20. package/dist/index.js.map +1 -1
  21. package/dist/index.mjs +44 -0
  22. package/dist/index.mjs.map +1 -1
  23. package/dist/react-document.js +58 -0
  24. package/dist/react-document.js.map +1 -1
  25. package/dist/react-document.mjs +58 -0
  26. package/dist/react-document.mjs.map +1 -1
  27. package/dist/react-document2-preview.js +41 -0
  28. package/dist/react-document2-preview.js.map +1 -1
  29. package/dist/react-document2-preview.mjs +41 -0
  30. package/dist/react-document2-preview.mjs.map +1 -1
  31. package/dist/react-document2.d.mts +1 -1
  32. package/dist/react-document2.d.ts +1 -1
  33. package/dist/react-document2.js +58 -0
  34. package/dist/react-document2.js.map +1 -1
  35. package/dist/react-document2.mjs +58 -0
  36. package/dist/react-document2.mjs.map +1 -1
  37. package/dist/react.d.mts +1 -1
  38. package/dist/react.d.ts +1 -1
  39. package/dist/react.js +58 -0
  40. package/dist/react.js.map +1 -1
  41. package/dist/react.mjs +58 -0
  42. package/dist/react.mjs.map +1 -1
  43. 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';
@@ -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", ""),
@@ -3297,6 +3303,10 @@ function renderNodeEnglish(node, options) {
3297
3303
  if (node.kind === "delimiter" && node.innerExpr) {
3298
3304
  return `${node.leftDelimExpr}${renderChainEnglish(node.innerExpr, options)}${node.rightDelimExpr}${latinScripts(node, options)}`;
3299
3305
  }
3306
+ if (node.kind === "boxed" && node.innerExpr) {
3307
+ const body = `\\boxed{${renderChainEnglish(node.innerExpr, options)}}`;
3308
+ return `${body}${latinScripts(node, options)}`;
3309
+ }
3300
3310
  if (node.kind === "frac" && node.numerator && node.denominator) {
3301
3311
  const body = `\\frac{${renderChainEnglish(node.numerator, options)}}{${renderChainEnglish(node.denominator, options)}}`;
3302
3312
  return `${body}${latinScripts(node, options)}`;
@@ -3353,6 +3363,10 @@ function renderNodeArabic(node, options) {
3353
3363
  const content = `${node.leftDelimExpr}${renderChainArabic(node.innerExpr, options)}${node.rightDelimExpr}`;
3354
3364
  return arabicScripts(node, content, options);
3355
3365
  }
3366
+ if (node.kind === "boxed" && node.innerExpr) {
3367
+ const content = `\\boxed{${renderChainArabic(node.innerExpr, options)}}`;
3368
+ return arabicScripts(node, content, options);
3369
+ }
3356
3370
  if (node.kind === "frac" && node.numerator && node.denominator) {
3357
3371
  const content = `\\frac{${renderChainArabic(node.numerator, options)}}{${renderChainArabic(node.denominator, options)}}`;
3358
3372
  return arabicScripts(node, content, options);
@@ -6189,6 +6203,29 @@ function buildDelimiterNodeBody(node, buildChain) {
6189
6203
  return pair;
6190
6204
  }
6191
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
+
6192
6229
  // src/editor/display/frac.ts
6193
6230
  var FRAC_CSS = `
6194
6231
  .frac {
@@ -6943,6 +6980,9 @@ function buildNodeBody(node, buildChain, side, digitForm = "western", uiLocale =
6943
6980
  if (node.kind === "delimiter") {
6944
6981
  return buildDelimiterNodeBody(node, buildChain);
6945
6982
  }
6983
+ if (node.kind === "boxed") {
6984
+ return buildBoxedNodeBody(node, buildChain);
6985
+ }
6946
6986
  if (node.kind === "frac") {
6947
6987
  return buildFracNodeBody(node, buildChain);
6948
6988
  }
@@ -7179,6 +7219,8 @@ ${CHARACTER_FONT_CSS}
7179
7219
 
7180
7220
  ${DELIMITER_CSS}
7181
7221
 
7222
+ ${BOXED_CSS}
7223
+
7182
7224
  ${FRAC_CSS}
7183
7225
 
7184
7226
  ${SQRT_CSS}
@@ -8458,6 +8500,16 @@ function commandToEditorNode(node) {
8458
8500
  }
8459
8501
  return { editable: true, node: sqrt };
8460
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
+ }
8461
8513
  if (node.name === "\\overset" && node.mandatoryArgs.length >= 2) {
8462
8514
  const overset = createOversetNode();
8463
8515
  const overExpr = chainToEditorChain(node.mandatoryArgs[0]);
@@ -8741,6 +8793,12 @@ function editorNodeToAstNode(node) {
8741
8793
  return inner;
8742
8794
  }
8743
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]);
8744
8802
  } else if (node.kind === "frac" && node.numerator && node.denominator) {
8745
8803
  const numerator = editorChainToAstChain(node.numerator);
8746
8804
  const denominator = editorChainToAstChain(node.denominator);