@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
@@ -19,6 +19,10 @@ type EditorNode = {
19
19
  kind: EditorNodeKind;
20
20
  expr: string;
21
21
  characterFont?: CharacterFontId;
22
+ /** Minimal upstream source identity used only while the node remains unchanged. */
23
+ sourceLatex?: string;
24
+ /** Existing editor node reused for wrapper commands that need editable content. */
25
+ wrapperCommand?: '\\unit' | '\\mathtt' | '\\mathbf' | '\\boldarabic';
22
26
  superscript: EditorChain | null;
23
27
  subscript: EditorChain | null;
24
28
  leftDelimExpr: string;
@@ -70,6 +74,8 @@ type EditorSession = {
70
74
  arabicReverseNumberTyping: boolean;
71
75
  /** Font applied to newly typed char nodes. */
72
76
  currentCharacterFont: CharacterFontId;
77
+ /** Structured command wrapper applied to newly typed chars; kept separate from fonts. */
78
+ currentCharacterWrapper: '\\boldarabic' | null;
73
79
  /** Digit glyph form used for editor display and LaTeX preview output. */
74
80
  currentDigitForm: DigitFormId;
75
81
  caret: EditorCaret;
@@ -97,6 +103,7 @@ type ArabicNodeJson = {
97
103
  opening?: string;
98
104
  closing?: string;
99
105
  lines?: ChainJson[];
106
+ source_latex?: string;
100
107
  };
101
108
  type ChainJson = {
102
109
  node_type: 'ChainClass';
@@ -109,6 +116,7 @@ declare class BaseAstNode {
109
116
  superscript: ChainNode | null;
110
117
  subscript: ChainNode | null;
111
118
  nodeType: string;
119
+ sourceLatex: string | null;
112
120
  constructor(state?: State | null);
113
121
  latex(): string;
114
122
  arabicLatex(): string;
@@ -19,6 +19,10 @@ type EditorNode = {
19
19
  kind: EditorNodeKind;
20
20
  expr: string;
21
21
  characterFont?: CharacterFontId;
22
+ /** Minimal upstream source identity used only while the node remains unchanged. */
23
+ sourceLatex?: string;
24
+ /** Existing editor node reused for wrapper commands that need editable content. */
25
+ wrapperCommand?: '\\unit' | '\\mathtt' | '\\mathbf' | '\\boldarabic';
22
26
  superscript: EditorChain | null;
23
27
  subscript: EditorChain | null;
24
28
  leftDelimExpr: string;
@@ -70,6 +74,8 @@ type EditorSession = {
70
74
  arabicReverseNumberTyping: boolean;
71
75
  /** Font applied to newly typed char nodes. */
72
76
  currentCharacterFont: CharacterFontId;
77
+ /** Structured command wrapper applied to newly typed chars; kept separate from fonts. */
78
+ currentCharacterWrapper: '\\boldarabic' | null;
73
79
  /** Digit glyph form used for editor display and LaTeX preview output. */
74
80
  currentDigitForm: DigitFormId;
75
81
  caret: EditorCaret;
@@ -97,6 +103,7 @@ type ArabicNodeJson = {
97
103
  opening?: string;
98
104
  closing?: string;
99
105
  lines?: ChainJson[];
106
+ source_latex?: string;
100
107
  };
101
108
  type ChainJson = {
102
109
  node_type: 'ChainClass';
@@ -109,6 +116,7 @@ declare class BaseAstNode {
109
116
  superscript: ChainNode | null;
110
117
  subscript: ChainNode | null;
111
118
  nodeType: string;
119
+ sourceLatex: string | null;
112
120
  constructor(state?: State | null);
113
121
  latex(): string;
114
122
  arabicLatex(): string;
@@ -410,6 +410,7 @@ var BaseAstNode = class {
410
410
  superscript;
411
411
  subscript;
412
412
  nodeType;
413
+ sourceLatex;
413
414
  constructor(state = null) {
414
415
  if (state === null) {
415
416
  state = new State();
@@ -418,6 +419,7 @@ var BaseAstNode = class {
418
419
  this.superscript = null;
419
420
  this.subscript = null;
420
421
  this.nodeType = this.constructor.name;
422
+ this.sourceLatex = null;
421
423
  }
422
424
  latex() {
423
425
  throw new Error("NotImplementedError");
@@ -606,6 +608,7 @@ ${this.closing}`;
606
608
  }
607
609
  };
608
610
  function parseScripts(node, json, mode) {
611
+ node.sourceLatex = typeof json.source_latex === "string" && json.source_latex.length > 0 ? json.source_latex : null;
609
612
  if (json.superscript) {
610
613
  node.superscript = parseChain(json.superscript, mode);
611
614
  }
@@ -745,7 +748,8 @@ function fromMathObjectJson(json, mode = "english") {
745
748
  function scriptsToJson(node, path) {
746
749
  return {
747
750
  ...node.superscript ? { superscript: chainToJson(node.superscript, `${path}.superscript`) } : {},
748
- ...node.subscript ? { subscript: chainToJson(node.subscript, `${path}.subscript`) } : {}
751
+ ...node.subscript ? { subscript: chainToJson(node.subscript, `${path}.subscript`) } : {},
752
+ ...node.sourceLatex ? { source_latex: node.sourceLatex } : {}
749
753
  };
750
754
  }
751
755
  function nodeToJson(node, path) {
@@ -2223,6 +2227,15 @@ var ATOMIC_OPERATOR_COMMANDS = {
2223
2227
  title: "\u0627\u0644\u0644\u0627\u0646\u0647\u0627\u064A\u0629",
2224
2228
  svg_path: null
2225
2229
  },
2230
+ top: {
2231
+ id: "top",
2232
+ category: "operators1",
2233
+ Tex: "\\top",
2234
+ mirror: false,
2235
+ Label: "\u22A4",
2236
+ title: "\u0627\u0644\u0645\u0646\u0642\u0648\u0644",
2237
+ svg_path: null
2238
+ },
2226
2239
  times: {
2227
2240
  id: "times",
2228
2241
  category: "operators1",
@@ -3003,6 +3016,7 @@ function cloneEditorSession(session) {
3003
3016
  forceSplitNextLeaf: session.forceSplitNextLeaf,
3004
3017
  arabicReverseNumberTyping: session.arabicReverseNumberTyping,
3005
3018
  currentCharacterFont: session.currentCharacterFont ?? "default",
3019
+ currentCharacterWrapper: session.currentCharacterWrapper ?? null,
3006
3020
  currentDigitForm: session.currentDigitForm ?? "western",
3007
3021
  caret: { ...session.caret },
3008
3022
  selection: session.selection ? { ...session.selection } : null,
@@ -3075,6 +3089,7 @@ function createEditorSession(englishTree, arabicTree, activeSide = "arabic") {
3075
3089
  forceSplitNextLeaf: false,
3076
3090
  arabicReverseNumberTyping: true,
3077
3091
  currentCharacterFont: "default",
3092
+ currentCharacterWrapper: null,
3078
3093
  currentDigitForm: "western",
3079
3094
  caret: {
3080
3095
  chainId: englishTree.id,
@@ -3144,6 +3159,7 @@ var CHARACTER_FONT_SPECS = [
3144
3159
  latexFontCommand: "\\maghribi",
3145
3160
  latexFontFamily: "Almaghribi Warsh Quran",
3146
3161
  browserFontStack: '"Almaghribi Warsh Quran", Amiri, "Segoe UI", Tahoma, sans-serif',
3162
+ importAliases: ["\\maghribi"],
3147
3163
  svgLayoutKey: "maghribi"
3148
3164
  }
3149
3165
  ];
@@ -3316,6 +3332,14 @@ function renderNodeEnglish(node, options) {
3316
3332
  return `${node.expr}${latinScripts(node, options)}`;
3317
3333
  }
3318
3334
  if (node.kind === "char") {
3335
+ if (node.sourceLatex) {
3336
+ return `${node.sourceLatex}${latinScripts(node, options)}`;
3337
+ }
3338
+ if (node.wrapperCommand) {
3339
+ const expr = formatDigits(node.expr, selectedDigitForm(options));
3340
+ const wrapper = node.wrapperCommand === "\\boldarabic" ? "\\mathbf" : node.wrapperCommand;
3341
+ return `${wrapper}{${escapeText(expr)}}${latinScripts(node, options)}`;
3342
+ }
3319
3343
  return `${renderCharContent(node, options)}${latinScripts(node, options)}`;
3320
3344
  }
3321
3345
  if (node.kind === "operator" && isDivideOperatorExpr(node.expr)) {
@@ -3369,6 +3393,10 @@ function renderNodeArabic(node, options) {
3369
3393
  if (node.kind === "char") {
3370
3394
  const expr = formatDigits(node.expr, selectedDigitForm(options));
3371
3395
  const content = renderCharContent(node, options);
3396
+ if (node.wrapperCommand) {
3397
+ const wrapper = node.wrapperCommand === "\\mathbf" ? "\\boldarabic" : node.wrapperCommand;
3398
+ return arabicScripts(node, `${wrapper}{${content}}`, options);
3399
+ }
3372
3400
  return arabicScripts(node, (node.characterFont ?? "default") === "default" ? `\\text{${escapeText(expr)}}` : content, options);
3373
3401
  }
3374
3402
  if (node.kind === "operator" && isDivideOperatorExpr(node.expr)) {
@@ -4597,6 +4625,16 @@ function markExprSync(session, nodeId) {
4597
4625
  }
4598
4626
  session.sync[nodeId].expr = english.node.expr === arabic.node.expr ? "synced" : "diverged";
4599
4627
  }
4628
+ function clearSourceIdentity(session, nodeId) {
4629
+ const english = findNodeById(session.englishTree, nodeId);
4630
+ const arabic = findNodeById(session.arabicTree, nodeId);
4631
+ if (english) {
4632
+ delete english.node.sourceLatex;
4633
+ }
4634
+ if (arabic) {
4635
+ delete arabic.node.sourceLatex;
4636
+ }
4637
+ }
4600
4638
  function syncSelectionToCaret(session) {
4601
4639
  const activeKey = activeTreeKey(session.activeSide);
4602
4640
  const tree = session[activeKey];
@@ -5180,7 +5218,10 @@ function insertLeaf(session, kind, expr) {
5180
5218
  const next = cloneEditorSession(session);
5181
5219
  const englishNode = createEditorNode(kind, expr);
5182
5220
  const arabicNode = createEditorNode(kind, expr);
5183
- if (kind === "char" && (next.currentCharacterFont ?? "default") !== "default") {
5221
+ if (kind === "char" && next.currentCharacterWrapper === "\\boldarabic") {
5222
+ englishNode.wrapperCommand = "\\boldarabic";
5223
+ arabicNode.wrapperCommand = "\\boldarabic";
5224
+ } else if (kind === "char" && (next.currentCharacterFont ?? "default") !== "default") {
5184
5225
  englishNode.characterFont = next.currentCharacterFont;
5185
5226
  arabicNode.characterFont = next.currentCharacterFont;
5186
5227
  }
@@ -5195,8 +5236,12 @@ function insertLeaf(session, kind, expr) {
5195
5236
  function shouldReverseArabicNumber(session) {
5196
5237
  return session.activeSide === "arabic" && session.arabicReverseNumberTyping;
5197
5238
  }
5198
- function characterFontOf(node) {
5199
- return node.kind === "char" ? node.characterFont ?? "default" : "default";
5239
+ function characterTypingStyleOf(node) {
5240
+ if (node.kind !== "char") return "none";
5241
+ return node.wrapperCommand ? `wrapper:${node.wrapperCommand}` : `font:${node.characterFont ?? "default"}`;
5242
+ }
5243
+ function currentCharacterTypingStyle(session) {
5244
+ return session.currentCharacterWrapper ? `wrapper:${session.currentCharacterWrapper}` : `font:${session.currentCharacterFont ?? "default"}`;
5200
5245
  }
5201
5246
  function tryMergeLeafTyping(session, kind, fragment) {
5202
5247
  const engLocated = findChainById(session.englishTree, session.caret.chainId);
@@ -5209,14 +5254,14 @@ function tryMergeLeafTyping(session, kind, fragment) {
5209
5254
  let prepend = false;
5210
5255
  if (i > 0) {
5211
5256
  const prev = nodes[i - 1];
5212
- if (prev.kind === kind && (kind !== "char" || characterFontOf(prev) === (session.currentCharacterFont ?? "default"))) {
5257
+ if (prev.kind === kind && (kind !== "char" || characterTypingStyleOf(prev) === currentCharacterTypingStyle(session))) {
5213
5258
  targetId = prev.id;
5214
5259
  prepend = false;
5215
5260
  }
5216
5261
  }
5217
5262
  if (!targetId && i < nodes.length) {
5218
5263
  const fwd = nodes[i];
5219
- if (fwd.kind === kind && (kind !== "char" || characterFontOf(fwd) === (session.currentCharacterFont ?? "default"))) {
5264
+ if (fwd.kind === kind && (kind !== "char" || characterTypingStyleOf(fwd) === currentCharacterTypingStyle(session))) {
5220
5265
  targetId = fwd.id;
5221
5266
  prepend = true;
5222
5267
  }
@@ -5237,6 +5282,7 @@ function tryMergeLeafTyping(session, kind, fragment) {
5237
5282
  englishHit.node.expr = `${englishHit.node.expr}${fragment}`;
5238
5283
  arabicHit.node.expr = `${arabicHit.node.expr}${fragment}`;
5239
5284
  }
5285
+ clearSourceIdentity(session, targetId);
5240
5286
  markExprSync(session, targetId);
5241
5287
  return true;
5242
5288
  }
@@ -5275,9 +5321,17 @@ function breakLeafTyping(session) {
5275
5321
  function setCurrentCharacterFont(session, fontId) {
5276
5322
  const next = cloneEditorSession(session);
5277
5323
  next.currentCharacterFont = fontId;
5324
+ next.currentCharacterWrapper = null;
5278
5325
  appendDebug(next, "setCurrentCharacterFont", fontId);
5279
5326
  return next;
5280
5327
  }
5328
+ function setCurrentBoldCharacterStyle(session) {
5329
+ const next = cloneEditorSession(session);
5330
+ next.currentCharacterFont = "default";
5331
+ next.currentCharacterWrapper = "\\boldarabic";
5332
+ appendDebug(next, "setCurrentBoldCharacterStyle", "\\boldarabic");
5333
+ return next;
5334
+ }
5281
5335
  function toggleTakweenCharacterFont(session) {
5282
5336
  return setCurrentCharacterFont(session, (session.currentCharacterFont ?? "default") === "takween" ? "default" : "takween");
5283
5337
  }
@@ -5826,6 +5880,7 @@ function deleteBackward(session) {
5826
5880
  englishHit.node.expr = englishHit.node.expr.slice(0, -1);
5827
5881
  arabicHit.node.expr = arabicHit.node.expr.slice(0, -1);
5828
5882
  }
5883
+ clearSourceIdentity(next, id);
5829
5884
  markExprSync(next, id);
5830
5885
  next.selectedStructureNodeId = null;
5831
5886
  syncSelectionToCaret(next);
@@ -5875,6 +5930,7 @@ function deleteForward(session) {
5875
5930
  englishHit.node.expr = englishHit.node.expr.slice(1);
5876
5931
  arabicHit.node.expr = arabicHit.node.expr.slice(1);
5877
5932
  }
5933
+ clearSourceIdentity(next, node.id);
5878
5934
  markExprSync(next, node.id);
5879
5935
  next.selectedStructureNodeId = null;
5880
5936
  syncSelectionToCaret(next);
@@ -5904,6 +5960,7 @@ function createStarterSession() {
5904
5960
  forceSplitNextLeaf: false,
5905
5961
  arabicReverseNumberTyping: true,
5906
5962
  currentCharacterFont: "default",
5963
+ currentCharacterWrapper: null,
5907
5964
  currentDigitForm: "western",
5908
5965
  caret: {
5909
5966
  chainId: englishRoot.id,
@@ -6029,6 +6086,9 @@ function buildBaseNodeBody(node, digitForm = "western", side = "english") {
6029
6086
  if (cssClass) {
6030
6087
  value.classList.add(cssClass);
6031
6088
  }
6089
+ if (node.wrapperCommand === "\\boldarabic" || node.wrapperCommand === "\\mathbf") {
6090
+ value.classList.add("node-value--bold");
6091
+ }
6032
6092
  }
6033
6093
  const surfaceExpr = node.kind === "operator" ? divideOperatorSurfaceExpr(node.expr, side) : node.expr;
6034
6094
  value.textContent = surfaceExpr === "" ? "\u25A1" : formatDigits(surfaceExpr, digitForm);
@@ -6949,6 +7009,11 @@ ${BUTEX_FONT_FACE_CSS}
6949
7009
 
6950
7010
  ${CHARACTER_FONT_CSS}
6951
7011
 
7012
+ .node-value--bold {
7013
+ font-family: var(--font-display-ar, Amiri), "Noto Serif Arabic", serif;
7014
+ font-weight: 700;
7015
+ }
7016
+
6952
7017
  .chain {
6953
7018
  display: inline-flex;
6954
7019
  align-items: center;
@@ -7941,6 +8006,10 @@ function createEditorRuntime(options) {
7941
8006
  applyTransient((prev) => setCurrentCharacterFont(prev, fontId));
7942
8007
  focusInput();
7943
8008
  },
8009
+ setCurrentBoldCharacterStyle: () => {
8010
+ applyTransient((prev) => setCurrentBoldCharacterStyle(prev));
8011
+ focusInput();
8012
+ },
7944
8013
  setCurrentDigitForm: (digitForm) => {
7945
8014
  applyStructural((prev) => setCurrentDigitForm(prev, digitForm));
7946
8015
  focusInput();
@@ -8136,6 +8205,10 @@ var CHAR_FONT_EXPORT_TEX = Object.fromEntries(
8136
8205
  function charEditorNodeToAstNode(node) {
8137
8206
  const font = node.characterFont ?? "default";
8138
8207
  const charNode = new CharNode(node.expr);
8208
+ if (node.wrapperCommand) {
8209
+ const wrapper = node.wrapperCommand === "\\boldarabic" ? "\\mathbf" : node.wrapperCommand;
8210
+ return new CommandNode(wrapper, [], [new ChainNode([charNode])]);
8211
+ }
8139
8212
  if (font === "default") {
8140
8213
  return charNode;
8141
8214
  }
@@ -8162,6 +8235,9 @@ function cloneChainWithFreshIds(chain) {
8162
8235
  return structuredClone(chain);
8163
8236
  }
8164
8237
  function attachScripts(astNode, editorNode) {
8238
+ if (astNode.sourceLatex) {
8239
+ editorNode.sourceLatex = astNode.sourceLatex;
8240
+ }
8165
8241
  if (astNode.superscript) {
8166
8242
  const sup = chainToEditorChain(astNode.superscript);
8167
8243
  if (!sup.editable) {
@@ -8288,6 +8364,49 @@ function charFromTextLikeCommand(node) {
8288
8364
  const scripts = attachScripts(node, editorNode);
8289
8365
  return scripts ?? { editable: true, node: editorNode };
8290
8366
  }
8367
+ function singleCommandChar(node) {
8368
+ if (node.optionalArgs.length > 0 || node.mandatoryArgs.length !== 1) {
8369
+ return null;
8370
+ }
8371
+ const arg = node.mandatoryArgs[0];
8372
+ if (arg.chain.length !== 1 || !(arg.chain[0] instanceof CharNode)) {
8373
+ return null;
8374
+ }
8375
+ return arg.chain[0];
8376
+ }
8377
+ function wrappedAtomicCommandId(node) {
8378
+ if (node.name !== "\\mathbb" && node.name !== "\\mathrm") {
8379
+ return null;
8380
+ }
8381
+ const child = singleCommandChar(node);
8382
+ if (!child) {
8383
+ return null;
8384
+ }
8385
+ return commandIdForTex(`${node.name}{${child.expr}}`);
8386
+ }
8387
+ function editableWrapperCommand(node) {
8388
+ if (node.name !== "\\mathtt" && node.name !== "\\mathsf" && node.name !== "\\unit" && node.name !== "\\mathbf" && node.name !== "\\boldarabic") {
8389
+ return null;
8390
+ }
8391
+ const child = singleCommandChar(node);
8392
+ if (!child) {
8393
+ return null;
8394
+ }
8395
+ const normalized = normalizeCharImportExpr(child.expr);
8396
+ const editorNode = createEditorNode("char", normalized.expr);
8397
+ if (normalized.characterFont !== "default") {
8398
+ editorNode.characterFont = normalized.characterFont;
8399
+ }
8400
+ editorNode.wrapperCommand = node.name === "\\mathtt" ? "\\mathtt" : node.name === "\\mathbf" ? "\\mathbf" : node.name === "\\boldarabic" ? "\\boldarabic" : "\\unit";
8401
+ const scripts = attachScripts(node, editorNode);
8402
+ if (scripts) {
8403
+ return scripts;
8404
+ }
8405
+ if (!editorNode.sourceLatex && node.name === "\\mathsf") {
8406
+ editorNode.sourceLatex = `\\mathsf{${child.expr}}`;
8407
+ }
8408
+ return { editable: true, node: editorNode };
8409
+ }
8291
8410
  function commandToEditorNode(node) {
8292
8411
  if (node.name === "\\frac" && node.mandatoryArgs.length >= 2) {
8293
8412
  const frac = createFracNode();
@@ -8377,6 +8496,19 @@ function commandToEditorNode(node) {
8377
8496
  }
8378
8497
  return { editable: true, node: accent };
8379
8498
  }
8499
+ const wrappedAtomicId = wrappedAtomicCommandId(node);
8500
+ if (wrappedAtomicId) {
8501
+ const atomic = createEditorNode("atomicCommand", wrappedAtomicId);
8502
+ const scripts = attachScripts(node, atomic);
8503
+ if (scripts) {
8504
+ return scripts;
8505
+ }
8506
+ return { editable: true, node: atomic };
8507
+ }
8508
+ const wrapper = editableWrapperCommand(node);
8509
+ if (wrapper) {
8510
+ return wrapper;
8511
+ }
8380
8512
  const atomicId = commandIdForTex(node.name);
8381
8513
  if (atomicId && node.optionalArgs.length === 0 && node.mandatoryArgs.length === 0) {
8382
8514
  const atomic = createEditorNode("atomicCommand", atomicId);
@@ -8656,7 +8788,13 @@ function editorNodeToAstNode(node) {
8656
8788
  if (!tex) {
8657
8789
  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}` };
8658
8790
  }
8659
- astNode = new CommandNode(tex);
8791
+ if (node.expr === "ad") {
8792
+ astNode = new CommandNode("\\mathrm", [], [new ChainNode([new CharNode("d")])]);
8793
+ } else if (["N", "Z", "Q", "R", "C", "H"].includes(node.expr)) {
8794
+ astNode = new CommandNode("\\mathbb", [], [new ChainNode([new CharNode(node.expr)])]);
8795
+ } else {
8796
+ astNode = new CommandNode(tex);
8797
+ }
8660
8798
  } else if (node.kind === "atomicOperatorCommand") {
8661
8799
  const tex = atomicOperatorCommandSpec(node.expr)?.Tex;
8662
8800
  if (!tex) {
@@ -8673,6 +8811,9 @@ function editorNodeToAstNode(node) {
8673
8811
  } else {
8674
8812
  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}` };
8675
8813
  }
8814
+ if (node.sourceLatex) {
8815
+ astNode.sourceLatex = node.sourceLatex;
8816
+ }
8676
8817
  const scripts = attachAstScripts(node, astNode);
8677
8818
  return scripts ?? { ok: true, node: astNode };
8678
8819
  }
@@ -14834,6 +14975,13 @@ ${MATRIX_PICKER_CSS}
14834
14975
  box-shadow: 0 0 0 3px var(--butex-focus-shadow);
14835
14976
  }
14836
14977
 
14978
+ .butex-widget .font-mode-btn--bold,
14979
+ .butex-widget .character-font-option--bold,
14980
+ .butex-widget .butex-widget__command-sheet .character-font-option--bold {
14981
+ font-family: var(--font-display-ar, Amiri), "Noto Serif Arabic", serif;
14982
+ font-weight: 700;
14983
+ }
14984
+
14837
14985
  .butex-widget .font-mode-btn--takween,
14838
14986
  .butex-widget .character-font-option--takween,
14839
14987
  .butex-widget .butex-widget__command-sheet .character-font-option--takween {
@@ -15663,6 +15811,9 @@ function alignmentTitle(alignment, messages) {
15663
15811
  if (alignment === "r") return messages.alignColumnRight;
15664
15812
  return messages.alignColumnCenter;
15665
15813
  }
15814
+ function boldCharacterStyleLabel(uiLocale) {
15815
+ return uiLocale === "ar" ? "\u0639\u0631\u064A\u0636" : "Bold";
15816
+ }
15666
15817
  function characterFontTitle(fontId, messages) {
15667
15818
  const key = characterFontSpec(fontId).titleKey;
15668
15819
  return messages[key] ?? messages.defaultFont;
@@ -16038,18 +16189,31 @@ function EquationMobileToolbar({
16038
16189
  sheetView === "typography" ? /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_jsx_runtime13.Fragment, { children: [
16039
16190
  /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("section", { className: "butex-widget__sheet-section", children: [
16040
16191
  /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("h4", { children: messages.chooseWritingFont }),
16041
- /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: "butex-widget__sheet-choice-row", children: CHARACTER_FONT_OPTIONS.map((option) => /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
16042
- "button",
16043
- {
16044
- type: "button",
16045
- className: `character-font-option--${option.id}`,
16046
- "aria-pressed": state.characterFont === option.id,
16047
- title: characterFontTitle(option.id, messages),
16048
- onClick: (event) => runAndKeepFocus(event.currentTarget, (runtime) => runtime.setCurrentCharacterFont(option.id)),
16049
- children: option.label
16050
- },
16051
- option.id
16052
- )) })
16192
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "butex-widget__sheet-choice-row", children: [
16193
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
16194
+ "button",
16195
+ {
16196
+ type: "button",
16197
+ className: "character-font-option--bold",
16198
+ "aria-pressed": state.boldCharacterStyle,
16199
+ title: boldCharacterStyleLabel(uiLocale),
16200
+ onClick: (event) => runAndKeepFocus(event.currentTarget, (runtime) => runtime.setCurrentBoldCharacterStyle()),
16201
+ children: boldCharacterStyleLabel(uiLocale)
16202
+ }
16203
+ ),
16204
+ CHARACTER_FONT_OPTIONS.map((option) => /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
16205
+ "button",
16206
+ {
16207
+ type: "button",
16208
+ className: `character-font-option--${option.id}`,
16209
+ "aria-pressed": !state.boldCharacterStyle && state.characterFont === option.id,
16210
+ title: characterFontTitle(option.id, messages),
16211
+ onClick: (event) => runAndKeepFocus(event.currentTarget, (runtime) => runtime.setCurrentCharacterFont(option.id)),
16212
+ children: option.label
16213
+ },
16214
+ option.id
16215
+ ))
16216
+ ] })
16053
16217
  ] }),
16054
16218
  /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
16055
16219
  "button",
@@ -16369,6 +16533,9 @@ function digitFormLabel3(digitForm) {
16369
16533
  function characterFontOption(fontId) {
16370
16534
  return CHARACTER_FONT_OPTIONS.find((option) => option.id === fontId) ?? CHARACTER_FONT_OPTIONS[0];
16371
16535
  }
16536
+ function boldCharacterStyleLabel2(uiLocale) {
16537
+ return uiLocale === "ar" ? "\u0639\u0631\u064A\u0636" : "Bold";
16538
+ }
16372
16539
  function characterFontTitle2(fontId, messages) {
16373
16540
  const key = characterFontSpec(fontId).titleKey;
16374
16541
  return messages[key] ?? messages.defaultFont;
@@ -16473,6 +16640,7 @@ var ButexEditor = (0, import_react12.forwardRef)(
16473
16640
  const [openDesktopMenu, setOpenDesktopMenu] = (0, import_react12.useState)(null);
16474
16641
  const [selectedDigitForm2, setSelectedDigitForm] = (0, import_react12.useState)("western");
16475
16642
  const [selectedCharacterFont, setSelectedCharacterFont] = (0, import_react12.useState)("default");
16643
+ const [boldCharacterStyle, setBoldCharacterStyle] = (0, import_react12.useState)(initialSession?.currentCharacterWrapper === "\\boldarabic");
16476
16644
  const [activeEditorSide, setActiveEditorSide] = (0, import_react12.useState)("arabic");
16477
16645
  const [compactPreviewOpen, setCompactPreviewOpen] = (0, import_react12.useState)(false);
16478
16646
  const [compactControlState, setCompactControlState] = (0, import_react12.useState)({
@@ -16625,6 +16793,7 @@ ${arabic || currentMessages.empty}`;
16625
16793
  runtimeRef.current?.setSession(next);
16626
16794
  setSelectedDigitForm(next.currentDigitForm ?? "western");
16627
16795
  setSelectedCharacterFont(next.currentCharacterFont ?? "default");
16796
+ setBoldCharacterStyle(next.currentCharacterWrapper === "\\boldarabic");
16628
16797
  setActiveEditorSide(next.activeSide);
16629
16798
  onSessionChangeRef.current?.(next);
16630
16799
  setDebugImportError("");
@@ -16666,6 +16835,7 @@ ${arabic || currentMessages.empty}`;
16666
16835
  onSessionChange: (session) => {
16667
16836
  setSelectedDigitForm(session.currentDigitForm ?? "western");
16668
16837
  setSelectedCharacterFont(session.currentCharacterFont ?? "default");
16838
+ setBoldCharacterStyle(session.currentCharacterWrapper === "\\boldarabic");
16669
16839
  setActiveEditorSide(session.activeSide);
16670
16840
  const hasSelection = Boolean(session.selection && session.selection.anchorIndex !== session.selection.focusIndex);
16671
16841
  const nextCompactState = {
@@ -16748,6 +16918,7 @@ ${arabic || currentMessages.empty}`;
16748
16918
  ...compactControlState,
16749
16919
  activeSide: activeEditorSide,
16750
16920
  characterFont: selectedCharacterFont,
16921
+ boldCharacterStyle,
16751
16922
  digitForm: selectedDigitForm2
16752
16923
  };
16753
16924
  return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
@@ -17774,35 +17945,54 @@ ${arabic || currentMessages.empty}`;
17774
17945
  {
17775
17946
  ref: characterFontBtnRef,
17776
17947
  id: "select-character-font",
17777
- className: `icon-btn font-mode-btn font-mode-btn--${selectedCharacterFont}`,
17948
+ className: `icon-btn font-mode-btn font-mode-btn--${boldCharacterStyle ? "bold" : selectedCharacterFont}`,
17778
17949
  type: "button",
17779
- title: characterFontTitle2(selectedCharacterFont, messages),
17950
+ title: boldCharacterStyle ? boldCharacterStyleLabel2(uiLocale) : characterFontTitle2(selectedCharacterFont, messages),
17780
17951
  "aria-label": messages.chooseWritingFont,
17781
17952
  "aria-haspopup": "listbox",
17782
17953
  "aria-expanded": characterFontMenuOpen,
17783
17954
  onClick: () => setCharacterFontMenuOpen((open) => !open),
17784
- children: characterFontOption(selectedCharacterFont).label
17955
+ children: boldCharacterStyle ? boldCharacterStyleLabel2(uiLocale) : characterFontOption(selectedCharacterFont).label
17785
17956
  }
17786
17957
  ),
17787
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: "character-font-options", role: "listbox", "aria-label": messages.chooseWritingFont, hidden: !characterFontMenuOpen, children: CHARACTER_FONT_OPTIONS.map((option) => /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
17788
- "button",
17789
- {
17790
- type: "button",
17791
- role: "option",
17792
- "aria-selected": selectedCharacterFont === option.id,
17793
- className: `character-font-option character-font-option--${option.id}`,
17794
- title: characterFontTitle2(option.id, messages),
17795
- onMouseDown: (event) => event.preventDefault(),
17796
- onClick: () => {
17797
- runtimeRef.current?.setCurrentCharacterFont(option.id);
17798
- setSelectedCharacterFont(option.id);
17799
- setCharacterFontMenuOpen(false);
17800
- focusSurface();
17958
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "character-font-options", role: "listbox", "aria-label": messages.chooseWritingFont, hidden: !characterFontMenuOpen, children: [
17959
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
17960
+ "button",
17961
+ {
17962
+ type: "button",
17963
+ role: "option",
17964
+ "aria-selected": boldCharacterStyle,
17965
+ className: "character-font-option character-font-option--bold",
17966
+ title: boldCharacterStyleLabel2(uiLocale),
17967
+ onMouseDown: (event) => event.preventDefault(),
17968
+ onClick: () => {
17969
+ runtimeRef.current?.setCurrentBoldCharacterStyle();
17970
+ setCharacterFontMenuOpen(false);
17971
+ focusSurface();
17972
+ },
17973
+ children: boldCharacterStyleLabel2(uiLocale)
17974
+ }
17975
+ ),
17976
+ CHARACTER_FONT_OPTIONS.map((option) => /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
17977
+ "button",
17978
+ {
17979
+ type: "button",
17980
+ role: "option",
17981
+ "aria-selected": !boldCharacterStyle && selectedCharacterFont === option.id,
17982
+ className: `character-font-option character-font-option--${option.id}`,
17983
+ title: characterFontTitle2(option.id, messages),
17984
+ onMouseDown: (event) => event.preventDefault(),
17985
+ onClick: () => {
17986
+ runtimeRef.current?.setCurrentCharacterFont(option.id);
17987
+ setSelectedCharacterFont(option.id);
17988
+ setCharacterFontMenuOpen(false);
17989
+ focusSurface();
17990
+ },
17991
+ children: option.label
17801
17992
  },
17802
- children: option.label
17803
- },
17804
- option.id
17805
- )) })
17993
+ option.id
17994
+ ))
17995
+ ] })
17806
17996
  ]
17807
17997
  }
17808
17998
  ),