API 参考

FSlide

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

The facade class for a slide page.

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

FSlide.deleteElement

Removes a page element from this slide.

TypeScript
deleteElement(element: FSlidePageElement): boolean

Parameters

  • element — Required. The element to remove.

Returns

Whether the element was removed successfully.

Examples

TypeScript
const fPresentation = univerAPI.getActivePresentation()const fSlide = fPresentation.getSlideByIndex(0)const element = fSlide.getElements()[0]if (element) {  fSlide.deleteElement(element)}

Types: FSlidePageElement

Package: @univerjs-pro/slides · Type definitions

FSlide.getBackground

Get this slide's explicit background.

TypeScript
getBackground(): ISlideBackgroundData | undefined

Returns

The explicit background.

Examples

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

Types: ISlideBackgroundData

Package: @univerjs-pro/slides · Type definitions

FSlide.getData

Get the raw slide data.

TypeScript
getData(): ISlidePage

Returns

The slide page data.

Examples

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

Types: ISlidePage

Package: @univerjs-pro/slides · Type definitions

FSlide.getElementById

Returns a page element by element id.

TypeScript
getElementById(id: string): FSlidePageElement | null

Parameters

  • id — Required. The element id.

Returns

The page element, or null when it does not exist.

Examples

TypeScript
const fPresentation = univerAPI.getActivePresentation()const fSlide = fPresentation.getSlideByIndex(0)const element = fSlide.getElementById('shape-1')console.log(element)

Types: FSlidePageElement

Package: @univerjs-pro/slides · Type definitions

FSlide.getElementPermission

Returns the permission facade for one element on this Slide.

TypeScript
getElementPermission(elementId: string): FSlideObjectPermission

Parameters

  • elementId — Required. Stable element id.

Returns

Permission facade combining Presentation, Slide, and Element Edit points.

Examples

TypeScript
const slide = univerAPI.getActivePresentation()?.getSlideByIndex(0)if (!slide) throw new Error('Slide not found.')const element = slide.getElements()[0]if (!element) throw new Error('Slide element not found.')await slide.getElementPermission(element.getId()).setReadOnly()

Types: FSlideObjectPermission

Package: @univerjs-pro/slides · Type definitions

FSlide.getElements

Returns all page elements on this slide.

TypeScript
getElements(): FSlidePageElement[]

Returns

All page elements in element order.

Examples

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

Types: FSlidePageElement

Package: @univerjs-pro/slides · Type definitions

FSlide.getGroups

Returns all group elements on this slide.

TypeScript
getGroups(): FGroup[]

Returns

The groups on this slide.

Examples

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

Types: FGroup

Package: @univerjs-pro/slides · Type definitions

FSlide.getId

Get the slide id.

TypeScript
getId(): string

Returns

The slide id.

Examples

TypeScript
const fPresentation = univerAPI.getActivePresentation()if (!fPresentation) throw new Error('No active presentation.')const fSlide = fPresentation.getSlideByIndex(0)if (!fSlide) throw new Error('Slide not found.')console.log(fSlide.getId())

Package: @univerjs-pro/slides · Type definitions

FSlide.getImages

Returns all images on this slide.

TypeScript
getImages(): FImage[]

Returns

The images on this slide.

Examples

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

Types: FImage

Package: @univerjs-pro/slides · Type definitions

FSlide.getName

Get the slide name.

TypeScript
getName(): string

Returns

The slide name.

Examples

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

Package: @univerjs-pro/slides · Type definitions

FSlide.getPageLayout

Returns this page's model-space size and ordered element bounds.

This model-only query does not include viewport, screen, scroll, or zoom coordinates and does not require a UI or render plugin.

TypeScript
getPageLayout(): ISlideFacadePageLayout

Returns

Page size and element bounds in Slide model coordinates.

Examples

TypeScript
const presentation = univerAPI.getActivePresentation()const slide = presentation?.getSlideByIndex(0)console.log(slide?.getPageLayout())

Types: ISlideFacadePageLayout

Package: @univerjs-pro/slides · Type definitions

FSlide.getPageSize

Get this slide's page size, falling back to the presentation default.

TypeScript
getPageSize(): ISlidePageSize

Returns

The resolved page size.

Examples

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

Types: ISlidePageSize

Package: @univerjs-pro/slides · Type definitions

FSlide.getPermission

