@@ -32,10 +32,6 @@ function NoteNode({
3232 ( key ) => key === data . node ?. template . backgroundColor ,
3333 ) ?? Object . keys ( COLOR_OPTIONS ) [ 0 ] ;
3434 const nodeDiv = useRef < HTMLDivElement > ( null ) ;
35- const [ size , setSize ] = useState ( {
36- width : DEFAULT_WIDTH - NOTE_NODE_PADDING ,
37- height : DEFAULT_HEIGHT - NOTE_NODE_PADDING ,
38- } ) ;
3935 const [ resizedNote , setResizedNote ] = useState ( false ) ;
4036 const currentFlow = useFlowStore ( ( state ) => state . currentFlow ) ;
4137 const setNode = useFlowStore ( ( state ) => state . setNode ) ;
@@ -47,12 +43,12 @@ function NoteNode({
4743 ) ;
4844
4945 const nodeDataWidth = useMemo (
50- ( ) => nodeData ?. width ?? DEFAULT_WIDTH ,
51- [ nodeData ?. width ] ,
46+ ( ) => nodeData ?. measured ?. width ?? DEFAULT_WIDTH ,
47+ [ nodeData ?. measured ?. width ] ,
5248 ) ;
5349 const nodeDataHeight = useMemo (
54- ( ) => nodeData ?. height ?? DEFAULT_HEIGHT ,
55- [ nodeData ?. height ] ,
50+ ( ) => nodeData ?. measured ?. height ?? DEFAULT_HEIGHT ,
51+ [ nodeData ?. measured ?. height ] ,
5652 ) ;
5753
5854 const dataId = useMemo ( ( ) => data . id , [ data . id ] ) ;
@@ -64,10 +60,6 @@ function NoteNode({
6460 const debouncedResize = useMemo (
6561 ( ) =>
6662 debounce ( ( width : number , height : number ) => {
67- setSize ( {
68- width : width - NOTE_NODE_PADDING ,
69- height : height - NOTE_NODE_PADDING ,
70- } ) ;
7163 setNode ( data . id , ( node ) => {
7264 return {
7365 ...node ,
@@ -79,22 +71,6 @@ function NoteNode({
7971 [ ] ,
8072 ) ;
8173
82- useEffect ( ( ) => {
83- if ( nodeData && ! resizedNote && nodeDataWidth > 0 && nodeDataHeight > 0 ) {
84- setSize ( {
85- width : nodeDataWidth - NOTE_NODE_PADDING ,
86- height : nodeDataHeight - NOTE_NODE_PADDING ,
87- } ) ;
88- } else if ( ! nodeData && nodeDiv . current ) {
89- const currentWidth = nodeDiv . current . offsetWidth || DEFAULT_WIDTH ;
90- const currentHeight = nodeDiv . current . offsetHeight || DEFAULT_HEIGHT ;
91- setSize ( {
92- width : Math . max ( currentWidth , DEFAULT_WIDTH ) - NOTE_NODE_PADDING ,
93- height : Math . max ( currentHeight , DEFAULT_HEIGHT ) - NOTE_NODE_PADDING ,
94- } ) ;
95- }
96- } , [ nodeData , nodeDataWidth , nodeDataHeight , resizedNote ] ) ;
97-
9874 const [ editNameDescription , set ] = useAlternate ( false ) ;
9975
10076 const MemoNoteToolbarComponent = useMemo (
@@ -108,6 +84,8 @@ function NoteNode({
10884 ) ,
10985 [ data , bgColor , selected ] ,
11086 ) ;
87+ console . log ( nodeData ) ;
88+ console . log ( ) ;
11189 return (
11290 < >
11391 < NodeResizer
@@ -133,8 +111,8 @@ function NoteNode({
133111 < div
134112 data-testid = "note_node"
135113 style = { {
136- minWidth : Math . max ( DEFAULT_WIDTH , NOTE_NODE_MIN_WIDTH ) ,
137- minHeight : Math . max ( DEFAULT_HEIGHT , NOTE_NODE_MIN_HEIGHT ) ,
114+ minWidth : nodeDataWidth ,
115+ minHeight : nodeDataHeight ,
138116 backgroundColor : COLOR_OPTIONS [ bgColor ] ?? "#00000000" ,
139117 } }
140118 ref = { nodeDiv }
@@ -161,7 +139,7 @@ function NoteNode({
161139 >
162140 < NodeDescription
163141 inputClassName = { cn (
164- "border-0 ring-0 focus:ring-0 resize-none shadow-none rounded-sm h-full w-full" ,
142+ "border-0 ring-0 focus:ring-0 resize-none shadow-none rounded-sm h-full min- w-full" ,
165143 COLOR_OPTIONS [ bgColor ] === null
166144 ? ""
167145 : "dark:!ring-background dark:text-background" ,
@@ -178,9 +156,10 @@ function NoteNode({
178156 selected = { selected }
179157 description = { dataDescription }
180158 emptyPlaceholder = "Double-click to start typing or enter Markdown..."
181- placeholderClassName = {
182- COLOR_OPTIONS [ bgColor ] === null ? "" : "dark:!text-background"
183- }
159+ placeholderClassName = { cn (
160+ COLOR_OPTIONS [ bgColor ] === null ? "" : "dark:!text-background" ,
161+ "px-2" ,
162+ ) }
184163 editNameDescription = { editNameDescription }
185164 setEditNameDescription = { set }
186165 stickyNote
0 commit comments