@drghaliasri/butex 7.2.1 → 7.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/dist/document.d.mts +8 -0
- package/dist/document.d.ts +8 -0
- package/dist/document.js +37 -2
- package/dist/document.js.map +1 -1
- package/dist/document.mjs +37 -2
- package/dist/document.mjs.map +1 -1
- package/dist/document2-cli.js +106 -2
- package/dist/document2-cli.js.map +1 -1
- package/dist/document2.d.mts +8 -0
- package/dist/document2.d.ts +8 -0
- package/dist/document2.js +106 -2
- package/dist/document2.js.map +1 -1
- package/dist/document2.mjs +106 -2
- package/dist/document2.mjs.map +1 -1
- package/dist/index.d.mts +19 -1
- package/dist/index.d.ts +19 -1
- package/dist/index.global.js +108 -11
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +108 -11
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +108 -11
- package/dist/index.mjs.map +1 -1
- package/dist/react-document.d.mts +2 -0
- package/dist/react-document.d.ts +2 -0
- package/dist/react-document.js +229 -40
- package/dist/react-document.js.map +1 -1
- package/dist/react-document.mjs +229 -40
- package/dist/react-document.mjs.map +1 -1
- package/dist/react-document2-preview.d.mts +2 -0
- package/dist/react-document2-preview.d.ts +2 -0
- package/dist/react-document2-preview.js +90 -0
- package/dist/react-document2-preview.js.map +1 -1
- package/dist/react-document2-preview.mjs +90 -0
- package/dist/react-document2-preview.mjs.map +1 -1
- package/dist/react-document2.d.mts +8 -0
- package/dist/react-document2.d.ts +8 -0
- package/dist/react-document2.js +229 -40
- package/dist/react-document2.js.map +1 -1
- package/dist/react-document2.mjs +229 -40
- package/dist/react-document2.mjs.map +1 -1
- package/dist/react.d.mts +16 -0
- package/dist/react.d.ts +16 -0
- package/dist/react.js +229 -40
- package/dist/react.js.map +1 -1
- package/dist/react.mjs +229 -40
- package/dist/react.mjs.map +1 -1
- package/package.json +1 -1
package/dist/react-document2.mjs
CHANGED
|
@@ -373,6 +373,7 @@ var BaseAstNode = class {
|
|
|
373
373
|
superscript;
|
|
374
374
|
subscript;
|
|
375
375
|
nodeType;
|
|
376
|
+
sourceLatex;
|
|
376
377
|
constructor(state = null) {
|
|
377
378
|
if (state === null) {
|
|
378
379
|
state = new State();
|
|
@@ -381,6 +382,7 @@ var BaseAstNode = class {
|
|
|
381
382
|
this.superscript = null;
|
|
382
383
|
this.subscript = null;
|
|
383
384
|
this.nodeType = this.constructor.name;
|
|
385
|
+
this.sourceLatex = null;
|
|
384
386
|
}
|
|
385
387
|
latex() {
|
|
386
388
|
throw new Error("NotImplementedError");
|
|
@@ -569,6 +571,7 @@ ${this.closing}`;
|
|
|
569
571
|
}
|
|
570
572
|
};
|
|
571
573
|
function parseScripts(node, json, mode) {
|
|
574
|
+
node.sourceLatex = typeof json.source_latex === "string" && json.source_latex.length > 0 ? json.source_latex : null;
|
|
572
575
|
if (json.superscript) {
|
|
573
576
|
node.superscript = parseChain(json.superscript, mode);
|
|
574
577
|
}
|
|
@@ -708,7 +711,8 @@ function fromMathObjectJson(json, mode = "english") {
|
|
|
708
711
|
function scriptsToJson(node, path) {
|
|
709
712
|
return {
|
|
710
713
|
...node.superscript ? { superscript: chainToJson(node.superscript, `${path}.superscript`) } : {},
|
|
711
|
-
...node.subscript ? { subscript: chainToJson(node.subscript, `${path}.subscript`) } : {}
|
|
714
|
+
...node.subscript ? { subscript: chainToJson(node.subscript, `${path}.subscript`) } : {},
|
|
715
|
+
...node.sourceLatex ? { source_latex: node.sourceLatex } : {}
|
|
712
716
|
};
|
|
713
717
|
}
|
|
714
718
|
function nodeToJson(node, path) {
|
|
@@ -2186,6 +2190,15 @@ var ATOMIC_OPERATOR_COMMANDS = {
|
|
|
2186
2190
|
title: "\u0627\u0644\u0644\u0627\u0646\u0647\u0627\u064A\u0629",
|
|
2187
2191
|
svg_path: null
|
|
2188
2192
|
},
|
|
2193
|
+
top: {
|
|
2194
|
+
id: "top",
|
|
2195
|
+
category: "operators1",
|
|
2196
|
+
Tex: "\\top",
|
|
2197
|
+
mirror: false,
|
|
2198
|
+
Label: "\u22A4",
|
|
2199
|
+
title: "\u0627\u0644\u0645\u0646\u0642\u0648\u0644",
|
|
2200
|
+
svg_path: null
|
|
2201
|
+
},
|
|
2189
2202
|
times: {
|
|
2190
2203
|
id: "times",
|
|
2191
2204
|
category: "operators1",
|
|
@@ -2966,6 +2979,7 @@ function cloneEditorSession(session) {
|
|
|
2966
2979
|
forceSplitNextLeaf: session.forceSplitNextLeaf,
|
|
2967
2980
|
arabicReverseNumberTyping: session.arabicReverseNumberTyping,
|
|
2968
2981
|
currentCharacterFont: session.currentCharacterFont ?? "default",
|
|
2982
|
+
currentCharacterWrapper: session.currentCharacterWrapper ?? null,
|
|
2969
2983
|
currentDigitForm: session.currentDigitForm ?? "western",
|
|
2970
2984
|
caret: { ...session.caret },
|
|
2971
2985
|
selection: session.selection ? { ...session.selection } : null,
|
|
@@ -3038,6 +3052,7 @@ function createEditorSession(englishTree, arabicTree, activeSide = "arabic") {
|
|
|
3038
3052
|
forceSplitNextLeaf: false,
|
|
3039
3053
|
arabicReverseNumberTyping: true,
|
|
3040
3054
|
currentCharacterFont: "default",
|
|
3055
|
+
currentCharacterWrapper: null,
|
|
3041
3056
|
currentDigitForm: "western",
|
|
3042
3057
|
caret: {
|
|
3043
3058
|
chainId: englishTree.id,
|
|
@@ -3280,6 +3295,14 @@ function renderNodeEnglish(node, options) {
|
|
|
3280
3295
|
return `${node.expr}${latinScripts(node, options)}`;
|
|
3281
3296
|
}
|
|
3282
3297
|
if (node.kind === "char") {
|
|
3298
|
+
if (node.sourceLatex) {
|
|
3299
|
+
return `${node.sourceLatex}${latinScripts(node, options)}`;
|
|
3300
|
+
}
|
|
3301
|
+
if (node.wrapperCommand) {
|
|
3302
|
+
const expr = formatDigits(node.expr, selectedDigitForm(options));
|
|
3303
|
+
const wrapper = node.wrapperCommand === "\\boldarabic" ? "\\mathbf" : node.wrapperCommand;
|
|
3304
|
+
return `${wrapper}{${escapeText(expr)}}${latinScripts(node, options)}`;
|
|
3305
|
+
}
|
|
3283
3306
|
return `${renderCharContent(node, options)}${latinScripts(node, options)}`;
|
|
3284
3307
|
}
|
|
3285
3308
|
if (node.kind === "operator" && isDivideOperatorExpr(node.expr)) {
|
|
@@ -3333,6 +3356,10 @@ function renderNodeArabic(node, options) {
|
|
|
3333
3356
|
if (node.kind === "char") {
|
|
3334
3357
|
const expr = formatDigits(node.expr, selectedDigitForm(options));
|
|
3335
3358
|
const content = renderCharContent(node, options);
|
|
3359
|
+
if (node.wrapperCommand) {
|
|
3360
|
+
const wrapper = node.wrapperCommand === "\\mathbf" ? "\\boldarabic" : node.wrapperCommand;
|
|
3361
|
+
return arabicScripts(node, `${wrapper}{${content}}`, options);
|
|
3362
|
+
}
|
|
3336
3363
|
return arabicScripts(node, (node.characterFont ?? "default") === "default" ? `\\text{${escapeText(expr)}}` : content, options);
|
|
3337
3364
|
}
|
|
3338
3365
|
if (node.kind === "operator" && isDivideOperatorExpr(node.expr)) {
|
|
@@ -4561,6 +4588,16 @@ function markExprSync(session, nodeId) {
|
|
|
4561
4588
|
}
|
|
4562
4589
|
session.sync[nodeId].expr = english.node.expr === arabic.node.expr ? "synced" : "diverged";
|
|
4563
4590
|
}
|
|
4591
|
+
function clearSourceIdentity(session, nodeId) {
|
|
4592
|
+
const english = findNodeById(session.englishTree, nodeId);
|
|
4593
|
+
const arabic = findNodeById(session.arabicTree, nodeId);
|
|
4594
|
+
if (english) {
|
|
4595
|
+
delete english.node.sourceLatex;
|
|
4596
|
+
}
|
|
4597
|
+
if (arabic) {
|
|
4598
|
+
delete arabic.node.sourceLatex;
|
|
4599
|
+
}
|
|
4600
|
+
}
|
|
4564
4601
|
function syncSelectionToCaret(session) {
|
|
4565
4602
|
const activeKey = activeTreeKey(session.activeSide);
|
|
4566
4603
|
const tree = session[activeKey];
|
|
@@ -5144,7 +5181,10 @@ function insertLeaf(session, kind, expr) {
|
|
|
5144
5181
|
const next = cloneEditorSession(session);
|
|
5145
5182
|
const englishNode = createEditorNode(kind, expr);
|
|
5146
5183
|
const arabicNode = createEditorNode(kind, expr);
|
|
5147
|
-
if (kind === "char" &&
|
|
5184
|
+
if (kind === "char" && next.currentCharacterWrapper === "\\boldarabic") {
|
|
5185
|
+
englishNode.wrapperCommand = "\\boldarabic";
|
|
5186
|
+
arabicNode.wrapperCommand = "\\boldarabic";
|
|
5187
|
+
} else if (kind === "char" && (next.currentCharacterFont ?? "default") !== "default") {
|
|
5148
5188
|
englishNode.characterFont = next.currentCharacterFont;
|
|
5149
5189
|
arabicNode.characterFont = next.currentCharacterFont;
|
|
5150
5190
|
}
|
|
@@ -5159,8 +5199,12 @@ function insertLeaf(session, kind, expr) {
|
|
|
5159
5199
|
function shouldReverseArabicNumber(session) {
|
|
5160
5200
|
return session.activeSide === "arabic" && session.arabicReverseNumberTyping;
|
|
5161
5201
|
}
|
|
5162
|
-
function
|
|
5163
|
-
|
|
5202
|
+
function characterTypingStyleOf(node) {
|
|
5203
|
+
if (node.kind !== "char") return "none";
|
|
5204
|
+
return node.wrapperCommand ? `wrapper:${node.wrapperCommand}` : `font:${node.characterFont ?? "default"}`;
|
|
5205
|
+
}
|
|
5206
|
+
function currentCharacterTypingStyle(session) {
|
|
5207
|
+
return session.currentCharacterWrapper ? `wrapper:${session.currentCharacterWrapper}` : `font:${session.currentCharacterFont ?? "default"}`;
|
|
5164
5208
|
}
|
|
5165
5209
|
function tryMergeLeafTyping(session, kind, fragment) {
|
|
5166
5210
|
const engLocated = findChainById(session.englishTree, session.caret.chainId);
|
|
@@ -5173,14 +5217,14 @@ function tryMergeLeafTyping(session, kind, fragment) {
|
|
|
5173
5217
|
let prepend = false;
|
|
5174
5218
|
if (i > 0) {
|
|
5175
5219
|
const prev = nodes[i - 1];
|
|
5176
|
-
if (prev.kind === kind && (kind !== "char" ||
|
|
5220
|
+
if (prev.kind === kind && (kind !== "char" || characterTypingStyleOf(prev) === currentCharacterTypingStyle(session))) {
|
|
5177
5221
|
targetId = prev.id;
|
|
5178
5222
|
prepend = false;
|
|
5179
5223
|
}
|
|
5180
5224
|
}
|
|
5181
5225
|
if (!targetId && i < nodes.length) {
|
|
5182
5226
|
const fwd = nodes[i];
|
|
5183
|
-
if (fwd.kind === kind && (kind !== "char" ||
|
|
5227
|
+
if (fwd.kind === kind && (kind !== "char" || characterTypingStyleOf(fwd) === currentCharacterTypingStyle(session))) {
|
|
5184
5228
|
targetId = fwd.id;
|
|
5185
5229
|
prepend = true;
|
|
5186
5230
|
}
|
|
@@ -5201,6 +5245,7 @@ function tryMergeLeafTyping(session, kind, fragment) {
|
|
|
5201
5245
|
englishHit.node.expr = `${englishHit.node.expr}${fragment}`;
|
|
5202
5246
|
arabicHit.node.expr = `${arabicHit.node.expr}${fragment}`;
|
|
5203
5247
|
}
|
|
5248
|
+
clearSourceIdentity(session, targetId);
|
|
5204
5249
|
markExprSync(session, targetId);
|
|
5205
5250
|
return true;
|
|
5206
5251
|
}
|
|
@@ -5239,9 +5284,17 @@ function breakLeafTyping(session) {
|
|
|
5239
5284
|
function setCurrentCharacterFont(session, fontId) {
|
|
5240
5285
|
const next = cloneEditorSession(session);
|
|
5241
5286
|
next.currentCharacterFont = fontId;
|
|
5287
|
+
next.currentCharacterWrapper = null;
|
|
5242
5288
|
appendDebug(next, "setCurrentCharacterFont", fontId);
|
|
5243
5289
|
return next;
|
|
5244
5290
|
}
|
|
5291
|
+
function setCurrentBoldCharacterStyle(session) {
|
|
5292
|
+
const next = cloneEditorSession(session);
|
|
5293
|
+
next.currentCharacterFont = "default";
|
|
5294
|
+
next.currentCharacterWrapper = "\\boldarabic";
|
|
5295
|
+
appendDebug(next, "setCurrentBoldCharacterStyle", "\\boldarabic");
|
|
5296
|
+
return next;
|
|
5297
|
+
}
|
|
5245
5298
|
function toggleTakweenCharacterFont(session) {
|
|
5246
5299
|
return setCurrentCharacterFont(session, (session.currentCharacterFont ?? "default") === "takween" ? "default" : "takween");
|
|
5247
5300
|
}
|
|
@@ -5790,6 +5843,7 @@ function deleteBackward(session) {
|
|
|
5790
5843
|
englishHit.node.expr = englishHit.node.expr.slice(0, -1);
|
|
5791
5844
|
arabicHit.node.expr = arabicHit.node.expr.slice(0, -1);
|
|
5792
5845
|
}
|
|
5846
|
+
clearSourceIdentity(next, id);
|
|
5793
5847
|
markExprSync(next, id);
|
|
5794
5848
|
next.selectedStructureNodeId = null;
|
|
5795
5849
|
syncSelectionToCaret(next);
|
|
@@ -5839,6 +5893,7 @@ function deleteForward(session) {
|
|
|
5839
5893
|
englishHit.node.expr = englishHit.node.expr.slice(1);
|
|
5840
5894
|
arabicHit.node.expr = arabicHit.node.expr.slice(1);
|
|
5841
5895
|
}
|
|
5896
|
+
clearSourceIdentity(next, node.id);
|
|
5842
5897
|
markExprSync(next, node.id);
|
|
5843
5898
|
next.selectedStructureNodeId = null;
|
|
5844
5899
|
syncSelectionToCaret(next);
|
|
@@ -5868,6 +5923,7 @@ function createStarterSession() {
|
|
|
5868
5923
|
forceSplitNextLeaf: false,
|
|
5869
5924
|
arabicReverseNumberTyping: true,
|
|
5870
5925
|
currentCharacterFont: "default",
|
|
5926
|
+
currentCharacterWrapper: null,
|
|
5871
5927
|
currentDigitForm: "western",
|
|
5872
5928
|
caret: {
|
|
5873
5929
|
chainId: englishRoot.id,
|
|
@@ -5993,6 +6049,9 @@ function buildBaseNodeBody(node, digitForm = "western", side = "english") {
|
|
|
5993
6049
|
if (cssClass) {
|
|
5994
6050
|
value.classList.add(cssClass);
|
|
5995
6051
|
}
|
|
6052
|
+
if (node.wrapperCommand === "\\boldarabic" || node.wrapperCommand === "\\mathbf") {
|
|
6053
|
+
value.classList.add("node-value--bold");
|
|
6054
|
+
}
|
|
5996
6055
|
}
|
|
5997
6056
|
const surfaceExpr = node.kind === "operator" ? divideOperatorSurfaceExpr(node.expr, side) : node.expr;
|
|
5998
6057
|
value.textContent = surfaceExpr === "" ? "\u25A1" : formatDigits(surfaceExpr, digitForm);
|
|
@@ -6913,6 +6972,11 @@ ${BUTEX_FONT_FACE_CSS}
|
|
|
6913
6972
|
|
|
6914
6973
|
${CHARACTER_FONT_CSS}
|
|
6915
6974
|
|
|
6975
|
+
.node-value--bold {
|
|
6976
|
+
font-family: var(--font-display-ar, Amiri), "Noto Serif Arabic", serif;
|
|
6977
|
+
font-weight: 700;
|
|
6978
|
+
}
|
|
6979
|
+
|
|
6916
6980
|
.chain {
|
|
6917
6981
|
display: inline-flex;
|
|
6918
6982
|
align-items: center;
|
|
@@ -7905,6 +7969,10 @@ function createEditorRuntime(options) {
|
|
|
7905
7969
|
applyTransient((prev) => setCurrentCharacterFont(prev, fontId));
|
|
7906
7970
|
focusInput();
|
|
7907
7971
|
},
|
|
7972
|
+
setCurrentBoldCharacterStyle: () => {
|
|
7973
|
+
applyTransient((prev) => setCurrentBoldCharacterStyle(prev));
|
|
7974
|
+
focusInput();
|
|
7975
|
+
},
|
|
7908
7976
|
setCurrentDigitForm: (digitForm) => {
|
|
7909
7977
|
applyStructural((prev) => setCurrentDigitForm(prev, digitForm));
|
|
7910
7978
|
focusInput();
|
|
@@ -8100,6 +8168,10 @@ var CHAR_FONT_EXPORT_TEX = Object.fromEntries(
|
|
|
8100
8168
|
function charEditorNodeToAstNode(node) {
|
|
8101
8169
|
const font = node.characterFont ?? "default";
|
|
8102
8170
|
const charNode = new CharNode(node.expr);
|
|
8171
|
+
if (node.wrapperCommand) {
|
|
8172
|
+
const wrapper = node.wrapperCommand === "\\boldarabic" ? "\\mathbf" : node.wrapperCommand;
|
|
8173
|
+
return new CommandNode(wrapper, [], [new ChainNode([charNode])]);
|
|
8174
|
+
}
|
|
8103
8175
|
if (font === "default") {
|
|
8104
8176
|
return charNode;
|
|
8105
8177
|
}
|
|
@@ -8126,6 +8198,9 @@ function cloneChainWithFreshIds(chain) {
|
|
|
8126
8198
|
return structuredClone(chain);
|
|
8127
8199
|
}
|
|
8128
8200
|
function attachScripts(astNode, editorNode) {
|
|
8201
|
+
if (astNode.sourceLatex) {
|
|
8202
|
+
editorNode.sourceLatex = astNode.sourceLatex;
|
|
8203
|
+
}
|
|
8129
8204
|
if (astNode.superscript) {
|
|
8130
8205
|
const sup = chainToEditorChain(astNode.superscript);
|
|
8131
8206
|
if (!sup.editable) {
|
|
@@ -8252,6 +8327,49 @@ function charFromTextLikeCommand(node) {
|
|
|
8252
8327
|
const scripts = attachScripts(node, editorNode);
|
|
8253
8328
|
return scripts ?? { editable: true, node: editorNode };
|
|
8254
8329
|
}
|
|
8330
|
+
function singleCommandChar(node) {
|
|
8331
|
+
if (node.optionalArgs.length > 0 || node.mandatoryArgs.length !== 1) {
|
|
8332
|
+
return null;
|
|
8333
|
+
}
|
|
8334
|
+
const arg = node.mandatoryArgs[0];
|
|
8335
|
+
if (arg.chain.length !== 1 || !(arg.chain[0] instanceof CharNode)) {
|
|
8336
|
+
return null;
|
|
8337
|
+
}
|
|
8338
|
+
return arg.chain[0];
|
|
8339
|
+
}
|
|
8340
|
+
function wrappedAtomicCommandId(node) {
|
|
8341
|
+
if (node.name !== "\\mathbb" && node.name !== "\\mathrm") {
|
|
8342
|
+
return null;
|
|
8343
|
+
}
|
|
8344
|
+
const child = singleCommandChar(node);
|
|
8345
|
+
if (!child) {
|
|
8346
|
+
return null;
|
|
8347
|
+
}
|
|
8348
|
+
return commandIdForTex(`${node.name}{${child.expr}}`);
|
|
8349
|
+
}
|
|
8350
|
+
function editableWrapperCommand(node) {
|
|
8351
|
+
if (node.name !== "\\mathtt" && node.name !== "\\mathsf" && node.name !== "\\unit" && node.name !== "\\mathbf" && node.name !== "\\boldarabic") {
|
|
8352
|
+
return null;
|
|
8353
|
+
}
|
|
8354
|
+
const child = singleCommandChar(node);
|
|
8355
|
+
if (!child) {
|
|
8356
|
+
return null;
|
|
8357
|
+
}
|
|
8358
|
+
const normalized = normalizeCharImportExpr(child.expr);
|
|
8359
|
+
const editorNode = createEditorNode("char", normalized.expr);
|
|
8360
|
+
if (normalized.characterFont !== "default") {
|
|
8361
|
+
editorNode.characterFont = normalized.characterFont;
|
|
8362
|
+
}
|
|
8363
|
+
editorNode.wrapperCommand = node.name === "\\mathtt" ? "\\mathtt" : node.name === "\\mathbf" ? "\\mathbf" : node.name === "\\boldarabic" ? "\\boldarabic" : "\\unit";
|
|
8364
|
+
const scripts = attachScripts(node, editorNode);
|
|
8365
|
+
if (scripts) {
|
|
8366
|
+
return scripts;
|
|
8367
|
+
}
|
|
8368
|
+
if (!editorNode.sourceLatex && node.name === "\\mathsf") {
|
|
8369
|
+
editorNode.sourceLatex = `\\mathsf{${child.expr}}`;
|
|
8370
|
+
}
|
|
8371
|
+
return { editable: true, node: editorNode };
|
|
8372
|
+
}
|
|
8255
8373
|
function commandToEditorNode(node) {
|
|
8256
8374
|
if (node.name === "\\frac" && node.mandatoryArgs.length >= 2) {
|
|
8257
8375
|
const frac = createFracNode();
|
|
@@ -8341,6 +8459,19 @@ function commandToEditorNode(node) {
|
|
|
8341
8459
|
}
|
|
8342
8460
|
return { editable: true, node: accent };
|
|
8343
8461
|
}
|
|
8462
|
+
const wrappedAtomicId = wrappedAtomicCommandId(node);
|
|
8463
|
+
if (wrappedAtomicId) {
|
|
8464
|
+
const atomic = createEditorNode("atomicCommand", wrappedAtomicId);
|
|
8465
|
+
const scripts = attachScripts(node, atomic);
|
|
8466
|
+
if (scripts) {
|
|
8467
|
+
return scripts;
|
|
8468
|
+
}
|
|
8469
|
+
return { editable: true, node: atomic };
|
|
8470
|
+
}
|
|
8471
|
+
const wrapper = editableWrapperCommand(node);
|
|
8472
|
+
if (wrapper) {
|
|
8473
|
+
return wrapper;
|
|
8474
|
+
}
|
|
8344
8475
|
const atomicId = commandIdForTex(node.name);
|
|
8345
8476
|
if (atomicId && node.optionalArgs.length === 0 && node.mandatoryArgs.length === 0) {
|
|
8346
8477
|
const atomic = createEditorNode("atomicCommand", atomicId);
|
|
@@ -8620,7 +8751,13 @@ function editorNodeToAstNode(node) {
|
|
|
8620
8751
|
if (!tex) {
|
|
8621
8752
|
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}` };
|
|
8622
8753
|
}
|
|
8623
|
-
|
|
8754
|
+
if (node.expr === "ad") {
|
|
8755
|
+
astNode = new CommandNode("\\mathrm", [], [new ChainNode([new CharNode("d")])]);
|
|
8756
|
+
} else if (["N", "Z", "Q", "R", "C", "H"].includes(node.expr)) {
|
|
8757
|
+
astNode = new CommandNode("\\mathbb", [], [new ChainNode([new CharNode(node.expr)])]);
|
|
8758
|
+
} else {
|
|
8759
|
+
astNode = new CommandNode(tex);
|
|
8760
|
+
}
|
|
8624
8761
|
} else if (node.kind === "atomicOperatorCommand") {
|
|
8625
8762
|
const tex = atomicOperatorCommandSpec(node.expr)?.Tex;
|
|
8626
8763
|
if (!tex) {
|
|
@@ -8637,6 +8774,9 @@ function editorNodeToAstNode(node) {
|
|
|
8637
8774
|
} else {
|
|
8638
8775
|
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}` };
|
|
8639
8776
|
}
|
|
8777
|
+
if (node.sourceLatex) {
|
|
8778
|
+
astNode.sourceLatex = node.sourceLatex;
|
|
8779
|
+
}
|
|
8640
8780
|
const scripts = attachAstScripts(node, astNode);
|
|
8641
8781
|
return scripts ?? { ok: true, node: astNode };
|
|
8642
8782
|
}
|
|
@@ -14806,6 +14946,13 @@ ${MATRIX_PICKER_CSS}
|
|
|
14806
14946
|
box-shadow: 0 0 0 3px var(--butex-focus-shadow);
|
|
14807
14947
|
}
|
|
14808
14948
|
|
|
14949
|
+
.butex-widget .font-mode-btn--bold,
|
|
14950
|
+
.butex-widget .character-font-option--bold,
|
|
14951
|
+
.butex-widget .butex-widget__command-sheet .character-font-option--bold {
|
|
14952
|
+
font-family: var(--font-display-ar, Amiri), "Noto Serif Arabic", serif;
|
|
14953
|
+
font-weight: 700;
|
|
14954
|
+
}
|
|
14955
|
+
|
|
14809
14956
|
.butex-widget .font-mode-btn--takween,
|
|
14810
14957
|
.butex-widget .character-font-option--takween,
|
|
14811
14958
|
.butex-widget .butex-widget__command-sheet .character-font-option--takween {
|
|
@@ -15635,6 +15782,9 @@ function alignmentTitle(alignment, messages) {
|
|
|
15635
15782
|
if (alignment === "r") return messages.alignColumnRight;
|
|
15636
15783
|
return messages.alignColumnCenter;
|
|
15637
15784
|
}
|
|
15785
|
+
function boldCharacterStyleLabel(uiLocale) {
|
|
15786
|
+
return uiLocale === "ar" ? "\u0639\u0631\u064A\u0636" : "Bold";
|
|
15787
|
+
}
|
|
15638
15788
|
function characterFontTitle(fontId, messages) {
|
|
15639
15789
|
const key = characterFontSpec(fontId).titleKey;
|
|
15640
15790
|
return messages[key] ?? messages.defaultFont;
|
|
@@ -16010,18 +16160,31 @@ function EquationMobileToolbar({
|
|
|
16010
16160
|
sheetView === "typography" ? /* @__PURE__ */ jsxs12(Fragment5, { children: [
|
|
16011
16161
|
/* @__PURE__ */ jsxs12("section", { className: "butex-widget__sheet-section", children: [
|
|
16012
16162
|
/* @__PURE__ */ jsx13("h4", { children: messages.chooseWritingFont }),
|
|
16013
|
-
/* @__PURE__ */
|
|
16014
|
-
|
|
16015
|
-
|
|
16016
|
-
|
|
16017
|
-
|
|
16018
|
-
|
|
16019
|
-
|
|
16020
|
-
|
|
16021
|
-
|
|
16022
|
-
|
|
16023
|
-
|
|
16024
|
-
|
|
16163
|
+
/* @__PURE__ */ jsxs12("div", { className: "butex-widget__sheet-choice-row", children: [
|
|
16164
|
+
/* @__PURE__ */ jsx13(
|
|
16165
|
+
"button",
|
|
16166
|
+
{
|
|
16167
|
+
type: "button",
|
|
16168
|
+
className: "character-font-option--bold",
|
|
16169
|
+
"aria-pressed": state.boldCharacterStyle,
|
|
16170
|
+
title: boldCharacterStyleLabel(uiLocale),
|
|
16171
|
+
onClick: (event) => runAndKeepFocus(event.currentTarget, (runtime) => runtime.setCurrentBoldCharacterStyle()),
|
|
16172
|
+
children: boldCharacterStyleLabel(uiLocale)
|
|
16173
|
+
}
|
|
16174
|
+
),
|
|
16175
|
+
CHARACTER_FONT_OPTIONS.map((option) => /* @__PURE__ */ jsx13(
|
|
16176
|
+
"button",
|
|
16177
|
+
{
|
|
16178
|
+
type: "button",
|
|
16179
|
+
className: `character-font-option--${option.id}`,
|
|
16180
|
+
"aria-pressed": !state.boldCharacterStyle && state.characterFont === option.id,
|
|
16181
|
+
title: characterFontTitle(option.id, messages),
|
|
16182
|
+
onClick: (event) => runAndKeepFocus(event.currentTarget, (runtime) => runtime.setCurrentCharacterFont(option.id)),
|
|
16183
|
+
children: option.label
|
|
16184
|
+
},
|
|
16185
|
+
option.id
|
|
16186
|
+
))
|
|
16187
|
+
] })
|
|
16025
16188
|
] }),
|
|
16026
16189
|
/* @__PURE__ */ jsx13(
|
|
16027
16190
|
"button",
|
|
@@ -16341,6 +16504,9 @@ function digitFormLabel3(digitForm) {
|
|
|
16341
16504
|
function characterFontOption(fontId) {
|
|
16342
16505
|
return CHARACTER_FONT_OPTIONS.find((option) => option.id === fontId) ?? CHARACTER_FONT_OPTIONS[0];
|
|
16343
16506
|
}
|
|
16507
|
+
function boldCharacterStyleLabel2(uiLocale) {
|
|
16508
|
+
return uiLocale === "ar" ? "\u0639\u0631\u064A\u0636" : "Bold";
|
|
16509
|
+
}
|
|
16344
16510
|
function characterFontTitle2(fontId, messages) {
|
|
16345
16511
|
const key = characterFontSpec(fontId).titleKey;
|
|
16346
16512
|
return messages[key] ?? messages.defaultFont;
|
|
@@ -16445,6 +16611,7 @@ var ButexEditor = forwardRef(
|
|
|
16445
16611
|
const [openDesktopMenu, setOpenDesktopMenu] = useState9(null);
|
|
16446
16612
|
const [selectedDigitForm2, setSelectedDigitForm] = useState9("western");
|
|
16447
16613
|
const [selectedCharacterFont, setSelectedCharacterFont] = useState9("default");
|
|
16614
|
+
const [boldCharacterStyle, setBoldCharacterStyle] = useState9(initialSession?.currentCharacterWrapper === "\\boldarabic");
|
|
16448
16615
|
const [activeEditorSide, setActiveEditorSide] = useState9("arabic");
|
|
16449
16616
|
const [compactPreviewOpen, setCompactPreviewOpen] = useState9(false);
|
|
16450
16617
|
const [compactControlState, setCompactControlState] = useState9({
|
|
@@ -16597,6 +16764,7 @@ ${arabic || currentMessages.empty}`;
|
|
|
16597
16764
|
runtimeRef.current?.setSession(next);
|
|
16598
16765
|
setSelectedDigitForm(next.currentDigitForm ?? "western");
|
|
16599
16766
|
setSelectedCharacterFont(next.currentCharacterFont ?? "default");
|
|
16767
|
+
setBoldCharacterStyle(next.currentCharacterWrapper === "\\boldarabic");
|
|
16600
16768
|
setActiveEditorSide(next.activeSide);
|
|
16601
16769
|
onSessionChangeRef.current?.(next);
|
|
16602
16770
|
setDebugImportError("");
|
|
@@ -16638,6 +16806,7 @@ ${arabic || currentMessages.empty}`;
|
|
|
16638
16806
|
onSessionChange: (session) => {
|
|
16639
16807
|
setSelectedDigitForm(session.currentDigitForm ?? "western");
|
|
16640
16808
|
setSelectedCharacterFont(session.currentCharacterFont ?? "default");
|
|
16809
|
+
setBoldCharacterStyle(session.currentCharacterWrapper === "\\boldarabic");
|
|
16641
16810
|
setActiveEditorSide(session.activeSide);
|
|
16642
16811
|
const hasSelection = Boolean(session.selection && session.selection.anchorIndex !== session.selection.focusIndex);
|
|
16643
16812
|
const nextCompactState = {
|
|
@@ -16720,6 +16889,7 @@ ${arabic || currentMessages.empty}`;
|
|
|
16720
16889
|
...compactControlState,
|
|
16721
16890
|
activeSide: activeEditorSide,
|
|
16722
16891
|
characterFont: selectedCharacterFont,
|
|
16892
|
+
boldCharacterStyle,
|
|
16723
16893
|
digitForm: selectedDigitForm2
|
|
16724
16894
|
};
|
|
16725
16895
|
return /* @__PURE__ */ jsx14(
|
|
@@ -17746,35 +17916,54 @@ ${arabic || currentMessages.empty}`;
|
|
|
17746
17916
|
{
|
|
17747
17917
|
ref: characterFontBtnRef,
|
|
17748
17918
|
id: "select-character-font",
|
|
17749
|
-
className: `icon-btn font-mode-btn font-mode-btn--${selectedCharacterFont}`,
|
|
17919
|
+
className: `icon-btn font-mode-btn font-mode-btn--${boldCharacterStyle ? "bold" : selectedCharacterFont}`,
|
|
17750
17920
|
type: "button",
|
|
17751
|
-
title: characterFontTitle2(selectedCharacterFont, messages),
|
|
17921
|
+
title: boldCharacterStyle ? boldCharacterStyleLabel2(uiLocale) : characterFontTitle2(selectedCharacterFont, messages),
|
|
17752
17922
|
"aria-label": messages.chooseWritingFont,
|
|
17753
17923
|
"aria-haspopup": "listbox",
|
|
17754
17924
|
"aria-expanded": characterFontMenuOpen,
|
|
17755
17925
|
onClick: () => setCharacterFontMenuOpen((open) => !open),
|
|
17756
|
-
children: characterFontOption(selectedCharacterFont).label
|
|
17926
|
+
children: boldCharacterStyle ? boldCharacterStyleLabel2(uiLocale) : characterFontOption(selectedCharacterFont).label
|
|
17757
17927
|
}
|
|
17758
17928
|
),
|
|
17759
|
-
/* @__PURE__ */
|
|
17760
|
-
|
|
17761
|
-
|
|
17762
|
-
|
|
17763
|
-
|
|
17764
|
-
|
|
17765
|
-
|
|
17766
|
-
|
|
17767
|
-
|
|
17768
|
-
|
|
17769
|
-
|
|
17770
|
-
|
|
17771
|
-
|
|
17772
|
-
|
|
17929
|
+
/* @__PURE__ */ jsxs13("div", { className: "character-font-options", role: "listbox", "aria-label": messages.chooseWritingFont, hidden: !characterFontMenuOpen, children: [
|
|
17930
|
+
/* @__PURE__ */ jsx14(
|
|
17931
|
+
"button",
|
|
17932
|
+
{
|
|
17933
|
+
type: "button",
|
|
17934
|
+
role: "option",
|
|
17935
|
+
"aria-selected": boldCharacterStyle,
|
|
17936
|
+
className: "character-font-option character-font-option--bold",
|
|
17937
|
+
title: boldCharacterStyleLabel2(uiLocale),
|
|
17938
|
+
onMouseDown: (event) => event.preventDefault(),
|
|
17939
|
+
onClick: () => {
|
|
17940
|
+
runtimeRef.current?.setCurrentBoldCharacterStyle();
|
|
17941
|
+
setCharacterFontMenuOpen(false);
|
|
17942
|
+
focusSurface();
|
|
17943
|
+
},
|
|
17944
|
+
children: boldCharacterStyleLabel2(uiLocale)
|
|
17945
|
+
}
|
|
17946
|
+
),
|
|
17947
|
+
CHARACTER_FONT_OPTIONS.map((option) => /* @__PURE__ */ jsx14(
|
|
17948
|
+
"button",
|
|
17949
|
+
{
|
|
17950
|
+
type: "button",
|
|
17951
|
+
role: "option",
|
|
17952
|
+
"aria-selected": !boldCharacterStyle && selectedCharacterFont === option.id,
|
|
17953
|
+
className: `character-font-option character-font-option--${option.id}`,
|
|
17954
|
+
title: characterFontTitle2(option.id, messages),
|
|
17955
|
+
onMouseDown: (event) => event.preventDefault(),
|
|
17956
|
+
onClick: () => {
|
|
17957
|
+
runtimeRef.current?.setCurrentCharacterFont(option.id);
|
|
17958
|
+
setSelectedCharacterFont(option.id);
|
|
17959
|
+
setCharacterFontMenuOpen(false);
|
|
17960
|
+
focusSurface();
|
|
17961
|
+
},
|
|
17962
|
+
children: option.label
|
|
17773
17963
|
},
|
|
17774
|
-
|
|
17775
|
-
|
|
17776
|
-
|
|
17777
|
-
)) })
|
|
17964
|
+
option.id
|
|
17965
|
+
))
|
|
17966
|
+
] })
|
|
17778
17967
|
]
|
|
17779
17968
|
}
|
|
17780
17969
|
),
|