@pie-lib/editable-html 9.2.6-next.4 → 9.2.7
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 +16 -0
- package/lib/editor.js.map +1 -1
- package/lib/index.js.map +1 -1
- package/lib/parse-html.js.map +1 -1
- package/lib/plugins/characters/custom-popper.js.map +1 -1
- package/lib/plugins/characters/index.js.map +1 -1
- package/lib/plugins/characters/utils.js.map +1 -1
- package/lib/plugins/image/alt-dialog.js.map +1 -1
- package/lib/plugins/image/component.js.map +1 -1
- package/lib/plugins/image/image-toolbar.js.map +1 -1
- package/lib/plugins/image/index.js.map +1 -1
- package/lib/plugins/index.js.map +1 -1
- package/lib/plugins/list/index.js.map +1 -1
- package/lib/plugins/math/index.js +1 -1
- package/lib/plugins/math/index.js.map +1 -1
- package/lib/plugins/media/index.js.map +1 -1
- package/lib/plugins/media/media-dialog.js.map +1 -1
- package/lib/plugins/media/media-toolbar.js.map +1 -1
- package/lib/plugins/media/media-wrapper.js.map +1 -1
- package/lib/plugins/respArea/drag-in-the-blank/choice.js.map +1 -1
- package/lib/plugins/respArea/drag-in-the-blank/index.js.map +1 -1
- package/lib/plugins/respArea/explicit-constructed-response/index.js.map +1 -1
- package/lib/plugins/respArea/icons/index.js.map +1 -1
- package/lib/plugins/respArea/index.js.map +1 -1
- package/lib/plugins/respArea/inline-dropdown/index.js.map +1 -1
- package/lib/plugins/respArea/utils.js.map +1 -1
- package/lib/plugins/table/icons/index.js.map +1 -1
- package/lib/plugins/table/index.js.map +1 -1
- package/lib/plugins/table/table-toolbar.js.map +1 -1
- package/lib/plugins/toolbar/default-toolbar.js.map +1 -1
- package/lib/plugins/toolbar/done-button.js.map +1 -1
- package/lib/plugins/toolbar/editor-and-toolbar.js.map +1 -1
- package/lib/plugins/toolbar/index.js.map +1 -1
- package/lib/plugins/toolbar/toolbar-buttons.js.map +1 -1
- package/lib/plugins/toolbar/toolbar.js.map +1 -1
- package/lib/plugins/utils.js.map +1 -1
- package/lib/serialization.js.map +1 -1
- package/package.json +6 -6
- package/playground/image/data.js +20 -20
- package/playground/image/index.html +20 -22
- package/playground/image/index.jsx +7 -12
- package/playground/index.html +23 -25
- package/playground/mathquill/index.html +20 -23
- package/playground/mathquill/index.jsx +7 -18
- package/playground/prod-test/index.html +20 -24
- package/playground/prod-test/index.jsx +2 -5
- package/playground/schema-override/data.js +10 -10
- package/playground/schema-override/image-plugin.jsx +3 -3
- package/playground/schema-override/index.html +19 -21
- package/playground/schema-override/index.jsx +12 -12
- package/playground/serialization/data.js +10 -10
- package/playground/serialization/image-plugin.jsx +3 -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 +77 -101
- package/src/index.jsx +11 -18
- package/src/parse-html.js +1 -1
- package/src/plugins/characters/custom-popper.js +7 -7
- package/src/plugins/characters/index.jsx +19 -25
- package/src/plugins/characters/utils.js +81 -81
- package/src/plugins/image/alt-dialog.jsx +3 -3
- package/src/plugins/image/component.jsx +42 -46
- package/src/plugins/image/image-toolbar.jsx +14 -26
- package/src/plugins/image/index.jsx +21 -23
- package/src/plugins/index.jsx +10 -12
- package/src/plugins/list/index.jsx +10 -10
- package/src/plugins/math/index.jsx +28 -31
- package/src/plugins/media/index.jsx +21 -21
- package/src/plugins/media/media-dialog.js +60 -86
- package/src/plugins/media/media-toolbar.jsx +6 -6
- package/src/plugins/media/media-wrapper.jsx +6 -6
- package/src/plugins/respArea/drag-in-the-blank/choice.jsx +19 -21
- package/src/plugins/respArea/drag-in-the-blank/index.jsx +10 -12
- package/src/plugins/respArea/explicit-constructed-response/index.jsx +5 -5
- package/src/plugins/respArea/icons/index.jsx +8 -8
- package/src/plugins/respArea/index.jsx +21 -31
- package/src/plugins/respArea/inline-dropdown/index.jsx +6 -6
- package/src/plugins/respArea/utils.jsx +12 -12
- package/src/plugins/table/icons/index.jsx +11 -17
- package/src/plugins/table/index.jsx +43 -49
- package/src/plugins/table/table-toolbar.jsx +8 -13
- package/src/plugins/toolbar/default-toolbar.jsx +11 -19
- package/src/plugins/toolbar/done-button.jsx +4 -4
- package/src/plugins/toolbar/editor-and-toolbar.jsx +39 -47
- package/src/plugins/toolbar/index.jsx +2 -2
- package/src/plugins/toolbar/toolbar-buttons.jsx +11 -11
- package/src/plugins/toolbar/toolbar.jsx +34 -47
- package/src/plugins/utils.js +4 -5
- package/src/serialization.jsx +32 -32
package/src/index.jsx
CHANGED
|
@@ -18,7 +18,7 @@ export { htmlToValue, valueToHtml, Editor, DEFAULT_PLUGINS, ALL_PLUGINS };
|
|
|
18
18
|
* `markup` api whilst avoiding the serialization mismatch. We should be making better use of schemas w/ normalize.
|
|
19
19
|
*/
|
|
20
20
|
|
|
21
|
-
const reduceMultipleBrs = markup => {
|
|
21
|
+
const reduceMultipleBrs = (markup) => {
|
|
22
22
|
try {
|
|
23
23
|
return markup.replace(/(<br\s*\/?>){3,}/gi, '<br>');
|
|
24
24
|
} catch (e) {
|
|
@@ -33,19 +33,19 @@ export default class EditableHtml extends React.Component {
|
|
|
33
33
|
onChange: PropTypes.func.isRequired,
|
|
34
34
|
onDone: PropTypes.func,
|
|
35
35
|
markup: PropTypes.string.isRequired,
|
|
36
|
-
allowValidation: PropTypes.bool
|
|
36
|
+
allowValidation: PropTypes.bool,
|
|
37
37
|
};
|
|
38
38
|
|
|
39
39
|
static defaultProps = {
|
|
40
40
|
onDone: () => {},
|
|
41
|
-
allowValidation: false
|
|
41
|
+
allowValidation: false,
|
|
42
42
|
};
|
|
43
43
|
|
|
44
44
|
constructor(props) {
|
|
45
45
|
super(props);
|
|
46
46
|
const v = htmlToValue(props.markup);
|
|
47
47
|
this.state = {
|
|
48
|
-
value: v
|
|
48
|
+
value: v,
|
|
49
49
|
};
|
|
50
50
|
}
|
|
51
51
|
|
|
@@ -80,13 +80,9 @@ export default class EditableHtml extends React.Component {
|
|
|
80
80
|
|
|
81
81
|
focus = (position, node) => {
|
|
82
82
|
if (this.editorRef) {
|
|
83
|
-
this.editorRef.change(c => {
|
|
84
|
-
const lastText = node
|
|
85
|
-
|
|
86
|
-
: c.value.document.getLastText();
|
|
87
|
-
const editorDOM = document.querySelector(
|
|
88
|
-
`[data-key="${this.editorRef.value.document.key}"]`
|
|
89
|
-
);
|
|
83
|
+
this.editorRef.change((c) => {
|
|
84
|
+
const lastText = node ? c.value.document.getNextText(node.key) : c.value.document.getLastText();
|
|
85
|
+
const editorDOM = document.querySelector(`[data-key="${this.editorRef.value.document.key}"]`);
|
|
90
86
|
|
|
91
87
|
if (editorDOM !== document.activeElement) {
|
|
92
88
|
document.activeElement.blur();
|
|
@@ -95,10 +91,7 @@ export default class EditableHtml extends React.Component {
|
|
|
95
91
|
c.focus();
|
|
96
92
|
|
|
97
93
|
if (position === 'end' && lastText) {
|
|
98
|
-
c.moveFocusTo(lastText.key, lastText.text?.length).moveAnchorTo(
|
|
99
|
-
lastText.key,
|
|
100
|
-
lastText.text?.length
|
|
101
|
-
);
|
|
94
|
+
c.moveFocusTo(lastText.key, lastText.text?.length).moveAnchorTo(lastText.key, lastText.text?.length);
|
|
102
95
|
}
|
|
103
96
|
|
|
104
97
|
if (position === 'beginning' && lastText) {
|
|
@@ -127,17 +120,17 @@ export default class EditableHtml extends React.Component {
|
|
|
127
120
|
markup: null,
|
|
128
121
|
value,
|
|
129
122
|
onChange: this.onChange,
|
|
130
|
-
focus: this.focus
|
|
123
|
+
focus: this.focus,
|
|
131
124
|
};
|
|
132
125
|
|
|
133
126
|
return (
|
|
134
127
|
<Editor
|
|
135
|
-
onRef={ref => {
|
|
128
|
+
onRef={(ref) => {
|
|
136
129
|
if (ref) {
|
|
137
130
|
this.rootRef = ref;
|
|
138
131
|
}
|
|
139
132
|
}}
|
|
140
|
-
editorRef={ref => ref && (this.editorRef = ref)}
|
|
133
|
+
editorRef={(ref) => ref && (this.editorRef = ref)}
|
|
141
134
|
{...props}
|
|
142
135
|
/>
|
|
143
136
|
);
|
package/src/parse-html.js
CHANGED
|
@@ -8,17 +8,17 @@ const styles = () => ({
|
|
|
8
8
|
background: '#fff',
|
|
9
9
|
padding: '10px',
|
|
10
10
|
pointerEvents: 'none',
|
|
11
|
-
zIndex: 99999
|
|
11
|
+
zIndex: 99999,
|
|
12
12
|
},
|
|
13
13
|
paper: {
|
|
14
14
|
padding: 20,
|
|
15
15
|
height: 'auto',
|
|
16
|
-
width: 'auto'
|
|
16
|
+
width: 'auto',
|
|
17
17
|
},
|
|
18
18
|
typography: {
|
|
19
19
|
fontSize: 50,
|
|
20
|
-
textAlign: 'center'
|
|
21
|
-
}
|
|
20
|
+
textAlign: 'center',
|
|
21
|
+
},
|
|
22
22
|
});
|
|
23
23
|
|
|
24
24
|
const CustomPopper = withStyles(styles)(({ classes, children, ...props }) => (
|
|
@@ -27,15 +27,15 @@ const CustomPopper = withStyles(styles)(({ classes, children, ...props }) => (
|
|
|
27
27
|
open
|
|
28
28
|
className={classes.popover}
|
|
29
29
|
classes={{
|
|
30
|
-
paper: classes.paper
|
|
30
|
+
paper: classes.paper,
|
|
31
31
|
}}
|
|
32
32
|
anchorOrigin={{
|
|
33
33
|
vertical: 'bottom',
|
|
34
|
-
horizontal: 'left'
|
|
34
|
+
horizontal: 'left',
|
|
35
35
|
}}
|
|
36
36
|
transformOrigin={{
|
|
37
37
|
vertical: 'top',
|
|
38
|
-
horizontal: 'left'
|
|
38
|
+
horizontal: 'left',
|
|
39
39
|
}}
|
|
40
40
|
disableRestoreFocus
|
|
41
41
|
disableAutoFocus
|
|
@@ -14,14 +14,14 @@ const removePopOvers = () => {
|
|
|
14
14
|
const prevPopOvers = document.querySelectorAll('#mouse-over-popover');
|
|
15
15
|
|
|
16
16
|
log('[characters:removePopOvers]');
|
|
17
|
-
prevPopOvers.forEach(s => s.remove());
|
|
17
|
+
prevPopOvers.forEach((s) => s.remove());
|
|
18
18
|
};
|
|
19
19
|
|
|
20
20
|
export const removeDialogs = () => {
|
|
21
21
|
const prevDialogs = document.querySelectorAll('.insert-character-dialog');
|
|
22
22
|
|
|
23
23
|
log('[characters:removeDialogs]');
|
|
24
|
-
prevDialogs.forEach(s => s.remove());
|
|
24
|
+
prevDialogs.forEach((s) => s.remove());
|
|
25
25
|
removePopOvers();
|
|
26
26
|
};
|
|
27
27
|
|
|
@@ -60,7 +60,7 @@ const insertDialog = ({ editorDOM, value, callback, opts }) => {
|
|
|
60
60
|
|
|
61
61
|
return obj;
|
|
62
62
|
},
|
|
63
|
-
{ rows: configToUse.characters.length, columns: 0 }
|
|
63
|
+
{ rows: configToUse.characters.length, columns: 0 },
|
|
64
64
|
);
|
|
65
65
|
|
|
66
66
|
let popoverEl;
|
|
@@ -91,7 +91,7 @@ const insertDialog = ({ editorDOM, value, callback, opts }) => {
|
|
|
91
91
|
|
|
92
92
|
<div style={infoStyle}>{el.unicode}</div>
|
|
93
93
|
</CustomPopper>,
|
|
94
|
-
popoverEl
|
|
94
|
+
popoverEl,
|
|
95
95
|
);
|
|
96
96
|
|
|
97
97
|
document.body.appendChild(newEl);
|
|
@@ -99,13 +99,12 @@ const insertDialog = ({ editorDOM, value, callback, opts }) => {
|
|
|
99
99
|
|
|
100
100
|
let firstCallMade = false;
|
|
101
101
|
|
|
102
|
-
const listener = e => {
|
|
102
|
+
const listener = (e) => {
|
|
103
103
|
// this will be triggered right after setting it because
|
|
104
104
|
// this toolbar is added on the mousedown event
|
|
105
105
|
// so right after mouseup, the click will be triggered
|
|
106
106
|
if (firstCallMade) {
|
|
107
|
-
const focusIsInModals =
|
|
108
|
-
newEl.contains(e.target) || (popoverEl && popoverEl.contains(e.target));
|
|
107
|
+
const focusIsInModals = newEl.contains(e.target) || (popoverEl && popoverEl.contains(e.target));
|
|
109
108
|
const focusIsInEditor = editorDOM.contains(e.target);
|
|
110
109
|
|
|
111
110
|
if (!(focusIsInModals || focusIsInEditor)) {
|
|
@@ -123,7 +122,7 @@ const insertDialog = ({ editorDOM, value, callback, opts }) => {
|
|
|
123
122
|
document.body.removeEventListener('click', listener);
|
|
124
123
|
};
|
|
125
124
|
|
|
126
|
-
const handleChange = val => {
|
|
125
|
+
const handleChange = (val) => {
|
|
127
126
|
if (typeof val === 'string') {
|
|
128
127
|
callback(val, true);
|
|
129
128
|
}
|
|
@@ -139,7 +138,7 @@ const insertDialog = ({ editorDOM, value, callback, opts }) => {
|
|
|
139
138
|
additionalKeys={configToUse.characters.reduce((arr, n) => {
|
|
140
139
|
arr = [
|
|
141
140
|
...arr,
|
|
142
|
-
...n.map(k => ({
|
|
141
|
+
...n.map((k) => ({
|
|
143
142
|
name: get(k, 'name') || k,
|
|
144
143
|
write: get(k, 'write') || k,
|
|
145
144
|
label: get(k, 'label') || k,
|
|
@@ -149,15 +148,15 @@ const insertDialog = ({ editorDOM, value, callback, opts }) => {
|
|
|
149
148
|
...(k.extraProps || {}),
|
|
150
149
|
style: {
|
|
151
150
|
...(k.extraProps || {}).style,
|
|
152
|
-
border: '1px solid #000'
|
|
153
|
-
}
|
|
151
|
+
border: '1px solid #000',
|
|
152
|
+
},
|
|
154
153
|
},
|
|
155
154
|
...(configToUse.hasPreview
|
|
156
155
|
? {
|
|
157
|
-
actions: { onMouseEnter: ev => renderPopOver(ev, k), onMouseLeave: closePopOver }
|
|
156
|
+
actions: { onMouseEnter: (ev) => renderPopOver(ev, k), onMouseLeave: closePopOver },
|
|
158
157
|
}
|
|
159
|
-
: {})
|
|
160
|
-
}))
|
|
158
|
+
: {}),
|
|
159
|
+
})),
|
|
161
160
|
];
|
|
162
161
|
|
|
163
162
|
return arr;
|
|
@@ -180,10 +179,7 @@ const insertDialog = ({ editorDOM, value, callback, opts }) => {
|
|
|
180
179
|
newEl.style.top = `${boundRect.top + Math.abs(bodyRect.top) - newEl.offsetHeight - 10}px`;
|
|
181
180
|
newEl.style.zIndex = 99999;
|
|
182
181
|
|
|
183
|
-
const leftValue = `${boundRect.left +
|
|
184
|
-
Math.abs(bodyRect.left) +
|
|
185
|
-
cursorItem.offsetWidth +
|
|
186
|
-
10}px`;
|
|
182
|
+
const leftValue = `${boundRect.left + Math.abs(bodyRect.left) + cursorItem.offsetWidth + 10}px`;
|
|
187
183
|
|
|
188
184
|
const rightValue = `${boundRect.x}px`;
|
|
189
185
|
|
|
@@ -214,7 +210,7 @@ const CharacterIcon = ({ letter }) => (
|
|
|
214
210
|
<div
|
|
215
211
|
style={{
|
|
216
212
|
fontSize: '25px',
|
|
217
|
-
lineHeight: '15px'
|
|
213
|
+
lineHeight: '15px',
|
|
218
214
|
}}
|
|
219
215
|
>
|
|
220
216
|
{letter}
|
|
@@ -234,9 +230,7 @@ export default function CharactersPlugin(opts) {
|
|
|
234
230
|
valueToUse = getFocusedValue();
|
|
235
231
|
|
|
236
232
|
if (char) {
|
|
237
|
-
const change = valueToUse
|
|
238
|
-
.change()
|
|
239
|
-
.insertTextByKey(valueToUse.anchorKey, valueToUse.anchorOffset, char);
|
|
233
|
+
const change = valueToUse.change().insertTextByKey(valueToUse.anchorKey, valueToUse.anchorOffset, char);
|
|
240
234
|
|
|
241
235
|
valueToUse = change.value;
|
|
242
236
|
log('[characters:insert]: ', value);
|
|
@@ -253,16 +247,16 @@ export default function CharactersPlugin(opts) {
|
|
|
253
247
|
};
|
|
254
248
|
|
|
255
249
|
insertDialog({ editorDOM, value: valueToUse, callback, opts });
|
|
256
|
-
}
|
|
250
|
+
},
|
|
257
251
|
},
|
|
258
252
|
|
|
259
253
|
pluginStyles: (node, parentNode, p) => {
|
|
260
254
|
if (p) {
|
|
261
255
|
return {
|
|
262
256
|
position: 'absolute',
|
|
263
|
-
top: 'initial'
|
|
257
|
+
top: 'initial',
|
|
264
258
|
};
|
|
265
259
|
}
|
|
266
|
-
}
|
|
260
|
+
},
|
|
267
261
|
};
|
|
268
262
|
}
|