@pie-lib/editable-html 11.18.6-esmbeta.0 → 11.19.0-mui-update.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.
Files changed (136) hide show
  1. package/CHANGELOG.md +37 -0
  2. package/lib/block-tags.js +2 -3
  3. package/lib/block-tags.js.map +1 -1
  4. package/lib/constants.js +3 -6
  5. package/lib/constants.js.map +1 -1
  6. package/lib/editor.js +302 -450
  7. package/lib/editor.js.map +1 -1
  8. package/lib/index.js +19 -77
  9. package/lib/index.js.map +1 -1
  10. package/lib/parse-html.js +7 -7
  11. package/lib/parse-html.js.map +1 -1
  12. package/lib/plugins/characters/custom-popper.js +24 -44
  13. package/lib/plugins/characters/custom-popper.js.map +1 -1
  14. package/lib/plugins/characters/index.js +9 -60
  15. package/lib/plugins/characters/index.js.map +1 -1
  16. package/lib/plugins/characters/utils.js +3 -6
  17. package/lib/plugins/characters/utils.js.map +1 -1
  18. package/lib/plugins/css/icons/index.js +13 -25
  19. package/lib/plugins/css/icons/index.js.map +1 -1
  20. package/lib/plugins/css/index.js +22 -88
  21. package/lib/plugins/css/index.js.map +1 -1
  22. package/lib/plugins/customPlugin/index.js +10 -26
  23. package/lib/plugins/customPlugin/index.js.map +1 -1
  24. package/lib/plugins/html/icons/index.js +14 -26
  25. package/lib/plugins/html/icons/index.js.map +1 -1
  26. package/lib/plugins/html/index.js +4 -13
  27. package/lib/plugins/html/index.js.map +1 -1
  28. package/lib/plugins/image/alt-dialog.js +20 -49
  29. package/lib/plugins/image/alt-dialog.js.map +1 -1
  30. package/lib/plugins/image/component.js +119 -190
  31. package/lib/plugins/image/component.js.map +1 -1
  32. package/lib/plugins/image/image-toolbar.js +44 -86
  33. package/lib/plugins/image/image-toolbar.js.map +1 -1
  34. package/lib/plugins/image/index.js +6 -46
  35. package/lib/plugins/image/index.js.map +1 -1
  36. package/lib/plugins/image/insert-image-handler.js +10 -31
  37. package/lib/plugins/image/insert-image-handler.js.map +1 -1
  38. package/lib/plugins/index.js +44 -106
  39. package/lib/plugins/index.js.map +1 -1
  40. package/lib/plugins/list/index.js +27 -73
  41. package/lib/plugins/list/index.js.map +1 -1
  42. package/lib/plugins/math/index.js +64 -116
  43. package/lib/plugins/math/index.js.map +1 -1
  44. package/lib/plugins/media/index.js +23 -81
  45. package/lib/plugins/media/index.js.map +1 -1
  46. package/lib/plugins/media/media-dialog.js +192 -307
  47. package/lib/plugins/media/media-dialog.js.map +1 -1
  48. package/lib/plugins/media/media-toolbar.js +40 -65
  49. package/lib/plugins/media/media-toolbar.js.map +1 -1
  50. package/lib/plugins/media/media-wrapper.js +20 -49
  51. package/lib/plugins/media/media-wrapper.js.map +1 -1
  52. package/lib/plugins/rendering/index.js +5 -15
  53. package/lib/plugins/rendering/index.js.map +1 -1
  54. package/lib/plugins/respArea/drag-in-the-blank/choice.js +175 -249
  55. package/lib/plugins/respArea/drag-in-the-blank/choice.js.map +1 -1
  56. package/lib/plugins/respArea/drag-in-the-blank/index.js +39 -29
  57. package/lib/plugins/respArea/drag-in-the-blank/index.js.map +1 -1
  58. package/lib/plugins/respArea/explicit-constructed-response/index.js +3 -10
  59. package/lib/plugins/respArea/explicit-constructed-response/index.js.map +1 -1
  60. package/lib/plugins/respArea/icons/index.js +22 -45
  61. package/lib/plugins/respArea/icons/index.js.map +1 -1
  62. package/lib/plugins/respArea/index.js +5 -59
  63. package/lib/plugins/respArea/index.js.map +1 -1
  64. package/lib/plugins/respArea/inline-dropdown/index.js +2 -10
  65. package/lib/plugins/respArea/inline-dropdown/index.js.map +1 -1
  66. package/lib/plugins/respArea/math-templated/index.js +92 -109
  67. package/lib/plugins/respArea/math-templated/index.js.map +1 -1
  68. package/lib/plugins/respArea/utils.js +8 -40
  69. package/lib/plugins/respArea/utils.js.map +1 -1
  70. package/lib/plugins/table/CustomTablePlugin.js +24 -41
  71. package/lib/plugins/table/CustomTablePlugin.js.map +1 -1
  72. package/lib/plugins/table/icons/index.js +19 -35
  73. package/lib/plugins/table/icons/index.js.map +1 -1
  74. package/lib/plugins/table/index.js +41 -118
  75. package/lib/plugins/table/index.js.map +1 -1
  76. package/lib/plugins/table/table-toolbar.js +37 -87
  77. package/lib/plugins/table/table-toolbar.js.map +1 -1
  78. package/lib/plugins/textAlign/icons/index.js +18 -64
  79. package/lib/plugins/textAlign/icons/index.js.map +1 -1
  80. package/lib/plugins/textAlign/index.js +1 -6
  81. package/lib/plugins/textAlign/index.js.map +1 -1
  82. package/lib/plugins/toolbar/default-toolbar.js +30 -79
  83. package/lib/plugins/toolbar/default-toolbar.js.map +1 -1
  84. package/lib/plugins/toolbar/done-button.js +16 -34
  85. package/lib/plugins/toolbar/done-button.js.map +1 -1
  86. package/lib/plugins/toolbar/editor-and-toolbar.js +174 -201
  87. package/lib/plugins/toolbar/editor-and-toolbar.js.map +1 -1
  88. package/lib/plugins/toolbar/index.js +0 -5
  89. package/lib/plugins/toolbar/index.js.map +1 -1
  90. package/lib/plugins/toolbar/toolbar-buttons.js +57 -107
  91. package/lib/plugins/toolbar/toolbar-buttons.js.map +1 -1
  92. package/lib/plugins/toolbar/toolbar.js +95 -161
  93. package/lib/plugins/toolbar/toolbar.js.map +1 -1
  94. package/lib/plugins/utils.js +5 -25
  95. package/lib/plugins/utils.js.map +1 -1
  96. package/lib/serialization.js +44 -150
  97. package/lib/serialization.js.map +1 -1
  98. package/lib/shared/alert-dialog.js +23 -42
  99. package/lib/theme.js +1 -2
  100. package/lib/theme.js.map +1 -1
  101. package/package.json +15 -21
  102. package/src/__tests__/utils.js +1 -1
  103. package/src/editor.jsx +110 -108
  104. package/src/plugins/characters/custom-popper.js +20 -25
  105. package/src/plugins/css/icons/index.jsx +11 -13
  106. package/src/plugins/css/index.jsx +3 -5
  107. package/src/plugins/html/icons/index.jsx +12 -14
  108. package/src/plugins/image/alt-dialog.jsx +9 -8
  109. package/src/plugins/image/component.jsx +67 -87
  110. package/src/plugins/image/image-toolbar.jsx +26 -26
  111. package/src/plugins/image/index.jsx +1 -1
  112. package/src/plugins/index.jsx +10 -10
  113. package/src/plugins/math/index.jsx +1 -1
  114. package/src/plugins/media/index.jsx +2 -2
  115. package/src/plugins/media/media-dialog.js +65 -76
  116. package/src/plugins/media/media-toolbar.jsx +32 -33
  117. package/src/plugins/media/media-wrapper.jsx +10 -13
  118. package/src/plugins/respArea/drag-in-the-blank/choice.jsx +193 -180
  119. package/src/plugins/respArea/drag-in-the-blank/index.jsx +58 -22
  120. package/src/plugins/respArea/icons/index.jsx +16 -16
  121. package/src/plugins/respArea/math-templated/index.jsx +88 -89
  122. package/src/plugins/respArea/utils.jsx +1 -1
  123. package/src/plugins/table/icons/index.jsx +14 -16
  124. package/src/plugins/table/index.jsx +27 -19
  125. package/src/plugins/table/table-toolbar.jsx +17 -19
  126. package/src/plugins/textAlign/icons/index.jsx +3 -3
  127. package/src/plugins/toolbar/__tests__/default-toolbar.test.jsx +1 -1
  128. package/src/plugins/toolbar/__tests__/toolbar.test.jsx +1 -1
  129. package/src/plugins/toolbar/default-toolbar.jsx +18 -21
  130. package/src/plugins/toolbar/done-button.jsx +16 -22
  131. package/src/plugins/toolbar/editor-and-toolbar.jsx +134 -157
  132. package/src/plugins/toolbar/toolbar-buttons.jsx +29 -46
  133. package/src/plugins/toolbar/toolbar.jsx +60 -78
  134. package/esm/index.js +0 -111560
  135. package/esm/index.js.map +0 -1
  136. package/esm/package.json +0 -1
