Support for copying nodes between workflows.
Summary
Fix #19708
This pull request updates the clipboard functionality in the workflow-slice.ts file to persist clipboard elements in localStorage. The most important change involves initializing clipboardElements from localStorage and ensuring updates to it are saved back to localStorage.
Close https://github.com/langgenius/dify/issues/17566
Clipboard persistence updates: clipboardElements now initializes by retrieving data from localStorage (clipboard_elements key) or defaults to an empty array if no data is found. setClipboardElements has been updated to save the provided clipboard elements to localStorage (clipboard_elements key) whenever it is called. Support for copying nodes between workflows. Resolves https://github.com/langgenius/dify/issues/19545, see https://github.com/langgenius/dify/issues/19545
I just tried it, copying across tabs still doesn't work correctly. It only works after refreshing the tab page.
The issue seems to be related to state management - it might be better to read directly from localStorage when pasting rather than relying on some internal state that may not be in sync across tabs.
The issue seems to be related to state management - it might be better to read directly from localStorage when pasting rather than relying on some internal state that may not be in sync across tabs.
That makes sense, but if we proceed this way, the existing state management might become redundant. In my view, there's a more optimal approach: listen for the visibilitychange event, when document.visibilityState === 'visible' is satisfied, retrieve clipboard_elements from localStorage and invoke setClipboardElements with that value.
The issue seems to be related to state management - it might be better to read directly from localStorage when pasting rather than relying on some internal state that may not be in sync across tabs.
That makes sense, but if we proceed this way, the existing state management might become redundant. In my view, there's a more optimal approach: listen for the
visibilitychangeevent, whendocument.visibilityState === 'visible'is satisfied, retrieveclipboard_elementsfrom localStorage and invokesetClipboardElementswith that value.
That's better 👍👍👍
Awaiting official support.