@pie-lib/editable-html 7.22.6 → 8.1.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 +41 -0
- package/lib/editor.js +80 -4
- package/lib/editor.js.map +1 -1
- package/lib/plugins/image/component.js +190 -29
- package/lib/plugins/image/component.js.map +1 -1
- package/lib/plugins/image/image-toolbar.js +4 -58
- package/lib/plugins/image/image-toolbar.js.map +1 -1
- package/lib/plugins/image/index.js +3 -1
- package/lib/plugins/image/index.js.map +1 -1
- package/lib/plugins/toolbar/toolbar.js +10 -3
- package/lib/plugins/toolbar/toolbar.js.map +1 -1
- package/lib/serialization.js +18 -1
- package/lib/serialization.js.map +1 -1
- package/package.json +2 -2
- package/src/editor.jsx +59 -9
- package/src/plugins/image/component.jsx +171 -19
- package/src/plugins/image/image-toolbar.jsx +2 -32
- package/src/plugins/image/index.jsx +3 -1
- package/src/plugins/toolbar/toolbar.jsx +9 -2
- package/src/serialization.jsx +9 -0
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { MarkButton } from '../toolbar/toolbar-buttons';
|
|
2
|
-
|
|
3
1
|
import PropTypes from 'prop-types';
|
|
4
2
|
import React from 'react';
|
|
5
3
|
import debug from 'debug';
|
|
@@ -7,45 +5,17 @@ import { withStyles } from '@material-ui/core/styles';
|
|
|
7
5
|
|
|
8
6
|
const log = debug('@pie-lib:editable-html:plugins:image:image-toolbar');
|
|
9
7
|
|
|
10
|
-
const PercentButton = ({ percent, active, onClick }) => {
|
|
11
|
-
const label = `${percent}%`;
|
|
12
|
-
return (
|
|
13
|
-
<MarkButton active={active} onToggle={() => onClick(percent)} label={label}>
|
|
14
|
-
{label}
|
|
15
|
-
</MarkButton>
|
|
16
|
-
);
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
PercentButton.propTypes = {
|
|
20
|
-
percent: PropTypes.number.isRequired,
|
|
21
|
-
active: PropTypes.bool.isRequired,
|
|
22
|
-
onClick: PropTypes.func.isRequired
|
|
23
|
-
};
|
|
24
|
-
|
|
25
8
|
export class ImageToolbar extends React.Component {
|
|
26
9
|
static propTypes = {
|
|
27
|
-
percent: PropTypes.number.isRequired,
|
|
28
10
|
onChange: PropTypes.func.isRequired,
|
|
29
11
|
classes: PropTypes.object.isRequired
|
|
30
12
|
};
|
|
31
13
|
|
|
32
|
-
onPercentClick = percent => {
|
|
33
|
-
log('[onPercentClick]: percent:', percent);
|
|
34
|
-
this.props.onChange(percent);
|
|
35
|
-
};
|
|
36
|
-
|
|
37
14
|
render() {
|
|
38
|
-
|
|
15
|
+
// Don't remove toolbar since we will have other new buttons
|
|
16
|
+
const { classes } = this.props;
|
|
39
17
|
return (
|
|
40
18
|
<div className={classes.holder}>
|
|
41
|
-
<PercentButton percent={25} active={percent === 25} onClick={this.onPercentClick} />
|
|
42
|
-
<PercentButton percent={50} active={percent === 50} onClick={this.onPercentClick} />
|
|
43
|
-
<PercentButton active={percent === 75} percent={75} onClick={this.onPercentClick} />
|
|
44
|
-
<PercentButton
|
|
45
|
-
percent={100}
|
|
46
|
-
active={percent === 100 || !percent}
|
|
47
|
-
onClick={this.onPercentClick}
|
|
48
|
-
/>
|
|
49
19
|
</div>
|
|
50
20
|
);
|
|
51
21
|
}
|
|
@@ -1,13 +1,15 @@
|
|
|
1
|
-
import
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Change } from 'slate';
|
|
2
3
|
import Delete from '@material-ui/icons/Delete';
|
|
3
4
|
import IconButton from '@material-ui/core/IconButton';
|
|
4
5
|
import PropTypes from 'prop-types';
|
|
5
|
-
import React from 'react';
|
|
6
6
|
import classNames from 'classnames';
|
|
7
7
|
import debug from 'debug';
|
|
8
8
|
import SlatePropTypes from 'slate-prop-types';
|
|
9
9
|
import debounce from 'lodash/debounce';
|
|
10
10
|
|
|
11
|
+
import { DoneButton } from './done-button';
|
|
12
|
+
|
|
11
13
|
import { findSingleNode, findParentNode } from '../utils';
|
|
12
14
|
import { withStyles } from '@material-ui/core/styles';
|
|
13
15
|
import DefaultToolbar from './default-toolbar';
|
|
@@ -167,6 +169,11 @@ export class Toolbar extends React.Component {
|
|
|
167
169
|
log('[render] plugin: ', plugin);
|
|
168
170
|
|
|
169
171
|
const handleDone = (change, done) => {
|
|
172
|
+
// use handler only if this is an actual Slate Change
|
|
173
|
+
if (!(change instanceof Change)) {
|
|
174
|
+
return;
|
|
175
|
+
}
|
|
176
|
+
|
|
170
177
|
let handler = onDone;
|
|
171
178
|
|
|
172
179
|
if (plugin && plugin.toolbar && plugin.toolbar.customToolbar) {
|
package/src/serialization.jsx
CHANGED
|
@@ -58,6 +58,15 @@ export const parseStyleString = s => {
|
|
|
58
58
|
return result;
|
|
59
59
|
};
|
|
60
60
|
|
|
61
|
+
export const getBase64 = file => {
|
|
62
|
+
return new Promise((resolve, reject) => {
|
|
63
|
+
const reader = new FileReader();
|
|
64
|
+
reader.readAsDataURL(file);
|
|
65
|
+
reader.onload = () => resolve(reader.result);
|
|
66
|
+
reader.onerror = error => reject(error);
|
|
67
|
+
});
|
|
68
|
+
};
|
|
69
|
+
|
|
61
70
|
export const reactAttributes = o => toStyleObject(o, { camelize: true, addUnits: false });
|
|
62
71
|
|
|
63
72
|
const attributesToMap = el => (acc, attribute) => {
|