Returns the Slide page permission facade.

TypeScript
getPermission(): FSlideObjectPermission

Returns

Permission facade combining Presentation and Slide page Edit points.

Examples

TypeScript
const slide = univerAPI.getActivePresentation()?.getSlideByIndex(0)if (!slide) throw new Error('Slide not found.')await slide.getPermission().setReadOnly()

Types: FSlideObjectPermission

Package: @univerjs-pro/slides · Type definitions

FSlide.getShape

Returns a shape by id.

TypeScript
getShape(id: string): FShape | FConnectorShape | null

Parameters

  • id — Required. The shape id.

Returns

The Shape facade, or null when it does not exist.

Examples

TypeScript
const fPresentation = univerAPI.getActivePresentation()const fSlide = fPresentation.getSlideByIndex(0)const fShape = fSlide.getShape('shape-1')console.log(fShape)

Types: FShape · FConnectorShape

Package: @univerjs-pro/slides · Type definitions

FSlide.getShapes

Returns all shapes on this slide.

TypeScript
getShapes(): Array<FShape | FConnectorShape>

Returns

The Shape facades on this slide.

Examples

TypeScript
const fPresentation = univerAPI.getActivePresentation()const fSlide = fPresentation.getSlideByIndex(0)const fShapes = fSlide.getShapes()console.log(fShapes)

Types: FShape · FConnectorShape · Array

Package: @univerjs-pro/slides · Type definitions

FSlide.getSlide

Get the underlying slide page model.

TypeScript
getSlide(): SlidePage

Returns

The slide page model.

Examples

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

Types: SlidePage

Package: @univerjs-pro/slides · Type definitions

FSlide.getSpeakerNotes

Get this slide's speaker notes.

TypeScript
getSpeakerNotes(): string | undefined

Returns

The speaker notes, or undefined if none are set.

Examples

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

Package: @univerjs-pro/slides · Type definitions

FSlide.getTransition

Get the transition used when entering this slide during playback.

TypeScript
getTransition(): ISlideTransition | undefined

Returns

The resolved slide transition, or undefined if there is no transition.

Examples

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

Types: ISlideTransition

Package: @univerjs-pro/slides · Type definitions

FSlide.group

Group two or more slide elements.

TypeScript
group(elements: FSlidePageElement[]): FGroup

Parameters

  • elements — Required. The elements to group.

Returns

The created group.

Examples

TypeScript
const fPresentation = univerAPI.getActivePresentation()const fSlide = fPresentation.getSlideByIndex(0)const element1 = fSlide.getElements()[0]const element2 = fSlide.getElements()[1]if (element1 && element2) {  const group = fSlide.group([element1, element2])  console.log(group)}

Types: FGroup · FSlidePageElement

Package: @univerjs-pro/slides · Type definitions

FSlide.insertElement

Adds a page element to this slide.

TypeScript
insertElement(element: ISlidePageElement, index?: number): FSlidePageElement

Parameters

  • element — Required. The slide element data.
  • index — Optional. The insert index in the element order.

Returns

The inserted element.

Examples

TypeScript
const fPresentation = univerAPI.getActivePresentation()const fSlide = fPresentation.getSlideByIndex(0)const shapeElement = fSlide.insertElement(element)console.log(shapeElement)

Types: FSlidePageElement · ISlidePageElement

Package: @univerjs-pro/slides · Type definitions

FSlide.insertImage

Adds an image to this slide.

TypeScript
insertImage(imageBuilderInfo: ISlideImageBuilderInfo, index?: number): FImage

Parameters

  • imageBuilderInfo — Required. The image builder info returned by FImageBuilder.build().
  • index — Optional. The insert index in the element order.

Returns

The inserted image.

Examples

TypeScript
const fPresentation = univerAPI.getActivePresentation()const fSlide = fPresentation.getSlideByIndex(0)const imageInfo = fSlide  .newImage()  .setSource('https://example.com/image.png', univerAPI.Enum.ImageSourceType.URL)  .setAbsolutePosition(80, 120)  .setSize(320, 180)  .setRotation(15)  .setCrop({    left: 10,    top: 10,    right: 10,    bottom: 10,  })  .setClipShape(univerAPI.Enum.ShapeTypeEnum.RoundRect, { adj1: 5000 })  .build()fSlide.insertImage(imageInfo)

Types: FImage · ISlideImageBuilderInfo

