@@ -18,7 +18,7 @@ import { SettingTile } from '../../../components/setting-tile';
1818import * as css from './BioEditor.css' ;
1919
2020type BioEditorProps = {
21- value ?: string ;
21+ value ?: string | any ;
2222 isSaving ?: boolean ;
2323 imagePackRooms ?: any [ ] ;
2424 onSave : ( htmlContent : string ) => void ;
@@ -67,15 +67,23 @@ export function BioEditor({ value, isSaving, imagePackRooms, onSave }: BioEditor
6767
6868 if ( valueChanged || isFirstValidLoad ) {
6969 prevValue . current = value ;
70- const incomingPlainText = value ? toPlainText ( htmlToEditorInput ( value , isMarkdown ) , isMarkdown ) . trim ( ) : '' ;
70+
71+ let normalizedValue = value ;
72+ if ( typeof normalizedValue === 'object' && normalizedValue !== null && 'formatted_body' in normalizedValue ) {
73+ normalizedValue = normalizedValue . formatted_body ;
74+ }
75+
76+ const safeValue = typeof normalizedValue === 'string' ? normalizedValue : '' ;
77+
78+ const incomingPlainText = toPlainText ( htmlToEditorInput ( safeValue , isMarkdown ) , isMarkdown ) . trim ( ) ;
7179 const currentPlainText = toPlainText ( editor . children , isMarkdown ) . trim ( ) ;
7280
7381 if ( currentPlainText === incomingPlainText && initialized . current ) return ;
7482
75- const isLikelyHtml = value ? .includes ( '<' ) || value ? .includes ( '>' ) ;
83+ const isLikelyHtml = safeValue . includes ( '<' ) || safeValue . includes ( '>' ) ;
7684 const initialValue = isLikelyHtml
77- ? htmlToEditorInput ( value ! , isMarkdown )
78- : plainToEditorInput ( value ?? '' , isMarkdown ) ;
85+ ? htmlToEditorInput ( safeValue , isMarkdown )
86+ : plainToEditorInput ( safeValue , isMarkdown ) ;
7987
8088 editor . children = initialValue ;
8189 Editor . normalize ( editor , { force : true } ) ;
0 commit comments