API 参考

FPresentation

本 API 页面目前提供英文正文。代码签名与标识符不随界面语言变化。

The facade class for a presentation.

Access

Access through:

Setup

Register @univerjs-pro/slides or a preset that includes it. In plugin mode, import @univerjs-pro/slides/facade. Additional methods below require their listed plugin packages. See Facade setup.

@univerjs-pro/slides

FPresentation.appendSlide

Append a new slide to the end of the presentation.

TypeScript
appendSlide(options?: Partial<ISlidePage>): FSlide

Parameters

  • options — Optional. Default: {}. The slide creation options.

Returns

The created slide.

Examples

TypeScript
const fPresentation = univerAPI.getActivePresentation()const slide = fPresentation.appendSlide({ name: 'Summary' })console.log(slide)

Types: FSlide · Partial · ISlidePage

Package: @univerjs-pro/slides · Type definitions

FPresentation.applyTransitionToAll

Apply a slide transition to all slides that currently exist in the presentation.

The transition is visible during slide playback when moving between slides. Slides added after this call are not automatically assigned this transition; call this method again if newly added slides should use the same transition.

TypeScript
applyTransitionToAll(transition: ISlideTransition): this

Parameters

  • transition — Required. The slide transition to apply.

Returns

This presentation, for chaining.

Examples

TypeScript
const fPresentation = univerAPI.getActivePresentation()fPresentation.applyTransitionToAll({  type: univerAPI.Enum.SlideTransitionTypeEnum.Push,  duration: 1000,  direction: univerAPI.Enum.SlideTransitionDirectionEnum.Right,})

Types: ISlideTransition

Package: @univerjs-pro/slides · Type definitions

FPresentation.clearPresentationBackgroundGraphics

Clear managed presentation background graphics.

TypeScript
clearPresentationBackgroundGraphics(options?: ISetPresentationBackgroundGraphicsOptions): this

Parameters

  • options — Optional. Target master options.

Returns

This presentation, for chaining.

Examples

TypeScript
const fPresentation = univerAPI.getActivePresentation()fPresentation.clearPresentationBackgroundGraphics({  target: univerAPI.Enum.SlidePresentationBackgroundGraphicsTargetEnum.ActiveMaster,})

Types: ISetPresentationBackgroundGraphicsOptions

Package: @univerjs-pro/slides · Type definitions

FPresentation.deleteSlide

Delete a slide.

TypeScript
deleteSlide(slide: FSlide): boolean

Parameters

  • slide — Required. The slide facade or slide id to delete.

Returns

Whether the slide was deleted successfully.

Examples

TypeScript
const fPresentation = univerAPI.getActivePresentation()const slide = fPresentation.getSlideByIndex(1)if (slide) {  fPresentation.deleteSlide(slide)}

Types: FSlide

Package: @univerjs-pro/slides · Type definitions

FPresentation.getActiveSlide

Get the active slide.

TypeScript
getActiveSlide(): FSlide | null

Returns

The active slide, or null if no slide is active.

Examples

TypeScript
const fPresentation = univerAPI.getActivePresentation()const activeSlide = fPresentation.getActiveSlide()console.log(activeSlide)

Types: FSlide

Package: @univerjs-pro/slides · Type definitions

FPresentation.getId

Get the presentation id.

TypeScript
getId(): string

Returns

The presentation id.

Examples

TypeScript
const fPresentation = univerAPI.getActivePresentation()console.log(fPresentation.getId())

Package: @univerjs-pro/slides · Type definitions

FPresentation.getMasterElementPermission

Returns an Element permission facade for a Master or Layout page.

TypeScript
getMasterElementPermission(sourcePageType: PageTypeEnum.Master | PageTypeEnum.Layout, pageId: string, elementId: string): FSlideObjectPermission

Parameters

  • sourcePageType — Required. Whether the element belongs to a Master or Layout page.
  • pageId — Required. Stable source page id.
  • elementId — Required. Stable element id.

Returns

Permission facade combining Presentation, Master View, and Element Edit points.

Examples

TypeScript
import { PageTypeEnum } from '@univerjs-pro/slides'const presentation = univerAPI.getActivePresentation()if (!presentation) throw new Error('No active Presentation.')const master = Object.values(presentation.save().masterPages ?? {})[0]const elementId = master?.elementOrder[0]if (!master || !elementId) throw new Error('Master element not found.')await presentation  .getMasterElementPermission(PageTypeEnum.Master, master.id, elementId)  .setReadOnly()

Types: FSlideObjectPermission · PageTypeEnum.Master · PageTypeEnum.Layout

