mirror of
https://github.com/facebook/lexical.git
synced 2025-08-06 16:39:33 +08:00
Feature: $config protocol + NodeState registration/flattening (#7258)
This commit is contained in:
@ -14,26 +14,21 @@ import type {
|
||||
} from 'lexical';
|
||||
|
||||
import {$applyNodeReplacement, ElementNode} from 'lexical';
|
||||
import invariant from 'shared/invariant';
|
||||
|
||||
export type SerializedOverflowNode = SerializedElementNode;
|
||||
|
||||
/** @noInheritDoc */
|
||||
export class OverflowNode extends ElementNode {
|
||||
static getType(): string {
|
||||
return 'overflow';
|
||||
}
|
||||
|
||||
static clone(node: OverflowNode): OverflowNode {
|
||||
return new OverflowNode(node.__key);
|
||||
}
|
||||
|
||||
static importJSON(serializedNode: SerializedOverflowNode): OverflowNode {
|
||||
return $createOverflowNode().updateFromJSON(serializedNode);
|
||||
}
|
||||
|
||||
static importDOM(): null {
|
||||
return null;
|
||||
/** @internal */
|
||||
$config() {
|
||||
return this.config('overflow', {
|
||||
$transform(node: OverflowNode) {
|
||||
if (node.isEmpty()) {
|
||||
node.remove();
|
||||
}
|
||||
},
|
||||
extends: ElementNode,
|
||||
});
|
||||
}
|
||||
|
||||
createDOM(config: EditorConfig): HTMLElement {
|
||||
@ -60,15 +55,6 @@ 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