@lexical/list 0.4.1 → 0.5.1-next.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.
- package/LexicalList.dev.js +7 -7
- package/LexicalList.prod.js +6 -6
- package/formatList.d.ts +1 -1
- package/package.json +3 -3
package/LexicalList.dev.js
CHANGED
|
@@ -187,7 +187,7 @@ function insertList(editor, listType) {
|
|
|
187
187
|
if ($isSelectingEmptyListItem(anchorNode, nodes)) {
|
|
188
188
|
const list = $createListNode(listType);
|
|
189
189
|
|
|
190
|
-
if (lexical.$
|
|
190
|
+
if (lexical.$isRootOrShadowRoot(anchorNodeParent)) {
|
|
191
191
|
anchorNode.replace(list);
|
|
192
192
|
const listItem = $createListItemNode();
|
|
193
193
|
|
|
@@ -234,7 +234,7 @@ function insertList(editor, listType) {
|
|
|
234
234
|
} else {
|
|
235
235
|
const nextParent = parent.getParent();
|
|
236
236
|
|
|
237
|
-
if (lexical.$
|
|
237
|
+
if (lexical.$isRootOrShadowRoot(nextParent) && !handled.has(parentKey)) {
|
|
238
238
|
handled.add(parentKey);
|
|
239
239
|
createListOrMerge(parent, listType);
|
|
240
240
|
break;
|
|
@@ -547,7 +547,7 @@ function $handleListInsertParagraph() {
|
|
|
547
547
|
const grandparent = parent.getParent();
|
|
548
548
|
let replacementNode;
|
|
549
549
|
|
|
550
|
-
if (lexical.$
|
|
550
|
+
if (lexical.$isRootOrShadowRoot(grandparent)) {
|
|
551
551
|
replacementNode = lexical.$createParagraphNode();
|
|
552
552
|
topListNode.insertAfter(replacementNode);
|
|
553
553
|
} else if ($isListItemNode(grandparent)) {
|
|
@@ -1263,10 +1263,10 @@ function $isListNode(node) {
|
|
|
1263
1263
|
}
|
|
1264
1264
|
|
|
1265
1265
|
/** @module @lexical/list */
|
|
1266
|
-
const INSERT_UNORDERED_LIST_COMMAND = lexical.createCommand();
|
|
1267
|
-
const INSERT_ORDERED_LIST_COMMAND = lexical.createCommand();
|
|
1268
|
-
const INSERT_CHECK_LIST_COMMAND = lexical.createCommand();
|
|
1269
|
-
const REMOVE_LIST_COMMAND = lexical.createCommand();
|
|
1266
|
+
const INSERT_UNORDERED_LIST_COMMAND = lexical.createCommand('INSERT_UNORDERED_LIST_COMMAND');
|
|
1267
|
+
const INSERT_ORDERED_LIST_COMMAND = lexical.createCommand('INSERT_ORDERED_LIST_COMMAND');
|
|
1268
|
+
const INSERT_CHECK_LIST_COMMAND = lexical.createCommand('INSERT_CHECK_LIST_COMMAND');
|
|
1269
|
+
const REMOVE_LIST_COMMAND = lexical.createCommand('REMOVE_LIST_COMMAND');
|
|
1270
1270
|
|
|
1271
1271
|
exports.$createListItemNode = $createListItemNode;
|
|
1272
1272
|
exports.$createListNode = $createListNode;
|
package/LexicalList.prod.js
CHANGED
|
@@ -26,11 +26,11 @@ class N extends h.ElementNode{static getType(){return"list"}static clone(a){retu
|
|
|
26
26
|
return b}updateDOM(a,b,c){if(a.__tag!==this.__tag)return!0;P(b,c.theme,this);return!1}static importDOM(){return{ol:()=>({conversion:Q,priority:0}),ul:()=>({conversion:Q,priority:0})}}static importJSON(a){let b=E(a.listType,a.start);b.setFormat(a.format);b.setIndent(a.indent);b.setDirection(a.direction);return b}exportJSON(){return{...super.exportJSON(),listType:this.getListType(),start:this.getStart(),tag:this.getTag(),type:"list",version:1}}canBeEmpty(){return!1}canIndent(){return!1}append(...a){for(let c=
|
|
27
27
|
0;c<a.length;c++){var b=a[c];if(p(b))super.append(b);else{let d=z();q(b)?d.append(b):(b=h.$createTextNode(b.getTextContent()),d.append(b));super.append(d)}}return this}extractWithChild(a){return p(a)}}
|
|
28
28
|
function P(a,b,c){let d=[],e=[];var f=b.list;if(void 0!==f){let k=f[`${c.__tag}Depth`]||[];b=n(c)-1;let x=b%k.length;var g=k[x];let y=f[c.__tag],B;f=f.nested;void 0!==f&&f.list&&(B=f.list);void 0!==y&&d.push(y);if(void 0!==g)for(g=g.split(" "),d.push(...g),g=0;g<k.length;g++)g!==x&&e.push(c.__tag+g);void 0!==B&&(c=B.split(" "),1<b?d.push(...c):e.push(...c))}0<e.length&&l.removeClassNamesFromElement(a,...e);0<d.length&&l.addClassNamesToElement(a,...d)}
|
|
29
|
-
function R(a){let b=[];for(let c=0;c<a.length;c++){let d=a[c];p(d)?(b.push(d),d.getChildren().forEach(e=>{q(e)&&b.push(w(e))})):b.push(w(d))}return b}function Q(a){a=a.nodeName.toLowerCase();let b=null;"ol"===a?b=E("number"):"ul"===a&&(b=E("bullet"));return{after:R,node:b}}let O={ol:"number",ul:"bullet"};function E(a,b=1){return new N(a,b)}function q(a){return a instanceof N}
|
|
30
|
-
exports.$createListNode=E;exports.$getListDepth=n;
|
|
31
|
-
exports.$handleListInsertParagraph=function(){var a=h.$getSelection();if(!h.$isRangeSelection(a)||!a.isCollapsed())return!1;a=a.anchor.getNode();if(!p(a)||""!==a.getTextContent())return!1;var b=r(a),c=a.getParent();q(c)||m(40);let d=c.getParent(),e;if(h.$
|
|
32
|
-
b.forEach(g=>{g.remove();f.append(g)})}v(a);return!0};exports.$isListItemNode=p;exports.$isListNode=q;exports.INSERT_CHECK_LIST_COMMAND=U;exports.INSERT_ORDERED_LIST_COMMAND=T;exports.INSERT_UNORDERED_LIST_COMMAND=S;exports.ListItemNode=J;exports.ListNode=N;exports.REMOVE_LIST_COMMAND=V;exports.indentList=function(){I("indent")};
|
|
33
|
-
exports.insertList=function(a,b){a.update(()=>{var c=h.$getSelection();if(h.$isRangeSelection(c)){var d=c.getNodes();c=c.anchor.getNode();var e=c.getParent();if(A(c,d))d=E(b),h.$
|
|
34
|
-
f.getParent();null!=f;){let k=f.getKey();if(q(f)){if(!c.has(k)){var g=E(b);C(g,f.getChildren());f.replace(g);F(g);c.add(k)}break}else{g=f.getParent();if(h.$
|
|
29
|
+
function R(a){let b=[];for(let c=0;c<a.length;c++){let d=a[c];p(d)?(b.push(d),d.getChildren().forEach(e=>{q(e)&&b.push(w(e))})):b.push(w(d))}return b}function Q(a){a=a.nodeName.toLowerCase();let b=null;"ol"===a?b=E("number"):"ul"===a&&(b=E("bullet"));return{after:R,node:b}}let O={ol:"number",ul:"bullet"};function E(a,b=1){return new N(a,b)}function q(a){return a instanceof N}
|
|
30
|
+
let S=h.createCommand("INSERT_UNORDERED_LIST_COMMAND"),T=h.createCommand("INSERT_ORDERED_LIST_COMMAND"),U=h.createCommand("INSERT_CHECK_LIST_COMMAND"),V=h.createCommand("REMOVE_LIST_COMMAND");exports.$createListItemNode=z;exports.$createListNode=E;exports.$getListDepth=n;
|
|
31
|
+
exports.$handleListInsertParagraph=function(){var a=h.$getSelection();if(!h.$isRangeSelection(a)||!a.isCollapsed())return!1;a=a.anchor.getNode();if(!p(a)||""!==a.getTextContent())return!1;var b=r(a),c=a.getParent();q(c)||m(40);let d=c.getParent(),e;if(h.$isRootOrShadowRoot(d))e=h.$createParagraphNode(),b.insertAfter(e);else if(p(d))e=z(),d.insertAfter(e);else return!1;e.select();b=a.getNextSiblings();if(0<b.length){let f=E(c.getListType());h.$isParagraphNode(e)?e.insertAfter(f):(c=z(),c.append(f),
|
|
32
|
+
e.insertAfter(c));b.forEach(g=>{g.remove();f.append(g)})}v(a);return!0};exports.$isListItemNode=p;exports.$isListNode=q;exports.INSERT_CHECK_LIST_COMMAND=U;exports.INSERT_ORDERED_LIST_COMMAND=T;exports.INSERT_UNORDERED_LIST_COMMAND=S;exports.ListItemNode=J;exports.ListNode=N;exports.REMOVE_LIST_COMMAND=V;exports.indentList=function(){I("indent")};
|
|
33
|
+
exports.insertList=function(a,b){a.update(()=>{var c=h.$getSelection();if(h.$isRangeSelection(c)){var d=c.getNodes();c=c.anchor.getNode();var e=c.getParent();if(A(c,d))d=E(b),h.$isRootOrShadowRoot(e)?(c.replace(d),e=z(),h.$isElementNode(c)&&(e.setFormat(c.getFormatType()),e.setIndent(c.getIndent())),d.append(e)):p(c)&&(c=c.getParentOrThrow(),C(d,c.getChildren()),c.replace(d));else for(c=new Set,e=0;e<d.length;e++){var f=d[e];if(h.$isElementNode(f)&&f.isEmpty()&&!c.has(f.getKey()))D(f,b);else if(h.$isLeafNode(f))for(f=
|
|
34
|
+
f.getParent();null!=f;){let k=f.getKey();if(q(f)){if(!c.has(k)){var g=E(b);C(g,f.getChildren());f.replace(g);F(g);c.add(k)}break}else{g=f.getParent();if(h.$isRootOrShadowRoot(g)&&!c.has(k)){c.add(k);D(f,b);break}f=g}}}}})};exports.outdentList=function(){I("outdent")};
|
|
35
35
|
exports.removeList=function(a){a.update(()=>{let b=h.$getSelection();if(h.$isRangeSelection(b)){var c=new Set,d=b.getNodes(),e=b.anchor.getNode();if(A(e,d))c.add(r(e));else for(e=0;e<d.length;e++){var f=d[e];h.$isLeafNode(f)&&(f=l.$getNearestNodeOfType(f,J),null!=f&&c.add(r(f)))}for(let g of c){c=g;d=t(g);for(let k of d)d=h.$createParagraphNode(),C(d,k.getChildren()),c.insertAfter(d),c=d,k.__key===b.anchor.key&&b.anchor.set(d.getKey(),0,"element"),k.__key===b.focus.key&&b.focus.set(d.getKey(),0,"element"),
|
|
36
36
|
k.remove();g.remove()}}})}
|
package/formatList.d.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
|
-
import
|
|
8
|
+
import { LexicalEditor } from 'lexical';
|
|
9
9
|
import { ListItemNode, ListNode } from './';
|
|
10
10
|
import { ListType } from './LexicalListNode';
|
|
11
11
|
export declare function insertList(editor: LexicalEditor, listType: ListType): void;
|
package/package.json
CHANGED
|
@@ -8,13 +8,13 @@
|
|
|
8
8
|
"list"
|
|
9
9
|
],
|
|
10
10
|
"license": "MIT",
|
|
11
|
-
"version": "0.
|
|
11
|
+
"version": "0.5.1-next.0",
|
|
12
12
|
"main": "LexicalList.js",
|
|
13
13
|
"peerDependencies": {
|
|
14
|
-
"lexical": "0.
|
|
14
|
+
"lexical": "0.5.1-next.0"
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@lexical/utils": "0.
|
|
17
|
+
"@lexical/utils": "0.5.1-next.0"
|
|
18
18
|
},
|
|
19
19
|
"repository": {
|
|
20
20
|
"type": "git",
|