@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
package/dist/index.mjs
CHANGED
|
@@ -161,6 +161,18 @@ mjx-container[jax="CHTML"] .butex-preview-mirror {
|
|
|
161
161
|
font-family: ${BUTEX_DIWANI_OUTLINE_FONT_STACK} !important;
|
|
162
162
|
}
|
|
163
163
|
|
|
164
|
+
.butex-bold-text {
|
|
165
|
+
font-family: var(--font-display-ar, Amiri), "Noto Serif Arabic", serif;
|
|
166
|
+
font-weight: 700;
|
|
167
|
+
direction: rtl;
|
|
168
|
+
unicode-bidi: isolate;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
.butex-bold-text mjx-utext {
|
|
172
|
+
font-family: var(--font-display-ar, Amiri), "Noto Serif Arabic", serif !important;
|
|
173
|
+
font-weight: 700;
|
|
174
|
+
}
|
|
175
|
+
|
|
164
176
|
.butex-takween-text {
|
|
165
177
|
font-family: ${BUTEX_TAKWEEN_FONT_STACK};
|
|
166
178
|
direction: rtl;
|
|
@@ -808,12 +820,15 @@ function fontText(className, parser, name) {
|
|
|
808
820
|
parser.Push(node);
|
|
809
821
|
}
|
|
810
822
|
function registerFontTextCommands(CommandMap) {
|
|
811
|
-
const mappings =
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
((
|
|
815
|
-
|
|
816
|
-
|
|
823
|
+
const mappings = {
|
|
824
|
+
boldarabic: ((parser, name) => fontText("butex-bold-text", parser, name)),
|
|
825
|
+
...Object.fromEntries(
|
|
826
|
+
NON_DEFAULT_CHARACTER_FONT_SPECS.filter((font) => font.mathJaxClass).map((font) => [
|
|
827
|
+
font.macro.replace(/^\\/, ""),
|
|
828
|
+
((parser, name) => fontText(font.mathJaxClass, parser, name))
|
|
829
|
+
])
|
|
830
|
+
)
|
|
831
|
+
};
|
|
817
832
|
new CommandMap(COMMAND_MAP5, mappings);
|
|
818
833
|
return COMMAND_MAP5;
|
|
819
834
|
}
|
|
@@ -2111,6 +2126,15 @@ var ATOMIC_OPERATOR_COMMANDS = {
|
|
|
2111
2126
|
title: "\u0627\u0644\u0644\u0627\u0646\u0647\u0627\u064A\u0629",
|
|
2112
2127
|
svg_path: null
|
|
2113
2128
|
},
|
|
2129
|
+
top: {
|
|
2130
|
+
id: "top",
|
|
2131
|
+
category: "operators1",
|
|
2132
|
+
Tex: "\\top",
|
|
2133
|
+
mirror: false,
|
|
2134
|
+
Label: "\u22A4",
|
|
2135
|
+
title: "\u0627\u0644\u0645\u0646\u0642\u0648\u0644",
|
|
2136
|
+
svg_path: null
|
|
2137
|
+
},
|
|
2114
2138
|
times: {
|
|
2115
2139
|
id: "times",
|
|
2116
2140
|
category: "operators1",
|
|
@@ -2899,6 +2923,11 @@ ${BUTEX_FONT_FACE_CSS}
|
|
|
2899
2923
|
|
|
2900
2924
|
${CHARACTER_FONT_CSS}
|
|
2901
2925
|
|
|
2926
|
+
.node-value--bold {
|
|
2927
|
+
font-family: var(--font-display-ar, Amiri), "Noto Serif Arabic", serif;
|
|
2928
|
+
font-weight: 700;
|
|
2929
|
+
}
|
|
2930
|
+
|
|
2902
2931
|
.chain {
|
|
2903
2932
|
display: inline-flex;
|
|
2904
2933
|
align-items: center;
|
|
@@ -3213,6 +3242,7 @@ __export(editor_exports, {
|
|
|
3213
3242
|
setArabicReverseNumberTyping: () => setArabicReverseNumberTyping,
|
|
3214
3243
|
setArrayColumnAlignment: () => setArrayColumnAlignment,
|
|
3215
3244
|
setCaret: () => setCaret,
|
|
3245
|
+
setCurrentBoldCharacterStyle: () => setCurrentBoldCharacterStyle,
|
|
3216
3246
|
setCurrentCharacterFont: () => setCurrentCharacterFont,
|
|
3217
3247
|
setCurrentDigitForm: () => setCurrentDigitForm,
|
|
3218
3248
|
setExpr: () => setExpr,
|
|
@@ -3343,6 +3373,7 @@ function cloneEditorSession(session) {
|
|
|
3343
3373
|
forceSplitNextLeaf: session.forceSplitNextLeaf,
|
|
3344
3374
|
arabicReverseNumberTyping: session.arabicReverseNumberTyping,
|
|
3345
3375
|
currentCharacterFont: session.currentCharacterFont ?? "default",
|
|
3376
|
+
currentCharacterWrapper: session.currentCharacterWrapper ?? null,
|
|
3346
3377
|
currentDigitForm: session.currentDigitForm ?? "western",
|
|
3347
3378
|
caret: { ...session.caret },
|
|
3348
3379
|
selection: session.selection ? { ...session.selection } : null,
|
|
@@ -3415,6 +3446,7 @@ function createEditorSession(englishTree, arabicTree, activeSide = "arabic") {
|
|
|
3415
3446
|
forceSplitNextLeaf: false,
|
|
3416
3447
|
arabicReverseNumberTyping: true,
|
|
3417
3448
|
currentCharacterFont: "default",
|
|
3449
|
+
currentCharacterWrapper: null,
|
|
3418
3450
|
currentDigitForm: "western",
|
|
3419
3451
|
caret: {
|
|
3420
3452
|
chainId: englishTree.id,
|
|
@@ -3617,6 +3649,14 @@ function renderNodeEnglish(node, options) {
|
|
|
3617
3649
|
return `${node.expr}${latinScripts(node, options)}`;
|
|
3618
3650
|
}
|
|
3619
3651
|
if (node.kind === "char") {
|
|
3652
|
+
if (node.sourceLatex) {
|
|
3653
|
+
return `${node.sourceLatex}${latinScripts(node, options)}`;
|
|
3654
|
+
}
|
|
3655
|
+
if (node.wrapperCommand) {
|
|
3656
|
+
const expr = formatDigits(node.expr, selectedDigitForm(options));
|
|
3657
|
+
const wrapper = node.wrapperCommand === "\\boldarabic" ? "\\mathbf" : node.wrapperCommand;
|
|
3658
|
+
return `${wrapper}{${escapeText(expr)}}${latinScripts(node, options)}`;
|
|
3659
|
+
}
|
|
3620
3660
|
return `${renderCharContent(node, options)}${latinScripts(node, options)}`;
|
|
3621
3661
|
}
|
|
3622
3662
|
if (node.kind === "operator" && isDivideOperatorExpr(node.expr)) {
|
|
@@ -3670,6 +3710,10 @@ function renderNodeArabic(node, options) {
|
|
|
3670
3710
|
if (node.kind === "char") {
|
|
3671
3711
|
const expr = formatDigits(node.expr, selectedDigitForm(options));
|
|
3672
3712
|
const content = renderCharContent(node, options);
|
|
3713
|
+
if (node.wrapperCommand) {
|
|
3714
|
+
const wrapper = node.wrapperCommand === "\\mathbf" ? "\\boldarabic" : node.wrapperCommand;
|
|
3715
|
+
return arabicScripts(node, `${wrapper}{${content}}`, options);
|
|
3716
|
+
}
|
|
3673
3717
|
return arabicScripts(node, (node.characterFont ?? "default") === "default" ? `\\text{${escapeText(expr)}}` : content, options);
|
|
3674
3718
|
}
|
|
3675
3719
|
if (node.kind === "operator" && isDivideOperatorExpr(node.expr)) {
|
|
@@ -4516,6 +4560,16 @@ function markExprSync(session, nodeId) {
|
|
|
4516
4560
|
}
|
|
4517
4561
|
session.sync[nodeId].expr = english.node.expr === arabic.node.expr ? "synced" : "diverged";
|
|
4518
4562
|
}
|
|
4563
|
+
function clearSourceIdentity(session, nodeId) {
|
|
4564
|
+
const english = findNodeById(session.englishTree, nodeId);
|
|
4565
|
+
const arabic = findNodeById(session.arabicTree, nodeId);
|
|
4566
|
+
if (english) {
|
|
4567
|
+
delete english.node.sourceLatex;
|
|
4568
|
+
}
|
|
4569
|
+
if (arabic) {
|
|
4570
|
+
delete arabic.node.sourceLatex;
|
|
4571
|
+
}
|
|
4572
|
+
}
|
|
4519
4573
|
function syncSelectionToCaret(session) {
|
|
4520
4574
|
const activeKey = activeTreeKey(session.activeSide);
|
|
4521
4575
|
const tree = session[activeKey];
|
|
@@ -5099,7 +5153,10 @@ function insertLeaf(session, kind, expr) {
|
|
|
5099
5153
|
const next = cloneEditorSession(session);
|
|
5100
5154
|
const englishNode = createEditorNode(kind, expr);
|
|
5101
5155
|
const arabicNode = createEditorNode(kind, expr);
|
|
5102
|
-
if (kind === "char" &&
|
|
5156
|
+
if (kind === "char" && next.currentCharacterWrapper === "\\boldarabic") {
|
|
5157
|
+
englishNode.wrapperCommand = "\\boldarabic";
|
|
5158
|
+
arabicNode.wrapperCommand = "\\boldarabic";
|
|
5159
|
+
} else if (kind === "char" && (next.currentCharacterFont ?? "default") !== "default") {
|
|
5103
5160
|
englishNode.characterFont = next.currentCharacterFont;
|
|
5104
5161
|
arabicNode.characterFont = next.currentCharacterFont;
|
|
5105
5162
|
}
|
|
@@ -5114,8 +5171,12 @@ function insertLeaf(session, kind, expr) {
|
|
|
5114
5171
|
function shouldReverseArabicNumber(session) {
|
|
5115
5172
|
return session.activeSide === "arabic" && session.arabicReverseNumberTyping;
|
|
5116
5173
|
}
|
|
5117
|
-
function
|
|
5118
|
-
|
|
5174
|
+
function characterTypingStyleOf(node) {
|
|
5175
|
+
if (node.kind !== "char") return "none";
|
|
5176
|
+
return node.wrapperCommand ? `wrapper:${node.wrapperCommand}` : `font:${node.characterFont ?? "default"}`;
|
|
5177
|
+
}
|
|
5178
|
+
function currentCharacterTypingStyle(session) {
|
|
5179
|
+
return session.currentCharacterWrapper ? `wrapper:${session.currentCharacterWrapper}` : `font:${session.currentCharacterFont ?? "default"}`;
|
|
5119
5180
|
}
|
|
5120
5181
|
function tryMergeLeafTyping(session, kind, fragment) {
|
|
5121
5182
|
const engLocated = findChainById(session.englishTree, session.caret.chainId);
|
|
@@ -5128,14 +5189,14 @@ function tryMergeLeafTyping(session, kind, fragment) {
|
|
|
5128
5189
|
let prepend = false;
|
|
5129
5190
|
if (i > 0) {
|
|
5130
5191
|
const prev = nodes[i - 1];
|
|
5131
|
-
if (prev.kind === kind && (kind !== "char" ||
|
|
5192
|
+
if (prev.kind === kind && (kind !== "char" || characterTypingStyleOf(prev) === currentCharacterTypingStyle(session))) {
|
|
5132
5193
|
targetId = prev.id;
|
|
5133
5194
|
prepend = false;
|
|
5134
5195
|
}
|
|
5135
5196
|
}
|
|
5136
5197
|
if (!targetId && i < nodes.length) {
|
|
5137
5198
|
const fwd = nodes[i];
|
|
5138
|
-
if (fwd.kind === kind && (kind !== "char" ||
|
|
5199
|
+
if (fwd.kind === kind && (kind !== "char" || characterTypingStyleOf(fwd) === currentCharacterTypingStyle(session))) {
|
|
5139
5200
|
targetId = fwd.id;
|
|
5140
5201
|
prepend = true;
|
|
5141
5202
|
}
|
|
@@ -5156,6 +5217,7 @@ function tryMergeLeafTyping(session, kind, fragment) {
|
|
|
5156
5217
|
englishHit.node.expr = `${englishHit.node.expr}${fragment}`;
|
|
5157
5218
|
arabicHit.node.expr = `${arabicHit.node.expr}${fragment}`;
|
|
5158
5219
|
}
|
|
5220
|
+
clearSourceIdentity(session, targetId);
|
|
5159
5221
|
markExprSync(session, targetId);
|
|
5160
5222
|
return true;
|
|
5161
5223
|
}
|
|
@@ -5194,9 +5256,17 @@ function breakLeafTyping(session) {
|
|
|
5194
5256
|
function setCurrentCharacterFont(session, fontId) {
|
|
5195
5257
|
const next = cloneEditorSession(session);
|
|
5196
5258
|
next.currentCharacterFont = fontId;
|
|
5259
|
+
next.currentCharacterWrapper = null;
|
|
5197
5260
|
appendDebug(next, "setCurrentCharacterFont", fontId);
|
|
5198
5261
|
return next;
|
|
5199
5262
|
}
|
|
5263
|
+
function setCurrentBoldCharacterStyle(session) {
|
|
5264
|
+
const next = cloneEditorSession(session);
|
|
5265
|
+
next.currentCharacterFont = "default";
|
|
5266
|
+
next.currentCharacterWrapper = "\\boldarabic";
|
|
5267
|
+
appendDebug(next, "setCurrentBoldCharacterStyle", "\\boldarabic");
|
|
5268
|
+
return next;
|
|
5269
|
+
}
|
|
5200
5270
|
function toggleTakweenCharacterFont(session) {
|
|
5201
5271
|
return setCurrentCharacterFont(session, (session.currentCharacterFont ?? "default") === "takween" ? "default" : "takween");
|
|
5202
5272
|
}
|
|
@@ -5745,6 +5815,7 @@ function deleteBackward(session) {
|
|
|
5745
5815
|
englishHit.node.expr = englishHit.node.expr.slice(0, -1);
|
|
5746
5816
|
arabicHit.node.expr = arabicHit.node.expr.slice(0, -1);
|
|
5747
5817
|
}
|
|
5818
|
+
clearSourceIdentity(next, id);
|
|
5748
5819
|
markExprSync(next, id);
|
|
5749
5820
|
next.selectedStructureNodeId = null;
|
|
5750
5821
|
syncSelectionToCaret(next);
|
|
@@ -5794,6 +5865,7 @@ function deleteForward(session) {
|
|
|
5794
5865
|
englishHit.node.expr = englishHit.node.expr.slice(1);
|
|
5795
5866
|
arabicHit.node.expr = arabicHit.node.expr.slice(1);
|
|
5796
5867
|
}
|
|
5868
|
+
clearSourceIdentity(next, node.id);
|
|
5797
5869
|
markExprSync(next, node.id);
|
|
5798
5870
|
next.selectedStructureNodeId = null;
|
|
5799
5871
|
syncSelectionToCaret(next);
|
|
@@ -5820,6 +5892,7 @@ function setExpr(session, nodeId, expr) {
|
|
|
5820
5892
|
return session;
|
|
5821
5893
|
}
|
|
5822
5894
|
activeNode.node.expr = expr;
|
|
5895
|
+
clearSourceIdentity(next, nodeId);
|
|
5823
5896
|
markExprSync(next, nodeId);
|
|
5824
5897
|
appendDebug(next, "setExpr", nodeId);
|
|
5825
5898
|
return next;
|
|
@@ -5837,6 +5910,7 @@ function createStarterSession() {
|
|
|
5837
5910
|
forceSplitNextLeaf: false,
|
|
5838
5911
|
arabicReverseNumberTyping: true,
|
|
5839
5912
|
currentCharacterFont: "default",
|
|
5913
|
+
currentCharacterWrapper: null,
|
|
5840
5914
|
currentDigitForm: "western",
|
|
5841
5915
|
caret: {
|
|
5842
5916
|
chainId: englishRoot.id,
|
|
@@ -5974,6 +6048,9 @@ function buildBaseNodeBody(node, digitForm = "western", side = "english") {
|
|
|
5974
6048
|
if (cssClass) {
|
|
5975
6049
|
value.classList.add(cssClass);
|
|
5976
6050
|
}
|
|
6051
|
+
if (node.wrapperCommand === "\\boldarabic" || node.wrapperCommand === "\\mathbf") {
|
|
6052
|
+
value.classList.add("node-value--bold");
|
|
6053
|
+
}
|
|
5977
6054
|
}
|
|
5978
6055
|
const surfaceExpr = node.kind === "operator" ? divideOperatorSurfaceExpr(node.expr, side) : node.expr;
|
|
5979
6056
|
value.textContent = surfaceExpr === "" ? "\u25A1" : formatDigits(surfaceExpr, digitForm);
|
|
@@ -6849,6 +6926,10 @@ function createEditorRuntime(options) {
|
|
|
6849
6926
|
applyTransient((prev) => setCurrentCharacterFont(prev, fontId));
|
|
6850
6927
|
focusInput();
|
|
6851
6928
|
},
|
|
6929
|
+
setCurrentBoldCharacterStyle: () => {
|
|
6930
|
+
applyTransient((prev) => setCurrentBoldCharacterStyle(prev));
|
|
6931
|
+
focusInput();
|
|
6932
|
+
},
|
|
6852
6933
|
setCurrentDigitForm: (digitForm) => {
|
|
6853
6934
|
applyStructural((prev) => setCurrentDigitForm(prev, digitForm));
|
|
6854
6935
|
focusInput();
|
|
@@ -7571,6 +7652,15 @@ var SVG_TEXT_ATTR = "data-butex-svg-text";
|
|
|
7571
7652
|
var SVG_FONT_ATTR = "data-butex-svg-font";
|
|
7572
7653
|
var EM = 1e3;
|
|
7573
7654
|
var FALLBACK_CHAR_WIDTH = 0.72;
|
|
7655
|
+
var BOLD_LAYOUT = {
|
|
7656
|
+
key: "bold",
|
|
7657
|
+
stack: 'Amiri, "Noto Serif Arabic", serif',
|
|
7658
|
+
height: 0.75,
|
|
7659
|
+
depth: 0.25,
|
|
7660
|
+
drawScale: 1,
|
|
7661
|
+
baselineShift: 0,
|
|
7662
|
+
fontWeight: 700
|
|
7663
|
+
};
|
|
7574
7664
|
var FONT_LAYOUTS = Object.fromEntries(
|
|
7575
7665
|
NON_DEFAULT_CHARACTER_FONT_SPECS.filter((font) => font.svgLayoutKey && font.browserFontStack).map((font) => {
|
|
7576
7666
|
const key = font.svgLayoutKey;
|
|
@@ -7591,6 +7681,9 @@ var FONT_LAYOUTS = Object.fromEntries(
|
|
|
7591
7681
|
);
|
|
7592
7682
|
function fontLayoutForClass(className) {
|
|
7593
7683
|
const classes = className.split(/\s+/);
|
|
7684
|
+
if (classes.includes("butex-bold-text")) {
|
|
7685
|
+
return BOLD_LAYOUT;
|
|
7686
|
+
}
|
|
7594
7687
|
for (const font of NON_DEFAULT_CHARACTER_FONT_SPECS) {
|
|
7595
7688
|
if (font.mathJaxClass && font.svgLayoutKey && classes.includes(font.mathJaxClass)) {
|
|
7596
7689
|
return FONT_LAYOUTS[font.svgLayoutKey] ?? null;
|
|
@@ -7643,12 +7736,14 @@ function measureAdvance(wrapper, text, fontStack) {
|
|
|
7643
7736
|
y: 0,
|
|
7644
7737
|
"font-family": fontStack,
|
|
7645
7738
|
"font-size": EM,
|
|
7739
|
+
"font-weight": fontStack === BOLD_LAYOUT.stack ? BOLD_LAYOUT.fontWeight : void 0,
|
|
7646
7740
|
"text-anchor": "end",
|
|
7647
7741
|
direction: "rtl",
|
|
7648
7742
|
"unicode-bidi": "isolate",
|
|
7649
7743
|
"dominant-baseline": "alphabetic",
|
|
7650
7744
|
style: {
|
|
7651
7745
|
"font-family": fontStack,
|
|
7746
|
+
"font-weight": fontStack === BOLD_LAYOUT.stack ? BOLD_LAYOUT.fontWeight : void 0,
|
|
7652
7747
|
direction: "rtl",
|
|
7653
7748
|
"unicode-bidi": "isolate"
|
|
7654
7749
|
}
|
|
@@ -7748,6 +7843,7 @@ function createBuTeXSvgMtextClass(OriginalMtext) {
|
|
|
7748
7843
|
transform: `scale(${formatSvgNumber(font.drawScale)},${formatSvgNumber(-font.drawScale)})`,
|
|
7749
7844
|
"font-family": font.stack,
|
|
7750
7845
|
"font-size": EM,
|
|
7846
|
+
"font-weight": font.fontWeight,
|
|
7751
7847
|
"text-anchor": "end",
|
|
7752
7848
|
direction: "rtl",
|
|
7753
7849
|
"unicode-bidi": "isolate",
|
|
@@ -7756,6 +7852,7 @@ function createBuTeXSvgMtextClass(OriginalMtext) {
|
|
|
7756
7852
|
[SVG_FONT_ATTR]: font.key,
|
|
7757
7853
|
style: {
|
|
7758
7854
|
"font-family": font.stack,
|
|
7855
|
+
"font-weight": font.fontWeight,
|
|
7759
7856
|
direction: "rtl",
|
|
7760
7857
|
"unicode-bidi": "isolate"
|
|
7761
7858
|
}
|