@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
package/dist/react.mjs CHANGED
@@ -54,6 +54,12 @@ function createDelimiterNode(leftDelimExpr2, rightDelimExpr2) {
54
54
  innerExpr: createEditorChain()
55
55
  };
56
56
  }
57
+ function createBoxedNode() {
58
+ return {
59
+ ...createEditorNode("boxed", ""),
60
+ innerExpr: createEditorChain()
61
+ };
62
+ }
57
63
  function createFracNode() {
58
64
  return {
59
65
  ...createEditorNode("frac", ""),
@@ -1467,8 +1473,9 @@ function characterFontSpec(fontId) {
1467
1473
  // src/editor/divideOperator.ts
1468
1474
  var DIVIDE_OPERATOR_EN = "/";
1469
1475
  var DIVIDE_OPERATOR_AR = "\\";
1476
+ var DIVIDE_OPERATOR_AR_LATEX = "\\backslash";
1470
1477
  function isDivideOperatorExpr(expr) {
1471
- return expr === DIVIDE_OPERATOR_EN || expr === DIVIDE_OPERATOR_AR;
1478
+ return expr === DIVIDE_OPERATOR_EN || expr === DIVIDE_OPERATOR_AR || expr === DIVIDE_OPERATOR_AR_LATEX;
1472
1479
  }
1473
1480
  function divideOperatorSurfaceExpr(expr, side) {
1474
1481
  if (!isDivideOperatorExpr(expr)) {
@@ -1617,6 +1624,10 @@ function renderNodeEnglish(node, options) {
1617
1624
  if (node.kind === "delimiter" && node.innerExpr) {
1618
1625
  return `${node.leftDelimExpr}${renderChainEnglish(node.innerExpr, options)}${node.rightDelimExpr}${latinScripts(node, options)}`;
1619
1626
  }
1627
+ if (node.kind === "boxed" && node.innerExpr) {
1628
+ const body = `\\boxed{${renderChainEnglish(node.innerExpr, options)}}`;
1629
+ return `${body}${latinScripts(node, options)}`;
1630
+ }
1620
1631
  if (node.kind === "frac" && node.numerator && node.denominator) {
1621
1632
  const body = `\\frac{${renderChainEnglish(node.numerator, options)}}{${renderChainEnglish(node.denominator, options)}}`;
1622
1633
  return `${body}${latinScripts(node, options)}`;
@@ -1673,6 +1684,10 @@ function renderNodeArabic(node, options) {
1673
1684
  const content = `${node.leftDelimExpr}${renderChainArabic(node.innerExpr, options)}${node.rightDelimExpr}`;
1674
1685
  return arabicScripts(node, content, options);
1675
1686
  }
1687
+ if (node.kind === "boxed" && node.innerExpr) {
1688
+ const content = `\\boxed{${renderChainArabic(node.innerExpr, options)}}`;
1689
+ return arabicScripts(node, content, options);
1690
+ }
1676
1691
  if (node.kind === "frac" && node.numerator && node.denominator) {
1677
1692
  const content = `\\frac{${renderChainArabic(node.numerator, options)}}{${renderChainArabic(node.denominator, options)}}`;
1678
1693
  return arabicScripts(node, content, options);
@@ -4410,6 +4425,10 @@ function buildBaseNodeBody(node, digitForm = "western", side = "english") {
4410
4425
  if (node.wrapperCommand === "\\boldarabic" || node.wrapperCommand === "\\mathbf") {
4411
4426
  value.classList.add("node-value--bold");
4412
4427
  }
4428
+ if (node.wrapperCommand === "\\unit") {
4429
+ value.classList.add("node-value--unit");
4430
+ value.title = "\u0648\u062D\u062F\u0629 (unit)";
4431
+ }
4413
4432
  }
4414
4433
  const surfaceExpr = node.kind === "operator" ? divideOperatorSurfaceExpr(node.expr, side) : node.expr;
4415
4434
  value.textContent = surfaceExpr === "" ? "\u25A1" : formatDigits(surfaceExpr, digitForm);
@@ -4505,6 +4524,29 @@ function buildDelimiterNodeBody(node, buildChain) {
4505
4524
  return pair;
4506
4525
  }
4507
4526
 
4527
+ // src/editor/display/boxed.ts
4528
+ var BOXED_CSS = `
4529
+ .boxed-command {
4530
+ display: inline-flex;
4531
+ align-items: center;
4532
+ border: 1.5px solid currentColor;
4533
+ padding: 0.12em 0.22em;
4534
+ min-height: 1.25em;
4535
+ }
4536
+
4537
+ .boxed-command > .chain {
4538
+ min-height: auto;
4539
+ }
4540
+ `.trim();
4541
+ function buildBoxedNodeBody(node, buildChain) {
4542
+ const box = document.createElement("span");
4543
+ box.className = "boxed-command";
4544
+ if (node.innerExpr) {
4545
+ box.appendChild(buildChain(node.innerExpr));
4546
+ }
4547
+ return box;
4548
+ }
4549
+
4508
4550
  // src/editor/display/frac.ts
4509
4551
  var FRAC_CSS = `
4510
4552
  .frac {
@@ -5259,6 +5301,9 @@ function buildNodeBody(node, buildChain, side, digitForm = "western", uiLocale =
5259
5301
  if (node.kind === "delimiter") {
5260
5302
  return buildDelimiterNodeBody(node, buildChain);
5261
5303
  }
5304
+ if (node.kind === "boxed") {
5305
+ return buildBoxedNodeBody(node, buildChain);
5306
+ }
5262
5307
  if (node.kind === "frac") {
5263
5308
  return buildFracNodeBody(node, buildChain);
5264
5309
  }
@@ -5335,6 +5380,13 @@ ${CHARACTER_FONT_CSS}
5335
5380
  font-weight: 700;
5336
5381
  }
5337
5382
 
5383
+ .node-value--unit {
5384
+ font-style: normal;
5385
+ text-decoration-line: underline;
5386
+ text-decoration-style: dotted;
5387
+ text-underline-offset: 0.2em;
5388
+ }
5389
+
5338
5390
  .chain {
5339
5391
  display: inline-flex;
5340
5392
  align-items: center;
@@ -5488,6 +5540,8 @@ ${CHARACTER_FONT_CSS}
5488
5540
 
5489
5541
  ${DELIMITER_CSS}
5490
5542
 
5543
+ ${BOXED_CSS}
5544
+
5491
5545
  ${FRAC_CSS}
5492
5546
 
5493
5547
  ${SQRT_CSS}
@@ -9018,6 +9072,16 @@ function commandToEditorNode(node) {
9018
9072
  }
9019
9073
  return { editable: true, node: sqrt };
9020
9074
  }
9075
+ if (node.name === "\\boxed" && node.optionalArgs.length === 0 && node.mandatoryArgs.length === 1) {
9076
+ const boxed = createBoxedNode();
9077
+ const inner = chainToEditorChain(node.mandatoryArgs[0]);
9078
+ if (!inner.editable) {
9079
+ return inner;
9080
+ }
9081
+ boxed.innerExpr = inner.chain;
9082
+ const scripts = attachScripts(node, boxed);
9083
+ return scripts ?? { editable: true, node: boxed };
9084
+ }
9021
9085
  if (node.name === "\\overset" && node.mandatoryArgs.length >= 2) {
9022
9086
  const overset = createOversetNode();
9023
9087
  const overExpr = chainToEditorChain(node.mandatoryArgs[0]);
@@ -9301,6 +9365,12 @@ function editorNodeToAstNode(node) {
9301
9365
  return inner;
9302
9366
  }
9303
9367
  astNode = new DelimiterNode(node.leftDelimExpr, inner.chain, node.rightDelimExpr);
9368
+ } else if (node.kind === "boxed" && node.innerExpr) {
9369
+ const inner = editorChainToAstChain(node.innerExpr);
9370
+ if (!inner.ok) {
9371
+ return inner;
9372
+ }
9373
+ astNode = new CommandNode("\\boxed", [], [inner.chain]);
9304
9374
  } else if (node.kind === "frac" && node.numerator && node.denominator) {
9305
9375
  const numerator = editorChainToAstChain(node.numerator);
9306
9376
  const denominator = editorChainToAstChain(node.denominator);