@@ -31,33 +31,47 @@ import InfoIcon from "svgs/icons/info-circle.svg";
3131const Container = styled . div < { isEmpty : boolean } > `
3232 width: 100%;
3333
34- [class*="mdxeditor"] {
35- background-color: ${ ( { theme } ) => theme . whiteBackground } !important ;
34+ [class*="mdxeditor-toolbar "] {
35+ background-color: ${ ( { theme } ) => theme . lightGrey } ;
3636 border: 1px solid ${ ( { theme } ) => theme . stroke } !important;
3737 border-radius: 3px;
3838 font-family: "Open Sans", sans-serif;
39- }
4039
41- [class*="toolbar"] {
42- background- color: ${ ( { theme } ) => theme . lightGrey } !important;
43- border-bottom: none !important;
40+ * svg {
41+ color: ${ ( { theme } ) => theme . primaryText } !important;
42+ }
4443
45- button {
46- color: ${ ( { theme } ) => theme . whiteBackground } !important;
44+ [class*="selectTrigger"] {
45+ background-color: ${ ( { theme } ) => theme . whiteBackground } !important;
46+ color: ${ ( { theme } ) => theme . primaryText } !important;
47+ cursor: pointer !important;
4748 }
4849
49- svg {
50- fill: ${ ( { theme } ) => theme . whiteBackground } !important;
50+ button:hover {
51+ background-color: ${ ( { theme } ) => theme . lightGrey } 80 !important;
52+ cursor: pointer;
5153 }
5254
53- select {
55+ button[data-state="on"],
56+ button[aria-pressed="true"] {
5457 background-color: ${ ( { theme } ) => theme . whiteBackground } !important;
55- color: ${ ( { theme } ) => theme . primaryText } !important;
58+ }
59+
60+ button:disabled,
61+ button[data-disabled="true"] {
62+ opacity: 0.4 !important;
63+ cursor: not-allowed !important;
64+
65+ svg {
66+ color: ${ ( { theme } ) => theme . secondaryText } !important;
67+ }
5668 }
5769 }
5870
5971 [class*="contentEditable"] {
6072 background-color: ${ ( { theme } ) => theme . whiteBackground } !important;
73+ border: 1px solid ${ ( { theme } ) => theme . stroke } !important;
74+ border-radius: 3px;
6175 color: ${ ( { theme } ) => theme . primaryText } !important;
6276 min-height: 200px;
6377 padding: 16px;
@@ -165,7 +179,19 @@ const MarkdownEditor: React.FC<IMarkdownEditor> = ({
165179 const editorRef = useRef < MDXEditorMethods > ( null ) ;
166180
167181 const handleChange = ( markdown : string ) => {
168- onChange ( markdown ) ;
182+ const cleanedMarkdown = markdown === "\u200B" ? "" : markdown . replace ( / ^ \u200B / , "" ) ;
183+ onChange ( cleanedMarkdown ) ;
184+ } ;
185+
186+ const handleContainerClick = ( ) => {
187+ if ( isEmpty && editorRef . current ) {
188+ editorRef . current . setMarkdown ( "\u200B" ) ;
189+ setTimeout ( ( ) => {
190+ if ( editorRef . current ) {
191+ editorRef . current . focus ( ) ;
192+ }
193+ } , 0 ) ;
194+ }
169195 } ;
170196
171197 const isEmpty = ! value || value . trim ( ) === "" ;
@@ -204,7 +230,7 @@ const MarkdownEditor: React.FC<IMarkdownEditor> = ({
204230 } ;
205231
206232 return (
207- < Container isEmpty = { isEmpty } >
233+ < Container isEmpty = { isEmpty } onClick = { handleContainerClick } >
208234 < MDXEditor ref = { editorRef } { ...editorProps } />
209235 { showMessage && (
210236 < MessageContainer >
0 commit comments