mirror of
https://github.com/langgenius/dify.git
synced 2024-11-16 19:59:50 +08:00
fix: workflow zoomin/out shortcuts (#4283)
This commit is contained in:
parent
1e451991db
commit
13f4ed6e0e
|
@ -19,6 +19,7 @@ import {
|
||||||
import {
|
import {
|
||||||
getKeyboardKeyCodeBySystem,
|
getKeyboardKeyCodeBySystem,
|
||||||
getKeyboardKeyNameBySystem,
|
getKeyboardKeyNameBySystem,
|
||||||
|
isEventTargetInputArea,
|
||||||
} from '../utils'
|
} from '../utils'
|
||||||
import ShortcutsName from '../shortcuts-name'
|
import ShortcutsName from '../shortcuts-name'
|
||||||
import TipPopup from './tip-popup'
|
import TipPopup from './tip-popup'
|
||||||
|
@ -128,10 +129,13 @@ const ZoomInOut: FC = () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
useKeyPress('shift.1', (e) => {
|
useKeyPress('shift.1', (e) => {
|
||||||
e.preventDefault()
|
|
||||||
if (workflowReadOnly)
|
if (workflowReadOnly)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
if (isEventTargetInputArea(e.target as HTMLElement))
|
||||||
|
return
|
||||||
|
|
||||||
|
e.preventDefault()
|
||||||
zoomTo(1)
|
zoomTo(1)
|
||||||
handleSyncWorkflowDraft()
|
handleSyncWorkflowDraft()
|
||||||
}, {
|
}, {
|
||||||
|
@ -140,10 +144,13 @@ const ZoomInOut: FC = () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
useKeyPress('shift.2', (e) => {
|
useKeyPress('shift.2', (e) => {
|
||||||
e.preventDefault()
|
|
||||||
if (workflowReadOnly)
|
if (workflowReadOnly)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
if (isEventTargetInputArea(e.target as HTMLElement))
|
||||||
|
return
|
||||||
|
|
||||||
|
e.preventDefault()
|
||||||
zoomTo(2)
|
zoomTo(2)
|
||||||
handleSyncWorkflowDraft()
|
handleSyncWorkflowDraft()
|
||||||
}, {
|
}, {
|
||||||
|
@ -152,10 +159,13 @@ const ZoomInOut: FC = () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
useKeyPress('shift.5', (e) => {
|
useKeyPress('shift.5', (e) => {
|
||||||
e.preventDefault()
|
|
||||||
if (workflowReadOnly)
|
if (workflowReadOnly)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
if (isEventTargetInputArea(e.target as HTMLElement))
|
||||||
|
return
|
||||||
|
|
||||||
|
e.preventDefault()
|
||||||
zoomTo(0.5)
|
zoomTo(0.5)
|
||||||
handleSyncWorkflowDraft()
|
handleSyncWorkflowDraft()
|
||||||
}, {
|
}, {
|
||||||
|
|
|
@ -406,3 +406,11 @@ export const getTopLeftNodePosition = (nodes: Node[]) => {
|
||||||
y: minY,
|
y: minY,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const isEventTargetInputArea = (target: HTMLElement) => {
|
||||||
|
if (target.tagName === 'INPUT' || target.tagName === 'TEXTAREA')
|
||||||
|
return true
|
||||||
|
|
||||||
|
if (target.contentEditable === 'true')
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user