@lexical/react
Version:
This package provides Lexical components and hooks for React applications.
50 lines (49 loc) • 2.33 kB
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.
*
*/
import type { JSX } from 'react';
import { DecoratorNode, type ElementFormatType, type LexicalNode, type LexicalParseJSON, type NodeKey, type SerializedLexicalNode, type SerializedPartial, type Spread } from 'lexical';
/**
* The serialized form of a {@link DecoratorBlockNode}: the base serialized node
* data plus the block's element `format` (alignment).
*/
export type SerializedDecoratorBlockNode = Spread<{
format: ElementFormatType;
}, SerializedLexicalNode>;
export interface DecoratorBlockNode {
exportJSON(compact?: false): SerializedDecoratorBlockNode;
exportJSON(compact: boolean): SerializedPartial<SerializedDecoratorBlockNode>;
updateFromJSON(serializedNode: LexicalParseJSON<SerializedDecoratorBlockNode>): this;
}
/**
* A base class for block-level {@link DecoratorNode}s (decorator nodes rendered
* on their own line rather than inline). It stores an {@link ElementFormatType}
* alignment, is not indentable, and renders into a `<div>`. Extend it for custom
* block embeds such as images, videos, or tweets, typically pairing it with
* {@link BlockWithAlignableContents} to handle selection and alignment.
*/
export declare class DecoratorBlockNode extends DecoratorNode<JSX.Element> {
__format: ElementFormatType;
constructor(format?: ElementFormatType, key?: NodeKey);
$config(): import("lexical").BaseStaticNodeConfig & import("lexical").StaticNodeConfigAccessor<{
readonly extends: typeof DecoratorNode;
readonly generated: import("lexical").GeneratedJSONFactory;
readonly json: import("lexical").NodeSerializationSchema<DecoratorBlockNode, {
readonly format?: "" | "left" | "start" | "center" | "right" | "end" | "justify" | undefined;
}>;
}>;
canIndent(): false;
createDOM(): HTMLElement;
updateDOM(): false;
setFormat(format: ElementFormatType): this;
getFormat(): ElementFormatType;
isInline(): false;
}
/**
* @returns `true` if `node` is a {@link DecoratorBlockNode}, narrowing its type.
*/
export declare function $isDecoratorBlockNode(node: LexicalNode | null | undefined): node is DecoratorBlockNode;