@@ -39,22 +39,26 @@ import { EmojiBoard } from '$components/emoji-board';
3939import { mobileOrTablet } from '$utils/user-agent' ;
4040import * as css from './UploadDescriptionEditor.css' ;
4141
42- type BioEditorProps = {
42+ type DescriptionEditorProps = {
4343 value ?: string | any ;
4444 isSaving ?: boolean ;
4545 imagePackRooms ?: any [ ] ;
46- onSave : ( htmlContent : string ) => void ;
46+ onSave : ( plaintext : string , htmlContent : string ) => void ;
4747} ;
4848
49- export function DescriptionEditor ( { value, isSaving, imagePackRooms, onSave } : BioEditorProps ) {
49+ export function DescriptionEditor ( {
50+ value,
51+ isSaving,
52+ imagePackRooms,
53+ onSave,
54+ } : DescriptionEditorProps ) {
5055 const editor = useEditor ( ) ;
5156 const [ enterForNewline ] = useSetting ( settingsAtom , 'enterForNewline' ) ;
5257 const [ isMarkdown ] = useSetting ( settingsAtom , 'isMarkdown' ) ;
5358 const [ toolbar , setToolbar ] = useState ( false ) ;
5459
5560 const [ autocompleteQuery , setAutocompleteQuery ] =
5661 useState < AutocompleteQuery < AutocompletePrefix > > ( ) ;
57- const [ hasChanged , setHasChanged ] = useState ( false ) ;
5862
5963 const prevValue = useRef ( value ) ;
6064 const initialized = useRef ( false ) ;
@@ -69,8 +73,7 @@ export function DescriptionEditor({ value, isSaving, imagePackRooms, onSave }: B
6973 } )
7074 ) ;
7175
72- onSave ( customHtml || plainText ) ;
73- setHasChanged ( false ) ;
76+ onSave ( plainText , customHtml || plainText ) ;
7477 } , [ editor , isMarkdown , onSave ] ) ;
7578
7679 useEffect ( ( ) => {
@@ -109,7 +112,6 @@ export function DescriptionEditor({ value, isSaving, imagePackRooms, onSave }: B
109112 Transforms . select ( editor , Editor . start ( editor , [ ] ) ) ;
110113
111114 initialized . current = true ;
112- setHasChanged ( false ) ;
113115 }
114116 } , [ value , editor , isMarkdown ] ) ;
115117
@@ -146,12 +148,15 @@ export function DescriptionEditor({ value, isSaving, imagePackRooms, onSave }: B
146148 const handleEmoticonSelect = ( key : string , shortcode : string ) => {
147149 editor . insertNode ( createEmoticonElement ( key , shortcode ) ) ;
148150 moveCursor ( editor ) ;
149- setHasChanged ( true ) ;
150151 } ;
151152
152153 return (
153154 < Box direction = "Column" gap = "100" >
154- < Box className = { css . BioEditorContainer } direction = "Column" style = { { position : 'relative' } } >
155+ < Box
156+ className = { css . DescriptionEditorContainer }
157+ direction = "Column"
158+ style = { { position : 'relative' } }
159+ >
155160 { autocompleteQuery ?. prefix === AutocompletePrefix . Emoticon && (
156161 < EmoticonAutocomplete
157162 imagePackRooms = { imagePackRooms || [ ] }
@@ -176,19 +181,17 @@ export function DescriptionEditor({ value, isSaving, imagePackRooms, onSave }: B
176181 gap = "100"
177182 >
178183 < Box gap = "200" alignItems = "Center" >
179- { hasChanged && (
180- < Chip
181- onClick = { handleSave }
182- variant = "Primary"
183- radii = "Pill"
184- outlined
185- before = {
186- isSaving ? < Spinner variant = "Primary" fill = "Soft" size = "100" /> : undefined
187- }
188- >
189- < Text size = "B300" > { isSaving ? 'Saving' : 'Save' } </ Text >
190- </ Chip >
191- ) }
184+ < Chip
185+ onClick = { handleSave }
186+ variant = "Primary"
187+ radii = "Pill"
188+ outlined
189+ before = {
190+ isSaving ? < Spinner variant = "Primary" fill = "Soft" size = "100" /> : undefined
191+ }
192+ >
193+ < Text size = "B300" > { isSaving ? 'Saving' : 'Save' } </ Text >
194+ </ Chip >
192195 </ Box >
193196 < Box gap = "Inherit" >
194197 < IconButton
0 commit comments