mirror of
https://github.com/langgenius/dify.git
synced 2026-05-03 17:08:03 +08:00
fix: can editor in disabled skill editor
This commit is contained in:
@ -35,6 +35,7 @@ const FileReferenceBlock = ({ nodeKey, resourceId }: FileReferenceBlockProps) =>
|
||||
const [previewStyle, setPreviewStyle] = useState<React.CSSProperties | null>(null)
|
||||
const closeTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null)
|
||||
const { enabled: isPreviewEnabled } = useFilePreviewContext()
|
||||
const isInteractive = editor.isEditable()
|
||||
|
||||
const currentNode = useMemo(() => nodeMap?.get(resourceId), [nodeMap, resourceId])
|
||||
const isFolder = currentNode?.node_type === 'folder'
|
||||
@ -125,11 +126,16 @@ const FileReferenceBlock = ({ nodeKey, resourceId }: FileReferenceBlockProps) =>
|
||||
<PortalToFollowElemTrigger asChild ref={ref}>
|
||||
<span
|
||||
className={cn(
|
||||
'inline-flex min-w-[18px] cursor-pointer select-none items-center gap-[2px] overflow-hidden rounded-[5px] border border-state-accent-hover-alt bg-state-accent-hover py-[1px] pl-[1px] pr-[4px] shadow-xs',
|
||||
'inline-flex min-w-[18px] select-none items-center gap-[2px] overflow-hidden rounded-[5px] border border-state-accent-hover-alt bg-state-accent-hover py-[1px] pl-[1px] pr-[4px] shadow-xs',
|
||||
isInteractive ? 'cursor-pointer' : 'cursor-default',
|
||||
isSelected && 'border-text-accent',
|
||||
)}
|
||||
title={title}
|
||||
onMouseDown={() => setOpen(prev => !prev)}
|
||||
onMouseDown={() => {
|
||||
if (!isInteractive)
|
||||
return
|
||||
setOpen(prev => !prev)
|
||||
}}
|
||||
>
|
||||
<span className="flex items-center justify-center p-px">
|
||||
{isFolder
|
||||
|
||||
@ -2,6 +2,7 @@ import type { PluginDetail } from '@/app/components/plugins/types'
|
||||
import type { Emoji } from '@/app/components/tools/types'
|
||||
import type { ToolValue } from '@/app/components/workflow/block-selector/types'
|
||||
import type { ToolWithProvider } from '@/app/components/workflow/types'
|
||||
import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext'
|
||||
import { RiAlertFill } from '@remixicon/react'
|
||||
import * as React from 'react'
|
||||
import { useEffect, useMemo, useState } from 'react'
|
||||
@ -115,6 +116,7 @@ const ToolBlockComponent = ({
|
||||
icon,
|
||||
iconDark,
|
||||
}: ToolBlockComponentProps) => {
|
||||
const [editor] = useLexicalComposerContext()
|
||||
const [ref, isSelected] = useSelectOrDelete(nodeKey, DELETE_TOOL_BLOCK_COMMAND)
|
||||
const language = useGetLanguage()
|
||||
const { t } = useTranslation()
|
||||
@ -185,6 +187,8 @@ const ToolBlockComponent = ({
|
||||
return metadata?.tools?.[configId]
|
||||
}, [activeTabId, configId, fileMetadata, isUsingExternalMetadata, toolBlockContext?.metadata])
|
||||
|
||||
const isInteractive = editor.isEditable()
|
||||
|
||||
const defaultToolValue = useMemo(() => {
|
||||
if (!currentProvider || !currentTool)
|
||||
return null
|
||||
@ -515,13 +519,16 @@ const ToolBlockComponent = ({
|
||||
<span
|
||||
ref={ref}
|
||||
className={cn(
|
||||
'inline-flex cursor-pointer items-center gap-[2px] rounded-[5px] border py-px pl-px pr-[3px] shadow-xs',
|
||||
'inline-flex items-center gap-[2px] rounded-[5px] border py-px pl-px pr-[3px] shadow-xs',
|
||||
isInteractive ? 'cursor-pointer' : 'cursor-default',
|
||||
needAuthorization ? 'border-state-warning-active bg-state-warning-hover' : 'border-state-accent-hover-alt bg-state-accent-hover',
|
||||
isSelected && 'border-text-accent',
|
||||
)}
|
||||
title={`${provider}.${tool}`}
|
||||
data-tool-config-id={configId}
|
||||
onMouseDown={() => {
|
||||
if (!isInteractive)
|
||||
return
|
||||
if (!currentProvider || !currentTool)
|
||||
return
|
||||
if (configuredToolValue)
|
||||
|
||||
Reference in New Issue
Block a user