/** * 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 { Nullable } from '@univerjs/core'; import type { ISheetNote } from '@univerjs/sheets-note'; import { FRange } from '@univerjs/sheets/facade'; export interface ICreateOrUpdateNoteOptions { id?: string; width: number; height: number; note: string; show?: boolean; } /** * @ignore */ export interface IFRangeSheetsNoteMixin { /** * Get the annotation of the top-left cell in the range * @returns {Nullable} The annotation of the top-left cell in the range * @example * ```ts * const fWorkbook = univerAPI.getActiveWorkbook(); * const fWorksheet = fWorkbook.getSheetByName('Sheet1'); * if (!fWorksheet) return; * const fRange = fWorksheet.getRange('A1:D10'); * const note = fRange.getNote(); * console.log(note); * ``` */ getNote(): Nullable; /** * Create or update the annotation of the top-left cell in the range * @param {ICreateOrUpdateNoteOptions} note The annotation to create or update * @returns {FRange} This range for method chaining * @example * ```ts * const fWorkbook = univerAPI.getActiveWorkbook(); * const fWorksheet = fWorkbook.getSheetByName('Sheet1'); * if (!fWorksheet) return; * const fRange = fWorksheet.getRange('A1'); * fRange.createOrUpdateNote({ * note: 'This is a note', * width: 160, * height: 100, * show: true, * }); * ``` */ createOrUpdateNote(note: ICreateOrUpdateNoteOptions): FRange; /** * Delete the annotation of the top-left cell in the range * @returns {FRange} This range for method chaining * @example * ```ts * const fWorkbook = univerAPI.getActiveWorkbook(); * const fWorksheet = fWorkbook.getSheetByName('Sheet1'); * if (!fWorksheet) return; * const notes = fWorksheet.getNotes(); * console.log(notes); * * if (notes.length > 0) { * // Delete the first note * const { row, col } = notes[0]; * fWorksheet.getRange(row, col).deleteNote(); * } * ``` */ deleteNote(): FRange; } export declare class FRangeSheetsNoteMixin extends FRange implements IFRangeSheetsNoteMixin { createOrUpdateNote(note: ICreateOrUpdateNoteOptions): FRange; deleteNote(): FRange; getNote(): Nullable; } declare module '@univerjs/sheets/facade' { interface FRange extends IFRangeSheetsNoteMixin { } }