'use client' import type { ContentEditorMode } from '@admin/utils/editor/content-editor-mode' import { Card, CardContent } from '@admin/components/ui/card' import { useContentEditor } from '@admin/hooks/content-editor/use-content-editor' import { useContentEditorTableAddControls } from '@admin/hooks/content-editor/use-content-editor-table-add-controls' import { cn } from '@admin/utils/shared/cn' import { EditorContent, EditorContext } from '@tiptap/react' import { EditorToolbar } from './editor-toolbar' import { MainToolbarContent } from './main-toolbar-content' import { MathBubbleMenu } from './math-popover' import { ModeToggleButton } from './mode-toggle-button' import { SelectionBubbleMenu } from './selection-bubble-menu' import { SlashCommandMenu } from './slash-command-menu' import { SourceMode } from './source-mode' import { TableAddControls } from './table-add-controls' import { TableBubbleMenu } from './table-bubble-menu' export interface ContentEditorProps { value?: string onChange?: (value: string) => void placeholder?: string disabled?: boolean className?: string defaultMode: ContentEditorMode } export function ContentEditor({ value = '', onChange, placeholder, disabled = false, className, defaultMode }: ContentEditorProps) { const { activeSlashIndex, closeSlashMenu, editor, filteredSlashCommands, handleModeChange, handleSourceChange, handleSourceSelectionChange, mode, selectSlashCommand, setActiveSlashIndex, setSlashSearch, slashMenu, slashSearchQuery, sourceValue, sourceSelectionRequest } = useContentEditor({ value, onChange, placeholder, disabled, defaultMode }) const isSourceMode = mode === 'source' const tableAddControls = useContentEditorTableAddControls(!editor || isSourceMode ? null : editor) if (!editor) return null return ( {isSourceMode ? ( } className="max-h-none min-h-0 flex-1 resize-none rounded-none border-0" /> ) : ( <>
)}
) }