Skip to content

Class: Slide ​

The part-level surface a Shape resolves against.

Implements ​

Constructors ​

Constructor ​

new Slide(presentation, part, slideId, index): Slide

Parameters ​

ParameterTypeDescription
presentationPresentation-
partPartThe slide's OPC part (/ppt/slides/slideN.xml).
slideIdnumberThe slide id from p:sldIdLst (p:sldId/@id).
indexnumberZero-based position in presentation order.

Returns ​

Slide

Properties ​

index ​

readonly index: number

Zero-based position in presentation order.


part ​

readonly part: Part

The slide's OPC part (/ppt/slides/slideN.xml).

Implementation of ​

ShapeHost.part


presentation ​

readonly presentation: Presentation


slideId ​

readonly slideId: number

The slide id from p:sldIdLst (p:sldId/@id).

Accessors ​

background ​

Get Signature ​

get background(): SlideBackground | null

The slide's effective background (p:cSld/p:bg), decoded into a typed SlideBackground. Resolved through the inheritance chain: the slide's own p:bg wins; failing that the slideLayout's, then the slideMaster's — the result's source records which supplied it. null when nothing in the chain defines a background.

Colour tokens resolve against this slide's theme; an image background's r:embed resolves to an absolute part name through the owning part's relationships (the layout's rels for a layout-inherited image, etc.). Solid, gradient, pattern and image backgrounds are the ones the writer authors and so round-trip faithfully; themeRef is read-only for imported decks.

Returns ​

SlideBackground | null


comments ​

Get Signature ​

get comments(): Comment[]

The slide's legacy review comments (p:cm in its comments/commentN.xml part), [] when it has none. Each Comment carries its body text, marker position (EMU), timestamp, and its author resolved through the deck-wide Presentation.commentAuthors registry (@authorId → name/initials). These are the comments the writer authors via slide.addComment(...); the 2018 modern comment parts (p188:cm) are a separate schema, read by modernComments.

Returns ​

Comment[]


element_ ​

Get Signature ​

get element_(): Element

Escape hatch: the underlying p:sld element. After mutating it call markDirty, or save() writes the original bytes. Slide-level DOM access is also reachable as slide.part.dom; this getter is the same node, on the same rung of the ladder as Shape.element_ and the rest.

Returns ​

Element


hasAnimations ​

Get Signature ​

get hasAnimations(): boolean

Whether the slide carries build animations (p:timing with a <p:bldP> or a presetID-bearing time node). The animation tree itself is preserved opaquely; see animationSpids.

Returns ​

boolean


hidden ​

Get Signature ​

get hidden(): boolean

Whether this slide is hidden (p:sld/@show="0"). The attribute is xsd:boolean defaulting to true, so an absent attribute means shown. Hidden slides are dropped from PowerPoint/LibreOffice presentations and exported PDFs, so render order diverges from model order when any earlier slide is hidden.

Returns ​

boolean

Set Signature ​

set hidden(value): void

Hide or show this slide. Hiding writes p:sld/@show="0"; showing removes the attribute, restoring PowerPoint's canonical shown form (absent ⇒ shown). Marks the slide part dirty.

Parameters ​
ParameterType
valueboolean
Returns ​

void


layout ​

Get Signature ​

get layout(): SlideLayout | null

The slide layout this slide is bound to (slideLayout relationship), as a modeled SlideLayout, or null when the slide has no layout. The layout carries the placeholder geometry and background a slide inherits; walk on to master and theme through it (slide.layout.master.theme).

Returns ​

SlideLayout | null


master ​

Get Signature ​

get master(): SlideMaster | null

The slide master this slide resolves against, via its layout, as a modeled SlideMaster, or null when the layout/master chain is broken. The master owns the colour map (schemeClr token → theme slot) and the default text styles a placeholder inherits.

Returns ​

SlideMaster | null


modernComments ​

Get Signature ​

get modernComments(): ModernComment[]

