@drghaliasri/butex 7.2.0 → 7.2.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.
Files changed (48) hide show
  1. package/README.md +1 -0
  2. package/dist/document.d.mts +8 -0
  3. package/dist/document.d.ts +8 -0
  4. package/dist/document.js +38 -2
  5. package/dist/document.js.map +1 -1
  6. package/dist/document.mjs +38 -2
  7. package/dist/document.mjs.map +1 -1
  8. package/dist/document2-cli.js +107 -2
  9. package/dist/document2-cli.js.map +1 -1
  10. package/dist/document2.d.mts +8 -0
  11. package/dist/document2.d.ts +8 -0
  12. package/dist/document2.js +107 -2
  13. package/dist/document2.js.map +1 -1
  14. package/dist/document2.mjs +107 -2
  15. package/dist/document2.mjs.map +1 -1
  16. package/dist/index.d.mts +19 -1
  17. package/dist/index.d.ts +19 -1
  18. package/dist/index.global.js +109 -11
  19. package/dist/index.global.js.map +1 -1
  20. package/dist/index.js +109 -11
  21. package/dist/index.js.map +1 -1
  22. package/dist/index.mjs +109 -11
  23. package/dist/index.mjs.map +1 -1
  24. package/dist/react-document.d.mts +2 -0
  25. package/dist/react-document.d.ts +2 -0
  26. package/dist/react-document.js +230 -40
  27. package/dist/react-document.js.map +1 -1
  28. package/dist/react-document.mjs +230 -40
  29. package/dist/react-document.mjs.map +1 -1
  30. package/dist/react-document2-preview.d.mts +2 -0
  31. package/dist/react-document2-preview.d.ts +2 -0
  32. package/dist/react-document2-preview.js +91 -0
  33. package/dist/react-document2-preview.js.map +1 -1
  34. package/dist/react-document2-preview.mjs +91 -0
  35. package/dist/react-document2-preview.mjs.map +1 -1
  36. package/dist/react-document2.d.mts +8 -0
  37. package/dist/react-document2.d.ts +8 -0
  38. package/dist/react-document2.js +230 -40
  39. package/dist/react-document2.js.map +1 -1
  40. package/dist/react-document2.mjs +230 -40
  41. package/dist/react-document2.mjs.map +1 -1
  42. package/dist/react.d.mts +16 -0
  43. package/dist/react.d.ts +16 -0
  44. package/dist/react.js +230 -40
  45. package/dist/react.js.map +1 -1
  46. package/dist/react.mjs +230 -40
  47. package/dist/react.mjs.map +1 -1
  48. package/package.json +1 -1
