/** * Copyright 2023-present DreamNum Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import type { IDisposable, IRange } from '@univerjs/core'; import { Disposable, IImageIoService, ImageSourceType, IUniverInstanceService, IURLImageService } from '@univerjs/core'; import { SheetsSelectionsService } from '@univerjs/sheets'; declare global { interface Window { showDirectoryPicker(options?: { mode?: 'read' | 'readwrite'; }): Promise; } } /** * File name part type for multi-select */ export declare enum FileNamePart { /** * Use cell address as part of file name (e.g., A1, B2) */ CELL_ADDRESS = "cellAddress", /** * Use value from a specific column as part of file name */ COLUMN_VALUE = "columnValue" } export interface ICellImageInfo { row: number; col: number; cellAddress: string; source: string; imageSourceType: ImageSourceType; imageId: string; } export interface IBatchSaveImagesConfig { /** * Selected file name parts (multi-select) */ fileNameParts: FileNamePart[]; /** * Column index for COLUMN_VALUE part */ columnIndex?: number; } export interface IBatchSaveImagesService { /** * Get all cell images in the current selection */ getCellImagesInSelection(): ICellImageInfo[]; /** * Get cell images from specified ranges * @param unitId The workbook unit ID * @param subUnitId The worksheet ID * @param ranges The ranges to get images from */ getCellImagesFromRanges(unitId: string, subUnitId: string, ranges: IRange[]): ICellImageInfo[]; /** * Get columns that have data in the current selection */ getDataColumns(): Array<{ index: number; label: string; }>; /** * Get columns that have data for specified ranges * @param unitId The workbook unit ID * @param subUnitId The worksheet ID * @param ranges The ranges to check */ getDataColumnsForRanges(unitId: string, subUnitId: string, ranges: IRange[]): Array<{ index: number; label: string; }>; /** * Get current selection range as A1 notation */ getSelectionRangeNotation(): string; /** * Generate file name for a cell image based on config * @param imageInfo The cell image info * @param config The file name configuration */ generateFileName(imageInfo: ICellImageInfo, config: IBatchSaveImagesConfig): string; /** * Generate file name with specified worksheet context * @param imageInfo The cell image info * @param config The file name configuration * @param unitId The workbook unit ID * @param subUnitId The worksheet ID */ generateFileNameWithContext(imageInfo: ICellImageInfo, config: IBatchSaveImagesConfig, unitId: string, subUnitId: string): string; /** * Save images to the file system * @param images The images to save * @param config The file name configuration */ saveImages(images: ICellImageInfo[], config: IBatchSaveImagesConfig): Promise; /** * Save images to the file system with specified worksheet context * @param images The images to save * @param config The file name configuration * @param unitId The workbook unit ID * @param subUnitId The worksheet ID */ saveImagesWithContext(images: ICellImageInfo[], config: IBatchSaveImagesConfig, unitId: string, subUnitId: string): Promise; /** * Download a single image directly * @param imageInfo The cell image info */ downloadSingleImage(imageInfo: ICellImageInfo): Promise; /** * Get the row range of current selection * Returns the min and max row indices */ getSelectionRowRange(): { startRow: number; endRow: number; } | null; /** * Get all column indices that are within the current selection */ /** * Get all column indices that are within the current selection */ getSelectionColumnIndices(): Set; /** * Register a custom image downloader for URL images * @param downloader The downloader function that takes a URL and returns a base64 string * @returns A disposable object to unregister the downloader */ registerURLImageDownloader(downloader: (url: string) => Promise): IDisposable; } export declare const IBatchSaveImagesService: import("@wendellhu/redi").IdentifierDecorator; export declare class BatchSaveImagesService extends Disposable implements IBatchSaveImagesService { private readonly _univerInstanceService; private readonly _selectionService; private readonly _imageIoService; private readonly _urlImageService; constructor(_univerInstanceService: IUniverInstanceService, _selectionService: SheetsSelectionsService, _imageIoService: IImageIoService, _urlImageService: IURLImageService); /** * @deprecated Use IURLImageService directly */ registerURLImageDownloader(downloader: (url: string) => Promise): IDisposable; getCellImagesInSelection(): ICellImageInfo[]; getCellImagesFromRanges(unitId: string, subUnitId: string, ranges: IRange[]): ICellImageInfo[]; getDataColumns(): Array<{ index: number; label: string; }>; getDataColumnsForRanges(unitId: string, subUnitId: string, ranges: IRange[]): Array<{ index: number; label: string; }>; getSelectionRangeNotation(): string; getSelectionRowRange(): { startRow: number; endRow: number; } | null; getSelectionColumnIndices(): Set; generateFileName(imageInfo: ICellImageInfo, config: IBatchSaveImagesConfig): string; generateFileNameWithContext(imageInfo: ICellImageInfo, config: IBatchSaveImagesConfig, unitId: string, subUnitId: string): string; saveImages(images: ICellImageInfo[], config: IBatchSaveImagesConfig): Promise; saveImagesWithContext(images: ICellImageInfo[], config: IBatchSaveImagesConfig, unitId: string, subUnitId: string): Promise; downloadSingleImage(imageInfo: ICellImageInfo): Promise; private _getImageBlob; }