lexical 0.1.4 → 0.1.8

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.
Files changed (44) hide show
  1. package/AutoLinkNode.js +9 -1
  2. package/CodeHighlightNode.js +9 -3
  3. package/CodeNode.js +9 -5
  4. package/HashtagNode.js +9 -3
  5. package/HeadingNode.js +9 -3
  6. package/Lexical.dev.js +7638 -0
  7. package/Lexical.js +9 -143
  8. package/Lexical.prod.js +153 -0
  9. package/LexicalAutoLinkNode.dev.js +58 -0
  10. package/LexicalAutoLinkNode.prod.js +7 -0
  11. package/LexicalCodeHighlightNode.dev.js +100 -0
  12. package/LexicalCodeHighlightNode.prod.js +9 -0
  13. package/LexicalCodeNode.dev.js +173 -0
  14. package/LexicalCodeNode.prod.js +11 -0
  15. package/LexicalExtendedNode.js +9 -0
  16. package/LexicalExtendedNodes.dev.js +32 -0
  17. package/LexicalExtendedNodes.prod.js +8 -0
  18. package/LexicalHashtagNode.dev.js +111 -0
  19. package/LexicalHashtagNode.prod.js +9 -0
  20. package/LexicalHeadingNode.dev.js +100 -0
  21. package/LexicalHeadingNode.prod.js +9 -0
  22. package/LexicalLinkNode.dev.js +115 -0
  23. package/LexicalLinkNode.prod.js +9 -0
  24. package/LexicalOverflowNode.dev.js +67 -0
  25. package/LexicalOverflowNode.js +9 -0
  26. package/LexicalOverflowNode.prod.js +8 -0
  27. package/LexicalQuoteNode.dev.js +86 -0
  28. package/LexicalQuoteNode.prod.js +9 -0
  29. package/LexicalTableCellNode.dev.js +81 -0
  30. package/LexicalTableCellNode.prod.js +9 -0
  31. package/LexicalTableNode.dev.js +638 -0
  32. package/LexicalTableNode.prod.js +21 -0
  33. package/LexicalTableRowNode.dev.js +76 -0
  34. package/LexicalTableRowNode.prod.js +8 -0
  35. package/LinkNode.js +9 -3
  36. package/QuoteNode.js +9 -3
  37. package/README.md +102 -4
  38. package/TableCellNode.js +9 -3
  39. package/TableNode.js +9 -10
  40. package/TableRowNode.js +9 -2
  41. package/package.json +2 -2
  42. package/ListItemNode.js +0 -8
  43. package/ListNode.js +0 -5
  44. package/ParagraphNode.js +0 -3