Package: @univerjs-pro/slides · Type definitions

FSlide.insertImageAsync

Insert an image from a string source or blob source.

TypeScript
insertImageAsync(source: string | IFBlobSource, options?: ISlideImageInsertOptions): Promise<FImage>

Parameters

  • source — Required. The image source or blob source.
  • options — Optional. Default: {}. Image insertion options.

Returns

The inserted image.

Examples

TypeScript
const fPresentation = univerAPI.getActivePresentation()const fSlide = fPresentation.getSlideByIndex(0)// Insert an image from a URL.await fSlide.insertImageAsync('https://example.com/image.png', {  imageSourceType: univerAPI.Enum.ImageSourceType.URL,  left: 80,  top: 120,  width: 320,  height: 180,  rotation: 15,  crop: {    left: 10,    top: 10,    right: 10,    bottom: 10,  },  prstGeom: univerAPI.Enum.ShapeTypeEnum.RoundRect,  adjustValues: { adj1: 5000 },})// Insert an image from a blob source.const blobSource = createBlobSourceFromFile(fileInput.files[0])await fSlide.insertImageAsync(blobSource, {  imageSourceType: univerAPI.Enum.ImageSourceType.BASE64,  left: 80,  top: 120,  width: 320,  height: 180,})

Types: FImage · Promise · IFBlobSource · ISlideImageInsertOptions

Package: @univerjs-pro/slides · Type definitions

FSlide.insertShape

Adds a shape to this slide.

TypeScript
insertShape(input: IShapeCreateInput): FShape | FConnectorShape | null

Parameters

  • input — Required. The common Shape creation input.

Returns

The inserted Shape facade, or null when creation fails.

Examples

TypeScript
const fPresentation = univerAPI.getActivePresentation()const fSlide = fPresentation.getSlideByIndex(0)const fShape = fSlide.insertShape({  shapeType: univerAPI.Enum.ShapeTypeEnum.RoundRect,  transform: { left: 100, top: 120, width: 240, height: 120 },  visible: true,  selectable: true,  shapeData: {    fill: { fillType: univerAPI.Enum.ShapeFillEnum.SolidFill, color: '#fef3c7' },    stroke: {      lineStrokeType: univerAPI.Enum.ShapeLineTypeEnum.SolidLine,      color: '#d97706',      width: 2,    },  },})if (!fShape) throw new Error('Shape could not be inserted.')fShape.setRotation(-6).setStrokeLineJoinType(univerAPI.Enum.ShapeLineJoinEnum.Round)const richText = univerAPI  .newRichText()  .text('Open ')  .link('the project brief', 'https://example.com/project-brief')fShape  .getText()  .setRichText(richText)  .setHorizontalAlign(univerAPI.Enum.HorizontalAlign.CENTER)  .setVerticalAlign(univerAPI.Enum.VerticalAlign.MIDDLE)

Types: FShape · FConnectorShape · IShapeCreateInput

Package: @univerjs-pro/slides · Type definitions

FSlide.insertSmartArt

Inserts an editable SmartArt composite using one of the built-in layout IDs. All model writes are delegated to the Slide Shape host adapter command path.

TypeScript
insertSmartArt(layoutId: string, transform?: IShapeCreateInput['transform']): FShape | FConnectorShape | null

Parameters

  • layoutId — Required. The built-in SmartArt layout id.
  • transform — Optional. The optional position, size, rotation, and flip overrides.

Returns

The SmartArt Shape facade, or null when the layout or host is unavailable.

Examples

Slide — executable with univer execute

TypeScript
const presentation = univerAPI.getActivePresentation()const slide = presentation?.getActiveSlide()if (!slide) throw new Error('No active slide')const smartArt = slide.insertSmartArt(  'urn:microsoft.com/office/officeart/2005/8/layout/orgChart1',  { left: 120, top: 90, width: 720, height: 360 },)if (!smartArt) throw new Error('Cannot insert SmartArt')console.log(smartArt.getSmartArtData()?.layout.id)

Types: FShape · FConnectorShape · IShapeCreateInput

Package: @univerjs-pro/slides · Type definitions

FSlide.newImage

Returns a builder to create a new image for this slide. The builder will not automatically upload or choose an image.

TypeScript
newImage(existing?: FImage | string): FImageBuilder

