@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
@@ -1993,6 +1993,12 @@ function createDelimiterNode(leftDelimExpr2, rightDelimExpr2) {
1993
1993
  innerExpr: createEditorChain()
1994
1994
  };
1995
1995
  }
1996
+ function createBoxedNode() {
1997
+ return {
1998
+ ...createEditorNode("boxed", ""),
1999
+ innerExpr: createEditorChain()
2000
+ };
2001
+ }
1996
2002
  function createFracNode() {
1997
2003
  return {
1998
2004
  ...createEditorNode("frac", ""),
@@ -2216,8 +2222,9 @@ function characterFontSpec(fontId) {
2216
2222
  // src/editor/divideOperator.ts
2217
2223
  var DIVIDE_OPERATOR_EN = "/";
2218
2224
  var DIVIDE_OPERATOR_AR = "\\";
2225
+ var DIVIDE_OPERATOR_AR_LATEX = "\\backslash";
2219
2226
  function isDivideOperatorExpr(expr) {
2220
- return expr === DIVIDE_OPERATOR_EN || expr === DIVIDE_OPERATOR_AR;
2227
+ return expr === DIVIDE_OPERATOR_EN || expr === DIVIDE_OPERATOR_AR || expr === DIVIDE_OPERATOR_AR_LATEX;
2221
2228
  }
2222
2229
  function divideOperatorSurfaceExpr(expr, side) {
2223
2230
  if (!isDivideOperatorExpr(expr)) {
@@ -2366,6 +2373,10 @@ function renderNodeEnglish(node, options) {
2366
2373
  if (node.kind === "delimiter" && node.innerExpr) {
2367
2374
  return `${node.leftDelimExpr}${renderChainEnglish(node.innerExpr, options)}${node.rightDelimExpr}${latinScripts(node, options)}`;
2368
2375
  }
2376
+ if (node.kind === "boxed" && node.innerExpr) {
2377
+ const body = `\\boxed{${renderChainEnglish(node.innerExpr, options)}}`;
2378
+ return `${body}${latinScripts(node, options)}`;
2379
+ }
2369
2380
  if (node.kind === "frac" && node.numerator && node.denominator) {
2370
2381
  const body = `\\frac{${renderChainEnglish(node.numerator, options)}}{${renderChainEnglish(node.denominator, options)}}`;
2371
2382
  return `${body}${latinScripts(node, options)}`;
@@ -2422,6 +2433,10 @@ function renderNodeArabic(node, options) {
2422
2433
  const content = `${node.leftDelimExpr}${renderChainArabic(node.innerExpr, options)}${node.rightDelimExpr}`;
2423
2434
  return arabicScripts(node, content, options);
2424
2435
  }
2436
+ if (node.kind === "boxed" && node.innerExpr) {
2437
+ const content = `\\boxed{${renderChainArabic(node.innerExpr, options)}}`;
2438
+ return arabicScripts(node, content, options);
2439
+ }
2425
2440
  if (node.kind === "frac" && node.numerator && node.denominator) {
2426
2441
  const content = `\\frac{${renderChainArabic(node.numerator, options)}}{${renderChainArabic(node.denominator, options)}}`;
2427
2442
  return arabicScripts(node, content, options);
@@ -5159,6 +5174,10 @@ function buildBaseNodeBody(node, digitForm = "western", side = "english") {
5159
5174
  if (node.wrapperCommand === "\\boldarabic" || node.wrapperCommand === "\\mathbf") {
5160
5175
  value.classList.add("node-value--bold");
5161
5176
  }
5177
+ if (node.wrapperCommand === "\\unit") {
5178
+ value.classList.add("node-value--unit");
5179
+ value.title = "\u0648\u062D\u062F\u0629 (unit)";
5180
+ }
5162
5181
  }
5163
5182
  const surfaceExpr = node.kind === "operator" ? divideOperatorSurfaceExpr(node.expr, side) : node.expr;
5164
5183
  value.textContent = surfaceExpr === "" ? "\u25A1" : formatDigits(surfaceExpr, digitForm);
@@ -5254,6 +5273,29 @@ function buildDelimiterNodeBody(node, buildChain) {
5254
5273
  return pair;
5255
5274
  }
5256
5275
 
5276
+ // src/editor/display/boxed.ts
5277
+ var BOXED_CSS = `
5278
+ .boxed-command {
5279
+ display: inline-flex;
5280
+ align-items: center;
5281
+ border: 1.5px solid currentColor;
5282
+ padding: 0.12em 0.22em;
5283
+ min-height: 1.25em;
5284
+ }
5285
+
5286
+ .boxed-command > .chain {
5287
+ min-height: auto;
5288
+ }
5289
+ `.trim();
5290
+ function buildBoxedNodeBody(node, buildChain) {
5291
+ const box = document.createElement("span");
5292
+ box.className = "boxed-command";
5293
+ if (node.innerExpr) {
5294
+ box.appendChild(buildChain(node.innerExpr));
5295
+ }
5296
+ return box;
5297
+ }
5298
+
5257
5299
  // src/editor/display/frac.ts
5258
5300
  var FRAC_CSS = `
5259
5301
  .frac {
@@ -6008,6 +6050,9 @@ function buildNodeBody(node, buildChain, side, digitForm = "western", uiLocale =
6008
6050
  if (node.kind === "delimiter") {
6009
6051
  return buildDelimiterNodeBody(node, buildChain);
6010
6052
  }
6053
+ if (node.kind === "boxed") {
6054
+ return buildBoxedNodeBody(node, buildChain);
6055
+ }
6011
6056
  if (node.kind === "frac") {
6012
6057
  return buildFracNodeBody(node, buildChain);
6013
6058
  }
@@ -6084,6 +6129,13 @@ ${CHARACTER_FONT_CSS}
6084
6129
  font-weight: 700;
6085
6130
  }
6086
6131
 
6132
+ .node-value--unit {
6133
+ font-style: normal;
6134
+ text-decoration-line: underline;
6135
+ text-decoration-style: dotted;
6136
+ text-underline-offset: 0.2em;
6137
+ }
6138
+
6087
6139
  .chain {
6088
6140
  display: inline-flex;
6089
6141
  align-items: center;
@@ -6237,6 +6289,8 @@ ${CHARACTER_FONT_CSS}
6237
6289
 
6238
6290
  ${DELIMITER_CSS}
6239
6291
 
6292
+ ${BOXED_CSS}
6293
+
6240
6294
  ${FRAC_CSS}
6241
6295
 
6242
6296
  ${SQRT_CSS}
@@ -7516,6 +7570,16 @@ function commandToEditorNode(node) {
7516
7570
  }
7517
7571
  return { editable: true, node: sqrt };
7518
7572
  }
7573
+ if (node.name === "\\boxed" && node.optionalArgs.length === 0 && node.mandatoryArgs.length === 1) {
7574
+ const boxed = createBoxedNode();
7575
+ const inner = chainToEditorChain(node.mandatoryArgs[0]);
7576
+ if (!inner.editable) {
7577
+ return inner;
7578
+ }
7579
+ boxed.innerExpr = inner.chain;
7580
+ const scripts = attachScripts(node, boxed);
7581
+ return scripts ?? { editable: true, node: boxed };
7582
+ }
7519
7583
  if (node.name === "\\overset" && node.mandatoryArgs.length >= 2) {
7520
7584
  const overset = createOversetNode();
7521
7585
  const overExpr = chainToEditorChain(node.mandatoryArgs[0]);
@@ -7799,6 +7863,12 @@ function editorNodeToAstNode(node) {
7799
7863
  return inner;
7800
7864
  }
7801
7865
  astNode = new DelimiterNode(node.leftDelimExpr, inner.chain, node.rightDelimExpr);
7866
+ } else if (node.kind === "boxed" && node.innerExpr) {
7867
+ const inner = editorChainToAstChain(node.innerExpr);
7868
+ if (!inner.ok) {
7869
+ return inner;
7870
+ }
7871
+ astNode = new CommandNode("\\boxed", [], [inner.chain]);
7802
7872
  } else if (node.kind === "frac" && node.numerator && node.denominator) {
7803
7873
  const numerator = editorChainToAstChain(node.numerator);
7804
7874
  const denominator = editorChainToAstChain(node.denominator);