mirror of
https://github.com/facebook/lexical.git
synced 2025-08-06 16:39:33 +08:00
Add unstable serialization logic for node JSON parsing (#2157)
* Add unstable serialization logic for node JSON parsing * Ooops * Freeze editorState * Migrate code node * Address feedback * Address feedback * Address feedback * Address more feedback * Address more feedback * Address FlowFixMes * update types * prettier * remove import * polish types * fix types * add ut for unstable APIs * fix rebase issue * oops * wip * more nodes * types * prettier * add tests for core nodes * update codes.json * Merge global files * Rename global type defs * Update packages/lexical-link/src/index.js Co-authored-by: Gerard Rovira <zurfyx@users.noreply.github.com> * fix linter an versions * more versions Co-authored-by: acywatson <acy.watson@gmail.com> Co-authored-by: John Flockton <thegreatercurve@users.noreply.github.com> Co-authored-by: Gerard Rovira <zurfyx@users.noreply.github.com>
This commit is contained in:
@ -7,10 +7,23 @@
|
||||
* @flow strict
|
||||
*/
|
||||
|
||||
import type {EditorConfig, LexicalNode, NodeKey, RangeSelection} from 'lexical';
|
||||
import type {
|
||||
EditorConfig,
|
||||
LexicalNode,
|
||||
NodeKey,
|
||||
RangeSelection,
|
||||
SerializedElementNode,
|
||||
} from 'lexical';
|
||||
|
||||
import {ElementNode} from 'lexical';
|
||||
|
||||
export type SerializedOverflowNode = {
|
||||
...SerializedElementNode,
|
||||
type: 'overflow',
|
||||
version: 1,
|
||||
...
|
||||
};
|
||||
|
||||
export class OverflowNode extends ElementNode {
|
||||
static getType(): string {
|
||||
return 'overflow';
|
||||
@ -20,11 +33,22 @@ export class OverflowNode extends ElementNode {
|
||||
return new OverflowNode(node.__key);
|
||||
}
|
||||
|
||||
static importJSON(serializedNode: SerializedOverflowNode): OverflowNode {
|
||||
return $createOverflowNode();
|
||||
}
|
||||
|
||||
constructor(key?: NodeKey): void {
|
||||
super(key);
|
||||
this.__type = 'overflow';
|
||||
}
|
||||
|
||||
exportJSON(): SerializedElementNode {
|
||||
return {
|
||||
...super.exportJSON(),
|
||||
type: 'overflow',
|
||||
};
|
||||
}
|
||||
|
||||
createDOM(config: EditorConfig): HTMLElement {
|
||||
const div = document.createElement('span');
|
||||
const className = config.theme.characterLimit;
|
||||
|
Reference in New Issue
Block a user