# Univer Slides API

- Human documentation: [https://docs.univer.ai/guides/slides/features/core/slides-api](https://docs.univer.ai/guides/slides/features/core/slides-api)

- Agent Markdown: [https://docs.univer.ai/guides/slides/features/core/slides-api.md](https://docs.univer.ai/guides/slides/features/core/slides-api.md)

- Requested language: `en-US`

- Content language: `en-US`

- Documentation version: `1.0.0-rc.0`

- Source: [slides/features/core/slides-api.mdx](https://github.com/dream-num/documentation/blob/dev/content/guides/slides/features/core/slides-api.mdx)

---

The Slides Facade adds presentation and slide objects to `FUniver`. Import its side-effect entry before creating the API object:

```ts
import { FUniver } from '@univerjs/core/facade'

import '@univerjs-pro/slides/facade'

const univerAPI = FUniver.newAPI(univer)
```

## Create and find presentations

```ts
const presentation = univerAPI.createPresentation({
  id: 'quarterly-review',
  name: 'Quarterly review',
})

const activePresentation = univerAPI.getActivePresentation()
const samePresentation = univerAPI.getPresentation(presentation.getId())
```

`createPresentation()` accepts a partial `ISlideData` snapshot. Pass a snapshot returned by `save()` to restore a presentation.

## Work with the presentation unit

`FPresentation` exposes the unit identity, name, page size, slides, active slide, transitions, permissions, and detached snapshot:

```ts
presentation.setName('FY 2027 review')

const opening = presentation.getSlideByIndex(0) ?? presentation.appendSlide({
  name: 'Opening',
})

presentation.setActiveSlide(opening)
const snapshot = presentation.save()
```

Do not mutate `snapshot` to update a running presentation. Use Facade methods or commands so rendering and undo history remain synchronized.

## Enter a slide

`FSlide` is the entry point for a slide’s background, speaker notes, transition, and elements:

```ts
const slide = presentation.getActiveSlide()

if (slide) {
  const elements = slide.getElements()
  const notes = slide.getSpeakerNotes()
}
```

Continue with [Slides and Layouts](https://docs.univer.ai/guides/slides/features/core/slides-and-layouts.md), [Shapes and Text](https://docs.univer.ai/guides/slides/features/core/shapes-and-text.md), and [Images and Groups](https://docs.univer.ai/guides/slides/features/core/images-and-groups.md) for focused operations.

## Resolve command targets

Command event parameters may contain a presentation and slide identifier. Resolve them without relying on the current selection:

```ts
const listener = univerAPI.addEvent(
  univerAPI.Event.CommandExecuted,
  ({ params }) => {
    const target = univerAPI.getSlideCommandTarget(params)
    console.log(target?.presentation.getId(), target?.slide.getId())
  }
)
```

Dispose the listener when its host component is removed.

## Dispose a presentation

Unload one Slides unit by ID when it is no longer needed. Dispose the root `univer` instance only when the whole application is being destroyed.

```ts
const presentation = univerAPI.getActivePresentation()

if (presentation) {
  univerAPI.disposeUnit(presentation.getId())
}
```
