@pie-lib/editable-html 9.2.6-next.4 → 9.2.7
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 +16 -0
- package/lib/editor.js.map +1 -1
- package/lib/index.js.map +1 -1
- package/lib/parse-html.js.map +1 -1
- package/lib/plugins/characters/custom-popper.js.map +1 -1
- package/lib/plugins/characters/index.js.map +1 -1
- package/lib/plugins/characters/utils.js.map +1 -1
- package/lib/plugins/image/alt-dialog.js.map +1 -1
- package/lib/plugins/image/component.js.map +1 -1
- package/lib/plugins/image/image-toolbar.js.map +1 -1
- package/lib/plugins/image/index.js.map +1 -1
- package/lib/plugins/index.js.map +1 -1
- package/lib/plugins/list/index.js.map +1 -1
- package/lib/plugins/math/index.js +1 -1
- package/lib/plugins/math/index.js.map +1 -1
- package/lib/plugins/media/index.js.map +1 -1
- package/lib/plugins/media/media-dialog.js.map +1 -1
- package/lib/plugins/media/media-toolbar.js.map +1 -1
- package/lib/plugins/media/media-wrapper.js.map +1 -1
- package/lib/plugins/respArea/drag-in-the-blank/choice.js.map +1 -1
- package/lib/plugins/respArea/drag-in-the-blank/index.js.map +1 -1
- package/lib/plugins/respArea/explicit-constructed-response/index.js.map +1 -1
- package/lib/plugins/respArea/icons/index.js.map +1 -1
- package/lib/plugins/respArea/index.js.map +1 -1
- package/lib/plugins/respArea/inline-dropdown/index.js.map +1 -1
- package/lib/plugins/respArea/utils.js.map +1 -1
- package/lib/plugins/table/icons/index.js.map +1 -1
- package/lib/plugins/table/index.js.map +1 -1
- package/lib/plugins/table/table-toolbar.js.map +1 -1
- package/lib/plugins/toolbar/default-toolbar.js.map +1 -1
- package/lib/plugins/toolbar/done-button.js.map +1 -1
- package/lib/plugins/toolbar/editor-and-toolbar.js.map +1 -1
- package/lib/plugins/toolbar/index.js.map +1 -1
- package/lib/plugins/toolbar/toolbar-buttons.js.map +1 -1
- package/lib/plugins/toolbar/toolbar.js.map +1 -1
- package/lib/plugins/utils.js.map +1 -1
- package/lib/serialization.js.map +1 -1
- package/package.json +6 -6
- package/playground/image/data.js +20 -20
- package/playground/image/index.html +20 -22
- package/playground/image/index.jsx +7 -12
- package/playground/index.html +23 -25
- package/playground/mathquill/index.html +20 -23
- package/playground/mathquill/index.jsx +7 -18
- package/playground/prod-test/index.html +20 -24
- package/playground/prod-test/index.jsx +2 -5
- package/playground/schema-override/data.js +10 -10
- package/playground/schema-override/image-plugin.jsx +3 -3
- package/playground/schema-override/index.html +19 -21
- package/playground/schema-override/index.jsx +12 -12
- package/playground/serialization/data.js +10 -10
- package/playground/serialization/image-plugin.jsx +3 -3
- package/playground/serialization/index.html +20 -22
- package/playground/table-examples.html +8 -5
- package/playground/webpack.config.js +10 -10
- package/src/editor.jsx +77 -101
- package/src/index.jsx +11 -18
- package/src/parse-html.js +1 -1
- package/src/plugins/characters/custom-popper.js +7 -7
- package/src/plugins/characters/index.jsx +19 -25
- package/src/plugins/characters/utils.js +81 -81
- package/src/plugins/image/alt-dialog.jsx +3 -3
- package/src/plugins/image/component.jsx +42 -46
- package/src/plugins/image/image-toolbar.jsx +14 -26
- package/src/plugins/image/index.jsx +21 -23
- package/src/plugins/index.jsx +10 -12
- package/src/plugins/list/index.jsx +10 -10
- package/src/plugins/math/index.jsx +28 -31
- package/src/plugins/media/index.jsx +21 -21
- package/src/plugins/media/media-dialog.js +60 -86
- package/src/plugins/media/media-toolbar.jsx +6 -6
- package/src/plugins/media/media-wrapper.jsx +6 -6
- package/src/plugins/respArea/drag-in-the-blank/choice.jsx +19 -21
- package/src/plugins/respArea/drag-in-the-blank/index.jsx +10 -12
- package/src/plugins/respArea/explicit-constructed-response/index.jsx +5 -5
- package/src/plugins/respArea/icons/index.jsx +8 -8
- package/src/plugins/respArea/index.jsx +21 -31
- package/src/plugins/respArea/inline-dropdown/index.jsx +6 -6
- package/src/plugins/respArea/utils.jsx +12 -12
- package/src/plugins/table/icons/index.jsx +11 -17
- package/src/plugins/table/index.jsx +43 -49
- package/src/plugins/table/table-toolbar.jsx +8 -13
- package/src/plugins/toolbar/default-toolbar.jsx +11 -19
- package/src/plugins/toolbar/done-button.jsx +4 -4
- package/src/plugins/toolbar/editor-and-toolbar.jsx +39 -47
- package/src/plugins/toolbar/index.jsx +2 -2
- package/src/plugins/toolbar/toolbar-buttons.jsx +11 -11
- package/src/plugins/toolbar/toolbar.jsx +34 -47
- package/src/plugins/utils.js +4 -5
- package/src/serialization.jsx +32 -32
|
@@ -24,16 +24,16 @@ export class TableToolbar extends React.Component {
|
|
|
24
24
|
onToggleBorder: PropTypes.func.isRequired,
|
|
25
25
|
hasBorder: PropTypes.bool,
|
|
26
26
|
onDone: PropTypes.func.isRequired,
|
|
27
|
-
classes: PropTypes.object.isRequired
|
|
27
|
+
classes: PropTypes.object.isRequired,
|
|
28
28
|
};
|
|
29
29
|
|
|
30
30
|
static defaultProps = {
|
|
31
31
|
plugins: [],
|
|
32
32
|
value: {},
|
|
33
|
-
onChange: () => {}
|
|
33
|
+
onChange: () => {},
|
|
34
34
|
};
|
|
35
35
|
|
|
36
|
-
onDone = e => {
|
|
36
|
+
onDone = (e) => {
|
|
37
37
|
const { onDone } = this.props;
|
|
38
38
|
e.preventDefault();
|
|
39
39
|
onDone();
|
|
@@ -51,7 +51,7 @@ export class TableToolbar extends React.Component {
|
|
|
51
51
|
onRemoveTable,
|
|
52
52
|
onToggleBorder,
|
|
53
53
|
hasBorder,
|
|
54
|
-
classes
|
|
54
|
+
classes,
|
|
55
55
|
} = this.props;
|
|
56
56
|
log('[render] hasBorder:', hasBorder);
|
|
57
57
|
|
|
@@ -74,12 +74,7 @@ export class TableToolbar extends React.Component {
|
|
|
74
74
|
<RemoveTable />
|
|
75
75
|
</Button>
|
|
76
76
|
{plugins.map((p, index) => (
|
|
77
|
-
<ToolbarButton
|
|
78
|
-
key={`plugin-${index}`}
|
|
79
|
-
{...p.toolbar}
|
|
80
|
-
value={value}
|
|
81
|
-
onChange={onChange}
|
|
82
|
-
/>
|
|
77
|
+
<ToolbarButton key={`plugin-${index}`} {...p.toolbar} value={value} onChange={onChange} />
|
|
83
78
|
))}
|
|
84
79
|
<Button onClick={onToggleBorder} active={hasBorder}>
|
|
85
80
|
<BorderAll />
|
|
@@ -95,10 +90,10 @@ const styles = () => ({
|
|
|
95
90
|
tableToolbar: {
|
|
96
91
|
width: '100%',
|
|
97
92
|
display: 'flex',
|
|
98
|
-
justifyContent: 'space-between'
|
|
93
|
+
justifyContent: 'space-between',
|
|
99
94
|
},
|
|
100
95
|
toolbarButtons: {
|
|
101
|
-
display: 'flex'
|
|
102
|
-
}
|
|
96
|
+
display: 'flex',
|
|
97
|
+
},
|
|
103
98
|
});
|
|
104
99
|
export default withStyles(styles)(TableToolbar);
|
|
@@ -11,7 +11,7 @@ import debug from 'debug';
|
|
|
11
11
|
|
|
12
12
|
const log = debug('@pie-lib:editable-html:plugins:toolbar');
|
|
13
13
|
|
|
14
|
-
export const ToolbarButton = props => {
|
|
14
|
+
export const ToolbarButton = (props) => {
|
|
15
15
|
const onToggle = () => {
|
|
16
16
|
const c = props.onToggle(props.value.change(), props);
|
|
17
17
|
|
|
@@ -30,9 +30,7 @@ export const ToolbarButton = props => {
|
|
|
30
30
|
);
|
|
31
31
|
} else {
|
|
32
32
|
const { disabled } = props;
|
|
33
|
-
const isActive = props.isActive
|
|
34
|
-
? props.isActive(props.value, props.type)
|
|
35
|
-
: hasBlock(props.value, props.type);
|
|
33
|
+
const isActive = props.isActive ? props.isActive(props.value, props.type) : hasBlock(props.value, props.type);
|
|
36
34
|
|
|
37
35
|
log('[ToolbarButton] block:isActive: ', isActive);
|
|
38
36
|
|
|
@@ -49,7 +47,7 @@ export const ToolbarButton = props => {
|
|
|
49
47
|
}
|
|
50
48
|
};
|
|
51
49
|
|
|
52
|
-
const isActiveToolbarPlugin = props => plugin => {
|
|
50
|
+
const isActiveToolbarPlugin = (props) => (plugin) => {
|
|
53
51
|
const isDisabled = (props[plugin.name] || {}).disabled;
|
|
54
52
|
|
|
55
53
|
return plugin && plugin.toolbar && !isDisabled;
|
|
@@ -64,22 +62,16 @@ export const DefaultToolbar = ({
|
|
|
64
62
|
onDone,
|
|
65
63
|
classes,
|
|
66
64
|
showDone,
|
|
67
|
-
deletable
|
|
65
|
+
deletable,
|
|
68
66
|
}) => {
|
|
69
|
-
const filtered = plugins.filter(isActiveToolbarPlugin(pluginProps)).map(p => p.toolbar);
|
|
67
|
+
const filtered = plugins.filter(isActiveToolbarPlugin(pluginProps)).map((p) => p.toolbar);
|
|
70
68
|
|
|
71
69
|
return (
|
|
72
70
|
<div className={classes.defaultToolbar}>
|
|
73
71
|
<div className={classes.buttonsContainer}>
|
|
74
72
|
{filtered.map((p, index) => {
|
|
75
73
|
return (
|
|
76
|
-
<ToolbarButton
|
|
77
|
-
{...p}
|
|
78
|
-
key={index}
|
|
79
|
-
value={value}
|
|
80
|
-
onChange={onChange}
|
|
81
|
-
getFocusedValue={getFocusedValue}
|
|
82
|
-
/>
|
|
74
|
+
<ToolbarButton {...p} key={index} value={value} onChange={onChange} getFocusedValue={getFocusedValue} />
|
|
83
75
|
);
|
|
84
76
|
})}
|
|
85
77
|
</div>
|
|
@@ -98,24 +90,24 @@ DefaultToolbar.propTypes = {
|
|
|
98
90
|
onDone: PropTypes.func.isRequired,
|
|
99
91
|
showDone: PropTypes.bool,
|
|
100
92
|
addArea: PropTypes.bool,
|
|
101
|
-
deletable: PropTypes.bool
|
|
93
|
+
deletable: PropTypes.bool,
|
|
102
94
|
};
|
|
103
95
|
|
|
104
96
|
DefaultToolbar.defaultProps = {
|
|
105
|
-
pluginProps: {}
|
|
97
|
+
pluginProps: {},
|
|
106
98
|
};
|
|
107
99
|
|
|
108
100
|
const toolbarStyles = () => ({
|
|
109
101
|
defaultToolbar: {
|
|
110
102
|
display: 'flex',
|
|
111
103
|
width: '100%',
|
|
112
|
-
justifyContent: 'space-between'
|
|
104
|
+
justifyContent: 'space-between',
|
|
113
105
|
},
|
|
114
106
|
buttonsContainer: {
|
|
115
107
|
alignItems: 'center',
|
|
116
108
|
display: 'flex',
|
|
117
|
-
width: '100%'
|
|
118
|
-
}
|
|
109
|
+
width: '100%',
|
|
110
|
+
},
|
|
119
111
|
});
|
|
120
112
|
|
|
121
113
|
export default withStyles(toolbarStyles)(DefaultToolbar);
|
|
@@ -12,7 +12,7 @@ export const RawDoneButton = ({ classes, onClick }) => (
|
|
|
12
12
|
onClick={onClick}
|
|
13
13
|
classes={{
|
|
14
14
|
label: classes.label,
|
|
15
|
-
root: classes.iconRoot
|
|
15
|
+
root: classes.iconRoot,
|
|
16
16
|
}}
|
|
17
17
|
>
|
|
18
18
|
<Check />
|
|
@@ -21,7 +21,7 @@ export const RawDoneButton = ({ classes, onClick }) => (
|
|
|
21
21
|
|
|
22
22
|
RawDoneButton.propTypes = {
|
|
23
23
|
classes: PropTypes.object.isRequired,
|
|
24
|
-
onClick: PropTypes.func
|
|
24
|
+
onClick: PropTypes.func,
|
|
25
25
|
};
|
|
26
26
|
|
|
27
27
|
const styles = {
|
|
@@ -30,7 +30,7 @@ const styles = {
|
|
|
30
30
|
width: '28px',
|
|
31
31
|
height: '28px',
|
|
32
32
|
color: 'var(--editable-html-toolbar-check, #00bb00)',
|
|
33
|
-
padding: '4px'
|
|
34
|
-
}
|
|
33
|
+
padding: '4px',
|
|
34
|
+
},
|
|
35
35
|
};
|
|
36
36
|
export const DoneButton = withStyles(styles)(RawDoneButton);
|
|
@@ -31,8 +31,8 @@ export class EditorAndToolbar extends React.Component {
|
|
|
31
31
|
toolbarOpts: PropTypes.shape({
|
|
32
32
|
position: PropTypes.oneOf(['bottom', 'top']),
|
|
33
33
|
alwaysVisible: PropTypes.bool,
|
|
34
|
-
error: PropTypes.string
|
|
35
|
-
})
|
|
34
|
+
error: PropTypes.string,
|
|
35
|
+
}),
|
|
36
36
|
};
|
|
37
37
|
|
|
38
38
|
/** This is an interim fix until this PR is merged in slate:
|
|
@@ -61,7 +61,7 @@ export class EditorAndToolbar extends React.Component {
|
|
|
61
61
|
pluginProps,
|
|
62
62
|
toolbarOpts,
|
|
63
63
|
onDataChange,
|
|
64
|
-
toolbarRef
|
|
64
|
+
toolbarRef,
|
|
65
65
|
} = this.props;
|
|
66
66
|
|
|
67
67
|
const inFocus = value.isFocused || (focusedNode !== null && focusedNode !== undefined);
|
|
@@ -69,42 +69,35 @@ export class EditorAndToolbar extends React.Component {
|
|
|
69
69
|
[classes.editorInFocus]: inFocus,
|
|
70
70
|
[classes.readOnly]: readOnly,
|
|
71
71
|
[classes.disabledUnderline]: disableUnderline,
|
|
72
|
-
[classes.disabledScrollbar]: disableScrollbar
|
|
72
|
+
[classes.disabledScrollbar]: disableScrollbar,
|
|
73
73
|
});
|
|
74
74
|
let clonedChildren = children;
|
|
75
75
|
|
|
76
76
|
if (typeof children !== 'string') {
|
|
77
77
|
clonedChildren = React.cloneElement(children, {
|
|
78
|
-
ref: el => (this.editorRef = el)
|
|
78
|
+
ref: (el) => (this.editorRef = el),
|
|
79
79
|
});
|
|
80
80
|
}
|
|
81
81
|
|
|
82
|
-
log(
|
|
83
|
-
'[render] inFocus: ',
|
|
84
|
-
inFocus,
|
|
85
|
-
'value.isFocused:',
|
|
86
|
-
value.isFocused,
|
|
87
|
-
'focused node: ',
|
|
88
|
-
focusedNode
|
|
89
|
-
);
|
|
82
|
+
log('[render] inFocus: ', inFocus, 'value.isFocused:', value.isFocused, 'focused node: ', focusedNode);
|
|
90
83
|
|
|
91
84
|
return (
|
|
92
85
|
<div
|
|
93
86
|
className={classNames(
|
|
94
87
|
{
|
|
95
88
|
[classes.noBorder]: toolbarOpts && toolbarOpts.noBorder,
|
|
96
|
-
[classes.error]: toolbarOpts && toolbarOpts.error
|
|
89
|
+
[classes.error]: toolbarOpts && toolbarOpts.error,
|
|
97
90
|
},
|
|
98
|
-
classes.root
|
|
91
|
+
classes.root,
|
|
99
92
|
)}
|
|
100
93
|
>
|
|
101
94
|
<div className={holderNames}>
|
|
102
95
|
<div
|
|
103
96
|
className={classNames(
|
|
104
97
|
{
|
|
105
|
-
[classes.noPadding]: toolbarOpts && toolbarOpts.noBorder
|
|
98
|
+
[classes.noPadding]: toolbarOpts && toolbarOpts.noBorder,
|
|
106
99
|
},
|
|
107
|
-
classes.children
|
|
100
|
+
classes.children,
|
|
108
101
|
)}
|
|
109
102
|
>
|
|
110
103
|
{clonedChildren}
|
|
@@ -141,11 +134,11 @@ const style = {
|
|
|
141
134
|
overflow: 'visible',
|
|
142
135
|
maxHeight: '500px',
|
|
143
136
|
// needed in order to be able to put the focus before a void element when it is the first one in the editor
|
|
144
|
-
padding: '5px'
|
|
145
|
-
}
|
|
137
|
+
padding: '5px',
|
|
138
|
+
},
|
|
146
139
|
},
|
|
147
140
|
children: {
|
|
148
|
-
padding: '10px 16px'
|
|
141
|
+
padding: '10px 16px',
|
|
149
142
|
},
|
|
150
143
|
editorHolder: {
|
|
151
144
|
position: 'relative',
|
|
@@ -162,7 +155,7 @@ const style = {
|
|
|
162
155
|
position: 'absolute',
|
|
163
156
|
transition: 'background-color 200ms cubic-bezier(0.4, 0, 0.2, 1) 0ms',
|
|
164
157
|
pointerEvents: 'none',
|
|
165
|
-
backgroundColor: 'rgba(0, 0, 0, 0.42)'
|
|
158
|
+
backgroundColor: 'rgba(0, 0, 0, 0.42)',
|
|
166
159
|
},
|
|
167
160
|
'&::after': {
|
|
168
161
|
left: '0',
|
|
@@ -172,39 +165,38 @@ const style = {
|
|
|
172
165
|
content: '""',
|
|
173
166
|
position: 'absolute',
|
|
174
167
|
transform: 'scaleX(0)',
|
|
175
|
-
transition:
|
|
176
|
-
|
|
177
|
-
backgroundColor: 'rgba(0, 0, 0, 0.42)'
|
|
168
|
+
transition: 'transform 200ms cubic-bezier(0.0, 0.0, 0.2, 1) 0ms, background-color 200ms linear',
|
|
169
|
+
backgroundColor: 'rgba(0, 0, 0, 0.42)',
|
|
178
170
|
},
|
|
179
171
|
'&:focus': {
|
|
180
172
|
'&::after': {
|
|
181
173
|
transform: 'scaleX(1)',
|
|
182
174
|
backgroundColor: primary,
|
|
183
|
-
height: '2px'
|
|
184
|
-
}
|
|
175
|
+
height: '2px',
|
|
176
|
+
},
|
|
185
177
|
},
|
|
186
178
|
'&:hover': {
|
|
187
179
|
'&::after': {
|
|
188
180
|
transform: 'scaleX(1)',
|
|
189
181
|
backgroundColor: 'black',
|
|
190
|
-
height: '2px'
|
|
191
|
-
}
|
|
192
|
-
}
|
|
182
|
+
height: '2px',
|
|
183
|
+
},
|
|
184
|
+
},
|
|
193
185
|
},
|
|
194
186
|
disabledUnderline: {
|
|
195
187
|
'&::before': {
|
|
196
|
-
display: 'none'
|
|
188
|
+
display: 'none',
|
|
197
189
|
},
|
|
198
190
|
'&::after': {
|
|
199
|
-
display: 'none'
|
|
200
|
-
}
|
|
191
|
+
display: 'none',
|
|
192
|
+
},
|
|
201
193
|
},
|
|
202
194
|
disabledScrollbar: {
|
|
203
195
|
'&::-webkit-scrollbar': {
|
|
204
|
-
display: 'none'
|
|
196
|
+
display: 'none',
|
|
205
197
|
},
|
|
206
198
|
scrollbarWidth: 'none',
|
|
207
|
-
'-ms-overflow-style': 'none'
|
|
199
|
+
'-ms-overflow-style': 'none',
|
|
208
200
|
},
|
|
209
201
|
readOnly: {
|
|
210
202
|
'&::before': {
|
|
@@ -212,7 +204,7 @@ const style = {
|
|
|
212
204
|
backgroundSize: '5px 1px',
|
|
213
205
|
backgroundImage: 'linear-gradient(to right, rgba(0, 0, 0, 0.42) 33%, transparent 0%)',
|
|
214
206
|
backgroundRepeat: 'repeat-x',
|
|
215
|
-
backgroundPosition: 'left top'
|
|
207
|
+
backgroundPosition: 'left top',
|
|
216
208
|
},
|
|
217
209
|
'&::after': {
|
|
218
210
|
left: '0',
|
|
@@ -223,37 +215,37 @@ const style = {
|
|
|
223
215
|
position: 'absolute',
|
|
224
216
|
transform: 'scaleX(0)',
|
|
225
217
|
transition: 'transform 200ms cubic-bezier(0.0, 0.0, 0.2, 1) 0ms, background-color 0ms linear',
|
|
226
|
-
backgroundColor: 'rgba(0, 0, 0, 0)'
|
|
218
|
+
backgroundColor: 'rgba(0, 0, 0, 0)',
|
|
227
219
|
},
|
|
228
220
|
'&:hover': {
|
|
229
221
|
'&::after': {
|
|
230
222
|
transform: 'scaleX(0)',
|
|
231
223
|
backgroundColor: 'black',
|
|
232
|
-
height: '2px'
|
|
233
|
-
}
|
|
234
|
-
}
|
|
224
|
+
height: '2px',
|
|
225
|
+
},
|
|
226
|
+
},
|
|
235
227
|
},
|
|
236
228
|
editorInFocus: {
|
|
237
229
|
'&::after': {
|
|
238
230
|
transform: 'scaleX(1)',
|
|
239
231
|
backgroundColor: primary,
|
|
240
|
-
height: '2px'
|
|
232
|
+
height: '2px',
|
|
241
233
|
},
|
|
242
234
|
'&:hover': {
|
|
243
235
|
'&::after': {
|
|
244
|
-
backgroundColor: primary
|
|
245
|
-
}
|
|
246
|
-
}
|
|
236
|
+
backgroundColor: primary,
|
|
237
|
+
},
|
|
238
|
+
},
|
|
247
239
|
},
|
|
248
240
|
error: {
|
|
249
|
-
border: '2px solid red'
|
|
241
|
+
border: '2px solid red',
|
|
250
242
|
},
|
|
251
243
|
noBorder: {
|
|
252
|
-
border: 'none'
|
|
244
|
+
border: 'none',
|
|
253
245
|
},
|
|
254
246
|
noPadding: {
|
|
255
|
-
padding: 0
|
|
256
|
-
}
|
|
247
|
+
padding: 0,
|
|
248
|
+
},
|
|
257
249
|
};
|
|
258
250
|
|
|
259
251
|
export default withStyles(style)(EditorAndToolbar);
|
|
@@ -9,7 +9,7 @@ import EditorAndToolbar from './editor-and-toolbar';
|
|
|
9
9
|
export default function ToolbarPlugin(opts) {
|
|
10
10
|
return {
|
|
11
11
|
/* eslint-disable-next-line */
|
|
12
|
-
renderEditor: props => (
|
|
12
|
+
renderEditor: (props) => (
|
|
13
13
|
<EditorAndToolbar
|
|
14
14
|
{...props}
|
|
15
15
|
mainEditorRef={opts.mainEditorRef}
|
|
@@ -18,6 +18,6 @@ export default function ToolbarPlugin(opts) {
|
|
|
18
18
|
autoWidth={opts.autoWidth}
|
|
19
19
|
onDone={opts.onDone}
|
|
20
20
|
/>
|
|
21
|
-
)
|
|
21
|
+
),
|
|
22
22
|
};
|
|
23
23
|
}
|
|
@@ -10,19 +10,19 @@ const styles = () => ({
|
|
|
10
10
|
display: 'inline-flex',
|
|
11
11
|
padding: '2px',
|
|
12
12
|
'& :hover': {
|
|
13
|
-
color: 'black'
|
|
14
|
-
}
|
|
13
|
+
color: 'black',
|
|
14
|
+
},
|
|
15
15
|
},
|
|
16
16
|
active: {
|
|
17
|
-
color: 'black'
|
|
17
|
+
color: 'black',
|
|
18
18
|
},
|
|
19
19
|
disabled: {
|
|
20
20
|
opacity: 0.7,
|
|
21
21
|
cursor: 'not-allowed',
|
|
22
22
|
'& :hover': {
|
|
23
|
-
color: 'grey'
|
|
24
|
-
}
|
|
25
|
-
}
|
|
23
|
+
color: 'grey',
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
26
|
});
|
|
27
27
|
|
|
28
28
|
const log = debug('pie-elements:editable-html:raw-button');
|
|
@@ -34,14 +34,14 @@ export class RawButton extends React.Component {
|
|
|
34
34
|
children: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.node), PropTypes.node]).isRequired,
|
|
35
35
|
active: PropTypes.bool,
|
|
36
36
|
disabled: PropTypes.bool,
|
|
37
|
-
extraStyles: PropTypes.object
|
|
37
|
+
extraStyles: PropTypes.object,
|
|
38
38
|
};
|
|
39
39
|
|
|
40
40
|
constructor(props) {
|
|
41
41
|
super(props);
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
-
onClick = e => {
|
|
44
|
+
onClick = (e) => {
|
|
45
45
|
log('[onClick]');
|
|
46
46
|
e.preventDefault();
|
|
47
47
|
const { onClick } = this.props;
|
|
@@ -52,7 +52,7 @@ export class RawButton extends React.Component {
|
|
|
52
52
|
const { active, classes, children, disabled, extraStyles } = this.props;
|
|
53
53
|
const names = classNames(classes.button, {
|
|
54
54
|
[classes.active]: active,
|
|
55
|
-
[classes.disabled]: disabled
|
|
55
|
+
[classes.disabled]: disabled,
|
|
56
56
|
});
|
|
57
57
|
|
|
58
58
|
return (
|
|
@@ -71,14 +71,14 @@ export class RawMarkButton extends React.Component {
|
|
|
71
71
|
mark: PropTypes.string,
|
|
72
72
|
children: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.node), PropTypes.node]).isRequired,
|
|
73
73
|
classes: PropTypes.object.isRequired,
|
|
74
|
-
active: PropTypes.bool
|
|
74
|
+
active: PropTypes.bool,
|
|
75
75
|
};
|
|
76
76
|
|
|
77
77
|
constructor(props) {
|
|
78
78
|
super(props);
|
|
79
79
|
}
|
|
80
80
|
|
|
81
|
-
onToggle = e => {
|
|
81
|
+
onToggle = (e) => {
|
|
82
82
|
e.preventDefault();
|
|
83
83
|
this.props.onToggle(this.props.mark);
|
|
84
84
|
};
|
|
@@ -58,15 +58,15 @@ export class Toolbar extends React.Component {
|
|
|
58
58
|
alignment: PropTypes.oneOf(['left', 'right']),
|
|
59
59
|
alwaysVisible: PropTypes.bool,
|
|
60
60
|
ref: PropTypes.func,
|
|
61
|
-
showDone: PropTypes.bool
|
|
61
|
+
showDone: PropTypes.bool,
|
|
62
62
|
}),
|
|
63
|
-
onDataChange: PropTypes.func
|
|
63
|
+
onDataChange: PropTypes.func,
|
|
64
64
|
};
|
|
65
65
|
|
|
66
66
|
constructor(props) {
|
|
67
67
|
super(props);
|
|
68
68
|
this.state = {
|
|
69
|
-
change: null
|
|
69
|
+
change: null,
|
|
70
70
|
};
|
|
71
71
|
}
|
|
72
72
|
|
|
@@ -74,17 +74,17 @@ export class Toolbar extends React.Component {
|
|
|
74
74
|
removeCharacterDialogs();
|
|
75
75
|
}
|
|
76
76
|
|
|
77
|
-
hasMark = type => {
|
|
77
|
+
hasMark = (type) => {
|
|
78
78
|
const { value } = this.props;
|
|
79
|
-
return value.marks.some(mark => mark.type == type);
|
|
79
|
+
return value.marks.some((mark) => mark.type == type);
|
|
80
80
|
};
|
|
81
81
|
|
|
82
|
-
hasBlock = type => {
|
|
82
|
+
hasBlock = (type) => {
|
|
83
83
|
const { value } = this.props;
|
|
84
|
-
return value.blocks.some(node => node.type == type);
|
|
84
|
+
return value.blocks.some((node) => node.type == type);
|
|
85
85
|
};
|
|
86
86
|
|
|
87
|
-
onToggle = plugin => {
|
|
87
|
+
onToggle = (plugin) => {
|
|
88
88
|
const { value, onChange } = this.props;
|
|
89
89
|
|
|
90
90
|
if (!plugin.onToggle) return;
|
|
@@ -93,13 +93,13 @@ export class Toolbar extends React.Component {
|
|
|
93
93
|
onChange(change);
|
|
94
94
|
};
|
|
95
95
|
|
|
96
|
-
onClick = e => {
|
|
96
|
+
onClick = (e) => {
|
|
97
97
|
log('[onClick]');
|
|
98
98
|
e.preventDefault();
|
|
99
99
|
};
|
|
100
100
|
|
|
101
|
-
onButtonClick = fn => {
|
|
102
|
-
return e => {
|
|
101
|
+
onButtonClick = (fn) => {
|
|
102
|
+
return (e) => {
|
|
103
103
|
e.preventDefault();
|
|
104
104
|
fn();
|
|
105
105
|
};
|
|
@@ -123,10 +123,7 @@ export class Toolbar extends React.Component {
|
|
|
123
123
|
}
|
|
124
124
|
};
|
|
125
125
|
|
|
126
|
-
onDeleteClick = debounce(
|
|
127
|
-
(e, plugin, node, value, onChange) => plugin.deleteNode(e, node, value, onChange),
|
|
128
|
-
500
|
|
129
|
-
);
|
|
126
|
+
onDeleteClick = debounce((e, plugin, node, value, onChange) => plugin.deleteNode(e, node, value, onChange), 500);
|
|
130
127
|
|
|
131
128
|
onDeleteMouseDown = (e, plugin, node, value, onChange) => {
|
|
132
129
|
e.persist();
|
|
@@ -145,7 +142,7 @@ export class Toolbar extends React.Component {
|
|
|
145
142
|
getFocusedValue,
|
|
146
143
|
isFocused,
|
|
147
144
|
onDone,
|
|
148
|
-
toolbarRef
|
|
145
|
+
toolbarRef,
|
|
149
146
|
} = this.props;
|
|
150
147
|
|
|
151
148
|
const node = findSingleNode(value);
|
|
@@ -154,7 +151,7 @@ export class Toolbar extends React.Component {
|
|
|
154
151
|
log(' --------------> [render] node: ', node);
|
|
155
152
|
log('[render] node: ', node);
|
|
156
153
|
|
|
157
|
-
const plugin = plugins.find(p => {
|
|
154
|
+
const plugin = plugins.find((p) => {
|
|
158
155
|
if (!node) {
|
|
159
156
|
return;
|
|
160
157
|
}
|
|
@@ -163,7 +160,7 @@ export class Toolbar extends React.Component {
|
|
|
163
160
|
return p.toolbar.supports && p.toolbar.supports(node, value);
|
|
164
161
|
}
|
|
165
162
|
});
|
|
166
|
-
const parentPlugin = plugins.find(p => {
|
|
163
|
+
const parentPlugin = plugins.find((p) => {
|
|
167
164
|
if (!parentNode) {
|
|
168
165
|
return;
|
|
169
166
|
}
|
|
@@ -198,27 +195,17 @@ export class Toolbar extends React.Component {
|
|
|
198
195
|
this.props.onDataChange(key, data);
|
|
199
196
|
};
|
|
200
197
|
|
|
201
|
-
const CustomToolbar = getCustomToolbar(
|
|
202
|
-
plugin,
|
|
203
|
-
node,
|
|
204
|
-
value,
|
|
205
|
-
handleDone,
|
|
206
|
-
this.props.onDataChange
|
|
207
|
-
);
|
|
198
|
+
const CustomToolbar = getCustomToolbar(plugin, node, value, handleDone, this.props.onDataChange);
|
|
208
199
|
|
|
209
|
-
const filteredPlugins =
|
|
210
|
-
plugin && plugin.filterPlugins ? plugin.filterPlugins(node, plugins) : plugins;
|
|
200
|
+
const filteredPlugins = plugin && plugin.filterPlugins ? plugin.filterPlugins(node, plugins) : plugins;
|
|
211
201
|
|
|
212
202
|
log('[render] CustomToolbar: ', CustomToolbar);
|
|
213
203
|
const parentExtraStyles =
|
|
214
|
-
parentPlugin && parentPlugin.pluginStyles
|
|
215
|
-
|
|
216
|
-
: {};
|
|
217
|
-
const pluginExtraStyles =
|
|
218
|
-
plugin && plugin.pluginStyles ? plugin.pluginStyles(node, parentNode, plugin) : {};
|
|
204
|
+
parentPlugin && parentPlugin.pluginStyles ? parentPlugin.pluginStyles(node, parentNode, plugin) : {};
|
|
205
|
+
const pluginExtraStyles = plugin && plugin.pluginStyles ? plugin.pluginStyles(node, parentNode, plugin) : {};
|
|
219
206
|
const extraStyles = {
|
|
220
207
|
...pluginExtraStyles,
|
|
221
|
-
...parentExtraStyles
|
|
208
|
+
...parentExtraStyles,
|
|
222
209
|
};
|
|
223
210
|
|
|
224
211
|
const deletable = node && plugin && plugin.deleteNode;
|
|
@@ -236,7 +223,7 @@ export class Toolbar extends React.Component {
|
|
|
236
223
|
[classes.toolbarRight]: toolbarOpts.alignment === 'right',
|
|
237
224
|
[classes.focused]: toolbarOpts.alwaysVisible || isFocused,
|
|
238
225
|
[classes.autoWidth]: autoWidth,
|
|
239
|
-
[classes.fullWidth]: !autoWidth
|
|
226
|
+
[classes.fullWidth]: !autoWidth,
|
|
240
227
|
});
|
|
241
228
|
|
|
242
229
|
return (
|
|
@@ -267,9 +254,9 @@ export class Toolbar extends React.Component {
|
|
|
267
254
|
<IconButton
|
|
268
255
|
aria-label="Delete"
|
|
269
256
|
className={classes.iconRoot}
|
|
270
|
-
onMouseDown={e => this.onDeleteMouseDown(e, plugin, node, value, onChange)}
|
|
257
|
+
onMouseDown={(e) => this.onDeleteMouseDown(e, plugin, node, value, onChange)}
|
|
271
258
|
classes={{
|
|
272
|
-
root: classes.iconRoot
|
|
259
|
+
root: classes.iconRoot,
|
|
273
260
|
}}
|
|
274
261
|
>
|
|
275
262
|
<Delete />
|
|
@@ -295,37 +282,37 @@ const style = {
|
|
|
295
282
|
boxShadow:
|
|
296
283
|
'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)',
|
|
297
284
|
boxSizing: 'border-box',
|
|
298
|
-
display: 'none'
|
|
285
|
+
display: 'none',
|
|
299
286
|
},
|
|
300
287
|
toolbarWithNoDone: {
|
|
301
|
-
minWidth: '265px'
|
|
288
|
+
minWidth: '265px',
|
|
302
289
|
},
|
|
303
290
|
toolbarTop: {
|
|
304
|
-
top: '-45px'
|
|
291
|
+
top: '-45px',
|
|
305
292
|
},
|
|
306
293
|
toolbarRight: {
|
|
307
|
-
right: 0
|
|
294
|
+
right: 0,
|
|
308
295
|
},
|
|
309
296
|
fullWidth: {
|
|
310
|
-
width: '100%'
|
|
297
|
+
width: '100%',
|
|
311
298
|
},
|
|
312
299
|
autoWidth: {
|
|
313
|
-
width: 'auto'
|
|
300
|
+
width: 'auto',
|
|
314
301
|
},
|
|
315
302
|
focused: {
|
|
316
|
-
display: 'flex'
|
|
303
|
+
display: 'flex',
|
|
317
304
|
},
|
|
318
305
|
iconRoot: {
|
|
319
306
|
width: '28px',
|
|
320
307
|
height: '28px',
|
|
321
308
|
padding: '4px',
|
|
322
|
-
verticalAlign: 'top'
|
|
309
|
+
verticalAlign: 'top',
|
|
323
310
|
},
|
|
324
311
|
label: {
|
|
325
|
-
color: 'var(--editable-html-toolbar-check, #00bb00)'
|
|
312
|
+
color: 'var(--editable-html-toolbar-check, #00bb00)',
|
|
326
313
|
},
|
|
327
314
|
shared: {
|
|
328
|
-
display: 'flex'
|
|
329
|
-
}
|
|
315
|
+
display: 'flex',
|
|
316
|
+
},
|
|
330
317
|
};
|
|
331
318
|
export default withStyles(style, { index: 1000 })(Toolbar);
|
package/src/plugins/utils.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export const findSingleNode = value => {
|
|
1
|
+
export const findSingleNode = (value) => {
|
|
2
2
|
if (!value || !value.isCollapsed || !value.startKey) {
|
|
3
3
|
return;
|
|
4
4
|
}
|
|
@@ -24,9 +24,8 @@ export const findParentNode = (value, node) => {
|
|
|
24
24
|
return value.document.getParent(node.key);
|
|
25
25
|
};
|
|
26
26
|
|
|
27
|
-
export const hasMark = (value, type) => value && value.marks.some(mark => mark.type == type);
|
|
27
|
+
export const hasMark = (value, type) => value && value.marks.some((mark) => mark.type == type);
|
|
28
28
|
|
|
29
|
-
export const hasBlock = (value, type) => value && value.blocks.some(node => node.type == type);
|
|
29
|
+
export const hasBlock = (value, type) => value && value.blocks.some((node) => node.type == type);
|
|
30
30
|
|
|
31
|
-
export const hasNode = ({ document }, type) =>
|
|
32
|
-
document && document.nodes.some(node => node.type == type);
|
|
31
|
+
export const hasNode = ({ document }, type) => document && document.nodes.some((node) => node.type == type);
|