import type { NodeProps } from 'reactflow' import type { NoteNodeType } from './types' import { cn } from '@langgenius/dify-ui/cn' import { useClickAway } from 'ahooks' import { memo, useRef } from 'react' import { useTranslation } from 'react-i18next' import { useNodeDataUpdate, useNodesInteractions } from '../hooks' import NodeResizer from '../nodes/_base/components/node-resizer' import { useStore } from '../store/workflow' import { THEME_MAP } from './constants' import { useNote } from './hooks' import { NoteEditor, NoteEditorContextProvider, NoteEditorToolbar } from './note-editor' const Icon = () => { return ( ) } const NoteNode = ({ id, data }: NodeProps) => { const { t } = useTranslation() const controlPromptEditorRerenderKey = useStore((s) => s.controlPromptEditorRerenderKey) const setHistoryShortcutsEnabled = useStore((s) => s.setHistoryShortcutsEnabled) const ref = useRef(null) const theme = data.theme const { handleThemeChange, handleEditorChange, handleShowAuthorChange } = useNote(id) const { handleNodesCopy, handleNodesDuplicate, handleNodeDelete } = useNodesInteractions() const { handleNodeDataUpdateWithSyncDraft } = useNodeDataUpdate() useClickAway(() => { handleNodeDataUpdateWithSyncDraft({ id, data: { selected: false } }) }, ref) return (
<> {!data._isTempNode && ( } minWidth={240} minHeight={88} /> )}
{data.selected && !data._isTempNode && (
handleNodesCopy(id)} onDuplicate={() => handleNodesDuplicate(id)} onDelete={() => handleNodeDelete(id)} showAuthor={data.showAuthor} onShowAuthorChange={handleShowAuthorChange} />
)}
$['nodes.note.editor.placeholder'], { ns: 'workflow' }) || ''} onChange={handleEditorChange} setHistoryShortcutsEnabled={setHistoryShortcutsEnabled} />
{data.showAuthor && (
{data.author}
)}
) } export default memo(NoteNode)