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.
- package/AutoLinkNode.js +9 -1
- package/CodeHighlightNode.js +9 -3
- package/CodeNode.js +9 -5
- package/HashtagNode.js +9 -3
- package/HeadingNode.js +9 -3
- package/Lexical.dev.js +7638 -0
- package/Lexical.js +9 -143
- package/Lexical.prod.js +153 -0
- package/LexicalAutoLinkNode.dev.js +58 -0
- package/LexicalAutoLinkNode.prod.js +7 -0
- package/LexicalCodeHighlightNode.dev.js +100 -0
- package/LexicalCodeHighlightNode.prod.js +9 -0
- package/LexicalCodeNode.dev.js +173 -0
- package/LexicalCodeNode.prod.js +11 -0
- package/LexicalExtendedNode.js +9 -0
- package/LexicalExtendedNodes.dev.js +32 -0
- package/LexicalExtendedNodes.prod.js +8 -0
- package/LexicalHashtagNode.dev.js +111 -0
- package/LexicalHashtagNode.prod.js +9 -0
- package/LexicalHeadingNode.dev.js +100 -0
- package/LexicalHeadingNode.prod.js +9 -0
- package/LexicalLinkNode.dev.js +115 -0
- package/LexicalLinkNode.prod.js +9 -0
- package/LexicalOverflowNode.dev.js +67 -0
- package/LexicalOverflowNode.js +9 -0
- package/LexicalOverflowNode.prod.js +8 -0
- package/LexicalQuoteNode.dev.js +86 -0
- package/LexicalQuoteNode.prod.js +9 -0
- package/LexicalTableCellNode.dev.js +81 -0
- package/LexicalTableCellNode.prod.js +9 -0
- package/LexicalTableNode.dev.js +638 -0
- package/LexicalTableNode.prod.js +21 -0
- package/LexicalTableRowNode.dev.js +76 -0
- package/LexicalTableRowNode.prod.js +8 -0
- package/LinkNode.js +9 -3
- package/QuoteNode.js +9 -3
- package/README.md +102 -4
- package/TableCellNode.js +9 -3
- package/TableNode.js +9 -10
- package/TableRowNode.js +9 -2
- package/package.json +2 -2
- package/ListItemNode.js +0 -8
- package/ListNode.js +0 -5
- 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
|
-
|
|
2
|
-
|
|
3
|
-
|
|
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
|
-
|
|
2
|
-
|
|
3
|
-
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
2
|
-
|
|
3
|
-
|
|
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
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
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
|
-
|
|
2
|
-
|
|
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.
|
|
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;
|