/** * PresentationML high-level API — a LENS over presentation/slide DOMs. * * `Presentation`/`Slide` operate on the live XML of /ppt/presentation.xml * and slide parts. Media, animations, transitions, notes and all unmodeled * content are preserved byte-for-byte unless touched (L3 via the document * layer's dirty tracking). * * DOM ownership model: the document layer's cache is the single source * of truth for every modeled DOM. * - Parts read from an opened file are parsed through * `OfficeDocument.xml()`; lens mutations mark them dirty via * `office.markDirty` and `office.save()` reserializes them. * - Parts this module creates itself (`create()` skeleton parts, slides * from `addSlide()`) register their freshly parsed DOM in the same * cache via its sync priming hook (entry born dirty, so the DOM is * always serialized at save — these parts are new, never raw-copied, * so this costs no fidelity). Either way `office.xml()` returns the * exact instance the lenses mutate and `save()` is a pure delegate to * `office.save()`. * * Eager-load note (documented deviation from the original CONTRACTS §9.1 * wording): `open()` eagerly loads presentation.xml, every slide part in * p:sldIdLst, every slide master in p:sldMasterIdLst and the layouts those * masters reference — masters/layouts are needed so that the synchronous * `layouts()` / `addSlide()` can walk p:sldLayoutIdLst and clone layout * placeholders without an async step. Loaded-but-clean DOMs still * raw-copy at save, so L3 is unaffected. Themes and everything else stay * lazy. * * `Presentation.create()` produces a minimal single-slide deck that real * PowerPoint opens without repair — presentation, slide master, slide * layout, slide, and theme parts wired with correct relationships. See * CONTRACTS.md §pptx for the exact part list. */ import { OfficeDocument } from '../document/index.js'; import { XmlElement, type XmlDocument } from '../xml/index.js'; /** PresentationML main namespace (the `p:` prefix). */ export declare const PML_NAMESPACE = "http://schemas.openxmlformats.org/presentationml/2006/main"; /** DrawingML main namespace (the `a:` prefix) — used by all three apps. */ export declare const DRAWINGML_NAMESPACE = "http://schemas.openxmlformats.org/drawingml/2006/main"; /** * Lens over one slide part. Obtain instances via * {@link Presentation.slides} / {@link Presentation.addSlide}; they are * stable (the same part always yields the same lens). */ export declare class Slide { #private; /** @internal Construct via Presentation only. */ constructor(internal: symbol, pres: Presentation, partName: string, doc: XmlDocument); /** Absolute part name, e.g. '/ppt/slides/slide1.xml'. */ get partName(): string; /** * Current zero-based position of this slide in p:sldIdLst, or -1 when * the slide has been removed from the deck. */ get index(): number; /** * Absolute part name of the slide layout this slide references through * its slideLayout relationship, or undefined when it has none. */ get layoutPartName(): string | undefined; /** * The `p:sld` root element of this slide. Direct DOM edits require * marking the part dirty via `presentation.office.markDirty(partName)`. */ root(): XmlElement; /** * Extract the slide's text: one string per DrawingML paragraph (`a:p`) * that contains at least one non-empty text run, across the whole * `p:cSld/p:spTree` in document order. Runs within a paragraph are * concatenated; `a:br` becomes '\n'. mc:AlternateContent is read * through the mce module's selection (never both branches). */ text(): readonly string[]; /** * Replace the text of the slide's title placeholder (`p:ph` of type * 'title' or 'ctrTitle') with a single run containing `text`, preserving * the run properties (`a:rPr`) of the first existing run. Extra title * paragraphs are removed; `a:pPr` and `a:endParaRPr` are kept. Marks * the slide part dirty. Throws when the slide has no title placeholder. */ setTitle(text: string): void; } /** Options for {@link Presentation.addSlide}. */ export interface AddSlideOptions { /** * Index into {@link Presentation.layouts} of the layout the new slide * should reference. Default 0 (the presentation's first layout). * Mutually exclusive with `layoutPartName`. */ layoutIndex?: number; /** * Absolute part name of the layout the new slide should reference * (e.g. '/ppt/slideLayouts/slideLayout2.xml'). Mutually exclusive with * `layoutIndex`. */ layoutPartName?: string; } /** @internal One resolved p:sldId entry. */ interface SlideRef { /** The live p:sldId element. */ el: XmlElement; /** Numeric slide id (p:sldId/@id). */ id: number; /** Relationship id (p:sldId/@r:id). */ rid: string; /** Resolved absolute slide part name (stored case). */ partName: string; } /** * A PowerPoint presentation (pptx/pptm/potx/potm/ppsx/ppsm/ppam). */ export declare class Presentation { #private; /** @internal Construct via {@link Presentation.open} / {@link Presentation.create}. */ constructor(internal: symbol, office: OfficeDocument); /** * Open an existing PowerPoint-family file (any of the 7 modern * extensions — detection is by content type, never file extension). * Eagerly loads the DOMs of presentation.xml, every slide listed in * p:sldIdLst, and the slide masters + layouts (see module doc comment). * Throws `Error` when the bytes are not a PowerPoint-family package or * a p:sldId entry cannot be resolved to a slide part. */ static open(bytes: Uint8Array): Promise; /** * Create a new single-slide pptx that real PowerPoint opens without * repair: presentation.xml (+ rels), slideMaster1 (+ rels), slideLayout1 * (+ rels), slide1 (+ rels), theme1 (complete minimal a:themeElements), * and content types for all of them. The slide is blank (empty spTree). */ static create(): Presentation; /** The underlying office document (escape hatch to package and parts). */ get office(): OfficeDocument; /** Slides in presentation order (p:sldIdLst order). Stable lenses. */ slides(): readonly Slide[]; /** * Absolute part names of the slide layouts reachable from the deck's * slide masters, in presentation order: masters in p:sldMasterIdLst * order, each master's layouts in its p:sldLayoutIdLst order. This is * the list {@link AddSlideOptions.layoutIndex} indexes into. */ layouts(): readonly string[]; /** * Append a new slide at the end of the deck. The slide part is minimal: * the required group-shape scaffolding plus one empty placeholder shape * cloned (type/idx only, no layout-only content) from each non-date/ * footer/slide-number placeholder of the chosen layout, so the new * slide inherits the layout's geometry and formatting and `setTitle` * works when the layout has a title. Registers the part in * [Content_Types].xml, the slide→layout relationship, the presentation * relationship, and a p:sldId (smallest free id ≥ 256, fresh rId) at * the end of p:sldIdLst. Marks affected parts dirty. Returns the new * slide's lens; its `text()` is empty. */ addSlide(options?: AddSlideOptions): Slide; /** * Remove the slide at `index` (p:sldIdLst order): deletes its p:sldId * entry, the presentation relationship, the slide part with its .rels * and content-type override, and any notes-slide parts the slide * references (they are slide-specific). Shared targets (layouts, media) * are left alone. Marks the presentation part dirty. Throws when * `index` is out of range. * * Removing the FINAL slide is deliberately permitted: a zero-slide deck * (empty p:sldIdLst) is valid PresentationML — PowerPoint's own UI * produces one when the user deletes every slide, and a deck emptied * through this API opens repair-free in real PowerPoint (validated via * the office-spec L2 harness against PowerPoint 16.0.20131.20154). */ removeSlide(index: number): void; /** * Serialize to file bytes — a pure delegate to the document layer's L3 * save pipeline (dirty DOMs reserialized, untouched parts copied * byte-for-byte). */ save(): Promise; /** @internal Resolved p:sldId entries in document order. */ _slideRefs(): readonly SlideRef[]; /** * @internal Mark a lens-managed part dirty through the document layer. * Throws when the part is gone (e.g. a removed slide's lens is used * afterwards). */ _markSlideDirty(partName: string): void; } export {}; //# sourceMappingURL=index.d.ts.map