@drghaliasri/butex 7.1.4 → 7.2.0

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 -2
  2. package/dist/document.d.ts +1 -2
  3. package/dist/document.js +55 -0
  4. package/dist/document.js.map +1 -1
  5. package/dist/document.mjs +55 -0
  6. package/dist/document.mjs.map +1 -1
  7. package/dist/document2-cli.js +297 -4
  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 +66 -0
  12. package/dist/document2.js.map +1 -1
  13. package/dist/document2.mjs +66 -0
  14. package/dist/document2.mjs.map +1 -1
  15. package/dist/index.d.mts +129 -2
  16. package/dist/index.d.ts +129 -2
  17. package/dist/index.global.js +98 -0
  18. package/dist/index.global.js.map +1 -1
  19. package/dist/index.js +98 -0
  20. package/dist/index.js.map +1 -1
  21. package/dist/index.mjs +98 -0
  22. package/dist/index.mjs.map +1 -1
  23. package/dist/react-document.js +77 -0
  24. package/dist/react-document.js.map +1 -1
  25. package/dist/react-document.mjs +77 -0
  26. package/dist/react-document.mjs.map +1 -1
  27. package/dist/react-document2-preview.js +61 -0
  28. package/dist/react-document2-preview.js.map +1 -1
  29. package/dist/react-document2-preview.mjs +61 -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 +118 -0
  34. package/dist/react-document2.js.map +1 -1
  35. package/dist/react-document2.mjs +118 -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 +77 -0
  40. package/dist/react.js.map +1 -1
  41. package/dist/react.mjs +77 -0
  42. package/dist/react.mjs.map +1 -1
  43. package/package.json +1 -1
package/dist/index.mjs CHANGED
@@ -2775,6 +2775,88 @@ function buildAtomicOperatorCommandNodeBody(node, side, uiLocale = "ar") {
2775
2775
  return value;
2776
2776
  }
2777
2777
 
