2026-03-08 22:15:08 +01:00
|
|
|
import { useRef, useEffect, useCallback, memo } from 'react'
|
2026-03-18 15:42:48 +01:00
|
|
|
import { useEditorTabSwap } from '../hooks/useEditorTabSwap'
|
refactor: decompose Editor.tsx, NoteList.tsx, Sidebar.tsx — CodeScene hotspots (#126)
* 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>
2026-02-27 15:27:25 +01:00
|
|
|
import { useCreateBlockNote } from '@blocknote/react'
|
2026-02-15 19:14:55 +01:00
|
|
|
import '@blocknote/mantine/style.css'
|
refactor: decompose Editor.tsx, NoteList.tsx, Sidebar.tsx — CodeScene hotspots (#126)
* 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>
2026-02-27 15:27:25 +01:00
|
|
|
import { uploadImageFile } from '../hooks/useImageDrop'
|
2026-02-24 15:54:24 +01:00
|
|
|
import type { VaultEntry, GitCommit, NoteStatus } from '../types'
|
2026-03-04 19:53:46 +01:00
|
|
|
import type { NoteListItem } from '../utils/ai-context'
|
refactor: decompose Editor.tsx, NoteList.tsx, Sidebar.tsx — CodeScene hotspots (#126)
* 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>
2026-02-27 15:27:25 +01:00
|
|
|
import type { FrontmatterValue } from './Inspector'
|
2026-02-17 11:03:23 +01:00
|
|
|
import { ResizeHandle } from './ResizeHandle'
|
refactor: decompose Editor.tsx, NoteList.tsx, Sidebar.tsx — CodeScene hotspots (#126)
* 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>
2026-02-27 15:27:25 +01:00
|
|
|
import { useDiffMode } from '../hooks/useDiffMode'
|
2026-03-02 18:38:25 +01:00
|
|
|
import { useRawMode } from '../hooks/useRawMode'
|
refactor: decompose Editor.tsx, NoteList.tsx, Sidebar.tsx — CodeScene hotspots (#126)
* 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>
2026-02-27 15:27:25 +01:00
|
|
|
import { useEditorFocus } from '../hooks/useEditorFocus'
|
|
|
|
|
import { EditorRightPanel } from './EditorRightPanel'
|
|
|
|
|
import { EditorContent } from './EditorContent'
|
|
|
|
|
import { schema } from './editorSchema'
|
2026-02-14 18:22:42 +01:00
|
|
|
import './Editor.css'
|
2026-02-16 08:04:06 +01:00
|
|
|
import './EditorTheme.css'
|
2026-02-14 18:22:42 +01:00
|
|
|
|
2026-02-14 20:15:44 +01:00
|
|
|
interface Tab {
|
|
|
|
|
entry: VaultEntry
|
2026-02-14 20:07:23 +01:00
|
|
|
content: string
|
2026-02-14 20:15:44 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
interface EditorProps {
|
|
|
|
|
tabs: Tab[]
|
|
|
|
|
activeTabPath: string | null
|
2026-02-15 19:50:23 +01:00
|
|
|
entries: VaultEntry[]
|
2026-02-14 20:30:45 +01:00
|
|
|
onNavigateWikilink: (target: string) => void
|
2026-02-15 12:58:00 +01:00
|
|
|
onLoadDiff?: (path: string) => Promise<string>
|
2026-02-21 22:27:18 +01:00
|
|
|
onLoadDiffAtCommit?: (path: string, commitHash: string) => Promise<string>
|
2026-02-24 15:54:24 +01:00
|
|
|
getNoteStatus?: (path: string) => NoteStatus
|
2026-02-17 11:03:23 +01:00
|
|
|
onCreateNote?: () => void
|
|
|
|
|
inspectorCollapsed: boolean
|
|
|
|
|
onToggleInspector: () => void
|
|
|
|
|
inspectorWidth: number
|
|
|
|
|
onInspectorResize: (delta: number) => void
|
|
|
|
|
inspectorEntry: VaultEntry | null
|
|
|
|
|
inspectorContent: string | null
|
|
|
|
|
gitHistory: GitCommit[]
|
|
|
|
|
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>
|
2026-03-11 21:24:57 +01:00
|
|
|
onCreateAndOpenNote?: (title: string) => Promise<boolean>
|
2026-03-31 11:07:39 +02:00
|
|
|
onInitializeProperties?: (path: string) => void
|
2026-02-20 16:06:51 +01:00
|
|
|
showAIChat?: boolean
|
|
|
|
|
onToggleAIChat?: () => void
|
2026-02-21 10:07:02 +01:00
|
|
|
vaultPath?: string
|
2026-03-04 19:53:46 +01:00
|
|
|
noteList?: NoteListItem[]
|
|
|
|
|
noteListFilter?: { type: string | null; query: string }
|
2026-04-02 14:44:23 +02:00
|
|
|
onToggleFavorite?: (path: string) => void
|
2026-04-04 20:54:16 +02:00
|
|
|
onToggleOrganized?: (path: string) => void
|
2026-03-03 01:37:25 +01:00
|
|
|
onDeleteNote?: (path: string) => void
|
2026-02-21 18:45:25 +01:00
|
|
|
onArchiveNote?: (path: string) => void
|
|
|
|
|
onUnarchiveNote?: (path: string) => void
|
2026-02-23 14:48:21 +01:00
|
|
|
onContentChange?: (path: string, content: string) => void
|
2026-03-02 18:38:25 +01:00
|
|
|
onSave?: () => void
|
2026-03-18 15:42:48 +01:00
|
|
|
/** Called when the user edits the title in TitleField. */
|
2026-02-28 10:57:30 +01:00
|
|
|
onTitleSync?: (path: string, newTitle: string) => void
|
2026-02-25 19:39:12 +01:00
|
|
|
canGoBack?: boolean
|
|
|
|
|
canGoForward?: boolean
|
|
|
|
|
onGoBack?: () => void
|
|
|
|
|
onGoForward?: () => void
|
2026-02-28 20:19:03 +01:00
|
|
|
leftPanelsCollapsed?: boolean
|
2026-03-02 18:38:25 +01:00
|
|
|
/** Mutable ref that Editor registers its raw-mode toggle into, for command palette access. */
|
|
|
|
|
rawToggleRef?: React.MutableRefObject<() => void>
|
2026-03-03 02:00:48 +01:00
|
|
|
/** Mutable ref that Editor registers its diff-mode toggle into, for command palette access. */
|
|
|
|
|
diffToggleRef?: React.MutableRefObject<() => void>
|
2026-03-05 12:12:12 +01:00
|
|
|
onFileCreated?: (relativePath: string) => void
|
|
|
|
|
onFileModified?: (relativePath: string) => void
|
2026-03-07 14:19:41 +01:00
|
|
|
onVaultChanged?: () => void
|
2026-03-19 09:51:06 +01:00
|
|
|
/** Whether the active note has a merge conflict. */
|
|
|
|
|
isConflicted?: boolean
|
|
|
|
|
/** Resolve conflict by keeping the local version. */
|
|
|
|
|
onKeepMine?: (path: string) => void
|
|
|
|
|
/** Resolve conflict by keeping the remote version. */
|
|
|
|
|
onKeepTheirs?: (path: string) => void
|
2026-03-02 18:38:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function useEditorModeExclusion({
|
2026-03-03 02:00:48 +01:00
|
|
|
diffMode, rawMode, handleToggleDiff, handleToggleRaw, rawToggleRef, diffToggleRef,
|
2026-03-02 18:38:25 +01:00
|
|
|
}: {
|
|
|
|
|
diffMode: boolean
|
|
|
|
|
rawMode: boolean
|
|
|
|
|
handleToggleDiff: () => void | Promise<void>
|
|
|
|
|
handleToggleRaw: () => void
|
|
|
|
|
rawToggleRef?: React.MutableRefObject<() => void>
|
2026-03-03 02:00:48 +01:00
|
|
|
diffToggleRef?: React.MutableRefObject<() => void>
|
2026-03-02 18:38:25 +01:00
|
|
|
}) {
|
|
|
|
|
const handleToggleDiffExclusive = useCallback(async () => {
|
|
|
|
|
if (!diffMode && rawMode) handleToggleRaw()
|
|
|
|
|
await handleToggleDiff()
|
|
|
|
|
}, [diffMode, rawMode, handleToggleDiff, handleToggleRaw])
|
|
|
|
|
|
|
|
|
|
const handleToggleRawExclusive = useCallback(() => {
|
|
|
|
|
if (!rawMode && diffMode) handleToggleDiff()
|
|
|
|
|
handleToggleRaw()
|
|
|
|
|
}, [rawMode, diffMode, handleToggleDiff, handleToggleRaw])
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
if (rawToggleRef) rawToggleRef.current = handleToggleRawExclusive
|
|
|
|
|
}, [rawToggleRef, handleToggleRawExclusive])
|
|
|
|
|
|
2026-03-03 02:00:48 +01:00
|
|
|
useEffect(() => {
|
|
|
|
|
if (diffToggleRef) diffToggleRef.current = handleToggleDiffExclusive
|
|
|
|
|
}, [diffToggleRef, handleToggleDiffExclusive])
|
|
|
|
|
|
2026-03-02 18:38:25 +01:00
|
|
|
return { handleToggleDiffExclusive, handleToggleRawExclusive }
|
2026-02-14 20:07:23 +01:00
|
|
|
}
|
|
|
|
|
|
refactor: decompose Editor.tsx, NoteList.tsx, Sidebar.tsx — CodeScene hotspots (#126)
* 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>
2026-02-27 15:27:25 +01:00
|
|
|
function EditorEmptyState() {
|
2026-02-15 19:14:55 +01:00
|
|
|
return (
|
refactor: decompose Editor.tsx, NoteList.tsx, Sidebar.tsx — CodeScene hotspots (#126)
* 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>
2026-02-27 15:27:25 +01:00
|
|
|
<div className="flex flex-1 flex-col items-center justify-center gap-2 text-center text-muted-foreground">
|
|
|
|
|
<p className="m-0 text-[15px]">Select a note to start editing</p>
|
|
|
|
|
<span className="text-xs text-muted-foreground">Cmd+P to search · Cmd+N to create</span>
|
2026-02-15 19:14:55 +01:00
|
|
|
</div>
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-17 12:07:33 +01:00
|
|
|
interface EditorSetupParams {
|
|
|
|
|
tabs: Tab[]
|
|
|
|
|
activeTabPath: string | null
|
|
|
|
|
vaultPath?: string
|
|
|
|
|
onContentChange?: (path: string, content: string) => void
|
|
|
|
|
onLoadDiff?: (path: string) => Promise<string>
|
|
|
|
|
onLoadDiffAtCommit?: (path: string, commitHash: string) => Promise<string>
|
|
|
|
|
getNoteStatus?: (path: string) => NoteStatus
|
|
|
|
|
rawToggleRef?: React.MutableRefObject<() => void>
|
|
|
|
|
diffToggleRef?: React.MutableRefObject<() => void>
|
|
|
|
|
}
|
2026-02-28 10:57:30 +01:00
|
|
|
|
2026-03-17 12:07:33 +01:00
|
|
|
function useRawModeWithFlush(
|
|
|
|
|
activeTabPath: string | null,
|
|
|
|
|
onContentChange?: (path: string, content: string) => void,
|
|
|
|
|
) {
|
2026-03-11 22:14:20 +01:00
|
|
|
const rawLatestContentRef = useRef<string | null>(null)
|
|
|
|
|
|
|
|
|
|
const handleBeforeRawEnd = useCallback(() => {
|
|
|
|
|
if (rawLatestContentRef.current != null && activeTabPath) {
|
|
|
|
|
onContentChange?.(activeTabPath, rawLatestContentRef.current)
|
|
|
|
|
}
|
|
|
|
|
rawLatestContentRef.current = null
|
|
|
|
|
}, [activeTabPath, onContentChange])
|
|
|
|
|
|
|
|
|
|
const { rawMode, handleToggleRaw } = useRawMode({
|
|
|
|
|
activeTabPath, onBeforeRawEnd: handleBeforeRawEnd,
|
|
|
|
|
})
|
|
|
|
|
|
2026-03-17 12:07:33 +01:00
|
|
|
return { rawMode, handleToggleRaw, rawLatestContentRef }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function useEditorSetup({
|
2026-03-18 15:42:48 +01:00
|
|
|
tabs, activeTabPath, vaultPath, onContentChange,
|
|
|
|
|
onLoadDiff, onLoadDiffAtCommit, getNoteStatus,
|
2026-03-17 12:07:33 +01:00
|
|
|
rawToggleRef, diffToggleRef,
|
|
|
|
|
}: EditorSetupParams) {
|
|
|
|
|
const vaultPathRef = useRef(vaultPath)
|
|
|
|
|
useEffect(() => { vaultPathRef.current = vaultPath }, [vaultPath])
|
|
|
|
|
|
|
|
|
|
const editor = useCreateBlockNote({
|
|
|
|
|
schema,
|
|
|
|
|
uploadFile: (file: File) => uploadImageFile(file, vaultPathRef.current),
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
const activeTab = tabs.find((t) => t.entry.path === activeTabPath) ?? null
|
|
|
|
|
|
|
|
|
|
const { rawMode, handleToggleRaw, rawLatestContentRef } = useRawModeWithFlush(
|
|
|
|
|
activeTabPath, onContentChange,
|
|
|
|
|
)
|
|
|
|
|
|
2026-02-28 10:57:30 +01:00
|
|
|
const { handleEditorChange, editorMountedRef } = useEditorTabSwap({
|
2026-03-18 15:42:48 +01:00
|
|
|
tabs, activeTabPath, editor, onContentChange, rawMode,
|
2026-02-28 10:57:30 +01:00
|
|
|
})
|
refactor: decompose Editor.tsx, NoteList.tsx, Sidebar.tsx — CodeScene hotspots (#126)
* 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>
2026-02-27 15:27:25 +01:00
|
|
|
useEditorFocus(editor, editorMountedRef)
|
2026-02-17 17:38:57 +01:00
|
|
|
|
refactor: decompose Editor.tsx, NoteList.tsx, Sidebar.tsx — CodeScene hotspots (#126)
* 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>
2026-02-27 15:27:25 +01:00
|
|
|
const { diffMode, diffContent, diffLoading, handleToggleDiff, handleViewCommitDiff } = useDiffMode({
|
|
|
|
|
activeTabPath, onLoadDiff, onLoadDiffAtCommit,
|
|
|
|
|
})
|
2026-03-02 18:38:25 +01:00
|
|
|
|
|
|
|
|
const { handleToggleDiffExclusive, handleToggleRawExclusive } = useEditorModeExclusion({
|
2026-03-03 02:00:48 +01:00
|
|
|
diffMode, rawMode, handleToggleDiff, handleToggleRaw, rawToggleRef, diffToggleRef,
|
2026-03-02 18:38:25 +01:00
|
|
|
})
|
|
|
|
|
|
2026-02-17 17:32:57 +01:00
|
|
|
const isLoadingNewTab = activeTabPath !== null && !activeTab
|
2026-02-24 15:54:24 +01:00
|
|
|
const activeStatus = activeTab ? getNoteStatus?.(activeTab.entry.path) ?? 'clean' : 'clean'
|
refactor: decompose Editor.tsx, NoteList.tsx, Sidebar.tsx — CodeScene hotspots (#126)
* 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>
2026-02-27 15:27:25 +01:00
|
|
|
const showDiffToggle = !!(activeTab && (diffMode || activeStatus === 'modified'))
|
2026-02-17 11:03:23 +01:00
|
|
|
|
2026-03-17 12:07:33 +01:00
|
|
|
return {
|
|
|
|
|
editor, activeTab, rawLatestContentRef,
|
|
|
|
|
rawMode, diffMode, diffContent, diffLoading,
|
|
|
|
|
handleToggleDiffExclusive, handleToggleRawExclusive,
|
2026-03-18 15:42:48 +01:00
|
|
|
handleEditorChange, handleViewCommitDiff,
|
2026-03-17 12:07:33 +01:00
|
|
|
isLoadingNewTab, activeStatus, showDiffToggle,
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export const Editor = memo(function Editor(props: EditorProps) {
|
|
|
|
|
const {
|
refactor: remove tab bar — single note open at a time
Replace the multi-tab model with single-note navigation. One note is
open at a time; clicking any note (sidebar, wikilink, relationship)
replaces the current note in the editor. Back/Forward history still
works via Cmd+[/].
Removed: TabBar component, useClosedTabHistory, tab reorder/close/
reopen logic, Cmd+W/Cmd+Shift+T shortcuts, Close Tab and Reopen
Closed Tab menu items, tabLayout utility, and all related tests.
Simplified: useTabManagement (single-note), useAppNavigation (no tab
lookup), useKeyboardNavigation (note nav only), useNoteCreation (no
close-tab cleanup), useDeleteActions (deselect instead of close tab),
Editor (no TabBar render), Rust menu (removed 2 menu items).
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-24 17:24:49 +01:00
|
|
|
tabs, activeTabPath, entries, onNavigateWikilink,
|
|
|
|
|
getNoteStatus,
|
2026-03-17 12:07:33 +01:00
|
|
|
inspectorCollapsed, onToggleInspector, inspectorWidth, onInspectorResize,
|
|
|
|
|
inspectorEntry, inspectorContent, gitHistory,
|
2026-03-31 11:07:39 +02:00
|
|
|
onUpdateFrontmatter, onDeleteProperty, onAddProperty, onCreateAndOpenNote, onInitializeProperties,
|
2026-03-17 12:07:33 +01:00
|
|
|
showAIChat, onToggleAIChat,
|
|
|
|
|
vaultPath, noteList, noteListFilter,
|
2026-04-06 12:21:56 +02:00
|
|
|
onToggleFavorite, onToggleOrganized, onDeleteNote, onArchiveNote, onUnarchiveNote,
|
2026-03-17 12:07:33 +01:00
|
|
|
onContentChange, onSave, onTitleSync,
|
refactor: remove theming system entirely
Remove all theme switching, creation, and management functionality
from the app — backend (Rust theme module, Tauri commands, menu items,
startup tasks, vault seeding), frontend (useThemeManager, ThemePropertyEditor,
themeSchema, command palette Appearance group, settings panel appearance
section, isDarkTheme prop chain), mock data, and all related tests.
Editor styling via theme.json/EditorTheme.css is preserved (not user theming).
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-23 19:57:58 +01:00
|
|
|
onFileCreated, onFileModified, onVaultChanged,
|
2026-03-19 09:51:06 +01:00
|
|
|
isConflicted, onKeepMine, onKeepTheirs,
|
2026-03-17 12:07:33 +01:00
|
|
|
} = props
|
|
|
|
|
|
|
|
|
|
const {
|
|
|
|
|
editor, activeTab, rawLatestContentRef,
|
|
|
|
|
rawMode, diffMode, diffContent, diffLoading,
|
|
|
|
|
handleToggleDiffExclusive, handleToggleRawExclusive,
|
2026-03-18 15:42:48 +01:00
|
|
|
handleEditorChange, handleViewCommitDiff,
|
2026-03-17 12:07:33 +01:00
|
|
|
isLoadingNewTab, activeStatus, showDiffToggle,
|
|
|
|
|
} = useEditorSetup({
|
2026-03-18 15:42:48 +01:00
|
|
|
tabs, activeTabPath, vaultPath, onContentChange,
|
|
|
|
|
onLoadDiff: props.onLoadDiff,
|
2026-03-17 12:07:33 +01:00
|
|
|
onLoadDiffAtCommit: props.onLoadDiffAtCommit, getNoteStatus,
|
|
|
|
|
rawToggleRef: props.rawToggleRef, diffToggleRef: props.diffToggleRef,
|
|
|
|
|
})
|
|
|
|
|
|
2026-02-17 11:03:23 +01:00
|
|
|
return (
|
2026-02-17 11:31:23 +01:00
|
|
|
<div className="editor flex flex-col min-h-0 overflow-hidden bg-background text-foreground">
|
2026-02-17 11:03:23 +01:00
|
|
|
<div className="flex flex-1 min-h-0">
|
refactor: decompose Editor.tsx, NoteList.tsx, Sidebar.tsx — CodeScene hotspots (#126)
* 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>
2026-02-27 15:27:25 +01:00
|
|
|
{tabs.length === 0
|
|
|
|
|
? <EditorEmptyState />
|
|
|
|
|
: <EditorContent
|
|
|
|
|
activeTab={activeTab}
|
|
|
|
|
isLoadingNewTab={isLoadingNewTab}
|
|
|
|
|
entries={entries}
|
|
|
|
|
editor={editor}
|
|
|
|
|
diffMode={diffMode}
|
|
|
|
|
diffContent={diffContent}
|
|
|
|
|
diffLoading={diffLoading}
|
2026-03-02 18:38:25 +01:00
|
|
|
onToggleDiff={handleToggleDiffExclusive}
|
|
|
|
|
rawMode={rawMode}
|
|
|
|
|
onToggleRaw={handleToggleRawExclusive}
|
|
|
|
|
onRawContentChange={onContentChange}
|
|
|
|
|
onSave={onSave}
|
refactor: decompose Editor.tsx, NoteList.tsx, Sidebar.tsx — CodeScene hotspots (#126)
* 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>
2026-02-27 15:27:25 +01:00
|
|
|
activeStatus={activeStatus}
|
|
|
|
|
showDiffToggle={showDiffToggle}
|
|
|
|
|
showAIChat={showAIChat}
|
|
|
|
|
onToggleAIChat={onToggleAIChat}
|
|
|
|
|
inspectorCollapsed={inspectorCollapsed}
|
|
|
|
|
onToggleInspector={onToggleInspector}
|
|
|
|
|
onNavigateWikilink={onNavigateWikilink}
|
|
|
|
|
onEditorChange={handleEditorChange}
|
2026-04-02 14:44:23 +02:00
|
|
|
onToggleFavorite={onToggleFavorite}
|
2026-04-04 20:54:16 +02:00
|
|
|
onToggleOrganized={onToggleOrganized}
|
2026-03-03 01:37:25 +01:00
|
|
|
onDeleteNote={onDeleteNote}
|
refactor: decompose Editor.tsx, NoteList.tsx, Sidebar.tsx — CodeScene hotspots (#126)
* 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>
2026-02-27 15:27:25 +01:00
|
|
|
onArchiveNote={onArchiveNote}
|
|
|
|
|
onUnarchiveNote={onUnarchiveNote}
|
2026-02-28 21:31:47 +01:00
|
|
|
vaultPath={vaultPath}
|
2026-03-11 22:14:20 +01:00
|
|
|
rawLatestContentRef={rawLatestContentRef}
|
2026-03-16 04:46:28 +01:00
|
|
|
onTitleChange={onTitleSync}
|
2026-03-19 09:51:06 +01:00
|
|
|
isConflicted={isConflicted}
|
|
|
|
|
onKeepMine={onKeepMine}
|
|
|
|
|
onKeepTheirs={onKeepTheirs}
|
refactor: decompose Editor.tsx, NoteList.tsx, Sidebar.tsx — CodeScene hotspots (#126)
* 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>
2026-02-27 15:27:25 +01:00
|
|
|
/>
|
|
|
|
|
}
|
2026-03-03 01:37:25 +01:00
|
|
|
{(showAIChat || !inspectorCollapsed) && <ResizeHandle onResize={onInspectorResize} />}
|
refactor: decompose Editor.tsx, NoteList.tsx, Sidebar.tsx — CodeScene hotspots (#126)
* 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>
2026-02-27 15:27:25 +01:00
|
|
|
<EditorRightPanel
|
|
|
|
|
showAIChat={showAIChat}
|
|
|
|
|
inspectorCollapsed={inspectorCollapsed}
|
|
|
|
|
inspectorWidth={inspectorWidth}
|
|
|
|
|
inspectorEntry={inspectorEntry}
|
|
|
|
|
inspectorContent={inspectorContent}
|
|
|
|
|
entries={entries}
|
|
|
|
|
gitHistory={gitHistory}
|
2026-03-01 19:49:58 +01:00
|
|
|
vaultPath={vaultPath ?? ''}
|
2026-03-04 19:53:46 +01:00
|
|
|
noteList={noteList}
|
|
|
|
|
noteListFilter={noteListFilter}
|
refactor: decompose Editor.tsx, NoteList.tsx, Sidebar.tsx — CodeScene hotspots (#126)
* 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>
2026-02-27 15:27:25 +01:00
|
|
|
onToggleInspector={onToggleInspector}
|
|
|
|
|
onToggleAIChat={onToggleAIChat}
|
|
|
|
|
onNavigateWikilink={onNavigateWikilink}
|
|
|
|
|
onViewCommitDiff={handleViewCommitDiff}
|
|
|
|
|
onUpdateFrontmatter={onUpdateFrontmatter}
|
|
|
|
|
onDeleteProperty={onDeleteProperty}
|
|
|
|
|
onAddProperty={onAddProperty}
|
2026-03-11 21:24:57 +01:00
|
|
|
onCreateAndOpenNote={onCreateAndOpenNote}
|
2026-03-31 11:07:39 +02:00
|
|
|
onInitializeProperties={onInitializeProperties}
|
|
|
|
|
onToggleRawEditor={handleToggleRawExclusive}
|
2026-02-28 22:21:42 +01:00
|
|
|
onOpenNote={onNavigateWikilink}
|
2026-03-05 12:12:12 +01:00
|
|
|
onFileCreated={onFileCreated}
|
|
|
|
|
onFileModified={onFileModified}
|
2026-03-07 14:19:41 +01:00
|
|
|
onVaultChanged={onVaultChanged}
|
refactor: decompose Editor.tsx, NoteList.tsx, Sidebar.tsx — CodeScene hotspots (#126)
* 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>
2026-02-27 15:27:25 +01:00
|
|
|
/>
|
2026-02-17 11:03:23 +01:00
|
|
|
</div>
|
2026-02-14 18:22:42 +01:00
|
|
|
</div>
|
|
|
|
|
)
|
2026-02-17 17:14:43 +01:00
|
|
|
})
|