mirror of
https://github.com/facebook/lexical.git
synced 2025-05-20 08:37:41 +08:00
[lexical][lexical-overflow] Refactor: simplified removeText and insertText rewrite (part 1) (#6456)
Co-authored-by: EgonBolton <43938777+EgonBolton@users.noreply.github.com> Co-authored-by: Bob Ippolito <bob@redivi.com>
This commit is contained in:
@ -15,6 +15,7 @@ import type {
|
||||
} from 'lexical';
|
||||
|
||||
import {$applyNodeReplacement, ElementNode} from 'lexical';
|
||||
import invariant from 'shared/invariant';
|
||||
|
||||
export type SerializedOverflowNode = SerializedElementNode;
|
||||
|
||||
@ -72,6 +73,15 @@ export class OverflowNode extends ElementNode {
|
||||
excludeFromCopy(): boolean {
|
||||
return true;
|
||||
}
|
||||
|
||||
static transform(): (node: LexicalNode) => void {
|
||||
return (node: LexicalNode) => {
|
||||
invariant($isOverflowNode(node), 'node is not a OverflowNode');
|
||||
if (node.isEmpty()) {
|
||||
node.remove();
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export function $createOverflowNode(): OverflowNode {
|
||||
|
Reference in New Issue
Block a user