Parameters

  • existing — Optional. An existing image to initialize the builder with for updating or a string element id to create a new image with that id. Omit to create a new image with an auto-generated id.

Returns

A new image builder.

Examples

TypeScript
const fPresentation = univerAPI.getActivePresentation()const fSlide = fPresentation.getSlideByIndex(0)const imageInfo = fSlide  .newImage()  .setSource('https://example.com/image.png', univerAPI.Enum.ImageSourceType.URL)  .setAbsolutePosition(80, 120)  .setSize(320, 180)  .setRotation(15)  .setCrop({    left: 10,    top: 10,    right: 10,    bottom: 10,  })  .setClipShape(univerAPI.Enum.ShapeTypeEnum.RoundRect, { adj1: 5000 })  .build()fSlide.insertImage(imageInfo)

Types: FImageBuilder · FImage

Package: @univerjs-pro/slides · Type definitions

FSlide.removeImage

Removes an image from this slide.

TypeScript
removeImage(image: FImage): boolean

Parameters

  • image — Required. The image or image element id to remove.

Returns

Whether the image was removed successfully.

Examples

TypeScript
const fPresentation = univerAPI.getActivePresentation()const fSlide = fPresentation.getSlideByIndex(0)const image = fSlide.getImages()[0]if (image) {  fSlide.removeImage(image)}

Types: FImage

Package: @univerjs-pro/slides · Type definitions

FSlide.setBackground

Set this slide's explicit background.

TypeScript
setBackground(background?: ISlideBackgroundData): this

Parameters

  • background — Optional. The slide background. Omit to clear it.

Returns

This slide, for chaining.

Examples

TypeScript
const fPresentation = univerAPI.getActivePresentation()const fSlide = fPresentation.getSlideByIndex(0)// Set a solid background color on this slide.fSlide.setBackground({  type: univerAPI.Enum.SlideBackgroundTypeEnum.Solid,  color: '#4f90ff',})// Set a gradient background on this slide.fSlide.setBackground({  type: univerAPI.Enum.SlideBackgroundTypeEnum.Gradient,  angle: 45,  stops: [    {      color: '#4f90ff',      position: 0,    },    {      color: '#ffffff',      position: 1,    },  ],})// Set an image background on this slide.fSlide.setBackground({  type: univerAPI.Enum.SlideBackgroundTypeEnum.Image,  source: 'https://example.com/image.png',  imageSourceType: univerAPI.Enum.ImageSourceType.URL,  fit: univerAPI.Enum.SlidePresentationBackgroundGraphicFitEnum.Cover,})// Set a pattern background on this slide.fSlide.setBackground({  type: univerAPI.Enum.SlideBackgroundTypeEnum.Pattern,  pattern: 'diagonal',  foregroundColor: '#4f90ff',  backgroundColor: '#ffffff',})

Types: ISlideBackgroundData

Package: @univerjs-pro/slides · Type definitions

FSlide.setPageSize

Set this slide's page size.

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

Parameters

  • pageSize — Required. The new slide page size.

Returns

This slide, for chaining.

Examples

TypeScript
const fPresentation = univerAPI.getActivePresentation()const fSlide = fPresentation.getSlideByIndex(0)fSlide.setPageSize({  width: 1280,  preset: univerAPI.Enum.SlidePageSizePresetEnum.WideScreen16By9,})

Types: Partial · ISlidePageSize

Package: @univerjs-pro/slides · Type definitions

FSlide.setShowMasterBackground

Set whether this slide shows inherited master shapes and background graphics.

TypeScript
setShowMasterBackground(show: boolean): this

Parameters

  • show — Required. Whether inherited master background content is shown.

Returns

This slide, for chaining.

Examples

TypeScript
const fPresentation = univerAPI.getActivePresentation()const fSlide = fPresentation.getSlideByIndex(0)fSlide.setShowMasterBackground(false)

Package: @univerjs-pro/slides · Type definitions

FSlide.setSpeakerNotes

Set or clear this slide's speaker notes.

TypeScript
setSpeakerNotes(speakerNotes?: string): this

Parameters

  • speakerNotes — Optional. The speaker notes. Pass an empty string or omit the argument to clear them.

Returns

This slide, for chaining.

Examples

