@pie-lib/mask-markup 2.1.1-next.2 → 2.1.1-next.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/__tests__/drag-in-the-blank.test.js +1 -8
- package/lib/__tests__/index.test.js +1 -11
- package/lib/__tests__/mask.test.js +1 -15
- package/lib/__tests__/utils.js +1 -2
- package/lib/__tests__/with-mask.test.js +1 -8
- package/lib/choices/__tests__/index.test.js +1 -8
- package/lib/choices/choice.js +1 -15
- package/lib/choices/choice.js.map +1 -1
- package/lib/choices/index.js +3 -16
- package/lib/choices/index.js.map +1 -1
- package/lib/componentize.js +1 -5
- package/lib/componentize.js.map +1 -1
- package/lib/components/__tests__/blank.test.js +1 -9
- package/lib/components/__tests__/correct-input.test.js +1 -8
- package/lib/components/__tests__/dropdown.test.js +1 -11
- package/lib/components/__tests__/input.test.js +1 -8
- package/lib/components/blank.js +4 -20
- package/lib/components/blank.js.map +1 -1
- package/lib/components/correct-input.js +1 -2
- package/lib/components/correct-input.js.map +1 -1
- package/lib/components/dropdown.js +11 -18
- package/lib/components/dropdown.js.map +1 -1
- package/lib/components/input.js +1 -2
- package/lib/components/input.js.map +1 -1
- package/lib/constructed-response.js +2 -14
- package/lib/constructed-response.js.map +1 -1
- package/lib/customizable.js +1 -4
- package/lib/customizable.js.map +1 -1
- package/lib/drag-in-the-blank.js +2 -17
- package/lib/drag-in-the-blank.js.map +1 -1
- package/lib/index.js +1 -2
- package/lib/index.js.map +1 -1
- package/lib/inline-dropdown.js +1 -6
- package/lib/inline-dropdown.js.map +1 -1
- package/lib/mask.js +5 -21
- package/lib/mask.js.map +1 -1
- package/lib/serialization.js +1 -19
- package/lib/serialization.js.map +1 -1
- package/lib/with-mask.js +1 -6
- package/lib/with-mask.js.map +1 -1
- package/package.json +7 -7
- package/src/__tests__/drag-in-the-blank.test.js +1 -1
- package/src/__tests__/index.test.js +0 -1
- package/src/choices/index.jsx +2 -7
- package/src/components/__tests__/blank.test.js +0 -1
- package/src/components/__tests__/dropdown.test.js +2 -2
- package/src/components/blank.jsx +8 -2
- package/src/components/correct-input.jsx +1 -11
- package/src/components/dropdown.jsx +15 -11
- package/src/constructed-response.jsx +1 -1
- package/src/customizable.jsx +0 -1
- package/src/drag-in-the-blank.jsx +2 -3
- package/src/index.js +1 -1
- package/src/mask.jsx +5 -8
package/lib/with-mask.js
CHANGED
|
@@ -1,15 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
require("core-js/modules/es.object.define-property.js");
|
|
4
|
-
require("core-js/modules/es.reflect.construct.js");
|
|
5
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
6
4
|
Object.defineProperty(exports, "__esModule", {
|
|
7
5
|
value: true
|
|
8
6
|
});
|
|
9
7
|
exports.withMask = exports.buildLayoutFromMarkup = void 0;
|
|
10
|
-
require("core-js/modules/es.array.for-each.js");
|
|
11
|
-
require("core-js/modules/es.object.to-string.js");
|
|
12
|
-
require("core-js/modules/web.dom-collections.for-each.js");
|
|
13
8
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
14
9
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
15
10
|
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
@@ -99,4 +94,4 @@ var withMask = exports.withMask = function withMask(type, renderChildren) {
|
|
|
99
94
|
elementType: _propTypes["default"].string
|
|
100
95
|
}), _WithMask;
|
|
101
96
|
};
|
|
102
|
-
//# sourceMappingURL=
|
|
97
|
+
//# sourceMappingURL=with-mask.js.map
|
package/lib/with-mask.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"with-mask.js","names":["_react","_interopRequireDefault","require","_propTypes","_mask","_componentize2","_serialization","_callSuper","t","o","e","_getPrototypeOf2","_possibleConstructorReturn2","_isNativeReflectConstruct","Reflect","construct","constructor","apply","Boolean","prototype","valueOf","call","buildLayoutFromMarkup","exports","markup","type","_componentize","componentize","processed","value","deserialize","document","withMask","renderChildren","_WithMask","_React$Component","WithMask","props","_this","_classCallCheck2","containerRef","React","createRef","_inherits2","_createClass2","key","componentDidUpdate","prevProps","domNode","current","mathElements","querySelectorAll","forEach","el","mjxContainer","querySelector","removeChild","latexCode","getAttribute","innerHTML","removeAttribute","render","_this$props","layout","onChange","elementType","maskLayout","createElement","Component","_defineProperty2","PropTypes","string","object","func","customMarkMarkupComponent"],"sources":["../src/with-mask.jsx"],"sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport Mask from './mask';\nimport componentize from './componentize';\nimport { deserialize } from './serialization';\n\nexport const buildLayoutFromMarkup = (markup, type) => {\n const { markup: processed } = componentize(markup, type);\n const value = deserialize(processed);\n return value.document;\n};\n\nexport const withMask = (type, renderChildren) => {\n return class WithMask extends React.Component {\n static propTypes = {\n /**\n * At the start we'll probably work with markup\n */\n markup: PropTypes.string,\n /**\n * Once we start authoring, it may make sense for use to us layout, which will be a simple js object that maps to `slate.Value`.\n */\n layout: PropTypes.object,\n value: PropTypes.object,\n onChange: PropTypes.func,\n customMarkMarkupComponent: PropTypes.func,\n elementType: PropTypes.string,\n };\n\n constructor(props) {\n super(props);\n this.containerRef = React.createRef();\n }\n\n componentDidUpdate(prevProps) {\n if (this.props.markup !== prevProps.markup) {\n const domNode = this.containerRef.current;\n const mathElements = domNode && domNode.querySelectorAll('[data-latex][data-math-handled=\"true\"]');\n\n // Clean up for fresh MathJax processing\n (mathElements || []).forEach((el) => {\n // Remove the MathJax container to allow for clean updates\n const mjxContainer = el.querySelector('mjx-container');\n\n if (mjxContainer) {\n el.removeChild(mjxContainer);\n }\n\n // Update the innerHTML to match the raw LaTeX data, ensuring it is reprocessed correctly\n const latexCode = el.getAttribute('data-raw');\n el.innerHTML = latexCode;\n\n // Remove the attribute to signal that MathJax should reprocess this element\n el.removeAttribute('data-math-handled');\n });\n }\n }\n\n render() {\n const { markup, layout, value, onChange, elementType } = this.props;\n\n const maskLayout = layout ? layout : buildLayoutFromMarkup(markup, type);\n return (\n <Mask\n containerRef={this.containerRef}\n elementType={elementType}\n layout={maskLayout}\n value={value}\n onChange={onChange}\n renderChildren={renderChildren(this.props)}\n />\n );\n }\n };\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"with-mask.js","names":["_react","_interopRequireDefault","require","_propTypes","_mask","_componentize2","_serialization","_callSuper","t","o","e","_getPrototypeOf2","_possibleConstructorReturn2","_isNativeReflectConstruct","Reflect","construct","constructor","apply","Boolean","prototype","valueOf","call","buildLayoutFromMarkup","exports","markup","type","_componentize","componentize","processed","value","deserialize","document","withMask","renderChildren","_WithMask","_React$Component","WithMask","props","_this","_classCallCheck2","containerRef","React","createRef","_inherits2","_createClass2","key","componentDidUpdate","prevProps","domNode","current","mathElements","querySelectorAll","forEach","el","mjxContainer","querySelector","removeChild","latexCode","getAttribute","innerHTML","removeAttribute","render","_this$props","layout","onChange","elementType","maskLayout","createElement","Component","_defineProperty2","PropTypes","string","object","func","customMarkMarkupComponent"],"sources":["../src/with-mask.jsx"],"sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport Mask from './mask';\nimport componentize from './componentize';\nimport { deserialize } from './serialization';\n\nexport const buildLayoutFromMarkup = (markup, type) => {\n const { markup: processed } = componentize(markup, type);\n const value = deserialize(processed);\n return value.document;\n};\n\nexport const withMask = (type, renderChildren) => {\n return class WithMask extends React.Component {\n static propTypes = {\n /**\n * At the start we'll probably work with markup\n */\n markup: PropTypes.string,\n /**\n * Once we start authoring, it may make sense for use to us layout, which will be a simple js object that maps to `slate.Value`.\n */\n layout: PropTypes.object,\n value: PropTypes.object,\n onChange: PropTypes.func,\n customMarkMarkupComponent: PropTypes.func,\n elementType: PropTypes.string,\n };\n\n constructor(props) {\n super(props);\n this.containerRef = React.createRef();\n }\n\n componentDidUpdate(prevProps) {\n if (this.props.markup !== prevProps.markup) {\n const domNode = this.containerRef.current;\n const mathElements = domNode && domNode.querySelectorAll('[data-latex][data-math-handled=\"true\"]');\n\n // Clean up for fresh MathJax processing\n (mathElements || []).forEach((el) => {\n // Remove the MathJax container to allow for clean updates\n const mjxContainer = el.querySelector('mjx-container');\n\n if (mjxContainer) {\n el.removeChild(mjxContainer);\n }\n\n // Update the innerHTML to match the raw LaTeX data, ensuring it is reprocessed correctly\n const latexCode = el.getAttribute('data-raw');\n el.innerHTML = latexCode;\n\n // Remove the attribute to signal that MathJax should reprocess this element\n el.removeAttribute('data-math-handled');\n });\n }\n }\n\n render() {\n const { markup, layout, value, onChange, elementType } = this.props;\n\n const maskLayout = layout ? layout : buildLayoutFromMarkup(markup, type);\n return (\n <Mask\n containerRef={this.containerRef}\n elementType={elementType}\n layout={maskLayout}\n value={value}\n onChange={onChange}\n renderChildren={renderChildren(this.props)}\n />\n );\n }\n };\n};\n"],"mappings":";;;;;;;;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,UAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,KAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,IAAAG,cAAA,GAAAJ,sBAAA,CAAAC,OAAA;AACA,IAAAI,cAAA,GAAAJ,OAAA;AAA8C,SAAAK,WAAAC,CAAA,EAAAC,CAAA,EAAAC,CAAA,WAAAD,CAAA,OAAAE,gBAAA,aAAAF,CAAA,OAAAG,2BAAA,aAAAJ,CAAA,EAAAK,yBAAA,KAAAC,OAAA,CAAAC,SAAA,CAAAN,CAAA,EAAAC,CAAA,YAAAC,gBAAA,aAAAH,CAAA,EAAAQ,WAAA,IAAAP,CAAA,CAAAQ,KAAA,CAAAT,CAAA,EAAAE,CAAA;AAAA,SAAAG,0BAAA,cAAAL,CAAA,IAAAU,OAAA,CAAAC,SAAA,CAAAC,OAAA,CAAAC,IAAA,CAAAP,OAAA,CAAAC,SAAA,CAAAG,OAAA,iCAAAV,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,EAAEM,qBAAS,CAACG,IAAI;IACxBC,yBAAyB,EAAEJ,qBAAS,CAACG,IAAI;IACzCR,WAAW,EAAEK,qBAAS,CAACC;EACzB,CAAC,GAAArC,SAAA;AA+CL,CAAC","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pie-lib/mask-markup",
|
|
3
|
-
"version": "2.1.1-next.
|
|
3
|
+
"version": "2.1.1-next.4",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "src/index.js",
|
|
@@ -12,13 +12,13 @@
|
|
|
12
12
|
"@emotion/style": "^0.8.0",
|
|
13
13
|
"@mui/icons-material": "^7.3.4",
|
|
14
14
|
"@mui/material": "^7.3.4",
|
|
15
|
-
"@pie-lib/drag": "^3.1.1-next.
|
|
16
|
-
"@pie-lib/editable-html-tip-tap": "^1.1.1-next.
|
|
17
|
-
"@pie-lib/math-rendering": "^4.1.1-next.
|
|
18
|
-
"@pie-lib/render-ui": "^5.1.1-next.
|
|
15
|
+
"@pie-lib/drag": "^3.1.1-next.1",
|
|
16
|
+
"@pie-lib/editable-html-tip-tap": "^1.1.1-next.4",
|
|
17
|
+
"@pie-lib/math-rendering": "^4.1.1-next.1",
|
|
18
|
+
"@pie-lib/render-ui": "^5.1.1-next.1",
|
|
19
19
|
"classnames": "^2.2.6",
|
|
20
20
|
"debug": "^4.1.1",
|
|
21
|
-
"lodash": "^4.17.23",
|
|
21
|
+
"lodash-es": "^4.17.23",
|
|
22
22
|
"prop-types": "^15.7.2",
|
|
23
23
|
"react": "^18.2.0",
|
|
24
24
|
"react-dom": "^18.2.0",
|
|
@@ -27,5 +27,5 @@
|
|
|
27
27
|
"keywords": [],
|
|
28
28
|
"author": "",
|
|
29
29
|
"license": "ISC",
|
|
30
|
-
"gitHead": "
|
|
30
|
+
"gitHead": "433bcb776c2975739e7417f133d31cd996164116"
|
|
31
31
|
}
|
package/src/choices/index.jsx
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
|
-
import findKey from 'lodash
|
|
3
|
+
import { findKey } from 'lodash-es';
|
|
4
4
|
import Choice from './choice';
|
|
5
5
|
import { DragDroppablePlaceholder } from '@pie-lib/drag';
|
|
6
6
|
|
|
@@ -55,12 +55,7 @@ export default class Choices extends React.Component {
|
|
|
55
55
|
<div style={elementStyle}>
|
|
56
56
|
<DragDroppablePlaceholder disabled={disabled} instanceId={instanceId}>
|
|
57
57
|
{filteredChoices.map((c, index) => (
|
|
58
|
-
<Choice
|
|
59
|
-
key={`${c.value}-${index}`}
|
|
60
|
-
disabled={disabled}
|
|
61
|
-
choice={c}
|
|
62
|
-
instanceId={instanceId}
|
|
63
|
-
/>
|
|
58
|
+
<Choice key={`${c.value}-${index}`} disabled={disabled} choice={c} instanceId={instanceId} />
|
|
64
59
|
))}
|
|
65
60
|
</DragDroppablePlaceholder>
|
|
66
61
|
</div>
|
|
@@ -68,7 +68,7 @@ describe('Dropdown', () => {
|
|
|
68
68
|
|
|
69
69
|
// Find the option by getting all options and selecting the one with "Laughed" text
|
|
70
70
|
const options = screen.getAllByRole('option');
|
|
71
|
-
const laughedOption = options.find(opt => opt.textContent.includes('Laughed'));
|
|
71
|
+
const laughedOption = options.find((opt) => opt.textContent.includes('Laughed'));
|
|
72
72
|
await user.click(laughedOption);
|
|
73
73
|
|
|
74
74
|
expect(onChange).toHaveBeenCalledWith('1', 'Laughed');
|
|
@@ -84,7 +84,7 @@ describe('Dropdown', () => {
|
|
|
84
84
|
|
|
85
85
|
// Find the option by getting all options and selecting the one with "Smiled" text
|
|
86
86
|
const options = screen.getAllByRole('option');
|
|
87
|
-
const smiledOption = options.find(opt => opt.textContent.includes('Smiled'));
|
|
87
|
+
const smiledOption = options.find((opt) => opt.textContent.includes('Smiled'));
|
|
88
88
|
await user.click(smiledOption);
|
|
89
89
|
|
|
90
90
|
expect(onChange).toHaveBeenCalledWith('1', 'Smiled');
|
package/src/components/blank.jsx
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { useRef, useState
|
|
1
|
+
import React, { useEffect, useRef, useState } from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import { renderMath } from '@pie-lib/math-rendering';
|
|
4
4
|
import debug from 'debug';
|
|
@@ -87,6 +87,8 @@ const StyledChipLabel = styled('span')(() => ({
|
|
|
87
87
|
position: 'absolute',
|
|
88
88
|
left: 16,
|
|
89
89
|
maxWidth: '60px',
|
|
90
|
+
top: '50%',
|
|
91
|
+
transform: 'translateY(-50%)',
|
|
90
92
|
},
|
|
91
93
|
}));
|
|
92
94
|
|
|
@@ -296,7 +298,11 @@ function DragDropBlank({
|
|
|
296
298
|
});
|
|
297
299
|
|
|
298
300
|
// Setup droppable functionality
|
|
299
|
-
const {
|
|
301
|
+
const {
|
|
302
|
+
setNodeRef: setDropNodeRef,
|
|
303
|
+
isOver,
|
|
304
|
+
active: dragItem,
|
|
305
|
+
} = useDroppable({
|
|
300
306
|
id: `mask-blank-drop-${id}`,
|
|
301
307
|
data: {
|
|
302
308
|
id: id,
|
|
@@ -46,16 +46,7 @@ const StyledOutlinedInput = styled(OutlinedInput)(() => ({
|
|
|
46
46
|
}));
|
|
47
47
|
|
|
48
48
|
const CorrectInput = (props) => {
|
|
49
|
-
const {
|
|
50
|
-
correct,
|
|
51
|
-
charactersLimit,
|
|
52
|
-
disabled,
|
|
53
|
-
isBox,
|
|
54
|
-
isConstructedResponse,
|
|
55
|
-
width,
|
|
56
|
-
spellCheck,
|
|
57
|
-
...rest
|
|
58
|
-
} = props;
|
|
49
|
+
const { correct, charactersLimit, disabled, isBox, isConstructedResponse, width, spellCheck, ...rest } = props;
|
|
59
50
|
|
|
60
51
|
const label = typeof correct === 'boolean' ? (correct ? 'correct' : 'incorrect') : undefined;
|
|
61
52
|
const inputProps = charactersLimit
|
|
@@ -89,4 +80,3 @@ const CorrectInput = (props) => {
|
|
|
89
80
|
};
|
|
90
81
|
|
|
91
82
|
export default CorrectInput;
|
|
92
|
-
|
|
@@ -70,9 +70,19 @@ const StyledMenu = styled(Menu)(() => ({
|
|
|
70
70
|
}));
|
|
71
71
|
|
|
72
72
|
const StyledMenuItem = styled(MenuItem)(() => ({
|
|
73
|
+
// base text/layout styles (from old JSS - before mui v5 migration)
|
|
74
|
+
height: 24,
|
|
75
|
+
overflow: 'hidden',
|
|
76
|
+
fontSize: '1rem',
|
|
77
|
+
fontWeight: 400,
|
|
78
|
+
fontFamily: 'inherit',
|
|
79
|
+
lineHeight: '1.5em',
|
|
80
|
+
whiteSpace: 'nowrap',
|
|
81
|
+
|
|
82
|
+
// custom styles
|
|
73
83
|
color: color.text(),
|
|
74
84
|
backgroundColor: color.background(),
|
|
75
|
-
'&.Mui-
|
|
85
|
+
'&.Mui-focusVisible': {
|
|
76
86
|
outline: `3px solid ${color.tertiary()}`,
|
|
77
87
|
outlineOffset: '-1px', // keeps it inside the item
|
|
78
88
|
color: color.text(),
|
|
@@ -309,11 +319,7 @@ class Dropdown extends React.Component {
|
|
|
309
319
|
aria-hidden="true"
|
|
310
320
|
>
|
|
311
321
|
{(choices || []).map((c, index) => (
|
|
312
|
-
<StyledMenuItem
|
|
313
|
-
key={index}
|
|
314
|
-
tabIndex={-1}
|
|
315
|
-
aria-hidden="true"
|
|
316
|
-
>
|
|
322
|
+
<StyledMenuItem key={index} tabIndex={-1} aria-hidden="true">
|
|
317
323
|
<StyledLabel dangerouslySetInnerHTML={{ __html: c.label }} />
|
|
318
324
|
</StyledMenuItem>
|
|
319
325
|
))}
|
|
@@ -348,8 +354,8 @@ class Dropdown extends React.Component {
|
|
|
348
354
|
__html: correctValue
|
|
349
355
|
? correctValue
|
|
350
356
|
: open && this.state.previewValue
|
|
351
|
-
|
|
352
|
-
|
|
357
|
+
? this.getLabel(choices, this.state.previewValue)
|
|
358
|
+
: this.getLabel(choices, value) || '',
|
|
353
359
|
}}
|
|
354
360
|
/>
|
|
355
361
|
{open ? <ArrowDropUpIcon /> : <ArrowDropDownIcon />}
|
|
@@ -391,9 +397,7 @@ class Dropdown extends React.Component {
|
|
|
391
397
|
ref={(ref) => (this.elementRefs[index] = ref)}
|
|
392
398
|
dangerouslySetInnerHTML={{ __html: c.label }}
|
|
393
399
|
/>
|
|
394
|
-
<StyledSelectedIndicator
|
|
395
|
-
dangerouslySetInnerHTML={{ __html: c.value === value ? ' ✓' : '' }}
|
|
396
|
-
/>
|
|
400
|
+
<StyledSelectedIndicator dangerouslySetInnerHTML={{ __html: c.value === value ? ' ✓' : '' }} />
|
|
397
401
|
</StyledMenuItem>
|
|
398
402
|
);
|
|
399
403
|
})}
|
|
@@ -67,7 +67,7 @@ const MaskedInput = (props) => (node, data) => {
|
|
|
67
67
|
pluginProps={pluginProps}
|
|
68
68
|
languageCharactersProps={[{ language: 'spanish' }]}
|
|
69
69
|
spellCheck={spellCheck}
|
|
70
|
-
|
|
70
|
+
adjustWidthForLimit
|
|
71
71
|
onKeyDown={handleKeyDown}
|
|
72
72
|
autoWidthToolbar
|
|
73
73
|
toolbarOpts={{
|
package/src/customizable.jsx
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import { DragProvider } from '@pie-lib/drag';
|
|
4
|
-
import { DragOverlay,
|
|
5
|
-
|
|
4
|
+
import { DragOverlay, rectIntersection } from '@dnd-kit/core';
|
|
6
5
|
import Choices from './choices';
|
|
7
6
|
import Choice from './choices/choice';
|
|
8
7
|
import Blank from './components/blank';
|
|
@@ -200,7 +199,7 @@ export default class DragInTheBlank extends React.Component {
|
|
|
200
199
|
<DragProvider
|
|
201
200
|
onDragStart={this.handleDragStart}
|
|
202
201
|
onDragEnd={this.handleDragEnd}
|
|
203
|
-
collisionDetection={
|
|
202
|
+
collisionDetection={rectIntersection}
|
|
204
203
|
>
|
|
205
204
|
<div ref={(ref) => (this.rootRef = ref)} style={style}>
|
|
206
205
|
<Choices
|
package/src/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { buildLayoutFromMarkup, withMask } from './with-mask';
|
|
2
2
|
import DragInTheBlank from './drag-in-the-blank';
|
|
3
3
|
import ConstructedResponse from './constructed-response';
|
|
4
4
|
import Customizable from './customizable';
|
package/src/mask.jsx
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
|
-
import get from 'lodash
|
|
3
|
+
import { get } from 'lodash-es';
|
|
4
4
|
import { styled } from '@mui/material/styles';
|
|
5
5
|
import { renderMath } from '@pie-lib/math-rendering';
|
|
6
6
|
import { MARK_TAGS } from './serialization';
|
|
7
7
|
|
|
8
8
|
const Paragraph = styled('div')(({ theme }) => ({
|
|
9
|
-
paddingTop: theme.spacing(
|
|
10
|
-
paddingBottom: theme.spacing(
|
|
9
|
+
paddingTop: theme.spacing(0.5),
|
|
10
|
+
paddingBottom: theme.spacing(0.5),
|
|
11
11
|
}));
|
|
12
12
|
|
|
13
13
|
const Spacer = styled('span')(() => ({
|
|
@@ -134,7 +134,7 @@ const MaskContainer = styled('div')(() => ({
|
|
|
134
134
|
export default class Mask extends React.Component {
|
|
135
135
|
constructor(props) {
|
|
136
136
|
super(props);
|
|
137
|
-
|
|
137
|
+
this.internalContainerRef = React.createRef();
|
|
138
138
|
}
|
|
139
139
|
|
|
140
140
|
static propTypes = {
|
|
@@ -143,10 +143,7 @@ export default class Mask extends React.Component {
|
|
|
143
143
|
value: PropTypes.object,
|
|
144
144
|
onChange: PropTypes.func,
|
|
145
145
|
elementType: PropTypes.string,
|
|
146
|
-
containerRef: PropTypes.oneOfType([
|
|
147
|
-
PropTypes.func,
|
|
148
|
-
PropTypes.shape({ current: PropTypes.instanceOf(Element) }),
|
|
149
|
-
]),
|
|
146
|
+
containerRef: PropTypes.oneOfType([PropTypes.func, PropTypes.shape({ current: PropTypes.instanceOf(Element) })]),
|
|
150
147
|
};
|
|
151
148
|
|
|
152
149
|
componentDidMount() {
|