/** * 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, IDocumentBody, IDocumentData } from '@univerjs/core'; import type { IRectRangeWithStyle, ITextRangeWithStyle } from '@univerjs/engine-render'; import type { Observable } from 'rxjs'; import { Disposable, ErrorService, ICommandService, ILogService, ImageSourceType, IPermissionService, IUndoRedoService, IUniverInstanceService, SliceBodyType } from '@univerjs/core'; import { DocSelectionManagerService, DocStateChangeManagerService } from '@univerjs/docs'; import { IClipboardInterfaceService } from '@univerjs/ui'; import type { DocPasteMode } from './paste-options'; import { DocMenuStyleService } from '../doc-menu-style.service'; import { DocHtmlExportService } from './udm-to-html/doc-html-export.service'; export declare function convertClipboardHtmlToDocumentData(html: string, unitId?: string): Partial; export declare function removeClipboardHtmlImages(html: string): string; export interface IClipboardPropertyItem { } export interface IDocClipboardCopyDocDataContext { sourceDocuments: IDocumentData[]; } export interface IDocClipboardCopyContentContext { body: IDocumentBody; segmentId?: string; unitId: string; } export interface IDocClipboardPasteContext { documentData: Partial; targetUnitId: string; } export interface IDocClipboardHook { /** Opt an internal rich-text editor into the post-paste format menu. */ supportsPasteOptions?(unitId: string): boolean; /** Supply a rich fragment for selections owned by a plugin rather than native text ranges. */ onCopySelection?(unitId: string): { documentData: IDocumentData; plainText: string; } | undefined; onCopyDocData?(doc: Partial, context: IDocClipboardCopyDocDataContext): Partial; onCopyProperty?(start: number, end: number): IClipboardPropertyItem; onCopyContent?(start: number, end: number, context: IDocClipboardCopyContentContext): string; onBeforePaste?: (body: IDocumentBody, context: IDocClipboardPasteContext) => IDocumentBody; onBeforePasteImage?: (file: File) => Promise<{ source: string; imageSourceType: ImageSourceType; } | null>; } export interface IDocClipboardPayload { html?: string; text?: string; internalJson?: string; files: File[]; unitId?: string; mode?: DocPasteMode; } export interface IDocPasteOptionsState { unitId: string; mode: DocPasteMode; range: ITextRangeWithStyle; } export interface IDocClipboardService { copy(sliceType?: SliceBodyType, ranges?: ITextRangeWithStyle[]): Promise; cut(ranges?: ITextRangeWithStyle[]): Promise; paste(items?: ClipboardItem[], mode?: DocPasteMode): Promise; pasteFromClipboard(mode?: DocPasteMode): Promise; legacyPaste(options: IDocClipboardPayload): Promise; readonly pasteOptions$: Observable; isPasteOptionsEnabled(unitId: string): boolean; setNextPasteMode(mode: DocPasteMode): void; dismissPasteOptions(): void; changePasteMode(mode: DocPasteMode): Promise; addClipboardHook(hook: IDocClipboardHook): IDisposable; } export declare function getTableClipboardBodySlice(body: IDocumentBody, range: IRectRangeWithStyle): IDocumentBody; export declare const IDocClipboardService: import("@wendellhu/redi").IdentifierDecorator; export declare class DocClipboardService extends Disposable implements IDocClipboardService { private readonly _univerInstanceService; private readonly _logService; private readonly _commandService; private readonly _permissionService; private readonly _clipboardInterfaceService; private readonly _errorService; private readonly _docSelectionManagerService; private readonly _stateChangeManager; private readonly _menuStyleService; private readonly _undoRedoService; private readonly _pasteOptions$; readonly pasteOptions$: Observable; private _pasteSession; private _applyingPaste; private _pasteGeneration; private _nextPasteMode; private _lastSelectionKey; private _clipboardHooks; private _memoryClipboardData; private _htmlToUDM; private readonly _umdToHtml; constructor(_univerInstanceService: IUniverInstanceService, _logService: ILogService, _commandService: ICommandService, _permissionService: IPermissionService, _clipboardInterfaceService: IClipboardInterfaceService, _errorService: ErrorService, docHtmlExportService: DocHtmlExportService, _docSelectionManagerService: DocSelectionManagerService, _stateChangeManager: DocStateChangeManagerService, _menuStyleService: DocMenuStyleService, _undoRedoService: IUndoRedoService); copy(sliceType?: SliceBodyType, ranges?: ITextRangeWithStyle[]): Promise; cut(ranges?: ITextRangeWithStyle[]): Promise; pasteFromClipboard(mode?: DocPasteMode): Promise; paste(items?: ClipboardItem[], mode?: DocPasteMode): Promise; isPasteOptionsEnabled(unitId: string): boolean; setNextPasteMode(mode: DocPasteMode): void; legacyPaste(options: IDocClipboardPayload): Promise; dismissPasteOptions(): void; changePasteMode(mode: DocPasteMode): Promise; private _preparePaste; private _pasteWithOptions; private _getPasteStyle; private _getPasteSelectionKey; private _savePasteSession; private _getCurrentDocumentUnitId; private _canEditTargets; private _cut; private _paste; private _setClipboardData; private _getSelectionParams; addClipboardHook(hook: IDocClipboardHook): IDisposable; private _applyCopyDocDataHooks; private _getDocumentBodyInRanges; private _readClipboardItems; private _genDocDataFromHtmlAndText; private _uploadBase64ImagesInHtml; private _createImagePasteHtml; }