@@ -2,146 +2,83 @@ import React from "react";
2
2
import PropTypes from "prop-types" ;
3
3
import { isEmpty } from 'lodash' ;
4
4
import Editor from "../editorjs" ;
5
-
6
5
import cn from 'classnames' ;
7
- import { Error } from "@buffetjs/core" ;
8
6
import Wrapper from './wrapper' ;
9
7
import { useIntl } from 'react-intl' ;
10
8
import { Box } from '@strapi/design-system/Box' ;
11
9
import { Typography } from '@strapi/design-system/Typography' ;
12
10
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 ( ) ;
13
24
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
+ } ;
85
50
86
- WysiwygWithErrors . defaultProps = {
87
- autoFocus : false ,
51
+ Wysiwyg . defaultProps = {
88
52
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 ,
101
53
style : { } ,
102
54
tabIndex : "0" ,
103
- validations : { } ,
104
55
value : null ,
56
+ description : '' ,
57
+ disabled : false ,
58
+ error : undefined ,
59
+ intlLabel : '' ,
60
+ required : false ,
61
+ value : '' ,
105
62
} ;
106
63
107
- WysiwygWithErrors . propTypes = {
108
- autoFocus : PropTypes . bool ,
64
+ Wysiwyg . propTypes = {
109
65
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
+ } ) ,
112
72
disabled : PropTypes . bool ,
113
73
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 ,
135
77
} ) ,
78
+ required : PropTypes . bool ,
79
+ value : PropTypes . string ,
136
80
name : PropTypes . string . isRequired ,
137
- onBlur : PropTypes . oneOfType ( [ PropTypes . bool , PropTypes . func ] ) ,
138
81
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 ,
145
82
} ;
146
83
147
- export default WysiwygWithErrors ;
84
+ export default Wysiwyg ;
0 commit comments