@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.
@@ -127,12 +127,12 @@ var DelimiterNode = class extends BaseAstNode {
127
127
  leftDelimExpr;
128
128
  innerExpr;
129
129
  rightDelimExpr;
130
- constructor(leftDelimExpr, innerExpr, rightDelimExpr, state = null) {
130
+ constructor(leftDelimExpr2, innerExpr, rightDelimExpr2, state = null) {
131
131
  super(state);
132
132
  this.nodeType = "DelimiterObject";
133
- this.leftDelimExpr = leftDelimExpr;
133
+ this.leftDelimExpr = leftDelimExpr2;
134
134
  this.innerExpr = innerExpr;
135
- this.rightDelimExpr = rightDelimExpr;
135
+ this.rightDelimExpr = rightDelimExpr2;
136
136
  }
137
137
  latex() {
138
138
  return this.leftDelimExpr + this.innerExpr.latex() + this.rightDelimExpr + this.latexScripts();
@@ -1055,6 +1055,14 @@ var ATOMIC_COMMANDS = {
1055
1055
  arabicLabel: "\u0646\u0640\u0640\u0640\u0640\u0640\u0647\u0627",
1056
1056
  title: "\u062D\u062F"
1057
1057
  },
1058
+ arg: {
1059
+ id: "arg",
1060
+ category: "limits_series",
1061
+ englishTex: "\\arg",
1062
+ arabicTex: "\\ararg",
1063
+ arabicLabel: "\u062D\u062C",
1064
+ title: "\u062D\u062C\u0629"
1065
+ },
1058
1066
  max: {
1059
1067
  id: "max",
1060
1068
  category: "limits_series",
@@ -1903,11 +1911,11 @@ function createEditorNode(kind, expr) {
1903
1911
  columnAlignments: null
1904
1912
  };
1905
1913
  }
1906
- function createDelimiterNode(leftDelimExpr, rightDelimExpr) {
1914
+ function createDelimiterNode(leftDelimExpr2, rightDelimExpr2) {
1907
1915
  return {
1908
1916
  ...createEditorNode("delimiter", ""),
1909
- leftDelimExpr,
1910
- rightDelimExpr,
1917
+ leftDelimExpr: leftDelimExpr2,
1918
+ rightDelimExpr: rightDelimExpr2,
1911
1919
  innerExpr: createEditorChain()
1912
1920
  };
1913
1921
  }
@@ -4362,11 +4370,11 @@ function insertAtomicOperatorCommand(session, commandId) {
4362
4370
  appendDebug(next, "insertAtomicOperatorCommand", commandId);
4363
4371
  return next;
4364
4372
  }
4365
- function insertDelimiterPair(session, leftDelimExpr, rightDelimExpr) {
4373
+ function insertDelimiterPair(session, leftDelimExpr2, rightDelimExpr2) {
4366
4374
  const base = replaceSelectionFirst(session);
4367
4375
  const next = cloneEditorSession(base);
4368
- const englishNode = createDelimiterNode(leftDelimExpr, rightDelimExpr);
4369
- const arabicNode = createDelimiterNode(leftDelimExpr, rightDelimExpr);
4376
+ const englishNode = createDelimiterNode(leftDelimExpr2, rightDelimExpr2);
4377
+ const arabicNode = createDelimiterNode(leftDelimExpr2, rightDelimExpr2);
4370
4378
  arabicNode.id = englishNode.id;
4371
4379
  if (arabicNode.innerExpr && englishNode.innerExpr) {
4372
4380
  arabicNode.innerExpr.id = englishNode.innerExpr.id;
@@ -4378,7 +4386,7 @@ function insertDelimiterPair(session, leftDelimExpr, rightDelimExpr) {
4378
4386
  };
4379
4387
  next.selectedStructureNodeId = null;
4380
4388
  syncSelectionToCaret(next);
4381
- appendDebug(next, "insertDelimiterPair", `${leftDelimExpr}${rightDelimExpr}`);
4389
+ appendDebug(next, "insertDelimiterPair", `${leftDelimExpr2}${rightDelimExpr2}`);
4382
4390
  return next;
4383
4391
  }
4384
4392
  function insertFraction(session) {
@@ -5062,6 +5070,22 @@ var DELIMITER_CSS = `
5062
5070
  transform-origin: center;
5063
5071
  }
5064
5072
  `.trim();
5073
+ function escapeDelimiterExpr(value) {
5074
+ return value.replace(/[.*+?^$()|[\]\\]/g, "\\$&");
5075
+ }
5076
+ function buildDelimiterExpr(prefixes, delimiters) {
5077
+ const prefixExpr = prefixes.map(escapeDelimiterExpr).join("|");
5078
+ const delimiterExpr = delimiters.map(escapeDelimiterExpr).join("|");
5079
+ return new RegExp(`^(?:(?:${prefixExpr}))?(?:${delimiterExpr})$`);
5080
+ }
5081
+ var leftDelimExpr = buildDelimiterExpr(
5082
+ ["\\left", "\\bigl", "\\Bigl", "\\biggl", "\\Biggl"],
5083
+ ["(", "[", "\\{", "\\lfloor", "\\lceil", "\\langle", "`", "|", "\\lvert", "\\vert", "\\lVert", "\\Vert"]
5084
+ );
5085
+ var rightDelimExpr = buildDelimiterExpr(
5086
+ ["\\right", "\\bigr", "\\Bigr", "\\biggr", "\\Biggr"],
5087
+ [")", "]", "\\}", "\\rfloor", "\\rceil", "\\rangle", "`", "|", "\\rvert", "\\vert", "\\rVert", "\\Vert"]
5088
+ );
5065
5089
  var DELIMITER_BASE_HEIGHT_PX = 18;
5066
5090
  var DELIMITER_MAX_SCALE = 4.8;
5067
5091
  function clamp(value, min, max) {
@@ -5073,7 +5097,7 @@ function applyDelimiterScale(pair, inner) {
5073
5097
  pair.style.setProperty("--butex-delim-scale", scale.toFixed(3));
5074
5098
  }
5075
5099
  function visibleDelimiter(expr) {
5076
- return expr.replace("\\left", "").replace("\\right", "").replace("\\{", "{").replace("\\}", "}");
5100
+ return expr.replace(/\\\\(?:left|right|bigl|Bigl|biggl|Biggl|bigr|Bigr|biggr|Biggr)/, "").replace("\\{", "{").replace("\\}", "}").replace(/\\\\(?:lvert|rvert|vert)/, "|").replace(/\\\\(?:lVert|rVert|Vert)/, "\u2016");
5077
5101
  }
5078
5102
  function buildDelimiterNodeBody(node, buildChain) {
5079
5103
  const pair = document.createElement("span");
@@ -6903,8 +6927,12 @@ function createEditorRuntime(options) {
6903
6927
  applyStructural((prev) => insertDelimiterPair(prev, "\\left(", "\\right)"));
6904
6928
  } else if (kind === "bracket") {
6905
6929
  applyStructural((prev) => insertDelimiterPair(prev, "\\left[", "\\right]"));
6906
- } else {
6930
+ } else if (kind === "brace") {
6907
6931
  applyStructural((prev) => insertDelimiterPair(prev, "\\left\\{", "\\right\\}"));
6932
+ } else if (kind === "vert") {
6933
+ applyStructural((prev) => insertDelimiterPair(prev, "\\left\\lvert", "\\right\\rvert"));
6934
+ } else {
6935
+ applyStructural((prev) => insertDelimiterPair(prev, "\\left\\lVert", "\\right\\rVert"));
6908
6936
  }
6909
6937
  focusInput();
6910
6938
  },
@@ -10350,7 +10378,9 @@ function EquationMobileToolbar({
10350
10378
  sheetView === "delimiters" ? /* @__PURE__ */ jsx("div", { className: "butex-widget__sheet-command-grid butex-widget__sheet-command-grid--three", children: [
10351
10379
  { kind: "paren", label: "()", title: messages.insertParentheses },
10352
10380
  { kind: "bracket", label: "[]", title: messages.insertBrackets },
10353
- { kind: "brace", label: "{}", title: messages.insertBraces }
10381
+ { kind: "brace", label: "{}", title: messages.insertBraces },
10382
+ { kind: "vert", label: "| |", title: "| |" },
10383
+ { kind: "Vert", label: "\u2016 \u2016", title: "\u2016 \u2016" }
10354
10384
  ].map((option) => /* @__PURE__ */ jsx("button", { type: "button", "aria-label": option.title, title: option.title, onClick: () => runAndClose((runtime) => runtime.insertDelimiterByKind(option.kind)), children: option.label }, option.kind)) }) : null,
10355
10385
  sheetView === "structures" ? /* @__PURE__ */ jsxs(Fragment, { children: [
10356
10386
  /* @__PURE__ */ jsxs("div", { className: "butex-widget__sheet-command-grid", children: [
@@ -11323,6 +11353,42 @@ ${arabic || currentMessages.empty}`;
11323
11353
  },
11324
11354
  children: "{}"
11325
11355
  }
11356
+ ),
11357
+ /* @__PURE__ */ jsx2(
11358
+ "button",
11359
+ {
11360
+ className: "delimiter-command-option",
11361
+ "data-delim": "vert",
11362
+ type: "button",
11363
+ role: "menuitem",
11364
+ title: "| |",
11365
+ "aria-label": "| |",
11366
+ onMouseDown: (event) => event.preventDefault(),
11367
+ onClick: () => {
11368
+ runtimeRef.current?.insertDelimiterByKind("vert");
11369
+ setDelimiterMenuOpen(false);
11370
+ focusSurface();
11371
+ },
11372
+ children: "| |"
11373
+ }
11374
+ ),
11375
+ /* @__PURE__ */ jsx2(
11376
+ "button",
11377
+ {
11378
+ className: "delimiter-command-option",
11379
+ "data-delim": "Vert",
11380
+ type: "button",
11381
+ role: "menuitem",
11382
+ title: "\u2016 \u2016",
11383
+ "aria-label": "\u2016 \u2016",
11384
+ onMouseDown: (event) => event.preventDefault(),
11385
+ onClick: () => {
11386
+ runtimeRef.current?.insertDelimiterByKind("Vert");
11387
+ setDelimiterMenuOpen(false);
11388
+ focusSurface();
11389
+ },
11390
+ children: "\u2016 \u2016"
11391
+ }
11326
11392
  )
11327
11393
  ] })
11328
11394
  ]