@drghaliasri/butex 7.1.4 → 7.2.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 (43) hide show
  1. package/dist/document.d.mts +1 -2
  2. package/dist/document.d.ts +1 -2
  3. package/dist/document.js +56 -0
  4. package/dist/document.js.map +1 -1
  5. package/dist/document.mjs +56 -0
  6. package/dist/document.mjs.map +1 -1
  7. package/dist/document2-cli.js +298 -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 +67 -0
  12. package/dist/document2.js.map +1 -1
  13. package/dist/document2.mjs +67 -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 +99 -0
  18. package/dist/index.global.js.map +1 -1
  19. package/dist/index.js +99 -0
  20. package/dist/index.js.map +1 -1
  21. package/dist/index.mjs +99 -0
  22. package/dist/index.mjs.map +1 -1
  23. package/dist/react-document.js +78 -0
  24. package/dist/react-document.js.map +1 -1
  25. package/dist/react-document.mjs +78 -0
  26. package/dist/react-document.mjs.map +1 -1
  27. package/dist/react-document2-preview.js +62 -0
  28. package/dist/react-document2-preview.js.map +1 -1
  29. package/dist/react-document2-preview.mjs +62 -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 +119 -0
  34. package/dist/react-document2.js.map +1 -1
  35. package/dist/react-document2.mjs +119 -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 +78 -0
  40. package/dist/react.js.map +1 -1
  41. package/dist/react.mjs +78 -0
  42. package/dist/react.mjs.map +1 -1
  43. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -820,6 +820,7 @@ var CHARACTER_FONT_SPECS = [
820
820
  latexFontCommand: "\\maghribi",
821
821
  latexFontFamily: "Almaghribi Warsh Quran",
822
822
  browserFontStack: '"Almaghribi Warsh Quran", Amiri, "Segoe UI", Tahoma, sans-serif',
823
+ importAliases: ["\\maghribi"],
823
824
  svgLayoutKey: "maghribi"
824
825
  }
825
826
  ];
@@ -2817,6 +2818,88 @@ function buildAtomicOperatorCommandNodeBody(node, side, uiLocale = "ar") {
2817
2818
  return value;
2818
2819
  }
2819
2820
 