package/dist/react.d.mts CHANGED
@@ -17,6 +17,10 @@ type EditorNode = {
17
17
  kind: EditorNodeKind;
18
18
  expr: string;
19
19
  characterFont?: CharacterFontId;
20
+ /** Minimal upstream source identity used only while the node remains unchanged. */
21
+ sourceLatex?: string;
22
+ /** Existing editor node reused for wrapper commands that need editable content. */
23
+ wrapperCommand?: '\\unit' | '\\mathtt' | '\\mathbf' | '\\boldarabic';
20
24
  superscript: EditorChain | null;
21
25
  subscript: EditorChain | null;
22
26
  leftDelimExpr: string;
@@ -68,6 +72,8 @@ type EditorSession = {
68
72
  arabicReverseNumberTyping: boolean;
69
73
  /** Font applied to newly typed char nodes. */
70
74
  currentCharacterFont: CharacterFontId;
75
+ /** Structured command wrapper applied to newly typed chars; kept separate from fonts. */
76
+ currentCharacterWrapper: '\\boldarabic' | null;
71
77
  /** Digit glyph form used for editor display and LaTeX preview output. */
72
78
  currentDigitForm: DigitFormId;
73
79
  caret: EditorCaret;
@@ -575,6 +581,15 @@ declare const ATOMIC_OPERATOR_COMMANDS: {
575
581
  readonly title: "اللانهاية";
576
582
  readonly svg_path: null;
577
583
  };
584
+ readonly top: {
585
+ readonly id: "top";
586
+ readonly category: "operators1";
587
+ readonly Tex: "\\top";
588
+ readonly mirror: false;
589
+ readonly Label: "⊤";
590
+ readonly title: "المنقول";
591
+ readonly svg_path: null;
592
+ };
578
593
  readonly times: {
579
594
  readonly id: "times";
580
595
  readonly category: "operators1";
@@ -1125,6 +1140,7 @@ type EditorRuntimeApi = {
1125
1140
  toggleArabicReverseNumberTyping: () => void;
1126
1141
  toggleTakweenCharacterFont: () => void;
1127
1142
  setCurrentCharacterFont: (fontId: CharacterFontId) => void;
1143
+ setCurrentBoldCharacterStyle: () => void;
1128
1144
  setCurrentDigitForm: (digitForm: DigitFormId) => void;
1129
1145
  insertDelimiterByKind: (kind: 'paren' | 'bracket' | 'brace' | 'vert' | 'Vert') => void;
1130
1146
  insertFraction: () => void;
package/dist/react.d.ts CHANGED
@@ -17,6 +17,10 @@ type EditorNode = {
17
17
  kind: EditorNodeKind;
18
18
  expr: string;
19
19
  characterFont?: CharacterFontId;
20
+ /** Minimal upstream source identity used only while the node remains unchanged. */
21
+ sourceLatex?: string;
22
+ /** Existing editor node reused for wrapper commands that need editable content. */
23
+ wrapperCommand?: '\\unit' | '\\mathtt' | '\\mathbf' | '\\boldarabic';
20
24
  superscript: EditorChain | null;
21
25
  subscript: EditorChain | null;
22
26
  leftDelimExpr: string;
@@ -68,6 +72,8 @@ type EditorSession = {
68
72
  arabicReverseNumberTyping: boolean;
69
73
  /** Font applied to newly typed char nodes. */
70
74
  currentCharacterFont: CharacterFontId;
75
+ /** Structured command wrapper applied to newly typed chars; kept separate from fonts. */
76
+ currentCharacterWrapper: '\\boldarabic' | null;
71
77
  /** Digit glyph form used for editor display and LaTeX preview output. */
72
78
  currentDigitForm: DigitFormId;
73
79
  caret: EditorCaret;
@@ -575,6 +581,15 @@ declare const ATOMIC_OPERATOR_COMMANDS: {
575
581
  readonly title: "اللانهاية";
576
582
  readonly svg_path: null;
577
583
  };
584
+ readonly top: {
585
+ readonly id: "top";
586
+ readonly category: "operators1";
587
+ readonly Tex: "\\top";
588
+ readonly mirror: false;
589
+ readonly Label: "⊤";
590
+ readonly title: "المنقول";
591
+ readonly svg_path: null;
592
+ };
578
593
  readonly times: {
579
594
  readonly id: "times";
580
595
  readonly category: "operators1";
@@ -1125,6 +1140,7 @@ type EditorRuntimeApi = {
1125
1140
  toggleArabicReverseNumberTyping: () => void;
1126
1141
  toggleTakweenCharacterFont: () => void;
1127
1142
  setCurrentCharacterFont: (fontId: CharacterFontId) => void;
1143
+ setCurrentBoldCharacterStyle: () => void;
1128
1144
  setCurrentDigitForm: (digitForm: DigitFormId) => void;
1129
1145
  insertDelimiterByKind: (kind: 'paren' | 'bracket' | 'brace' | 'vert' | 'Vert') => void;
1130
1146
  insertFraction: () => void;
package/dist/react.js CHANGED
@@ -137,6 +137,7 @@ function cloneEditorSession(session) {
137
137
  forceSplitNextLeaf: session.forceSplitNextLeaf,
138
138
  arabicReverseNumberTyping: session.arabicReverseNumberTyping,
139
139
  currentCharacterFont: session.currentCharacterFont ?? "default",
140
+ currentCharacterWrapper: session.currentCharacterWrapper ?? null,
140
141
  currentDigitForm: session.currentDigitForm ?? "western",
141
142
  caret: { ...session.caret },
142
143
  selection: session.selection ? { ...session.selection } : null,
@@ -209,6 +210,7 @@ function createEditorSession(englishTree, arabicTree, activeSide = "arabic") {
209
210
  forceSplitNextLeaf: false,
210
211
  arabicReverseNumberTyping: true,
211
212
  currentCharacterFont: "default",
213
+ currentCharacterWrapper: null,
212
214
  currentDigitForm: "western",
213
215
  caret: {
214
216
  chainId: englishTree.id,
@@ -762,6 +764,15 @@ var ATOMIC_OPERATOR_COMMANDS = {
762
764
  title: "\u0627\u0644\u0644\u0627\u0646\u0647\u0627\u064A\u0629",
763
765
  svg_path: null
764
766
  },
767
+ top: {
768
+ id: "top",
769
+ category: "operators1",
770
+ Tex: "\\top",
771
+ mirror: false,
772
+ Label: "\u22A4",
773
+ title: "\u0627\u0644\u0645\u0646\u0642\u0648\u0644",
774
+ svg_path: null
775
+ },
765
776
  times: {
766
777
  id: "times",
767
778
  category: "operators1",
@@ -1459,6 +1470,7 @@ var CHARACTER_FONT_SPECS = [
1459
1470
  latexFontCommand: "\\maghribi",
1460
1471
  latexFontFamily: "Almaghribi Warsh Quran",
1461
1472
  browserFontStack: '"Almaghribi Warsh Quran", Amiri, "Segoe UI", Tahoma, sans-serif',
1473
+ importAliases: ["\\maghribi"],
1462
1474
  svgLayoutKey: "maghribi"
1463
1475
  }
1464
1476
  ];
@@ -1659,6 +1671,14 @@ function renderNodeEnglish(node, options) {
1659
1671
  return `${node.expr}${latinScripts(node, options)}`;
1660
1672
  }
1661
1673
  if (node.kind === "char") {
1674
+ if (node.sourceLatex) {
1675
+ return `${node.sourceLatex}${latinScripts(node, options)}`;
1676
+ }
1677
+ if (node.wrapperCommand) {
1678
+ const expr = formatDigits(node.expr, selectedDigitForm(options));
1679
+ const wrapper = node.wrapperCommand === "\\boldarabic" ? "\\mathbf" : node.wrapperCommand;
1680
+ return `${wrapper}{${escapeText(expr)}}${latinScripts(node, options)}`;
1681
+ }
1662
1682
  return `${renderCharContent(node, options)}${latinScripts(node, options)}`;
1663
1683
  }
1664
1684
  if (node.kind === "operator" && isDivideOperatorExpr(node.expr)) {
@@ -1712,6 +1732,10 @@ function renderNodeArabic(node, options) {
1712
1732
  if (node.kind === "char") {
1713
1733
  const expr = formatDigits(node.expr, selectedDigitForm(options));
1714
1734
  const content = renderCharContent(node, options);
1735
+ if (node.wrapperCommand) {
1736
+ const wrapper = node.wrapperCommand === "\\mathbf" ? "\\boldarabic" : node.wrapperCommand;
1737
+ return arabicScripts(node, `${wrapper}{${content}}`, options);
1738
+ }
1715
1739
  return arabicScripts(node, (node.characterFont ?? "default") === "default" ? `\\text{${escapeText(expr)}}` : content, options);
1716
1740
  }
1717
1741
  if (node.kind === "operator" && isDivideOperatorExpr(node.expr)) {
@@ -2940,6 +2964,16 @@ function markExprSync(session, nodeId) {
2940
2964
  }
2941
2965
  session.sync[nodeId].expr = english.node.expr === arabic.node.expr ? "synced" : "diverged";
2942
2966
  }
2967
+ function clearSourceIdentity(session, nodeId) {
2968
+ const english = findNodeById(session.englishTree, nodeId);
2969
+ const arabic = findNodeById(session.arabicTree, nodeId);
2970
+ if (english) {
2971
+ delete english.node.sourceLatex;
2972
+ }
2973
+ if (arabic) {
2974
+ delete arabic.node.sourceLatex;
2975
+ }
2976
+ }
2943
2977
  function syncSelectionToCaret(session) {
2944
2978
  const activeKey = activeTreeKey(session.activeSide);
2945
2979
  const tree = session[activeKey];
@@ -3523,7 +3557,10 @@ function insertLeaf(session, kind, expr) {
3523
3557
  const next = cloneEditorSession(session);
3524
3558
  const englishNode = createEditorNode(kind, expr);
3525
3559
  const arabicNode = createEditorNode(kind, expr);
3526
- if (kind === "char" && (next.currentCharacterFont ?? "default") !== "default") {
3560
+ if (kind === "char" && next.currentCharacterWrapper === "\\boldarabic") {
3561
+ englishNode.wrapperCommand = "\\boldarabic";
3562
+ arabicNode.wrapperCommand = "\\boldarabic";
3563
+ } else if (kind === "char" && (next.currentCharacterFont ?? "default") !== "default") {
3527
3564
  englishNode.characterFont = next.currentCharacterFont;
3528
3565
  arabicNode.characterFont = next.currentCharacterFont;
3529
3566
  }
@@ -3538,8 +3575,12 @@ function insertLeaf(session, kind, expr) {
3538
3575
  function shouldReverseArabicNumber(session) {
3539
3576
  return session.activeSide === "arabic" && session.arabicReverseNumberTyping;
3540
3577
  }
3541
- function characterFontOf(node) {
3542
- return node.kind === "char" ? node.characterFont ?? "default" : "default";
3578
+ function characterTypingStyleOf(node) {
3579
+ if (node.kind !== "char") return "none";
3580
+ return node.wrapperCommand ? `wrapper:${node.wrapperCommand}` : `font:${node.characterFont ?? "default"}`;
3581
+ }
3582
+ function currentCharacterTypingStyle(session) {
3583
+ return session.currentCharacterWrapper ? `wrapper:${session.currentCharacterWrapper}` : `font:${session.currentCharacterFont ?? "default"}`;
3543
3584
  }
3544
3585
  function tryMergeLeafTyping(session, kind, fragment) {
3545
3586
  const engLocated = findChainById(session.englishTree, session.caret.chainId);
@@ -3552,14 +3593,14 @@ function tryMergeLeafTyping(session, kind, fragment) {
3552
3593
  let prepend = false;
3553
3594
  if (i > 0) {
3554
3595
  const prev = nodes[i - 1];
3555
- if (prev.kind === kind && (kind !== "char" || characterFontOf(prev) === (session.currentCharacterFont ?? "default"))) {
3596
+ if (prev.kind === kind && (kind !== "char" || characterTypingStyleOf(prev) === currentCharacterTypingStyle(session))) {
3556
3597
  targetId = prev.id;
3557
3598
  prepend = false;
3558
3599
  }
3559
3600
  }
3560
3601
  if (!targetId && i < nodes.length) {
3561
3602
  const fwd = nodes[i];
3562
- if (fwd.kind === kind && (kind !== "char" || characterFontOf(fwd) === (session.currentCharacterFont ?? "default"))) {
3603
+ if (fwd.kind === kind && (kind !== "char" || characterTypingStyleOf(fwd) === currentCharacterTypingStyle(session))) {
3563
3604
  targetId = fwd.id;
3564
3605
  prepend = true;
3565
3606
  }
@@ -3580,6 +3621,7 @@ function tryMergeLeafTyping(session, kind, fragment) {
3580
3621
  englishHit.node.expr = `${englishHit.node.expr}${fragment}`;
3581
3622
  arabicHit.node.expr = `${arabicHit.node.expr}${fragment}`;
3582
3623
  }
3624
+ clearSourceIdentity(session, targetId);
3583
3625
  markExprSync(session, targetId);
3584
3626
  return true;
3585
3627
  }
@@ -3618,9 +3660,17 @@ function breakLeafTyping(session) {
3618
3660
  function setCurrentCharacterFont(session, fontId) {
3619
3661
  const next = cloneEditorSession(session);
3620
3662
  next.currentCharacterFont = fontId;
3663
+ next.currentCharacterWrapper = null;
3621
3664
  appendDebug(next, "setCurrentCharacterFont", fontId);
3622
3665
  return next;
3623
3666
  }
3667
+ function setCurrentBoldCharacterStyle(session) {
3668
+ const next = cloneEditorSession(session);
3669
+ next.currentCharacterFont = "default";
3670
+ next.currentCharacterWrapper = "\\boldarabic";
3671
+ appendDebug(next, "setCurrentBoldCharacterStyle", "\\boldarabic");
3672
+ return next;
3673
+ }
3624
3674
  function toggleTakweenCharacterFont(session) {
3625
3675
  return setCurrentCharacterFont(session, (session.currentCharacterFont ?? "default") === "takween" ? "default" : "takween");
3626
3676
  }
@@ -4169,6 +4219,7 @@ function deleteBackward(session) {
4169
4219
  englishHit.node.expr = englishHit.node.expr.slice(0, -1);
4170
4220
  arabicHit.node.expr = arabicHit.node.expr.slice(0, -1);
4171
4221
  }
4222
+ clearSourceIdentity(next, id);
4172
4223
  markExprSync(next, id);
4173
4224
  next.selectedStructureNodeId = null;
4174
4225
  syncSelectionToCaret(next);
@@ -4218,6 +4269,7 @@ function deleteForward(session) {
4218
4269
  englishHit.node.expr = englishHit.node.expr.slice(1);
4219
4270
  arabicHit.node.expr = arabicHit.node.expr.slice(1);
4220
4271
  }
4272
+ clearSourceIdentity(next, node.id);
4221
4273
  markExprSync(next, node.id);
4222
4274
  next.selectedStructureNodeId = null;
4223
4275
  syncSelectionToCaret(next);
@@ -4247,6 +4299,7 @@ function createStarterSession() {
4247
4299
  forceSplitNextLeaf: false,
4248
4300
  arabicReverseNumberTyping: true,
4249
4301
  currentCharacterFont: "default",
4302
+ currentCharacterWrapper: null,
4250
4303
  currentDigitForm: "western",
4251
4304
  caret: {
4252
4305
  chainId: englishRoot.id,
@@ -4372,6 +4425,9 @@ function buildBaseNodeBody(node, digitForm = "western", side = "english") {
4372
4425
  if (cssClass) {
4373
4426
  value.classList.add(cssClass);
4374
4427
  }
4428
+ if (node.wrapperCommand === "\\boldarabic" || node.wrapperCommand === "\\mathbf") {
4429
+ value.classList.add("node-value--bold");
4430
+ }
4375
4431
  }
4376
4432
  const surfaceExpr = node.kind === "operator" ? divideOperatorSurfaceExpr(node.expr, side) : node.expr;
4377
4433
  value.textContent = surfaceExpr === "" ? "\u25A1" : formatDigits(surfaceExpr, digitForm);
@@ -5292,6 +5348,11 @@ ${BUTEX_FONT_FACE_CSS}
5292
5348
 
5293
5349
  ${CHARACTER_FONT_CSS}
5294
5350
 
5351
+ .node-value--bold {
5352
+ font-family: var(--font-display-ar, Amiri), "Noto Serif Arabic", serif;
5353
+ font-weight: 700;
5354
+ }
5355
+
5295
5356
  .chain {
5296
5357
  display: inline-flex;
5297
5358
  align-items: center;
@@ -6284,6 +6345,10 @@ function createEditorRuntime(options) {
6284
6345
  applyTransient((prev) => setCurrentCharacterFont(prev, fontId));
6285
6346
  focusInput();
6286
6347
  },
6348
+ setCurrentBoldCharacterStyle: () => {
6349
+ applyTransient((prev) => setCurrentBoldCharacterStyle(prev));
6350
+ focusInput();
6351
+ },
6287
6352
  setCurrentDigitForm: (digitForm) => {
6288
6353
  applyStructural((prev) => setCurrentDigitForm(prev, digitForm));
6289
6354
  focusInput();
@@ -7456,6 +7521,13 @@ ${MATRIX_PICKER_CSS}
7456
7521
  box-shadow: 0 0 0 3px var(--butex-focus-shadow);
7457
7522
  }
7458
7523
 
7524
+ .butex-widget .font-mode-btn--bold,
7525
+ .butex-widget .character-font-option--bold,
7526
+ .butex-widget .butex-widget__command-sheet .character-font-option--bold {
7527
+ font-family: var(--font-display-ar, Amiri), "Noto Serif Arabic", serif;
7528
+ font-weight: 700;
7529
+ }
7530
+
7459
7531
  .butex-widget .font-mode-btn--takween,
7460
7532
  .butex-widget .character-font-option--takween,
7461
7533
  .butex-widget .butex-widget__command-sheet .character-font-option--takween {
@@ -8248,6 +8320,7 @@ var BaseAstNode = class {
8248
8320
  superscript;
8249
8321
  subscript;
8250
8322
  nodeType;
8323
+ sourceLatex;
8251
8324
  constructor(state = null) {
8252
8325
  if (state === null) {
8253
8326
  state = new State();
@@ -8256,6 +8329,7 @@ var BaseAstNode = class {
8256
8329
  this.superscript = null;
8257
8330
  this.subscript = null;
8258
8331
  this.nodeType = this.constructor.name;
8332
+ this.sourceLatex = null;
8259
8333
  }
8260
8334
  latex() {
8261
8335
  throw new Error("NotImplementedError");
@@ -8444,6 +8518,7 @@ ${this.closing}`;
8444
8518
  }
8445
8519
  };
8446
8520
  function parseScripts(node, json, mode) {
8521
+ node.sourceLatex = typeof json.source_latex === "string" && json.source_latex.length > 0 ? json.source_latex : null;
8447
8522
  if (json.superscript) {
8448
8523
  node.superscript = parseChain(json.superscript, mode);
8449
8524
  }
@@ -8583,7 +8658,8 @@ function fromMathObjectJson(json, mode = "english") {
8583
8658
  function scriptsToJson(node, path) {
8584
8659
  return {
8585
8660
  ...node.superscript ? { superscript: chainToJson(node.superscript, `${path}.superscript`) } : {},
8586
- ...node.subscript ? { subscript: chainToJson(node.subscript, `${path}.subscript`) } : {}
8661
+ ...node.subscript ? { subscript: chainToJson(node.subscript, `${path}.subscript`) } : {},
8662
+ ...node.sourceLatex ? { source_latex: node.sourceLatex } : {}
8587
8663
  };
8588
8664
  }
8589
8665
  function nodeToJson(node, path) {
@@ -8719,6 +8795,10 @@ var CHAR_FONT_EXPORT_TEX = Object.fromEntries(
8719
8795
  function charEditorNodeToAstNode(node) {
8720
8796
  const font = node.characterFont ?? "default";
8721
8797
  const charNode = new CharNode(node.expr);
8798
+ if (node.wrapperCommand) {
8799
+ const wrapper = node.wrapperCommand === "\\boldarabic" ? "\\mathbf" : node.wrapperCommand;
8800
+ return new CommandNode(wrapper, [], [new ChainNode([charNode])]);
8801
+ }
8722
8802
  if (font === "default") {
8723
8803
  return charNode;
8724
8804
  }
@@ -8745,6 +8825,9 @@ function cloneChainWithFreshIds(chain) {
8745
8825
  return structuredClone(chain);
8746
8826
  }
8747
8827
  function attachScripts(astNode, editorNode) {
8828
+ if (astNode.sourceLatex) {
8829
+ editorNode.sourceLatex = astNode.sourceLatex;
8830
+ }
8748
8831
  if (astNode.superscript) {
8749
8832
  const sup = chainToEditorChain(astNode.superscript);
8750
8833
  if (!sup.editable) {
@@ -8871,6 +8954,49 @@ function charFromTextLikeCommand(node) {
8871
8954
  const scripts = attachScripts(node, editorNode);
8872
8955
  return scripts ?? { editable: true, node: editorNode };
8873
8956
  }
8957
+ function singleCommandChar(node) {
8958
+ if (node.optionalArgs.length > 0 || node.mandatoryArgs.length !== 1) {
8959
+ return null;
8960
+ }
8961
+ const arg = node.mandatoryArgs[0];
8962
+ if (arg.chain.length !== 1 || !(arg.chain[0] instanceof CharNode)) {
8963
+ return null;
8964
+ }
8965
+ return arg.chain[0];
8966
+ }
8967
+ function wrappedAtomicCommandId(node) {
8968
+ if (node.name !== "\\mathbb" && node.name !== "\\mathrm") {
8969
+ return null;
8970
+ }
8971
+ const child = singleCommandChar(node);
8972
+ if (!child) {
8973
+ return null;
8974
+ }
8975
+ return commandIdForTex(`${node.name}{${child.expr}}`);
8976
+ }
8977
+ function editableWrapperCommand(node) {
8978
+ if (node.name !== "\\mathtt" && node.name !== "\\mathsf" && node.name !== "\\unit" && node.name !== "\\mathbf" && node.name !== "\\boldarabic") {
8979
+ return null;
8980
+ }
8981
+ const child = singleCommandChar(node);
8982
+ if (!child) {
8983
+ return null;
8984
+ }
8985
+ const normalized = normalizeCharImportExpr(child.expr);
8986
+ const editorNode = createEditorNode("char", normalized.expr);
8987
+ if (normalized.characterFont !== "default") {
8988
+ editorNode.characterFont = normalized.characterFont;
8989
+ }
8990
+ editorNode.wrapperCommand = node.name === "\\mathtt" ? "\\mathtt" : node.name === "\\mathbf" ? "\\mathbf" : node.name === "\\boldarabic" ? "\\boldarabic" : "\\unit";
8991
+ const scripts = attachScripts(node, editorNode);
8992
+ if (scripts) {
8993
+ return scripts;
8994
+ }
8995
+ if (!editorNode.sourceLatex && node.name === "\\mathsf") {
8996
+ editorNode.sourceLatex = `\\mathsf{${child.expr}}`;
8997
+ }
8998
+ return { editable: true, node: editorNode };
8999
+ }
8874
9000
  function commandToEditorNode(node) {
8875
9001
  if (node.name === "\\frac" && node.mandatoryArgs.length >= 2) {
8876
9002
  const frac = createFracNode();
@@ -8960,6 +9086,19 @@ function commandToEditorNode(node) {
8960
9086
  }
8961
9087
  return { editable: true, node: accent };
8962
9088
  }
9089
+ const wrappedAtomicId = wrappedAtomicCommandId(node);
9090
+ if (wrappedAtomicId) {
9091
+ const atomic = createEditorNode("atomicCommand", wrappedAtomicId);
9092
+ const scripts = attachScripts(node, atomic);
9093
+ if (scripts) {
9094
+ return scripts;
9095
+ }
9096
+ return { editable: true, node: atomic };
9097
+ }
9098
+ const wrapper = editableWrapperCommand(node);
9099
+ if (wrapper) {
9100
+ return wrapper;
9101
+ }
8963
9102
  const atomicId = commandIdForTex(node.name);
8964
9103
  if (atomicId && node.optionalArgs.length === 0 && node.mandatoryArgs.length === 0) {
8965
9104
  const atomic = createEditorNode("atomicCommand", atomicId);
@@ -9239,7 +9378,13 @@ function editorNodeToAstNode(node) {
9239
9378
  if (!tex) {
9240
9379
  return { ok: false, reason: `\u0623\u0645\u0631 \u0631\u064A\u0627\u0636\u064A \u063A\u064A\u0631 \u0645\u062F\u0639\u0648\u0645 \u062D\u0627\u0644\u064A\u0627: ${node.expr}` };
9241
9380
  }
9242
- astNode = new CommandNode(tex);
9381
+ if (node.expr === "ad") {
9382
+ astNode = new CommandNode("\\mathrm", [], [new ChainNode([new CharNode("d")])]);
9383
+ } else if (["N", "Z", "Q", "R", "C", "H"].includes(node.expr)) {
9384
+ astNode = new CommandNode("\\mathbb", [], [new ChainNode([new CharNode(node.expr)])]);
9385
+ } else {
9386
+ astNode = new CommandNode(tex);
9387
+ }
9243
9388
  } else if (node.kind === "atomicOperatorCommand") {
9244
9389
  const tex = atomicOperatorCommandSpec(node.expr)?.Tex;
9245
9390
  if (!tex) {
@@ -9256,6 +9401,9 @@ function editorNodeToAstNode(node) {
9256
9401
  } else {
9257
9402
  return { ok: 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.kind}` };
9258
9403
  }
9404
+ if (node.sourceLatex) {
9405
+ astNode.sourceLatex = node.sourceLatex;
9406
+ }
9259
9407
  const scripts = attachAstScripts(node, astNode);
9260
9408
  return scripts ?? { ok: true, node: astNode };
9261
9409
  }
@@ -9481,6 +9629,9 @@ function alignmentTitle(alignment, messages) {
9481
9629
  if (alignment === "r") return messages.alignColumnRight;
9482
9630
  return messages.alignColumnCenter;
9483
9631
  }
9632
+ function boldCharacterStyleLabel(uiLocale) {
9633
+ return uiLocale === "ar" ? "\u0639\u0631\u064A\u0636" : "Bold";
9634
+ }
9484
9635
  function characterFontTitle(fontId, messages) {
9485
9636
  const key = characterFontSpec(fontId).titleKey;
9486
9637
  return messages[key] ?? messages.defaultFont;
@@ -9856,18 +10007,31 @@ function EquationMobileToolbar({
9856
10007
  sheetView === "typography" ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
9857
10008
  /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("section", { className: "butex-widget__sheet-section", children: [
9858
10009
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)("h4", { children: messages.chooseWritingFont }),
9859
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "butex-widget__sheet-choice-row", children: CHARACTER_FONT_OPTIONS.map((option) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
9860
- "button",
9861
- {
9862
- type: "button",
9863
- className: `character-font-option--${option.id}`,
9864
- "aria-pressed": state.characterFont === option.id,
9865
- title: characterFontTitle(option.id, messages),
9866
- onClick: (event) => runAndKeepFocus(event.currentTarget, (runtime) => runtime.setCurrentCharacterFont(option.id)),
9867
- children: option.label
9868
- },
9869
- option.id
9870
- )) })
10010
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "butex-widget__sheet-choice-row", children: [
10011
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
10012
+ "button",
10013
+ {
10014
+ type: "button",
10015
+ className: "character-font-option--bold",
10016
+ "aria-pressed": state.boldCharacterStyle,
10017
+ title: boldCharacterStyleLabel(uiLocale),
10018
+ onClick: (event) => runAndKeepFocus(event.currentTarget, (runtime) => runtime.setCurrentBoldCharacterStyle()),
10019
+ children: boldCharacterStyleLabel(uiLocale)
10020
+ }
10021
+ ),
10022
+ CHARACTER_FONT_OPTIONS.map((option) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
10023
+ "button",
10024
+ {
10025
+ type: "button",
10026
+ className: `character-font-option--${option.id}`,
10027
+ "aria-pressed": !state.boldCharacterStyle && state.characterFont === option.id,
10028
+ title: characterFontTitle(option.id, messages),
10029
+ onClick: (event) => runAndKeepFocus(event.currentTarget, (runtime) => runtime.setCurrentCharacterFont(option.id)),
10030
+ children: option.label
10031
+ },
10032
+ option.id
10033
+ ))
10034
+ ] })
9871
10035
  ] }),
9872
10036
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
9873
10037
  "button",
@@ -10187,6 +10351,9 @@ function digitFormLabel(digitForm) {
10187
10351
  function characterFontOption(fontId) {
10188
10352
  return CHARACTER_FONT_OPTIONS.find((option) => option.id === fontId) ?? CHARACTER_FONT_OPTIONS[0];
10189
10353
  }
10354
+ function boldCharacterStyleLabel2(uiLocale) {
10355
+ return uiLocale === "ar" ? "\u0639\u0631\u064A\u0636" : "Bold";
10356
+ }
10190
10357
  function characterFontTitle2(fontId, messages) {
10191
10358
  const key = characterFontSpec(fontId).titleKey;
10192
10359
  return messages[key] ?? messages.defaultFont;
@@ -10291,6 +10458,7 @@ var ButexEditor = (0, import_react4.forwardRef)(
10291
10458
  const [openDesktopMenu, setOpenDesktopMenu] = (0, import_react4.useState)(null);
10292
10459
  const [selectedDigitForm2, setSelectedDigitForm] = (0, import_react4.useState)("western");
10293
10460
  const [selectedCharacterFont, setSelectedCharacterFont] = (0, import_react4.useState)("default");
10461
+ const [boldCharacterStyle, setBoldCharacterStyle] = (0, import_react4.useState)(initialSession?.currentCharacterWrapper === "\\boldarabic");
10294
10462
  const [activeEditorSide, setActiveEditorSide] = (0, import_react4.useState)("arabic");
10295
10463
  const [compactPreviewOpen, setCompactPreviewOpen] = (0, import_react4.useState)(false);
10296
10464
  const [compactControlState, setCompactControlState] = (0, import_react4.useState)({
@@ -10443,6 +10611,7 @@ ${arabic || currentMessages.empty}`;
10443
10611
  runtimeRef.current?.setSession(next);
10444
10612
  setSelectedDigitForm(next.currentDigitForm ?? "western");
10445
10613
  setSelectedCharacterFont(next.currentCharacterFont ?? "default");
10614
+ setBoldCharacterStyle(next.currentCharacterWrapper === "\\boldarabic");
10446
10615
  setActiveEditorSide(next.activeSide);
10447
10616
  onSessionChangeRef.current?.(next);
10448
10617
  setDebugImportError("");
@@ -10484,6 +10653,7 @@ ${arabic || currentMessages.empty}`;
10484
10653
  onSessionChange: (session) => {
10485
10654
  setSelectedDigitForm(session.currentDigitForm ?? "western");
10486
10655
  setSelectedCharacterFont(session.currentCharacterFont ?? "default");
10656
+ setBoldCharacterStyle(session.currentCharacterWrapper === "\\boldarabic");
10487
10657
  setActiveEditorSide(session.activeSide);
10488
10658
  const hasSelection = Boolean(session.selection && session.selection.anchorIndex !== session.selection.focusIndex);
10489
10659
  const nextCompactState = {
@@ -10566,6 +10736,7 @@ ${arabic || currentMessages.empty}`;
10566
10736
  ...compactControlState,
10567
10737
  activeSide: activeEditorSide,
10568
10738
  characterFont: selectedCharacterFont,
10739
+ boldCharacterStyle,
10569
10740
  digitForm: selectedDigitForm2
10570
10741
  };
10571
10742
  return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
@@ -11592,35 +11763,54 @@ ${arabic || currentMessages.empty}`;
11592
11763
  {
11593
11764
  ref: characterFontBtnRef,
11594
11765
  id: "select-character-font",
11595
- className: `icon-btn font-mode-btn font-mode-btn--${selectedCharacterFont}`,
11766
+ className: `icon-btn font-mode-btn font-mode-btn--${boldCharacterStyle ? "bold" : selectedCharacterFont}`,
11596
11767
  type: "button",
11597
- title: characterFontTitle2(selectedCharacterFont, messages),
11768
+ title: boldCharacterStyle ? boldCharacterStyleLabel2(uiLocale) : characterFontTitle2(selectedCharacterFont, messages),
11598
11769
  "aria-label": messages.chooseWritingFont,
11599
11770
  "aria-haspopup": "listbox",
11600
11771
  "aria-expanded": characterFontMenuOpen,
11601
11772
  onClick: () => setCharacterFontMenuOpen((open) => !open),
11602
- children: characterFontOption(selectedCharacterFont).label
11773
+ children: boldCharacterStyle ? boldCharacterStyleLabel2(uiLocale) : characterFontOption(selectedCharacterFont).label
11603
11774
  }
11604
11775
  ),
11605
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "character-font-options", role: "listbox", "aria-label": messages.chooseWritingFont, hidden: !characterFontMenuOpen, children: CHARACTER_FONT_OPTIONS.map((option) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
11606
- "button",
11607
- {
11608
- type: "button",
11609
- role: "option",
11610
- "aria-selected": selectedCharacterFont === option.id,
11611
- className: `character-font-option character-font-option--${option.id}`,
11612
- title: characterFontTitle2(option.id, messages),
11613
- onMouseDown: (event) => event.preventDefault(),
11614
- onClick: () => {
11615
- runtimeRef.current?.setCurrentCharacterFont(option.id);
11616
- setSelectedCharacterFont(option.id);
11617
- setCharacterFontMenuOpen(false);
11618
- focusSurface();
11776
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "character-font-options", role: "listbox", "aria-label": messages.chooseWritingFont, hidden: !characterFontMenuOpen, children: [
11777
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
11778
+ "button",
11779
+ {
11780
+ type: "button",
11781
+ role: "option",
11782
+ "aria-selected": boldCharacterStyle,
11783
+ className: "character-font-option character-font-option--bold",
11784
+ title: boldCharacterStyleLabel2(uiLocale),
11785
+ onMouseDown: (event) => event.preventDefault(),
11786
+ onClick: () => {
11787
+ runtimeRef.current?.setCurrentBoldCharacterStyle();
11788
+ setCharacterFontMenuOpen(false);
11789
+ focusSurface();
11790
+ },
11791
+ children: boldCharacterStyleLabel2(uiLocale)
11792
+ }
11793
+ ),
11794
+ CHARACTER_FONT_OPTIONS.map((option) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
11795
+ "button",
11796
+ {
11797
+ type: "button",
11798
+ role: "option",
11799
+ "aria-selected": !boldCharacterStyle && selectedCharacterFont === option.id,
11800
+ className: `character-font-option character-font-option--${option.id}`,
11801
+ title: characterFontTitle2(option.id, messages),
11802
+ onMouseDown: (event) => event.preventDefault(),
11803
+ onClick: () => {
11804
+ runtimeRef.current?.setCurrentCharacterFont(option.id);
11805
+ setSelectedCharacterFont(option.id);
11806
+ setCharacterFontMenuOpen(false);
11807
+ focusSurface();
11808
+ },
11809
+ children: option.label
11619
11810
  },
11620
- children: option.label
11621
- },
11622
- option.id
11623
- )) })
11811
+ option.id
11812
+ ))
11813
+ ] })
11624
11814
  ]
11625
11815
  }
11626
11816
  ),