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,76 @@
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 TableRowNode extends lexical.ElementNode {
36
+ static getType() {
37
+ return 'table-row';
38
+ }
39
+
40
+ static clone(node) {
41
+ return new TableRowNode(node.__key);
42
+ }
43
+
44
+ constructor(key) {
45
+ super(key);
46
+ }
47
+
48
+ createDOM(config) {
49
+ const element = document.createElement('tr');
50
+ addClassNamesToElement(element, config.theme.tableRow);
51
+ return element;
52
+ }
53
+
54
+ updateDOM() {
55
+ return false;
56
+ }
57
+
58
+ canBeEmpty() {
59
+ return false;
60
+ }
61
+
62
+ canSelectionRemove() {
63
+ return false;
64
+ }
65
+
66
+ }
67
+ function $createTableRowNode() {
68
+ return new TableRowNode();
69
+ }
70
+ function $isTableRowNode(node) {
71
+ return node instanceof TableRowNode;
72
+ }
73
+
74
+ exports.$createTableRowNode = $createTableRowNode;
75
+ exports.$isTableRowNode = $isTableRowNode;
76
+ exports.TableRowNode = TableRowNode;
@@ -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 c=require("lexical");function e(a,...b){b.forEach(d=>{null!=d&&"string"===typeof d&&a.classList.add(...d.split(" "))})}class f extends c.ElementNode{static getType(){return"table-row"}static clone(a){return new f(a.__key)}constructor(a){super(a)}createDOM(a){const b=document.createElement("tr");e(b,a.theme.tableRow);return b}updateDOM(){return!1}canBeEmpty(){return!1}canSelectionRemove(){return!1}}exports.$createTableRowNode=function(){return new f};
8
+ exports.$isTableRowNode=function(a){return a instanceof f};exports.TableRowNode=f;
package/LinkNode.js CHANGED
@@ -1,3 +1,9 @@
1
- 'use strict';var d=require("lexical");function e(a,...b){b.forEach(c=>{null!=c&&"string"===typeof c&&a.classList.add(...c.split(" "))})}
2
- 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);
3
- 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;
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 LexicalLinkNode = process.env.NODE_ENV === 'development' ? require('./LexicalLinkNode.dev.js') : require('./LexicalLinkNode.prod.js')
9
+ module.exports = LexicalLinkNode;
package/QuoteNode.js CHANGED
@@ -1,3 +1,9 @@
1
- 'use strict';var c=require("lexical"),e=require("lexical/ParagraphNode");function f(a,...b){b.forEach(d=>{null!=d&&"string"===typeof d&&a.classList.add(...d.split(" "))})}
2
- class g extends c.ElementNode{static getType(){return"quote"}static clone(a){return new g(a.__key)}constructor(a){super(a)}createDOM(a){const b=document.createElement("blockquote");f(b,a.theme.quote);return b}updateDOM(){return!1}insertNewAfter(){const a=e.$createParagraphNode(),b=this.getDirection();a.setDirection(b);this.insertAfter(a);return a}collapseAtStart(){const a=e.$createParagraphNode();this.getChildren().forEach(b=>a.append(b));this.replace(a);return!0}}exports.$createQuoteNode=function(){return new g};
3
- exports.$isQuoteNode=function(a){return a instanceof g};exports.QuoteNode=g;
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 LexicalQuoteNode = process.env.NODE_ENV === 'development' ? require('./LexicalQuoteNode.dev.js') : require('./LexicalQuoteNode.prod.js')
9
+ module.exports = LexicalQuoteNode;
package/README.md CHANGED
@@ -4,6 +4,7 @@ Lexical is an extensible JavaScript text-editor that provides reliable, accessib
4
4
 
5
5
  The core of Lexical is a dependency-free text editor engine that allows for powerful, simple and complex,
6
6
  editor implementations to be built on top. Lexical's engine provides three main parts:
7
+
7
8
  - editor instances that each attach to a single content editable element.
8
9
  - a set of editor states that represent the current and pending states of the editor at any given time.
9
10
  - a DOM reconciler that takes a set of editor states, diffs the changes, and updates the DOM according to their state.
@@ -25,10 +26,12 @@ The `lexical` package contains only the core Lexical engine and nodes. This pack
25
26
  This section covers how to use Lexical, independently of any framework or library. For those intending to use Lexical in their React applications,
