@@ -18,17 +18,24 @@ import { FormElement } from '@/ui/FormElement';
1818import { Inline } from '@/ui/Inline' ;
1919import { Input } from '@/ui/Input' ;
2020import { Page } from '@/ui/Page' ;
21+ import { Panel } from '@/ui/Panel' ;
2122import { Stack } from '@/ui/Stack' ;
2223import { Text } from '@/ui/Text' ;
2324import { getGlobalBorderRadius , getValueFromTheme } from '@/ui/theme' ;
2425import { Title } from '@/ui/Title' ;
2526import { Toast } from '@/ui/Toast' ;
2627
28+ import {
29+ DescriptionPreview ,
30+ dompurifySanitizeEventDescription ,
31+ } from './events/[eventId]/preview/DescriptionPreview' ;
32+
2733const htmlToDraft =
2834 typeof window === 'object' && require ( 'html-to-draftjs' ) . default ;
2935
3036const languageOptions = [ ...Object . values ( SupportedLanguages ) , 'en' ] ;
3137const getGlobalValue = getValueFromTheme ( 'global' ) ;
38+ const getTextValue = getValueFromTheme ( 'text' ) ;
3239
3340const TranslateForm = ( ) => {
3441 const { t } = useTranslation ( ) ;
@@ -88,7 +95,9 @@ const TranslateForm = () => {
8895 const newEditorStates : Record < string , EditorState > = { } ;
8996
9097 languageOptions . forEach ( ( langValue ) => {
91- const description = offer . description ?. [ langValue ] ;
98+ const description = dompurifySanitizeEventDescription (
99+ offer . description ?. [ langValue ] ,
100+ ) ;
92101
93102 if ( description ) {
94103 const draftState = htmlToDraft ( description ) ;
@@ -316,21 +325,30 @@ const TranslateForm = () => {
316325 </ Text >
317326 { originalLanguage === language &&
318327 ! isEditingOriginalDescription ? (
319- < Inline >
320- < Text variant = "muted" >
321- { descriptionEditorStates [ language ]
322- ? descriptionEditorStates [ language ]
323- . getCurrentContent ( )
324- . getPlainText ( )
325- : '' }
326- </ Text >
328+ < Stack spacing = { 3 } >
329+ < Panel padding = { 3 } color = { getTextValue ( 'muted.color' ) } >
330+ < DescriptionPreview
331+ description = {
332+ descriptionEditorStates [ language ]
333+ ? draftToHtml (
334+ convertToRaw (
335+ descriptionEditorStates [
336+ language
337+ ] . getCurrentContent ( ) ,
338+ ) ,
339+ )
340+ : ''
341+ }
342+ />
343+ </ Panel >
344+
327345 < Button
328346 variant = { ButtonVariants . LINK }
329347 onClick = { toggleEditOriginalDescription }
330348 >
331349 { t ( 'translate.change' ) }
332350 </ Button >
333- </ Inline >
351+ </ Stack >
334352 ) : (
335353 < div id = { `description-editor-container-${ language } ` } >
336354 < FormElement
0 commit comments