@drghaliasri/butex 7.4.2 → 8.0.1

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 (53) hide show
  1. package/README.md +49 -553
  2. package/dist/{document2-cli.js → document-cli.js} +419 -348
  3. package/dist/document-cli.js.map +1 -0
  4. package/dist/document.d.mts +1022 -186
  5. package/dist/document.d.ts +1022 -186
  6. package/dist/document.js +6103 -652
  7. package/dist/document.js.map +1 -1
  8. package/dist/document.mjs +5963 -612
  9. package/dist/document.mjs.map +1 -1
  10. package/dist/index.d.mts +12 -0
  11. package/dist/index.d.ts +12 -0
  12. package/dist/index.global.js +14 -0
  13. package/dist/index.global.js.map +1 -1
  14. package/dist/index.js +14 -0
  15. package/dist/index.js.map +1 -1
  16. package/dist/index.mjs +14 -0
  17. package/dist/index.mjs.map +1 -1
  18. package/dist/react-document-preview.d.mts +338 -0
  19. package/dist/react-document-preview.d.ts +338 -0
  20. package/dist/{react-document2-preview.js → react-document-preview.js} +811 -791
  21. package/dist/react-document-preview.js.map +1 -0
  22. package/dist/{react-document2-preview.mjs → react-document-preview.mjs} +804 -784
  23. package/dist/react-document-preview.mjs.map +1 -0
  24. package/dist/react-document.d.mts +634 -35
  25. package/dist/react-document.d.ts +634 -35
  26. package/dist/react-document.js +13540 -4542
  27. package/dist/react-document.js.map +1 -1
  28. package/dist/react-document.mjs +13536 -4546
  29. package/dist/react-document.mjs.map +1 -1
  30. package/dist/react.d.mts +12 -0
  31. package/dist/react.d.ts +12 -0
  32. package/dist/react.js +33 -12
  33. package/dist/react.js.map +1 -1
  34. package/dist/react.mjs +33 -12
  35. package/dist/react.mjs.map +1 -1
  36. package/package.json +7 -17
  37. package/dist/document2-cli.js.map +0 -1
  38. package/dist/document2.d.mts +0 -1156
  39. package/dist/document2.d.ts +0 -1156
  40. package/dist/document2.js +0 -9137
  41. package/dist/document2.js.map +0 -1
  42. package/dist/document2.mjs +0 -8972
  43. package/dist/document2.mjs.map +0 -1
  44. package/dist/react-document2-preview.d.mts +0 -338
  45. package/dist/react-document2-preview.d.ts +0 -338
  46. package/dist/react-document2-preview.js.map +0 -1
  47. package/dist/react-document2-preview.mjs.map +0 -1
  48. package/dist/react-document2.d.mts +0 -754
  49. package/dist/react-document2.d.ts +0 -754
  50. package/dist/react-document2.js +0 -23011
  51. package/dist/react-document2.js.map +0 -1
  52. package/dist/react-document2.mjs +0 -22981
  53. package/dist/react-document2.mjs.map +0 -1
package/dist/react.d.mts CHANGED
@@ -522,6 +522,18 @@ declare const ATOMIC_COMMANDS: {
522
522
  readonly level: 1;
523
523
  };
524
524
  };
525
+ readonly thinSpace: {
526
+ readonly id: "thinSpace";
527
+ readonly category: "spacing";
528
+ readonly englishTex: "\\,";
529
+ readonly arabicTex: "\\,";
530
+ readonly arabicLabel: "";
531
+ readonly title: "فراغ رفيع";
532
+ readonly spacing: {
533
+ readonly direction: "positive";
534
+ readonly level: 1;
535
+ };
536
+ };
525
537
  readonly mediumSpace: {
526
538
  readonly id: "mediumSpace";
527
539
  readonly category: "spacing";
package/dist/react.d.ts CHANGED
@@ -522,6 +522,18 @@ declare const ATOMIC_COMMANDS: {
522
522
  readonly level: 1;
523
523
  };
524
524
  };