The slide's modern (2018) review comments (p188:cm in its modernComment_*.xml part), [] when it has none. Each ModernComment carries its body text, created timestamp, marker position (EMU), its author resolved through the deck-wide Presentation.modernCommentAuthors registry (@authorId GUID → name/initials), and its reply thread nested under replies. Read-only — the writer authors the legacy schema; see Presentation.commentSchema to tell which schema a deck uses.

Returns ​

ModernComment[]


name ​

Get Signature ​

get name(): string | null

Authoring name of the slide (p:cSld/@name), or null if unnamed.

Returns ​

string | null


notesSlide ​

Get Signature ​

get notesSlide(): NotesSlide | null

The slide's speaker-notes slide (notesSlideN.xml) as a modeled NotesSlide, or null when the slide has no notes slide part. Beyond the body text notesText/notesTextFrame surface, this exposes the notes slide's three placeholders — the slide thumbnail (slideImage), the notes body, and the slide-number field (slideNumber) — each with its geometry and (where present) a navigable text frame.

The writer authors all three placeholders but leaves sldImg/sldNum with an empty p:spPr, so on an authored deck their geometry reads null while an imported deck carries the notesMaster-derived geometry. The body text and the slide-number field round-trip either way.

Returns ​

NotesSlide | null


notesText ​

Get Signature ​

get notesText(): string | null

The slide's speaker-note text — the companion to text for the notes that text deliberately excludes. Delegates to notesSlide: finds the notes body placeholder (p:ph type="body") and flattens its text frame the same way TextFrame.text does (paragraphs joined by \n).

Returns null when the slide has no notes slide part at all — distinct from '', which means a notes slide exists but its body is empty (PowerPoint often attaches an empty notes slide to every slide). Only the body placeholder is read; the slide-thumbnail (sldImg) and slide-number (sldNum) placeholders a notes slide also carries are read via notesSlide.

Returns ​

string | null


notesTextFrame ​

Get Signature ​

get notesTextFrame(): TextFrame | null

The slide's speaker-note body as a navigable TextFrame — the rich companion to notesText, which flattens the same body to a plain string. Walk paragraphs → runs to recover per-run formatting (bold/italic/underline, colour, size, face) and any notes hyperlink that notesText discards.

null when the slide has no notes slide part (the same boundary notesText returns null at), and also when a notes part exists but carries no body-placeholder text frame — there is then no frame to hand back (whereas notesText reports '' for that empty-body case). Convenience for notesSlide.textFrame; see notesSlide for the whole modeled notes slide (its sldImg/sldNum placeholders and their geometry).

Returns ​

TextFrame | null


opc ​

Get Signature ​

get opc(): OpcPackage

The deck's OPC package. Convenience for presentation.opc, and the member ShapeHost names so a shape can reach a referenced part (an image, a chart) the same way whether it lives on a slide, a layout, or a master.

Returns ​

OpcPackage

The package the host belongs to, for reaching a referenced part (image, chart, …).

Implementation of ​

ShapeHost.opc


partName ​

Get Signature ​

get partName(): string

Partname of this slide's part.

Returns ​

string

Partname of part.

Implementation of ​

ShapeHost.partName


relationships ​

Get Signature ​

get relationships(): Relationships

This slide part's relationships (image embeds, layout, hyperlinks, …).

Returns ​

Relationships

part's relationships — image embeds, hyperlinks, chart references.

Implementation of ​

ShapeHost.relationships


shapes ​

Get Signature ​

get shapes(): AnyShape[]

Top-level shapes in the slide's shape tree, in document order.

Returns ​

AnyShape[]


showMasterSp ​

Get Signature ​

get showMasterSp(): boolean

Whether this slide draws the master's non-placeholder shapes (p:sld/@showMasterSp). xsd:boolean defaulting to true, so an absent attribute means shown — the same shape as hidden.

This is the switch that decides whether SlideMaster.shapes belongs on this slide. A slide the author gave a full-bleed image or a section divider usually sets it to 0, and a renderer that paints the master's band and logo anyway puts the template's furniture on top of a slide that deliberately hid it. Placeholders are unaffected: the flag suppresses only the master's decorative shapes.

Returns ​

boolean


slideNumberPlaceholder ​

Get Signature ​

get slideNumberPlaceholder(): AutoShape | null

