@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.
Files changed (144) hide show
  1. package/CHANGELOG.md +0 -302
  2. package/lib/components.js +116 -0
  3. package/lib/components.js.map +1 -0
  4. package/lib/editor.js +418 -103
  5. package/lib/editor.js.map +1 -1
  6. package/lib/index.js +101 -155
  7. package/lib/index.js.map +1 -1
  8. package/lib/new-serialization.js +320 -0
  9. package/lib/new-serialization.js.map +1 -0
  10. package/lib/old-serialization.js +330 -0
  11. package/lib/parse-html.js +1 -1
  12. package/lib/parse-html.js.map +1 -1
  13. package/lib/plugins/characters/custom-popper.js +1 -1
  14. package/lib/plugins/characters/custom-popper.js.map +1 -1
  15. package/lib/plugins/characters/index.js +21 -19
  16. package/lib/plugins/characters/index.js.map +1 -1
  17. package/lib/plugins/characters/utils.js +1 -1
  18. package/lib/plugins/characters/utils.js.map +1 -1
  19. package/lib/plugins/hotKeys/index.js +67 -0
  20. package/lib/plugins/hotKeys/index.js.map +1 -0
  21. package/lib/plugins/image/alt-dialog.js +1 -6
  22. package/lib/plugins/image/alt-dialog.js.map +1 -1
  23. package/lib/plugins/image/component.js +70 -53
  24. package/lib/plugins/image/component.js.map +1 -1
  25. package/lib/plugins/image/image-toolbar.js +7 -9
  26. package/lib/plugins/image/image-toolbar.js.map +1 -1
  27. package/lib/plugins/image/index.js +83 -27
  28. package/lib/plugins/image/index.js.map +1 -1
  29. package/lib/plugins/image/insert-image-handler.js +72 -33
  30. package/lib/plugins/image/insert-image-handler.js.map +1 -1
  31. package/lib/plugins/index.js +23 -41
  32. package/lib/plugins/index.js.map +1 -1
  33. package/lib/plugins/list/index.js +64 -100
  34. package/lib/plugins/list/index.js.map +1 -1
  35. package/lib/plugins/math/index.js +86 -60
  36. package/lib/plugins/math/index.js.map +1 -1
  37. package/lib/plugins/media/index.js +202 -132
  38. package/lib/plugins/media/index.js.map +1 -1
  39. package/lib/plugins/media/media-dialog.js +17 -16
  40. package/lib/plugins/media/media-dialog.js.map +1 -1
  41. package/lib/plugins/media/media-toolbar.js +3 -3
  42. package/lib/plugins/media/media-toolbar.js.map +1 -1
  43. package/lib/plugins/media/media-wrapper.js +21 -58
  44. package/lib/plugins/media/media-wrapper.js.map +1 -1
  45. package/lib/plugins/respArea/drag-in-the-blank/choice.js +3 -3
  46. package/lib/plugins/respArea/drag-in-the-blank/choice.js.map +1 -1
  47. package/lib/plugins/respArea/drag-in-the-blank/index.js +3 -2
  48. package/lib/plugins/respArea/drag-in-the-blank/index.js.map +1 -1
  49. package/lib/plugins/respArea/explicit-constructed-response/index.js +3 -2
  50. package/lib/plugins/respArea/explicit-constructed-response/index.js.map +1 -1
  51. package/lib/plugins/respArea/icons/index.js +13 -15
  52. package/lib/plugins/respArea/icons/index.js.map +1 -1
  53. package/lib/plugins/respArea/index.js +87 -53
  54. package/lib/plugins/respArea/index.js.map +1 -1
  55. package/lib/plugins/respArea/inline-dropdown/index.js +4 -3
  56. package/lib/plugins/respArea/inline-dropdown/index.js.map +1 -1
  57. package/lib/plugins/respArea/utils.js +17 -20
  58. package/lib/plugins/respArea/utils.js.map +1 -1
  59. package/lib/plugins/table/icons/index.js +1 -1
  60. package/lib/plugins/table/icons/index.js.map +1 -1
  61. package/lib/plugins/table/index.js +381 -212
  62. package/lib/plugins/table/index.js.map +1 -1
  63. package/lib/plugins/table/table-toolbar.js +5 -6
  64. package/lib/plugins/table/table-toolbar.js.map +1 -1
  65. package/lib/plugins/toolbar/default-toolbar.js +55 -11
  66. package/lib/plugins/toolbar/default-toolbar.js.map +1 -1
  67. package/lib/plugins/toolbar/done-button.js +1 -1
  68. package/lib/plugins/toolbar/done-button.js.map +1 -1
  69. package/lib/plugins/toolbar/editor-and-toolbar.js +186 -232
  70. package/lib/plugins/toolbar/editor-and-toolbar.js.map +1 -1
  71. package/lib/plugins/toolbar/index.js +1 -2
  72. package/lib/plugins/toolbar/index.js.map +1 -1
  73. package/lib/plugins/toolbar/toolbar-buttons.js +1 -1
  74. package/lib/plugins/toolbar/toolbar-buttons.js.map +1 -1
  75. package/lib/plugins/toolbar/toolbar.js +253 -239
  76. package/lib/plugins/toolbar/toolbar.js.map +1 -1
  77. package/lib/plugins/utils.js +27 -2
  78. package/lib/plugins/utils.js.map +1 -1
  79. package/lib/serialization.js +1 -1
  80. package/lib/serialization.js.map +1 -1
  81. package/lib/slate-editor.js +302 -0
  82. package/lib/test-serializer.js +189 -0
  83. package/lib/test-serializer.js.map +1 -0
  84. package/lib/theme.js +1 -1
  85. package/lib/theme.js.map +1 -1
  86. package/package.json +18 -14
  87. package/playground/image/data.js +20 -20
  88. package/playground/image/index.html +22 -20
  89. package/playground/image/index.jsx +12 -10
  90. package/playground/index.html +25 -23
  91. package/playground/mathquill/index.html +23 -20
  92. package/playground/mathquill/index.jsx +18 -22
  93. package/playground/prod-test/index.html +24 -20
  94. package/playground/prod-test/index.jsx +5 -3
  95. package/playground/schema-override/data.js +10 -10
  96. package/playground/schema-override/image-plugin.jsx +3 -4
  97. package/playground/schema-override/index.html +21 -19
  98. package/playground/schema-override/index.jsx +13 -14
  99. package/playground/serialization/data.js +10 -10
  100. package/playground/serialization/image-plugin.jsx +3 -4
  101. package/playground/serialization/index.html +22 -20
  102. package/playground/table-examples.html +5 -8
  103. package/playground/webpack.config.js +10 -10
  104. package/src/components.js +135 -0
  105. package/src/editor.jsx +478 -141
  106. package/src/index.jsx +71 -95
  107. package/src/new-serialization.jsx +291 -0
  108. package/src/parse-html.js +1 -1
  109. package/src/plugins/characters/custom-popper.js +7 -7
  110. package/src/plugins/characters/index.jsx +33 -34
  111. package/src/plugins/characters/utils.js +81 -81
  112. package/src/plugins/hotKeys/index.js +54 -0
  113. package/src/plugins/image/alt-dialog.jsx +4 -5
  114. package/src/plugins/image/component.jsx +106 -89
  115. package/src/plugins/image/image-toolbar.jsx +27 -19
  116. package/src/plugins/image/index.jsx +75 -43
  117. package/src/plugins/image/insert-image-handler.js +62 -27
  118. package/src/plugins/index.jsx +23 -41
  119. package/src/plugins/list/index.jsx +70 -95
  120. package/src/plugins/math/index.jsx +102 -82
  121. package/src/plugins/media/index.jsx +159 -124
  122. package/src/plugins/media/media-dialog.js +98 -71
  123. package/src/plugins/media/media-toolbar.jsx +8 -8
  124. package/src/plugins/media/media-wrapper.jsx +29 -30
  125. package/src/plugins/respArea/drag-in-the-blank/choice.jsx +21 -19
  126. package/src/plugins/respArea/drag-in-the-blank/index.jsx +14 -11
  127. package/src/plugins/respArea/explicit-constructed-response/index.jsx +7 -6
  128. package/src/plugins/respArea/icons/index.jsx +11 -14
  129. package/src/plugins/respArea/index.jsx +92 -52
  130. package/src/plugins/respArea/inline-dropdown/index.jsx +9 -8
  131. package/src/plugins/respArea/utils.jsx +26 -35
  132. package/src/plugins/table/icons/index.jsx +17 -11
  133. package/src/plugins/table/index.jsx +288 -231
  134. package/src/plugins/table/table-toolbar.jsx +15 -11
  135. package/src/plugins/toolbar/default-toolbar.jsx +65 -19
  136. package/src/plugins/toolbar/done-button.jsx +4 -4
  137. package/src/plugins/toolbar/editor-and-toolbar.jsx +150 -145
  138. package/src/plugins/toolbar/index.jsx +2 -3
  139. package/src/plugins/toolbar/toolbar-buttons.jsx +11 -11
  140. package/src/plugins/toolbar/toolbar.jsx +244 -221
  141. package/src/plugins/utils.js +21 -4
  142. package/src/serialization.jsx +32 -32
  143. package/src/test-serializer.js +139 -0
  144. 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 SlatePropTypes from 'slate-prop-types';
