@pie-lib/editable-html 10.0.0-beta.6 → 10.0.0-beta.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/package.json +1 -1
- package/src/components.js +7 -7
- package/src/editor.jsx +36 -51
- package/src/index.jsx +4 -4
- package/src/new-serialization.jsx +22 -22
- package/src/plugins/characters/index.jsx +2 -3
- package/src/plugins/hotKeys/index.js +3 -3
- package/src/plugins/image/component.jsx +5 -9
- package/src/plugins/image/index.jsx +17 -29
- package/src/plugins/image/insert-image-handler.js +14 -14
- package/src/plugins/index.jsx +1 -1
- package/src/plugins/list/index.jsx +14 -17
- package/src/plugins/math/index.jsx +24 -14
- package/src/plugins/media/index.jsx +35 -35
- package/src/plugins/media/media-wrapper.jsx +2 -2
- package/src/plugins/respArea/drag-in-the-blank/index.jsx +6 -8
- package/src/plugins/respArea/explicit-constructed-response/index.jsx +1 -1
- package/src/plugins/respArea/index.jsx +23 -41
- package/src/plugins/respArea/utils.jsx +8 -8
- package/src/plugins/table/index.jsx +55 -59
- package/src/plugins/table/table-toolbar.jsx +2 -7
- package/src/plugins/toolbar/default-toolbar.jsx +7 -9
- package/src/plugins/toolbar/editor-and-toolbar.jsx +14 -21
- package/src/plugins/toolbar/toolbar.jsx +37 -41
- package/src/plugins/utils.js +5 -6
- package/src/test-serializer.js +13 -13
package/package.json
CHANGED
package/src/components.js
CHANGED
|
@@ -12,14 +12,14 @@ export const Button = React.forwardRef(({ className, active, reversed, ...props
|
|
|
12
12
|
cursor: pointer;
|
|
13
13
|
|
|
14
14
|
color: ${reversed ? (active ? 'white' : '#aaa') : active ? 'black' : '#ccc'};
|
|
15
|
-
|
|
15
|
+
`,
|
|
16
16
|
)}
|
|
17
17
|
/>
|
|
18
18
|
));
|
|
19
19
|
|
|
20
20
|
export const EditorValue = React.forwardRef(({ className, value, ...props }, ref) => {
|
|
21
21
|
const textLines = value.document.nodes
|
|
22
|
-
.map(node => node.text)
|
|
22
|
+
.map((node) => node.text)
|
|
23
23
|
.toArray()
|
|
24
24
|
.join('\n');
|
|
25
25
|
return (
|
|
@@ -30,7 +30,7 @@ export const EditorValue = React.forwardRef(({ className, value, ...props }, ref
|
|
|
30
30
|
className,
|
|
31
31
|
css`
|
|
32
32
|
margin: 30px -20px 0;
|
|
33
|
-
|
|
33
|
+
`,
|
|
34
34
|
)}
|
|
35
35
|
>
|
|
36
36
|
<div
|
|
@@ -72,7 +72,7 @@ export const Icon = React.forwardRef(({ className, ...props }, ref) => (
|
|
|
72
72
|
css`
|
|
73
73
|
font-size: 18px;
|
|
74
74
|
vertical-align: text-bottom;
|
|
75
|
-
|
|
75
|
+
`,
|
|
76
76
|
)}
|
|
77
77
|
/>
|
|
78
78
|
));
|
|
@@ -89,7 +89,7 @@ export const Instruction = React.forwardRef(({ className, ...props }, ref) => (
|
|
|
89
89
|
padding: 10px 20px;
|
|
90
90
|
font-size: 14px;
|
|
91
91
|
background: #f8f8e8;
|
|
92
|
-
|
|
92
|
+
`,
|
|
93
93
|
)}
|
|
94
94
|
/>
|
|
95
95
|
));
|
|
@@ -108,7 +108,7 @@ export const Menu = React.forwardRef(({ className, ...props }, ref) => (
|
|
|
108
108
|
& > * + * {
|
|
109
109
|
margin-left: 15px;
|
|
110
110
|
}
|
|
111
|
-
|
|
111
|
+
`,
|
|
112
112
|
)}
|
|
113
113
|
/>
|
|
114
114
|
));
|
|
@@ -129,7 +129,7 @@ export const Toolbar = React.forwardRef(({ className, ...props }, ref) => (
|
|
|
129
129
|
margin: 0 -20px;
|
|
130
130
|
border-bottom: 2px solid #eee;
|
|
131
131
|
margin-bottom: 20px;
|
|
132
|
-
|
|
132
|
+
`,
|
|
133
133
|
)}
|
|
134
134
|
/>
|
|
135
135
|
));
|
package/src/editor.jsx
CHANGED
|
@@ -1,10 +1,5 @@
|
|
|
1
1
|
import React, { useCallback, useMemo, useRef, useState, useEffect } from 'react';
|
|
2
|
-
import {
|
|
3
|
-
Editor as OldSlateEditor,
|
|
4
|
-
findNode,
|
|
5
|
-
getEventRange,
|
|
6
|
-
getEventTransfer,
|
|
7
|
-
} from 'slate-react';
|
|
2
|
+
import { Editor as OldSlateEditor, findNode, getEventRange, getEventTransfer } from 'slate-react';
|
|
8
3
|
import RootRef from '@material-ui/core/RootRef';
|
|
9
4
|
|
|
10
5
|
import isEqual from 'lodash/isEqual';
|
|
@@ -37,7 +32,7 @@ const HOTKEYS = {
|
|
|
37
32
|
'mod+b': 'bold',
|
|
38
33
|
'mod+i': 'italic',
|
|
39
34
|
'mod+u': 'underline',
|
|
40
|
-
'mod+`': 'code'
|
|
35
|
+
'mod+`': 'code',
|
|
41
36
|
};
|
|
42
37
|
|
|
43
38
|
const LIST_TYPES = ['numbered-list', 'bulleted-list'];
|
|
@@ -51,23 +46,23 @@ const initialValue = [
|
|
|
51
46
|
type: 'math',
|
|
52
47
|
data: {
|
|
53
48
|
latex: '\\frac{1}{2}',
|
|
54
|
-
wrapper: 'round_brackets'
|
|
49
|
+
wrapper: 'round_brackets',
|
|
55
50
|
},
|
|
56
51
|
children: [
|
|
57
52
|
{
|
|
58
|
-
text: '\\(\\frac{1}{2}\\)'
|
|
59
|
-
}
|
|
60
|
-
]
|
|
61
|
-
}
|
|
62
|
-
]
|
|
63
|
-
}
|
|
53
|
+
text: '\\(\\frac{1}{2}\\)',
|
|
54
|
+
},
|
|
55
|
+
],
|
|
56
|
+
},
|
|
57
|
+
],
|
|
58
|
+
},
|
|
64
59
|
];
|
|
65
60
|
|
|
66
|
-
const SlateEditor = editorProps => {
|
|
61
|
+
const SlateEditor = (editorProps) => {
|
|
67
62
|
const mounted = useRef(false);
|
|
68
63
|
const { autoFocus, value, plugins, actionsRef, onEditingDone } = editorProps;
|
|
69
|
-
const renderElement = useCallback(props => <Element {...props} plugins={plugins} />, []);
|
|
70
|
-
const renderLeaf = useCallback(props => <Leaf {...props} />, []);
|
|
64
|
+
const renderElement = useCallback((props) => <Element {...props} plugins={plugins} />, []);
|
|
65
|
+
const renderLeaf = useCallback((props) => <Leaf {...props} />, []);
|
|
71
66
|
const editor = useMemo(() => withPlugins(createEditor(), plugins), []);
|
|
72
67
|
const [isFocused, setIsFocused] = useState(false);
|
|
73
68
|
const editorRef = useRef(null);
|
|
@@ -108,7 +103,7 @@ const SlateEditor = editorProps => {
|
|
|
108
103
|
|
|
109
104
|
window.editor = editor;
|
|
110
105
|
|
|
111
|
-
const onKeyDown = event => {
|
|
106
|
+
const onKeyDown = (event) => {
|
|
112
107
|
if (event.key === 'Enter' && event.shiftKey === true) {
|
|
113
108
|
editor.insertText('\n');
|
|
114
109
|
event.preventDefault();
|
|
@@ -124,7 +119,7 @@ const SlateEditor = editorProps => {
|
|
|
124
119
|
}
|
|
125
120
|
};
|
|
126
121
|
const onFocus = () => setIsFocused(true);
|
|
127
|
-
const onBlur = e => {
|
|
122
|
+
const onBlur = (e) => {
|
|
128
123
|
setTimeout(() => {
|
|
129
124
|
if (!editorRef.current || !editorRef.current.contains(document.activeElement)) {
|
|
130
125
|
if (editorProps.onBlur) {
|
|
@@ -154,7 +149,7 @@ const SlateEditor = editorProps => {
|
|
|
154
149
|
if (typeof onEditingDone === 'function') {
|
|
155
150
|
onEditingDone(editor);
|
|
156
151
|
}
|
|
157
|
-
}
|
|
152
|
+
},
|
|
158
153
|
};
|
|
159
154
|
|
|
160
155
|
if (actionsRef) {
|
|
@@ -190,29 +185,25 @@ const SlateEditor = editorProps => {
|
|
|
190
185
|
};
|
|
191
186
|
|
|
192
187
|
const toggleBlock = (editor, format) => {
|
|
193
|
-
const isActive = isBlockActive(
|
|
194
|
-
editor,
|
|
195
|
-
format,
|
|
196
|
-
TEXT_ALIGN_TYPES.includes(format) ? 'align' : 'type'
|
|
197
|
-
);
|
|
188
|
+
const isActive = isBlockActive(editor, format, TEXT_ALIGN_TYPES.includes(format) ? 'align' : 'type');
|
|
198
189
|
const isList = LIST_TYPES.includes(format);
|
|
199
190
|
|
|
200
191
|
Transforms.unwrapNodes(editor, {
|
|
201
|
-
match: n =>
|
|
192
|
+
match: (n) =>
|
|
202
193
|
!Editor.isEditor(n) &&
|
|
203
194
|
SlateElement.isElement(n) &&
|
|
204
195
|
LIST_TYPES.includes(n.type) &&
|
|
205
196
|
!TEXT_ALIGN_TYPES.includes(format),
|
|
206
|
-
split: true
|
|
197
|
+
split: true,
|
|
207
198
|
});
|
|
208
199
|
let newProperties;
|
|
209
200
|
if (TEXT_ALIGN_TYPES.includes(format)) {
|
|
210
201
|
newProperties = {
|
|
211
|
-
align: isActive ? undefined : format
|
|
202
|
+
align: isActive ? undefined : format,
|
|
212
203
|
};
|
|
213
204
|
} else {
|
|
214
205
|
newProperties = {
|
|
215
|
-
type: isActive ? 'paragraph' : isList ? 'list_item' : format
|
|
206
|
+
type: isActive ? 'paragraph' : isList ? 'list_item' : format,
|
|
216
207
|
};
|
|
217
208
|
}
|
|
218
209
|
Transforms.setNodes(editor, newProperties);
|
|
@@ -240,8 +231,8 @@ const isBlockActive = (editor, format, blockType = 'type') => {
|
|
|
240
231
|
const [match] = Array.from(
|
|
241
232
|
Editor.nodes(editor, {
|
|
242
233
|
at: Editor.unhangRange(editor, selection),
|
|
243
|
-
match: n => !Editor.isEditor(n) && SlateElement.isElement(n) && n[blockType] === format
|
|
244
|
-
})
|
|
234
|
+
match: (n) => !Editor.isEditor(n) && SlateElement.isElement(n) && n[blockType] === format,
|
|
235
|
+
}),
|
|
245
236
|
);
|
|
246
237
|
|
|
247
238
|
return !!match;
|
|
@@ -252,16 +243,14 @@ const isMarkActive = (editor, format) => {
|
|
|
252
243
|
return marks ? marks[format] === true : false;
|
|
253
244
|
};
|
|
254
245
|
|
|
255
|
-
const Element = props => {
|
|
246
|
+
const Element = (props) => {
|
|
256
247
|
const editor = useSlateStatic();
|
|
257
248
|
const focused = useFocused();
|
|
258
249
|
const { attributes, children, element, plugins } = props;
|
|
259
250
|
const style = { textAlign: element.align };
|
|
260
251
|
|
|
261
252
|
const nodeProps = { ...attributes, ...props, node: { ...element }, children };
|
|
262
|
-
const pluginToRender = plugins.find(
|
|
263
|
-
plugin => typeof plugin.supports === 'function' && plugin.supports(element)
|
|
264
|
-
);
|
|
253
|
+
const pluginToRender = plugins.find((plugin) => typeof plugin.supports === 'function' && plugin.supports(element));
|
|
265
254
|
|
|
266
255
|
if (pluginToRender) {
|
|
267
256
|
return pluginToRender.renderNode({ ...nodeProps, editor, focused });
|
|
@@ -309,7 +298,7 @@ const Element = props => {
|
|
|
309
298
|
<div
|
|
310
299
|
style={{
|
|
311
300
|
...style,
|
|
312
|
-
margin: 0
|
|
301
|
+
margin: 0,
|
|
313
302
|
}}
|
|
314
303
|
{...attributes}
|
|
315
304
|
>
|
|
@@ -348,7 +337,7 @@ const BlockButton = ({ format, icon }) => {
|
|
|
348
337
|
return (
|
|
349
338
|
<Button
|
|
350
339
|
active={isBlockActive(editor, format, TEXT_ALIGN_TYPES.includes(format) ? 'align' : 'type')}
|
|
351
|
-
onMouseDown={event => {
|
|
340
|
+
onMouseDown={(event) => {
|
|
352
341
|
event.preventDefault();
|
|
353
342
|
toggleBlock(editor, format);
|
|
354
343
|
}}
|
|
@@ -363,7 +352,7 @@ const MarkButton = ({ format, icon }) => {
|
|
|
363
352
|
return (
|
|
364
353
|
<Button
|
|
365
354
|
active={isMarkActive(editor, format)}
|
|
366
|
-
onMouseDown={event => {
|
|
355
|
+
onMouseDown={(event) => {
|
|
367
356
|
event.preventDefault();
|
|
368
357
|
toggleMark(editor, format);
|
|
369
358
|
}}
|
|
@@ -417,8 +406,8 @@ export class EditorComponent extends React.Component {
|
|
|
417
406
|
PropTypes.shape({
|
|
418
407
|
type: PropTypes.string,
|
|
419
408
|
children: PropTypes.array,
|
|
420
|
-
data: PropTypes.object
|
|
421
|
-
})
|
|
409
|
+
data: PropTypes.object,
|
|
410
|
+
}),
|
|
422
411
|
),
|
|
423
412
|
imageSupport: PropTypes.object,
|
|
424
413
|
mathMlOptions: PropTypes.shape({
|
|
@@ -673,14 +662,14 @@ export class EditorComponent extends React.Component {
|
|
|
673
662
|
this.setState({ selectedNode: node });
|
|
674
663
|
};
|
|
675
664
|
|
|
676
|
-
onEditingDone = editor => {
|
|
665
|
+
onEditingDone = (editor) => {
|
|
677
666
|
log('[onEditingDone]');
|
|
678
667
|
// this.setState({ stashedValue: null, focusedNode: null });
|
|
679
668
|
log('[onEditingDone] value: ', this.state.value);
|
|
680
669
|
this.props.onChange(editor, true);
|
|
681
670
|
};
|
|
682
671
|
|
|
683
|
-
onDone = editor => {
|
|
672
|
+
onDone = (editor) => {
|
|
684
673
|
const { nonEmpty } = this.props;
|
|
685
674
|
|
|
686
675
|
log('[onDone]');
|
|
@@ -1078,14 +1067,14 @@ export class EditorComponent extends React.Component {
|
|
|
1078
1067
|
spellCheck={spellCheck}
|
|
1079
1068
|
className={classNames(
|
|
1080
1069
|
{
|
|
1081
|
-
[classes.noPadding]: toolbarOpts && toolbarOpts.noBorder
|
|
1070
|
+
[classes.noPadding]: toolbarOpts && toolbarOpts.noBorder,
|
|
1082
1071
|
},
|
|
1083
|
-
classes.slateEditor
|
|
1072
|
+
classes.slateEditor,
|
|
1084
1073
|
)}
|
|
1085
1074
|
style={{
|
|
1086
1075
|
minHeight: sizeStyle.minHeight,
|
|
1087
1076
|
height: sizeStyle.height,
|
|
1088
|
-
maxHeight: sizeStyle.maxHeight
|
|
1077
|
+
maxHeight: sizeStyle.maxHeight,
|
|
1089
1078
|
}}
|
|
1090
1079
|
pluginProps={pluginProps}
|
|
1091
1080
|
toolbarOpts={toolbarOpts}
|
|
@@ -1096,14 +1085,10 @@ export class EditorComponent extends React.Component {
|
|
|
1096
1085
|
);
|
|
1097
1086
|
|
|
1098
1087
|
return (
|
|
1099
|
-
<div
|
|
1100
|
-
ref={ref => (this.wrapperRef = ref)}
|
|
1101
|
-
style={{ width: sizeStyle.width }}
|
|
1102
|
-
className={names}
|
|
1103
|
-
>
|
|
1088
|
+
<div ref={(ref) => (this.wrapperRef = ref)} style={{ width: sizeStyle.width }} className={names}>
|
|
1104
1089
|
<OldSlateEditor
|
|
1105
1090
|
plugins={this.plugins}
|
|
1106
|
-
toolbarRef={r => {
|
|
1091
|
+
toolbarRef={(r) => {
|
|
1107
1092
|
if (r) {
|
|
1108
1093
|
this.toolbarRef = r;
|
|
1109
1094
|
}
|
package/src/index.jsx
CHANGED
|
@@ -101,7 +101,7 @@ const EditableHtml = React.forwardRef((props, forwardedRef) => {
|
|
|
101
101
|
return (
|
|
102
102
|
<Editor
|
|
103
103
|
{...newProps}
|
|
104
|
-
onRef={ref => {
|
|
104
|
+
onRef={(ref) => {
|
|
105
105
|
if (ref) {
|
|
106
106
|
rootRef.current = ref;
|
|
107
107
|
|
|
@@ -110,7 +110,7 @@ const EditableHtml = React.forwardRef((props, forwardedRef) => {
|
|
|
110
110
|
}
|
|
111
111
|
}
|
|
112
112
|
}}
|
|
113
|
-
editorRef={ref => ref && (editorRef.current = ref)}
|
|
113
|
+
editorRef={(ref) => ref && (editorRef.current = ref)}
|
|
114
114
|
/>
|
|
115
115
|
);
|
|
116
116
|
});
|
|
@@ -120,12 +120,12 @@ EditableHtml.propTypes = {
|
|
|
120
120
|
onDone: PropTypes.func,
|
|
121
121
|
onEditor: PropTypes.func,
|
|
122
122
|
markup: PropTypes.string.isRequired,
|
|
123
|
-
allowValidation: PropTypes.bool
|
|
123
|
+
allowValidation: PropTypes.bool,
|
|
124
124
|
};
|
|
125
125
|
|
|
126
126
|
EditableHtml.defaultProps = {
|
|
127
127
|
onDone: () => {},
|
|
128
|
-
allowValidation: false
|
|
128
|
+
allowValidation: false,
|
|
129
129
|
};
|
|
130
130
|
|
|
131
131
|
export default EditableHtml;
|
|
@@ -9,9 +9,9 @@ import { serialization as mediaSerialization } from './plugins/media';
|
|
|
9
9
|
import { serialization as listSerialization } from './plugins/list';
|
|
10
10
|
import { serialization as tableSerialization } from './plugins/table';
|
|
11
11
|
import { serialization as responseAreaSerialization } from './plugins/respArea';
|
|
12
|
-
import { Mark, Text, Value } from
|
|
13
|
-
import { jsx } from
|
|
14
|
-
import escapeHtml from
|
|
12
|
+
import { Mark, Text, Value } from 'slate';
|
|
13
|
+
import { jsx } from 'slate-hyperscript';
|
|
14
|
+
import escapeHtml from 'escape-html';
|
|
15
15
|
|
|
16
16
|
const log = debug('@pie-lib:editable-html:serialization');
|
|
17
17
|
|
|
@@ -32,7 +32,7 @@ export const BLOCK_TAGS = {
|
|
|
32
32
|
h3: 'heading-three',
|
|
33
33
|
h4: 'heading-four',
|
|
34
34
|
h5: 'heading-five',
|
|
35
|
-
h6: 'heading-six'
|
|
35
|
+
h6: 'heading-six',
|
|
36
36
|
};
|
|
37
37
|
|
|
38
38
|
/**
|
|
@@ -48,10 +48,10 @@ export const MARK_TAGS = {
|
|
|
48
48
|
s: 'strikethrough',
|
|
49
49
|
del: 'strikethrough',
|
|
50
50
|
code: 'code',
|
|
51
|
-
strong: 'bold'
|
|
51
|
+
strong: 'bold',
|
|
52
52
|
};
|
|
53
53
|
|
|
54
|
-
export const parseStyleString = s => {
|
|
54
|
+
export const parseStyleString = (s) => {
|
|
55
55
|
const regex = /([\w-]*)\s*:\s*([^;]*)/g;
|
|
56
56
|
let match;
|
|
57
57
|
const result = {};
|
|
@@ -61,18 +61,18 @@ export const parseStyleString = s => {
|
|
|
61
61
|
return result;
|
|
62
62
|
};
|
|
63
63
|
|
|
64
|
-
export const getBase64 = file => {
|
|
64
|
+
export const getBase64 = (file) => {
|
|
65
65
|
return new Promise((resolve, reject) => {
|
|
66
66
|
const reader = new FileReader();
|
|
67
67
|
reader.readAsDataURL(file);
|
|
68
68
|
reader.onload = () => resolve(reader.result);
|
|
69
|
-
reader.onerror = error => reject(error);
|
|
69
|
+
reader.onerror = (error) => reject(error);
|
|
70
70
|
});
|
|
71
71
|
};
|
|
72
72
|
|
|
73
|
-
export const reactAttributes = o => toStyleObject(o, { camelize: true, addUnits: false });
|
|
73
|
+
export const reactAttributes = (o) => toStyleObject(o, { camelize: true, addUnits: false });
|
|
74
74
|
|
|
75
|
-
const attributesToMap = el => (acc, attribute) => {
|
|
75
|
+
const attributesToMap = (el) => (acc, attribute) => {
|
|
76
76
|
const value = el.getAttribute(attribute);
|
|
77
77
|
if (value) {
|
|
78
78
|
if (attribute === 'style') {
|
|
@@ -116,9 +116,9 @@ const blocks = {
|
|
|
116
116
|
/**
|
|
117
117
|
* Here for rendering styles for all block elements
|
|
118
118
|
*/
|
|
119
|
-
data: { attributes: attributes.reduce(attributesToMap(el), {}) }
|
|
119
|
+
data: { attributes: attributes.reduce(attributesToMap(el), {}) },
|
|
120
120
|
},
|
|
121
|
-
next(el.childNodes)
|
|
121
|
+
next(el.childNodes),
|
|
122
122
|
);
|
|
123
123
|
},
|
|
124
124
|
serialize: (object, children) => {
|
|
@@ -136,7 +136,7 @@ const blocks = {
|
|
|
136
136
|
return <Tag {...jsonData.attributes}>{children}</Tag>;
|
|
137
137
|
}
|
|
138
138
|
}
|
|
139
|
-
}
|
|
139
|
+
},
|
|
140
140
|
};
|
|
141
141
|
|
|
142
142
|
const marks = {
|
|
@@ -175,10 +175,10 @@ const marks = {
|
|
|
175
175
|
|
|
176
176
|
return string;
|
|
177
177
|
}
|
|
178
|
-
}
|
|
178
|
+
},
|
|
179
179
|
};
|
|
180
180
|
|
|
181
|
-
const findPreviousText = el => {
|
|
181
|
+
const findPreviousText = (el) => {
|
|
182
182
|
if (el.nodeName === '#text') {
|
|
183
183
|
return el;
|
|
184
184
|
}
|
|
@@ -217,7 +217,7 @@ export const TEXT_RULE = {
|
|
|
217
217
|
return array;
|
|
218
218
|
}, []);
|
|
219
219
|
}
|
|
220
|
-
}
|
|
220
|
+
},
|
|
221
221
|
};
|
|
222
222
|
|
|
223
223
|
const RULES = [
|
|
@@ -229,7 +229,7 @@ const RULES = [
|
|
|
229
229
|
responseAreaSerialization,
|
|
230
230
|
TEXT_RULE,
|
|
231
231
|
blocks,
|
|
232
|
-
marks
|
|
232
|
+
marks,
|
|
233
233
|
];
|
|
234
234
|
|
|
235
235
|
function allWhitespace(node) {
|
|
@@ -240,7 +240,7 @@ function allWhitespace(node) {
|
|
|
240
240
|
function defaultParseHtml(html) {
|
|
241
241
|
if (typeof DOMParser === 'undefined') {
|
|
242
242
|
throw new Error(
|
|
243
|
-
'The native `DOMParser` global which the `Html` serializer uses by default is not present in this environment. You must supply the `options.parseHtml` function instead.'
|
|
243
|
+
'The native `DOMParser` global which the `Html` serializer uses by default is not present in this environment. You must supply the `options.parseHtml` function instead.',
|
|
244
244
|
);
|
|
245
245
|
}
|
|
246
246
|
|
|
@@ -264,14 +264,14 @@ function defaultParseHtml(html) {
|
|
|
264
264
|
const parseHtml =
|
|
265
265
|
typeof window === 'undefined'
|
|
266
266
|
? () => ({
|
|
267
|
-
childNodes: []
|
|
267
|
+
childNodes: [],
|
|
268
268
|
})
|
|
269
269
|
: defaultParseHtml;
|
|
270
270
|
|
|
271
271
|
const serializer = new TestSerializer({
|
|
272
272
|
defaultBlock: 'div',
|
|
273
273
|
rules: RULES,
|
|
274
|
-
parseHtml
|
|
274
|
+
parseHtml,
|
|
275
275
|
});
|
|
276
276
|
|
|
277
277
|
const _extends =
|
|
@@ -290,7 +290,7 @@ const _extends =
|
|
|
290
290
|
return target;
|
|
291
291
|
};
|
|
292
292
|
|
|
293
|
-
export const htmlToValue = html => {
|
|
293
|
+
export const htmlToValue = (html) => {
|
|
294
294
|
try {
|
|
295
295
|
return serializer.deserialize(html);
|
|
296
296
|
} catch (e) {
|
|
@@ -299,7 +299,7 @@ export const htmlToValue = html => {
|
|
|
299
299
|
}
|
|
300
300
|
};
|
|
301
301
|
|
|
302
|
-
export const valueToHtml = value => serializer.serialize(value);
|
|
302
|
+
export const valueToHtml = (value) => serializer.serialize(value);
|
|
303
303
|
|
|
304
304
|
/**
|
|
305
305
|
*
|
|
@@ -107,8 +107,7 @@ const insertDialog = ({ editor, callback, opts }) => {
|
|
|
107
107
|
// this toolbar is added on the mousedown event
|
|
108
108
|
// so right after mouseup, the click will be triggered
|
|
109
109
|
if (firstCallMade) {
|
|
110
|
-
const focusIsInModals =
|
|
111
|
-
newEl.contains(e.target) || (popoverEl && popoverEl.contains(e.target));
|
|
110
|
+
const focusIsInModals = newEl.contains(e.target) || (popoverEl && popoverEl.contains(e.target));
|
|
112
111
|
const editorDOM = ReactEditor.toDOMNode(editor, editor);
|
|
113
112
|
const focusIsInEditor = editorDOM.contains(e.target);
|
|
114
113
|
|
|
@@ -242,7 +241,7 @@ export default function CharactersPlugin(opts) {
|
|
|
242
241
|
name: 'characters',
|
|
243
242
|
toolbar: {
|
|
244
243
|
icon: <CharacterIcon letter={opts.characterIcon || characterIcons[opts.language] || 'ñ'} />,
|
|
245
|
-
onClick: editor => {
|
|
244
|
+
onClick: (editor) => {
|
|
246
245
|
const callback = (char, focus) => {
|
|
247
246
|
if (char) {
|
|
248
247
|
log('[characters:insert]: ', char);
|
|
@@ -28,10 +28,10 @@ export default function MarkHotkey(options) {
|
|
|
28
28
|
isMark: true,
|
|
29
29
|
type,
|
|
30
30
|
icon,
|
|
31
|
-
onToggle: editor => {
|
|
31
|
+
onToggle: (editor) => {
|
|
32
32
|
log('[onToggleMark] type: ', type);
|
|
33
33
|
toggleMark(editor, type);
|
|
34
|
-
}
|
|
34
|
+
},
|
|
35
35
|
},
|
|
36
36
|
renderMark(props) {
|
|
37
37
|
if (props.mark.type === type) {
|
|
@@ -49,6 +49,6 @@ export default function MarkHotkey(options) {
|
|
|
49
49
|
// Toggle the mark `type`.
|
|
50
50
|
change.toggleMark(type);
|
|
51
51
|
return true;
|
|
52
|
-
}
|
|
52
|
+
},
|
|
53
53
|
};
|
|
54
54
|
}
|
|
@@ -17,7 +17,7 @@ export class Component extends React.Component {
|
|
|
17
17
|
node: PropTypes.shape({
|
|
18
18
|
type: PropTypes.string,
|
|
19
19
|
children: PropTypes.array,
|
|
20
|
-
data: PropTypes.object
|
|
20
|
+
data: PropTypes.object,
|
|
21
21
|
}).isRequired,
|
|
22
22
|
focused: PropTypes.bool,
|
|
23
23
|
editor: PropTypes.shape({
|
|
@@ -67,9 +67,9 @@ export class Component extends React.Component {
|
|
|
67
67
|
type: 'set_node',
|
|
68
68
|
path: nodePath,
|
|
69
69
|
properties: {
|
|
70
|
-
data: node.data
|
|
70
|
+
data: node.data,
|
|
71
71
|
},
|
|
72
|
-
newProperties: { data: update }
|
|
72
|
+
newProperties: { data: update },
|
|
73
73
|
});
|
|
74
74
|
}
|
|
75
75
|
};
|
|
@@ -262,17 +262,13 @@ export class Component extends React.Component {
|
|
|
262
262
|
});
|
|
263
263
|
|
|
264
264
|
const progressClasses = classNames(classes.progress, {
|
|
265
|
-
[classes.hideProgress]: isLoaded
|
|
265
|
+
[classes.hideProgress]: isLoaded,
|
|
266
266
|
});
|
|
267
267
|
|
|
268
268
|
return (
|
|
269
269
|
<div onFocus={onFocus} className={className} style={{ justifyContent }} {...attributes}>
|
|
270
270
|
{children}
|
|
271
|
-
<LinearProgress
|
|
272
|
-
mode="determinate"
|
|
273
|
-
value={percent > 0 ? percent : 0}
|
|
274
|
-
className={progressClasses}
|
|
275
|
-
/>
|
|
271
|
+
<LinearProgress mode="determinate" value={percent > 0 ? percent : 0} className={progressClasses} />
|
|
276
272
|
<div className={classes.imageContainer}>
|
|
277
273
|
<img
|
|
278
274
|
className={classNames(classes.image, { [classes.active]: active })}
|