@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.
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 +36 -1
  4. package/dist/document.js.map +1 -1
  5. package/dist/document.mjs +36 -1
  6. package/dist/document.mjs.map +1 -1
  7. package/dist/document2-cli.js +56 -1
  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 +56 -1
  12. package/dist/document2.js.map +1 -1
  13. package/dist/document2.mjs +56 -1
  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 +75 -2
  18. package/dist/index.global.js.map +1 -1
  19. package/dist/index.js +75 -2
  20. package/dist/index.js.map +1 -1
  21. package/dist/index.mjs +75 -2
  22. package/dist/index.mjs.map +1 -1
  23. package/dist/react-document.js +71 -1
  24. package/dist/react-document.js.map +1 -1
  25. package/dist/react-document.mjs +71 -1
  26. package/dist/react-document.mjs.map +1 -1
  27. package/dist/react-document2-preview.js +50 -1
  28. package/dist/react-document2-preview.js.map +1 -1
  29. package/dist/react-document2-preview.mjs +50 -1
  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 +71 -1
  34. package/dist/react-document2.js.map +1 -1
  35. package/dist/react-document2.mjs +71 -1
  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 +71 -1
  40. package/dist/react.js.map +1 -1
  41. package/dist/react.mjs +71 -1
  42. package/dist/react.mjs.map +1 -1
  43. package/package.json +1 -1
@@ -2914,6 +2914,12 @@ function createDelimiterNode(leftDelimExpr2, rightDelimExpr2) {
2914
2914
  innerExpr: createEditorChain()
2915
2915
  };
2916
2916
  }
