import type { SourceFormat } from "./editor"; /** * Every structural element in a PreTeXt project — book, article, chapter, * section, worksheet, etc. — is a `Division`. Divisions are stored as a flat * pool of records on the host (Rails) side; hierarchy is expressed by * embedding `` placeholder tags inside a parent * division's `content`. * * Type-specific aliases (``, ``) * are accepted by the editor as equivalent to ``. * * Root divisions (type `"book"`, `"article"`, or `"slideshow"`) are the entry * point for building the tree. Non-root divisions whose `xmlId` does not * appear in any other division's ref placeholders are considered *orphaned* and * are shown separately in the TOC so they can be placed. * * `"latex"` and `"markdown"` divisions are always leaf nodes for now — they * cannot contain child ref placeholders. Syntax for embedded refs in those * formats will be added in a future release. */ /** * The PreTeXt element type of a division. Values match the XML tag name so * the type can be used directly when serialising (`<${type}>…`). */ export type DivisionType = "book" | "article" | "slideshow" | "part" | "chapter" | "section" | "subsection" | "subsubsection" | "introduction" | "conclusion" | "worksheet" | "handout" | "exercises" | "references" | "glossary" | "solutions" | "reading-questions" | "paragraphs"; /** * A single division record, as stored in the host database and passed to * the editor. */ export interface Division { /** Stable server-assigned identifier (Rails record id or UUID). */ id: string; /** * The `xml:id` attribute value for this division. Used as the `ref` * value in `` placeholders in parent divisions. * Must be unique within the project. */ xmlId: string; /** Plain-text display title (extracted from ``). */ title: string; /** The PreTeXt element type of this division. */ type: DivisionType; /** * The source format of this division's content. * Replaces the project-level `sourceFormat` prop; individual divisions * may eventually be converted between formats independently. */ sourceFormat: SourceFormat; /** * The full source string for this division. * * For PreTeXt divisions this is the complete XML including the outer * wrapper element, e.g. `<section xml:id="..."><title>……`. * Parent divisions may include `` placeholders * where child divisions should be rendered. * * For LaTeX / Markdown divisions this is raw source; child ref placeholders * are not yet supported for these formats. */ content: string; } /** * @deprecated Use `DivisionType` instead. This alias will be removed in a * future release once all consumers have migrated to the `Division` model. */ export type DocumentSectionType = DivisionType; /** * @deprecated Use `Division` instead. This alias will be removed in a future * release once all consumers have migrated to the `Division` model. */ export type DocumentSection = Division; /** * @deprecated The chapter/section split no longer exists in the `Division` * model — chapters are simply divisions with `type: "chapter"`. This alias * will be removed in a future release. */ export interface DocumentChapter { id: string; title: string; xmlId?: string; label?: string; content?: string; sections?: Division[]; } /** * @deprecated The `wrapper` concept has been removed. Use `Division` records * and `` placeholders instead. */ export interface DocumentSplitResult { wrapper: string; sections: Division[]; }