cupertino-files / KeynoteDocument
Class: KeynoteDocument
Defined in: src/keynote/document.ts:652
Extends
Properties
container
readonlycontainer:IWorkContainer
Defined in: src/tsa/document.ts:128
Inherited from
format
readonlyformat:FormatInfo
Defined in: src/tsa/document.ts:130
Inherited from
store
readonlystore:ObjectStore
Defined in: src/tsa/document.ts:129
Inherited from
Accessors
app
Get Signature
get app():
IWorkApp
Defined in: src/tsa/document.ts:170
Returns
Inherited from
era
Get Signature
get era():
"iwork13"|"iwork16"|"iwork19"|"modern"|"current"|"future"
Defined in: src/tsa/document.ts:336
Format era this document was written by (see tsp/version.ts).
Returns
"iwork13" | "iwork16" | "iwork19" | "modern" | "current" | "future"
Inherited from
loops
Get Signature
get loops():
boolean
Defined in: src/keynote/document.ts:690
Returns
boolean
slideNumbersVisible
Get Signature
get slideNumbersVisible():
boolean
Defined in: src/keynote/document.ts:686
Returns
boolean
Methods
addImage()
addImage(
slideIndex,data,options):object
Defined in: src/keynote/document.ts:1404
Put a picture on a slide.
The archive is the measured slide-image shape, unanimous across the corpus's 22: the drawable's parent is the slide, the exterior wrap is the on-page shape, the aspect ratio is locked, stand-in title and caption ride along, and the style is the theme's image-0-imageStyle media style. The image lands in the slide's own package component beside its other content and joins both drawable lists — ownership and paint order. Sized like insertInlineImage: explicit width/height win, otherwise the intrinsic size is fitted to maxWidth (default 400 pt). Unless x/y say otherwise the picture is centred on the slide.
Parameters
slideIndex
number
data
Uint8Array
options
fileName
string
height?
number
maxWidth?
number
width?
number
x?
number
y?
number
Returns
object
dataId
dataId:
bigint
imageId
imageId:
bigint
Agent Tool
add_image
addSlide()
addSlide(
options?):KeynoteSlide
Defined in: src/keynote/document.ts:1045
Add a slide, copying an existing one.
Keynote slides are not blank canvases — a usable one carries a style, a template-slide reference, placeholders and a transition, and inventing that set from nothing produces a slide the app quietly repairs or rejects. Copying an existing slide inherits a working set, which is also how Keynote's own "new slide" works: it instantiates a master.
after is a slide index; -1 puts the new slide first. By default the copy is emptied of its drawables, giving a fresh slide on the same layout; pass withContent to duplicate outright.
master instead instantiates a layout — one of masterSlides, by name or id — the way the app's "add slide" does: the master is deep-copied, its decorations and placeholders included, and the copy is made a content slide. The corpus states the difference between a content slide and its master exactly: the slide carries a reference to the master, a note, and the slide-number placeholder's storage holds the number attachment; it never carries the master's name, object placeholder, style lists or thumbnail texts. The title and body are emptied like a copied slide's.
Parameters
options?
after?
number
copyOf?
number
master?
string | bigint
withContent?
boolean
Returns
Agent Tool
manage_slides
allNotes()
allNotes():
object[]
Defined in: src/keynote/document.ts:1567
Presenter notes of every slide, in order.
Returns
object[]
allText()
allText():
string
Defined in: src/tsa/document.ts:279
Concatenated plain text of all in-document storages (reading order approximation).
Returns
string
Inherited from
audit()
audit():
AuditFinding[]
Defined in: src/tsa/document.ts:242
Every fault this library knows how to recognise offline, across the whole document — the checks a person otherwise performs by opening the file in an app. Each finding names a state some review round has already watched an app refuse, repair destructively, or render against the author's intent. save() refuses the error classes it can see; audit() reports them without saving, warnings included, so a builder can ask "what would a person object to?" before shipping a document.
Returns
Agent Tool
audit_document
Inherited from
charts()
charts():
ChartModel[]
Defined in: src/tsa/document.ts:210
Every chart, with its plotted data (see ChartModel).
Returns
Inherited from
compact()
compact():
number
Defined in: src/tsa/document.ts:363
Drop archives nothing can reach, returning how many went.
What this collects today is very little, and that is worth knowing before reaching for it. Removing a sheet or a table unlinks it from the document tree, but the calc engine keeps its own references to every table it ever knew, so those archives stay genuinely reachable. The gap is in removal — unregistering a table's formula owners is calc-engine surgery this library does not do yet — not in the walk. What compaction does reclaim is objects created and then abandoned, and the Data/ files (a removed picture's bytes) that no surviving object names; the count is archives and files together.
Roots are the package metadata, each component's first object, and every selection archive; see ObjectStore.prune for the scan and for why it errs towards keeping things, and ObjectStore.collectData for how a file is known to be live. It is a no-op on every untouched document in the corpus, which is the property that matters: a collector that trims a file nobody edited is broken.
Returns
number
Inherited from
compatibility()
compatibility():
CompatibilityReport
Defined in: src/tsa/document.ts:317
What this library can and cannot do with THIS document: declared versions, the era they place it in, structural probes (unknown type IDs, cell-storage generation, patch archives, collaboration state) and any unsupported features. Loading never fails on version grounds — this is how a caller finds out what to expect.
Returns
Inherited from
compatibilitySummary()
compatibilitySummary():
string
Defined in: src/tsa/document.ts:331
One-line human summary of compatibility.
Returns
string
Inherited from
IWorkDocument.compatibilitySummary
drawables()
drawables():
DrawableModel[]
Defined in: src/tsa/document.ts:195
Every object that carries drawable geometry (shapes, images, boxes).
Returns
Inherited from
duplicateSlide()
duplicateSlide(
index):KeynoteSlide
Defined in: src/keynote/document.ts:1385
Duplicate a slide, content and all.
Parameters
index
number
Returns
Agent Tool
manage_slides
images()
images():
ImageModel[]
Defined in: src/tsa/document.ts:215
Every image, with filter/mask access (see ImageModel).
Returns
Inherited from
masterSlides()
masterSlides():
object[]
Defined in: src/keynote/document.ts:1009
Master/layout slides: SlideArchives that are not placed in the slide tree. They carry a name and are referenced by content slides through template_slide.
Returns
object[]
moveSlide()
moveSlide(
from,to):void
Defined in: src/keynote/document.ts:1480
Move a slide to a new position in presentation order.
Parameters
from
number
to
number
Returns
void
Agent Tool
manage_slides
noteStorages()
noteStorages():
TextStorage[]
Defined in: src/keynote/document.ts:1572
Every NOTE-kind storage in the document.
Returns
object()
object(
id):IwaObject|undefined
Defined in: src/tsa/document.ts:286
Parameters
id
bigint
Returns
IwaObject | undefined
Inherited from
presentation()
presentation():
PresentationSettings
Defined in: src/keynote/document.ts:702
How the deck plays: the settings behind Keynote's Document inspector.
Defaults come from the schema, not from zero — every corpus deck omits slideNumbersVisible and relies on the default, and reading an omitted autoplay_transition_delay as 0 rather than 5 would describe a self-playing deck that races through itself.
Returns
presentedSlides()
presentedSlides():
KeynoteSlide[]
Defined in: src/keynote/document.ts:959
Slides that will actually be presented (skipped ones removed).
Returns
pruneRoots()
protectedpruneRoots():bigint[]
Defined in: src/tsa/document.ts:375
Objects that must survive compact.
The package metadata anchors the component and data tables, and each component's first object anchors that component — a component whose objects all vanished would still be listed in the metadata, which is a worse state than a few extra archives.
Returns
bigint[]
Inherited from
relayoutSlide()
relayoutSlide(
slide,master):void
Defined in: src/keynote/document.ts:1281
The work behind KeynoteSlide.setLayout.
Parameters
slide
master
string | bigint
Returns
void
removeSlide()
removeSlide(
index):void
Defined in: src/keynote/document.ts:1467
Remove a slide from the presentation.
Only the tree entry is removed. The slide archive itself is left in the package: other objects may still reference it, and this library never garbage-collects the object graph — an orphan is inert, a dangling reference is not.
Parameters
index
number
Returns
void
Agent Tool
manage_slides
save()
save():
Uint8Array
Defined in: src/tsa/document.ts:394
Returns
Uint8Array
Inherited from
setPresentation()
setPresentation(
settings):void
Defined in: src/keynote/document.ts:717
Change how the deck plays. Only the properties given are touched.
Parameters
settings
Partial<PresentationSettings>
Returns
void
setSlideSize()
setSlideSize(
width,height):void
Defined in: src/keynote/document.ts:750
Resize the slide canvas.
Changes the coordinate space every drawable on every slide sits in, and nothing is rescaled to match: a deck resized from 1920×1080 to 1024×768 keeps its objects where they were, which is what Keynote's own "change slide size" does before you rearrange.
Parameters
width
number
height
number
Returns
void
Agent Tool
manage_slides
slideCount()
slideCount():
number
Defined in: src/keynote/document.ts:1000
Number of slides reachable from the slide tree.
Returns
number
slides()
slides():
KeynoteSlide[]
Defined in: src/keynote/document.ts:920
Returns
slideSize()
slideSize(): {
height:number;width:number; } |undefined
Defined in: src/keynote/document.ts:679
Slide canvas size in points (e.g. 1920×1080).
Returns
{ height: number; width: number; } | undefined
stats()
stats():
DocumentStats
Defined in: src/tsa/document.ts:294
Returns
Inherited from
stylesheets()
stylesheets():
StylesheetModel[]
Defined in: src/tsa/document.ts:186
All stylesheets (document + theme).
Returns
Inherited from
tables()
tables():
TableModel[]
Defined in: src/tsa/document.ts:226
Every table (see TableModel).
Lives on the base because tables are not a Numbers feature: Pages documents and Keynote slides embed the same TST archives, and the reading and writing code is identical for all three.
Returns
Inherited from
textStorages()
textStorages(
kind?):TextStorage[]
Defined in: src/tsa/document.ts:175
Every text storage in the document (bodies, headers, cells, notes …).
Parameters
kind?
number
Returns
Inherited from
toMarkdown()
toMarkdown(
options?):string
Defined in: src/keynote/document.ts:969
The deck as Markdown: a section per slide headed by its number and title, the body's paragraphs as list items, the slide's text boxes, pictures and tables, the presenter notes as a block quote; then the tables on no slide, and the charts.
Parameters
options?
MarkdownOptions = {}
Returns
string
Overrides
typeNameOf()
typeNameOf(
obj):string|undefined
Defined in: src/tsa/document.ts:290
Parameters
obj
Returns
string | undefined
Inherited from
blank()
staticblank():KeynoteDocument
Defined in: src/keynote/document.ts:916
A new, empty Keynote deck — one slide, 16:9 (1920 × 1080), no template file needed.
The embedded donor is an Apple-written corpus fixture emptied by blankFrom, so every master, style, and identity in the "new" deck was authored by an Apple app. scripts/make-blanks.ts records its provenance.
Returns
KeynoteDocument
Agent Tool
create_document
blankFrom()
staticblankFrom(template):KeynoteDocument
Defined in: src/keynote/document.ts:781
A new, empty deck built from one you supply.
There is no from-nothing constructor, and there will not be one. A deck is dozens of interlinked archives — theme, masters, slide styles — and inventing that graph would produce a file nothing offline could validate. Emptying a real one keeps every identity and master exactly as an Apple app wrote it.
One slide survives, with its text placeholders emptied. Masters are untouched: they are the template.
Parameters
template
Uint8Array
Returns
KeynoteDocument
fromMarkdown()
staticfromMarkdown(markdown,options?):KeynoteDocument
Defined in: src/keynote/document.ts:806
A new deck written from Markdown: the first heading titles the blank deck's title slide and every later heading adds a slide on layout ("Title & Bullets" by default; a theme without it gets copies of the first slide's layout); the paragraphs and list items under a heading become that slide's body, one line each, its block quotes its presenter notes and its pipe tables tables on the slide; an image on a line of its own lands on the slide when images supplies its bytes, and a thematic break (---) starts an untitled slide; links, bold and italic in the body survive. Text before any heading goes on the title slide. With template, the deck is that one emptied (blankFrom), so its theme and layouts apply.
Parameters
markdown
string
options?
images?
ImageResolver
layout?
string
template?
Uint8Array<ArrayBufferLike>
Returns
KeynoteDocument
load()
staticload(bytes):KeynoteDocument
Defined in: src/keynote/document.ts:660
Parameters
bytes
Uint8Array
Returns
KeynoteDocument
loadStore()
protectedstaticloadStore(bytes,app,extractors):object
Defined in: src/tsa/document.ts:155
Parameters
bytes
Uint8Array
app
extractors
ReadonlyMap<number, ReferenceExtractor>
Returns
object
container
container:
IWorkContainer
store
store:
ObjectStore
Inherited from
open()
staticopen(bytes):IWorkDocument
Defined in: src/tsa/document.ts:142
Load any modern iWork document, auto-detecting the app. Prefer the app subclasses' load when the type is known — they expose richer APIs.
Parameters
bytes
Uint8Array