2917
+ function createBoxedNode() {
2918
+ return {
2919
+ ...createEditorNode("boxed", ""),
2920
+ innerExpr: createEditorChain()
2921
+ };
2922
+ }
2917
2923
  function createFracNode() {
2918
2924
  return {
2919
2925
  ...createEditorNode("frac", ""),
@@ -3137,8 +3143,9 @@ function characterFontSpec(fontId) {
3137
3143
  // src/editor/divideOperator.ts
3138
3144
  var DIVIDE_OPERATOR_EN = "/";
3139
3145
  var DIVIDE_OPERATOR_AR = "\\";
3146
+ var DIVIDE_OPERATOR_AR_LATEX = "\\backslash";
3140
3147
  function isDivideOperatorExpr(expr) {
3141
- return expr === DIVIDE_OPERATOR_EN || expr === DIVIDE_OPERATOR_AR;
3148
+ return expr === DIVIDE_OPERATOR_EN || expr === DIVIDE_OPERATOR_AR || expr === DIVIDE_OPERATOR_AR_LATEX;
3142
3149
  }
3143
3150
  function divideOperatorSurfaceExpr(expr, side) {
3144
3151
  if (!isDivideOperatorExpr(expr)) {
@@ -3259,6 +3266,10 @@ function renderNodeEnglish(node, options) {
3259
3266
  if (node.kind === "delimiter" && node.innerExpr) {
3260
3267
  return `${node.leftDelimExpr}${renderChainEnglish(node.innerExpr, options)}${node.rightDelimExpr}${latinScripts(node, options)}`;
3261
3268
  }
3269
+ if (node.kind === "boxed" && node.innerExpr) {
3270
+ const body = `\\boxed{${renderChainEnglish(node.innerExpr, options)}}`;
3271
+ return `${body}${latinScripts(node, options)}`;
3272
+ }
3262
3273
  if (node.kind === "frac" && node.numerator && node.denominator) {
3263
3274
  const body = `\\frac{${renderChainEnglish(node.numerator, options)}}{${renderChainEnglish(node.denominator, options)}}`;
3264
3275
  return `${body}${latinScripts(node, options)}`;
@@ -3315,6 +3326,10 @@ function renderNodeArabic(node, options) {
3315
3326
  const content = `${node.leftDelimExpr}${renderChainArabic(node.innerExpr, options)}${node.rightDelimExpr}`;
3316
3327
  return arabicScripts(node, content, options);
3317
3328
  }
3329
+ if (node.kind === "boxed" && node.innerExpr) {
3330
+ const content = `\\boxed{${renderChainArabic(node.innerExpr, options)}}`;
3331
+ return arabicScripts(node, content, options);
3332
+ }
3318
3333
  if (node.kind === "frac" && node.numerator && node.denominator) {
3319
3334
  const content = `\\frac{${renderChainArabic(node.numerator, options)}}{${renderChainArabic(node.denominator, options)}}`;
3320
3335
  return arabicScripts(node, content, options);
@@ -6052,6 +6067,10 @@ function buildBaseNodeBody(node, digitForm = "western", side = "english") {
6052
6067
  if (node.wrapperCommand === "\\boldarabic" || node.wrapperCommand === "\\mathbf") {
6053
6068
  value.classList.add("node-value--bold");
6054
6069
  }
6070
+ if (node.wrapperCommand === "\\unit") {
6071
+ value.classList.add("node-value--unit");
6072
+ value.title = "\u0648\u062D\u062F\u0629 (unit)";
6073
+ }
6055
6074
  }
6056
6075
  const surfaceExpr = node.kind === "operator" ? divideOperatorSurfaceExpr(node.expr, side) : node.expr;
6057
6076
  value.textContent = surfaceExpr === "" ? "\u25A1" : formatDigits(surfaceExpr, digitForm);
@@ -6147,6 +6166,29 @@ function buildDelimiterNodeBody(node, buildChain) {
6147
6166
  return pair;
6148
6167
  }
6149
6168
 
6169
+ // src/editor/display/boxed.ts
6170
+ var BOXED_CSS = `
6171
+ .boxed-command {
6172
+ display: inline-flex;
6173
+ align-items: center;
6174
+ border: 1.5px solid currentColor;
6175
+ padding: 0.12em 0.22em;
6176
+ min-height: 1.25em;
6177
+ }
6178
+
6179
+ .boxed-command > .chain {
6180
+ min-height: auto;
6181
+ }
6182
+ `.trim();
6183
+ function buildBoxedNodeBody(node, buildChain) {
6184
+ const box = document.createElement("span");
6185
+ box.className = "boxed-command";
6186
+ if (node.innerExpr) {
6187
+ box.appendChild(buildChain(node.innerExpr));
6188
+ }
6189
+ return box;
6190
+ }
6191
+
6150
6192
  // src/editor/display/frac.ts
6151
6193
  var FRAC_CSS = `
6152
6194
  .frac {
@@ -6901,6 +6943,9 @@ function buildNodeBody(node, buildChain, side, digitForm = "western", uiLocale =
6901
6943
  if (node.kind === "delimiter") {
6902
6944
  return buildDelimiterNodeBody(node, buildChain);
6903
6945
  }
6946
+ if (node.kind === "boxed") {
6947
+ return buildBoxedNodeBody(node, buildChain);
6948
+ }
6904
6949
  if (node.kind === "frac") {
6905
6950
  return buildFracNodeBody(node, buildChain);
6906
6951
  }
@@ -6977,6 +7022,13 @@ ${CHARACTER_FONT_CSS}
6977
7022
  font-weight: 700;
6978
7023
  }
6979
7024
 
7025
+ .node-value--unit {
7026
+ font-style: normal;
7027
+ text-decoration-line: underline;
7028
+ text-decoration-style: dotted;
7029
+ text-underline-offset: 0.2em;
7030
+ }
7031
+
6980
7032
  .chain {
6981
7033
  display: inline-flex;
6982
7034
  align-items: center;
@@ -7130,6 +7182,8 @@ ${CHARACTER_FONT_CSS}
7130
7182
 
7131
7183
  ${DELIMITER_CSS}
7132
7184
 
7185
+ ${BOXED_CSS}
7186
+
7133
7187
  ${FRAC_CSS}
7134
7188
 
7135
7189
  ${SQRT_CSS}
@@ -8409,6 +8463,16 @@ function commandToEditorNode(node) {
8409
8463
  }
8410
8464
  return { editable: true, node: sqrt };
8411
8465
  }
8466
+ if (node.name === "\\boxed" && node.optionalArgs.length === 0 && node.mandatoryArgs.length === 1) {
8467
+ const boxed = createBoxedNode();
8468
+ const inner = chainToEditorChain(node.mandatoryArgs[0]);
8469
+ if (!inner.editable) {
8470
+ return inner;
8471
+ }
8472
+ boxed.innerExpr = inner.chain;
8473
+ const scripts = attachScripts(node, boxed);
8474
+ return scripts ?? { editable: true, node: boxed };
8475
+ }
8412
8476
  if (node.name === "\\overset" && node.mandatoryArgs.length >= 2) {
8413
8477
  const overset = createOversetNode();
8414
8478
  const overExpr = chainToEditorChain(node.mandatoryArgs[0]);
@@ -8692,6 +8756,12 @@ function editorNodeToAstNode(node) {
8692
8756
  return inner;
8693
8757
  }
8694
8758
  astNode = new DelimiterNode(node.leftDelimExpr, inner.chain, node.rightDelimExpr);
8759
+ } else if (node.kind === "boxed" && node.innerExpr) {
8760
+ const inner = editorChainToAstChain(node.innerExpr);
8761
+ if (!inner.ok) {
8762
+ return inner;
8763
+ }
8764
+ astNode = new CommandNode("\\boxed", [], [inner.chain]);
8695
8765
  } else if (node.kind === "frac" && node.numerator && node.denominator) {
8696
8766
  const numerator = editorChainToAstChain(node.numerator);
8697
8767
  const denominator = editorChainToAstChain(node.denominator);