FSlide
The facade class for a slide page.
Access
Access through:
FUniver.getSlideCommandTarget()FPresentation.getSlides()FPresentation.getSlideById()FPresentation.getSlideByIndex()FPresentation.getActiveSlide()FPresentation.appendSlide()FPresentation.insertSlide()
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.
deleteElement(element: FSlidePageElement): booleanParameters
element— Required. The element to remove.
Returns
Whether the element was removed successfully.
Examples
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.
getBackground(): ISlideBackgroundData | undefinedReturns
The explicit background.
Examples
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.
getData(): ISlidePageReturns
The slide page data.
Examples
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.
getElementById(id: string): FSlidePageElement | nullParameters
id— Required. The element id.
Returns
The page element, or null when it does not exist.
Examples
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.
getElementPermission(elementId: string): FSlideObjectPermissionParameters
elementId— Required. Stable element id.
Returns
Permission facade combining Presentation, Slide, and Element Edit points.
Examples
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.
getElements(): FSlidePageElement[]Returns
All page elements in element order.
Examples
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.
getGroups(): FGroup[]Returns
The groups on this slide.
Examples
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.
getId(): stringReturns
The slide id.
Examples
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.
getImages(): FImage[]Returns
The images on this slide.
Examples
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.
getName(): stringReturns
The slide name.
Examples
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.
getPageLayout(): ISlideFacadePageLayoutReturns
Page size and element bounds in Slide model coordinates.
Examples
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.
getPageSize(): ISlidePageSizeReturns
The resolved page size.
Examples
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.
getPermission(): FSlideObjectPermissionReturns
Permission facade combining Presentation and Slide page Edit points.
Examples
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.
getShape(id: string): FShape | FConnectorShape | nullParameters
id— Required. The shape id.
Returns
The Shape facade, or null when it does not exist.
Examples
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.
getShapes(): Array<FShape | FConnectorShape>Returns
The Shape facades on this slide.
Examples
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.
getSlide(): SlidePageReturns
The slide page model.
Examples
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.
getSpeakerNotes(): string | undefinedReturns
The speaker notes, or undefined if none are set.
Examples
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.
getTransition(): ISlideTransition | undefinedReturns
The resolved slide transition, or undefined if there is no transition.
Examples
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.
group(elements: FSlidePageElement[]): FGroupParameters
elements— Required. The elements to group.
Returns
The created group.
Examples
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.
insertElement(element: ISlidePageElement, index?: number): FSlidePageElementParameters
element— Required. The slide element data.index— Optional. The insert index in the element order.
Returns
The inserted element.
Examples
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.
insertImage(imageBuilderInfo: ISlideImageBuilderInfo, index?: number): FImageParameters
imageBuilderInfo— Required. The image builder info returned byFImageBuilder.build().index— Optional. The insert index in the element order.
Returns
The inserted image.
Examples
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.
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
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.
insertShape(input: IShapeCreateInput): FShape | FConnectorShape | nullParameters
input— Required. The common Shape creation input.
Returns
The inserted Shape facade, or null when creation fails.
Examples
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.
insertSmartArt(layoutId: string, transform?: IShapeCreateInput['transform']): FShape | FConnectorShape | nullParameters
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
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.
newImage(existing?: FImage | string): FImageBuilderParameters
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
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.
removeImage(image: FImage): booleanParameters
image— Required. The image or image element id to remove.
Returns
Whether the image was removed successfully.
Examples
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.
setBackground(background?: ISlideBackgroundData): thisParameters
background— Optional. The slide background. Omit to clear it.
Returns
This slide, for chaining.
Examples
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.
setPageSize(pageSize: Partial<ISlidePageSize>): thisParameters
pageSize— Required. The new slide page size.
Returns
This slide, for chaining.
Examples
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.
setShowMasterBackground(show: boolean): thisParameters
show— Required. Whether inherited master background content is shown.
Returns
This slide, for chaining.
Examples
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.
setSpeakerNotes(speakerNotes?: string): thisParameters
speakerNotes— Optional. The speaker notes. Pass an empty string or omit the argument to clear them.
Returns
This slide, for chaining.
Examples
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()) // undefinedPackage: @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.
setTransition(transition?: ISlideTransition): thisParameters
transition— Optional. The slide transition to set. Omit to clear the slide's explicit transition.
Returns
This slide, for chaining.
Examples
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.
ungroup(group: FGroup): FSlidePageElement[]Parameters
group— Required. The group facade or group id to ungroup.
Returns
The released child elements.
Examples
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.
updateImage(imageBuilderInfo: ISlideImageBuilderInfo): FImageParameters
imageBuilderInfo— Required. The image builder info returned byFImageBuilder.build().
Returns
The updated image.
Examples
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
getChart(chartIdOrElementId: string): FSlideChart | nullParameters
chartIdOrElementId— Required.
Types: FSlideChart
Package: @univerjs-pro/slides-chart · Type definitions
FSlide.getCharts
getCharts(): FSlideChart[]Types: FSlideChart
Package: @univerjs-pro/slides-chart · Type definitions
FSlide.insertChart
insertChart(info: ISlideChartInfo): Promise<FSlideChart>Parameters
info— Required.
Types: FSlideChart · Promise · ISlideChartInfo
Package: @univerjs-pro/slides-chart · Type definitions
FSlide.newChart
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.
getTableAt(index: number): FSlideTable | nullParameters
index— Required. The zero-based table index.
Returns
The table facade, or null when the index is out of range.
Examples
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.
getTableById(tableIdOrElementId: string): FSlideTable | nullParameters
tableIdOrElementId— Required. The table resource id or table element id.
Returns
The table facade, or null when it does not exist.
Examples
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.
getTables(): FSlideTable[]Returns
All table facades in element order.
Examples
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.
insertTable(tableInfo: ISlideTableBuilderInfo, index?: number): FSlideTable | nullParameters
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
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.
insertTableFromData(values: string[][], options?: ICreateSlideTableOptions): FSlideTable | nullParameters
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
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.
newTable(existing?: FSlideTable | string): FSlideTableBuilderParameters
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
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.
removeTable(table: FSlideTable): booleanParameters
table— Required. The table to remove.
Returns
Whether the command succeeded.
Examples
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.
updateTable(tableInfo: ISlideTableBuilderInfo): FSlideTableParameters
tableInfo— Required. The table builder info with updated properties. Thetable.idandelement.idmust be provided to identify which table to update.
Returns
The updated table facade.
Examples
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.
createElementCommentAsync(elementId: string, content: ThreadComment.ThreadCommentContent, options?: ISlideCommentCreateOptions): Promise<boolean>Parameters
elementId— Required. Stable ID returned by the target element Facade, such asgetId()orgetElementId().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
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.
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
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.
getComments(): ThreadComment.IFacadeThreadCommentInfo[]Returns
Every locally loaded comment thread anchored to this slide.
Examples
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.
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
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.
listCommentsAsync(): Promise<ThreadComment.IFacadeThreadCommentInfo[]>Returns
A promise resolving to every synchronized comment thread anchored to this slide.
Examples
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.
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
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
How is this guide?