From f4b3104a1b979d453d5653cca38f40b245419965 Mon Sep 17 00:00:00 2001 From: dvirlabs Date: Tue, 24 Mar 2026 12:51:44 +0200 Subject: [PATCH] Add missing TextNode component --- frontend/src/components/TextNode.jsx | 78 ++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 frontend/src/components/TextNode.jsx diff --git a/frontend/src/components/TextNode.jsx b/frontend/src/components/TextNode.jsx new file mode 100644 index 0000000..44c086e --- /dev/null +++ b/frontend/src/components/TextNode.jsx @@ -0,0 +1,78 @@ +import { useRef, useEffect } from 'react'; +import { Handle, Position } from 'reactflow'; +import ReactQuill from 'react-quill-new'; +import 'react-quill-new/dist/quill.snow.css'; +import '../styles/quill-dark.css'; + +function TextNode({ data }) { + const quillRef = useRef(null); + + useEffect(() => { + const editor = quillRef.current?.getEditor?.(); + const editorRoot = editor?.root; + + if (editorRoot) { + const stopKey = (e) => { + // fix for spacebar and prevent ReactFlow stealing key + if (e.key === ' ' || e.key === 'ArrowLeft' || e.key === 'ArrowRight') { + e.stopPropagation(); + } + }; + editorRoot.addEventListener('keydown', stopKey); + return () => { + editorRoot.removeEventListener('keydown', stopKey); + }; + } + }, [data.editing]); // reapply listener only when editing mode is toggled + + return ( +
+ + + {data.editing ? ( +
e.stopPropagation()} + onMouseDown={(e) => e.stopPropagation()} + onClick={(e) => e.stopPropagation()} + onDoubleClick={(e) => e.stopPropagation()} + > + + +
+ ) : ( +
Double-click to edit...', + }} + /> + )} + + +
+ ); +} + +export default TextNode;