import type { SourceFormat } from "../types/editor"; import "./CodeEditor.css"; interface CodeEditorProps { /** The current source content to display. */ content: string; /** Determines the Monaco language mode (`"xml"` for PreTeXt, `"latex"` for LaTeX). */ sourceFormat: SourceFormat; /** Called (debounced 500 ms) whenever the user edits the content. */ onChange: (value: string | undefined) => void; /** If provided, Ctrl+Enter in the editor triggers this callback. */ onRebuild?: () => void; /** If provided, Ctrl+S in the editor triggers this callback. */ onSave?: () => void; /** Called when the user clicks "Import LaTeX" in the toolbar. */ onOpenLatexImport: () => void; /** Called when the user clicks "Edit Macros" in the toolbar. */ onOpenDocinfoEditor: () => void; /** * If provided, a "Convert to PreTeXt" button is shown in the toolbar. * Called when the user clicks to open the conversion confirmation dialog. */ onOpenConvertToPretext?: () => void; /** * Controls whether the "Convert to PreTeXt" button is enabled. * Should be `false` when conversion has failed. */ canConvertToPretext?: boolean; /** If provided, an "Assets" button is shown in the toolbar (PreTeXt mode only). */ onOpenAssets?: () => void; /** Called when the user clicks "Display Full Source" to open the assembled-source modal. */ onShowFullSource: () => void; /** * Called when the user clicks any locked leading line of the wrapper (the * opening tag, and the title line right after it when present). Hosts use * this to open the division's properties editor in the Table of Contents, * since the tag/title/xml:id aren't editable in-place. */ onRequestWrapperEdit?: () => void; } /** Imperative handle exposed via `forwardRef` for programmatic control. */ export interface CodeEditorHandle { /** Insert `text` at the current cursor position (or replace the selection). */ insertAtCursor: (text: string) => void; } /** * Monaco-based code editor with an attached toolbar. * * Manages its own undo/redo state so the toolbar buttons stay in sync with * the editor model. `onRebuild` and `onSave` callbacks are stored in refs * so keyboard shortcuts registered at mount time always call the latest * version without needing to re-register. * * Content is synced from props only when the prop value differs from what the * editor model already contains, to prevent cursor jumps on re-render. * * Exposes a {@link CodeEditorHandle} via `forwardRef` for programmatic control. */ declare const CodeEditor: import("react").ForwardRefExoticComponent>; export default CodeEditor;