2026-04-27 10:12:13 +02:00
|
|
|
import { useRef, useEffect, useCallback, memo, useState } 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'
|
2026-04-26 03:52:10 +02:00
|
|
|
import 'katex/dist/katex.min.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-04-28 07:36:22 +02:00
|
|
|
import { DEFAULT_AI_AGENT, type AiAgentId, type AiAgentReadiness } from '../lib/aiAgents'
|
2026-05-03 16:15:03 +02:00
|
|
|
import type { AiTarget } from '../lib/aiTargets'
|
2026-04-26 19:37:21 +02:00
|
|
|
import { translate, type AppLocale } from '../lib/i18n'
|
2026-04-26 11:31:41 +02:00
|
|
|
import { RUNTIME_STYLE_NONCE } from '../lib/runtimeStyleNonce'
|
2026-04-29 19:26:24 +02:00
|
|
|
import type { VaultEntry, GitCommit, NoteWidthMode, 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'
|
2026-04-15 17:57:38 +02:00
|
|
|
import { useDiffMode, type CommitDiffRequest } from '../hooks/useDiffMode'
|
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'
|
2026-04-13 11:52:55 +02:00
|
|
|
import { useDragRegion } from '../hooks/useDragRegion'
|
2026-04-24 18:45:17 +02:00
|
|
|
import { formatShortcutDisplay } from '../hooks/appCommandCatalog'
|
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 { EditorRightPanel } from './EditorRightPanel'
|
|
|
|
|
import { EditorContent } from './EditorContent'
|
2026-05-01 23:14:36 +02:00
|
|
|
import { EditorMemoryProbe } from './EditorMemoryProbe'
|
2026-04-27 00:36:24 +02:00
|
|
|
import { FilePreview } from './FilePreview'
|
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 { schema } from './editorSchema'
|
2026-04-27 10:12:13 +02:00
|
|
|
import type { RawEditorFindRequest } from './RawEditorFindBar'
|
2026-04-12 11:45:59 +02:00
|
|
|
import {
|
|
|
|
|
applyPendingRawExitContent,
|
|
|
|
|
resolvePendingRawExitContent,
|
|
|
|
|
resolveRawModeContent,
|
|
|
|
|
} from './editorRawModeSync'
|
2026-04-29 18:19:35 +02:00
|
|
|
import { useRegisterEditorContentFlushes } from './editorContentFlushRegistration'
|
2026-04-15 23:33:30 +02:00
|
|
|
import { useRawModeWithFlush } from './useRawModeWithFlush'
|
2026-04-23 22:06:01 +02:00
|
|
|
import { createArrowLigaturesExtension } from './arrowLigaturesExtension'
|
2026-04-27 10:39:00 +02:00
|
|
|
import { createMathInputExtension } from './mathInputExtension'
|
2026-04-17 22:20:48 +02:00
|
|
|
import { useFilenameAutolinkGuard } from './useFilenameAutolinkGuard'
|
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-04-29 22:52:19 +02:00
|
|
|
isVaultLoading?: boolean
|
2026-02-15 19:50:23 +01:00
|
|
|
entries: VaultEntry[]
|
2026-02-14 20:30:45 +01:00
|
|
|
onNavigateWikilink: (target: string) => void
|
2026-04-24 13:52:58 +02:00
|
|
|
onUnsupportedAiPaste?: (message: 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-04-15 17:57:38 +02:00
|
|
|
pendingCommitDiffRequest?: CommitDiffRequest | null
|
|
|
|
|
onPendingCommitDiffHandled?: (requestId: number) => void
|
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
|
2026-04-13 19:37:59 +02:00
|
|
|
defaultAiAgent?: AiAgentId
|
2026-05-03 16:15:03 +02:00
|
|
|
defaultAiTarget?: AiTarget
|
2026-04-28 07:36:22 +02:00
|
|
|
defaultAiAgentReadiness?: AiAgentReadiness
|
2026-04-13 19:37:59 +02:00
|
|
|
defaultAiAgentReady?: boolean
|
2026-02-17 11:03:23 +01:00
|
|
|
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-04-22 22:37:01 +02:00
|
|
|
onCreateMissingType?: (path: string, missingType: string, nextTypeName: string) => Promise<boolean | 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-04-27 01:45:16 +02:00
|
|
|
onRevealFile?: (path: string) => void
|
|
|
|
|
onCopyFilePath?: (path: string) => void
|
|
|
|
|
onOpenExternalFile?: (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-04-10 17:59:21 +02:00
|
|
|
/** Called when the user explicitly renames the filename from the breadcrumb. */
|
|
|
|
|
onRenameFilename?: (path: string, newFilenameStem: string) => void
|
2026-04-29 19:26:24 +02:00
|
|
|
noteWidth?: NoteWidthMode
|
|
|
|
|
onToggleNoteWidth?: () => 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-04-27 10:12:13 +02:00
|
|
|
/** Mutable ref that Editor registers editor find commands into, for shortcuts and menus. */
|
|
|
|
|
findInNoteRef?: React.MutableRefObject<((options?: { replace?: boolean }) => void) | null>
|
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-04-29 18:19:35 +02:00
|
|
|
/** Registers a hook that flushes pending rich-editor changes into app state before external actions. */
|
|
|
|
|
flushPendingEditorContentRef?: React.MutableRefObject<((path: string) => void) | null>
|
2026-04-18 09:19:29 +02:00
|
|
|
/** Registers a hook that flushes the raw editor buffer into app state before external actions. */
|
|
|
|
|
flushPendingRawContentRef?: React.MutableRefObject<((path: string) => void) | null>
|
2026-04-26 19:37:21 +02:00
|
|
|
locale?: AppLocale
|
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
|
|
|
}
|
|
|
|
|
|
2026-04-26 19:37:21 +02:00
|
|
|
function EditorEmptyState({ locale = 'en' }: { locale?: AppLocale }) {
|
2026-04-13 11:52:55 +02:00
|
|
|
const breadcrumbBarHeight = 52
|
|
|
|
|
const { onMouseDown } = useDragRegion()
|
2026-04-24 18:45:17 +02:00
|
|
|
const quickOpenShortcut = formatShortcutDisplay({ display: '⌘P / ⌘O' })
|
|
|
|
|
const newNoteShortcut = formatShortcutDisplay({ display: '⌘N' })
|
2026-04-13 11:52:55 +02:00
|
|
|
|
2026-02-15 19:14:55 +01:00
|
|
|
return (
|
2026-04-13 11:52:55 +02:00
|
|
|
<div className="flex flex-1 flex-col overflow-hidden">
|
|
|
|
|
<div
|
|
|
|
|
aria-hidden="true"
|
|
|
|
|
data-tauri-drag-region
|
|
|
|
|
data-testid="editor-empty-state-drag-region"
|
|
|
|
|
className="shrink-0"
|
|
|
|
|
onMouseDown={onMouseDown}
|
|
|
|
|
style={{ height: breadcrumbBarHeight }}
|
|
|
|
|
/>
|
|
|
|
|
<div className="flex flex-1 flex-col items-center justify-center gap-2 text-center text-muted-foreground">
|
2026-04-26 19:37:21 +02:00
|
|
|
<p className="m-0 text-[15px]">{translate(locale, 'editor.empty.selectNote')}</p>
|
|
|
|
|
<span className="text-xs text-muted-foreground">{translate(locale, 'editor.empty.shortcuts', { quickOpen: quickOpenShortcut, newNote: newNoteShortcut })}</span>
|
2026-04-13 11:52:55 +02:00
|
|
|
</div>
|
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>
|
2026-04-15 17:57:38 +02:00
|
|
|
pendingCommitDiffRequest?: CommitDiffRequest | null
|
|
|
|
|
onPendingCommitDiffHandled?: (requestId: number) => void
|
2026-03-17 12:07:33 +01:00
|
|
|
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 useEditorSetup({
|
2026-03-18 15:42:48 +01:00
|
|
|
tabs, activeTabPath, vaultPath, onContentChange,
|
2026-04-15 17:57:38 +02:00
|
|
|
onLoadDiff, onLoadDiffAtCommit, pendingCommitDiffRequest, onPendingCommitDiffHandled, getNoteStatus,
|
2026-03-17 12:07:33 +01:00
|
|
|
rawToggleRef, diffToggleRef,
|
|
|
|
|
}: EditorSetupParams) {
|
|
|
|
|
const vaultPathRef = useRef(vaultPath)
|
2026-05-02 00:41:42 +02:00
|
|
|
const flushPendingEditorChangeRef = useRef<(() => boolean) | null>(null)
|
2026-03-17 12:07:33 +01:00
|
|
|
useEffect(() => { vaultPathRef.current = vaultPath }, [vaultPath])
|
|
|
|
|
|
|
|
|
|
const editor = useCreateBlockNote({
|
|
|
|
|
schema,
|
|
|
|
|
uploadFile: (file: File) => uploadImageFile(file, vaultPathRef.current),
|
2026-04-26 11:31:41 +02:00
|
|
|
_tiptapOptions: { injectNonce: RUNTIME_STYLE_NONCE },
|
2026-04-27 10:39:00 +02:00
|
|
|
extensions: [createArrowLigaturesExtension(), createMathInputExtension()],
|
2026-03-17 12:07:33 +01:00
|
|
|
})
|
2026-04-17 22:20:48 +02:00
|
|
|
useFilenameAutolinkGuard(editor)
|
2026-03-17 12:07:33 +01:00
|
|
|
const activeTab = tabs.find((t) => t.entry.path === activeTabPath) ?? null
|
2026-04-12 11:45:59 +02:00
|
|
|
const {
|
|
|
|
|
rawMode,
|
|
|
|
|
handleToggleRaw,
|
|
|
|
|
rawLatestContentRef,
|
|
|
|
|
pendingRawExitContent,
|
|
|
|
|
setPendingRawExitContent,
|
|
|
|
|
rawModeContentOverride,
|
|
|
|
|
} = useRawModeWithFlush(
|
|
|
|
|
editor,
|
|
|
|
|
activeTabPath,
|
|
|
|
|
activeTab?.content ?? null,
|
|
|
|
|
onContentChange,
|
2026-04-23 16:31:36 +02:00
|
|
|
vaultPath,
|
2026-05-02 00:41:42 +02:00
|
|
|
flushPendingEditorChangeRef,
|
2026-03-17 12:07:33 +01:00
|
|
|
)
|
2026-04-12 11:45:59 +02:00
|
|
|
const tabsForEditorSwap = applyPendingRawExitContent(tabs, pendingRawExitContent)
|
|
|
|
|
const rawModeContent = resolveRawModeContent({ activeTab, rawModeContentOverride })
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
setPendingRawExitContent((current) => resolvePendingRawExitContent({
|
|
|
|
|
activeTabPath,
|
|
|
|
|
tabs,
|
|
|
|
|
pendingRawExitContent: current,
|
|
|
|
|
}))
|
|
|
|
|
}, [activeTabPath, setPendingRawExitContent, tabs])
|
2026-03-17 12:07:33 +01:00
|
|
|
|
2026-04-29 18:19:35 +02:00
|
|
|
const { handleEditorChange, flushPendingEditorChange, editorMountedRef } = useEditorTabSwap({
|
2026-04-23 16:31:36 +02:00
|
|
|
tabs: tabsForEditorSwap, activeTabPath, editor, onContentChange, rawMode, vaultPath,
|
2026-02-28 10:57:30 +01:00
|
|
|
})
|
2026-05-02 00:41:42 +02:00
|
|
|
useEffect(() => {
|
|
|
|
|
flushPendingEditorChangeRef.current = flushPendingEditorChange
|
|
|
|
|
return () => {
|
|
|
|
|
if (flushPendingEditorChangeRef.current === flushPendingEditorChange) {
|
|
|
|
|
flushPendingEditorChangeRef.current = null
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}, [flushPendingEditorChange])
|
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({
|
2026-04-15 17:57:38 +02:00
|
|
|
activeTabPath,
|
|
|
|
|
onLoadDiff,
|
|
|
|
|
onLoadDiffAtCommit,
|
|
|
|
|
pendingCommitDiffRequest,
|
|
|
|
|
onPendingCommitDiffHandled,
|
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-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 {
|
2026-04-12 11:45:59 +02:00
|
|
|
editor, activeTab, rawLatestContentRef, rawModeContent,
|
2026-03-17 12:07:33 +01:00
|
|
|
rawMode, diffMode, diffContent, diffLoading,
|
|
|
|
|
handleToggleDiffExclusive, handleToggleRawExclusive,
|
2026-04-29 18:19:35 +02:00
|
|
|
handleEditorChange, flushPendingEditorChange, handleViewCommitDiff,
|
2026-03-17 12:07:33 +01:00
|
|
|
isLoadingNewTab, activeStatus, showDiffToggle,
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-04-27 10:12:13 +02:00
|
|
|
function useEditorFindCommand({
|
|
|
|
|
activeTab,
|
|
|
|
|
findInNoteRef,
|
|
|
|
|
handleToggleRawExclusive,
|
|
|
|
|
rawMode,
|
|
|
|
|
}: {
|
|
|
|
|
activeTab: Tab | null
|
|
|
|
|
findInNoteRef?: EditorProps['findInNoteRef']
|
|
|
|
|
handleToggleRawExclusive: () => void
|
|
|
|
|
rawMode: boolean
|
|
|
|
|
}): RawEditorFindRequest | null {
|
|
|
|
|
const [findRequest, setFindRequest] = useState<RawEditorFindRequest | null>(null)
|
|
|
|
|
const handleFindInNote = useCallback((options: { replace?: boolean } = {}) => {
|
|
|
|
|
if (!activeTab || activeTab.entry.fileKind === 'binary') return
|
|
|
|
|
if (!rawMode) handleToggleRawExclusive()
|
|
|
|
|
|
|
|
|
|
setFindRequest((current) => ({
|
|
|
|
|
id: (current?.id ?? 0) + 1,
|
|
|
|
|
path: activeTab.entry.path,
|
|
|
|
|
replace: options.replace === true,
|
|
|
|
|
}))
|
|
|
|
|
}, [activeTab, handleToggleRawExclusive, rawMode])
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
if (!findInNoteRef) return
|
|
|
|
|
|
|
|
|
|
findInNoteRef.current = handleFindInNote
|
|
|
|
|
return () => {
|
|
|
|
|
if (findInNoteRef.current === handleFindInNote) {
|
|
|
|
|
findInNoteRef.current = null
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}, [findInNoteRef, handleFindInNote])
|
|
|
|
|
|
|
|
|
|
return findRequest
|
|
|
|
|
}
|
|
|
|
|
|
2026-04-18 09:19:29 +02:00
|
|
|
function EditorLayout({
|
|
|
|
|
tabs,
|
2026-04-29 22:52:19 +02:00
|
|
|
activeTabPath,
|
2026-04-18 09:19:29 +02:00
|
|
|
activeTab,
|
|
|
|
|
isLoadingNewTab,
|
2026-04-29 22:52:19 +02:00
|
|
|
isVaultLoading,
|
2026-04-18 09:19:29 +02:00
|
|
|
entries,
|
|
|
|
|
editor,
|
|
|
|
|
diffMode,
|
|
|
|
|
diffContent,
|
|
|
|
|
diffLoading,
|
|
|
|
|
handleToggleDiffExclusive,
|
|
|
|
|
rawMode,
|
|
|
|
|
handleToggleRawExclusive,
|
|
|
|
|
onContentChange,
|
|
|
|
|
onSave,
|
|
|
|
|
activeStatus,
|
|
|
|
|
showDiffToggle,
|
|
|
|
|
showAIChat,
|
|
|
|
|
onToggleAIChat,
|
|
|
|
|
inspectorCollapsed,
|
|
|
|
|
onToggleInspector,
|
|
|
|
|
onNavigateWikilink,
|
|
|
|
|
handleEditorChange,
|
|
|
|
|
onToggleFavorite,
|
|
|
|
|
onToggleOrganized,
|
2026-04-27 01:45:16 +02:00
|
|
|
onRevealFile,
|
|
|
|
|
onCopyFilePath,
|
|
|
|
|
onOpenExternalFile,
|
2026-04-18 09:19:29 +02:00
|
|
|
onDeleteNote,
|
|
|
|
|
onArchiveNote,
|
|
|
|
|
onUnarchiveNote,
|
|
|
|
|
vaultPath,
|
|
|
|
|
rawModeContent,
|
2026-04-27 10:12:13 +02:00
|
|
|
findRequest,
|
2026-04-18 09:19:29 +02:00
|
|
|
rawLatestContentRef,
|
|
|
|
|
onRenameFilename,
|
2026-04-29 19:26:24 +02:00
|
|
|
noteWidth,
|
|
|
|
|
onToggleNoteWidth,
|
2026-04-18 09:19:29 +02:00
|
|
|
isConflicted,
|
|
|
|
|
onKeepMine,
|
|
|
|
|
onKeepTheirs,
|
|
|
|
|
onInspectorResize,
|
|
|
|
|
inspectorWidth,
|
|
|
|
|
defaultAiAgent,
|
2026-05-03 16:15:03 +02:00
|
|
|
defaultAiTarget,
|
2026-04-28 07:36:22 +02:00
|
|
|
defaultAiAgentReadiness,
|
2026-04-18 09:19:29 +02:00
|
|
|
defaultAiAgentReady,
|
|
|
|
|
inspectorEntry,
|
|
|
|
|
inspectorContent,
|
|
|
|
|
gitHistory,
|
|
|
|
|
noteList,
|
|
|
|
|
noteListFilter,
|
|
|
|
|
handleViewCommitDiff,
|
|
|
|
|
onUpdateFrontmatter,
|
|
|
|
|
onDeleteProperty,
|
|
|
|
|
onAddProperty,
|
|
|
|
|
onCreateMissingType,
|
|
|
|
|
onCreateAndOpenNote,
|
|
|
|
|
onInitializeProperties,
|
|
|
|
|
onFileCreated,
|
|
|
|
|
onFileModified,
|
|
|
|
|
onVaultChanged,
|
2026-04-24 13:52:58 +02:00
|
|
|
onUnsupportedAiPaste,
|
2026-04-26 19:37:21 +02:00
|
|
|
locale,
|
2026-04-18 09:19:29 +02:00
|
|
|
}: {
|
|
|
|
|
tabs: Tab[]
|
2026-04-29 22:52:19 +02:00
|
|
|
activeTabPath: string | null
|
2026-04-18 09:19:29 +02:00
|
|
|
activeTab: Tab | null
|
|
|
|
|
isLoadingNewTab: boolean
|
2026-04-29 22:52:19 +02:00
|
|
|
isVaultLoading?: boolean
|
2026-04-18 09:19:29 +02:00
|
|
|
entries: VaultEntry[]
|
|
|
|
|
editor: ReturnType<typeof useCreateBlockNote>
|
|
|
|
|
diffMode: boolean
|
|
|
|
|
diffContent: string | null
|
|
|
|
|
diffLoading: boolean
|
|
|
|
|
handleToggleDiffExclusive: () => void | Promise<void>
|
|
|
|
|
rawMode: boolean
|
|
|
|
|
handleToggleRawExclusive: () => void
|
|
|
|
|
onContentChange?: (path: string, content: string) => void
|
|
|
|
|
onSave?: () => void
|
|
|
|
|
activeStatus: NoteStatus
|
|
|
|
|
showDiffToggle: boolean
|
|
|
|
|
showAIChat?: boolean
|
|
|
|
|
onToggleAIChat?: () => void
|
|
|
|
|
inspectorCollapsed: boolean
|
|
|
|
|
onToggleInspector: () => void
|
|
|
|
|
onNavigateWikilink: (target: string) => void
|
|
|
|
|
handleEditorChange: () => void
|
|
|
|
|
onToggleFavorite?: (path: string) => void
|
|
|
|
|
onToggleOrganized?: (path: string) => void
|
2026-04-27 01:45:16 +02:00
|
|
|
onRevealFile?: (path: string) => void
|
|
|
|
|
onCopyFilePath?: (path: string) => void
|
|
|
|
|
onOpenExternalFile?: (path: string) => void
|
2026-04-18 09:19:29 +02:00
|
|
|
onDeleteNote?: (path: string) => void
|
|
|
|
|
onArchiveNote?: (path: string) => void
|
|
|
|
|
onUnarchiveNote?: (path: string) => void
|
|
|
|
|
vaultPath?: string
|
|
|
|
|
rawModeContent: string | null
|
2026-04-27 10:12:13 +02:00
|
|
|
findRequest?: RawEditorFindRequest | null
|
2026-04-18 09:19:29 +02:00
|
|
|
rawLatestContentRef: React.MutableRefObject<string | null>
|
|
|
|
|
onRenameFilename?: (path: string, newFilenameStem: string) => void
|
2026-04-29 19:26:24 +02:00
|
|
|
noteWidth?: NoteWidthMode
|
|
|
|
|
onToggleNoteWidth?: () => void
|
2026-04-18 09:19:29 +02:00
|
|
|
isConflicted?: boolean
|
|
|
|
|
onKeepMine?: (path: string) => void
|
|
|
|
|
onKeepTheirs?: (path: string) => void
|
|
|
|
|
onInspectorResize: (delta: number) => void
|
|
|
|
|
inspectorWidth: number
|
|
|
|
|
defaultAiAgent: AiAgentId
|
2026-05-03 16:15:03 +02:00
|
|
|
defaultAiTarget?: AiTarget
|
2026-04-28 07:36:22 +02:00
|
|
|
defaultAiAgentReadiness?: AiAgentReadiness
|
2026-04-18 09:19:29 +02:00
|
|
|
defaultAiAgentReady: boolean
|
|
|
|
|
inspectorEntry: VaultEntry | null
|
|
|
|
|
inspectorContent: string | null
|
|
|
|
|
gitHistory: GitCommit[]
|
|
|
|
|
noteList?: NoteListItem[]
|
|
|
|
|
noteListFilter?: { type: string | null; query: string }
|
2026-04-18 09:21:44 +02:00
|
|
|
handleViewCommitDiff: (commitHash: string) => Promise<void>
|
2026-04-18 09:19:29 +02:00
|
|
|
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-04-22 22:37:01 +02:00
|
|
|
onCreateMissingType?: (path: string, missingType: string, nextTypeName: string) => Promise<boolean | void>
|
2026-04-18 09:19:29 +02:00
|
|
|
onCreateAndOpenNote?: (title: string) => Promise<boolean>
|
|
|
|
|
onInitializeProperties?: (path: string) => void
|
|
|
|
|
onFileCreated?: (relativePath: string) => void
|
|
|
|
|
onFileModified?: (relativePath: string) => void
|
|
|
|
|
onVaultChanged?: () => void
|
2026-04-24 13:52:58 +02:00
|
|
|
onUnsupportedAiPaste?: (message: string) => void
|
2026-04-26 19:37:21 +02:00
|
|
|
locale?: AppLocale
|
2026-04-18 09:19:29 +02:00
|
|
|
}) {
|
2026-04-27 00:36:24 +02:00
|
|
|
const activeBinaryTab = activeTab?.entry.fileKind === 'binary' ? activeTab : null
|
2026-04-29 22:52:19 +02:00
|
|
|
const showEmptyState = tabs.length === 0 && activeTabPath === null && !isVaultLoading
|
2026-04-27 00:36:24 +02:00
|
|
|
|
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">
|
2026-04-29 22:52:19 +02:00
|
|
|
{showEmptyState
|
2026-04-26 19:37:21 +02:00
|
|
|
? <EditorEmptyState locale={locale} />
|
2026-04-27 00:36:24 +02:00
|
|
|
: activeBinaryTab
|
2026-04-27 01:45:16 +02:00
|
|
|
? (
|
|
|
|
|
<FilePreview
|
|
|
|
|
entry={activeBinaryTab.entry}
|
|
|
|
|
onCopyFilePath={onCopyFilePath}
|
|
|
|
|
onOpenExternalFile={onOpenExternalFile}
|
|
|
|
|
onRevealFile={onRevealFile}
|
|
|
|
|
/>
|
|
|
|
|
)
|
2026-04-27 00:36:24 +02:00
|
|
|
: <EditorContent
|
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
|
|
|
activeTab={activeTab}
|
2026-04-29 22:52:19 +02:00
|
|
|
activeTabPath={activeTabPath}
|
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
|
|
|
isLoadingNewTab={isLoadingNewTab}
|
2026-04-29 22:52:19 +02:00
|
|
|
isVaultLoading={isVaultLoading}
|
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
|
|
|
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-04-27 01:45:16 +02:00
|
|
|
onRevealFile={onRevealFile}
|
|
|
|
|
onCopyFilePath={onCopyFilePath}
|
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-04-12 11:45:59 +02:00
|
|
|
rawModeContent={rawModeContent}
|
2026-04-27 10:12:13 +02:00
|
|
|
findRequest={findRequest}
|
2026-03-11 22:14:20 +01:00
|
|
|
rawLatestContentRef={rawLatestContentRef}
|
2026-04-10 17:59:21 +02:00
|
|
|
onRenameFilename={onRenameFilename}
|
2026-04-29 19:26:24 +02:00
|
|
|
noteWidth={noteWidth}
|
|
|
|
|
onToggleNoteWidth={onToggleNoteWidth}
|
2026-03-19 09:51:06 +01:00
|
|
|
isConflicted={isConflicted}
|
|
|
|
|
onKeepMine={onKeepMine}
|
|
|
|
|
onKeepTheirs={onKeepTheirs}
|
2026-04-26 19:37:21 +02:00
|
|
|
locale={locale}
|
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}
|
2026-04-13 19:37:59 +02:00
|
|
|
defaultAiAgent={defaultAiAgent}
|
2026-05-03 16:15:03 +02:00
|
|
|
defaultAiTarget={defaultAiTarget}
|
2026-04-28 07:36:22 +02:00
|
|
|
defaultAiAgentReadiness={defaultAiAgentReadiness}
|
2026-04-13 19:37:59 +02:00
|
|
|
defaultAiAgentReady={defaultAiAgentReady}
|
2026-04-24 13:52:58 +02:00
|
|
|
onUnsupportedAiPaste={onUnsupportedAiPaste}
|
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
|
|
|
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-04-17 00:44:14 +02:00
|
|
|
onCreateMissingType={onCreateMissingType}
|
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}
|
2026-04-26 19:37:21 +02:00
|
|
|
locale={locale}
|
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-05-01 23:14:36 +02:00
|
|
|
<EditorMemoryProbe entries={entries} vaultPath={vaultPath} locale={locale} />
|
2026-02-14 18:22:42 +01:00
|
|
|
</div>
|
|
|
|
|
)
|
2026-04-18 09:19:29 +02:00
|
|
|
}
|
|
|
|
|
|
2026-05-03 16:15:03 +02:00
|
|
|
type EditorRuntime = ReturnType<typeof useEditorSetup>
|
|
|
|
|
type EditorLayoutProps = Parameters<typeof EditorLayout>[0]
|
|
|
|
|
|
|
|
|
|
function buildEditorLayoutProps(
|
|
|
|
|
props: EditorProps,
|
|
|
|
|
runtime: EditorRuntime,
|
|
|
|
|
findRequest: RawEditorFindRequest | null,
|
|
|
|
|
): EditorLayoutProps {
|
|
|
|
|
return {
|
|
|
|
|
...props,
|
|
|
|
|
...runtime,
|
|
|
|
|
activeTabPath: props.activeTabPath,
|
|
|
|
|
defaultAiAgent: props.defaultAiAgent ?? DEFAULT_AI_AGENT,
|
|
|
|
|
defaultAiAgentReady: props.defaultAiAgentReady ?? true,
|
|
|
|
|
findRequest,
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-04-18 09:19:29 +02:00
|
|
|
export const Editor = memo(function Editor(props: EditorProps) {
|
2026-05-03 16:15:03 +02:00
|
|
|
const runtime = useEditorSetup({
|
|
|
|
|
tabs: props.tabs,
|
|
|
|
|
activeTabPath: props.activeTabPath,
|
|
|
|
|
vaultPath: props.vaultPath,
|
|
|
|
|
onContentChange: props.onContentChange,
|
2026-04-18 09:19:29 +02:00
|
|
|
onLoadDiff: props.onLoadDiff,
|
|
|
|
|
onLoadDiffAtCommit: props.onLoadDiffAtCommit,
|
|
|
|
|
pendingCommitDiffRequest: props.pendingCommitDiffRequest,
|
|
|
|
|
onPendingCommitDiffHandled: props.onPendingCommitDiffHandled,
|
2026-05-03 16:15:03 +02:00
|
|
|
getNoteStatus: props.getNoteStatus,
|
|
|
|
|
rawToggleRef: props.rawToggleRef,
|
|
|
|
|
diffToggleRef: props.diffToggleRef,
|
2026-04-18 09:19:29 +02:00
|
|
|
})
|
2026-04-27 10:12:13 +02:00
|
|
|
const findRequest = useEditorFindCommand({
|
2026-05-03 16:15:03 +02:00
|
|
|
activeTab: runtime.activeTab,
|
|
|
|
|
findInNoteRef: props.findInNoteRef,
|
|
|
|
|
handleToggleRawExclusive: runtime.handleToggleRawExclusive,
|
|
|
|
|
rawMode: runtime.rawMode,
|
2026-04-27 10:12:13 +02:00
|
|
|
})
|
2026-04-29 18:19:35 +02:00
|
|
|
useRegisterEditorContentFlushes({
|
2026-05-03 16:15:03 +02:00
|
|
|
activeTab: runtime.activeTab,
|
|
|
|
|
flushPendingEditorChange: runtime.flushPendingEditorChange,
|
|
|
|
|
flushPendingEditorContentRef: props.flushPendingEditorContentRef,
|
|
|
|
|
rawLatestContentRef: runtime.rawLatestContentRef,
|
|
|
|
|
rawMode: runtime.rawMode,
|
|
|
|
|
onContentChange: props.onContentChange,
|
|
|
|
|
flushPendingRawContentRef: props.flushPendingRawContentRef,
|
2026-04-18 09:19:29 +02:00
|
|
|
})
|
2026-05-03 16:15:03 +02:00
|
|
|
return <EditorLayout {...buildEditorLayoutProps(props, runtime, findRequest)} />
|
2026-02-17 17:14:43 +01:00
|
|
|
})
|