@drghaliasri/butex 7.1.0 → 7.1.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.
@@ -483,12 +483,12 @@ var DelimiterNode = class extends BaseAstNode {
483
483
  leftDelimExpr;
484
484
  innerExpr;
485
485
  rightDelimExpr;
486
- constructor(leftDelimExpr, innerExpr, rightDelimExpr, state = null) {
486
+ constructor(leftDelimExpr2, innerExpr, rightDelimExpr2, state = null) {
487
487
  super(state);
488
488
  this.nodeType = "DelimiterObject";
489
- this.leftDelimExpr = leftDelimExpr;
489
+ this.leftDelimExpr = leftDelimExpr2;
490
490
  this.innerExpr = innerExpr;
491
- this.rightDelimExpr = rightDelimExpr;
491
+ this.rightDelimExpr = rightDelimExpr2;
492
492
  }
493
493
  latex() {
494
494
  return this.leftDelimExpr + this.innerExpr.latex() + this.rightDelimExpr + this.latexScripts();
@@ -1976,6 +1976,14 @@ var ATOMIC_COMMANDS = {
1976
1976
  arabicLabel: "\u0646\u0640\u0640\u0640\u0640\u0640\u0647\u0627",
1977
1977
  title: "\u062D\u062F"
1978
1978
  },
1979
+ arg: {
1980
+ id: "arg",
1981
+ category: "limits_series",
1982
+ englishTex: "\\arg",
1983
+ arabicTex: "\\ararg",
1984
+ arabicLabel: "\u062D\u062C",
1985
+ title: "\u062D\u062C\u0629"
1986
+ },
1979
1987
  max: {
1980
1988
  id: "max",
1981
1989
  category: "limits_series",
@@ -2824,11 +2832,11 @@ function createEditorNode(kind, expr) {
2824
2832
  columnAlignments: null
2825
2833
  };
2826
2834
  }
2827
- function createDelimiterNode(leftDelimExpr, rightDelimExpr) {
2835
+ function createDelimiterNode(leftDelimExpr2, rightDelimExpr2) {
2828
2836
  return {
2829
2837
  ...createEditorNode("delimiter", ""),
2830
- leftDelimExpr,
2831
- rightDelimExpr,
2838
+ leftDelimExpr: leftDelimExpr2,
2839
+ rightDelimExpr: rightDelimExpr2,
2832
2840
  innerExpr: createEditorChain()
2833
2841
  };
2834
2842
  }
@@ -5255,11 +5263,11 @@ function insertAtomicOperatorCommand(session, commandId) {
5255
5263
  appendDebug(next, "insertAtomicOperatorCommand", commandId);
5256
5264
  return next;
5257
5265
  }
5258
- function insertDelimiterPair(session, leftDelimExpr, rightDelimExpr) {
5266
+ function insertDelimiterPair(session, leftDelimExpr2, rightDelimExpr2) {
5259
5267
  const base = replaceSelectionFirst(session);
5260
5268
  const next = cloneEditorSession(base);
5261
- const englishNode = createDelimiterNode(leftDelimExpr, rightDelimExpr);
5262
- const arabicNode = createDelimiterNode(leftDelimExpr, rightDelimExpr);
5269
+ const englishNode = createDelimiterNode(leftDelimExpr2, rightDelimExpr2);
5270
+ const arabicNode = createDelimiterNode(leftDelimExpr2, rightDelimExpr2);
5263
5271
  arabicNode.id = englishNode.id;
5264
5272
  if (arabicNode.innerExpr && englishNode.innerExpr) {
5265
5273
  arabicNode.innerExpr.id = englishNode.innerExpr.id;
@@ -5271,7 +5279,7 @@ function insertDelimiterPair(session, leftDelimExpr, rightDelimExpr) {
5271
5279
  };
5272
5280
  next.selectedStructureNodeId = null;
5273
5281
  syncSelectionToCaret(next);
5274
- appendDebug(next, "insertDelimiterPair", `${leftDelimExpr}${rightDelimExpr}`);
5282
+ appendDebug(next, "insertDelimiterPair", `${leftDelimExpr2}${rightDelimExpr2}`);
5275
5283
  return next;
5276
5284
  }
5277
5285
  function insertFraction(session) {
@@ -5955,6 +5963,22 @@ var DELIMITER_CSS = `
5955
5963
  transform-origin: center;
5956
5964
  }
5957
5965
  `.trim();
5966
+ function escapeDelimiterExpr(value) {
5967
+ return value.replace(/[.*+?^$()|[\]\\]/g, "\\$&");
5968
+ }
5969
+ function buildDelimiterExpr(prefixes, delimiters) {
5970
+ const prefixExpr = prefixes.map(escapeDelimiterExpr).join("|");
5971
+ const delimiterExpr = delimiters.map(escapeDelimiterExpr).join("|");
5972
+ return new RegExp(`^(?:(?:${prefixExpr}))?(?:${delimiterExpr})$`);
5973
+ }
5974
+ var leftDelimExpr = buildDelimiterExpr(
5975
+ ["\\left", "\\bigl", "\\Bigl", "\\biggl", "\\Biggl"],
5976
+ ["(", "[", "\\{", "\\lfloor", "\\lceil", "\\langle", "`", "|", "\\lvert", "\\vert", "\\lVert", "\\Vert"]
5977
+ );
5978
+ var rightDelimExpr = buildDelimiterExpr(
5979
+ ["\\right", "\\bigr", "\\Bigr", "\\biggr", "\\Biggr"],
5980
+ [")", "]", "\\}", "\\rfloor", "\\rceil", "\\rangle", "`", "|", "\\rvert", "\\vert", "\\rVert", "\\Vert"]
5981
+ );
5958
5982
  var DELIMITER_BASE_HEIGHT_PX = 18;
5959
5983
  var DELIMITER_MAX_SCALE = 4.8;
5960
5984
  function clamp(value, min, max) {
@@ -5966,7 +5990,7 @@ function applyDelimiterScale(pair, inner) {
5966
5990
  pair.style.setProperty("--butex-delim-scale", scale.toFixed(3));
5967
5991
  }
5968
5992
  function visibleDelimiter(expr) {
5969
- return expr.replace("\\left", "").replace("\\right", "").replace("\\{", "{").replace("\\}", "}");
5993
+ return expr.replace(/\\\\(?:left|right|bigl|Bigl|biggl|Biggl|bigr|Bigr|biggr|Biggr)/, "").replace("\\{", "{").replace("\\}", "}").replace(/\\\\(?:lvert|rvert|vert)/, "|").replace(/\\\\(?:lVert|rVert|Vert)/, "\u2016");
5970
5994
  }
5971
5995
  function buildDelimiterNodeBody(node, buildChain) {
5972
5996
  const pair = document.createElement("span");
@@ -7796,8 +7820,12 @@ function createEditorRuntime(options) {
7796
7820
  applyStructural((prev) => insertDelimiterPair(prev, "\\left(", "\\right)"));
7797
7821
  } else if (kind === "bracket") {
7798
7822
  applyStructural((prev) => insertDelimiterPair(prev, "\\left[", "\\right]"));
7799
- } else {
7823
+ } else if (kind === "brace") {
7800
7824
  applyStructural((prev) => insertDelimiterPair(prev, "\\left\\{", "\\right\\}"));
7825
+ } else if (kind === "vert") {
7826
+ applyStructural((prev) => insertDelimiterPair(prev, "\\left\\lvert", "\\right\\rvert"));
7827
+ } else {
7828
+ applyStructural((prev) => insertDelimiterPair(prev, "\\left\\lVert", "\\right\\rVert"));
7801
7829
  }
7802
7830
  focusInput();
7803
7831
  },
@@ -9735,6 +9763,7 @@ ${fontCommands}
9735
9763
  \newcommand{\arprod}[0]{\text{جـــذ}}
9736
9764
 
9737
9765
  \newcommand{\arlim}[0]{\text{نـــــها}}
9766
+ \newcommand{\ararg}[0]{\text{حج}}
9738
9767
  \newcommand{\armax}[0]{\text{أكبر}}
9739
9768
  \newcommand{\armin}[0]{\text{أصغر}}
9740
9769
  \newcommand{\arsup}[0]{\text{أعلى}}
@@ -15691,7 +15720,9 @@ function EquationMobileToolbar({
15691
15720
  sheetView === "delimiters" ? /* @__PURE__ */ jsx13("div", { className: "butex-widget__sheet-command-grid butex-widget__sheet-command-grid--three", children: [
15692
15721
  { kind: "paren", label: "()", title: messages.insertParentheses },
15693
15722
  { kind: "bracket", label: "[]", title: messages.insertBrackets },
15694
- { kind: "brace", label: "{}", title: messages.insertBraces }
15723
+ { kind: "brace", label: "{}", title: messages.insertBraces },
15724
+ { kind: "vert", label: "| |", title: "| |" },
15725
+ { kind: "Vert", label: "\u2016 \u2016", title: "\u2016 \u2016" }
15695
15726
  ].map((option) => /* @__PURE__ */ jsx13("button", { type: "button", "aria-label": option.title, title: option.title, onClick: () => runAndClose((runtime) => runtime.insertDelimiterByKind(option.kind)), children: option.label }, option.kind)) }) : null,
15696
15727
  sheetView === "structures" ? /* @__PURE__ */ jsxs12(Fragment5, { children: [
15697
15728
  /* @__PURE__ */ jsxs12("div", { className: "butex-widget__sheet-command-grid", children: [
@@ -16664,6 +16695,42 @@ ${arabic || currentMessages.empty}`;
16664
16695
  },
16665
16696
  children: "{}"
16666
16697
  }
16698
+ ),
16699
+ /* @__PURE__ */ jsx14(
16700
+ "button",
16701
+ {
16702
+ className: "delimiter-command-option",
16703
+ "data-delim": "vert",
16704
+ type: "button",
16705
+ role: "menuitem",
16706
+ title: "| |",
16707
+ "aria-label": "| |",
16708
+ onMouseDown: (event) => event.preventDefault(),
16709
+ onClick: () => {
16710
+ runtimeRef.current?.insertDelimiterByKind("vert");
16711
+ setDelimiterMenuOpen(false);
16712
+ focusSurface();
16713
+ },
16714
+ children: "| |"
16715
+ }
16716
+ ),
16717
+ /* @__PURE__ */ jsx14(
16718
+ "button",
16719
+ {
16720
+ className: "delimiter-command-option",
16721
+ "data-delim": "Vert",
16722
+ type: "button",
16723
+ role: "menuitem",
16724
+ title: "\u2016 \u2016",
16725
+ "aria-label": "\u2016 \u2016",
16726
+ onMouseDown: (event) => event.preventDefault(),
16727
+ onClick: () => {
16728
+ runtimeRef.current?.insertDelimiterByKind("Vert");
16729
+ setDelimiterMenuOpen(false);
16730
+ focusSurface();
16731
+ },
16732
+ children: "\u2016 \u2016"
16733
+ }
16667
16734
  )
16668
16735
  ] })
16669
16736
  ]