@drghaliasri/butex 7.2.1 → 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 +37 -2
  5. package/dist/document.js.map +1 -1
  6. package/dist/document.mjs +37 -2
  7. package/dist/document.mjs.map +1 -1
  8. package/dist/document2-cli.js +106 -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 +106 -2
  13. package/dist/document2.js.map +1 -1
  14. package/dist/document2.mjs +106 -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 +108 -11
  19. package/dist/index.global.js.map +1 -1
  20. package/dist/index.js +108 -11
  21. package/dist/index.js.map +1 -1
  22. package/dist/index.mjs +108 -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 +229 -40
  27. package/dist/react-document.js.map +1 -1
  28. package/dist/react-document.mjs +229 -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 +90 -0
  33. package/dist/react-document2-preview.js.map +1 -1
  34. package/dist/react-document2-preview.mjs +90 -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 +229 -40
  39. package/dist/react-document2.js.map +1 -1
  40. package/dist/react-document2.mjs +229 -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 +229 -40
  45. package/dist/react.js.map +1 -1
  46. package/dist/react.mjs +229 -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",
@@ -1660,6 +1671,14 @@ function renderNodeEnglish(node, options) {
1660
1671
  return `${node.expr}${latinScripts(node, options)}`;
1661
1672
  }
1662
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
+ }
1663
1682
  return `${renderCharContent(node, options)}${latinScripts(node, options)}`;
1664
1683
  }