@@ -1,15 +1,66 @@
1
- import LinearProgress from '@material-ui/core/LinearProgress';
1
+ import LinearProgress from '@mui/material/LinearProgress';
2
2
  import PropTypes from 'prop-types';
3
3
  import React from 'react';
4
4
  import classNames from 'classnames';
5
5
  import debug from 'debug';
6
- import { withStyles } from '@material-ui/core/styles';
6
+ import { styled } from '@mui/material/styles';
7
7
  import SlatePropTypes from 'slate-prop-types';
8
8
 
9
9
  const log = debug('@pie-lib:editable-html:plugins:image:component');
10
10
 
11
11
  const size = (s) => (s ? `${s}px` : 'auto');
12
12
 
13
+ const StyledImageRoot = styled('div')(({ theme }) => ({
14
+ position: 'relative',
15
+ border: `solid 1px ${theme.palette.common.white}`,
16
+ display: 'flex',
17
+ transition: 'opacity 200ms linear',
18
+ '&.loading': {
19
+ opacity: 0.3,
20
+ },
21
+ '&.pendingDelete': {
22
+ opacity: 0.3,
23
+ },
24
+ }));
25
+
26
+ const StyledProgress = styled(LinearProgress)(() => ({
27
+ position: 'absolute',
28
+ left: '0',
29
+ width: 'fit-content',
30
+ top: '0%',
31
+ transition: 'opacity 200ms linear',
32
+ '&.hideProgress': {
33
+ opacity: 0,
34
+ },
35
+ }));
36
+
37
+ const StyledImageContainer = styled('div')(() => ({
38
+ position: 'relative',
39
+ width: 'fit-content',
40
+ display: 'flex',
41
+ alignItems: 'center',
42
+ '&&:hover > .resize': {
43
+ display: 'block',
44
+ },
45
+ }));
46
+
47
+ const StyledImage = styled('img')(({ theme }) => ({
48
+ '&.active': {
49
+ border: `solid 1px ${theme.palette.primary.main}`,
50
+ },
51
+ }));
52
+
53
+ const StyledResize = styled('div')(({ theme }) => ({
54
+ backgroundColor: theme.palette.primary.main,
55
+ cursor: 'col-resize',
56
+ height: '35px',
57
+ width: '5px',
58
+ borderRadius: 8,
59
+ marginLeft: '5px',
60
+ marginRight: '10px',
61
+ display: 'none',
62
+ }));
63
+
13
64
  export class Component extends React.Component {
14
65
  static propTypes = {
15
66
  node: SlatePropTypes.node.isRequired,
@@ -17,7 +68,6 @@ export class Component extends React.Component {
17
68
  change: PropTypes.func.isRequired,
18
69
  value: PropTypes.object,
19
70
  }).isRequired,
20
- classes: PropTypes.object.isRequired,
21
71
  attributes: PropTypes.object,
22
72
  onFocus: PropTypes.func,
23
73
  onBlur: PropTypes.func,
@@ -201,7 +251,7 @@ export class Component extends React.Component {
201
251
  };
202
252
 
203
253
  render() {
204
- const { node, editor, classes, attributes, onFocus } = this.props;
254
+ const { node, editor, attributes, onFocus } = this.props;
205
255
  const active = editor.value.isFocused && editor.value.selection.hasEdgeIn(node);
206
256
  const src = node.data.get('src');
207
257
  const loaded = node.data.get('loaded') !== false;
@@ -235,21 +285,20 @@ export class Component extends React.Component {
235
285
  log('[render] style:', size);
236
286
 
237
287
  const className = classNames(
238
- classes.root,
239
- !loaded && classes.loading,
240
- deleteStatus === 'pending' && classes.pendingDelete,
288
+ !loaded && 'loading',
289
+ deleteStatus === 'pending' && 'pendingDelete',
241
290
  );
242
291
 
243
- const progressClasses = classNames(classes.progress, loaded && classes.hideProgress);
292
+ const progressClasses = classNames(loaded && 'hideProgress');
244
293
 
245
294
  return [
246
295
  <span key={'sp1'}>&nbsp;</span>,
247
- <div key={'comp'} onFocus={onFocus} className={className} style={{ justifyContent }}>
248
- <LinearProgress mode="determinate" value={percent > 0 ? percent : 0} className={progressClasses} />
249
- <div className={classes.imageContainer}>
250
- <img
296
+ <StyledImageRoot key={'comp'} onFocus={onFocus} className={className} style={{ justifyContent }}>
297
+ <StyledProgress mode="determinate" value={percent > 0 ? percent : 0} className={progressClasses} />
298
+ <StyledImageContainer>
299
+ <StyledImage
251
300
  {...attributes}
252
- className={classNames(classes.image, active && classes.active)}
301
+ className={classNames(active && 'active')}
253
302
  ref={(ref) => {
254
303
  this.img = ref;
255
304
  }}
@@ -258,86 +307,17 @@ export class Component extends React.Component {
258
307
  onLoad={this.loadImage}
259
308
  alt={alt}
260
309
  />
261
- <div
310
+ <StyledResize
262
311
  ref={(ref) => {
263
312
  this.resize = ref;
264
313
  }}
265
- className={classNames(classes.resize, 'resize')}
314
+ className="resize"
266
315
  />
267
- </div>
268
- </div>,
316
+ </StyledImageContainer>
317
+ </StyledImageRoot>,
269
318
  <span key={'sp2'}>&nbsp;</span>,
270
319
  ];
271
320
  }
272
321
  }
273
322
 
274
- const styles = (theme) => ({
275
- portal: {
276
- position: 'absolute',
277
- opacity: 0,
278
- transition: 'opacity 200ms linear',
279
- },
280
- floatingButtonRow: {
281
- backgroundColor: theme.palette.background.paper,
282
- borderRadius: '1px',
283
- display: 'flex',
284
- padding: '10px',
285
- border: `solid 1px ${theme.palette.grey[200]}`,
286
- boxShadow:
287
- '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)',
288
- },
289
- progress: {
290
- position: 'absolute',
291
- left: '0',
292
- width: 'fit-content',
293
- top: '0%',
294
- transition: 'opacity 200ms linear',
295
- },
296
- hideProgress: {
297
- opacity: 0,
298
- },
299
- loading: {
300
- opacity: 0.3,
301
- },
302
- pendingDelete: {
303
- opacity: 0.3,
304
- },
305
- root: {
306
- position: 'relative',
307
- border: `solid 1px ${theme.palette.common.white}`,
308
- display: 'flex',
309
- transition: 'opacity 200ms linear',
310
- },
311
- delete: {
312
- position: 'absolute',
313
- right: 0,
314
- },
315
- imageContainer: {
316
- position: 'relative',
317
- width: 'fit-content',
318
- display: 'flex',
319
- alignItems: 'center',
320
-
321
- '&&:hover > .resize': {
322
- display: 'block',
323
- },
324
- },
325
- active: {
326
- border: `solid 1px ${theme.palette.primary.main}`,
327
- },
328
- resize: {
329
- backgroundColor: theme.palette.primary.main,
330
- cursor: 'col-resize',
331
- height: '35px',
332
- width: '5px',
333
- borderRadius: 8,
334
- marginLeft: '5px',
335
- marginRight: '10px',
336
- display: 'none',
337
- },
338
- drawableHeight: {
339
- minHeight: 350,
340
- },
341
- });
342
-
343
- export default withStyles(styles)(Component);
323
+ export default Component;
@@ -2,7 +2,7 @@ import PropTypes from 'prop-types';
2
2
  import React from 'react';
3
3
  import debug from 'debug';
4
4
  import ReactDOM from 'react-dom';
5
- import { withStyles } from '@material-ui/core/styles';
5
+ import { styled } from '@mui/material/styles';
6
6
  import classNames from 'classnames';
7
7
 
8
8
  import { MarkButton } from '../toolbar/toolbar-buttons';
@@ -24,10 +24,26 @@ AlignmentButton.propTypes = {
24
24
  onClick: PropTypes.func.isRequired,
25
25
  };
26
26
 
27
+ const StyledHolder = styled('div')(({ theme }) => ({
28
+ paddingLeft: theme.spacing(1),
29
+ display: 'flex',
30
+ alignItems: 'center',
31
+ }));
32
+
33
+ const StyledAltText = styled('span')(() => ({
34
+ '&.disabled': {
35
+ opacity: 0.5,
36
+ },
37
+ '&.altButton': {
38
+ borderLeft: '1px solid grey',
39
+ paddingLeft: 8,
40
+ marginLeft: 4,
41
+ },
42
+ }));
43
+
27
44
  export class ImageToolbar extends React.Component {
28
45
  static propTypes = {
29
46
  onChange: PropTypes.func.isRequired,
30
- classes: PropTypes.object.isRequired,
31
47
  alignment: PropTypes.string,
32
48
  alt: PropTypes.string,
33
49
  imageLoaded: PropTypes.bool,
@@ -57,9 +73,9 @@ export class ImageToolbar extends React.Component {
57
73
  };
58
74
 
59
75
  render() {
60
- const { classes, alignment, imageLoaded, disableImageAlignmentButtons } = this.props;
76
+ const { alignment, imageLoaded, disableImageAlignmentButtons } = this.props;
61
77
  return (
62
- <div className={classes.holder}>
78
+ <StyledHolder>
63
79
  {!disableImageAlignmentButtons && (
64
80
  <>
65
81
  <AlignmentButton alignment={'left'} active={alignment === 'left'} onClick={this.onAlignmentClick} />
@@ -67,34 +83,18 @@ export class ImageToolbar extends React.Component {
67
83
  <AlignmentButton alignment={'right'} active={alignment === 'right'} onClick={this.onAlignmentClick} />
68
84
  </>
69
85
  )}
70
- <span
86
+ <StyledAltText
71
87
  className={classNames({
72
- [classes.disabled]: !imageLoaded,
73
- [classes.altButton]: !disableImageAlignmentButtons,
88
+ disabled: !imageLoaded,
89
+ altButton: !disableImageAlignmentButtons,
74
90
  })}
75
91
  onMouseDown={(event) => imageLoaded && this.renderDialog(event)}
76
92
  >
77
93
  Alt text
78
- </span>
79
- </div>
94
+ </StyledAltText>
95
+ </StyledHolder>
80
96
  );
81
97
  }
82
98
  }
83
99
 
84
- const styles = (theme) => ({
85
- holder: {
86
- paddingLeft: theme.spacing.unit,
87
- display: 'flex',
88
- alignItems: 'center',
89
- },
90
- disabled: {
91
- opacity: 0.5,
92
- },
93
- altButton: {
94
- borderLeft: '1px solid grey',
95
- paddingLeft: 8,
96
- marginLeft: 4,
97
- },
98
- });
99
-
100
- export default withStyles(styles)(ImageToolbar);
100
+ export default ImageToolbar;
@@ -1,6 +1,6 @@
1
1
  import { Data, Inline } from 'slate';
2
2
 
3
- import Image from '@material-ui/icons/Image';
3
+ import Image from '@mui/icons-material/Image';
4
4
  import ImageComponent from './component';
5
5
  import ImageToolbar from './image-toolbar';
6
6
  import InsertImageHandler from './insert-image-handler';
@@ -1,22 +1,22 @@
1
1
  import Hotkeys from 'slate-hotkeys';
2
2
  import { IS_IOS } from 'slate-dev-environment';
3
3
  import { Mark } from 'slate';
4
- import Bold from '@material-ui/icons/FormatBold';
5
- import FormatQuote from '@material-ui/icons/FormatQuote';
6
- //import Code from '@material-ui/icons/Code';
7
- import BulletedListIcon from '@material-ui/icons/FormatListBulleted';
8
- import NumberedListIcon from '@material-ui/icons/FormatListNumbered';
9
- import Redo from '@material-ui/icons/Redo';
10
- import Undo from '@material-ui/icons/Undo';
4
+ import Bold from '@mui/icons-material/FormatBold';
5
+ import FormatQuote from '@mui/icons-material/FormatQuote';
6
+ //import Code from '@mui/icons-material/Code';
7
+ import BulletedListIcon from '@mui/icons-material/FormatListBulleted';
8
+ import NumberedListIcon from '@mui/icons-material/FormatListNumbered';
9
+ import Redo from '@mui/icons-material/Redo';
10
+ import Undo from '@mui/icons-material/Undo';
11
11
  import ImagePlugin from './image';
12
12
  import MediaPlugin from './media';
13
13
  import CharactersPlugin from './characters';
14
- import Italic from '@material-ui/icons/FormatItalic';
14
+ import Italic from '@mui/icons-material/FormatItalic';
15
15
  import MathPlugin from './math';
16
16
  import React from 'react';
17
- import Strikethrough from '@material-ui/icons/FormatStrikethrough';
17
+ import Strikethrough from '@mui/icons-material/FormatStrikethrough';
18
18
  import ToolbarPlugin from './toolbar';
19
- import Underline from '@material-ui/icons/FormatUnderlined';
19
+ import Underline from '@mui/icons-material/FormatUnderlined';
20
20
  import compact from 'lodash/compact';
21
21
  import isEmpty from 'lodash/isEmpty';
22
22
  import SoftBreakPlugin from 'slate-soft-break';
@@ -1,4 +1,4 @@
1
- import Functions from '@material-ui/icons/Functions';
1
+ import Functions from '@mui/icons-material/Functions';
2
2
  import { Inline } from 'slate';
3
3
  import { MathPreview, MathToolbar } from '@pie-lib/math-toolbar';
4
4
  import { wrapMath, unWrapMath, mmlToLatex, renderMath } from '@pie-lib/math-rendering';
@@ -1,8 +1,8 @@
1
1
  import React from 'react';
2
2
  import ReactDOM from 'react-dom';
3
3
  import { Inline } from 'slate';
4
- import TheatersIcon from '@material-ui/icons/Theaters';
5
- import VolumeUpIcon from '@material-ui/icons/VolumeUp';
4
+ import TheatersIcon from '@mui/icons-material/Theaters';
5
+ import VolumeUpIcon from '@mui/icons-material/VolumeUp';
6
6
  import debug from 'debug';
7
7
 
8
8
  import MediaDialog from './media-dialog';
@@ -1,20 +1,19 @@
1
1
  import React from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
  import debug from 'debug';
4
- import { color } from '@pie-lib/render-ui';
5
- import { withStyles } from '@material-ui/core/styles';
6
- import Button from '@material-ui/core/Button';
7
- import Dialog from '@material-ui/core/Dialog';
8
- import MuiTabs from '@material-ui/core/Tabs';
9
- import MuiTab from '@material-ui/core/Tab';
10
- import DialogTitle from '@material-ui/core/DialogTitle';
11
- import DialogContent from '@material-ui/core/DialogContent';
12
- import DialogContentText from '@material-ui/core/DialogContentText';
13
- import DialogActions from '@material-ui/core/DialogActions';
14
- import TextField from '@material-ui/core/TextField';
15
- import Typography from '@material-ui/core/Typography';
16
- import IconButton from '@material-ui/core/IconButton';
17
- import ActionDelete from '@material-ui/icons/Delete';
4
+ import { styled } from '@mui/material/styles';
5
+ import Button from '@mui/material/Button';
6
+ import Dialog from '@mui/material/Dialog';
7
+ import MuiTabs from '@mui/material/Tabs';
8
+ import MuiTab from '@mui/material/Tab';
9
+ import DialogTitle from '@mui/material/DialogTitle';
10
+ import DialogContent from '@mui/material/DialogContent';
11
+ import DialogContentText from '@mui/material/DialogContentText';
12
+ import DialogActions from '@mui/material/DialogActions';
13
+ import TextField from '@mui/material/TextField';
14
+ import Typography from '@mui/material/Typography';
15
+ import IconButton from '@mui/material/IconButton';
16
+ import ActionDelete from '@mui/icons-material/Delete';
18
17
 
19
18
  const log = debug('@pie-lib:editable-html:plugins:media:dialog');
20
19
 
@@ -82,9 +81,38 @@ const tabsTypeMap = {
82
81
  insertUrl: 'insert-url',
83
82
  };
84
83
 
84
+ const StyledDialog = styled(Dialog)(() => ({
85
+ '& .MuiPaper-root': {
86
+ minWidth: '500px',
87
+ },
88
+ }));
89
+
90
+ const StyledDialogContent = styled(DialogContent)(() => ({
91
+ '&.properties': {
92
+ padding: 0,
93
+ },
94
+ }));
95
+
96
+ const StyledRow = styled('div')(() => ({
97
+ display: 'flex',
98
+ flexDirection: 'space-between',
99
+ }));
100
+
101
+ const StyledUploadInput = styled('div')(({ theme }) => ({
102
+ marginTop: theme.spacing(1.5),
103
+ }));
104
+
105
+ const StyledError = styled(Typography)(({ theme }) => ({
106
+ marginTop: theme.spacing(1.5),
107
+ color: theme.palette.error.main,
108
+ }));
109
+
110
+ const StyledDeleteIcon = styled(IconButton)(({ theme }) => ({
111
+ marginLeft: theme.spacing(1.5),
112
+ }));
113
+
85
114
  export class MediaDialog extends React.Component {
86
115
  static propTypes = {
87
- classes: PropTypes.object.isRequired,
88
116
  open: PropTypes.bool,
89
117
  edit: PropTypes.bool,
90
118
  disablePortal: PropTypes.bool,
@@ -404,7 +432,7 @@ export class MediaDialog extends React.Component {
404
432
  };
405
433
 
406
434
  render() {
407
- const { classes, open, disablePortal, type, edit, uploadSoundSupport } = this.props;
435
+ const { open, disablePortal, type, edit, uploadSoundSupport } = this.props;
408
436
  const {
409
437
  ends,
410
438
  height,
@@ -427,10 +455,7 @@ export class MediaDialog extends React.Component {
427
455
  const showUploadFile = uploadSoundSupport?.add && uploadSoundSupport?.delete && type !== 'video';
428
456
 
429
457
  return (
430
- <Dialog
431
- classes={{
432
- paper: classes.paper,
433
- }}
458
+ <StyledDialog
434
459
  disablePortal={disablePortal}
435
460
  open={open}
436
461
  onClose={() => this.handleDone(false)}
@@ -439,7 +464,7 @@ export class MediaDialog extends React.Component {
439
464
  <DialogTitle id="form-dialog-title">Insert {typeMap[type]}</DialogTitle>
440
465
  <DialogContent>
441
466
  <div>
442
- <div className={classes.row}>
467
+ <StyledRow>
443
468
  <MuiTabs
444
469
  indicatorColor="primary"
445
470
  value={tabValue}
@@ -453,7 +478,7 @@ export class MediaDialog extends React.Component {
453
478
  label={type === 'video' ? 'Insert YouTube, Vimeo, or Google Drive URL' : 'Insert SoundCloud URL'}
454
479
  />
455
480
  </MuiTabs>
456
- </div>
481
+ </StyledRow>
457
482
  {isInsertURL && (
458
483
  <div>
459
484
  <TextField
@@ -470,11 +495,7 @@ export class MediaDialog extends React.Component {
470
495
  fullWidth
471
496
  />
472
497
  {type === 'video' && (
473
- <DialogContent
474
- classes={{
475
- root: classes.properties,
476
- }}
477
- >
498
+ <StyledDialogContent className="properties">
478
499
  <DialogContentText>Video Properties</DialogContentText>
479
500
  <TextField
480
501
  autoFocus
@@ -496,7 +517,7 @@ export class MediaDialog extends React.Component {
496
517
  value={height}
497
518
  onChange={this.changeHandler('height')}
498
519
  />
499
- </DialogContent>
520
+ </StyledDialogContent>
500
521
  )}
501
522
  {formattedUrl && (
502
523
  <iframe
@@ -510,11 +531,7 @@ export class MediaDialog extends React.Component {
510
531
  )}
511
532
  {type === 'video' && (formattedUrl || updating) && !invalid && (
512
533
  <React.Fragment>
513
- <DialogContent
514
- classes={{
515
- root: classes.properties,
516
- }}
517
- >
534
+ <StyledDialogContent className="properties">
518
535
  <TextField
519
536
  autoFocus
520
537
  margin="dense"
@@ -537,24 +554,27 @@ export class MediaDialog extends React.Component {
537
554
  onChange={this.changeHandler('ends')}
538
555
  />
539
556
  )}
540
- </DialogContent>
557
+ </StyledDialogContent>
541
558
  </React.Fragment>
542
559
  )}
543
560
  </div>
544
561
  )}
545
562
  {isUploadMedia && (
546
- <div className={classes.uploadInput}>
563
+ <StyledUploadInput>
547
564
  <div>
548
565
  {fileUpload.url ? (
549
566
  <>
550
- <div className={classes.row}>
567
+ <StyledRow>
551
568
  <audio controls="controls" controlsList="nodownload">
552
569
  <source type={mimeType} src={fileUpload.url} />
553
570
  </audio>
554
- <IconButton aria-label="delete" className={classes.deleteIcon} onClick={this.handleRemoveFile}>
571
+ <StyledDeleteIcon
572
+ aria-label="delete"
573
+ onClick={this.handleRemoveFile}
574
+ size="large">
555
575
  <ActionDelete />
556
- </IconButton>
557
- </div>
576
+ </StyledDeleteIcon>
577
+ </StyledRow>
558
578
  {!fileUpload.scheduled && fileUpload.loading ? (
559
579
  <Typography variant="subheading">Loading...</Typography>
560
580
  ) : null}
@@ -565,15 +585,15 @@ export class MediaDialog extends React.Component {
565
585
  ) : null}
566
586
  </>
567
587
  ) : !fileUpload.loading ? (
568
- <input accept="audio/*" className={classes.input} onChange={this.handleUploadFile} type="file" />
588
+ <input accept="audio/*" onChange={this.handleUploadFile} type="file" />
569
589
  ) : null}
570
590
  {!!fileUpload.error && (
571
- <Typography className={classes.error} variant="caption">
591
+ <StyledError variant="caption">
572
592
  {fileUpload.error}
573
- </Typography>
593
+ </StyledError>
574
594
  )}
575
595
  </div>
576
- </div>
596
+ </StyledUploadInput>
577
597
  )}
578
598
  </div>
579
599
  </DialogContent>
@@ -585,40 +605,9 @@ export class MediaDialog extends React.Component {
585
605
  {edit ? 'Update' : 'Insert'}
586
606
  </Button>
587
607
  </DialogActions>
588
- </Dialog>
608
+ </StyledDialog>
589
609
  );
590
610
  }
591
611
  }
592
612
 
593
- const styles = (theme) => ({
594
- paper: {
595
- minWidth: '500px',
596
- },
597
- properties: {
598
- padding: 0,
599
- },
600
- row: {
601
- display: 'flex',
602
- flexDirection: 'space-between',
603
- },
604
- rowItem: {
605
- marginRight: theme.spacing.unit * 1.5,
606
- cursor: 'pointer',
607
- },
608
- active: {
609
- color: color.primary(),
610
- borderBottom: `2px solid ${color.primary()}`,
611
- },
612
- uploadInput: {
613
- marginTop: theme.spacing.unit * 1.5,
614
- },
615
- error: {
616
- marginTop: theme.spacing.unit * 1.5,
617
- color: theme.palette.error.main,
618
- },
619
- deleteIcon: {
620
- marginLeft: theme.spacing.unit * 1.5,
621
- },
622
- });
623
-
624
- export default withStyles(styles)(MediaDialog);
613
+ export default MediaDialog;