@@ -24,113 +24,15 @@ import {
2424 Separator ,
2525} from "@mdxeditor/editor" ;
2626
27- import "@mdxeditor/editor/style.css" ;
28-
2927import InfoIcon from "svgs/icons/info-circle.svg" ;
3028
31- const Container = styled . div < { isEmpty : boolean } > `
32- width: 100%;
29+ import { sanitizeMarkdown } from "utils/markdownSanitization" ;
3330
34- [class*="mdxeditor-toolbar"] {
35- background-color: ${ ( { theme } ) => theme . lightGrey } ;
36- border: 1px solid ${ ( { theme } ) => theme . stroke } !important;
37- border-radius: 3px;
38- font-family: "Open Sans", sans-serif;
31+ import { MDXEditorContainer , MDXEditorGlobalStyles } from "styles/mdxEditorTheme" ;
3932
40- * svg {
41- color: ${ ( { theme } ) => theme . primaryText } !important;
42- }
43-
44- [class*="selectTrigger"] {
45- background-color: ${ ( { theme } ) => theme . whiteBackground } !important;
46- color: ${ ( { theme } ) => theme . primaryText } !important;
47- cursor: pointer !important;
48- }
49-
50- button:hover {
51- background-color: ${ ( { theme } ) => theme . lightGrey } 80 !important;
52- cursor: pointer;
53- }
54-
55- button[data-state="on"],
56- button[aria-pressed="true"] {
57- background-color: ${ ( { theme } ) => theme . whiteBackground } !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- }
68- }
69- }
70-
71- [class*="contentEditable"] {
72- background-color: ${ ( { theme } ) => theme . whiteBackground } !important;
73- border: 1px solid ${ ( { theme } ) => theme . stroke } !important;
74- border-radius: 3px;
75- color: ${ ( { theme } ) => theme . primaryText } !important;
76- min-height: 200px;
77- padding: 16px;
78- font-size: 16px;
79- line-height: 1.5;
80-
81- p {
82- color: ${ ( { theme, isEmpty } ) => ( isEmpty ? theme . secondaryText : theme . primaryText ) } !important;
83- margin: 0 0 12px 0;
84- }
85-
86- p:empty::before {
87- color: ${ ( { theme } ) => theme . secondaryText } !important;
88- opacity: 0.6 !important;
89- }
90-
91- h1,
92- h2,
93- h3,
94- h4,
95- h5,
96- h6 {
97- color: ${ ( { theme } ) => theme . primaryText } !important;
98- font-weight: 600;
99- margin: 16px 0 8px 0;
100- }
101-
102- blockquote {
103- color: ${ ( { theme } ) => theme . secondaryText } !important;
104- border-left: 3px solid ${ ( { theme } ) => theme . mediumBlue } !important;
105- font-style: italic;
106- margin: 16px 0;
107- padding-left: 12px;
108- }
109-
110- code {
111- background-color: ${ ( { theme } ) => theme . lightGrey } !important;
112- color: ${ ( { theme } ) => theme . primaryText } !important;
113- }
114-
115- pre {
116- background-color: ${ ( { theme } ) => theme . lightGrey } !important;
117- color: ${ ( { theme } ) => theme . primaryText } !important;
118- }
119-
120- a {
121- color: ${ ( { theme } ) => theme . primaryBlue } !important;
122- }
123-
124- th {
125- background-color: ${ ( { theme } ) => theme . lightGrey } !important;
126- color: ${ ( { theme } ) => theme . primaryText } !important;
127- }
33+ import "@mdxeditor/editor/style.css" ;
12834
129- td {
130- color: ${ ( { theme } ) => theme . primaryText } !important;
131- }
132- }
133- ` ;
35+ const Container = styled ( MDXEditorContainer ) < { isEmpty : boolean } > `` ;
13436
13537const MessageContainer = styled . div `
13638 display: flex;
@@ -180,7 +82,8 @@ const MarkdownEditor: React.FC<IMarkdownEditor> = ({
18082
18183 const handleChange = ( markdown : string ) => {
18284 const cleanedMarkdown = markdown === "\u200B" ? "" : markdown . replace ( / ^ \u200B / , "" ) ;
183- onChange ( cleanedMarkdown ) ;
85+ const sanitizedMarkdown = sanitizeMarkdown ( cleanedMarkdown ) ;
86+ onChange ( sanitizedMarkdown ) ;
18487 } ;
18588
18689 const handleContainerClick = ( ) => {
@@ -230,19 +133,22 @@ const MarkdownEditor: React.FC<IMarkdownEditor> = ({
230133 } ;
231134
232135 return (
233- < Container isEmpty = { isEmpty } onClick = { handleContainerClick } >
234- < MDXEditor ref = { editorRef } { ...editorProps } />
235- { showMessage && (
236- < MessageContainer >
237- < StyledInfoIcon />
238- < MessageText >
239- Please provide a comprehensive justification for your decision. Quality explanations are essential for the
240- parties involved and may be eligible for additional compensation in accordance with our justification
241- policy.
242- </ MessageText >
243- </ MessageContainer >
244- ) }
245- </ Container >
136+ < >
137+ < MDXEditorGlobalStyles />
138+ < Container isEmpty = { isEmpty } onClick = { handleContainerClick } role = "region" aria-label = "Markdown editor" >
139+ < MDXEditor ref = { editorRef } { ...editorProps } aria-label = "Rich text editor for markdown content" />
140+ { showMessage && (
141+ < MessageContainer >
142+ < StyledInfoIcon />
143+ < MessageText >
144+ Please provide a comprehensive justification for your decision. Quality explanations are essential for the
145+ parties involved and may be eligible for additional compensation in accordance with our justification
146+ policy.
147+ </ MessageText >
148+ </ MessageContainer >
149+ ) }
150+ </ Container >
151+ </ >
246152 ) ;
247153} ;
248154
0 commit comments