can't zoomOnPinch when mouse over comment preview

This commit is contained in:
hjlarry 2025-11-07 09:27:49 +08:00
parent da2421f378
commit 0ae2d2b631
3 changed files with 14 additions and 2 deletions

View File

@ -1,10 +1,11 @@
'use client' 'use client'
import type { FC } from 'react' import type { FC } from 'react'
import { memo, useMemo } from 'react' import { memo, useEffect, useMemo } from 'react'
import { UserAvatarList } from '@/app/components/base/user-avatar-list' import { UserAvatarList } from '@/app/components/base/user-avatar-list'
import type { WorkflowCommentList } from '@/service/workflow-comment' import type { WorkflowCommentList } from '@/service/workflow-comment'
import { useFormatTimeFromNow } from '@/hooks/use-format-time-from-now' import { useFormatTimeFromNow } from '@/hooks/use-format-time-from-now'
import { useStore } from '../store'
type CommentPreviewProps = { type CommentPreviewProps = {
comment: WorkflowCommentList comment: WorkflowCommentList
@ -13,6 +14,7 @@ type CommentPreviewProps = {
const CommentPreview: FC<CommentPreviewProps> = ({ comment, onClick }) => { const CommentPreview: FC<CommentPreviewProps> = ({ comment, onClick }) => {
const { formatTimeFromNow } = useFormatTimeFromNow() const { formatTimeFromNow } = useFormatTimeFromNow()
const setCommentPreviewHovering = useStore(s => s.setCommentPreviewHovering)
const participants = useMemo(() => { const participants = useMemo(() => {
const list = comment.participants ?? [] const list = comment.participants ?? []
const author = comment.created_by_account const author = comment.created_by_account
@ -21,11 +23,16 @@ const CommentPreview: FC<CommentPreviewProps> = ({ comment, onClick }) => {
const rest = list.filter(user => user.id !== author.id) const rest = list.filter(user => user.id !== author.id)
return [author, ...rest] return [author, ...rest]
}, [comment.created_by_account, comment.participants]) }, [comment.created_by_account, comment.participants])
useEffect(() => () => {
setCommentPreviewHovering(false)
}, [setCommentPreviewHovering])
return ( return (
<div <div
className="w-80 cursor-pointer rounded-3xl rounded-bl-[3px] border-[0.5px] border-components-panel-border bg-components-panel-bg-blur p-4 shadow-lg backdrop-blur-[10px] transition-colors hover:bg-components-panel-on-panel-item-bg-hover" className="w-80 cursor-pointer rounded-3xl rounded-bl-[3px] border-[0.5px] border-components-panel-border bg-components-panel-bg-blur p-4 shadow-lg backdrop-blur-[10px] transition-colors hover:bg-components-panel-on-panel-item-bg-hover"
onClick={onClick} onClick={onClick}
onMouseEnter={() => setCommentPreviewHovering(true)}
onMouseLeave={() => setCommentPreviewHovering(false)}
> >
<div className="mb-3 flex items-center justify-between"> <div className="mb-3 flex items-center justify-between">
<UserAvatarList <UserAvatarList

View File

@ -209,6 +209,7 @@ export const Workflow: FC<WorkflowProps> = memo(({
} = useWorkflowComment() } = useWorkflowComment()
const showUserComments = useStore(s => s.showUserComments) const showUserComments = useStore(s => s.showUserComments)
const showUserCursors = useStore(s => s.showUserCursors) const showUserCursors = useStore(s => s.showUserCursors)
const isCommentPreviewHovering = useStore(s => s.isCommentPreviewHovering)
const { t } = useTranslation() const { t } = useTranslation()
eventEmitter?.useSubscription((v: any) => { eventEmitter?.useSubscription((v: any) => {
@ -535,7 +536,7 @@ export const Workflow: FC<WorkflowProps> = memo(({
edgesFocusable={!nodesReadOnly} edgesFocusable={!nodesReadOnly}
panOnScroll={false} panOnScroll={false}
panOnDrag={controlMode === ControlMode.Hand} panOnDrag={controlMode === ControlMode.Hand}
zoomOnPinch={true} zoomOnPinch={!isCommentPreviewHovering}
zoomOnScroll={true} zoomOnScroll={true}
zoomOnDoubleClick={true} zoomOnDoubleClick={true}
isValidConnection={isValidConnection} isValidConnection={isValidConnection}

View File

@ -32,6 +32,8 @@ export type WorkflowSliceShape = {
setPendingComment: (pendingComment: WorkflowSliceShape['pendingComment']) => void setPendingComment: (pendingComment: WorkflowSliceShape['pendingComment']) => void
mousePosition: MousePosition mousePosition: MousePosition
setMousePosition: (mousePosition: WorkflowSliceShape['mousePosition']) => void setMousePosition: (mousePosition: WorkflowSliceShape['mousePosition']) => void
isCommentPreviewHovering: boolean
setCommentPreviewHovering: (hovering: boolean) => void
showConfirm?: { title: string; desc?: string; onConfirm: () => void } showConfirm?: { title: string; desc?: string; onConfirm: () => void }
setShowConfirm: (showConfirm: WorkflowSliceShape['showConfirm']) => void setShowConfirm: (showConfirm: WorkflowSliceShape['showConfirm']) => void
controlPromptEditorRerenderKey: number controlPromptEditorRerenderKey: number
@ -66,6 +68,8 @@ export const createWorkflowSlice: StateCreator<WorkflowSliceShape> = set => ({
setPendingComment: pendingComment => set(() => ({ pendingComment })), setPendingComment: pendingComment => set(() => ({ pendingComment })),
mousePosition: { pageX: 0, pageY: 0, elementX: 0, elementY: 0 }, mousePosition: { pageX: 0, pageY: 0, elementX: 0, elementY: 0 },
setMousePosition: mousePosition => set(() => ({ mousePosition })), setMousePosition: mousePosition => set(() => ({ mousePosition })),
isCommentPreviewHovering: false,
setCommentPreviewHovering: hovering => set(() => ({ isCommentPreviewHovering: hovering })),
showConfirm: undefined, showConfirm: undefined,
setShowConfirm: showConfirm => set(() => ({ showConfirm })), setShowConfirm: showConfirm => set(() => ({ showConfirm })),
controlPromptEditorRerenderKey: 0, controlPromptEditorRerenderKey: 0,