Fix remaining notes bugs: breadcrumb root navigation and line break preservation

- Add root breadcrumb item for easy navigation back to notes home
- Add onClearActiveFile callback to deselect active file when clicking root
- Enable line breaks preservation in markdown (breaks: true) to fix forced line breaks when pasting text
- Root breadcrumb now allows users to return to notes tree view

Co-authored-by: DeJeune <67425183+DeJeune@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot] 2025-10-23 18:05:22 +00:00
parent 6d259bb5bd
commit d8bbd3fdb9
3 changed files with 30 additions and 5 deletions

View File

@ -16,7 +16,14 @@ import { menuItems } from './MenuConfig'
const logger = loggerService.withContext('HeaderNavbar')
const HeaderNavbar = ({ notesTree, getCurrentNoteContent, onToggleStar, onExpandPath, onRenameNode }) => {
const HeaderNavbar = ({
notesTree,
getCurrentNoteContent,
onToggleStar,
onExpandPath,
onRenameNode,
onClearActiveFile
}) => {
const { showWorkspace, toggleShowWorkspace } = useShowWorkspace()
const { activeNode } = useActiveNode(notesTree)
const [breadcrumbItems, setBreadcrumbItems] = useState<
@ -54,11 +61,14 @@ const HeaderNavbar = ({ notesTree, getCurrentNoteContent, onToggleStar, onExpand
const handleBreadcrumbClick = useCallback(
(item: { treePath: string; isFolder: boolean }) => {
if (item.isFolder && onExpandPath) {
if (item.treePath === '/' && onClearActiveFile) {
// Clicking root clears the active file and returns to tree view
onClearActiveFile()
} else if (item.isFolder && onExpandPath) {
onExpandPath(item.treePath)
}
},
[onExpandPath]
[onExpandPath, onClearActiveFile]
)
const handleTitleChange = useCallback((e: React.ChangeEvent<HTMLInputElement>) => {
@ -166,8 +176,18 @@ const HeaderNavbar = ({ notesTree, getCurrentNoteContent, onToggleStar, onExpand
}
})
// Add root directory as the first breadcrumb item if not already at root
if (pathParts.length > 0) {
items.unshift({
key: 'root',
title: t('notes.root_directory') || 'Notes',
treePath: '/',
isFolder: true
})
}
setBreadcrumbItems(items)
}, [activeNode, notesTree])
}, [activeNode, notesTree, t])
return (
<NavbarHeader

View File

@ -777,6 +777,10 @@ const NotesPage: FC = () => {
[notesTree, updateExpandedPaths]
)
const handleClearActiveFile = useCallback(() => {
dispatch(setActiveFilePath(undefined))
}, [dispatch])
const getCurrentNoteContent = useCallback(() => {
if (settings.defaultEditMode === 'source') {
return currentContent
@ -870,6 +874,7 @@ const NotesPage: FC = () => {
onToggleStar={handleToggleStar}
onExpandPath={handleExpandPath}
onRenameNode={handleRenameNode}
onClearActiveFile={handleClearActiveFile}
/>
<NotesEditor
activeNodeId={activeNode?.id}

View File

@ -81,7 +81,7 @@ export interface TaskListOptions {
const md = new MarkdownIt({
html: true, // Enable HTML tags in source
xhtmlOut: true, // Use '>' for single tags (<br> instead of <br />)
breaks: false,
breaks: true, // Preserve line breaks when pasting text
linkify: false, // Autoconvert URL-like text to links
typographer: false // Enable smartypants and other sweet transforms
})