dify icon indicating copy to clipboard operation
dify copied to clipboard

Support for copying nodes between workflows.

Open FyhSky opened this issue 7 months ago • 5 comments

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

FyhSky avatar May 16 '25 08:05 FyhSky

I just tried it, copying across tabs still doesn't work correctly. It only works after refreshing the tab page.

Kevin9703 avatar May 19 '25 02:05 Kevin9703

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.

Kevin9703 avatar May 19 '25 02:05 Kevin9703

image

Kevin9703 avatar May 19 '25 02:05 Kevin9703

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.

lexmin0412 avatar May 20 '25 09:05 lexmin0412

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.

That's better 👍👍👍

Kevin9703 avatar May 20 '25 09:05 Kevin9703

Awaiting official support.

FyhSky avatar May 21 '25 06:05 FyhSky