@pie-lib/math-input-mathlive 1.0.5 → 1.0.6
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.
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _keypad = require("../keypad");
|
|
4
|
+
var _latexBridge = require("../latex-bridge");
|
|
5
|
+
/**
|
|
6
|
+
* Keys use empty groups to show a command's shape (`\frac{}{}`, `x^{}`).
|
|
7
|
+
* MathLive renders `{}` as nothing, so labels need a visible stand-in - but the
|
|
8
|
+
* value that gets *inserted* must stay untouched.
|
|
9
|
+
*/
|
|
10
|
+
describe('keypad label display normalisation', function () {
|
|
11
|
+
it('gives empty groups a visible glyph', function () {
|
|
12
|
+
var out = (0, _keypad.latexForDisplay)('\\frac{}{}');
|
|
13
|
+
expect(out).not.toEqual('\\frac{}{}');
|
|
14
|
+
expect(out).toContain('25AB'); // white small square
|
|
15
|
+
expect(out).toContain('pie-empty');
|
|
16
|
+
});
|
|
17
|
+
it('handles every empty-group key shape', function () {
|
|
18
|
+
['\\frac{}{}', '\\overline{}', 'x^{}', 'x_{}', '\\sqrt{}', '\\sqrt[{}]{}', '\\abs{}', '\\log_{}', '\\longdiv{}'].forEach(function (latex) {
|
|
19
|
+
expect((0, _keypad.latexForDisplay)(latex)).not.toContain('{}');
|
|
20
|
+
});
|
|
21
|
+
});
|
|
22
|
+
it('treats a whitespace-only group as empty', function () {
|
|
23
|
+
// e.g. \frac{x}{ }
|
|
24
|
+
expect((0, _keypad.latexForDisplay)('\\frac{x}{ }')).toContain('pie-empty');
|
|
25
|
+
});
|
|
26
|
+
it('leaves latex without empty groups alone', function () {
|
|
27
|
+
['\\pi', '\\sin', 'x^2', '\\overline{AB}'].forEach(function (latex) {
|
|
28
|
+
expect((0, _keypad.latexForDisplay)(latex)).toEqual(latex);
|
|
29
|
+
});
|
|
30
|
+
});
|
|
31
|
+
it('handles nullish input', function () {
|
|
32
|
+
expect((0, _keypad.latexForDisplay)(undefined)).toEqual('');
|
|
33
|
+
expect((0, _keypad.latexForDisplay)('')).toEqual('');
|
|
34
|
+
});
|
|
35
|
+
it('does NOT affect what gets inserted into the field', function () {
|
|
36
|
+
// the action must use the key's own latex, never the display form
|
|
37
|
+
var key = {
|
|
38
|
+
name: 'frac',
|
|
39
|
+
latex: '\\frac{}{}'
|
|
40
|
+
};
|
|
41
|
+
expect((0, _latexBridge.keyToAction)(key).value).toEqual('\\frac{}{}');
|
|
42
|
+
expect((0, _latexBridge.keyToAction)(key).value).not.toContain('pie-empty');
|
|
43
|
+
});
|
|
44
|
+
});
|
|
45
|
+
//# sourceMappingURL=keypad-label.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"keypad-label.test.js","names":["_keypad","require","_latexBridge","describe","it","out","latexForDisplay","expect","not","toEqual","toContain","forEach","latex","undefined","key","name","keyToAction","value"],"sources":["../../src/__tests__/keypad-label.test.jsx"],"sourcesContent":["import { latexForDisplay } from '../keypad';\nimport { keyToAction } from '../latex-bridge';\n\n/**\n * Keys use empty groups to show a command's shape (`\\frac{}{}`, `x^{}`).\n * MathLive renders `{}` as nothing, so labels need a visible stand-in - but the\n * value that gets *inserted* must stay untouched.\n */\ndescribe('keypad label display normalisation', () => {\n it('gives empty groups a visible glyph', () => {\n const out = latexForDisplay('\\\\frac{}{}');\n\n expect(out).not.toEqual('\\\\frac{}{}');\n expect(out).toContain('25AB'); // white small square\n expect(out).toContain('pie-empty');\n });\n\n it('handles every empty-group key shape', () => {\n ['\\\\frac{}{}', '\\\\overline{}', 'x^{}', 'x_{}', '\\\\sqrt{}', '\\\\sqrt[{}]{}', '\\\\abs{}', '\\\\log_{}', '\\\\longdiv{}'].forEach(\n (latex) => {\n expect(latexForDisplay(latex)).not.toContain('{}');\n },\n );\n });\n\n it('treats a whitespace-only group as empty', () => {\n // e.g. \\frac{x}{ }\n expect(latexForDisplay('\\\\frac{x}{ }')).toContain('pie-empty');\n });\n\n it('leaves latex without empty groups alone', () => {\n ['\\\\pi', '\\\\sin', 'x^2', '\\\\overline{AB}'].forEach((latex) => {\n expect(latexForDisplay(latex)).toEqual(latex);\n });\n });\n\n it('handles nullish input', () => {\n expect(latexForDisplay(undefined)).toEqual('');\n expect(latexForDisplay('')).toEqual('');\n });\n\n it('does NOT affect what gets inserted into the field', () => {\n // the action must use the key's own latex, never the display form\n const key = { name: 'frac', latex: '\\\\frac{}{}' };\n\n expect(keyToAction(key).value).toEqual('\\\\frac{}{}');\n expect(keyToAction(key).value).not.toContain('pie-empty');\n });\n});\n"],"mappings":";;AAAA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AAEA;AACA;AACA;AACA;AACA;AACAE,QAAQ,CAAC,oCAAoC,EAAE,YAAM;EACnDC,EAAE,CAAC,oCAAoC,EAAE,YAAM;IAC7C,IAAMC,GAAG,GAAG,IAAAC,uBAAe,EAAC,YAAY,CAAC;IAEzCC,MAAM,CAACF,GAAG,CAAC,CAACG,GAAG,CAACC,OAAO,CAAC,YAAY,CAAC;IACrCF,MAAM,CAACF,GAAG,CAAC,CAACK,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC;IAC/BH,MAAM,CAACF,GAAG,CAAC,CAACK,SAAS,CAAC,WAAW,CAAC;EACpC,CAAC,CAAC;EAEFN,EAAE,CAAC,qCAAqC,EAAE,YAAM;IAC9C,CAAC,YAAY,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,cAAc,EAAE,SAAS,EAAE,UAAU,EAAE,aAAa,CAAC,CAACO,OAAO,CACtH,UAACC,KAAK,EAAK;MACTL,MAAM,CAAC,IAAAD,uBAAe,EAACM,KAAK,CAAC,CAAC,CAACJ,GAAG,CAACE,SAAS,CAAC,IAAI,CAAC;IACpD,CACF,CAAC;EACH,CAAC,CAAC;EAEFN,EAAE,CAAC,yCAAyC,EAAE,YAAM;IAClD;IACAG,MAAM,CAAC,IAAAD,uBAAe,EAAC,cAAc,CAAC,CAAC,CAACI,SAAS,CAAC,WAAW,CAAC;EAChE,CAAC,CAAC;EAEFN,EAAE,CAAC,yCAAyC,EAAE,YAAM;IAClD,CAAC,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,gBAAgB,CAAC,CAACO,OAAO,CAAC,UAACC,KAAK,EAAK;MAC5DL,MAAM,CAAC,IAAAD,uBAAe,EAACM,KAAK,CAAC,CAAC,CAACH,OAAO,CAACG,KAAK,CAAC;IAC/C,CAAC,CAAC;EACJ,CAAC,CAAC;EAEFR,EAAE,CAAC,uBAAuB,EAAE,YAAM;IAChCG,MAAM,CAAC,IAAAD,uBAAe,EAACO,SAAS,CAAC,CAAC,CAACJ,OAAO,CAAC,EAAE,CAAC;IAC9CF,MAAM,CAAC,IAAAD,uBAAe,EAAC,EAAE,CAAC,CAAC,CAACG,OAAO,CAAC,EAAE,CAAC;EACzC,CAAC,CAAC;EAEFL,EAAE,CAAC,mDAAmD,EAAE,YAAM;IAC5D;IACA,IAAMU,GAAG,GAAG;MAAEC,IAAI,EAAE,MAAM;MAAEH,KAAK,EAAE;IAAa,CAAC;IAEjDL,MAAM,CAAC,IAAAS,wBAAW,EAACF,GAAG,CAAC,CAACG,KAAK,CAAC,CAACR,OAAO,CAAC,YAAY,CAAC;IACpDF,MAAM,CAAC,IAAAS,wBAAW,EAACF,GAAG,CAAC,CAACG,KAAK,CAAC,CAACT,GAAG,CAACE,SAAS,CAAC,WAAW,CAAC;EAC3D,CAAC,CAAC;AACJ,CAAC,CAAC","ignoreList":[]}
|
package/lib/keypad/index.js
CHANGED
|
@@ -4,7 +4,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports["default"] = exports.LatexLabel = exports.KeyPad = void 0;
|
|
7
|
+
exports.latexForDisplay = exports["default"] = exports.LatexLabel = exports.KeyPad = void 0;
|
|
8
8
|
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
9
9
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
10
10
|
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
@@ -68,16 +68,46 @@ var LabelHolder = (0, _styles.styled)('span')(function () {
|
|
|
68
68
|
// Answer-block / empty-slot boxes inside a label.
|
|
69
69
|
'& .ML__placeholder': {
|
|
70
70
|
backgroundColor: _renderUi.color.keypadEmptyPlaceholder ? _renderUi.color.keypadEmptyPlaceholder() : undefined
|
|
71
|
+
},
|
|
72
|
+
// The stand-in glyph for an empty argument slot (see EMPTY_SLOT). Muted so it
|
|
73
|
+
// reads as "a slot goes here" rather than as part of the symbol, matching how
|
|
74
|
+
// MathQuill shaded `.mq-empty`.
|
|
75
|
+
'& [data-pie-empty]': {
|
|
76
|
+
opacity: 0.5
|
|
71
77
|
}
|
|
72
78
|
};
|
|
73
79
|
});
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* A visible stand-in for an empty argument slot.
|
|
83
|
+
*
|
|
84
|
+
* Key latex uses empty groups to show the shape of a command - `\frac{}{}`,
|
|
85
|
+
* `\overline{}`, `x^{}`. MathQuill drew those as a shaded box (`.mq-empty`);
|
|
86
|
+
* MathLive renders `{}` as nothing at all, so those buttons come out blank.
|
|
87
|
+
* `\placeholder{}` is not a substitute: in static markup it renders as a
|
|
88
|
+
* non-breaking space (the editable box only exists inside a live mathfield), so
|
|
89
|
+
* an actual glyph is required.
|
|
90
|
+
*
|
|
91
|
+
* Tagged with `pie-empty` so it can be muted via CSS.
|
|
92
|
+
*/
|
|
93
|
+
var EMPTY_SLOT = "\\htmlData{pie-empty=1}{\\unicode{\"25AB}}";
|
|
94
|
+
var EMPTY_GROUP_REGEX = /\{\s*\}/g;
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Display-only: give empty groups something visible.
|
|
98
|
+
* Never use this for the value that gets inserted into the field - the key's
|
|
99
|
+
* own latex is what gets typed.
|
|
100
|
+
*/
|
|
101
|
+
var latexForDisplay = exports.latexForDisplay = function latexForDisplay(latex) {
|
|
102
|
+
return (latex || '').replace(EMPTY_GROUP_REGEX, "{".concat(EMPTY_SLOT, "}"));
|
|
103
|
+
};
|
|
74
104
|
var LatexLabel = exports.LatexLabel = /*#__PURE__*/function (_React$Component) {
|
|
75
105
|
function LatexLabel(props) {
|
|
76
106
|
var _this;
|
|
77
107
|
(0, _classCallCheck2["default"])(this, LatexLabel);
|
|
78
108
|
_this = _callSuper(this, LatexLabel, [props]);
|
|
79
109
|
_this.state = {
|
|
80
|
-
markup: (0, _mathliveInstance.latexToMarkup)(props.latex)
|
|
110
|
+
markup: (0, _mathliveInstance.latexToMarkup)(latexForDisplay(props.latex))
|
|
81
111
|
};
|
|
82
112
|
return _this;
|
|
83
113
|
}
|
|
@@ -105,7 +135,7 @@ var LatexLabel = exports.LatexLabel = /*#__PURE__*/function (_React$Component) {
|
|
|
105
135
|
}
|
|
106
136
|
return _context.abrupt("return");
|
|
107
137
|
case 3:
|
|
108
|
-
markup = (0, _mathliveInstance.latexToMarkup)(this.props.latex);
|
|
138
|
+
markup = (0, _mathliveInstance.latexToMarkup)(latexForDisplay(this.props.latex));
|
|
109
139
|
if (!markup) {
|
|
110
140
|
_context.next = 4;
|
|
111
141
|
break;
|
|
@@ -138,7 +168,7 @@ var LatexLabel = exports.LatexLabel = /*#__PURE__*/function (_React$Component) {
|
|
|
138
168
|
value: function componentDidUpdate(prevProps) {
|
|
139
169
|
if (prevProps.latex !== this.props.latex) {
|
|
140
170
|
this.setState({
|
|
141
|
-
markup: (0, _mathliveInstance.latexToMarkup)(this.props.latex)
|
|
171
|
+
markup: (0, _mathliveInstance.latexToMarkup)(latexForDisplay(this.props.latex))
|
|
142
172
|
});
|
|
143
173
|
}
|
|
144
174
|
}
|
package/lib/keypad/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["_react","_interopRequireDefault","require","_propTypes","_Button","_IconButton","_styles","_debug","_lodashEs","_renderUi","_keys","_keysLayout","_commonStyles","_mathliveInstance","ownKeys","e","r","t","Object","keys","getOwnPropertySymbols","o","filter","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","arguments","length","forEach","_defineProperty2","getOwnPropertyDescriptors","defineProperties","defineProperty","_callSuper","_getPrototypeOf2","_possibleConstructorReturn2","_isNativeReflectConstruct","Reflect","construct","constructor","Boolean","prototype","valueOf","call","log","debug","LabelHolder","styled","pointerEvents","textTransform","color","text","display","alignItems","justifyContent","lineHeight","maxWidth","overflow","position","width","backgroundColor","keypadEmptyPlaceholder","undefined","LatexLabel","exports","_React$Component","props","_this","_classCallCheck2","state","markup","latexToMarkup","latex","_inherits2","_createClass2","key","value","_componentDidMount","_asyncToGenerator2","_regenerator","mark","_callee","wrap","_context","prev","next","abrupt","loadMathLive","unmounted","setState","warned","stop","componentDidMount","componentDidUpdate","prevProps","componentWillUnmount","render","createElement","dangerouslySetInnerHTML","__html","React","Component","PropTypes","string","isRequired","createCustomLayout","layoutObj","gridTemplateColumns","concat","columns","gridTemplateRows","rows","gridAutoFlow","KeyPadContainer","commonKeyboardStyles","gridRowGap","gridColumnGap","fontFamily","buttonBackground","category","keypadButtonOperator","keypadButton","keypadButtonOperatorHover","keypadButtonHover","StyledButton","Button","_ref","isDelete","isComma","isDot","minWidth","fontSize","borderRadius","StyledLatexButtonWrapper","_ref2","padding","margin","StyledIconButton","IconButton","_ref3","height","KeyPad","_React$Component2","_this2","setKeypadInteraction","onPress","base","extras","flatten","_toConsumableArray2","sortKeys","noDecimal","write","label","keypadRef","createRef","_this$keypadRef","keyPadElement","current","mainContainer","closest","currentToolbar","controlledKeypadMode","mainContainerPosition","getBoundingClientRect","currentToolbarPosition","difference","top","totalHeight","style","addEventListener","handleKeypadInteraction","_this$keypadRef2","removeEventListener","_this3","_this$props","className","baseSet","additionalKeys","layoutForKeyPad","onFocus","mode","noBaseSet","keysWithoutBaseSet","includes","allKeys","flowKeys","shift","Math","floor","ref","join","map","k","index","command","extra","actions","extraProps","onClick","buttonClick","bind","disabled","keyIsNotAllowed","ariaLabel","name","_extends2","Icon","icon","tabIndex","size","bool","array","object","func","oneOfType","number","_default"],"sources":["../../src/keypad/index.jsx"],"sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport Button from '@mui/material/Button';\nimport IconButton from '@mui/material/IconButton';\nimport { styled } from '@mui/material/styles';\nimport debug from 'debug';\nimport { flatten } from 'lodash-es';\nimport { color } from '@pie-lib/render-ui';\n\nimport { baseSet } from '../keys';\nimport { sortKeys } from './keys-layout';\nimport { commonKeyboardStyles } from '../mf/common-styles';\nimport { loadMathLive, latexToMarkup } from '../mathlive-instance';\n\nconst log = debug('pie-lib:math-input-mathlive:keypad');\n\n/**\n * A LaTeX keypad label.\n *\n * The MathQuill implementation rendered every LaTeX label as its own\n * `MQ.StaticMath` instance. Here each label is static HTML produced once by\n * `convertLatexToMarkup`, so a 40-key keypad no longer creates 40 live math\n * instances.\n */\n// The `color.*()` helpers must be called lazily, inside the styled callback.\n// Evaluating them in a plain object literal runs them at module load, which\n// breaks any consumer that mocks a subset of @pie-lib/render-ui.\nconst LabelHolder = styled('span')(() => ({\n pointerEvents: 'none',\n textTransform: 'none',\n color: color.text(),\n display: 'inline-flex',\n alignItems: 'center',\n justifyContent: 'center',\n lineHeight: 1,\n // Never let a label size its grid column. Stretchy accents\n // (\\overrightarrow, \\overleftrightarrow, \\overarc) render an <svg> that\n // mathlive-static.css positions absolutely at width:100%; if that stylesheet\n // is missing the svg lays out statically and expands without bound, dragging\n // the whole column across the screen. `overflow: hidden` also collapses the\n // label's min-content contribution, so the grid can't blow out either way.\n maxWidth: '100%',\n overflow: 'hidden',\n '& svg': {\n position: 'absolute',\n width: '100%',\n },\n // Answer-block / empty-slot boxes inside a label.\n '& .ML__placeholder': {\n backgroundColor: color.keypadEmptyPlaceholder ? color.keypadEmptyPlaceholder() : undefined,\n },\n}));\n\nexport class LatexLabel extends React.Component {\n static propTypes = {\n latex: PropTypes.string.isRequired,\n };\n\n constructor(props) {\n super(props);\n this.state = { markup: latexToMarkup(props.latex) };\n }\n\n async componentDidMount() {\n // MathLive may not have finished loading when the keypad first mounts.\n if (this.state.markup) {\n return;\n }\n\n await loadMathLive();\n\n if (this.unmounted) {\n return;\n }\n\n const markup = latexToMarkup(this.props.latex);\n\n if (markup) {\n this.setState({ markup });\n return;\n }\n\n // Still nothing: the engine is genuinely unavailable (a missing chunk, a\n // blocked request). Keep the raw-latex fallback visible rather than an\n // empty button, and log once so this is diagnosable.\n if (!LatexLabel.warned) {\n LatexLabel.warned = true;\n log('MathLive unavailable - keypad labels are falling back to raw latex');\n }\n }\n\n componentDidUpdate(prevProps) {\n if (prevProps.latex !== this.props.latex) {\n this.setState({ markup: latexToMarkup(this.props.latex) });\n }\n }\n\n componentWillUnmount() {\n this.unmounted = true;\n }\n\n render() {\n const { markup } = this.state;\n\n // Fall back to the raw latex so a button is never blank.\n return markup ? (\n // eslint-disable-next-line react/no-danger\n <LabelHolder dangerouslySetInnerHTML={{ __html: markup }} />\n ) : (\n <LabelHolder>{this.props.latex}</LabelHolder>\n );\n }\n}\n\nconst createCustomLayout = (layoutObj) => {\n if (layoutObj) {\n return {\n gridTemplateColumns: `repeat(${layoutObj.columns}, minmax(min-content, 150px))`,\n gridTemplateRows: `repeat(${layoutObj.rows}, minmax(40px, 60px))`,\n gridAutoFlow: 'initial',\n };\n }\n\n return {};\n};\n\nconst KeyPadContainer = styled('div')(() => ({\n ...commonKeyboardStyles,\n width: '100%',\n display: 'grid',\n gridTemplateRows: 'repeat(5, minmax(40px, 60px))',\n gridRowGap: '0px',\n gridColumnGap: '0px',\n gridAutoFlow: 'column',\n '&.character': {\n textTransform: 'initial !important',\n gridTemplateRows: 'repeat(5, minmax(40px, 50px)) !important',\n },\n '&.language': {\n gridTemplateRows: 'repeat(4, minmax(40px, 50px)) !important',\n '& *': {\n fontFamily: 'Roboto, Helvetica, Arial, sans-serif !important',\n },\n },\n}));\n\nconst buttonBackground = (category) => ({\n backgroundColor: category === 'operators' ? color.keypadButtonOperator() : color.keypadButton(),\n '&:hover': {\n backgroundColor: category === 'operators' ? color.keypadButtonOperatorHover() : color.keypadButtonHover(),\n },\n});\n\nconst StyledButton = styled(Button)(({ category, isDelete, isComma, isDot }) => ({\n minWidth: 'auto',\n textTransform: 'none',\n fontSize: isComma || isDot ? '200% !important' : '140% !important',\n lineHeight: isComma || isDot ? '100%' : 'normal',\n color: color.text(),\n ...buttonBackground(category),\n borderRadius: 0,\n ...(isDelete && {\n fontFamily: 'Roboto, Helvetica, Arial, sans-serif !important',\n }),\n}));\n\nconst StyledLatexButtonWrapper = styled(Button)(({ category }) => ({\n textTransform: 'none',\n padding: 0,\n margin: 0,\n fontSize: '110% !important',\n minWidth: 'auto',\n borderRadius: 0,\n ...buttonBackground(category),\n}));\n\nconst StyledIconButton = styled(IconButton)(({ category }) => ({\n minWidth: 'auto',\n ...buttonBackground(category),\n borderRadius: 0,\n '& .icon': {\n height: '30px',\n },\n}));\n\nexport class KeyPad extends React.Component {\n static propTypes = {\n className: PropTypes.string,\n controlledKeypadMode: PropTypes.bool,\n baseSet: PropTypes.array,\n additionalKeys: PropTypes.array,\n layoutForKeyPad: PropTypes.object,\n onPress: PropTypes.func.isRequired,\n onFocus: PropTypes.func,\n noDecimal: PropTypes.bool,\n setKeypadInteraction: PropTypes.func,\n mode: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),\n };\n\n static defaultProps = {\n baseSet: baseSet,\n noDecimal: false,\n };\n\n constructor(props) {\n super(props);\n this.keypadRef = React.createRef();\n }\n\n componentDidMount() {\n // Ensure MathLive is available for the LaTeX labels.\n loadMathLive();\n\n const keyPadElement = this.keypadRef?.current;\n const mainContainer = keyPadElement?.closest('.main-container');\n const currentToolbar = keyPadElement?.closest('.pie-toolbar');\n\n // need only for math keyboard so we need also controlledKeypadMode\n if (this.props.controlledKeypadMode && mainContainer && currentToolbar) {\n const mainContainerPosition = mainContainer.getBoundingClientRect();\n const currentToolbarPosition = currentToolbar.getBoundingClientRect();\n const difference =\n mainContainerPosition.top +\n mainContainerPosition.height -\n (currentToolbarPosition.top + currentToolbarPosition.height);\n\n if (difference < 0) {\n const totalHeight = mainContainerPosition.height + mainContainerPosition.top - difference;\n\n mainContainer.style.height = `${totalHeight}px`;\n }\n }\n\n if (keyPadElement) {\n keyPadElement.addEventListener('touchstart', this.handleKeypadInteraction, true);\n keyPadElement.addEventListener('mousedown', this.handleKeypadInteraction, true);\n }\n }\n\n componentWillUnmount() {\n const keyPadElement = this.keypadRef?.current;\n\n if (this.props.controlledKeypadMode && keyPadElement) {\n const mainContainer = keyPadElement.closest('.main-container');\n\n if (mainContainer) {\n mainContainer.style.height = 'unset';\n }\n }\n\n if (keyPadElement) {\n keyPadElement.removeEventListener('touchstart', this.handleKeypadInteraction, true);\n keyPadElement.removeEventListener('mousedown', this.handleKeypadInteraction, true);\n }\n }\n\n handleKeypadInteraction = () => {\n if (this.props.setKeypadInteraction) {\n this.props.setKeypadInteraction(true);\n }\n };\n\n buttonClick = (key) => {\n log('[buttonClick]', key);\n this.props.onPress(key);\n };\n\n flowKeys = (base, extras) => flatten([...sortKeys(base), ...sortKeys(extras)]);\n\n keyIsNotAllowed = (key) => {\n const { noDecimal } = this.props;\n\n return !!(((key.write === '.' && key.label === '.') || (key.write === ',' && key.label === ',')) && noDecimal);\n };\n\n render() {\n const { className, baseSet: base, additionalKeys, layoutForKeyPad, onFocus, mode } = this.props;\n\n const noBaseSet = ['non-negative-integers', 'integers', 'decimals', 'fractions', 'item-authoring', 'language'];\n const keysWithoutBaseSet = noBaseSet.includes(mode);\n const allKeys = keysWithoutBaseSet\n ? this.flowKeys([], additionalKeys || [])\n : this.flowKeys(base, additionalKeys || []);\n\n const shift = allKeys.length % 5 ? 1 : 0;\n const style = {\n gridTemplateColumns: `repeat(${Math.floor(allKeys.length / 5) + shift}, minmax(min-content, 150px))`,\n ...createCustomLayout(layoutForKeyPad),\n };\n\n return (\n <KeyPadContainer\n ref={this.keypadRef}\n className={[className, mode].filter(Boolean).join(' ')}\n style={style}\n onFocus={onFocus}\n >\n {allKeys.map((k, index) => {\n if (!k) {\n return <span key={`empty-${index}`} />;\n }\n\n const key = `${k.label || k.latex || k.command}-${index}`;\n const category = !keysWithoutBaseSet ? k.category : undefined;\n const extra = { ...(k.actions || {}), ...(k.extraProps || {}) };\n const onClick = this.buttonClick.bind(this, k);\n const disabled = this.keyIsNotAllowed(k);\n const ariaLabel = k.ariaLabel ? k.ariaLabel : k.name || k.label;\n\n if (k.latex) {\n return (\n <StyledLatexButtonWrapper\n key={key}\n onClick={onClick}\n disabled={disabled}\n category={category}\n aria-label={ariaLabel}\n {...extra}\n >\n <LatexLabel latex={k.latex} />\n </StyledLatexButtonWrapper>\n );\n }\n\n if (k.label) {\n return (\n <StyledButton\n key={key}\n onClick={onClick}\n disabled={disabled}\n category={category}\n isDelete={k.label === '⌫'}\n isComma={k.label === ','}\n isDot={k.label === '.'}\n aria-label={ariaLabel}\n {...extra}\n >\n {k.label}\n </StyledButton>\n );\n }\n\n const Icon = k.icon ? k.icon : 'div';\n\n return (\n <StyledIconButton\n key={key}\n tabIndex={'-1'}\n onClick={onClick}\n disabled={disabled}\n category={category}\n size=\"large\"\n {...extra}\n >\n <Icon className=\"icon\" />\n </StyledIconButton>\n );\n })}\n </KeyPadContainer>\n );\n }\n}\n\nexport default KeyPad;\n"],"mappings":";;;;;;;;;;;;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,UAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,OAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,IAAAG,WAAA,GAAAJ,sBAAA,CAAAC,OAAA;AACA,IAAAI,OAAA,GAAAJ,OAAA;AACA,IAAAK,MAAA,GAAA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UACfnI,GAAG,EAAEA,GAAI;UACTsI,QAAQ,EAAE,IAAK;UACfV,OAAO,EAAEA,OAAQ;UACjBG,QAAQ,EAAEA,QAAS;UACnBnF,QAAQ,EAAEA,QAAS;UACnB2F,IAAI,EAAC;QAAO,GACRd,KAAK,gBAETtM,MAAA,YAAAmG,aAAA,CAAC8G,IAAI;UAAC/B,SAAS,EAAC;QAAM,CAAE,CACR,CAAC;MAEvB,CAAC,CACc,CAAC;IAEtB;EAAC;AAAA,EA/KyB5E,iBAAK,CAACC,SAAS;AAAA,IAAAxE,gBAAA,aAA9BgH,MAAM,eACE;EACjBmC,SAAS,EAAE1E,qBAAS,CAACC,MAAM;EAC3B2D,oBAAoB,EAAE5D,qBAAS,CAAC6G,IAAI;EACpClC,OAAO,EAAE3E,qBAAS,CAAC8G,KAAK;EACxBlC,cAAc,EAAE5E,qBAAS,CAAC8G,KAAK;EAC/BjC,eAAe,EAAE7E,qBAAS,CAAC+G,MAAM;EACjCpE,OAAO,EAAE3C,qBAAS,CAACgH,IAAI,CAAC9G,UAAU;EAClC4E,OAAO,EAAE9E,qBAAS,CAACgH,IAAI;EACvB/D,SAAS,EAAEjD,qBAAS,CAAC6G,IAAI;EACzBnE,oBAAoB,EAAE1C,qBAAS,CAACgH,IAAI;EACpCjC,IAAI,EAAE/E,qBAAS,CAACiH,SAAS,CAAC,CAACjH,qBAAS,CAACC,MAAM,EAAED,qBAAS,CAACkH,MAAM,CAAC;AAChE,CAAC;AAAA,IAAA3L,gBAAA,aAZUgH,MAAM,kBAcK;EACpBoC,OAAO,EAAEA,aAAO;EAChB1B,SAAS,EAAE;AACb,CAAC;AAAA,IAAAkE,QAAA,GAAAzJ,OAAA,cAiKY6E,MAAM","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"index.js","names":["_react","_interopRequireDefault","require","_propTypes","_Button","_IconButton","_styles","_debug","_lodashEs","_renderUi","_keys","_keysLayout","_commonStyles","_mathliveInstance","ownKeys","e","r","t","Object","keys","getOwnPropertySymbols","o","filter","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","arguments","length","forEach","_defineProperty2","getOwnPropertyDescriptors","defineProperties","defineProperty","_callSuper","_getPrototypeOf2","_possibleConstructorReturn2","_isNativeReflectConstruct","Reflect","construct","constructor","Boolean","prototype","valueOf","call","log","debug","LabelHolder","styled","pointerEvents","textTransform","color","text","display","alignItems","justifyContent","lineHeight","maxWidth","overflow","position","width","backgroundColor","keypadEmptyPlaceholder","undefined","opacity","EMPTY_SLOT","EMPTY_GROUP_REGEX","latexForDisplay","exports","latex","replace","concat","LatexLabel","_React$Component","props","_this","_classCallCheck2","state","markup","latexToMarkup","_inherits2","_createClass2","key","value","_componentDidMount","_asyncToGenerator2","_regenerator","mark","_callee","wrap","_context","prev","next","abrupt","loadMathLive","unmounted","setState","warned","stop","componentDidMount","componentDidUpdate","prevProps","componentWillUnmount","render","createElement","dangerouslySetInnerHTML","__html","React","Component","PropTypes","string","isRequired","createCustomLayout","layoutObj","gridTemplateColumns","columns","gridTemplateRows","rows","gridAutoFlow","KeyPadContainer","commonKeyboardStyles","gridRowGap","gridColumnGap","fontFamily","buttonBackground","category","keypadButtonOperator","keypadButton","keypadButtonOperatorHover","keypadButtonHover","StyledButton","Button","_ref","isDelete","isComma","isDot","minWidth","fontSize","borderRadius","StyledLatexButtonWrapper","_ref2","padding","margin","StyledIconButton","IconButton","_ref3","height","KeyPad","_React$Component2","_this2","setKeypadInteraction","onPress","base","extras","flatten","_toConsumableArray2","sortKeys","noDecimal","write","label","keypadRef","createRef","_this$keypadRef","keyPadElement","current","mainContainer","closest","currentToolbar","controlledKeypadMode","mainContainerPosition","getBoundingClientRect","currentToolbarPosition","difference","top","totalHeight","style","addEventListener","handleKeypadInteraction","_this$keypadRef2","removeEventListener","_this3","_this$props","className","baseSet","additionalKeys","layoutForKeyPad","onFocus","mode","noBaseSet","keysWithoutBaseSet","includes","allKeys","flowKeys","shift","Math","floor","ref","join","map","k","index","command","extra","actions","extraProps","onClick","buttonClick","bind","disabled","keyIsNotAllowed","ariaLabel","name","_extends2","Icon","icon","tabIndex","size","bool","array","object","func","oneOfType","number","_default"],"sources":["../../src/keypad/index.jsx"],"sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport Button from '@mui/material/Button';\nimport IconButton from '@mui/material/IconButton';\nimport { styled } from '@mui/material/styles';\nimport debug from 'debug';\nimport { flatten } from 'lodash-es';\nimport { color } from '@pie-lib/render-ui';\n\nimport { baseSet } from '../keys';\nimport { sortKeys } from './keys-layout';\nimport { commonKeyboardStyles } from '../mf/common-styles';\nimport { loadMathLive, latexToMarkup } from '../mathlive-instance';\n\nconst log = debug('pie-lib:math-input-mathlive:keypad');\n\n/**\n * A LaTeX keypad label.\n *\n * The MathQuill implementation rendered every LaTeX label as its own\n * `MQ.StaticMath` instance. Here each label is static HTML produced once by\n * `convertLatexToMarkup`, so a 40-key keypad no longer creates 40 live math\n * instances.\n */\n// The `color.*()` helpers must be called lazily, inside the styled callback.\n// Evaluating them in a plain object literal runs them at module load, which\n// breaks any consumer that mocks a subset of @pie-lib/render-ui.\nconst LabelHolder = styled('span')(() => ({\n pointerEvents: 'none',\n textTransform: 'none',\n color: color.text(),\n display: 'inline-flex',\n alignItems: 'center',\n justifyContent: 'center',\n lineHeight: 1,\n // Never let a label size its grid column. Stretchy accents\n // (\\overrightarrow, \\overleftrightarrow, \\overarc) render an <svg> that\n // mathlive-static.css positions absolutely at width:100%; if that stylesheet\n // is missing the svg lays out statically and expands without bound, dragging\n // the whole column across the screen. `overflow: hidden` also collapses the\n // label's min-content contribution, so the grid can't blow out either way.\n maxWidth: '100%',\n overflow: 'hidden',\n '& svg': {\n position: 'absolute',\n width: '100%',\n },\n // Answer-block / empty-slot boxes inside a label.\n '& .ML__placeholder': {\n backgroundColor: color.keypadEmptyPlaceholder ? color.keypadEmptyPlaceholder() : undefined,\n },\n // The stand-in glyph for an empty argument slot (see EMPTY_SLOT). Muted so it\n // reads as \"a slot goes here\" rather than as part of the symbol, matching how\n // MathQuill shaded `.mq-empty`.\n '& [data-pie-empty]': {\n opacity: 0.5,\n },\n}));\n\n/**\n * A visible stand-in for an empty argument slot.\n *\n * Key latex uses empty groups to show the shape of a command - `\\frac{}{}`,\n * `\\overline{}`, `x^{}`. MathQuill drew those as a shaded box (`.mq-empty`);\n * MathLive renders `{}` as nothing at all, so those buttons come out blank.\n * `\\placeholder{}` is not a substitute: in static markup it renders as a\n * non-breaking space (the editable box only exists inside a live mathfield), so\n * an actual glyph is required.\n *\n * Tagged with `pie-empty` so it can be muted via CSS.\n */\nconst EMPTY_SLOT = '\\\\htmlData{pie-empty=1}{\\\\unicode{\"25AB}}';\nconst EMPTY_GROUP_REGEX = /\\{\\s*\\}/g;\n\n/**\n * Display-only: give empty groups something visible.\n * Never use this for the value that gets inserted into the field - the key's\n * own latex is what gets typed.\n */\nexport const latexForDisplay = (latex) => (latex || '').replace(EMPTY_GROUP_REGEX, `{${EMPTY_SLOT}}`);\n\nexport class LatexLabel extends React.Component {\n static propTypes = {\n latex: PropTypes.string.isRequired,\n };\n\n constructor(props) {\n super(props);\n this.state = { markup: latexToMarkup(latexForDisplay(props.latex)) };\n }\n\n async componentDidMount() {\n // MathLive may not have finished loading when the keypad first mounts.\n if (this.state.markup) {\n return;\n }\n\n await loadMathLive();\n\n if (this.unmounted) {\n return;\n }\n\n const markup = latexToMarkup(latexForDisplay(this.props.latex));\n\n if (markup) {\n this.setState({ markup });\n return;\n }\n\n // Still nothing: the engine is genuinely unavailable (a missing chunk, a\n // blocked request). Keep the raw-latex fallback visible rather than an\n // empty button, and log once so this is diagnosable.\n if (!LatexLabel.warned) {\n LatexLabel.warned = true;\n log('MathLive unavailable - keypad labels are falling back to raw latex');\n }\n }\n\n componentDidUpdate(prevProps) {\n if (prevProps.latex !== this.props.latex) {\n this.setState({ markup: latexToMarkup(latexForDisplay(this.props.latex)) });\n }\n }\n\n componentWillUnmount() {\n this.unmounted = true;\n }\n\n render() {\n const { markup } = this.state;\n\n // Fall back to the raw latex so a button is never blank.\n return markup ? (\n // eslint-disable-next-line react/no-danger\n <LabelHolder dangerouslySetInnerHTML={{ __html: markup }} />\n ) : (\n <LabelHolder>{this.props.latex}</LabelHolder>\n );\n }\n}\n\nconst createCustomLayout = (layoutObj) => {\n if (layoutObj) {\n return {\n gridTemplateColumns: `repeat(${layoutObj.columns}, minmax(min-content, 150px))`,\n gridTemplateRows: `repeat(${layoutObj.rows}, minmax(40px, 60px))`,\n gridAutoFlow: 'initial',\n };\n }\n\n return {};\n};\n\nconst KeyPadContainer = styled('div')(() => ({\n ...commonKeyboardStyles,\n width: '100%',\n display: 'grid',\n gridTemplateRows: 'repeat(5, minmax(40px, 60px))',\n gridRowGap: '0px',\n gridColumnGap: '0px',\n gridAutoFlow: 'column',\n '&.character': {\n textTransform: 'initial !important',\n gridTemplateRows: 'repeat(5, minmax(40px, 50px)) !important',\n },\n '&.language': {\n gridTemplateRows: 'repeat(4, minmax(40px, 50px)) !important',\n '& *': {\n fontFamily: 'Roboto, Helvetica, Arial, sans-serif !important',\n },\n },\n}));\n\nconst buttonBackground = (category) => ({\n backgroundColor: category === 'operators' ? color.keypadButtonOperator() : color.keypadButton(),\n '&:hover': {\n backgroundColor: category === 'operators' ? color.keypadButtonOperatorHover() : color.keypadButtonHover(),\n },\n});\n\nconst StyledButton = styled(Button)(({ category, isDelete, isComma, isDot }) => ({\n minWidth: 'auto',\n textTransform: 'none',\n fontSize: isComma || isDot ? '200% !important' : '140% !important',\n lineHeight: isComma || isDot ? '100%' : 'normal',\n color: color.text(),\n ...buttonBackground(category),\n borderRadius: 0,\n ...(isDelete && {\n fontFamily: 'Roboto, Helvetica, Arial, sans-serif !important',\n }),\n}));\n\nconst StyledLatexButtonWrapper = styled(Button)(({ category }) => ({\n textTransform: 'none',\n padding: 0,\n margin: 0,\n fontSize: '110% !important',\n minWidth: 'auto',\n borderRadius: 0,\n ...buttonBackground(category),\n}));\n\nconst StyledIconButton = styled(IconButton)(({ category }) => ({\n minWidth: 'auto',\n ...buttonBackground(category),\n borderRadius: 0,\n '& .icon': {\n height: '30px',\n },\n}));\n\nexport class KeyPad extends React.Component {\n static propTypes = {\n className: PropTypes.string,\n controlledKeypadMode: PropTypes.bool,\n baseSet: PropTypes.array,\n additionalKeys: PropTypes.array,\n layoutForKeyPad: PropTypes.object,\n onPress: PropTypes.func.isRequired,\n onFocus: PropTypes.func,\n noDecimal: PropTypes.bool,\n setKeypadInteraction: PropTypes.func,\n mode: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),\n };\n\n static defaultProps = {\n baseSet: baseSet,\n noDecimal: false,\n };\n\n constructor(props) {\n super(props);\n this.keypadRef = React.createRef();\n }\n\n componentDidMount() {\n // Ensure MathLive is available for the LaTeX labels.\n loadMathLive();\n\n const keyPadElement = this.keypadRef?.current;\n const mainContainer = keyPadElement?.closest('.main-container');\n const currentToolbar = keyPadElement?.closest('.pie-toolbar');\n\n // need only for math keyboard so we need also controlledKeypadMode\n if (this.props.controlledKeypadMode && mainContainer && currentToolbar) {\n const mainContainerPosition = mainContainer.getBoundingClientRect();\n const currentToolbarPosition = currentToolbar.getBoundingClientRect();\n const difference =\n mainContainerPosition.top +\n mainContainerPosition.height -\n (currentToolbarPosition.top + currentToolbarPosition.height);\n\n if (difference < 0) {\n const totalHeight = mainContainerPosition.height + mainContainerPosition.top - difference;\n\n mainContainer.style.height = `${totalHeight}px`;\n }\n }\n\n if (keyPadElement) {\n keyPadElement.addEventListener('touchstart', this.handleKeypadInteraction, true);\n keyPadElement.addEventListener('mousedown', this.handleKeypadInteraction, true);\n }\n }\n\n componentWillUnmount() {\n const keyPadElement = this.keypadRef?.current;\n\n if (this.props.controlledKeypadMode && keyPadElement) {\n const mainContainer = keyPadElement.closest('.main-container');\n\n if (mainContainer) {\n mainContainer.style.height = 'unset';\n }\n }\n\n if (keyPadElement) {\n keyPadElement.removeEventListener('touchstart', this.handleKeypadInteraction, true);\n keyPadElement.removeEventListener('mousedown', this.handleKeypadInteraction, true);\n }\n }\n\n handleKeypadInteraction = () => {\n if (this.props.setKeypadInteraction) {\n this.props.setKeypadInteraction(true);\n }\n };\n\n buttonClick = (key) => {\n log('[buttonClick]', key);\n this.props.onPress(key);\n };\n\n flowKeys = (base, extras) => flatten([...sortKeys(base), ...sortKeys(extras)]);\n\n keyIsNotAllowed = (key) => {\n const { noDecimal } = this.props;\n\n return !!(((key.write === '.' && key.label === '.') || (key.write === ',' && key.label === ',')) && noDecimal);\n };\n\n render() {\n const { className, baseSet: base, additionalKeys, layoutForKeyPad, onFocus, mode } = this.props;\n\n const noBaseSet = ['non-negative-integers', 'integers', 'decimals', 'fractions', 'item-authoring', 'language'];\n const keysWithoutBaseSet = noBaseSet.includes(mode);\n const allKeys = keysWithoutBaseSet\n ? this.flowKeys([], additionalKeys || [])\n : this.flowKeys(base, additionalKeys || []);\n\n const shift = allKeys.length % 5 ? 1 : 0;\n const style = {\n gridTemplateColumns: `repeat(${Math.floor(allKeys.length / 5) + shift}, minmax(min-content, 150px))`,\n ...createCustomLayout(layoutForKeyPad),\n };\n\n return (\n <KeyPadContainer\n ref={this.keypadRef}\n className={[className, mode].filter(Boolean).join(' ')}\n style={style}\n onFocus={onFocus}\n >\n {allKeys.map((k, index) => {\n if (!k) {\n return <span key={`empty-${index}`} />;\n }\n\n const key = `${k.label || k.latex || k.command}-${index}`;\n const category = !keysWithoutBaseSet ? k.category : undefined;\n const extra = { ...(k.actions || {}), ...(k.extraProps || {}) };\n const onClick = this.buttonClick.bind(this, k);\n const disabled = this.keyIsNotAllowed(k);\n const ariaLabel = k.ariaLabel ? k.ariaLabel : k.name || k.label;\n\n if (k.latex) {\n return (\n <StyledLatexButtonWrapper\n key={key}\n onClick={onClick}\n disabled={disabled}\n category={category}\n aria-label={ariaLabel}\n {...extra}\n >\n <LatexLabel latex={k.latex} />\n </StyledLatexButtonWrapper>\n );\n }\n\n if (k.label) {\n return (\n <StyledButton\n key={key}\n onClick={onClick}\n disabled={disabled}\n category={category}\n isDelete={k.label === '⌫'}\n isComma={k.label === ','}\n isDot={k.label === '.'}\n aria-label={ariaLabel}\n {...extra}\n >\n {k.label}\n </StyledButton>\n );\n }\n\n const Icon = k.icon ? k.icon : 'div';\n\n return (\n <StyledIconButton\n key={key}\n tabIndex={'-1'}\n onClick={onClick}\n disabled={disabled}\n category={category}\n size=\"large\"\n {...extra}\n >\n <Icon className=\"icon\" />\n </StyledIconButton>\n );\n })}\n </KeyPadContainer>\n );\n }\n}\n\nexport default KeyPad;\n"],"mappings":";;;;;;;;;;;;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,UAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,OAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,IAAAG,WAAA,GAAAJ,sBAAA,CAAAC,OAAA;AACA,IAAAI,OAAA,GAAAJ,OAAA;AACA,IAAAK,MAAA,GAAAN,sBAAA,CAAAC,OAAA;AACA,IAAAM,SAAA,GAAAN,OAAA;AACA,IAAAO,SAAA,GAAAP,OAAA;AAEA,IAAAQ,KAAA,GAAAR,OAAA;AACA,IAAAS,WAAA,GAAAT,OAAA;AACA,IAAAU,aAAA,GAAAV,OAAA;AACA,IAAAW,iBAAA,GAAAX,OAAA;AAAmE,SAAAY,QAAAC,CAAA,EAAAC,CAAA,QAAAC,CAAA,GAAAC,MAAA,CAAAC,IAAA,CAAAJ,CAAA,OAAAG,MAAA,CAAAE,qBAAA,QAAAC,CAAA,GAAAH,MAAA,CAAAE,qBAAA,CAAAL,CAAA,GAAAC,CAAA,KAAAK,CAAA,GAAAA,CAAA,CAAAC,MAAA,WAAAN,CAAA,WAAAE,MAAA,CAAAK,wBAAA,CAAAR,CAAA,EAAAC,CAAA,EAAAQ,UAAA,OAAAP,CAAA,CAAAQ,IAAA,CAAAC,KAAA,CAAAT,CAAA,EAAAI,CAAA,YAAAJ,CAAA;AAAA,SAAAU,cAAAZ,CAAA,aAAAC,CAA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gBAET3M,MAAA,YAAAyG,aAAA,CAAC6G,IAAI;UAAC/B,SAAS,EAAC;QAAM,CAAE,CACR,CAAC;MAEvB,CAAC,CACc,CAAC;IAEtB;EAAC;AAAA,EA/KyB3E,iBAAK,CAACC,SAAS;AAAA,IAAA9E,gBAAA,aAA9BqH,MAAM,eACE;EACjBmC,SAAS,EAAEzE,qBAAS,CAACC,MAAM;EAC3B0D,oBAAoB,EAAE3D,qBAAS,CAAC4G,IAAI;EACpClC,OAAO,EAAE1E,qBAAS,CAAC6G,KAAK;EACxBlC,cAAc,EAAE3E,qBAAS,CAAC6G,KAAK;EAC/BjC,eAAe,EAAE5E,qBAAS,CAAC8G,MAAM;EACjCpE,OAAO,EAAE1C,qBAAS,CAAC+G,IAAI,CAAC7G,UAAU;EAClC2E,OAAO,EAAE7E,qBAAS,CAAC+G,IAAI;EACvB/D,SAAS,EAAEhD,qBAAS,CAAC4G,IAAI;EACzBnE,oBAAoB,EAAEzC,qBAAS,CAAC+G,IAAI;EACpCjC,IAAI,EAAE9E,qBAAS,CAACgH,SAAS,CAAC,CAAChH,qBAAS,CAACC,MAAM,EAAED,qBAAS,CAACiH,MAAM,CAAC;AAChE,CAAC;AAAA,IAAAhM,gBAAA,aAZUqH,MAAM,kBAcK;EACpBoC,OAAO,EAAEA,aAAO;EAChB1B,SAAS,EAAE;AACb,CAAC;AAAA,IAAAkE,QAAA,GAAA3J,OAAA,cAiKY+E,MAAM","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { latexForDisplay } from '../keypad';
|
|
2
|
+
import { keyToAction } from '../latex-bridge';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Keys use empty groups to show a command's shape (`\frac{}{}`, `x^{}`).
|
|
6
|
+
* MathLive renders `{}` as nothing, so labels need a visible stand-in - but the
|
|
7
|
+
* value that gets *inserted* must stay untouched.
|
|
8
|
+
*/
|
|
9
|
+
describe('keypad label display normalisation', () => {
|
|
10
|
+
it('gives empty groups a visible glyph', () => {
|
|
11
|
+
const out = latexForDisplay('\\frac{}{}');
|
|
12
|
+
|
|
13
|
+
expect(out).not.toEqual('\\frac{}{}');
|
|
14
|
+
expect(out).toContain('25AB'); // white small square
|
|
15
|
+
expect(out).toContain('pie-empty');
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
it('handles every empty-group key shape', () => {
|
|
19
|
+
['\\frac{}{}', '\\overline{}', 'x^{}', 'x_{}', '\\sqrt{}', '\\sqrt[{}]{}', '\\abs{}', '\\log_{}', '\\longdiv{}'].forEach(
|
|
20
|
+
(latex) => {
|
|
21
|
+
expect(latexForDisplay(latex)).not.toContain('{}');
|
|
22
|
+
},
|
|
23
|
+
);
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
it('treats a whitespace-only group as empty', () => {
|
|
27
|
+
// e.g. \frac{x}{ }
|
|
28
|
+
expect(latexForDisplay('\\frac{x}{ }')).toContain('pie-empty');
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
it('leaves latex without empty groups alone', () => {
|
|
32
|
+
['\\pi', '\\sin', 'x^2', '\\overline{AB}'].forEach((latex) => {
|
|
33
|
+
expect(latexForDisplay(latex)).toEqual(latex);
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
it('handles nullish input', () => {
|
|
38
|
+
expect(latexForDisplay(undefined)).toEqual('');
|
|
39
|
+
expect(latexForDisplay('')).toEqual('');
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
it('does NOT affect what gets inserted into the field', () => {
|
|
43
|
+
// the action must use the key's own latex, never the display form
|
|
44
|
+
const key = { name: 'frac', latex: '\\frac{}{}' };
|
|
45
|
+
|
|
46
|
+
expect(keyToAction(key).value).toEqual('\\frac{}{}');
|
|
47
|
+
expect(keyToAction(key).value).not.toContain('pie-empty');
|
|
48
|
+
});
|
|
49
|
+
});
|
package/src/keypad/index.jsx
CHANGED
|
@@ -49,8 +49,36 @@ const LabelHolder = styled('span')(() => ({
|
|
|
49
49
|
'& .ML__placeholder': {
|
|
50
50
|
backgroundColor: color.keypadEmptyPlaceholder ? color.keypadEmptyPlaceholder() : undefined,
|
|
51
51
|
},
|
|
52
|
+
// The stand-in glyph for an empty argument slot (see EMPTY_SLOT). Muted so it
|
|
53
|
+
// reads as "a slot goes here" rather than as part of the symbol, matching how
|
|
54
|
+
// MathQuill shaded `.mq-empty`.
|
|
55
|
+
'& [data-pie-empty]': {
|
|
56
|
+
opacity: 0.5,
|
|
57
|
+
},
|
|
52
58
|
}));
|
|
53
59
|
|
|
60
|
+
/**
|
|
61
|
+
* A visible stand-in for an empty argument slot.
|
|
62
|
+
*
|
|
63
|
+
* Key latex uses empty groups to show the shape of a command - `\frac{}{}`,
|
|
64
|
+
* `\overline{}`, `x^{}`. MathQuill drew those as a shaded box (`.mq-empty`);
|
|
65
|
+
* MathLive renders `{}` as nothing at all, so those buttons come out blank.
|
|
66
|
+
* `\placeholder{}` is not a substitute: in static markup it renders as a
|
|
67
|
+
* non-breaking space (the editable box only exists inside a live mathfield), so
|
|
68
|
+
* an actual glyph is required.
|
|
69
|
+
*
|
|
70
|
+
* Tagged with `pie-empty` so it can be muted via CSS.
|
|
71
|
+
*/
|
|
72
|
+
const EMPTY_SLOT = '\\htmlData{pie-empty=1}{\\unicode{"25AB}}';
|
|
73
|
+
const EMPTY_GROUP_REGEX = /\{\s*\}/g;
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Display-only: give empty groups something visible.
|
|
77
|
+
* Never use this for the value that gets inserted into the field - the key's
|
|
78
|
+
* own latex is what gets typed.
|
|
79
|
+
*/
|
|
80
|
+
export const latexForDisplay = (latex) => (latex || '').replace(EMPTY_GROUP_REGEX, `{${EMPTY_SLOT}}`);
|
|
81
|
+
|
|
54
82
|
export class LatexLabel extends React.Component {
|
|
55
83
|
static propTypes = {
|
|
56
84
|
latex: PropTypes.string.isRequired,
|
|
@@ -58,7 +86,7 @@ export class LatexLabel extends React.Component {
|
|
|
58
86
|
|
|
59
87
|
constructor(props) {
|
|
60
88
|
super(props);
|
|
61
|
-
this.state = { markup: latexToMarkup(props.latex) };
|
|
89
|
+
this.state = { markup: latexToMarkup(latexForDisplay(props.latex)) };
|
|
62
90
|
}
|
|
63
91
|
|
|
64
92
|
async componentDidMount() {
|
|
@@ -73,7 +101,7 @@ export class LatexLabel extends React.Component {
|
|
|
73
101
|
return;
|
|
74
102
|
}
|
|
75
103
|
|
|
76
|
-
const markup = latexToMarkup(this.props.latex);
|
|
104
|
+
const markup = latexToMarkup(latexForDisplay(this.props.latex));
|
|
77
105
|
|
|
78
106
|
if (markup) {
|
|
79
107
|
this.setState({ markup });
|
|
@@ -91,7 +119,7 @@ export class LatexLabel extends React.Component {
|
|
|
91
119
|
|
|
92
120
|
componentDidUpdate(prevProps) {
|
|
93
121
|
if (prevProps.latex !== this.props.latex) {
|
|
94
|
-
this.setState({ markup: latexToMarkup(this.props.latex) });
|
|
122
|
+
this.setState({ markup: latexToMarkup(latexForDisplay(this.props.latex)) });
|
|
95
123
|
}
|
|
96
124
|
}
|
|
97
125
|
|