9
+ import { Editor } from 'slate';
8
10
 
9
11
  const log = debug('@pie-lib:editable-html:plugins:image:component');
10
12
 
11
- const size = (s) => (s ? `${s}px` : 'auto');
13
+ const size = s => (s ? `${s}px` : 'auto');
12
14
 
13
15
  export class Component extends React.Component {
14
16
  static propTypes = {
15
- node: SlatePropTypes.node.isRequired,
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 = (percent) => {
35
+ getWidth = percent => {
29
36
  const multiplier = percent / 100;
30
37
  return this.img.naturalWidth * multiplier;
31
38
  };
32
39
 
33
- getHeight = (percent) => {
40
+ getHeight = percent => {
34
41
  const multiplier = percent / 100;
35
42
  return this.img.naturalHeight * multiplier;
36
43
  };
37
44
 
38
- getPercentFromWidth = (width) => {
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.set('resizePercent', this.getPercentFromWidth(w));
58
+ update = update.resizePercent = this.getPercentFromWidth(w);
51
59
  }
52
60
 
53
61
  log('[applySizeData] update: ', update);
54
62
 
55
- if (!update.equals(node.data)) {
56
- editor.change((c) => c.setNodeByKey(node.key, { data: update }));
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.get('width')),
82
- height: size(data.get('height')),
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
- let update = node.data;
136
+ const update = cloneDeep(node.data);
120
137
 
121
- update = update.set('width', width);
122
- update = update.set('height', height);
138
+ update.width = width;
139
+ update.height = height;
123
140
 
124
- if (!update.equals(node.data)) {
125
- editor.change((c) => c.setNodeByKey(node.key, { data: update }));
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 = (e) => {
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((c) => c.setNodeByKey(node.key, { data: update }));
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, editor, classes, attributes, onFocus } = this.props;
205
- const active = editor.value.isFocused && editor.value.selection.hasEdgeIn(node);
206
- const src = node.data.get('src');
207
- const loaded = node.data.get('loaded') !== false;
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.root,
244
- !loaded && classes.loading,
245
- deleteStatus === 'pending' && classes.pendingDelete,
246
- );
247
-
248
- const progressClasses = classNames(classes.progress, loaded && classes.hideProgress);
249
-
250
- return [
251
- <span key={'sp1'}>&nbsp;</span>,
252
- <div key={'comp'} onFocus={onFocus} className={className} style={{ justifyContent }}>
253
- <LinearProgress mode="determinate" value={percent > 0 ? percent : 0} className={progressClasses} />
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
- {...attributes}
257
- className={classNames(classes.image, active && classes.active)}
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={(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
- <span key={'sp2'}>&nbsp;</span>,
275
- ];
291
+ </div>
292
+ );
276
293
  }
277
294
  }
278
295
 
279
- const styles = (theme) => ({
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: theme.palette.background.paper,
303
+ backgroundColor: 'white',
287
304
  borderRadius: '1px',
288
305
  display: 'flex',
289
306
  padding: '10px',
290
- border: `solid 1px ${theme.palette.grey[200]}`,
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: `solid 1px ${theme.palette.common.white}`,
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 = (newAlt) => {
36
+ onAltTextDone = newAlt => {
38
37
  log('[onAltTextDone]: alt:', newAlt);
39
38
 
40
- this.props.onChange({ alt: newAlt }, true);
39
+ this.props.onChange({ alt: newAlt });
41
40
  };
42
41
 
43
- onAlignmentClick = (alignment) => {
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, disableImageAlignmentButtons } = this.props;
59
+ const { classes, alignment, imageLoaded } = this.props;
60
+
61
61
  return (
62
62
  <div className={classes.holder}>
63
- {!disableImageAlignmentButtons && (
64
- <>
65
- <AlignmentButton alignment={'left'} active={alignment === 'left'} onClick={this.onAlignmentClick} />
66
- <AlignmentButton alignment={'center'} active={alignment === 'center'} onClick={this.onAlignmentClick} />
67
- <AlignmentButton alignment={'right'} active={alignment === 'right'} onClick={this.onAlignmentClick} />
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]: !disableImageAlignmentButtons,
81
+ [classes.altButton]: true
74
82
  })}
75
- onMouseDown={(event) => imageLoaded && this.renderDialog(event)}
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 = (theme) => ({
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',