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