/* * Copyright (c) 2025, Salesforce, Inc. * All rights reserved. * For full license text, see the LICENSE.txt file */ /** * The `lightning/inputRichText` component provides a WYSIWYG editor with a customizable toolbar for entering rich text. * @see {@link https://developer.salesforce.com/docs/component-library/bundle/lightning-input-rich-text/documentation |Lightning Input Rich Text Documentation} */ declare module "lightning/inputRichText" { import { LightningElement } from "lwc"; /** * Represents formatting options that can be applied to text in the rich text editor. */ interface QuillFormat { font?: string; size?: string; color?: string; align?: string; bold?: boolean; italic?: boolean; underline?: boolean; strike?: boolean; link?: string; } /** * Defines how the selection is set after text is replaced in the rich text editor. */ type SelectMode = "select" | "start" | "end" | "preserve"; /** * Defines the toolbar variant options for the rich text editor. */ type ToolbarVariant = "bottom-toolbar" | undefined; /** * Represents a custom button configuration for the rich text editor toolbar. */ interface CustomButton { category?: string; buttons: ToolbarButton[]; } /** * Represents a toolbar button configuration for the rich text editor. */ interface ToolbarButton { label: string; iconName: string; format: string; value?: string; computedClass?: string; key?: string; variant?: "bare" | "bare-inverse"; handler?: (event: Event) => void; } /** * A WYSIWYG editor with a customizable toolbar for entering rich text. */ export default class LightningInputRichText extends LightningElement { /** * The label of the rich text editor. */ label: string | undefined; /** * Help text detailing the purpose and function of the rich text editor. * The text is displayed in a tooltip above the rich text editor when you provide a label value. * To display the label next to the tooltip, use the label-visible attribute. */ fieldLevelHelp: string | undefined; /** * If present, the label on the rich text editor is visible. * @default false */ labelVisible: boolean; /** * Specifies whether users must enter content in the editor. If present, an asterisk is displayed before the label when label-visible is present. */ required: boolean; /** * Text that is displayed when the field is empty, to prompt the user for a valid entry. */ placeholder: string | undefined; /** * A comma-separated list of button categories to remove from the toolbar. */ disabledCategories: string[]; /** * A list of allowed formats. By default, the list is computed based on enabled categories. * The 'table' format is always enabled to support copying and pasting of tables if formats are not provided. */ formats: string[]; /** * The variant changes the appearance of the toolbar. Accepted variant is bottom-toolbar which causes * the toolbar to be displayed below the text box. */ variant: ToolbarVariant | undefined; /** * Error message to be displayed when invalid input is detected. */ messageWhenBadInput: string | undefined; /** * Entity ID to share the image with. */ shareWithEntityId: string | undefined; /** * The HTML content in the rich text editor. */ value: string | undefined; /** * Specifies whether the editor content is valid. This value defaults to true. * @default true */ valid: boolean; /** * If present, the editor is disabled and users cannot interact with it. * @default false */ disabled: boolean; /** * Sets focus on the rich text editor. */ focus(): void; /** * Removes focus from the rich text editor. */ blur(): void; /** * Sets a format in the editor from the cursor point onwards. * The format also applies to currently selected content. * Valid formats are font, size, and align. * @param formats A key-value pair with format names and values. */ setFormat(formats: QuillFormat): void; /** * Returns an object representing the formats applied to the current selection. * Formats supported are align, background, bold, code, code-block, color, font, * header, italic, link, size, strike, underline. * @returns format an object representing the formats applied to the selection or editor */ getFormat(): QuillFormat; /** * Replaces a range of text in the rich text editor with a new string * @param replacement The string to insert. * @param start The 0-based index of the first character to replace. * @param end The 0-based index of the character after the last character to replace. * @param selectMode Defines how the selection is set after the text is replaced. Valid values are select, start, end, and preserve. */ setRangeText( replacement: string, start: number, end: number, selectMode: SelectMode, ): void; } }