@lexical/hashtag 0.2.9 → 0.3.2

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.
@@ -6,7 +6,12 @@
6
6
  *
7
7
  */
8
8
 
9
- import type {EditorConfig, LexicalNode, NodeKey} from 'lexical';
9
+ import type {
10
+ EditorConfig,
11
+ LexicalNode,
12
+ NodeKey,
13
+ SerializedTextNode,
14
+ } from 'lexical';
10
15
  import {TextNode} from 'lexical';
11
16
 
12
17
  export declare class HashtagNode extends TextNode {
@@ -16,8 +21,9 @@ export declare class HashtagNode extends TextNode {
16
21
  createDOM(config: EditorConfig): HTMLElement;
17
22
  canInsertTextBefore(): boolean;
18
23
  isTextEntity(): true;
24
+ static importJSON(serializedNode: SerializedTextNode): HashtagNode;
19
25
  }
20
- export function $createHashtagNode(text?: string): TextNode;
26
+ export function $createHashtagNode(text?: string): HashtagNode;
21
27
  export function $isHashtagNode(
22
28
  node: LexicalNode | null | undefined,
23
29
  ): node is HashtagNode;
@@ -15,7 +15,7 @@ var lexical = require('lexical');
15
15
  * This source code is licensed under the MIT license found in the
16
16
  * LICENSE file in the root directory of this source tree.
17
17
  *
18
- * @flow strict
18
+
19
19
  */
20
20
  class HashtagNode extends lexical.TextNode {
21
21
  static getType() {
@@ -36,6 +36,21 @@ class HashtagNode extends lexical.TextNode {
36
36
  return element;
37
37
  }
38
38
 
39
+ static importJSON(serializedNode) {
40
+ const node = $createHashtagNode(serializedNode.text);
41
+ node.setFormat(serializedNode.format);
42
+ node.setDetail(serializedNode.detail);
43
+ node.setMode(serializedNode.mode);
44
+ node.setStyle(serializedNode.style);
45
+ return node;
46
+ }
47
+
48
+ exportJSON() {
49
+ return { ...super.exportJSON(),
50
+ type: 'hashtag'
51
+ };
52
+ }
53
+
39
54
  canInsertTextBefore() {
40
55
  return false;
41
56
  }
@@ -7,17 +7,25 @@
7
7
  * @flow strict
8
8
  */
9
9
 
10
- import type {EditorConfig, LexicalNode, NodeKey} from 'lexical';
10
+ import type {
11
+ EditorConfig,
12
+ LexicalNode,
13
+ NodeKey,
14
+ SerializedTextNode,
15
+ } from 'lexical';
11
16
 
12
17
  import {TextNode} from 'lexical';
13
18
 
14
19
  declare export class HashtagNode extends TextNode {
15
20
  static getType(): string;
21
+ // $FlowFixMe
16
22
  static clone(node: HashtagNode): HashtagNode;
23
+ static importJSON(serializedNode: SerializedTextNode): HashtagNode;
17
24
  constructor(text: string, key?: NodeKey): void;
18
25
  createDOM(config: EditorConfig): HTMLElement;
19
26
  canInsertTextBefore(): boolean;
20
27
  isTextEntity(): true;
28
+ exportJSON(): SerializedTextNode;
21
29
  }
22
30
  declare export function $createHashtagNode(text?: string): HashtagNode;
23
31
  declare export function $isHashtagNode(
@@ -4,4 +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/utils"),d=require("lexical");class e extends d.TextNode{static getType(){return"hashtag"}static clone(a){return new e(a.__text,a.__key)}constructor(a,c){super(a,c)}createDOM(a){const c=super.createDOM(a);b.addClassNamesToElement(c,a.theme.hashtag);return c}canInsertTextBefore(){return!1}isTextEntity(){return!0}}exports.$createHashtagNode=function(a=""){return new e(a)};exports.$isHashtagNode=function(a){return a instanceof e};exports.HashtagNode=e;
7
+ 'use strict';var c=require("@lexical/utils"),d=require("lexical");
8
+ class e extends d.TextNode{static getType(){return"hashtag"}static clone(a){return new e(a.__text,a.__key)}constructor(a,b){super(a,b)}createDOM(a){let b=super.createDOM(a);c.addClassNamesToElement(b,a.theme.hashtag);return b}static importJSON(a){let b=f(a.text);b.setFormat(a.format);b.setDetail(a.detail);b.setMode(a.mode);b.setStyle(a.style);return b}exportJSON(){return{...super.exportJSON(),type:"hashtag"}}canInsertTextBefore(){return!1}isTextEntity(){return!0}}
9
+ function f(a=""){return new e(a)}exports.$createHashtagNode=f;exports.$isHashtagNode=function(a){return a instanceof e};exports.HashtagNode=e
package/package.json CHANGED
@@ -8,13 +8,13 @@
8
8
  "hashtag"
9
9
  ],
10
10
  "license": "MIT",
11
- "version": "0.2.9",
11
+ "version": "0.3.2",
12
12
  "main": "LexicalHashtag.js",
13
13
  "peerDependencies": {
14
- "lexical": "0.2.9"
14
+ "lexical": "0.3.2"
15
15
  },
16
16
  "dependencies": {
17
- "@lexical/utils": "0.2.9"
17
+ "@lexical/utils": "0.3.2"
18
18
  },
19
19
  "repository": {
20
20
  "type": "git",