@univerjs/docs-ui
Version:
Editor UI layer for Univer Docs.
76 lines (75 loc) • 3.44 kB
TypeScript
/**
* 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 } from '@univerjs/core';
import type { IRectRangeWithStyle, ITextRangeWithStyle } from '@univerjs/engine-render';
import { Disposable, ICommandService, ILogService, IUniverInstanceService, SliceBodyType } from '@univerjs/core';
import { DocSelectionManagerService } from '@univerjs/docs';
import { ImageSourceType } from '@univerjs/drawing';
import { IClipboardInterfaceService } from '@univerjs/ui';
export interface IClipboardPropertyItem {
}
export interface IDocClipboardHook {
onCopyProperty?(start: number, end: number): IClipboardPropertyItem;
onCopyContent?(start: number, end: number): string;
onBeforePaste?: (body: IDocumentBody) => IDocumentBody;
onBeforePasteImage?: (file: File) => Promise<{
source: string;
imageSourceType: ImageSourceType;
} | null>;
}
export interface IDocClipboardService {
copy(sliceType?: SliceBodyType, ranges?: ITextRangeWithStyle[]): Promise<boolean>;
cut(ranges?: ITextRangeWithStyle[]): Promise<boolean>;
paste(items: ClipboardItem[]): Promise<boolean>;
legacyPaste(options: {
html?: string;
text?: string;
internalJson?: string;
files: File[];
}): Promise<boolean>;
addClipboardHook(hook: IDocClipboardHook): IDisposable;
}
export declare function getTableClipboardBodySlice(body: IDocumentBody, range: IRectRangeWithStyle): IDocumentBody;
export declare const IDocClipboardService: import("@wendellhu/redi").IdentifierDecorator<IDocClipboardService>;
export declare class DocClipboardService extends Disposable implements IDocClipboardService {
private readonly _univerInstanceService;
private readonly _logService;
private readonly _commandService;
private readonly _clipboardInterfaceService;
private readonly _docSelectionManagerService;
private _clipboardHooks;
private _htmlToUDM;
private _umdToHtml;
constructor(_univerInstanceService: IUniverInstanceService, _logService: ILogService, _commandService: ICommandService, _clipboardInterfaceService: IClipboardInterfaceService, _docSelectionManagerService: DocSelectionManagerService);
copy(sliceType?: SliceBodyType, ranges?: ITextRangeWithStyle[]): Promise<boolean>;
cut(ranges?: ITextRangeWithStyle[]): Promise<boolean>;
paste(items: ClipboardItem[]): Promise<boolean>;
legacyPaste(options: {
html?: string;
internalJson?: string;
text?: string;
files: File[];
}): Promise<boolean>;
private _cut;
private _paste;
private _setClipboardData;
addClipboardHook(hook: IDocClipboardHook): IDisposable;
private _getDocumentBodyInRanges;
private _genDocDataFromClipboardItems;
private _genDocDataFromHtmlAndText;
private _uploadBase64ImagesInHtml;
private _createImagePasteHtml;
}