diff --git a/.yarn/cache/@lexical-list-patch-23d6e89b76-4605422c81.zip b/.yarn/cache/@lexical-list-patch-23d6e89b76-4605422c81.zip new file mode 100644 index 000000000..4e443ece9 Binary files /dev/null and b/.yarn/cache/@lexical-list-patch-23d6e89b76-4605422c81.zip differ diff --git a/.yarn/patches/@lexical-list-npm-0.13.1-788c53f078.patch b/.yarn/patches/@lexical-list-npm-0.13.1-788c53f078.patch new file mode 100644 index 000000000..4a290d34c --- /dev/null +++ b/.yarn/patches/@lexical-list-npm-0.13.1-788c53f078.patch @@ -0,0 +1,71 @@ +diff --git a/LexicalList.dev.js b/LexicalList.dev.js +index 3b91ac0e93f7e6a9d784c7d8a19f11496369ecc0..7965886b460ec64dbfad0025e5076ccb656d51c3 100644 +--- a/LexicalList.dev.js ++++ b/LexicalList.dev.js +@@ -140,26 +140,18 @@ function wrapInListItem(node) { + function $isSelectingEmptyListItem(anchorNode, nodes) { + return $isListItemNode(anchorNode) && (nodes.length === 0 || nodes.length === 1 && anchorNode.is(nodes[0]) && anchorNode.getChildrenSize() === 0); + } +-function $getListItemValue(listItem) { +- const list = listItem.getParent(); +- let value = 1; +- if (list != null) { +- if (!$isListNode(list)) { +- { +- throw Error(`$getListItemValue: list node is not parent of list item node`); ++function $getListItemValues(list) { ++ let value = list.getStart(); ++ const keyToValue = new Map(); ++ for (const child of list.getChildren()) { ++ if ($isListItemNode(child)) { ++ keyToValue.set(child.getKey(), value); ++ if (!$isListNode(child.getFirstChild())) { ++ value++; + } +- } else { +- value = list.getStart(); + } + } +- const siblings = listItem.getPreviousSiblings(); +- for (let i = 0; i < siblings.length; i++) { +- const sibling = siblings[i]; +- if ($isListItemNode(sibling) && !$isListNode(sibling.getFirstChild())) { +- value++; +- } +- } +- return value; ++ return keyToValue; + } + + /** +@@ -360,11 +352,15 @@ function removeList(editor) { + function updateChildrenListItemValue(list, children) { + const childrenOrExisting = children || list.getChildren(); + if (childrenOrExisting !== undefined) { ++ const keyValueMap = $getListItemValues(list); + for (let i = 0; i < childrenOrExisting.length; i++) { + const child = childrenOrExisting[i]; + if ($isListItemNode(child)) { + const prevValue = child.getValue(); +- const nextValue = $getListItemValue(child); ++ const nextValue = keyValueMap.get(child.getKey()); ++ if (!(nextValue !== undefined)) { ++ throw Error(`updateChildrenListItemValue: list node is not parent of list item node`); ++ } + if (prevValue !== nextValue) { + child.setValue(nextValue); + } +diff --git a/LexicalList.prod.js b/LexicalList.prod.js +index 4687f6a90633c254974aedd06538d334f84de249..462d3ab6f912f9e843d996ce19512529608829dd 100644 +--- a/LexicalList.prod.js ++++ b/LexicalList.prod.js +@@ -8,7 +8,8 @@ + function n(a){let b=1;for(a=a.getParent();null!=a;){if(p(a)){a=a.getParent();if(q(a)){b++;a=a.getParent();continue}l(40)}break}return b}function r(a){a=a.getParent();q(a)||l(40);let b=a;for(;null!==b;)b=b.getParent(),q(b)&&(a=b);return a}function t(a){let b=[];a=a.getChildren().filter(p);for(let c=0;cm.append(x));f=y();g=E(g);f.append(g);C(g,a.getNextSiblings());c.insertBefore(e);c.insertAfter(f);c.replace(a)}F(b);F(d)}}} + class I extends h.ElementNode{static getType(){return"listitem"}static clone(a){return new I(a.__value,a.__checked,a.__key)}constructor(a,b,c){super(c);this.__value=void 0===a?1:a;this.__checked=b}createDOM(a){let b=document.createElement("li"),c=this.getParent();q(c)&&"check"===c.getListType()&&J(b,this,null);b.value=this.__value;K(b,a.theme,this);return b}updateDOM(a,b,c){let d=this.getParent();q(d)&&"check"===d.getListType()&&J(b,this,a);b.value=this.__value;K(b,c.theme,this);return!1}static transform(){return a=> + {let b=a.getParent();q(b)&&(F(b),p(a)||l(144),"check"!==b.getListType()&&null!=a.getChecked()&&a.setChecked(void 0))}}static importDOM(){return{li:()=>({conversion:L,priority:0})}}static importJSON(a){let b=y();b.setChecked(a.checked);b.setValue(a.value);b.setFormat(a.format);b.setDirection(a.direction);return b}exportDOM(a){a=this.createDOM(a._config);a.style.textAlign=this.getFormatType();return{element:a}}exportJSON(){return{...super.exportJSON(),checked:this.getChecked(),type:"listitem",value:this.getValue(), diff --git a/package.json b/package.json index f8c2a04e1..ade9b7ea6 100644 --- a/package.json +++ b/package.json @@ -46,7 +46,8 @@ "@types/hoist-non-react-statics/@types/react": "17.0.2", "lexical@0.13.1": "patch:lexical@npm:0.13.1#.yarn/patches/lexical-npm-0.13.1-ac06219fd6.patch", "@lexical/clipboard@0.13.1": "patch:@lexical/clipboard@npm:0.13.1#.yarn/patches/@lexical-clipboard-npm-0.13.1-b4788bb0a9.patch", - "@lexical/rich-text@0.13.1": "patch:@lexical/rich-text@npm:0.13.1#.yarn/patches/@lexical-rich-text-npm-0.13.1-df610fad54.patch" + "@lexical/rich-text@0.13.1": "patch:@lexical/rich-text@npm:0.13.1#.yarn/patches/@lexical-rich-text-npm-0.13.1-df610fad54.patch", + "@lexical/list@0.13.1": "patch:@lexical/list@npm:0.13.1#.yarn/patches/@lexical-list-npm-0.13.1-788c53f078.patch" }, "dependencies": { "@standardnotes/snjs": "workspace:*" diff --git a/yarn.lock b/yarn.lock index 6c660d72c..3eca64e02 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3888,6 +3888,17 @@ __metadata: languageName: node linkType: hard +"@lexical/list@patch:@lexical/list@npm:0.13.1#.yarn/patches/@lexical-list-npm-0.13.1-788c53f078.patch::locator=%40standardnotes%2Fapp-monorepo%40workspace%3A.": + version: 0.13.1 + resolution: "@lexical/list@patch:@lexical/list@npm%3A0.13.1#.yarn/patches/@lexical-list-npm-0.13.1-788c53f078.patch::version=0.13.1&hash=759f3b&locator=%40standardnotes%2Fapp-monorepo%40workspace%3A." + dependencies: + "@lexical/utils": 0.13.1 + peerDependencies: + lexical: 0.13.1 + checksum: 4605422c81bc6e4d4b6881f539a9481f10c6a58b19af4ecd8b10a4d1917bed1ec3774986ab0bc2ba94b7c0b04212ada3f58ba55c82c44e95f6328dfed0cf0df6 + languageName: node + linkType: hard + "@lexical/mark@npm:0.13.1": version: 0.13.1 resolution: "@lexical/mark@npm:0.13.1"