Skip to content

Slideshow

Run the Present-mode slideshow programmatically — the scriptable counterpart of the Present toolbar's slideshow button. The slideshow plays all layout sheets in sheet order (hidden sheets are excluded); start options only pick the slide it opens on. Accessed via snaptrude.presentation.slideshow.

All methods are host API calls that return Promises. Slide navigation stays with the user (arrow keys / the on-screen controls); there is intentionally no next/prev/goTo — the active slide is view-local state with no scriptable seam.

At a glance

MethodWhat it doesMutates?
start(options?)Launch the slideshow over all sheets
stop()Close the running slideshow (no-op if not running)
getState()Whether it is running + the current slide index

Fullscreen needs a user gesture

Browsers only grant fullscreen on a user gesture. A plugin-triggered start usually fails that check, in which case the slideshow catches the rejection and runs non-fullscreen — same slides, same keyboard/on-screen controls, windowed. stop still exits fullscreen when it was entered.

Present mode required

start and stop require Present mode (the documentation editor) to be open and throw otherwise. getState is a never-throw read that reports not-running when Present mode is closed.

Types

PluginPresentationSlideshowState

Result of start, stop, and getState.

PropertyTypeDescription
runningbooleanWhether a slideshow is currently running
indexnumber | nullCurrent 0-based slide index (null when not running)

Functions

start(options?)

Start the slideshow over all layout sheets in sheet order. options.startIndex opens on that slide (clamped into range); otherwise options.sheetIds naming exactly one sheet opens on that sheet (the same semantics as launching with one sheet selected on the panel — more than one id is ignored, the slideshow always plays all sheets); otherwise it opens on the first slide. Idempotent — returns the current state when a slideshow is already running.

  • Parameters:
    • options.sheetIds: string[] | undefined — open on this sheet when exactly one id is given
    • options.startIndex: number | undefined — 0-based slide to open on (wins over sheetIds; clamped into range)
  • Returns: PluginPresentationSlideshowStaterunning: true and the opening index.
  • Throws: If Present mode is not open or there are no sheets to present.
ts
const state = await snaptrude.presentation.slideshow.start({ startIndex: 2 });
console.log(state.running, state.index); // true, 2

stop()

Stop the slideshow — closes the running overlay (exiting fullscreen if it entered it) and returns to the Present canvas. A no-op when no slideshow is running.

  • Parameters: none
  • Returns: PluginPresentationSlideshowStaterunning: false.
  • Throws: If Present mode is not open.
ts
await snaptrude.presentation.slideshow.stop();

getState()

Read the slideshow state — a never-throw read: whether a slideshow is running and, when it is, the current 0-based slide index (index is null when not running, including when Present mode is closed).

  • Parameters: none
  • Returns: PluginPresentationSlideshowState
ts
const { running, index } = await snaptrude.presentation.slideshow.getState();

Errors

Failed calls reject with a typed PluginError — see Error Handling. Conditions specific to this namespace:

CodeThrown byWhendetails
PRECONDITION_FAILEDstart, stopPresent mode is not open
PRECONDITION_FAILEDstartThe presentation has no sheets to present
HANDLE_INVALIDstartA single sheetIds entry is not a visible sheet
OPERATION_FAILEDstart, stopThe slideshow overlay failed to appear / disappear within 5s