* refactor: decompose Editor.tsx into focused subcomponents and hooks Extract from the monolithic Editor component (cc=35, 213 LoC, score 7.82): - useDiffMode hook: diff state + toggle/commit-diff handlers - useEditorFocus hook: new-note focus event listener - editorSchema: WikiLink spec + BlockNote schema (module-level) - SingleEditorView: BlockNote editor + suggestion menus - EditorContent: breadcrumb bar + diff/editor/loading views - EditorRightPanel: AI chat / Inspector panel switching - suggestionEnrichment util: shared enrichment logic (eliminates duplication) Editor.tsx is now 10.0 code health (was 7.82). All 25 existing tests pass. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * refactor: extract standalone functions from NoteList and Sidebar to reduce cc NoteList: extract createNoteStatusResolver and toggleSetMember from NoteListInner (cc 13→8, score 9.04→9.38). Sidebar: extract applyCustomization from Sidebar (cc 10→7, score 9.09→10.0). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * test: add tests for useDiffMode, useEditorFocus, and suggestionEnrichment Cover extracted hook/utility logic: diff toggle/reset, editor focus event listener with adaptive timing, and suggestion item enrichment pipeline. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * docs: update architecture for editor decomposition and write .claude-done Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
68 lines
2.1 KiB
TypeScript
68 lines
2.1 KiB
TypeScript
import type { VaultEntry, GitCommit } from '../types'
|
|
import { Inspector, type FrontmatterValue } from './Inspector'
|
|
import { AIChatPanel } from './AIChatPanel'
|
|
|
|
interface EditorRightPanelProps {
|
|
showAIChat?: boolean
|
|
inspectorCollapsed: boolean
|
|
inspectorWidth: number
|
|
inspectorEntry: VaultEntry | null
|
|
inspectorContent: string | null
|
|
entries: VaultEntry[]
|
|
allContent: Record<string, string>
|
|
gitHistory: GitCommit[]
|
|
onToggleInspector: () => void
|
|
onToggleAIChat?: () => void
|
|
onNavigateWikilink: (target: string) => void
|
|
onViewCommitDiff: (commitHash: string) => Promise<void>
|
|
onUpdateFrontmatter?: (path: string, key: string, value: FrontmatterValue) => Promise<void>
|
|
onDeleteProperty?: (path: string, key: string) => Promise<void>
|
|
onAddProperty?: (path: string, key: string, value: FrontmatterValue) => Promise<void>
|
|
}
|
|
|
|
export function EditorRightPanel({
|
|
showAIChat, inspectorCollapsed, inspectorWidth,
|
|
inspectorEntry, inspectorContent, entries, allContent, gitHistory,
|
|
onToggleInspector, onToggleAIChat, onNavigateWikilink, onViewCommitDiff,
|
|
onUpdateFrontmatter, onDeleteProperty, onAddProperty,
|
|
}: EditorRightPanelProps) {
|
|
if (showAIChat) {
|
|
return (
|
|
<div
|
|
className="shrink-0 flex flex-col min-h-0"
|
|
style={{ width: inspectorWidth, height: '100%' }}
|
|
>
|
|
<AIChatPanel
|
|
entry={inspectorEntry}
|
|
allContent={allContent}
|
|
entries={entries}
|
|
onClose={() => onToggleAIChat?.()}
|
|
/>
|
|
</div>
|
|
)
|
|
}
|
|
|
|
if (inspectorCollapsed) return null
|
|
|
|
return (
|
|
<div
|
|
className="shrink-0 flex flex-col min-h-0"
|
|
style={{ width: inspectorWidth, height: '100%' }}
|
|
>
|
|
<Inspector
|
|
collapsed={inspectorCollapsed}
|
|
onToggle={onToggleInspector}
|
|
entry={inspectorEntry}
|
|
content={inspectorContent}
|
|
entries={entries}
|
|
gitHistory={gitHistory}
|
|
onNavigate={onNavigateWikilink}
|
|
onViewCommitDiff={onViewCommitDiff}
|
|
onUpdateFrontmatter={onUpdateFrontmatter}
|
|
onDeleteProperty={onDeleteProperty}
|
|
onAddProperty={onAddProperty}
|
|
/>
|
|
</div>
|
|
)
|
|
}
|