mirror of
https://github.com/langgenius/dify.git
synced 2026-05-06 10:28:10 +08:00
feat: mouse right click can add new comment
This commit is contained in:
@ -7,14 +7,25 @@ const CommentManager = () => {
|
||||
const { handleCreateComment, handleCommentCancel } = useWorkflowComment()
|
||||
|
||||
useEventListener('click', (e) => {
|
||||
const { controlMode, mousePosition, pendingComment } = workflowStore.getState()
|
||||
const { controlMode, mousePosition, pendingComment, isCommentPlacing } = workflowStore.getState()
|
||||
const target = e.target as HTMLElement
|
||||
const isInDropdown = target.closest('[data-mention-dropdown]')
|
||||
const isInCommentInput = target.closest('[data-comment-input]')
|
||||
const isOnCanvasPane = target.closest('.react-flow__pane')
|
||||
|
||||
if (isCommentPlacing) {
|
||||
if (!isInDropdown && !isInCommentInput && isOnCanvasPane) {
|
||||
e.preventDefault()
|
||||
e.stopPropagation()
|
||||
workflowStore.setState({
|
||||
pendingComment: mousePosition,
|
||||
isCommentPlacing: false,
|
||||
})
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
if (controlMode === 'comment') {
|
||||
const target = e.target as HTMLElement
|
||||
const isInDropdown = target.closest('[data-mention-dropdown]')
|
||||
const isInCommentInput = target.closest('[data-comment-input]')
|
||||
const isOnCanvasPane = target.closest('.react-flow__pane')
|
||||
|
||||
// Only when clicking on the React Flow canvas pane (background),
|
||||
// and not inside comment input or its dropdown
|
||||
if (!isInDropdown && !isInCommentInput && isOnCanvasPane) {
|
||||
@ -28,6 +39,16 @@ const CommentManager = () => {
|
||||
}
|
||||
})
|
||||
|
||||
useEventListener('contextmenu', () => {
|
||||
const { isCommentPlacing } = workflowStore.getState()
|
||||
if (!isCommentPlacing)
|
||||
return
|
||||
workflowStore.setState({
|
||||
isCommentPlacing: false,
|
||||
isCommentQuickAdd: false,
|
||||
})
|
||||
})
|
||||
|
||||
return null
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user