UNPKG

carbon-react

Version:

A library of reusable React components for easily building user interfaces.

62 lines (61 loc) 2.22 kB
import { DOMConversionOutput, EditorConfig, LexicalNode, NodeKey, SerializedTextNode, TextNode } from "lexical"; export interface SerializedMentionNode extends SerializedTextNode { mention: string; } export declare class MentionNode extends TextNode { __mention: string; /** * Returns the custom type when requested * @returns the custom "mention" typing */ static getType(): string; /** * [INTERNAL] Copies the node. This method is internal to Lexical and should not be used; * use $convertMentionElement or $createMentionNode */ static clone(node: MentionNode): MentionNode; /** * Initializes the node with the mention name and optional text/key * @param mentionName The actual mention data * @param text The displayed mention * @param key Lexical key */ constructor(mentionName: string, text?: string, key?: NodeKey); createDOM(config: EditorConfig): HTMLElement; exportJSON(): { type: string; version: number; mention: string; format: number; $?: Record<string, unknown> | undefined; detail: number; mode: import("lexical").TextModeType; style: string; text: string; }; static importJSON(serializedNode: SerializedMentionNode): MentionNode; setFormat(): this; toggleFormat(): this; hasFormat(): boolean; canInsertTextBefore(): boolean; canInsertTextAfter(): boolean; } /** * Creates a new mention instance * @param mentionName The underlying mention content e.g. `john-doe` * @param textContent The text representation to display e.g. `John Doe` * @returns a new MentionNode */ export declare function $createMentionNode(mentionName: string, textContent?: string): MentionNode; /** * Determines whether a node is a MentionNode * @param node the node to check * @returns true if a mention, otherwise false */ export declare function $isMentionNode(node?: LexicalNode | null): node is MentionNode; /** * Converts a DOM node to a MentionNode * @param domNode The DOM node to convert * @returns a MentionNode */ export declare const $convertMentionElement: (domNode: HTMLElement) => DOMConversionOutput | null;