@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/index.js
CHANGED
|
@@ -203,6 +203,18 @@ mjx-container[jax="CHTML"] .butex-preview-mirror {
|
|
|
203
203
|
font-family: ${BUTEX_DIWANI_OUTLINE_FONT_STACK} !important;
|
|
204
204
|
}
|
|
205
205
|
|
|
206
|
+
.butex-bold-text {
|
|
207
|
+
font-family: var(--font-display-ar, Amiri), "Noto Serif Arabic", serif;
|
|
208
|
+
font-weight: 700;
|
|
209
|
+
direction: rtl;
|
|
210
|
+
unicode-bidi: isolate;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
.butex-bold-text mjx-utext {
|
|
214
|
+
font-family: var(--font-display-ar, Amiri), "Noto Serif Arabic", serif !important;
|
|
215
|
+
font-weight: 700;
|
|
216
|
+
}
|
|
217
|
+
|
|
206
218
|
.butex-takween-text {
|
|
207
219
|
font-family: ${BUTEX_TAKWEEN_FONT_STACK};
|
|
208
220
|
direction: rtl;
|
|
@@ -850,12 +862,15 @@ function fontText(className, parser, name) {
|
|
|
850
862
|
parser.Push(node);
|
|
851
863
|
}
|
|
852
864
|
function registerFontTextCommands(CommandMap) {
|
|
853
|
-
const mappings =
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
((
|
|
857
|
-
|
|
858
|
-
|
|
865
|
+
const mappings = {
|
|
866
|
+
boldarabic: ((parser, name) => fontText("butex-bold-text", parser, name)),
|
|
867
|
+
...Object.fromEntries(
|
|
868
|
+
NON_DEFAULT_CHARACTER_FONT_SPECS.filter((font) => font.mathJaxClass).map((font) => [
|
|
869
|
+
font.macro.replace(/^\\/, ""),
|
|
870
|
+
((parser, name) => fontText(font.mathJaxClass, parser, name))
|
|
871
|
+
])
|
|
872
|
+
)
|
|
873
|
+
};
|
|
859
874
|
new CommandMap(COMMAND_MAP5, mappings);
|
|
860
875
|
return COMMAND_MAP5;
|
|
861
876
|
}
|
|
@@ -2153,6 +2168,15 @@ var ATOMIC_OPERATOR_COMMANDS = {
|
|
|
2153
2168
|
title: "\u0627\u0644\u0644\u0627\u0646\u0647\u0627\u064A\u0629",
|
|
2154
2169
|
svg_path: null
|
|
2155
2170
|
},
|
|
2171
|
+
top: {
|
|
2172
|
+
id: "top",
|
|
2173
|
+
category: "operators1",
|
|
2174
|
+
Tex: "\\top",
|
|
2175
|
+
mirror: false,
|
|
2176
|
+
Label: "\u22A4",
|
|
2177
|
+
title: "\u0627\u0644\u0645\u0646\u0642\u0648\u0644",
|
|
2178
|
+
svg_path: null
|
|
2179
|
+
},
|
|
2156
2180
|
times: {
|
|
2157
2181
|
id: "times",
|
|
2158
2182
|
category: "operators1",
|
|
@@ -2941,6 +2965,11 @@ ${BUTEX_FONT_FACE_CSS}
|
|
|
2941
2965
|
|
|
2942
2966
|
${CHARACTER_FONT_CSS}
|
|
2943
2967
|
|
|
2968
|
+
.node-value--bold {
|
|
2969
|
+
font-family: var(--font-display-ar, Amiri), "Noto Serif Arabic", serif;
|
|
2970
|
+
font-weight: 700;
|
|
2971
|
+
}
|
|
2972
|
+
|
|
2944
2973
|
.chain {
|
|
2945
2974
|
display: inline-flex;
|
|
2946
2975
|
align-items: center;
|
|
@@ -3255,6 +3284,7 @@ __export(editor_exports, {
|
|
|
3255
3284
|
setArabicReverseNumberTyping: () => setArabicReverseNumberTyping,
|
|
3256
3285
|
setArrayColumnAlignment: () => setArrayColumnAlignment,
|
|
3257
3286
|
setCaret: () => setCaret,
|
|
3287
|
+
setCurrentBoldCharacterStyle: () => setCurrentBoldCharacterStyle,
|
|
3258
3288
|
setCurrentCharacterFont: () => setCurrentCharacterFont,
|
|
3259
3289
|
setCurrentDigitForm: () => setCurrentDigitForm,
|
|
3260
3290
|
setExpr: () => setExpr,
|
|
@@ -3385,6 +3415,7 @@ function cloneEditorSession(session) {
|
|
|
3385
3415
|
forceSplitNextLeaf: session.forceSplitNextLeaf,
|
|
3386
3416
|
arabicReverseNumberTyping: session.arabicReverseNumberTyping,
|
|
3387
3417
|
currentCharacterFont: session.currentCharacterFont ?? "default",
|
|
3418
|
+
currentCharacterWrapper: session.currentCharacterWrapper ?? null,
|
|
3388
3419
|
currentDigitForm: session.currentDigitForm ?? "western",
|
|
3389
3420
|
caret: { ...session.caret },
|
|
3390
3421
|
selection: session.selection ? { ...session.selection } : null,
|
|
@@ -3457,6 +3488,7 @@ function createEditorSession(englishTree, arabicTree, activeSide = "arabic") {
|
|
|
3457
3488
|
forceSplitNextLeaf: false,
|
|
3458
3489
|
arabicReverseNumberTyping: true,
|
|
3459
3490
|
currentCharacterFont: "default",
|
|
3491
|
+
currentCharacterWrapper: null,
|
|
3460
3492
|
currentDigitForm: "western",
|
|
3461
3493
|
caret: {
|
|
3462
3494
|
chainId: englishTree.id,
|
|
@@ -3659,6 +3691,14 @@ function renderNodeEnglish(node, options) {
|
|
|
3659
3691
|
return `${node.expr}${latinScripts(node, options)}`;
|
|
3660
3692
|
}
|
|
3661
3693
|
if (node.kind === "char") {
|
|
3694
|
+
if (node.sourceLatex) {
|
|
3695
|
+
return `${node.sourceLatex}${latinScripts(node, options)}`;
|
|
3696
|
+
}
|
|
3697
|
+
if (node.wrapperCommand) {
|
|
3698
|
+
const expr = formatDigits(node.expr, selectedDigitForm(options));
|
|
3699
|
+
const wrapper = node.wrapperCommand === "\\boldarabic" ? "\\mathbf" : node.wrapperCommand;
|
|
3700
|
+
return `${wrapper}{${escapeText(expr)}}${latinScripts(node, options)}`;
|
|
3701
|
+
}
|
|
3662
3702
|
return `${renderCharContent(node, options)}${latinScripts(node, options)}`;
|
|
3663
3703
|
}
|
|
3664
3704
|
if (node.kind === "operator" && isDivideOperatorExpr(node.expr)) {
|
|
@@ -3712,6 +3752,10 @@ function renderNodeArabic(node, options) {
|
|
|
3712
3752
|
if (node.kind === "char") {
|
|
3713
3753
|
const expr = formatDigits(node.expr, selectedDigitForm(options));
|
|
3714
3754
|
const content = renderCharContent(node, options);
|
|
3755
|
+
if (node.wrapperCommand) {
|
|
3756
|
+
const wrapper = node.wrapperCommand === "\\mathbf" ? "\\boldarabic" : node.wrapperCommand;
|
|
3757
|
+
return arabicScripts(node, `${wrapper}{${content}}`, options);
|
|
3758
|
+
}
|
|
3715
3759
|
return arabicScripts(node, (node.characterFont ?? "default") === "default" ? `\\text{${escapeText(expr)}}` : content, options);
|
|
3716
3760
|
}
|
|
3717
3761
|
if (node.kind === "operator" && isDivideOperatorExpr(node.expr)) {
|
|
@@ -4558,6 +4602,16 @@ function markExprSync(session, nodeId) {
|
|
|
4558
4602
|
}
|
|
4559
4603
|
session.sync[nodeId].expr = english.node.expr === arabic.node.expr ? "synced" : "diverged";
|
|
4560
4604
|
}
|
|
4605
|
+
function clearSourceIdentity(session, nodeId) {
|
|
4606
|
+
const english = findNodeById(session.englishTree, nodeId);
|
|
4607
|
+
const arabic = findNodeById(session.arabicTree, nodeId);
|
|
4608
|
+
if (english) {
|
|
4609
|
+
delete english.node.sourceLatex;
|
|
4610
|
+
}
|
|
4611
|
+
if (arabic) {
|
|
4612
|
+
delete arabic.node.sourceLatex;
|
|
4613
|
+
}
|
|
4614
|
+
}
|
|
4561
4615
|
function syncSelectionToCaret(session) {
|
|
4562
4616
|
const activeKey = activeTreeKey(session.activeSide);
|
|
4563
4617
|
const tree = session[activeKey];
|
|
@@ -5141,7 +5195,10 @@ function insertLeaf(session, kind, expr) {
|
|
|
5141
5195
|
const next = cloneEditorSession(session);
|
|
5142
5196
|
const englishNode = createEditorNode(kind, expr);
|
|
5143
5197
|
const arabicNode = createEditorNode(kind, expr);
|
|
5144
|
-
if (kind === "char" &&
|
|
5198
|
+
if (kind === "char" && next.currentCharacterWrapper === "\\boldarabic") {
|
|
5199
|
+
englishNode.wrapperCommand = "\\boldarabic";
|
|
5200
|
+
arabicNode.wrapperCommand = "\\boldarabic";
|
|
5201
|
+
} else if (kind === "char" && (next.currentCharacterFont ?? "default") !== "default") {
|
|
5145
5202
|
englishNode.characterFont = next.currentCharacterFont;
|
|
5146
5203
|
arabicNode.characterFont = next.currentCharacterFont;
|
|
5147
5204
|
}
|
|
@@ -5156,8 +5213,12 @@ function insertLeaf(session, kind, expr) {
|
|
|
5156
5213
|
function shouldReverseArabicNumber(session) {
|
|
5157
5214
|
return session.activeSide === "arabic" && session.arabicReverseNumberTyping;
|
|
5158
5215
|
}
|
|
5159
|
-
function
|
|
5160
|
-
|
|
5216
|
+
function characterTypingStyleOf(node) {
|
|
5217
|
+
if (node.kind !== "char") return "none";
|
|
5218
|
+
return node.wrapperCommand ? `wrapper:${node.wrapperCommand}` : `font:${node.characterFont ?? "default"}`;
|
|
5219
|
+
}
|
|
5220
|
+
function currentCharacterTypingStyle(session) {
|
|
5221
|
+
return session.currentCharacterWrapper ? `wrapper:${session.currentCharacterWrapper}` : `font:${session.currentCharacterFont ?? "default"}`;
|
|
5161
5222
|
}
|
|
5162
5223
|
function tryMergeLeafTyping(session, kind, fragment) {
|
|
5163
5224
|
const engLocated = findChainById(session.englishTree, session.caret.chainId);
|
|
@@ -5170,14 +5231,14 @@ function tryMergeLeafTyping(session, kind, fragment) {
|
|
|
5170
5231
|
let prepend = false;
|
|
5171
5232
|
if (i > 0) {
|
|
5172
5233
|
const prev = nodes[i - 1];
|
|
5173
|
-
if (prev.kind === kind && (kind !== "char" ||
|
|
5234
|
+
if (prev.kind === kind && (kind !== "char" || characterTypingStyleOf(prev) === currentCharacterTypingStyle(session))) {
|
|
5174
5235
|
targetId = prev.id;
|
|
5175
5236
|
prepend = false;
|
|
5176
5237
|
}
|
|
5177
5238
|
}
|
|
5178
5239
|
if (!targetId && i < nodes.length) {
|
|
5179
5240
|
const fwd = nodes[i];
|
|
5180
|
-
if (fwd.kind === kind && (kind !== "char" ||
|
|
5241
|
+
if (fwd.kind === kind && (kind !== "char" || characterTypingStyleOf(fwd) === currentCharacterTypingStyle(session))) {
|
|
5181
5242
|
targetId = fwd.id;
|
|
5182
5243
|
prepend = true;
|
|
5183
5244
|
}
|
|
@@ -5198,6 +5259,7 @@ function tryMergeLeafTyping(session, kind, fragment) {
|
|
|
5198
5259
|
englishHit.node.expr = `${englishHit.node.expr}${fragment}`;
|
|
5199
5260
|
arabicHit.node.expr = `${arabicHit.node.expr}${fragment}`;
|
|
5200
5261
|
}
|
|
5262
|
+
clearSourceIdentity(session, targetId);
|
|
5201
5263
|
markExprSync(session, targetId);
|
|
5202
5264
|
return true;
|
|
5203
5265
|
}
|
|
@@ -5236,9 +5298,17 @@ function breakLeafTyping(session) {
|
|
|
5236
5298
|
function setCurrentCharacterFont(session, fontId) {
|
|
5237
5299
|
const next = cloneEditorSession(session);
|
|
5238
5300
|
next.currentCharacterFont = fontId;
|
|
5301
|
+
next.currentCharacterWrapper = null;
|
|
5239
5302
|
appendDebug(next, "setCurrentCharacterFont", fontId);
|
|
5240
5303
|
return next;
|
|
5241
5304
|
}
|
|
5305
|
+
function setCurrentBoldCharacterStyle(session) {
|
|
5306
|
+
const next = cloneEditorSession(session);
|
|
5307
|
+
next.currentCharacterFont = "default";
|
|
5308
|
+
next.currentCharacterWrapper = "\\boldarabic";
|
|
5309
|
+
appendDebug(next, "setCurrentBoldCharacterStyle", "\\boldarabic");
|
|
5310
|
+
return next;
|
|
5311
|
+
}
|
|
5242
5312
|
function toggleTakweenCharacterFont(session) {
|
|
5243
5313
|
return setCurrentCharacterFont(session, (session.currentCharacterFont ?? "default") === "takween" ? "default" : "takween");
|
|
5244
5314
|
}
|
|
@@ -5787,6 +5857,7 @@ function deleteBackward(session) {
|
|
|
5787
5857
|
englishHit.node.expr = englishHit.node.expr.slice(0, -1);
|
|
5788
5858
|
arabicHit.node.expr = arabicHit.node.expr.slice(0, -1);
|
|
5789
5859
|
}
|
|
5860
|
+
clearSourceIdentity(next, id);
|
|
5790
5861
|
markExprSync(next, id);
|
|
5791
5862
|
next.selectedStructureNodeId = null;
|
|
5792
5863
|
syncSelectionToCaret(next);
|
|
@@ -5836,6 +5907,7 @@ function deleteForward(session) {
|
|
|
5836
5907
|
englishHit.node.expr = englishHit.node.expr.slice(1);
|
|
5837
5908
|
arabicHit.node.expr = arabicHit.node.expr.slice(1);
|
|
5838
5909
|
}
|
|
5910
|
+
clearSourceIdentity(next, node.id);
|
|
5839
5911
|
markExprSync(next, node.id);
|
|
5840
5912
|
next.selectedStructureNodeId = null;
|
|
5841
5913
|
syncSelectionToCaret(next);
|
|
@@ -5862,6 +5934,7 @@ function setExpr(session, nodeId, expr) {
|
|
|
5862
5934
|
return session;
|
|
5863
5935
|
}
|
|
5864
5936
|
activeNode.node.expr = expr;
|
|
5937
|
+
clearSourceIdentity(next, nodeId);
|
|
5865
5938
|
markExprSync(next, nodeId);
|
|
5866
5939
|
appendDebug(next, "setExpr", nodeId);
|
|
5867
5940
|
return next;
|
|
@@ -5879,6 +5952,7 @@ function createStarterSession() {
|
|
|
5879
5952
|
forceSplitNextLeaf: false,
|
|
5880
5953
|
arabicReverseNumberTyping: true,
|
|
5881
5954
|
currentCharacterFont: "default",
|
|
5955
|
+
currentCharacterWrapper: null,
|
|
5882
5956
|
currentDigitForm: "western",
|
|
5883
5957
|
caret: {
|
|
5884
5958
|
chainId: englishRoot.id,
|
|
@@ -6016,6 +6090,9 @@ function buildBaseNodeBody(node, digitForm = "western", side = "english") {
|
|
|
6016
6090
|
if (cssClass) {
|
|
6017
6091
|
value.classList.add(cssClass);
|
|
6018
6092
|
}
|
|
6093
|
+
if (node.wrapperCommand === "\\boldarabic" || node.wrapperCommand === "\\mathbf") {
|
|
6094
|
+
value.classList.add("node-value--bold");
|
|
6095
|
+
}
|
|
6019
6096
|
}
|
|
6020
6097
|
const surfaceExpr = node.kind === "operator" ? divideOperatorSurfaceExpr(node.expr, side) : node.expr;
|
|
6021
6098
|
value.textContent = surfaceExpr === "" ? "\u25A1" : formatDigits(surfaceExpr, digitForm);
|
|
@@ -6891,6 +6968,10 @@ function createEditorRuntime(options) {
|
|
|
6891
6968
|
applyTransient((prev) => setCurrentCharacterFont(prev, fontId));
|
|
6892
6969
|
focusInput();
|
|
6893
6970
|
},
|
|
6971
|
+
setCurrentBoldCharacterStyle: () => {
|
|
6972
|
+
applyTransient((prev) => setCurrentBoldCharacterStyle(prev));
|
|
6973
|
+
focusInput();
|
|
6974
|
+
},
|
|
6894
6975
|
setCurrentDigitForm: (digitForm) => {
|
|
6895
6976
|
applyStructural((prev) => setCurrentDigitForm(prev, digitForm));
|
|
6896
6977
|
focusInput();
|
|
@@ -7613,6 +7694,15 @@ var SVG_TEXT_ATTR = "data-butex-svg-text";
|
|
|
7613
7694
|
var SVG_FONT_ATTR = "data-butex-svg-font";
|
|
7614
7695
|
var EM = 1e3;
|
|
7615
7696
|
var FALLBACK_CHAR_WIDTH = 0.72;
|
|
7697
|
+
var BOLD_LAYOUT = {
|
|
7698
|
+
key: "bold",
|
|
7699
|
+
stack: 'Amiri, "Noto Serif Arabic", serif',
|
|
7700
|
+
height: 0.75,
|
|
7701
|
+
depth: 0.25,
|
|
7702
|
+
drawScale: 1,
|
|
7703
|
+
baselineShift: 0,
|
|
7704
|
+
fontWeight: 700
|
|
7705
|
+
};
|
|
7616
7706
|
var FONT_LAYOUTS = Object.fromEntries(
|
|
7617
7707
|
NON_DEFAULT_CHARACTER_FONT_SPECS.filter((font) => font.svgLayoutKey && font.browserFontStack).map((font) => {
|
|
7618
7708
|
const key = font.svgLayoutKey;
|
|
@@ -7633,6 +7723,9 @@ var FONT_LAYOUTS = Object.fromEntries(
|
|
|
7633
7723
|
);
|
|
7634
7724
|
function fontLayoutForClass(className) {
|
|
7635
7725
|
const classes = className.split(/\s+/);
|
|
7726
|
+
if (classes.includes("butex-bold-text")) {
|
|
7727
|
+
return BOLD_LAYOUT;
|
|
7728
|
+
}
|
|
7636
7729
|
for (const font of NON_DEFAULT_CHARACTER_FONT_SPECS) {
|
|
7637
7730
|
if (font.mathJaxClass && font.svgLayoutKey && classes.includes(font.mathJaxClass)) {
|
|
7638
7731
|
return FONT_LAYOUTS[font.svgLayoutKey] ?? null;
|
|
@@ -7685,12 +7778,14 @@ function measureAdvance(wrapper, text, fontStack) {
|
|
|
7685
7778
|
y: 0,
|
|
7686
7779
|
"font-family": fontStack,
|
|
7687
7780
|
"font-size": EM,
|
|
7781
|
+
"font-weight": fontStack === BOLD_LAYOUT.stack ? BOLD_LAYOUT.fontWeight : void 0,
|
|
7688
7782
|
"text-anchor": "end",
|
|
7689
7783
|
direction: "rtl",
|
|
7690
7784
|
"unicode-bidi": "isolate",
|
|
7691
7785
|
"dominant-baseline": "alphabetic",
|
|
7692
7786
|
style: {
|
|
7693
7787
|
"font-family": fontStack,
|
|
7788
|
+
"font-weight": fontStack === BOLD_LAYOUT.stack ? BOLD_LAYOUT.fontWeight : void 0,
|
|
7694
7789
|
direction: "rtl",
|
|
7695
7790
|
"unicode-bidi": "isolate"
|
|
7696
7791
|
}
|
|
@@ -7790,6 +7885,7 @@ function createBuTeXSvgMtextClass(OriginalMtext) {
|
|
|
7790
7885
|
transform: `scale(${formatSvgNumber(font.drawScale)},${formatSvgNumber(-font.drawScale)})`,
|
|
7791
7886
|
"font-family": font.stack,
|
|
7792
7887
|
"font-size": EM,
|
|
7888
|
+
"font-weight": font.fontWeight,
|
|
7793
7889
|
"text-anchor": "end",
|
|
7794
7890
|
direction: "rtl",
|
|
7795
7891
|
"unicode-bidi": "isolate",
|
|
@@ -7798,6 +7894,7 @@ function createBuTeXSvgMtextClass(OriginalMtext) {
|
|
|
7798
7894
|
[SVG_FONT_ATTR]: font.key,
|
|
7799
7895
|
style: {
|
|
7800
7896
|
"font-family": font.stack,
|
|
7897
|
+
"font-weight": font.fontWeight,
|
|
7801
7898
|
direction: "rtl",
|
|
7802
7899
|
"unicode-bidi": "isolate"
|
|
7803
7900
|
}
|