UNPKG

@lobehub/editor

Version:

A powerful and extensible rich text editor built on Meta's Lexical framework, providing a modern editing experience with React integration.

65 lines (64 loc) 3.29 kB
import { BaseSelection, LexicalEditor, LexicalNode, TextNode } from 'lexical'; import { IRootNode } from "../../../editor-kernel/inode"; /** * Returns true if the node can contain transformable markdown. * Code nodes cannot contain transformable markdown. * For example, `code **bold**` should not be transformed to * <code>code <strong>bold</strong></code>. */ export declare function canContainTransformableMarkdown(node: LexicalNode | undefined): node is TextNode; export declare function isEqualSubString(stringA: string, aStart: number, stringB: string, bStart: number, length: number): boolean; export declare const PUNCTUATION_OR_SPACE: RegExp; export declare function getOpenTagStartIndex(string: string, maxIndex: number, tag: string): number; export declare function indexBy<T>(list: Array<T>, callback: (arg0: T) => string | undefined): Readonly<Record<string, Array<T>>>; /** * Checks if a character is a punctuation character. * @param char The character to check. * @returns True if the character is a punctuation character, false otherwise. */ export declare function isPunctuationChar(char: string): boolean; /** * Inserts Lexical nodes into the editor using different strategies depending on * some simple selection-based heuristics. If you're looking for a generic way to * to insert nodes into the editor at a specific selection point, you probably want * {@link lexical.$insertNodes} * * @param editor LexicalEditor instance to insert the nodes into. * @param nodes The nodes to insert. * @param selection The selection to insert the nodes into. */ export declare function $insertGeneratedNodes(editor: LexicalEditor, nodes: Array<LexicalNode>, selection: BaseSelection): void; export interface BaseSerializedNode { children?: Array<BaseSerializedNode>; type: string; version: number; } /** * Creates an object containing all the styles and their values provided in the CSS string. * @param css - The CSS string of styles and their values. * @returns The styleObject containing all the styles and their values. */ export declare function getStyleObjectFromRawCSS(css: string): Record<string, string>; /** * Copyright (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * */ export declare const CSS_TO_STYLES: Map<string, Record<string, string>>; /** * Gets the TextNode's style object and adds the styles to the CSS. * @param node - The TextNode to add styles to. */ export declare function $addNodeStyle(node: TextNode): void; /** * This method takes an array of objects conforming to the BaseSerializedNode interface and returns * an Array containing instances of the corresponding LexicalNode classes registered on the editor. * Normally, you'd get an Array of BaseSerialized nodes from {@link $generateJSONFromSelectedNodes} * * @param serializedNodes an Array of objects conforming to the BaseSerializedNode interface. * @returns an Array of Lexical Node objects. */ export declare function $generateNodesFromSerializedNodes(serializedNodes: Array<BaseSerializedNode>): Array<LexicalNode>; export declare function insertIRootNode(editor: LexicalEditor, root: IRootNode, selection: BaseSelection): void;