525
+ readonly thinSpace: {
526
+ readonly id: "thinSpace";
527
+ readonly category: "spacing";
528
+ readonly englishTex: "\\,";
529
+ readonly arabicTex: "\\,";
530
+ readonly arabicLabel: "";
531
+ readonly title: "فراغ رفيع";
532
+ readonly spacing: {
533
+ readonly direction: "positive";
534
+ readonly level: 1;
535
+ };
536
+ };
525
537
  readonly mediumSpace: {
526
538
  readonly id: "mediumSpace";
527
539
  readonly category: "spacing";
package/dist/react.js CHANGED
@@ -712,6 +712,15 @@ var ATOMIC_COMMANDS = {
712
712
  title: "\u0641\u0631\u0627\u063A \u0633\u0627\u0644\u0628 \u0631\u0641\u064A\u0639",
713
713
  spacing: { direction: "negative", level: 1 }
714
714
  },
715
+ thinSpace: {
716
+ id: "thinSpace",
717
+ category: "spacing",
718
+ englishTex: "\\,",
719
+ arabicTex: "\\,",
720
+ arabicLabel: "",
721
+ title: "\u0641\u0631\u0627\u063A \u0631\u0641\u064A\u0639",
722
+ spacing: { direction: "positive", level: 1 }
723
+ },
715
724
  mediumSpace: {
716
725
  id: "mediumSpace",
717
726
  category: "spacing",
@@ -1732,6 +1741,10 @@ function renderNodeEnglish(node, options) {
1732
1741
  }
1733
1742
  if (node.kind === "char") {
1734
1743
  if (node.sourceLatex) {
1744
+ if (node.wrapperCommand === "\\boldarabic" || node.wrapperCommand === "\\mathbf") {
1745
+ const boldSource = node.sourceLatex.startsWith("\\mathbf{") ? node.sourceLatex : `\\mathbf{${node.sourceLatex}}`;
1746
+ return `${boldSource}${latinScripts(node, options)}`;
1747
+ }
1735
1748
  return `${node.sourceLatex}${latinScripts(node, options)}`;
1736
1749
  }
1737
1750
  if (node.wrapperCommand) {
@@ -2673,6 +2686,7 @@ var ENGLISH_COMMAND_TITLES = {
2673
2686
  C: "Complex numbers",
2674
2687
  H: "Quaternions",
2675
2688
  negThinSpace: "Negative thin space",
2689
+ thinSpace: "Thin space",
2676
2690
  mediumSpace: "Medium space",
2677
2691
  thickSpace: "Thick space",
2678
2692
  quadSpace: "Large space",
@@ -8735,7 +8749,7 @@ function fromArabicJson(json) {
8735
8749
  return parseNode(json, "arabic");
8736
8750
  }
8737
8751
 
8738
- // src/document/mathObject.ts
8752
+ // src/shared/math-document/mathObject.ts
8739
8753
  function isObject(value) {
8740
8754
  return typeof value === "object" && value !== null;
8741
8755
  }
@@ -8832,7 +8846,7 @@ function toMathObjectJson(math) {
8832
8846
  };
8833
8847
  }
8834
8848
 
8835
- // src/document/normalizeCharImport.ts
8849
+ // src/shared/math-document/normalizeCharImport.ts
8836
8850
  var WRAPPER_SPECS = [
8837
8851
  ...NON_DEFAULT_CHARACTER_FONT_SPECS.flatMap((font) => [
8838
8852
  { prefix: font.macro, font: font.id },
@@ -8896,7 +8910,7 @@ function normalizeCharImportExpr(expr) {
8896
8910
  return { expr: current, characterFont };
8897
8911
  }
8898
8912
 
8899
- // src/document/mathEditorAdapter.ts
8913
+ // src/shared/math-document/mathEditorAdapter.ts
8900
8914
  var COMMAND_FONT_MAP = Object.fromEntries([
8901
8915
  ["\\text", "infer"],
8902
8916
  ...NON_DEFAULT_CHARACTER_FONT_SPECS.flatMap((font) => [
@@ -9094,20 +9108,27 @@ function editableWrapperCommand(node) {
9094
9108
  return null;
9095
9109
  }
9096
9110
  const child = singleCommandChar(node);
9097
- if (!child) {
9098
- return null;
9099
- }
9100
- const normalized = normalizeCharImportExpr(child.expr);
9101
- const editorNode = createEditorNode("char", normalized.expr);
9102
- if (normalized.characterFont !== "default") {
9103
- editorNode.characterFont = normalized.characterFont;
9111
+ let editorNode;
9112
+ if (child) {
9113
+ const normalized = normalizeCharImportExpr(child.expr);
9114
+ editorNode = createEditorNode("char", normalized.expr);
9115
+ if (normalized.characterFont !== "default") {
9116
+ editorNode.characterFont = normalized.characterFont;
9117
+ }
9118
+ } else {
9119
+ if (node.optionalArgs.length || node.mandatoryArgs.length !== 1) return null;
9120
+ const nodes = node.mandatoryArgs[0]?.chain;
9121
+ if (!nodes || nodes.length !== 1 || !(nodes[0] instanceof CommandNode)) return null;
9122
+ const nested = charFromTextLikeCommand(nodes[0]);
9123
+ if (!nested?.editable) return null;
9124
+ editorNode = nested.node;
9104
9125
  }
9105
9126
  editorNode.wrapperCommand = node.name === "\\mathtt" ? "\\mathtt" : node.name === "\\mathbf" ? "\\mathbf" : node.name === "\\boldarabic" ? "\\boldarabic" : "\\unit";
9106
9127
  const scripts = attachScripts(node, editorNode);
9107
9128
  if (scripts) {
9108
9129
  return scripts;
9109
9130
  }
9110
- if (!editorNode.sourceLatex && node.name === "\\mathsf") {
9131
+ if (!editorNode.sourceLatex && node.name === "\\mathsf" && child) {
9111
9132
  editorNode.sourceLatex = `\\mathsf{${child.expr}}`;
9112
9133
  }
9113
9134
  return { editable: true, node: editorNode };
@@ -10360,7 +10381,7 @@ function useDesktopPopoverPlacement(rootRef, active, onClose) {
10360
10381
  popover.style.position = "fixed";
10361
10382
  popover.style.inset = "auto";
10362
10383
  const rootRect = root.getBoundingClientRect();
10363
- const scrollBoundary = root.closest(".butex-document2-widget__equation-modal-body");
10384
+ const scrollBoundary = root.closest(".butex-document-widget__equation-modal-body");
10364
10385
  const scrollBoundaryRect = scrollBoundary?.getBoundingClientRect();
10365
10386
  const triggerRect = trigger.getBoundingClientRect();
10366
10387
  const boundaryLeft = Math.max(VIEWPORT_MARGIN, rootRect.left + VIEWPORT_MARGIN);