26
27
  it's advisable to [check out the source-code for the hooks that are shipped in `@lexical/react`](https://github.com/facebook/lexical/tree/main/packages/lexical-react/src).
27
28
 
28
- ### Creating an editor instance and using it
29
+ ### Creating an editor and using it
30
+
31
+ When you work with Lexical, you normally work with a single editor instance. An editor instance can be thought of as the one responsible
32
+ for wiring up an EditorState with the DOM. The editor is also the place where you can register custom nodes, add listeners, and transforms.
29
33
 
30
- When you work with Lexical, you normally work with a single editor instance. An editor instance can be created from the `lexical` package and accepts
31
- an optional configuration object that allows for theming and the passing of context:
34
+ An editor instance can be created from the `lexical` package and accepts an optional configuration object that allows for theming and other options:
32
35
 
33
36
  ```js
34
37
  import {createEditor} from 'lexical';
@@ -51,4 +54,99 @@ editor.setRootElement(contentEditableElement);
51
54
  ```
52
55
 
53
56
  If you want to clear the editor instance from the element, you can pass `null`. Alternatively, you can switch to another element if need be,
54
- just pass an alternative element reference to `setRootElement`.
57
+ just pass an alternative element reference to `setRootElement()`.
58
+
59
+ ### Understanding the Editor State
60
+
61
+ With Lexical, the source of truth is not the DOM, but rather an underlying state model
62
+ that Lexical maintains and associates with an editor instance. You can get the latest
63
+ editor state from an editor by calling `editor.getEditorState()`.
64
+
65
+ Editor states have two phases:
66
+
67
+ - During an update they can be thought of as "mutable". See "Updating an editor" below to
68
+ mutate an editor state.
69
+ - After an update, the editor state is then locked and deemed immutable from there one. This
70
+ editor state can therefore be thought of as a "snapshot".
71
+
72
+ Editor states contain two core things:
73
+
74
+ - The editor node tree (starting from the root node).
75
+ - The editor selection (which can be null).
76
+
77
+ Editor states are serializable to JSON, and the editor instance provides a useful method
78
+ to deserialize stringified editor states.
79
+
80
+ ```js
81
+ const stringifiedEditorState = JSON.stringify(editor.getEditorState().toJSON());
82
+
83
+ const newEditorState = editor.parseEditorState(stringifiedEditorState);
84
+ ```
85
+
86
+ ### Updating an editor
87
+
88
+ There are a few ways to update an editor instance:
89
+
90
+ - Trigger an update with `editor.update()`
91
+ - Setting the editor state via `editor.setEditorState()`
92
+ - Applying a change as part of an existing update via `editor.addTransform()`
93
+ - Using a command listener with `editor.addListener('command', () => {...}, priority)`
94
+
95
+ The most common way to update the editor is to use `editor.update()`. Calling this function
96
+ requires a function to be passed in that will provide access to mutate the underlying
97
+ editor state. When starting a fresh update, the current editor state is cloned and
98
+ used as the starting point. From a technical perspective, this means that Lexical leverages a technique
99
+ called double-buffering during updates. There's an editor state to represent what is current on
100
+ the screen, and another work-in-progress editor state that represents future changes.
101
+
102
+ Creating an update is typically an async process that allows Lexical to batch multiple updates together in
103
+ a single update – improving performance. When Lexical is ready to commit the update to
104
+ the DOM, the underlying mutations and changes in the update will form a new immutable
105
+ editor state. Calling `editor.getEditorState()` will then return the latest editor state
106
+ based on the changes from the update.
107
+
108
+ Here's an example of how you can update an editor instance:
109
+
110
+ ```js
111
+ import {$getRoot, $getSelection} from 'lexical';
112
+ import {$createParagraphNode} from 'lexical/PargraphNode';
113
+
114
+ // Inside the `editor.update` you can use special $ prefixed helper functions.
115
+ // These functions cannot be used outside the closure, and will error if you try.
116
+ // (If you're familiar with React, you can imagine these to be a bit like using a hook
117
+ // outside of a React function component).
118
+ editor.update(() => {
119
+ // Get the RootNode from the EditorState
120
+ const root = $getRoot();
121
+
122
+ // Get the selection from the EditorState
123
+ const selection = $getSelection();
124
+
125
+ // Create a new ParagraphNode
126
+ const paragraphNode = $createParagraphNode();
127
+
128
+ // Create a new TextNode
129
+ const textNode = $createTextNode('Hello world');
130
+
131
+ // Append the text node to the paragraph
132
+ paragraphNode.append(textNode);
133
+
134
+ // Finally, append the paragraph to the root
135
+ root.append(paragraphNode);
136
+ });
137
+ ```
138
+
139
+ If you want to know when the editor updates so you can react to the changes, you can add an update
140
+ listener to the editor, as shown below:
141
+
142
+ ```js
143
+ editor.addListener('update', ({editorState}) => {
144
+ // The latest EditorState can be found as `editorState`.
145
+ // To read the contents of the EditorState, use the following API:
146
+
147
+ editorState.read(() => {
148
+ // Just like editor.update(), .read() expects a closure where you can use
149
+ // the $ prefixed helper functions.
150
+ });
151
+ });
152
+ ```
package/TableCellNode.js CHANGED
@@ -1,3 +1,9 @@
1
- 'use strict';var c=require("lexical");function e(a,...b){b.forEach(d=>{null!=d&&"string"===typeof d&&a.classList.add(...d.split(" "))})}
2
- 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)};
3
- exports.$isTableCellNode=function(a){return a instanceof f};exports.TableCellNode=f;
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 LexicalTableCellNode = process.env.NODE_ENV === 'development' ? require('./LexicalTableCellNode.dev.js') : require('./LexicalTableCellNode.prod.js')
9
+ module.exports = LexicalTableCellNode;
package/TableNode.js CHANGED
@@ -1,10 +1,9 @@
1
- 'use strict';var r=require("lexical");function y(a,...f){f.forEach(e=>{null!=e&&"string"===typeof e&&a.classList.add(...e.split(" "))})}const z=document.createElement("style");z.appendChild(document.createTextNode("::selection{background-color: transparent}"));function A(a){for(;null!=a;){const f=a.nodeName;if("TD"===f||"TH"===f){a=a._cell;if(void 0===a)break;return a}a=a.parentNode}return null}
2
- function B(a,f,e){const q=[],l={rows:0,columns:0,cells:q};(new MutationObserver(p=>{e.update(()=>{var d=f.firstChild;let m=0,g=0;var b=!1;for(let h=0;h<p.length;h++){const t=p[h].target.nodeName;if("TABLE"===t||"TR"===t){b=!0;break}}if(b){for(q.length=0;null!=d;){b=d.nodeName;if("TD"===b||"TH"===b)b={elem:d,highlighted:!1,x:m,y:g},d._cell=b,void 0===q[g]&&(q[g]=[]),q[g][m]=b;else if(b=d.firstChild,null!=b){d=b;continue}b=d.nextSibling;if(null!=b)m++,d=b;else if(b=d.parentNode,null!=b){d=b.nextSibling;
3
- if(null==d)break;g++;m=0}}l.columns=m+1;l.rows=g+1;a.setGrid(l)}})})).observe(f,{childList:!0,subtree:!0});a.setGrid(l);return l}
4
- function C(a,f,e,q,l){const p=[];for(let d=0;d<l.length;d++){const m=l[d];for(let g=0;g<m.length;g++){const b=m[g],h=b.elem.style;g>=a&&g<=f&&d>=e&&d<=q?(b.highlighted||(b.highlighted=!0,h.setProperty("background-color","rgb(163, 187, 255)"),h.setProperty("caret-color","transparent")),p.push(b)):b.highlighted&&(b.highlighted=!1,h.removeProperty("background-color"),h.removeProperty("caret-color"))}}return p}
5
- function D(a,f,e){const q=a.getGrid();if(null!==e.getRootElement()){var l=!1,p=!1,d=-1,m=-1,g=-1,b=-1,h=[];if(null==q)throw Error("Table grid not found.");f.addEventListener("mousemove",k=>{if(l){var c=A(k.target);if(null!==c){const u=c.x;c=c.y;if(!p&&(d!==u||m!==c))k.preventDefault(),k=window.getSelection(),k.setBaseAndExtent(k.anchorNode,0,k.anchorNode,0),p=!0,document.body&&document.body.appendChild(z),null===w&&(w=e.addListener("command",(v,x)=>{if("deleteCharacter"===v){if(h.length===q.columns*
6
- q.rows)return a.selectPrevious(),a.remove(),t(),!0;h.forEach(({elem:n})=>{n=r.$getNearestNodeFromDOMNode(n);r.$isElementNode(n)&&n.clear()});return!0}if("formatText"===v)return F(x),!0;"insertText"===v&&t();return!1},1));else if(u===g&&c===b)return;g=u;b=c;if(p){const v=Math.min(d,g),x=Math.max(d,g),n=Math.min(m,b),G=Math.max(m,b);e.update(()=>{h=a.setSelectionState({fromX:v,toX:x,fromY:n,toY:G})})}}}});var t=()=>{e.update(()=>{l=p=!1;b=g=m=d=-1;e.update(()=>{a.setSelectionState(null)});h=[];null!==
7
- w&&(w(),w=null);const k=z.parentNode;null!=k&&k.removeChild(z)})};f.addEventListener("mouseleave",()=>{});var F=k=>{let c=r.$getSelection();null===c&&(c=r.$createSelection());const u=c,v=u.anchor,x=u.focus;h.forEach(n=>{n=r.$getNearestNodeFromDOMNode(n.elem);r.$isElementNode(n)&&(v.set(n.getKey(),0,"element"),x.set(n.getKey(),n.getChildrenSize(),"element"),u.formatText(k))});c.anchor.set(c.anchor.key,c.anchor.offset,c.anchor.type);c.focus.set(c.anchor.key,c.anchor.offset,c.anchor.type);r.$setSelection(c)},
8
- w=null;f.addEventListener("mousedown",k=>{l?p&&t():setTimeout(()=>{p&&t();const c=A(k.target);null!==c&&(l=!0,d=c.x,m=c.y,document.addEventListener("mouseup",()=>{l=!1},{capture:!0,once:!0}))},0)});window.addEventListener("click",k=>{0<h.length&&!f.contains(k.target)&&e.update(()=>{a.setSelectionState(null)})})}}
9
- class E extends r.ElementNode{static getType(){return"table"}static clone(a){return new E(a.__key,a.__selectionShape,a.__grid)}constructor(a,f,e){super(a);this.__selectionShape=f;this.__grid=e}createDOM(a,f){const e=document.createElement("table");y(e,a.theme.table);B(this,e,f);D(this,e,f);return e}updateDOM(){return!1}canExtractContents(){return!1}canBeEmpty(){return!1}setSelectionState(a){this.getWritable().__selectionShape=a;return null==this.__grid?[]:a?C(a.fromX,a.toX,a.fromY,a.toY,this.__grid.cells):
10
- C(-1,-1,-1,-1,this.__grid.cells)}getSelectionState(){return this.__selectionShape}setGrid(a){this.getWritable().__grid=a}getGrid(){return this.__grid}}exports.$createTableNode=function(){return new E};exports.$isTableNode=function(a){return a instanceof E};exports.TableNode=E;exports.trackTableGrid=B;
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 LexicalTableNode = process.env.NODE_ENV === 'development' ? require('./LexicalTableNode.dev.js') : require('./LexicalTableNode.prod.js')
9
+ module.exports = LexicalTableNode;
package/TableRowNode.js CHANGED
@@ -1,2 +1,9 @@
1
- 'use strict';var c=require("lexical");function e(a,...b){b.forEach(d=>{null!=d&&"string"===typeof d&&a.classList.add(...d.split(" "))})}class f extends c.ElementNode{static getType(){return"table-row"}static clone(a){return new f(a.__key)}constructor(a){super(a)}createDOM(a){const b=document.createElement("tr");e(b,a.theme.tableRow);return b}updateDOM(){return!1}canBeEmpty(){return!1}canSelectionRemove(){return!1}}exports.$createTableRowNode=function(){return new f};
2
- exports.$isTableRowNode=function(a){return a instanceof f};exports.TableRowNode=f;
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 LexicalTableRowNode = process.env.NODE_ENV === 'development' ? require('./LexicalTableRowNode.dev.js') : require('./LexicalTableRowNode.prod.js')
9
+ module.exports = LexicalTableRowNode;
package/package.json CHANGED
@@ -13,11 +13,11 @@
13
13
  "rich-text"