TypeScript
const fPresentation = univerAPI.getActivePresentation()const fSlide = fPresentation.getSlideByIndex(0)fSlide.setSpeakerNotes('Review Q2 revenue')console.log(fSlide.getSpeakerNotes()) // 'Review Q2 revenue'fSlide.setSpeakerNotes()console.log(fSlide.getSpeakerNotes()) // undefined

Package: @univerjs-pro/slides · Type definitions

FSlide.setTransition

Set the transition used when entering this slide during playback.

For example, setting a transition on slide 2 is visible when playback moves from slide 1 to slide 2. Setting a transition on the current slide is not visible when moving to the next slide unless the next slide has its own transition.

TypeScript
setTransition(transition?: ISlideTransition): this

Parameters

  • transition — Optional. The slide transition to set. Omit to clear the slide's explicit transition.

Returns

This slide, for chaining.

Examples

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

Types: ISlideTransition

Package: @univerjs-pro/slides · Type definitions

FSlide.ungroup

Ungroup a slide group.

TypeScript
ungroup(group: FGroup): FSlidePageElement[]

Parameters

  • group — Required. The group facade or group id to ungroup.

Returns

The released child elements.

Examples

TypeScript
const fPresentation = univerAPI.getActivePresentation()const fSlide = fPresentation.getSlideByIndex(0)const group = fSlide.getGroups()[0]if (group) {  const releasedElements = fSlide.ungroup(group)  console.log(releasedElements)}

Types: FSlidePageElement · FGroup

Package: @univerjs-pro/slides · Type definitions

FSlide.updateImage

Updates an existing image on this slide.

TypeScript
updateImage(imageBuilderInfo: ISlideImageBuilderInfo): FImage

Parameters

  • imageBuilderInfo — Required. The image builder info returned by FImageBuilder.build().

Returns

The updated image.

Examples

TypeScript
const fPresentation = univerAPI.getActivePresentation()const fSlide = fPresentation.getSlideByIndex(0)const image = fSlide.getImages()[0]if (image) {  const imageInfo = image.toBuilder().setSize(480, 300).build()  fSlide.updateImage(imageInfo)}

Types: FImage · ISlideImageBuilderInfo

Package: @univerjs-pro/slides · Type definitions

@univerjs-pro/slides-chart

FSlide.getChart

TypeScript
getChart(chartIdOrElementId: string): FSlideChart | null

Parameters

  • chartIdOrElementId — Required.

Types: FSlideChart

Package: @univerjs-pro/slides-chart · Type definitions

FSlide.getCharts

TypeScript
getCharts(): FSlideChart[]

Types: FSlideChart

Package: @univerjs-pro/slides-chart · Type definitions

FSlide.insertChart

TypeScript
insertChart(info: ISlideChartInfo): Promise<FSlideChart>

Parameters

  • info — Required.

Types: FSlideChart · Promise · ISlideChartInfo

Package: @univerjs-pro/slides-chart · Type definitions

FSlide.newChart

TypeScript
newChart<T extends ChartTypeString>(type: T): FSlideChartBuilderOf<T>

Parameters

  • type — Required.

Types: FSlideChartBuilderOf

Package: @univerjs-pro/slides-chart · Type definitions

@univerjs-pro/slides-table

FSlide.getTableAt

Return a slide table by its order on the slide.

TypeScript
getTableAt(index: number): FSlideTable | null

Parameters

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

Returns

The table facade, or null when the index is out of range.

Examples

TypeScript
const fPresentation = univerAPI.getActivePresentation()const fSlide = fPresentation.getSlideByIndex(0)const firstTable = fSlide.getTableAt(0)console.log(firstTable)

Types: FSlideTable

Package: @univerjs-pro/slides-table · Type definitions

FSlide.getTableById

Return a slide table by table resource id or element id.

TypeScript
getTableById(tableIdOrElementId: string): FSlideTable | null

Parameters

  • tableIdOrElementId — Required. The table resource id or table element id.

Returns

The table facade, or null when it does not exist.

Examples

TypeScript
const fPresentation = univerAPI.getActivePresentation()const fSlide = fPresentation.getSlideByIndex(0)const table = fSlide.getTableById('status-table')console.log(table)

Types: FSlideTable

Package: @univerjs-pro/slides-table · Type definitions

FSlide.getTables

Return all slide tables on this slide.

TypeScript
getTables(): FSlideTable[]

Returns

All table facades in element order.

Examples

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

Types: FSlideTable

Package: @univerjs-pro/slides-table · Type definitions