The slide's own slide-number placeholder (p:sp with p:ph type="sldNum", carrying an <a:fld type="slidenum">), or null when the slide shows no slide number of its own. This is the concrete shape the writer emits for a slide given slide.slideNumber, or added to a master defined with slideNumber; its geometry and run formatting read off the returned AutoShape the same as any placeholder.

Scoped to the slide's own shape tree — a slide number inherited purely from the master's p:hf/placeholder (with no shape on the slide) is a master-level concern this getter does not resolve.

Returns ​

AutoShape | null


tags ​

Get Signature ​

get tags(): Tag[]

The slide's programmatic tags (p:custDataLst/p:tags on the slide part, resolved to ppt/tags/tagN.xml) as { name, val } string pairs, [] when it has none. Host/add-in metadata with no visible rendering and no writer — read-only, preserved byte-for-byte on round-trip. Deck-level tags are Presentation.tags.

Returns ​

Tag[]


text ​

Get Signature ​

get text(): string

All text on the slide, flattened in document order — the read-model counterpart to TextFrame.text one level up. Every text-bearing shape contributes its text, recursing into groups (GroupShape) and reading table cells (GraphicFrame.table) and SmartArt node text (GraphicFrame.diagram); text-free shapes (pictures, connectors, empty boxes) contribute nothing. Blocks are joined by \n; within a table, cells in a row are joined by \t and rows by \n.

A diagram contributes for the same reason a table does: its nodes are body text PowerPoint itself searches and spell-checks, so a slide whose whole message is a SmartArt graphic would otherwise flatten to the empty string.

This is deliberately scoped to the slide's own shape tree. It does not include speaker notes (read those via notesText) or chart data labels (read those via GraphicFrame.chart); folding those in would force ordering and separator choices a caller is better placed to make. Extract a whole deck with deck.slides.map((s) => s.text).

Returns ​

string


theme ​

Get Signature ​

get theme(): Theme | null

The theme this slide resolves colour and font tokens against, via its layout → master → theme, as a modeled Theme, or null. Read its Theme.colorScheme/Theme.fontScheme to see the literal palette and faces a schemeClr/+mj-* token resolves to.

Returns ​

Theme | null


transition ​

Get Signature ​

get transition(): TransitionInfo | null

The slide's show transition (p:transition), decoded into a typed model, or null when the slide has none. Handles both PowerPoint forms: the bare <p:transition> and the mc:AlternateContent wrapper that carries the exact p14:dur duration (the p14 Choice is preferred so durationMs is recovered).

Returns ​

TransitionInfo | null

Set Signature ​

set transition(value): void

Set or clear the slide's show transition. Assigning null removes it. Writing a transition with durationMs emits the mc:AlternateContent form (a p14 Choice carrying p14:dur plus a base mc:Fallback); otherwise the bare <p:transition> is written. The node is inserted at its schema slot — after p:clrMapOvr, before p:timing/p:extLst. Marks the slide part dirty.

