mirror of
https://github.com/facebook/lexical.git
synced 2025-08-06 16:39:33 +08:00

* Improve multi element indentation * Remove bad UT * Remove bad UT * Add e2e test * Address feedback
79 lines
2.3 KiB
TypeScript
79 lines
2.3 KiB
TypeScript
/**
|
|
* 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.
|
|
*
|
|
* @flow strict
|
|
*/
|
|
|
|
import type {
|
|
EditorConfig,
|
|
LexicalNode,
|
|
NodeKey,
|
|
ParagraphNode,
|
|
RangeSelection,
|
|
EditorThemeClasses,
|
|
LexicalEditor,
|
|
} from 'lexical';
|
|
|
|
import {ElementNode, TextNode} from 'lexical';
|
|
|
|
declare class CodeNode extends ElementNode {
|
|
static getType(): string;
|
|
static clone(node: CodeNode): CodeNode;
|
|
constructor(key?: NodeKey);
|
|
createDOM<EditorContext>(config: EditorConfig<EditorContext>): HTMLElement;
|
|
updateDOM(prevNode: CodeNode, dom: HTMLElement): boolean;
|
|
insertNewAfter(
|
|
selection: RangeSelection,
|
|
): null | ParagraphNode | CodeHighlightNode;
|
|
canInsertTab(): boolean;
|
|
collapseAtStart(): true;
|
|
setLanguage(language: string): void;
|
|
getLanguage(): string | void;
|
|
}
|
|
declare function $createCodeNode(): CodeNode;
|
|
declare function $isCodeNode(
|
|
node: null | undefined | LexicalNode,
|
|
): node is CodeNode;
|
|
|
|
declare function getFirstCodeHighlightNodeOfLine(
|
|
anchor: LexicalNode,
|
|
): null | undefined | CodeHighlightNode;
|
|
|
|
declare function getLastCodeHighlightNodeOfLine(
|
|
anchor: LexicalNode,
|
|
): null | undefined | CodeHighlightNode;
|
|
|
|
declare function getDefaultCodeLanguage(): string;
|
|
declare function getCodeLanguages(): Array<string>;
|
|
|
|
declare class CodeHighlightNode extends TextNode {
|
|
__highlightType: null | undefined | string;
|
|
constructor(text: string, highlightType?: string, key?: NodeKey);
|
|
static getType(): string;
|
|
static clone(node: CodeHighlightNode): CodeHighlightNode;
|
|
createDOM<EditorContext>(config: EditorConfig<EditorContext>): HTMLElement;
|
|
updateDOM<EditorContext>(
|
|
// $FlowFixMe
|
|
prevNode: CodeHighlightNode,
|
|
dom: HTMLElement,
|
|
config: EditorConfig<EditorContext>,
|
|
): boolean;
|
|
setFormat(format: number): this;
|
|
}
|
|
declare function getHighlightThemeClass(
|
|
theme: EditorThemeClasses,
|
|
highlightType: null | undefined | string,
|
|
): null | undefined | string;
|
|
declare function $createCodeHighlightNode(
|
|
text: string,
|
|
highlightType?: string,
|
|
): CodeHighlightNode;
|
|
declare function $isCodeHighlightNode(
|
|
node: ?LexicalNode,
|
|
): node is CodeHighlightNode;
|
|
|
|
declare function registerCodeHighlighting(editor: LexicalEditor): () => void;
|