FSlide.insertTable

Insert a table from builder info.

TypeScript
insertTable(tableInfo: ISlideTableBuilderInfo, index?: number): FSlideTable | null

Parameters

  • tableInfo — Required. The table builder info.
  • index — Optional. The slide element insert index.

Returns

The inserted table facade, or null if the insert failed.

Examples

TypeScript
const fPresentation = univerAPI.getActivePresentation()const fSlide = fPresentation.getSlideByIndex(0)const tableInfo = fSlide.newTable().setRows(3).setColumns(4).build()fSlide.insertTable(tableInfo)

Types: FSlideTable · ISlideTableBuilderInfo

Package: @univerjs-pro/slides-table · Type definitions

FSlide.insertTableFromData

Insert a table and fill it with plain text data.

TypeScript
insertTableFromData(values: string[][], options?: ICreateSlideTableOptions): FSlideTable | null

Parameters

  • values — Required. Two-dimensional plain text values.
  • options — Optional. Optional ids, layout, and style settings.

Returns

The inserted table facade, or null if the insert failed.

Examples

TypeScript
const fPresentation = univerAPI.getActivePresentation()const fSlide = fPresentation.getSlideByIndex(0)const table = fSlide.insertTableFromData(  [    ['Name', 'Status'],    ['Facade', 'Ready'],  ],  {    tableId: 'status-table',  },)console.log(table)

Types: FSlideTable · ICreateSlideTableOptions

Package: @univerjs-pro/slides-table · Type definitions

FSlide.newTable

Return a builder for a new slide table.

TypeScript
newTable(existing?: FSlideTable | string): FSlideTableBuilder

Parameters

  • existing — Optional. An existing table facade or table resource/element id to initialize the builder with for updating. If not specified, the builder will create a new table.

Returns

A table builder.

Examples

TypeScript
const fPresentation = univerAPI.getActivePresentation()const fSlide = fPresentation.getSlideByIndex(0)const tableInfo = fSlide  .newTable()  .setValues([    ['Name', 'Owner', 'Status'],    ['Facade', 'API', 'Ready'],  ])  .build()fSlide.insertTable(tableInfo)

Types: FSlideTableBuilder · FSlideTable

Package: @univerjs-pro/slides-table · Type definitions

FSlide.removeTable

Remove a slide table by facade, table id, or element id.

TypeScript
removeTable(table: FSlideTable): boolean

Parameters

  • table — Required. The table to remove.

Returns

Whether the command succeeded.

Examples

TypeScript
const fPresentation = univerAPI.getActivePresentation()const fSlide = fPresentation.getSlideByIndex(0)const table = fSlide.getTableById('status-table')if (table) {  fSlide.removeTable(table)}

Types: FSlideTable

Package: @univerjs-pro/slides-table · Type definitions

FSlide.updateTable

Update a slide table by builder info.

TypeScript
updateTable(tableInfo: ISlideTableBuilderInfo): FSlideTable

Parameters

  • tableInfo — Required. The table builder info with updated properties. The table.id and element.id must be provided to identify which table to update.

Returns

The updated table facade.

Examples

TypeScript
const fPresentation = univerAPI.getActivePresentation()const fSlide = fPresentation.getSlideByIndex(0)const table = fSlide.getTableById('status-table')const tableInfo = table  .toBuilder()  .setValues([    ['Quarter', 'Owner', 'Status'],    ['Q1', 'Sales', 'Done'],  ])  .setRows(3)  .setColumns(4)  .setColumnWidth(105)  .setRowHeight(60)  .setAbsolutePosition(80, 120)  .setSize(420, 180)  .build()fSlide.updateTable(tableInfo)

Types: FSlideTable · ISlideTableBuilderInfo

Package: @univerjs-pro/slides-table · Type definitions

@univerjs-pro/slides-thread-comment

FSlide.createElementCommentAsync

Creates a comment for any slide element ID, including shapes, text, images, charts, tables, and groups.

TypeScript
createElementCommentAsync(elementId: string, content: ThreadComment.ThreadCommentContent, options?: ISlideCommentCreateOptions): Promise<boolean>

Parameters

  • elementId — Required. Stable ID returned by the target element Facade, such as getId() or getElementId().
  • content — Required. Plain text or a Univer document body for rich comment content.
  • options — Optional. Default: {}. Optional stable IDs, author, attachments, and creation time.

