@@ -5,7 +5,7 @@ import { commands, ICommand } from "@uiw/react-md-editor";
55import { useIntl } from "react-intl" ;
66import { styled } from "styled-components" ;
77import "@uiw/react-markdown-preview/markdown.css" ;
8- import { PLUGIN_ID } from ' ../utils/pluginId' ;
8+ import { PLUGIN_ID } from " ../utils/pluginId" ;
99import MediaLib from "./MediaLib" ;
1010import { useField } from "@strapi/strapi/admin" ;
1111import assetsToMarkdown from "../utils/assetsToMarkdown" ;
@@ -20,6 +20,13 @@ const Wrapper = styled.div`
2020 display: none;
2121 }
2222 .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+ }
2330 border: 1px solid #dcdce4;
2431 border-radius: 4px;
2532 box-shadow: none;
@@ -33,8 +40,9 @@ const Wrapper = styled.div`
3340 img {
3441 max-width: 100%;
3542 }
36- ul,ol{
37- list-style:inherit;
43+ ul,
44+ ol {
45+ list-style: inherit;
3846 }
3947 .w-md-editor-preview {
4048 display: block;
@@ -100,22 +108,26 @@ const CustomField: FunctionComponent<FieldProps> = ({
100108 const formatMessage = ( message : { id : string ; defaultMessage : string } ) =>
101109 message ?. defaultMessage ?? "" ;
102110 const [ mediaLibVisible , setMediaLibVisible ] = useState ( false ) ;
103- const [ cursorPosition , setCursorPosition ] = useState < CursorPosition | null > ( null ) ;
111+ const [ cursorPosition , setCursorPosition ] = useState < CursorPosition | null > (
112+ null
113+ ) ;
104114
105115 const handleToggleMediaLib = ( ) => setMediaLibVisible ( ( prev ) => ! prev ) ;
106116
107- const updateFieldValue = ( value :any ) => {
117+ const updateFieldValue = ( value : any ) => {
108118 field . onChange ( { target : { name, value : value } } ) ;
109- }
119+ } ;
110120
111121 const handleChangeAssets = ( assets : Schema . Attribute . MediaValue < true > ) => {
112-
113122 let output ;
114123 const assetsString = assetsToMarkdown ( assets ) ;
115124
116125 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 {
119131 output = field . value + assetsString ;
120132 }
121133
@@ -144,9 +156,10 @@ const CustomField: FunctionComponent<FieldProps> = ({
144156 } ,
145157 } ;
146158 if ( ! config ?. toolbarCommands ) {
147- return [ ...commands . getCommands ( ) ,
159+ return [
160+ ...commands . getCommands ( ) ,
148161 commands . divider ,
149- mediaLibraryButton
162+ mediaLibraryButton ,
150163 ] as ICommand [ ] ;
151164 }
152165 const customCommands = config ?. toolbarCommands
0 commit comments