@pie-lib/math-input-mathlive 1.0.0 → 1.0.1
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 +16 -15
- package/lib/__tests__/drop-in-compat.test.js +133 -0
- package/lib/__tests__/drop-in-compat.test.js.map +1 -0
- package/lib/__tests__/latex-bridge.test.js.map +1 -1
- package/lib/__tests__/mathlive-instance.test.js.map +1 -1
- package/lib/keypad/index.js +17 -12
- package/lib/keypad/index.js.map +1 -1
- package/package.json +1 -1
- package/src/__tests__/drop-in-compat.test.jsx +112 -0
- package/src/__tests__/latex-bridge.test.js +1 -8
- package/src/__tests__/mathlive-instance.test.js +5 -3
- package/src/keypad/index.jsx +7 -7
package/README.md
CHANGED
|
@@ -20,14 +20,14 @@ The field wrappers are exported as `mf`, with `mq` kept as an alias so existing
|
|
|
20
20
|
|
|
21
21
|
### Behaviour differences
|
|
22
22
|
|
|
23
|
-
|
|
|
24
|
-
|
|
25
|
-
| `mq.Input`
|
|
26
|
-
| `mq.Static` (display)
|
|
27
|
-
| `mq.Static` (answer blocks) | `innerFields`
|
|
28
|
-
| `updateSpans()`
|
|
29
|
-
| `registerEmbed`
|
|
30
|
-
| Loading
|
|
23
|
+
| | `@pie-lib/math-input` | this package |
|
|
24
|
+
| --------------------------- | -------------------------------- | ----------------------------------------------------------------------------- |
|
|
25
|
+
| `mq.Input` | MathQuill `MathField` | `<math-field>` |
|
|
26
|
+
| `mq.Static` (display) | one `MQ.StaticMath` per instance | `convertLatexToMarkup`, no live instance |
|
|
27
|
+
| `mq.Static` (answer blocks) | `innerFields` | prompts API (`getPrompts`/`getPromptValue`) |
|
|
28
|
+
| `updateSpans()` | patched MathQuill DOM | **no-op** (kept for compatibility) |
|
|
29
|
+
| `registerEmbed` | MathQuill embed plugin | macro + `\htmlData` shim, see below |
|
|
30
|
+
| Loading | synchronous | **async** - `await loadMathLive()` before `applyStaticMath` / `latexToMarkup` |
|
|
31
31
|
|
|
32
32
|
### Content model is preserved
|
|
33
33
|
|
|
@@ -35,10 +35,10 @@ Stored latex keeps its MathQuill-era form, so items authored with either
|
|
|
35
35
|
implementation stay readable and `@pie-lib/math-rendering` needs no change.
|
|
36
36
|
Translation happens at the package boundary:
|
|
37
37
|
|
|
38
|
-
| stored
|
|
39
|
-
|
|
40
|
-
| `\embed{newLine}[]`
|
|
41
|
-
| `\MathQuillMathField[id]{}` | `\placeholder[id]{}`
|
|
38
|
+
| stored | in MathLive |
|
|
39
|
+
| --------------------------- | ----------------------- |
|
|
40
|
+
| `\embed{newLine}[]` | `\displaylines{… \\ …}` |
|
|
41
|
+
| `\MathQuillMathField[id]{}` | `\placeholder[id]{}` |
|
|
42
42
|
|
|
43
43
|
`toMathLive()` / `fromMathLive()` are exported if you need the conversion directly.
|
|
44
44
|
|
|
@@ -89,7 +89,7 @@ widget do not port and need a redesign (`mf.getElementInfo()` exposes per-elemen
|
|
|
89
89
|
`Failed to construct 'URL': Invalid base URL`. Importing the stylesheet avoids
|
|
90
90
|
that code path completely.
|
|
91
91
|
|
|
92
|
-
|
|
92
|
+
_Bundler caveat:_ a `url-loader`/`file-loader` rule matching `woff2` will
|
|
93
93
|
corrupt these fonts (it emits a JS module under a `.woff2` name). Exclude
|
|
94
94
|
mathlive from such rules - see `packages/demo/next.config.js`.
|
|
95
95
|
|
|
@@ -98,14 +98,15 @@ widget do not port and need a redesign (`mf.getElementInfo()` exposes per-elemen
|
|
|
98
98
|
```js
|
|
99
99
|
import { configureFonts } from '@pie-lib/math-input-mathlive';
|
|
100
100
|
|
|
101
|
-
configureFonts('/mathlive-fonts');
|
|
101
|
+
configureFonts('/mathlive-fonts'); // before loadMathLive()
|
|
102
102
|
configureFonts('https://unpkg.com/mathlive@0.110.0/dist/fonts');
|
|
103
|
-
configureFonts(null);
|
|
103
|
+
configureFonts(null); // system fonts
|
|
104
104
|
```
|
|
105
105
|
|
|
106
106
|
Paths are resolved to absolute URLs against `document.baseURI`. If you neither
|
|
107
107
|
import the stylesheet nor call `configureFonts`, the package disables font
|
|
108
108
|
loading rather than leaving MathLive's crashing default in place.
|
|
109
|
+
|
|
109
110
|
- **Custom macros.** `PIE_MACROS` covers the pie-specific commands the MathQuill
|
|
110
111
|
fork understood (`\parallelogram`, `\longdiv`, `\napprox`, …) and is kept in
|
|
111
112
|
sync with the MathJax macros in `@pie-lib/math-rendering`.
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
5
|
+
var _react = _interopRequireDefault(require("react"));
|
|
6
|
+
var _react2 = require("@testing-library/react");
|
|
7
|
+
var _styles = require("@mui/material/styles");
|
|
8
|
+
var _index = require("../index");
|
|
9
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
10
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2["default"])(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
11
|
+
/**
|
|
12
|
+
* Exercises the exact call patterns real consumers use against
|
|
13
|
+
* @pie-lib/math-input, to catch drop-in incompatibilities.
|
|
14
|
+
*
|
|
15
|
+
* Sources:
|
|
16
|
+
* - packages/math-toolbar/src/editor-and-pad.jsx:16,185
|
|
17
|
+
* - packages/math-toolbar/src/math-preview.jsx:8,156
|
|
18
|
+
* - packages/editable-html/src/plugins/respArea/math-templated/index.jsx:92
|
|
19
|
+
* - packages/editable-html-tip-tap/src/components/respArea/MathTemplated.jsx:111
|
|
20
|
+
*/
|
|
21
|
+
describe('drop-in compatibility with @pie-lib/math-input consumers', function () {
|
|
22
|
+
describe('mq.CommonMqStyles destructuring', function () {
|
|
23
|
+
it('math-preview.jsx: { commonMqFontStyles, longdivStyles, supsubStyles }', function () {
|
|
24
|
+
var _mq$CommonMqStyles = _index.mq.CommonMqStyles,
|
|
25
|
+
commonMqFontStyles = _mq$CommonMqStyles.commonMqFontStyles,
|
|
26
|
+
longdivStyles = _mq$CommonMqStyles.longdivStyles,
|
|
27
|
+
supsubStyles = _mq$CommonMqStyles.supsubStyles;
|
|
28
|
+
expect(commonMqFontStyles).toBeDefined();
|
|
29
|
+
expect(longdivStyles).toBeDefined();
|
|
30
|
+
expect(supsubStyles).toBeDefined();
|
|
31
|
+
});
|
|
32
|
+
it('editor-and-pad.jsx: also { commonMqKeyboardStyles }', function () {
|
|
33
|
+
var _mq$CommonMqStyles2 = _index.mq.CommonMqStyles,
|
|
34
|
+
commonMqFontStyles = _mq$CommonMqStyles2.commonMqFontStyles,
|
|
35
|
+
commonMqKeyboardStyles = _mq$CommonMqStyles2.commonMqKeyboardStyles,
|
|
36
|
+
longdivStyles = _mq$CommonMqStyles2.longdivStyles,
|
|
37
|
+
supsubStyles = _mq$CommonMqStyles2.supsubStyles;
|
|
38
|
+
expect(commonMqKeyboardStyles).toBeDefined();
|
|
39
|
+
// All four must be spreadable into an emotion style object.
|
|
40
|
+
expect(function () {
|
|
41
|
+
return _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, commonMqFontStyles), commonMqKeyboardStyles), longdivStyles), supsubStyles);
|
|
42
|
+
}).not.toThrow();
|
|
43
|
+
});
|
|
44
|
+
it('the destructured groups survive being spread into a styled component', function () {
|
|
45
|
+
var _mq$CommonMqStyles3 = _index.mq.CommonMqStyles,
|
|
46
|
+
commonMqFontStyles = _mq$CommonMqStyles3.commonMqFontStyles,
|
|
47
|
+
longdivStyles = _mq$CommonMqStyles3.longdivStyles,
|
|
48
|
+
supsubStyles = _mq$CommonMqStyles3.supsubStyles;
|
|
49
|
+
var Styled = (0, _styles.styled)('div')(_objectSpread(_objectSpread(_objectSpread({}, commonMqFontStyles), longdivStyles), supsubStyles));
|
|
50
|
+
expect(function () {
|
|
51
|
+
return (0, _react2.render)(/*#__PURE__*/_react["default"].createElement(Styled, null));
|
|
52
|
+
}).not.toThrow();
|
|
53
|
+
});
|
|
54
|
+
});
|
|
55
|
+
describe('mq.Input', function () {
|
|
56
|
+
it('editor-and-pad.jsx: styled(mq.Input) renders', function () {
|
|
57
|
+
var MathEditor = (0, _styles.styled)(_index.mq.Input)(function () {
|
|
58
|
+
return {
|
|
59
|
+
width: '100%'
|
|
60
|
+
};
|
|
61
|
+
});
|
|
62
|
+
expect(function () {
|
|
63
|
+
return (0, _react2.render)(/*#__PURE__*/_react["default"].createElement(MathEditor, {
|
|
64
|
+
latex: "\\\\frac{1}{2}",
|
|
65
|
+
onChange: function onChange() {}
|
|
66
|
+
}));
|
|
67
|
+
}).not.toThrow();
|
|
68
|
+
});
|
|
69
|
+
it('accepts the className that styled() injects', function () {
|
|
70
|
+
var Styled = (0, _styles.styled)(_index.mq.Input)({
|
|
71
|
+
padding: 4
|
|
72
|
+
});
|
|
73
|
+
var _render = (0, _react2.render)(/*#__PURE__*/_react["default"].createElement(Styled, {
|
|
74
|
+
latex: "x",
|
|
75
|
+
onChange: function onChange() {}
|
|
76
|
+
})),
|
|
77
|
+
container = _render.container;
|
|
78
|
+
expect(container.firstChild).toBeTruthy();
|
|
79
|
+
expect(container.firstChild.className).toBeTruthy();
|
|
80
|
+
});
|
|
81
|
+
});
|
|
82
|
+
describe('mq.Static', function () {
|
|
83
|
+
it('math-preview.jsx: <mq.Static latex onFocus onBlur />', function () {
|
|
84
|
+
expect(function () {
|
|
85
|
+
return (0, _react2.render)(/*#__PURE__*/_react["default"].createElement(_index.mq.Static, {
|
|
86
|
+
latex: '\\frac{1}{2}',
|
|
87
|
+
onFocus: function onFocus() {},
|
|
88
|
+
onBlur: function onBlur() {}
|
|
89
|
+
}));
|
|
90
|
+
}).not.toThrow();
|
|
91
|
+
});
|
|
92
|
+
it('math-templated respArea: <mq.Static latex={value} />', function () {
|
|
93
|
+
expect(function () {
|
|
94
|
+
return (0, _react2.render)(/*#__PURE__*/_react["default"].createElement(_index.mq.Static, {
|
|
95
|
+
latex: 'x=1'
|
|
96
|
+
}));
|
|
97
|
+
}).not.toThrow();
|
|
98
|
+
});
|
|
99
|
+
it('renders answer-block latex (the templated-math case) without throwing', function () {
|
|
100
|
+
expect(function () {
|
|
101
|
+
return (0, _react2.render)(/*#__PURE__*/_react["default"].createElement(_index.mq.Static, {
|
|
102
|
+
latex: 'x=\\MathQuillMathField[r1]{}',
|
|
103
|
+
onSubFieldChange: function onSubFieldChange() {}
|
|
104
|
+
}));
|
|
105
|
+
}).not.toThrow();
|
|
106
|
+
});
|
|
107
|
+
it('is styleable, as keypad labels were in math-input', function () {
|
|
108
|
+
var Styled = (0, _styles.styled)(_index.mq.Static)({
|
|
109
|
+
pointerEvents: 'none'
|
|
110
|
+
});
|
|
111
|
+
expect(function () {
|
|
112
|
+
return (0, _react2.render)(/*#__PURE__*/_react["default"].createElement(Styled, {
|
|
113
|
+
latex: '\\pi'
|
|
114
|
+
}));
|
|
115
|
+
}).not.toThrow();
|
|
116
|
+
});
|
|
117
|
+
});
|
|
118
|
+
describe('surface parity', function () {
|
|
119
|
+
it('exposes exactly the names math-input exported', function () {
|
|
120
|
+
// eslint-disable-next-line global-require
|
|
121
|
+
var pkg = require('../index');
|
|
122
|
+
['keysForGrade', 'addBrackets', 'removeBrackets', 'keys', 'HorizontalKeypad', 'mq', 'updateSpans', 'registerEmbed', 'applyStaticMath'].forEach(function (name) {
|
|
123
|
+
expect(pkg[name]).toBeDefined();
|
|
124
|
+
});
|
|
125
|
+
});
|
|
126
|
+
it('mq exposes Input, Static and CommonMqStyles', function () {
|
|
127
|
+
['Input', 'Static', 'CommonMqStyles'].forEach(function (name) {
|
|
128
|
+
expect(_index.mq[name]).toBeDefined();
|
|
129
|
+
});
|
|
130
|
+
});
|
|
131
|
+
});
|
|
132
|
+
});
|
|
133
|
+
//# sourceMappingURL=drop-in-compat.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"drop-in-compat.test.js","names":["_react","_interopRequireDefault","require","_react2","_styles","_index","ownKeys","e","r","t","Object","keys","getOwnPropertySymbols","o","filter","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","arguments","length","forEach","_defineProperty2","getOwnPropertyDescriptors","defineProperties","defineProperty","describe","it","_mq$CommonMqStyles","mq","CommonMqStyles","commonMqFontStyles","longdivStyles","supsubStyles","expect","toBeDefined","_mq$CommonMqStyles2","commonMqKeyboardStyles","not","toThrow","_mq$CommonMqStyles3","Styled","styled","render","createElement","MathEditor","Input","width","latex","onChange","padding","_render","container","firstChild","toBeTruthy","className","Static","onFocus","onBlur","onSubFieldChange","pointerEvents","pkg","name"],"sources":["../../src/__tests__/drop-in-compat.test.jsx"],"sourcesContent":["import React from 'react';\nimport { render } from '@testing-library/react';\nimport { styled } from '@mui/material/styles';\n\nimport { mq } from '../index';\n\n/**\n * Exercises the exact call patterns real consumers use against\n * @pie-lib/math-input, to catch drop-in incompatibilities.\n *\n * Sources:\n * - packages/math-toolbar/src/editor-and-pad.jsx:16,185\n * - packages/math-toolbar/src/math-preview.jsx:8,156\n * - packages/editable-html/src/plugins/respArea/math-templated/index.jsx:92\n * - packages/editable-html-tip-tap/src/components/respArea/MathTemplated.jsx:111\n */\ndescribe('drop-in compatibility with @pie-lib/math-input consumers', () => {\n describe('mq.CommonMqStyles destructuring', () => {\n it('math-preview.jsx: { commonMqFontStyles, longdivStyles, supsubStyles }', () => {\n const { commonMqFontStyles, longdivStyles, supsubStyles } = mq.CommonMqStyles;\n\n expect(commonMqFontStyles).toBeDefined();\n expect(longdivStyles).toBeDefined();\n expect(supsubStyles).toBeDefined();\n });\n\n it('editor-and-pad.jsx: also { commonMqKeyboardStyles }', () => {\n const { commonMqFontStyles, commonMqKeyboardStyles, longdivStyles, supsubStyles } = mq.CommonMqStyles;\n\n expect(commonMqKeyboardStyles).toBeDefined();\n // All four must be spreadable into an emotion style object.\n expect(() => ({\n ...commonMqFontStyles,\n ...commonMqKeyboardStyles,\n ...longdivStyles,\n ...supsubStyles,\n })).not.toThrow();\n });\n\n it('the destructured groups survive being spread into a styled component', () => {\n const { commonMqFontStyles, longdivStyles, supsubStyles } = mq.CommonMqStyles;\n const Styled = styled('div')({ ...commonMqFontStyles, ...longdivStyles, ...supsubStyles });\n\n expect(() => render(<Styled />)).not.toThrow();\n });\n });\n\n describe('mq.Input', () => {\n it('editor-and-pad.jsx: styled(mq.Input) renders', () => {\n const MathEditor = styled(mq.Input)(() => ({ width: '100%' }));\n\n expect(() => render(<MathEditor latex=\"\\\\frac{1}{2}\" onChange={() => {}} />)).not.toThrow();\n });\n\n it('accepts the className that styled() injects', () => {\n const Styled = styled(mq.Input)({ padding: 4 });\n const { container } = render(<Styled latex=\"x\" onChange={() => {}} />);\n\n expect(container.firstChild).toBeTruthy();\n expect(container.firstChild.className).toBeTruthy();\n });\n });\n\n describe('mq.Static', () => {\n it('math-preview.jsx: <mq.Static latex onFocus onBlur />', () => {\n expect(() => render(<mq.Static latex={'\\\\frac{1}{2}'} onFocus={() => {}} onBlur={() => {}} />)).not.toThrow();\n });\n\n it('math-templated respArea: <mq.Static latex={value} />', () => {\n expect(() => render(<mq.Static latex={'x=1'} />)).not.toThrow();\n });\n\n it('renders answer-block latex (the templated-math case) without throwing', () => {\n expect(() =>\n render(<mq.Static latex={'x=\\\\MathQuillMathField[r1]{}'} onSubFieldChange={() => {}} />),\n ).not.toThrow();\n });\n\n it('is styleable, as keypad labels were in math-input', () => {\n const Styled = styled(mq.Static)({ pointerEvents: 'none' });\n\n expect(() => render(<Styled latex={'\\\\pi'} />)).not.toThrow();\n });\n });\n\n describe('surface parity', () => {\n it('exposes exactly the names math-input exported', () => {\n // eslint-disable-next-line global-require\n const pkg = require('../index');\n\n [\n 'keysForGrade',\n 'addBrackets',\n 'removeBrackets',\n 'keys',\n 'HorizontalKeypad',\n 'mq',\n 'updateSpans',\n 'registerEmbed',\n 'applyStaticMath',\n ].forEach((name) => {\n expect(pkg[name]).toBeDefined();\n });\n });\n\n it('mq exposes Input, Static and CommonMqStyles', () => {\n ['Input', 'Static', 'CommonMqStyles'].forEach((name) => {\n expect(mq[name]).toBeDefined();\n });\n });\n });\n});\n"],"mappings":";;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AAEA,IAAAG,MAAA,GAAAH,OAAA;AAA8B,SAAAI,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,CAAA,MAAAA,CAAA,GAAAY,SAAA,CAAAC,MAAA,EAAAb,CAAA,UAAAC,CAAA,WAAAW,SAAA,CAAAZ,CAAA,IAAAY,SAAA,CAAAZ,CAAA,QAAAA,CAAA,OAAAF,OAAA,CAAAI,MAAA,CAAAD,CAAA,OAAAa,OAAA,WAAAd,CAAA,QAAAe,gBAAA,aAAAhB,CAAA,EAAAC,CAAA,EAAAC,CAAA,CAAAD,CAAA,SAAAE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SAAE,CAACiC,IAAI,CAAC,CAAC,CAAC3B,WAAW,CAAC,CAAC;MAChC,CAAC,CAAC;IACJ,CAAC,CAAC;EACJ,CAAC,CAAC;AACJ,CAAC,CAAC","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"latex-bridge.test.js","names":["_latexBridge","require","describe","it","expect","toMathLive","toEqual","undefined","concat","NEWLINE_EMBED","DEFAULT_FIELD_ID","fromMathLive","stored","fieldIds","latex","keyToAction","write","type","value","command","forEach","k","_typeof2","toBe","keystroke","toBeUndefined"],"sources":["../../src/__tests__/latex-bridge.test.js"],"sourcesContent":["import {\n toMathLive,\n fromMathLive,\n fieldIds,\n keyToAction,\n NEWLINE_EMBED,\n DEFAULT_FIELD_ID,\n} from '../latex-bridge';\n\ndescribe('latex-bridge', () => {\n describe('toMathLive', () => {\n it('passes plain latex through', () => {\n expect(toMathLive('\\\\frac{1}{2}')).toEqual('\\\\frac{1}{2}');\n });\n\n it('handles empty/nullish', () => {\n expect(toMathLive('')).toEqual('');\n expect(toMathLive(undefined)).toEqual('');\n expect(toMathLive(null)).toEqual('');\n });\n\n it('converts a newLine embed to a multiline environment', () => {\n expect(toMathLive(`a${NEWLINE_EMBED}b`)).toEqual('\\\\displaylines{a \\\\\\\\ b}');\n });\n\n it('converts multiple newLine embeds', () => {\n expect(toMathLive(`a${NEWLINE_EMBED}b${NEWLINE_EMBED}c`)).toEqual('\\\\displaylines{a \\\\\\\\ b \\\\\\\\ c}');\n });\n\n it('converts MathQuill answer blocks to placeholders', () => {\n expect(toMathLive('x=\\\\MathQuillMathField[r1]{}')).toEqual('x=\\\\placeholder[r1]{}');\n });\n\n it('preserves answer block content', () => {\n expect(toMathLive('\\\\MathQuillMathField[r2]{7}')).toEqual('\\\\placeholder[r2]{7}');\n });\n\n it('defaults an unnamed answer block id', () => {\n expect(toMathLive('\\\\MathQuillMathField[]{}')).toEqual(`\\\\placeholder[${DEFAULT_FIELD_ID}]{}`);\n });\n\n it('handles answer blocks and newlines together', () => {\n expect(toMathLive(`\\\\MathQuillMathField[r1]{}${NEWLINE_EMBED}x`)).toEqual(\n '\\\\displaylines{\\\\placeholder[r1]{} \\\\\\\\ x}',\n );\n });\n });\n\n describe('fromMathLive', () => {\n it('passes plain latex through', () => {\n expect(fromMathLive('\\\\frac{1}{2}')).toEqual('\\\\frac{1}{2}');\n });\n\n it('unwraps displaylines back to newLine embeds', () => {\n expect(fromMathLive('\\\\displaylines{a \\\\\\\\ b}')).toEqual(`a${NEWLINE_EMBED}b`);\n });\n\n it('converts placeholders back to MathQuill answer blocks', () => {\n expect(fromMathLive('x=\\\\placeholder[r1]{}')).toEqual('x=\\\\MathQuillMathField[r1]{}');\n });\n\n it('round-trips a newline document', () => {\n const stored = `a${NEWLINE_EMBED}b${NEWLINE_EMBED}c`;\n\n expect(fromMathLive(toMathLive(stored))).toEqual(stored);\n });\n\n it('round-trips an answer-block document', () => {\n const stored = 'x=\\\\MathQuillMathField[r1]{}+\\\\MathQuillMathField[r2]{3}';\n\n expect(fromMathLive(toMathLive(stored))).toEqual(stored);\n });\n\n it('round-trips answer blocks combined with newlines', () => {\n const stored = `\\\\MathQuillMathField[r1]{}${NEWLINE_EMBED}y`;\n\n expect(fromMathLive(toMathLive(stored))).toEqual(stored);\n });\n });\n\n describe('fieldIds', () => {\n it('returns ids in document order', () => {\n expect(fieldIds('\\\\MathQuillMathField[r1]{}+\\\\MathQuillMathField[r2]{}')).toEqual(['r1', 'r2']);\n });\n\n it('returns [] when there are none', () => {\n expect(fieldIds('x+y')).toEqual([]);\n expect(fieldIds(undefined)).toEqual([]);\n });\n\n it('is repeatable (regex lastIndex is reset)', () => {\n const latex = '\\\\MathQuillMathField[r1]{}';\n\n expect(fieldIds(latex)).toEqual(['r1']);\n expect(fieldIds(latex)).toEqual(['r1']);\n });\n });\n\n describe('keyToAction', () => {\n it('prefers latex when there is no command', () => {\n expect(keyToAction({ latex: '\\\\pi', write: 'p' })).toEqual({ type: 'insert', value: '\\\\pi' });\n });\n\n it('uses write', () => {\n expect(keyToAction({ write: 'x' })).toEqual({ type: 'insert', value: 'x' });\n });\n\n it('expands commands that take arguments into placeholders', () => {\n expect(keyToAction({ command: '\\\\frac' })).toEqual({ type: 'insert', value: '\\\\frac{#?}{#?}' });\n expect(keyToAction({ command: '\\\\sqrt' })).toEqual({ type: 'insert', value: '\\\\sqrt{#?}' });\n expect(keyToAction({ command: '^' })).toEqual({ type: 'insert', value: '^{#?}' });\n });\n\n it('passes argument-less commands through', () => {\n expect(keyToAction({ command: '\\\\pi' })).toEqual({ type: 'insert', value: '\\\\pi' });\n });\n\n it('concatenates array commands (MathQuill cmd() applied them in sequence)', () => {\n // Measured Angle\n expect(keyToAction({ command: ['m', '\\\\angle'] })).toEqual({ type: 'insert', value: 'm\\\\angle' });\n // log base n - the `_` part must still expand to a placeholder\n expect(keyToAction({ command: ['\\\\log', '_'] })).toEqual({ type: 'insert', value: '\\\\log_{#?}' });\n });\n\n it('always returns a string value for insert actions', () => {\n [{ command: ['m', '\\\\angle'] }, { command: '\\\\frac' }, { write: 'x' }, { latex: '\\\\pi' }].forEach((k) => {\n expect(typeof keyToAction(k).value).toBe('string');\n });\n });\n\n it('maps keystrokes to MathLive selectors', () => {\n expect(keyToAction({ keystroke: 'Left' })).toEqual({ type: 'command', value: 'moveToPreviousChar' });\n expect(keyToAction({ keystroke: 'Right' })).toEqual({ type: 'command', value: 'moveToNextChar' });\n expect(keyToAction({ keystroke: 'Backspace' })).toEqual({ type: 'command', value: 'deleteBackward' });\n });\n\n it('returns undefined for unknown/empty input', () => {\n expect(keyToAction(undefined)).toBeUndefined();\n expect(keyToAction({})).toBeUndefined();\n expect(keyToAction({ keystroke: 'Nope' })).toBeUndefined();\n });\n\n it('latex wins over command only when command is absent', () => {\n // a key with both should use the command path (matches MathInput.keypadPress)\n expect(keyToAction({ latex: '\\\\frac{}{}', command: '\\\\frac' })).toEqual({\n type: 'insert',\n value: '\\\\frac{#?}{#?}',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AAM,CAAC,IAAAW,wBAAW,EAAC;QAAES,SAAS,EAAE;MAAY,CAAC,CAAC,CAAC,CAAClB,OAAO,CAAC;QAAEW,IAAI,EAAE,SAAS;QAAEC,KAAK,EAAE;MAAiB,CAAC,CAAC;IACvG,CAAC,CAAC;IAEFf,EAAE,CAAC,2CAA2C,EAAE,YAAM;MACpDC,MAAM,CAAC,IAAAW,wBAAW,EAACR,SAAS,CAAC,CAAC,CAACkB,aAAa,CAAC,CAAC;MAC9CrB,MAAM,CAAC,IAAAW,wBAAW,EAAC,CAAC,CAAC,CAAC,CAAC,CAACU,aAAa,CAAC,CAAC;MACvCrB,MAAM,CAAC,IAAAW,wBAAW,EAAC;QAAES,SAAS,EAAE;MAAO,CAAC,CAAC,CAAC,CAACC,aAAa,CAAC,CAAC;IAC5D,CAAC,CAAC;IAEFtB,EAAE,CAAC,qDAAqD,EAAE,YAAM;MAC9D;MACAC,MAAM,CAAC,IAAAW,wBAAW,EAAC;QAAED,KAAK,EAAE,YAAY;QAAEK,OAAO,EAAE;MAAS,CAAC,CAAC,CAAC,CAACb,OAAO,CAAC;QACtEW,IAAI,EAAE,QAAQ;QACdC,KAAK,EAAE;MACT,CAAC,CAAC;IACJ,CAAC,CAAC;EACJ,CAAC,CAAC;AACJ,CAAC,CAAC","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"latex-bridge.test.js","names":["_latexBridge","require","describe","it","expect","toMathLive","toEqual","undefined","concat","NEWLINE_EMBED","DEFAULT_FIELD_ID","fromMathLive","stored","fieldIds","latex","keyToAction","write","type","value","command","forEach","k","_typeof2","toBe","keystroke","toBeUndefined"],"sources":["../../src/__tests__/latex-bridge.test.js"],"sourcesContent":["import { toMathLive, fromMathLive, fieldIds, keyToAction, NEWLINE_EMBED, DEFAULT_FIELD_ID } from '../latex-bridge';\n\ndescribe('latex-bridge', () => {\n describe('toMathLive', () => {\n it('passes plain latex through', () => {\n expect(toMathLive('\\\\frac{1}{2}')).toEqual('\\\\frac{1}{2}');\n });\n\n it('handles empty/nullish', () => {\n expect(toMathLive('')).toEqual('');\n expect(toMathLive(undefined)).toEqual('');\n expect(toMathLive(null)).toEqual('');\n });\n\n it('converts a newLine embed to a multiline environment', () => {\n expect(toMathLive(`a${NEWLINE_EMBED}b`)).toEqual('\\\\displaylines{a \\\\\\\\ b}');\n });\n\n it('converts multiple newLine embeds', () => {\n expect(toMathLive(`a${NEWLINE_EMBED}b${NEWLINE_EMBED}c`)).toEqual('\\\\displaylines{a \\\\\\\\ b \\\\\\\\ c}');\n });\n\n it('converts MathQuill answer blocks to placeholders', () => {\n expect(toMathLive('x=\\\\MathQuillMathField[r1]{}')).toEqual('x=\\\\placeholder[r1]{}');\n });\n\n it('preserves answer block content', () => {\n expect(toMathLive('\\\\MathQuillMathField[r2]{7}')).toEqual('\\\\placeholder[r2]{7}');\n });\n\n it('defaults an unnamed answer block id', () => {\n expect(toMathLive('\\\\MathQuillMathField[]{}')).toEqual(`\\\\placeholder[${DEFAULT_FIELD_ID}]{}`);\n });\n\n it('handles answer blocks and newlines together', () => {\n expect(toMathLive(`\\\\MathQuillMathField[r1]{}${NEWLINE_EMBED}x`)).toEqual(\n '\\\\displaylines{\\\\placeholder[r1]{} \\\\\\\\ x}',\n );\n });\n });\n\n describe('fromMathLive', () => {\n it('passes plain latex through', () => {\n expect(fromMathLive('\\\\frac{1}{2}')).toEqual('\\\\frac{1}{2}');\n });\n\n it('unwraps displaylines back to newLine embeds', () => {\n expect(fromMathLive('\\\\displaylines{a \\\\\\\\ b}')).toEqual(`a${NEWLINE_EMBED}b`);\n });\n\n it('converts placeholders back to MathQuill answer blocks', () => {\n expect(fromMathLive('x=\\\\placeholder[r1]{}')).toEqual('x=\\\\MathQuillMathField[r1]{}');\n });\n\n it('round-trips a newline document', () => {\n const stored = `a${NEWLINE_EMBED}b${NEWLINE_EMBED}c`;\n\n expect(fromMathLive(toMathLive(stored))).toEqual(stored);\n });\n\n it('round-trips an answer-block document', () => {\n const stored = 'x=\\\\MathQuillMathField[r1]{}+\\\\MathQuillMathField[r2]{3}';\n\n expect(fromMathLive(toMathLive(stored))).toEqual(stored);\n });\n\n it('round-trips answer blocks combined with newlines', () => {\n const stored = `\\\\MathQuillMathField[r1]{}${NEWLINE_EMBED}y`;\n\n expect(fromMathLive(toMathLive(stored))).toEqual(stored);\n });\n });\n\n describe('fieldIds', () => {\n it('returns ids in document order', () => {\n expect(fieldIds('\\\\MathQuillMathField[r1]{}+\\\\MathQuillMathField[r2]{}')).toEqual(['r1', 'r2']);\n });\n\n it('returns [] when there are none', () => {\n expect(fieldIds('x+y')).toEqual([]);\n expect(fieldIds(undefined)).toEqual([]);\n });\n\n it('is repeatable (regex lastIndex is reset)', () => {\n const latex = '\\\\MathQuillMathField[r1]{}';\n\n expect(fieldIds(latex)).toEqual(['r1']);\n expect(fieldIds(latex)).toEqual(['r1']);\n });\n });\n\n describe('keyToAction', () => {\n it('prefers latex when there is no command', () => {\n expect(keyToAction({ latex: '\\\\pi', write: 'p' })).toEqual({ type: 'insert', value: '\\\\pi' });\n });\n\n it('uses write', () => {\n expect(keyToAction({ write: 'x' })).toEqual({ type: 'insert', value: 'x' });\n });\n\n it('expands commands that take arguments into placeholders', () => {\n expect(keyToAction({ command: '\\\\frac' })).toEqual({ type: 'insert', value: '\\\\frac{#?}{#?}' });\n expect(keyToAction({ command: '\\\\sqrt' })).toEqual({ type: 'insert', value: '\\\\sqrt{#?}' });\n expect(keyToAction({ command: '^' })).toEqual({ type: 'insert', value: '^{#?}' });\n });\n\n it('passes argument-less commands through', () => {\n expect(keyToAction({ command: '\\\\pi' })).toEqual({ type: 'insert', value: '\\\\pi' });\n });\n\n it('concatenates array commands (MathQuill cmd() applied them in sequence)', () => {\n // Measured Angle\n expect(keyToAction({ command: ['m', '\\\\angle'] })).toEqual({ type: 'insert', value: 'm\\\\angle' });\n // log base n - the `_` part must still expand to a placeholder\n expect(keyToAction({ command: ['\\\\log', '_'] })).toEqual({ type: 'insert', value: '\\\\log_{#?}' });\n });\n\n it('always returns a string value for insert actions', () => {\n [{ command: ['m', '\\\\angle'] }, { command: '\\\\frac' }, { write: 'x' }, { latex: '\\\\pi' }].forEach((k) => {\n expect(typeof keyToAction(k).value).toBe('string');\n });\n });\n\n it('maps keystrokes to MathLive selectors', () => {\n expect(keyToAction({ keystroke: 'Left' })).toEqual({ type: 'command', value: 'moveToPreviousChar' });\n expect(keyToAction({ keystroke: 'Right' })).toEqual({ type: 'command', value: 'moveToNextChar' });\n expect(keyToAction({ keystroke: 'Backspace' })).toEqual({ type: 'command', value: 'deleteBackward' });\n });\n\n it('returns undefined for unknown/empty input', () => {\n expect(keyToAction(undefined)).toBeUndefined();\n expect(keyToAction({})).toBeUndefined();\n expect(keyToAction({ keystroke: 'Nope' })).toBeUndefined();\n });\n\n it('latex wins over command only when command is absent', () => {\n // a key with both should use the command path (matches MathInput.keypadPress)\n expect(keyToAction({ latex: '\\\\frac{}{}', command: '\\\\frac' })).toEqual({\n type: 'insert',\n value: '\\\\frac{#?}{#?}',\n });\n });\n });\n});\n"],"mappings":";;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAEAC,QAAQ,CAAC,cAAc,EAAE,YAAM;EAC7BA,QAAQ,CAAC,YAAY,EAAE,YAAM;IAC3BC,EAAE,CAAC,4BAA4B,EAAE,YAAM;MACrCC,MAAM,CAAC,IAAAC,uBAAU,EAAC,cAAc,CAAC,CAAC,CAACC,OAAO,CAAC,cAAc,CAAC;IAC5D,CAAC,CAAC;IAEFH,EAAE,CAAC,uBAAuB,EAAE,YAAM;MAChCC,MAAM,CAAC,IAAAC,uBAAU,EAAC,EAAE,CAAC,CAAC,CAACC,OAAO,CAAC,EAAE,CAAC;MAClCF,MAAM,CAAC,IAAAC,uBAAU,EAACE,SAAS,CAAC,CAAC,CAACD,OAAO,CAAC,EAAE,CAAC;MACzCF,MAAM,CAAC,IAAAC,uBAAU,EAAC,IAAI,CAAC,CAAC,CAACC,OAAO,CAAC,EAAE,CAAC;IACtC,CA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;QAAED,KAAK,EAAE,YAAY;QAAEK,OAAO,EAAE;MAAS,CAAC,CAAC,CAAC,CAACb,OAAO,CAAC;QACtEW,IAAI,EAAE,QAAQ;QACdC,KAAK,EAAE;MACT,CAAC,CAAC;IACJ,CAAC,CAAC;EACJ,CAAC,CAAC;AACJ,CAAC,CAAC","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mathlive-instance.test.js","names":["describe","instance","beforeEach","jest","resetModules","require","__resetEmbeds","it","registerEmbed","htmlString","latex","expect","registeredEmbeds","toEqual","getMacros","answerBlock","newLine","somethingCustom","mathliveLatex","custom","Error","not","toThrow","undefined","macros","parallelogram","toBeDefined","longdiv","napprox","applyStaticMath","toBeUndefined","el","document","createElement","_typeof2","configureFonts","toBe","MathfieldElement","__setMathLiveForTest","fontsDirectory","concat","baseURI","replace","startsWith","toBeNull","latexToMarkup"],"sources":["../../src/__tests__/mathlive-instance.test.js"],"sourcesContent":["describe('mathlive-instance', () => {\n let instance;\n\n beforeEach(() => {\n jest.resetModules();\n // eslint-disable-next-line global-require\n instance = require('../mathlive-instance');\n instance.__resetEmbeds();\n });\n\n describe('registerEmbed', () => {\n it('registers a known embed and exposes it as a macro', () => {\n instance.registerEmbed('answerBlock', () => ({\n htmlString: '<div class=\"answerBlock\"></div>',\n latex: () => '\\\\embed{answerBlock}[]',\n }));\n\n expect(instance.registeredEmbeds()).toEqual(['answerBlock']);\n // The macro tags output with data-embed so CSS can target it, replacing\n // MathQuill's htmlString hook.\n expect(instance.getMacros().answerBlock).toEqual('\\\\htmlData{embed=answerBlock}{\\\\placeholder{}}');\n });\n\n it('registers newLine as a harmless macro (it is handled by latex-bridge)', () => {\n instance.registerEmbed('newLine', () => ({ latex: () => '\\\\embed{newLine}[]' }));\n\n expect(instance.getMacros().newLine).toEqual('\\\\htmlData{embed=newLine}{}');\n });\n\n it('falls back to a placeholder for an unknown embed', () => {\n instance.registerEmbed('somethingCustom', () => ({ htmlString: '<b>x</b>' }));\n\n expect(instance.getMacros().somethingCustom).toEqual('\\\\htmlData{embed=somethingCustom}{\\\\placeholder{}}');\n });\n\n it('honours an explicit mathliveLatex from the factory', () => {\n instance.registerEmbed('custom', () => ({ mathliveLatex: '\\\\alpha' }));\n\n expect(instance.getMacros().custom).toEqual('\\\\htmlData{embed=custom}{\\\\alpha}');\n });\n\n it('does not throw when the factory throws', () => {\n expect(()
|
|
1
|
+
{"version":3,"file":"mathlive-instance.test.js","names":["describe","instance","beforeEach","jest","resetModules","require","__resetEmbeds","it","registerEmbed","htmlString","latex","expect","registeredEmbeds","toEqual","getMacros","answerBlock","newLine","somethingCustom","mathliveLatex","custom","Error","not","toThrow","undefined","macros","parallelogram","toBeDefined","longdiv","napprox","applyStaticMath","toBeUndefined","el","document","createElement","_typeof2","configureFonts","toBe","MathfieldElement","__setMathLiveForTest","fontsDirectory","concat","baseURI","replace","startsWith","toBeNull","latexToMarkup"],"sources":["../../src/__tests__/mathlive-instance.test.js"],"sourcesContent":["describe('mathlive-instance', () => {\n let instance;\n\n beforeEach(() => {\n jest.resetModules();\n // eslint-disable-next-line global-require\n instance = require('../mathlive-instance');\n instance.__resetEmbeds();\n });\n\n describe('registerEmbed', () => {\n it('registers a known embed and exposes it as a macro', () => {\n instance.registerEmbed('answerBlock', () => ({\n htmlString: '<div class=\"answerBlock\"></div>',\n latex: () => '\\\\embed{answerBlock}[]',\n }));\n\n expect(instance.registeredEmbeds()).toEqual(['answerBlock']);\n // The macro tags output with data-embed so CSS can target it, replacing\n // MathQuill's htmlString hook.\n expect(instance.getMacros().answerBlock).toEqual('\\\\htmlData{embed=answerBlock}{\\\\placeholder{}}');\n });\n\n it('registers newLine as a harmless macro (it is handled by latex-bridge)', () => {\n instance.registerEmbed('newLine', () => ({ latex: () => '\\\\embed{newLine}[]' }));\n\n expect(instance.getMacros().newLine).toEqual('\\\\htmlData{embed=newLine}{}');\n });\n\n it('falls back to a placeholder for an unknown embed', () => {\n instance.registerEmbed('somethingCustom', () => ({ htmlString: '<b>x</b>' }));\n\n expect(instance.getMacros().somethingCustom).toEqual('\\\\htmlData{embed=somethingCustom}{\\\\placeholder{}}');\n });\n\n it('honours an explicit mathliveLatex from the factory', () => {\n instance.registerEmbed('custom', () => ({ mathliveLatex: '\\\\alpha' }));\n\n expect(instance.getMacros().custom).toEqual('\\\\htmlData{embed=custom}{\\\\alpha}');\n });\n\n it('does not throw when the factory throws', () => {\n expect(() =>\n instance.registerEmbed('bad', () => {\n throw new Error('boom');\n }),\n ).not.toThrow();\n\n expect(instance.registeredEmbeds()).toEqual(['bad']);\n });\n\n it('ignores bad arguments', () => {\n instance.registerEmbed(undefined, () => ({}));\n instance.registerEmbed('noFactory', undefined);\n\n expect(instance.registeredEmbeds()).toEqual([]);\n });\n\n it('always includes the pie macro set', () => {\n const macros = instance.getMacros();\n\n expect(macros.parallelogram).toBeDefined();\n expect(macros.longdiv).toBeDefined();\n expect(macros.napprox).toEqual('\\\\not\\\\approx');\n });\n });\n\n describe('applyStaticMath', () => {\n it('returns undefined without an element', () => {\n expect(instance.applyStaticMath(null, 'x')).toBeUndefined();\n });\n\n it('returns undefined when MathLive has not loaded', () => {\n const el = document.createElement('div');\n\n expect(instance.applyStaticMath(el, 'x')).toBeUndefined();\n });\n });\n\n describe('configureFonts', () => {\n // MathLive's default fontsDirectory is the relative './fonts/', which it\n // resolves against its own (empty, when bundled) script url and throws\n // \"Invalid base URL\" from loadFonts. Paths must become absolute.\n it('is exported and callable before MathLive loads', () => {\n expect(typeof instance.configureFonts).toBe('function');\n expect(() => instance.configureFonts('/mathlive-fonts')).not.toThrow();\n });\n\n it('accepts null to disable font loading', () => {\n expect(() => instance.configureFonts(null)).not.toThrow();\n });\n\n it('applies an absolute url to an already-loaded MathfieldElement', () => {\n const MathfieldElement = {};\n\n // simulate a loaded instance\n instance.__setMathLiveForTest({ MathfieldElement });\n instance.configureFonts('/mathlive-fonts');\n\n expect(MathfieldElement.fontsDirectory).toEqual(`${document.baseURI.replace(/\\/$/, '')}/mathlive-fonts`);\n expect(MathfieldElement.fontsDirectory.startsWith('http')).toBe(true);\n });\n\n it('leaves a fully-qualified url untouched', () => {\n const MathfieldElement = {};\n\n instance.__setMathLiveForTest({ MathfieldElement });\n instance.configureFonts('https://cdn.example.com/fonts');\n\n expect(MathfieldElement.fontsDirectory).toEqual('https://cdn.example.com/fonts');\n });\n\n it('passes null through rather than resolving it', () => {\n const MathfieldElement = {};\n\n instance.__setMathLiveForTest({ MathfieldElement });\n instance.configureFonts(null);\n\n expect(MathfieldElement.fontsDirectory).toBeNull();\n });\n });\n\n describe('latexToMarkup', () => {\n it('returns empty string when MathLive is not loaded', () => {\n expect(instance.latexToMarkup('\\\\pi')).toEqual('');\n });\n\n it('returns empty string for empty latex', () => {\n expect(instance.latexToMarkup('')).toEqual('');\n });\n });\n});\n"],"mappings":";;;;AAAAA,QAAQ,CAAC,mBAAmB,EAAE,YAAM;EAClC,IAAIC,QAAQ;EAEZC,UAAU,CAAC,YAAM;IACfC,IAAI,CAACC,YAAY,CAAC,CAAC;IACnB;IACAH,QAAQ,GAAGI,OAAO,CAAC,sBAAsB,CAAC;IAC1CJ,QAAQ,CAACK,aAAa,CAAC,CAAC;EAC1B,CAAC,CAAC;EAEFN,QAAQ,CAAC,eAAe,EAAE,YAAM;IAC9BO,EAAE,CAAC,mDAAmD,EAAE,YAAM;MAC5DN,QAAQ,CAACO,aAAa,CAAC,aAAa,EAAE;QAAA,OAAO;UAC3CC,UAAU,EAAE,iCAAiC;UAC7CC,KAAK,EAAE,SAAPA,KAAKA,CAAA;YAAA,OAAQ,wBAAwB;UAAA;QACvC,CAAC;MAAA,CAAC,CAAC;MAEHC,MAAM,CAACV,QAAQ,CAACW,gBAAgB,CAAC,CAAC,CAAC,CAACC,OAAO,CAAC,CAAC,aAAa,CAAC,CAAC;MAC5D;MACA;MACAF,MAAM,CAACV,QAAQ,CAACa,SAAS,CAAC,CAAC,CAACC,WAAW,CAAC,CAACF,OAAO,CAAC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AM;MACvD,IAAM8B,gBAAgB,GAAG,CAAC,CAAC;MAE3BpC,QAAQ,CAACqC,oBAAoB,CAAC;QAAED,gBAAgB,EAAhBA;MAAiB,CAAC,CAAC;MACnDpC,QAAQ,CAACkC,cAAc,CAAC,IAAI,CAAC;MAE7BxB,MAAM,CAAC0B,gBAAgB,CAACE,cAAc,CAAC,CAACK,QAAQ,CAAC,CAAC;IACpD,CAAC,CAAC;EACJ,CAAC,CAAC;EAEF5C,QAAQ,CAAC,eAAe,EAAE,YAAM;IAC9BO,EAAE,CAAC,kDAAkD,EAAE,YAAM;MAC3DI,MAAM,CAACV,QAAQ,CAAC4C,aAAa,CAAC,MAAM,CAAC,CAAC,CAAChC,OAAO,CAAC,EAAE,CAAC;IACpD,CAAC,CAAC;IAEFN,EAAE,CAAC,sCAAsC,EAAE,YAAM;MAC/CI,MAAM,CAACV,QAAQ,CAAC4C,aAAa,CAAC,EAAE,CAAC,CAAC,CAAChC,OAAO,CAAC,EAAE,CAAC;IAChD,CAAC,CAAC;EACJ,CAAC,CAAC;AACJ,CAAC,CAAC","ignoreList":[]}
|
package/lib/keypad/index.js
CHANGED
|
@@ -41,18 +41,23 @@ var log = (0, _debug["default"])('pie-lib:math-input-mathlive:keypad');
|
|
|
41
41
|
* `convertLatexToMarkup`, so a 40-key keypad no longer creates 40 live math
|
|
42
42
|
* instances.
|
|
43
43
|
*/
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
44
|
+
// The `color.*()` helpers must be called lazily, inside the styled callback.
|
|
45
|
+
// Evaluating them in a plain object literal runs them at module load, which
|
|
46
|
+
// breaks any consumer that mocks a subset of @pie-lib/render-ui.
|
|
47
|
+
var LabelHolder = (0, _styles.styled)('span')(function () {
|
|
48
|
+
return {
|
|
49
|
+
pointerEvents: 'none',
|
|
50
|
+
textTransform: 'none',
|
|
51
|
+
color: _renderUi.color.text(),
|
|
52
|
+
display: 'inline-flex',
|
|
53
|
+
alignItems: 'center',
|
|
54
|
+
justifyContent: 'center',
|
|
55
|
+
lineHeight: 1,
|
|
56
|
+
// Answer-block / empty-slot boxes inside a label.
|
|
57
|
+
'& .ML__placeholder': {
|
|
58
|
+
backgroundColor: _renderUi.color.keypadEmptyPlaceholder ? _renderUi.color.keypadEmptyPlaceholder() : undefined
|
|
59
|
+
}
|
|
60
|
+
};
|
|
56
61
|
});
|
|
57
62
|
var LatexLabel = exports.LatexLabel = /*#__PURE__*/function (_React$Component) {
|
|
58
63
|
function LatexLabel(props) {
|
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","backgroundColor","keypadEmptyPlaceholder","LatexLabel","exports","_React$Component","props","_this","_classCallCheck2","state","markup","latexToMarkup","latex","_inherits2","_createClass2","key","value","_componentDidMount","_asyncToGenerator2","_regenerator","mark","_callee","wrap","_context","prev","next","loadMathLive","unmounted","setState","stop","componentDidMount","componentDidUpdate","prevProps","componentWillUnmount","render","createElement","dangerouslySetInnerHTML","__html","React","Component","PropTypes","string","isRequired","createCustomLayout","layoutObj","gridTemplateColumns","concat","columns","gridTemplateRows","rows","gridAutoFlow","KeyPadContainer","commonKeyboardStyles","width","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","undefined","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 */\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 // Answer-block / empty-slot boxes inside a label.\n '& .ML__placeholder': {\n backgroundColor: color.keypadEmptyPlaceholder(),\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 await loadMathLive();\n\n if (!this.unmounted) {\n this.setState({ markup: latexToMarkup(this.props.latex) });\n }\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 !!(\n ((key.write === '.' && key.label === '.') || (key.write === ',' && key.label === ',')) &&\n noDecimal\n );\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,IA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EACpClC,IAAI,EAAEhF,qBAAS,CAACmH,SAAS,CAAC,CAACnH,qBAAS,CAACC,MAAM,EAAED,qBAAS,CAACoH,MAAM,CAAC;AAChE,CAAC;AAAA,IAAAtL,gBAAA,aAZU0G,MAAM,kBAcK;EACpBoC,OAAO,EAAEA,aAAO;EAChB1B,SAAS,EAAE;AACb,CAAC;AAAA,IAAAmE,QAAA,GAAAzJ,OAAA,cAoKY4E,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","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","loadMathLive","unmounted","setState","stop","componentDidMount","componentDidUpdate","prevProps","componentWillUnmount","render","createElement","dangerouslySetInnerHTML","__html","React","Component","PropTypes","string","isRequired","createCustomLayout","layoutObj","gridTemplateColumns","concat","columns","gridTemplateRows","rows","gridAutoFlow","KeyPadContainer","commonKeyboardStyles","width","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 // 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 await loadMathLive();\n\n if (!this.unmounted) {\n this.setState({ markup: latexToMarkup(this.props.latex) });\n }\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,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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AE3C,qBAAS,CAACiH,IAAI;EACpCjC,IAAI,EAAEhF,qBAAS,CAACkH,SAAS,CAAC,CAAClH,qBAAS,CAACC,MAAM,EAAED,qBAAS,CAACmH,MAAM,CAAC;AAChE,CAAC;AAAA,IAAAtL,gBAAA,aAZU2G,MAAM,kBAcK;EACpBoC,OAAO,EAAEA,aAAO;EAChB1B,SAAS,EAAE;AACb,CAAC;AAAA,IAAAkE,QAAA,GAAAxJ,OAAA,cAiKY4E,MAAM","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { render } from '@testing-library/react';
|
|
3
|
+
import { styled } from '@mui/material/styles';
|
|
4
|
+
|
|
5
|
+
import { mq } from '../index';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Exercises the exact call patterns real consumers use against
|
|
9
|
+
* @pie-lib/math-input, to catch drop-in incompatibilities.
|
|
10
|
+
*
|
|
11
|
+
* Sources:
|
|
12
|
+
* - packages/math-toolbar/src/editor-and-pad.jsx:16,185
|
|
13
|
+
* - packages/math-toolbar/src/math-preview.jsx:8,156
|
|
14
|
+
* - packages/editable-html/src/plugins/respArea/math-templated/index.jsx:92
|
|
15
|
+
* - packages/editable-html-tip-tap/src/components/respArea/MathTemplated.jsx:111
|
|
16
|
+
*/
|
|
17
|
+
describe('drop-in compatibility with @pie-lib/math-input consumers', () => {
|
|
18
|
+
describe('mq.CommonMqStyles destructuring', () => {
|
|
19
|
+
it('math-preview.jsx: { commonMqFontStyles, longdivStyles, supsubStyles }', () => {
|
|
20
|
+
const { commonMqFontStyles, longdivStyles, supsubStyles } = mq.CommonMqStyles;
|
|
21
|
+
|
|
22
|
+
expect(commonMqFontStyles).toBeDefined();
|
|
23
|
+
expect(longdivStyles).toBeDefined();
|
|
24
|
+
expect(supsubStyles).toBeDefined();
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
it('editor-and-pad.jsx: also { commonMqKeyboardStyles }', () => {
|
|
28
|
+
const { commonMqFontStyles, commonMqKeyboardStyles, longdivStyles, supsubStyles } = mq.CommonMqStyles;
|
|
29
|
+
|
|
30
|
+
expect(commonMqKeyboardStyles).toBeDefined();
|
|
31
|
+
// All four must be spreadable into an emotion style object.
|
|
32
|
+
expect(() => ({
|
|
33
|
+
...commonMqFontStyles,
|
|
34
|
+
...commonMqKeyboardStyles,
|
|
35
|
+
...longdivStyles,
|
|
36
|
+
...supsubStyles,
|
|
37
|
+
})).not.toThrow();
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
it('the destructured groups survive being spread into a styled component', () => {
|
|
41
|
+
const { commonMqFontStyles, longdivStyles, supsubStyles } = mq.CommonMqStyles;
|
|
42
|
+
const Styled = styled('div')({ ...commonMqFontStyles, ...longdivStyles, ...supsubStyles });
|
|
43
|
+
|
|
44
|
+
expect(() => render(<Styled />)).not.toThrow();
|
|
45
|
+
});
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
describe('mq.Input', () => {
|
|
49
|
+
it('editor-and-pad.jsx: styled(mq.Input) renders', () => {
|
|
50
|
+
const MathEditor = styled(mq.Input)(() => ({ width: '100%' }));
|
|
51
|
+
|
|
52
|
+
expect(() => render(<MathEditor latex="\\frac{1}{2}" onChange={() => {}} />)).not.toThrow();
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
it('accepts the className that styled() injects', () => {
|
|
56
|
+
const Styled = styled(mq.Input)({ padding: 4 });
|
|
57
|
+
const { container } = render(<Styled latex="x" onChange={() => {}} />);
|
|
58
|
+
|
|
59
|
+
expect(container.firstChild).toBeTruthy();
|
|
60
|
+
expect(container.firstChild.className).toBeTruthy();
|
|
61
|
+
});
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
describe('mq.Static', () => {
|
|
65
|
+
it('math-preview.jsx: <mq.Static latex onFocus onBlur />', () => {
|
|
66
|
+
expect(() => render(<mq.Static latex={'\\frac{1}{2}'} onFocus={() => {}} onBlur={() => {}} />)).not.toThrow();
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
it('math-templated respArea: <mq.Static latex={value} />', () => {
|
|
70
|
+
expect(() => render(<mq.Static latex={'x=1'} />)).not.toThrow();
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
it('renders answer-block latex (the templated-math case) without throwing', () => {
|
|
74
|
+
expect(() =>
|
|
75
|
+
render(<mq.Static latex={'x=\\MathQuillMathField[r1]{}'} onSubFieldChange={() => {}} />),
|
|
76
|
+
).not.toThrow();
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
it('is styleable, as keypad labels were in math-input', () => {
|
|
80
|
+
const Styled = styled(mq.Static)({ pointerEvents: 'none' });
|
|
81
|
+
|
|
82
|
+
expect(() => render(<Styled latex={'\\pi'} />)).not.toThrow();
|
|
83
|
+
});
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
describe('surface parity', () => {
|
|
87
|
+
it('exposes exactly the names math-input exported', () => {
|
|
88
|
+
// eslint-disable-next-line global-require
|
|
89
|
+
const pkg = require('../index');
|
|
90
|
+
|
|
91
|
+
[
|
|
92
|
+
'keysForGrade',
|
|
93
|
+
'addBrackets',
|
|
94
|
+
'removeBrackets',
|
|
95
|
+
'keys',
|
|
96
|
+
'HorizontalKeypad',
|
|
97
|
+
'mq',
|
|
98
|
+
'updateSpans',
|
|
99
|
+
'registerEmbed',
|
|
100
|
+
'applyStaticMath',
|
|
101
|
+
].forEach((name) => {
|
|
102
|
+
expect(pkg[name]).toBeDefined();
|
|
103
|
+
});
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
it('mq exposes Input, Static and CommonMqStyles', () => {
|
|
107
|
+
['Input', 'Static', 'CommonMqStyles'].forEach((name) => {
|
|
108
|
+
expect(mq[name]).toBeDefined();
|
|
109
|
+
});
|
|
110
|
+
});
|
|
111
|
+
});
|
|
112
|
+
});
|
|
@@ -1,11 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
toMathLive,
|
|
3
|
-
fromMathLive,
|
|
4
|
-
fieldIds,
|
|
5
|
-
keyToAction,
|
|
6
|
-
NEWLINE_EMBED,
|
|
7
|
-
DEFAULT_FIELD_ID,
|
|
8
|
-
} from '../latex-bridge';
|
|
1
|
+
import { toMathLive, fromMathLive, fieldIds, keyToAction, NEWLINE_EMBED, DEFAULT_FIELD_ID } from '../latex-bridge';
|
|
9
2
|
|
|
10
3
|
describe('latex-bridge', () => {
|
|
11
4
|
describe('toMathLive', () => {
|
|
@@ -40,9 +40,11 @@ describe('mathlive-instance', () => {
|
|
|
40
40
|
});
|
|
41
41
|
|
|
42
42
|
it('does not throw when the factory throws', () => {
|
|
43
|
-
expect(() =>
|
|
44
|
-
|
|
45
|
-
|
|
43
|
+
expect(() =>
|
|
44
|
+
instance.registerEmbed('bad', () => {
|
|
45
|
+
throw new Error('boom');
|
|
46
|
+
}),
|
|
47
|
+
).not.toThrow();
|
|
46
48
|
|
|
47
49
|
expect(instance.registeredEmbeds()).toEqual(['bad']);
|
|
48
50
|
});
|
package/src/keypad/index.jsx
CHANGED
|
@@ -22,7 +22,10 @@ const log = debug('pie-lib:math-input-mathlive:keypad');
|
|
|
22
22
|
* `convertLatexToMarkup`, so a 40-key keypad no longer creates 40 live math
|
|
23
23
|
* instances.
|
|
24
24
|
*/
|
|
25
|
-
|
|
25
|
+
// The `color.*()` helpers must be called lazily, inside the styled callback.
|
|
26
|
+
// Evaluating them in a plain object literal runs them at module load, which
|
|
27
|
+
// breaks any consumer that mocks a subset of @pie-lib/render-ui.
|
|
28
|
+
const LabelHolder = styled('span')(() => ({
|
|
26
29
|
pointerEvents: 'none',
|
|
27
30
|
textTransform: 'none',
|
|
28
31
|
color: color.text(),
|
|
@@ -32,9 +35,9 @@ const LabelHolder = styled('span')({
|
|
|
32
35
|
lineHeight: 1,
|
|
33
36
|
// Answer-block / empty-slot boxes inside a label.
|
|
34
37
|
'& .ML__placeholder': {
|
|
35
|
-
backgroundColor: color.keypadEmptyPlaceholder(),
|
|
38
|
+
backgroundColor: color.keypadEmptyPlaceholder ? color.keypadEmptyPlaceholder() : undefined,
|
|
36
39
|
},
|
|
37
|
-
});
|
|
40
|
+
}));
|
|
38
41
|
|
|
39
42
|
export class LatexLabel extends React.Component {
|
|
40
43
|
static propTypes = {
|
|
@@ -238,10 +241,7 @@ export class KeyPad extends React.Component {
|
|
|
238
241
|
keyIsNotAllowed = (key) => {
|
|
239
242
|
const { noDecimal } = this.props;
|
|
240
243
|
|
|
241
|
-
return !!(
|
|
242
|
-
((key.write === '.' && key.label === '.') || (key.write === ',' && key.label === ',')) &&
|
|
243
|
-
noDecimal
|
|
244
|
-
);
|
|
244
|
+
return !!(((key.write === '.' && key.label === '.') || (key.write === ',' && key.label === ',')) && noDecimal);
|
|
245
245
|
};
|
|
246
246
|
|
|
247
247
|
render() {
|