@lexical/list
Advanced tools
Comparing version 0.3.11 to 0.4.0
@@ -0,1 +1,2 @@ | ||
/** @module @lexical/list */ | ||
/** | ||
@@ -8,3 +9,4 @@ * Copyright (c) Meta Platforms, Inc. and affiliates. | ||
*/ | ||
import type { ListType } from './LexicalListNode'; | ||
import type { SerializedListItemNode } from './LexicalListItemNode'; | ||
import type { ListType, SerializedListNode } from './LexicalListNode'; | ||
import type { LexicalCommand } from 'lexical'; | ||
@@ -15,3 +17,3 @@ import { $handleListInsertParagraph, indentList, insertList, outdentList, removeList } from './formatList'; | ||
import { $getListDepth } from './utils'; | ||
export { $createListItemNode, $createListNode, $getListDepth, $handleListInsertParagraph, $isListItemNode, $isListNode, indentList, insertList, ListItemNode, ListNode, ListType, outdentList, removeList, }; | ||
export { $createListItemNode, $createListNode, $getListDepth, $handleListInsertParagraph, $isListItemNode, $isListNode, indentList, insertList, ListItemNode, ListNode, ListType, outdentList, removeList, SerializedListItemNode, SerializedListNode, }; | ||
export declare const INSERT_UNORDERED_LIST_COMMAND: LexicalCommand<void>; | ||
@@ -18,0 +20,0 @@ export declare const INSERT_ORDERED_LIST_COMMAND: LexicalCommand<void>; |
@@ -193,2 +193,8 @@ /** | ||
const listItem = $createListItemNode(); | ||
if (lexical.$isElementNode(anchorNode)) { | ||
listItem.setFormat(anchorNode.getFormatType()); | ||
listItem.setIndent(anchorNode.getIndent()); | ||
} | ||
list.append(listItem); | ||
@@ -260,2 +266,4 @@ } else if ($isListItemNode(anchorNode)) { | ||
const listItem = $createListItemNode(); | ||
listItem.setFormat(node.getFormatType()); | ||
listItem.setIndent(node.getIndent()); | ||
append(listItem, node.getChildren()); | ||
@@ -586,3 +594,8 @@ | ||
*/ | ||
/** @noInheritDoc */ | ||
class ListItemNode extends lexical.ElementNode { | ||
/** @internal */ | ||
/** @internal */ | ||
static getType() { | ||
@@ -1017,3 +1030,10 @@ return 'listitem'; | ||
*/ | ||
/** @noInheritDoc */ | ||
class ListNode extends lexical.ElementNode { | ||
/** @internal */ | ||
/** @internal */ | ||
/** @internal */ | ||
static getType() { | ||
@@ -1249,9 +1269,3 @@ return 'list'; | ||
/** | ||
* Copyright (c) Meta Platforms, Inc. and affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
* | ||
*/ | ||
/** @module @lexical/list */ | ||
const INSERT_UNORDERED_LIST_COMMAND = lexical.createCommand(); | ||
@@ -1258,0 +1272,0 @@ const INSERT_ORDERED_LIST_COMMAND = lexical.createCommand(); |
@@ -10,3 +10,3 @@ /** | ||
function A(a,b){return p(a)&&(0===b.length||1===b.length&&a.is(b[0])&&0===a.getChildrenSize())}function C(a,b){a.splice(a.getChildrenSize(),0,b)} | ||
function D(a,b){if(q(a))return a;let c=a.getPreviousSibling(),d=a.getNextSibling(),e=z();C(e,a.getChildren());if(q(c)&&b===c.getListType())return c.append(e),a.remove(),q(d)&&b===d.getListType()&&(C(c,d.getChildren()),d.remove()),c;if(q(d)&&b===d.getListType())return d.getFirstChildOrThrow().insertBefore(e),a.remove(),d;b=E(b);b.append(e);a.replace(b);F(b);return b} | ||
function D(a,b){if(q(a))return a;let c=a.getPreviousSibling(),d=a.getNextSibling(),e=z();e.setFormat(a.getFormatType());e.setIndent(a.getIndent());C(e,a.getChildren());if(q(c)&&b===c.getListType())return c.append(e),a.remove(),q(d)&&b===d.getListType()&&(C(c,d.getChildren()),d.remove()),c;if(q(d)&&b===d.getListType())return d.getFirstChildOrThrow().insertBefore(e),a.remove(),d;b=E(b);b.append(e);a.replace(b);F(b);return b} | ||
function F(a,b){(b||a.getChildren()).forEach(c=>{let d=c.getValue();var e=c.getParent();var f=1;null!=e&&(q(e)?f=e.getStart():m(44));e=c.getPreviousSiblings();for(let g=0;g<e.length;g++){let k=e[g];p(k)&&!q(k.getFirstChild())&&f++}d!==f&&c.setValue(f)})} | ||
@@ -34,5 +34,5 @@ function G(a){let b=new Set;a.forEach(c=>{if(!u(c)&&!b.has(c.getKey())){var d=c.getParent(),e=c.getNextSibling(),f=c.getPreviousSibling();if(u(e)&&u(f))f=f.getFirstChild(),q(f)&&(f.append(c),c=e.getFirstChild(),q(c)&&(c=c.getChildren(),C(f,c),e.remove(),b.add(e.getKey())),F(f));else if(u(e))e=e.getFirstChild(),q(e)&&(f=e.getFirstChild(),null!==f&&f.insertBefore(c),F(e));else if(u(f))e=f.getFirstChild(),q(e)&&(e.append(c),F(e));else if(q(d)){let g=z(),k=E(d.getListType());g.append(k);k.append(c);f? | ||
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")}; | ||
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.$isRootNode(e)?(c.replace(d),c=z(),d.append(c)):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=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.$isRootNode(g)&&!c.has(k)){c.add(k);D(f,b);break}f=g}}}}})};exports.outdentList=function(){I("outdent")}; | ||
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.$isRootNode(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= | ||
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.$isRootNode(g)&&!c.has(k)){c.add(k);D(f,b);break}f=g}}}}})};exports.outdentList=function(){I("outdent")}; | ||
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"), | ||
k.remove();g.remove()}}})} |
@@ -16,4 +16,7 @@ /** | ||
}, SerializedElementNode>; | ||
/** @noInheritDoc */ | ||
export declare class ListItemNode extends ElementNode { | ||
/** @internal */ | ||
__value: number; | ||
/** @internal */ | ||
__checked?: boolean; | ||
@@ -20,0 +23,0 @@ static getType(): string; |
@@ -19,5 +19,9 @@ /** | ||
export declare type ListNodeTagType = 'ul' | 'ol'; | ||
/** @noInheritDoc */ | ||
export declare class ListNode extends ElementNode { | ||
/** @internal */ | ||
__tag: ListNodeTagType; | ||
/** @internal */ | ||
__start: number; | ||
/** @internal */ | ||
__listType: ListType; | ||
@@ -24,0 +28,0 @@ static getType(): string; |
@@ -11,9 +11,9 @@ { | ||
"license": "MIT", | ||
"version": "0.3.11", | ||
"version": "0.4.0", | ||
"main": "LexicalList.js", | ||
"peerDependencies": { | ||
"lexical": "0.3.11" | ||
"lexical": "0.4.0" | ||
}, | ||
"dependencies": { | ||
"@lexical/utils": "0.3.11" | ||
"@lexical/utils": "0.4.0" | ||
}, | ||
@@ -20,0 +20,0 @@ "repository": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
59617
1252
+ Added@lexical/table@0.4.0(transitive)
+ Added@lexical/utils@0.4.0(transitive)
+ Addedlexical@0.4.0(transitive)
- Removed@lexical/table@0.3.11(transitive)
- Removed@lexical/utils@0.3.11(transitive)
- Removedlexical@0.3.11(transitive)
Updated@lexical/utils@0.4.0