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: prioritize copying selected text (#30141)

JeeekXY0f85ce3d0ec3
diff --git a/web/app/components/workflow/hooks/use-shortcuts.ts b/web/app/components/workflow/hooks/use-shortcuts.ts
index 00ed25bad08..1b3d141d8df 100644
--- a/web/app/components/workflow/hooks/use-shortcuts.ts
+++ b/web/app/components/workflow/hooks/use-shortcuts.ts
@@ -63,6 +63,11 @@ export const useShortcuts = (): void => {
return !isEventTargetInputArea(e.target as HTMLElement)
}, [])
+ const shouldHandleCopy = useCallback(() => {
+ const selection = document.getSelection()
+ return !selection || selection.isCollapsed
+ }, [])
+
useKeyPress(['delete', 'backspace'], (e) => {
if (shouldHandleShortcut(e)) {
e.preventDefault()
@@ -73,7 +78,7 @@ export const useShortcuts = (): void => {
useKeyPress(`${getKeyboardKeyCodeBySystem('ctrl')}.c`, (e) => {
const { showDebugAndPreviewPanel } = workflowStore.getState()
- if (shouldHandleShortcut(e) && !showDebugAndPreviewPanel) {
+ if (shouldHandleShortcut(e) && shouldHandleCopy() && !showDebugAndPreviewPanel) {
e.preventDefault()
handleNodesCopy()
}