@pie-lib/editable-html 10.0.0-beta.4 → 10.0.0-beta.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +255 -152
- package/lib/components.js +15 -39
- package/lib/components.js.map +1 -1
- package/lib/editor.js +200 -356
- package/lib/editor.js.map +1 -1
- package/lib/index.js +25 -49
- package/lib/index.js.map +1 -1
- package/lib/new-serialization.js +31 -71
- package/lib/new-serialization.js.map +1 -1
- package/lib/parse-html.js +7 -6
- package/lib/parse-html.js.map +1 -1
- package/lib/plugins/characters/custom-popper.js +3 -13
- package/lib/plugins/characters/custom-popper.js.map +1 -1
- package/lib/plugins/characters/index.js +20 -59
- package/lib/plugins/characters/index.js.map +1 -1
- package/lib/plugins/characters/utils.js +1 -1
- package/lib/plugins/characters/utils.js.map +1 -1
- package/lib/plugins/hotKeys/index.js +9 -16
- package/lib/plugins/hotKeys/index.js.map +1 -1
- package/lib/plugins/image/alt-dialog.js +6 -27
- package/lib/plugins/image/alt-dialog.js.map +1 -1
- package/lib/plugins/image/component.js +42 -99
- package/lib/plugins/image/component.js.map +1 -1
- package/lib/plugins/image/image-toolbar.js +14 -50
- package/lib/plugins/image/image-toolbar.js.map +1 -1
- package/lib/plugins/image/index.js +16 -59
- package/lib/plugins/image/index.js.map +1 -1
- package/lib/plugins/image/insert-image-handler.js +13 -25
- package/lib/plugins/image/insert-image-handler.js.map +1 -1
- package/lib/plugins/index.js +6 -36
- package/lib/plugins/index.js.map +1 -1
- package/lib/plugins/list/index.js +11 -46
- package/lib/plugins/list/index.js.map +1 -1
- package/lib/plugins/math/index.js +89 -93
- package/lib/plugins/math/index.js.map +1 -1
- package/lib/plugins/media/index.js +32 -109
- package/lib/plugins/media/index.js.map +1 -1
- package/lib/plugins/media/media-dialog.js +107 -195
- package/lib/plugins/media/media-dialog.js.map +1 -1
- package/lib/plugins/media/media-toolbar.js +7 -27
- package/lib/plugins/media/media-toolbar.js.map +1 -1
- package/lib/plugins/media/media-wrapper.js +9 -14
- package/lib/plugins/media/media-wrapper.js.map +1 -1
- package/lib/plugins/respArea/drag-in-the-blank/choice.js +13 -53
- package/lib/plugins/respArea/drag-in-the-blank/choice.js.map +1 -1
- package/lib/plugins/respArea/drag-in-the-blank/index.js +6 -20
- package/lib/plugins/respArea/drag-in-the-blank/index.js.map +1 -1
- package/lib/plugins/respArea/explicit-constructed-response/index.js +5 -10
- package/lib/plugins/respArea/explicit-constructed-response/index.js.map +1 -1
- package/lib/plugins/respArea/icons/index.js +16 -31
- package/lib/plugins/respArea/icons/index.js.map +1 -1
- package/lib/plugins/respArea/index.js +7 -54
- package/lib/plugins/respArea/index.js.map +1 -1
- package/lib/plugins/respArea/inline-dropdown/index.js +3 -10
- package/lib/plugins/respArea/inline-dropdown/index.js.map +1 -1
- package/lib/plugins/respArea/utils.js +6 -21
- package/lib/plugins/respArea/utils.js.map +1 -1
- package/lib/plugins/table/icons/index.js +1 -8
- package/lib/plugins/table/icons/index.js.map +1 -1
- package/lib/plugins/table/index.js +54 -187
- package/lib/plugins/table/index.js.map +1 -1
- package/lib/plugins/table/table-toolbar.js +12 -44
- package/lib/plugins/table/table-toolbar.js.map +1 -1
- package/lib/plugins/toolbar/default-toolbar.js +17 -46
- package/lib/plugins/toolbar/default-toolbar.js.map +1 -1
- package/lib/plugins/toolbar/done-button.js +2 -10
- package/lib/plugins/toolbar/done-button.js.map +1 -1
- package/lib/plugins/toolbar/editor-and-toolbar.js +134 -144
- package/lib/plugins/toolbar/editor-and-toolbar.js.map +1 -1
- package/lib/plugins/toolbar/index.js +2 -6
- package/lib/plugins/toolbar/index.js.map +1 -1
- package/lib/plugins/toolbar/toolbar-buttons.js +9 -40
- package/lib/plugins/toolbar/toolbar-buttons.js.map +1 -1
- package/lib/plugins/toolbar/toolbar.js +29 -83
- package/lib/plugins/toolbar/toolbar.js.map +1 -1
- package/lib/plugins/utils.js +8 -30
- package/lib/plugins/utils.js.map +1 -1
- package/lib/serialization.js +11 -69
- package/lib/serialization.js.map +1 -1
- package/lib/test-serializer.js +5 -56
- package/lib/test-serializer.js.map +1 -1
- package/lib/theme.js +1 -1
- package/lib/theme.js.map +1 -1
- package/package.json +7 -7
- package/playground/image/data.js +20 -20
- package/playground/image/index.html +20 -22
- package/playground/image/index.jsx +10 -12
- package/playground/index.html +23 -25
- package/playground/mathquill/index.html +20 -23
- package/playground/mathquill/index.jsx +22 -18
- package/playground/prod-test/index.html +20 -24
- package/playground/prod-test/index.jsx +3 -5
- package/playground/schema-override/data.js +10 -10
- package/playground/schema-override/image-plugin.jsx +4 -3
- package/playground/schema-override/index.html +19 -21
- package/playground/schema-override/index.jsx +14 -13
- package/playground/serialization/data.js +10 -10
- package/playground/serialization/image-plugin.jsx +4 -3
- package/playground/serialization/index.html +20 -22
- package/playground/table-examples.html +8 -5
- package/playground/webpack.config.js +10 -10
- package/src/editor.jsx +108 -104
- package/src/index.jsx +20 -13
- package/src/new-serialization.jsx +30 -11
- package/src/parse-html.js +1 -1
- package/src/plugins/characters/custom-popper.js +7 -7
- package/src/plugins/characters/index.jsx +34 -23
- package/src/plugins/characters/utils.js +81 -81
- package/src/plugins/image/alt-dialog.jsx +5 -4
- package/src/plugins/image/component.jsx +47 -44
- package/src/plugins/image/image-toolbar.jsx +19 -27
- package/src/plugins/image/index.jsx +24 -18
- package/src/plugins/image/insert-image-handler.js +9 -0
- package/src/plugins/index.jsx +7 -9
- package/src/plugins/list/index.jsx +7 -7
- package/src/plugins/math/index.jsx +71 -28
- package/src/plugins/media/index.jsx +7 -7
- package/src/plugins/media/media-dialog.js +63 -89
- package/src/plugins/media/media-toolbar.jsx +8 -8
- package/src/plugins/media/media-wrapper.jsx +8 -5
- package/src/plugins/respArea/drag-in-the-blank/choice.jsx +19 -21
- package/src/plugins/respArea/drag-in-the-blank/index.jsx +4 -4
- package/src/plugins/respArea/explicit-constructed-response/index.jsx +5 -4
- package/src/plugins/respArea/icons/index.jsx +14 -11
- package/src/plugins/respArea/index.jsx +9 -15
- package/src/plugins/respArea/inline-dropdown/index.jsx +6 -6
- package/src/plugins/respArea/utils.jsx +7 -3
- package/src/plugins/table/icons/index.jsx +11 -17
- package/src/plugins/table/index.jsx +14 -10
- package/src/plugins/table/table-toolbar.jsx +6 -6
- package/src/plugins/toolbar/default-toolbar.jsx +9 -9
- package/src/plugins/toolbar/done-button.jsx +4 -4
- package/src/plugins/toolbar/editor-and-toolbar.jsx +36 -33
- package/src/plugins/toolbar/index.jsx +3 -2
- package/src/plugins/toolbar/toolbar-buttons.jsx +11 -11
- package/src/plugins/toolbar/toolbar.jsx +6 -1
- package/src/plugins/utils.js +2 -2
- package/src/serialization.jsx +34 -32
- package/src/test-serializer.js +2 -9
- package/lib/old-serialization.js +0 -330
- package/lib/slate-editor.js +0 -302
- package/src/test-serializer.js.rej +0 -20
- package/yarn-error.log +0 -18318
|
@@ -2,29 +2,29 @@ import React from 'react';
|
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import { withStyles } from '@material-ui/core/styles';
|
|
4
4
|
|
|
5
|
-
const useStyles = withStyles(theme => ({
|
|
5
|
+
const useStyles = withStyles((theme) => ({
|
|
6
6
|
root: {
|
|
7
7
|
position: 'relative',
|
|
8
8
|
bottom: '5px',
|
|
9
9
|
left: 0,
|
|
10
10
|
width: '100%',
|
|
11
|
-
background:
|
|
11
|
+
background: theme.palette.common.white,
|
|
12
12
|
display: 'inline-flex',
|
|
13
13
|
padding: '5px',
|
|
14
|
-
boxShadow: '0px 4px 4px rgba(0, 0, 0, 0.25)'
|
|
14
|
+
boxShadow: '0px 4px 4px rgba(0, 0, 0, 0.25)',
|
|
15
15
|
},
|
|
16
16
|
editContainer: {
|
|
17
17
|
cursor: 'pointer',
|
|
18
18
|
flex: 3,
|
|
19
|
-
border:
|
|
19
|
+
border: `solid ${theme.palette.common.black}`,
|
|
20
20
|
textAlign: 'right',
|
|
21
21
|
borderWidth: '0 2px 0 0',
|
|
22
22
|
marginRight: '5px',
|
|
23
|
-
paddingRight: '5px'
|
|
23
|
+
paddingRight: '5px',
|
|
24
24
|
},
|
|
25
25
|
removeContainer: {
|
|
26
|
-
cursor: 'pointer'
|
|
27
|
-
}
|
|
26
|
+
cursor: 'pointer',
|
|
27
|
+
},
|
|
28
28
|
}));
|
|
29
29
|
|
|
30
30
|
class MediaToolbar extends React.Component {
|
|
@@ -32,7 +32,7 @@ class MediaToolbar extends React.Component {
|
|
|
32
32
|
classes: PropTypes.object,
|
|
33
33
|
onEdit: PropTypes.func,
|
|
34
34
|
hideEdit: PropTypes.bool,
|
|
35
|
-
onRemove: PropTypes.func
|
|
35
|
+
onRemove: PropTypes.func,
|
|
36
36
|
};
|
|
37
37
|
|
|
38
38
|
render() {
|
|
@@ -5,22 +5,25 @@ import { makeStyles } from '@material-ui/styles';
|
|
|
5
5
|
|
|
6
6
|
const useStyles = makeStyles(() => ({
|
|
7
7
|
root: {
|
|
8
|
-
position: 'relative'
|
|
8
|
+
position: 'relative',
|
|
9
9
|
},
|
|
10
10
|
editor: {
|
|
11
11
|
display: 'inline-block',
|
|
12
|
-
overflow: 'hidden'
|
|
13
|
-
}
|
|
12
|
+
overflow: 'hidden',
|
|
13
|
+
},
|
|
14
14
|
}));
|
|
15
15
|
|
|
16
16
|
const MediaWrapper = React.forwardRef((props, ref) => {
|
|
17
|
-
const { children, width, attributes } = props;
|
|
17
|
+
const { children, width, attributes, ...rest } = props;
|
|
18
18
|
const classes = useStyles(props);
|
|
19
19
|
|
|
20
20
|
return (
|
|
21
21
|
<span
|
|
22
|
-
className={classNames(classes.root,
|
|
22
|
+
className={classNames(classes.root, {
|
|
23
|
+
[classes.editor]: editor,
|
|
24
|
+
})}
|
|
23
25
|
ref={ref}
|
|
26
|
+
{...rest}
|
|
24
27
|
{...attributes}
|
|
25
28
|
contentEditable={false}
|
|
26
29
|
style={{
|
|
@@ -9,22 +9,22 @@ import classnames from 'classnames';
|
|
|
9
9
|
|
|
10
10
|
import { GripIcon } from '../icons';
|
|
11
11
|
|
|
12
|
-
const useStyles = withStyles(theme => ({
|
|
12
|
+
const useStyles = withStyles((theme) => ({
|
|
13
13
|
content: {
|
|
14
|
-
border: `solid 0px ${theme.palette.primary.main}
|
|
14
|
+
border: `solid 0px ${theme.palette.primary.main}`,
|
|
15
15
|
},
|
|
16
16
|
chip: {
|
|
17
|
-
minWidth: '90px'
|
|
17
|
+
minWidth: '90px',
|
|
18
18
|
},
|
|
19
19
|
correct: {
|
|
20
|
-
border:
|
|
20
|
+
border: `solid 1px ${color.correct()}`,
|
|
21
21
|
},
|
|
22
22
|
incorrect: {
|
|
23
|
-
border:
|
|
23
|
+
border: `solid 1px ${theme.palette.error.main}`,
|
|
24
24
|
},
|
|
25
25
|
selected: {
|
|
26
|
-
border: `2px solid ${color.primaryDark()} !important
|
|
27
|
-
}
|
|
26
|
+
border: `2px solid ${color.primaryDark()} !important`,
|
|
27
|
+
},
|
|
28
28
|
}));
|
|
29
29
|
|
|
30
30
|
export class BlankContent extends React.Component {
|
|
@@ -35,7 +35,7 @@ export class BlankContent extends React.Component {
|
|
|
35
35
|
isOver: PropTypes.bool,
|
|
36
36
|
dragItem: PropTypes.object,
|
|
37
37
|
value: PropTypes.object,
|
|
38
|
-
classes: PropTypes.object
|
|
38
|
+
classes: PropTypes.object,
|
|
39
39
|
};
|
|
40
40
|
|
|
41
41
|
constructor(props) {
|
|
@@ -75,7 +75,7 @@ export class BlankContent extends React.Component {
|
|
|
75
75
|
|
|
76
76
|
return (
|
|
77
77
|
<div
|
|
78
|
-
ref={ref => (this.elementRef = ref)}
|
|
78
|
+
ref={(ref) => (this.elementRef = ref)}
|
|
79
79
|
style={{
|
|
80
80
|
display: 'inline-flex',
|
|
81
81
|
minWidth: '178px',
|
|
@@ -86,7 +86,7 @@ export class BlankContent extends React.Component {
|
|
|
86
86
|
borderRadius: '3px',
|
|
87
87
|
overflow: 'hidden',
|
|
88
88
|
position: 'relative',
|
|
89
|
-
padding: '8px 8px 8px 35px'
|
|
89
|
+
padding: '8px 8px 8px 35px',
|
|
90
90
|
}}
|
|
91
91
|
data-key={n.key}
|
|
92
92
|
contentEditable={false}
|
|
@@ -97,14 +97,14 @@ export class BlankContent extends React.Component {
|
|
|
97
97
|
position: 'absolute',
|
|
98
98
|
top: '6px',
|
|
99
99
|
left: '15px',
|
|
100
|
-
color: '#9B9B9B'
|
|
100
|
+
color: '#9B9B9B',
|
|
101
101
|
}}
|
|
102
102
|
contentEditable={false}
|
|
103
103
|
/>
|
|
104
104
|
)}
|
|
105
105
|
<span
|
|
106
106
|
dangerouslySetInnerHTML={{
|
|
107
|
-
__html: finalLabel
|
|
107
|
+
__html: finalLabel,
|
|
108
108
|
}}
|
|
109
109
|
/>
|
|
110
110
|
{children}
|
|
@@ -119,9 +119,7 @@ const connectedBlankContent = useStyles(({ connectDropTarget, connectDragSource,
|
|
|
119
119
|
const { classes, isOver, value } = props;
|
|
120
120
|
const dragContent = <StyledBlankContent {...props} />;
|
|
121
121
|
const dragEl = !value ? dragContent : connectDragSource(<span>{dragContent}</span>);
|
|
122
|
-
const content = (
|
|
123
|
-
<span className={classnames(classes.content, isOver && classes.over)}>{dragEl}</span>
|
|
124
|
-
);
|
|
122
|
+
const content = <span className={classnames(classes.content, isOver && classes.over)}>{dragEl}</span>;
|
|
125
123
|
|
|
126
124
|
return connectDropTarget ? connectDropTarget(content) : content;
|
|
127
125
|
});
|
|
@@ -139,20 +137,20 @@ export const tileTarget = {
|
|
|
139
137
|
}
|
|
140
138
|
|
|
141
139
|
return {
|
|
142
|
-
dropped: shouldDrop
|
|
140
|
+
dropped: shouldDrop,
|
|
143
141
|
};
|
|
144
142
|
},
|
|
145
143
|
canDrop(props, monitor) {
|
|
146
144
|
const draggedItem = monitor.getItem();
|
|
147
145
|
|
|
148
146
|
return draggedItem.instanceId === props.instanceId;
|
|
149
|
-
}
|
|
147
|
+
},
|
|
150
148
|
};
|
|
151
149
|
|
|
152
150
|
const DropTile = DropTarget('drag-in-the-blank-choice', tileTarget, (connect, monitor) => ({
|
|
153
151
|
connectDropTarget: connect.dropTarget(),
|
|
154
152
|
isOver: monitor.isOver(),
|
|
155
|
-
dragItem: monitor.getItem()
|
|
153
|
+
dragItem: monitor.getItem(),
|
|
156
154
|
}))(connectedBlankContent);
|
|
157
155
|
|
|
158
156
|
export const tileSource = {
|
|
@@ -164,7 +162,7 @@ export const tileSource = {
|
|
|
164
162
|
id: props.targetId,
|
|
165
163
|
value: props.value,
|
|
166
164
|
instanceId: props.instanceId,
|
|
167
|
-
fromChoice: true
|
|
165
|
+
fromChoice: true,
|
|
168
166
|
};
|
|
169
167
|
},
|
|
170
168
|
endDrag(props, monitor) {
|
|
@@ -178,10 +176,10 @@ export const tileSource = {
|
|
|
178
176
|
props.removeResponse(draggedItem.value);
|
|
179
177
|
}
|
|
180
178
|
}
|
|
181
|
-
}
|
|
179
|
+
},
|
|
182
180
|
};
|
|
183
181
|
|
|
184
182
|
export default DragSource('drag-in-the-blank-choice', tileSource, (connect, monitor) => ({
|
|
185
183
|
connectDragSource: connect.dragSource(),
|
|
186
|
-
isDragging: monitor.isDragging()
|
|
184
|
+
isDragging: monitor.isDragging(),
|
|
187
185
|
}))(DropTile);
|
|
@@ -49,7 +49,7 @@ const DragDrop = props => {
|
|
|
49
49
|
minWidth: '178px',
|
|
50
50
|
position: 'relative',
|
|
51
51
|
margin: inTable ? '10px' : '0 10px',
|
|
52
|
-
cursor: 'pointer'
|
|
52
|
+
cursor: 'pointer',
|
|
53
53
|
}}
|
|
54
54
|
>
|
|
55
55
|
<DragDropTile
|
|
@@ -58,8 +58,8 @@ const DragDrop = props => {
|
|
|
58
58
|
targetId="0"
|
|
59
59
|
value={data}
|
|
60
60
|
duplicates={opts.options.duplicates}
|
|
61
|
-
onChange={value => onValueChange(nodeProps, n, value)}
|
|
62
|
-
removeResponse={value => onRemoveResponse(nodeProps, value)}
|
|
61
|
+
onChange={(value) => onValueChange(nodeProps, n, value)}
|
|
62
|
+
removeResponse={(value) => onRemoveResponse(nodeProps, value)}
|
|
63
63
|
>
|
|
64
64
|
{nodeProps.children}
|
|
65
65
|
{children}
|
|
@@ -73,7 +73,7 @@ DragDrop.propTypes = {
|
|
|
73
73
|
data: PropTypes.object,
|
|
74
74
|
n: PropTypes.object,
|
|
75
75
|
nodeProps: PropTypes.object,
|
|
76
|
-
opts: PropTypes.object
|
|
76
|
+
opts: PropTypes.object,
|
|
77
77
|
};
|
|
78
78
|
|
|
79
79
|
export default DragDrop;
|
|
@@ -13,7 +13,7 @@ const ExplicitConstructedResponse = props => {
|
|
|
13
13
|
minWidth: '178px',
|
|
14
14
|
position: 'relative',
|
|
15
15
|
margin: '0 5px',
|
|
16
|
-
cursor: 'pointer'
|
|
16
|
+
cursor: 'pointer',
|
|
17
17
|
}}
|
|
18
18
|
>
|
|
19
19
|
<div
|
|
@@ -27,10 +27,10 @@ const ExplicitConstructedResponse = props => {
|
|
|
27
27
|
boxSizing: 'border-box',
|
|
28
28
|
borderRadius: '3px',
|
|
29
29
|
overflow: 'hidden',
|
|
30
|
-
padding: '8px'
|
|
30
|
+
padding: '8px',
|
|
31
31
|
}}
|
|
32
32
|
dangerouslySetInnerHTML={{
|
|
33
|
-
__html: value || '<div> </div>'
|
|
33
|
+
__html: value || '<div> </div>',
|
|
34
34
|
}}
|
|
35
35
|
/>
|
|
36
36
|
{children}
|
|
@@ -40,7 +40,8 @@ const ExplicitConstructedResponse = props => {
|
|
|
40
40
|
|
|
41
41
|
ExplicitConstructedResponse.propTypes = {
|
|
42
42
|
attributes: PropTypes.object,
|
|
43
|
-
|
|
43
|
+
error: PropTypes.any,
|
|
44
|
+
value: PropTypes.string,
|
|
44
45
|
};
|
|
45
46
|
|
|
46
47
|
export default ExplicitConstructedResponse;
|
|
@@ -4,20 +4,23 @@ import ChevronRight from '@material-ui/icons/ChevronRight';
|
|
|
4
4
|
import MoreVert from '@material-ui/icons/MoreVert';
|
|
5
5
|
import { withStyles } from '@material-ui/core/styles';
|
|
6
6
|
|
|
7
|
-
const getRotate = direction => {
|
|
7
|
+
const getRotate = (direction) => {
|
|
8
8
|
switch (direction) {
|
|
9
9
|
case 'down':
|
|
10
10
|
return 90;
|
|
11
|
+
|
|
11
12
|
case 'up':
|
|
12
13
|
return -90;
|
|
14
|
+
|
|
13
15
|
case 'left':
|
|
14
16
|
return 180;
|
|
17
|
+
|
|
15
18
|
default:
|
|
16
19
|
return 0;
|
|
17
20
|
}
|
|
18
21
|
};
|
|
19
22
|
|
|
20
|
-
export const Chevron = props => {
|
|
23
|
+
export const Chevron = (props) => {
|
|
21
24
|
const { direction, style } = props;
|
|
22
25
|
const rotate = getRotate(direction);
|
|
23
26
|
|
|
@@ -25,7 +28,7 @@ export const Chevron = props => {
|
|
|
25
28
|
<ChevronRight
|
|
26
29
|
style={{
|
|
27
30
|
transform: `rotate(${rotate}deg)`,
|
|
28
|
-
...style
|
|
31
|
+
...style,
|
|
29
32
|
}}
|
|
30
33
|
/>
|
|
31
34
|
);
|
|
@@ -33,7 +36,7 @@ export const Chevron = props => {
|
|
|
33
36
|
|
|
34
37
|
Chevron.propTypes = {
|
|
35
38
|
direction: PropTypes.string,
|
|
36
|
-
style: PropTypes.object
|
|
39
|
+
style: PropTypes.object,
|
|
37
40
|
};
|
|
38
41
|
|
|
39
42
|
export const GripIcon = ({ style }) => {
|
|
@@ -41,7 +44,7 @@ export const GripIcon = ({ style }) => {
|
|
|
41
44
|
<span style={style}>
|
|
42
45
|
<MoreVert
|
|
43
46
|
style={{
|
|
44
|
-
margin: '0 -16px'
|
|
47
|
+
margin: '0 -16px',
|
|
45
48
|
}}
|
|
46
49
|
/>
|
|
47
50
|
<MoreVert />
|
|
@@ -50,19 +53,19 @@ export const GripIcon = ({ style }) => {
|
|
|
50
53
|
};
|
|
51
54
|
|
|
52
55
|
GripIcon.propTypes = {
|
|
53
|
-
style: PropTypes.object
|
|
56
|
+
style: PropTypes.object,
|
|
54
57
|
};
|
|
55
58
|
|
|
56
|
-
export const ToolbarIcon = withStyles({
|
|
59
|
+
export const ToolbarIcon = withStyles((theme) => ({
|
|
57
60
|
icon: {
|
|
58
61
|
fontFamily: 'Cerebri Sans !important',
|
|
59
|
-
fontSize:
|
|
62
|
+
fontSize: theme.typography.fontSize,
|
|
60
63
|
fontWeight: 'bold',
|
|
61
64
|
lineHeight: '14px',
|
|
62
65
|
position: 'relative',
|
|
63
66
|
top: '7px',
|
|
64
67
|
width: '110px',
|
|
65
68
|
height: '28px',
|
|
66
|
-
whiteSpace: 'nowrap'
|
|
67
|
-
}
|
|
68
|
-
})(({ classes }) => <div className={classes.icon}>+ Response Area</div>);
|
|
69
|
+
whiteSpace: 'nowrap',
|
|
70
|
+
},
|
|
71
|
+
}))(({ classes }) => <div className={classes.icon}>+ Response Area</div>);
|
|
@@ -18,17 +18,17 @@ const lastIndexMap = {};
|
|
|
18
18
|
const elTypesMap = {
|
|
19
19
|
'inline-dropdown': 'inline_dropdown',
|
|
20
20
|
'explicit-constructed-response': 'explicit_constructed_response',
|
|
21
|
-
'drag-in-the-blank': 'drag_in_the_blank'
|
|
21
|
+
'drag-in-the-blank': 'drag_in_the_blank',
|
|
22
22
|
};
|
|
23
23
|
const elTypesArray = Object.values(elTypesMap);
|
|
24
24
|
|
|
25
25
|
export default function ResponseAreaPlugin(opts) {
|
|
26
|
-
const isOfCurrentType = d => d.type === opts.type || d.type === elTypesMap[opts.type];
|
|
26
|
+
const isOfCurrentType = (d) => d.type === opts.type || d.type === elTypesMap[opts.type];
|
|
27
27
|
|
|
28
28
|
const toolbar = {
|
|
29
29
|
icon: <ToolbarIcon />,
|
|
30
30
|
buttonStyles: {
|
|
31
|
-
margin: '0 20px 0 auto'
|
|
31
|
+
margin: '0 20px 0 auto',
|
|
32
32
|
},
|
|
33
33
|
onClick: editor => {
|
|
34
34
|
log('[toolbar] onClick');
|
|
@@ -86,7 +86,7 @@ export default function ResponseAreaPlugin(opts) {
|
|
|
86
86
|
}
|
|
87
87
|
},
|
|
88
88
|
customToolbar: opts.respAreaToolbar,
|
|
89
|
-
showDone: false
|
|
89
|
+
showDone: false,
|
|
90
90
|
};
|
|
91
91
|
|
|
92
92
|
return {
|
|
@@ -166,7 +166,7 @@ export default function ResponseAreaPlugin(opts) {
|
|
|
166
166
|
return [];
|
|
167
167
|
}
|
|
168
168
|
|
|
169
|
-
return plugins.filter(p => p.name !== 'response_area');
|
|
169
|
+
return plugins.filter((p) => p.name !== 'response_area');
|
|
170
170
|
},
|
|
171
171
|
deleteNode: (e, node, nodePath, editor, onChange) => {
|
|
172
172
|
e.preventDefault();
|
|
@@ -229,12 +229,12 @@ export default function ResponseAreaPlugin(opts) {
|
|
|
229
229
|
},
|
|
230
230
|
onDrop(event, change, editor) {
|
|
231
231
|
const closestEl = event.target.closest('[data-key]');
|
|
232
|
-
const inline = editor.value.document.findDescendant(d => d.key === closestEl.dataset.key);
|
|
232
|
+
const inline = editor.value.document.findDescendant((d) => d.key === closestEl.dataset.key);
|
|
233
233
|
|
|
234
234
|
if (inline.type === 'drag_in_the_blank') {
|
|
235
235
|
return false;
|
|
236
236
|
}
|
|
237
|
-
}
|
|
237
|
+
},
|
|
238
238
|
};
|
|
239
239
|
}
|
|
240
240
|
|
|
@@ -281,13 +281,7 @@ export const serialization = {
|
|
|
281
281
|
case 'explicit_constructed_response': {
|
|
282
282
|
const data = object.data;
|
|
283
283
|
|
|
284
|
-
return
|
|
285
|
-
<span
|
|
286
|
-
data-type="explicit_constructed_response"
|
|
287
|
-
data-index={data.index}
|
|
288
|
-
data-value={data.value}
|
|
289
|
-
/>
|
|
290
|
-
);
|
|
284
|
+
return <span data-type="explicit_constructed_response" data-index={data.index} data-value={data.value} />;
|
|
291
285
|
}
|
|
292
286
|
case 'drag_in_the_blank': {
|
|
293
287
|
const data = object.data;
|
|
@@ -303,5 +297,5 @@ export const serialization = {
|
|
|
303
297
|
);
|
|
304
298
|
}
|
|
305
299
|
}
|
|
306
|
-
}
|
|
300
|
+
},
|
|
307
301
|
};
|
|
@@ -14,7 +14,7 @@ const InlineDropdown = ({ attributes, children, selectedItem }) => {
|
|
|
14
14
|
display: 'inline-flex',
|
|
15
15
|
height: '50px',
|
|
16
16
|
margin: '0 5px',
|
|
17
|
-
cursor: 'pointer'
|
|
17
|
+
cursor: 'pointer',
|
|
18
18
|
}}
|
|
19
19
|
>
|
|
20
20
|
<div
|
|
@@ -26,7 +26,7 @@ const InlineDropdown = ({ attributes, children, selectedItem }) => {
|
|
|
26
26
|
border: '1px solid #C0C3CF',
|
|
27
27
|
boxSizing: 'border-box',
|
|
28
28
|
borderRadius: '3px',
|
|
29
|
-
position: 'relative'
|
|
29
|
+
position: 'relative',
|
|
30
30
|
}}
|
|
31
31
|
>
|
|
32
32
|
{children}
|
|
@@ -37,10 +37,10 @@ const InlineDropdown = ({ attributes, children, selectedItem }) => {
|
|
|
37
37
|
padding: '0 25px 0 8px',
|
|
38
38
|
whiteSpace: 'nowrap',
|
|
39
39
|
textOverflow: 'ellipsis',
|
|
40
|
-
lineHeight: '35px'
|
|
40
|
+
lineHeight: '35px',
|
|
41
41
|
}}
|
|
42
42
|
dangerouslySetInnerHTML={{
|
|
43
|
-
__html: html
|
|
43
|
+
__html: html,
|
|
44
44
|
}}
|
|
45
45
|
/>
|
|
46
46
|
<Chevron
|
|
@@ -48,7 +48,7 @@ const InlineDropdown = ({ attributes, children, selectedItem }) => {
|
|
|
48
48
|
style={{
|
|
49
49
|
position: 'absolute',
|
|
50
50
|
top: '5px',
|
|
51
|
-
right: '5px'
|
|
51
|
+
right: '5px',
|
|
52
52
|
}}
|
|
53
53
|
/>
|
|
54
54
|
</div>
|
|
@@ -58,7 +58,7 @@ const InlineDropdown = ({ attributes, children, selectedItem }) => {
|
|
|
58
58
|
|
|
59
59
|
InlineDropdown.propTypes = {
|
|
60
60
|
attributes: PropTypes.object,
|
|
61
|
-
selectedItem: PropTypes.oneOfType([PropTypes.string, PropTypes.object])
|
|
61
|
+
selectedItem: PropTypes.oneOfType([PropTypes.string, PropTypes.object]),
|
|
62
62
|
};
|
|
63
63
|
|
|
64
64
|
export default InlineDropdown;
|
|
@@ -2,10 +2,12 @@ import React from 'react';
|
|
|
2
2
|
import ReactDOM from 'react-dom';
|
|
3
3
|
import Snackbar from '@material-ui/core/Snackbar';
|
|
4
4
|
|
|
5
|
-
export const
|
|
5
|
+
export const isNumber = (val) => !isNaN(parseFloat(val)) && isFinite(val);
|
|
6
|
+
|
|
7
|
+
export const insertSnackBar = (message) => {
|
|
6
8
|
const prevSnacks = document.querySelectorAll('.response-area-alert');
|
|
7
9
|
|
|
8
|
-
prevSnacks.forEach(s => s.remove());
|
|
10
|
+
prevSnacks.forEach((s) => s.remove());
|
|
9
11
|
|
|
10
12
|
const newEl = document.createElement('div');
|
|
11
13
|
|
|
@@ -16,7 +18,7 @@ export const insertSnackBar = message => {
|
|
|
16
18
|
anchorOrigin={{ vertical: 'top', horizontal: 'center' }}
|
|
17
19
|
open={true}
|
|
18
20
|
ContentProps={{
|
|
19
|
-
'aria-describedby': 'message-id'
|
|
21
|
+
'aria-describedby': 'message-id',
|
|
20
22
|
}}
|
|
21
23
|
message={<span id="message-id">{message}</span>}
|
|
22
24
|
/>
|
|
@@ -61,8 +63,10 @@ export const getDefaultElement = (opts, index) => {
|
|
|
61
63
|
switch (opts.type) {
|
|
62
64
|
case 'explicit-constructed-response':
|
|
63
65
|
return defaultECR(index);
|
|
66
|
+
|
|
64
67
|
case 'drag-in-the-blank':
|
|
65
68
|
return defaultDIB(opts, index);
|
|
69
|
+
|
|
66
70
|
default:
|
|
67
71
|
// inline-dropdown
|
|
68
72
|
return defaultIDD(index);
|
|
@@ -5,53 +5,47 @@ const styles = {
|
|
|
5
5
|
icon: {
|
|
6
6
|
fill: 'grey',
|
|
7
7
|
'&:hover': {
|
|
8
|
-
fill: 'black'
|
|
9
|
-
}
|
|
10
|
-
}
|
|
8
|
+
fill: 'black',
|
|
9
|
+
},
|
|
10
|
+
},
|
|
11
11
|
};
|
|
12
12
|
|
|
13
|
-
const SvgIcon = Component => {
|
|
14
|
-
return withStyles(styles)(props => (
|
|
15
|
-
<svg
|
|
16
|
-
xmlns="http://www.w3.org/2000/svg"
|
|
17
|
-
version="1.1"
|
|
18
|
-
width="24"
|
|
19
|
-
height="24"
|
|
20
|
-
viewBox="0 0 24 24"
|
|
21
|
-
>
|
|
13
|
+
const SvgIcon = (Component) => {
|
|
14
|
+
return withStyles(styles)((props) => (
|
|
15
|
+
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="24" height="24" viewBox="0 0 24 24">
|
|
22
16
|
<Component className={props.classes.icon} />
|
|
23
17
|
</svg>
|
|
24
18
|
));
|
|
25
19
|
};
|
|
26
|
-
export const AddRow = SvgIcon(props => (
|
|
20
|
+
export const AddRow = SvgIcon((props) => (
|
|
27
21
|
<path
|
|
28
22
|
{...props}
|
|
29
23
|
d="M22,10A2,2 0 0,1 20,12H4A2,2 0 0,1 2,10V3H4V5H8V3H10V5H14V3H16V5H20V3H22V10M4,10H8V7H4V10M10,10H14V7H10V10M20,10V7H16V10H20M11,14H13V17H16V19H13V22H11V19H8V17H11V14Z"
|
|
30
24
|
/>
|
|
31
25
|
));
|
|
32
26
|
|
|
33
|
-
export const RemoveRow = SvgIcon(props => (
|
|
27
|
+
export const RemoveRow = SvgIcon((props) => (
|
|
34
28
|
<path
|
|
35
29
|
{...props}
|
|
36
30
|
d="M9.41,13L12,15.59L14.59,13L16,14.41L13.41,17L16,19.59L14.59,21L12,18.41L9.41,21L8,19.59L10.59,17L8,14.41L9.41,13M22,9A2,2 0 0,1 20,11H4A2,2 0 0,1 2,9V6A2,2 0 0,1 4,4H20A2,2 0 0,1 22,6V9M4,9H8V6H4V9M10,9H14V6H10V9M16,9H20V6H16V9Z"
|
|
37
31
|
/>
|
|
38
32
|
));
|
|
39
33
|
|
|
40
|
-
export const AddColumn = SvgIcon(props => (
|
|
34
|
+
export const AddColumn = SvgIcon((props) => (
|
|
41
35
|
<path
|
|
42
36
|
{...props}
|
|
43
37
|
d="M11,2A2,2 0 0,1 13,4V20A2,2 0 0,1 11,22H2V2H11M4,10V14H11V10H4M4,16V20H11V16H4M4,4V8H11V4H4M15,11H18V8H20V11H23V13H20V16H18V13H15V11Z"
|
|
44
38
|
/>
|
|
45
39
|
));
|
|
46
40
|
|
|
47
|
-
export const RemoveColumn = SvgIcon(props => (
|
|
41
|
+
export const RemoveColumn = SvgIcon((props) => (
|
|
48
42
|
<path
|
|
49
43
|
{...props}
|
|
50
44
|
d="M4,2H11A2,2 0 0,1 13,4V20A2,2 0 0,1 11,22H4A2,2 0 0,1 2,20V4A2,2 0 0,1 4,2M4,10V14H11V10H4M4,16V20H11V16H4M4,4V8H11V4H4M17.59,12L15,9.41L16.41,8L19,10.59L21.59,8L23,9.41L20.41,12L23,14.59L21.59,16L19,13.41L16.41,16L15,14.59L17.59,12Z"
|
|
51
45
|
/>
|
|
52
46
|
));
|
|
53
47
|
|
|
54
|
-
export const RemoveTable = SvgIcon(props => (
|
|
48
|
+
export const RemoveTable = SvgIcon((props) => (
|
|
55
49
|
<path
|
|
56
50
|
{...props}
|
|
57
51
|
d="M15.46,15.88L16.88,14.46L19,16.59L21.12,14.46L22.54,15.88L20.41,18L22.54,20.12L21.12,21.54L19,19.41L16.88,21.54L15.46,20.12L17.59,18L15.46,15.88M4,3H18A2,2 0 0,1 20,5V12.08C18.45,11.82 16.92,12.18 15.68,13H12V17H13.08C12.97,17.68 12.97,18.35 13.08,19H4A2,2 0 0,1 2,17V5A2,2 0 0,1 4,3M4,7V11H10V7H4M12,7V11H18V7H12M4,13V17H10V13H4Z"
|
|
@@ -44,7 +44,7 @@ TableRow.propTypes = {
|
|
|
44
44
|
attributes: PropTypes.object,
|
|
45
45
|
onFocus: PropTypes.func,
|
|
46
46
|
onBlur: PropTypes.func,
|
|
47
|
-
children: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.node), PropTypes.node]).isRequired
|
|
47
|
+
children: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.node), PropTypes.node]).isRequired,
|
|
48
48
|
};
|
|
49
49
|
|
|
50
50
|
const TableBody = React.forwardRef(props => <tbody {...props.attributes}>{props.children}</tbody>);
|
|
@@ -90,7 +90,7 @@ TableCell.propTypes = {
|
|
|
90
90
|
attributes: PropTypes.object,
|
|
91
91
|
onFocus: PropTypes.func,
|
|
92
92
|
onBlur: PropTypes.func,
|
|
93
|
-
children: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.node), PropTypes.node]).isRequired
|
|
93
|
+
children: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.node), PropTypes.node]).isRequired,
|
|
94
94
|
};
|
|
95
95
|
|
|
96
96
|
const getAncestorByType = (editor, type) => {
|
|
@@ -245,8 +245,8 @@ export default (opts, toolbarPlugins /* : {toolbar: {}}[] */) => {
|
|
|
245
245
|
const newTable = core.utils.createTableWithOptions(2, 2, {
|
|
246
246
|
data: {
|
|
247
247
|
border: '1',
|
|
248
|
-
newTable: true
|
|
249
|
-
}
|
|
248
|
+
newTable: true,
|
|
249
|
+
},
|
|
250
250
|
});
|
|
251
251
|
|
|
252
252
|
editor.insertNode(newTable);
|
|
@@ -399,7 +399,7 @@ export default (opts, toolbarPlugins /* : {toolbar: {}}[] */) => {
|
|
|
399
399
|
/>
|
|
400
400
|
);
|
|
401
401
|
return Tb;
|
|
402
|
-
}
|
|
402
|
+
},
|
|
403
403
|
};
|
|
404
404
|
|
|
405
405
|
core.supports = node => TABLE_TYPES.includes(node.type);
|
|
@@ -419,7 +419,7 @@ export default (opts, toolbarPlugins /* : {toolbar: {}}[] */) => {
|
|
|
419
419
|
}
|
|
420
420
|
};
|
|
421
421
|
Node.propTypes = {
|
|
422
|
-
node: PropTypes.object
|
|
422
|
+
node: PropTypes.object,
|
|
423
423
|
};
|
|
424
424
|
|
|
425
425
|
core.renderNode = Node;
|
|
@@ -427,7 +427,7 @@ export default (opts, toolbarPlugins /* : {toolbar: {}}[] */) => {
|
|
|
427
427
|
return core;
|
|
428
428
|
};
|
|
429
429
|
|
|
430
|
-
export const parseStyleString = s => {
|
|
430
|
+
export const parseStyleString = (s) => {
|
|
431
431
|
const regex = /([\w-]*)\s*:\s*([^;]*)/g;
|
|
432
432
|
let match;
|
|
433
433
|
const result = {};
|
|
@@ -437,9 +437,9 @@ export const parseStyleString = s => {
|
|
|
437
437
|
return result;
|
|
438
438
|
};
|
|
439
439
|
|
|
440
|
-
export const reactAttributes = o => toStyleObject(o, { camelize: true, addUnits: false });
|
|
440
|
+
export const reactAttributes = (o) => toStyleObject(o, { camelize: true, addUnits: false });
|
|
441
441
|
|
|
442
|
-
const attributesToMap = el => (acc, attribute) => {
|
|
442
|
+
const attributesToMap = (el) => (acc, attribute) => {
|
|
443
443
|
const value = el.getAttribute(attribute);
|
|
444
444
|
if (value) {
|
|
445
445
|
if (attribute === 'style') {
|
|
@@ -500,6 +500,7 @@ export const serialization = {
|
|
|
500
500
|
next(el.childNodes)
|
|
501
501
|
);
|
|
502
502
|
}
|
|
503
|
+
|
|
503
504
|
case 'th': {
|
|
504
505
|
return jsx(
|
|
505
506
|
'element',
|
|
@@ -510,6 +511,7 @@ export const serialization = {
|
|
|
510
511
|
next(el.childNodes)
|
|
511
512
|
);
|
|
512
513
|
}
|
|
514
|
+
|
|
513
515
|
case 'tr': {
|
|
514
516
|
return jsx(
|
|
515
517
|
'element',
|
|
@@ -519,6 +521,7 @@ export const serialization = {
|
|
|
519
521
|
next(Array.from(el.children))
|
|
520
522
|
);
|
|
521
523
|
}
|
|
524
|
+
|
|
522
525
|
case 'td': {
|
|
523
526
|
return jsx(
|
|
524
527
|
'element',
|
|
@@ -535,6 +538,7 @@ export const serialization = {
|
|
|
535
538
|
switch (object.type) {
|
|
536
539
|
case 'table': {
|
|
537
540
|
const attributes = dataToAttributes(object.data);
|
|
541
|
+
|
|
538
542
|
return (
|
|
539
543
|
<table {...attributes}>
|
|
540
544
|
{children}
|
|
@@ -556,5 +560,5 @@ export const serialization = {
|
|
|
556
560
|
return <th {...attributes}>{children}</th>;
|
|
557
561
|
}
|
|
558
562
|
}
|
|
559
|
-
}
|
|
563
|
+
},
|
|
560
564
|
};
|