@@ -5,7 +5,7 @@ import { commands, ICommand } from "@uiw/react-md-editor";
5
5
import { useIntl } from "react-intl" ;
6
6
import { styled } from "styled-components" ;
7
7
import "@uiw/react-markdown-preview/markdown.css" ;
8
- import { PLUGIN_ID } from ' ../utils/pluginId' ;
8
+ import { PLUGIN_ID } from " ../utils/pluginId" ;
9
9
import MediaLib from "./MediaLib" ;
10
10
import { useField } from "@strapi/strapi/admin" ;
11
11
import assetsToMarkdown from "../utils/assetsToMarkdown" ;
@@ -20,6 +20,13 @@ const Wrapper = styled.div`
20
20
display: none;
21
21
}
22
22
.w-md-editor {
23
+ code[class*="language-"],
24
+ pre[class*="language-"] {
25
+ color: inherit;
26
+ }
27
+ .w-md-editor-text-pre {
28
+ padding: 0;
29
+ }
23
30
border: 1px solid #dcdce4;
24
31
border-radius: 4px;
25
32
box-shadow: none;
@@ -33,8 +40,9 @@ const Wrapper = styled.div`
33
40
img {
34
41
max-width: 100%;
35
42
}
36
- ul,ol{
37
- list-style:inherit;
43
+ ul,
44
+ ol {
45
+ list-style: inherit;
38
46
}
39
47
.w-md-editor-preview {
40
48
display: block;
@@ -100,22 +108,26 @@ const CustomField: FunctionComponent<FieldProps> = ({
100
108
const formatMessage = ( message : { id : string ; defaultMessage : string } ) =>
101
109
message ?. defaultMessage ?? "" ;
102
110
const [ mediaLibVisible , setMediaLibVisible ] = useState ( false ) ;
103
- const [ cursorPosition , setCursorPosition ] = useState < CursorPosition | null > ( null ) ;
111
+ const [ cursorPosition , setCursorPosition ] = useState < CursorPosition | null > (
112
+ null
113
+ ) ;
104
114
105
115
const handleToggleMediaLib = ( ) => setMediaLibVisible ( ( prev ) => ! prev ) ;
106
116
107
- const updateFieldValue = ( value :any ) => {
117
+ const updateFieldValue = ( value : any ) => {
108
118
field . onChange ( { target : { name, value : value } } ) ;
109
- }
119
+ } ;
110
120
111
121
const handleChangeAssets = ( assets : Schema . Attribute . MediaValue < true > ) => {
112
-
113
122
let output ;
114
123
const assetsString = assetsToMarkdown ( assets ) ;
115
124
116
125
if ( cursorPosition ) {
117
- output = field . value . slice ( 0 , cursorPosition . start ) + assetsString + field . value . slice ( cursorPosition . end ) ;
118
- } else {
126
+ output =
127
+ field . value . slice ( 0 , cursorPosition . start ) +
128
+ assetsString +
129
+ field . value . slice ( cursorPosition . end ) ;
130
+ } else {
119
131
output = field . value + assetsString ;
120
132
}
121
133
@@ -144,9 +156,10 @@ const CustomField: FunctionComponent<FieldProps> = ({
144
156
} ,
145
157
} ;
146
158
if ( ! config ?. toolbarCommands ) {
147
- return [ ...commands . getCommands ( ) ,
159
+ return [
160
+ ...commands . getCommands ( ) ,
148
161
commands . divider ,
149
- mediaLibraryButton
162
+ mediaLibraryButton ,
150
163
] as ICommand [ ] ;
151
164
}
152
165
const customCommands = config ?. toolbarCommands
0 commit comments