2821
+ // src/editor/standardCommands.ts
2822
+ var STANDARD_COMMANDS = {
2823
+ "\\alpha": { tex: "\\alpha", label: "\u03B1", title: "alpha" },
2824
+ "\\beta": { tex: "\\beta", label: "\u03B2", title: "beta" },
2825
+ "\\gamma": { tex: "\\gamma", label: "\u03B3", title: "gamma" },
2826
+ "\\delta": { tex: "\\delta", label: "\u03B4", title: "delta" },
2827
+ "\\epsilon": { tex: "\\epsilon", label: "\u03B5", title: "epsilon" },
2828
+ "\\eta": { tex: "\\eta", label: "\u03B7", title: "eta" },
2829
+ "\\theta": { tex: "\\theta", label: "\u03B8", title: "theta" },
2830
+ "\\lambda": { tex: "\\lambda", label: "\u03BB", title: "lambda" },
2831
+ "\\mu": { tex: "\\mu", label: "\u03BC", title: "mu" },
2832
+ "\\rho": { tex: "\\rho", label: "\u03C1", title: "rho" },
2833
+ "\\sigma": { tex: "\\sigma", label: "\u03C3", title: "sigma" },
2834
+ "\\tau": { tex: "\\tau", label: "\u03C4", title: "tau" },
2835
+ "\\phi": { tex: "\\phi", label: "\u03C6", title: "phi" },
2836
+ "\\chi": { tex: "\\chi", label: "\u03C7", title: "chi" },
2837
+ "\\psi": { tex: "\\psi", label: "\u03C8", title: "psi" },
2838
+ "\\omega": { tex: "\\omega", label: "\u03C9", title: "omega" },
2839
+ "\\zeta": { tex: "\\zeta", label: "\u03B6", title: "zeta" },
2840
+ "\\nabla": { tex: "\\nabla", label: "\u2207", title: "nabla" },
2841
+ "\\Delta": { tex: "\\Delta", label: "\u0394", title: "Delta" },
2842
+ "\\partial": { tex: "\\partial", label: "\u2202", title: "partial derivative" },
2843
+ "\\Longleftrightarrow": { tex: "\\Longleftrightarrow", label: "\u27FA", title: "long equivalence arrow" },
2844
+ "\\backslash": { tex: "\\backslash", label: "\u2216", title: "reverse solidus" }
2845
+ };
2846
+ function standardCommandSpec(tex) {
2847
+ return Object.prototype.hasOwnProperty.call(STANDARD_COMMANDS, tex) ? STANDARD_COMMANDS[tex] : null;
2848
+ }
2849
+ function isStandardCommandTex(tex) {
2850
+ return standardCommandSpec(tex) !== null;
2851
+ }
2852
+ function chainHasStandardCommands(chain) {
2853
+ for (const node of chain.nodes) {
2854
+ if (node.kind === "standardCommand") {
2855
+ return true;
2856
+ }
2857
+ const childChains = [
2858
+ node.superscript,
2859
+ node.subscript,
2860
+ node.innerExpr,
2861
+ node.numerator,
2862
+ node.denominator,
2863
+ node.radicand,
2864
+ node.rootIndex,
2865
+ node.overExpr,
2866
+ node.underExpr,
2867
+ node.baseExpr
2868
+ ];
2869
+ if (childChains.some((child) => child && chainHasStandardCommands(child))) {
2870
+ return true;
2871
+ }
2872
+ if (node.matrixRows?.some((row) => row.some(chainHasStandardCommands))) {
2873
+ return true;
2874
+ }
2875
+ }
2876
+ return false;
2877
+ }
2878
+ function sessionHasStandardCommands(session) {
2879
+ return chainHasStandardCommands(session.englishTree) || chainHasStandardCommands(session.arabicTree);
2880
+ }
2881
+
2882
+ // src/editor/display/standardCommand.ts
2883
+ var STANDARD_COMMAND_CSS = `
2884
+ .standard-command {
2885
+ display: inline-flex;
2886
+ align-items: center;
2887
+ justify-content: center;
2888
+ min-width: 0.9em;
2889
+ font-family: "Cambria Math", "Times New Roman", serif;
2890
+ font-size: 1.05em;
2891
+ line-height: 1;
2892
+ }
2893
+ `.trim();
2894
+ function buildStandardCommandNodeBody(node) {
2895
+ const spec = standardCommandSpec(node.expr);
2896
+ const value = document.createElement("span");
2897
+ value.className = "standard-command";
2898
+ value.title = spec?.title ?? node.expr;
2899
+ value.textContent = spec?.label ?? node.expr;
2900
+ return value;
2901
+ }
2902
+
2820
2903
  // src/editor/styles.ts
