@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.
- package/CHANGELOG.md +37 -0
- package/lib/block-tags.js +2 -3
- package/lib/block-tags.js.map +1 -1
- package/lib/constants.js +3 -6
- package/lib/constants.js.map +1 -1
- package/lib/editor.js +302 -450
- package/lib/editor.js.map +1 -1
- package/lib/index.js +19 -77
- package/lib/index.js.map +1 -1
- package/lib/parse-html.js +7 -7
- package/lib/parse-html.js.map +1 -1
- package/lib/plugins/characters/custom-popper.js +24 -44
- package/lib/plugins/characters/custom-popper.js.map +1 -1
- package/lib/plugins/characters/index.js +9 -60
- package/lib/plugins/characters/index.js.map +1 -1
- package/lib/plugins/characters/utils.js +3 -6
- package/lib/plugins/characters/utils.js.map +1 -1
- package/lib/plugins/css/icons/index.js +13 -25
- package/lib/plugins/css/icons/index.js.map +1 -1
- package/lib/plugins/css/index.js +22 -88
- package/lib/plugins/css/index.js.map +1 -1
- package/lib/plugins/customPlugin/index.js +10 -26
- package/lib/plugins/customPlugin/index.js.map +1 -1
- package/lib/plugins/html/icons/index.js +14 -26
- package/lib/plugins/html/icons/index.js.map +1 -1
- package/lib/plugins/html/index.js +4 -13
- package/lib/plugins/html/index.js.map +1 -1
- package/lib/plugins/image/alt-dialog.js +20 -49
- package/lib/plugins/image/alt-dialog.js.map +1 -1
- package/lib/plugins/image/component.js +119 -190
- package/lib/plugins/image/component.js.map +1 -1
- package/lib/plugins/image/image-toolbar.js +44 -86
- package/lib/plugins/image/image-toolbar.js.map +1 -1
- package/lib/plugins/image/index.js +6 -46
- package/lib/plugins/image/index.js.map +1 -1
- package/lib/plugins/image/insert-image-handler.js +10 -31
- package/lib/plugins/image/insert-image-handler.js.map +1 -1
- package/lib/plugins/index.js +44 -106
- package/lib/plugins/index.js.map +1 -1
- package/lib/plugins/list/index.js +27 -73
- package/lib/plugins/list/index.js.map +1 -1
- package/lib/plugins/math/index.js +64 -116
- package/lib/plugins/math/index.js.map +1 -1
- package/lib/plugins/media/index.js +23 -81
- package/lib/plugins/media/index.js.map +1 -1
- package/lib/plugins/media/media-dialog.js +192 -307
- package/lib/plugins/media/media-dialog.js.map +1 -1
- package/lib/plugins/media/media-toolbar.js +40 -65
- package/lib/plugins/media/media-toolbar.js.map +1 -1
- package/lib/plugins/media/media-wrapper.js +20 -49
- package/lib/plugins/media/media-wrapper.js.map +1 -1
- package/lib/plugins/rendering/index.js +5 -15
- package/lib/plugins/rendering/index.js.map +1 -1
- package/lib/plugins/respArea/drag-in-the-blank/choice.js +175 -249
- package/lib/plugins/respArea/drag-in-the-blank/choice.js.map +1 -1
- package/lib/plugins/respArea/drag-in-the-blank/index.js +39 -29
- package/lib/plugins/respArea/drag-in-the-blank/index.js.map +1 -1
- package/lib/plugins/respArea/explicit-constructed-response/index.js +3 -10
- package/lib/plugins/respArea/explicit-constructed-response/index.js.map +1 -1
- package/lib/plugins/respArea/icons/index.js +22 -45
- package/lib/plugins/respArea/icons/index.js.map +1 -1
- package/lib/plugins/respArea/index.js +5 -59
- package/lib/plugins/respArea/index.js.map +1 -1
- package/lib/plugins/respArea/inline-dropdown/index.js +2 -10
- package/lib/plugins/respArea/inline-dropdown/index.js.map +1 -1
- package/lib/plugins/respArea/math-templated/index.js +92 -109
- package/lib/plugins/respArea/math-templated/index.js.map +1 -1
- package/lib/plugins/respArea/utils.js +8 -40
- package/lib/plugins/respArea/utils.js.map +1 -1
- package/lib/plugins/table/CustomTablePlugin.js +24 -41
- package/lib/plugins/table/CustomTablePlugin.js.map +1 -1
- package/lib/plugins/table/icons/index.js +19 -35
- package/lib/plugins/table/icons/index.js.map +1 -1
- package/lib/plugins/table/index.js +41 -118
- package/lib/plugins/table/index.js.map +1 -1
- package/lib/plugins/table/table-toolbar.js +37 -87
- package/lib/plugins/table/table-toolbar.js.map +1 -1
- package/lib/plugins/textAlign/icons/index.js +18 -64
- package/lib/plugins/textAlign/icons/index.js.map +1 -1
- package/lib/plugins/textAlign/index.js +1 -6
- package/lib/plugins/textAlign/index.js.map +1 -1
- package/lib/plugins/toolbar/default-toolbar.js +30 -79
- package/lib/plugins/toolbar/default-toolbar.js.map +1 -1
- package/lib/plugins/toolbar/done-button.js +16 -34
- package/lib/plugins/toolbar/done-button.js.map +1 -1
- package/lib/plugins/toolbar/editor-and-toolbar.js +174 -201
- package/lib/plugins/toolbar/editor-and-toolbar.js.map +1 -1
- package/lib/plugins/toolbar/index.js +0 -5
- package/lib/plugins/toolbar/index.js.map +1 -1
- package/lib/plugins/toolbar/toolbar-buttons.js +57 -107
- package/lib/plugins/toolbar/toolbar-buttons.js.map +1 -1
- package/lib/plugins/toolbar/toolbar.js +95 -161
- package/lib/plugins/toolbar/toolbar.js.map +1 -1
- package/lib/plugins/utils.js +5 -25
- package/lib/plugins/utils.js.map +1 -1
- package/lib/serialization.js +44 -150
- package/lib/serialization.js.map +1 -1
- package/lib/shared/alert-dialog.js +23 -42
- package/lib/theme.js +1 -2
- package/lib/theme.js.map +1 -1
- package/package.json +15 -21
- package/src/__tests__/utils.js +1 -1
- package/src/editor.jsx +110 -108
- package/src/plugins/characters/custom-popper.js +20 -25
- package/src/plugins/css/icons/index.jsx +11 -13
- package/src/plugins/css/index.jsx +3 -5
- package/src/plugins/html/icons/index.jsx +12 -14
- package/src/plugins/image/alt-dialog.jsx +9 -8
- package/src/plugins/image/component.jsx +67 -87
- package/src/plugins/image/image-toolbar.jsx +26 -26
- package/src/plugins/image/index.jsx +1 -1
- package/src/plugins/index.jsx +10 -10
- package/src/plugins/math/index.jsx +1 -1
- package/src/plugins/media/index.jsx +2 -2
- package/src/plugins/media/media-dialog.js +65 -76
- package/src/plugins/media/media-toolbar.jsx +32 -33
- package/src/plugins/media/media-wrapper.jsx +10 -13
- package/src/plugins/respArea/drag-in-the-blank/choice.jsx +193 -180
- package/src/plugins/respArea/drag-in-the-blank/index.jsx +58 -22
- package/src/plugins/respArea/icons/index.jsx +16 -16
- package/src/plugins/respArea/math-templated/index.jsx +88 -89
- package/src/plugins/respArea/utils.jsx +1 -1
- package/src/plugins/table/icons/index.jsx +14 -16
- package/src/plugins/table/index.jsx +27 -19
- package/src/plugins/table/table-toolbar.jsx +17 -19
- package/src/plugins/textAlign/icons/index.jsx +3 -3
- package/src/plugins/toolbar/__tests__/default-toolbar.test.jsx +1 -1
- package/src/plugins/toolbar/__tests__/toolbar.test.jsx +1 -1
- package/src/plugins/toolbar/default-toolbar.jsx +18 -21
- package/src/plugins/toolbar/done-button.jsx +16 -22
- package/src/plugins/toolbar/editor-and-toolbar.jsx +134 -157
- package/src/plugins/toolbar/toolbar-buttons.jsx +29 -46
- package/src/plugins/toolbar/toolbar.jsx +60 -78
- package/esm/index.js +0 -111560
- package/esm/index.js.map +0 -1
- package/esm/package.json +0 -1
|
@@ -3,13 +3,132 @@ import Toolbar from './toolbar';
|
|
|
3
3
|
import classNames from 'classnames';
|
|
4
4
|
import debug from 'debug';
|
|
5
5
|
import { primary } from '../../theme';
|
|
6
|
-
import {
|
|
6
|
+
import { styled } from '@mui/material/styles';
|
|
7
7
|
import PropTypes from 'prop-types';
|
|
8
8
|
import SlatePropTypes from 'slate-prop-types';
|
|
9
9
|
import { color } from '@pie-lib/render-ui';
|
|
10
10
|
|
|
11
11
|
const log = debug('@pie-lib:editable-html:plugins:toolbar:editor-and-toolbar');
|
|
12
12
|
|
|
13
|
+
const Root = styled('div', {
|
|
14
|
+
shouldForwardProp: (prop) => !['noBorder', 'error'].includes(prop),
|
|
15
|
+
})(({ theme, noBorder, error }) => ({
|
|
16
|
+
position: 'relative',
|
|
17
|
+
padding: '0px',
|
|
18
|
+
border: noBorder ? 'none' : '1px solid #ccc',
|
|
19
|
+
borderRadius: '4px',
|
|
20
|
+
cursor: 'text',
|
|
21
|
+
borderColor: error ? `${theme.palette.error.main} !important` : undefined,
|
|
22
|
+
borderWidth: error ? '2px !important' : undefined,
|
|
23
|
+
'& [data-slate-editor="true"]': {
|
|
24
|
+
wordBreak: 'break-word',
|
|
25
|
+
overflow: 'visible',
|
|
26
|
+
maxHeight: '500px',
|
|
27
|
+
// needed in order to be able to put the focus before a void element when it is the first one in the editor
|
|
28
|
+
padding: '5px',
|
|
29
|
+
},
|
|
30
|
+
}));
|
|
31
|
+
|
|
32
|
+
const EditorHolder = styled('div', {
|
|
33
|
+
shouldForwardProp: (prop) => !['inFocus', 'readOnly', 'disableUnderline', 'disableScrollbar'].includes(prop),
|
|
34
|
+
})(({ theme, inFocus, readOnly, disableUnderline, disableScrollbar }) => ({
|
|
35
|
+
position: 'relative',
|
|
36
|
+
padding: '0px',
|
|
37
|
+
overflowY: 'auto',
|
|
38
|
+
color: color.text(),
|
|
39
|
+
backgroundColor: color.background(),
|
|
40
|
+
...(disableScrollbar && {
|
|
41
|
+
'&::-webkit-scrollbar': {
|
|
42
|
+
display: 'none',
|
|
43
|
+
},
|
|
44
|
+
scrollbarWidth: 'none',
|
|
45
|
+
'-ms-overflow-style': 'none',
|
|
46
|
+
}),
|
|
47
|
+
...(!disableUnderline && {
|
|
48
|
+
'&::before': {
|
|
49
|
+
left: '0',
|
|
50
|
+
right: '0',
|
|
51
|
+
bottom: '0',
|
|
52
|
+
height: '1px',
|
|
53
|
+
content: '""',
|
|
54
|
+
position: 'absolute',
|
|
55
|
+
transition: 'background-color 200ms cubic-bezier(0.4, 0, 0.2, 1) 0ms',
|
|
56
|
+
pointerEvents: 'none',
|
|
57
|
+
backgroundColor: 'rgba(0, 0, 0, 0.42)',
|
|
58
|
+
},
|
|
59
|
+
'&::after': {
|
|
60
|
+
left: '0',
|
|
61
|
+
right: '0',
|
|
62
|
+
bottom: '0',
|
|
63
|
+
height: '1px',
|
|
64
|
+
content: '""',
|
|
65
|
+
position: 'absolute',
|
|
66
|
+
transform: 'scaleX(0)',
|
|
67
|
+
transition: 'transform 200ms cubic-bezier(0.0, 0.0, 0.2, 1) 0ms, background-color 200ms linear',
|
|
68
|
+
backgroundColor: 'rgba(0, 0, 0, 0.42)',
|
|
69
|
+
},
|
|
70
|
+
'&:focus': {
|
|
71
|
+
'&::after': {
|
|
72
|
+
transform: 'scaleX(1)',
|
|
73
|
+
backgroundColor: primary,
|
|
74
|
+
height: '2px',
|
|
75
|
+
},
|
|
76
|
+
},
|
|
77
|
+
'&:hover': {
|
|
78
|
+
'&::after': {
|
|
79
|
+
transform: 'scaleX(1)',
|
|
80
|
+
backgroundColor: theme.palette.common.black,
|
|
81
|
+
height: '2px',
|
|
82
|
+
},
|
|
83
|
+
},
|
|
84
|
+
}),
|
|
85
|
+
...(readOnly && {
|
|
86
|
+
'&::before': {
|
|
87
|
+
background: 'transparent',
|
|
88
|
+
backgroundSize: '5px 1px',
|
|
89
|
+
backgroundImage: 'linear-gradient(to right, rgba(0, 0, 0, 0.42) 33%, transparent 0%)',
|
|
90
|
+
backgroundRepeat: 'repeat-x',
|
|
91
|
+
backgroundPosition: 'left top',
|
|
92
|
+
},
|
|
93
|
+
'&::after': {
|
|
94
|
+
left: '0',
|
|
95
|
+
right: '0',
|
|
96
|
+
bottom: '0',
|
|
97
|
+
height: '1px',
|
|
98
|
+
content: '""',
|
|
99
|
+
position: 'absolute',
|
|
100
|
+
transform: 'scaleX(0)',
|
|
101
|
+
transition: 'transform 200ms cubic-bezier(0.0, 0.0, 0.2, 1) 0ms, background-color 0ms linear',
|
|
102
|
+
backgroundColor: 'rgba(0, 0, 0, 0)',
|
|
103
|
+
},
|
|
104
|
+
'&:hover': {
|
|
105
|
+
'&::after': {
|
|
106
|
+
transform: 'scaleX(0)',
|
|
107
|
+
backgroundColor: theme.palette.common.black,
|
|
108
|
+
height: '2px',
|
|
109
|
+
},
|
|
110
|
+
},
|
|
111
|
+
}),
|
|
112
|
+
...(inFocus && {
|
|
113
|
+
'&::after': {
|
|
114
|
+
transform: 'scaleX(1)',
|
|
115
|
+
backgroundColor: primary,
|
|
116
|
+
height: '2px',
|
|
117
|
+
},
|
|
118
|
+
'&:hover': {
|
|
119
|
+
'&::after': {
|
|
120
|
+
backgroundColor: primary,
|
|
121
|
+
},
|
|
122
|
+
},
|
|
123
|
+
}),
|
|
124
|
+
}));
|
|
125
|
+
|
|
126
|
+
const ChildrenContainer = styled('div', {
|
|
127
|
+
shouldForwardProp: (prop) => !['noPadding'].includes(prop),
|
|
128
|
+
})(({ noPadding }) => ({
|
|
129
|
+
padding: noPadding ? 0 : '10px 16px',
|
|
130
|
+
}));
|
|
131
|
+
|
|
13
132
|
export class EditorAndToolbar extends React.Component {
|
|
14
133
|
static propTypes = {
|
|
15
134
|
children: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.node), PropTypes.node]).isRequired,
|
|
@@ -25,7 +144,6 @@ export class EditorAndToolbar extends React.Component {
|
|
|
25
144
|
disableScrollbar: PropTypes.bool,
|
|
26
145
|
disableUnderline: PropTypes.bool,
|
|
27
146
|
autoWidth: PropTypes.bool,
|
|
28
|
-
classes: PropTypes.object.isRequired,
|
|
29
147
|
pluginProps: PropTypes.object,
|
|
30
148
|
toolbarOpts: PropTypes.shape({
|
|
31
149
|
position: PropTypes.oneOf(['bottom', 'top']),
|
|
@@ -42,7 +160,6 @@ export class EditorAndToolbar extends React.Component {
|
|
|
42
160
|
|
|
43
161
|
render() {
|
|
44
162
|
const {
|
|
45
|
-
classes,
|
|
46
163
|
children,
|
|
47
164
|
value,
|
|
48
165
|
plugins,
|
|
@@ -66,13 +183,6 @@ export class EditorAndToolbar extends React.Component {
|
|
|
66
183
|
|
|
67
184
|
let inFocus = value.isFocused || (focusedNode !== null && focusedNode !== undefined) || focusToolbar;
|
|
68
185
|
|
|
69
|
-
const holderNames = classNames(classes.editorHolder, {
|
|
70
|
-
[classes.editorInFocus]: inFocus,
|
|
71
|
-
[classes.readOnly]: readOnly,
|
|
72
|
-
[classes.disabledUnderline]: disableUnderline,
|
|
73
|
-
[classes.disabledScrollbar]: disableScrollbar,
|
|
74
|
-
});
|
|
75
|
-
|
|
76
186
|
let clonedChildren = children;
|
|
77
187
|
|
|
78
188
|
if (typeof children !== 'string') {
|
|
@@ -84,27 +194,20 @@ export class EditorAndToolbar extends React.Component {
|
|
|
84
194
|
log('[render] inFocus: ', inFocus, 'value.isFocused:', value.isFocused, 'focused node: ', focusedNode);
|
|
85
195
|
|
|
86
196
|
return (
|
|
87
|
-
<
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
[classes.noBorder]: toolbarOpts && toolbarOpts.noBorder,
|
|
91
|
-
[classes.error]: toolbarOpts && toolbarOpts.error,
|
|
92
|
-
},
|
|
93
|
-
classes.root,
|
|
94
|
-
)}
|
|
197
|
+
<Root
|
|
198
|
+
noBorder={toolbarOpts && toolbarOpts.noBorder}
|
|
199
|
+
error={toolbarOpts && toolbarOpts.error}
|
|
95
200
|
>
|
|
96
|
-
<
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
)}
|
|
104
|
-
>
|
|
201
|
+
<EditorHolder
|
|
202
|
+
inFocus={inFocus}
|
|
203
|
+
readOnly={readOnly}
|
|
204
|
+
disableUnderline={disableUnderline}
|
|
205
|
+
disableScrollbar={disableScrollbar}
|
|
206
|
+
>
|
|
207
|
+
<ChildrenContainer noPadding={toolbarOpts && toolbarOpts.noPadding}>
|
|
105
208
|
{clonedChildren}
|
|
106
|
-
</
|
|
107
|
-
</
|
|
209
|
+
</ChildrenContainer>
|
|
210
|
+
</EditorHolder>
|
|
108
211
|
|
|
109
212
|
<Toolbar
|
|
110
213
|
autoWidth={autoWidth}
|
|
@@ -123,135 +226,9 @@ export class EditorAndToolbar extends React.Component {
|
|
|
123
226
|
pluginProps={pluginProps}
|
|
124
227
|
toolbarOpts={toolbarOpts}
|
|
125
228
|
/>
|
|
126
|
-
</
|
|
229
|
+
</Root>
|
|
127
230
|
);
|
|
128
231
|
}
|
|
129
232
|
}
|
|
130
233
|
|
|
131
|
-
|
|
132
|
-
root: {
|
|
133
|
-
position: 'relative',
|
|
134
|
-
padding: '0px',
|
|
135
|
-
border: '1px solid #ccc',
|
|
136
|
-
borderRadius: '4px',
|
|
137
|
-
cursor: 'text',
|
|
138
|
-
'& [data-slate-editor="true"]': {
|
|
139
|
-
wordBreak: 'break-word',
|
|
140
|
-
overflow: 'visible',
|
|
141
|
-
maxHeight: '500px',
|
|
142
|
-
// needed in order to be able to put the focus before a void element when it is the first one in the editor
|
|
143
|
-
padding: '5px',
|
|
144
|
-
},
|
|
145
|
-
},
|
|
146
|
-
children: {
|
|
147
|
-
padding: '10px 16px',
|
|
148
|
-
},
|
|
149
|
-
editorHolder: {
|
|
150
|
-
position: 'relative',
|
|
151
|
-
padding: '0px',
|
|
152
|
-
overflowY: 'auto',
|
|
153
|
-
color: color.text(),
|
|
154
|
-
backgroundColor: color.background(),
|
|
155
|
-
'&::before': {
|
|
156
|
-
left: '0',
|
|
157
|
-
right: '0',
|
|
158
|
-
bottom: '0',
|
|
159
|
-
height: '1px',
|
|
160
|
-
content: '""',
|
|
161
|
-
position: 'absolute',
|
|
162
|
-
transition: 'background-color 200ms cubic-bezier(0.4, 0, 0.2, 1) 0ms',
|
|
163
|
-
pointerEvents: 'none',
|
|
164
|
-
backgroundColor: 'rgba(0, 0, 0, 0.42)',
|
|
165
|
-
},
|
|
166
|
-
'&::after': {
|
|
167
|
-
left: '0',
|
|
168
|
-
right: '0',
|
|
169
|
-
bottom: '0',
|
|
170
|
-
height: '1px',
|
|
171
|
-
content: '""',
|
|
172
|
-
position: 'absolute',
|
|
173
|
-
transform: 'scaleX(0)',
|
|
174
|
-
transition: 'transform 200ms cubic-bezier(0.0, 0.0, 0.2, 1) 0ms, background-color 200ms linear',
|
|
175
|
-
backgroundColor: 'rgba(0, 0, 0, 0.42)',
|
|
176
|
-
},
|
|
177
|
-
'&:focus': {
|
|
178
|
-
'&::after': {
|
|
179
|
-
transform: 'scaleX(1)',
|
|
180
|
-
backgroundColor: primary,
|
|
181
|
-
height: '2px',
|
|
182
|
-
},
|
|
183
|
-
},
|
|
184
|
-
'&:hover': {
|
|
185
|
-
'&::after': {
|
|
186
|
-
transform: 'scaleX(1)',
|
|
187
|
-
backgroundColor: theme.palette.common.black,
|
|
188
|
-
height: '2px',
|
|
189
|
-
},
|
|
190
|
-
},
|
|
191
|
-
},
|
|
192
|
-
disabledUnderline: {
|
|
193
|
-
'&::before': {
|
|
194
|
-
display: 'none',
|
|
195
|
-
},
|
|
196
|
-
'&::after': {
|
|
197
|
-
display: 'none',
|
|
198
|
-
},
|
|
199
|
-
},
|
|
200
|
-
disabledScrollbar: {
|
|
201
|
-
'&::-webkit-scrollbar': {
|
|
202
|
-
display: 'none',
|
|
203
|
-
},
|
|
204
|
-
scrollbarWidth: 'none',
|
|
205
|
-
'-ms-overflow-style': 'none',
|
|
206
|
-
},
|
|
207
|
-
readOnly: {
|
|
208
|
-
'&::before': {
|
|
209
|
-
background: 'transparent',
|
|
210
|
-
backgroundSize: '5px 1px',
|
|
211
|
-
backgroundImage: 'linear-gradient(to right, rgba(0, 0, 0, 0.42) 33%, transparent 0%)',
|
|
212
|
-
backgroundRepeat: 'repeat-x',
|
|
213
|
-
backgroundPosition: 'left top',
|
|
214
|
-
},
|
|
215
|
-
'&::after': {
|
|
216
|
-
left: '0',
|
|
217
|
-
right: '0',
|
|
218
|
-
bottom: '0',
|
|
219
|
-
height: '1px',
|
|
220
|
-
content: '""',
|
|
221
|
-
position: 'absolute',
|
|
222
|
-
transform: 'scaleX(0)',
|
|
223
|
-
transition: 'transform 200ms cubic-bezier(0.0, 0.0, 0.2, 1) 0ms, background-color 0ms linear',
|
|
224
|
-
backgroundColor: 'rgba(0, 0, 0, 0)',
|
|
225
|
-
},
|
|
226
|
-
'&:hover': {
|
|
227
|
-
'&::after': {
|
|
228
|
-
transform: 'scaleX(0)',
|
|
229
|
-
backgroundColor: theme.palette.common.black,
|
|
230
|
-
height: '2px',
|
|
231
|
-
},
|
|
232
|
-
},
|
|
233
|
-
},
|
|
234
|
-
editorInFocus: {
|
|
235
|
-
'&::after': {
|
|
236
|
-
transform: 'scaleX(1)',
|
|
237
|
-
backgroundColor: primary,
|
|
238
|
-
height: '2px',
|
|
239
|
-
},
|
|
240
|
-
'&:hover': {
|
|
241
|
-
'&::after': {
|
|
242
|
-
backgroundColor: primary,
|
|
243
|
-
},
|
|
244
|
-
},
|
|
245
|
-
},
|
|
246
|
-
error: {
|
|
247
|
-
border: `2px solid ${theme.palette.error.main} !important`,
|
|
248
|
-
},
|
|
249
|
-
noBorder: {
|
|
250
|
-
border: 'none',
|
|
251
|
-
},
|
|
252
|
-
noPadding: {
|
|
253
|
-
padding: 0,
|
|
254
|
-
},
|
|
255
|
-
});
|
|
256
|
-
|
|
257
|
-
export default withStyles(style)(EditorAndToolbar);
|
|
234
|
+
export default EditorAndToolbar;
|
|
@@ -1,42 +1,32 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import debug from 'debug';
|
|
3
|
-
import {
|
|
4
|
-
import classNames from 'classnames';
|
|
3
|
+
import { styled } from '@mui/material/styles';
|
|
5
4
|
import PropTypes from 'prop-types';
|
|
6
5
|
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
'
|
|
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, extraStyles }) => ({
|
|
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
|
+
opacity: disabled ? 0.7 : 1,
|
|
16
|
+
'&:hover': {
|
|
17
|
+
color: disabled ? 'grey' : 'black',
|
|
21
18
|
},
|
|
22
|
-
|
|
23
|
-
|
|
19
|
+
'&:focus': {
|
|
20
|
+
outline: `2px solid ${theme.palette.grey[700]}`,
|
|
24
21
|
},
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
cursor: 'not-allowed',
|
|
28
|
-
'& :hover': {
|
|
29
|
-
color: 'grey',
|
|
30
|
-
},
|
|
31
|
-
},
|
|
32
|
-
});
|
|
22
|
+
...extraStyles,
|
|
23
|
+
}));
|
|
33
24
|
|
|
34
25
|
const log = debug('pie-elements:editable-html:raw-button');
|
|
35
26
|
|
|
36
27
|
export class RawButton extends React.Component {
|
|
37
28
|
static propTypes = {
|
|
38
29
|
onClick: PropTypes.func.isRequired,
|
|
39
|
-
classes: PropTypes.object.isRequired,
|
|
40
30
|
children: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.node), PropTypes.node]).isRequired,
|
|
41
31
|
active: PropTypes.bool,
|
|
42
32
|
disabled: PropTypes.bool,
|
|
@@ -64,31 +54,26 @@ export class RawButton extends React.Component {
|
|
|
64
54
|
};
|
|
65
55
|
|
|
66
56
|
render() {
|
|
67
|
-
const { active,
|
|
68
|
-
|
|
69
|
-
const names = classNames(classes.button, {
|
|
70
|
-
[classes.active]: active,
|
|
71
|
-
[classes.disabled]: disabled,
|
|
72
|
-
});
|
|
57
|
+
const { active, children, disabled, extraStyles, ariaLabel } = this.props;
|
|
73
58
|
|
|
74
59
|
return (
|
|
75
|
-
<
|
|
76
|
-
|
|
77
|
-
|
|
60
|
+
<StyledButton
|
|
61
|
+
active={active}
|
|
62
|
+
disabled={disabled}
|
|
63
|
+
extraStyles={extraStyles}
|
|
78
64
|
onMouseDown={this.onClick}
|
|
79
65
|
onKeyDown={this.onKeyDown}
|
|
80
|
-
disabled={disabled}
|
|
81
66
|
aria-label={ariaLabel}
|
|
82
67
|
aria-pressed={active}
|
|
83
68
|
tabIndex={0}
|
|
84
69
|
>
|
|
85
70
|
{children}
|
|
86
|
-
</
|
|
71
|
+
</StyledButton>
|
|
87
72
|
);
|
|
88
73
|
}
|
|
89
74
|
}
|
|
90
75
|
|
|
91
|
-
export const Button =
|
|
76
|
+
export const Button = RawButton;
|
|
92
77
|
|
|
93
78
|
export class RawMarkButton extends React.Component {
|
|
94
79
|
static propTypes = {
|
|
@@ -96,7 +81,6 @@ export class RawMarkButton extends React.Component {
|
|
|
96
81
|
mark: PropTypes.string,
|
|
97
82
|
label: PropTypes.string.isRequired,
|
|
98
83
|
children: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.node), PropTypes.node]).isRequired,
|
|
99
|
-
classes: PropTypes.object.isRequired,
|
|
100
84
|
active: PropTypes.bool,
|
|
101
85
|
};
|
|
102
86
|
|
|
@@ -117,12 +101,11 @@ export class RawMarkButton extends React.Component {
|
|
|
117
101
|
};
|
|
118
102
|
|
|
119
103
|
render() {
|
|
120
|
-
const {
|
|
104
|
+
const { children, active, label } = this.props;
|
|
121
105
|
|
|
122
|
-
const names = classNames(classes.button, active && classes.active);
|
|
123
106
|
return (
|
|
124
|
-
<
|
|
125
|
-
|
|
107
|
+
<StyledButton
|
|
108
|
+
active={active}
|
|
126
109
|
onMouseDown={this.onToggle}
|
|
127
110
|
aria-pressed={active}
|
|
128
111
|
onKeyDown={this.onKeyDown}
|
|
@@ -130,9 +113,9 @@ export class RawMarkButton extends React.Component {
|
|
|
130
113
|
tabIndex={0}
|
|
131
114
|
>
|
|
132
115
|
{children}
|
|
133
|
-
</
|
|
116
|
+
</StyledButton>
|
|
134
117
|
);
|
|
135
118
|
}
|
|
136
119
|
}
|
|
137
120
|
|
|
138
|
-
export const MarkButton =
|
|
121
|
+
export const MarkButton = RawMarkButton;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { Change } from 'slate';
|
|
3
|
-
import Delete from '@
|
|
4
|
-
import IconButton from '@material
|
|
3
|
+
import Delete from '@mui/icons-material/Delete';
|
|
4
|
+
import IconButton from '@mui/material/IconButton';
|
|
5
5
|
import PropTypes from 'prop-types';
|
|
6
6
|
import classNames from 'classnames';
|
|
7
7
|
import debug from 'debug';
|
|
@@ -11,13 +11,51 @@ import debounce from 'lodash/debounce';
|
|
|
11
11
|
import { DoneButton } from './done-button';
|
|
12
12
|
|
|
13
13
|
import { findSingleNode, findParentNode } from '../utils';
|
|
14
|
-
import {
|
|
14
|
+
import { styled } from '@mui/material/styles';
|
|
15
15
|
import DefaultToolbar from './default-toolbar';
|
|
16
16
|
import { removeDialogs as removeCharacterDialogs } from '../characters';
|
|
17
17
|
import { PIE_TOOLBAR__CLASS } from '../../constants';
|
|
18
18
|
|
|
19
19
|
const log = debug('@pie-lib:editable-html:plugins:toolbar');
|
|
20
20
|
|
|
21
|
+
const StyledToolbar = styled('div', {
|
|
22
|
+
shouldForwardProp: (prop) => !['hasDoneButton', 'position', 'alignment', 'focused', 'autoWidth', 'hidden'].includes(prop),
|
|
23
|
+
})(({ hasDoneButton, position, alignment, focused, autoWidth, hidden }) => ({
|
|
24
|
+
position: 'absolute',
|
|
25
|
+
zIndex: 10,
|
|
26
|
+
cursor: 'pointer',
|
|
27
|
+
justifyContent: 'space-between',
|
|
28
|
+
background: 'var(--editable-html-toolbar-bg, #efefef)',
|
|
29
|
+
minWidth: hasDoneButton ? '280px' : '265px',
|
|
30
|
+
margin: '5px 0 0 0',
|
|
31
|
+
padding: '2px',
|
|
32
|
+
boxShadow:
|
|
33
|
+
'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)',
|
|
34
|
+
boxSizing: 'border-box',
|
|
35
|
+
display: 'flex',
|
|
36
|
+
opacity: focused ? 1 : 0,
|
|
37
|
+
pointerEvents: focused ? 'auto' : 'none',
|
|
38
|
+
top: position === 'top' ? '-45px' : 'auto',
|
|
39
|
+
right: alignment === 'right' ? 0 : 'auto',
|
|
40
|
+
width: autoWidth ? 'auto' : '100%',
|
|
41
|
+
visibility: hidden ? 'hidden' : 'visible',
|
|
42
|
+
}));
|
|
43
|
+
|
|
44
|
+
const SharedContainer = styled('div')({
|
|
45
|
+
display: 'flex',
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
const StyledIconButton = styled(IconButton)({
|
|
49
|
+
width: '28px',
|
|
50
|
+
height: '28px',
|
|
51
|
+
padding: '4px',
|
|
52
|
+
verticalAlign: 'top',
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
const StyledLabel = styled('div')({
|
|
56
|
+
color: 'var(--editable-html-toolbar-check, #00bb00)',
|
|
57
|
+
});
|
|
58
|
+
|
|
21
59
|
const getCustomToolbar = (plugin, node, value, handleDone, getFocusedValue, onDataChange) => {
|
|
22
60
|
if (!plugin) {
|
|
23
61
|
return;
|
|
@@ -141,7 +179,6 @@ export class Toolbar extends React.Component {
|
|
|
141
179
|
|
|
142
180
|
render() {
|
|
143
181
|
const {
|
|
144
|
-
classes,
|
|
145
182
|
plugins,
|
|
146
183
|
pluginProps,
|
|
147
184
|
toolbarOpts,
|
|
@@ -223,20 +260,21 @@ export class Toolbar extends React.Component {
|
|
|
223
260
|
const defaultToolbarShowDone = !toolbarOpts || toolbarOpts.showDone !== false;
|
|
224
261
|
|
|
225
262
|
const hasDoneButton = defaultToolbarShowDone || customToolbarShowDone;
|
|
226
|
-
|
|
227
|
-
const names = classNames(classes.toolbar, PIE_TOOLBAR__CLASS, {
|
|
228
|
-
[classes.toolbarWithNoDone]: !hasDoneButton,
|
|
229
|
-
[classes.toolbarTop]: toolbarOpts.position === 'top',
|
|
230
|
-
[classes.toolbarRight]: toolbarOpts.alignment === 'right',
|
|
231
|
-
[classes.focused]: toolbarOpts.alwaysVisible || isFocused,
|
|
232
|
-
[classes.autoWidth]: autoWidth,
|
|
233
|
-
[classes.fullWidth]: !autoWidth,
|
|
234
|
-
[classes.hidden]: toolbarOpts.isHidden === true,
|
|
235
|
-
});
|
|
236
263
|
const customStyles = toolbarOpts.minWidth !== undefined ? { minWidth: toolbarOpts.minWidth } : {};
|
|
237
264
|
|
|
238
265
|
return (
|
|
239
|
-
<
|
|
266
|
+
<StyledToolbar
|
|
267
|
+
className={PIE_TOOLBAR__CLASS}
|
|
268
|
+
hasDoneButton={hasDoneButton}
|
|
269
|
+
position={toolbarOpts.position}
|
|
270
|
+
alignment={toolbarOpts.alignment}
|
|
271
|
+
focused={toolbarOpts.alwaysVisible || isFocused}
|
|
272
|
+
autoWidth={autoWidth}
|
|
273
|
+
hidden={toolbarOpts.isHidden === true}
|
|
274
|
+
style={{ ...extraStyles, ...customStyles }}
|
|
275
|
+
onClick={this.onClick}
|
|
276
|
+
ref={toolbarRef}
|
|
277
|
+
>
|
|
240
278
|
{CustomToolbar ? (
|
|
241
279
|
<CustomToolbar
|
|
242
280
|
node={node}
|
|
@@ -262,77 +300,21 @@ export class Toolbar extends React.Component {
|
|
|
262
300
|
onBlur={onBlur}
|
|
263
301
|
/>
|
|
264
302
|
)}
|
|
265
|
-
|
|
266
|
-
<div className={classes.shared}>
|
|
303
|
+
<SharedContainer>
|
|
267
304
|
{deletable && (
|
|
268
|
-
<
|
|
305
|
+
<StyledIconButton
|
|
269
306
|
aria-label="Delete"
|
|
270
|
-
className={classes.iconRoot}
|
|
271
307
|
onMouseDown={(e) => this.onDeleteMouseDown(e, plugin, node, value, onChange)}
|
|
272
|
-
|
|
273
|
-
root: classes.iconRoot,
|
|
274
|
-
}}
|
|
308
|
+
size="large"
|
|
275
309
|
>
|
|
276
310
|
<Delete />
|
|
277
|
-
</
|
|
311
|
+
</StyledIconButton>
|
|
278
312
|
)}
|
|
279
313
|
{customToolbarShowDone && <DoneButton doneButtonRef={doneButtonRef} onClick={handleDone} />}
|
|
280
|
-
</
|
|
281
|
-
</
|
|
314
|
+
</SharedContainer>
|
|
315
|
+
</StyledToolbar>
|
|
282
316
|
);
|
|
283
317
|
}
|
|
284
318
|
}
|
|
285
319
|
|
|
286
|
-
|
|
287
|
-
toolbar: {
|
|
288
|
-
position: 'absolute',
|
|
289
|
-
zIndex: 10,
|
|
290
|
-
cursor: 'pointer',
|
|
291
|
-
justifyContent: 'space-between',
|
|
292
|
-
background: 'var(--editable-html-toolbar-bg, #efefef)',
|
|
293
|
-
minWidth: '280px',
|
|
294
|
-
margin: '5px 0 0 0',
|
|
295
|
-
padding: '2px',
|
|
296
|
-
boxShadow:
|
|
297
|
-
'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)',
|
|
298
|
-
boxSizing: 'border-box',
|
|
299
|
-
display: 'flex',
|
|
300
|
-
opacity: 0,
|
|
301
|
-
pointerEvents: 'none',
|
|
302
|
-
},
|
|
303
|
-
toolbarWithNoDone: {
|
|
304
|
-
minWidth: '265px',
|
|
305
|
-
},
|
|
306
|
-
toolbarTop: {
|
|
307
|
-
top: '-45px',
|
|
308
|
-
},
|
|
309
|
-
toolbarRight: {
|
|
310
|
-
right: 0,
|
|
311
|
-
},
|
|
312
|
-
fullWidth: {
|
|
313
|
-
width: '100%',
|
|
314
|
-
},
|
|
315
|
-
hidden: {
|
|
316
|
-
visibility: 'hidden',
|
|
317
|
-
},
|
|
318
|
-
autoWidth: {
|
|
319
|
-
width: 'auto',
|
|
320
|
-
},
|
|
321
|
-
focused: {
|
|
322
|
-
opacity: 1,
|
|
323
|
-
pointerEvents: 'auto',
|
|
324
|
-
},
|
|
325
|
-
iconRoot: {
|
|
326
|
-
width: '28px',
|
|
327
|
-
height: '28px',
|
|
328
|
-
padding: '4px',
|
|
329
|
-
verticalAlign: 'top',
|
|
330
|
-
},
|
|
331
|
-
label: {
|
|
332
|
-
color: 'var(--editable-html-toolbar-check, #00bb00)',
|
|
333
|
-
},
|
|
334
|
-
shared: {
|
|
335
|
-
display: 'flex',
|
|
336
|
-
},
|
|
337
|
-
};
|
|
338
|
-
export default withStyles(style, { index: 1000 })(Toolbar);
|
|
320
|
+
export default Toolbar;
|