2778
+ // src/editor/standardCommands.ts
2779
+ var STANDARD_COMMANDS = {
2780
+ "\\alpha": { tex: "\\alpha", label: "\u03B1", title: "alpha" },
2781
+ "\\beta": { tex: "\\beta", label: "\u03B2", title: "beta" },
2782
+ "\\gamma": { tex: "\\gamma", label: "\u03B3", title: "gamma" },
2783
+ "\\delta": { tex: "\\delta", label: "\u03B4", title: "delta" },
2784
+ "\\epsilon": { tex: "\\epsilon", label: "\u03B5", title: "epsilon" },
2785
+ "\\eta": { tex: "\\eta", label: "\u03B7", title: "eta" },
2786
+ "\\theta": { tex: "\\theta", label: "\u03B8", title: "theta" },
2787
+ "\\lambda": { tex: "\\lambda", label: "\u03BB", title: "lambda" },
2788
+ "\\mu": { tex: "\\mu", label: "\u03BC", title: "mu" },
2789
+ "\\rho": { tex: "\\rho", label: "\u03C1", title: "rho" },
2790
+ "\\sigma": { tex: "\\sigma", label: "\u03C3", title: "sigma" },
2791
+ "\\tau": { tex: "\\tau", label: "\u03C4", title: "tau" },
2792
+ "\\phi": { tex: "\\phi", label: "\u03C6", title: "phi" },
2793
+ "\\chi": { tex: "\\chi", label: "\u03C7", title: "chi" },
2794
+ "\\psi": { tex: "\\psi", label: "\u03C8", title: "psi" },
2795
+ "\\omega": { tex: "\\omega", label: "\u03C9", title: "omega" },
2796
+ "\\zeta": { tex: "\\zeta", label: "\u03B6", title: "zeta" },
2797
+ "\\nabla": { tex: "\\nabla", label: "\u2207", title: "nabla" },
2798
+ "\\Delta": { tex: "\\Delta", label: "\u0394", title: "Delta" },
2799
+ "\\partial": { tex: "\\partial", label: "\u2202", title: "partial derivative" },
2800
+ "\\Longleftrightarrow": { tex: "\\Longleftrightarrow", label: "\u27FA", title: "long equivalence arrow" },
2801
+ "\\backslash": { tex: "\\backslash", label: "\u2216", title: "reverse solidus" }
2802
+ };
2803
+ function standardCommandSpec(tex) {
2804
+ return Object.prototype.hasOwnProperty.call(STANDARD_COMMANDS, tex) ? STANDARD_COMMANDS[tex] : null;
2805
+ }
2806
+ function isStandardCommandTex(tex) {
2807
+ return standardCommandSpec(tex) !== null;
2808
+ }
2809
+ function chainHasStandardCommands(chain) {
2810
+ for (const node of chain.nodes) {
2811
+ if (node.kind === "standardCommand") {
2812
+ return true;
2813
+ }
2814
+ const childChains = [
2815
+ node.superscript,
2816
+ node.subscript,
2817
+ node.innerExpr,
2818
+ node.numerator,
2819
+ node.denominator,
2820
+ node.radicand,
2821
+ node.rootIndex,
2822
+ node.overExpr,
2823
+ node.underExpr,
2824
+ node.baseExpr
2825
+ ];
2826
+ if (childChains.some((child) => child && chainHasStandardCommands(child))) {
2827
+ return true;
2828
+ }
2829
+ if (node.matrixRows?.some((row) => row.some(chainHasStandardCommands))) {
2830
+ return true;
2831
+ }
2832
+ }
2833
+ return false;
2834
+ }
2835
+ function sessionHasStandardCommands(session) {
2836
+ return chainHasStandardCommands(session.englishTree) || chainHasStandardCommands(session.arabicTree);
2837
+ }
2838
+
2839
+ // src/editor/display/standardCommand.ts
2840
+ var STANDARD_COMMAND_CSS = `
2841
+ .standard-command {
2842
+ display: inline-flex;
2843
+ align-items: center;
2844
+ justify-content: center;
2845
+ min-width: 0.9em;
2846
+ font-family: "Cambria Math", "Times New Roman", serif;
2847
+ font-size: 1.05em;
2848
+ line-height: 1;
2849
+ }
2850
+ `.trim();
2851
+ function buildStandardCommandNodeBody(node) {
2852
+ const spec = standardCommandSpec(node.expr);
2853
+ const value = document.createElement("span");
2854
+ value.className = "standard-command";
2855
+ value.title = spec?.title ?? node.expr;
2856
+ value.textContent = spec?.label ?? node.expr;
2857
+ return value;
2858
+ }
2859
+
2778
2860
  // src/editor/styles.ts
