@drghaliasri/butex 7.1.2 → 7.1.3

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/document2.js CHANGED
@@ -3497,11 +3497,11 @@ function buildDelimiterExpr(prefixes, delimiters) {
3497
3497
  }
3498
3498
  var leftDelimExpr = buildDelimiterExpr(
3499
3499
  ["\\left", "\\bigl", "\\Bigl", "\\biggl", "\\Biggl"],
3500
- ["(", "[", "\\{", "\\lfloor", "\\lceil", "\\langle", "`", "|", "\\lvert", "\\vert", "\\lVert", "\\Vert"]
3500
+ ["(", "[", "\\{", "\\lfloor", "\\lceil", "\\langle", "`", "|", "\\|", "\\lvert", "\\vert", "\\lVert", "\\Vert"]
3501
3501
  );
3502
3502
  var rightDelimExpr = buildDelimiterExpr(
3503
3503
  ["\\right", "\\bigr", "\\Bigr", "\\biggr", "\\Biggr"],
3504
- [")", "]", "\\}", "\\rfloor", "\\rceil", "\\rangle", "`", "|", "\\rvert", "\\vert", "\\rVert", "\\Vert"]
3504
+ [")", "]", "\\}", "\\rfloor", "\\rceil", "\\rangle", "`", "|", "\\|", "\\rvert", "\\vert", "\\rVert", "\\Vert"]
3505
3505
  );
3506
3506
 
3507
3507
  // src/editor/display/frac.ts
@@ -4547,9 +4547,56 @@ function astNodeToEditorNode(node) {
4547
4547
  }
4548
4548
  return { editable: false, reason: `\u0639\u0642\u062F\u0629 \u0631\u064A\u0627\u0636\u064A\u0629 \u063A\u064A\u0631 \u0645\u062F\u0639\u0648\u0645\u0629 \u062D\u0627\u0644\u064A\u0627: ${node.nodeType}` };
4549
4549
  }
4550
+ var VERTICAL_DELIMITER_COMMAND_PAIRS = {
4551
+ "\\vert": "\\vert",
4552
+ "\\lvert": "\\rvert",
4553
+ "\\Vert": "\\Vert",
4554
+ "\\lVert": "\\rVert",
4555
+ "\\|": "\\|"
4556
+ };
4557
+ function isBareCommand(node, name) {
4558
+ return node instanceof CommandNode && node.name === name && node.optionalArgs.length === 0 && node.mandatoryArgs.length === 0;
4559
+ }
4560
+ function normalizeVerticalDelimiterCommands(chain) {
4561
+ const normalized = [];
4562
+ for (let index = 0; index < chain.chain.length; index += 1) {
4563
+ const left = chain.chain[index];
4564
+ if (!(left instanceof CommandNode) || left.superscript || left.subscript) {
4565
+ normalized.push(left);
4566
+ continue;
4567
+ }
4568
+ const rightName = VERTICAL_DELIMITER_COMMAND_PAIRS[left.name];
4569
+ if (!rightName || left.optionalArgs.length > 0 || left.mandatoryArgs.length > 0) {
4570
+ normalized.push(left);
4571
+ continue;
4572
+ }
4573
+ let rightIndex = -1;
4574
+ for (let candidate = index + 1; candidate < chain.chain.length; candidate += 1) {
4575
+ if (isBareCommand(chain.chain[candidate], rightName)) {
4576
+ rightIndex = candidate;
4577
+ break;
4578
+ }
4579
+ }
4580
+ if (rightIndex < 0) {
4581
+ normalized.push(left);
4582
+ continue;
4583
+ }
4584
+ const right = chain.chain[rightIndex];
4585
+ const delimiter = new DelimiterNode(
4586
+ left.name,
4587
+ new ChainNode(chain.chain.slice(index + 1, rightIndex)),
4588
+ right.name
4589
+ );
4590
+ delimiter.superscript = right.superscript;
4591
+ delimiter.subscript = right.subscript;
4592
+ normalized.push(delimiter);
4593
+ index = rightIndex;
4594
+ }
4595
+ return new ChainNode(normalized);
4596
+ }
4550
4597
  function chainToEditorChain(chain) {
4551
4598
  const nodes = [];
4552
- for (const astNode of chain.chain) {
4599
+ for (const astNode of normalizeVerticalDelimiterCommands(chain).chain) {
4553
4600
  const converted = astNodeToEditorNode(astNode);
4554
4601
  if (!converted.editable) {
4555
4602
  return converted;