@@ -0,0 +1,115 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+ 'use strict';
8
+
9
+ var lexical = require('lexical');
10
+
11
+ /**
12
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
13
+ *
14
+ * This source code is licensed under the MIT license found in the
15
+ * LICENSE file in the root directory of this source tree.
16
+ *
17
+ *
18
+ */
19
+ function addClassNamesToElement(element, ...classNames) {
20
+ classNames.forEach(className => {
21
+ if (className != null && typeof className === 'string') {
22
+ element.classList.add(...className.split(' '));
23
+ }
24
+ });
25
+ }
26
+
27
+ /**
28
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
29
+ *
30
+ * This source code is licensed under the MIT license found in the
31
+ * LICENSE file in the root directory of this source tree.
32
+ *
33
+ *
34
+ */
35
+ class LinkNode extends lexical.ElementNode {
36
+ static getType() {
37
+ return 'link';
38
+ }
39
+
40
+ static clone(node) {
41
+ return new LinkNode(node.__url, node.__key);
42
+ }
43
+
44
+ constructor(url, key) {
45
+ super(key);
46
+ this.__url = url;
47
+ }
48
+
49
+ createDOM(config) {
50
+ const element = document.createElement('a');
51
+ element.href = this.__url;
52
+ addClassNamesToElement(element, config.theme.link);
53
+ return element;
54
+ }
55
+
56
+ updateDOM( // $FlowFixMe: not sure how to fix this
57
+ prevNode, // $FlowFixMe: not sure how to fix this
58
+ dom, config) {
59
+ const url = this.__url;
60
+
61
+ if (url !== prevNode.__url) {
62
+ dom.href = url;
63
+ }
64
+
65
+ return false;
66
+ }
67
+
68
+ getURL() {
69
+ return this.getLatest().__url;
70
+ }
71
+
72
+ setURL(url) {
73
+ const writable = this.getWritable();
74
+ writable.__url = url;
75
+ }
76
+
77
+ insertNewAfter(selection) {
78
+ const element = this.getParentOrThrow().insertNewAfter(selection);
79
+
80
+ if (lexical.$isElementNode(element)) {
81
+ const linkNode = $createLinkNode(this.__url);
82
+ element.append(linkNode);
83
+ return linkNode;
84
+ }
85
+
86
+ return null;
87
+ }
88
+
89
+ canInsertTextBefore() {
90
+ return false;
91
+ }
92
+
93
+ canInsertTextAfter() {
94
+ return false;
95
+ }
96
+
97
+ canBeEmpty() {
98
+ return false;
99
+ }
100
+
101
+ isInline() {
102
+ return true;
103
+ }
104
+
105
+ }
106
+ function $createLinkNode(url) {
107
+ return new LinkNode(url);
108
+ }
109
+ function $isLinkNode(node) {
110
+ return node instanceof LinkNode;
111
+ }
112
+
113
+ exports.$createLinkNode = $createLinkNode;
114
+ exports.$isLinkNode = $isLinkNode;
115
+ exports.LinkNode = LinkNode;
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+ 'use strict';var d=require("lexical");function e(a,...b){b.forEach(c=>{null!=c&&"string"===typeof c&&a.classList.add(...c.split(" "))})}
8
+ class f extends d.ElementNode{static getType(){return"link"}static clone(a){return new f(a.__url,a.__key)}constructor(a,b){super(b);this.__url=a}createDOM(a){const b=document.createElement("a");b.href=this.__url;e(b,a.theme.link);return b}updateDOM(a,b){const c=this.__url;c!==a.__url&&(b.href=c);return!1}getURL(){return this.getLatest().__url}setURL(a){this.getWritable().__url=a}insertNewAfter(a){a=this.getParentOrThrow().insertNewAfter(a);if(d.$isElementNode(a)){const b=g(this.__url);a.append(b);
9
+ return b}return null}canInsertTextBefore(){return!1}canInsertTextAfter(){return!1}canBeEmpty(){return!1}isInline(){return!0}}function g(a){return new f(a)}exports.$createLinkNode=g;exports.$isLinkNode=function(a){return a instanceof f};exports.LinkNode=f;
@@ -0,0 +1,67 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+ 'use strict';
8
+
9
+ var lexical = require('lexical');
10
+
11
+ /**
12
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
13
+ *
14
+ * This source code is licensed under the MIT license found in the
15
+ * LICENSE file in the root directory of this source tree.
16
+ *
17
+ *
18
+ */
19
+ class OverflowNode extends lexical.ElementNode {
20
+ static getType() {
21
+ return 'overflow';
22
+ }
23
+
24
+ static clone(node) {
25
+ return new OverflowNode(node.__key);
26
+ }
27
+
28
+ constructor(key) {
29
+ super(key);
30
+ this.__type = 'overflow';
31
+ }
32
+
33
+ createDOM(config) {
34
+ const div = document.createElement('div');
35
+ const className = config.theme.characterLimit;
36
+
37
+ if (typeof className === 'string') {
38
+ div.className = className;
39
+ }
40
+
41
+ return div;
42
+ }
43
+
44
+ updateDOM(prevNode, dom) {
45
+ return false;
46
+ }
47
+
48
+ insertNewAfter(selection) {
49
+ const parent = this.getParentOrThrow();
50
+ return parent.insertNewAfter(selection);
51
+ }
52
+
53
+ excludeFromCopy() {
54
+ return true;
55
+ }
56
+
57
+ }
58
+ function $createOverflowNode() {
59
+ return new OverflowNode();
60
+ }
61
+ function $isOverflowNode(node) {
62
+ return node instanceof OverflowNode;
63
+ }
64
+
65
+ exports.$createOverflowNode = $createOverflowNode;
66
+ exports.$isOverflowNode = $isOverflowNode;
67
+ exports.OverflowNode = OverflowNode;
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+ 'use strict'
8
+ const LexicalOverflowNode = process.env.NODE_ENV === 'development' ? require('./LexicalOverflowNode.dev.js') : require('./LexicalOverflowNode.prod.js')
9
+ module.exports = LexicalOverflowNode;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+ 'use strict';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("div");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;
@@ -0,0 +1,86 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+ 'use strict';
8
+
9
+ var lexical = require('lexical');
10
+
11
+ /**
12
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
13
+ *
14
+ * This source code is licensed under the MIT license found in the
15
+ * LICENSE file in the root directory of this source tree.
16
+ *
17
+ *
18
+ */
19
+ function addClassNamesToElement(element, ...classNames) {
20
+ classNames.forEach(className => {
21
+ if (className != null && typeof className === 'string') {
22
+ element.classList.add(...className.split(' '));
23
+ }
24
+ });
25
+ }
26
+
27
+ /**
28
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
29
+ *
30
+ * This source code is licensed under the MIT license found in the
31
+ * LICENSE file in the root directory of this source tree.
32
+ *
33
+ *
34
+ */
35
+ class QuoteNode extends lexical.ElementNode {
36
+ static getType() {
37
+ return 'quote';
38
+ }
39
+
40
+ static clone(node) {
41
+ return new QuoteNode(node.__key);
42
+ }
43
+
44
+ constructor(key) {
45
+ super(key);
46
+ } // View
47
+
48
+
49
+ createDOM(config) {
50
+ const element = document.createElement('blockquote');
51
+ addClassNamesToElement(element, config.theme.quote);
52
+ return element;
53
+ }
54
+
55
+ updateDOM(prevNode, dom) {
56
+ return false;
57
+ } // Mutation
58
+
59
+
60
+ insertNewAfter() {
61
+ const newBlock = lexical.$createParagraphNode();
62
+ const direction = this.getDirection();
63
+ newBlock.setDirection(direction);
64
+ this.insertAfter(newBlock);
65
+ return newBlock;
66
+ }
67
+
68
+ collapseAtStart() {
69
+ const paragraph = lexical.$createParagraphNode();
70
+ const children = this.getChildren();
71
+ children.forEach(child => paragraph.append(child));
72
+ this.replace(paragraph);
73
+ return true;
74
+ }
75
+
76
+ }
77
+ function $createQuoteNode() {
78
+ return new QuoteNode();
79
+ }
80
+ function $isQuoteNode(node) {
81
+ return node instanceof QuoteNode;
82
+ }
83
+
84
+ exports.$createQuoteNode = $createQuoteNode;
85
+ exports.$isQuoteNode = $isQuoteNode;
86
+ exports.QuoteNode = QuoteNode;
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+ 'use strict';var c=require("lexical");function d(a,...b){b.forEach(e=>{null!=e&&"string"===typeof e&&a.classList.add(...e.split(" "))})}
8
+ class f extends c.ElementNode{static getType(){return"quote"}static clone(a){return new f(a.__key)}constructor(a){super(a)}createDOM(a){const b=document.createElement("blockquote");d(b,a.theme.quote);return b}updateDOM(){return!1}insertNewAfter(){const a=c.$createParagraphNode(),b=this.getDirection();a.setDirection(b);this.insertAfter(a);return a}collapseAtStart(){const a=c.$createParagraphNode();this.getChildren().forEach(b=>a.append(b));this.replace(a);return!0}}exports.$createQuoteNode=function(){return new f};
9
+ exports.$isQuoteNode=function(a){return a instanceof f};exports.QuoteNode=f;
@@ -0,0 +1,81 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+ 'use strict';
8
+
9
+ var lexical = require('lexical');
10
+
11
+ /**
12
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
13
+ *
14
+ * This source code is licensed under the MIT license found in the
15
+ * LICENSE file in the root directory of this source tree.
16
+ *
17
+ *
18
+ */
19
+ function addClassNamesToElement(element, ...classNames) {
20
+ classNames.forEach(className => {
21
+ if (className != null && typeof className === 'string') {
22
+ element.classList.add(...className.split(' '));
23
+ }
24
+ });
25
+ }
26
+
27
+ /**
28
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
29
+ *
30
+ * This source code is licensed under the MIT license found in the
31
+ * LICENSE file in the root directory of this source tree.
32
+ *
33
+ *
34
+ */
35
+ class TableCellNode extends lexical.ElementNode {
36
+ static getType() {
37
+ return 'table-cell';
38
+ }
39
+
40
+ static clone(node) {
41
+ return new TableCellNode(false, node.__key);
42
+ }
43
+
44
+ constructor(isHeader = false, key) {
45
+ super(key);
46
+ this.__isHeader = isHeader;
47
+ }
48
+
49
+ getTag() {
50
+ return this.__isHeader ? 'th' : 'td';
51
+ }
52
+
53
+ createDOM(config) {
54
+ const element = document.createElement(this.getTag());
55
+ addClassNamesToElement(element, config.theme.tableCell, this.__isHeader === true && config.theme.tableCellHeader);
56
+ return element;
57
+ }
58
+
59
+ updateDOM() {
60
+ return false;
61
+ }
62
+
63
+ collapseAtStart() {
64
+ return true;
65
+ }
66
+
67
+ canSelectionRemove() {
68
+ return false;
69
+ }
70
+
71
+ }
72
+ function $createTableCellNode(isHeader) {
73
+ return new TableCellNode(isHeader);
74
+ }
75
+ function $isTableCellNode(node) {
76
+ return node instanceof TableCellNode;
77
+ }
78
+
79
+ exports.$createTableCellNode = $createTableCellNode;
80
+ exports.$isTableCellNode = $isTableCellNode;
81
+ exports.TableCellNode = TableCellNode;
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+ 'use strict';var c=require("lexical");function e(a,...b){b.forEach(d=>{null!=d&&"string"===typeof d&&a.classList.add(...d.split(" "))})}
8
+ class f extends c.ElementNode{static getType(){return"table-cell"}static clone(a){return new f(!1,a.__key)}constructor(a=!1,b){super(b);this.__isHeader=a}getTag(){return this.__isHeader?"th":"td"}createDOM(a){const b=document.createElement(this.getTag());e(b,a.theme.tableCell,!0===this.__isHeader&&a.theme.tableCellHeader);return b}updateDOM(){return!1}collapseAtStart(){return!0}canSelectionRemove(){return!1}}exports.$createTableCellNode=function(a){return new f(a)};
9
+ exports.$isTableCellNode=function(a){return a instanceof f};exports.TableCellNode=f;