Returns

true when the create command succeeds; otherwise, false.

Throws

If the element does not exist on this slide.

If the content is empty.

Examples

TypeScript
const slide = univerAPI.getActivePresentation()?.getSlideByIndex(0)const chart = slide?.getCharts()[0]if (chart) await slide?.createElementCommentAsync(chart.getElementId(), 'Verify the chart source.')

Types: Promise · ThreadComment.ThreadCommentContent · ISlideCommentCreateOptions

Package: @univerjs-pro/slides-thread-comment · Type definitions

FSlide.createPositionCommentAsync

Creates a free-position comment. Coordinates are normalized to the slide size.

TypeScript
createPositionCommentAsync(position: ISlideCommentPosition, content: ThreadComment.ThreadCommentContent, options?: ISlideCommentCreateOptions): Promise<boolean>

Parameters

  • position — Required. Normalized position where (0, 0) is the top-left and (1, 1) is the bottom-right.
  • content — Required. Plain text or a Univer document body for rich comment content.
  • options — Optional. Default: {}. Optional stable IDs, author, attachments, and creation time.

Returns

true when the create command succeeds; otherwise, false.

Throws

If either coordinate is not finite or is outside the inclusive range from 0 to 1.

If the content is empty.

Examples

TypeScript
const slide = univerAPI.getActivePresentation()?.getSlideByIndex(0)await slide?.createPositionCommentAsync({ x: 0.5, y: 0.25 }, 'Check this area.')

Types: Promise · ISlideCommentPosition · ThreadComment.ThreadCommentContent · ISlideCommentCreateOptions

Package: @univerjs-pro/slides-thread-comment · Type definitions

FSlide.getComments

Returns locally loaded element and free-position comments on this slide.

TypeScript
getComments(): ThreadComment.IFacadeThreadCommentInfo[]

Returns

Every locally loaded comment thread anchored to this slide.

Examples

TypeScript
const comments = univerAPI.getActivePresentation()?.getSlideByIndex(0)?.getComments() ?? []comments.forEach(({ root, anchor }) => console.log(root.id, anchor))

Types: ThreadComment.IFacadeThreadCommentInfo

Package: @univerjs-pro/slides-thread-comment · Type definitions

FSlide.getElementComments

Returns locally loaded comments for one stable slide element ID.

TypeScript
getElementComments(elementId: string): ThreadComment.IFacadeThreadCommentInfo[]

Parameters

  • elementId — Required. Stable ID of the target slide element.

Returns

Matching comment threads for this slide and element.

Examples

TypeScript
const slide = univerAPI.getActivePresentation()?.getSlideByIndex(0)const element = slide?.getElements()[0]const comments = element ? (slide?.getElementComments(element.getId()) ?? []) : []console.log(comments.length)

Types: ThreadComment.IFacadeThreadCommentInfo

Package: @univerjs-pro/slides-thread-comment · Type definitions

FSlide.listCommentsAsync

Synchronizes known threads and returns element and free-position comments on this slide.

TypeScript
listCommentsAsync(): Promise<ThreadComment.IFacadeThreadCommentInfo[]>

Returns

A promise resolving to every synchronized comment thread anchored to this slide.

Examples

TypeScript
const slide = univerAPI.getActivePresentation()?.getSlideByIndex(0)const comments = slide ? await slide.listCommentsAsync() : []console.log(comments.length)

Types: ThreadComment.IFacadeThreadCommentInfo · Promise

Package: @univerjs-pro/slides-thread-comment · Type definitions

FSlide.listElementCommentsAsync

Synchronizes known threads and returns comments for one stable slide element ID.

TypeScript
listElementCommentsAsync(elementId: string): Promise<ThreadComment.IFacadeThreadCommentInfo[]>

Parameters

  • elementId — Required. Stable ID of the target slide element.

Returns

A promise resolving to matching synchronized comment threads.

Examples

TypeScript
const slide = univerAPI.getActivePresentation()?.getSlideByIndex(0)const element = slide?.getElements()[0]const comments = element ? await slide.listElementCommentsAsync(element.getId()) : []console.log(comments.length)

Types: ThreadComment.IFacadeThreadCommentInfo · Promise

Package: @univerjs-pro/slides-thread-comment · Type definitions

你觉得这篇文档如何?

© 2026 DreamNum Co., Ltd.