@pie-lib/math-input-mathlive 1.1.5-beta.13 → 1.1.5-beta.15
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/lib/__tests__/keypad-label.test.js +2 -201
- package/lib/__tests__/latex-bridge.test.js +1 -164
- package/lib/__tests__/mathlive-instance.test.js +1 -232
- package/lib/keypad/index.js +12 -8
- package/lib/keypad/index.js.map +1 -1
- package/lib/mathlive-instance.js +31 -14
- package/lib/mathlive-instance.js.map +1 -1
- package/lib/mf/common-styles.js +51 -10
- package/lib/mf/common-styles.js.map +1 -1
- package/package.json +1 -1
- package/src/keypad/index.jsx +12 -8
- package/src/mathlive-instance.js +45 -14
- package/src/mf/common-styles.js +54 -10
package/src/mf/common-styles.js
CHANGED
|
@@ -103,6 +103,10 @@ export const supsubStyles = {
|
|
|
103
103
|
...parallelStyles,
|
|
104
104
|
};
|
|
105
105
|
|
|
106
|
+
const OVERLINE_BAR_MASK =
|
|
107
|
+
'url("data:image/svg+xml,%3Csvg xmlns=\'http://www.w3.org/2000/svg\' viewBox=\'0 0 100 522\' preserveAspectRatio=\'none\'%3E' +
|
|
108
|
+
'%3Crect y=\'241\' width=\'100\' height=\'40\'/%3E%3C/svg%3E") 0 0/100% 100% no-repeat';
|
|
109
|
+
|
|
106
110
|
/** Empty placeholder boxes (answer blocks / open slots). */
|
|
107
111
|
export const placeholderStyles = {
|
|
108
112
|
'& .ML__placeholder': {
|
|
@@ -115,24 +119,64 @@ export const placeholderStyles = {
|
|
|
115
119
|
'& [data-pie-empty]': {
|
|
116
120
|
opacity: 0.5,
|
|
117
121
|
},
|
|
122
|
+
// A filled fraction (`55/555`): MathLive's bar sits ~0.075em nearer the numerator's
|
|
123
|
+
// digits than the denominator's (measured at 40px: 8.5px above, 11.5px below).
|
|
124
|
+
// Dropping the bar 0.04em evens the two gaps. Fractions with an empty slot have
|
|
125
|
+
// their own drop below, which is more specific and overrides this one.
|
|
126
|
+
'& .ML__mfrac:not(:has([data-pie-empty])) .ML__frac-line': {
|
|
127
|
+
position: 'relative',
|
|
128
|
+
top: '0.04em',
|
|
129
|
+
},
|
|
118
130
|
// A fraction with an empty slot: MathLive spaces the bar for text, but the
|
|
119
|
-
// slot's box is a taller `\rule`, so the bar hugs the numerator's box
|
|
120
|
-
//
|
|
121
|
-
//
|
|
131
|
+
// slot's box is a taller `\rule`, so the bar hugs the numerator's box. Measured
|
|
132
|
+
// at 100px: dropping it 0.14em centres it between two boxes, and 0.13em between
|
|
133
|
+
// a real numerator (`x`, whose ink ends at the baseline) and an empty denominator.
|
|
134
|
+
// Only the bar moves, not the slots. The numerator is the second `.ML__center`
|
|
135
|
+
// (MathLive emits the denominator first).
|
|
122
136
|
'& .ML__mfrac:has([data-pie-empty]) .ML__frac-line': {
|
|
123
137
|
position: 'relative',
|
|
124
|
-
top: '0.
|
|
138
|
+
top: '0.14em',
|
|
125
139
|
},
|
|
126
|
-
// A real numerator (`x`) is lighter than an empty box and its ink ends at the
|
|
127
|
-
// baseline, so the full drop overshoots: it needs a smaller drop. The numerator is
|
|
128
|
-
// the second `.ML__center` (MathLive emits the denominator first).
|
|
129
140
|
'& .ML__mfrac:has([data-pie-empty]):not(:has(.ML__center ~ .ML__center [data-pie-empty])) .ML__frac-line': {
|
|
130
141
|
top: '0.13em',
|
|
131
142
|
},
|
|
132
|
-
//
|
|
133
|
-
//
|
|
143
|
+
// A mixed number (`x` then the fraction): the leading `x` is a sibling of the
|
|
144
|
+
// fraction, which a lone `\frac{}{}` does not have, and the label's pixel
|
|
145
|
+
// rounding then lands the bar a row lower - so it takes a smaller drop. This
|
|
146
|
+
// also keeps the bar level with the `x`.
|
|
134
147
|
'& .ML__mfrac:has([data-pie-empty]):not(:only-child) .ML__frac-line': {
|
|
135
|
-
top: '0.
|
|
148
|
+
top: '0.1em',
|
|
149
|
+
},
|
|
150
|
+
// Segment (`\overline`) vs ray / line (stretchy arrows). Over filled content
|
|
151
|
+
// MathLive draws the bar ~0.31em below the arrows' shafts, and the bar is
|
|
152
|
+
// `max(1px, 0.04em)` twice (:before + :after) while a shaft is a 0.04em path,
|
|
153
|
+
// so it also renders heavier. Raise it to the shaft height and draw it once at
|
|
154
|
+
// 0.04em. An empty slot (`data-pie-empty`) is already aligned by the struts in
|
|
155
|
+
// `withVisibleEmptySlots`, so it keeps its position. `!important`: the offset is
|
|
156
|
+
// an inline style.
|
|
157
|
+
'& .overline:not(:has([data-pie-empty])) > .ML__vlist-t > .ML__vlist-r > .ML__vlist > span:has(> .overline-line)': {
|
|
158
|
+
top: '-4.07em !important',
|
|
159
|
+
},
|
|
160
|
+
'& .overline .overline-line': {
|
|
161
|
+
position: 'relative',
|
|
162
|
+
},
|
|
163
|
+
// Drawn as a mask with the arrow shaft's geometry (y 241-281 of a 522-high box)
|
|
164
|
+
// instead of a border, which the browser snaps to whole device pixels.
|
|
165
|
+
'& .overline .overline-line:before': {
|
|
166
|
+
content: '""',
|
|
167
|
+
display: 'block',
|
|
168
|
+
position: 'absolute',
|
|
169
|
+
left: 0,
|
|
170
|
+
right: 0,
|
|
171
|
+
top: '-0.241em',
|
|
172
|
+
height: '0.522em !important',
|
|
173
|
+
border: '0 !important',
|
|
174
|
+
background: 'currentColor',
|
|
175
|
+
WebkitMask: OVERLINE_BAR_MASK,
|
|
176
|
+
mask: OVERLINE_BAR_MASK,
|
|
177
|
+
},
|
|
178
|
+
'& .overline .overline-line:after': {
|
|
179
|
+
display: 'none !important',
|
|
136
180
|
},
|
|
137
181
|
// Stretchy accents (\overarc, \overleftrightarrow, \overrightarrow) render an
|
|
138
182
|
// <svg width="100%" preserveAspectRatio="none"> inside a `.ML__stretchy`. That
|