Spaces:
Running
Running
Commit ·
9bcc2ab
1
Parent(s): 6e7bb10
Fix performance: Debounce node resizing updates and resolve drawing node spawning conflict
Browse filesFiles changed (3)
6 unmodified lines78910111213141516171819203 unmodified lines2425262728296 unmodified linesconst { t } = useTranslation();const imageUrl = data.url || '';return (<divclassName={`relative group transition-all ${selected ? 'ring-2 ring-primary/40 shadow-xl' : ''}`}style={{width: data.width || 300,height: data.height || 'auto',minWidth: 50,minHeight: 50,}}3 unmodified linesminWidth={50}minHeight={50}onResize={(e, params) => {if (data.updateNodeData) {data.updateNodeData(id, { width: params.width, height: params.height });}6 unmodified lines7891011121314151617181920212223242526272829303132333435363 unmodified lines4041424344454647486 unmodified linesconst { t } = useTranslation();const imageUrl = data.url || '';// Local state for smooth resizing without lagconst [localSize, setLocalSize] = useState({width: data.width || 300,height: data.height || 'auto'});useEffect(() => {// Sync if data changes from remote, but only if not being actively manipulatedif (!selected) {setLocalSize({width: data.width || 300,height: data.height || 'auto'});}}, [data.width, data.height, selected]);return (<divclassName={`relative group transition-all ${selected ? 'ring-2 ring-primary/40 shadow-xl' : ''}`}style={{width: localSize.width,height: localSize.height,minWidth: 50,minHeight: 50,}}3 unmodified linesminWidth={50}minHeight={50}onResize={(e, params) => {setLocalSize({ width: params.width, height: params.height });}}onResizeEnd={(e, params) => {if (data.updateNodeData) {data.updateNodeData(id, { width: params.width, height: params.height });}
6 unmodified lines7891011122 unmodified lines1516171819202122232425262712 unmodified lines404142434445461 unmodified line4849505152536 unmodified linesconst { t } = useTranslation();const { isDarkMode } = useTheme();const [localText, setLocalText] = useState(data.label || '');const textareaRef = useRef(null);// Auto-resize textarea height2 unmodified linestextareaRef.current.style.height = 'auto';textareaRef.current.style.height = textareaRef.current.scrollHeight + 'px';}}, [localText]);useEffect(() => {if (document.activeElement !== textareaRef.current) {setLocalText(data.label || '');}}, [data.label]);const handleTextChange = (e) => {const newText = e.target.value;12 unmodified linesselected ? 'ring-2 ring-primary/20 rounded-md' : ''}`}style={{width: data.width || 250,minWidth: 50,}}>1 unmodified lineisVisible={selected}minWidth={50}onResize={(e, params) => {if (data.updateNodeData) {data.updateNodeData(id, { width: params.width });}6 unmodified lines789101112132 unmodified lines161718192021222324252627282930313212 unmodified lines454647484950511 unmodified line5354555657585960616 unmodified linesconst { t } = useTranslation();const { isDarkMode } = useTheme();const [localText, setLocalText] = useState(data.label || '');const [localWidth, setLocalWidth] = useState(data.width || 250);const textareaRef = useRef(null);// Auto-resize textarea height2 unmodified linestextareaRef.current.style.height = 'auto';textareaRef.current.style.height = textareaRef.current.scrollHeight + 'px';}}, [localText, localWidth]);useEffect(() => {if (document.activeElement !== textareaRef.current) {setLocalText(data.label || '');}// Only update local width from data if we aren't currently dragging itif (!selected) {setLocalWidth(data.width || 250);}}, [data.label, data.width, selected]);const handleTextChange = (e) => {const newText = e.target.value;12 unmodified linesselected ? 'ring-2 ring-primary/20 rounded-md' : ''}`}style={{width: localWidth,minWidth: 50,}}>1 unmodified lineisVisible={selected}minWidth={50}onResize={(e, params) => {setLocalWidth(params.width);}}onResizeEnd={(e, params) => {if (data.updateNodeData) {data.updateNodeData(id, { width: params.width });}
1879 unmodified lines18801881188218831884188518861879 unmodified lines<divref={reactFlowWrapper}className="flex-grow graph-paper-bg relative"onMouseDown={handleMouseDown}onPointerDown={onPointerDown}onPointerMove={onPointerMove}onPointerUp={onPointerUp}1879 unmodified lines18801881188218831884188518861879 unmodified lines<divref={reactFlowWrapper}className="flex-grow graph-paper-bg relative"onMouseDown={drawingMode ? undefined : handleMouseDown}onPointerDown={onPointerDown}onPointerMove={onPointerMove}onPointerUp={onPointerUp}
src/features/canvas/components/nodes/ImageNode.jsx+21-2
src/features/canvas/components/nodes/TextNode.jsx+11-3
src/pages/CanvasPage.jsx+1-1