Skip to content

armgit / dify

Public Imported from GitHub
0

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.

fix(workflow): resolve note node copy/duplicate errors (#27528)

yangzhelia7c855cab8d8
diff --git a/web/app/components/workflow/hooks/use-nodes-interactions.ts b/web/app/components/workflow/hooks/use-nodes-interactions.ts
index fa61cdeb8c8..4de53c431cf 100644
--- a/web/app/components/workflow/hooks/use-nodes-interactions.ts
+++ b/web/app/components/workflow/hooks/use-nodes-interactions.ts
@@ -1445,6 +1445,7 @@ export const useNodesInteractions = () => {
// If no nodeId is provided, fall back to the current behavior
const bundledNodes = nodes.filter((node) => {
if (!node.data._isBundled) return false
+ if (node.type === CUSTOM_NOTE_NODE) return true
const { metaData } = nodesMetaDataMap![node.data.type as BlockEnum]
if (metaData.isSingleton) return false
return !node.data.isInIteration && !node.data.isInLoop
@@ -1457,6 +1458,7 @@ export const useNodesInteractions = () => {
const selectedNode = nodes.find((node) => {
if (!node.data.selected) return false
+ if (node.type === CUSTOM_NOTE_NODE) return true
const { metaData } = nodesMetaDataMap![node.data.type as BlockEnum]
return !metaData.isSingleton
})
@@ -1495,7 +1497,7 @@ export const useNodesInteractions = () => {
= generateNewNode({
type: nodeToPaste.type,
data: {
- ...nodesMetaDataMap![nodeType].defaultValue,
+ ...(nodeToPaste.type !== CUSTOM_NOTE_NODE && nodesMetaDataMap![nodeType].defaultValue),
...nodeToPaste.data,
selected: false,
_isBundled: false,
diff --git a/web/app/components/workflow/note-node/index.tsx b/web/app/components/workflow/note-node/index.tsx
index 7f2cde42d60..5a0b2677c12 100644
--- a/web/app/components/workflow/note-node/index.tsx
+++ b/web/app/components/workflow/note-node/index.tsx
@@ -1,6 +1,5 @@
import {
memo,
- useCallback,
useRef,
} from 'react'
import { useTranslation } from 'react-i18next'
@@ -51,10 +50,6 @@ const NoteNode = ({
} = useNodesInteractions()
const { handleNodeDataUpdateWithSyncDraft } = useNodeDataUpdate()
- const handleDeleteNode = useCallback(() => {
- handleNodeDelete(id)
- }, [id, handleNodeDelete])
-
useClickAway(() => {
handleNodeDataUpdateWithSyncDraft({ id, data: { selected: false } })
}, ref)
@@ -102,9 +97,9 @@ const NoteNode = ({
<NoteEditorToolbar
theme={theme}
onThemeChange={handleThemeChange}
- onCopy={handleNodesCopy}
- onDuplicate={handleNodesDuplicate}
- onDelete={handleDeleteNode}
+ onCopy={() => handleNodesCopy(id)}
+ onDuplicate={() => handleNodesDuplicate(id)}
+ onDelete={() => handleNodeDelete(id)}
showAuthor={data.showAuthor}
onShowAuthorChange={handleShowAuthorChange}
/>