14
14
  ],
15
15
  "license": "MIT",
16
- "version": "0.1.4",
16
+ "version": "0.1.8",
17
17
  "main": "Lexical.js",
18
18
  "repository": {
19
19
  "type": "git",
20
20
  "url": "https://github.com/facebook/lexical",
21
21
  "directory": "packages/lexical"
22
22
  }
23
- }
23
+ }
package/ListItemNode.js DELETED
@@ -1,8 +0,0 @@
1
- 'use strict';var f=require("lexical"),g=require("lexical/ParagraphNode"),l=require("lexical/ListNode"),m=require("lexical/ListItemNode");function n(a){throw Error(`Minified Lexical error #${a}; see codes.json for the full message or `+"use the non-minified dev environment for full errors and additional helpful warnings.");}function p(a,...b){b.forEach(c=>{null!=c&&"string"===typeof c&&a.classList.add(...c.split(" "))})}function q(a,...b){b.forEach(c=>{a.classList.remove(...c.split(" "))})}
2
- class r extends f.ElementNode{static getType(){return"listitem"}static clone(a){return new r(a.__key)}constructor(a){super(a)}createDOM(a){const b=document.createElement("li");b.value=t(this);u(b,a.theme,this);return b}updateDOM(a,b,c){b.value=t(this);u(b,c.theme,this);return!1}append(...a){for(let b=0;b<a.length;b++){const c=a[b];if(f.$isElementNode(c)&&this.canMergeWith(c)){const d=c.getChildren();this.append(...d);c.remove()}else super.append(c)}return this}replace(a){if(v(a))return super.replace(a);
3
- const b=this.getParentOrThrow();if(l.$isListNode(b)){var c=b.__children;const e=c.length;var d=c.indexOf(this.__key);if(0===d)b.insertBefore(a);else if(d===e-1)b.insertAfter(a);else{c=l.$createListNode(b.__tag);const h=b.getChildren();for(d+=1;d<e;d++)c.append(h[d]);b.insertAfter(a);a.insertAfter(c)}this.remove();1===e&&b.remove()}return a}insertAfter(a){var b=this.getNextSiblings();if(v(a))return b.forEach(d=>d.markDirty()),super.insertAfter(a);var c=this.getParentOrThrow();l.$isListNode(c)||n(1);
4
- if(l.$isListNode(a)&&a.getTag()===c.getTag()){b=a;a=a.getChildren();for(c=a.length-1;0<=c;c--)b=a[c],this.insertAfter(b);return b}c.insertAfter(a);if(0!==b.length){const d=l.$createListNode(c.getTag());b.forEach(e=>d.append(e));a.insertAfter(d)}return a}insertNewAfter(){var a=this.getNextSibling(),b=this.getPreviousSibling();var c=this.getParent();l.$isListNode(c)||n(2);for(var d=c;null!==d;)d=d.getParent(),l.$isListNode(d)&&(c=d);d=!0;var e=this.getFirstChild();if(l.$isListNode(e))d=!1;else for(e=
5
- this;null!==e;)m.$isListItemNode(e)&&0<e.getNextSiblings().length&&(d=!1),e=e.getParent();if(f.$isElementNode(c)&&""===this.getTextContent()&&(null===b||null===a)&&d){null===a?(a=g.$createParagraphNode(),c.insertAfter(a)):(a=g.$createParagraphNode(),c.insertBefore(a));for(b=this;null==b.getNextSibling()&&null==b.getPreviousSibling();){c=b.getParent();if(null==c||!v(b)&&!l.$isListNode(b))break;b=c}b.remove()}else a=w(),this.insertAfter(a);return a}collapseAtStart(a){const b=g.$createParagraphNode();
6
- this.getChildren().forEach(h=>b.append(h));var c=this.getParentOrThrow(),d=c.getParentOrThrow();const e=v(d);1===c.getChildrenSize()?e?(c.remove(),d.select()):(c.replace(b),c=a.anchor,a=a.focus,d=b.getKey(),"element"===c.type&&c.getNode().is(this)&&c.set(d,c.offset,"element"),"element"===a.type&&a.getNode().is(this)&&a.set(d,a.offset,"element")):(c.insertBefore(b),this.remove());return!0}insertBefore(a){const b=this.getNextSiblings();v(a)&&b.forEach(c=>c.markDirty());return super.insertBefore(a)}canInsertAfter(a){return v(a)}canReplaceWith(a){return v(a)}canMergeWith(a){return g.$isParagraphNode(a)||
7
- v(a)}}function t(a){var b=a.getParent();let c=1;null!=b&&(l.$isListNode(b)?c=b.__start:n(47));a=a.getPreviousSiblings();for(b=0;b<a.length;b++){const d=a[b];v(d)&&!l.$isListNode(d.getFirstChild())&&c++}return c}function u(a,b,c){const d=[],e=[],h=(b=b.list)?b.listitem:void 0;if(b&&b.nested)var k=b.nested.listitem;void 0!==h&&(b=h.split(" "),d.push(...b));void 0!==k&&(k=k.split(" "),c.getChildren().some(x=>l.$isListNode(x))?d.push(...k):e.push(...k));0<d.length&&p(a,...d);0<e.length&&q(a,...e)}
8
- function w(){return new r}function v(a){return a instanceof r}exports.$createListItemNode=w;exports.$isListItemNode=v;exports.ListItemNode=r;
package/ListNode.js DELETED
@@ -1,5 +0,0 @@
1
- 'use strict';var f=require("lexical"),h=require("lexical/ListItemNode"),m=require("lexical/ListNode");function n(b,...a){a.forEach(c=>{null!=c&&"string"===typeof c&&b.classList.add(...c.split(" "))})}function p(b,...a){a.forEach(c=>{b.classList.remove(...c.split(" "))})}
2
- class t extends f.ElementNode{static getType(){return"list"}static clone(b){return new t(b.__tag,b.__start,b.__key)}constructor(b,a,c){super(c);this.__tag=b;this.__start=a}getTag(){return this.__tag}createDOM(b){const a=document.createElement(this.__tag);1!==this.__start&&a.setAttribute("start",String(this.__start));u(a,b.theme,this);return a}updateDOM(b,a,c){if(b.__tag!==this.__tag)return!0;u(a,c.theme,this);return!1}canBeEmpty(){return!1}append(...b){for(let c=0;c<b.length;c++){var a=b[c];if(h.$isListItemNode(a))super.append(a);
3
- else{const e=h.$createListItemNode();v(a)?e.append(a):(a=f.$createTextNode(a.getTextContent()),e.append(a));super.append(e)}}return this}}
4
- function u(b,a,c){const e=[],g=[];a=a.list;if(void 0!==a){a:{var k=1;for(var d=c.getParent();null!=d;){if(h.$isListItemNode(d)){d=d.getParent();if(m.$isListNode(d)){k++;d=d.getParent();continue}throw Error("Minified Lexical error #2; see codes.json for the full message or use the non-minified dev environment for full errors and additional helpful warnings.");}break a}}d=k%5;const q=a[c.__tag+(0===d?5:d)],r=a[c.__tag];let l;a=a.nested;void 0!==a&&a.list&&(l=a.list);void 0!==r&&e.push(r);if(void 0!==
5
- q)for(a=q.split(" "),e.push(...a),a=1;6>a;a++)a!==d&&g.push(c.__tag+a);void 0!==l&&(c=l.split(" "),1<k?e.push(...c):g.push(...c))}0<e.length&&n(b,...e);0<g.length&&p(b,...g)}function v(b){return b instanceof t}exports.$createListNode=function(b,a=1){return new t(b,a)};exports.$isListNode=v;exports.ListNode=t;
package/ParagraphNode.js DELETED
@@ -1,3 +0,0 @@
1
- 'use strict';var c=require("lexical");function d(a,...b){b.forEach(e=>{null!=e&&"string"===typeof e&&a.classList.add(...e.split(" "))})}
2
- class f extends c.ElementNode{static getType(){return"paragraph"}static clone(a){return new f(a.__key)}constructor(a){super(a)}createDOM(a){const b=document.createElement("p");d(b,a.theme.paragraph);return b}updateDOM(){return!1}insertNewAfter(){const a=g(),b=this.getDirection();a.setDirection(b);this.insertAfter(a);return a}collapseAtStart(){var a=this.getChildren();const b=this.getNextSibling();return c.$isElementNode(b)&&0===this.getIndexWithinParent()&&(0===a.length||c.$isTextNode(a[0])&&""===
3
- a[0].getTextContent().trim())?(a=b.getFirstChild(),c.$isTextNode(a)?a.select(0,0):b.select(0,0),this.remove(),!0):!1}}function g(){return new f}exports.$createParagraphNode=g;exports.$isParagraphNode=function(a){return a instanceof f};exports.ParagraphNode=f;