/** * 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 { IEventBase } from '@univerjs/core/facade'; import type { ICellLinkContent, ISheetHyperLink } from '@univerjs/sheets-hyper-link'; import type { FWorkbook, FWorksheet } from '@univerjs/sheets/facade'; import { FEventName } from '@univerjs/core/facade'; /** * @ignore */ interface IFSheetsHyperlinkEventNameMixin { /** * Event triggered before adding a link * @see {@link IBeforeSheetLinkAddEventParams} * @example * ```ts * const disposable = univerAPI.addEvent(univerAPI.Event.BeforeSheetLinkAdd, (params) => { * const { workbook, worksheet, row, col, link } = params; * console.log('before sheet link add', params); * * // Cancel the sheet link add operation * params.cancel = true; * }); * * // Remove the event listener, use `disposable.dispose()` * ``` */ readonly BeforeSheetLinkAdd: 'BeforeSheetLinkAdd'; /** * Event triggered before canceling a link * @see {@link IBeforeSheetLinkCancelEventParams} * @example * ```ts * const disposable = univerAPI.addEvent(univerAPI.Event.BeforeSheetLinkCancel, (params) => { * const { workbook, worksheet, row, column, id } = params; * console.log('before sheet link cancel', params); * * // Cancel the sheet link cancel operation * params.cancel = true; * }); * * // Remove the event listener, use `disposable.dispose()` * ``` */ readonly BeforeSheetLinkCancel: 'BeforeSheetLinkCancel'; /** * Event triggered before updating a link * @see {@link IBeforeSheetLinkUpdateEventParams} * @example * ```ts * const disposable = univerAPI.addEvent(univerAPI.Event.BeforeSheetLinkUpdate, (params) => { * const { workbook, worksheet, row, column, id, payload } = params; * console.log('before sheet link update', params); * * // Cancel the sheet link update operation * params.cancel = true; * }); * * // Remove the event listener, use `disposable.dispose()` * ``` */ readonly BeforeSheetLinkUpdate: 'BeforeSheetLinkUpdate'; } export declare class FSheetsHyperlinkEventNameMixin extends FEventName implements IFSheetsHyperlinkEventNameMixin { get BeforeSheetLinkAdd(): 'BeforeSheetLinkAdd'; get BeforeSheetLinkCancel(): 'BeforeSheetLinkCancel'; get BeforeSheetLinkUpdate(): 'BeforeSheetLinkUpdate'; } export interface IBeforeSheetLinkAddEventParams extends IEventBase { /** The workbook instance */ workbook: FWorkbook; /** The worksheet where the link will be added */ worksheet: FWorksheet; /** The row index of the target cell */ row: number; /** The column index of the target cell */ col: number; /** The hyperlink information to be added */ link: ISheetHyperLink; } export interface IBeforeSheetLinkCancelEventParams extends IEventBase { /** The workbook instance */ workbook: FWorkbook; /** The worksheet containing the link */ worksheet: FWorksheet; /** The row index of the cell */ row: number; /** The column index of the cell */ column: number; /** The unique identifier of the hyperlink */ id: string; } export interface IBeforeSheetLinkUpdateEventParams extends IEventBase { /** The workbook instance */ workbook: FWorkbook; /** The worksheet containing the link */ worksheet: FWorksheet; /** The row index of the cell */ row: number; /** The column index of the cell */ column: number; /** The unique identifier of the hyperlink */ id: string; /** The new hyperlink content/information */ payload: ICellLinkContent; } /** * @ignore */ export interface ISheetsHyperlinkEventParamConfig { BeforeSheetLinkAdd: IBeforeSheetLinkAddEventParams; BeforeSheetLinkCancel: IBeforeSheetLinkCancelEventParams; BeforeSheetLinkUpdate: IBeforeSheetLinkUpdateEventParams; } declare module '@univerjs/core/facade' { interface FEventName extends IFSheetsHyperlinkEventNameMixin { } interface IEventParamConfig extends ISheetsHyperlinkEventParamConfig { } } export {};