2821
2904
  var CHARACTER_FONT_CSS = NON_DEFAULT_CHARACTER_FONT_SPECS.filter((font) => font.cssClass && font.browserFontStack).map((font) => `.${font.cssClass} {
2822
2905
  font-family: ${font.browserFontStack};
@@ -3026,6 +3109,8 @@ ${MATRIX_ENV_CSS}
3026
3109
  ${ATOMIC_COMMAND_CSS}
3027
3110
 
3028
3111
  ${ATOMIC_OPERATOR_COMMAND_CSS}
3112
+
3113
+ ${STANDARD_COMMAND_CSS}
3029
3114
  `.trim();
3030
3115
  function injectBuTeXEditorStyles(doc) {
3031
3116
  const d = doc ?? (typeof document !== "undefined" ? document : void 0);
@@ -3064,6 +3149,8 @@ __export(editor_exports, {
3064
3149
  NON_DEFAULT_CHARACTER_FONT_SPECS: () => NON_DEFAULT_CHARACTER_FONT_SPECS,
3065
3150
  OVERSET_CSS: () => OVERSET_CSS,
3066
3151
  SQRT_CSS: () => SQRT_CSS,
3152
+ STANDARD_COMMANDS: () => STANDARD_COMMANDS,
3153
+ STANDARD_COMMAND_CSS: () => STANDARD_COMMAND_CSS,
3067
3154
  UNDERSET_CSS: () => UNDERSET_CSS,
3068
3155
  accentCommandIdFromTex: () => accentCommandIdFromTex,
3069
3156
  accentCommandSpec: () => accentCommandSpec,
@@ -3139,6 +3226,7 @@ __export(editor_exports, {
3139
3226
  insertUnderset: () => insertUnderset,
3140
3227
  isSelectionActive: () => isSelectionActive,
3141
3228
  isSpacingCommandSpec: () => isSpacingCommandSpec,
3229
+ isStandardCommandTex: () => isStandardCommandTex,
3142
3230
  mirrorBuTeXOperatorsInTex: () => mirrorBuTeXOperatorsInTex,
3143
3231
  moveCaret: () => moveCaret,
3144
3232
  moveCaretHorizontal: () => moveCaretHorizontal,
@@ -3163,6 +3251,7 @@ __export(editor_exports, {
3163
3251
  runtimeStatusText: () => runtimeStatusText,
3164
3252
  selectNode: () => selectNode,
3165
3253
  serializeSelection: () => serializeSelection,
3254
+ sessionHasStandardCommands: () => sessionHasStandardCommands,
3166
3255
  setArabicReverseNumberTyping: () => setArabicReverseNumberTyping,
3167
3256
  setArrayColumnAlignment: () => setArrayColumnAlignment,
3168
3257
  setCaret: () => setCaret,
@@ -3174,6 +3263,7 @@ __export(editor_exports, {
3174
3263
  setSelectionFromMouse: () => setSelectionFromMouse,
3175
3264
  setSplitLeafTyping: () => setSplitLeafTyping,
3176
3265
  shouldMirrorOperatorDisplay: () => shouldMirrorOperatorDisplay,
3266
+ standardCommandSpec: () => standardCommandSpec,
3177
3267
  switchSide: () => switchSide,
3178
3268
  syncSelectionToCaret: () => syncSelectionToCaret,
3179
3269
  syncStateSummary: () => syncStateSummary,
@@ -3565,6 +3655,9 @@ function renderNodeEnglish(node, options) {
3565
3655
  const body = atomicOperatorCommandSpec(node.expr)?.Tex ?? node.expr;
3566
3656
  return `${body}${latinScripts(node, options)}`;
3567
3657
  }
3658
+ if (node.kind === "standardCommand") {
3659
+ return `${node.expr}${latinScripts(node, options)}`;
3660
+ }
3568
3661
  if (node.kind === "char") {
3569
3662
  return `${renderCharContent(node, options)}${latinScripts(node, options)}`;
3570
3663
  }
@@ -3613,6 +3706,9 @@ function renderNodeArabic(node, options) {
3613
3706
  const content = spec?.mirror ? `\\butexmirror{${tex}}` : tex;
3614
3707
  return arabicScripts(node, content, options);
3615
3708
  }
3709
+ if (node.kind === "standardCommand") {
3710
+ return arabicScripts(node, node.expr, options);
3711
+ }
3616
3712
  if (node.kind === "char") {
3617
3713
  const expr = formatDigits(node.expr, selectedDigitForm(options));
3618
3714
  const content = renderCharContent(node, options);
@@ -5985,6 +6081,9 @@ function buildNodeBody(node, buildChain, side, digitForm = "western", uiLocale =
5985
6081
  if (node.kind === "atomicOperatorCommand") {
5986
6082
  return buildAtomicOperatorCommandNodeBody(node, side, uiLocale);
5987
6083
  }
6084
+ if (node.kind === "standardCommand") {
6085
+ return buildStandardCommandNodeBody(node);
6086
+ }
5988
6087
  return buildBaseNodeBody(node, digitForm, side);
5989
6088
  }
5990
6089