@pie-lib/editable-html 9.5.13 → 10.0.0-beta.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 +0 -302
- package/lib/components.js +116 -0
- package/lib/components.js.map +1 -0
- package/lib/editor.js +418 -103
- package/lib/editor.js.map +1 -1
- package/lib/index.js +101 -155
- package/lib/index.js.map +1 -1
- package/lib/new-serialization.js +320 -0
- package/lib/new-serialization.js.map +1 -0
- package/lib/old-serialization.js +330 -0
- package/lib/parse-html.js +1 -1
- package/lib/parse-html.js.map +1 -1
- package/lib/plugins/characters/custom-popper.js +1 -1
- package/lib/plugins/characters/custom-popper.js.map +1 -1
- package/lib/plugins/characters/index.js +21 -19
- package/lib/plugins/characters/index.js.map +1 -1
- package/lib/plugins/characters/utils.js +1 -1
- package/lib/plugins/characters/utils.js.map +1 -1
- package/lib/plugins/hotKeys/index.js +67 -0
- package/lib/plugins/hotKeys/index.js.map +1 -0
- package/lib/plugins/image/alt-dialog.js +1 -6
- package/lib/plugins/image/alt-dialog.js.map +1 -1
- package/lib/plugins/image/component.js +70 -53
- package/lib/plugins/image/component.js.map +1 -1
- package/lib/plugins/image/image-toolbar.js +7 -9
- package/lib/plugins/image/image-toolbar.js.map +1 -1
- package/lib/plugins/image/index.js +83 -27
- package/lib/plugins/image/index.js.map +1 -1
- package/lib/plugins/image/insert-image-handler.js +72 -33
- package/lib/plugins/image/insert-image-handler.js.map +1 -1
- package/lib/plugins/index.js +23 -41
- package/lib/plugins/index.js.map +1 -1
- package/lib/plugins/list/index.js +64 -100
- package/lib/plugins/list/index.js.map +1 -1
- package/lib/plugins/math/index.js +86 -60
- package/lib/plugins/math/index.js.map +1 -1
- package/lib/plugins/media/index.js +202 -132
- package/lib/plugins/media/index.js.map +1 -1
- package/lib/plugins/media/media-dialog.js +17 -16
- package/lib/plugins/media/media-dialog.js.map +1 -1
- package/lib/plugins/media/media-toolbar.js +3 -3
- package/lib/plugins/media/media-toolbar.js.map +1 -1
- package/lib/plugins/media/media-wrapper.js +21 -58
- package/lib/plugins/media/media-wrapper.js.map +1 -1
- package/lib/plugins/respArea/drag-in-the-blank/choice.js +3 -3
- package/lib/plugins/respArea/drag-in-the-blank/choice.js.map +1 -1
- package/lib/plugins/respArea/drag-in-the-blank/index.js +3 -2
- package/lib/plugins/respArea/drag-in-the-blank/index.js.map +1 -1
- package/lib/plugins/respArea/explicit-constructed-response/index.js +3 -2
- package/lib/plugins/respArea/explicit-constructed-response/index.js.map +1 -1
- package/lib/plugins/respArea/icons/index.js +13 -15
- package/lib/plugins/respArea/icons/index.js.map +1 -1
- package/lib/plugins/respArea/index.js +87 -53
- package/lib/plugins/respArea/index.js.map +1 -1
- package/lib/plugins/respArea/inline-dropdown/index.js +4 -3
- package/lib/plugins/respArea/inline-dropdown/index.js.map +1 -1
- package/lib/plugins/respArea/utils.js +17 -20
- package/lib/plugins/respArea/utils.js.map +1 -1
- package/lib/plugins/table/icons/index.js +1 -1
- package/lib/plugins/table/icons/index.js.map +1 -1
- package/lib/plugins/table/index.js +381 -212
- package/lib/plugins/table/index.js.map +1 -1
- package/lib/plugins/table/table-toolbar.js +5 -6
- package/lib/plugins/table/table-toolbar.js.map +1 -1
- package/lib/plugins/toolbar/default-toolbar.js +55 -11
- package/lib/plugins/toolbar/default-toolbar.js.map +1 -1
- package/lib/plugins/toolbar/done-button.js +1 -1
- package/lib/plugins/toolbar/done-button.js.map +1 -1
- package/lib/plugins/toolbar/editor-and-toolbar.js +186 -232
- package/lib/plugins/toolbar/editor-and-toolbar.js.map +1 -1
- package/lib/plugins/toolbar/index.js +1 -2
- package/lib/plugins/toolbar/index.js.map +1 -1
- package/lib/plugins/toolbar/toolbar-buttons.js +1 -1
- package/lib/plugins/toolbar/toolbar-buttons.js.map +1 -1
- package/lib/plugins/toolbar/toolbar.js +253 -239
- package/lib/plugins/toolbar/toolbar.js.map +1 -1
- package/lib/plugins/utils.js +27 -2
- package/lib/plugins/utils.js.map +1 -1
- package/lib/serialization.js +1 -1
- package/lib/serialization.js.map +1 -1
- package/lib/slate-editor.js +302 -0
- package/lib/test-serializer.js +189 -0
- package/lib/test-serializer.js.map +1 -0
- package/lib/theme.js +1 -1
- package/lib/theme.js.map +1 -1
- package/package.json +18 -14
- package/playground/image/data.js +20 -20
- package/playground/image/index.html +22 -20
- package/playground/image/index.jsx +12 -10
- package/playground/index.html +25 -23
- package/playground/mathquill/index.html +23 -20
- package/playground/mathquill/index.jsx +18 -22
- package/playground/prod-test/index.html +24 -20
- package/playground/prod-test/index.jsx +5 -3
- package/playground/schema-override/data.js +10 -10
- package/playground/schema-override/image-plugin.jsx +3 -4
- package/playground/schema-override/index.html +21 -19
- package/playground/schema-override/index.jsx +13 -14
- package/playground/serialization/data.js +10 -10
- package/playground/serialization/image-plugin.jsx +3 -4
- package/playground/serialization/index.html +22 -20
- package/playground/table-examples.html +5 -8
- package/playground/webpack.config.js +10 -10
- package/src/components.js +135 -0
- package/src/editor.jsx +478 -141
- package/src/index.jsx +71 -95
- package/src/new-serialization.jsx +291 -0
- package/src/parse-html.js +1 -1
- package/src/plugins/characters/custom-popper.js +7 -7
- package/src/plugins/characters/index.jsx +33 -34
- package/src/plugins/characters/utils.js +81 -81
- package/src/plugins/hotKeys/index.js +54 -0
- package/src/plugins/image/alt-dialog.jsx +4 -5
- package/src/plugins/image/component.jsx +106 -89
- package/src/plugins/image/image-toolbar.jsx +27 -19
- package/src/plugins/image/index.jsx +75 -43
- package/src/plugins/image/insert-image-handler.js +62 -27
- package/src/plugins/index.jsx +23 -41
- package/src/plugins/list/index.jsx +70 -95
- package/src/plugins/math/index.jsx +102 -82
- package/src/plugins/media/index.jsx +159 -124
- package/src/plugins/media/media-dialog.js +98 -71
- package/src/plugins/media/media-toolbar.jsx +8 -8
- package/src/plugins/media/media-wrapper.jsx +29 -30
- package/src/plugins/respArea/drag-in-the-blank/choice.jsx +21 -19
- package/src/plugins/respArea/drag-in-the-blank/index.jsx +14 -11
- package/src/plugins/respArea/explicit-constructed-response/index.jsx +7 -6
- package/src/plugins/respArea/icons/index.jsx +11 -14
- package/src/plugins/respArea/index.jsx +92 -52
- package/src/plugins/respArea/inline-dropdown/index.jsx +9 -8
- package/src/plugins/respArea/utils.jsx +26 -35
- package/src/plugins/table/icons/index.jsx +17 -11
- package/src/plugins/table/index.jsx +288 -231
- package/src/plugins/table/table-toolbar.jsx +15 -11
- package/src/plugins/toolbar/default-toolbar.jsx +65 -19
- package/src/plugins/toolbar/done-button.jsx +4 -4
- package/src/plugins/toolbar/editor-and-toolbar.jsx +150 -145
- package/src/plugins/toolbar/index.jsx +2 -3
- package/src/plugins/toolbar/toolbar-buttons.jsx +11 -11
- package/src/plugins/toolbar/toolbar.jsx +244 -221
- package/src/plugins/utils.js +21 -4
- package/src/serialization.jsx +32 -32
- package/src/test-serializer.js +139 -0
- package/src/test-serializer.js.rej +20 -0
|
@@ -1,41 +1,48 @@
|
|
|
1
|
-
import LinearProgress from '@material-ui/core/LinearProgress';
|
|
2
|
-
import PropTypes from 'prop-types';
|
|
3
1
|
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
4
3
|
import classNames from 'classnames';
|
|
5
4
|
import debug from 'debug';
|
|
5
|
+
import isEqual from 'lodash/isEqual';
|
|
6
|
+
import cloneDeep from 'lodash/cloneDeep';
|
|
7
|
+
import LinearProgress from '@material-ui/core/LinearProgress';
|
|
6
8
|
import { withStyles } from '@material-ui/core/styles';
|
|
7
|
-
import
|
|
9
|
+
import { Editor } from 'slate';
|
|
8
10
|
|
|
9
11
|
const log = debug('@pie-lib:editable-html:plugins:image:component');
|
|
10
12
|
|
|
11
|
-
const size =
|
|
13
|
+
const size = s => (s ? `${s}px` : 'auto');
|
|
12
14
|
|
|
13
15
|
export class Component extends React.Component {
|
|
14
16
|
static propTypes = {
|
|
15
|
-
node:
|
|
17
|
+
node: PropTypes.shape({
|
|
18
|
+
type: PropTypes.string,
|
|
19
|
+
children: PropTypes.array,
|
|
20
|
+
data: PropTypes.object
|
|
21
|
+
}).isRequired,
|
|
22
|
+
focused: PropTypes.bool,
|
|
16
23
|
editor: PropTypes.shape({
|
|
17
24
|
change: PropTypes.func.isRequired,
|
|
18
|
-
value: PropTypes.object
|
|
25
|
+
value: PropTypes.object
|
|
19
26
|
}).isRequired,
|
|
20
27
|
classes: PropTypes.object.isRequired,
|
|
21
28
|
attributes: PropTypes.object,
|
|
22
29
|
onFocus: PropTypes.func,
|
|
23
30
|
onBlur: PropTypes.func,
|
|
24
31
|
maxImageWidth: PropTypes.number,
|
|
25
|
-
maxImageHeight: PropTypes.number
|
|
32
|
+
maxImageHeight: PropTypes.number
|
|
26
33
|
};
|
|
27
34
|
|
|
28
|
-
getWidth =
|
|
35
|
+
getWidth = percent => {
|
|
29
36
|
const multiplier = percent / 100;
|
|
30
37
|
return this.img.naturalWidth * multiplier;
|
|
31
38
|
};
|
|
32
39
|
|
|
33
|
-
getHeight =
|
|
40
|
+
getHeight = percent => {
|
|
34
41
|
const multiplier = percent / 100;
|
|
35
42
|
return this.img.naturalHeight * multiplier;
|
|
36
43
|
};
|
|
37
44
|
|
|
38
|
-
getPercentFromWidth =
|
|
45
|
+
getPercentFromWidth = width => {
|
|
39
46
|
var floored = (width / this.img.naturalWidth) * 4;
|
|
40
47
|
return parseInt(floored.toFixed(0) * 25, 10);
|
|
41
48
|
};
|
|
@@ -43,17 +50,27 @@ export class Component extends React.Component {
|
|
|
43
50
|
applySizeData = () => {
|
|
44
51
|
const { node, editor } = this.props;
|
|
45
52
|
|
|
46
|
-
let update = node.data;
|
|
53
|
+
let update = cloneDeep(node.data);
|
|
54
|
+
|
|
55
|
+
const w = update.width;
|
|
47
56
|
|
|
48
|
-
const w = update.get('width');
|
|
49
57
|
if (w) {
|
|
50
|
-
update = update.
|
|
58
|
+
update = update.resizePercent = this.getPercentFromWidth(w);
|
|
51
59
|
}
|
|
52
60
|
|
|
53
61
|
log('[applySizeData] update: ', update);
|
|
54
62
|
|
|
55
|
-
if (!update
|
|
56
|
-
|
|
63
|
+
if (!isEqual(update, node.data)) {
|
|
64
|
+
const nodePath = Editor.path(editor, editor.selection);
|
|
65
|
+
|
|
66
|
+
editor.apply({
|
|
67
|
+
type: 'set_node',
|
|
68
|
+
path: nodePath,
|
|
69
|
+
properties: {
|
|
70
|
+
data: node.data
|
|
71
|
+
},
|
|
72
|
+
newProperties: { data: update }
|
|
73
|
+
});
|
|
57
74
|
}
|
|
58
75
|
};
|
|
59
76
|
|
|
@@ -78,9 +95,9 @@ export class Component extends React.Component {
|
|
|
78
95
|
|
|
79
96
|
getSize(data) {
|
|
80
97
|
return {
|
|
81
|
-
width: size(data.
|
|
82
|
-
height: size(data.
|
|
83
|
-
objectFit: 'contain'
|
|
98
|
+
width: size(data.width),
|
|
99
|
+
height: size(data.height),
|
|
100
|
+
objectFit: 'contain'
|
|
84
101
|
};
|
|
85
102
|
}
|
|
86
103
|
|
|
@@ -95,53 +112,62 @@ export class Component extends React.Component {
|
|
|
95
112
|
if (!box.style.width || box.style.width === 'auto') {
|
|
96
113
|
const dimensions = {
|
|
97
114
|
width: (box && box.naturalWidth) || 100,
|
|
98
|
-
height: (box && box.naturalHeight) || 100
|
|
115
|
+
height: (box && box.naturalHeight) || 100
|
|
99
116
|
};
|
|
100
117
|
|
|
101
118
|
const { width, height } = this.updateImageDimensions(
|
|
102
119
|
dimensions,
|
|
103
120
|
{
|
|
104
121
|
width: dimensions.width < maxImageWidth ? dimensions.width : maxImageWidth,
|
|
105
|
-
height: dimensions.height < maxImageHeight ? dimensions.height : maxImageHeight
|
|
122
|
+
height: dimensions.height < maxImageHeight ? dimensions.height : maxImageHeight
|
|
106
123
|
},
|
|
107
|
-
true
|
|
124
|
+
true
|
|
108
125
|
);
|
|
109
126
|
|
|
110
127
|
box.style.width = `${width}px`;
|
|
111
128
|
box.style.height = `${height}px`;
|
|
112
129
|
|
|
113
130
|
this.setState({
|
|
114
|
-
dimensions: { height: height, width: width }
|
|
131
|
+
dimensions: { height: height, width: width }
|
|
115
132
|
});
|
|
116
133
|
|
|
117
134
|
const { node, editor } = this.props;
|
|
118
135
|
|
|
119
|
-
|
|
136
|
+
const update = cloneDeep(node.data);
|
|
120
137
|
|
|
121
|
-
update =
|
|
122
|
-
update =
|
|
138
|
+
update.width = width;
|
|
139
|
+
update.height = height;
|
|
123
140
|
|
|
124
|
-
if (!update
|
|
125
|
-
|
|
141
|
+
if (!isEqual(update, node.data)) {
|
|
142
|
+
const nodePath = Editor.path(editor, editor.selection);
|
|
143
|
+
|
|
144
|
+
editor.apply({
|
|
145
|
+
type: 'set_node',
|
|
146
|
+
path: nodePath,
|
|
147
|
+
properties: {
|
|
148
|
+
data: node.data
|
|
149
|
+
},
|
|
150
|
+
newProperties: { data: update }
|
|
151
|
+
});
|
|
126
152
|
}
|
|
127
153
|
}
|
|
128
154
|
};
|
|
129
155
|
|
|
130
|
-
startResizing =
|
|
156
|
+
startResizing = e => {
|
|
131
157
|
const bounds = e.target.getBoundingClientRect();
|
|
132
158
|
const box = this.img;
|
|
133
159
|
const dimensions = {
|
|
134
160
|
width: (box && box.naturalWidth) || 100,
|
|
135
|
-
height: (box && box.naturalHeight) || 100
|
|
161
|
+
height: (box && box.naturalHeight) || 100
|
|
136
162
|
};
|
|
137
163
|
|
|
138
164
|
const { width, height } = this.updateImageDimensions(
|
|
139
165
|
dimensions,
|
|
140
166
|
{
|
|
141
167
|
width: e.clientX - bounds.left,
|
|
142
|
-
height: e.clientY - bounds.top
|
|
168
|
+
height: e.clientY - bounds.top
|
|
143
169
|
},
|
|
144
|
-
true
|
|
170
|
+
true
|
|
145
171
|
);
|
|
146
172
|
|
|
147
173
|
const hasMinimumWidth = width > 50 && height > 50;
|
|
@@ -152,7 +178,7 @@ export class Component extends React.Component {
|
|
|
152
178
|
box.style.height = `${height}px`;
|
|
153
179
|
|
|
154
180
|
this.setState({
|
|
155
|
-
dimensions: { height: height, width: width }
|
|
181
|
+
dimensions: { height: height, width: width }
|
|
156
182
|
});
|
|
157
183
|
|
|
158
184
|
const { node, editor } = this.props;
|
|
@@ -163,7 +189,7 @@ export class Component extends React.Component {
|
|
|
163
189
|
update = update.set('height', height);
|
|
164
190
|
|
|
165
191
|
if (!update.equals(node.data)) {
|
|
166
|
-
editor.change(
|
|
192
|
+
editor.change(c => c.setNodeByKey(node.key, { data: update }));
|
|
167
193
|
}
|
|
168
194
|
}
|
|
169
195
|
};
|
|
@@ -182,55 +208,43 @@ export class Component extends React.Component {
|
|
|
182
208
|
// if we want to change image height => we update the width accordingly
|
|
183
209
|
return {
|
|
184
210
|
width: nextDim.height * imageAspectRatio,
|
|
185
|
-
height: nextDim.height
|
|
211
|
+
height: nextDim.height
|
|
186
212
|
};
|
|
187
213
|
}
|
|
188
214
|
|
|
189
215
|
// if we want to change image width => we update the height accordingly
|
|
190
216
|
return {
|
|
191
217
|
width: nextDim.width,
|
|
192
|
-
height: nextDim.width / imageAspectRatio
|
|
218
|
+
height: nextDim.width / imageAspectRatio
|
|
193
219
|
};
|
|
194
220
|
}
|
|
195
221
|
|
|
196
222
|
// if we don't want to keep aspect ratio, we just update both values
|
|
197
223
|
return {
|
|
198
224
|
width: nextDim.width,
|
|
199
|
-
height: nextDim.height
|
|
225
|
+
height: nextDim.height
|
|
200
226
|
};
|
|
201
227
|
};
|
|
202
228
|
|
|
203
229
|
render() {
|
|
204
|
-
const { node,
|
|
205
|
-
const active =
|
|
206
|
-
const src = node.data
|
|
207
|
-
const
|
|
208
|
-
const deleteStatus = node.data.get('deleteStatus');
|
|
209
|
-
const alignment = node.data.get('alignment');
|
|
210
|
-
const percent = node.data.get('percent');
|
|
211
|
-
const alt = node.data.get('alt');
|
|
212
|
-
let margin;
|
|
230
|
+
const { node, focused, classes, attributes, children, onFocus } = this.props;
|
|
231
|
+
const active = focused;
|
|
232
|
+
const { alignment, alt, deleteStatus, loaded, percent, src } = node.data;
|
|
233
|
+
const isLoaded = loaded !== false;
|
|
213
234
|
let justifyContent;
|
|
214
235
|
|
|
215
236
|
switch (alignment) {
|
|
216
237
|
case 'left':
|
|
217
238
|
justifyContent = 'flex-start';
|
|
218
|
-
margin = '0';
|
|
219
239
|
break;
|
|
220
|
-
|
|
221
240
|
case 'center':
|
|
222
241
|
justifyContent = 'center';
|
|
223
|
-
margin = '0 auto';
|
|
224
242
|
break;
|
|
225
|
-
|
|
226
243
|
case 'right':
|
|
227
244
|
justifyContent = 'flex-end';
|
|
228
|
-
margin = 'auto 0 0 auto ';
|
|
229
245
|
break;
|
|
230
|
-
|
|
231
246
|
default:
|
|
232
247
|
justifyContent = 'flex-start';
|
|
233
|
-
margin = '0';
|
|
234
248
|
break;
|
|
235
249
|
}
|
|
236
250
|
log('[render] node.data:', node.data);
|
|
@@ -239,23 +253,27 @@ export class Component extends React.Component {
|
|
|
239
253
|
|
|
240
254
|
log('[render] style:', size);
|
|
241
255
|
|
|
242
|
-
const className = classNames(
|
|
243
|
-
classes.
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
<div
|
|
253
|
-
|
|
256
|
+
const className = classNames(classes.root, {
|
|
257
|
+
[classes.loading]: !isLoaded,
|
|
258
|
+
[classes.pendingDelete]: deleteStatus === 'pending'
|
|
259
|
+
});
|
|
260
|
+
|
|
261
|
+
const progressClasses = classNames(classes.progress, {
|
|
262
|
+
[classes.hideProgress]: isLoaded
|
|
263
|
+
});
|
|
264
|
+
|
|
265
|
+
return (
|
|
266
|
+
<div onFocus={onFocus} className={className} style={{ justifyContent }} {...attributes}>
|
|
267
|
+
{children}
|
|
268
|
+
<LinearProgress
|
|
269
|
+
mode="determinate"
|
|
270
|
+
value={percent > 0 ? percent : 0}
|
|
271
|
+
className={progressClasses}
|
|
272
|
+
/>
|
|
254
273
|
<div className={classes.imageContainer}>
|
|
255
274
|
<img
|
|
256
|
-
{
|
|
257
|
-
|
|
258
|
-
ref={(ref) => {
|
|
275
|
+
className={classNames(classes.image, { [classes.active]: active })}
|
|
276
|
+
ref={ref => {
|
|
259
277
|
this.img = ref;
|
|
260
278
|
}}
|
|
261
279
|
src={src}
|
|
@@ -264,58 +282,57 @@ export class Component extends React.Component {
|
|
|
264
282
|
alt={alt}
|
|
265
283
|
/>
|
|
266
284
|
<div
|
|
267
|
-
ref={
|
|
285
|
+
ref={ref => {
|
|
268
286
|
this.resize = ref;
|
|
269
287
|
}}
|
|
270
288
|
className={classNames(classes.resize, 'resize')}
|
|
271
289
|
/>
|
|
272
290
|
</div>
|
|
273
|
-
</div
|
|
274
|
-
|
|
275
|
-
];
|
|
291
|
+
</div>
|
|
292
|
+
);
|
|
276
293
|
}
|
|
277
294
|
}
|
|
278
295
|
|
|
279
|
-
const styles =
|
|
296
|
+
const styles = theme => ({
|
|
280
297
|
portal: {
|
|
281
298
|
position: 'absolute',
|
|
282
299
|
opacity: 0,
|
|
283
|
-
transition: 'opacity 200ms linear'
|
|
300
|
+
transition: 'opacity 200ms linear'
|
|
284
301
|
},
|
|
285
302
|
floatingButtonRow: {
|
|
286
|
-
backgroundColor:
|
|
303
|
+
backgroundColor: 'white',
|
|
287
304
|
borderRadius: '1px',
|
|
288
305
|
display: 'flex',
|
|
289
306
|
padding: '10px',
|
|
290
|
-
border:
|
|
307
|
+
border: 'solid 1px #eeeeee',
|
|
291
308
|
boxShadow:
|
|
292
|
-
'0px 1px 5px 0px rgba(0, 0, 0, 0.2), 0px 2px 2px 0px rgba(0, 0, 0, 0.14), 0px 3px 1px -2px rgba(0, 0, 0, 0.12)'
|
|
309
|
+
'0px 1px 5px 0px rgba(0, 0, 0, 0.2), 0px 2px 2px 0px rgba(0, 0, 0, 0.14), 0px 3px 1px -2px rgba(0, 0, 0, 0.12)'
|
|
293
310
|
},
|
|
294
311
|
progress: {
|
|
295
312
|
position: 'absolute',
|
|
296
313
|
left: '0',
|
|
297
314
|
width: 'fit-content',
|
|
298
315
|
top: '0%',
|
|
299
|
-
transition: 'opacity 200ms linear'
|
|
316
|
+
transition: 'opacity 200ms linear'
|
|
300
317
|
},
|
|
301
318
|
hideProgress: {
|
|
302
|
-
opacity: 0
|
|
319
|
+
opacity: 0
|
|
303
320
|
},
|
|
304
321
|
loading: {
|
|
305
|
-
opacity: 0.3
|
|
322
|
+
opacity: 0.3
|
|
306
323
|
},
|
|
307
324
|
pendingDelete: {
|
|
308
|
-
opacity: 0.3
|
|
325
|
+
opacity: 0.3
|
|
309
326
|
},
|
|
310
327
|
root: {
|
|
311
328
|
position: 'relative',
|
|
312
|
-
border:
|
|
329
|
+
border: 'solid 1px white',
|
|
313
330
|
display: 'flex',
|
|
314
|
-
transition: 'opacity 200ms linear'
|
|
331
|
+
transition: 'opacity 200ms linear'
|
|
315
332
|
},
|
|
316
333
|
delete: {
|
|
317
334
|
position: 'absolute',
|
|
318
|
-
right: 0
|
|
335
|
+
right: 0
|
|
319
336
|
},
|
|
320
337
|
imageContainer: {
|
|
321
338
|
position: 'relative',
|
|
@@ -324,11 +341,11 @@ const styles = (theme) => ({
|
|
|
324
341
|
alignItems: 'center',
|
|
325
342
|
|
|
326
343
|
'&&:hover > .resize': {
|
|
327
|
-
display: 'block'
|
|
328
|
-
}
|
|
344
|
+
display: 'block'
|
|
345
|
+
}
|
|
329
346
|
},
|
|
330
347
|
active: {
|
|
331
|
-
border: `solid 1px ${theme.palette.primary.main}
|
|
348
|
+
border: `solid 1px ${theme.palette.primary.main}`
|
|
332
349
|
},
|
|
333
350
|
resize: {
|
|
334
351
|
backgroundColor: theme.palette.primary.main,
|
|
@@ -338,11 +355,11 @@ const styles = (theme) => ({
|
|
|
338
355
|
borderRadius: 8,
|
|
339
356
|
marginLeft: '5px',
|
|
340
357
|
marginRight: '10px',
|
|
341
|
-
display: 'none'
|
|
358
|
+
display: 'none'
|
|
342
359
|
},
|
|
343
360
|
drawableHeight: {
|
|
344
|
-
minHeight: 350
|
|
345
|
-
}
|
|
361
|
+
minHeight: 350
|
|
362
|
+
}
|
|
346
363
|
});
|
|
347
364
|
|
|
348
365
|
export default withStyles(styles)(Component);
|
|
@@ -21,7 +21,7 @@ const AlignmentButton = ({ alignment, active, onClick }) => {
|
|
|
21
21
|
AlignmentButton.propTypes = {
|
|
22
22
|
alignment: PropTypes.string.isRequired,
|
|
23
23
|
active: PropTypes.bool.isRequired,
|
|
24
|
-
onClick: PropTypes.func.isRequired
|
|
24
|
+
onClick: PropTypes.func.isRequired
|
|
25
25
|
};
|
|
26
26
|
|
|
27
27
|
export class ImageToolbar extends React.Component {
|
|
@@ -30,17 +30,16 @@ export class ImageToolbar extends React.Component {
|
|
|
30
30
|
classes: PropTypes.object.isRequired,
|
|
31
31
|
alignment: PropTypes.string,
|
|
32
32
|
alt: PropTypes.string,
|
|
33
|
-
imageLoaded: PropTypes.bool
|
|
34
|
-
disableImageAlignmentButtons: PropTypes.bool,
|
|
33
|
+
imageLoaded: PropTypes.bool
|
|
35
34
|
};
|
|
36
35
|
|
|
37
|
-
onAltTextDone =
|
|
36
|
+
onAltTextDone = newAlt => {
|
|
38
37
|
log('[onAltTextDone]: alt:', newAlt);
|
|
39
38
|
|
|
40
|
-
this.props.onChange({ alt: newAlt }
|
|
39
|
+
this.props.onChange({ alt: newAlt });
|
|
41
40
|
};
|
|
42
41
|
|
|
43
|
-
onAlignmentClick =
|
|
42
|
+
onAlignmentClick = alignment => {
|
|
44
43
|
log('[onAlignmentClick]: alignment:', alignment);
|
|
45
44
|
this.props.onChange({ alignment });
|
|
46
45
|
};
|
|
@@ -57,22 +56,31 @@ export class ImageToolbar extends React.Component {
|
|
|
57
56
|
};
|
|
58
57
|
|
|
59
58
|
render() {
|
|
60
|
-
const { classes, alignment, imageLoaded
|
|
59
|
+
const { classes, alignment, imageLoaded } = this.props;
|
|
60
|
+
|
|
61
61
|
return (
|
|
62
62
|
<div className={classes.holder}>
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
63
|
+
<AlignmentButton
|
|
64
|
+
alignment={'left'}
|
|
65
|
+
active={alignment === 'left'}
|
|
66
|
+
onClick={this.onAlignmentClick}
|
|
67
|
+
/>
|
|
68
|
+
<AlignmentButton
|
|
69
|
+
alignment={'center'}
|
|
70
|
+
active={alignment === 'center'}
|
|
71
|
+
onClick={this.onAlignmentClick}
|
|
72
|
+
/>
|
|
73
|
+
<AlignmentButton
|
|
74
|
+
alignment={'right'}
|
|
75
|
+
active={alignment === 'right'}
|
|
76
|
+
onClick={this.onAlignmentClick}
|
|
77
|
+
/>
|
|
70
78
|
<span
|
|
71
79
|
className={classNames({
|
|
72
80
|
[classes.disabled]: !imageLoaded,
|
|
73
|
-
[classes.altButton]:
|
|
81
|
+
[classes.altButton]: true
|
|
74
82
|
})}
|
|
75
|
-
onMouseDown={
|
|
83
|
+
onMouseDown={event => imageLoaded && this.renderDialog(event)}
|
|
76
84
|
>
|
|
77
85
|
Alt text
|
|
78
86
|
</span>
|
|
@@ -81,14 +89,14 @@ export class ImageToolbar extends React.Component {
|
|
|
81
89
|
}
|
|
82
90
|
}
|
|
83
91
|
|
|
84
|
-
const styles =
|
|
92
|
+
const styles = theme => ({
|
|
85
93
|
holder: {
|
|
86
94
|
paddingLeft: theme.spacing.unit,
|
|
87
95
|
display: 'flex',
|
|
88
|
-
alignItems: 'center'
|
|
96
|
+
alignItems: 'center'
|
|
89
97
|
},
|
|
90
98
|
disabled: {
|
|
91
|
-
opacity: 0.5
|
|
99
|
+
opacity: 0.5
|
|
92
100
|
},
|
|
93
101
|
altButton: {
|
|
94
102
|
borderLeft: '1px solid grey',
|