@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.mjs
CHANGED
|
@@ -868,7 +868,7 @@ function unitArgument(parser, name) {
|
|
|
868
868
|
const node = parser.create(
|
|
869
869
|
"token",
|
|
870
870
|
"mtext",
|
|
871
|
-
{ class: "butex-unit-text", "data-butex-unit": text },
|
|
871
|
+
{ class: "butex-unit-text", "data-butex-unit": text, "data-butex-svg-text": text },
|
|
872
872
|
text
|
|
873
873
|
);
|
|
874
874
|
parser.Push(node);
|
|
@@ -5401,6 +5401,8 @@ function setCurrentDigitForm(session, digitForm) {
|
|
|
5401
5401
|
return next;
|
|
5402
5402
|
}
|
|
5403
5403
|
function insertChar(session, expr) {
|
|
5404
|
+
const digit = formatDigits(expr, "western");
|
|
5405
|
+
if (/^[0-9]$/.test(digit)) return insertNumber(session, digit);
|
|
5404
5406
|
const base = replaceSelectionFirst(session);
|
|
5405
5407
|
if (!base.splitLeafTyping && !base.forceSplitNextLeaf) {
|
|
5406
5408
|
const next = cloneEditorSession(base);
|
|
@@ -5416,17 +5418,18 @@ function insertChar(session, expr) {
|
|
|
5416
5418
|
return inserted;
|
|
5417
5419
|
}
|
|
5418
5420
|
function insertNumber(session, expr) {
|
|
5421
|
+
const digit = formatDigits(expr, "western");
|
|
5419
5422
|
const base = replaceSelectionFirst(session);
|
|
5420
5423
|
if (!base.splitLeafTyping && !base.forceSplitNextLeaf) {
|
|
5421
5424
|
const next = cloneEditorSession(base);
|
|
5422
|
-
if (tryMergeLeafTyping(next, "number",
|
|
5425
|
+
if (tryMergeLeafTyping(next, "number", digit)) {
|
|
5423
5426
|
next.selectedStructureNodeId = null;
|
|
5424
5427
|
syncSelectionToCaret(next);
|
|
5425
5428
|
appendDebug(next, "mergeLeaf", `number:${expr}`);
|
|
5426
5429
|
return next;
|
|
5427
5430
|
}
|
|
5428
5431
|
}
|
|
5429
|
-
const inserted = insertLeaf(base, "number",
|
|
5432
|
+
const inserted = insertLeaf(base, "number", digit);
|
|
5430
5433
|
inserted.forceSplitNextLeaf = false;
|
|
5431
5434
|
return inserted;
|
|
5432
5435
|
}
|
|
@@ -7792,6 +7795,15 @@ var BOLD_LAYOUT = {
|
|
|
7792
7795
|
baselineShift: 0,
|
|
7793
7796
|
fontWeight: 700
|
|
7794
7797
|
};
|
|
7798
|
+
var UNIT_LAYOUT = {
|
|
7799
|
+
key: "unit",
|
|
7800
|
+
stack: BOLD_LAYOUT.stack,
|
|
7801
|
+
height: 0.75,
|
|
7802
|
+
depth: 0.25,
|
|
7803
|
+
drawScale: 1,
|
|
7804
|
+
baselineShift: 0,
|
|
7805
|
+
fontWeight: 400
|
|
7806
|
+
};
|
|
7795
7807
|
var FONT_LAYOUTS = Object.fromEntries(
|
|
7796
7808
|
NON_DEFAULT_CHARACTER_FONT_SPECS.filter((font) => font.svgLayoutKey && font.browserFontStack).map((font) => {
|
|
7797
7809
|
const key = font.svgLayoutKey;
|
|
@@ -7815,6 +7827,9 @@ function fontLayoutForClass(className) {
|
|
|
7815
7827
|
if (classes.includes("butex-bold-text")) {
|
|
7816
7828
|
return BOLD_LAYOUT;
|
|
7817
7829
|
}
|
|
7830
|
+
if (classes.includes("butex-unit-text")) {
|
|
7831
|
+
return UNIT_LAYOUT;
|
|
7832
|
+
}
|
|
7818
7833
|
for (const font of NON_DEFAULT_CHARACTER_FONT_SPECS) {
|
|
7819
7834
|
if (font.mathJaxClass && font.svgLayoutKey && classes.includes(font.mathJaxClass)) {
|
|
7820
7835
|
return FONT_LAYOUTS[font.svgLayoutKey] ?? null;
|
|
@@ -7853,7 +7868,7 @@ function getSvgGraphicsBox(node) {
|
|
|
7853
7868
|
function formatSvgNumber(value) {
|
|
7854
7869
|
return Number.isFinite(value) ? value.toFixed(3).replace(/\.?0+$/, "") : "0";
|
|
7855
7870
|
}
|
|
7856
|
-
function measureAdvance(wrapper, text,
|
|
7871
|
+
function measureAdvance(wrapper, text, font) {
|
|
7857
7872
|
const jax = wrapper.jax;
|
|
7858
7873
|
const adaptor = jax.adaptor;
|
|
7859
7874
|
const body = adaptor.document == null ? null : adaptor.body(adaptor.document);
|
|
@@ -7865,16 +7880,16 @@ function measureAdvance(wrapper, text, fontStack) {
|
|
|
7865
7880
|
{
|
|
7866
7881
|
x: 0,
|
|
7867
7882
|
y: 0,
|
|
7868
|
-
"font-family":
|
|
7883
|
+
"font-family": font.stack,
|
|
7869
7884
|
"font-size": EM,
|
|
7870
|
-
"font-weight":
|
|
7885
|
+
"font-weight": font.fontWeight,
|
|
7871
7886
|
"text-anchor": "end",
|
|
7872
7887
|
direction: "rtl",
|
|
7873
7888
|
"unicode-bidi": "isolate",
|
|
7874
7889
|
"dominant-baseline": "alphabetic",
|
|
7875
7890
|
style: {
|
|
7876
|
-
"font-family":
|
|
7877
|
-
"font-weight":
|
|
7891
|
+
"font-family": font.stack,
|
|
7892
|
+
"font-weight": font.fontWeight,
|
|
7878
7893
|
direction: "rtl",
|
|
7879
7894
|
"unicode-bidi": "isolate"
|
|
7880
7895
|
}
|
|
@@ -7917,7 +7932,7 @@ function metricsFor(wrapper) {
|
|
|
7917
7932
|
if (!text || !font) {
|
|
7918
7933
|
return null;
|
|
7919
7934
|
}
|
|
7920
|
-
const measured = measureAdvance(wrapper, text, font
|
|
7935
|
+
const measured = measureAdvance(wrapper, text, font);
|
|
7921
7936
|
const charCount = Math.max(1, Array.from(text).length);
|
|
7922
7937
|
const anchorUnits = measured ? measured.anchorUnits : charCount * FALLBACK_CHAR_WIDTH * EM;
|
|
7923
7938
|
const widthUnits = measured ? measured.widthUnits : charCount * FALLBACK_CHAR_WIDTH * EM;
|