Package: @univerjs-pro/slides · Type definitions

FPresentation.getMasterViewPermission

Returns the shared Master and Layout edit permission facade.

TypeScript
getMasterViewPermission(): FSlideObjectPermission

Returns

Permission facade combining Presentation and Master View Edit points.

Examples

TypeScript
const presentation = univerAPI.getActivePresentation()if (!presentation) throw new Error('No active Presentation.')await presentation.getMasterViewPermission().setReadOnly()

Types: FSlideObjectPermission

Package: @univerjs-pro/slides · Type definitions

FPresentation.getName

Get the presentation name.

TypeScript
getName(): string

Returns

The presentation name.

Examples

TypeScript
const fPresentation = univerAPI.getActivePresentation()console.log(fPresentation.getName())

Package: @univerjs-pro/slides · Type definitions

FPresentation.getPageSize

Get the default page size of the presentation.

TypeScript
getPageSize(): ISlidePageSize

Returns

The page size.

Examples

TypeScript
const fPresentation = univerAPI.getActivePresentation()console.log(fPresentation.getPageSize())

Types: ISlidePageSize

Package: @univerjs-pro/slides · Type definitions

FPresentation.getPermission

Returns the Presentation unit permission facade.

TypeScript
getPermission(): FPresentationPermission

Returns

Permission facade for Edit, Copy, Print, Export, and Comment.

Examples

TypeScript
const presentation = univerAPI.getActivePresentation()if (!presentation) throw new Error('No active Presentation.')await presentation.getPermission().setReadOnly()

Types: FPresentationPermission

Package: @univerjs-pro/slides · Type definitions

FPresentation.getPresentation

Get the underlying presentation model.

TypeScript
getPresentation(): SlideModel

Returns

The presentation model.

Examples

TypeScript
const fPresentation = univerAPI.getActivePresentation()const model = fPresentation.getPresentation()console.log(model)

Types: SlideModel

Package: @univerjs-pro/slides · Type definitions

FPresentation.getPresentationBackgroundGraphics

Get managed presentation background graphics from a master page. When masterPageId is omitted, the active slide's master is used.

TypeScript
getPresentationBackgroundGraphics(masterPageId?: string): ISlidePresentationBackgroundGraphic[]

Parameters

  • masterPageId — Optional. Optional master page id to read from.

Returns

The managed deck background graphics.

Examples

TypeScript
const fPresentation = univerAPI.getActivePresentation()const graphics = fPresentation.getPresentationBackgroundGraphics()console.log(graphics)

Types: ISlidePresentationBackgroundGraphic

Package: @univerjs-pro/slides · Type definitions

FPresentation.getSlideById

Get a slide by id.

TypeScript
getSlideById(id: string): FSlide | null

Parameters

  • id — Required. The slide id.

Returns

The slide, or null if it does not exist.

Examples

TypeScript
const fPresentation = univerAPI.getActivePresentation()const slide = fPresentation.getSlideById('slide-1')console.log(slide)

Types: FSlide

Package: @univerjs-pro/slides · Type definitions

FPresentation.getSlideByIndex

Get a slide by index.

TypeScript
getSlideByIndex(index: number): FSlide | null

Parameters

  • index — Required. The zero-based slide index.

Returns

The slide, or null if the index is out of range.

Examples

TypeScript
const fPresentation = univerAPI.getActivePresentation()const firstSlide = fPresentation.getSlideByIndex(0)console.log(firstSlide)

Types: FSlide

Package: @univerjs-pro/slides · Type definitions

FPresentation.getSlides

Get all slides in the presentation.

TypeScript
getSlides(): FSlide[]

Returns

The slides in slide order.

Examples

TypeScript
const fPresentation = univerAPI.getActivePresentation()const slides = fPresentation.getSlides()console.log(slides)

Types: FSlide

Package: @univerjs-pro/slides · Type definitions

FPresentation.insertSlide

Insert a new slide at the specified index.

TypeScript
insertSlide(index: number, options?: Partial<ISlidePage>): FSlide

Parameters

  • index — Required. The zero-based insert index.
  • options — Optional. Default: {}. The slide creation options.

Returns

The created slide.

Examples

TypeScript
const fPresentation = univerAPI.getActivePresentation()const slide = fPresentation.insertSlide(0, { name: 'Opening' })console.log(slide)

Types: FSlide · Partial · ISlidePage

Package: @univerjs-pro/slides · Type definitions

FPresentation.moveSlide

Move a slide to a new index.

TypeScript
moveSlide(slide: FSlide, toIndex: number): boolean