The new transition is built from the current one before that is removed: it keeps the sound unless sound says otherwise (see TransitionInput.sound), and a value that is refused (a durationMs or advanceAfterMs that is not a number of milliseconds from 0, or a sound that is not the slide's own) leaves the slide as it was.

Parameters ​
ParameterType
valueTransitionInput | null
Returns ​

void

Methods ​

addNotes() ​

addNotes(text): NotesSlide

Give this slide the speaker notes text, and return the resulting NotesSlide. A starts a new paragraph, matching the write-side addNotes; the runs carry no formatting of their own, so style them afterwards through notesTextFrame.

The counterpart to the read side's notesText/notesTextFrame/notesSlide getters, and the way to annotate a slide that has no notes part at all — the state an importSlide without { importNotes: true } leaves behind, and the one a notesTextFrame edit cannot reach because there is no frame to hand back. Calling it on a slide that already has notes replaces the body text and leaves the rest of the part (its geometry, its other two placeholders) alone.

Creating the part pulls in what a notes slide must bind to: a notesMaster, of which a presentation may hold at most one. This deck's own is reused when it has one; otherwise one is installed, bound to a clone of this deck's theme so it resolves against the destination palette. That is the same single-master rule importSlide({ importNotes: true }) and appendSlides follow, so mixing the three cannot produce a second notes master.

Parameters ​

ParameterType
textstring

Returns ​

NotesSlide


addPicture() ​

addPicture(image, options): Picture

Add a picture (p:pic) from raw image bytes and return it. Creates a media part under /ppt/media/, registers its content type, wires an image relationship from this slide, and appends the picture to the shape tree. Geometry is required (EMU); width and height must be positive. The image format is sniffed from the bytes unless extension/contentType are given.

Parameters ​

ParameterType
imageUint8Array
optionsAddPictureOptions

Returns ​

Picture


addTextBox() ​

addTextBox(options): AutoShape

Append a text box (p:sp with txBox="1") to the slide's shape tree and return it. Geometry is required (EMU); width and height must be positive. Allocates a drawing id unique within the slide. Marks the slide part dirty.

Parameters ​

ParameterType
optionsAddTextBoxOptions

Returns ​

AutoShape


flattenAnimations() ​

flattenAnimations(): boolean

Flatten the slide's build animations: remove the <p:timing> block so the slide renders and edits as its final static state, with every shape shown at once. Gated like hasAnimations — a <p:timing> that is purely a media loop (no <p:bldP> or presetID) is preserved so media playback survives. Marks the slide part dirty and returns true only when a timing block was removed.

This removes click-through staging only; it does not delete shapes. If a slide animated alternating states over the same region, the flattened render shows them all at once — keep that distinct from removing staged/duplicate shapes.

Returns ​

boolean


markDirty() ​

markDirty(): void

Mark this slide's part dirty so save() reserializes it. Call after mutating element_.

Returns ​

void


placeholder() ​

placeholder(type, idx?): AutoShape | undefined

The first placeholder of the given type (p:ph/@type, e.g. title, ctrTitle, subTitle, body), optionally narrowed by idx. Returns undefined when none match. Only p:sp shapes can be placeholders, so the result is an AutoShape.

Parameters ​

ParameterType
typestring
idx?string

Returns ​

AutoShape | undefined


shapeById() ​

shapeById(id): AnyShape | undefined

The first top-level shape with the given drawing id (p:cNvPr/@id), or undefined.

Parameters ​

ParameterType
idnumber

Returns ​

AnyShape | undefined


shapeByIdDeep() ​

shapeByIdDeep(id): AnyShape | undefined

The first shape anywhere in the slide's shape tree with the given drawing id (p:cNvPr/@id), descending into groups — unlike shapeById, which scans only top-level shapes. Walked pre-order (a group is visited before its children), matching how the writer allocates ids. undefined when no shape carries that id.

Drawing ids are unique within a slide, so the first match is the only match; the pre-order walk just fixes a deterministic order. This backs the connector-binding resolution (Connector.startConnection), which must resolve a binding into a group that top-level shapeById cannot see.

Parameters ​

ParameterType
idnumber

Returns ​

AnyShape | undefined

Implementation of ​

ShapeHost.shapeByIdDeep


shapeByName() ​

shapeByName(name): AnyShape | undefined

The first top-level shape with the given name (p:cNvPr/@name), or undefined.

Parameters ​

ParameterType
namestring

Returns ​

AnyShape | undefined


themeContext() ​

themeContext(): ThemeContext

The slide's resolved theme context (clrMap + clrScheme + the theme fmtScheme + fontScheme, plus the layout/master roots), walked once from slide → layout → master → theme and cached on this proxy. Backs the read-model resolved getters (Shape.resolvedFill, Run.resolvedColor, Run.resolvedSizePt, Run.resolvedFontFace) so a schemeClr token — including one delivered through a shape's p:style fillRef/lnRef — resolves to a literal hex, and a placeholder run's inherited size/typeface (a +mj-*/+mn-* font token included) resolves to a literal value. The maps/roots are empty when the theme chain is incomplete, in which case tokens simply stay unresolved.

Returns ​

ThemeContext

Implementation of ​

ShapeHost.themeContext