Files
lexical/packages/lexical-code/flow/LexicalCode.js.flow
2022-04-11 15:50:44 +01:00

77 lines
2.2 KiB
Plaintext

/**
* 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} from 'lexical';
declare export class CodeNode extends ElementNode {
static getType(): string;
static clone(node: CodeNode): CodeNode;
constructor(key?: NodeKey): void;
createDOM<EditorContext>(config: EditorConfig<EditorContext>): HTMLElement;
updateDOM(prevNode: CodeNode, dom: HTMLElement): boolean;
insertNewAfter(
selection: RangeSelection,
): null | ParagraphNode | CodeHighlightNode;
canInsertTab(): true;
collapseAtStart(): true;
setLanguage(language: string): void;
getLanguage(): string | void;
}
declare export function $createCodeNode(): CodeNode;
declare export function $isCodeNode(
node: ?LexicalNode,
): boolean %checks(node instanceof CodeNode);
declare export function getFirstCodeHighlightNodeOfLine(
anchor: LexicalNode,
): ?CodeHighlightNode;
declare export function getLastCodeHighlightNodeOfLine(
anchor: LexicalNode,
): ?CodeHighlightNode;
import {TextNode} from 'lexical';
declare export class CodeHighlightNode extends TextNode {
__highlightType: ?string;
constructor(text: string, highlightType?: string, key?: NodeKey): void;
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: ?string,
): ?string;
declare export function $createCodeHighlightNode(
text: string,
highlightType?: string,
): CodeHighlightNode;
declare export function $isCodeHighlightNode(
node: ?LexicalNode,
): boolean %checks(node instanceof CodeHighlightNode);
declare export function registerCodeHighlighting(editor: LexicalEditor): () => void;