import "./Editors.css";
import type { EditorContentChange, FeedbackSubmission, PretextProjectCopyRequest, ProjectAsset, SourceFormat } from "../types/editor";
import type { DocumentSection, DocumentChapter } from "../types/sections";
export interface editorProps {
    /** The source content string (PreTeXt XML, LaTeX, or Markdown). */
    source: string;
    /**
     * The format of `source`.  Defaults to `"pretext"` when omitted.
     * When set to `"latex"`, the editor displays a LaTeX code editor, `"markdown"` displays a Markdown code editor, and
     * derives a read-only PreTeXt preview via conversion.
     */
    sourceFormat?: SourceFormat;
    /**
     * Pre-computed PreTeXt XML corresponding to `source`.
     * Providing this avoids running the conversion on first render when the
     * host already has a cached result.  Only meaningful when
     * `sourceFormat` is not `"pretext"`.
     */
    pretextSource?: string;
    /**
     * The docinfo element for a pretext document, which can contain macros and similar
     * document wide information.
     */
    docinfo?: string;
    /**
     * Optional user-level common docinfo/preamble that project docinfo can import.
     */
    commonDocinfo?: string;
    /**
     * Whether this project should use the user's common docinfo/preamble.
     */
    useCommonDocinfo?: boolean;
    /**
     * Called when the project-level "use common docinfo" choice changes.
     */
    onUseCommonDocinfoChange?: (value: boolean) => void;
    /**
     * Called when the user edits their common docinfo from the project dialog.
     */
    onCommonDocinfoChange?: (value: string) => void;
    /**
     * Called whenever the source content changes (user edits in the code
     * editor or WYSIWYG editor).
     *
     * @param value - The new source string (`undefined` is passed by Monaco on
     *   certain edge cases; treat it as an empty string).
     * @param meta - The full derived {@link EditorContentChange} state at the
     *   time of the change, including the converted PreTeXt and any error.
     */
    onContentChange: (value: string | undefined, meta?: EditorContentChange) => void;
    /** Document title shown in the menu bar title field. */
    title?: string;
    /** Called when the user edits the title field. */
    onTitleChange?: (value: string) => void;
    /** If provided, a Save button is rendered in the menu bar. */
    onSaveButton?: () => void;
    /** Label for the Save button.  Defaults to `"Save"`. */
    saveButtonLabel?: string;
    /** If provided, a Cancel button is rendered in the menu bar. */
    onCancelButton?: () => void;
    /** Label for the Cancel button.  Defaults to `"Cancel"`. */
    cancelButtonLabel?: string;
    /** Called when a user submits feedback from any built-in feedback link. */
    onFeedbackSubmit?: (feedback: FeedbackSubmission) => void | Promise<void>;
    /** Optional URL for the current project, included in feedback submissions. */
    projectUrl?: string;
    /**
     * Called when user confirms creating a new project copy from LaTeX using
     * converted PreTeXt source.
     */
    onCreatePretextProjectCopy?: (request: PretextProjectCopyRequest) => void | Promise<void>;
    /**
     * If provided, `onSave` is called on Ctrl+S in addition to `onSaveButton`.
     * Useful when the host wants a keyboard shortcut to trigger saving without
     * necessarily showing an explicit Save button.
     */
    onSave?: () => void;
    /**
     * If provided, the right-hand panel shows a full iframe-based preview
     * instead of the Tiptap visual editor, and a rebuild button / Ctrl+Enter
     * shortcut become active.
     *
     * @param source - The current PreTeXt XML to render.
     * @param title - The current document title.
     * @param postToIframe - Helper to post a message into the preview iframe.
     */
    onPreviewRebuild?: (source: string, title: string, postToIframe: (url: string, data: any) => void) => void;
    /**
     * Controls the editing mode from the outside.  When provided, the
     * component operates in controlled mode; omit to use internal state
     * (uncontrolled).  "document" can also mean a single chapter in a book project.
     */
    editMode?: "document" | "sectioned";
    /**
     * Initial editing mode for uncontrolled usage.  Defaults to `"document"`.
     */
    defaultEditMode?: "document" | "sectioned";
    /**
     * Called when the user switches between `"document"` and `"sectioned"` mode.
     */
    onEditModeChange?: (mode: "document" | "sectioned") => void;
    /**
     * Called when the section list changes structurally (add, remove, reorder,
     * or rename).  Only fired in `"sectioned"` mode.
     */
    onSectionsChange?: (sections: DocumentSection[]) => void;
    /**
     * Called when the content of a single section is edited.  Only fired in
     * `"sectioned"` mode.
     */
    onSectionChange?: (section: DocumentSection) => void;
    /**
     * Whether this is an `"article"` (default) or `"book"` project.
     * When `"book"`, the TOC shows a chapter list that expands to show sections.
     */
    projectType?: "article" | "book";
    /**
     * Book chapter summaries used to populate the TOC chapter list.
     * Only meaningful when `projectType === "book"`.
     */
    chapters?: DocumentChapter[];
    /**
     * The id of the currently loaded/active chapter.
     * Only meaningful when `projectType === "book"`.
     */
    currentChapterId?: string | null;
    /**
     * Called when the user clicks a chapter in the TOC.
     * The host should fetch that chapter's source from the server and update
     * the `source` and `currentChapterId` props accordingly.
     */
    onChapterSelect?: (chapterId: string) => void;
    /**
     * Called when the user drags chapters into a new order.
     * Receives the full reordered `DocumentChapter[]`; the host is responsible
     * for persisting the new order (e.g., via a Rails PATCH request).
     * When omitted, chapter drag handles are hidden.
     */
    onChaptersReorder?: (chapters: DocumentChapter[]) => void;
    /**
     * Called when the editor needs a chapter's `content` and the chapter
     * doesn't already have it.  The host should fetch the chapter source
     * from the back-end and update the `chapters` prop with the loaded
     * `content` for that id.  Wired up in a later phase.
     */
    onChapterRequestLoad?: (chapterId: string) => void;
    /**
     * Called whenever a chapter's `content` changes from within the editor
     * (direct content edit, section reorder, or a section moved in/out of
     * this chapter).  The host is responsible for persisting the change.
     * Wired up in a later phase.
     */
    onChapterContentChange?: (chapterId: string, content: string) => void;
    /**
     * Called when the user clicks the "+ Add chapter" row at the bottom
     * of the chapter list.  The host should create a new chapter record
     * on the back-end and append it to the `chapters` array.
     * `afterChapterId` is the id of the chapter immediately preceding the
     * insertion point, or `null` to append at the end of the list.
     */
    onChapterAdd?: (afterChapterId: string | null) => void;
    /**
     * Called when the user removes a chapter from the TOC.  The host
     * should delete the corresponding back-end record and update the
     * `chapters` array accordingly.  Wired up in a later phase.
     */
    onChapterRemove?: (chapterId: string) => void;
    /**
     * Called when the user edits a chapter's title or other metadata
     * (xml:id, label).  Wired up in a later phase.
     */
    onChapterUpdate?: (chapterId: string, changes: {
        title?: string;
        xmlId?: string | null;
        label?: string | null;
    }) => void;
    /**
     * Assets already associated with this project.  Shown in the TOC Assets
     * panel and highlighted in the picker Library tab.  When omitted, the
     * Assets panel and picker are hidden entirely.
     */
    projectAssets?: ProjectAsset[];
    /**
     * All assets available in the user's library (across all projects).
     * Shown in the picker Library tab; assets not in `projectAssets` display
     * an "Add to project" affordance.  Defaults to `projectAssets` when omitted.
     */
    libraryAssets?: ProjectAsset[];
    /**
     * Optional notification called after the editor inserts the asset snippet at
     * the cursor.  The component handles insertion automatically (format-specific
     * snippet: `<image source="…"/>` for PreTeXt, `\includegraphics{…}` for
     * LaTeX, `![name](…)` for Markdown).  Use this hook for analytics, saving,
     * or any additional host-side side-effects.
     */
    onAssetInsert?: (asset: ProjectAsset) => void;
    /**
     * Called when the user uploads a file from the asset picker Upload tab.
     * The host uploads to the server and returns the created {@link ProjectAsset}
     * (with a server-assigned `filename`).  The asset is also added to the
     * project automatically by the host.
     */
    onAssetUpload?: (file: File) => Promise<ProjectAsset>;
    /**
     * Called when the user submits an external URL in the asset picker URL tab.
     * The host downloads the image, stores it in the library, associates it with
     * this project, and returns the created {@link ProjectAsset} with a stable
     * `filename`.  When omitted, the URL is inserted directly without a
     * server-side record.
     */
    onAssetAddUrl?: (url: string, name: string) => Promise<ProjectAsset>;
    /**
     * Called when the user picks a library asset not yet in this project.
     * The host should create the project–asset association (e.g. a Rails join
     * record).  Called before `onAssetInsert`.
     */
    onAssetAddFromLibrary?: (asset: ProjectAsset) => Promise<void> | void;
}
/**
 * Top-level editor component that wires together the Monaco code editor and
 * the right-hand preview panel (either Tiptap visual editor or full iframe
 * preview).  Also owns the menu bar and responsive layout logic.
 *
 * Content state is derived from props on every render via `useMemo` so the
 * parent always controls the source of truth; the component itself holds no
 * long-lived content state.
 *
 * Sectioned-editing state (section list, current section, TOC handlers, etc.)
 * is delegated to {@link useSectionedEditing}.
 */
declare const Editors: (props: editorProps) => import("react/jsx-runtime").JSX.Element;
export default Editors;
