@lexical/list 0.8.0 → 0.8.1
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 +2 -2
- package/LexicalList.prod.js +3 -3
- package/package.json +3 -3
package/LexicalList.dev.js
CHANGED
|
@@ -795,7 +795,7 @@ function updateListItemChecked(dom, listItemNode, prevListItemNode, listNode) {
|
|
|
795
795
|
}
|
|
796
796
|
}
|
|
797
797
|
function convertListItemElement(domNode) {
|
|
798
|
-
const checked = domNode
|
|
798
|
+
const checked = utils.isHTMLElement(domNode) && domNode.getAttribute('aria-checked') === 'true';
|
|
799
799
|
return {
|
|
800
800
|
node: $createListItemNode(checked)
|
|
801
801
|
};
|
|
@@ -1016,7 +1016,7 @@ function convertListNode(domNode) {
|
|
|
1016
1016
|
if (nodeName === 'ol') {
|
|
1017
1017
|
node = $createListNode('number');
|
|
1018
1018
|
} else if (nodeName === 'ul') {
|
|
1019
|
-
if (domNode
|
|
1019
|
+
if (utils.isHTMLElement(domNode) && domNode.getAttribute('__lexicallisttype') === 'check') {
|
|
1020
1020
|
node = $createListNode('check');
|
|
1021
1021
|
} else {
|
|
1022
1022
|
node = $createListNode('bullet');
|
package/LexicalList.prod.js
CHANGED
|
@@ -19,14 +19,14 @@ a}toggleChecked(){this.setChecked(!this.__checked)}getIndent(){var a=this.getPar
|
|
|
19
19
|
q(f)&&(f=f.getChildren(),B(e,f),d.remove(),c.add(d.getKey()));E(e)}}else u(d)?(d=d.getFirstChild(),q(d)&&(c=d.getFirstChild(),null!==c&&c.insertBefore(this),E(d))):u(e)?(d=e.getFirstChild(),q(d)&&(d.append(this),E(d))):q(g)&&(c=y(),f=D(g.getListType()),c.append(f),f.append(this),e?e.insertAfter(c):d?d.insertBefore(c):g.append(c));q(g)&&E(g)}b++}else F(this),b--;return this}insertBefore(a){if(p(a)){let b=this.getParentOrThrow();if(q(b)){let c=this.getNextSiblings();E(b,c)}}return super.insertBefore(a)}canInsertAfter(a){return p(a)}canReplaceWith(a){return p(a)}canMergeWith(a){return h.$isParagraphNode(a)||
|
|
20
20
|
p(a)}extractWithChild(a,b){if(!h.$isRangeSelection(b))return!1;a=b.anchor.getNode();let c=b.focus.getNode();return this.isParentOf(a)&&this.isParentOf(c)&&this.getTextContent().length===b.getTextContent().length}isParentRequired(){return!0}createParentElementNode(){return D("bullet")}}
|
|
21
21
|
function I(a,b,c){let d=[],e=[];var f=(b=b.list)?b.listitem:void 0;if(b&&b.nested)var g=b.nested.listitem;void 0!==f&&(f=f.split(" "),d.push(...f));if(b){f=c.getParent();f=q(f)&&"check"===f.getListType();let l=c.getChecked();f&&!l||e.push(b.listitemUnchecked);f&&l||e.push(b.listitemChecked);f&&d.push(l?b.listitemChecked:b.listitemUnchecked)}void 0!==g&&(g=g.split(" "),c.getChildren().some(l=>q(l))?d.push(...g):e.push(...g));0<e.length&&k.removeClassNamesFromElement(a,...e);0<d.length&&k.addClassNamesToElement(a,
|
|
22
|
-
...d)}function H(a,b,c,d){"check"===d.getListType()?q(b.getFirstChild())?(a.removeAttribute("role"),a.removeAttribute("tabIndex"),a.removeAttribute("aria-checked")):(a.setAttribute("role","checkbox"),a.setAttribute("tabIndex","-1"),c&&b.__checked===c.__checked||a.setAttribute("aria-checked",b.getChecked()?"true":"false")):null!=b.getChecked()&&b.setChecked(void 0)}function J(a){a=a
|
|
22
|
+
...d)}function H(a,b,c,d){"check"===d.getListType()?q(b.getFirstChild())?(a.removeAttribute("role"),a.removeAttribute("tabIndex"),a.removeAttribute("aria-checked")):(a.setAttribute("role","checkbox"),a.setAttribute("tabIndex","-1"),c&&b.__checked===c.__checked||a.setAttribute("aria-checked",b.getChecked()?"true":"false")):null!=b.getChecked()&&b.setChecked(void 0)}function J(a){a=k.isHTMLElement(a)&&"true"===a.getAttribute("aria-checked");return{node:y(a)}}
|
|
23
23
|
function y(a){return h.$applyNodeReplacement(new G(void 0,a))}function p(a){return a instanceof G}
|
|
24
24
|
class K extends h.ElementNode{static getType(){return"list"}static clone(a){return new K(a.__listType||M[a.__tag],a.__start,a.__key)}constructor(a,b,c){super(c);this.__listType=a=M[a]||a;this.__tag="number"===a?"ol":"ul";this.__start=b}getTag(){return this.__tag}getListType(){return this.__listType}getStart(){return this.__start}createDOM(a){let b=document.createElement(this.__tag);1!==this.__start&&b.setAttribute("start",String(this.__start));b.__lexicalListType=this.__listType;N(b,a.theme,this);
|
|
25
25
|
return b}updateDOM(a,b,c){if(a.__tag!==this.__tag)return!0;N(b,c.theme,this);return!1}static importDOM(){return{ol:()=>({conversion:O,priority:0}),ul:()=>({conversion:O,priority:0})}}static importJSON(a){let b=D(a.listType,a.start);b.setFormat(a.format);b.setIndent(a.indent);b.setDirection(a.direction);return b}exportDOM(a){({element:a}=super.exportDOM(a));a&&(1!==this.__start&&a.setAttribute("start",String(this.__start)),"check"===this.__listType&&a.setAttribute("__lexicalListType","check"));return{element:a}}exportJSON(){return{...super.exportJSON(),
|
|
26
26
|
listType:this.getListType(),start:this.getStart(),tag:this.getTag(),type:"list",version:1}}canBeEmpty(){return!1}canIndent(){return!1}append(...a){for(let c=0;c<a.length;c++){var b=a[c];if(p(b))super.append(b);else{let d=y();q(b)?d.append(b):h.$isElementNode(b)?(b=h.$createTextNode(b.getTextContent()),d.append(b)):d.append(b);super.append(d)}}return this}extractWithChild(a){return p(a)}}
|
|
27
27
|
function N(a,b,c){let d=[],e=[];var f=b.list;if(void 0!==f){let l=f[`${c.__tag}Depth`]||[];b=n(c)-1;let x=b%l.length;var g=l[x];let L=f[c.__tag],A;f=f.nested;void 0!==f&&f.list&&(A=f.list);void 0!==L&&d.push(L);if(void 0!==g)for(g=g.split(" "),d.push(...g),g=0;g<l.length;g++)g!==x&&e.push(c.__tag+g);void 0!==A&&(c=A.split(" "),1<b?d.push(...c):e.push(...c))}0<e.length&&k.removeClassNamesFromElement(a,...e);0<d.length&&k.addClassNamesToElement(a,...d)}
|
|
28
|
-
function P(a){let b=[];for(let d=0;d<a.length;d++){var c=a[d];p(c)?(b.push(c),c=c.getChildren(),1<c.length&&c.forEach(e=>{q(e)&&b.push(w(e))})):b.push(w(c))}return b}function O(a){let b=a.nodeName.toLowerCase(),c=null;"ol"===b?c=D("number"):"ul"===b&&(c=a
|
|
29
|
-
|
|
28
|
+
function P(a){let b=[];for(let d=0;d<a.length;d++){var c=a[d];p(c)?(b.push(c),c=c.getChildren(),1<c.length&&c.forEach(e=>{q(e)&&b.push(w(e))})):b.push(w(c))}return b}function O(a){let b=a.nodeName.toLowerCase(),c=null;"ol"===b?c=D("number"):"ul"===b&&(c=k.isHTMLElement(a)&&"check"===a.getAttribute("__lexicallisttype")?D("check"):D("bullet"));return{after:P,node:c}}let M={ol:"number",ul:"bullet"};function D(a,b=1){return h.$applyNodeReplacement(new K(a,b))}function q(a){return a instanceof K}
|
|
29
|
+
let Q=h.createCommand("INSERT_UNORDERED_LIST_COMMAND"),R=h.createCommand("INSERT_ORDERED_LIST_COMMAND"),S=h.createCommand("INSERT_CHECK_LIST_COMMAND"),T=h.createCommand("REMOVE_LIST_COMMAND");exports.$createListItemNode=y;exports.$createListNode=D;exports.$getListDepth=n;
|
|
30
30
|
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=y(),d.insertAfter(e);else return!1;e.select();b=a.getNextSiblings();if(0<b.length){let f=D(c.getListType());h.$isParagraphNode(e)?e.insertAfter(f):(c=y(),c.append(f),
|
|
31
31
|
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=S;exports.INSERT_ORDERED_LIST_COMMAND=R;exports.INSERT_UNORDERED_LIST_COMMAND=Q;exports.ListItemNode=G;exports.ListNode=K;exports.REMOVE_LIST_COMMAND=T;
|
|
32
32
|
exports.insertList=function(a,b){a.update(()=>{var c=h.$getSelection();if(h.$isRangeSelection(c)||h.DEPRECATED_$isGridSelection(c)){var d=c.getNodes();c=c.anchor.getNode();var e=c.getParent();if(z(c,d))d=D(b),h.$isRootOrShadowRoot(e)?(c.replace(d),e=y(),h.$isElementNode(c)&&(e.setFormat(c.getFormatType()),e.setIndent(c.getIndent())),d.append(e)):p(c)&&(c=c.getParentOrThrow(),B(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()))C(f,
|
package/package.json
CHANGED
|
@@ -8,13 +8,13 @@
|
|
|
8
8
|
"list"
|
|
9
9
|
],
|
|
10
10
|
"license": "MIT",
|
|
11
|
-
"version": "0.8.
|
|
11
|
+
"version": "0.8.1",
|
|
12
12
|
"main": "LexicalList.js",
|
|
13
13
|
"peerDependencies": {
|
|
14
|
-
"lexical": "0.8.
|
|
14
|
+
"lexical": "0.8.1"
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@lexical/utils": "0.8.
|
|
17
|
+
"@lexical/utils": "0.8.1"
|
|
18
18
|
},
|
|
19
19
|
"repository": {
|
|
20
20
|
"type": "git",
|