2026-04-08 21:28:28 +02:00
|
|
|
|
import { useMemo, type ComponentType, type SVGAttributes } from 'react'
|
2026-03-27 16:20:31 +01:00
|
|
|
|
import type { VaultEntry, NoteStatus } from '../types'
|
2026-02-22 10:18:05 +01:00
|
|
|
|
import { cn } from '@/lib/utils'
|
|
|
|
|
|
import {
|
|
|
|
|
|
Wrench, Flask, Target, ArrowsClockwise,
|
|
|
|
|
|
Users, CalendarBlank, Tag, FileText, StackSimple,
|
feat: show all files in folder view, open text files in raw editor, gray out binary
Vault scanner now includes all files (not just .md). Each VaultEntry has a
fileKind field ("markdown", "text", or "binary") that controls how the
frontend handles it:
- Folder view shows all file kinds; other views (All Notes, type sections)
continue to show only markdown files
- Text files (.yml, .json, .txt, .py, etc.) open in the raw CodeMirror editor
- Binary files (.png, .jpg, .pdf, etc.) appear grayed out and are not clickable
- Non-markdown files use filename as title, skip frontmatter parsing
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-02 17:38:09 +02:00
|
|
|
|
File, FileDashed,
|
2026-02-22 10:18:05 +01:00
|
|
|
|
} from '@phosphor-icons/react'
|
|
|
|
|
|
import { getTypeColor, getTypeLightColor } from '../utils/typeColors'
|
2026-04-08 21:28:28 +02:00
|
|
|
|
import { resolveIcon } from '../utils/iconRegistry'
|
2026-02-27 15:27:38 +01:00
|
|
|
|
import { relativeDate, getDisplayDate } from '../utils/noteListHelpers'
|
2026-04-07 21:09:06 +02:00
|
|
|
|
import { NoteTitleIcon } from './NoteTitleIcon'
|
2026-04-08 21:28:28 +02:00
|
|
|
|
import { PropertyChips } from './note-item/PropertyChips'
|
2026-02-22 10:18:05 +01:00
|
|
|
|
|
|
|
|
|
|
const TYPE_ICON_MAP: Record<string, ComponentType<SVGAttributes<SVGSVGElement>>> = {
|
|
|
|
|
|
Project: Wrench,
|
|
|
|
|
|
Experiment: Flask,
|
|
|
|
|
|
Responsibility: Target,
|
|
|
|
|
|
Procedure: ArrowsClockwise,
|
|
|
|
|
|
Person: Users,
|
|
|
|
|
|
Event: CalendarBlank,
|
|
|
|
|
|
Topic: Tag,
|
|
|
|
|
|
Type: StackSimple,
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-02-22 13:11:38 +01:00
|
|
|
|
// eslint-disable-next-line react-refresh/only-export-components -- utility co-located with component
|
2026-02-22 10:18:05 +01:00
|
|
|
|
export function getTypeIcon(isA: string | null, customIcon?: string | null): ComponentType<SVGAttributes<SVGSVGElement>> {
|
|
|
|
|
|
if (customIcon) return resolveIcon(customIcon)
|
|
|
|
|
|
return (isA && TYPE_ICON_MAP[isA]) || FileText
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-02-24 15:54:24 +01:00
|
|
|
|
const NOTE_STATUS_DOT: Record<string, { color: string; testId: string; title: string }> = {
|
2026-02-27 14:11:31 +01:00
|
|
|
|
pendingSave: { color: 'var(--accent-green)', testId: 'pending-save-indicator', title: 'Saving to disk…' },
|
2026-02-24 22:20:22 +01:00
|
|
|
|
new: { color: 'var(--accent-green)', testId: 'new-indicator', title: 'New (uncommitted)' },
|
2026-02-24 15:54:24 +01:00
|
|
|
|
modified: { color: 'var(--accent-orange)', testId: 'modified-indicator', title: 'Modified (uncommitted)' },
|
|
|
|
|
|
}
|
|
|
|
|
|
|
feat: keyboard-first navigation — menu bar shortcuts, note list nav, inspector Tab/Enter (#158)
* feat: keyboard-first navigation — menu bar shortcuts, note list nav, inspector Tab/Enter
- Add missing menu bar items: Archive Note (⌘E), Trash Note (⌘⌫),
Find in Vault (⌘⇧F), Go Back (⌘[), Go Forward (⌘])
- Wire new menu events through useMenuEvents → useAppCommands
- Note list: ↑↓ moves highlight, Enter opens selected note (useNoteListKeyboard hook)
- Inspector properties: Tab between rows, Enter to start editing
- Settings panel: auto-focus first input on open
- Extract StatusDot, StateBadge, noteItemStyle from NoteItem (reduces complexity)
- Extract dispatchActiveTabEvent/dispatchOptionalEvent from useMenuEvents
- 21 new tests (useNoteListKeyboard + useMenuEvents for new events)
- All 1275 frontend tests pass, 319 Rust tests pass
- CodeScene quality gates: passed (NoteItem improved from 22→18 complexity)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* design: keyboard-first-nav wireframes (note list highlight, menu shortcuts, inspector tab nav)
* test: add search.rs coverage for fallback branches (qmd_uri_to_vault_path, extract_clean_snippet)
* chore: exclude search.rs and lib.rs from coverage (qmd integration + Tauri setup code)
---------
Co-authored-by: Test <test@test.com>
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-01 19:32:15 +01:00
|
|
|
|
function StatusDot({ noteStatus }: { noteStatus: NoteStatus }) {
|
|
|
|
|
|
const dot = NOTE_STATUS_DOT[noteStatus]
|
|
|
|
|
|
if (!dot) return null
|
|
|
|
|
|
return (
|
|
|
|
|
|
<span
|
|
|
|
|
|
className={`mr-1.5 inline-block align-middle${noteStatus === 'pendingSave' ? ' tab-status-pulse' : ''}`}
|
|
|
|
|
|
style={{ width: 6, height: 6, borderRadius: '50%', background: dot.color, verticalAlign: 'middle' }}
|
|
|
|
|
|
data-testid={dot.testId}
|
|
|
|
|
|
title={dot.title}
|
|
|
|
|
|
/>
|
|
|
|
|
|
)
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-04-06 12:21:56 +02:00
|
|
|
|
function StateBadge({ archived }: { archived: boolean }) {
|
feat: keyboard-first navigation — menu bar shortcuts, note list nav, inspector Tab/Enter (#158)
* feat: keyboard-first navigation — menu bar shortcuts, note list nav, inspector Tab/Enter
- Add missing menu bar items: Archive Note (⌘E), Trash Note (⌘⌫),
Find in Vault (⌘⇧F), Go Back (⌘[), Go Forward (⌘])
- Wire new menu events through useMenuEvents → useAppCommands
- Note list: ↑↓ moves highlight, Enter opens selected note (useNoteListKeyboard hook)
- Inspector properties: Tab between rows, Enter to start editing
- Settings panel: auto-focus first input on open
- Extract StatusDot, StateBadge, noteItemStyle from NoteItem (reduces complexity)
- Extract dispatchActiveTabEvent/dispatchOptionalEvent from useMenuEvents
- 21 new tests (useNoteListKeyboard + useMenuEvents for new events)
- All 1275 frontend tests pass, 319 Rust tests pass
- CodeScene quality gates: passed (NoteItem improved from 22→18 complexity)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* design: keyboard-first-nav wireframes (note list highlight, menu shortcuts, inspector tab nav)
* test: add search.rs coverage for fallback branches (qmd_uri_to_vault_path, extract_clean_snippet)
* chore: exclude search.rs and lib.rs from coverage (qmd integration + Tauri setup code)
---------
Co-authored-by: Test <test@test.com>
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-01 19:32:15 +01:00
|
|
|
|
if (archived) {
|
|
|
|
|
|
return (
|
|
|
|
|
|
<span className="ml-1.5 inline-block align-middle text-muted-foreground" style={{ fontSize: 9, fontWeight: 500, background: 'var(--muted)', borderRadius: 4, padding: '1px 4px', verticalAlign: 'middle' }}>
|
|
|
|
|
|
ARCHIVED
|
|
|
|
|
|
</span>
|
|
|
|
|
|
)
|
|
|
|
|
|
}
|
|
|
|
|
|
return null
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-04-08 21:28:28 +02:00
|
|
|
|
const CHANGE_STATUS_DISPLAY: Record<string, { label: string; color: string; symbol: string }> = {
|
|
|
|
|
|
modified: { label: 'Modified', color: 'var(--accent-orange, #f59e0b)', symbol: '·' },
|
|
|
|
|
|
added: { label: 'Added', color: 'var(--accent-green, #22c55e)', symbol: '+' },
|
|
|
|
|
|
untracked: { label: 'Added', color: 'var(--accent-green, #22c55e)', symbol: '+' },
|
|
|
|
|
|
deleted: { label: 'Deleted', color: 'var(--destructive, #ef4444)', symbol: '−' },
|
|
|
|
|
|
renamed: { label: 'Renamed', color: 'var(--accent-orange, #f59e0b)', symbol: 'R' },
|
2026-04-04 12:52:54 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
2026-04-08 21:28:28 +02:00
|
|
|
|
function ChangeStatusIcon({ status }: { status: string }) {
|
|
|
|
|
|
const display = CHANGE_STATUS_DISPLAY[status] ?? CHANGE_STATUS_DISPLAY.modified
|
|
|
|
|
|
return (
|
|
|
|
|
|
<span
|
|
|
|
|
|
className="absolute right-3 top-2.5 text-xs font-bold"
|
|
|
|
|
|
style={{ color: display.color, fontSize: status === 'modified' ? 18 : 14 }}
|
|
|
|
|
|
title={display.label}
|
|
|
|
|
|
data-testid="change-status-icon"
|
|
|
|
|
|
>
|
|
|
|
|
|
{display.symbol}
|
|
|
|
|
|
</span>
|
|
|
|
|
|
)
|
2026-04-07 22:09:21 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
2026-04-08 21:28:28 +02:00
|
|
|
|
function noteItemClassName({
|
|
|
|
|
|
isBinary,
|
|
|
|
|
|
isSelected,
|
|
|
|
|
|
isMultiSelected,
|
|
|
|
|
|
isHighlighted,
|
|
|
|
|
|
}: {
|
|
|
|
|
|
isBinary: boolean
|
|
|
|
|
|
isSelected: boolean
|
|
|
|
|
|
isMultiSelected: boolean
|
|
|
|
|
|
isHighlighted: boolean
|
|
|
|
|
|
}) {
|
|
|
|
|
|
return cn(
|
|
|
|
|
|
'relative border-b border-[var(--border)] transition-colors',
|
|
|
|
|
|
isBinary ? 'cursor-default opacity-50' : 'cursor-pointer',
|
|
|
|
|
|
isSelected && !isMultiSelected && !isBinary && 'border-l-[3px]',
|
|
|
|
|
|
!isSelected && !isMultiSelected && !isBinary && 'hover:bg-muted',
|
|
|
|
|
|
isHighlighted && !isSelected && !isMultiSelected && !isBinary && 'bg-muted',
|
|
|
|
|
|
)
|
2026-04-04 12:52:54 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
2026-04-08 21:28:28 +02:00
|
|
|
|
function ChangeStatusContent({
|
|
|
|
|
|
entry,
|
|
|
|
|
|
changeStatus,
|
|
|
|
|
|
isSelected,
|
|
|
|
|
|
isDeletedChange,
|
|
|
|
|
|
}: {
|
|
|
|
|
|
entry: VaultEntry
|
|
|
|
|
|
changeStatus: NonNullable<NoteItemProps['changeStatus']>
|
|
|
|
|
|
isSelected: boolean
|
|
|
|
|
|
isDeletedChange: boolean
|
|
|
|
|
|
}) {
|
|
|
|
|
|
return (
|
|
|
|
|
|
<>
|
|
|
|
|
|
<ChangeStatusIcon status={changeStatus} />
|
|
|
|
|
|
<div className="pr-5">
|
|
|
|
|
|
<div
|
|
|
|
|
|
className={cn(
|
|
|
|
|
|
'truncate text-[13px] font-mono',
|
|
|
|
|
|
isSelected ? 'font-semibold' : 'font-normal',
|
|
|
|
|
|
isDeletedChange && 'text-muted-foreground line-through opacity-70',
|
|
|
|
|
|
)}
|
|
|
|
|
|
style={{ fontSize: 12 }}
|
|
|
|
|
|
>
|
|
|
|
|
|
{entry.filename}
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</>
|
|
|
|
|
|
)
|
2026-04-07 22:09:21 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
2026-04-08 21:28:28 +02:00
|
|
|
|
function StandardNoteContent({
|
2026-04-07 22:09:21 +02:00
|
|
|
|
entry,
|
2026-04-08 21:28:28 +02:00
|
|
|
|
isBinary,
|
|
|
|
|
|
noteStatus,
|
|
|
|
|
|
isSelected,
|
|
|
|
|
|
typeColor,
|
2026-04-07 22:09:21 +02:00
|
|
|
|
displayProps,
|
|
|
|
|
|
allEntries,
|
|
|
|
|
|
typeEntryMap,
|
2026-04-08 21:28:28 +02:00
|
|
|
|
onClickNote,
|
2026-04-07 22:09:21 +02:00
|
|
|
|
}: {
|
|
|
|
|
|
entry: VaultEntry
|
2026-04-08 21:28:28 +02:00
|
|
|
|
isBinary: boolean
|
|
|
|
|
|
noteStatus: NoteStatus
|
|
|
|
|
|
isSelected: boolean
|
|
|
|
|
|
typeColor: string
|
2026-04-07 22:09:21 +02:00
|
|
|
|
displayProps: string[]
|
|
|
|
|
|
allEntries: VaultEntry[]
|
|
|
|
|
|
typeEntryMap: Record<string, VaultEntry>
|
2026-04-08 21:28:28 +02:00
|
|
|
|
onClickNote: NoteItemProps['onClickNote']
|
2026-04-07 22:09:21 +02:00
|
|
|
|
}) {
|
2026-04-08 21:28:28 +02:00
|
|
|
|
const isNonMarkdown = !!entry.fileKind && entry.fileKind !== 'markdown'
|
|
|
|
|
|
const te = typeEntryMap[entry.isA ?? '']
|
|
|
|
|
|
const TypeIcon = useMemo(() => {
|
|
|
|
|
|
if (isNonMarkdown) return getFileKindIcon(entry.fileKind)
|
|
|
|
|
|
return getTypeIcon(entry.isA, te?.icon)
|
|
|
|
|
|
}, [entry.fileKind, entry.isA, isNonMarkdown, te?.icon])
|
2026-04-04 12:52:54 +02:00
|
|
|
|
|
|
|
|
|
|
return (
|
2026-04-08 21:28:28 +02:00
|
|
|
|
<>
|
|
|
|
|
|
{/* eslint-disable-next-line react-hooks/static-components -- icon lookup from static map, no internal state */}
|
|
|
|
|
|
<TypeIcon width={14} height={14} className="absolute right-3 top-2.5" style={{ color: typeColor }} data-testid="type-icon" />
|
|
|
|
|
|
<div className="pr-5">
|
|
|
|
|
|
<div className={cn('truncate text-[13px]', isBinary ? 'text-muted-foreground' : 'text-foreground', isSelected && !isBinary ? 'font-semibold' : 'font-medium')}>
|
|
|
|
|
|
{noteStatus !== 'clean' && !isBinary && <StatusDot noteStatus={noteStatus} />}
|
|
|
|
|
|
<NoteTitleIcon icon={entry.icon} size={15} className="mr-1" testId="note-title-icon" />
|
|
|
|
|
|
{entry.title}
|
|
|
|
|
|
{!isBinary && <StateBadge archived={entry.archived} />}
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
{entry.snippet && !isBinary && (
|
|
|
|
|
|
<div className="mt-0.5 text-[12px] leading-[1.5] text-muted-foreground" data-testid="note-snippet" style={{ display: '-webkit-box', WebkitLineClamp: 2, WebkitBoxOrient: 'vertical', overflow: 'hidden' }}>
|
|
|
|
|
|
{entry.snippet}
|
|
|
|
|
|
</div>
|
2026-04-04 12:52:54 +02:00
|
|
|
|
)}
|
2026-04-08 21:28:28 +02:00
|
|
|
|
{!isBinary && displayProps.length > 0 && (
|
|
|
|
|
|
<PropertyChips
|
|
|
|
|
|
entry={entry}
|
|
|
|
|
|
displayProps={displayProps}
|
|
|
|
|
|
allEntries={allEntries}
|
|
|
|
|
|
typeEntryMap={typeEntryMap}
|
|
|
|
|
|
onOpenNote={onClickNote}
|
|
|
|
|
|
/>
|
|
|
|
|
|
)}
|
|
|
|
|
|
{!isBinary && (
|
|
|
|
|
|
<div className="mt-0.5 text-[10px] text-muted-foreground">{relativeDate(getDisplayDate(entry))}</div>
|
|
|
|
|
|
)}
|
|
|
|
|
|
</>
|
2026-04-05 02:58:26 +02:00
|
|
|
|
)
|
|
|
|
|
|
}
|
|
|
|
|
|
|
feat: keyboard-first navigation — menu bar shortcuts, note list nav, inspector Tab/Enter (#158)
* feat: keyboard-first navigation — menu bar shortcuts, note list nav, inspector Tab/Enter
- Add missing menu bar items: Archive Note (⌘E), Trash Note (⌘⌫),
Find in Vault (⌘⇧F), Go Back (⌘[), Go Forward (⌘])
- Wire new menu events through useMenuEvents → useAppCommands
- Note list: ↑↓ moves highlight, Enter opens selected note (useNoteListKeyboard hook)
- Inspector properties: Tab between rows, Enter to start editing
- Settings panel: auto-focus first input on open
- Extract StatusDot, StateBadge, noteItemStyle from NoteItem (reduces complexity)
- Extract dispatchActiveTabEvent/dispatchOptionalEvent from useMenuEvents
- 21 new tests (useNoteListKeyboard + useMenuEvents for new events)
- All 1275 frontend tests pass, 319 Rust tests pass
- CodeScene quality gates: passed (NoteItem improved from 22→18 complexity)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* design: keyboard-first-nav wireframes (note list highlight, menu shortcuts, inspector tab nav)
* test: add search.rs coverage for fallback branches (qmd_uri_to_vault_path, extract_clean_snippet)
* chore: exclude search.rs and lib.rs from coverage (qmd integration + Tauri setup code)
---------
Co-authored-by: Test <test@test.com>
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-01 19:32:15 +01:00
|
|
|
|
function noteItemStyle(isSelected: boolean, isMultiSelected: boolean, typeColor: string, typeLightColor: string): React.CSSProperties {
|
|
|
|
|
|
const base: React.CSSProperties = { padding: isSelected && !isMultiSelected ? '14px 16px 14px 13px' : '14px 16px' }
|
|
|
|
|
|
if (isMultiSelected) base.backgroundColor = 'color-mix(in srgb, var(--accent-blue) 10%, transparent)'
|
|
|
|
|
|
else if (isSelected) { base.borderLeftColor = typeColor; base.backgroundColor = typeLightColor }
|
|
|
|
|
|
return base
|
|
|
|
|
|
}
|
|
|
|
|
|
|
feat: show all files in folder view, open text files in raw editor, gray out binary
Vault scanner now includes all files (not just .md). Each VaultEntry has a
fileKind field ("markdown", "text", or "binary") that controls how the
frontend handles it:
- Folder view shows all file kinds; other views (All Notes, type sections)
continue to show only markdown files
- Text files (.yml, .json, .txt, .py, etc.) open in the raw CodeMirror editor
- Binary files (.png, .jpg, .pdf, etc.) appear grayed out and are not clickable
- Non-markdown files use filename as title, skip frontmatter parsing
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-02 17:38:09 +02:00
|
|
|
|
function getFileKindIcon(fileKind: string | undefined): ComponentType<SVGAttributes<SVGSVGElement>> {
|
|
|
|
|
|
if (fileKind === 'text') return File
|
|
|
|
|
|
if (fileKind === 'binary') return FileDashed
|
|
|
|
|
|
return FileText
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-04-07 20:31:08 +02:00
|
|
|
|
function resolveDisplayProps(entry: VaultEntry, typeEntryMap: Record<string, VaultEntry>, displayPropsOverride?: string[] | null): string[] {
|
|
|
|
|
|
if (displayPropsOverride && displayPropsOverride.length > 0) return displayPropsOverride
|
|
|
|
|
|
return typeEntryMap[entry.isA ?? '']?.listPropertiesDisplay ?? []
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-04-08 21:28:28 +02:00
|
|
|
|
type NoteItemProps = {
|
2026-02-22 10:18:05 +01:00
|
|
|
|
entry: VaultEntry
|
|
|
|
|
|
isSelected: boolean
|
2026-02-27 15:14:21 +01:00
|
|
|
|
isMultiSelected?: boolean
|
feat: keyboard-first navigation — menu bar shortcuts, note list nav, inspector Tab/Enter (#158)
* feat: keyboard-first navigation — menu bar shortcuts, note list nav, inspector Tab/Enter
- Add missing menu bar items: Archive Note (⌘E), Trash Note (⌘⌫),
Find in Vault (⌘⇧F), Go Back (⌘[), Go Forward (⌘])
- Wire new menu events through useMenuEvents → useAppCommands
- Note list: ↑↓ moves highlight, Enter opens selected note (useNoteListKeyboard hook)
- Inspector properties: Tab between rows, Enter to start editing
- Settings panel: auto-focus first input on open
- Extract StatusDot, StateBadge, noteItemStyle from NoteItem (reduces complexity)
- Extract dispatchActiveTabEvent/dispatchOptionalEvent from useMenuEvents
- 21 new tests (useNoteListKeyboard + useMenuEvents for new events)
- All 1275 frontend tests pass, 319 Rust tests pass
- CodeScene quality gates: passed (NoteItem improved from 22→18 complexity)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* design: keyboard-first-nav wireframes (note list highlight, menu shortcuts, inspector tab nav)
* test: add search.rs coverage for fallback branches (qmd_uri_to_vault_path, extract_clean_snippet)
* chore: exclude search.rs and lib.rs from coverage (qmd integration + Tauri setup code)
---------
Co-authored-by: Test <test@test.com>
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-01 19:32:15 +01:00
|
|
|
|
isHighlighted?: boolean
|
2026-02-24 15:54:24 +01:00
|
|
|
|
noteStatus?: NoteStatus
|
2026-04-05 02:58:26 +02:00
|
|
|
|
/** When set, renders in Changes-view style: filename + change type icon */
|
|
|
|
|
|
changeStatus?: 'modified' | 'added' | 'deleted' | 'untracked' | 'renamed'
|
2026-02-22 10:18:05 +01:00
|
|
|
|
typeEntryMap: Record<string, VaultEntry>
|
2026-04-07 22:09:21 +02:00
|
|
|
|
allEntries?: VaultEntry[]
|
2026-04-07 20:31:08 +02:00
|
|
|
|
displayPropsOverride?: string[] | null
|
2026-02-23 20:12:54 +01:00
|
|
|
|
onClickNote: (entry: VaultEntry, e: React.MouseEvent) => void
|
2026-03-09 13:05:18 +01:00
|
|
|
|
onPrefetch?: (path: string) => void
|
2026-04-04 18:16:52 +02:00
|
|
|
|
onContextMenu?: (entry: VaultEntry, e: React.MouseEvent) => void
|
2026-04-08 21:28:28 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function createNoteItemClickHandler(
|
|
|
|
|
|
entry: VaultEntry,
|
|
|
|
|
|
isBinary: boolean,
|
|
|
|
|
|
onClickNote: NoteItemProps['onClickNote'],
|
|
|
|
|
|
) {
|
|
|
|
|
|
if (isBinary) {
|
|
|
|
|
|
return (event: React.MouseEvent) => {
|
|
|
|
|
|
event.preventDefault()
|
|
|
|
|
|
event.stopPropagation()
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
return (event: React.MouseEvent) => onClickNote(entry, event)
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
export function NoteItem({ entry, isSelected, isMultiSelected = false, isHighlighted = false, noteStatus = 'clean', changeStatus, typeEntryMap, allEntries, displayPropsOverride, onClickNote, onPrefetch, onContextMenu }: NoteItemProps) {
|
feat: show all files in folder view, open text files in raw editor, gray out binary
Vault scanner now includes all files (not just .md). Each VaultEntry has a
fileKind field ("markdown", "text", or "binary") that controls how the
frontend handles it:
- Folder view shows all file kinds; other views (All Notes, type sections)
continue to show only markdown files
- Text files (.yml, .json, .txt, .py, etc.) open in the raw CodeMirror editor
- Binary files (.png, .jpg, .pdf, etc.) appear grayed out and are not clickable
- Non-markdown files use filename as title, skip frontmatter parsing
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-02 17:38:09 +02:00
|
|
|
|
const isBinary = entry.fileKind === 'binary'
|
2026-04-07 20:09:04 +02:00
|
|
|
|
const isDeletedChange = changeStatus === 'deleted'
|
2026-02-22 10:18:05 +01:00
|
|
|
|
const te = typeEntryMap[entry.isA ?? '']
|
2026-04-07 20:31:08 +02:00
|
|
|
|
const displayProps = resolveDisplayProps(entry, typeEntryMap, displayPropsOverride)
|
feat: show all files in folder view, open text files in raw editor, gray out binary
Vault scanner now includes all files (not just .md). Each VaultEntry has a
fileKind field ("markdown", "text", or "binary") that controls how the
frontend handles it:
- Folder view shows all file kinds; other views (All Notes, type sections)
continue to show only markdown files
- Text files (.yml, .json, .txt, .py, etc.) open in the raw CodeMirror editor
- Binary files (.png, .jpg, .pdf, etc.) appear grayed out and are not clickable
- Non-markdown files use filename as title, skip frontmatter parsing
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-02 17:38:09 +02:00
|
|
|
|
const typeColor = isBinary ? 'var(--muted-foreground)' : getTypeColor(entry.isA ?? 'Note', te?.color)
|
2026-02-22 10:18:05 +01:00
|
|
|
|
const typeLightColor = getTypeLightColor(entry.isA ?? 'Note', te?.color)
|
2026-04-08 21:28:28 +02:00
|
|
|
|
const handleClick = createNoteItemClickHandler(entry, isBinary, onClickNote)
|
2026-02-22 10:18:05 +01:00
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
|
<div
|
2026-04-08 21:28:28 +02:00
|
|
|
|
className={noteItemClassName({ isBinary, isSelected, isMultiSelected, isHighlighted })}
|
feat: show all files in folder view, open text files in raw editor, gray out binary
Vault scanner now includes all files (not just .md). Each VaultEntry has a
fileKind field ("markdown", "text", or "binary") that controls how the
frontend handles it:
- Folder view shows all file kinds; other views (All Notes, type sections)
continue to show only markdown files
- Text files (.yml, .json, .txt, .py, etc.) open in the raw CodeMirror editor
- Binary files (.png, .jpg, .pdf, etc.) appear grayed out and are not clickable
- Non-markdown files use filename as title, skip frontmatter parsing
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-02 17:38:09 +02:00
|
|
|
|
style={isBinary ? { padding: '14px 16px' } : noteItemStyle(isSelected, isMultiSelected, typeColor, typeLightColor)}
|
|
|
|
|
|
onClick={handleClick}
|
2026-04-04 18:16:52 +02:00
|
|
|
|
onContextMenu={onContextMenu ? (e) => onContextMenu(entry, e) : undefined}
|
feat: show all files in folder view, open text files in raw editor, gray out binary
Vault scanner now includes all files (not just .md). Each VaultEntry has a
fileKind field ("markdown", "text", or "binary") that controls how the
frontend handles it:
- Folder view shows all file kinds; other views (All Notes, type sections)
continue to show only markdown files
- Text files (.yml, .json, .txt, .py, etc.) open in the raw CodeMirror editor
- Binary files (.png, .jpg, .pdf, etc.) appear grayed out and are not clickable
- Non-markdown files use filename as title, skip frontmatter parsing
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-02 17:38:09 +02:00
|
|
|
|
onMouseEnter={!isBinary && onPrefetch ? () => onPrefetch(entry.path) : undefined}
|
|
|
|
|
|
data-testid={isMultiSelected ? 'multi-selected-item' : isBinary ? 'binary-file-item' : undefined}
|
feat: keyboard-first navigation — menu bar shortcuts, note list nav, inspector Tab/Enter (#158)
* feat: keyboard-first navigation — menu bar shortcuts, note list nav, inspector Tab/Enter
- Add missing menu bar items: Archive Note (⌘E), Trash Note (⌘⌫),
Find in Vault (⌘⇧F), Go Back (⌘[), Go Forward (⌘])
- Wire new menu events through useMenuEvents → useAppCommands
- Note list: ↑↓ moves highlight, Enter opens selected note (useNoteListKeyboard hook)
- Inspector properties: Tab between rows, Enter to start editing
- Settings panel: auto-focus first input on open
- Extract StatusDot, StateBadge, noteItemStyle from NoteItem (reduces complexity)
- Extract dispatchActiveTabEvent/dispatchOptionalEvent from useMenuEvents
- 21 new tests (useNoteListKeyboard + useMenuEvents for new events)
- All 1275 frontend tests pass, 319 Rust tests pass
- CodeScene quality gates: passed (NoteItem improved from 22→18 complexity)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* design: keyboard-first-nav wireframes (note list highlight, menu shortcuts, inspector tab nav)
* test: add search.rs coverage for fallback branches (qmd_uri_to_vault_path, extract_clean_snippet)
* chore: exclude search.rs and lib.rs from coverage (qmd integration + Tauri setup code)
---------
Co-authored-by: Test <test@test.com>
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-01 19:32:15 +01:00
|
|
|
|
data-highlighted={isHighlighted || undefined}
|
2026-04-07 20:09:04 +02:00
|
|
|
|
data-note-path={entry.path}
|
|
|
|
|
|
data-change-status={changeStatus}
|
feat: show all files in folder view, open text files in raw editor, gray out binary
Vault scanner now includes all files (not just .md). Each VaultEntry has a
fileKind field ("markdown", "text", or "binary") that controls how the
frontend handles it:
- Folder view shows all file kinds; other views (All Notes, type sections)
continue to show only markdown files
- Text files (.yml, .json, .txt, .py, etc.) open in the raw CodeMirror editor
- Binary files (.png, .jpg, .pdf, etc.) appear grayed out and are not clickable
- Non-markdown files use filename as title, skip frontmatter parsing
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-02 17:38:09 +02:00
|
|
|
|
title={isBinary ? 'Cannot open this file type' : undefined}
|
2026-02-22 10:18:05 +01:00
|
|
|
|
>
|
2026-04-05 02:58:26 +02:00
|
|
|
|
{changeStatus ? (
|
2026-04-08 21:28:28 +02:00
|
|
|
|
<ChangeStatusContent
|
|
|
|
|
|
entry={entry}
|
|
|
|
|
|
changeStatus={changeStatus}
|
|
|
|
|
|
isSelected={isSelected}
|
|
|
|
|
|
isDeletedChange={isDeletedChange}
|
|
|
|
|
|
/>
|
2026-04-05 02:58:26 +02:00
|
|
|
|
) : (
|
2026-04-08 21:28:28 +02:00
|
|
|
|
<StandardNoteContent
|
|
|
|
|
|
entry={entry}
|
|
|
|
|
|
isBinary={isBinary}
|
|
|
|
|
|
noteStatus={noteStatus}
|
|
|
|
|
|
isSelected={isSelected}
|
|
|
|
|
|
typeColor={typeColor}
|
|
|
|
|
|
displayProps={displayProps}
|
|
|
|
|
|
allEntries={allEntries ?? [entry]}
|
|
|
|
|
|
typeEntryMap={typeEntryMap}
|
|
|
|
|
|
onClickNote={onClickNote}
|
|
|
|
|
|
/>
|
feat: show all files in folder view, open text files in raw editor, gray out binary
Vault scanner now includes all files (not just .md). Each VaultEntry has a
fileKind field ("markdown", "text", or "binary") that controls how the
frontend handles it:
- Folder view shows all file kinds; other views (All Notes, type sections)
continue to show only markdown files
- Text files (.yml, .json, .txt, .py, etc.) open in the raw CodeMirror editor
- Binary files (.png, .jpg, .pdf, etc.) appear grayed out and are not clickable
- Non-markdown files use filename as title, skip frontmatter parsing
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-02 17:38:09 +02:00
|
|
|
|
)}
|
2026-02-22 10:18:05 +01:00
|
|
|
|
</div>
|
|
|
|
|
|
)
|
|
|
|
|
|
}
|