mirror of
https://github.com/shumaiOne/shumai.git
synced 2026-12-01 13:34:33 +00:00
feat(agent): add nested agents.md support across backend and webui (#309)
* feat(agent): add nested agents.md support across backend and webui * fix(webui): update agentsmd route paths and unnest folder agentsmd route * fix(agent): flush agents.md autosave on close and address review feedback - Flush pending debounced AGENTS.md autosave on close/unmount so edits made within 750ms of navigating away are no longer silently lost - Serialize autosaves through a promise chain so an older in-flight request can never overwrite newer content on the server - Internationalize the hardcoded "Failed to save" and "Loading AGENTS.md..." strings (en + zh) - Validate that AGENTS.md is only stored on folder/root assets in AssetService, preventing bogus virtual paths for file assets - Cap updateAgentsMd content at 100k chars via Zod validation - Remove unused getAgentsMd/updateAgentsMd response DTO schemas - Drop unused teamId prop from AgentsMdEditor - Add tests: non-folder asset rejection, oversized content 400, and agent-chat workflow assetId passthrough * refactor(db): isolate AGENTS.md content in dedicated 1:1 AssetAgentMd table * style(webui): unify top bar button hover styles and add wand icon to agentsmd button * style(webui): update agentsmd button state colors and remove presence dot * fix(webui): fix close button overflow and stabilize debounced autosave in agentsmd editor * fix(webui): update debounce to 1s and await pending save before closing agentsmd editor * feat(webui): add terminal AGENTS.md breadcrumb on agentsmd editor page * fix(webui): use ScrollArea for markdown editor scrolling
This commit is contained in:
@@ -0,0 +1,240 @@
|
||||
import { client } from '@/ui/api/client'
|
||||
import { usePermissions } from '@/ui/hooks/use-permissions'
|
||||
import { m } from '@/ui/paraglide/messages.js'
|
||||
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'
|
||||
import { useNavigate } from '@tanstack/react-router'
|
||||
import { AlertCircle, Check, Lock, Save, X } from 'lucide-react'
|
||||
import { useCallback, useEffect, useRef, useState } from 'react'
|
||||
import { MarkdownEditor } from '../markdown-editor/markdown-editor'
|
||||
import { Button } from '../ui/button'
|
||||
import { Separator } from '../ui/separator'
|
||||
|
||||
export interface AgentsMdEditorProps {
|
||||
projectId: string
|
||||
assetId: string
|
||||
rootFolderId: string
|
||||
isRoot?: boolean
|
||||
}
|
||||
|
||||
export function AgentsMdEditor({ projectId, assetId, rootFolderId, isRoot }: AgentsMdEditorProps) {
|
||||
const navigate = useNavigate()
|
||||
const queryClient = useQueryClient()
|
||||
const { canAdmin } = usePermissions(projectId)
|
||||
|
||||
const { data, isLoading } = useQuery({
|
||||
queryKey: ['folders', assetId, 'agentsmd'],
|
||||
queryFn: async () => {
|
||||
const res = await client.api.folders[':folderId'].agentsmd.$get({
|
||||
param: { folderId: assetId },
|
||||
})
|
||||
if (!res.ok) throw new Error('Failed to fetch agents.md')
|
||||
return await res.json()
|
||||
},
|
||||
})
|
||||
|
||||
const [content, setContent] = useState<string>('')
|
||||
const [isInitialized, setIsInitialized] = useState(false)
|
||||
const [saveStatus, setSaveStatus] = useState<'idle' | 'saving' | 'saved' | 'error'>('idle')
|
||||
const saveTimeoutRef = useRef<ReturnType<typeof setTimeout> | null>(null)
|
||||
const clearSavedTimeoutRef = useRef<ReturnType<typeof setTimeout> | null>(null)
|
||||
const latestContentRef = useRef<string>('')
|
||||
const lastSavedContentRef = useRef<string | null>(null)
|
||||
// Serializes autosaves so a newer write can never be overwritten by an older
|
||||
// in-flight request completing out of order.
|
||||
const saveChainRef = useRef<Promise<unknown>>(Promise.resolve())
|
||||
|
||||
useEffect(() => {
|
||||
if (!isInitialized && data !== undefined) {
|
||||
const initial = data.content ?? ''
|
||||
setContent(initial)
|
||||
latestContentRef.current = initial
|
||||
lastSavedContentRef.current = initial
|
||||
setIsInitialized(true)
|
||||
}
|
||||
}, [data, isInitialized])
|
||||
|
||||
const [isClosing, setIsClosing] = useState(false)
|
||||
|
||||
const saveMutation = useMutation({
|
||||
mutationFn: async (newContent: string) => {
|
||||
const res = await client.api.folders[':folderId'].agentsmd.$patch({
|
||||
param: { folderId: assetId },
|
||||
json: { content: newContent },
|
||||
})
|
||||
if (!res.ok) throw new Error('Failed to save agents.md')
|
||||
return await res.json()
|
||||
},
|
||||
onSuccess: (_, newContent) => {
|
||||
setSaveStatus('saved')
|
||||
lastSavedContentRef.current = newContent
|
||||
queryClient.setQueryData(['folders', assetId, 'agentsmd'], { content: newContent })
|
||||
queryClient.invalidateQueries({ queryKey: ['folders', assetId] })
|
||||
if (clearSavedTimeoutRef.current) {
|
||||
clearTimeout(clearSavedTimeoutRef.current)
|
||||
}
|
||||
clearSavedTimeoutRef.current = setTimeout(() => {
|
||||
setSaveStatus('idle')
|
||||
}, 2500)
|
||||
},
|
||||
onError: () => {
|
||||
setSaveStatus('error')
|
||||
},
|
||||
})
|
||||
|
||||
const saveMutationRef = useRef(saveMutation.mutateAsync)
|
||||
saveMutationRef.current = saveMutation.mutateAsync
|
||||
|
||||
const enqueueSave = useCallback(
|
||||
(textToSave: string) => {
|
||||
if (!canAdmin) return Promise.resolve()
|
||||
if (lastSavedContentRef.current === textToSave) {
|
||||
setSaveStatus('saved')
|
||||
return Promise.resolve()
|
||||
}
|
||||
setSaveStatus('saving')
|
||||
const p = saveChainRef.current
|
||||
.then(async () => {
|
||||
await saveMutationRef.current(textToSave)
|
||||
})
|
||||
.catch(() => {
|
||||
// Swallow so a failed save does not break the chain for later saves.
|
||||
// The mutation's onError handler already surfaces the failure.
|
||||
})
|
||||
saveChainRef.current = p
|
||||
return p
|
||||
},
|
||||
[canAdmin],
|
||||
)
|
||||
|
||||
const handleContentChange = useCallback(
|
||||
(newMarkdown: string) => {
|
||||
if (!canAdmin) return
|
||||
setContent(newMarkdown)
|
||||
latestContentRef.current = newMarkdown
|
||||
|
||||
if (saveTimeoutRef.current) {
|
||||
clearTimeout(saveTimeoutRef.current)
|
||||
}
|
||||
|
||||
setSaveStatus('saving')
|
||||
saveTimeoutRef.current = setTimeout(() => {
|
||||
saveTimeoutRef.current = null
|
||||
enqueueSave(newMarkdown)
|
||||
}, 1000)
|
||||
},
|
||||
[canAdmin, enqueueSave],
|
||||
)
|
||||
|
||||
// Flushes any pending debounced edits so they are not lost when the editor
|
||||
// unmounts (close button, folder-tree navigation, or route change).
|
||||
const flushPendingSave = useCallback(() => {
|
||||
if (saveTimeoutRef.current) {
|
||||
clearTimeout(saveTimeoutRef.current)
|
||||
saveTimeoutRef.current = null
|
||||
return enqueueSave(latestContentRef.current)
|
||||
}
|
||||
return saveChainRef.current
|
||||
}, [enqueueSave])
|
||||
|
||||
useEffect(() => {
|
||||
return () => {
|
||||
flushPendingSave()
|
||||
if (clearSavedTimeoutRef.current) {
|
||||
clearTimeout(clearSavedTimeoutRef.current)
|
||||
}
|
||||
}
|
||||
}, [flushPendingSave])
|
||||
|
||||
const handleClose = async () => {
|
||||
setIsClosing(true)
|
||||
try {
|
||||
flushPendingSave()
|
||||
await saveChainRef.current
|
||||
} catch {
|
||||
// Proceed with navigation even if error occurs
|
||||
} finally {
|
||||
if (isRoot || assetId === rootFolderId) {
|
||||
navigate({
|
||||
to: '/projects/$projectId',
|
||||
params: { projectId },
|
||||
})
|
||||
} else {
|
||||
navigate({
|
||||
to: '/projects/$projectId/folders/$folderId',
|
||||
params: { projectId, folderId: assetId },
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const rightToolbarContent = (
|
||||
<div className="flex items-center gap-2 shrink-0">
|
||||
{canAdmin ? (
|
||||
<div className="flex items-center gap-1.5 text-xs shrink-0">
|
||||
{(saveStatus === 'saving' || isClosing) && (
|
||||
<span className="inline-flex items-center gap-1 text-muted-foreground animate-pulse whitespace-nowrap">
|
||||
<Save className="h-3.5 w-3.5 shrink-0" />
|
||||
<span>{m.saving_ellipsis()}</span>
|
||||
</span>
|
||||
)}
|
||||
{saveStatus === 'saved' && !isClosing && (
|
||||
<span className="inline-flex items-center gap-1 text-emerald-600 dark:text-emerald-400 font-medium whitespace-nowrap">
|
||||
<Check className="h-3.5 w-3.5 shrink-0" />
|
||||
<span>{m.saved()}</span>
|
||||
</span>
|
||||
)}
|
||||
{saveStatus === 'error' && !isClosing && (
|
||||
<span className="inline-flex items-center gap-1 text-destructive font-medium whitespace-nowrap">
|
||||
<AlertCircle className="h-3.5 w-3.5 shrink-0" />
|
||||
<span>{m.agents_md_save_failed()}</span>
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
) : (
|
||||
<div
|
||||
className="inline-flex items-center gap-1 text-xs text-muted-foreground bg-muted px-2 py-0.5 rounded-md shrink-0"
|
||||
title={m.agents_md_readonly_hint()}
|
||||
>
|
||||
<Lock className="h-3 w-3 shrink-0" />
|
||||
<span>{m.read_only()}</span>
|
||||
</div>
|
||||
)}
|
||||
|
||||
<Separator orientation="vertical" className="h-4 shrink-0" />
|
||||
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
onClick={handleClose}
|
||||
disabled={isClosing}
|
||||
className="h-7 px-2.5 hover:bg-muted text-muted-foreground hover:text-foreground shrink-0"
|
||||
title={m.close()}
|
||||
>
|
||||
<X className="h-4 w-4 mr-1 shrink-0" />
|
||||
<span>{m.close()}</span>
|
||||
</Button>
|
||||
</div>
|
||||
)
|
||||
|
||||
if (isLoading || !isInitialized) {
|
||||
return (
|
||||
<div className="flex-1 flex items-center justify-center p-8 text-sm text-muted-foreground">
|
||||
<Save className="h-4 w-4 animate-pulse mr-2" />
|
||||
<span>{m.agents_md_loading()}</span>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="flex-1 flex flex-col h-full min-h-0 overflow-hidden">
|
||||
<MarkdownEditor
|
||||
value={content}
|
||||
onChange={handleContentChange}
|
||||
placeholder={m.agents_md_placeholder()}
|
||||
readOnly={!canAdmin}
|
||||
rightToolbarContent={rightToolbarContent}
|
||||
className="flex-1 flex flex-col h-full min-h-0 border rounded-lg shadow-sm"
|
||||
/>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,158 @@
|
||||
import { client } from '@/ui/api/client'
|
||||
import { ChatbotSidebar } from '@/ui/components/chatbot-sidebar'
|
||||
import { FolderTree } from '@/ui/components/folder-tree'
|
||||
import { ResizeHandle } from '@/ui/components/resize-handle'
|
||||
import { useChatbotStore } from '@/ui/stores/chatbot'
|
||||
import { useTopNavStore } from '@/ui/stores/top-nav'
|
||||
import { useUiStore } from '@/ui/stores/ui'
|
||||
import type { AncestorFolder, AssetInfo } from '@shumai/dtos'
|
||||
import { useQuery } from '@tanstack/react-query'
|
||||
import { useNavigate } from '@tanstack/react-router'
|
||||
import { useEffect, useState } from 'react'
|
||||
import { AgentsMdEditor } from './agents-md-editor'
|
||||
|
||||
export interface AgentsMdManagerProps {
|
||||
teamId: string
|
||||
projectId: string
|
||||
projectName: string
|
||||
assetId: string
|
||||
rootFolderId: string
|
||||
isRoot?: boolean
|
||||
}
|
||||
|
||||
export default function AgentsMdManager({
|
||||
teamId,
|
||||
projectId,
|
||||
projectName,
|
||||
assetId,
|
||||
rootFolderId,
|
||||
isRoot,
|
||||
}: AgentsMdManagerProps) {
|
||||
const navigate = useNavigate()
|
||||
const [leftSidebarWidth, setLeftSidebarWidth] = useState(240)
|
||||
const [rightSidebarWidth, setRightSidebarWidth] = useState(360)
|
||||
const {
|
||||
fileListLeftSidebarCollapsed: isLeftSidebarCollapsed,
|
||||
setFileListLeftSidebarCollapsed: setIsLeftSidebarCollapsed,
|
||||
} = useUiStore()
|
||||
const { isChatbotOpen, setIsChatbotOpen } = useChatbotStore()
|
||||
|
||||
const { data: folderInfo } = useQuery({
|
||||
queryKey: ['folders', assetId],
|
||||
queryFn: async () => {
|
||||
const res = await client.api.folders[':folderId'].$get({
|
||||
param: { folderId: assetId },
|
||||
})
|
||||
if (!res.ok) throw new Error('failed to fetch folder')
|
||||
return (await res.json()) as unknown as AssetInfo
|
||||
},
|
||||
enabled: !!assetId,
|
||||
})
|
||||
|
||||
const { setProjectState, clearProjectState } = useTopNavStore()
|
||||
|
||||
useEffect(() => {
|
||||
const isRootFolder = isRoot || assetId === rootFolderId
|
||||
const ancestors: AncestorFolder[] = isRootFolder
|
||||
? []
|
||||
: folderInfo?.name
|
||||
? [{ id: assetId, name: folderInfo.name }, ...(folderInfo?.ancestorFolders ?? [])]
|
||||
: (folderInfo?.ancestorFolders ?? [])
|
||||
|
||||
setProjectState({
|
||||
teamId,
|
||||
projectId,
|
||||
projectName,
|
||||
ancestorFolders: ancestors,
|
||||
currentAsset: { name: folderInfo?.name, type: 'folder' },
|
||||
isRootFolder: true,
|
||||
customTerminalBreadcrumb: 'AGENTS.md',
|
||||
onFolderClick: (id: string) => {
|
||||
navigate({
|
||||
to: '/projects/$projectId/folders/$folderId',
|
||||
params: { projectId, folderId: id },
|
||||
})
|
||||
},
|
||||
})
|
||||
|
||||
return () => clearProjectState()
|
||||
}, [
|
||||
teamId,
|
||||
projectId,
|
||||
projectName,
|
||||
folderInfo?.ancestorFolders,
|
||||
folderInfo?.name,
|
||||
isRoot,
|
||||
assetId,
|
||||
rootFolderId,
|
||||
setProjectState,
|
||||
clearProjectState,
|
||||
navigate,
|
||||
])
|
||||
|
||||
return (
|
||||
<div className="flex-1 flex flex-col h-full overflow-hidden bg-background">
|
||||
<div className="flex-1 flex overflow-hidden relative">
|
||||
{!isLeftSidebarCollapsed && (
|
||||
<div
|
||||
className="md:hidden fixed inset-0 bg-black/50 z-40"
|
||||
onClick={() => setIsLeftSidebarCollapsed(true)}
|
||||
/>
|
||||
)}
|
||||
{isChatbotOpen && (
|
||||
<div
|
||||
className="md:hidden fixed inset-0 bg-black/50 z-40"
|
||||
onClick={() => setIsChatbotOpen(false)}
|
||||
/>
|
||||
)}
|
||||
|
||||
{!isLeftSidebarCollapsed && (
|
||||
<>
|
||||
<div className="bg-background flex-shrink-0" style={{ width: leftSidebarWidth }}>
|
||||
<FolderTree
|
||||
teamId={teamId}
|
||||
projectId={projectId}
|
||||
projectName={projectName}
|
||||
rootFolderId={rootFolderId}
|
||||
selectedFolderId={assetId}
|
||||
ancestorFolders={folderInfo?.ancestorFolders ?? []}
|
||||
/>
|
||||
</div>
|
||||
<ResizeHandle
|
||||
onResize={(delta) => {
|
||||
setLeftSidebarWidth((prev) => Math.max(180, Math.min(400, prev + delta)))
|
||||
}}
|
||||
className="hidden md:block"
|
||||
/>
|
||||
</>
|
||||
)}
|
||||
|
||||
<div className="flex-1 flex flex-col min-w-0 min-h-0 bg-background overflow-hidden p-3">
|
||||
<AgentsMdEditor
|
||||
projectId={projectId}
|
||||
assetId={assetId}
|
||||
rootFolderId={rootFolderId}
|
||||
isRoot={isRoot}
|
||||
/>
|
||||
</div>
|
||||
|
||||
{isChatbotOpen && (
|
||||
<>
|
||||
<ResizeHandle
|
||||
onResize={(delta) => {
|
||||
setRightSidebarWidth((prev) => Math.max(240, Math.min(600, prev - delta)))
|
||||
}}
|
||||
className="hidden md:block"
|
||||
/>
|
||||
<div
|
||||
style={{ width: rightSidebarWidth }}
|
||||
className="bg-background flex flex-col flex-shrink-0"
|
||||
>
|
||||
<ChatbotSidebar projectId={projectId} contextAssetId={assetId} />
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -53,6 +53,7 @@ interface BreadcrumbNavProps {
|
||||
proxyType?: 'image' | 'video' | 'audio' | 'pdf' | null
|
||||
}
|
||||
isRootFolder: boolean
|
||||
customTerminalBreadcrumb?: string
|
||||
displayStyle?: 'card' | 'list'
|
||||
onDisplayStyleChange?: (style: 'card' | 'list') => void
|
||||
isLeftSidebarCollapsed?: boolean
|
||||
@@ -95,6 +96,7 @@ export function BreadcrumbNav({
|
||||
ancestorFolders,
|
||||
currentAsset,
|
||||
isRootFolder,
|
||||
customTerminalBreadcrumb,
|
||||
displayStyle,
|
||||
onDisplayStyleChange,
|
||||
isLeftSidebarCollapsed,
|
||||
@@ -219,7 +221,14 @@ export function BreadcrumbNav({
|
||||
)}
|
||||
</div>
|
||||
))}
|
||||
{!isRootFolder && !compareMode && (
|
||||
{customTerminalBreadcrumb ? (
|
||||
<div className="flex items-center gap-1">
|
||||
<span className="text-muted-foreground">/</span>
|
||||
<span className="truncate rounded px-2 py-1 text-sm font-medium text-foreground">
|
||||
{customTerminalBreadcrumb}
|
||||
</span>
|
||||
</div>
|
||||
) : !isRootFolder && !compareMode ? (
|
||||
<div className="flex items-center gap-1">
|
||||
<span className="text-muted-foreground">/</span>
|
||||
{currentAsset.type === 'folder' ? (
|
||||
@@ -385,7 +394,7 @@ export function BreadcrumbNav({
|
||||
</DropdownMenu>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
) : null}
|
||||
</div>
|
||||
|
||||
<div className="flex items-center gap-2">
|
||||
|
||||
@@ -4,6 +4,7 @@ import { m } from '@/ui/paraglide/messages.js'
|
||||
import type { AssetInfo, CollectionInfo, SearchCondition, SearchSort } from '@shumai/dtos'
|
||||
import { type FieldInfo as MetadataFieldInfo } from '@shumai/dtos'
|
||||
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'
|
||||
import { useNavigate } from '@tanstack/react-router'
|
||||
import type { InferRequestType, InferResponseType } from 'hono/client'
|
||||
import { useState } from 'react'
|
||||
import { FieldsManager } from '../fields-manager'
|
||||
@@ -17,6 +18,7 @@ import { Avatar, AvatarFallback, AvatarImage } from '../ui/avatar'
|
||||
import { Button } from '../ui/button'
|
||||
import { Popover, PopoverContent, PopoverTrigger } from '../ui/popover'
|
||||
import { Separator } from '../ui/separator'
|
||||
import { cn } from '@/ui/lib/utils'
|
||||
|
||||
type FileBrowserToolbarProps = {
|
||||
teamId: string
|
||||
@@ -55,6 +57,7 @@ export function FileBrowserToolbar({
|
||||
const [isMembersDialogOpen, setIsMembersDialogOpen] = useState(false)
|
||||
const [isFolderSelectorOpen, setIsFolderSelectorOpen] = useState(false)
|
||||
|
||||
const navigate = useNavigate()
|
||||
const activeFiltersCount = filterConditions.length
|
||||
const isCollection = !!collection
|
||||
const queryClient = useQueryClient()
|
||||
@@ -68,9 +71,23 @@ export function FileBrowserToolbar({
|
||||
if (!res.ok) throw new Error('failed to fetch folder')
|
||||
return (await res.json()) as unknown as AssetInfo
|
||||
},
|
||||
enabled: isCollection && !!assetId,
|
||||
enabled: !!assetId && !isRecentlyDeleted,
|
||||
})
|
||||
|
||||
const handleOpenAgentsMd = () => {
|
||||
if (assetId === rootFolderId) {
|
||||
navigate({
|
||||
to: '/projects/$projectId/agentsmd',
|
||||
params: { projectId },
|
||||
})
|
||||
} else {
|
||||
navigate({
|
||||
to: '/projects/$projectId/folders/$folderId/agentsmd',
|
||||
params: { projectId, folderId: assetId },
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
const { data: members, refetch: refetchProjectMembers } = useQuery({
|
||||
queryKey: ['projects', projectId, 'members'],
|
||||
queryFn: async () => {
|
||||
@@ -225,11 +242,9 @@ export function FileBrowserToolbar({
|
||||
<div className="flex items-center gap-2 h-full">
|
||||
<Popover open={popoverOpen} onOpenChange={setPopoverOpen}>
|
||||
<PopoverTrigger asChild>
|
||||
<div>
|
||||
<Button variant="ghost" size="sm">
|
||||
{m.field()}
|
||||
</Button>
|
||||
</div>
|
||||
<Button variant="ghost" size="sm">
|
||||
{m.field()}
|
||||
</Button>
|
||||
</PopoverTrigger>
|
||||
<PopoverContent className="w-auto p-0" align="start">
|
||||
<FieldsManager
|
||||
@@ -254,11 +269,7 @@ export function FileBrowserToolbar({
|
||||
<>
|
||||
<Popover open={isFolderSelectorOpen} onOpenChange={setIsFolderSelectorOpen}>
|
||||
<PopoverTrigger asChild>
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
className="inline-flex items-center gap-2 px-3 py-2 hover:bg-primary/10 font-semibold rounded-xl cursor-pointer h-8 text-muted-foreground"
|
||||
>
|
||||
<Button variant="ghost" size="sm" className="text-muted-foreground">
|
||||
<span className="truncate max-w-[150px]">{folderInfo?.name || 'Loading...'}</span>
|
||||
</Button>
|
||||
</PopoverTrigger>
|
||||
@@ -295,11 +306,7 @@ export function FileBrowserToolbar({
|
||||
|
||||
<Popover>
|
||||
<PopoverTrigger asChild>
|
||||
<Button
|
||||
variant={activeFiltersCount > 0 ? 'secondary' : 'ghost'}
|
||||
size="sm"
|
||||
className="inline-flex items-center gap-2 px-4 py-2 hover:bg-primary/10 font-semibold rounded-xl cursor-pointer h-8"
|
||||
>
|
||||
<Button variant={activeFiltersCount > 0 ? 'secondary' : 'ghost'} size="sm">
|
||||
<span>Filter</span>
|
||||
{activeFiltersCount > 0 && (
|
||||
<span className="ml-1 px-1.5 py-0.5 rounded-full text-[10px] font-mono font-bold bg-primary/50 border border-primary-foreground/20">
|
||||
@@ -333,20 +340,49 @@ export function FileBrowserToolbar({
|
||||
</Popover>
|
||||
</>
|
||||
) : (
|
||||
<Button
|
||||
onClick={() => setSearchDialogOpen(true)}
|
||||
disabled={isRecentlyDeleted}
|
||||
variant={activeFiltersCount > 0 ? 'secondary' : 'ghost'}
|
||||
size="sm"
|
||||
className="inline-flex items-center gap-2 px-4 py-2 hover:bg-primary/10 font-semibold rounded-xl cursor-pointer h-8"
|
||||
>
|
||||
<span>{m.search()}</span>
|
||||
{activeFiltersCount > 0 && (
|
||||
<span className="ml-1 px-1.5 py-0.5 rounded-full text-[10px] font-mono font-bold bg-primary/50 border border-primary-foreground/20">
|
||||
{activeFiltersCount}
|
||||
</span>
|
||||
<>
|
||||
<Button
|
||||
onClick={() => setSearchDialogOpen(true)}
|
||||
disabled={isRecentlyDeleted}
|
||||
variant={activeFiltersCount > 0 ? 'secondary' : 'ghost'}
|
||||
size="sm"
|
||||
>
|
||||
<span>{m.search()}</span>
|
||||
{activeFiltersCount > 0 && (
|
||||
<span className="ml-1 px-1.5 py-0.5 rounded-full text-[10px] font-mono font-bold bg-primary/50 border border-primary-foreground/20">
|
||||
{activeFiltersCount}
|
||||
</span>
|
||||
)}
|
||||
</Button>
|
||||
|
||||
{!isRecentlyDeleted && (
|
||||
<>
|
||||
<Separator orientation="vertical" />
|
||||
<Button
|
||||
onClick={handleOpenAgentsMd}
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
title="AGENTS.md"
|
||||
className={cn(
|
||||
folderInfo?.hasAgentsMd ? 'text-foreground' : 'text-muted-foreground',
|
||||
)}
|
||||
>
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
viewBox="0 -960 960 960"
|
||||
className={cn(
|
||||
'size-4',
|
||||
folderInfo?.hasAgentsMd ? 'text-primary' : 'text-muted-foreground',
|
||||
)}
|
||||
fill="currentColor"
|
||||
>
|
||||
<path d="m176-120-56-56 301-302-181-45 198-123-17-234 179 151 216-88-87 217 151 178-234-16-124 198-45-181-301 301Zm24-520-80-80 80-80 80 80-80 80Zm520 520-80-80 80-80 80 80-80 80Z" />
|
||||
</svg>
|
||||
<span>{m.agents_md()}</span>
|
||||
</Button>
|
||||
</>
|
||||
)}
|
||||
</Button>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
.shumai-editor-wrapper {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
height: 100%;
|
||||
min-height: 0;
|
||||
border: 1px solid var(--border, #e2e8f0);
|
||||
border-radius: 8px;
|
||||
background-color: var(--background, #ffffff);
|
||||
@@ -23,7 +25,7 @@
|
||||
user-select: none;
|
||||
}
|
||||
|
||||
.shumai-editor-toolbar button {
|
||||
.shumai-editor-toolbar-left button {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
@@ -38,17 +40,17 @@
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.shumai-editor-toolbar button:hover:not(:disabled) {
|
||||
.shumai-editor-toolbar-left button:hover:not(:disabled) {
|
||||
background-color: var(--accent, #e2e8f0);
|
||||
color: var(--accent-foreground, #0f172a);
|
||||
}
|
||||
|
||||
.shumai-editor-toolbar button:disabled {
|
||||
.shumai-editor-toolbar-left button:disabled {
|
||||
opacity: 0.35;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
|
||||
.shumai-editor-toolbar button.active {
|
||||
.shumai-editor-toolbar-left button.active {
|
||||
background-color: var(--primary, #0f172a);
|
||||
color: var(--primary-foreground, #ffffff);
|
||||
}
|
||||
@@ -74,14 +76,14 @@
|
||||
|
||||
.shumai-editor-content-area {
|
||||
position: relative;
|
||||
min-height: 240px;
|
||||
min-height: 0;
|
||||
flex: 1;
|
||||
width: 100%;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.editor-input {
|
||||
min-height: 240px;
|
||||
min-height: 100%;
|
||||
padding: 16px;
|
||||
outline: none;
|
||||
font-size: 15px;
|
||||
|
||||
@@ -24,6 +24,7 @@ import { AutoLinkNode, LinkNode } from '@lexical/link'
|
||||
import { ToolbarPlugin } from './toolbar'
|
||||
import { editorTheme } from './theme'
|
||||
import { EDITOR_TRANSFORMERS } from './transformers'
|
||||
import { ScrollArea } from '@/ui/components/ui/scroll-area'
|
||||
import './markdown-editor.css'
|
||||
|
||||
function MarkdownSyncPlugin({
|
||||
@@ -90,6 +91,7 @@ export interface MarkdownEditorProps {
|
||||
autoFocus?: boolean
|
||||
className?: string
|
||||
hideToolbar?: boolean
|
||||
rightToolbarContent?: React.ReactNode
|
||||
}
|
||||
|
||||
export function MarkdownEditor({
|
||||
@@ -101,6 +103,7 @@ export function MarkdownEditor({
|
||||
autoFocus = false,
|
||||
className = '',
|
||||
hideToolbar = false,
|
||||
rightToolbarContent,
|
||||
}: MarkdownEditorProps) {
|
||||
const initialConfig: InitialConfigType = {
|
||||
namespace: 'ShumaiWysiwygMarkdownEditor',
|
||||
@@ -126,13 +129,21 @@ export function MarkdownEditor({
|
||||
return (
|
||||
<div className={`shumai-editor-wrapper ${readOnly ? 'read-only' : ''} ${className}`}>
|
||||
<LexicalComposer initialConfig={initialConfig}>
|
||||
{!readOnly && !hideToolbar && <ToolbarPlugin />}
|
||||
<div className="shumai-editor-content-area">
|
||||
<RichTextPlugin
|
||||
contentEditable={<ContentEditable className="editor-input" />}
|
||||
placeholder={<div className="editor-placeholder">{placeholder}</div>}
|
||||
ErrorBoundary={LexicalErrorBoundary}
|
||||
/>
|
||||
{!readOnly && !hideToolbar ? (
|
||||
<ToolbarPlugin rightContent={rightToolbarContent} />
|
||||
) : rightToolbarContent ? (
|
||||
<div className="shumai-editor-toolbar flex items-center justify-end px-3 py-1.5 border-b">
|
||||
{rightToolbarContent}
|
||||
</div>
|
||||
) : null}
|
||||
<ScrollArea className="shumai-editor-content-area flex-1 min-h-0 w-full">
|
||||
<div className="relative min-h-full">
|
||||
<RichTextPlugin
|
||||
contentEditable={<ContentEditable className="editor-input" />}
|
||||
placeholder={<div className="editor-placeholder">{placeholder}</div>}
|
||||
ErrorBoundary={LexicalErrorBoundary}
|
||||
/>
|
||||
</div>
|
||||
<HistoryPlugin />
|
||||
<ListPlugin />
|
||||
<CheckListPlugin />
|
||||
@@ -141,7 +152,7 @@ export function MarkdownEditor({
|
||||
<MarkdownShortcutPlugin transformers={EDITOR_TRANSFORMERS} />
|
||||
<MarkdownSyncPlugin value={value} initialContent={initialContent} onChange={onChange} />
|
||||
{autoFocus && <AutoFocusPlugin />}
|
||||
</div>
|
||||
</ScrollArea>
|
||||
</LexicalComposer>
|
||||
</div>
|
||||
)
|
||||
|
||||
@@ -83,7 +83,7 @@ function getSelectedNode(selection: RangeSelection): TextNode | ElementNode {
|
||||
}
|
||||
}
|
||||
|
||||
export function ToolbarPlugin() {
|
||||
export function ToolbarPlugin({ rightContent }: { rightContent?: React.ReactNode } = {}) {
|
||||
const [editor] = useLexicalComposerContext()
|
||||
const [canUndo, setCanUndo] = useState(false)
|
||||
const [canRedo, setCanRedo] = useState(false)
|
||||
@@ -296,194 +296,200 @@ export function ToolbarPlugin() {
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="shumai-editor-toolbar">
|
||||
{/* Undo / Redo */}
|
||||
<button
|
||||
type="button"
|
||||
disabled={!canUndo}
|
||||
onMouseDown={(e) => e.preventDefault()}
|
||||
onClick={() => editor.dispatchCommand(UNDO_COMMAND, undefined)}
|
||||
title="Undo"
|
||||
aria-label="Undo"
|
||||
>
|
||||
<Undo2 className="h-4 w-4" />
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
disabled={!canRedo}
|
||||
onMouseDown={(e) => e.preventDefault()}
|
||||
onClick={() => editor.dispatchCommand(REDO_COMMAND, undefined)}
|
||||
title="Redo"
|
||||
aria-label="Redo"
|
||||
>
|
||||
<Redo2 className="h-4 w-4" />
|
||||
</button>
|
||||
<div className="shumai-editor-toolbar flex items-center justify-between">
|
||||
<div className="shumai-editor-toolbar-left flex items-center flex-wrap gap-1">
|
||||
{/* Undo / Redo */}
|
||||
<button
|
||||
type="button"
|
||||
disabled={!canUndo}
|
||||
onMouseDown={(e) => e.preventDefault()}
|
||||
onClick={() => editor.dispatchCommand(UNDO_COMMAND, undefined)}
|
||||
title="Undo"
|
||||
aria-label="Undo"
|
||||
>
|
||||
<Undo2 className="h-4 w-4" />
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
disabled={!canRedo}
|
||||
onMouseDown={(e) => e.preventDefault()}
|
||||
onClick={() => editor.dispatchCommand(REDO_COMMAND, undefined)}
|
||||
title="Redo"
|
||||
aria-label="Redo"
|
||||
>
|
||||
<Redo2 className="h-4 w-4" />
|
||||
</button>
|
||||
|
||||
<div className="toolbar-divider" />
|
||||
<div className="toolbar-divider" />
|
||||
|
||||
{/* Block Type Dropdown */}
|
||||
<select value={blockType} onChange={handleBlockTypeChange} aria-label="Block formatting">
|
||||
<option value="paragraph">Normal</option>
|
||||
<option value="h1">Heading 1</option>
|
||||
<option value="h2">Heading 2</option>
|
||||
<option value="h3">Heading 3</option>
|
||||
<option value="bullet">Bullet List</option>
|
||||
<option value="number">Numbered List</option>
|
||||
<option value="check">Check List</option>
|
||||
<option value="quote">Quote</option>
|
||||
<option value="code">Code Block</option>
|
||||
</select>
|
||||
{/* Block Type Dropdown */}
|
||||
<select value={blockType} onChange={handleBlockTypeChange} aria-label="Block formatting">
|
||||
<option value="paragraph">Normal</option>
|
||||
<option value="h1">Heading 1</option>
|
||||
<option value="h2">Heading 2</option>
|
||||
<option value="h3">Heading 3</option>
|
||||
<option value="bullet">Bullet List</option>
|
||||
<option value="number">Numbered List</option>
|
||||
<option value="check">Check List</option>
|
||||
<option value="quote">Quote</option>
|
||||
<option value="code">Code Block</option>
|
||||
</select>
|
||||
|
||||
<div className="toolbar-divider" />
|
||||
<div className="toolbar-divider" />
|
||||
|
||||
{/* Inline Styles */}
|
||||
<button
|
||||
type="button"
|
||||
className={isBold ? 'active' : ''}
|
||||
onMouseDown={(e) => e.preventDefault()}
|
||||
onClick={() => editor.dispatchCommand(FORMAT_TEXT_COMMAND, 'bold')}
|
||||
title="Bold (Ctrl+B)"
|
||||
aria-label="Bold"
|
||||
>
|
||||
<Bold className="h-4 w-4" />
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
className={isItalic ? 'active' : ''}
|
||||
onMouseDown={(e) => e.preventDefault()}
|
||||
onClick={() => editor.dispatchCommand(FORMAT_TEXT_COMMAND, 'italic')}
|
||||
title="Italic (Ctrl+I)"
|
||||
aria-label="Italic"
|
||||
>
|
||||
<Italic className="h-4 w-4" />
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
className={isUnderline ? 'active' : ''}
|
||||
onMouseDown={(e) => e.preventDefault()}
|
||||
onClick={() => editor.dispatchCommand(FORMAT_TEXT_COMMAND, 'underline')}
|
||||
title="Underline (Ctrl+U)"
|
||||
aria-label="Underline"
|
||||
>
|
||||
<Underline className="h-4 w-4" />
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
className={isStrikethrough ? 'active' : ''}
|
||||
onMouseDown={(e) => e.preventDefault()}
|
||||
onClick={() => editor.dispatchCommand(FORMAT_TEXT_COMMAND, 'strikethrough')}
|
||||
title="Strikethrough"
|
||||
aria-label="Strikethrough"
|
||||
>
|
||||
<Strikethrough className="h-4 w-4" />
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
className={isCode ? 'active' : ''}
|
||||
onMouseDown={(e) => e.preventDefault()}
|
||||
onClick={() => editor.dispatchCommand(FORMAT_TEXT_COMMAND, 'code')}
|
||||
title="Inline Code"
|
||||
aria-label="Inline Code"
|
||||
>
|
||||
<Code className="h-4 w-4" />
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
className={isLink ? 'active' : ''}
|
||||
onMouseDown={(e) => e.preventDefault()}
|
||||
onClick={insertLink}
|
||||
title="Insert Link"
|
||||
aria-label="Link"
|
||||
>
|
||||
<LinkIcon className="h-4 w-4" />
|
||||
</button>
|
||||
{/* Inline Styles */}
|
||||
<button
|
||||
type="button"
|
||||
className={isBold ? 'active' : ''}
|
||||
onMouseDown={(e) => e.preventDefault()}
|
||||
onClick={() => editor.dispatchCommand(FORMAT_TEXT_COMMAND, 'bold')}
|
||||
title="Bold (Ctrl+B)"
|
||||
aria-label="Bold"
|
||||
>
|
||||
<Bold className="h-4 w-4" />
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
className={isItalic ? 'active' : ''}
|
||||
onMouseDown={(e) => e.preventDefault()}
|
||||
onClick={() => editor.dispatchCommand(FORMAT_TEXT_COMMAND, 'italic')}
|
||||
title="Italic (Ctrl+I)"
|
||||
aria-label="Italic"
|
||||
>
|
||||
<Italic className="h-4 w-4" />
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
className={isUnderline ? 'active' : ''}
|
||||
onMouseDown={(e) => e.preventDefault()}
|
||||
onClick={() => editor.dispatchCommand(FORMAT_TEXT_COMMAND, 'underline')}
|
||||
title="Underline (Ctrl+U)"
|
||||
aria-label="Underline"
|
||||
>
|
||||
<Underline className="h-4 w-4" />
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
className={isStrikethrough ? 'active' : ''}
|
||||
onMouseDown={(e) => e.preventDefault()}
|
||||
onClick={() => editor.dispatchCommand(FORMAT_TEXT_COMMAND, 'strikethrough')}
|
||||
title="Strikethrough"
|
||||
aria-label="Strikethrough"
|
||||
>
|
||||
<Strikethrough className="h-4 w-4" />
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
className={isCode ? 'active' : ''}
|
||||
onMouseDown={(e) => e.preventDefault()}
|
||||
onClick={() => editor.dispatchCommand(FORMAT_TEXT_COMMAND, 'code')}
|
||||
title="Inline Code"
|
||||
aria-label="Inline Code"
|
||||
>
|
||||
<Code className="h-4 w-4" />
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
className={isLink ? 'active' : ''}
|
||||
onMouseDown={(e) => e.preventDefault()}
|
||||
onClick={insertLink}
|
||||
title="Insert Link"
|
||||
aria-label="Link"
|
||||
>
|
||||
<LinkIcon className="h-4 w-4" />
|
||||
</button>
|
||||
|
||||
<div className="toolbar-divider" />
|
||||
<div className="toolbar-divider" />
|
||||
|
||||
{/* Quick Insert / Block shortcuts */}
|
||||
<button
|
||||
type="button"
|
||||
className={blockType === 'h1' ? 'active' : ''}
|
||||
onMouseDown={(e) => e.preventDefault()}
|
||||
onClick={() => formatHeading('h1')}
|
||||
title="H1"
|
||||
aria-label="Heading 1"
|
||||
>
|
||||
<Heading1 className="h-4 w-4" />
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
className={blockType === 'h2' ? 'active' : ''}
|
||||
onMouseDown={(e) => e.preventDefault()}
|
||||
onClick={() => formatHeading('h2')}
|
||||
title="H2"
|
||||
aria-label="Heading 2"
|
||||
>
|
||||
<Heading2 className="h-4 w-4" />
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
className={blockType === 'h3' ? 'active' : ''}
|
||||
onMouseDown={(e) => e.preventDefault()}
|
||||
onClick={() => formatHeading('h3')}
|
||||
title="H3"
|
||||
aria-label="Heading 3"
|
||||
>
|
||||
<Heading3 className="h-4 w-4" />
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
className={blockType === 'bullet' ? 'active' : ''}
|
||||
onMouseDown={(e) => e.preventDefault()}
|
||||
onClick={formatBulletList}
|
||||
title="Bullet List"
|
||||
aria-label="Bullet List"
|
||||
>
|
||||
<List className="h-4 w-4" />
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
className={blockType === 'number' ? 'active' : ''}
|
||||
onMouseDown={(e) => e.preventDefault()}
|
||||
onClick={formatNumberedList}
|
||||
title="Numbered List"
|
||||
aria-label="Numbered List"
|
||||
>
|
||||
<ListOrdered className="h-4 w-4" />
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
className={blockType === 'check' ? 'active' : ''}
|
||||
onMouseDown={(e) => e.preventDefault()}
|
||||
onClick={formatCheckList}
|
||||
title="Check List"
|
||||
aria-label="Check List"
|
||||
>
|
||||
<ListTodo className="h-4 w-4" />
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
className={blockType === 'quote' ? 'active' : ''}
|
||||
onMouseDown={(e) => e.preventDefault()}
|
||||
onClick={formatQuote}
|
||||
title="Quote"
|
||||
aria-label="Quote"
|
||||
>
|
||||
<Quote className="h-4 w-4" />
|
||||
</button>
|
||||
{/* Quick Insert / Block shortcuts */}
|
||||
<button
|
||||
type="button"
|
||||
className={blockType === 'h1' ? 'active' : ''}
|
||||
onMouseDown={(e) => e.preventDefault()}
|
||||
onClick={() => formatHeading('h1')}
|
||||
title="H1"
|
||||
aria-label="Heading 1"
|
||||
>
|
||||
<Heading1 className="h-4 w-4" />
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
className={blockType === 'h2' ? 'active' : ''}
|
||||
onMouseDown={(e) => e.preventDefault()}
|
||||
onClick={() => formatHeading('h2')}
|
||||
title="H2"
|
||||
aria-label="Heading 2"
|
||||
>
|
||||
<Heading2 className="h-4 w-4" />
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
className={blockType === 'h3' ? 'active' : ''}
|
||||
onMouseDown={(e) => e.preventDefault()}
|
||||
onClick={() => formatHeading('h3')}
|
||||
title="H3"
|
||||
aria-label="Heading 3"
|
||||
>
|
||||
<Heading3 className="h-4 w-4" />
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
className={blockType === 'bullet' ? 'active' : ''}
|
||||
onMouseDown={(e) => e.preventDefault()}
|
||||
onClick={formatBulletList}
|
||||
title="Bullet List"
|
||||
aria-label="Bullet List"
|
||||
>
|
||||
<List className="h-4 w-4" />
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
className={blockType === 'number' ? 'active' : ''}
|
||||
onMouseDown={(e) => e.preventDefault()}
|
||||
onClick={formatNumberedList}
|
||||
title="Numbered List"
|
||||
aria-label="Numbered List"
|
||||
>
|
||||
<ListOrdered className="h-4 w-4" />
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
className={blockType === 'check' ? 'active' : ''}
|
||||
onMouseDown={(e) => e.preventDefault()}
|
||||
onClick={formatCheckList}
|
||||
title="Check List"
|
||||
aria-label="Check List"
|
||||
>
|
||||
<ListTodo className="h-4 w-4" />
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
className={blockType === 'quote' ? 'active' : ''}
|
||||
onMouseDown={(e) => e.preventDefault()}
|
||||
onClick={formatQuote}
|
||||
title="Quote"
|
||||
aria-label="Quote"
|
||||
>
|
||||
<Quote className="h-4 w-4" />
|
||||
</button>
|
||||
|
||||
<div className="toolbar-divider" />
|
||||
<div className="toolbar-divider" />
|
||||
|
||||
{/* Clear formatting */}
|
||||
<button
|
||||
type="button"
|
||||
onMouseDown={(e) => e.preventDefault()}
|
||||
onClick={clearFormatting}
|
||||
title="Clear Formatting"
|
||||
aria-label="Clear Formatting"
|
||||
>
|
||||
<RemoveFormatting className="h-4 w-4" />
|
||||
</button>
|
||||
{/* Clear formatting */}
|
||||
<button
|
||||
type="button"
|
||||
onMouseDown={(e) => e.preventDefault()}
|
||||
onClick={clearFormatting}
|
||||
title="Clear Formatting"
|
||||
aria-label="Clear Formatting"
|
||||
>
|
||||
<RemoveFormatting className="h-4 w-4" />
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{rightContent && (
|
||||
<div className="flex items-center gap-2 ml-auto flex-shrink-0">{rightContent}</div>
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -74,12 +74,7 @@ export function SortControl({ fields, sort, onSortChange, disabled }: SortContro
|
||||
return (
|
||||
<Popover>
|
||||
<PopoverTrigger asChild>
|
||||
<Button
|
||||
variant={sort ? 'secondary' : 'ghost'}
|
||||
size="sm"
|
||||
className="h-8"
|
||||
disabled={disabled}
|
||||
>
|
||||
<Button variant={sort ? 'secondary' : 'ghost'} size="sm" disabled={disabled}>
|
||||
{sort ? m.sorted_by({ field: currentField.label }) : m.sort_by()}
|
||||
</Button>
|
||||
</PopoverTrigger>
|
||||
|
||||
@@ -20,6 +20,7 @@ export function TopNav() {
|
||||
ancestorFolders,
|
||||
currentAsset,
|
||||
isRootFolder,
|
||||
customTerminalBreadcrumb,
|
||||
fileId,
|
||||
downloadInfo,
|
||||
versions,
|
||||
@@ -35,6 +36,7 @@ export function TopNav() {
|
||||
} = projectState
|
||||
|
||||
const isFileView = !!fileId
|
||||
const isAgentsMd = !!customTerminalBreadcrumb
|
||||
|
||||
const isShareConfig = !!shareId && !isFileView
|
||||
|
||||
@@ -105,8 +107,11 @@ export function TopNav() {
|
||||
ancestorFolders={ancestorFolders}
|
||||
currentAsset={currentAsset}
|
||||
isRootFolder={isRootFolder}
|
||||
displayStyle={isFileView || isShareConfig ? undefined : displayStyle}
|
||||
onDisplayStyleChange={isFileView || isShareConfig ? undefined : onDisplayStyleChange}
|
||||
customTerminalBreadcrumb={customTerminalBreadcrumb}
|
||||
displayStyle={isFileView || isShareConfig || isAgentsMd ? undefined : displayStyle}
|
||||
onDisplayStyleChange={
|
||||
isFileView || isShareConfig || isAgentsMd ? undefined : onDisplayStyleChange
|
||||
}
|
||||
isLeftSidebarCollapsed={isLeftSidebarCollapsed}
|
||||
onLeftSidebarToggle={onLeftSidebarToggle}
|
||||
isRightSidebarCollapsed={isRightSidebarCollapsed}
|
||||
|
||||
Reference in New Issue
Block a user