/** * 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, IExecutionOptions } from '@univerjs/core'; import type { CommentUpdate, IAddCommentCommandParams, IDeleteCommentCommandParams } from '@univerjs/thread-comment'; import { FWorkbook } from '@univerjs/sheets/facade'; import { ThreadCommentModel } from '@univerjs/thread-comment'; import { FThreadComment } from './f-thread-comment'; type IUpdateCommandParams = any; /** * @ignore */ export interface IFWorkbookSheetsThreadCommentMixin { /** * Get all comments in the current workbook * @returns {FThreadComment[]} All comments in the current workbook * @example * ```ts * const fWorkbook = univerAPI.getActiveWorkbook(); * const comments = fWorkbook.getComments(); * comments.forEach((comment) => { * const isRoot = comment.getIsRoot(); * * if (isRoot) { * console.log('root comment:', comment.getCommentData()); * * const replies = comment.getReplies(); * replies.forEach((reply) => { * console.log('reply comment:', reply.getCommentData()); * }); * } * }); * ``` */ getComments(): FThreadComment[]; /** * Clear all comments in the current workbook * @returns {Promise} Whether the comments are cleared successfully. * @example * ```ts * const fWorkbook = univerAPI.getActiveWorkbook(); * const result = await fWorkbook.clearComments(); * console.log(result); * ``` */ clearComments(): Promise; /** * @deprecated use `univerAPI.addEvent(univerAPI.Event.CommentUpdated, (params) => {})` as instead */ onThreadCommentChange(callback: (commentUpdate: CommentUpdate) => void | false): IDisposable; /** * @deprecated use `univerAPI.addEvent(univerAPI.Event.BeforeCommentAdd, (params) => {})` as instead */ onBeforeAddThreadComment(this: FWorkbook, callback: (params: IAddCommentCommandParams, options: IExecutionOptions | undefined) => void | false): IDisposable; /** * @deprecated use `univerAPI.addEvent(univerAPI.Event.BeforeCommentUpdate, (params) => {})` as instead */ onBeforeUpdateThreadComment(this: FWorkbook, callback: (params: IUpdateCommandParams, options: IExecutionOptions | undefined) => void | false): IDisposable; /** * @deprecated use `univerAPI.addEvent(univerAPI.Event.BeforeCommentDelete, (params) => {})` as instead */ onBeforeDeleteThreadComment(this: FWorkbook, callback: (params: IDeleteCommentCommandParams, options: IExecutionOptions | undefined) => void | false): IDisposable; } /** * @ignore */ export declare class FWorkbookSheetsThreadCommentMixin extends FWorkbook implements IFWorkbookSheetsThreadCommentMixin { _threadCommentModel: ThreadCommentModel; /** * @ignore */ _initialize(): void; getComments(): FThreadComment[]; clearComments(): Promise; /** * @param callback * @deprecated */ onThreadCommentChange(callback: (commentUpdate: CommentUpdate) => void | false): IDisposable; /** * @param callback * @deprecated */ onBeforeAddThreadComment(callback: (params: IAddCommentCommandParams, options: IExecutionOptions | undefined) => void | false): IDisposable; /** * @param callback * @deprecated */ onBeforeUpdateThreadComment(callback: (params: IUpdateCommandParams, options: IExecutionOptions | undefined) => void | false): IDisposable; /** * @param callback * @deprecated */ onBeforeDeleteThreadComment(callback: (params: IDeleteCommentCommandParams, options: IExecutionOptions | undefined) => void | false): IDisposable; } declare module '@univerjs/sheets/facade' { interface FWorkbook extends IFWorkbookSheetsThreadCommentMixin { } } export {};