@drghaliasri/butex 7.1.1 → 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.
package/dist/react.d.mts CHANGED
@@ -1126,7 +1126,7 @@ type EditorRuntimeApi = {
1126
1126
  toggleTakweenCharacterFont: () => void;
1127
1127
  setCurrentCharacterFont: (fontId: CharacterFontId) => void;
1128
1128
  setCurrentDigitForm: (digitForm: DigitFormId) => void;
1129
- insertDelimiterByKind: (kind: 'paren' | 'bracket' | 'brace') => void;
1129
+ insertDelimiterByKind: (kind: 'paren' | 'bracket' | 'brace' | 'vert' | 'Vert') => void;
1130
1130
  insertFraction: () => void;
1131
1131
  insertFirstDerivative: () => void;
1132
1132
  insertSecondDerivative: () => void;
package/dist/react.d.ts CHANGED
@@ -1126,7 +1126,7 @@ type EditorRuntimeApi = {
1126
1126
  toggleTakweenCharacterFont: () => void;
1127
1127
  setCurrentCharacterFont: (fontId: CharacterFontId) => void;
1128
1128
  setCurrentDigitForm: (digitForm: DigitFormId) => void;
1129
- insertDelimiterByKind: (kind: 'paren' | 'bracket' | 'brace') => void;
1129
+ insertDelimiterByKind: (kind: 'paren' | 'bracket' | 'brace' | 'vert' | 'Vert') => void;
1130
1130
  insertFraction: () => void;
1131
1131
  insertFirstDerivative: () => void;
1132
1132
  insertSecondDerivative: () => void;
package/dist/react.js CHANGED
@@ -64,11 +64,11 @@ function createEditorNode(kind, expr) {
64
64
  columnAlignments: null
65
65
  };
66
66
  }
67
- function createDelimiterNode(leftDelimExpr, rightDelimExpr) {
67
+ function createDelimiterNode(leftDelimExpr2, rightDelimExpr2) {
68
68
  return {
69
69
  ...createEditorNode("delimiter", ""),
70
- leftDelimExpr,
71
- rightDelimExpr,
70
+ leftDelimExpr: leftDelimExpr2,
71
+ rightDelimExpr: rightDelimExpr2,
72
72
  innerExpr: createEditorChain()
73
73
  };
74
74
  }
@@ -3672,11 +3672,11 @@ function insertAtomicOperatorCommand(session, commandId) {
3672
3672
  appendDebug(next, "insertAtomicOperatorCommand", commandId);
3673
3673
  return next;
3674
3674
  }
3675
- function insertDelimiterPair(session, leftDelimExpr, rightDelimExpr) {
3675
+ function insertDelimiterPair(session, leftDelimExpr2, rightDelimExpr2) {
3676
3676
  const base = replaceSelectionFirst(session);
3677
3677
  const next = cloneEditorSession(base);
3678
- const englishNode = createDelimiterNode(leftDelimExpr, rightDelimExpr);
3679
- const arabicNode = createDelimiterNode(leftDelimExpr, rightDelimExpr);
3678
+ const englishNode = createDelimiterNode(leftDelimExpr2, rightDelimExpr2);
3679
+ const arabicNode = createDelimiterNode(leftDelimExpr2, rightDelimExpr2);
3680
3680
  arabicNode.id = englishNode.id;
3681
3681
  if (arabicNode.innerExpr && englishNode.innerExpr) {
3682
3682
  arabicNode.innerExpr.id = englishNode.innerExpr.id;
@@ -3688,7 +3688,7 @@ function insertDelimiterPair(session, leftDelimExpr, rightDelimExpr) {
3688
3688
  };
3689
3689
  next.selectedStructureNodeId = null;
3690
3690
  syncSelectionToCaret(next);
3691
- appendDebug(next, "insertDelimiterPair", `${leftDelimExpr}${rightDelimExpr}`);
3691
+ appendDebug(next, "insertDelimiterPair", `${leftDelimExpr2}${rightDelimExpr2}`);
3692
3692
  return next;
3693
3693
  }
3694
3694
  function insertFraction(session) {
@@ -4372,6 +4372,22 @@ var DELIMITER_CSS = `
4372
4372
  transform-origin: center;
4373
4373
  }
4374
4374
  `.trim();
4375
+ function escapeDelimiterExpr(value) {
4376
+ return value.replace(/[.*+?^$()|[\]\\]/g, "\\$&");
4377
+ }
4378
+ function buildDelimiterExpr(prefixes, delimiters) {
4379
+ const prefixExpr = prefixes.map(escapeDelimiterExpr).join("|");
4380
+ const delimiterExpr = delimiters.map(escapeDelimiterExpr).join("|");
4381
+ return new RegExp(`^(?:(?:${prefixExpr}))?(?:${delimiterExpr})$`);
4382
+ }
4383
+ var leftDelimExpr = buildDelimiterExpr(
4384
+ ["\\left", "\\bigl", "\\Bigl", "\\biggl", "\\Biggl"],
4385
+ ["(", "[", "\\{", "\\lfloor", "\\lceil", "\\langle", "`", "|", "\\lvert", "\\vert", "\\lVert", "\\Vert"]
4386
+ );
4387
+ var rightDelimExpr = buildDelimiterExpr(
4388
+ ["\\right", "\\bigr", "\\Bigr", "\\biggr", "\\Biggr"],
4389
+ [")", "]", "\\}", "\\rfloor", "\\rceil", "\\rangle", "`", "|", "\\rvert", "\\vert", "\\rVert", "\\Vert"]
4390
+ );
4375
4391
  var DELIMITER_BASE_HEIGHT_PX = 18;
4376
4392
  var DELIMITER_MAX_SCALE = 4.8;
4377
4393
  function clamp(value, min, max) {
@@ -4383,7 +4399,7 @@ function applyDelimiterScale(pair, inner) {
4383
4399
  pair.style.setProperty("--butex-delim-scale", scale.toFixed(3));
4384
4400
  }
4385
4401
  function visibleDelimiter(expr) {
4386
- return expr.replace("\\left", "").replace("\\right", "").replace("\\{", "{").replace("\\}", "}");
4402
+ return expr.replace(/\\\\(?:left|right|bigl|Bigl|biggl|Biggl|bigr|Bigr|biggr|Biggr)/, "").replace("\\{", "{").replace("\\}", "}").replace(/\\\\(?:lvert|rvert|vert)/, "|").replace(/\\\\(?:lVert|rVert|Vert)/, "\u2016");
4387
4403
  }
4388
4404
  function buildDelimiterNodeBody(node, buildChain) {
4389
4405
  const pair = document.createElement("span");
@@ -6213,8 +6229,12 @@ function createEditorRuntime(options) {
6213
6229
  applyStructural((prev) => insertDelimiterPair(prev, "\\left(", "\\right)"));
6214
6230
  } else if (kind === "bracket") {
6215
6231
  applyStructural((prev) => insertDelimiterPair(prev, "\\left[", "\\right]"));
6216
- } else {
6232
+ } else if (kind === "brace") {
6217
6233
  applyStructural((prev) => insertDelimiterPair(prev, "\\left\\{", "\\right\\}"));
6234
+ } else if (kind === "vert") {
6235
+ applyStructural((prev) => insertDelimiterPair(prev, "\\left\\lvert", "\\right\\rvert"));
6236
+ } else {
6237
+ applyStructural((prev) => insertDelimiterPair(prev, "\\left\\lVert", "\\right\\rVert"));
6218
6238
  }
6219
6239
  focusInput();
6220
6240
  },
@@ -8274,12 +8294,12 @@ var DelimiterNode = class extends BaseAstNode {
8274
8294
  leftDelimExpr;
8275
8295
  innerExpr;
8276
8296
  rightDelimExpr;
8277
- constructor(leftDelimExpr, innerExpr, rightDelimExpr, state = null) {
8297
+ constructor(leftDelimExpr2, innerExpr, rightDelimExpr2, state = null) {
8278
8298
  super(state);
8279
8299
  this.nodeType = "DelimiterObject";
8280
- this.leftDelimExpr = leftDelimExpr;
8300
+ this.leftDelimExpr = leftDelimExpr2;
8281
8301
  this.innerExpr = innerExpr;
8282
- this.rightDelimExpr = rightDelimExpr;
8302
+ this.rightDelimExpr = rightDelimExpr2;
8283
8303
  }
8284
8304
  latex() {
8285
8305
  return this.leftDelimExpr + this.innerExpr.latex() + this.rightDelimExpr + this.latexScripts();
@@ -9576,7 +9596,9 @@ function EquationMobileToolbar({
9576
9596
  sheetView === "delimiters" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "butex-widget__sheet-command-grid butex-widget__sheet-command-grid--three", children: [
9577
9597
  { kind: "paren", label: "()", title: messages.insertParentheses },
9578
9598
  { kind: "bracket", label: "[]", title: messages.insertBrackets },
9579
- { kind: "brace", label: "{}", title: messages.insertBraces }
9599
+ { kind: "brace", label: "{}", title: messages.insertBraces },
9600
+ { kind: "vert", label: "| |", title: "| |" },
9601
+ { kind: "Vert", label: "\u2016 \u2016", title: "\u2016 \u2016" }
9580
9602
  ].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,
9581
9603
  sheetView === "structures" ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
9582
9604
  /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "butex-widget__sheet-command-grid", children: [
@@ -10549,6 +10571,42 @@ ${arabic || currentMessages.empty}`;
10549
10571
  },
10550
10572
  children: "{}"
10551
10573
  }
10574
+ ),
10575
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
10576
+ "button",
10577
+ {
10578
+ className: "delimiter-command-option",
10579
+ "data-delim": "vert",
10580
+ type: "button",
10581
+ role: "menuitem",
10582
+ title: "| |",
10583
+ "aria-label": "| |",
10584
+ onMouseDown: (event) => event.preventDefault(),
10585
+ onClick: () => {
10586
+ runtimeRef.current?.insertDelimiterByKind("vert");
10587
+ setDelimiterMenuOpen(false);
10588
+ focusSurface();
10589
+ },
10590
+ children: "| |"
10591
+ }
10592
+ ),
10593
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
10594
+ "button",
10595
+ {
10596
+ className: "delimiter-command-option",
10597
+ "data-delim": "Vert",
10598
+ type: "button",
10599
+ role: "menuitem",
10600
+ title: "\u2016 \u2016",
10601
+ "aria-label": "\u2016 \u2016",
10602
+ onMouseDown: (event) => event.preventDefault(),
10603
+ onClick: () => {
10604
+ runtimeRef.current?.insertDelimiterByKind("Vert");
10605
+ setDelimiterMenuOpen(false);
10606
+ focusSurface();
10607
+ },
10608
+ children: "\u2016 \u2016"
10609
+ }
10552
10610
  )
10553
10611
  ] })
10554
10612
  ]