@lexical/overflow 0.2.9 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4,10 +4,19 @@
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  *
7
- * @flow strict
8
7
  */
9
- import type {EditorConfig, LexicalNode, NodeKey, RangeSelection} from 'lexical';
8
+
9
+ import type {
10
+ EditorConfig,
11
+ LexicalNode,
12
+ NodeKey,
13
+ RangeSelection,
14
+ SerializedElementNode,
15
+ } from 'lexical';
16
+
10
17
  import {ElementNode} from 'lexical';
18
+ import {Spread} from 'libdefs/globals';
19
+
11
20
  export declare class OverflowNode extends ElementNode {
12
21
  static getType(): string;
13
22
  static clone(node: OverflowNode): OverflowNode;
@@ -16,6 +25,16 @@ export declare class OverflowNode extends ElementNode {
16
25
  updateDOM(prevNode: OverflowNode, dom: HTMLElement): boolean;
17
26
  insertNewAfter(selection: RangeSelection): null | LexicalNode;
18
27
  excludeFromCopy(): boolean;
28
+ static importJSON(serializedNode: SerializedOverflowNode): OverflowNode;
29
+ exportJSON(): SerializedElementNode;
19
30
  }
31
+
20
32
  export function $createOverflowNode(): OverflowNode;
21
33
  export function $isOverflowNode(node: LexicalNode | null): node is OverflowNode;
34
+
35
+ export type SerializedOverflowNode = Spread<
36
+ {
37
+ type: 'overflow';
38
+ },
39
+ SerializedElementNode
40
+ >;
@@ -14,7 +14,7 @@ var lexical = require('lexical');
14
14
  * This source code is licensed under the MIT license found in the
15
15
  * LICENSE file in the root directory of this source tree.
16
16
  *
17
- *
17
+
18
18
  */
19
19
  class OverflowNode extends lexical.ElementNode {
20
20
  static getType() {
@@ -25,11 +25,25 @@ class OverflowNode extends lexical.ElementNode {
25
25
  return new OverflowNode(node.__key);
26
26
  }
27
27
 
28
+ static importJSON(serializedNode) {
29
+ return $createOverflowNode();
30
+ }
31
+
32
+ static importDOM() {
33
+ return null;
34
+ }
35
+
28
36
  constructor(key) {
29
37
  super(key);
30
38
  this.__type = 'overflow';
31
39
  }
32
40
 
41
+ exportJSON() {
42
+ return { ...super.exportJSON(),
43
+ type: 'overflow'
44
+ };
45
+ }
46
+
33
47
  createDOM(config) {
34
48
  const div = document.createElement('span');
35
49
  const className = config.theme.characterLimit;
@@ -6,7 +6,13 @@
6
6
  *
7
7
  * @flow strict
8
8
  */
9
- import type {EditorConfig, LexicalNode, NodeKey, RangeSelection} from 'lexical';
9
+ import type {
10
+ EditorConfig,
11
+ LexicalNode,
12
+ NodeKey,
13
+ RangeSelection,
14
+ SerializedElementNode,
15
+ } from 'lexical';
10
16
  import {ElementNode} from 'lexical';
11
17
  declare export class OverflowNode extends ElementNode {
12
18
  static getType(): string;
@@ -16,8 +22,16 @@ declare export class OverflowNode extends ElementNode {
16
22
  updateDOM(prevNode: OverflowNode, dom: HTMLElement): boolean;
17
23
  insertNewAfter(selection: RangeSelection): null | LexicalNode;
18
24
  excludeFromCopy(): boolean;
25
+ static importJSON(serializedNode: SerializedOverflowNode): OverflowNode;
19
26
  }
20
27
  declare export function $createOverflowNode(): OverflowNode;
21
28
  declare export function $isOverflowNode(
22
29
  node: ?LexicalNode,
23
30
  ): boolean %checks(node instanceof OverflowNode);
31
+
32
+ export type SerializedOverflowNode = {
33
+ ...SerializedElementNode,
34
+ type: 'overflow',
35
+ version: 1,
36
+ ...
37
+ };
@@ -4,5 +4,6 @@
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
- var b=require("lexical");class d extends b.ElementNode{static getType(){return"overflow"}static clone(a){return new d(a.__key)}constructor(a){super(a);this.__type="overflow"}createDOM(a){const c=document.createElement("span");a=a.theme.characterLimit;"string"===typeof a&&(c.className=a);return c}updateDOM(){return!1}insertNewAfter(a){return this.getParentOrThrow().insertNewAfter(a)}excludeFromCopy(){return!0}}exports.$createOverflowNode=function(){return new d};
8
- exports.$isOverflowNode=function(a){return a instanceof d};exports.OverflowNode=d;
7
+ 'use strict';var b=require("lexical");
8
+ class c extends b.ElementNode{static getType(){return"overflow"}static clone(a){return new c(a.__key)}static importJSON(){return e()}static importDOM(){return null}constructor(a){super(a);this.__type="overflow"}exportJSON(){return{...super.exportJSON(),type:"overflow"}}createDOM(a){let d=document.createElement("span");a=a.theme.characterLimit;"string"===typeof a&&(d.className=a);return d}updateDOM(){return!1}insertNewAfter(a){return this.getParentOrThrow().insertNewAfter(a)}excludeFromCopy(){return!0}}
9
+ function e(){return new c}exports.$createOverflowNode=e;exports.$isOverflowNode=function(a){return a instanceof c};exports.OverflowNode=c
package/package.json CHANGED
@@ -8,10 +8,10 @@
8
8
  "overflow"
9
9
  ],
10
10
  "license": "MIT",
11
- "version": "0.2.9",
11
+ "version": "0.3.0",
12
12
  "main": "LexicalOverflow.js",
13
13
  "peerDependencies": {
14
- "lexical": "0.2.9"
14
+ "lexical": "0.3.0"
15
15
  },
16
16
  "repository": {
17
17
  "type": "git",