@lexical/offset
Version:
This package contains selection offset helpers for Lexical.
55 lines (54 loc) • 1.95 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 { $createChildrenArray as $createChildrenArray_, type EditorState, type LexicalEditor, type NodeKey, type RangeSelection } from 'lexical';
type OffsetElementNode = {
child: null | OffsetNode;
end: number;
key: NodeKey;
next: null | OffsetNode;
parent: null | OffsetElementNode;
prev: null | OffsetNode;
start: number;
type: 'element';
};
type OffsetTextNode = {
child: null;
end: number;
key: NodeKey;
next: null | OffsetNode;
parent: null | OffsetElementNode;
prev: null | OffsetNode;
start: number;
type: 'text';
};
type OffsetInlineNode = {
child: null;
end: number;
key: NodeKey;
next: null | OffsetNode;
parent: null | OffsetElementNode;
prev: null | OffsetNode;
start: number;
type: 'inline';
};
type OffsetNode = OffsetElementNode | OffsetTextNode | OffsetInlineNode;
type OffsetMap = Map<NodeKey, OffsetNode>;
/** @deprecated OffsetView has never worked correctly and will be removed */
export declare class OffsetView {
_offsetMap: OffsetMap;
_firstNode: null | OffsetNode;
_blockOffsetSize: number;
constructor(offsetMap: OffsetMap, firstNode: null | OffsetNode, blockOffsetSize?: number);
createSelectionFromOffsets(originalStart: number, originalEnd: number, diffOffsetView?: OffsetView): null | RangeSelection;
getOffsetsFromSelection(selection: RangeSelection): [number, number];
}
/** @deprecated moved to `lexical` */
export declare const $createChildrenArray: typeof $createChildrenArray_;
/** @deprecated OffsetView has never worked correctly and will be removed */
export declare function $createOffsetView(editor: LexicalEditor, blockOffsetSize?: number, editorState?: EditorState | null): OffsetView;
export {};