2026-03-11 22:14:20 +01:00
|
|
|
import type React from 'react'
|
2026-03-27 16:20:31 +01:00
|
|
|
import { useCallback } from 'react'
|
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 { VaultEntry, NoteStatus } from '../types'
|
|
|
|
|
import type { useCreateBlockNote } from '@blocknote/react'
|
|
|
|
|
import { DiffView } from './DiffView'
|
|
|
|
|
import { BreadcrumbBar } from './BreadcrumbBar'
|
2026-03-16 04:46:28 +01:00
|
|
|
import { TitleField } from './TitleField'
|
2026-03-17 22:42:55 +01:00
|
|
|
import { NoteIcon } from './NoteIcon'
|
2026-03-03 01:37:25 +01:00
|
|
|
import { TrashedNoteBanner } from './TrashedNoteBanner'
|
2026-03-03 02:31:10 +01:00
|
|
|
import { ArchivedNoteBanner } from './ArchivedNoteBanner'
|
2026-03-19 09:51:06 +01:00
|
|
|
import { ConflictNoteBanner } from './ConflictNoteBanner'
|
2026-03-02 18:38:25 +01:00
|
|
|
import { RawEditorView } from './RawEditorView'
|
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 { countWords } from '../utils/wikilinks'
|
|
|
|
|
import { SingleEditorView } from './SingleEditorView'
|
2026-03-17 22:42:55 +01:00
|
|
|
import { isEmoji } from '../utils/emoji'
|
2026-03-30 13:04:04 +02:00
|
|
|
import { useEditorTheme } from '../hooks/useTheme'
|
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
|
|
|
|
|
|
|
|
interface Tab {
|
|
|
|
|
entry: VaultEntry
|
|
|
|
|
content: string
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
interface EditorContentProps {
|
|
|
|
|
activeTab: Tab | null
|
|
|
|
|
isLoadingNewTab: boolean
|
|
|
|
|
entries: VaultEntry[]
|
|
|
|
|
editor: ReturnType<typeof useCreateBlockNote>
|
|
|
|
|
diffMode: boolean
|
|
|
|
|
diffContent: string | null
|
|
|
|
|
diffLoading: boolean
|
|
|
|
|
onToggleDiff: () => void
|
2026-03-02 18:38:25 +01:00
|
|
|
rawMode: boolean
|
|
|
|
|
onToggleRaw: () => void
|
|
|
|
|
onRawContentChange?: (path: string, content: string) => void
|
|
|
|
|
onSave?: () => void
|
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: NoteStatus
|
|
|
|
|
showDiffToggle: boolean
|
|
|
|
|
showAIChat?: boolean
|
|
|
|
|
onToggleAIChat?: () => void
|
|
|
|
|
inspectorCollapsed: boolean
|
|
|
|
|
onToggleInspector: () => void
|
|
|
|
|
onNavigateWikilink: (target: string) => void
|
|
|
|
|
onEditorChange?: () => void
|
|
|
|
|
onTrashNote?: (path: string) => void
|
|
|
|
|
onRestoreNote?: (path: string) => void
|
2026-03-03 01:37:25 +01:00
|
|
|
onDeleteNote?: (path: string) => void
|
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?: (path: string) => void
|
|
|
|
|
onUnarchiveNote?: (path: string) => void
|
2026-02-28 21:31:47 +01:00
|
|
|
vaultPath?: string
|
2026-03-11 22:14:20 +01:00
|
|
|
/** Ref updated by RawEditorView on every keystroke with the latest doc. */
|
|
|
|
|
rawLatestContentRef?: React.MutableRefObject<string | null>
|
2026-03-16 04:46:28 +01:00
|
|
|
/** Called when the user edits the dedicated title field. */
|
|
|
|
|
onTitleChange?: (path: string, newTitle: string) => void
|
2026-03-17 22:42:55 +01:00
|
|
|
/** Called when user sets or changes an emoji icon via the picker. */
|
|
|
|
|
onSetNoteIcon?: (path: string, emoji: string) => void
|
|
|
|
|
/** Called when user removes an emoji icon. */
|
|
|
|
|
onRemoveNoteIcon?: (path: string) => 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
|
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 EditorLoadingSkeleton() {
|
|
|
|
|
return (
|
|
|
|
|
<div className="flex flex-1 flex-col gap-3 p-8 animate-pulse" style={{ minHeight: 0 }}>
|
|
|
|
|
<div className="h-6 w-2/5 rounded bg-muted" />
|
|
|
|
|
<div className="h-4 w-4/5 rounded bg-muted" />
|
|
|
|
|
<div className="h-4 w-3/5 rounded bg-muted" />
|
|
|
|
|
<div className="h-4 w-4/5 rounded bg-muted" />
|
|
|
|
|
<div className="h-4 w-2/5 rounded bg-muted" />
|
|
|
|
|
</div>
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function DiffModeView({ diffContent, onToggleDiff }: { diffContent: string | null; onToggleDiff: () => void }) {
|
|
|
|
|
return (
|
|
|
|
|
<div className="flex-1 overflow-auto">
|
|
|
|
|
<button
|
|
|
|
|
className="flex items-center gap-1.5 px-4 py-2 text-xs text-primary bg-muted border-b border-border cursor-pointer hover:bg-accent transition-colors w-full border-t-0 border-l-0 border-r-0"
|
|
|
|
|
onClick={onToggleDiff}
|
|
|
|
|
title="Back to editor"
|
|
|
|
|
>
|
|
|
|
|
<span style={{ fontSize: 14, lineHeight: 1 }}>←</span>
|
|
|
|
|
Back to editor
|
|
|
|
|
</button>
|
|
|
|
|
<DiffView diff={diffContent ?? ''} />
|
|
|
|
|
</div>
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-02 18:38:25 +01:00
|
|
|
function RawModeEditorSection({
|
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
|
|
|
rawMode, activeTab, entries, onContentChange, onSave, latestContentRef,
|
2026-03-02 18:38:25 +01:00
|
|
|
}: {
|
|
|
|
|
rawMode: boolean
|
|
|
|
|
activeTab: Tab | null
|
|
|
|
|
entries: VaultEntry[]
|
|
|
|
|
onContentChange?: (path: string, content: string) => void
|
|
|
|
|
onSave?: () => void
|
2026-03-11 22:14:20 +01:00
|
|
|
latestContentRef?: React.MutableRefObject<string | null>
|
2026-03-02 18:38:25 +01:00
|
|
|
}) {
|
|
|
|
|
if (!rawMode || !activeTab) return null
|
|
|
|
|
return (
|
|
|
|
|
<RawEditorView
|
|
|
|
|
key={activeTab.entry.path}
|
|
|
|
|
content={activeTab.content}
|
|
|
|
|
path={activeTab.entry.path}
|
|
|
|
|
entries={entries}
|
|
|
|
|
onContentChange={onContentChange ?? (() => {})}
|
|
|
|
|
onSave={onSave ?? (() => {})}
|
2026-03-11 22:14:20 +01:00
|
|
|
latestContentRef={latestContentRef}
|
2026-03-02 18:38:25 +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
|
|
|
/** Bind an optional callback to a path, returning undefined if callback is absent */
|
|
|
|
|
function bindPath(cb: ((path: string) => void) | undefined, path: string) {
|
|
|
|
|
return cb ? () => cb(path) : undefined
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function ActiveTabBreadcrumb({ activeTab, props }: {
|
|
|
|
|
activeTab: Tab
|
2026-03-03 01:37:25 +01:00
|
|
|
props: Omit<EditorContentProps, 'activeTab' | 'isLoadingNewTab' | 'entries' | 'editor' | 'onNavigateWikilink' | 'onEditorChange' | 'onRawContentChange' | 'onSave' | '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
|
|
|
}) {
|
|
|
|
|
const wordCount = countWords(activeTab.content)
|
|
|
|
|
const path = activeTab.entry.path
|
|
|
|
|
return (
|
|
|
|
|
<BreadcrumbBar
|
|
|
|
|
entry={activeTab.entry}
|
|
|
|
|
wordCount={wordCount}
|
|
|
|
|
noteStatus={props.activeStatus}
|
|
|
|
|
showDiffToggle={props.showDiffToggle}
|
|
|
|
|
diffMode={props.diffMode}
|
|
|
|
|
diffLoading={props.diffLoading}
|
|
|
|
|
onToggleDiff={props.onToggleDiff}
|
2026-03-02 18:38:25 +01:00
|
|
|
rawMode={props.rawMode}
|
|
|
|
|
onToggleRaw={props.onToggleRaw}
|
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
|
|
|
showAIChat={props.showAIChat}
|
|
|
|
|
onToggleAIChat={props.onToggleAIChat}
|
|
|
|
|
inspectorCollapsed={props.inspectorCollapsed}
|
|
|
|
|
onToggleInspector={props.onToggleInspector}
|
|
|
|
|
onTrash={bindPath(props.onTrashNote, path)}
|
|
|
|
|
onRestore={bindPath(props.onRestoreNote, path)}
|
|
|
|
|
onArchive={bindPath(props.onArchiveNote, path)}
|
|
|
|
|
onUnarchive={bindPath(props.onUnarchiveNote, path)}
|
|
|
|
|
/>
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function EditorContent({
|
|
|
|
|
activeTab, isLoadingNewTab, entries, editor,
|
|
|
|
|
diffMode, diffContent, onToggleDiff,
|
2026-03-02 18:38:25 +01:00
|
|
|
rawMode, onToggleRaw, onRawContentChange, onSave,
|
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
|
|
|
onNavigateWikilink, onEditorChange, vaultPath,
|
2026-03-16 04:46:28 +01:00
|
|
|
onDeleteNote, rawLatestContentRef, onTitleChange,
|
2026-03-17 22:42:55 +01:00
|
|
|
onSetNoteIcon, onRemoveNoteIcon,
|
2026-03-19 09:51:06 +01:00
|
|
|
isConflicted, onKeepMine, 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
|
|
|
...breadcrumbProps
|
|
|
|
|
}: EditorContentProps) {
|
2026-03-20 22:36:59 +01:00
|
|
|
// Look up trashed/archived from the latest vault entries, not the tab snapshot,
|
|
|
|
|
// so the banner appears regardless of navigation context.
|
2026-03-30 13:04:04 +02:00
|
|
|
const { cssVars } = useEditorTheme()
|
2026-03-20 22:36:59 +01:00
|
|
|
const freshEntry = activeTab ? entries.find(e => e.path === activeTab.entry.path) : undefined
|
|
|
|
|
const isTrashed = freshEntry?.trashed ?? activeTab?.entry.trashed ?? false
|
|
|
|
|
const isArchived = freshEntry?.archived ?? activeTab?.entry.archived ?? false
|
2026-03-18 21:32:03 +01:00
|
|
|
const showEditor = !diffMode && !rawMode
|
2026-03-17 22:42:55 +01:00
|
|
|
const entryIcon = activeTab?.entry.icon ?? null
|
|
|
|
|
const emojiIcon = entryIcon && isEmoji(entryIcon) ? entryIcon : null
|
|
|
|
|
|
|
|
|
|
const handleSetIcon = useCallback((emoji: string) => {
|
|
|
|
|
if (activeTab) onSetNoteIcon?.(activeTab.entry.path, emoji)
|
|
|
|
|
}, [activeTab, onSetNoteIcon])
|
|
|
|
|
|
|
|
|
|
const handleRemoveIcon = useCallback(() => {
|
|
|
|
|
if (activeTab) onRemoveNoteIcon?.(activeTab.entry.path)
|
|
|
|
|
}, [activeTab, onRemoveNoteIcon])
|
2026-03-02 18:38:25 +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
|
|
|
return (
|
|
|
|
|
<div className="flex flex-1 flex-col min-w-0 min-h-0">
|
2026-03-02 18:38:25 +01:00
|
|
|
{activeTab && (
|
|
|
|
|
<ActiveTabBreadcrumb
|
|
|
|
|
activeTab={activeTab}
|
|
|
|
|
props={{ diffMode, diffContent, onToggleDiff, rawMode, onToggleRaw, ...breadcrumbProps }}
|
|
|
|
|
/>
|
|
|
|
|
)}
|
2026-03-03 01:37:25 +01:00
|
|
|
{activeTab && isTrashed && (
|
|
|
|
|
<TrashedNoteBanner
|
|
|
|
|
onRestore={() => breadcrumbProps.onRestoreNote?.(activeTab.entry.path)}
|
|
|
|
|
onDeletePermanently={() => onDeleteNote?.(activeTab.entry.path)}
|
|
|
|
|
/>
|
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-20 22:36:59 +01:00
|
|
|
{activeTab && isArchived && breadcrumbProps.onUnarchiveNote && (
|
2026-03-03 02:31:10 +01:00
|
|
|
<ArchivedNoteBanner onUnarchive={() => breadcrumbProps.onUnarchiveNote!(activeTab.entry.path)} />
|
|
|
|
|
)}
|
2026-03-19 09:51:06 +01:00
|
|
|
{activeTab && isConflicted && (
|
|
|
|
|
<ConflictNoteBanner
|
|
|
|
|
onKeepMine={() => onKeepMine?.(activeTab.entry.path)}
|
|
|
|
|
onKeepTheirs={() => onKeepTheirs?.(activeTab.entry.path)}
|
|
|
|
|
/>
|
|
|
|
|
)}
|
2026-03-18 21:32:03 +01:00
|
|
|
{diffMode && <DiffModeView diffContent={diffContent} onToggleDiff={onToggleDiff} />}
|
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
|
|
|
<RawModeEditorSection rawMode={rawMode} activeTab={activeTab} entries={entries} onContentChange={onRawContentChange} onSave={onSave} latestContentRef={rawLatestContentRef} />
|
2026-03-18 21:32:03 +01:00
|
|
|
{showEditor && activeTab && (
|
2026-03-30 13:04:04 +02:00
|
|
|
<div className="editor-scroll-area" style={cssVars as React.CSSProperties}>
|
2026-03-18 21:32:03 +01:00
|
|
|
<div className="title-section">
|
2026-03-30 13:04:04 +02:00
|
|
|
<div className="title-section__row">
|
2026-03-29 14:31:35 +02:00
|
|
|
<NoteIcon
|
2026-03-30 13:04:04 +02:00
|
|
|
icon={emojiIcon}
|
2026-03-29 14:31:35 +02:00
|
|
|
editable={!isTrashed}
|
|
|
|
|
onSetIcon={handleSetIcon}
|
|
|
|
|
onRemoveIcon={handleRemoveIcon}
|
|
|
|
|
/>
|
|
|
|
|
<TitleField
|
|
|
|
|
title={activeTab.entry.title}
|
|
|
|
|
filename={activeTab.entry.filename}
|
|
|
|
|
editable={!isTrashed}
|
|
|
|
|
onTitleChange={(newTitle) => onTitleChange?.(activeTab.entry.path, newTitle)}
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
2026-03-18 21:32:03 +01:00
|
|
|
<div className="title-section__separator" />
|
|
|
|
|
</div>
|
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
|
|
|
<SingleEditorView editor={editor} entries={entries} onNavigateWikilink={onNavigateWikilink} onChange={onEditorChange} vaultPath={vaultPath} editable={!isTrashed} />
|
2026-03-18 21:32:03 +01:00
|
|
|
</div>
|
2026-03-16 04:46:28 +01:00
|
|
|
)}
|
2026-03-18 21:32:03 +01:00
|
|
|
{isLoadingNewTab && showEditor && <EditorLoadingSkeleton />}
|
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>
|
|
|
|
|
)
|
|
|
|
|
}
|