2779
2861
  var CHARACTER_FONT_CSS = NON_DEFAULT_CHARACTER_FONT_SPECS.filter((font) => font.cssClass && font.browserFontStack).map((font) => `.${font.cssClass} {
2780
2862
  font-family: ${font.browserFontStack};
@@ -2984,6 +3066,8 @@ ${MATRIX_ENV_CSS}
2984
3066
  ${ATOMIC_COMMAND_CSS}
2985
3067
 
2986
3068
  ${ATOMIC_OPERATOR_COMMAND_CSS}
3069
+
3070
+ ${STANDARD_COMMAND_CSS}
2987
3071
  `.trim();
2988
3072
  function injectBuTeXEditorStyles(doc) {
2989
3073
  const d = doc ?? (typeof document !== "undefined" ? document : void 0);
@@ -3022,6 +3106,8 @@ __export(editor_exports, {
3022
3106
  NON_DEFAULT_CHARACTER_FONT_SPECS: () => NON_DEFAULT_CHARACTER_FONT_SPECS,
3023
3107
  OVERSET_CSS: () => OVERSET_CSS,
3024
3108
  SQRT_CSS: () => SQRT_CSS,
3109
+ STANDARD_COMMANDS: () => STANDARD_COMMANDS,
3110
+ STANDARD_COMMAND_CSS: () => STANDARD_COMMAND_CSS,
3025
3111
  UNDERSET_CSS: () => UNDERSET_CSS,
3026
3112
  accentCommandIdFromTex: () => accentCommandIdFromTex,
3027
3113
  accentCommandSpec: () => accentCommandSpec,
@@ -3097,6 +3183,7 @@ __export(editor_exports, {
3097
3183
  insertUnderset: () => insertUnderset,
3098
3184
  isSelectionActive: () => isSelectionActive,
3099
3185
  isSpacingCommandSpec: () => isSpacingCommandSpec,
3186
+ isStandardCommandTex: () => isStandardCommandTex,
3100
3187
  mirrorBuTeXOperatorsInTex: () => mirrorBuTeXOperatorsInTex,
3101
3188
  moveCaret: () => moveCaret,
3102
3189
  moveCaretHorizontal: () => moveCaretHorizontal,
@@ -3121,6 +3208,7 @@ __export(editor_exports, {
3121
3208
  runtimeStatusText: () => runtimeStatusText,
3122
3209
  selectNode: () => selectNode,
3123
3210
  serializeSelection: () => serializeSelection,
3211
+ sessionHasStandardCommands: () => sessionHasStandardCommands,
3124
3212
  setArabicReverseNumberTyping: () => setArabicReverseNumberTyping,
3125
3213
  setArrayColumnAlignment: () => setArrayColumnAlignment,
3126
3214
  setCaret: () => setCaret,
@@ -3132,6 +3220,7 @@ __export(editor_exports, {
3132
3220
  setSelectionFromMouse: () => setSelectionFromMouse,
3133
3221
  setSplitLeafTyping: () => setSplitLeafTyping,
3134
3222
  shouldMirrorOperatorDisplay: () => shouldMirrorOperatorDisplay,
3223
+ standardCommandSpec: () => standardCommandSpec,
3135
3224
  switchSide: () => switchSide,
3136
3225
  syncSelectionToCaret: () => syncSelectionToCaret,
3137
3226
  syncStateSummary: () => syncStateSummary,
@@ -3523,6 +3612,9 @@ function renderNodeEnglish(node, options) {
3523
3612
  const body = atomicOperatorCommandSpec(node.expr)?.Tex ?? node.expr;
3524
3613
  return `${body}${latinScripts(node, options)}`;
3525
3614
  }
3615
+ if (node.kind === "standardCommand") {
3616
+ return `${node.expr}${latinScripts(node, options)}`;
3617
+ }
3526
3618
  if (node.kind === "char") {
3527
3619
  return `${renderCharContent(node, options)}${latinScripts(node, options)}`;
3528
3620
  }
@@ -3571,6 +3663,9 @@ function renderNodeArabic(node, options) {
3571
3663
  const content = spec?.mirror ? `\\butexmirror{${tex}}` : tex;
3572
3664
  return arabicScripts(node, content, options);
3573
3665
  }
3666
+ if (node.kind === "standardCommand") {
3667
+ return arabicScripts(node, node.expr, options);
3668
+ }
3574
3669
  if (node.kind === "char") {
3575
3670
  const expr = formatDigits(node.expr, selectedDigitForm(options));
3576
3671
  const content = renderCharContent(node, options);
@@ -5943,6 +6038,9 @@ function buildNodeBody(node, buildChain, side, digitForm = "western", uiLocale =
5943
6038
  if (node.kind === "atomicOperatorCommand") {
5944
6039
  return buildAtomicOperatorCommandNodeBody(node, side, uiLocale);
5945
6040
  }
6041
+ if (node.kind === "standardCommand") {
6042
+ return buildStandardCommandNodeBody(node);
6043
+ }
5946
6044
  return buildBaseNodeBody(node, digitForm, side);
5947
6045
  }
5948
6046