1665
1684
  if (node.kind === "operator" && isDivideOperatorExpr(node.expr)) {
@@ -1713,6 +1732,10 @@ function renderNodeArabic(node, options) {
1713
1732
  if (node.kind === "char") {
1714
1733
  const expr = formatDigits(node.expr, selectedDigitForm(options));
1715
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
+ }
1716
1739
  return arabicScripts(node, (node.characterFont ?? "default") === "default" ? `\\text{${escapeText(expr)}}` : content, options);
1717
1740
  }
1718
1741
  if (node.kind === "operator" && isDivideOperatorExpr(node.expr)) {
@@ -2941,6 +2964,16 @@ function markExprSync(session, nodeId) {
2941
2964
  }
2942
2965
  session.sync[nodeId].expr = english.node.expr === arabic.node.expr ? "synced" : "diverged";
2943
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
+ }
2944
2977
  function syncSelectionToCaret(session) {
2945
2978
  const activeKey = activeTreeKey(session.activeSide);
2946
2979
  const tree = session[activeKey];
@@ -3524,7 +3557,10 @@ function insertLeaf(session, kind, expr) {
3524
3557
  const next = cloneEditorSession(session);
3525
3558
  const englishNode = createEditorNode(kind, expr);
3526
3559
  const arabicNode = createEditorNode(kind, expr);
3527
- 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") {
3528
3564
  englishNode.characterFont = next.currentCharacterFont;
3529
3565
  arabicNode.characterFont = next.currentCharacterFont;
3530
3566
  }
@@ -3539,8 +3575,12 @@ function insertLeaf(session, kind, expr) {
3539
3575
  function shouldReverseArabicNumber(session) {
3540
3576
  return session.activeSide === "arabic" && session.arabicReverseNumberTyping;
3541
3577
  }
3542
- function characterFontOf(node) {
3543
- 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"}`;
3544
3584
  }
3545
3585
  function tryMergeLeafTyping(session, kind, fragment) {
3546
3586
  const engLocated = findChainById(session.englishTree, session.caret.chainId);
@@ -3553,14 +3593,14 @@ function tryMergeLeafTyping(session, kind, fragment) {
3553
3593
  let prepend = false;
3554
3594
  if (i > 0) {
3555
3595
  const prev = nodes[i - 1];
3556
- if (prev.kind === kind && (kind !== "char" || characterFontOf(prev) === (session.currentCharacterFont ?? "default"))) {
3596
+ if (prev.kind === kind && (kind !== "char" || characterTypingStyleOf(prev) === currentCharacterTypingStyle(session))) {
3557
3597
  targetId = prev.id;
3558
3598
  prepend = false;
3559
3599
  }
3560
3600
  }
3561
3601
  if (!targetId && i < nodes.length) {
3562
3602
  const fwd = nodes[i];
3563
- if (fwd.kind === kind && (kind !== "char" || characterFontOf(fwd) === (session.currentCharacterFont ?? "default"))) {
3603
+ if (fwd.kind === kind && (kind !== "char" || characterTypingStyleOf(fwd) === currentCharacterTypingStyle(session))) {
3564
3604
  targetId = fwd.id;
3565
3605
  prepend = true;
3566
3606
  }
@@ -3581,6 +3621,7 @@ function tryMergeLeafTyping(session, kind, fragment) {
3581
3621
  englishHit.node.expr = `${englishHit.node.expr}${fragment}`;
3582
3622
  arabicHit.node.expr = `${arabicHit.node.expr}${fragment}`;
3583
3623
  }
3624
+ clearSourceIdentity(session, targetId);
3584
3625
  markExprSync(session, targetId);
3585
3626
  return true;
3586
3627
  }
@@ -3619,9 +3660,17 @@ function breakLeafTyping(session) {
3619
3660
  function setCurrentCharacterFont(session, fontId) {
3620
3661
  const next = cloneEditorSession(session);
3621
3662
  next.currentCharacterFont = fontId;
3663
+ next.currentCharacterWrapper = null;
3622
3664
  appendDebug(next, "setCurrentCharacterFont", fontId);
3623
3665
  return next;
3624
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
+ }
3625
3674
  function toggleTakweenCharacterFont(session) {
3626
3675
  return setCurrentCharacterFont(session, (session.currentCharacterFont ?? "default") === "takween" ? "default" : "takween");
3627
3676
  }
@@ -4170,6 +4219,7 @@ function deleteBackward(session) {
4170
4219
  englishHit.node.expr = englishHit.node.expr.slice(0, -1);
4171
4220
  arabicHit.node.expr = arabicHit.node.expr.slice(0, -1);
4172
4221
  }
4222
+ clearSourceIdentity(next, id);
4173
4223
  markExprSync(next, id);
4174
4224
  next.selectedStructureNodeId = null;
4175
4225
  syncSelectionToCaret(next);
@@ -4219,6 +4269,7 @@ function deleteForward(session) {
4219
4269
  englishHit.node.expr = englishHit.node.expr.slice(1);
4220
4270
  arabicHit.node.expr = arabicHit.node.expr.slice(1);
4221
4271
  }
4272
+ clearSourceIdentity(next, node.id);
4222
4273
  markExprSync(next, node.id);
4223
4274
  next.selectedStructureNodeId = null;
4224
4275
  syncSelectionToCaret(next);
@@ -4248,6 +4299,7 @@ function createStarterSession() {
4248
4299
  forceSplitNextLeaf: false,
4249
4300
  arabicReverseNumberTyping: true,
4250
4301
  currentCharacterFont: "default",
4302
+ currentCharacterWrapper: null,
4251
4303
  currentDigitForm: "western",
4252
4304
  caret: {
4253
4305
  chainId: englishRoot.id,
@@ -4373,6 +4425,9 @@ function buildBaseNodeBody(node, digitForm = "western", side = "english") {
4373
4425
  if (cssClass) {
4374
4426
  value.classList.add(cssClass);
4375
4427
  }
4428
+ if (node.wrapperCommand === "\\boldarabic" || node.wrapperCommand === "\\mathbf") {
4429
+ value.classList.add("node-value--bold");
4430
+ }
4376
4431
  }
4377
4432
  const surfaceExpr = node.kind === "operator" ? divideOperatorSurfaceExpr(node.expr, side) : node.expr;
4378
4433
  value.textContent = surfaceExpr === "" ? "\u25A1" : formatDigits(surfaceExpr, digitForm);
@@ -5293,6 +5348,11 @@ ${BUTEX_FONT_FACE_CSS}
5293
5348
 
5294
5349
  ${CHARACTER_FONT_CSS}
5295
5350
 
5351
+ .node-value--bold {
5352
+ font-family: var(--font-display-ar, Amiri), "Noto Serif Arabic", serif;
5353
+ font-weight: 700;
5354
+ }
5355
+
5296
5356
  .chain {
5297
5357
  display: inline-flex;
5298
5358
  align-items: center;
@@ -6285,6 +6345,10 @@ function createEditorRuntime(options) {
6285
6345
  applyTransient((prev) => setCurrentCharacterFont(prev, fontId));
6286
6346
  focusInput();
6287
6347
  },
6348
+ setCurrentBoldCharacterStyle: () => {
6349
+ applyTransient((prev) => setCurrentBoldCharacterStyle(prev));
6350
+ focusInput();
6351
+ },
6288
6352
  setCurrentDigitForm: (digitForm) => {
6289
6353
  applyStructural((prev) => setCurrentDigitForm(prev, digitForm));
6290
6354
  focusInput();
@@ -7457,6 +7521,13 @@ ${MATRIX_PICKER_CSS}
7457
7521
  box-shadow: 0 0 0 3px var(--butex-focus-shadow);
7458
7522
  }
7459
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
+
7460
7531
  .butex-widget .font-mode-btn--takween,
7461
7532
  .butex-widget .character-font-option--takween,
7462
7533
  .butex-widget .butex-widget__command-sheet .character-font-option--takween {
@@ -8249,6 +8320,7 @@ var BaseAstNode = class {
8249
8320
  superscript;
8250
8321
  subscript;
8251
8322
  nodeType;
8323
+ sourceLatex;
8252
8324
  constructor(state = null) {
8253
8325
  if (state === null) {
8254
8326
  state = new State();
@@ -8257,6 +8329,7 @@ var BaseAstNode = class {
8257
8329
  this.superscript = null;
8258
8330
  this.subscript = null;
8259
8331
  this.nodeType = this.constructor.name;
8332
+ this.sourceLatex = null;
8260
8333
  }
8261
8334
  latex() {
8262
8335
  throw new Error("NotImplementedError");
@@ -8445,6 +8518,7 @@ ${this.closing}`;
8445
8518
  }
8446
8519
  };
8447
8520
  function parseScripts(node, json, mode) {
8521
+ node.sourceLatex = typeof json.source_latex === "string" && json.source_latex.length > 0 ? json.source_latex : null;
8448
8522
  if (json.superscript) {
8449
8523
  node.superscript = parseChain(json.superscript, mode);
8450
8524
  }
@@ -8584,7 +8658,8 @@ function fromMathObjectJson(json, mode = "english") {
8584
8658
  function scriptsToJson(node, path) {
8585
8659
  return {
8586
8660
  ...node.superscript ? { superscript: chainToJson(node.superscript, `${path}.superscript`) } : {},
8587
- ...node.subscript ? { subscript: chainToJson(node.subscript, `${path}.subscript`) } : {}
8661
+ ...node.subscript ? { subscript: chainToJson(node.subscript, `${path}.subscript`) } : {},
8662
+ ...node.sourceLatex ? { source_latex: node.sourceLatex } : {}
8588
8663
  };
8589
8664
  }
8590
8665
  function nodeToJson(node, path) {
@@ -8720,6 +8795,10 @@ var CHAR_FONT_EXPORT_TEX = Object.fromEntries(
8720
8795
  function charEditorNodeToAstNode(node) {
8721
8796
  const font = node.characterFont ?? "default";
8722
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
+ }
8723
8802
  if (font === "default") {
8724
8803
  return charNode;
8725
8804
  }
@@ -8746,6 +8825,9 @@ function cloneChainWithFreshIds(chain) {
8746
8825
  return structuredClone(chain);
8747
8826
  }
8748
8827
  function attachScripts(astNode, editorNode) {
8828
+ if (astNode.sourceLatex) {
8829
+ editorNode.sourceLatex = astNode.sourceLatex;
8830
+ }
8749
8831
  if (astNode.superscript) {
8750
8832
  const sup = chainToEditorChain(astNode.superscript);
8751
8833
  if (!sup.editable) {
@@ -8872,6 +8954,49 @@ function charFromTextLikeCommand(node) {
8872
8954
  const scripts = attachScripts(node, editorNode);
8873
8955
  return scripts ?? { editable: true, node: editorNode };
8874
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
+ }
8875
9000
  function commandToEditorNode(node) {
8876
9001
  if (node.name === "\\frac" && node.mandatoryArgs.length >= 2) {
8877
9002
  const frac = createFracNode();
@@ -8961,6 +9086,19 @@ function commandToEditorNode(node) {
8961
9086
  }
8962
9087
  return { editable: true, node: accent };
8963
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
+ }
8964
9102
  const atomicId = commandIdForTex(node.name);
8965
9103
  if (atomicId && node.optionalArgs.length === 0 && node.mandatoryArgs.length === 0) {
8966
9104
  const atomic = createEditorNode("atomicCommand", atomicId);
@@ -9240,7 +9378,13 @@ function editorNodeToAstNode(node) {
9240
9378
  if (!tex) {
9241
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}` };
9242
9380
  }
9243
- 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
+ }
9244
9388
  } else if (node.kind === "atomicOperatorCommand") {
9245
9389
  const tex = atomicOperatorCommandSpec(node.expr)?.Tex;
9246
9390
  if (!tex) {
@@ -9257,6 +9401,9 @@ function editorNodeToAstNode(node) {
9257
9401
  } else {
9258
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}` };
9259
9403
  }
9404
+ if (node.sourceLatex) {
9405
+ astNode.sourceLatex = node.sourceLatex;
9406
+ }
9260
9407
  const scripts = attachAstScripts(node, astNode);
9261
9408
  return scripts ?? { ok: true, node: astNode };
9262
9409
  }
@@ -9482,6 +9629,9 @@ function alignmentTitle(alignment, messages) {
9482
9629
  if (alignment === "r") return messages.alignColumnRight;
9483
9630
  return messages.alignColumnCenter;
9484
9631
  }
9632
+ function boldCharacterStyleLabel(uiLocale) {
9633
+ return uiLocale === "ar" ? "\u0639\u0631\u064A\u0636" : "Bold";
9634
+ }
9485
9635
  function characterFontTitle(fontId, messages) {
9486
9636
  const key = characterFontSpec(fontId).titleKey;
9487
9637
  return messages[key] ?? messages.defaultFont;
@@ -9857,18 +10007,31 @@ function EquationMobileToolbar({
9857
10007
  sheetView === "typography" ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
9858
10008
  /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("section", { className: "butex-widget__sheet-section", children: [
9859
10009
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)("h4", { children: messages.chooseWritingFont }),
9860
- /* @__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)(
9861
- "button",
9862
- {
9863
- type: "button",
9864
- className: `character-font-option--${option.id}`,
9865
- "aria-pressed": state.characterFont === option.id,
9866
- title: characterFontTitle(option.id, messages),
9867
- onClick: (event) => runAndKeepFocus(event.currentTarget, (runtime) => runtime.setCurrentCharacterFont(option.id)),
9868
- children: option.label
9869
- },
9870
- option.id
9871
- )) })
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
+ ] })
9872
10035
  ] }),
9873
10036
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
9874
10037
  "button",
@@ -10188,6 +10351,9 @@ function digitFormLabel(digitForm) {
10188
10351
  function characterFontOption(fontId) {
10189
10352
  return CHARACTER_FONT_OPTIONS.find((option) => option.id === fontId) ?? CHARACTER_FONT_OPTIONS[0];
10190
10353
  }
10354
+ function boldCharacterStyleLabel2(uiLocale) {
10355
+ return uiLocale === "ar" ? "\u0639\u0631\u064A\u0636" : "Bold";
10356
+ }
10191
10357
  function characterFontTitle2(fontId, messages) {
10192
10358
  const key = characterFontSpec(fontId).titleKey;
10193
10359
  return messages[key] ?? messages.defaultFont;
@@ -10292,6 +10458,7 @@ var ButexEditor = (0, import_react4.forwardRef)(
10292
10458
  const [openDesktopMenu, setOpenDesktopMenu] = (0, import_react4.useState)(null);
10293
10459
  const [selectedDigitForm2, setSelectedDigitForm] = (0, import_react4.useState)("western");
10294
10460
  const [selectedCharacterFont, setSelectedCharacterFont] = (0, import_react4.useState)("default");
10461
+ const [boldCharacterStyle, setBoldCharacterStyle] = (0, import_react4.useState)(initialSession?.currentCharacterWrapper === "\\boldarabic");
10295
10462
  const [activeEditorSide, setActiveEditorSide] = (0, import_react4.useState)("arabic");
10296
10463
  const [compactPreviewOpen, setCompactPreviewOpen] = (0, import_react4.useState)(false);
10297
10464
  const [compactControlState, setCompactControlState] = (0, import_react4.useState)({
@@ -10444,6 +10611,7 @@ ${arabic || currentMessages.empty}`;
10444
10611
  runtimeRef.current?.setSession(next);
10445
10612
  setSelectedDigitForm(next.currentDigitForm ?? "western");
10446
10613
  setSelectedCharacterFont(next.currentCharacterFont ?? "default");
10614
+ setBoldCharacterStyle(next.currentCharacterWrapper === "\\boldarabic");
10447
10615
  setActiveEditorSide(next.activeSide);
10448
10616
  onSessionChangeRef.current?.(next);
10449
10617
  setDebugImportError("");
@@ -10485,6 +10653,7 @@ ${arabic || currentMessages.empty}`;
10485
10653
  onSessionChange: (session) => {
10486
10654
  setSelectedDigitForm(session.currentDigitForm ?? "western");
10487
10655
  setSelectedCharacterFont(session.currentCharacterFont ?? "default");
10656
+ setBoldCharacterStyle(session.currentCharacterWrapper === "\\boldarabic");
10488
10657
  setActiveEditorSide(session.activeSide);
10489
10658
  const hasSelection = Boolean(session.selection && session.selection.anchorIndex !== session.selection.focusIndex);
10490
10659
  const nextCompactState = {
@@ -10567,6 +10736,7 @@ ${arabic || currentMessages.empty}`;
10567
10736
  ...compactControlState,
10568
10737
  activeSide: activeEditorSide,
10569
10738
  characterFont: selectedCharacterFont,
10739
+ boldCharacterStyle,
10570
10740
  digitForm: selectedDigitForm2
10571
10741
  };
10572
10742
  return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
@@ -11593,35 +11763,54 @@ ${arabic || currentMessages.empty}`;
11593
11763
  {
11594
11764
  ref: characterFontBtnRef,
11595
11765
  id: "select-character-font",
11596
- className: `icon-btn font-mode-btn font-mode-btn--${selectedCharacterFont}`,
11766
+ className: `icon-btn font-mode-btn font-mode-btn--${boldCharacterStyle ? "bold" : selectedCharacterFont}`,
11597
11767
  type: "button",
11598
- title: characterFontTitle2(selectedCharacterFont, messages),
11768
+ title: boldCharacterStyle ? boldCharacterStyleLabel2(uiLocale) : characterFontTitle2(selectedCharacterFont, messages),
11599
11769
  "aria-label": messages.chooseWritingFont,
11600
11770
  "aria-haspopup": "listbox",
11601
11771
  "aria-expanded": characterFontMenuOpen,
11602
11772
  onClick: () => setCharacterFontMenuOpen((open) => !open),
11603
- children: characterFontOption(selectedCharacterFont).label
11773
+ children: boldCharacterStyle ? boldCharacterStyleLabel2(uiLocale) : characterFontOption(selectedCharacterFont).label
11604
11774
  }
11605
11775
  ),
11606
- /* @__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)(
11607
- "button",
11608
- {
11609
- type: "button",
11610
- role: "option",
11611
- "aria-selected": selectedCharacterFont === option.id,
11612
- className: `character-font-option character-font-option--${option.id}`,
11613
- title: characterFontTitle2(option.id, messages),
11614
- onMouseDown: (event) => event.preventDefault(),
11615
- onClick: () => {
11616
- runtimeRef.current?.setCurrentCharacterFont(option.id);
11617
- setSelectedCharacterFont(option.id);
11618
- setCharacterFontMenuOpen(false);
11619
- 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
11620
11810
  },
11621
- children: option.label
11622
- },
11623
- option.id
11624
- )) })
11811
+ option.id
11812
+ ))
11813
+ ] })
11625
11814
  ]
11626
11815
  }
11627
11816
  ),