@pie-lib/editable-html 7.22.5 → 8.1.0
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 +37 -0
- package/lib/editor.js +214 -102
- package/lib/editor.js.map +1 -1
- package/lib/plugins/characters/custom-popover.js +73 -0
- package/lib/plugins/characters/custom-popover.js.map +1 -0
- package/lib/plugins/characters/index.js +271 -0
- package/lib/plugins/characters/index.js.map +1 -0
- package/lib/plugins/characters/utils.js +362 -0
- package/lib/plugins/characters/utils.js.map +1 -0
- 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/index.js +19 -4
- package/lib/plugins/index.js.map +1 -1
- package/lib/serialization.js +18 -1
- package/lib/serialization.js.map +1 -1
- package/package.json +5 -5
- package/src/editor.jsx +93 -17
- package/src/plugins/characters/custom-popover.js +45 -0
- package/src/plugins/characters/index.jsx +237 -0
- package/src/plugins/characters/utils.js +444 -0
- 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/index.jsx +3 -0
- 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
|
}
|
package/src/plugins/index.jsx
CHANGED
|
@@ -4,6 +4,7 @@ import BulletedListIcon from '@material-ui/icons/FormatListBulleted';
|
|
|
4
4
|
import NumberedListIcon from '@material-ui/icons/FormatListNumbered';
|
|
5
5
|
import ImagePlugin from './image';
|
|
6
6
|
import MediaPlugin from './media';
|
|
7
|
+
import CharactersPlugin from './characters';
|
|
7
8
|
import Italic from '@material-ui/icons/FormatItalic';
|
|
8
9
|
import MathPlugin from './math';
|
|
9
10
|
import React from 'react';
|
|
@@ -63,6 +64,7 @@ export const ALL_PLUGINS = [
|
|
|
63
64
|
'numbered-list',
|
|
64
65
|
'image',
|
|
65
66
|
'math',
|
|
67
|
+
'languageCharacters',
|
|
66
68
|
'table',
|
|
67
69
|
'video',
|
|
68
70
|
'audio',
|
|
@@ -103,6 +105,7 @@ export const buildPlugins = (activePlugins, opts) => {
|
|
|
103
105
|
addIf('video', MediaPlugin('video', opts.media)),
|
|
104
106
|
addIf('audio', MediaPlugin('audio', opts.media)),
|
|
105
107
|
addIf('math', mathPlugin),
|
|
108
|
+
...opts.languageCharacters.map(config => addIf('languageCharacters', CharactersPlugin(config))),
|
|
106
109
|
addIf('bulleted-list', List({ key: 'l', type: 'ul_list', icon: <BulletedListIcon /> })),
|
|
107
110
|
addIf('numbered-list', List({ key: 'n', type: 'ol_list', icon: <NumberedListIcon /> })),
|
|
108
111
|
ToolbarPlugin(opts.toolbar),
|
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) => {
|