File tree Expand file tree Collapse file tree 1 file changed +10
-2
lines changed
src/components/EditorCanvas Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Original file line number Diff line number Diff line change 1- import { useMemo , useState , useRef } from "react" ;
1+ import { useMemo , useState , useRef , useEffect } from "react" ;
22import { Action , ObjectType , Tab , State } from "../../data/constants" ;
33import { Input , Button , Popover } from "@douyinfe/semi-ui" ;
44import ColorPicker from "../EditorSidePanel/ColorPicker" ;
@@ -179,6 +179,14 @@ export default function Note({ data, onPointerDown }) {
179179 const width = data . width ?? noteWidth ;
180180 const MIN_NOTE_WIDTH = 120 ;
181181
182+ useEffect ( ( ) => {
183+ const textarea = document . getElementById ( `note_${ data . id } ` ) ;
184+ textarea . style . height = "0" ;
185+ textarea . style . height = textarea . scrollHeight + "px" ;
186+ const newHeight = textarea . scrollHeight + 42 ;
187+ updateNote ( data . id , { height : newHeight } ) ;
188+ } ) ;
189+
182190 return (
183191 < g
184192 onPointerEnter = { ( e ) => e . isPrimary && setHovered ( true ) }
@@ -506,4 +514,4 @@ export default function Note({ data, onPointerDown }) {
506514 </ foreignObject >
507515 </ g >
508516 ) ;
509- }
517+ }
You can’t perform that action at this time.
0 commit comments