@drghaliasri/butex 7.2.1 → 7.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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
|
@@ -14,6 +14,7 @@ type ArabicNodeJson = {
|
|
|
14
14
|
opening?: string;
|
|
15
15
|
closing?: string;
|
|
16
16
|
lines?: ChainJson[];
|
|
17
|
+
source_latex?: string;
|
|
17
18
|
};
|
|
18
19
|
type ChainJson = {
|
|
19
20
|
node_type: 'ChainClass';
|
|
@@ -26,6 +27,7 @@ declare class BaseAstNode {
|
|
|
26
27
|
superscript: ChainNode | null;
|
|
27
28
|
subscript: ChainNode | null;
|
|
28
29
|
nodeType: string;
|
|
30
|
+
sourceLatex: string | null;
|
|
29
31
|
constructor(state?: State | null);
|
|
30
32
|
latex(): string;
|
|
31
33
|
arabicLatex(): string;
|
package/dist/react-document.d.ts
CHANGED
|
@@ -14,6 +14,7 @@ type ArabicNodeJson = {
|
|
|
14
14
|
opening?: string;
|
|
15
15
|
closing?: string;
|
|
16
16
|
lines?: ChainJson[];
|
|
17
|
+
source_latex?: string;
|
|
17
18
|
};
|
|
18
19
|
type ChainJson = {
|
|
19
20
|
node_type: 'ChainClass';
|
|
@@ -26,6 +27,7 @@ declare class BaseAstNode {
|
|
|
26
27
|
superscript: ChainNode | null;
|
|
27
28
|
subscript: ChainNode | null;
|
|
28
29
|
nodeType: string;
|
|
30
|
+
sourceLatex: string | null;
|
|
29
31
|
constructor(state?: State | null);
|
|
30
32
|
latex(): string;
|
|
31
33
|
arabicLatex(): string;
|
package/dist/react-document.js
CHANGED
|
@@ -46,6 +46,7 @@ var BaseAstNode = class {
|
|
|
46
46
|
superscript;
|
|
47
47
|
subscript;
|
|
48
48
|
nodeType;
|
|
49
|
+
sourceLatex;
|
|
49
50
|
constructor(state = null) {
|
|
50
51
|
if (state === null) {
|
|
51
52
|
state = new State();
|
|
@@ -54,6 +55,7 @@ var BaseAstNode = class {
|
|
|
54
55
|
this.superscript = null;
|
|
55
56
|
this.subscript = null;
|
|
56
57
|
this.nodeType = this.constructor.name;
|
|
58
|
+
this.sourceLatex = null;
|
|
57
59
|
}
|
|
58
60
|
latex() {
|
|
59
61
|
throw new Error("NotImplementedError");
|
|
@@ -242,6 +244,7 @@ ${this.closing}`;
|
|
|
242
244
|
}
|
|
243
245
|
};
|
|
244
246
|
function parseScripts(node, json, mode) {
|
|
247
|
+
node.sourceLatex = typeof json.source_latex === "string" && json.source_latex.length > 0 ? json.source_latex : null;
|
|
245
248
|
if (json.superscript) {
|
|
246
249
|
node.superscript = parseChain(json.superscript, mode);
|
|
247
250
|
}
|
|
@@ -381,7 +384,8 @@ function fromMathObjectJson(json, mode = "english") {
|
|
|
381
384
|
function scriptsToJson(node, path) {
|
|
382
385
|
return {
|
|
383
386
|
...node.superscript ? { superscript: chainToJson(node.superscript, `${path}.superscript`) } : {},
|
|
384
|
-
...node.subscript ? { subscript: chainToJson(node.subscript, `${path}.subscript`) } : {}
|
|
387
|
+
...node.subscript ? { subscript: chainToJson(node.subscript, `${path}.subscript`) } : {},
|
|
388
|
+
...node.sourceLatex ? { source_latex: node.sourceLatex } : {}
|
|
385
389
|
};
|
|
386
390
|
}
|
|
387
391
|
function nodeToJson(node, path) {
|
|
@@ -1294,6 +1298,15 @@ var ATOMIC_OPERATOR_COMMANDS = {
|
|
|
1294
1298
|
title: "\u0627\u0644\u0644\u0627\u0646\u0647\u0627\u064A\u0629",
|
|
1295
1299
|
svg_path: null
|
|
1296
1300
|
},
|
|
1301
|
+
top: {
|
|
1302
|
+
id: "top",
|
|
1303
|
+
category: "operators1",
|
|
1304
|
+
Tex: "\\top",
|
|
1305
|
+
mirror: false,
|
|
1306
|
+
Label: "\u22A4",
|
|
1307
|
+
title: "\u0627\u0644\u0645\u0646\u0642\u0648\u0644",
|
|
1308
|
+
svg_path: null
|
|
1309
|
+
},
|
|
1297
1310
|
times: {
|
|
1298
1311
|
id: "times",
|
|
1299
1312
|
category: "operators1",
|
|
@@ -2045,6 +2058,7 @@ function cloneEditorSession(session) {
|
|
|
2045
2058
|
forceSplitNextLeaf: session.forceSplitNextLeaf,
|
|
2046
2059
|
arabicReverseNumberTyping: session.arabicReverseNumberTyping,
|
|
2047
2060
|
currentCharacterFont: session.currentCharacterFont ?? "default",
|
|
2061
|
+
currentCharacterWrapper: session.currentCharacterWrapper ?? null,
|
|
2048
2062
|
currentDigitForm: session.currentDigitForm ?? "western",
|
|
2049
2063
|
caret: { ...session.caret },
|
|
2050
2064
|
selection: session.selection ? { ...session.selection } : null,
|
|
@@ -2117,6 +2131,7 @@ function createEditorSession(englishTree, arabicTree, activeSide = "arabic") {
|
|
|
2117
2131
|
forceSplitNextLeaf: false,
|
|
2118
2132
|
arabicReverseNumberTyping: true,
|
|
2119
2133
|
currentCharacterFont: "default",
|
|
2134
|
+
currentCharacterWrapper: null,
|
|
2120
2135
|
currentDigitForm: "western",
|
|
2121
2136
|
caret: {
|
|
2122
2137
|
chainId: englishTree.id,
|
|
@@ -2387,6 +2402,14 @@ function renderNodeEnglish(node, options) {
|
|
|
2387
2402
|
return `${node.expr}${latinScripts(node, options)}`;
|
|
2388
2403
|
}
|
|
2389
2404
|
if (node.kind === "char") {
|
|
2405
|
+
if (node.sourceLatex) {
|
|
2406
|
+
return `${node.sourceLatex}${latinScripts(node, options)}`;
|
|
2407
|
+
}
|
|
2408
|
+
if (node.wrapperCommand) {
|
|
2409
|
+
const expr = formatDigits(node.expr, selectedDigitForm(options));
|
|
2410
|
+
const wrapper = node.wrapperCommand === "\\boldarabic" ? "\\mathbf" : node.wrapperCommand;
|
|
2411
|
+
return `${wrapper}{${escapeText(expr)}}${latinScripts(node, options)}`;
|
|
2412
|
+
}
|
|
2390
2413
|
return `${renderCharContent(node, options)}${latinScripts(node, options)}`;
|
|
2391
2414
|
}
|
|
2392
2415
|
if (node.kind === "operator" && isDivideOperatorExpr(node.expr)) {
|
|
@@ -2440,6 +2463,10 @@ function renderNodeArabic(node, options) {
|
|
|
2440
2463
|
if (node.kind === "char") {
|
|
2441
2464
|
const expr = formatDigits(node.expr, selectedDigitForm(options));
|
|
2442
2465
|
const content = renderCharContent(node, options);
|
|
2466
|
+
if (node.wrapperCommand) {
|
|
2467
|
+
const wrapper = node.wrapperCommand === "\\mathbf" ? "\\boldarabic" : node.wrapperCommand;
|
|
2468
|
+
return arabicScripts(node, `${wrapper}{${content}}`, options);
|
|
2469
|
+
}
|
|
2443
2470
|
return arabicScripts(node, (node.characterFont ?? "default") === "default" ? `\\text{${escapeText(expr)}}` : content, options);
|
|
2444
2471
|
}
|
|
2445
2472
|
if (node.kind === "operator" && isDivideOperatorExpr(node.expr)) {
|
|
@@ -3668,6 +3695,16 @@ function markExprSync(session, nodeId) {
|
|
|
3668
3695
|
}
|
|
3669
3696
|
session.sync[nodeId].expr = english.node.expr === arabic.node.expr ? "synced" : "diverged";
|
|
3670
3697
|
}
|
|
3698
|
+
function clearSourceIdentity(session, nodeId) {
|
|
3699
|
+
const english = findNodeById(session.englishTree, nodeId);
|
|
3700
|
+
const arabic = findNodeById(session.arabicTree, nodeId);
|
|
3701
|
+
if (english) {
|
|
3702
|
+
delete english.node.sourceLatex;
|
|
3703
|
+
}
|
|
3704
|
+
if (arabic) {
|
|
3705
|
+
delete arabic.node.sourceLatex;
|
|
3706
|
+
}
|
|
3707
|
+
}
|
|
3671
3708
|
function syncSelectionToCaret(session) {
|
|
3672
3709
|
const activeKey = activeTreeKey(session.activeSide);
|
|
3673
3710
|
const tree = session[activeKey];
|
|
@@ -4251,7 +4288,10 @@ function insertLeaf(session, kind, expr) {
|
|
|
4251
4288
|
const next = cloneEditorSession(session);
|
|
4252
4289
|
const englishNode = createEditorNode(kind, expr);
|
|
4253
4290
|
const arabicNode = createEditorNode(kind, expr);
|
|
4254
|
-
if (kind === "char" &&
|
|
4291
|
+
if (kind === "char" && next.currentCharacterWrapper === "\\boldarabic") {
|
|
4292
|
+
englishNode.wrapperCommand = "\\boldarabic";
|
|
4293
|
+
arabicNode.wrapperCommand = "\\boldarabic";
|
|
4294
|
+
} else if (kind === "char" && (next.currentCharacterFont ?? "default") !== "default") {
|
|
4255
4295
|
englishNode.characterFont = next.currentCharacterFont;
|
|
4256
4296
|
arabicNode.characterFont = next.currentCharacterFont;
|
|
4257
4297
|
}
|
|
@@ -4266,8 +4306,12 @@ function insertLeaf(session, kind, expr) {
|
|
|
4266
4306
|
function shouldReverseArabicNumber(session) {
|
|
4267
4307
|
return session.activeSide === "arabic" && session.arabicReverseNumberTyping;
|
|
4268
4308
|
}
|
|
4269
|
-
function
|
|
4270
|
-
|
|
4309
|
+
function characterTypingStyleOf(node) {
|
|
4310
|
+
if (node.kind !== "char") return "none";
|
|
4311
|
+
return node.wrapperCommand ? `wrapper:${node.wrapperCommand}` : `font:${node.characterFont ?? "default"}`;
|
|
4312
|
+
}
|
|
4313
|
+
function currentCharacterTypingStyle(session) {
|
|
4314
|
+
return session.currentCharacterWrapper ? `wrapper:${session.currentCharacterWrapper}` : `font:${session.currentCharacterFont ?? "default"}`;
|
|
4271
4315
|
}
|
|
4272
4316
|
function tryMergeLeafTyping(session, kind, fragment) {
|
|
4273
4317
|
const engLocated = findChainById(session.englishTree, session.caret.chainId);
|
|
@@ -4280,14 +4324,14 @@ function tryMergeLeafTyping(session, kind, fragment) {
|
|
|
4280
4324
|
let prepend = false;
|
|
4281
4325
|
if (i > 0) {
|
|
4282
4326
|
const prev = nodes[i - 1];
|
|
4283
|
-
if (prev.kind === kind && (kind !== "char" ||
|
|
4327
|
+
if (prev.kind === kind && (kind !== "char" || characterTypingStyleOf(prev) === currentCharacterTypingStyle(session))) {
|
|
4284
4328
|
targetId = prev.id;
|
|
4285
4329
|
prepend = false;
|
|
4286
4330
|
}
|
|
4287
4331
|
}
|
|
4288
4332
|
if (!targetId && i < nodes.length) {
|
|
4289
4333
|
const fwd = nodes[i];
|
|
4290
|
-
if (fwd.kind === kind && (kind !== "char" ||
|
|
4334
|
+
if (fwd.kind === kind && (kind !== "char" || characterTypingStyleOf(fwd) === currentCharacterTypingStyle(session))) {
|
|
4291
4335
|
targetId = fwd.id;
|
|
4292
4336
|
prepend = true;
|
|
4293
4337
|
}
|
|
@@ -4308,6 +4352,7 @@ function tryMergeLeafTyping(session, kind, fragment) {
|
|
|
4308
4352
|
englishHit.node.expr = `${englishHit.node.expr}${fragment}`;
|
|
4309
4353
|
arabicHit.node.expr = `${arabicHit.node.expr}${fragment}`;
|
|
4310
4354
|
}
|
|
4355
|
+
clearSourceIdentity(session, targetId);
|
|
4311
4356
|
markExprSync(session, targetId);
|
|
4312
4357
|
return true;
|
|
4313
4358
|
}
|
|
@@ -4346,9 +4391,17 @@ function breakLeafTyping(session) {
|
|
|
4346
4391
|
function setCurrentCharacterFont(session, fontId) {
|
|
4347
4392
|
const next = cloneEditorSession(session);
|
|
4348
4393
|
next.currentCharacterFont = fontId;
|
|
4394
|
+
next.currentCharacterWrapper = null;
|
|
4349
4395
|
appendDebug(next, "setCurrentCharacterFont", fontId);
|
|
4350
4396
|
return next;
|
|
4351
4397
|
}
|
|
4398
|
+
function setCurrentBoldCharacterStyle(session) {
|
|
4399
|
+
const next = cloneEditorSession(session);
|
|
4400
|
+
next.currentCharacterFont = "default";
|
|
4401
|
+
next.currentCharacterWrapper = "\\boldarabic";
|
|
4402
|
+
appendDebug(next, "setCurrentBoldCharacterStyle", "\\boldarabic");
|
|
4403
|
+
return next;
|
|
4404
|
+
}
|
|
4352
4405
|
function toggleTakweenCharacterFont(session) {
|
|
4353
4406
|
return setCurrentCharacterFont(session, (session.currentCharacterFont ?? "default") === "takween" ? "default" : "takween");
|
|
4354
4407
|
}
|
|
@@ -4897,6 +4950,7 @@ function deleteBackward(session) {
|
|
|
4897
4950
|
englishHit.node.expr = englishHit.node.expr.slice(0, -1);
|
|
4898
4951
|
arabicHit.node.expr = arabicHit.node.expr.slice(0, -1);
|
|
4899
4952
|
}
|
|
4953
|
+
clearSourceIdentity(next, id);
|
|
4900
4954
|
markExprSync(next, id);
|
|
4901
4955
|
next.selectedStructureNodeId = null;
|
|
4902
4956
|
syncSelectionToCaret(next);
|
|
@@ -4946,6 +5000,7 @@ function deleteForward(session) {
|
|
|
4946
5000
|
englishHit.node.expr = englishHit.node.expr.slice(1);
|
|
4947
5001
|
arabicHit.node.expr = arabicHit.node.expr.slice(1);
|
|
4948
5002
|
}
|
|
5003
|
+
clearSourceIdentity(next, node.id);
|
|
4949
5004
|
markExprSync(next, node.id);
|
|
4950
5005
|
next.selectedStructureNodeId = null;
|
|
4951
5006
|
syncSelectionToCaret(next);
|
|
@@ -4975,6 +5030,7 @@ function createStarterSession() {
|
|
|
4975
5030
|
forceSplitNextLeaf: false,
|
|
4976
5031
|
arabicReverseNumberTyping: true,
|
|
4977
5032
|
currentCharacterFont: "default",
|
|
5033
|
+
currentCharacterWrapper: null,
|
|
4978
5034
|
currentDigitForm: "western",
|
|
4979
5035
|
caret: {
|
|
4980
5036
|
chainId: englishRoot.id,
|
|
@@ -5100,6 +5156,9 @@ function buildBaseNodeBody(node, digitForm = "western", side = "english") {
|
|
|
5100
5156
|
if (cssClass) {
|
|
5101
5157
|
value.classList.add(cssClass);
|
|
5102
5158
|
}
|
|
5159
|
+
if (node.wrapperCommand === "\\boldarabic" || node.wrapperCommand === "\\mathbf") {
|
|
5160
|
+
value.classList.add("node-value--bold");
|
|
5161
|
+
}
|
|
5103
5162
|
}
|
|
5104
5163
|
const surfaceExpr = node.kind === "operator" ? divideOperatorSurfaceExpr(node.expr, side) : node.expr;
|
|
5105
5164
|
value.textContent = surfaceExpr === "" ? "\u25A1" : formatDigits(surfaceExpr, digitForm);
|
|
@@ -6020,6 +6079,11 @@ ${BUTEX_FONT_FACE_CSS}
|
|
|
6020
6079
|
|
|
6021
6080
|
${CHARACTER_FONT_CSS}
|
|
6022
6081
|
|
|
6082
|
+
.node-value--bold {
|
|
6083
|
+
font-family: var(--font-display-ar, Amiri), "Noto Serif Arabic", serif;
|
|
6084
|
+
font-weight: 700;
|
|
6085
|
+
}
|
|
6086
|
+
|
|
6023
6087
|
.chain {
|
|
6024
6088
|
display: inline-flex;
|
|
6025
6089
|
align-items: center;
|
|
@@ -7012,6 +7076,10 @@ function createEditorRuntime(options) {
|
|
|
7012
7076
|
applyTransient((prev) => setCurrentCharacterFont(prev, fontId));
|
|
7013
7077
|
focusInput();
|
|
7014
7078
|
},
|
|
7079
|
+
setCurrentBoldCharacterStyle: () => {
|
|
7080
|
+
applyTransient((prev) => setCurrentBoldCharacterStyle(prev));
|
|
7081
|
+
focusInput();
|
|
7082
|
+
},
|
|
7015
7083
|
setCurrentDigitForm: (digitForm) => {
|
|
7016
7084
|
applyStructural((prev) => setCurrentDigitForm(prev, digitForm));
|
|
7017
7085
|
focusInput();
|
|
@@ -7207,6 +7275,10 @@ var CHAR_FONT_EXPORT_TEX = Object.fromEntries(
|
|
|
7207
7275
|
function charEditorNodeToAstNode(node) {
|
|
7208
7276
|
const font = node.characterFont ?? "default";
|
|
7209
7277
|
const charNode = new CharNode(node.expr);
|
|
7278
|
+
if (node.wrapperCommand) {
|
|
7279
|
+
const wrapper = node.wrapperCommand === "\\boldarabic" ? "\\mathbf" : node.wrapperCommand;
|
|
7280
|
+
return new CommandNode(wrapper, [], [new ChainNode([charNode])]);
|
|
7281
|
+
}
|
|
7210
7282
|
if (font === "default") {
|
|
7211
7283
|
return charNode;
|
|
7212
7284
|
}
|
|
@@ -7233,6 +7305,9 @@ function cloneChainWithFreshIds(chain) {
|
|
|
7233
7305
|
return structuredClone(chain);
|
|
7234
7306
|
}
|
|
7235
7307
|
function attachScripts(astNode, editorNode) {
|
|
7308
|
+
if (astNode.sourceLatex) {
|
|
7309
|
+
editorNode.sourceLatex = astNode.sourceLatex;
|
|
7310
|
+
}
|
|
7236
7311
|
if (astNode.superscript) {
|
|
7237
7312
|
const sup = chainToEditorChain(astNode.superscript);
|
|
7238
7313
|
if (!sup.editable) {
|
|
@@ -7359,6 +7434,49 @@ function charFromTextLikeCommand(node) {
|
|
|
7359
7434
|
const scripts = attachScripts(node, editorNode);
|
|
7360
7435
|
return scripts ?? { editable: true, node: editorNode };
|
|
7361
7436
|
}
|
|
7437
|
+
function singleCommandChar(node) {
|
|
7438
|
+
if (node.optionalArgs.length > 0 || node.mandatoryArgs.length !== 1) {
|
|
7439
|
+
return null;
|
|
7440
|
+
}
|
|
7441
|
+
const arg = node.mandatoryArgs[0];
|
|
7442
|
+
if (arg.chain.length !== 1 || !(arg.chain[0] instanceof CharNode)) {
|
|
7443
|
+
return null;
|
|
7444
|
+
}
|
|
7445
|
+
return arg.chain[0];
|
|
7446
|
+
}
|
|
7447
|
+
function wrappedAtomicCommandId(node) {
|
|
7448
|
+
if (node.name !== "\\mathbb" && node.name !== "\\mathrm") {
|
|
7449
|
+
return null;
|
|
7450
|
+
}
|
|
7451
|
+
const child = singleCommandChar(node);
|
|
7452
|
+
if (!child) {
|
|
7453
|
+
return null;
|
|
7454
|
+
}
|
|
7455
|
+
return commandIdForTex(`${node.name}{${child.expr}}`);
|
|
7456
|
+
}
|
|
7457
|
+
function editableWrapperCommand(node) {
|
|
7458
|
+
if (node.name !== "\\mathtt" && node.name !== "\\mathsf" && node.name !== "\\unit" && node.name !== "\\mathbf" && node.name !== "\\boldarabic") {
|
|
7459
|
+
return null;
|
|
7460
|
+
}
|
|
7461
|
+
const child = singleCommandChar(node);
|
|
7462
|
+
if (!child) {
|
|
7463
|
+
return null;
|
|
7464
|
+
}
|
|
7465
|
+
const normalized = normalizeCharImportExpr(child.expr);
|
|
7466
|
+
const editorNode = createEditorNode("char", normalized.expr);
|
|
7467
|
+
if (normalized.characterFont !== "default") {
|
|
7468
|
+
editorNode.characterFont = normalized.characterFont;
|
|
7469
|
+
}
|
|
7470
|
+
editorNode.wrapperCommand = node.name === "\\mathtt" ? "\\mathtt" : node.name === "\\mathbf" ? "\\mathbf" : node.name === "\\boldarabic" ? "\\boldarabic" : "\\unit";
|
|
7471
|
+
const scripts = attachScripts(node, editorNode);
|
|
7472
|
+
if (scripts) {
|
|
7473
|
+
return scripts;
|
|
7474
|
+
}
|
|
7475
|
+
if (!editorNode.sourceLatex && node.name === "\\mathsf") {
|
|
7476
|
+
editorNode.sourceLatex = `\\mathsf{${child.expr}}`;
|
|
7477
|
+
}
|
|
7478
|
+
return { editable: true, node: editorNode };
|
|
7479
|
+
}
|
|
7362
7480
|
function commandToEditorNode(node) {
|
|
7363
7481
|
if (node.name === "\\frac" && node.mandatoryArgs.length >= 2) {
|
|
7364
7482
|
const frac = createFracNode();
|
|
@@ -7448,6 +7566,19 @@ function commandToEditorNode(node) {
|
|
|
7448
7566
|
}
|
|
7449
7567
|
return { editable: true, node: accent };
|
|
7450
7568
|
}
|
|
7569
|
+
const wrappedAtomicId = wrappedAtomicCommandId(node);
|
|
7570
|
+
if (wrappedAtomicId) {
|
|
7571
|
+
const atomic = createEditorNode("atomicCommand", wrappedAtomicId);
|
|
7572
|
+
const scripts = attachScripts(node, atomic);
|
|
7573
|
+
if (scripts) {
|
|
7574
|
+
return scripts;
|
|
7575
|
+
}
|
|
7576
|
+
return { editable: true, node: atomic };
|
|
7577
|
+
}
|
|
7578
|
+
const wrapper = editableWrapperCommand(node);
|
|
7579
|
+
if (wrapper) {
|
|
7580
|
+
return wrapper;
|
|
7581
|
+
}
|
|
7451
7582
|
const atomicId = commandIdForTex(node.name);
|
|
7452
7583
|
if (atomicId && node.optionalArgs.length === 0 && node.mandatoryArgs.length === 0) {
|
|
7453
7584
|
const atomic = createEditorNode("atomicCommand", atomicId);
|
|
@@ -7727,7 +7858,13 @@ function editorNodeToAstNode(node) {
|
|
|
7727
7858
|
if (!tex) {
|
|
7728
7859
|
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}` };
|
|
7729
7860
|
}
|
|
7730
|
-
|
|
7861
|
+
if (node.expr === "ad") {
|
|
7862
|
+
astNode = new CommandNode("\\mathrm", [], [new ChainNode([new CharNode("d")])]);
|
|
7863
|
+
} else if (["N", "Z", "Q", "R", "C", "H"].includes(node.expr)) {
|
|
7864
|
+
astNode = new CommandNode("\\mathbb", [], [new ChainNode([new CharNode(node.expr)])]);
|
|
7865
|
+
} else {
|
|
7866
|
+
astNode = new CommandNode(tex);
|
|
7867
|
+
}
|
|
7731
7868
|
} else if (node.kind === "atomicOperatorCommand") {
|
|
7732
7869
|
const tex = atomicOperatorCommandSpec(node.expr)?.Tex;
|
|
7733
7870
|
if (!tex) {
|
|
@@ -7744,6 +7881,9 @@ function editorNodeToAstNode(node) {
|
|
|
7744
7881
|
} else {
|
|
7745
7882
|
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}` };
|
|
7746
7883
|
}
|
|
7884
|
+
if (node.sourceLatex) {
|
|
7885
|
+
astNode.sourceLatex = node.sourceLatex;
|
|
7886
|
+
}
|
|
7747
7887
|
const scripts = attachAstScripts(node, astNode);
|
|
7748
7888
|
return scripts ?? { ok: true, node: astNode };
|
|
7749
7889
|
}
|
|
@@ -9314,6 +9454,13 @@ ${MATRIX_PICKER_CSS}
|
|
|
9314
9454
|
box-shadow: 0 0 0 3px var(--butex-focus-shadow);
|
|
9315
9455
|
}
|
|
9316
9456
|
|
|
9457
|
+
.butex-widget .font-mode-btn--bold,
|
|
9458
|
+
.butex-widget .character-font-option--bold,
|
|
9459
|
+
.butex-widget .butex-widget__command-sheet .character-font-option--bold {
|
|
9460
|
+
font-family: var(--font-display-ar, Amiri), "Noto Serif Arabic", serif;
|
|
9461
|
+
font-weight: 700;
|
|
9462
|
+
}
|
|
9463
|
+
|
|
9317
9464
|
.butex-widget .font-mode-btn--takween,
|
|
9318
9465
|
.butex-widget .character-font-option--takween,
|
|
9319
9466
|
.butex-widget .butex-widget__command-sheet .character-font-option--takween {
|
|
@@ -10285,6 +10432,9 @@ function alignmentTitle(alignment, messages) {
|
|
|
10285
10432
|
if (alignment === "r") return messages.alignColumnRight;
|
|
10286
10433
|
return messages.alignColumnCenter;
|
|
10287
10434
|
}
|
|
10435
|
+
function boldCharacterStyleLabel(uiLocale) {
|
|
10436
|
+
return uiLocale === "ar" ? "\u0639\u0631\u064A\u0636" : "Bold";
|
|
10437
|
+
}
|
|
10288
10438
|
function characterFontTitle(fontId, messages) {
|
|
10289
10439
|
const key = characterFontSpec(fontId).titleKey;
|
|
10290
10440
|
return messages[key] ?? messages.defaultFont;
|
|
@@ -10660,18 +10810,31 @@ function EquationMobileToolbar({
|
|
|
10660
10810
|
sheetView === "typography" ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
10661
10811
|
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("section", { className: "butex-widget__sheet-section", children: [
|
|
10662
10812
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("h4", { children: messages.chooseWritingFont }),
|
|
10663
|
-
/* @__PURE__ */ (0, import_jsx_runtime.
|
|
10664
|
-
|
|
10665
|
-
|
|
10666
|
-
|
|
10667
|
-
|
|
10668
|
-
|
|
10669
|
-
|
|
10670
|
-
|
|
10671
|
-
|
|
10672
|
-
|
|
10673
|
-
|
|
10674
|
-
|
|
10813
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "butex-widget__sheet-choice-row", children: [
|
|
10814
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
10815
|
+
"button",
|
|
10816
|
+
{
|
|
10817
|
+
type: "button",
|
|
10818
|
+
className: "character-font-option--bold",
|
|
10819
|
+
"aria-pressed": state.boldCharacterStyle,
|
|
10820
|
+
title: boldCharacterStyleLabel(uiLocale),
|
|
10821
|
+
onClick: (event) => runAndKeepFocus(event.currentTarget, (runtime) => runtime.setCurrentBoldCharacterStyle()),
|
|
10822
|
+
children: boldCharacterStyleLabel(uiLocale)
|
|
10823
|
+
}
|
|
10824
|
+
),
|
|
10825
|
+
CHARACTER_FONT_OPTIONS.map((option) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
10826
|
+
"button",
|
|
10827
|
+
{
|
|
10828
|
+
type: "button",
|
|
10829
|
+
className: `character-font-option--${option.id}`,
|
|
10830
|
+
"aria-pressed": !state.boldCharacterStyle && state.characterFont === option.id,
|
|
10831
|
+
title: characterFontTitle(option.id, messages),
|
|
10832
|
+
onClick: (event) => runAndKeepFocus(event.currentTarget, (runtime) => runtime.setCurrentCharacterFont(option.id)),
|
|
10833
|
+
children: option.label
|
|
10834
|
+
},
|
|
10835
|
+
option.id
|
|
10836
|
+
))
|
|
10837
|
+
] })
|
|
10675
10838
|
] }),
|
|
10676
10839
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
10677
10840
|
"button",
|
|
@@ -10991,6 +11154,9 @@ function digitFormLabel(digitForm) {
|
|
|
10991
11154
|
function characterFontOption(fontId) {
|
|
10992
11155
|
return CHARACTER_FONT_OPTIONS.find((option) => option.id === fontId) ?? CHARACTER_FONT_OPTIONS[0];
|
|
10993
11156
|
}
|
|
11157
|
+
function boldCharacterStyleLabel2(uiLocale) {
|
|
11158
|
+
return uiLocale === "ar" ? "\u0639\u0631\u064A\u0636" : "Bold";
|
|
11159
|
+
}
|
|
10994
11160
|
function characterFontTitle2(fontId, messages) {
|
|
10995
11161
|
const key = characterFontSpec(fontId).titleKey;
|
|
10996
11162
|
return messages[key] ?? messages.defaultFont;
|
|
@@ -11095,6 +11261,7 @@ var ButexEditor = (0, import_react4.forwardRef)(
|
|
|
11095
11261
|
const [openDesktopMenu, setOpenDesktopMenu] = (0, import_react4.useState)(null);
|
|
11096
11262
|
const [selectedDigitForm2, setSelectedDigitForm] = (0, import_react4.useState)("western");
|
|
11097
11263
|
const [selectedCharacterFont, setSelectedCharacterFont] = (0, import_react4.useState)("default");
|
|
11264
|
+
const [boldCharacterStyle, setBoldCharacterStyle] = (0, import_react4.useState)(initialSession?.currentCharacterWrapper === "\\boldarabic");
|
|
11098
11265
|
const [activeEditorSide, setActiveEditorSide] = (0, import_react4.useState)("arabic");
|
|
11099
11266
|
const [compactPreviewOpen, setCompactPreviewOpen] = (0, import_react4.useState)(false);
|
|
11100
11267
|
const [compactControlState, setCompactControlState] = (0, import_react4.useState)({
|
|
@@ -11247,6 +11414,7 @@ ${arabic || currentMessages.empty}`;
|
|
|
11247
11414
|
runtimeRef.current?.setSession(next);
|
|
11248
11415
|
setSelectedDigitForm(next.currentDigitForm ?? "western");
|
|
11249
11416
|
setSelectedCharacterFont(next.currentCharacterFont ?? "default");
|
|
11417
|
+
setBoldCharacterStyle(next.currentCharacterWrapper === "\\boldarabic");
|
|
11250
11418
|
setActiveEditorSide(next.activeSide);
|
|
11251
11419
|
onSessionChangeRef.current?.(next);
|
|
11252
11420
|
setDebugImportError("");
|
|
@@ -11288,6 +11456,7 @@ ${arabic || currentMessages.empty}`;
|
|
|
11288
11456
|
onSessionChange: (session) => {
|
|
11289
11457
|
setSelectedDigitForm(session.currentDigitForm ?? "western");
|
|
11290
11458
|
setSelectedCharacterFont(session.currentCharacterFont ?? "default");
|
|
11459
|
+
setBoldCharacterStyle(session.currentCharacterWrapper === "\\boldarabic");
|
|
11291
11460
|
setActiveEditorSide(session.activeSide);
|
|
11292
11461
|
const hasSelection = Boolean(session.selection && session.selection.anchorIndex !== session.selection.focusIndex);
|
|
11293
11462
|
const nextCompactState = {
|
|
@@ -11370,6 +11539,7 @@ ${arabic || currentMessages.empty}`;
|
|
|
11370
11539
|
...compactControlState,
|
|
11371
11540
|
activeSide: activeEditorSide,
|
|
11372
11541
|
characterFont: selectedCharacterFont,
|
|
11542
|
+
boldCharacterStyle,
|
|
11373
11543
|
digitForm: selectedDigitForm2
|
|
11374
11544
|
};
|
|
11375
11545
|
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
@@ -12396,35 +12566,54 @@ ${arabic || currentMessages.empty}`;
|
|
|
12396
12566
|
{
|
|
12397
12567
|
ref: characterFontBtnRef,
|
|
12398
12568
|
id: "select-character-font",
|
|
12399
|
-
className: `icon-btn font-mode-btn font-mode-btn--${selectedCharacterFont}`,
|
|
12569
|
+
className: `icon-btn font-mode-btn font-mode-btn--${boldCharacterStyle ? "bold" : selectedCharacterFont}`,
|
|
12400
12570
|
type: "button",
|
|
12401
|
-
title: characterFontTitle2(selectedCharacterFont, messages),
|
|
12571
|
+
title: boldCharacterStyle ? boldCharacterStyleLabel2(uiLocale) : characterFontTitle2(selectedCharacterFont, messages),
|
|
12402
12572
|
"aria-label": messages.chooseWritingFont,
|
|
12403
12573
|
"aria-haspopup": "listbox",
|
|
12404
12574
|
"aria-expanded": characterFontMenuOpen,
|
|
12405
12575
|
onClick: () => setCharacterFontMenuOpen((open) => !open),
|
|
12406
|
-
children: characterFontOption(selectedCharacterFont).label
|
|
12576
|
+
children: boldCharacterStyle ? boldCharacterStyleLabel2(uiLocale) : characterFontOption(selectedCharacterFont).label
|
|
12407
12577
|
}
|
|
12408
12578
|
),
|
|
12409
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.
|
|
12410
|
-
|
|
12411
|
-
|
|
12412
|
-
|
|
12413
|
-
|
|
12414
|
-
|
|
12415
|
-
|
|
12416
|
-
|
|
12417
|
-
|
|
12418
|
-
|
|
12419
|
-
|
|
12420
|
-
|
|
12421
|
-
|
|
12422
|
-
|
|
12579
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "character-font-options", role: "listbox", "aria-label": messages.chooseWritingFont, hidden: !characterFontMenuOpen, children: [
|
|
12580
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
12581
|
+
"button",
|
|
12582
|
+
{
|
|
12583
|
+
type: "button",
|
|
12584
|
+
role: "option",
|
|
12585
|
+
"aria-selected": boldCharacterStyle,
|
|
12586
|
+
className: "character-font-option character-font-option--bold",
|
|
12587
|
+
title: boldCharacterStyleLabel2(uiLocale),
|
|
12588
|
+
onMouseDown: (event) => event.preventDefault(),
|
|
12589
|
+
onClick: () => {
|
|
12590
|
+
runtimeRef.current?.setCurrentBoldCharacterStyle();
|
|
12591
|
+
setCharacterFontMenuOpen(false);
|
|
12592
|
+
focusSurface();
|
|
12593
|
+
},
|
|
12594
|
+
children: boldCharacterStyleLabel2(uiLocale)
|
|
12595
|
+
}
|
|
12596
|
+
),
|
|
12597
|
+
CHARACTER_FONT_OPTIONS.map((option) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
12598
|
+
"button",
|
|
12599
|
+
{
|
|
12600
|
+
type: "button",
|
|
12601
|
+
role: "option",
|
|
12602
|
+
"aria-selected": !boldCharacterStyle && selectedCharacterFont === option.id,
|
|
12603
|
+
className: `character-font-option character-font-option--${option.id}`,
|
|
12604
|
+
title: characterFontTitle2(option.id, messages),
|
|
12605
|
+
onMouseDown: (event) => event.preventDefault(),
|
|
12606
|
+
onClick: () => {
|
|
12607
|
+
runtimeRef.current?.setCurrentCharacterFont(option.id);
|
|
12608
|
+
setSelectedCharacterFont(option.id);
|
|
12609
|
+
setCharacterFontMenuOpen(false);
|
|
12610
|
+
focusSurface();
|
|
12611
|
+
},
|
|
12612
|
+
children: option.label
|
|
12423
12613
|
},
|
|
12424
|
-
|
|
12425
|
-
|
|
12426
|
-
|
|
12427
|
-
)) })
|
|
12614
|
+
option.id
|
|
12615
|
+
))
|
|
12616
|
+
] })
|
|
12428
12617
|
]
|
|
12429
12618
|
}
|
|
12430
12619
|
),
|