@pie-lib/editable-html-tip-tap 1.0.20 → 1.0.21-next.6053

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 (101) hide show
  1. package/CHANGELOG.md +7 -73
  2. package/LICENSE.md +5 -0
  3. package/NEXT.CHANGELOG.json +1 -0
  4. package/lib/components/CharacterPicker.js +20 -60
  5. package/lib/components/CharacterPicker.js.map +1 -1
  6. package/lib/components/EditableHtml.js +50 -121
  7. package/lib/components/EditableHtml.js.map +1 -1
  8. package/lib/components/MenuBar.js +96 -128
  9. package/lib/components/MenuBar.js.map +1 -1
  10. package/lib/components/TiptapContainer.js +162 -45
  11. package/lib/components/TiptapContainer.js.map +1 -1
  12. package/lib/components/characters/characterUtils.js +4 -7
  13. package/lib/components/characters/characterUtils.js.map +1 -1
  14. package/lib/components/characters/custom-popper.js +22 -51
  15. package/lib/components/characters/custom-popper.js.map +1 -1
  16. package/lib/components/common/done-button.js +17 -36
  17. package/lib/components/common/done-button.js.map +1 -1
  18. package/lib/components/common/toolbar-buttons.js +57 -107
  19. package/lib/components/common/toolbar-buttons.js.map +1 -1
  20. package/lib/components/icons/CssIcon.js +14 -26
  21. package/lib/components/icons/CssIcon.js.map +1 -1
  22. package/lib/components/icons/RespArea.js +23 -46
  23. package/lib/components/icons/RespArea.js.map +1 -1
  24. package/lib/components/icons/TableIcons.js +20 -36
  25. package/lib/components/icons/TableIcons.js.map +1 -1
  26. package/lib/components/icons/TextAlign.js +16 -53
  27. package/lib/components/icons/TextAlign.js.map +1 -1
  28. package/lib/components/image/AltDialog.js +18 -49
  29. package/lib/components/image/AltDialog.js.map +1 -1
  30. package/lib/components/image/ImageToolbar.js +50 -90
  31. package/lib/components/image/ImageToolbar.js.map +1 -1
  32. package/lib/components/image/InsertImageHandler.js +17 -35
  33. package/lib/components/image/InsertImageHandler.js.map +1 -1
  34. package/lib/components/media/MediaDialog.js +195 -309
  35. package/lib/components/media/MediaDialog.js.map +1 -1
  36. package/lib/components/media/MediaToolbar.js +39 -66
  37. package/lib/components/media/MediaToolbar.js.map +1 -1
  38. package/lib/components/media/MediaWrapper.js +30 -56
  39. package/lib/components/media/MediaWrapper.js.map +1 -1
  40. package/lib/components/respArea/DragInTheBlank/DragInTheBlank.js +21 -36
  41. package/lib/components/respArea/DragInTheBlank/DragInTheBlank.js.map +1 -1
  42. package/lib/components/respArea/DragInTheBlank/choice.js +215 -262
  43. package/lib/components/respArea/DragInTheBlank/choice.js.map +1 -1
  44. package/lib/components/respArea/ExplicitConstructedResponse.js +11 -33
  45. package/lib/components/respArea/ExplicitConstructedResponse.js.map +1 -1
  46. package/lib/components/respArea/InlineDropdown.js +19 -41
  47. package/lib/components/respArea/InlineDropdown.js.map +1 -1
  48. package/lib/components/respArea/ToolbarIcon.js +21 -45
  49. package/lib/components/respArea/ToolbarIcon.js.map +1 -1
  50. package/lib/constants.js +3 -5
  51. package/lib/constants.js.map +1 -1
  52. package/lib/extensions/component.js +94 -148
  53. package/lib/extensions/component.js.map +1 -1
  54. package/lib/extensions/css.js +9 -44
  55. package/lib/extensions/css.js.map +1 -1
  56. package/lib/extensions/custom-toolbar-wrapper.js +66 -94
  57. package/lib/extensions/custom-toolbar-wrapper.js.map +1 -1
  58. package/lib/extensions/extended-table.js +2 -6
  59. package/lib/extensions/extended-table.js.map +1 -1
  60. package/lib/extensions/image.js +4 -17
  61. package/lib/extensions/image.js.map +1 -1
  62. package/lib/extensions/index.js +11 -21
  63. package/lib/extensions/index.js.map +1 -1
  64. package/lib/extensions/math.js +45 -96
  65. package/lib/extensions/math.js.map +1 -1
  66. package/lib/extensions/media.js +21 -59
  67. package/lib/extensions/media.js.map +1 -1
  68. package/lib/extensions/responseArea.js +43 -89
  69. package/lib/extensions/responseArea.js.map +1 -1
  70. package/lib/index.js +3 -11
  71. package/lib/index.js.map +1 -1
  72. package/lib/styles/editorContainerStyles.js +2 -7
  73. package/lib/styles/editorContainerStyles.js.map +1 -1
  74. package/lib/theme.js +2 -3
  75. package/lib/theme.js.map +1 -1
  76. package/lib/utils/size.js +2 -10
  77. package/lib/utils/size.js.map +1 -1
  78. package/package.json +15 -13
  79. package/src/components/EditableHtml.jsx +21 -33
  80. package/src/components/MenuBar.jsx +66 -37
  81. package/src/components/TiptapContainer.jsx +133 -34
  82. package/src/components/characters/custom-popper.js +18 -28
  83. package/src/components/common/done-button.jsx +15 -26
  84. package/src/components/common/toolbar-buttons.jsx +28 -44
  85. package/src/components/icons/CssIcon.jsx +11 -13
  86. package/src/components/icons/RespArea.jsx +16 -16
  87. package/src/components/icons/TableIcons.jsx +15 -16
  88. package/src/components/icons/TextAlign.jsx +3 -3
  89. package/src/components/image/AltDialog.jsx +6 -6
  90. package/src/components/image/ImageToolbar.jsx +28 -29
  91. package/src/components/media/MediaDialog.js +61 -78
  92. package/src/components/media/MediaToolbar.jsx +30 -37
  93. package/src/components/media/MediaWrapper.jsx +12 -16
  94. package/src/components/respArea/DragInTheBlank/DragInTheBlank.jsx +5 -4
  95. package/src/components/respArea/DragInTheBlank/choice.jsx +191 -185
  96. package/src/components/respArea/ToolbarIcon.jsx +13 -15
  97. package/src/extensions/component.jsx +61 -89
  98. package/src/extensions/css.js +6 -5
  99. package/src/extensions/custom-toolbar-wrapper.jsx +61 -81
  100. package/lib/__tests__/utils.js +0 -106
  101. package/src/__tests__/utils.js +0 -36
