@@ -2,7 +2,7 @@ import './TextCard.scss'
22
33import { EditorContent } from '@tiptap/react'
44import clsx from 'clsx'
5- import React , { useEffect } from 'react'
5+ import React , { memo , useEffect , useMemo } from 'react'
66
77import 'lib/components/MarkdownEditor/RichMarkdownEditor.scss'
88import { Resizeable } from 'lib/components/Cards/CardMeta'
@@ -36,10 +36,12 @@ interface TextCardBodyProps extends Pick<React.HTMLAttributes<HTMLDivElement>, '
3636 closeDetails ?: ( ) => void
3737}
3838
39- export function TextContent ( { text, closeDetails, className } : TextCardBodyProps ) : JSX . Element {
39+ function TextContentImpl ( { text, closeDetails, className } : TextCardBodyProps ) : JSX . Element {
40+ const initialDoc = useMemo ( ( ) => markdownToTextCardDoc ( text ) , [ text ] )
41+
4042 const editor = useRichContentEditor ( {
4143 extensions : TEXT_CARD_MARKDOWN_READONLY_EXTENSIONS ,
42- initialContent : markdownToTextCardDoc ( text ) ,
44+ initialContent : initialDoc ,
4345 disabled : true ,
4446 } )
4547
@@ -48,8 +50,8 @@ export function TextContent({ text, closeDetails, className }: TextCardBodyProps
4850 return
4951 }
5052
51- editor . commands . setContent ( markdownToTextCardDoc ( text ) , { emitUpdate : false } )
52- } , [ editor , text ] )
53+ editor . commands . setContent ( initialDoc , { emitUpdate : false } )
54+ } , [ editor , initialDoc ] )
5355
5456 return (
5557 < div className = { clsx ( 'w-full' , className ) } onClick = { ( ) => closeDetails ?.( ) } >
@@ -64,6 +66,9 @@ export function TextContent({ text, closeDetails, className }: TextCardBodyProps
6466 )
6567}
6668
69+ export const TextContent = memo ( TextContentImpl )
70+ TextContent . displayName = 'TextContent'
71+
6772function TextCardInternal (
6873 {
6974 textTile,
0 commit comments