@drghaliasri/butex 7.4.0 → 7.4.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 -1
- package/dist/document2.js.map +1 -1
- package/dist/document2.mjs.map +1 -1
- package/dist/index.global.js +24 -9
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +24 -9
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +24 -9
- package/dist/index.mjs.map +1 -1
- package/dist/react-document.js +5 -2
- package/dist/react-document.js.map +1 -1
- package/dist/react-document.mjs +5 -2
- package/dist/react-document.mjs.map +1 -1
- package/dist/react-document2-preview.js.map +1 -1
- package/dist/react-document2-preview.mjs.map +1 -1
- package/dist/react-document2.js +5 -2
- package/dist/react-document2.js.map +1 -1
- package/dist/react-document2.mjs +5 -2
- package/dist/react-document2.mjs.map +1 -1
- package/dist/react.js +5 -2
- package/dist/react.js.map +1 -1
- package/dist/react.mjs +5 -2
- package/dist/react.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.global.js
CHANGED
|
@@ -910,7 +910,7 @@ mjx-container[jax="CHTML"] .butex-preview-mirror {
|
|
|
910
910
|
const node = parser.create(
|
|
911
911
|
"token",
|
|
912
912
|
"mtext",
|
|
913
|
-
{ class: "butex-unit-text", "data-butex-unit": text },
|
|
913
|
+
{ class: "butex-unit-text", "data-butex-unit": text, "data-butex-svg-text": text },
|
|
914
914
|
text
|
|
915
915
|
);
|
|
916
916
|
parser.Push(node);
|
|
@@ -5443,6 +5443,8 @@ ${STANDARD_COMMAND_CSS}
|
|
|
5443
5443
|
return next;
|
|
5444
5444
|
}
|
|
5445
5445
|
function insertChar(session, expr) {
|
|
5446
|
+
const digit = formatDigits(expr, "western");
|
|
5447
|
+
if (/^[0-9]$/.test(digit)) return insertNumber(session, digit);
|
|
5446
5448
|
const base = replaceSelectionFirst(session);
|
|
5447
5449
|
if (!base.splitLeafTyping && !base.forceSplitNextLeaf) {
|
|
5448
5450
|
const next = cloneEditorSession(base);
|
|
@@ -5458,17 +5460,18 @@ ${STANDARD_COMMAND_CSS}
|
|
|
5458
5460
|
return inserted;
|
|
5459
5461
|
}
|
|
5460
5462
|
function insertNumber(session, expr) {
|
|
5463
|
+
const digit = formatDigits(expr, "western");
|
|
5461
5464
|
const base = replaceSelectionFirst(session);
|
|
5462
5465
|
if (!base.splitLeafTyping && !base.forceSplitNextLeaf) {
|
|
5463
5466
|
const next = cloneEditorSession(base);
|
|
5464
|
-
if (tryMergeLeafTyping(next, "number",
|
|
5467
|
+
if (tryMergeLeafTyping(next, "number", digit)) {
|
|
5465
5468
|
next.selectedStructureNodeId = null;
|
|
5466
5469
|
syncSelectionToCaret(next);
|
|
5467
5470
|
appendDebug(next, "mergeLeaf", `number:${expr}`);
|
|
5468
5471
|
return next;
|
|
5469
5472
|
}
|
|
5470
5473
|
}
|
|
5471
|
-
const inserted = insertLeaf(base, "number",
|
|
5474
|
+
const inserted = insertLeaf(base, "number", digit);
|
|
5472
5475
|
inserted.forceSplitNextLeaf = false;
|
|
5473
5476
|
return inserted;
|
|
5474
5477
|
}
|
|
@@ -7834,6 +7837,15 @@ ${STANDARD_COMMAND_CSS}
|
|
|
7834
7837
|
baselineShift: 0,
|
|
7835
7838
|
fontWeight: 700
|
|
7836
7839
|
};
|
|
7840
|
+
var UNIT_LAYOUT = {
|
|
7841
|
+
key: "unit",
|
|
7842
|
+
stack: BOLD_LAYOUT.stack,
|
|
7843
|
+
height: 0.75,
|
|
7844
|
+
depth: 0.25,
|
|
7845
|
+
drawScale: 1,
|
|
7846
|
+
baselineShift: 0,
|
|
7847
|
+
fontWeight: 400
|
|
7848
|
+
};
|
|
7837
7849
|
var FONT_LAYOUTS = Object.fromEntries(
|
|
7838
7850
|
NON_DEFAULT_CHARACTER_FONT_SPECS.filter((font) => font.svgLayoutKey && font.browserFontStack).map((font) => {
|
|
7839
7851
|
const key = font.svgLayoutKey;
|
|
@@ -7857,6 +7869,9 @@ ${STANDARD_COMMAND_CSS}
|
|
|
7857
7869
|
if (classes.includes("butex-bold-text")) {
|
|
7858
7870
|
return BOLD_LAYOUT;
|
|
7859
7871
|
}
|
|
7872
|
+
if (classes.includes("butex-unit-text")) {
|
|
7873
|
+
return UNIT_LAYOUT;
|
|
7874
|
+
}
|
|
7860
7875
|
for (const font of NON_DEFAULT_CHARACTER_FONT_SPECS) {
|
|
7861
7876
|
if (font.mathJaxClass && font.svgLayoutKey && classes.includes(font.mathJaxClass)) {
|
|
7862
7877
|
return FONT_LAYOUTS[font.svgLayoutKey] ?? null;
|
|
@@ -7895,7 +7910,7 @@ ${STANDARD_COMMAND_CSS}
|
|
|
7895
7910
|
function formatSvgNumber(value) {
|
|
7896
7911
|
return Number.isFinite(value) ? value.toFixed(3).replace(/\.?0+$/, "") : "0";
|
|
7897
7912
|
}
|
|
7898
|
-
function measureAdvance(wrapper, text,
|
|
7913
|
+
function measureAdvance(wrapper, text, font) {
|
|
7899
7914
|
const jax = wrapper.jax;
|
|
7900
7915
|
const adaptor = jax.adaptor;
|
|
7901
7916
|
const body = adaptor.document == null ? null : adaptor.body(adaptor.document);
|
|
@@ -7907,16 +7922,16 @@ ${STANDARD_COMMAND_CSS}
|
|
|
7907
7922
|
{
|
|
7908
7923
|
x: 0,
|
|
7909
7924
|
y: 0,
|
|
7910
|
-
"font-family":
|
|
7925
|
+
"font-family": font.stack,
|
|
7911
7926
|
"font-size": EM,
|
|
7912
|
-
"font-weight":
|
|
7927
|
+
"font-weight": font.fontWeight,
|
|
7913
7928
|
"text-anchor": "end",
|
|
7914
7929
|
direction: "rtl",
|
|
7915
7930
|
"unicode-bidi": "isolate",
|
|
7916
7931
|
"dominant-baseline": "alphabetic",
|
|
7917
7932
|
style: {
|
|
7918
|
-
"font-family":
|
|
7919
|
-
"font-weight":
|
|
7933
|
+
"font-family": font.stack,
|
|
7934
|
+
"font-weight": font.fontWeight,
|
|
7920
7935
|
direction: "rtl",
|
|
7921
7936
|
"unicode-bidi": "isolate"
|
|
7922
7937
|
}
|
|
@@ -7959,7 +7974,7 @@ ${STANDARD_COMMAND_CSS}
|
|
|
7959
7974
|
if (!text || !font) {
|
|
7960
7975
|
return null;
|
|
7961
7976
|
}
|
|
7962
|
-
const measured = measureAdvance(wrapper, text, font
|
|
7977
|
+
const measured = measureAdvance(wrapper, text, font);
|
|
7963
7978
|
const charCount = Math.max(1, Array.from(text).length);
|
|
7964
7979
|
const anchorUnits = measured ? measured.anchorUnits : charCount * FALLBACK_CHAR_WIDTH * EM;
|
|
7965
7980
|
const widthUnits = measured ? measured.widthUnits : charCount * FALLBACK_CHAR_WIDTH * EM;
|