@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
|
@@ -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;
|
package/dist/react-document2.js
CHANGED
|
@@ -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,
|
|
@@ -3317,6 +3332,14 @@ function renderNodeEnglish(node, options) {
|
|
|
3317
3332
|
return `${node.expr}${latinScripts(node, options)}`;
|
|
3318
3333
|
}
|
|
3319
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
|
+
}
|
|
3320
3343
|
return `${renderCharContent(node, options)}${latinScripts(node, options)}`;
|
|
3321
3344
|
}
|
|
3322
3345
|
if (node.kind === "operator" && isDivideOperatorExpr(node.expr)) {
|
|
@@ -3370,6 +3393,10 @@ function renderNodeArabic(node, options) {
|
|
|
3370
3393
|
if (node.kind === "char") {
|
|
3371
3394
|
const expr = formatDigits(node.expr, selectedDigitForm(options));
|
|
3372
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
|
+
}
|
|
3373
3400
|
return arabicScripts(node, (node.characterFont ?? "default") === "default" ? `\\text{${escapeText(expr)}}` : content, options);
|
|
3374
3401
|
}
|
|
3375
3402
|
if (node.kind === "operator" && isDivideOperatorExpr(node.expr)) {
|
|
@@ -4598,6 +4625,16 @@ function markExprSync(session, nodeId) {
|
|
|
4598
4625
|
}
|
|
4599
4626
|
session.sync[nodeId].expr = english.node.expr === arabic.node.expr ? "synced" : "diverged";
|
|
4600
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
|
+
}
|
|
4601
4638
|
function syncSelectionToCaret(session) {
|
|
4602
4639
|
const activeKey = activeTreeKey(session.activeSide);
|
|
4603
4640
|
const tree = session[activeKey];
|
|
@@ -5181,7 +5218,10 @@ function insertLeaf(session, kind, expr) {
|
|
|
5181
5218
|
const next = cloneEditorSession(session);
|
|
5182
5219
|
const englishNode = createEditorNode(kind, expr);
|
|
5183
5220
|
const arabicNode = createEditorNode(kind, expr);
|
|
5184
|
-
if (kind === "char" &&
|
|
5221
|
+
if (kind === "char" && next.currentCharacterWrapper === "\\boldarabic") {
|
|
5222
|
+
englishNode.wrapperCommand = "\\boldarabic";
|
|
5223
|
+
arabicNode.wrapperCommand = "\\boldarabic";
|
|
5224
|
+
} else if (kind === "char" && (next.currentCharacterFont ?? "default") !== "default") {
|
|
5185
5225
|
englishNode.characterFont = next.currentCharacterFont;
|
|
5186
5226
|
arabicNode.characterFont = next.currentCharacterFont;
|
|
5187
5227
|
}
|
|
@@ -5196,8 +5236,12 @@ function insertLeaf(session, kind, expr) {
|
|
|
5196
5236
|
function shouldReverseArabicNumber(session) {
|
|
5197
5237
|
return session.activeSide === "arabic" && session.arabicReverseNumberTyping;
|
|
5198
5238
|
}
|
|
5199
|
-
function
|
|
5200
|
-
|
|
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"}`;
|
|
5201
5245
|
}
|
|
5202
5246
|
function tryMergeLeafTyping(session, kind, fragment) {
|
|
5203
5247
|
const engLocated = findChainById(session.englishTree, session.caret.chainId);
|
|
@@ -5210,14 +5254,14 @@ function tryMergeLeafTyping(session, kind, fragment) {
|
|
|
5210
5254
|
let prepend = false;
|
|
5211
5255
|
if (i > 0) {
|
|
5212
5256
|
const prev = nodes[i - 1];
|
|
5213
|
-
if (prev.kind === kind && (kind !== "char" ||
|
|
5257
|
+
if (prev.kind === kind && (kind !== "char" || characterTypingStyleOf(prev) === currentCharacterTypingStyle(session))) {
|
|
5214
5258
|
targetId = prev.id;
|
|
5215
5259
|
prepend = false;
|
|
5216
5260
|
}
|
|
5217
5261
|
}
|
|
5218
5262
|
if (!targetId && i < nodes.length) {
|
|
5219
5263
|
const fwd = nodes[i];
|
|
5220
|
-
if (fwd.kind === kind && (kind !== "char" ||
|
|
5264
|
+
if (fwd.kind === kind && (kind !== "char" || characterTypingStyleOf(fwd) === currentCharacterTypingStyle(session))) {
|
|
5221
5265
|
targetId = fwd.id;
|
|
5222
5266
|
prepend = true;
|
|
5223
5267
|
}
|
|
@@ -5238,6 +5282,7 @@ function tryMergeLeafTyping(session, kind, fragment) {
|
|
|
5238
5282
|
englishHit.node.expr = `${englishHit.node.expr}${fragment}`;
|
|
5239
5283
|
arabicHit.node.expr = `${arabicHit.node.expr}${fragment}`;
|
|
5240
5284
|
}
|
|
5285
|
+
clearSourceIdentity(session, targetId);
|
|
5241
5286
|
markExprSync(session, targetId);
|
|
5242
5287
|
return true;
|
|
5243
5288
|
}
|
|
@@ -5276,9 +5321,17 @@ function breakLeafTyping(session) {
|
|
|
5276
5321
|
function setCurrentCharacterFont(session, fontId) {
|
|
5277
5322
|
const next = cloneEditorSession(session);
|
|
5278
5323
|
next.currentCharacterFont = fontId;
|
|
5324
|
+
next.currentCharacterWrapper = null;
|
|
5279
5325
|
appendDebug(next, "setCurrentCharacterFont", fontId);
|
|
5280
5326
|
return next;
|
|
5281
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
|
+
}
|
|
5282
5335
|
function toggleTakweenCharacterFont(session) {
|
|
5283
5336
|
return setCurrentCharacterFont(session, (session.currentCharacterFont ?? "default") === "takween" ? "default" : "takween");
|
|
5284
5337
|
}
|
|
@@ -5827,6 +5880,7 @@ function deleteBackward(session) {
|
|
|
5827
5880
|
englishHit.node.expr = englishHit.node.expr.slice(0, -1);
|
|
5828
5881
|
arabicHit.node.expr = arabicHit.node.expr.slice(0, -1);
|
|
5829
5882
|
}
|
|
5883
|
+
clearSourceIdentity(next, id);
|
|
5830
5884
|
markExprSync(next, id);
|
|
5831
5885
|
next.selectedStructureNodeId = null;
|
|
5832
5886
|
syncSelectionToCaret(next);
|
|
@@ -5876,6 +5930,7 @@ function deleteForward(session) {
|
|
|
5876
5930
|
englishHit.node.expr = englishHit.node.expr.slice(1);
|
|
5877
5931
|
arabicHit.node.expr = arabicHit.node.expr.slice(1);
|
|
5878
5932
|
}
|
|
5933
|
+
clearSourceIdentity(next, node.id);
|
|
5879
5934
|
markExprSync(next, node.id);
|
|
5880
5935
|
next.selectedStructureNodeId = null;
|
|
5881
5936
|
syncSelectionToCaret(next);
|
|
@@ -5905,6 +5960,7 @@ function createStarterSession() {
|
|
|
5905
5960
|
forceSplitNextLeaf: false,
|
|
5906
5961
|
arabicReverseNumberTyping: true,
|
|
5907
5962
|
currentCharacterFont: "default",
|
|
5963
|
+
currentCharacterWrapper: null,
|
|
5908
5964
|
currentDigitForm: "western",
|
|
5909
5965
|
caret: {
|
|
5910
5966
|
chainId: englishRoot.id,
|
|
@@ -6030,6 +6086,9 @@ function buildBaseNodeBody(node, digitForm = "western", side = "english") {
|
|
|
6030
6086
|
if (cssClass) {
|
|
6031
6087
|
value.classList.add(cssClass);
|
|
6032
6088
|
}
|
|
6089
|
+
if (node.wrapperCommand === "\\boldarabic" || node.wrapperCommand === "\\mathbf") {
|
|
6090
|
+
value.classList.add("node-value--bold");
|
|
6091
|
+
}
|
|
6033
6092
|
}
|
|
6034
6093
|
const surfaceExpr = node.kind === "operator" ? divideOperatorSurfaceExpr(node.expr, side) : node.expr;
|
|
6035
6094
|
value.textContent = surfaceExpr === "" ? "\u25A1" : formatDigits(surfaceExpr, digitForm);
|
|
@@ -6950,6 +7009,11 @@ ${BUTEX_FONT_FACE_CSS}
|
|
|
6950
7009
|
|
|
6951
7010
|
${CHARACTER_FONT_CSS}
|
|
6952
7011
|
|
|
7012
|
+
.node-value--bold {
|
|
7013
|
+
font-family: var(--font-display-ar, Amiri), "Noto Serif Arabic", serif;
|
|
7014
|
+
font-weight: 700;
|
|
7015
|
+
}
|
|
7016
|
+
|
|
6953
7017
|
.chain {
|
|
6954
7018
|
display: inline-flex;
|
|
6955
7019
|
align-items: center;
|
|
@@ -7942,6 +8006,10 @@ function createEditorRuntime(options) {
|
|
|
7942
8006
|
applyTransient((prev) => setCurrentCharacterFont(prev, fontId));
|
|
7943
8007
|
focusInput();
|
|
7944
8008
|
},
|
|
8009
|
+
setCurrentBoldCharacterStyle: () => {
|
|
8010
|
+
applyTransient((prev) => setCurrentBoldCharacterStyle(prev));
|
|
8011
|
+
focusInput();
|
|
8012
|
+
},
|
|
7945
8013
|
setCurrentDigitForm: (digitForm) => {
|
|
7946
8014
|
applyStructural((prev) => setCurrentDigitForm(prev, digitForm));
|
|
7947
8015
|
focusInput();
|
|
@@ -8137,6 +8205,10 @@ var CHAR_FONT_EXPORT_TEX = Object.fromEntries(
|
|
|
8137
8205
|
function charEditorNodeToAstNode(node) {
|
|
8138
8206
|
const font = node.characterFont ?? "default";
|
|
8139
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
|
+
}
|
|
8140
8212
|
if (font === "default") {
|
|
8141
8213
|
return charNode;
|
|
8142
8214
|
}
|
|
@@ -8163,6 +8235,9 @@ function cloneChainWithFreshIds(chain) {
|
|
|
8163
8235
|
return structuredClone(chain);
|
|
8164
8236
|
}
|
|
8165
8237
|
function attachScripts(astNode, editorNode) {
|
|
8238
|
+
if (astNode.sourceLatex) {
|
|
8239
|
+
editorNode.sourceLatex = astNode.sourceLatex;
|
|
8240
|
+
}
|
|
8166
8241
|
if (astNode.superscript) {
|
|
8167
8242
|
const sup = chainToEditorChain(astNode.superscript);
|
|
8168
8243
|
if (!sup.editable) {
|
|
@@ -8289,6 +8364,49 @@ function charFromTextLikeCommand(node) {
|
|
|
8289
8364
|
const scripts = attachScripts(node, editorNode);
|
|
8290
8365
|
return scripts ?? { editable: true, node: editorNode };
|
|
8291
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
|
+
}
|
|
8292
8410
|
function commandToEditorNode(node) {
|
|
8293
8411
|
if (node.name === "\\frac" && node.mandatoryArgs.length >= 2) {
|
|
8294
8412
|
const frac = createFracNode();
|
|
@@ -8378,6 +8496,19 @@ function commandToEditorNode(node) {
|
|
|
8378
8496
|
}
|
|
8379
8497
|
return { editable: true, node: accent };
|
|
8380
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
|
+
}
|
|
8381
8512
|
const atomicId = commandIdForTex(node.name);
|
|
8382
8513
|
if (atomicId && node.optionalArgs.length === 0 && node.mandatoryArgs.length === 0) {
|
|
8383
8514
|
const atomic = createEditorNode("atomicCommand", atomicId);
|
|
@@ -8657,7 +8788,13 @@ function editorNodeToAstNode(node) {
|
|
|
8657
8788
|
if (!tex) {
|
|
8658
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}` };
|
|
8659
8790
|
}
|
|
8660
|
-
|
|
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
|
+
}
|
|
8661
8798
|
} else if (node.kind === "atomicOperatorCommand") {
|
|
8662
8799
|
const tex = atomicOperatorCommandSpec(node.expr)?.Tex;
|
|
8663
8800
|
if (!tex) {
|
|
@@ -8674,6 +8811,9 @@ function editorNodeToAstNode(node) {
|
|
|
8674
8811
|
} else {
|
|
8675
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}` };
|
|
8676
8813
|
}
|
|
8814
|
+
if (node.sourceLatex) {
|
|
8815
|
+
astNode.sourceLatex = node.sourceLatex;
|
|
8816
|
+
}
|
|
8677
8817
|
const scripts = attachAstScripts(node, astNode);
|
|
8678
8818
|
return scripts ?? { ok: true, node: astNode };
|
|
8679
8819
|
}
|
|
@@ -14835,6 +14975,13 @@ ${MATRIX_PICKER_CSS}
|
|
|
14835
14975
|
box-shadow: 0 0 0 3px var(--butex-focus-shadow);
|
|
14836
14976
|
}
|
|
14837
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
|
+
|
|
14838
14985
|
.butex-widget .font-mode-btn--takween,
|
|
14839
14986
|
.butex-widget .character-font-option--takween,
|
|
14840
14987
|
.butex-widget .butex-widget__command-sheet .character-font-option--takween {
|
|
@@ -15664,6 +15811,9 @@ function alignmentTitle(alignment, messages) {
|
|
|
15664
15811
|
if (alignment === "r") return messages.alignColumnRight;
|
|
15665
15812
|
return messages.alignColumnCenter;
|
|
15666
15813
|
}
|
|
15814
|
+
function boldCharacterStyleLabel(uiLocale) {
|
|
15815
|
+
return uiLocale === "ar" ? "\u0639\u0631\u064A\u0636" : "Bold";
|
|
15816
|
+
}
|
|
15667
15817
|
function characterFontTitle(fontId, messages) {
|
|
15668
15818
|
const key = characterFontSpec(fontId).titleKey;
|
|
15669
15819
|
return messages[key] ?? messages.defaultFont;
|
|
@@ -16039,18 +16189,31 @@ function EquationMobileToolbar({
|
|
|
16039
16189
|
sheetView === "typography" ? /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_jsx_runtime13.Fragment, { children: [
|
|
16040
16190
|
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("section", { className: "butex-widget__sheet-section", children: [
|
|
16041
16191
|
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("h4", { children: messages.chooseWritingFont }),
|
|
16042
|
-
/* @__PURE__ */ (0, import_jsx_runtime13.
|
|
16043
|
-
|
|
16044
|
-
|
|
16045
|
-
|
|
16046
|
-
|
|
16047
|
-
|
|
16048
|
-
|
|
16049
|
-
|
|
16050
|
-
|
|
16051
|
-
|
|
16052
|
-
|
|
16053
|
-
|
|
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
|
+
] })
|
|
16054
16217
|
] }),
|
|
16055
16218
|
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
16056
16219
|
"button",
|
|
@@ -16370,6 +16533,9 @@ function digitFormLabel3(digitForm) {
|
|
|
16370
16533
|
function characterFontOption(fontId) {
|
|
16371
16534
|
return CHARACTER_FONT_OPTIONS.find((option) => option.id === fontId) ?? CHARACTER_FONT_OPTIONS[0];
|
|
16372
16535
|
}
|
|
16536
|
+
function boldCharacterStyleLabel2(uiLocale) {
|
|
16537
|
+
return uiLocale === "ar" ? "\u0639\u0631\u064A\u0636" : "Bold";
|
|
16538
|
+
}
|
|
16373
16539
|
function characterFontTitle2(fontId, messages) {
|
|
16374
16540
|
const key = characterFontSpec(fontId).titleKey;
|
|
16375
16541
|
return messages[key] ?? messages.defaultFont;
|
|
@@ -16474,6 +16640,7 @@ var ButexEditor = (0, import_react12.forwardRef)(
|
|
|
16474
16640
|
const [openDesktopMenu, setOpenDesktopMenu] = (0, import_react12.useState)(null);
|
|
16475
16641
|
const [selectedDigitForm2, setSelectedDigitForm] = (0, import_react12.useState)("western");
|
|
16476
16642
|
const [selectedCharacterFont, setSelectedCharacterFont] = (0, import_react12.useState)("default");
|
|
16643
|
+
const [boldCharacterStyle, setBoldCharacterStyle] = (0, import_react12.useState)(initialSession?.currentCharacterWrapper === "\\boldarabic");
|
|
16477
16644
|
const [activeEditorSide, setActiveEditorSide] = (0, import_react12.useState)("arabic");
|
|
16478
16645
|
const [compactPreviewOpen, setCompactPreviewOpen] = (0, import_react12.useState)(false);
|
|
16479
16646
|
const [compactControlState, setCompactControlState] = (0, import_react12.useState)({
|
|
@@ -16626,6 +16793,7 @@ ${arabic || currentMessages.empty}`;
|
|
|
16626
16793
|
runtimeRef.current?.setSession(next);
|
|
16627
16794
|
setSelectedDigitForm(next.currentDigitForm ?? "western");
|
|
16628
16795
|
setSelectedCharacterFont(next.currentCharacterFont ?? "default");
|
|
16796
|
+
setBoldCharacterStyle(next.currentCharacterWrapper === "\\boldarabic");
|
|
16629
16797
|
setActiveEditorSide(next.activeSide);
|
|
16630
16798
|
onSessionChangeRef.current?.(next);
|
|
16631
16799
|
setDebugImportError("");
|
|
@@ -16667,6 +16835,7 @@ ${arabic || currentMessages.empty}`;
|
|
|
16667
16835
|
onSessionChange: (session) => {
|
|
16668
16836
|
setSelectedDigitForm(session.currentDigitForm ?? "western");
|
|
16669
16837
|
setSelectedCharacterFont(session.currentCharacterFont ?? "default");
|
|
16838
|
+
setBoldCharacterStyle(session.currentCharacterWrapper === "\\boldarabic");
|
|
16670
16839
|
setActiveEditorSide(session.activeSide);
|
|
16671
16840
|
const hasSelection = Boolean(session.selection && session.selection.anchorIndex !== session.selection.focusIndex);
|
|
16672
16841
|
const nextCompactState = {
|
|
@@ -16749,6 +16918,7 @@ ${arabic || currentMessages.empty}`;
|
|
|
16749
16918
|
...compactControlState,
|
|
16750
16919
|
activeSide: activeEditorSide,
|
|
16751
16920
|
characterFont: selectedCharacterFont,
|
|
16921
|
+
boldCharacterStyle,
|
|
16752
16922
|
digitForm: selectedDigitForm2
|
|
16753
16923
|
};
|
|
16754
16924
|
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
@@ -17775,35 +17945,54 @@ ${arabic || currentMessages.empty}`;
|
|
|
17775
17945
|
{
|
|
17776
17946
|
ref: characterFontBtnRef,
|
|
17777
17947
|
id: "select-character-font",
|
|
17778
|
-
className: `icon-btn font-mode-btn font-mode-btn--${selectedCharacterFont}`,
|
|
17948
|
+
className: `icon-btn font-mode-btn font-mode-btn--${boldCharacterStyle ? "bold" : selectedCharacterFont}`,
|
|
17779
17949
|
type: "button",
|
|
17780
|
-
title: characterFontTitle2(selectedCharacterFont, messages),
|
|
17950
|
+
title: boldCharacterStyle ? boldCharacterStyleLabel2(uiLocale) : characterFontTitle2(selectedCharacterFont, messages),
|
|
17781
17951
|
"aria-label": messages.chooseWritingFont,
|
|
17782
17952
|
"aria-haspopup": "listbox",
|
|
17783
17953
|
"aria-expanded": characterFontMenuOpen,
|
|
17784
17954
|
onClick: () => setCharacterFontMenuOpen((open) => !open),
|
|
17785
|
-
children: characterFontOption(selectedCharacterFont).label
|
|
17955
|
+
children: boldCharacterStyle ? boldCharacterStyleLabel2(uiLocale) : characterFontOption(selectedCharacterFont).label
|
|
17786
17956
|
}
|
|
17787
17957
|
),
|
|
17788
|
-
/* @__PURE__ */ (0, import_jsx_runtime14.
|
|
17789
|
-
|
|
17790
|
-
|
|
17791
|
-
|
|
17792
|
-
|
|
17793
|
-
|
|
17794
|
-
|
|
17795
|
-
|
|
17796
|
-
|
|
17797
|
-
|
|
17798
|
-
|
|
17799
|
-
|
|
17800
|
-
|
|
17801
|
-
|
|
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
|
|
17802
17992
|
},
|
|
17803
|
-
|
|
17804
|
-
|
|
17805
|
-
|
|
17806
|
-
)) })
|
|
17993
|
+
option.id
|
|
17994
|
+
))
|
|
17995
|
+
] })
|
|
17807
17996
|
]
|
|
17808
17997
|
}
|
|
17809
17998
|
),
|