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 ( +