@pie-lib/editable-html 9.5.22 → 9.5.23-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/editor.js +10 -12
- package/lib/editor.js.map +1 -1
- package/lib/index.js +4 -1
- package/lib/index.js.map +1 -1
- package/lib/plugins/characters/index.js +6 -0
- package/lib/plugins/characters/index.js.map +1 -1
- package/lib/plugins/image/component.js +0 -5
- package/lib/plugins/image/component.js.map +1 -1
- package/lib/plugins/math/index.js +6 -1
- package/lib/plugins/math/index.js.map +1 -1
- package/lib/plugins/respArea/explicit-constructed-response/index.js +1 -0
- package/lib/plugins/respArea/explicit-constructed-response/index.js.map +1 -1
- package/lib/plugins/toolbar/default-toolbar.js +13 -0
- package/lib/plugins/toolbar/default-toolbar.js.map +1 -1
- package/lib/plugins/toolbar/editor-and-toolbar.js +2 -1
- package/lib/plugins/toolbar/editor-and-toolbar.js.map +1 -1
- package/lib/serialization.js +2 -1
- package/lib/serialization.js.map +1 -1
- package/package.json +6 -6
- package/src/editor.jsx +9 -10
- package/src/index.jsx +3 -0
- package/src/plugins/characters/index.jsx +5 -0
- package/src/plugins/image/component.jsx +0 -5
- package/src/plugins/math/index.jsx +6 -0
- package/src/plugins/respArea/explicit-constructed-response/index.jsx +1 -0
- package/src/plugins/toolbar/default-toolbar.jsx +14 -0
- package/src/plugins/toolbar/editor-and-toolbar.jsx +1 -0
- package/src/serialization.jsx +2 -0
package/src/editor.jsx
CHANGED
|
@@ -48,6 +48,7 @@ export class Editor extends React.Component {
|
|
|
48
48
|
static propTypes = {
|
|
49
49
|
autoFocus: PropTypes.bool,
|
|
50
50
|
editorRef: PropTypes.func.isRequired,
|
|
51
|
+
error: PropTypes.any,
|
|
51
52
|
onRef: PropTypes.func.isRequired,
|
|
52
53
|
onChange: PropTypes.func.isRequired,
|
|
53
54
|
onFocus: PropTypes.func,
|
|
@@ -248,7 +249,7 @@ export class Editor extends React.Component {
|
|
|
248
249
|
}
|
|
249
250
|
}
|
|
250
251
|
|
|
251
|
-
|
|
252
|
+
UNSAFE_componentWillReceiveProps(nextProps) {
|
|
252
253
|
const { toolbarOpts } = this.state;
|
|
253
254
|
const newToolbarOpts = createToolbarOpts(nextProps.toolbarOpts, nextProps.error);
|
|
254
255
|
|
|
@@ -261,6 +262,13 @@ export class Editor extends React.Component {
|
|
|
261
262
|
if (!isEqual(nextProps.languageCharactersProps, this.props.languageCharactersProps)) {
|
|
262
263
|
this.handlePlugins(nextProps);
|
|
263
264
|
}
|
|
265
|
+
|
|
266
|
+
if (!nextProps.value.document.equals(this.props.value.document)) {
|
|
267
|
+
this.setState({
|
|
268
|
+
focus: false,
|
|
269
|
+
value: nextProps.value,
|
|
270
|
+
});
|
|
271
|
+
}
|
|
264
272
|
}
|
|
265
273
|
|
|
266
274
|
componentDidUpdate() {
|
|
@@ -499,15 +507,6 @@ export class Editor extends React.Component {
|
|
|
499
507
|
return this.state.preBlurValue;
|
|
500
508
|
};
|
|
501
509
|
|
|
502
|
-
UNSAFE_componentWillReceiveProps(props) {
|
|
503
|
-
if (!props.value.document.equals(this.props.value.document)) {
|
|
504
|
-
this.setState({
|
|
505
|
-
focus: false,
|
|
506
|
-
value: props.value,
|
|
507
|
-
});
|
|
508
|
-
}
|
|
509
|
-
}
|
|
510
|
-
|
|
511
510
|
valueToSize = (v) => {
|
|
512
511
|
if (!v) {
|
|
513
512
|
return;
|
package/src/index.jsx
CHANGED
|
@@ -23,6 +23,7 @@ const reduceMultipleBrs = (markup) => {
|
|
|
23
23
|
try {
|
|
24
24
|
return markup.replace(/(<br\s*\/?>){3,}/gi, '<br>');
|
|
25
25
|
} catch (e) {
|
|
26
|
+
// eslint-disable-next-line no-console
|
|
26
27
|
console.log("Couldn't remove <br/> tags: ", e);
|
|
27
28
|
}
|
|
28
29
|
|
|
@@ -31,10 +32,12 @@ const reduceMultipleBrs = (markup) => {
|
|
|
31
32
|
|
|
32
33
|
export default class EditableHtml extends React.Component {
|
|
33
34
|
static propTypes = {
|
|
35
|
+
error: PropTypes.any,
|
|
34
36
|
onChange: PropTypes.func.isRequired,
|
|
35
37
|
onDone: PropTypes.func,
|
|
36
38
|
markup: PropTypes.string.isRequired,
|
|
37
39
|
allowValidation: PropTypes.bool,
|
|
40
|
+
toolbarOpts: PropTypes.object,
|
|
38
41
|
};
|
|
39
42
|
|
|
40
43
|
static defaultProps = {
|
|
@@ -8,6 +8,7 @@ import { PureToolbar } from '@pie-lib/math-toolbar';
|
|
|
8
8
|
import CustomPopper from './custom-popper';
|
|
9
9
|
import { insertSnackBar } from '../respArea/utils';
|
|
10
10
|
import { characterIcons, spanishConfig, specialConfig } from './utils';
|
|
11
|
+
import PropTypes from 'prop-types';
|
|
11
12
|
const log = debug('@pie-lib:editable-html:plugins:characters');
|
|
12
13
|
|
|
13
14
|
const removePopOvers = () => {
|
|
@@ -224,6 +225,10 @@ const CharacterIcon = ({ letter }) => (
|
|
|
224
225
|
</div>
|
|
225
226
|
);
|
|
226
227
|
|
|
228
|
+
CharacterIcon.propTypes = {
|
|
229
|
+
letter: PropTypes.string,
|
|
230
|
+
};
|
|
231
|
+
|
|
227
232
|
export default function CharactersPlugin(opts) {
|
|
228
233
|
removeDialogs();
|
|
229
234
|
return {
|
|
@@ -209,28 +209,23 @@ export class Component extends React.Component {
|
|
|
209
209
|
const alignment = node.data.get('alignment');
|
|
210
210
|
const percent = node.data.get('percent');
|
|
211
211
|
const alt = node.data.get('alt');
|
|
212
|
-
let margin;
|
|
213
212
|
let justifyContent;
|
|
214
213
|
|
|
215
214
|
switch (alignment) {
|
|
216
215
|
case 'left':
|
|
217
216
|
justifyContent = 'flex-start';
|
|
218
|
-
margin = '0';
|
|
219
217
|
break;
|
|
220
218
|
|
|
221
219
|
case 'center':
|
|
222
220
|
justifyContent = 'center';
|
|
223
|
-
margin = '0 auto';
|
|
224
221
|
break;
|
|
225
222
|
|
|
226
223
|
case 'right':
|
|
227
224
|
justifyContent = 'flex-end';
|
|
228
|
-
margin = 'auto 0 0 auto ';
|
|
229
225
|
break;
|
|
230
226
|
|
|
231
227
|
default:
|
|
232
228
|
justifyContent = 'flex-start';
|
|
233
|
-
margin = '0';
|
|
234
229
|
break;
|
|
235
230
|
}
|
|
236
231
|
log('[render] node.data:', node.data);
|
|
@@ -21,6 +21,7 @@ function generateAdditionalKeys(keyData = []) {
|
|
|
21
21
|
}));
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
+
// eslint-disable-next-line react/display-name
|
|
24
25
|
export const CustomToolbarComp = React.memo(
|
|
25
26
|
(props) => {
|
|
26
27
|
const { node, value, onFocus, onBlur, onClick } = props;
|
|
@@ -150,6 +151,11 @@ MathPlugin.SQUARE_BRACKETS = 'square_brackets';
|
|
|
150
151
|
MathPlugin.DOLLAR = 'dollar';
|
|
151
152
|
MathPlugin.DOUBLE_DOLLAR = 'double_dollar';
|
|
152
153
|
|
|
154
|
+
MathPlugin.propTypes = {
|
|
155
|
+
attributes: PropTypes.object,
|
|
156
|
+
node: SlatePropTypes.node,
|
|
157
|
+
};
|
|
158
|
+
|
|
153
159
|
export const inlineMath = () =>
|
|
154
160
|
Inline.create({
|
|
155
161
|
object: 'inline',
|
|
@@ -47,6 +47,20 @@ export const ToolbarButton = (props) => {
|
|
|
47
47
|
}
|
|
48
48
|
};
|
|
49
49
|
|
|
50
|
+
ToolbarButton.propTypes = {
|
|
51
|
+
buttonStyles: PropTypes.object,
|
|
52
|
+
disabled: PropTypes.bool,
|
|
53
|
+
icon: PropTypes.any,
|
|
54
|
+
isActive: PropTypes.bool,
|
|
55
|
+
isMark: PropTypes.bool,
|
|
56
|
+
getFocusedValue: PropTypes.func,
|
|
57
|
+
onToggle: PropTypes.func,
|
|
58
|
+
onChange: PropTypes.func,
|
|
59
|
+
onClick: PropTypes.func,
|
|
60
|
+
type: PropTypes.string,
|
|
61
|
+
value: PropTypes.object,
|
|
62
|
+
};
|
|
63
|
+
|
|
50
64
|
const isActiveToolbarPlugin = (props) => (plugin) => {
|
|
51
65
|
const isDisabled = (props[plugin.name] || {}).disabled;
|
|
52
66
|
|
package/src/serialization.jsx
CHANGED
|
@@ -157,6 +157,7 @@ const marks = {
|
|
|
157
157
|
},
|
|
158
158
|
};
|
|
159
159
|
|
|
160
|
+
// eslint-disable-next-line no-unused-vars
|
|
160
161
|
const findPreviousText = (el) => {
|
|
161
162
|
if (el.nodeName === '#text') {
|
|
162
163
|
return el;
|
|
@@ -369,6 +370,7 @@ export const htmlToValue = (html) => {
|
|
|
369
370
|
try {
|
|
370
371
|
return serializer.deserialize(html);
|
|
371
372
|
} catch (e) {
|
|
373
|
+
// eslint-disable-next-line no-console
|
|
372
374
|
console.log("Couldn't parse html: ", e);
|
|
373
375
|
return {};
|
|
374
376
|
}
|