import type React from 'react' import { DiffView } from '../DiffView' import { BreadcrumbBar } from '../BreadcrumbBar' import { TitleField } from '../TitleField' import { NoteIcon } from '../NoteIcon' import { ArchivedNoteBanner } from '../ArchivedNoteBanner' import { ConflictNoteBanner } from '../ConflictNoteBanner' import { RawEditorView } from '../RawEditorView' import { SingleEditorView } from '../SingleEditorView' import type { useEditorContentModel } from './useEditorContentModel' type EditorContentModel = ReturnType type BreadcrumbActions = Pick< EditorContentModel, | 'diffMode' | 'diffLoading' | 'onToggleDiff' | 'effectiveRawMode' | 'onToggleRaw' | 'forceRawMode' | 'showAIChat' | 'onToggleAIChat' | 'inspectorCollapsed' | 'onToggleInspector' | 'showDiffToggle' | 'onToggleFavorite' | 'onToggleOrganized' | 'onDeleteNote' | 'onArchiveNote' | 'onUnarchiveNote' > function EditorLoadingSkeleton() { return (
) } function DiffModeView({ diffContent, onToggleDiff }: { diffContent: string | null; onToggleDiff: () => void }) { return (
) } function RawModeEditorSection({ activeTab, entries, rawMode, onRawContentChange, onSave, rawLatestContentRef, vaultPath, }: Pick< EditorContentModel, 'activeTab' | 'entries' | 'onRawContentChange' | 'onSave' | 'rawLatestContentRef' | 'vaultPath' > & { rawMode: boolean }) { if (!rawMode || !activeTab) return null return ( {})} onSave={onSave ?? (() => {})} latestContentRef={rawLatestContentRef} vaultPath={vaultPath} /> ) } function bindPath(cb: ((path: string) => void) | undefined, path: string) { return cb ? () => cb(path) : undefined } function ActiveTabBreadcrumb({ activeTab, barRef, wordCount, path, actions, }: { activeTab: NonNullable barRef: React.RefObject wordCount: number path: string actions: BreadcrumbActions }) { return ( ) } function TitleSection({ activeTab, entryIcon, hasDisplayIcon, path, showTitleSection, titleSectionRef, vaultPath, onTitleChange, }: Pick< EditorContentModel, 'activeTab' | 'entryIcon' | 'hasDisplayIcon' | 'path' | 'showTitleSection' | 'titleSectionRef' | 'vaultPath' | 'onTitleChange' >) { if (!activeTab) return null return (
{showTitleSection && ( <>
{!hasDisplayIcon && (
)}
{hasDisplayIcon && } onTitleChange?.(path, newTitle)} />
)}
) } function EditorChrome({ isArchived, onUnarchiveNote, path, isConflicted, onKeepMine, onKeepTheirs, diffMode, diffContent, onToggleDiff, }: Pick< EditorContentModel, 'isArchived' | 'onUnarchiveNote' | 'path' | 'isConflicted' | 'onKeepMine' | 'onKeepTheirs' | 'diffMode' | 'diffContent' | 'onToggleDiff' >) { return ( <> {isArchived && onUnarchiveNote && ( onUnarchiveNote(path)} /> )} {isConflicted && ( onKeepMine?.(path)} onKeepTheirs={() => onKeepTheirs?.(path)} /> )} {diffMode && } ) } function EditorCanvas({ showEditor, cssVars, activeTab, entryIcon, hasDisplayIcon, path, showTitleSection, titleSectionRef, vaultPath, onTitleChange, editor, entries, onNavigateWikilink, onEditorChange, isDeletedPreview, }: Pick< EditorContentModel, | 'showEditor' | 'cssVars' | 'activeTab' | 'entryIcon' | 'hasDisplayIcon' | 'path' | 'showTitleSection' | 'titleSectionRef' | 'vaultPath' | 'onTitleChange' | 'editor' | 'entries' | 'onNavigateWikilink' | 'onEditorChange' | 'isDeletedPreview' >) { if (!showEditor) return null return (
) } export function EditorContentLayout(model: EditorContentModel) { const { activeTab, isLoadingNewTab, entries, editor, diffMode, diffContent, onToggleDiff, effectiveRawMode, onRawContentChange, onSave, showEditor, isArchived, onUnarchiveNote, path, isConflicted, onKeepMine, onKeepTheirs, breadcrumbBarRef, wordCount, titleSectionRef, showTitleSection, hasDisplayIcon, entryIcon, vaultPath, onTitleChange, cssVars, onNavigateWikilink, onEditorChange, isDeletedPreview, rawLatestContentRef, } = model if (!activeTab) { return (
{isLoadingNewTab && showEditor && }
) } return (
{isLoadingNewTab && showEditor && }
) }