import { useReactFlow } from "@xyflow/react"; import { useState } from "react"; import Markdown from "react-markdown"; import type { UpdateOptions } from "./NodeParameter"; export default function NodeWithComment(props: any) { const reactFlow = useReactFlow(); const [editing, setEditing] = useState(false); function setComment(newValue: string, opts?: UpdateOptions) { reactFlow.updateNodeData(props.id, (prevData: any) => ({ ...prevData, params: { text: newValue }, __execution_delay: opts?.delay || 0, })); } function onClick(e: React.MouseEvent) { // Start editing on double-click. if (e.detail === 2) { setEditing(true); } } function finishEditing(el: HTMLTextAreaElement) { setComment(el.value); setEditing(false); } function onKeyDown(e: React.KeyboardEvent) { if (e.key === "Escape") { finishEditing(e.currentTarget); } } function onInput(el: HTMLTextAreaElement | null) { if (!el) return; el.focus(); // Resize the textarea to the content. el.style.height = "auto"; el.style.height = `${el.scrollHeight}px`; } if (editing) { return (