@@ -1,34 +1,24 @@
1
1
  import React from 'react';
2
- import { withStyles } from '@material-ui/core/styles';
3
- import Popper from '@material-ui/core/Popper';
4
- import Typography from '@material-ui/core/Typography';
2
+ import { styled } from '@mui/material/styles';
3
+ import Popper from '@mui/material/Popper';
4
+ import Typography from '@mui/material/Typography';
5
5
 
6
- const styles = () => ({
7
- popover: {
8
- background: '#fff',
9
- padding: '10px',
10
- pointerEvents: 'none',
11
- zIndex: 99999,
12
- },
13
- paper: {
14
- padding: 20,
15
- height: 'auto',
16
- width: 'auto',
17
- },
18
- typography: {
19
- fontSize: 50,
20
- textAlign: 'center',
21
- },
6
+ const StyledPopper = styled(Popper)({
7
+ background: '#fff',
8
+ padding: '10px',
9
+ pointerEvents: 'none',
10
+ zIndex: 99999,
22
11
  });
23
12
 
24
- const CustomPopper = withStyles(styles)(({ classes, children, ...props }) => (
25
- <Popper
13
+ const StyledTypography = styled(Typography)({
14
+ fontSize: 50,
15
+ textAlign: 'center',
16
+ });
17
+
18
+ const CustomPopper = ({ children, ...props }) => (
19
+ <StyledPopper
26
20
  id="mouse-over-popover"
27
21
  open
28
- className={classes.popover}
29
- classes={{
30
- paper: classes.paper,
31
- }}
32
22
  anchorOrigin={{
33
23
  vertical: 'bottom',
34
24
  horizontal: 'left',
@@ -41,8 +31,8 @@ const CustomPopper = withStyles(styles)(({ classes, children, ...props }) => (
41
31
  disableAutoFocus
42
32
  {...props}
43
33
  >
44
- <Typography classes={{ root: classes.typography }}>{children}</Typography>
45
- </Popper>
46
- ));
34
+ <StyledTypography>{children}</StyledTypography>
35
+ </StyledPopper>
36
+ );
47
37
 
48
38
  export default CustomPopper;
@@ -1,38 +1,27 @@
1
1
  import React from 'react';
2
2
 
3
- import IconButton from '@material-ui/core/IconButton';
4
- import Check from '@material-ui/icons/Check';
5
- import { withStyles } from '@material-ui/core/styles';
3
+ import IconButton from '@mui/material/IconButton';
4
+ import Check from '@mui/icons-material/Check';
5
+ import { styled } from '@mui/material/styles';
6
6
  import PropTypes from 'prop-types';
7
7
 
8
- export const RawDoneButton = ({ classes, onClick, doneButtonRef }) => (
9
- <IconButton
10
- aria-label="Done"
11
- className={classes.iconRoot}
12
- buttonRef={doneButtonRef}
13
- onClick={onClick}
14
- classes={{
15
- label: classes.label,
16
- root: classes.iconRoot,
17
- }}
18
- >
8
+ const StyledIconButton = styled(IconButton)({
9
+ verticalAlign: 'top',
10
+ width: '28px',
11
+ height: '28px',
12
+ color: 'var(--editable-html-toolbar-check, #00bb00)',
13
+ padding: '4px',
14
+ });
15
+
16
+ export const RawDoneButton = ({ onClick, doneButtonRef }) => (
17
+ <StyledIconButton aria-label="Done" buttonRef={doneButtonRef} onClick={onClick}>
19
18
  <Check />
20
- </IconButton>
19
+ </StyledIconButton>
21
20
  );
22
21
 
23
22
  RawDoneButton.propTypes = {
24
- classes: PropTypes.object.isRequired,
25
23
  onClick: PropTypes.func,
26
24
  doneButtonRef: PropTypes.func,
27
25
  };
28
26
 
29
- const styles = {
30
- iconRoot: {
31
- verticalAlign: 'top',
32
- width: '28px',
33
- height: '28px',
34
- color: 'var(--editable-html-toolbar-check, #00bb00)',
35
- padding: '4px',
36
- },
37
- };
38
- export const DoneButton = withStyles(styles)(RawDoneButton);
27
+ export const DoneButton = RawDoneButton;
@@ -1,42 +1,33 @@
1
1
  import React from 'react';
2
2
  import debug from 'debug';
3
- import { withStyles } from '@material-ui/core/styles';
4
- import classNames from 'classnames';
3
+ import { styled } from '@mui/material/styles';
5
4
  import PropTypes from 'prop-types';
6
5
 
7
- const styles = (theme) => ({
8
- button: {
9
- color: 'grey',
10
- display: 'inline-flex',
11
- padding: '2px',
12
- background: 'none',
13
- border: 'none',
14
- cursor: 'pointer',
15
- '&:hover': {
16
- color: 'black',
17
- },
18
- '&:focus': {
19
- outline: `2px solid ${theme.palette.grey[700]}`,
20
- },
6
+ const StyledButton = styled('button', {
7
+ shouldForwardProp: (prop) => !['active', 'disabled', 'extraStyles'].includes(prop),
8
+ })(({ theme, active, disabled }) => ({
9
+ color: active ? 'black' : 'grey',
10
+ display: 'inline-flex',
11
+ padding: '2px',
12
+ background: 'none',
13
+ border: 'none',
14
+ cursor: disabled ? 'not-allowed' : 'pointer',
15
+ '&:hover': {
16
+ color: disabled ? 'grey' : 'black',
21
17
  },
22
- active: {
23
- color: 'black',
18
+ '&:focus': {
19
+ outline: `2px solid ${theme.palette.grey[700]}`,
24
20
  },
25
- disabled: {
21
+ ...(disabled && {
26
22
  opacity: 0.7,
27
- cursor: 'not-allowed',
28
- '& :hover': {
29
- color: 'grey',
30
- },
31
- },
32
- });
23
+ }),
24
+ }));
33
25
 
34
26
  const log = debug('pie-elements:editable-html:raw-button');
35
27
 
36
28
  export class RawButton extends React.Component {
37
29
  static propTypes = {
38
30
  onClick: PropTypes.func.isRequired,
39
- classes: PropTypes.object.isRequired,
40
31
  children: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.node), PropTypes.node]).isRequired,
41
32
  active: PropTypes.bool,
42
33
  disabled: PropTypes.bool,
@@ -64,31 +55,26 @@ export class RawButton extends React.Component {
64
55
  };
65
56
 
66
57
  render() {
67
- const { active, classes, children, disabled, extraStyles, ariaLabel } = this.props;
68
-
69
- const names = classNames(classes.button, {
70
- [classes.active]: active,
71
- [classes.disabled]: disabled,
72
- });
58
+ const { active, children, disabled, extraStyles, ariaLabel } = this.props;
73
59
 
74
60
  return (
75
- <button
61
+ <StyledButton
76
62
  style={extraStyles}
77
- className={names}
63
+ active={active}
64
+ disabled={disabled}
78
65
  onMouseDown={this.onClick}
79
66
  onKeyDown={this.onKeyDown}
80
- disabled={disabled}
81
67
  aria-label={ariaLabel}
82
68
  aria-pressed={active}
83
69
  tabIndex={0}
84
70
  >
85
71
  {children}
86
- </button>
72
+ </StyledButton>
87
73
  );
88
74
  }
89
75
  }
90
76
 
91
- export const Button = withStyles(styles)(RawButton);
77
+ export const Button = RawButton;
92
78
 
93
79
  export class RawMarkButton extends React.Component {
94
80
  static propTypes = {
@@ -96,7 +82,6 @@ export class RawMarkButton extends React.Component {
96
82
  mark: PropTypes.string,
97
83
  label: PropTypes.string.isRequired,
98
84
  children: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.node), PropTypes.node]).isRequired,
99
- classes: PropTypes.object.isRequired,
100
85
  active: PropTypes.bool,
101
86
  };
102
87
 
@@ -117,12 +102,11 @@ export class RawMarkButton extends React.Component {
117
102
  };
118
103
 
119
104
  render() {
120
- const { classes, children, active, label } = this.props;
105
+ const { children, active, label } = this.props;
121
106
 
122
- const names = classNames(classes.button, active && classes.active);
123
107
  return (
124
- <button
125
- className={names}
108
+ <StyledButton
109
+ active={active}
126
110
  onMouseDown={this.onToggle}
127
111
  aria-pressed={active}
128
112
  onKeyDown={this.onKeyDown}
@@ -130,9 +114,9 @@ export class RawMarkButton extends React.Component {
130
114
  tabIndex={0}
131
115
  >
132
116
  {children}
133
- </button>
117
+ </StyledButton>
134
118
  );
135
119
  }
136
120
  }
137
121
 
138
- export const MarkButton = withStyles(styles)(RawMarkButton);
122
+ export const MarkButton = RawMarkButton;
@@ -1,17 +1,15 @@
1
1
  import React from 'react';
2
- import { withStyles } from '@material-ui/core/styles';
2
+ import { styled } from '@mui/material/styles';
3
3
 
4
- const styles = (theme) => ({
5
- icon: {
6
- fontFamily: 'Cerebri Sans, Arial, sans-serif',
7
- fontSize: theme.typography.fontSize,
8
- fontWeight: 'bold',
9
- lineHeight: '14px',
10
- position: 'relative',
11
- whiteSpace: 'nowrap',
12
- },
13
- });
4
+ const StyledCssIcon = styled('div')(({ theme }) => ({
5
+ fontFamily: 'Cerebri Sans, Arial, sans-serif',
6
+ fontSize: theme.typography.fontSize,
7
+ fontWeight: 'bold',
8
+ lineHeight: '14px',
9
+ position: 'relative',
10
+ whiteSpace: 'nowrap',
11
+ }));
14
12
 
15
- const CssIcon = ({ classes }) => <div className={classes.icon}>CSS</div>;
13
+ const CssIcon = () => <StyledCssIcon>CSS</StyledCssIcon>;
16
14
 
17
- export default withStyles(styles)(CssIcon);
15
+ export default CssIcon;
@@ -1,8 +1,8 @@
1
1
  import React from 'react';
2
2
  import PropTypes from 'prop-types';
3
- import ChevronRight from '@material-ui/icons/ChevronRight';
4
- import MoreVert from '@material-ui/icons/MoreVert';
5
- import { withStyles } from '@material-ui/core/styles';
3
+ import ChevronRight from '@mui/icons-material/ChevronRight';
4
+ import MoreVert from '@mui/icons-material/MoreVert';
5
+ import { styled } from '@mui/material/styles';
6
6
 
7
7
  const getRotate = (direction) => {
8
8
  switch (direction) {
@@ -56,16 +56,16 @@ GripIcon.propTypes = {
56
56
  style: PropTypes.object,
57
57
  };
58
58
 
59
- export const ToolbarIcon = withStyles((theme) => ({
60
- icon: {
61
- fontFamily: 'Cerebri Sans !important',
62
- fontSize: theme.typography.fontSize,
63
- fontWeight: 'bold',
64
- lineHeight: '14px',
65
- position: 'relative',
66
- top: '7px',
67
- width: '110px',
68
- height: '28px',
69
- whiteSpace: 'nowrap',
70
- },
71
- }))(({ classes }) => <div className={classes.icon}>+ Response Area</div>);
59
+ const StyledToolbarIcon = styled('div')(({ theme }) => ({
60
+ fontFamily: 'Cerebri Sans !important',
61
+ fontSize: theme.typography.fontSize,
62
+ fontWeight: 'bold',
63
+ lineHeight: '14px',
64
+ position: 'relative',
65
+ top: '7px',
66
+ width: '110px',
67
+ height: '28px',
68
+ whiteSpace: 'nowrap',
69
+ }));
70
+
71
+ export const ToolbarIcon = () => <StyledToolbarIcon>+ Response Area</StyledToolbarIcon>;
@@ -1,52 +1,51 @@
1
1
  import React from 'react';
2
- import { withStyles } from '@material-ui/core/styles';
2
+ import { styled } from '@mui/material/styles';
3
3
 
4
- const styles = {
5
- icon: {
6
- fill: 'grey',
7
- '&:hover': {
8
- fill: 'black',
9
- },
4
+ const StyledPath = styled('path')({
5
+ fill: 'grey',
6
+ '&:hover': {
7
+ fill: 'black',
10
8
  },
11
- };
9
+ });
12
10
 
13
11
  const SvgIcon = (Component) => {
14
- return withStyles(styles)((props) => (
12
+ return (props) => (
15
13
  <svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="24" height="24" viewBox="0 0 24 24">
16
- <Component className={props.classes.icon} />
14
+ <Component {...props} />
17
15
  </svg>
18
- ));
16
+ );
19
17
  };
18
+
20
19
  export const AddRow = SvgIcon((props) => (
21
- <path
20
+ <StyledPath
22
21
  {...props}
23
22
  d="M22,10A2,2 0 0,1 20,12H4A2,2 0 0,1 2,10V3H4V5H8V3H10V5H14V3H16V5H20V3H22V10M4,10H8V7H4V10M10,10H14V7H10V10M20,10V7H16V10H20M11,14H13V17H16V19H13V22H11V19H8V17H11V14Z"
24
23
  />
25
24
  ));
26
25
 
27
26
  export const RemoveRow = SvgIcon((props) => (
28
- <path
27
+ <StyledPath
29
28
  {...props}
30
29
  d="M9.41,13L12,15.59L14.59,13L16,14.41L13.41,17L16,19.59L14.59,21L12,18.41L9.41,21L8,19.59L10.59,17L8,14.41L9.41,13M22,9A2,2 0 0,1 20,11H4A2,2 0 0,1 2,9V6A2,2 0 0,1 4,4H20A2,2 0 0,1 22,6V9M4,9H8V6H4V9M10,9H14V6H10V9M16,9H20V6H16V9Z"
31
30
  />
32
31
  ));
33
32
 
34
33
  export const AddColumn = SvgIcon((props) => (
35
- <path
34
+ <StyledPath
36
35
  {...props}
37
36
  d="M11,2A2,2 0 0,1 13,4V20A2,2 0 0,1 11,22H2V2H11M4,10V14H11V10H4M4,16V20H11V16H4M4,4V8H11V4H4M15,11H18V8H20V11H23V13H20V16H18V13H15V11Z"
38
37
  />
39
38
  ));
40
39
 
41
40
  export const RemoveColumn = SvgIcon((props) => (
42
- <path
41
+ <StyledPath
43
42
  {...props}
44
43
  d="M4,2H11A2,2 0 0,1 13,4V20A2,2 0 0,1 11,22H4A2,2 0 0,1 2,20V4A2,2 0 0,1 4,2M4,10V14H11V10H4M4,16V20H11V16H4M4,4V8H11V4H4M17.59,12L15,9.41L16.41,8L19,10.59L21.59,8L23,9.41L20.41,12L23,14.59L21.59,16L19,13.41L16.41,16L15,14.59L17.59,12Z"
45
44
  />
46
45
  ));
47
46
 
48
47
  export const RemoveTable = SvgIcon((props) => (
49
- <path
48
+ <StyledPath
50
49
  {...props}
51
50
  d="M15.46,15.88L16.88,14.46L19,16.59L21.12,14.46L22.54,15.88L20.41,18L22.54,20.12L21.12,21.54L19,19.41L16.88,21.54L15.46,20.12L17.59,18L15.46,15.88M4,3H18A2,2 0 0,1 20,5V12.08C18.45,11.82 16.92,12.18 15.68,13H12V17H13.08C12.97,17.68 12.97,18.35 13.08,19H4A2,2 0 0,1 2,17V5A2,2 0 0,1 4,3M4,7V11H10V7H4M12,7V11H18V7H12M4,13V17H10V13H4Z"
52
51
  />
@@ -1,7 +1,7 @@
1
1
  import React, { useState } from 'react';
2
- import Collapse from '@material-ui/core/Collapse';
3
- import List from '@material-ui/core/List';
4
- import ListItem from '@material-ui/core/ListItem';
2
+ import Collapse from '@mui/material/Collapse';
3
+ import List from '@mui/material/List';
4
+ import ListItem from '@mui/material/ListItem';
5
5
 
6
6
  export const AlignLeft = () => (
7
7
  <svg width="20" height="20" viewBox="0 0 66 66" fill="none" xmlns="http://www.w3.org/2000/svg">
@@ -1,10 +1,10 @@
1
1
  import React from 'react';
2
- import DialogContent from '@material-ui/core/DialogContent';
3
- import ArrowBackIos from '@material-ui/icons/ArrowBackIos';
4
- import TextField from '@material-ui/core/TextField';
5
- import DialogActions from '@material-ui/core/DialogActions';
6
- import Button from '@material-ui/core/Button';
7
- import Dialog from '@material-ui/core/Dialog';
2
+ import DialogContent from '@mui/material/DialogContent';
3
+ import ArrowBackIos from '@mui/icons-material/ArrowBackIos';
4
+ import TextField from '@mui/material/TextField';
5
+ import DialogActions from '@mui/material/DialogActions';
6
+ import Button from '@mui/material/Button';
7
+ import Dialog from '@mui/material/Dialog';
8
8
  import PropTypes from 'prop-types';
9
9
 
10
10
  export class AltDialog extends React.Component {
@@ -2,14 +2,32 @@ 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';
6
- import classNames from 'classnames';
5
+ import { styled } from '@mui/material/styles';
7
6
 
8
7
  import AltDialog from './AltDialog';
9
8
  import { MarkButton } from '../common/toolbar-buttons';
10
9
 
11
10
  const log = debug('@pie-lib:editable-html:plugins:image:image-toolbar');
12
11
 
12
+ const StyledHolder = styled('div')(({ theme }) => ({
13
+ paddingLeft: theme.spacing.unit,
14
+ display: 'flex',
15
+ alignItems: 'center',
16
+ }));
17
+
18
+ const StyledAltText = styled('span', {
19
+ shouldForwardProp: (prop) => !['disabled', 'hasAlignmentButtons'].includes(prop),
20
+ })(({ disabled, hasAlignmentButtons }) => ({
21
+ ...(disabled && {
22
+ opacity: 0.5,
23
+ }),
24
+ ...(hasAlignmentButtons && {
25
+ borderLeft: '1px solid grey',
26
+ paddingLeft: 8,
27
+ marginLeft: 4,
28
+ }),
29
+ }));
30
+
13
31
  const AlignmentButton = ({ alignment, active, onClick }) => {
14
32
  return (
15
33
  <MarkButton active={active} onToggle={() => onClick(alignment)} label={alignment}>
@@ -27,7 +45,6 @@ AlignmentButton.propTypes = {
27
45
  export class ImageToolbar extends React.Component {
28
46
  static propTypes = {
29
47
  onChange: PropTypes.func.isRequired,
30
- classes: PropTypes.object.isRequired,
31
48
  alignment: PropTypes.string,
32
49
  alt: PropTypes.string,
33
50
  imageLoaded: PropTypes.bool,
@@ -57,9 +74,9 @@ export class ImageToolbar extends React.Component {
57
74
  };
58
75
 
59
76
  render() {
60
- const { classes, alignment, imageLoaded, disableImageAlignmentButtons } = this.props;
77
+ const { alignment, imageLoaded, disableImageAlignmentButtons } = this.props;
61
78
  return (
62
- <div className={classes.holder}>
79
+ <StyledHolder>
63
80
  {!disableImageAlignmentButtons && (
64
81
  <>
65
82
  <AlignmentButton alignment={'left'} active={alignment === 'left'} onClick={this.onAlignmentClick} />
@@ -67,34 +84,16 @@ export class ImageToolbar extends React.Component {
67
84
  <AlignmentButton alignment={'right'} active={alignment === 'right'} onClick={this.onAlignmentClick} />
68
85
  </>
69
86
  )}
70
- <span
71
- className={classNames({
72
- [classes.disabled]: !imageLoaded,
73
- [classes.altButton]: !disableImageAlignmentButtons,
74
- })}
87
+ <StyledAltText
88
+ disabled={!imageLoaded}
89
+ hasAlignmentButtons={!disableImageAlignmentButtons}
75
90
  onMouseDown={(event) => imageLoaded && this.renderDialog(event)}
76
91
  >
77
92
  Alt text
78
- </span>
79
- </div>
93
+ </StyledAltText>
94
+ </StyledHolder>
80
95
  );
81
96
  }
82
97
  }
83
98
 
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);
99
+ export default ImageToolbar;