@@ -447,6 +447,9 @@ export const useCommentsStore = defineStore('comments', () => {
447447 if ( __IS_DEBUG__ ) console . debug ( '[processLoadedDocxComments] processing comments...' , comments ) ;
448448
449449 comments . forEach ( ( comment ) => {
450+ const htmlContent = getHTmlFromComment ( comment . textJson ) ;
451+ if ( ! htmlContent ) return ;
452+
450453 const importedName = `${ comment . creatorName . replace ( '(imported)' , '' ) } (imported)`
451454 const newComment = useComment ( {
452455 fileId : documentId ,
@@ -522,14 +525,22 @@ export const useCommentsStore = defineStore('comments', () => {
522525 * @returns {string } The HTML content
523526 */
524527 const getHTmlFromComment = ( commentTextJson ) => {
525- const editor = new Editor ( {
526- mode : 'text' ,
527- isHeadless : true ,
528- content : commentTextJson ,
529- loadFromSchema : true ,
530- extensions : getRichTextExtensions ( ) ,
531- } ) ;
532- return editor . getHTML ( ) ;
528+ // If no content, we can't convert and its not a valid comment
529+ if ( ! commentTextJson . content ?. length ) return ;
530+
531+ try {
532+ const editor = new Editor ( {
533+ mode : 'text' ,
534+ isHeadless : true ,
535+ content : commentTextJson ,
536+ loadFromSchema : true ,
537+ extensions : getRichTextExtensions ( ) ,
538+ } ) ;
539+ return editor . getHTML ( ) ;
540+ } catch ( error ) {
541+ console . warn ( 'Failed to convert comment' , error ) ;
542+ return ;
543+ } ;
533544 } ;
534545
535546 return {
0 commit comments