diff --git a/.yarn/cache/@lexical-list-patch-23d6e89b76-4605422c81.zip b/.yarn/cache/@lexical-list-patch-23d6e89b76-4605422c81.zip deleted file mode 100644 index 4e443ece9..000000000 Binary files a/.yarn/cache/@lexical-list-patch-23d6e89b76-4605422c81.zip and /dev/null differ diff --git a/.yarn/cache/@lexical-list-patch-344b4121c3-6908fa16cf.zip b/.yarn/cache/@lexical-list-patch-344b4121c3-6908fa16cf.zip new file mode 100644 index 000000000..832a90fba Binary files /dev/null and b/.yarn/cache/@lexical-list-patch-344b4121c3-6908fa16cf.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 index 4a290d34c..0d3cfdac6 100644 --- a/.yarn/patches/@lexical-list-npm-0.13.1-788c53f078.patch +++ b/.yarn/patches/@lexical-list-npm-0.13.1-788c53f078.patch @@ -1,8 +1,8 @@ diff --git a/LexicalList.dev.js b/LexicalList.dev.js -index 3b91ac0e93f7e6a9d784c7d8a19f11496369ecc0..7965886b460ec64dbfad0025e5076ccb656d51c3 100644 +index 3b91ac0e93f7e6a9d784c7d8a19f11496369ecc0..04236f990c38a3dded3da16dc35ef7cb0300a5fd 100644 --- a/LexicalList.dev.js +++ b/LexicalList.dev.js -@@ -140,26 +140,18 @@ function wrapInListItem(node) { +@@ -140,27 +140,6 @@ function wrapInListItem(node) { function $isSelectingEmptyListItem(anchorNode, nodes) { return $isListItemNode(anchorNode) && (nodes.length === 0 || nodes.length === 1 && anchorNode.is(nodes[0]) && anchorNode.getChildrenSize() === 0); } @@ -13,19 +13,11 @@ index 3b91ac0e93f7e6a9d784c7d8a19f11496369ecc0..7965886b460ec64dbfad0025e5076ccb - 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]; @@ -34,38 +26,210 @@ index 3b91ac0e93f7e6a9d784c7d8a19f11496369ecc0..7965886b460ec64dbfad0025e5076ccb - } - } - 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(); + * Inserts a new ListNode. If the selection's anchor node is an empty ListItemNode and is a child of +@@ -357,17 +336,19 @@ function removeList(editor) { + * @param list - The list whose children are updated. + * @param children - An array of the children to be updated. + */ +-function updateChildrenListItemValue(list, children) { +- const childrenOrExisting = children || list.getChildren(); +- if (childrenOrExisting !== undefined) { +- 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); +- if (prevValue !== nextValue) { +- child.setValue(nextValue); +- } ++function updateChildrenListItemValue(list) { ++ const isNotChecklist = list.getListType() !== 'check'; ++ let value = list.getStart(); ++ for (const child of list.getChildren()) { ++ if ($isListItemNode(child)) { ++ if (child.getValue() !== value) { ++ child.setValue(value); ++ } ++ if (isNotChecklist && child.getChecked() != null) { ++ child.setChecked(undefined); ++ } ++ if (!$isListNode(child.getFirstChild())) { ++ value++; + } + } + } +@@ -603,12 +584,14 @@ class ListItemNode extends lexical.ElementNode { + } + static transform() { + return node => { ++ if (!$isListItemNode(node)) { ++ throw Error(`node is not a ListItemNode`); ++ } ++ if (node.__checked == null) { ++ return; ++ } + const parent = node.getParent(); + if ($isListNode(parent)) { +- updateChildrenListItemValue(parent); +- if (!$isListItemNode(node)) { +- throw Error(`node is not a ListItemNode`); +- } + if (parent.getListType() !== 'check' && node.getChecked() != null) { + node.setChecked(undefined); } +@@ -704,14 +687,8 @@ class ListItemNode extends lexical.ElementNode { + throw Error(`insertAfter: list node is not parent of list item node`); + } + } +- const siblings = this.getNextSiblings(); + if ($isListItemNode(node)) { +- const after = super.insertAfter(node, restoreSelection); +- const afterListNode = node.getParentOrThrow(); +- if ($isListNode(afterListNode)) { +- updateChildrenListItemValue(afterListNode); +- } +- return after; ++ return super.insertAfter(node, restoreSelection); + } + + // Attempt to merge if the list is of the same type. +@@ -725,6 +702,7 @@ class ListItemNode extends lexical.ElementNode { + } + return child; + } ++ const siblings = this.getNextSiblings(); + + // Otherwise, split the list + // Split the lists and insert the node in between them +@@ -743,11 +721,6 @@ class ListItemNode extends lexical.ElementNode { + if (prevSibling && nextSibling && isNestedListNode(prevSibling) && isNestedListNode(nextSibling)) { + mergeLists(prevSibling.getFirstChild(), nextSibling.getFirstChild()); + nextSibling.remove(); +- } else if (nextSibling) { +- const parent = nextSibling.getParent(); +- if ($isListNode(parent)) { +- updateChildrenListItemValue(parent); +- } + } + } + insertNewAfter(_, restoreSelection = true) { +@@ -839,16 +812,6 @@ class ListItemNode extends lexical.ElementNode { + } + return this; + } +- insertBefore(nodeToInsert) { +- if ($isListItemNode(nodeToInsert)) { +- const parent = this.getParentOrThrow(); +- if ($isListNode(parent)) { +- const siblings = this.getNextSiblings(); +- updateChildrenListItemValue(parent, siblings); +- } +- } +- return super.insertBefore(nodeToInsert); +- } + canInsertAfter(node) { + return $isListItemNode(node); + } +@@ -1018,6 +981,14 @@ class ListNode extends lexical.ElementNode { + setListThemeClassNames(dom, config.theme, this); + return false; + } ++ static transform() { ++ return node => { ++ if (!$isListNode(node)) { ++ throw Error(`node is not a ListNode`); ++ } ++ updateChildrenListItemValue(node); ++ }; ++ } + static importDOM() { + return { + ol: node => ({ diff --git a/LexicalList.prod.js b/LexicalList.prod.js -index 4687f6a90633c254974aedd06538d334f84de249..462d3ab6f912f9e843d996ce19512529608829dd 100644 +index 4687f6a90633c254974aedd06538d334f84de249..d8d58c7f664b5a4999e76041b755280fe2b25214 100644 --- a/LexicalList.prod.js +++ b/LexicalList.prod.js -@@ -8,7 +8,8 @@ +@@ -8,22 +8,23 @@ 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(), +-{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(), +-version:1}}append(...a){for(let b=0;b{a.append(d)}));this.remove();0===c.getChildrenSize()&&c.remove();return a}insertAfter(a,b=!0){var c=this.getParentOrThrow();q(c)||l(39);var d=this.getNextSiblings();if(p(a))return b=super.insertAfter(a,b),a=a.getParentOrThrow(),q(a)&&F(a),b;if(q(a)){c=a;a=a.getChildren();for(d=a.length-1;0<=d;d--)c=a[d],this.insertAfter(c,b);return c}c.insertAfter(a,b);if(0!==d.length){let e=E(c.getListType());d.forEach(f=>e.append(f)); +-a.insertAfter(e,b)}return a}remove(a){let b=this.getPreviousSibling(),c=this.getNextSibling();super.remove(a);b&&c&&u(b)&&u(c)?(G(b.getFirstChild(),c.getFirstChild()),c.remove()):c&&(a=c.getParent(),q(a)&&F(a))}insertNewAfter(a,b=!0){a=y(null==this.__checked?void 0:!1);this.insertAfter(a,b);return a}collapseAtStart(a){let b=h.$createParagraphNode();this.getChildren().forEach(f=>b.append(f));var c=this.getParentOrThrow(),d=c.getParentOrThrow();let e=p(d);1===c.getChildrenSize()?e?(c.remove(),d.select()): +-(c.insertBefore(b),c.remove(),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}getValue(){return this.getLatest().__value}setValue(a){this.getWritable().__value=a}getChecked(){return this.getLatest().__checked}setChecked(a){this.getWritable().__checked=a}toggleChecked(){this.setChecked(!this.__checked)}getIndent(){var a=this.getParent(); +-if(null===a)return this.getLatest().__indent;a=a.getParentOrThrow();let b=0;for(;p(a);)a=a.getParentOrThrow().getParentOrThrow(),b++;return b}setIndent(a){"number"===typeof a&&-1({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(),version:1}}append(...a){for(let b=0;b{a.append(d)}));this.remove();0===c.getChildrenSize()&&c.remove();return a}insertAfter(a,b=!0){var c=this.getParentOrThrow();q(c)||l(39);if(p(a))return super.insertAfter(a,b);if(q(a)){c=a;a=a.getChildren();for(var d=a.length-1;0<=d;d--)c=a[d],this.insertAfter(c,b);return c}d=this.getNextSiblings();c.insertAfter(a,b);if(0!==d.length){let e=E(c.getListType());d.forEach(f=>e.append(f));a.insertAfter(e, ++b)}return a}remove(a){let b=this.getPreviousSibling(),c=this.getNextSibling();super.remove(a);b&&c&&u(b)&&u(c)&&(G(b.getFirstChild(),c.getFirstChild()),c.remove())}insertNewAfter(a,b=!0){a=y(null==this.__checked?void 0:!1);this.insertAfter(a,b);return a}collapseAtStart(a){let b=h.$createParagraphNode();this.getChildren().forEach(f=>b.append(f));var c=this.getParentOrThrow(),d=c.getParentOrThrow();let e=p(d);1===c.getChildrenSize()?e?(c.remove(),d.select()):(c.insertBefore(b),c.remove(),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}getValue(){return this.getLatest().__value}setValue(a){this.getWritable().__value=a}getChecked(){return this.getLatest().__checked}setChecked(a){this.getWritable().__checked=a}toggleChecked(){this.setChecked(!this.__checked)}getIndent(){var a=this.getParent();if(null===a)return this.getLatest().__indent; ++a=a.getParentOrThrow();let b=0;for(;p(a);)a=a.getParentOrThrow().getParentOrThrow(),b++;return b}setIndent(a){"number"===typeof a&&-1q(m))?d.push(...g):e.push(...g));0({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}exportDOM(a){({element:a}=super.exportDOM(a));a&&k.isHTMLElement(a)&&(1!==this.__start&&a.setAttribute("start",String(this.__start)), +-"check"===this.__listType&&a.setAttribute("__lexicalListType","check"));return{element:a}}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=0;c{if(!q(a))throw Error("node is not a ListNode");F(a)}}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}exportDOM(a){({element:a}=super.exportDOM(a)); ++a&&k.isHTMLElement(a)&&(1!==this.__start&&a.setAttribute("start",String(this.__start)),"check"===this.__listType&&a.setAttribute("__lexicalListType","check"));return{element:a}}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=0;c{q(e)&&b.push(w(e))})):b.push(w(c))}return b}function Q(a){let b=a.nodeName.toLowerCase(),c=null;"ol"===b?c=E("number",a.start):"ul"===b&&(c=k.isHTMLElement(a)&&"check"===a.getAttribute("__lexicallisttype")?E("check"):E("bullet"));return{after:R,node:c}}let O={ol:"number",ul:"bullet"};function E(a,b=1){return h.$applyNodeReplacement(new M(a,b))} + function q(a){return a instanceof M}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=y;exports.$createListNode=E;exports.$getListDepth=n; +diff --git a/LexicalListItemNode.d.ts b/LexicalListItemNode.d.ts +index 9fd289fd0ab65e4f63b4d2814ec97f053348f9a9..cfed87598b2882973198cbb811552340a0fdcff6 100644 +--- a/LexicalListItemNode.d.ts ++++ b/LexicalListItemNode.d.ts +@@ -40,7 +40,6 @@ export declare class ListItemNode extends ElementNode { + toggleChecked(): void; + getIndent(): number; + setIndent(indent: number): this; +- insertBefore(nodeToInsert: LexicalNode): LexicalNode; + canInsertAfter(node: LexicalNode): boolean; + canReplaceWith(replacement: LexicalNode): boolean; + canMergeWith(node: LexicalNode): boolean; +diff --git a/LexicalListNode.d.ts b/LexicalListNode.d.ts +index a04521af0011a36bae4a15ad5d04ce06b887d54e..ab4e18ab7e4116a1969479ef44e84657c2c51c87 100644 +--- a/LexicalListNode.d.ts ++++ b/LexicalListNode.d.ts +@@ -30,6 +30,7 @@ export declare class ListNode extends ElementNode { + getStart(): number; + createDOM(config: EditorConfig, _editor?: LexicalEditor): HTMLElement; + updateDOM(prevNode: ListNode, dom: HTMLElement, config: EditorConfig): boolean; ++ static transform(): (node: LexicalNode) => void; + static importDOM(): DOMConversionMap | null; + static importJSON(serializedNode: SerializedListNode): ListNode; + exportDOM(editor: LexicalEditor): DOMExportOutput; +diff --git a/formatList.d.ts b/formatList.d.ts +index d1f43e38e50680a1248a03ae8ea71f8541c33bc1..2af0a0e63579c9e2fbcf67d9d018c75fcc39a76d 100644 +--- a/formatList.d.ts ++++ b/formatList.d.ts +@@ -5,7 +5,7 @@ + * LICENSE file in the root directory of this source tree. + * + */ +-import { LexicalEditor, LexicalNode } from 'lexical'; ++import { LexicalEditor } from 'lexical'; + import { ListItemNode, ListNode } from './'; + import { ListType } from './LexicalListNode'; + /** +@@ -41,7 +41,7 @@ export declare function removeList(editor: LexicalEditor): void; + * @param list - The list whose children are updated. + * @param children - An array of the children to be updated. + */ +-export declare function updateChildrenListItemValue(list: ListNode, children?: Array): void; ++export declare function updateChildrenListItemValue(list: ListNode): void; + /** + * Adds an empty ListNode/ListItemNode chain at listItemNode, so as to + * create an indent effect. Won't indent ListItemNodes that have a ListNode as diff --git a/packages/web/package.json b/packages/web/package.json index ca1095403..c6ab5402e 100644 --- a/packages/web/package.json +++ b/packages/web/package.json @@ -3,7 +3,7 @@ "version": "3.189.1", "license": "AGPL-3.0", "main": "dist/app.js", - "author": "Standard Notes", + "author": "Standard Notes.", "private": true, "files": [ "dist" diff --git a/yarn.lock b/yarn.lock index 3eca64e02..c2aa713a0 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3890,12 +3890,12 @@ __metadata: "@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." + 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=ef92c3&locator=%40standardnotes%2Fapp-monorepo%40workspace%3A." dependencies: "@lexical/utils": 0.13.1 peerDependencies: lexical: 0.13.1 - checksum: 4605422c81bc6e4d4b6881f539a9481f10c6a58b19af4ecd8b10a4d1917bed1ec3774986ab0bc2ba94b7c0b04212ada3f58ba55c82c44e95f6328dfed0cf0df6 + checksum: 6908fa16cf9ad0bae644e16aa3ed51993619b8c02040f55420be72b46047633d49fe5438fc6511c84c755dd83ea1c051bb18c2077212c3d818393993924c93f6 languageName: node linkType: hard