@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.
@@ -156,12 +156,12 @@ var DelimiterNode = class extends BaseAstNode {
156
156
  leftDelimExpr;
157
157
  innerExpr;
158
158
  rightDelimExpr;
159
- constructor(leftDelimExpr, innerExpr, rightDelimExpr, state = null) {
159
+ constructor(leftDelimExpr2, innerExpr, rightDelimExpr2, state = null) {
160
160
  super(state);
161
161
  this.nodeType = "DelimiterObject";
162
- this.leftDelimExpr = leftDelimExpr;
162
+ this.leftDelimExpr = leftDelimExpr2;
163
163
  this.innerExpr = innerExpr;
164
- this.rightDelimExpr = rightDelimExpr;
164
+ this.rightDelimExpr = rightDelimExpr2;
165
165
  }
166
166
  latex() {
167
167
  return this.leftDelimExpr + this.innerExpr.latex() + this.rightDelimExpr + this.latexScripts();
@@ -1084,6 +1084,14 @@ var ATOMIC_COMMANDS = {
1084
1084
  arabicLabel: "\u0646\u0640\u0640\u0640\u0640\u0640\u0647\u0627",
1085
1085
  title: "\u062D\u062F"
1086
1086
  },
1087
+ arg: {
1088
+ id: "arg",
1089
+ category: "limits_series",
1090
+ englishTex: "\\arg",
1091
+ arabicTex: "\\ararg",
1092
+ arabicLabel: "\u062D\u062C",
1093
+ title: "\u062D\u062C\u0629"
1094
+ },
1087
1095
  max: {
1088
1096
  id: "max",
1089
1097
  category: "limits_series",
@@ -1932,11 +1940,11 @@ function createEditorNode(kind, expr) {
1932
1940
  columnAlignments: null
1933
1941
  };
1934
1942
  }
1935
- function createDelimiterNode(leftDelimExpr, rightDelimExpr) {
1943
+ function createDelimiterNode(leftDelimExpr2, rightDelimExpr2) {
1936
1944
  return {
1937
1945
  ...createEditorNode("delimiter", ""),
1938
- leftDelimExpr,
1939
- rightDelimExpr,
1946
+ leftDelimExpr: leftDelimExpr2,
1947
+ rightDelimExpr: rightDelimExpr2,
1940
1948
  innerExpr: createEditorChain()
1941
1949
  };
1942
1950
  }
@@ -4391,11 +4399,11 @@ function insertAtomicOperatorCommand(session, commandId) {
4391
4399
  appendDebug(next, "insertAtomicOperatorCommand", commandId);
4392
4400
  return next;
4393
4401
  }
4394
- function insertDelimiterPair(session, leftDelimExpr, rightDelimExpr) {
4402
+ function insertDelimiterPair(session, leftDelimExpr2, rightDelimExpr2) {
4395
4403
  const base = replaceSelectionFirst(session);
4396
4404
  const next = cloneEditorSession(base);
4397
- const englishNode = createDelimiterNode(leftDelimExpr, rightDelimExpr);
4398
- const arabicNode = createDelimiterNode(leftDelimExpr, rightDelimExpr);
4405
+ const englishNode = createDelimiterNode(leftDelimExpr2, rightDelimExpr2);
4406
+ const arabicNode = createDelimiterNode(leftDelimExpr2, rightDelimExpr2);
4399
4407
  arabicNode.id = englishNode.id;
4400
4408
  if (arabicNode.innerExpr && englishNode.innerExpr) {
4401
4409
  arabicNode.innerExpr.id = englishNode.innerExpr.id;
@@ -4407,7 +4415,7 @@ function insertDelimiterPair(session, leftDelimExpr, rightDelimExpr) {
4407
4415
  };
4408
4416
  next.selectedStructureNodeId = null;
4409
4417
  syncSelectionToCaret(next);
4410
- appendDebug(next, "insertDelimiterPair", `${leftDelimExpr}${rightDelimExpr}`);
4418
+ appendDebug(next, "insertDelimiterPair", `${leftDelimExpr2}${rightDelimExpr2}`);
4411
4419
  return next;
4412
4420
  }
4413
4421
  function insertFraction(session) {
@@ -5091,6 +5099,22 @@ var DELIMITER_CSS = `
5091
5099
  transform-origin: center;
5092
5100
  }
5093
5101
  `.trim();
5102
+ function escapeDelimiterExpr(value) {
5103
+ return value.replace(/[.*+?^$()|[\]\\]/g, "\\$&");
5104
+ }
5105
+ function buildDelimiterExpr(prefixes, delimiters) {
5106
+ const prefixExpr = prefixes.map(escapeDelimiterExpr).join("|");
5107
+ const delimiterExpr = delimiters.map(escapeDelimiterExpr).join("|");
5108
+ return new RegExp(`^(?:(?:${prefixExpr}))?(?:${delimiterExpr})$`);
5109
+ }
5110
+ var leftDelimExpr = buildDelimiterExpr(
5111
+ ["\\left", "\\bigl", "\\Bigl", "\\biggl", "\\Biggl"],
5112
+ ["(", "[", "\\{", "\\lfloor", "\\lceil", "\\langle", "`", "|", "\\lvert", "\\vert", "\\lVert", "\\Vert"]
5113
+ );
5114
+ var rightDelimExpr = buildDelimiterExpr(
5115
+ ["\\right", "\\bigr", "\\Bigr", "\\biggr", "\\Biggr"],
5116
+ [")", "]", "\\}", "\\rfloor", "\\rceil", "\\rangle", "`", "|", "\\rvert", "\\vert", "\\rVert", "\\Vert"]
5117
+ );
5094
5118
  var DELIMITER_BASE_HEIGHT_PX = 18;
5095
5119
  var DELIMITER_MAX_SCALE = 4.8;
5096
5120
  function clamp(value, min, max) {
@@ -5102,7 +5126,7 @@ function applyDelimiterScale(pair, inner) {
5102
5126
  pair.style.setProperty("--butex-delim-scale", scale.toFixed(3));
5103
5127
  }
5104
5128
  function visibleDelimiter(expr) {
5105
- return expr.replace("\\left", "").replace("\\right", "").replace("\\{", "{").replace("\\}", "}");
5129
+ return expr.replace(/\\\\(?:left|right|bigl|Bigl|biggl|Biggl|bigr|Bigr|biggr|Biggr)/, "").replace("\\{", "{").replace("\\}", "}").replace(/\\\\(?:lvert|rvert|vert)/, "|").replace(/\\\\(?:lVert|rVert|Vert)/, "\u2016");
5106
5130
  }
5107
5131
  function buildDelimiterNodeBody(node, buildChain) {
5108
5132
  const pair = document.createElement("span");
@@ -6932,8 +6956,12 @@ function createEditorRuntime(options) {
6932
6956
  applyStructural((prev) => insertDelimiterPair(prev, "\\left(", "\\right)"));
6933
6957
  } else if (kind === "bracket") {
6934
6958
  applyStructural((prev) => insertDelimiterPair(prev, "\\left[", "\\right]"));
6935
- } else {
6959
+ } else if (kind === "brace") {
6936
6960
  applyStructural((prev) => insertDelimiterPair(prev, "\\left\\{", "\\right\\}"));
6961
+ } else if (kind === "vert") {
6962
+ applyStructural((prev) => insertDelimiterPair(prev, "\\left\\lvert", "\\right\\rvert"));
6963
+ } else {
6964
+ applyStructural((prev) => insertDelimiterPair(prev, "\\left\\lVert", "\\right\\rVert"));
6937
6965
  }
6938
6966
  focusInput();
6939
6967
  },
@@ -10371,7 +10399,9 @@ function EquationMobileToolbar({
10371
10399
  sheetView === "delimiters" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "butex-widget__sheet-command-grid butex-widget__sheet-command-grid--three", children: [
10372
10400
  { kind: "paren", label: "()", title: messages.insertParentheses },
10373
10401
  { kind: "bracket", label: "[]", title: messages.insertBrackets },
10374
- { kind: "brace", label: "{}", title: messages.insertBraces }
10402
+ { kind: "brace", label: "{}", title: messages.insertBraces },
10403
+ { kind: "vert", label: "| |", title: "| |" },
10404
+ { kind: "Vert", label: "\u2016 \u2016", title: "\u2016 \u2016" }
10375
10405
  ].map((option) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", "aria-label": option.title, title: option.title, onClick: () => runAndClose((runtime) => runtime.insertDelimiterByKind(option.kind)), children: option.label }, option.kind)) }) : null,
10376
10406
  sheetView === "structures" ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
10377
10407
  /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "butex-widget__sheet-command-grid", children: [
@@ -11344,6 +11374,42 @@ ${arabic || currentMessages.empty}`;
11344
11374
  },
11345
11375
  children: "{}"
11346
11376
  }
11377
+ ),
11378
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
11379
+ "button",
11380
+ {
11381
+ className: "delimiter-command-option",
11382
+ "data-delim": "vert",
11383
+ type: "button",
11384
+ role: "menuitem",
11385
+ title: "| |",
11386
+ "aria-label": "| |",
11387
+ onMouseDown: (event) => event.preventDefault(),
11388
+ onClick: () => {
11389
+ runtimeRef.current?.insertDelimiterByKind("vert");
11390
+ setDelimiterMenuOpen(false);
11391
+ focusSurface();
11392
+ },
11393
+ children: "| |"
11394
+ }
11395
+ ),
11396
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
11397
+ "button",
11398
+ {
11399
+ className: "delimiter-command-option",
11400
+ "data-delim": "Vert",
11401
+ type: "button",
11402
+ role: "menuitem",
11403
+ title: "\u2016 \u2016",
11404
+ "aria-label": "\u2016 \u2016",
11405
+ onMouseDown: (event) => event.preventDefault(),
11406
+ onClick: () => {
11407
+ runtimeRef.current?.insertDelimiterByKind("Vert");
11408
+ setDelimiterMenuOpen(false);
11409
+ focusSurface();
11410
+ },
11411
+ children: "\u2016 \u2016"
11412
+ }
11347
11413
  )
11348
11414
  ] })
11349
11415
  ]