import type React from 'react' import { cn } from '@/lib/utils' import { DiffView } from '../DiffView' import { BreadcrumbBar } from '../BreadcrumbBar' 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' | 'onRenameFilename' | 'noteLayout' | 'onToggleNoteLayout' > function EditorLoadingSkeleton() { return (
) } function DiffModeView({ diffContent, onToggleDiff }: { diffContent: string | null; onToggleDiff: () => void }) { return (
) } function RawModeEditorSection({ activeTab, entries, rawMode, rawModeContent, onRawContentChange, onSave, rawLatestContentRef, vaultPath, }: Pick< EditorContentModel, 'activeTab' | 'entries' | 'onRawContentChange' | 'onSave' | 'rawLatestContentRef' | 'rawModeContent' | '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 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, editor, entries, onNavigateWikilink, onEditorChange, isDeletedPreview, vaultPath, }: Pick< EditorContentModel, | 'showEditor' | 'cssVars' | 'editor' | 'entries' | 'onNavigateWikilink' | 'onEditorChange' | 'isDeletedPreview' | 'vaultPath' >) { 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, vaultPath, cssVars, onNavigateWikilink, onEditorChange, isDeletedPreview, rawLatestContentRef, rawModeContent, noteLayout, } = model const rootClassName = cn( 'flex flex-1 flex-col min-w-0 min-h-0', noteLayout === 'left' ? 'editor-content-layout--left' : 'editor-content-layout--centered', ) if (!activeTab) { return (
{isLoadingNewTab && showEditor && }
) } return (
{isLoadingNewTab && showEditor && }
) }