Parameters

  • slide — Required. The slide to move.
  • toIndex — Required. The target zero-based index.

Returns

Whether the slide was moved successfully.

Examples

TypeScript
const fPresentation = univerAPI.getActivePresentation()const firstSlide = fPresentation.getSlideByIndex(0)if (firstSlide) {  fPresentation.moveSlide(firstSlide, 1)}

Types: FSlide

Package: @univerjs-pro/slides · Type definitions

FPresentation.save

Save and return the presentation snapshot.

TypeScript
save(): ISlideData

Returns

The presentation snapshot.

Examples

TypeScript
const fPresentation = univerAPI.getActivePresentation()const snapshot = fPresentation.save()console.log(snapshot)

Types: ISlideData

Package: @univerjs-pro/slides · Type definitions

FPresentation.setActiveSlide

Set the active slide.

TypeScript
setActiveSlide(slide: FSlide): this

Parameters

  • slide — Required. The slide facade or slide id to activate.

Returns

This presentation, for chaining.

Examples

TypeScript
const fPresentation = univerAPI.getActivePresentation()const secondSlide = fPresentation.getSlideByIndex(1)if (secondSlide) {  fPresentation.setActiveSlide(secondSlide)}

Types: FSlide

Package: @univerjs-pro/slides · Type definitions

FPresentation.setName

Set the presentation name.

TypeScript
setName(name: string): this

Parameters

  • name — Required. The new presentation name.

Returns

This presentation, for chaining.

Examples

TypeScript
const fPresentation = univerAPI.getActivePresentation()fPresentation.setName('Quarterly Review')

Package: @univerjs-pro/slides · Type definitions

FPresentation.setPageSize

Set the default page size of the presentation.

TypeScript
setPageSize(pageSize: Partial<ISlidePageSize>): this

Parameters

  • pageSize — Required. The new default page size.

Returns

This presentation, for chaining.

Examples

TypeScript
const fPresentation = univerAPI.getActivePresentation()fPresentation.setPageSize({  width: 1024,  preset: univerAPI.Enum.SlidePageSizePresetEnum.WideScreen16By10,})

Types: Partial · ISlidePageSize

Package: @univerjs-pro/slides · Type definitions

FPresentation.setPresentationBackgroundGraphics

Set managed presentation background graphics. The call updates master pages through SetPresentationBackgroundGraphicsCommand.

TypeScript
setPresentationBackgroundGraphics(graphics: ISlidePresentationBackgroundGraphic[], options?: ISetPresentationBackgroundGraphicsOptions): this

Parameters

  • graphics — Required. The managed background graphics.
  • options — Optional. Default: {}. Target master options.

Returns

This presentation, for chaining.

Examples

TypeScript
const fPresentation = univerAPI.getActivePresentation()fPresentation.setPresentationBackgroundGraphics(  [    {      source: 'image-source-id',      imageSourceType: univerAPI.Enum.ImageSourceType.UUID,      fit: univerAPI.Enum.SlidePresentationBackgroundGraphicFitEnum.Cover,    },  ],  {    target: univerAPI.Enum.SlidePresentationBackgroundGraphicsTargetEnum.ActiveMaster,  },)
TSX
const fPresentation = univerAPI.getActivePresentation()const svg = `<svg xmlns="http://www.w3.org/2000/svg" width="960" height="540" viewBox="0 0 960 540">  <rect width="960" height="540" fill="#e0f2fe"/>  <path d="M0 540 L960 0" stroke="#22c55e" stroke-width="90" opacity="0.45"/>  <path d="M-120 420 L840 -120" stroke="#3b82f6" stroke-width="52" opacity="0.55"/>  <circle cx="760" cy="150" r="90" fill="#f97316" opacity="0.65"/>  <text x="64" y="455" font-size="54" font-family="Arial" fill="#0f172a">Deck background</text></svg>`const url = `data:image/svg+xml;charset=utf-8,${encodeURIComponent(svg)}`fPresentation.setPresentationBackgroundGraphics(  [    {      source: url,      imageSourceType: univerAPI.Enum.ImageSourceType.BASE64,      fit: univerAPI.Enum.SlidePresentationBackgroundGraphicFitEnum.Cover,    },  ],  {    target: univerAPI.Enum.SlidePresentationBackgroundGraphicsTargetEnum.AllMasters,  },)

Types: ISlidePresentationBackgroundGraphic · ISetPresentationBackgroundGraphicsOptions

Package: @univerjs-pro/slides · Type definitions

你觉得这篇文档如何?

© 2026 DreamNum Co., Ltd.