import type { ISlideDocumentData, ISlidePage, ISlidePageSize, ISlidePresentationBackgroundGraphic, ISlideTransition, SlideModel, SlidePresentationBackgroundGraphicsTarget } from '@univerjs-pro/slides'; import { ICommandService, Injector, IResourceLoaderService } from '@univerjs/core'; import { FBaseInitialable } from '@univerjs/core/facade'; import { FSlide } from './f-slide'; /** * Options used to create a slide page. */ export interface ISlideCreateOptions extends Partial { } /** * Options for applying presentation-level background graphics. */ export interface ISetPresentationBackgroundGraphicsOptions { /** * Which master pages should receive the managed background graphics. * Defaults to `allMasters` so the call behaves like a deck-level setting. */ target?: SlidePresentationBackgroundGraphicsTarget; /** * Explicit master page ids. When provided, this takes precedence over `target`. */ masterPageIds?: string[]; } /** * The facade class for a presentation. * @hideconstructor */ export declare class FPresentation extends FBaseInitialable { protected readonly _slideModel: SlideModel; protected readonly _injector: Injector; protected readonly _resourceLoaderService: IResourceLoaderService; protected readonly _commandService: ICommandService; /** * @property {string} id The presentation unit id. * @ignore */ readonly id: string; constructor(_slideModel: SlideModel, _injector: Injector, _resourceLoaderService: IResourceLoaderService, _commandService: ICommandService); /** * Get the presentation id. * @returns {string} The presentation id. * * @example * ```ts * const fPresentation = univerAPI.getActivePresentation(); * console.log(fPresentation.getId()); * ``` */ getId(): string; /** * Get the presentation name. * @returns {string} The presentation name. * * @example * ```ts * const fPresentation = univerAPI.getActivePresentation(); * console.log(fPresentation.getName()); * ``` */ getName(): string; /** * Set the presentation name. * @param {string} name The new presentation name. * @returns {FPresentation} This presentation, for chaining. * * @example * ```ts * const fPresentation = univerAPI.getActivePresentation(); * fPresentation.setName('Quarterly Review'); * ``` */ setName(name: string): this; /** * Get the underlying presentation model. * @returns {SlideModel} The presentation model. * * @example * ```ts * const fPresentation = univerAPI.getActivePresentation(); * const model = fPresentation.getPresentation(); * console.log(model.getUnitId()); * ``` */ getPresentation(): SlideModel; /** * Save and return the presentation snapshot. * @returns {ISlideDocumentData} The presentation snapshot. * * @example * ```ts * const fPresentation = univerAPI.getActivePresentation(); * const snapshot = fPresentation.save(); * console.log(snapshot.slideOrder); * ``` */ save(): ISlideDocumentData; /** * Get the presentation snapshot. * @returns {ISlideDocumentData} The presentation snapshot. * * @example * ```ts * const fPresentation = univerAPI.getActivePresentation(); * console.log(fPresentation.getSnapshot()); * ``` */ getSnapshot(): ISlideDocumentData; /** * Get the default page size of the presentation. * @returns {ISlidePageSize} The page size. * * @example * ```ts * const fPresentation = univerAPI.getActivePresentation(); * console.log(fPresentation.getPageSize()); * ``` */ getPageSize(): ISlidePageSize; /** * Set the default page size of the presentation. * @param {ISlidePageSize} pageSize The new default page size. * @returns {FPresentation} This presentation, for chaining. */ setPageSize(pageSize: ISlidePageSize): this; /** * Get managed presentation background graphics from a master page. * When `masterPageId` is omitted, the active slide's master is used. * @param {string} [masterPageId] Optional master page id to read from. * @returns {ISlidePresentationBackgroundGraphic[]} The managed deck background graphics. * * @example * ```ts * const fPresentation = univerAPI.getActivePresentation(); * const graphics = fPresentation.getPresentationBackgroundGraphics(); * console.log(graphics[0]?.fit); * ``` */ getPresentationBackgroundGraphics(masterPageId?: string): ISlidePresentationBackgroundGraphic[]; /** * Set managed presentation background graphics. * The call updates master pages through `SetPresentationBackgroundGraphicsCommand`. * @param {ISlidePresentationBackgroundGraphic[]} graphics The managed background graphics. * @param {ISetPresentationBackgroundGraphicsOptions} [options] Target master options. * @returns {FPresentation} This presentation, for chaining. * * @example * ```ts * fPresentation.setPresentationBackgroundGraphics([{ * source: 'image-source-id', * imageSourceType: 'UUID', * fit: 'cover', * }]); * ``` */ setPresentationBackgroundGraphics(graphics: ISlidePresentationBackgroundGraphic[], options?: ISetPresentationBackgroundGraphicsOptions): this; /** * Clear managed presentation background graphics. * @param {ISetPresentationBackgroundGraphicsOptions} [options] Target master options. * @returns {FPresentation} This presentation, for chaining. */ clearPresentationBackgroundGraphics(options?: ISetPresentationBackgroundGraphicsOptions): this; applyTransitionToAll(transition: ISlideTransition): this; /** * Get all slides in the presentation. * @returns {FSlide[]} The slides in slide order. * * @example * ```ts * const fPresentation = univerAPI.getActivePresentation(); * const slides = fPresentation.getSlides(); * console.log(slides.length); * ``` */ getSlides(): FSlide[]; /** * Get a slide by id. * @param {string} id The slide id. * @returns {FSlide|null} The slide, or `null` if it does not exist. * * @example * ```ts * const fPresentation = univerAPI.getActivePresentation(); * const slide = fPresentation.getSlideById('slide-1'); * console.log(slide?.getName()); * ``` */ getSlideById(id: string): FSlide | null; /** * Get a slide by index. * @param {number} index The zero-based slide index. * @returns {FSlide|null} The slide, or `null` if the index is out of range. * * @example * ```ts * const fPresentation = univerAPI.getActivePresentation(); * const firstSlide = fPresentation.getSlideByIndex(0); * console.log(firstSlide?.getId()); * ``` */ getSlideByIndex(index: number): FSlide | null; /** * Get the active slide. * @returns {FSlide|null} The active slide, or `null` if no slide is active. * * @example * ```ts * const fPresentation = univerAPI.getActivePresentation(); * const activeSlide = fPresentation.getActiveSlide(); * console.log(activeSlide?.getId()); * ``` */ getActiveSlide(): FSlide | null; /** * Set the active slide. * @param {FSlide|string} slide The slide facade or slide id to activate. * @returns {FPresentation} This presentation, for chaining. * * @example * ```ts * const fPresentation = univerAPI.getActivePresentation(); * const secondSlide = fPresentation.getSlideByIndex(1); * if (secondSlide) { * fPresentation.setActiveSlide(secondSlide); * } * ``` */ setActiveSlide(slide: FSlide | string): this; /** * Append a new slide to the end of the presentation. * @param {ISlideCreateOptions} [options] The slide creation options. * @param {string} [options.id] The slide id. If omitted, a random id is generated. * @param {string} [options.name] The slide name. * @param {Record} [options.elements] The slide element map. * @returns {FSlide} The created slide. * * @example * ```ts * const fPresentation = univerAPI.getActivePresentation(); * const slide = fPresentation.appendSlide({ name: 'Summary' }); * console.log(slide.getId()); * ``` */ appendSlide(options?: ISlideCreateOptions): FSlide; /** * Insert a new slide at the specified index. * @param {number} index The zero-based insert index. * @param {ISlideCreateOptions} [options] The slide creation options. * @param {string} [options.id] The slide id. If omitted, a random id is generated. * @param {string} [options.name] The slide name. * @param {Record} [options.elements] The slide element map. * @returns {FSlide} The created slide. * * @example * ```ts * const fPresentation = univerAPI.getActivePresentation(); * const slide = fPresentation.insertSlide(0, { name: 'Opening' }); * console.log(slide.getName()); * ``` */ insertSlide(index: number, options?: ISlideCreateOptions): FSlide; /** * Move a slide to a new index. * @param {FSlide|string} slide The slide facade or slide id to move. * @param {number} toIndex The target zero-based index. * @returns {boolean} Whether the slide was moved successfully. * * @example * ```ts * const fPresentation = univerAPI.getActivePresentation(); * const firstSlide = fPresentation.getSlideByIndex(0); * if (firstSlide) { * fPresentation.moveSlide(firstSlide, 1); * } * ``` */ moveSlide(slide: FSlide | string, toIndex: number): boolean; /** * Delete a slide. * @param {FSlide|string} slide The slide facade or slide id to delete. * @returns {boolean} Whether the slide was deleted successfully. * * @example * ```ts * const fPresentation = univerAPI.getActivePresentation(); * const slide = fPresentation.getSlideByIndex(1); * if (slide) { * fPresentation.deleteSlide(slide); * } * ``` */ deleteSlide(slide: FSlide | string): boolean; private _createSlideData; }