@drghaliasri/butex 7.2.0 → 7.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/dist/document.d.mts +8 -0
- package/dist/document.d.ts +8 -0
- package/dist/document.js +38 -2
- package/dist/document.js.map +1 -1
- package/dist/document.mjs +38 -2
- package/dist/document.mjs.map +1 -1
- package/dist/document2-cli.js +107 -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 +107 -2
- package/dist/document2.js.map +1 -1
- package/dist/document2.mjs +107 -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 +109 -11
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +109 -11
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +109 -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 +230 -40
- package/dist/react-document.js.map +1 -1
- package/dist/react-document.mjs +230 -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 +91 -0
- package/dist/react-document2-preview.js.map +1 -1
- package/dist/react-document2-preview.mjs +91 -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 +230 -40
- package/dist/react-document2.js.map +1 -1
- package/dist/react-document2.mjs +230 -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 +230 -40
- package/dist/react.js.map +1 -1
- package/dist/react.mjs +230 -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;
|
|
@@ -820,6 +832,7 @@ var CHARACTER_FONT_SPECS = [
|
|
|
820
832
|
latexFontCommand: "\\maghribi",
|
|
821
833
|
latexFontFamily: "Almaghribi Warsh Quran",
|
|
822
834
|
browserFontStack: '"Almaghribi Warsh Quran", Amiri, "Segoe UI", Tahoma, sans-serif',
|
|
835
|
+
importAliases: ["\\maghribi"],
|
|
823
836
|
svgLayoutKey: "maghribi"
|
|
824
837
|
}
|
|
825
838
|
];
|
|
@@ -849,12 +862,15 @@ function fontText(className, parser, name) {
|
|
|
849
862
|
parser.Push(node);
|
|
850
863
|
}
|
|
851
864
|
function registerFontTextCommands(CommandMap) {
|
|
852
|
-
const mappings =
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
((
|
|
856
|
-
|
|
857
|
-
|
|
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
|
+
};
|
|
858
874
|
new CommandMap(COMMAND_MAP5, mappings);
|
|
859
875
|
return COMMAND_MAP5;
|
|
860
876
|
}
|
|
@@ -2152,6 +2168,15 @@ var ATOMIC_OPERATOR_COMMANDS = {
|
|
|
2152
2168
|
title: "\u0627\u0644\u0644\u0627\u0646\u0647\u0627\u064A\u0629",
|
|
2153
2169
|
svg_path: null
|
|
2154
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
|
+
},
|
|
2155
2180
|
times: {
|
|
2156
2181
|
id: "times",
|
|
2157
2182
|
category: "operators1",
|
|
@@ -2940,6 +2965,11 @@ ${BUTEX_FONT_FACE_CSS}
|
|
|
2940
2965
|
|
|
2941
2966
|
${CHARACTER_FONT_CSS}
|
|
2942
2967
|
|
|
2968
|
+
.node-value--bold {
|
|
2969
|
+
font-family: var(--font-display-ar, Amiri), "Noto Serif Arabic", serif;
|
|
2970
|
+
font-weight: 700;
|
|
2971
|
+
}
|
|
2972
|
+
|
|
2943
2973
|
.chain {
|
|
2944
2974
|
display: inline-flex;
|
|
2945
2975
|
align-items: center;
|
|
@@ -3254,6 +3284,7 @@ __export(editor_exports, {
|
|
|
3254
3284
|
setArabicReverseNumberTyping: () => setArabicReverseNumberTyping,
|
|
3255
3285
|
setArrayColumnAlignment: () => setArrayColumnAlignment,
|
|
3256
3286
|
setCaret: () => setCaret,
|
|
3287
|
+
setCurrentBoldCharacterStyle: () => setCurrentBoldCharacterStyle,
|
|
3257
3288
|
setCurrentCharacterFont: () => setCurrentCharacterFont,
|
|
3258
3289
|
setCurrentDigitForm: () => setCurrentDigitForm,
|
|
3259
3290
|
setExpr: () => setExpr,
|
|
@@ -3384,6 +3415,7 @@ function cloneEditorSession(session) {
|
|
|
3384
3415
|
forceSplitNextLeaf: session.forceSplitNextLeaf,
|
|
3385
3416
|
arabicReverseNumberTyping: session.arabicReverseNumberTyping,
|
|
3386
3417
|
currentCharacterFont: session.currentCharacterFont ?? "default",
|
|
3418
|
+
currentCharacterWrapper: session.currentCharacterWrapper ?? null,
|
|
3387
3419
|
currentDigitForm: session.currentDigitForm ?? "western",
|
|
3388
3420
|
caret: { ...session.caret },
|
|
3389
3421
|
selection: session.selection ? { ...session.selection } : null,
|
|
@@ -3456,6 +3488,7 @@ function createEditorSession(englishTree, arabicTree, activeSide = "arabic") {
|
|
|
3456
3488
|
forceSplitNextLeaf: false,
|
|
3457
3489
|
arabicReverseNumberTyping: true,
|
|
3458
3490
|
currentCharacterFont: "default",
|
|
3491
|
+
currentCharacterWrapper: null,
|
|
3459
3492
|
currentDigitForm: "western",
|
|
3460
3493
|
caret: {
|
|
3461
3494
|
chainId: englishTree.id,
|
|
@@ -3658,6 +3691,14 @@ function renderNodeEnglish(node, options) {
|
|
|
3658
3691
|
return `${node.expr}${latinScripts(node, options)}`;
|
|
3659
3692
|
}
|
|
3660
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
|
+
}
|
|
3661
3702
|
return `${renderCharContent(node, options)}${latinScripts(node, options)}`;
|
|
3662
3703
|
}
|
|
3663
3704
|
if (node.kind === "operator" && isDivideOperatorExpr(node.expr)) {
|
|
@@ -3711,6 +3752,10 @@ function renderNodeArabic(node, options) {
|
|
|
3711
3752
|
if (node.kind === "char") {
|
|
3712
3753
|
const expr = formatDigits(node.expr, selectedDigitForm(options));
|
|
3713
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
|
+
}
|
|
3714
3759
|
return arabicScripts(node, (node.characterFont ?? "default") === "default" ? `\\text{${escapeText(expr)}}` : content, options);
|
|
3715
3760
|
}
|
|
3716
3761
|
if (node.kind === "operator" && isDivideOperatorExpr(node.expr)) {
|
|
@@ -4557,6 +4602,16 @@ function markExprSync(session, nodeId) {
|
|
|
4557
4602
|
}
|
|
4558
4603
|
session.sync[nodeId].expr = english.node.expr === arabic.node.expr ? "synced" : "diverged";
|
|
4559
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
|
+
}
|
|
4560
4615
|
function syncSelectionToCaret(session) {
|
|
4561
4616
|
const activeKey = activeTreeKey(session.activeSide);
|
|
4562
4617
|
const tree = session[activeKey];
|
|
@@ -5140,7 +5195,10 @@ function insertLeaf(session, kind, expr) {
|
|
|
5140
5195
|
const next = cloneEditorSession(session);
|
|
5141
5196
|
const englishNode = createEditorNode(kind, expr);
|
|
5142
5197
|
const arabicNode = createEditorNode(kind, expr);
|
|
5143
|
-
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") {
|
|
5144
5202
|
englishNode.characterFont = next.currentCharacterFont;
|
|
5145
5203
|
arabicNode.characterFont = next.currentCharacterFont;
|
|
5146
5204
|
}
|
|
@@ -5155,8 +5213,12 @@ function insertLeaf(session, kind, expr) {
|
|
|
5155
5213
|
function shouldReverseArabicNumber(session) {
|
|
5156
5214
|
return session.activeSide === "arabic" && session.arabicReverseNumberTyping;
|
|
5157
5215
|
}
|
|
5158
|
-
function
|
|
5159
|
-
|
|
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"}`;
|
|
5160
5222
|
}
|
|
5161
5223
|
function tryMergeLeafTyping(session, kind, fragment) {
|
|
5162
5224
|
const engLocated = findChainById(session.englishTree, session.caret.chainId);
|
|
@@ -5169,14 +5231,14 @@ function tryMergeLeafTyping(session, kind, fragment) {
|
|
|
5169
5231
|
let prepend = false;
|
|
5170
5232
|
if (i > 0) {
|
|
5171
5233
|
const prev = nodes[i - 1];
|
|
5172
|
-
if (prev.kind === kind && (kind !== "char" ||
|
|
5234
|
+
if (prev.kind === kind && (kind !== "char" || characterTypingStyleOf(prev) === currentCharacterTypingStyle(session))) {
|
|
5173
5235
|
targetId = prev.id;
|
|
5174
5236
|
prepend = false;
|
|
5175
5237
|
}
|
|
5176
5238
|
}
|
|
5177
5239
|
if (!targetId && i < nodes.length) {
|
|
5178
5240
|
const fwd = nodes[i];
|
|
5179
|
-
if (fwd.kind === kind && (kind !== "char" ||
|
|
5241
|
+
if (fwd.kind === kind && (kind !== "char" || characterTypingStyleOf(fwd) === currentCharacterTypingStyle(session))) {
|
|
5180
5242
|
targetId = fwd.id;
|
|
5181
5243
|
prepend = true;
|
|
5182
5244
|
}
|
|
@@ -5197,6 +5259,7 @@ function tryMergeLeafTyping(session, kind, fragment) {
|
|
|
5197
5259
|
englishHit.node.expr = `${englishHit.node.expr}${fragment}`;
|
|
5198
5260
|
arabicHit.node.expr = `${arabicHit.node.expr}${fragment}`;
|
|
5199
5261
|
}
|
|
5262
|
+
clearSourceIdentity(session, targetId);
|
|
5200
5263
|
markExprSync(session, targetId);
|
|
5201
5264
|
return true;
|
|
5202
5265
|
}
|
|
@@ -5235,9 +5298,17 @@ function breakLeafTyping(session) {
|
|
|
5235
5298
|
function setCurrentCharacterFont(session, fontId) {
|
|
5236
5299
|
const next = cloneEditorSession(session);
|
|
5237
5300
|
next.currentCharacterFont = fontId;
|
|
5301
|
+
next.currentCharacterWrapper = null;
|
|
5238
5302
|
appendDebug(next, "setCurrentCharacterFont", fontId);
|
|
5239
5303
|
return next;
|
|
5240
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
|
+
}
|
|
5241
5312
|
function toggleTakweenCharacterFont(session) {
|
|
5242
5313
|
return setCurrentCharacterFont(session, (session.currentCharacterFont ?? "default") === "takween" ? "default" : "takween");
|
|
5243
5314
|
}
|
|
@@ -5786,6 +5857,7 @@ function deleteBackward(session) {
|
|
|
5786
5857
|
englishHit.node.expr = englishHit.node.expr.slice(0, -1);
|
|
5787
5858
|
arabicHit.node.expr = arabicHit.node.expr.slice(0, -1);
|
|
5788
5859
|
}
|
|
5860
|
+
clearSourceIdentity(next, id);
|
|
5789
5861
|
markExprSync(next, id);
|
|
5790
5862
|
next.selectedStructureNodeId = null;
|
|
5791
5863
|
syncSelectionToCaret(next);
|
|
@@ -5835,6 +5907,7 @@ function deleteForward(session) {
|
|
|
5835
5907
|
englishHit.node.expr = englishHit.node.expr.slice(1);
|
|
5836
5908
|
arabicHit.node.expr = arabicHit.node.expr.slice(1);
|
|
5837
5909
|
}
|
|
5910
|
+
clearSourceIdentity(next, node.id);
|
|
5838
5911
|
markExprSync(next, node.id);
|
|
5839
5912
|
next.selectedStructureNodeId = null;
|
|
5840
5913
|
syncSelectionToCaret(next);
|
|
@@ -5861,6 +5934,7 @@ function setExpr(session, nodeId, expr) {
|
|
|
5861
5934
|
return session;
|
|
5862
5935
|
}
|
|
5863
5936
|
activeNode.node.expr = expr;
|
|
5937
|
+
clearSourceIdentity(next, nodeId);
|
|
5864
5938
|
markExprSync(next, nodeId);
|
|
5865
5939
|
appendDebug(next, "setExpr", nodeId);
|
|
5866
5940
|
return next;
|
|
@@ -5878,6 +5952,7 @@ function createStarterSession() {
|
|
|
5878
5952
|
forceSplitNextLeaf: false,
|
|
5879
5953
|
arabicReverseNumberTyping: true,
|
|
5880
5954
|
currentCharacterFont: "default",
|
|
5955
|
+
currentCharacterWrapper: null,
|
|
5881
5956
|
currentDigitForm: "western",
|
|
5882
5957
|
caret: {
|
|
5883
5958
|
chainId: englishRoot.id,
|
|
@@ -6015,6 +6090,9 @@ function buildBaseNodeBody(node, digitForm = "western", side = "english") {
|
|
|
6015
6090
|
if (cssClass) {
|
|
6016
6091
|
value.classList.add(cssClass);
|
|
6017
6092
|
}
|
|
6093
|
+
if (node.wrapperCommand === "\\boldarabic" || node.wrapperCommand === "\\mathbf") {
|
|
6094
|
+
value.classList.add("node-value--bold");
|
|
6095
|
+
}
|
|
6018
6096
|
}
|
|
6019
6097
|
const surfaceExpr = node.kind === "operator" ? divideOperatorSurfaceExpr(node.expr, side) : node.expr;
|
|
6020
6098
|
value.textContent = surfaceExpr === "" ? "\u25A1" : formatDigits(surfaceExpr, digitForm);
|
|
@@ -6890,6 +6968,10 @@ function createEditorRuntime(options) {
|
|
|
6890
6968
|
applyTransient((prev) => setCurrentCharacterFont(prev, fontId));
|
|
6891
6969
|
focusInput();
|
|
6892
6970
|
},
|
|
6971
|
+
setCurrentBoldCharacterStyle: () => {
|
|
6972
|
+
applyTransient((prev) => setCurrentBoldCharacterStyle(prev));
|
|
6973
|
+
focusInput();
|
|
6974
|
+
},
|
|
6893
6975
|
setCurrentDigitForm: (digitForm) => {
|
|
6894
6976
|
applyStructural((prev) => setCurrentDigitForm(prev, digitForm));
|
|
6895
6977
|
focusInput();
|
|
@@ -7612,6 +7694,15 @@ var SVG_TEXT_ATTR = "data-butex-svg-text";
|
|
|
7612
7694
|
var SVG_FONT_ATTR = "data-butex-svg-font";
|
|
7613
7695
|
var EM = 1e3;
|
|
7614
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
|
+
};
|
|
7615
7706
|
var FONT_LAYOUTS = Object.fromEntries(
|
|
7616
7707
|
NON_DEFAULT_CHARACTER_FONT_SPECS.filter((font) => font.svgLayoutKey && font.browserFontStack).map((font) => {
|
|
7617
7708
|
const key = font.svgLayoutKey;
|
|
@@ -7632,6 +7723,9 @@ var FONT_LAYOUTS = Object.fromEntries(
|
|
|
7632
7723
|
);
|
|
7633
7724
|
function fontLayoutForClass(className) {
|
|
7634
7725
|
const classes = className.split(/\s+/);
|
|
7726
|
+
if (classes.includes("butex-bold-text")) {
|
|
7727
|
+
return BOLD_LAYOUT;
|
|
7728
|
+
}
|
|
7635
7729
|
for (const font of NON_DEFAULT_CHARACTER_FONT_SPECS) {
|
|
7636
7730
|
if (font.mathJaxClass && font.svgLayoutKey && classes.includes(font.mathJaxClass)) {
|
|
7637
7731
|
return FONT_LAYOUTS[font.svgLayoutKey] ?? null;
|
|
@@ -7684,12 +7778,14 @@ function measureAdvance(wrapper, text, fontStack) {
|
|
|
7684
7778
|
y: 0,
|
|
7685
7779
|
"font-family": fontStack,
|
|
7686
7780
|
"font-size": EM,
|
|
7781
|
+
"font-weight": fontStack === BOLD_LAYOUT.stack ? BOLD_LAYOUT.fontWeight : void 0,
|
|
7687
7782
|
"text-anchor": "end",
|
|
7688
7783
|
direction: "rtl",
|
|
7689
7784
|
"unicode-bidi": "isolate",
|
|
7690
7785
|
"dominant-baseline": "alphabetic",
|
|
7691
7786
|
style: {
|
|
7692
7787
|
"font-family": fontStack,
|
|
7788
|
+
"font-weight": fontStack === BOLD_LAYOUT.stack ? BOLD_LAYOUT.fontWeight : void 0,
|
|
7693
7789
|
direction: "rtl",
|
|
7694
7790
|
"unicode-bidi": "isolate"
|
|
7695
7791
|
}
|
|
@@ -7789,6 +7885,7 @@ function createBuTeXSvgMtextClass(OriginalMtext) {
|
|
|
7789
7885
|
transform: `scale(${formatSvgNumber(font.drawScale)},${formatSvgNumber(-font.drawScale)})`,
|
|
7790
7886
|
"font-family": font.stack,
|
|
7791
7887
|
"font-size": EM,
|
|
7888
|
+
"font-weight": font.fontWeight,
|
|
7792
7889
|
"text-anchor": "end",
|
|
7793
7890
|
direction: "rtl",
|
|
7794
7891
|
"unicode-bidi": "isolate",
|
|
@@ -7797,6 +7894,7 @@ function createBuTeXSvgMtextClass(OriginalMtext) {
|
|
|
7797
7894
|
[SVG_FONT_ATTR]: font.key,
|
|
7798
7895
|
style: {
|
|
7799
7896
|
"font-family": font.stack,
|
|
7897
|
+
"font-weight": font.fontWeight,
|
|
7800
7898
|
direction: "rtl",
|
|
7801
7899
|
"unicode-bidi": "isolate"
|
|
7802
7900
|
}
|