Skip to content
This repository was archived by the owner on Dec 23, 2023. It is now read-only.

Commit 6223702

Browse files
committed
improvement: change over fully to use StrapiV4 design system
removed requirement for @buffetJS. Refactored.
1 parent 859faae commit 6223702

File tree

3 files changed

+63
-998
lines changed

3 files changed

+63
-998
lines changed

admin/src/components/Wysiwyg/index.js

+58-121
Original file line numberDiff line numberDiff line change
@@ -2,146 +2,83 @@ import React from "react";
22
import PropTypes from "prop-types";
33
import { isEmpty } from 'lodash';
44
import Editor from "../editorjs";
5-
65
import cn from 'classnames';
7-
import { Error } from "@buffetjs/core";
86
import Wrapper from './wrapper';
97
import { useIntl } from 'react-intl';
108
import { Box } from '@strapi/design-system/Box';
119
import { Typography } from '@strapi/design-system/Typography';
1210

11+
const Wysiwyg = ({
12+
name,
13+
className,
14+
error,
15+
description,
16+
intlLabel,
17+
required,
18+
onChange,
19+
style,
20+
value,
21+
disabled,
22+
}) => {
23+
const { formatMessage } = useIntl();
1324

14-
// eslint-disable-next-line react/prefer-stateless-function
15-
class WysiwygWithErrors extends React.Component {
16-
render() {
17-
const {
18-
autoFocus,
19-
className,
20-
deactivateErrorHighlight,
21-
disabled,
22-
error: inputError,
23-
inputClassName,
24-
inputDescription,
25-
inputStyle,
26-
label,
27-
description,
28-
intlLabel,
29-
labelIcon,
30-
required,
31-
name,
32-
onBlur: handleBlur,
33-
onChange,
34-
placeholder,
35-
resetProps,
36-
style,
37-
tabIndex,
38-
validations,
39-
value,
40-
...rest
41-
} = this.props;
42-
43-
return (
44-
<Error
45-
inputError={inputError}
46-
name={name}
47-
type="text"
48-
validations={validations}
49-
>
50-
{({ canCheck, onBlur, error, dispatch }) => {
51-
const hasError = Boolean(error);
52-
const { formatMessage } = useIntl();
53-
54-
return (
55-
56-
<Wrapper size={1} className={`${cn(!isEmpty(className) && className)} ${hasError ? 'bordered' : ''}`} style={style}>
57-
58-
<Box>
59-
<Typography variant="pi" fontWeight="bold">
60-
{formatMessage(intlLabel)}
61-
</Typography>
62-
{required && (
63-
<Typography variant="pi" fontWeight="bold" textColor="danger600">
64-
*
65-
</Typography>
66-
)}
67-
</Box>
68-
<Editor name={name} onChange={onChange} value={value} />
69-
{error && (
70-
<Typography variant="pi" textColor="danger600">
71-
{formatMessage({ id: error, defaultMessage: error })}
72-
</Typography>
73-
)}
74-
{description && (
75-
<Typography variant="pi">{formatMessage(description)}</Typography>
76-
)}
77-
78-
</Wrapper>
79-
);
80-
}}
81-
</Error>
82-
);
83-
}
84-
}
25+
return (
26+
<Wrapper size={1} className={`${cn(!isEmpty(className) && className)}`} style={style}>
27+
<Box>
28+
<Typography variant="pi" fontWeight="bold">
29+
{formatMessage(intlLabel)}
30+
</Typography>
31+
{required && (
32+
<Typography variant="pi" fontWeight="bold" textColor="danger600">
33+
*
34+
</Typography>
35+
)}
36+
</Box>
37+
<Editor onChange={onChange} value={value} name={name} disabled={disabled} />
38+
{error && (
39+
<Typography variant="pi" textColor="danger600">
40+
{formatMessage({ id: error, defaultMessage: error })}
41+
</Typography>
42+
)}
43+
{description && (
44+
<Typography variant="pi">{formatMessage(description)}</Typography>
45+
)}
46+
47+
</Wrapper>
48+
)
49+
};
8550

86-
WysiwygWithErrors.defaultProps = {
87-
autoFocus: false,
51+
Wysiwyg.defaultProps = {
8852
className: "",
89-
deactivateErrorHighlight: false,
90-
didCheckErrors: false,
91-
disabled: false,
92-
error: null,
93-
inputClassName: "",
94-
inputDescription: "",
95-
inputStyle: {},
96-
label: "",
97-
labelIcon: null,
98-
onBlur: false,
99-
placeholder: "",
100-
resetProps: false,
10153
style: {},
10254
tabIndex: "0",
103-
validations: {},
10455
value: null,
56+
description: '',
57+
disabled: false,
58+
error: undefined,
59+
intlLabel: '',
60+
required: false,
61+
value: '',
10562
};
10663

107-
WysiwygWithErrors.propTypes = {
108-
autoFocus: PropTypes.bool,
64+
Wysiwyg.propTypes = {
10965
className: PropTypes.string,
110-
deactivateErrorHighlight: PropTypes.bool,
111-
didCheckErrors: PropTypes.bool,
66+
style: PropTypes.object,
67+
tabIndex: PropTypes.string,
68+
description: PropTypes.shape({
69+
id: PropTypes.string,
70+
defaultMessage: PropTypes.string,
71+
}),
11272
disabled: PropTypes.bool,
11373
error: PropTypes.string,
114-
inputClassName: PropTypes.string,
115-
inputDescription: PropTypes.oneOfType([
116-
PropTypes.string,
117-
PropTypes.func,
118-
PropTypes.shape({
119-
id: PropTypes.string,
120-
params: PropTypes.object,
121-
}),
122-
]),
123-
inputStyle: PropTypes.object,
124-
label: PropTypes.oneOfType([
125-
PropTypes.string,
126-
PropTypes.func,
127-
PropTypes.shape({
128-
id: PropTypes.string,
129-
params: PropTypes.object,
130-
}),
131-
]),
132-
labelIcon: PropTypes.shape({
133-
icon: PropTypes.node.isRequired,
134-
title: PropTypes.string,
74+
intlLabel: PropTypes.shape({
75+
id: PropTypes.string,
76+
defaultMessage: PropTypes.string,
13577
}),
78+
required: PropTypes.bool,
79+
value: PropTypes.string,
13680
name: PropTypes.string.isRequired,
137-
onBlur: PropTypes.oneOfType([PropTypes.bool, PropTypes.func]),
13881
onChange: PropTypes.func.isRequired,
139-
placeholder: PropTypes.string,
140-
resetProps: PropTypes.bool,
141-
style: PropTypes.object,
142-
tabIndex: PropTypes.string,
143-
validations: PropTypes.object,
144-
value: PropTypes.string,
14582
};
14683

147-
export default WysiwygWithErrors;
84+
export default Wysiwyg;

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
"kind": "plugin"
1313
},
1414
"dependencies": {
15-
"@buffetjs/core": "^3.3.8",
1615
"@editorjs/checklist": "1.3.0",
1716
"@editorjs/code": "2.7.0",
1817
"@editorjs/delimiter": "1.2.0",
@@ -29,6 +28,7 @@
2928
"@editorjs/raw": "2.3.0",
3029
"@editorjs/table": "2.0.1",
3130
"@editorjs/warning": "1.2.0",
31+
"classnames": "^2.3.1",
3232
"get-file-object-from-local-path": "1.0.2",
3333
"open-graph-scraper": "4.9.2",
3434
"react-editor-js": "1.10.0"

0 commit comments

Comments
 (0)