File tree Expand file tree Collapse file tree
packages/ui/components/editor Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -7,7 +7,7 @@ import type { TextEditorProps } from "./types";
77
88describe ( "Editor" , ( ) => {
99 const defaultProps : TextEditorProps = {
10- getText : vi . fn ( ( ) => "" ) ,
10+ getText : vi . fn ( ) ,
1111 setText : vi . fn ( ) ,
1212 variables : [ "name" , "email" ] ,
1313 height : "200px" ,
Original file line number Diff line number Diff line change @@ -220,7 +220,6 @@ function getSelectedNode(selection: RangeSelection) {
220220}
221221
222222export default function ToolbarPlugin ( props : TextEditorProps ) {
223- const isInitialized = useRef ( false ) ;
224223 const [ editor ] = useLexicalComposerContext ( ) ;
225224 const toolbarRef = useRef ( null ) ;
226225 const [ blockType , setBlockType ] = useState ( "paragraph" ) ;
@@ -365,13 +364,11 @@ export default function ToolbarPlugin(props: TextEditorProps) {
365364 } , [ props . updateTemplate ] ) ;
366365
367366 useEffect ( ( ) => {
368- if ( props . setFirstRender && ! isInitialized . current ) {
369- isInitialized . current = true ;
367+ if ( props . setFirstRender ) {
370368 props . setFirstRender ( false ) ;
371369 editor . update ( ( ) => {
372370 const parser = new DOMParser ( ) ;
373- const content = props . getText ( ) ?. replace ( / \n / g, "<br>" ) ;
374- const dom = parser . parseFromString ( content , "text/html" ) ;
371+ const dom = parser . parseFromString ( props . getText ( ) , "text/html" ) ;
375372
376373 const nodes = $generateNodesFromDOM ( editor , dom ) ;
377374
You can’t perform that action at this time.
0 commit comments