@pie-lib/mask-markup 1.13.47-next.1 → 1.14.0-beta.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/CHANGELOG.md +15 -56
- package/NEXT.CHANGELOG.json +1 -0
- package/lib/choices/choice.js +80 -17
- package/lib/choices/choice.js.map +1 -1
- package/lib/choices/index.js +11 -3
- package/lib/choices/index.js.map +1 -1
- package/lib/components/blank.js +146 -34
- package/lib/components/blank.js.map +1 -1
- package/lib/components/correct-input.js +8 -3
- package/lib/components/correct-input.js.map +1 -1
- package/lib/components/dropdown.js +182 -49
- package/lib/components/dropdown.js.map +1 -1
- package/lib/constructed-response.js +87 -23
- package/lib/constructed-response.js.map +1 -1
- package/lib/customizable.js +48 -0
- package/lib/customizable.js.map +1 -0
- package/lib/drag-in-the-blank.js +34 -8
- package/lib/drag-in-the-blank.js.map +1 -1
- package/lib/index.js +8 -0
- package/lib/index.js.map +1 -1
- package/lib/inline-dropdown.js +3 -1
- package/lib/inline-dropdown.js.map +1 -1
- package/lib/mask.js +45 -6
- package/lib/mask.js.map +1 -1
- package/lib/with-mask.js +34 -2
- package/lib/with-mask.js.map +1 -1
- package/package.json +9 -5
- package/src/__tests__/__snapshots__/drag-in-the-blank.test.js.snap +316 -0
- package/src/__tests__/__snapshots__/mask.test.js.snap +55 -0
- package/src/__tests__/__snapshots__/with-mask.test.js.snap +62 -0
- package/src/__tests__/drag-in-the-blank.test.js +71 -0
- package/src/__tests__/index.test.js +39 -0
- package/src/__tests__/mask.test.js +152 -0
- package/src/__tests__/serialization.test.js +54 -0
- package/src/__tests__/utils.js +1 -0
- package/src/__tests__/with-mask.test.js +51 -0
- package/src/choices/__tests__/__snapshots__/index.test.js.snap +209 -0
- package/src/choices/__tests__/index.test.js +62 -0
- package/src/choices/choice.jsx +60 -6
- package/src/choices/index.jsx +2 -2
- package/src/components/__tests__/__snapshots__/blank.test.js.snap +111 -0
- package/src/components/__tests__/__snapshots__/correct-input.test.js.snap +64 -0
- package/src/components/__tests__/__snapshots__/dropdown.test.js.snap +133 -0
- package/src/components/__tests__/__snapshots__/input.test.js.snap +34 -0
- package/src/components/__tests__/blank.test.js +202 -0
- package/src/components/__tests__/correct-input.test.js +49 -0
- package/src/components/__tests__/dropdown.test.js +51 -0
- package/src/components/__tests__/input.test.js +50 -0
- package/src/components/blank.jsx +139 -28
- package/src/components/correct-input.jsx +6 -1
- package/src/components/dropdown.jsx +192 -71
- package/src/constructed-response.jsx +76 -18
- package/src/customizable.jsx +35 -0
- package/src/drag-in-the-blank.jsx +26 -3
- package/src/index.js +10 -1
- package/src/inline-dropdown.jsx +2 -0
- package/src/mask.jsx +30 -5
- package/src/with-mask.jsx +39 -2
- package/README.md +0 -14
|
@@ -1,34 +1,92 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import
|
|
2
|
+
import { withStyles } from '@material-ui/core/styles';
|
|
3
|
+
import classnames from 'classnames';
|
|
4
|
+
|
|
5
|
+
import { color } from '@pie-lib/render-ui';
|
|
6
|
+
import EditableHtml from '@pie-lib/editable-html';
|
|
3
7
|
import { withMask } from './with-mask';
|
|
4
8
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
const styles = () => ({
|
|
10
|
+
editableHtmlCustom: {
|
|
11
|
+
display: 'inline-block',
|
|
12
|
+
verticalAlign: 'middle',
|
|
13
|
+
margin: '4px',
|
|
14
|
+
borderRadius: '4px',
|
|
15
|
+
border: `1px solid ${color.black()}`,
|
|
16
|
+
},
|
|
17
|
+
correct: {
|
|
18
|
+
border: `1px solid ${color.correct()}`,
|
|
19
|
+
},
|
|
20
|
+
incorrect: {
|
|
21
|
+
border: `1px solid ${color.incorrect()}`,
|
|
22
|
+
},
|
|
23
|
+
});
|
|
11
24
|
|
|
12
|
-
|
|
13
|
-
|
|
25
|
+
const MaskedInput = (props) => (node, data) => {
|
|
26
|
+
const {
|
|
27
|
+
adjustedLimit,
|
|
28
|
+
disabled,
|
|
29
|
+
feedback,
|
|
30
|
+
showCorrectAnswer,
|
|
31
|
+
maxLength,
|
|
32
|
+
spellCheck,
|
|
33
|
+
classes,
|
|
34
|
+
pluginProps,
|
|
35
|
+
onChange,
|
|
36
|
+
} = props;
|
|
37
|
+
const dataset = node.data?.dataset || {};
|
|
38
|
+
|
|
39
|
+
if (dataset.component === 'input') {
|
|
14
40
|
const correctAnswer = ((props.choices && dataset && props.choices[dataset.id]) || [])[0];
|
|
15
41
|
const finalValue = showCorrectAnswer ? correctAnswer && correctAnswer.label : data[dataset.id] || '';
|
|
16
42
|
const width = maxLength && maxLength[dataset.id];
|
|
43
|
+
const feedbackStatus = feedback && feedback[dataset.id];
|
|
44
|
+
const isCorrect = showCorrectAnswer || feedbackStatus === 'correct';
|
|
45
|
+
const isIncorrect = !showCorrectAnswer && feedbackStatus === 'incorrect';
|
|
46
|
+
|
|
47
|
+
const handleInputChange = (newValue) => {
|
|
48
|
+
const updatedValue = {
|
|
49
|
+
...data,
|
|
50
|
+
[dataset.id]: newValue,
|
|
51
|
+
};
|
|
52
|
+
onChange(updatedValue);
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
const handleKeyDown = (event) => {
|
|
56
|
+
// the keyCode value for the Enter/Return key is 13
|
|
57
|
+
if (event.key === 'Enter' || event.keyCode === 13) {
|
|
58
|
+
return false;
|
|
59
|
+
}
|
|
60
|
+
};
|
|
17
61
|
|
|
18
62
|
return (
|
|
19
|
-
<
|
|
63
|
+
<EditableHtml
|
|
64
|
+
id={dataset.id}
|
|
20
65
|
key={`${node.type}-input-${dataset.id}`}
|
|
21
|
-
correct={feedback && feedback[dataset.id] && feedback[dataset.id] === 'correct'}
|
|
22
66
|
disabled={showCorrectAnswer || disabled}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
showCorrectAnswer={showCorrectAnswer}
|
|
27
|
-
width={width}
|
|
67
|
+
disableUnderline
|
|
68
|
+
onChange={handleInputChange}
|
|
69
|
+
markup={finalValue || ''}
|
|
28
70
|
charactersLimit={adjustedLimit ? width : 25}
|
|
29
|
-
|
|
71
|
+
activePlugins={['languageCharacters']}
|
|
72
|
+
pluginProps={pluginProps}
|
|
73
|
+
languageCharactersProps={[{ language: 'spanish' }]}
|
|
30
74
|
spellCheck={spellCheck}
|
|
75
|
+
width={`calc(${width}em + 42px)`} // added 42px for left and right padding of editable-html
|
|
76
|
+
onKeyDown={handleKeyDown}
|
|
77
|
+
autoWidthToolbar
|
|
78
|
+
toolbarOpts={{
|
|
79
|
+
minWidth: 'auto',
|
|
80
|
+
noBorder: true,
|
|
81
|
+
isHidden: !!pluginProps?.characters?.disabled,
|
|
82
|
+
}}
|
|
83
|
+
className={classnames(classes.editableHtmlCustom, {
|
|
84
|
+
[classes.correct]: isCorrect,
|
|
85
|
+
[classes.incorrect]: isIncorrect,
|
|
86
|
+
})}
|
|
31
87
|
/>
|
|
32
88
|
);
|
|
33
89
|
}
|
|
34
|
-
}
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
export default withStyles(styles)(withMask('input', MaskedInput));
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
// import Input from './components/input';
|
|
3
|
+
import { withMask } from './with-mask';
|
|
4
|
+
|
|
5
|
+
// eslint-disable-next-line react/display-name
|
|
6
|
+
export default withMask('input', (props) => (node, data, onChange) => {
|
|
7
|
+
const dataset = node.data ? node.data.dataset || {} : {};
|
|
8
|
+
if (dataset.component === 'input') {
|
|
9
|
+
// eslint-disable-next-line react/prop-types
|
|
10
|
+
// const { adjustedLimit, disabled, feedback, showCorrectAnswer, maxLength, spellCheck } = props;
|
|
11
|
+
|
|
12
|
+
// the first answer is the correct one
|
|
13
|
+
// eslint-disable-next-line react/prop-types
|
|
14
|
+
// const correctAnswer = ((props.choices && dataset && props.choices[dataset.id]) || [])[0];
|
|
15
|
+
// const finalValue = showCorrectAnswer ? correctAnswer && correctAnswer.label : data[dataset.id] || '';
|
|
16
|
+
// const width = maxLength && maxLength[dataset.id];
|
|
17
|
+
|
|
18
|
+
return props.customMarkMarkupComponent(dataset.id);
|
|
19
|
+
// return (
|
|
20
|
+
// <Input
|
|
21
|
+
// key={`${node.type}-input-${dataset.id}`}
|
|
22
|
+
// correct={feedback && feedback[dataset.id] && feedback[dataset.id] === 'correct'}
|
|
23
|
+
// disabled={showCorrectAnswer || disabled}
|
|
24
|
+
// value={finalValue}
|
|
25
|
+
// id={dataset.id}
|
|
26
|
+
// onChange={onChange}
|
|
27
|
+
// showCorrectAnswer={showCorrectAnswer}
|
|
28
|
+
// width={width}
|
|
29
|
+
// charactersLimit={adjustedLimit ? width : 25}
|
|
30
|
+
// isConstructedResponse={true}
|
|
31
|
+
// spellCheck={spellCheck}
|
|
32
|
+
// />
|
|
33
|
+
// );
|
|
34
|
+
}
|
|
35
|
+
});
|
|
@@ -10,7 +10,15 @@ const Masked = withMask('blank', (props) => (node, data, onChange) => {
|
|
|
10
10
|
const dataset = node.data ? node.data.dataset || {} : {};
|
|
11
11
|
if (dataset.component === 'blank') {
|
|
12
12
|
// eslint-disable-next-line react/prop-types
|
|
13
|
-
const {
|
|
13
|
+
const {
|
|
14
|
+
disabled,
|
|
15
|
+
duplicates,
|
|
16
|
+
correctResponse,
|
|
17
|
+
feedback,
|
|
18
|
+
showCorrectAnswer,
|
|
19
|
+
emptyResponseAreaWidth,
|
|
20
|
+
emptyResponseAreaHeight,
|
|
21
|
+
} = props;
|
|
14
22
|
const choiceId = showCorrectAnswer ? correctResponse[dataset.id] : data[dataset.id];
|
|
15
23
|
// eslint-disable-next-line react/prop-types
|
|
16
24
|
const choice = choiceId && props.choices.find((c) => c.id === choiceId);
|
|
@@ -23,6 +31,8 @@ const Masked = withMask('blank', (props) => (node, data, onChange) => {
|
|
|
23
31
|
duplicates={duplicates}
|
|
24
32
|
choice={choice}
|
|
25
33
|
id={dataset.id}
|
|
34
|
+
emptyResponseAreaWidth={emptyResponseAreaWidth}
|
|
35
|
+
emptyResponseAreaHeight={emptyResponseAreaHeight}
|
|
26
36
|
onChange={onChange}
|
|
27
37
|
/>
|
|
28
38
|
);
|
|
@@ -42,6 +52,8 @@ export default class DragInTheBlank extends React.Component {
|
|
|
42
52
|
feedback: PropTypes.object,
|
|
43
53
|
correctResponse: PropTypes.object,
|
|
44
54
|
showCorrectAnswer: PropTypes.bool,
|
|
55
|
+
emptyResponseAreaWidth: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
56
|
+
emptyResponseAreaHeight: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
45
57
|
};
|
|
46
58
|
|
|
47
59
|
UNSAFE_componentWillReceiveProps() {
|
|
@@ -56,13 +68,18 @@ export default class DragInTheBlank extends React.Component {
|
|
|
56
68
|
|
|
57
69
|
getPositionDirection = (choicePosition) => {
|
|
58
70
|
let flexDirection;
|
|
71
|
+
let justifyContent;
|
|
72
|
+
let alignItems;
|
|
59
73
|
|
|
60
74
|
switch (choicePosition) {
|
|
61
75
|
case 'left':
|
|
62
76
|
flexDirection = 'row';
|
|
77
|
+
alignItems = 'center';
|
|
63
78
|
break;
|
|
64
79
|
case 'right':
|
|
65
80
|
flexDirection = 'row-reverse';
|
|
81
|
+
justifyContent = 'flex-end';
|
|
82
|
+
alignItems = 'center';
|
|
66
83
|
break;
|
|
67
84
|
case 'below':
|
|
68
85
|
flexDirection = 'column-reverse';
|
|
@@ -73,7 +90,7 @@ export default class DragInTheBlank extends React.Component {
|
|
|
73
90
|
break;
|
|
74
91
|
}
|
|
75
92
|
|
|
76
|
-
return flexDirection;
|
|
93
|
+
return { flexDirection, justifyContent, alignItems };
|
|
77
94
|
};
|
|
78
95
|
|
|
79
96
|
render() {
|
|
@@ -89,12 +106,15 @@ export default class DragInTheBlank extends React.Component {
|
|
|
89
106
|
disabled,
|
|
90
107
|
feedback,
|
|
91
108
|
showCorrectAnswer,
|
|
109
|
+
emptyResponseAreaWidth,
|
|
110
|
+
emptyResponseAreaHeight,
|
|
92
111
|
} = this.props;
|
|
93
112
|
|
|
94
113
|
const choicePosition = choicesPosition || 'below';
|
|
95
114
|
const style = {
|
|
96
115
|
display: 'flex',
|
|
97
|
-
|
|
116
|
+
minWidth: '100px',
|
|
117
|
+
...this.getPositionDirection(choicePosition),
|
|
98
118
|
};
|
|
99
119
|
|
|
100
120
|
return (
|
|
@@ -107,6 +127,7 @@ export default class DragInTheBlank extends React.Component {
|
|
|
107
127
|
disabled={disabled}
|
|
108
128
|
/>
|
|
109
129
|
<Masked
|
|
130
|
+
elementType={'drag-in-the-blank'}
|
|
110
131
|
markup={markup}
|
|
111
132
|
layout={layout}
|
|
112
133
|
value={value}
|
|
@@ -117,6 +138,8 @@ export default class DragInTheBlank extends React.Component {
|
|
|
117
138
|
feedback={feedback}
|
|
118
139
|
correctResponse={correctResponse}
|
|
119
140
|
showCorrectAnswer={showCorrectAnswer}
|
|
141
|
+
emptyResponseAreaWidth={emptyResponseAreaWidth}
|
|
142
|
+
emptyResponseAreaHeight={emptyResponseAreaHeight}
|
|
120
143
|
/>
|
|
121
144
|
</div>
|
|
122
145
|
);
|
package/src/index.js
CHANGED
|
@@ -1,7 +1,16 @@
|
|
|
1
1
|
import { withMask, buildLayoutFromMarkup } from './with-mask';
|
|
2
2
|
import DragInTheBlank from './drag-in-the-blank';
|
|
3
3
|
import ConstructedResponse from './constructed-response';
|
|
4
|
+
import Customizable from './customizable';
|
|
4
5
|
import InlineDropdown from './inline-dropdown';
|
|
5
6
|
import componentize from './componentize';
|
|
6
7
|
|
|
7
|
-
export {
|
|
8
|
+
export {
|
|
9
|
+
withMask,
|
|
10
|
+
buildLayoutFromMarkup,
|
|
11
|
+
DragInTheBlank,
|
|
12
|
+
ConstructedResponse,
|
|
13
|
+
InlineDropdown,
|
|
14
|
+
componentize,
|
|
15
|
+
Customizable,
|
|
16
|
+
};
|
package/src/inline-dropdown.jsx
CHANGED
|
@@ -17,10 +17,12 @@ export default withMask('dropdown', (props) => (node, data, onChange) => {
|
|
|
17
17
|
correct={feedback && feedback[dataset.id] && feedback[dataset.id] === 'correct'}
|
|
18
18
|
disabled={disabled || showCorrectAnswer}
|
|
19
19
|
value={finalChoice}
|
|
20
|
+
correctValue={showCorrectAnswer ? correctAnswer && correctAnswer.label : undefined}
|
|
20
21
|
id={dataset.id}
|
|
21
22
|
onChange={onChange}
|
|
22
23
|
choices={choices[dataset.id]}
|
|
23
24
|
showCorrectAnswer={showCorrectAnswer}
|
|
25
|
+
singleQuery={Object.keys(choices).length == 1}
|
|
24
26
|
/>
|
|
25
27
|
);
|
|
26
28
|
}
|
package/src/mask.jsx
CHANGED
|
@@ -3,6 +3,7 @@ import PropTypes from 'prop-types';
|
|
|
3
3
|
import get from 'lodash/get';
|
|
4
4
|
import { withStyles } from '@material-ui/core/styles';
|
|
5
5
|
import { MARK_TAGS } from './serialization';
|
|
6
|
+
import cx from 'classnames';
|
|
6
7
|
|
|
7
8
|
const Paragraph = withStyles((theme) => ({
|
|
8
9
|
para: {
|
|
@@ -11,6 +12,13 @@ const Paragraph = withStyles((theme) => ({
|
|
|
11
12
|
},
|
|
12
13
|
}))((props) => <div className={props.classes.para}>{props.children}</div>);
|
|
13
14
|
|
|
15
|
+
const Spacer = withStyles(() => ({
|
|
16
|
+
spacer: {
|
|
17
|
+
display: 'inline-block',
|
|
18
|
+
width: '.75em',
|
|
19
|
+
},
|
|
20
|
+
}))((props) => <span className={props.classes.spacer} />);
|
|
21
|
+
|
|
14
22
|
const restrictWhitespaceTypes = ['tbody', 'tr'];
|
|
15
23
|
|
|
16
24
|
const addText = (parentNode, text) => {
|
|
@@ -34,7 +42,7 @@ const getMark = (n) => {
|
|
|
34
42
|
return null;
|
|
35
43
|
};
|
|
36
44
|
|
|
37
|
-
export const renderChildren = (layout, value, onChange, rootRenderChildren, parentNode) => {
|
|
45
|
+
export const renderChildren = (layout, value, onChange, rootRenderChildren, parentNode, elementType) => {
|
|
38
46
|
if (!value) {
|
|
39
47
|
return null;
|
|
40
48
|
}
|
|
@@ -59,6 +67,9 @@ export const renderChildren = (layout, value, onChange, rootRenderChildren, pare
|
|
|
59
67
|
const c = rootRenderChildren(n, value, onChange);
|
|
60
68
|
if (c) {
|
|
61
69
|
children.push(c);
|
|
70
|
+
if (parentNode?.type !== 'td' && elementType === 'drag-in-the-blank') {
|
|
71
|
+
children.push(<Spacer key={`spacer-${index}`} />);
|
|
72
|
+
}
|
|
62
73
|
return;
|
|
63
74
|
}
|
|
64
75
|
}
|
|
@@ -84,9 +95,12 @@ export const renderChildren = (layout, value, onChange, rootRenderChildren, pare
|
|
|
84
95
|
}
|
|
85
96
|
} else if (content.length > 0) {
|
|
86
97
|
children.push(content);
|
|
98
|
+
if (parentNode?.type !== 'td' && elementType === 'drag-in-the-blank') {
|
|
99
|
+
children.push(<Spacer key={`spacer-${index}`} />);
|
|
100
|
+
}
|
|
87
101
|
}
|
|
88
102
|
} else {
|
|
89
|
-
const subNodes = renderChildren(n, value, onChange, rootRenderChildren, n);
|
|
103
|
+
const subNodes = renderChildren(n, value, onChange, rootRenderChildren, n, elementType);
|
|
90
104
|
if (n.type === 'p' || n.type === 'paragraph') {
|
|
91
105
|
children.push(<Paragraph key={key}>{subNodes}</Paragraph>);
|
|
92
106
|
} else {
|
|
@@ -110,7 +124,17 @@ const MaskContainer = withStyles(() => ({
|
|
|
110
124
|
main: {
|
|
111
125
|
display: 'initial',
|
|
112
126
|
},
|
|
113
|
-
|
|
127
|
+
tableStyle: {
|
|
128
|
+
'&:not(.MathJax) table': {
|
|
129
|
+
borderCollapse: 'collapse',
|
|
130
|
+
},
|
|
131
|
+
// align table content to left as per STAR requirement PD-3687
|
|
132
|
+
'&:not(.MathJax) table td, &:not(.MathJax) table th': {
|
|
133
|
+
padding: '8px 12px',
|
|
134
|
+
textAlign: 'left',
|
|
135
|
+
},
|
|
136
|
+
},
|
|
137
|
+
}))((props) => <div className={cx(props.classes.main, props.classes.tableStyle)}>{props.children}</div>);
|
|
114
138
|
|
|
115
139
|
/**
|
|
116
140
|
* Renders a layout that uses the slate.js Value model structure.
|
|
@@ -121,6 +145,7 @@ export default class Mask extends React.Component {
|
|
|
121
145
|
layout: PropTypes.object,
|
|
122
146
|
value: PropTypes.object,
|
|
123
147
|
onChange: PropTypes.func,
|
|
148
|
+
elementType: PropTypes.string,
|
|
124
149
|
};
|
|
125
150
|
|
|
126
151
|
handleChange = (id, value) => {
|
|
@@ -129,8 +154,8 @@ export default class Mask extends React.Component {
|
|
|
129
154
|
};
|
|
130
155
|
|
|
131
156
|
render() {
|
|
132
|
-
const { value, layout } = this.props;
|
|
133
|
-
const children = renderChildren(layout, value, this.handleChange, this.props.renderChildren);
|
|
157
|
+
const { value, layout, elementType } = this.props;
|
|
158
|
+
const children = renderChildren(layout, value, this.handleChange, this.props.renderChildren, null, elementType);
|
|
134
159
|
|
|
135
160
|
return <MaskContainer>{children}</MaskContainer>;
|
|
136
161
|
}
|
package/src/with-mask.jsx
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import ReactDOM from 'react-dom';
|
|
2
3
|
import PropTypes from 'prop-types';
|
|
3
4
|
import Mask from './mask';
|
|
4
5
|
import componentize from './componentize';
|
|
@@ -23,13 +24,49 @@ export const withMask = (type, renderChildren) => {
|
|
|
23
24
|
layout: PropTypes.object,
|
|
24
25
|
value: PropTypes.object,
|
|
25
26
|
onChange: PropTypes.func,
|
|
27
|
+
customMarkMarkupComponent: PropTypes.func,
|
|
28
|
+
elementType: PropTypes.string,
|
|
26
29
|
};
|
|
27
30
|
|
|
31
|
+
componentDidUpdate(prevProps) {
|
|
32
|
+
if (this.props.markup !== prevProps.markup) {
|
|
33
|
+
// eslint-disable-next-line
|
|
34
|
+
const domNode = ReactDOM.findDOMNode(this);
|
|
35
|
+
// Query all elements that may contain outdated MathJax renderings
|
|
36
|
+
const mathElements = domNode && domNode.querySelectorAll('[data-latex][data-math-handled="true"]');
|
|
37
|
+
|
|
38
|
+
// Clean up for fresh MathJax processing
|
|
39
|
+
(mathElements || []).forEach((el) => {
|
|
40
|
+
// Remove the MathJax container to allow for clean updates
|
|
41
|
+
const mjxContainer = el.querySelector('mjx-container');
|
|
42
|
+
|
|
43
|
+
if (mjxContainer) {
|
|
44
|
+
el.removeChild(mjxContainer);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// Update the innerHTML to match the raw LaTeX data, ensuring it is reprocessed correctly
|
|
48
|
+
const latexCode = el.getAttribute('data-raw');
|
|
49
|
+
el.innerHTML = latexCode;
|
|
50
|
+
|
|
51
|
+
// Remove the attribute to signal that MathJax should reprocess this element
|
|
52
|
+
el.removeAttribute('data-math-handled');
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
28
57
|
render() {
|
|
29
|
-
const { markup, layout, value, onChange } = this.props;
|
|
58
|
+
const { markup, layout, value, onChange, elementType } = this.props;
|
|
30
59
|
|
|
31
60
|
const maskLayout = layout ? layout : buildLayoutFromMarkup(markup, type);
|
|
32
|
-
return
|
|
61
|
+
return (
|
|
62
|
+
<Mask
|
|
63
|
+
elementType={elementType}
|
|
64
|
+
layout={maskLayout}
|
|
65
|
+
value={value}
|
|
66
|
+
onChange={onChange}
|
|
67
|
+
renderChildren={renderChildren(this.props)}
|
|
68
|
+
/>
|
|
69
|
+
);
|
|
33
70
|
}
|
|
34
71
|
};
|
|
35
72
|
};
|
package/README.md
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
# mask-markup
|
|
2
|
-
|
|
3
|
-
## issues
|
|
4
|
-
|
|
5
|
-
- dnd
|
|
6
|
-
- simple approach loses context due to stepping out of react tree to run a ReactDOM.render().
|
|
7
|
-
- Would need to pass drag parts as props (no context)
|
|
8
|
-
- Or do the entire tree render in react - like a simple slate
|
|
9
|
-
- HTML5Backend - ? going to be a an issue w/ multiple items using dnd?
|
|
10
|
-
|
|
11
|
-
* hey diddle sample
|
|
12
|
-
* add feedback
|
|
13
|
-
* check perf
|
|
14
|
-
* more complex html
|