diff --git a/.yarn/cache/@lexical-clipboard-npm-0.16.0-3053c4af9c-8fe5cf11a1.zip b/.yarn/cache/@lexical-clipboard-npm-0.16.0-3053c4af9c-8fe5cf11a1.zip deleted file mode 100644 index 5ad1d8e15..000000000 Binary files a/.yarn/cache/@lexical-clipboard-npm-0.16.0-3053c4af9c-8fe5cf11a1.zip and /dev/null differ diff --git a/.yarn/cache/@lexical-clipboard-npm-0.22.0-e950aa6a7f-c6869ec54c.zip b/.yarn/cache/@lexical-clipboard-npm-0.22.0-e950aa6a7f-c6869ec54c.zip new file mode 100644 index 000000000..8b0f8049d Binary files /dev/null and b/.yarn/cache/@lexical-clipboard-npm-0.22.0-e950aa6a7f-c6869ec54c.zip differ diff --git a/.yarn/cache/@lexical-clipboard-patch-727e82298a-4bfeeaef9a.zip b/.yarn/cache/@lexical-clipboard-patch-727e82298a-4bfeeaef9a.zip deleted file mode 100644 index ec64bbfdd..000000000 Binary files a/.yarn/cache/@lexical-clipboard-patch-727e82298a-4bfeeaef9a.zip and /dev/null differ diff --git a/.yarn/cache/@lexical-clipboard-patch-f38883999e-8972b49800.zip b/.yarn/cache/@lexical-clipboard-patch-f38883999e-8972b49800.zip new file mode 100644 index 000000000..48085fee9 Binary files /dev/null and b/.yarn/cache/@lexical-clipboard-patch-f38883999e-8972b49800.zip differ diff --git a/.yarn/cache/@lexical-code-npm-0.16.0-1e607246ae-4f6283beca.zip b/.yarn/cache/@lexical-code-npm-0.16.0-1e607246ae-4f6283beca.zip deleted file mode 100644 index af4dce827..000000000 Binary files a/.yarn/cache/@lexical-code-npm-0.16.0-1e607246ae-4f6283beca.zip and /dev/null differ diff --git a/.yarn/cache/@lexical-code-npm-0.22.0-421f0c2d2a-6e7ff958d5.zip b/.yarn/cache/@lexical-code-npm-0.22.0-421f0c2d2a-6e7ff958d5.zip new file mode 100644 index 000000000..d167ac9c6 Binary files /dev/null and b/.yarn/cache/@lexical-code-npm-0.22.0-421f0c2d2a-6e7ff958d5.zip differ diff --git a/.yarn/cache/@lexical-devtools-core-npm-0.16.0-75f034c8c0-c6ba99da01.zip b/.yarn/cache/@lexical-devtools-core-npm-0.16.0-75f034c8c0-c6ba99da01.zip deleted file mode 100644 index 30e42c418..000000000 Binary files a/.yarn/cache/@lexical-devtools-core-npm-0.16.0-75f034c8c0-c6ba99da01.zip and /dev/null differ diff --git a/.yarn/cache/@lexical-devtools-core-npm-0.22.0-7aa26b96d3-e8c75cd1fb.zip b/.yarn/cache/@lexical-devtools-core-npm-0.22.0-7aa26b96d3-e8c75cd1fb.zip new file mode 100644 index 000000000..41edb9a89 Binary files /dev/null and b/.yarn/cache/@lexical-devtools-core-npm-0.22.0-7aa26b96d3-e8c75cd1fb.zip differ diff --git a/.yarn/cache/@lexical-dragon-npm-0.16.0-befd26b946-8f6fa61755.zip b/.yarn/cache/@lexical-dragon-npm-0.22.0-b04a8430eb-ba9b4143b7.zip similarity index 92% rename from .yarn/cache/@lexical-dragon-npm-0.16.0-befd26b946-8f6fa61755.zip rename to .yarn/cache/@lexical-dragon-npm-0.22.0-b04a8430eb-ba9b4143b7.zip index da41999a6..7f06004e8 100644 Binary files a/.yarn/cache/@lexical-dragon-npm-0.16.0-befd26b946-8f6fa61755.zip and b/.yarn/cache/@lexical-dragon-npm-0.22.0-b04a8430eb-ba9b4143b7.zip differ diff --git a/.yarn/cache/@lexical-hashtag-npm-0.16.0-183e6f69ee-a569b35a89.zip b/.yarn/cache/@lexical-hashtag-npm-0.16.0-183e6f69ee-a569b35a89.zip deleted file mode 100644 index 507f171c4..000000000 Binary files a/.yarn/cache/@lexical-hashtag-npm-0.16.0-183e6f69ee-a569b35a89.zip and /dev/null differ diff --git a/.yarn/cache/@lexical-hashtag-npm-0.22.0-f14a9bf13e-368cf96b08.zip b/.yarn/cache/@lexical-hashtag-npm-0.22.0-f14a9bf13e-368cf96b08.zip new file mode 100644 index 000000000..d1c969698 Binary files /dev/null and b/.yarn/cache/@lexical-hashtag-npm-0.22.0-f14a9bf13e-368cf96b08.zip differ diff --git a/.yarn/cache/@lexical-headless-npm-0.16.0-1c2965ae66-6a03375495.zip b/.yarn/cache/@lexical-headless-npm-0.22.0-7636576667-dedc45cec5.zip similarity index 77% rename from .yarn/cache/@lexical-headless-npm-0.16.0-1c2965ae66-6a03375495.zip rename to .yarn/cache/@lexical-headless-npm-0.22.0-7636576667-dedc45cec5.zip index 12339cc7e..0461e0f6d 100644 Binary files a/.yarn/cache/@lexical-headless-npm-0.16.0-1c2965ae66-6a03375495.zip and b/.yarn/cache/@lexical-headless-npm-0.22.0-7636576667-dedc45cec5.zip differ diff --git a/.yarn/cache/@lexical-history-npm-0.16.0-e8134b29c0-a26311ddcc.zip b/.yarn/cache/@lexical-history-npm-0.16.0-e8134b29c0-a26311ddcc.zip deleted file mode 100644 index a34f39d6d..000000000 Binary files a/.yarn/cache/@lexical-history-npm-0.16.0-e8134b29c0-a26311ddcc.zip and /dev/null differ diff --git a/.yarn/cache/@lexical-history-npm-0.22.0-7851715090-8eb683a5bb.zip b/.yarn/cache/@lexical-history-npm-0.22.0-7851715090-8eb683a5bb.zip new file mode 100644 index 000000000..881616b6b Binary files /dev/null and b/.yarn/cache/@lexical-history-npm-0.22.0-7851715090-8eb683a5bb.zip differ diff --git a/.yarn/cache/@lexical-html-npm-0.16.0-9e42e87c7e-3b3ffa9823.zip b/.yarn/cache/@lexical-html-npm-0.16.0-9e42e87c7e-3b3ffa9823.zip deleted file mode 100644 index f10de2ec9..000000000 Binary files a/.yarn/cache/@lexical-html-npm-0.16.0-9e42e87c7e-3b3ffa9823.zip and /dev/null differ diff --git a/.yarn/cache/@lexical-html-npm-0.22.0-a51c36910b-14e32af4fb.zip b/.yarn/cache/@lexical-html-npm-0.22.0-a51c36910b-14e32af4fb.zip new file mode 100644 index 000000000..c720637bc Binary files /dev/null and b/.yarn/cache/@lexical-html-npm-0.22.0-a51c36910b-14e32af4fb.zip differ diff --git a/.yarn/cache/@lexical-link-npm-0.16.0-638fd00b9d-2b2900001a.zip b/.yarn/cache/@lexical-link-npm-0.16.0-638fd00b9d-2b2900001a.zip deleted file mode 100644 index 905b6e907..000000000 Binary files a/.yarn/cache/@lexical-link-npm-0.16.0-638fd00b9d-2b2900001a.zip and /dev/null differ diff --git a/.yarn/cache/@lexical-link-npm-0.22.0-744858e6de-f36c3d3a7e.zip b/.yarn/cache/@lexical-link-npm-0.22.0-744858e6de-f36c3d3a7e.zip new file mode 100644 index 000000000..6406d8efd Binary files /dev/null and b/.yarn/cache/@lexical-link-npm-0.22.0-744858e6de-f36c3d3a7e.zip differ diff --git a/.yarn/cache/@lexical-list-npm-0.16.0-8f91da4ad5-f60fd40d03.zip b/.yarn/cache/@lexical-list-npm-0.16.0-8f91da4ad5-f60fd40d03.zip deleted file mode 100644 index 37ebd35d4..000000000 Binary files a/.yarn/cache/@lexical-list-npm-0.16.0-8f91da4ad5-f60fd40d03.zip and /dev/null differ diff --git a/.yarn/cache/@lexical-list-npm-0.22.0-979bed97d8-7ee86ccc56.zip b/.yarn/cache/@lexical-list-npm-0.22.0-979bed97d8-7ee86ccc56.zip new file mode 100644 index 000000000..be4d6b326 Binary files /dev/null and b/.yarn/cache/@lexical-list-npm-0.22.0-979bed97d8-7ee86ccc56.zip differ diff --git a/.yarn/cache/@lexical-list-patch-6980539b45-bb54618159.zip b/.yarn/cache/@lexical-list-patch-6980539b45-bb54618159.zip deleted file mode 100644 index 2a2b70797..000000000 Binary files a/.yarn/cache/@lexical-list-patch-6980539b45-bb54618159.zip and /dev/null differ diff --git a/.yarn/cache/@lexical-mark-npm-0.16.0-18bf20d026-08067e266d.zip b/.yarn/cache/@lexical-mark-npm-0.16.0-18bf20d026-08067e266d.zip deleted file mode 100644 index 48d5f2c15..000000000 Binary files a/.yarn/cache/@lexical-mark-npm-0.16.0-18bf20d026-08067e266d.zip and /dev/null differ diff --git a/.yarn/cache/@lexical-mark-npm-0.22.0-724843edb5-c3cf36c47b.zip b/.yarn/cache/@lexical-mark-npm-0.22.0-724843edb5-c3cf36c47b.zip new file mode 100644 index 000000000..8dcd45263 Binary files /dev/null and b/.yarn/cache/@lexical-mark-npm-0.22.0-724843edb5-c3cf36c47b.zip differ diff --git a/.yarn/cache/@lexical-markdown-npm-0.16.0-250358cbdd-2d061e4a3b.zip b/.yarn/cache/@lexical-markdown-npm-0.16.0-250358cbdd-2d061e4a3b.zip deleted file mode 100644 index 7c9f1e577..000000000 Binary files a/.yarn/cache/@lexical-markdown-npm-0.16.0-250358cbdd-2d061e4a3b.zip and /dev/null differ diff --git a/.yarn/cache/@lexical-markdown-npm-0.22.0-b4c001dc78-0e2c371ead.zip b/.yarn/cache/@lexical-markdown-npm-0.22.0-b4c001dc78-0e2c371ead.zip new file mode 100644 index 000000000..f41c6cf14 Binary files /dev/null and b/.yarn/cache/@lexical-markdown-npm-0.22.0-b4c001dc78-0e2c371ead.zip differ diff --git a/.yarn/cache/@lexical-offset-npm-0.16.0-085751d2ce-c6c581be2f.zip b/.yarn/cache/@lexical-offset-npm-0.22.0-32e1d156a2-9172370f74.zip similarity index 92% rename from .yarn/cache/@lexical-offset-npm-0.16.0-085751d2ce-c6c581be2f.zip rename to .yarn/cache/@lexical-offset-npm-0.22.0-32e1d156a2-9172370f74.zip index c006d86cb..111db85cc 100644 Binary files a/.yarn/cache/@lexical-offset-npm-0.16.0-085751d2ce-c6c581be2f.zip and b/.yarn/cache/@lexical-offset-npm-0.22.0-32e1d156a2-9172370f74.zip differ diff --git a/.yarn/cache/@lexical-overflow-npm-0.16.0-9b07e094d6-9b659e4053.zip b/.yarn/cache/@lexical-overflow-npm-0.16.0-9b07e094d6-9b659e4053.zip deleted file mode 100644 index ab6925b66..000000000 Binary files a/.yarn/cache/@lexical-overflow-npm-0.16.0-9b07e094d6-9b659e4053.zip and /dev/null differ diff --git a/.yarn/cache/@lexical-overflow-npm-0.22.0-bd40be9d93-9b48668292.zip b/.yarn/cache/@lexical-overflow-npm-0.22.0-bd40be9d93-9b48668292.zip new file mode 100644 index 000000000..7c058586e Binary files /dev/null and b/.yarn/cache/@lexical-overflow-npm-0.22.0-bd40be9d93-9b48668292.zip differ diff --git a/.yarn/cache/@lexical-plain-text-npm-0.16.0-224bff0814-026a745849.zip b/.yarn/cache/@lexical-plain-text-npm-0.16.0-224bff0814-026a745849.zip deleted file mode 100644 index 34bb0ece4..000000000 Binary files a/.yarn/cache/@lexical-plain-text-npm-0.16.0-224bff0814-026a745849.zip and /dev/null differ diff --git a/.yarn/cache/@lexical-plain-text-npm-0.22.0-d159d3e9a7-1093ebfc11.zip b/.yarn/cache/@lexical-plain-text-npm-0.22.0-d159d3e9a7-1093ebfc11.zip new file mode 100644 index 000000000..d664187f9 Binary files /dev/null and b/.yarn/cache/@lexical-plain-text-npm-0.22.0-d159d3e9a7-1093ebfc11.zip differ diff --git a/.yarn/cache/@lexical-react-npm-0.16.0-8fb67114ff-a58988010f.zip b/.yarn/cache/@lexical-react-npm-0.16.0-8fb67114ff-a58988010f.zip deleted file mode 100644 index 14efeab64..000000000 Binary files a/.yarn/cache/@lexical-react-npm-0.16.0-8fb67114ff-a58988010f.zip and /dev/null differ diff --git a/.yarn/cache/@lexical-react-npm-0.22.0-d8774fb2db-6d4f56be0b.zip b/.yarn/cache/@lexical-react-npm-0.22.0-d8774fb2db-6d4f56be0b.zip new file mode 100644 index 000000000..f4a5aca21 Binary files /dev/null and b/.yarn/cache/@lexical-react-npm-0.22.0-d8774fb2db-6d4f56be0b.zip differ diff --git a/.yarn/cache/@lexical-rich-text-npm-0.16.0-f484a17832-00318a6a78.zip b/.yarn/cache/@lexical-rich-text-npm-0.16.0-f484a17832-00318a6a78.zip deleted file mode 100644 index 3965afafb..000000000 Binary files a/.yarn/cache/@lexical-rich-text-npm-0.16.0-f484a17832-00318a6a78.zip and /dev/null differ diff --git a/.yarn/cache/@lexical-rich-text-npm-0.22.0-1c32cc4b16-f7c7153b16.zip b/.yarn/cache/@lexical-rich-text-npm-0.22.0-1c32cc4b16-f7c7153b16.zip new file mode 100644 index 000000000..763509b0f Binary files /dev/null and b/.yarn/cache/@lexical-rich-text-npm-0.22.0-1c32cc4b16-f7c7153b16.zip differ diff --git a/.yarn/cache/@lexical-rich-text-patch-5d68a30044-fb69c07964.zip b/.yarn/cache/@lexical-rich-text-patch-5d68a30044-fb69c07964.zip deleted file mode 100644 index 546e06105..000000000 Binary files a/.yarn/cache/@lexical-rich-text-patch-5d68a30044-fb69c07964.zip and /dev/null differ diff --git a/.yarn/cache/@lexical-rich-text-patch-bfbc9fddb3-c6523beac5.zip b/.yarn/cache/@lexical-rich-text-patch-bfbc9fddb3-c6523beac5.zip new file mode 100644 index 000000000..6429f97b2 Binary files /dev/null and b/.yarn/cache/@lexical-rich-text-patch-bfbc9fddb3-c6523beac5.zip differ diff --git a/.yarn/cache/@lexical-selection-npm-0.16.0-7e8d6b2662-fd4832f3b0.zip b/.yarn/cache/@lexical-selection-npm-0.16.0-7e8d6b2662-fd4832f3b0.zip deleted file mode 100644 index 002bf0bcd..000000000 Binary files a/.yarn/cache/@lexical-selection-npm-0.16.0-7e8d6b2662-fd4832f3b0.zip and /dev/null differ diff --git a/.yarn/cache/@lexical-selection-npm-0.22.0-4a213f5e36-5c3f80944e.zip b/.yarn/cache/@lexical-selection-npm-0.22.0-4a213f5e36-5c3f80944e.zip new file mode 100644 index 000000000..eff48489f Binary files /dev/null and b/.yarn/cache/@lexical-selection-npm-0.22.0-4a213f5e36-5c3f80944e.zip differ diff --git a/.yarn/cache/@lexical-table-npm-0.16.0-a9b846618e-484b6c53dd.zip b/.yarn/cache/@lexical-table-npm-0.16.0-a9b846618e-484b6c53dd.zip deleted file mode 100644 index 5e42fb48b..000000000 Binary files a/.yarn/cache/@lexical-table-npm-0.16.0-a9b846618e-484b6c53dd.zip and /dev/null differ diff --git a/.yarn/cache/@lexical-table-npm-0.22.0-0aa6b73b6f-6a8e3564ef.zip b/.yarn/cache/@lexical-table-npm-0.22.0-0aa6b73b6f-6a8e3564ef.zip new file mode 100644 index 000000000..98a8d2b7b Binary files /dev/null and b/.yarn/cache/@lexical-table-npm-0.22.0-0aa6b73b6f-6a8e3564ef.zip differ diff --git a/.yarn/cache/@lexical-text-npm-0.16.0-f56ddd1f35-60eadf8d4c.zip b/.yarn/cache/@lexical-text-npm-0.22.0-bfcd27f33d-82857b6c3b.zip similarity index 91% rename from .yarn/cache/@lexical-text-npm-0.16.0-f56ddd1f35-60eadf8d4c.zip rename to .yarn/cache/@lexical-text-npm-0.22.0-bfcd27f33d-82857b6c3b.zip index 300936816..394577a58 100644 Binary files a/.yarn/cache/@lexical-text-npm-0.16.0-f56ddd1f35-60eadf8d4c.zip and b/.yarn/cache/@lexical-text-npm-0.22.0-bfcd27f33d-82857b6c3b.zip differ diff --git a/.yarn/cache/@lexical-utils-npm-0.16.0-71a5e51a87-b6696b83b9.zip b/.yarn/cache/@lexical-utils-npm-0.16.0-71a5e51a87-b6696b83b9.zip deleted file mode 100644 index eb22b1086..000000000 Binary files a/.yarn/cache/@lexical-utils-npm-0.16.0-71a5e51a87-b6696b83b9.zip and /dev/null differ diff --git a/.yarn/cache/@lexical-utils-npm-0.22.0-8b465096d0-45e1e60f89.zip b/.yarn/cache/@lexical-utils-npm-0.22.0-8b465096d0-45e1e60f89.zip new file mode 100644 index 000000000..7471a4e96 Binary files /dev/null and b/.yarn/cache/@lexical-utils-npm-0.22.0-8b465096d0-45e1e60f89.zip differ diff --git a/.yarn/cache/@lexical-yjs-npm-0.16.0-d99f519ca8-9060569779.zip b/.yarn/cache/@lexical-yjs-npm-0.16.0-d99f519ca8-9060569779.zip deleted file mode 100644 index 7f7e6692a..000000000 Binary files a/.yarn/cache/@lexical-yjs-npm-0.16.0-d99f519ca8-9060569779.zip and /dev/null differ diff --git a/.yarn/cache/@lexical-yjs-npm-0.22.0-21fa141871-3ffe2fa446.zip b/.yarn/cache/@lexical-yjs-npm-0.22.0-21fa141871-3ffe2fa446.zip new file mode 100644 index 000000000..523dd6012 Binary files /dev/null and b/.yarn/cache/@lexical-yjs-npm-0.22.0-21fa141871-3ffe2fa446.zip differ diff --git a/.yarn/cache/lexical-npm-0.16.0-72c538fbd1-ef43cf65dd.zip b/.yarn/cache/lexical-npm-0.16.0-72c538fbd1-ef43cf65dd.zip deleted file mode 100644 index c550b1a75..000000000 Binary files a/.yarn/cache/lexical-npm-0.16.0-72c538fbd1-ef43cf65dd.zip and /dev/null differ diff --git a/.yarn/cache/lexical-npm-0.22.0-3ef92eee29-54153b6d31.zip b/.yarn/cache/lexical-npm-0.22.0-3ef92eee29-54153b6d31.zip new file mode 100644 index 000000000..9309792c5 Binary files /dev/null and b/.yarn/cache/lexical-npm-0.22.0-3ef92eee29-54153b6d31.zip differ diff --git a/.yarn/patches/@lexical-clipboard-npm-0.16.0-3053c4af9c.patch b/.yarn/patches/@lexical-clipboard-npm-0.16.0-3053c4af9c.patch deleted file mode 100644 index 3cc714cef..000000000 --- a/.yarn/patches/@lexical-clipboard-npm-0.16.0-3053c4af9c.patch +++ /dev/null @@ -1,151 +0,0 @@ -diff --git a/LexicalClipboard.dev.js b/LexicalClipboard.dev.js -index 3fad3811aa254c5b1b02e039c0d1f21c2a28562f..78aa3bc5048bb4354339efc558031ec0185163dd 100644 ---- a/LexicalClipboard.dev.js -+++ b/LexicalClipboard.dev.js -@@ -30,7 +30,6 @@ const CAN_USE_DOM = typeof window !== 'undefined' && typeof window.document !== - * LICENSE file in the root directory of this source tree. - * - */ -- - const getDOMSelection = targetWindow => CAN_USE_DOM ? (targetWindow || window).getSelection() : null; - - /** -@@ -105,7 +104,7 @@ function $insertDataTransferForPlainText(dataTransfer, selection) { - * @param selection the selection to use as the insertion point for the content in the DataTransfer object - * @param editor the LexicalEditor the content is being inserted into. - */ --function $insertDataTransferForRichText(dataTransfer, selection, editor) { -+function $insertDataTransferForRichText(dataTransfer, selection, editor, event) { - const lexicalString = dataTransfer.getData('application/x-lexical-editor'); - if (lexicalString) { - try { -@@ -118,15 +117,18 @@ function $insertDataTransferForRichText(dataTransfer, selection, editor) { - // Fail silently. - } - } -- const htmlString = dataTransfer.getData('text/html'); -- if (htmlString) { -- try { -- const parser = new DOMParser(); -- const dom = parser.parseFromString(htmlString, 'text/html'); -- const nodes = html.$generateNodesFromDOM(editor, dom); -- return $insertGeneratedNodes(editor, nodes, selection); -- } catch (_unused2) { -- // Fail silently. -+ const shouldIgnoreHTML = event && event.inputType === 'insertReplacementText' && dataTransfer.types.includes('text/plain'); -+ if (!shouldIgnoreHTML) { -+ const htmlString = dataTransfer.getData('text/html'); -+ if (htmlString) { -+ try { -+ const parser = new DOMParser(); -+ const dom = parser.parseFromString(htmlString, 'text/html'); -+ const nodes = html.$generateNodesFromDOM(editor, dom); -+ return $insertGeneratedNodes(editor, nodes, selection); -+ } catch (_unused2) { -+ // Fail silently. -+ } - } - } - -diff --git a/LexicalClipboard.dev.mjs b/LexicalClipboard.dev.mjs -index 9d1054125804bec18b6d2fc3b09386defa7c8be2..ef944d097da9cc4383c38c874a6d1e7c20ab22d0 100644 ---- a/LexicalClipboard.dev.mjs -+++ b/LexicalClipboard.dev.mjs -@@ -28,7 +28,6 @@ const CAN_USE_DOM = typeof window !== 'undefined' && typeof window.document !== - * LICENSE file in the root directory of this source tree. - * - */ -- - const getDOMSelection = targetWindow => CAN_USE_DOM ? (targetWindow || window).getSelection() : null; - - /** -@@ -103,7 +102,7 @@ function $insertDataTransferForPlainText(dataTransfer, selection) { - * @param selection the selection to use as the insertion point for the content in the DataTransfer object - * @param editor the LexicalEditor the content is being inserted into. - */ --function $insertDataTransferForRichText(dataTransfer, selection, editor) { -+function $insertDataTransferForRichText(dataTransfer, selection, editor, event) { - const lexicalString = dataTransfer.getData('application/x-lexical-editor'); - if (lexicalString) { - try { -@@ -116,15 +115,18 @@ function $insertDataTransferForRichText(dataTransfer, selection, editor) { - // Fail silently. - } - } -- const htmlString = dataTransfer.getData('text/html'); -- if (htmlString) { -- try { -- const parser = new DOMParser(); -- const dom = parser.parseFromString(htmlString, 'text/html'); -- const nodes = $generateNodesFromDOM(editor, dom); -- return $insertGeneratedNodes(editor, nodes, selection); -- } catch (_unused2) { -- // Fail silently. -+ const shouldIgnoreHTML = event && event.inputType === 'insertReplacementText' && dataTransfer.types.includes('text/plain'); -+ if (!shouldIgnoreHTML) { -+ const htmlString = dataTransfer.getData('text/html'); -+ if (htmlString) { -+ try { -+ const parser = new DOMParser(); -+ const dom = parser.parseFromString(htmlString, 'text/html'); -+ const nodes = $generateNodesFromDOM(editor, dom); -+ return $insertGeneratedNodes(editor, nodes, selection); -+ } catch (_unused2) { -+ // Fail silently. -+ } - } - } - -diff --git a/LexicalClipboard.prod.js b/LexicalClipboard.prod.js -index 38848b4d69dcae7d54a5ab99b8f3cdd9324e413f..7ddc6b87dd2c9c32973f4dc7ae552c8fdb80eeb0 100644 ---- a/LexicalClipboard.prod.js -+++ b/LexicalClipboard.prod.js -@@ -6,14 +6,14 @@ - * - */ - --'use strict';var f=require("@lexical/html"),m=require("@lexical/selection"),n=require("@lexical/utils"),p=require("lexical"),t;function u(a){let b=new URLSearchParams;b.append("code",a);for(let c=1;c{a.update(()=>{g(D(a,b))})});var c=a.getRootElement();let d=null==a._window?window.document:a._window.document,e=v?(a._window||window).getSelection():null;if(null===c||null===e)return!1;let h=d.createElement("span");h.style.cssText="position: fixed; top: -1000px;";h.append(d.createTextNode("#"));c.append(h);c=new Range;c.setStart(h,0);c.setEnd(h,1);e.removeAllRanges();e.addRange(c);return new Promise(g=> --{let k=a.registerCommand(p.COPY_COMMAND,q=>{n.objectKlassEquals(q,ClipboardEvent)&&(k(),null!==C&&(window.clearTimeout(C),C=null),g(D(a,q)));return!0},p.COMMAND_PRIORITY_CRITICAL);C=window.setTimeout(()=>{k();C=null;g(!1)},50);d.execCommand("copy");h.remove()})} -+'use strict';var f=require("@lexical/html"),m=require("@lexical/selection"),q=require("@lexical/utils"),r=require("lexical");function t(a){let b=new URLSearchParams;b.append("code",a);for(let c=1;c{a.update(()=>{d(C(a,b))})});var c=a.getRootElement();let e=null==a._window?window.document:a._window.document,g=u?(a._window||window).getSelection():null;if(null===c||null===g)return!1;let k=e.createElement("span");k.style.cssText="position: fixed; top: -1000px;";k.append(e.createTextNode("#"));c.append(k);c=new Range;c.setStart(k,0);c.setEnd(k,1);g.removeAllRanges();g.addRange(c);return new Promise(d=> -+{let h=a.registerCommand(r.COPY_COMMAND,n=>{q.objectKlassEquals(n,ClipboardEvent)&&(h(),null!==B&&(window.clearTimeout(B),B=null),d(C(a,n)));return!0},r.COMMAND_PRIORITY_CRITICAL);B=window.setTimeout(()=>{h();B=null;d(!1)},50);e.execCommand("copy");k.remove()})} -diff --git a/LexicalClipboard.prod.mjs b/LexicalClipboard.prod.mjs -index 6b572db295155b182e3077f64b308cbbf993e241..32076e8a14b02d37e0a8302e51920f13dc211180 100644 ---- a/LexicalClipboard.prod.mjs -+++ b/LexicalClipboard.prod.mjs -@@ -6,4 +6,4 @@ - * - */ - --import{$generateHtmlFromNodes as t,$generateNodesFromDOM as e}from"@lexical/html";import{$addNodeStyle as n,$cloneWithProperties as o,$sliceSelectedTextNodeContent as l}from"@lexical/selection";import{objectKlassEquals as r}from"@lexical/utils";import{$getSelection as i,$isRangeSelection as s,$createTabNode as a,SELECTION_INSERT_CLIPBOARD_NODES_COMMAND as c,$getRoot as u,$parseSerializedNode as d,$isTextNode as f,COPY_COMMAND as p,COMMAND_PRIORITY_CRITICAL as m,isSelectionWithinEditor as h,$isElementNode as g}from"lexical";function x(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var w=x((function(t){const e=new URLSearchParams;e.append("code",t);for(let t=1;ty?(t||window).getSelection():null;function D(e){const n=i();return null==n&&w(166),s(n)&&n.isCollapsed()||0===n.getNodes().length?"":t(e,n)}function C(t){const e=i();return null==e&&w(166),s(e)&&e.isCollapsed()||0===e.getNodes().length?null:JSON.stringify(A(t,e))}function N(t,e){const n=t.getData("text/plain")||t.getData("text/uri-list");null!=n&&e.insertRawText(n)}function _(t,n,o){const l=t.getData("application/x-lexical-editor");if(l)try{const t=JSON.parse(l);if(t.namespace===o._config.namespace&&Array.isArray(t.nodes)){return T(o,R(t.nodes),n)}}catch(t){}const r=t.getData("text/html");if(r)try{const t=(new DOMParser).parseFromString(r,"text/html");return T(o,e(o,t),n)}catch(t){}const c=t.getData("text/plain")||t.getData("text/uri-list");if(null!=c)if(s(n)){const t=c.split(/(\r?\n|\t)/);""===t[t.length-1]&&t.pop();for(let e=0;e0?u.text=t:i=!1}for(let o=0;o{t.update((()=>{n(P(t,e))}))}));const n=t.getRootElement(),o=null==t._window?window.document:t._window.document,l=v(t._window);if(null===n||null===l)return!1;const i=o.createElement("span");i.style.cssText="position: fixed; top: -1000px;",i.append(o.createTextNode("#")),n.append(i);const s=new Range;return s.setStart(i,0),s.setEnd(i,1),l.removeAllRanges(),l.addRange(s),new Promise(((e,n)=>{const l=t.registerCommand(p,(n=>(r(n,ClipboardEvent)&&(l(),null!==E&&(window.clearTimeout(E),E=null),e(P(t,n))),!0)),m);E=window.setTimeout((()=>{l(),E=null,e(!1)}),50),o.execCommand("copy"),i.remove()}))}function P(t,e){const n=v(t._window);if(!n)return!1;const o=n.anchorNode,l=n.focusNode;if(null!==o&&null!==l&&!h(t,o,l))return!1;e.preventDefault();const r=e.clipboardData,s=i();if(null===r||null===s)return!1;const a=D(t),c=C(t);let u="";return null!==s&&(u=s.getTextContent()),null!==a&&r.setData("text/html",a),null!==c&&r.setData("application/x-lexical-editor",c),r.setData("text/plain",u),!0}export{A as $generateJSONFromSelectedNodes,R as $generateNodesFromSerializedNodes,D as $getHtmlContent,C as $getLexicalContent,N as $insertDataTransferForPlainText,_ as $insertDataTransferForRichText,T as $insertGeneratedNodes,O as copyToClipboard}; -+import{$generateHtmlFromNodes as e,$generateNodesFromDOM as t}from"@lexical/html";import{$addNodeStyle as n,$cloneWithProperties as l,$sliceSelectedTextNodeContent as o}from"@lexical/selection";import{objectKlassEquals as r}from"@lexical/utils";import{$getSelection as i,$isRangeSelection as s,$createTabNode as a,SELECTION_INSERT_CLIPBOARD_NODES_COMMAND as c,$getRoot as u,$parseSerializedNode as d,$isTextNode as p,COPY_COMMAND as f,COMMAND_PRIORITY_CRITICAL as m,isSelectionWithinEditor as h,$isElementNode as g}from"lexical";var x=function(e){const t=new URLSearchParams;t.append("code",e);for(let e=1;ew?(e||window).getSelection():null;function v(t){const n=i();return null==n&&x(166),s(n)&&n.isCollapsed()||0===n.getNodes().length?"":e(t,n)}function D(e){const t=i();return null==t&&x(166),s(t)&&t.isCollapsed()||0===t.getNodes().length?null:JSON.stringify(S(e,t))}function C(e,t){const n=e.getData("text/plain")||e.getData("text/uri-list");null!=n&&t.insertRawText(n)}function T(e,n,l,o){const r=e.getData("application/x-lexical-editor");if(r)try{const e=JSON.parse(r);if(e.namespace===l._config.namespace&&Array.isArray(e.nodes)){return N(l,_(e.nodes),n)}}catch(e){}if(!(o&&"insertReplacementText"===o.inputType&&e.types.includes("text/plain"))){const o=e.getData("text/html");if(o)try{const e=(new DOMParser).parseFromString(o,"text/html");return N(l,t(l,e),n)}catch(e){}}const c=e.getData("text/plain")||e.getData("text/uri-list");if(null!=c)if(s(n)){const e=c.split(/(\r?\n|\t)/);""===e[e.length-1]&&e.pop();for(let t=0;t0?u.text=e:i=!1}for(let l=0;l{e.update((()=>{n(P(e,t))}))}));const n=e.getRootElement(),l=null==e._window?window.document:e._window.document,o=y(e._window);if(null===n||null===o)return!1;const i=l.createElement("span");i.style.cssText="position: fixed; top: -1000px;",i.append(l.createTextNode("#")),n.append(i);const s=new Range;return s.setStart(i,0),s.setEnd(i,1),o.removeAllRanges(),o.addRange(s),new Promise(((t,n)=>{const o=e.registerCommand(f,(n=>(r(n,ClipboardEvent)&&(o(),null!==A&&(window.clearTimeout(A),A=null),t(P(e,n))),!0)),m);A=window.setTimeout((()=>{o(),A=null,t(!1)}),50),l.execCommand("copy"),i.remove()}))}function P(e,t){const n=y(e._window);if(!n)return!1;const l=n.anchorNode,o=n.focusNode;if(null!==l&&null!==o&&!h(e,l,o))return!1;t.preventDefault();const r=t.clipboardData,s=i();if(null===r||null===s)return!1;const a=v(e),c=D(e);let u="";return null!==s&&(u=s.getTextContent()),null!==a&&r.setData("text/html",a),null!==c&&r.setData("application/x-lexical-editor",c),r.setData("text/plain",u),!0}export{S as $generateJSONFromSelectedNodes,_ as $generateNodesFromSerializedNodes,v as $getHtmlContent,D as $getLexicalContent,C as $insertDataTransferForPlainText,T as $insertDataTransferForRichText,N as $insertGeneratedNodes,E as copyToClipboard}; -diff --git a/clipboard.d.ts b/clipboard.d.ts -index 99e2138389b64d298a1330d7b354ba87d2e6f24e..83250a4c2049f94e08bfdfc757e03e8a85a08dd4 100644 ---- a/clipboard.d.ts -+++ b/clipboard.d.ts -@@ -44,7 +44,7 @@ export declare function $insertDataTransferForPlainText(dataTransfer: DataTransf - * @param selection the selection to use as the insertion point for the content in the DataTransfer object - * @param editor the LexicalEditor the content is being inserted into. - */ --export declare function $insertDataTransferForRichText(dataTransfer: DataTransfer, selection: BaseSelection, editor: LexicalEditor): void; -+export declare function $insertDataTransferForRichText(dataTransfer: DataTransfer, selection: BaseSelection, editor: LexicalEditor, event?: InputEvent): void; - /** - * Inserts Lexical nodes into the editor using different strategies depending on - * some simple selection-based heuristics. If you're looking for a generic way to diff --git a/.yarn/patches/@lexical-clipboard-npm-0.22.0-e950aa6a7f.patch b/.yarn/patches/@lexical-clipboard-npm-0.22.0-e950aa6a7f.patch new file mode 100644 index 000000000..3bf4bd6fd --- /dev/null +++ b/.yarn/patches/@lexical-clipboard-npm-0.22.0-e950aa6a7f.patch @@ -0,0 +1,134 @@ +diff --git a/LexicalClipboard.dev.js b/LexicalClipboard.dev.js +index 1bc958d606217588101f79ed3706669bb6b398ec..5c4e967e31d660504d41466b62e87449d4925ed2 100644 +--- a/LexicalClipboard.dev.js ++++ b/LexicalClipboard.dev.js +@@ -93,7 +93,7 @@ function $insertDataTransferForPlainText(dataTransfer, selection) { + * @param selection the selection to use as the insertion point for the content in the DataTransfer object + * @param editor the LexicalEditor the content is being inserted into. + */ +-function $insertDataTransferForRichText(dataTransfer, selection, editor) { ++function $insertDataTransferForRichText(dataTransfer, selection, editor, event) { + const lexicalString = dataTransfer.getData('application/x-lexical-editor'); + if (lexicalString) { + try { +@@ -106,15 +106,18 @@ function $insertDataTransferForRichText(dataTransfer, selection, editor) { + // Fail silently. + } + } +- const htmlString = dataTransfer.getData('text/html'); +- if (htmlString) { +- try { +- const parser = new DOMParser(); +- const dom = parser.parseFromString(trustHTML(htmlString), 'text/html'); +- const nodes = html.$generateNodesFromDOM(editor, dom); +- return $insertGeneratedNodes(editor, nodes, selection); +- } catch (_unused2) { +- // Fail silently. ++ const shouldIgnoreHTML = event && event.inputType === 'insertReplacementText' && dataTransfer.types.includes('text/plain'); ++ if (!shouldIgnoreHTML) { ++ const htmlString = dataTransfer.getData('text/html'); ++ if (htmlString) { ++ try { ++ const parser = new DOMParser(); ++ const dom = parser.parseFromString(trustHTML(htmlString), 'text/html'); ++ const nodes = html.$generateNodesFromDOM(editor, dom); ++ return $insertGeneratedNodes(editor, nodes, selection); ++ } catch (_unused2) { ++ // Fail silently. ++ } + } + } + +diff --git a/LexicalClipboard.dev.mjs b/LexicalClipboard.dev.mjs +index fd0c1b790dae92b742d569d62752d2c0b5705236..d00179beebd5d9f396fc3f7ab84745eea8959633 100644 +--- a/LexicalClipboard.dev.mjs ++++ b/LexicalClipboard.dev.mjs +@@ -91,7 +91,7 @@ function $insertDataTransferForPlainText(dataTransfer, selection) { + * @param selection the selection to use as the insertion point for the content in the DataTransfer object + * @param editor the LexicalEditor the content is being inserted into. + */ +-function $insertDataTransferForRichText(dataTransfer, selection, editor) { ++function $insertDataTransferForRichText(dataTransfer, selection, editor, event) { + const lexicalString = dataTransfer.getData('application/x-lexical-editor'); + if (lexicalString) { + try { +@@ -104,15 +104,18 @@ function $insertDataTransferForRichText(dataTransfer, selection, editor) { + // Fail silently. + } + } +- const htmlString = dataTransfer.getData('text/html'); +- if (htmlString) { +- try { +- const parser = new DOMParser(); +- const dom = parser.parseFromString(trustHTML(htmlString), 'text/html'); +- const nodes = $generateNodesFromDOM(editor, dom); +- return $insertGeneratedNodes(editor, nodes, selection); +- } catch (_unused2) { +- // Fail silently. ++ const shouldIgnoreHTML = event && event.inputType === 'insertReplacementText' && dataTransfer.types.includes('text/plain'); ++ if (!shouldIgnoreHTML) { ++ const htmlString = dataTransfer.getData('text/html'); ++ if (htmlString) { ++ try { ++ const parser = new DOMParser(); ++ const dom = parser.parseFromString(trustHTML(htmlString), 'text/html'); ++ const nodes = $generateNodesFromDOM(editor, dom); ++ return $insertGeneratedNodes(editor, nodes, selection); ++ } catch (_unused2) { ++ // Fail silently. ++ } + } + } + +diff --git a/LexicalClipboard.prod.js b/LexicalClipboard.prod.js +index da19707c8c6cfebbfbf4eab94eb4427e81015e01..afe044183dfe347f4da04277e1dd484ad11052fe 100644 +--- a/LexicalClipboard.prod.js ++++ b/LexicalClipboard.prod.js +@@ -6,15 +6,15 @@ + * + */ + +-'use strict';var e=require("@lexical/html"),m=require("@lexical/selection"),n=require("@lexical/utils"),p=require("lexical"),t;function u(a){let b=new URLSearchParams;b.append("code",a);for(let c=1;cb}).createHTML(a):a}function z(a,b,c){a.dispatchCommand(p.SELECTION_INSERT_CLIPBOARD_NODES_COMMAND,{nodes:b,selection:c})||c.insertNodes(b)} +-function A(a,b,c,d=[]){let f=null!==b?c.isSelected(b):!0,k=p.$isElementNode(c)&&c.excludeFromCopy("html");var g=c;if(null!==b){var h=p.$cloneWithProperties(c);g=h=p.$isTextNode(h)&&null!==b?m.$sliceSelectedTextNodeContent(b,h):h}let q=p.$isElementNode(g)?g.getChildren():[];var l=g;h=l.exportJSON();var r=l.constructor;h.type!==r.getType()&&t(58,r.name);p.$isElementNode(l)&&(Array.isArray(h.children)||t(59,r.name));p.$isTextNode(g)&&(g=g.__text,0{a.update(()=>{h(D(a,b,c))})});var d=a.getRootElement();let f=null==a._window?window.document:a._window.document,k=p.getDOMSelection(a._window);if(null===d||null===k)return!1;let g=f.createElement("span");g.style.cssText="position: fixed; top: -1000px;";g.append(f.createTextNode("#"));d.append(g);d=new Range;d.setStart(g,0);d.setEnd(g,1);k.removeAllRanges();k.addRange(d);return new Promise(h=>{let q= +-a.registerCommand(p.COPY_COMMAND,l=>{n.objectKlassEquals(l,ClipboardEvent)&&(q(),null!==C&&(window.clearTimeout(C),C=null),h(D(a,l,c)));return!0},p.COMMAND_PRIORITY_CRITICAL);C=window.setTimeout(()=>{q();C=null;h(!1)},50);f.execCommand("copy");g.remove()})};exports.setLexicalClipboardDataTransfer=F ++exports.$insertDataTransferForRichText=function(a,b,c,d){let h=a.getData("application/x-lexical-editor");if(h)try{let e=JSON.parse(h);if(e.namespace===c._config.namespace&&Array.isArray(e.nodes)){let g=B(e.nodes);return z(c,g,b)}}catch(e){}if(!d||"insertReplacementText"!==d.inputType||!a.types.includes("text/plain"))if(d=a.getData("text/html"))try{var k=(new DOMParser).parseFromString(y(d),"text/html");let e=f.$generateNodesFromDOM(c,k);return z(c,e,b)}catch(e){}a=a.getData("text/plain")||a.getData("text/uri-list"); ++if(null!=a)if(p.$isRangeSelection(b))for(b=a.split(/(\r?\n|\t)/),""===b[b.length-1]&&b.pop(),a=0;a{a.update(()=>{g(D(a,b,c))})});var d=a.getRootElement();let h=null==a._window?window.document:a._window.document,k=p.getDOMSelection(a._window);if(null===d||null===k)return!1;let e=h.createElement("span");e.style.cssText="position: fixed; top: -1000px;";e.append(h.createTextNode("#"));d.append(e);d=new Range;d.setStart(e,0);d.setEnd(e,1);k.removeAllRanges();k.addRange(d);return new Promise(g=>{let q= ++a.registerCommand(p.COPY_COMMAND,l=>{n.objectKlassEquals(l,ClipboardEvent)&&(q(),null!==C&&(window.clearTimeout(C),C=null),g(D(a,l,c)));return!0},p.COMMAND_PRIORITY_CRITICAL);C=window.setTimeout(()=>{q();C=null;g(!1)},50);h.execCommand("copy");e.remove()})};exports.setLexicalClipboardDataTransfer=F +diff --git a/LexicalClipboard.prod.mjs b/LexicalClipboard.prod.mjs +index 0a2b0694926fa9838a417295956bc832a02d5499..68090dd340db822053b4e3ceda8f68e4413c8908 100644 +--- a/LexicalClipboard.prod.mjs ++++ b/LexicalClipboard.prod.mjs +@@ -6,4 +6,4 @@ + * + */ + +-import{$generateHtmlFromNodes as t,$generateNodesFromDOM as e}from"@lexical/html";import{$addNodeStyle as n,$sliceSelectedTextNodeContent as o}from"@lexical/selection";import{objectKlassEquals as r}from"@lexical/utils";import{$isRangeSelection as l,$getSelection as i,$createTabNode as s,SELECTION_INSERT_CLIPBOARD_NODES_COMMAND as c,$getRoot as a,$parseSerializedNode as u,$isTextNode as d,getDOMSelection as f,COPY_COMMAND as p,COMMAND_PRIORITY_CRITICAL as m,isSelectionWithinEditor as h,$getEditor as g,$isElementNode as x,$cloneWithProperties as w}from"lexical";function y(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var T=y((function(t){const e=new URLSearchParams;e.append("code",t);for(let t=1;tt}).createHTML(t)}return t}(c),"text/html");return _(o,e(o,t),n)}catch(t){}const a=t.getData("text/plain")||t.getData("text/uri-list");if(null!=a)if(l(n)){const t=a.split(/(\r?\n|\t)/);""===t[t.length-1]&&t.pop();for(let e=0;e0?a.text=t:l=!1}for(let o=0;o{t.update((()=>{o(E(t,e,n))}))}));const o=t.getRootElement(),l=null==t._window?window.document:t._window.document,i=f(t._window);if(null===o||null===i)return!1;const s=l.createElement("span");s.style.cssText="position: fixed; top: -1000px;",s.append(l.createTextNode("#")),o.append(s);const c=new Range;return c.setStart(s,0),c.setEnd(s,1),i.removeAllRanges(),i.addRange(c),new Promise(((e,o)=>{const i=t.registerCommand(p,(o=>(r(o,ClipboardEvent)&&(i(),null!==S&&(window.clearTimeout(S),S=null),e(E(t,o,n))),!0)),m);S=window.setTimeout((()=>{i(),S=null,e(!1)}),50),l.execCommand("copy"),s.remove()}))}function E(t,e,n){if(void 0===n){const e=f(t._window);if(!e)return!1;const o=e.anchorNode,r=e.focusNode;if(null!==o&&null!==r&&!h(t,o,r))return!1;const l=i();if(null===l)return!1;n=L(l)}e.preventDefault();const o=e.clipboardData;return null!==o&&(b(o,n),!0)}const M=[["text/html",v],["application/x-lexical-editor",C]];function L(t=i()){const e={"text/plain":t?t.getTextContent():""};if(t){const n=g();for(const[o,r]of M){const l=r(n,t);null!==l&&(e[o]=l)}}return e}function b(t,e){for(const n in e){const o=e[n];void 0!==o&&t.setData(n,o)}}export{A as $generateJSONFromSelectedNodes,R as $generateNodesFromSerializedNodes,L as $getClipboardDataFromSelection,v as $getHtmlContent,C as $getLexicalContent,D as $insertDataTransferForPlainText,N as $insertDataTransferForRichText,_ as $insertGeneratedNodes,O as copyToClipboard,b as setLexicalClipboardDataTransfer}; ++import{$generateHtmlFromNodes as t,$generateNodesFromDOM as e}from"@lexical/html";import{$addNodeStyle as n,$sliceSelectedTextNodeContent as o}from"@lexical/selection";import{objectKlassEquals as r}from"@lexical/utils";import{$isRangeSelection as l,$getSelection as i,$createTabNode as s,SELECTION_INSERT_CLIPBOARD_NODES_COMMAND as c,$getRoot as a,$parseSerializedNode as u,$isTextNode as d,getDOMSelection as f,COPY_COMMAND as p,COMMAND_PRIORITY_CRITICAL as m,isSelectionWithinEditor as h,$getEditor as x,$isElementNode as g,$cloneWithProperties as w}from"lexical";function y(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var T=y((function(t){const e=new URLSearchParams;e.append("code",t);for(let t=1;tt}).createHTML(t)}return t}(r),"text/html");return _(o,e(o,t),n)}catch(t){}}const a=t.getData("text/plain")||t.getData("text/uri-list");if(null!=a)if(l(n)){const t=a.split(/(\r?\n|\t)/);""===t[t.length-1]&&t.pop();for(let e=0;e0?a.text=t:l=!1}for(let o=0;o{t.update((()=>{o(E(t,e,n))}))}));const o=t.getRootElement(),l=null==t._window?window.document:t._window.document,i=f(t._window);if(null===o||null===i)return!1;const s=l.createElement("span");s.style.cssText="position: fixed; top: -1000px;",s.append(l.createTextNode("#")),o.append(s);const c=new Range;return c.setStart(s,0),c.setEnd(s,1),i.removeAllRanges(),i.addRange(c),new Promise(((e,o)=>{const i=t.registerCommand(p,(o=>(r(o,ClipboardEvent)&&(i(),null!==S&&(window.clearTimeout(S),S=null),e(E(t,o,n))),!0)),m);S=window.setTimeout((()=>{i(),S=null,e(!1)}),50),l.execCommand("copy"),s.remove()}))}function E(t,e,n){if(void 0===n){const e=f(t._window);if(!e)return!1;const o=e.anchorNode,r=e.focusNode;if(null!==o&&null!==r&&!h(t,o,r))return!1;const l=i();if(null===l)return!1;n=L(l)}e.preventDefault();const o=e.clipboardData;return null!==o&&(b(o,n),!0)}const M=[["text/html",v],["application/x-lexical-editor",C]];function L(t=i()){const e={"text/plain":t?t.getTextContent():""};if(t){const n=x();for(const[o,r]of M){const l=r(n,t);null!==l&&(e[o]=l)}}return e}function b(t,e){for(const n in e){const o=e[n];void 0!==o&&t.setData(n,o)}}export{R as $generateJSONFromSelectedNodes,A as $generateNodesFromSerializedNodes,L as $getClipboardDataFromSelection,v as $getHtmlContent,C as $getLexicalContent,D as $insertDataTransferForPlainText,N as $insertDataTransferForRichText,_ as $insertGeneratedNodes,O as copyToClipboard,b as setLexicalClipboardDataTransfer}; +diff --git a/clipboard.d.ts b/clipboard.d.ts +index 33ee79d61150403f45566839251c5c2950fba8e0..b7a27d5f4700814f55bfc988eead2709e8f2a040 100644 +--- a/clipboard.d.ts ++++ b/clipboard.d.ts +@@ -51,7 +51,7 @@ export declare function $insertDataTransferForPlainText(dataTransfer: DataTransf + * @param selection the selection to use as the insertion point for the content in the DataTransfer object + * @param editor the LexicalEditor the content is being inserted into. + */ +-export declare function $insertDataTransferForRichText(dataTransfer: DataTransfer, selection: BaseSelection, editor: LexicalEditor): void; ++export declare function $insertDataTransferForRichText(dataTransfer: DataTransfer, selection: BaseSelection, editor: LexicalEditor, event?: InputEvent): void; + /** + * Inserts Lexical nodes into the editor using different strategies depending on + * some simple selection-based heuristics. If you're looking for a generic way to diff --git a/.yarn/patches/@lexical-list-npm-0.16.0-8f91da4ad5.patch b/.yarn/patches/@lexical-list-npm-0.16.0-8f91da4ad5.patch deleted file mode 100644 index 2609d36b3..000000000 --- a/.yarn/patches/@lexical-list-npm-0.16.0-8f91da4ad5.patch +++ /dev/null @@ -1,207 +0,0 @@ -diff --git a/LexicalList.dev.js b/LexicalList.dev.js -index 7f753188138466467c456d382ca6147aa38c2cd7..0de169d53da01cb4e1c8688aff81707c46acc844 100644 ---- a/LexicalList.dev.js -+++ b/LexicalList.dev.js -@@ -19,7 +19,6 @@ var utils = require('@lexical/utils'); - * - */ - -- - /** - * Checks the depth of listNode from the root node. - * @param listNode - The ListNode to be checked. -@@ -140,7 +139,6 @@ function $wrapInListItem(node) { - * LICENSE file in the root directory of this source tree. - * - */ -- - function $isSelectingEmptyListItem(anchorNode, nodes) { - return $isListItemNode(anchorNode) && (nodes.length === 0 || nodes.length === 1 && anchorNode.is(nodes[0]) && anchorNode.getChildrenSize() === 0); - } -@@ -569,7 +567,6 @@ function normalizeClassNames(...classNames) { - * LICENSE file in the root directory of this source tree. - * - */ -- - /** @noInheritDoc */ - class ListItemNode extends lexical.ElementNode { - /** @internal */ -@@ -786,7 +783,12 @@ class ListItemNode extends lexical.ElementNode { - } - getChecked() { - const self = this.getLatest(); -- return self.__checked; -+ let listType; -+ const parent = this.getParent(); -+ if ($isListNode(parent)) { -+ listType = parent.getListType(); -+ } -+ return listType === 'check' ? Boolean(self.__checked) : undefined; - } - setChecked(checked) { - const self = this.getWritable(); -@@ -962,7 +964,6 @@ function $isListItemNode(node) { - * LICENSE file in the root directory of this source tree. - * - */ -- - /** @noInheritDoc */ - class ListNode extends lexical.ElementNode { - /** @internal */ -@@ -1240,7 +1241,6 @@ function $isListNode(node) { - * LICENSE file in the root directory of this source tree. - * - */ -- - const INSERT_UNORDERED_LIST_COMMAND = lexical.createCommand('INSERT_UNORDERED_LIST_COMMAND'); - const INSERT_ORDERED_LIST_COMMAND = lexical.createCommand('INSERT_ORDERED_LIST_COMMAND'); - const INSERT_CHECK_LIST_COMMAND = lexical.createCommand('INSERT_CHECK_LIST_COMMAND'); -diff --git a/LexicalList.dev.mjs b/LexicalList.dev.mjs -index 7a8ebf02a30194b0cc37483dda338ebe571c0e05..45378dbc1af36bf87b130087a8c8dee4fddc2ea5 100644 ---- a/LexicalList.dev.mjs -+++ b/LexicalList.dev.mjs -@@ -6,7 +6,7 @@ - * - */ - --import { $getSelection, $isRangeSelection, $isRootOrShadowRoot, $isElementNode, $isLeafNode, $createParagraphNode, $isParagraphNode, ElementNode, $applyNodeReplacement, $createTextNode, createCommand } from 'lexical'; -+import { $getSelection, $isRangeSelection, $isRootOrShadowRoot, $isElementNode, $isLeafNode, $createParagraphNode, $isParagraphNode, $applyNodeReplacement, ElementNode, $createTextNode, createCommand } from 'lexical'; - import { $getNearestNodeOfType, removeClassNamesFromElement, addClassNamesToElement, isHTMLElement } from '@lexical/utils'; - - /** -@@ -17,7 +17,6 @@ import { $getNearestNodeOfType, removeClassNamesFromElement, addClassNamesToElem - * - */ - -- - /** - * Checks the depth of listNode from the root node. - * @param listNode - The ListNode to be checked. -@@ -138,7 +137,6 @@ function $wrapInListItem(node) { - * LICENSE file in the root directory of this source tree. - * - */ -- - function $isSelectingEmptyListItem(anchorNode, nodes) { - return $isListItemNode(anchorNode) && (nodes.length === 0 || nodes.length === 1 && anchorNode.is(nodes[0]) && anchorNode.getChildrenSize() === 0); - } -@@ -567,7 +565,6 @@ function normalizeClassNames(...classNames) { - * LICENSE file in the root directory of this source tree. - * - */ -- - /** @noInheritDoc */ - class ListItemNode extends ElementNode { - /** @internal */ -@@ -784,7 +781,12 @@ class ListItemNode extends ElementNode { - } - getChecked() { - const self = this.getLatest(); -- return self.__checked; -+ let listType; -+ const parent = this.getParent(); -+ if ($isListNode(parent)) { -+ listType = parent.getListType(); -+ } -+ return listType === 'check' ? Boolean(self.__checked) : undefined; - } - setChecked(checked) { - const self = this.getWritable(); -@@ -960,7 +962,6 @@ function $isListItemNode(node) { - * LICENSE file in the root directory of this source tree. - * - */ -- - /** @noInheritDoc */ - class ListNode extends ElementNode { - /** @internal */ -@@ -1238,7 +1239,6 @@ function $isListNode(node) { - * LICENSE file in the root directory of this source tree. - * - */ -- - const INSERT_UNORDERED_LIST_COMMAND = createCommand('INSERT_UNORDERED_LIST_COMMAND'); - const INSERT_ORDERED_LIST_COMMAND = createCommand('INSERT_ORDERED_LIST_COMMAND'); - const INSERT_CHECK_LIST_COMMAND = createCommand('INSERT_CHECK_LIST_COMMAND'); -diff --git a/LexicalList.prod.js b/LexicalList.prod.js -index a012b092aec19492d69038cf096963f52e466e1c..892463169ff1bb89fdefcafab31ea6c75c9ec35b 100644 ---- a/LexicalList.prod.js -+++ b/LexicalList.prod.js -@@ -6,35 +6,36 @@ - * - */ - --'use strict';var g=require("lexical"),h=require("@lexical/utils"),l;function n(a){let b=new URLSearchParams;b.append("code",a);for(let c=1;cf.append(k));d=y();e=E(e);d.append(e);A(e,a.getNextSiblings());c.insertBefore(b);c.insertAfter(d);c.replace(a)}}}} --function H(...a){let b=[];for(let c of a)if(c&&"string"===typeof c)for(let [d]of c.matchAll(/\S+/g))b.push(d);return b} --class I extends g.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();r(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();r(d)&&"check"===d.getListType()&&J(b,this,a);b.value=this.__value;K(b,c.theme,this);return!1}static transform(){return a=> --{q(a)||l(144);if(null!=a.__checked){var b=a.getParent();r(b)&&"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){let c=this.getParentOrThrow();r(c)||l(39);if(q(a))return super.insertAfter(a,b);let 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&&v(b)&&v(c)&&(F(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=g.$createParagraphNode();this.getChildren().forEach(f=>b.append(f));var c=this.getParentOrThrow(),d=c.getParentOrThrow();let e=q(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(;q(a);)a=a.getParentOrThrow().getParentOrThrow(), --b++;return b}setIndent(a){"number"===typeof a&&-1r(m))?d.push(...k):e.push(...k));0{r(a)||l(163);var b=a.getNextSibling();r(b)&&a.getListType()===b.getListType()&&F(a,b);b="check"!==a.getListType();let c=a.getStart();for(let d of a.getChildren())q(d)&&(d.getValue()!==c&&d.setValue(c),b&&null!=d.getChecked()&&d.setChecked(void 0),r(d.getFirstChild())||c++)}}static importDOM(){return{ol:()=>({conversion:R, --priority:0}),ul:()=>({conversion:R,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&&h.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{r(e)&&b.push(x(e))})):b.push(x(c))}return b} --function R(a){let b=a.nodeName.toLowerCase(),c=null;if("ol"===b)c=E("number",a.start);else if("ul"===b){a:if("check"===a.getAttribute("__lexicallisttype")||a.classList.contains("contains-task-list"))a=!0;else{for(let d of a.childNodes)if(h.isHTMLElement(d)&&d.hasAttribute("aria-checked")){a=!0;break a}a=!1}c=a?E("check"):E("bullet")}return{after:S,node:c}}let P={ol:"number",ul:"bullet"};function E(a,b=1){return g.$applyNodeReplacement(new M(a,b))}function r(a){return a instanceof M} --let T=g.createCommand("INSERT_UNORDERED_LIST_COMMAND"),U=g.createCommand("INSERT_ORDERED_LIST_COMMAND"),V=g.createCommand("INSERT_CHECK_LIST_COMMAND"),W=g.createCommand("REMOVE_LIST_COMMAND");exports.$createListItemNode=y;exports.$createListNode=E;exports.$getListDepth=p; --exports.$handleListInsertParagraph=function(){var a=g.$getSelection();if(!g.$isRangeSelection(a)||!a.isCollapsed())return!1;a=a.anchor.getNode();if(!q(a)||0!==a.getChildrenSize())return!1;var b=t(a),c=a.getParent();r(c)||l(40);let d=c.getParent(),e;if(g.$isRootOrShadowRoot(d))e=g.$createParagraphNode(),b.insertAfter(e);else if(q(d))e=y(),d.insertAfter(e);else return!1;e.select();b=a.getNextSiblings();if(0{k.remove();f.append(k)})}w(a);return!0};exports.$isListItemNode=q;exports.$isListNode=r;exports.INSERT_CHECK_LIST_COMMAND=V;exports.INSERT_ORDERED_LIST_COMMAND=U;exports.INSERT_UNORDERED_LIST_COMMAND=T;exports.ListItemNode=I;exports.ListNode=M;exports.REMOVE_LIST_COMMAND=W; --exports.insertList=function(a,b){a.update(()=>{var c=g.$getSelection();if(null!==c){var d=c.getNodes();if(g.$isRangeSelection(c)){c=c.getStartEndPoints();null===c&&l(143);[c]=c;c=c.getNode();var e=c.getParent();if(z(c,d)){d=E(b);g.$isRootOrShadowRoot(e)?(c.replace(d),e=y(),g.$isElementNode(c)&&(e.setFormat(c.getFormatType()),e.setIndent(c.getIndent())),d.append(e)):q(c)&&(c=c.getParentOrThrow(),A(d,c.getChildren()),c.replace(d));return}}c=new Set;for(e=0;e{let b=g.$getSelection();if(g.$isRangeSelection(b)){var c=new Set,d=b.getNodes(),e=b.anchor.getNode();if(z(e,d))c.add(t(e));else for(e=0;ef.append(k));d=x();e=D(e);d.append(e);z(e,a.getNextSiblings());c.insertBefore(b);c.insertAfter(d);c.replace(a)}}}} -+function G(...a){let b=[];for(let c of a)if(c&&"string"===typeof c)for(let [d]of c.matchAll(/\S+/g))b.push(d);return b} -+class H extends g.ElementNode{static getType(){return"listitem"}static clone(a){return new H(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()&&I(b,this,null);b.value=this.__value;J(b,a.theme,this);return b}updateDOM(a,b,c){let d=this.getParent();q(d)&&"check"===d.getListType()&&I(b,this,a);b.value=this.__value;J(b,c.theme,this);return!1}static transform(){return a=> -+{p(a)||l(144);if(null!=a.__checked){var b=a.getParent();q(b)&&"check"!==b.getListType()&&null!=a.getChecked()&&a.setChecked(void 0)}}}static importDOM(){return{li:()=>({conversion:K,priority:0})}}static importJSON(a){let b=x();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){let c=this.getParentOrThrow();q(c)||l(39);if(p(a))return super.insertAfter(a,b);let d=this.getNextSiblings();c.insertAfter(a,b);if(0!==d.length){let e=D(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)&&(E(b.getFirstChild(),c.getFirstChild()),c.remove())}insertNewAfter(a,b=!0){a=x(null==this.__checked?void 0:!1);this.insertAfter(a,b);return a}collapseAtStart(a){let b=g.$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(){let a=this.getLatest(),b,c=this.getParent();q(c)&&(b=c.getListType());return"check"===b?!!a.__checked:void 0}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(...k):e.push(...k));0{q(a)||l(163);var b=a.getNextSibling();q(b)&&a.getListType()===b.getListType()&&E(a,b);b="check"!==a.getListType();let c=a.getStart();for(let d of a.getChildren())p(d)&&(d.getValue()!==c&&d.setValue(c),b&&null!=d.getChecked()&&d.setChecked(void 0),q(d.getFirstChild())||c++)}}static importDOM(){return{ol:()=>({conversion:Q, -+priority:0}),ul:()=>({conversion:Q,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&&h.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;if("ol"===b)c=D("number",a.start);else if("ul"===b){a:if("check"===a.getAttribute("__lexicallisttype")||a.classList.contains("contains-task-list"))a=!0;else{for(let d of a.childNodes)if(h.isHTMLElement(d)&&d.hasAttribute("aria-checked")){a=!0;break a}a=!1}c=a?D("check"):D("bullet")}return{after:R,node:c}}let O={ol:"number",ul:"bullet"};function D(a,b=1){return g.$applyNodeReplacement(new L(a,b))}function q(a){return a instanceof L} -+let S=g.createCommand("INSERT_UNORDERED_LIST_COMMAND"),T=g.createCommand("INSERT_ORDERED_LIST_COMMAND"),U=g.createCommand("INSERT_CHECK_LIST_COMMAND"),V=g.createCommand("REMOVE_LIST_COMMAND");exports.$createListItemNode=x;exports.$createListNode=D;exports.$getListDepth=n; -+exports.$handleListInsertParagraph=function(){var a=g.$getSelection();if(!g.$isRangeSelection(a)||!a.isCollapsed())return!1;a=a.anchor.getNode();if(!p(a)||0!==a.getChildrenSize())return!1;var b=r(a),c=a.getParent();q(c)||l(40);let d=c.getParent(),e;if(g.$isRootOrShadowRoot(d))e=g.$createParagraphNode(),b.insertAfter(e);else if(p(d))e=x(),d.insertAfter(e);else return!1;e.select();b=a.getNextSiblings();if(0{k.remove();f.append(k)})}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=H;exports.ListNode=L;exports.REMOVE_LIST_COMMAND=V; -+exports.insertList=function(a,b){a.update(()=>{var c=g.$getSelection();if(null!==c){var d=c.getNodes();if(g.$isRangeSelection(c)){c=c.getStartEndPoints();null===c&&l(143);[c]=c;c=c.getNode();var e=c.getParent();if(y(c,d)){d=D(b);g.$isRootOrShadowRoot(e)?(c.replace(d),e=x(),g.$isElementNode(c)&&(e.setFormat(c.getFormatType()),e.setIndent(c.getIndent())),d.append(e)):p(c)&&(c=c.getParentOrThrow(),z(d,c.getChildren()),c.replace(d));return}}c=new Set;for(e=0;e{let b=g.$getSelection();if(g.$isRangeSelection(b)){var c=new Set,d=b.getNodes(),e=b.anchor.getNode();if(y(e,d))c.add(r(e));else for(e=0;e{const s=e();if(null!==s){const e=s.getNodes();if(t(s)){const t=s.getStartEndPoints();null===t&&_(143);const[i]=t,c=i.getNode(),l=c.getParent();if(T(c,e)){const e=U(o);if(n(l)){c.replace(e);const t=R();r(c)&&(t.setFormat(c.getFormatType()),t.setIndent(c.getIndent())),e.append(t)}else if(K(c)){const t=c.getParentOrThrow();S(e,t.getChildren()),t.replace(e)}return}}const c=new Set;for(let t=0;t0&&e.append(...i),t.remove()}function N(n){n.update((()=>{const n=e();if(t(n)){const e=new Set,t=n.getNodes(),r=n.anchor.getNode();if(T(r,t))e.add(v(r));else for(let n=0;ns.append(e)));const o=R(),c=U(r);o.append(c),S(c,e.getNextSiblings()),n.insertBefore(i),n.insertAfter(o),n.replace(e)}}}function L(){const r=e();if(!t(r)||!r.isCollapsed())return!1;const i=r.anchor.getNode();if(!K(i)||0!==i.getChildrenSize())return!1;const c=v(i),l=i.getParent();$(l)||_(40);const a=l.getParent();let h;if(n(a))h=s(),c.insertAfter(h);else{if(!K(a))return!1;h=R(),a.insertAfter(h)}h.select();const u=i.getNextSiblings();if(u.length>0){const e=U(l.getListType());if(o(h))h.insertAfter(e);else{const t=R();t.append(e),h.insertAfter(t)}u.forEach((t=>{t.remove(),e.append(t)}))}return function(e){let t=e;for(;null==t.getNextSibling()&&null==t.getPreviousSibling();){const e=t.getParent();if(null==e||!K(t)&&!$(t))break;t=e}t.remove()}(i),!0}function E(...e){const t=[];for(const n of e)if(n&&"string"==typeof n)for(const[e]of n.matchAll(/\S+/g))t.push(e);return t}class F extends c{static getType(){return"listitem"}static clone(e){return new F(e.__value,e.__checked,e.__key)}constructor(e,t,n){super(n),this.__value=void 0===e?1:e,this.__checked=t}createDOM(e){const t=document.createElement("li"),n=this.getParent();return $(n)&&"check"===n.getListType()&&w(t,this,null),t.value=this.__value,M(t,e.theme,this),t}updateDOM(e,t,n){const r=this.getParent();return $(r)&&"check"===r.getListType()&&w(t,this,e),t.value=this.__value,M(t,n.theme,this),!1}static transform(){return e=>{if(K(e)||_(144),null==e.__checked)return;const t=e.getParent();$(t)&&"check"!==t.getListType()&&null!=e.getChecked()&&e.setChecked(void 0)}}static importDOM(){return{li:()=>({conversion:D,priority:0})}}static importJSON(e){const t=R();return t.setChecked(e.checked),t.setValue(e.value),t.setFormat(e.format),t.setDirection(e.direction),t}exportDOM(e){const t=this.createDOM(e._config);return t.style.textAlign=this.getFormatType(),{element:t}}exportJSON(){return{...super.exportJSON(),checked:this.getChecked(),type:"listitem",value:this.getValue(),version:1}}append(...e){for(let t=0;t{e.append(t)}))),this.remove(),0===n.getChildrenSize()&&n.remove(),e}insertAfter(e,t=!0){const n=this.getParentOrThrow();if($(n)||_(39),K(e))return super.insertAfter(e,t);const r=this.getNextSiblings();if(n.insertAfter(e,t),0!==r.length){const i=U(n.getListType());r.forEach((e=>i.append(e))),e.insertAfter(i,t)}return e}remove(e){const t=this.getPreviousSibling(),n=this.getNextSibling();super.remove(e),t&&n&&C(t)&&C(n)&&(A(t.getFirstChild(),n.getFirstChild()),n.remove())}insertNewAfter(e,t=!0){const n=R(null==this.__checked&&void 0);return this.insertAfter(n,t),n}collapseAtStart(e){const t=s();this.getChildren().forEach((e=>t.append(e)));const n=this.getParentOrThrow(),r=n.getParentOrThrow(),i=K(r);if(1===n.getChildrenSize())if(i)n.remove(),r.select();else{n.insertBefore(t),n.remove();const r=e.anchor,i=e.focus,s=t.getKey();"element"===r.type&&r.getNode().is(this)&&r.set(s,r.offset,"element"),"element"===i.type&&i.getNode().is(this)&&i.set(s,i.offset,"element")}else n.insertBefore(t),this.remove();return!0}getValue(){return this.getLatest().__value}setValue(e){this.getWritable().__value=e}getChecked(){return this.getLatest().__checked}setChecked(e){this.getWritable().__checked=e}toggleChecked(){this.setChecked(!this.__checked)}getIndent(){const e=this.getParent();if(null===e)return this.getLatest().__indent;let t=e.getParentOrThrow(),n=0;for(;K(t);)t=t.getParentOrThrow().getParentOrThrow(),n++;return n}setIndent(e){"number"==typeof e&&e>-1||_(117);let t=this.getIndent();for(;t!==e;)t$(e)))?r.push(...e):i.push(...e)}i.length>0&&g(e,...i),r.length>0&&f(e,...r)}function w(e,t,n,r){$(t.getFirstChild())?(e.removeAttribute("role"),e.removeAttribute("tabIndex"),e.removeAttribute("aria-checked")):(e.setAttribute("role","checkbox"),e.setAttribute("tabIndex","-1"),n&&t.__checked===n.__checked||e.setAttribute("aria-checked",t.getChecked()?"true":"false"))}function D(e){if(e.classList.contains("task-list-item"))for(const t of e.children)if("INPUT"===t.tagName)return I(t);const t=e.getAttribute("aria-checked");return{node:R("true"===t||"false"!==t&&void 0)}}function I(e){if(!("checkbox"===e.getAttribute("type")))return{node:null};return{node:R(e.hasAttribute("checked"))}}function R(e){return l(new F(void 0,e))}function K(e){return e instanceof F}class B extends c{static getType(){return"list"}static clone(e){const t=e.__listType||z[e.__tag];return new B(t,e.__start,e.__key)}constructor(e,t,n){super(n);const r=z[e]||e;this.__listType=r,this.__tag="number"===r?"ol":"ul",this.__start=t}getTag(){return this.__tag}setListType(e){const t=this.getWritable();t.__listType=e,t.__tag="number"===e?"ol":"ul"}getListType(){return this.__listType}getStart(){return this.__start}createDOM(e,t){const n=this.__tag,r=document.createElement(n);return 1!==this.__start&&r.setAttribute("start",String(this.__start)),r.__lexicalListType=this.__listType,W(r,e.theme,this),r}updateDOM(e,t,n){return e.__tag!==this.__tag||(W(t,n.theme,this),!1)}static transform(){return e=>{$(e)||_(163),function(e){const t=e.getNextSibling();$(t)&&e.getListType()===t.getListType()&&A(e,t)}(e),function(e){const t="check"!==e.getListType();let n=e.getStart();for(const r of e.getChildren())K(r)&&(r.getValue()!==n&&r.setValue(n),t&&null!=r.getChecked()&&r.setChecked(void 0),$(r.getFirstChild())||n++)}(e)}}static importDOM(){return{ol:()=>({conversion:J,priority:0}),ul:()=>({conversion:J,priority:0})}}static importJSON(e){const t=U(e.listType,e.start);return t.setFormat(e.format),t.setIndent(e.indent),t.setDirection(e.direction),t}exportDOM(e){const{element:t}=super.exportDOM(e);return t&&d(t)&&(1!==this.__start&&t.setAttribute("start",String(this.__start)),"check"===this.__listType&&t.setAttribute("__lexicalListType","check")),{element:t}}exportJSON(){return{...super.exportJSON(),listType:this.getListType(),start:this.getStart(),tag:this.getTag(),type:"list",version:1}}canBeEmpty(){return!1}canIndent(){return!1}append(...e){for(let t=0;t1?r.push(...e):i.push(...e)}}i.length>0&&g(e,...i),r.length>0&&f(e,...r)}function V(e){const t=[];for(let n=0;n1&&e.forEach((e=>{$(e)&&t.push(k(e))}))}else t.push(k(r))}return t}function J(e){const t=e.nodeName.toLowerCase();let n=null;if("ol"===t){n=U("number",e.start)}else"ul"===t&&(n=function(e){if("check"===e.getAttribute("__lexicallisttype")||e.classList.contains("contains-task-list"))return!0;for(const t of e.childNodes)if(d(t)&&t.hasAttribute("aria-checked"))return!0;return!1}(e)?U("check"):U("bullet"));return{after:V,node:n}}const z={ol:"number",ul:"bullet"};function U(e,t=1){return l(new B(e,t))}function $(e){return e instanceof B}const j=h("INSERT_UNORDERED_LIST_COMMAND"),q=h("INSERT_ORDERED_LIST_COMMAND"),H=h("INSERT_CHECK_LIST_COMMAND"),G=h("REMOVE_LIST_COMMAND");export{R as $createListItemNode,U as $createListNode,m as $getListDepth,L as $handleListInsertParagraph,K as $isListItemNode,$ as $isListNode,H as INSERT_CHECK_LIST_COMMAND,q as INSERT_ORDERED_LIST_COMMAND,j as INSERT_UNORDERED_LIST_COMMAND,F as ListItemNode,B as ListNode,G as REMOVE_LIST_COMMAND,b as insertList,N as removeList}; -+import{$getSelection as e,$isRangeSelection as t,$isRootOrShadowRoot as n,$isElementNode as r,$isLeafNode as i,$createParagraphNode as s,$isParagraphNode as o,$applyNodeReplacement as c,ElementNode as l,$createTextNode as h,createCommand as a}from"lexical";import{$getNearestNodeOfType as u,removeClassNamesFromElement as g,addClassNamesToElement as f,isHTMLElement as d}from"@lexical/utils";var p=function(e){const t=new URLSearchParams;t.append("code",e);for(let e=1;e{const s=e();if(null!==s){const e=s.getNodes();if(t(s)){const t=s.getStartEndPoints();null===t&&p(143);const[i]=t,c=i.getNode(),l=c.getParent();if(k(c,e)){const e=z(o);if(n(l)){c.replace(e);const t=I();r(c)&&(t.setFormat(c.getFormatType()),t.setIndent(c.getIndent())),e.append(t)}else if(R(c)){const t=c.getParentOrThrow();b(e,t.getChildren()),t.replace(e)}return}}const c=new Set;for(let t=0;t0&&e.append(...i),t.remove()}function A(n){n.update((()=>{const n=e();if(t(n)){const e=new Set,t=n.getNodes(),r=n.anchor.getNode();if(k(r,t))e.add(m(r));else for(let n=0;ns.append(e)));const o=I(),c=z(r);o.append(c),b(c,e.getNextSiblings()),n.insertBefore(i),n.insertAfter(o),n.replace(e)}}}function L(){const r=e();if(!t(r)||!r.isCollapsed())return!1;const i=r.anchor.getNode();if(!R(i)||0!==i.getChildrenSize())return!1;const c=m(i),l=i.getParent();U(l)||p(40);const h=l.getParent();let a;if(n(h))a=s(),c.insertAfter(a);else{if(!R(h))return!1;a=I(),h.insertAfter(a)}a.select();const u=i.getNextSiblings();if(u.length>0){const e=z(l.getListType());if(o(a))a.insertAfter(e);else{const t=I();t.append(e),a.insertAfter(t)}u.forEach((t=>{t.remove(),e.append(t)}))}return function(e){let t=e;for(;null==t.getNextSibling()&&null==t.getPreviousSibling();){const e=t.getParent();if(null==e||!R(t)&&!U(t))break;t=e}t.remove()}(i),!0}function O(...e){const t=[];for(const n of e)if(n&&"string"==typeof n)for(const[e]of n.matchAll(/\S+/g))t.push(e);return t}class E extends l{static getType(){return"listitem"}static clone(e){return new E(e.__value,e.__checked,e.__key)}constructor(e,t,n){super(n),this.__value=void 0===e?1:e,this.__checked=t}createDOM(e){const t=document.createElement("li"),n=this.getParent();return U(n)&&"check"===n.getListType()&&M(t,this,null),t.value=this.__value,F(t,e.theme,this),t}updateDOM(e,t,n){const r=this.getParent();return U(r)&&"check"===r.getListType()&&M(t,this,e),t.value=this.__value,F(t,n.theme,this),!1}static transform(){return e=>{if(R(e)||p(144),null==e.__checked)return;const t=e.getParent();U(t)&&"check"!==t.getListType()&&null!=e.getChecked()&&e.setChecked(void 0)}}static importDOM(){return{li:()=>({conversion:w,priority:0})}}static importJSON(e){const t=I();return t.setChecked(e.checked),t.setValue(e.value),t.setFormat(e.format),t.setDirection(e.direction),t}exportDOM(e){const t=this.createDOM(e._config);return t.style.textAlign=this.getFormatType(),{element:t}}exportJSON(){return{...super.exportJSON(),checked:this.getChecked(),type:"listitem",value:this.getValue(),version:1}}append(...e){for(let t=0;t{e.append(t)}))),this.remove(),0===n.getChildrenSize()&&n.remove(),e}insertAfter(e,t=!0){const n=this.getParentOrThrow();if(U(n)||p(39),R(e))return super.insertAfter(e,t);const r=this.getNextSiblings();if(n.insertAfter(e,t),0!==r.length){const i=z(n.getListType());r.forEach((e=>i.append(e))),e.insertAfter(i,t)}return e}remove(e){const t=this.getPreviousSibling(),n=this.getNextSibling();super.remove(e),t&&n&&y(t)&&y(n)&&(P(t.getFirstChild(),n.getFirstChild()),n.remove())}insertNewAfter(e,t=!0){const n=I(null==this.__checked&&void 0);return this.insertAfter(n,t),n}collapseAtStart(e){const t=s();this.getChildren().forEach((e=>t.append(e)));const n=this.getParentOrThrow(),r=n.getParentOrThrow(),i=R(r);if(1===n.getChildrenSize())if(i)n.remove(),r.select();else{n.insertBefore(t),n.remove();const r=e.anchor,i=e.focus,s=t.getKey();"element"===r.type&&r.getNode().is(this)&&r.set(s,r.offset,"element"),"element"===i.type&&i.getNode().is(this)&&i.set(s,i.offset,"element")}else n.insertBefore(t),this.remove();return!0}getValue(){return this.getLatest().__value}setValue(e){this.getWritable().__value=e}getChecked(){const e=this.getLatest();let t;const n=this.getParent();return U(n)&&(t=n.getListType()),"check"===t?Boolean(e.__checked):void 0}setChecked(e){this.getWritable().__checked=e}toggleChecked(){this.setChecked(!this.__checked)}getIndent(){const e=this.getParent();if(null===e)return this.getLatest().__indent;let t=e.getParentOrThrow(),n=0;for(;R(t);)t=t.getParentOrThrow().getParentOrThrow(),n++;return n}setIndent(e){"number"==typeof e&&e>-1||p(117);let t=this.getIndent();for(;t!==e;)tU(e)))?r.push(...e):i.push(...e)}i.length>0&&g(e,...i),r.length>0&&f(e,...r)}function M(e,t,n,r){U(t.getFirstChild())?(e.removeAttribute("role"),e.removeAttribute("tabIndex"),e.removeAttribute("aria-checked")):(e.setAttribute("role","checkbox"),e.setAttribute("tabIndex","-1"),n&&t.__checked===n.__checked||e.setAttribute("aria-checked",t.getChecked()?"true":"false"))}function w(e){if(e.classList.contains("task-list-item"))for(const t of e.children)if("INPUT"===t.tagName)return D(t);const t=e.getAttribute("aria-checked");return{node:I("true"===t||"false"!==t&&void 0)}}function D(e){if(!("checkbox"===e.getAttribute("type")))return{node:null};return{node:I(e.hasAttribute("checked"))}}function I(e){return c(new E(void 0,e))}function R(e){return e instanceof E}class B extends l{static getType(){return"list"}static clone(e){const t=e.__listType||J[e.__tag];return new B(t,e.__start,e.__key)}constructor(e,t,n){super(n);const r=J[e]||e;this.__listType=r,this.__tag="number"===r?"ol":"ul",this.__start=t}getTag(){return this.__tag}setListType(e){const t=this.getWritable();t.__listType=e,t.__tag="number"===e?"ol":"ul"}getListType(){return this.__listType}getStart(){return this.__start}createDOM(e,t){const n=this.__tag,r=document.createElement(n);return 1!==this.__start&&r.setAttribute("start",String(this.__start)),r.__lexicalListType=this.__listType,K(r,e.theme,this),r}updateDOM(e,t,n){return e.__tag!==this.__tag||(K(t,n.theme,this),!1)}static transform(){return e=>{U(e)||p(163),function(e){const t=e.getNextSibling();U(t)&&e.getListType()===t.getListType()&&P(e,t)}(e),function(e){const t="check"!==e.getListType();let n=e.getStart();for(const r of e.getChildren())R(r)&&(r.getValue()!==n&&r.setValue(n),t&&null!=r.getChecked()&&r.setChecked(void 0),U(r.getFirstChild())||n++)}(e)}}static importDOM(){return{ol:()=>({conversion:V,priority:0}),ul:()=>({conversion:V,priority:0})}}static importJSON(e){const t=z(e.listType,e.start);return t.setFormat(e.format),t.setIndent(e.indent),t.setDirection(e.direction),t}exportDOM(e){const{element:t}=super.exportDOM(e);return t&&d(t)&&(1!==this.__start&&t.setAttribute("start",String(this.__start)),"check"===this.__listType&&t.setAttribute("__lexicalListType","check")),{element:t}}exportJSON(){return{...super.exportJSON(),listType:this.getListType(),start:this.getStart(),tag:this.getTag(),type:"list",version:1}}canBeEmpty(){return!1}canIndent(){return!1}append(...e){for(let t=0;t1?r.push(...e):i.push(...e)}}i.length>0&&g(e,...i),r.length>0&&f(e,...r)}function W(e){const t=[];for(let n=0;n1&&e.forEach((e=>{U(e)&&t.push(C(e))}))}else t.push(C(r))}return t}function V(e){const t=e.nodeName.toLowerCase();let n=null;if("ol"===t){n=z("number",e.start)}else"ul"===t&&(n=function(e){if("check"===e.getAttribute("__lexicallisttype")||e.classList.contains("contains-task-list"))return!0;for(const t of e.childNodes)if(d(t)&&t.hasAttribute("aria-checked"))return!0;return!1}(e)?z("check"):z("bullet"));return{after:W,node:n}}const J={ol:"number",ul:"bullet"};function z(e,t=1){return c(new B(e,t))}function U(e){return e instanceof B}const $=a("INSERT_UNORDERED_LIST_COMMAND"),q=a("INSERT_ORDERED_LIST_COMMAND"),H=a("INSERT_CHECK_LIST_COMMAND"),j=a("REMOVE_LIST_COMMAND");export{I as $createListItemNode,z as $createListNode,_ as $getListDepth,L as $handleListInsertParagraph,R as $isListItemNode,U as $isListNode,H as INSERT_CHECK_LIST_COMMAND,q as INSERT_ORDERED_LIST_COMMAND,$ as INSERT_UNORDERED_LIST_COMMAND,E as ListItemNode,B as ListNode,j as REMOVE_LIST_COMMAND,T as insertList,A as removeList}; diff --git a/.yarn/patches/@lexical-rich-text-npm-0.16.0-f484a17832.patch b/.yarn/patches/@lexical-rich-text-npm-0.16.0-f484a17832.patch deleted file mode 100644 index c65fc5e5c..000000000 --- a/.yarn/patches/@lexical-rich-text-npm-0.16.0-f484a17832.patch +++ /dev/null @@ -1,158 +0,0 @@ -diff --git a/LexicalRichText.dev.js b/LexicalRichText.dev.js -index a23f1faaf3da195b193a51e084a5cd2937dda6dc..fbfdc9c3fbb5d5934ad334989bc09f09d76a4d60 100644 ---- a/LexicalRichText.dev.js -+++ b/LexicalRichText.dev.js -@@ -65,15 +65,20 @@ const CAN_USE_DOM = typeof window !== 'undefined' && typeof window.document !== - * LICENSE file in the root directory of this source tree. - * - */ -- - const documentMode = CAN_USE_DOM && 'documentMode' in document ? document.documentMode : null; -+CAN_USE_DOM && /Mac|iPod|iPhone|iPad/.test(navigator.platform); -+CAN_USE_DOM && /^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent); - const CAN_USE_BEFORE_INPUT = CAN_USE_DOM && 'InputEvent' in window && !documentMode ? 'getTargetRanges' in new window.InputEvent('input') : false; - const IS_SAFARI = CAN_USE_DOM && /Version\/[\d.]+.*Safari/.test(navigator.userAgent); - const IS_IOS = CAN_USE_DOM && /iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream; -+const IS_ANDROID = CAN_USE_DOM && /Android/.test(navigator.userAgent); - - // Keep these in case we need to use them in the future. - // export const IS_WINDOWS: boolean = CAN_USE_DOM && /Win/.test(navigator.platform); - const IS_CHROME = CAN_USE_DOM && /^(?=.*Chrome).*/i.test(navigator.userAgent); -+// export const canUseTextInputEvent: boolean = CAN_USE_DOM && 'TextEvent' in window && !documentMode; -+ -+CAN_USE_DOM && IS_ANDROID && IS_CHROME; - const IS_APPLE_WEBKIT = CAN_USE_DOM && /AppleWebKit\/[\d.]+/.test(navigator.userAgent) && !IS_CHROME; - - /** -@@ -83,7 +88,6 @@ const IS_APPLE_WEBKIT = CAN_USE_DOM && /AppleWebKit\/[\d.]+/.test(navigator.user - * LICENSE file in the root directory of this source tree. - * - */ -- - const DRAG_DROP_PASTE = lexical.createCommand('DRAG_DROP_PASTE_FILE'); - /** @noInheritDoc */ - class QuoteNode extends lexical.ElementNode { -@@ -470,7 +474,7 @@ function registerRichText(editor) { - } - const dataTransfer = eventOrText.dataTransfer; - if (dataTransfer != null) { -- clipboard.$insertDataTransferForRichText(dataTransfer, selection, editor); -+ clipboard.$insertDataTransferForRichText(dataTransfer, selection, editor, eventOrText); - } else if (lexical.$isRangeSelection(selection)) { - const data = eventOrText.data; - if (data) { -diff --git a/LexicalRichText.dev.mjs b/LexicalRichText.dev.mjs -index 3b2880f2f7a6db47c61ab8df357d773371cc9a1c..667cf49bf0ac8a1fc3ae347f991420b3103be811 100644 ---- a/LexicalRichText.dev.mjs -+++ b/LexicalRichText.dev.mjs -@@ -9,7 +9,7 @@ - import { $insertDataTransferForRichText, copyToClipboard } from '@lexical/clipboard'; - import { $shouldOverrideDefaultCharacterSelection, $moveCharacter } from '@lexical/selection'; - import { addClassNamesToElement, isHTMLElement, objectKlassEquals, mergeRegister, $findMatchingParent, $getNearestBlockElementAncestorOrThrow } from '@lexical/utils'; --import { createCommand, ElementNode, $createParagraphNode, $applyNodeReplacement, CLICK_COMMAND, $getSelection, $isNodeSelection, DELETE_CHARACTER_COMMAND, $isRangeSelection, COMMAND_PRIORITY_EDITOR, DELETE_WORD_COMMAND, DELETE_LINE_COMMAND, CONTROLLED_TEXT_INSERTION_COMMAND, REMOVE_TEXT_COMMAND, FORMAT_TEXT_COMMAND, FORMAT_ELEMENT_COMMAND, $isElementNode, INSERT_LINE_BREAK_COMMAND, INSERT_PARAGRAPH_COMMAND, INSERT_TAB_COMMAND, $insertNodes, $createTabNode, INDENT_CONTENT_COMMAND, OUTDENT_CONTENT_COMMAND, KEY_ARROW_UP_COMMAND, $getAdjacentNode, $isDecoratorNode, KEY_ARROW_DOWN_COMMAND, KEY_ARROW_LEFT_COMMAND, KEY_ARROW_RIGHT_COMMAND, KEY_BACKSPACE_COMMAND, $isRootNode, KEY_DELETE_COMMAND, KEY_ENTER_COMMAND, KEY_ESCAPE_COMMAND, DROP_COMMAND, $getNearestNodeFromDOMNode, $createRangeSelection, $isTextNode, $normalizeSelection__EXPERIMENTAL, $setSelection, DRAGSTART_COMMAND, DRAGOVER_COMMAND, SELECT_ALL_COMMAND, $selectAll, COPY_COMMAND, CUT_COMMAND, PASTE_COMMAND, isSelectionCapturedInDecoratorInput, $getRoot } from 'lexical'; -+import { createCommand, ElementNode, $applyNodeReplacement, $createParagraphNode, CLICK_COMMAND, $getSelection, $isNodeSelection, DELETE_CHARACTER_COMMAND, $isRangeSelection, COMMAND_PRIORITY_EDITOR, DELETE_WORD_COMMAND, DELETE_LINE_COMMAND, CONTROLLED_TEXT_INSERTION_COMMAND, REMOVE_TEXT_COMMAND, FORMAT_TEXT_COMMAND, FORMAT_ELEMENT_COMMAND, $isElementNode, INSERT_LINE_BREAK_COMMAND, INSERT_PARAGRAPH_COMMAND, INSERT_TAB_COMMAND, $insertNodes, $createTabNode, INDENT_CONTENT_COMMAND, OUTDENT_CONTENT_COMMAND, KEY_ARROW_UP_COMMAND, $isDecoratorNode, $getAdjacentNode, KEY_ARROW_DOWN_COMMAND, $getRoot, KEY_ARROW_LEFT_COMMAND, KEY_ARROW_RIGHT_COMMAND, KEY_BACKSPACE_COMMAND, $isRootNode, KEY_DELETE_COMMAND, KEY_ENTER_COMMAND, KEY_ESCAPE_COMMAND, DROP_COMMAND, $getNearestNodeFromDOMNode, $createRangeSelection, $isTextNode, $normalizeSelection__EXPERIMENTAL, $setSelection, DRAGSTART_COMMAND, DRAGOVER_COMMAND, SELECT_ALL_COMMAND, $selectAll, COPY_COMMAND, CUT_COMMAND, PASTE_COMMAND, isSelectionCapturedInDecoratorInput } from 'lexical'; - - /** - * Copyright (c) Meta Platforms, Inc. and affiliates. -@@ -63,15 +63,20 @@ const CAN_USE_DOM = typeof window !== 'undefined' && typeof window.document !== - * LICENSE file in the root directory of this source tree. - * - */ -- - const documentMode = CAN_USE_DOM && 'documentMode' in document ? document.documentMode : null; -+CAN_USE_DOM && /Mac|iPod|iPhone|iPad/.test(navigator.platform); -+CAN_USE_DOM && /^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent); - const CAN_USE_BEFORE_INPUT = CAN_USE_DOM && 'InputEvent' in window && !documentMode ? 'getTargetRanges' in new window.InputEvent('input') : false; - const IS_SAFARI = CAN_USE_DOM && /Version\/[\d.]+.*Safari/.test(navigator.userAgent); - const IS_IOS = CAN_USE_DOM && /iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream; -+const IS_ANDROID = CAN_USE_DOM && /Android/.test(navigator.userAgent); - - // Keep these in case we need to use them in the future. - // export const IS_WINDOWS: boolean = CAN_USE_DOM && /Win/.test(navigator.platform); - const IS_CHROME = CAN_USE_DOM && /^(?=.*Chrome).*/i.test(navigator.userAgent); -+// export const canUseTextInputEvent: boolean = CAN_USE_DOM && 'TextEvent' in window && !documentMode; -+ -+CAN_USE_DOM && IS_ANDROID && IS_CHROME; - const IS_APPLE_WEBKIT = CAN_USE_DOM && /AppleWebKit\/[\d.]+/.test(navigator.userAgent) && !IS_CHROME; - - /** -@@ -81,7 +86,6 @@ const IS_APPLE_WEBKIT = CAN_USE_DOM && /AppleWebKit\/[\d.]+/.test(navigator.user - * LICENSE file in the root directory of this source tree. - * - */ -- - const DRAG_DROP_PASTE = createCommand('DRAG_DROP_PASTE_FILE'); - /** @noInheritDoc */ - class QuoteNode extends ElementNode { -@@ -468,7 +472,7 @@ function registerRichText(editor) { - } - const dataTransfer = eventOrText.dataTransfer; - if (dataTransfer != null) { -- $insertDataTransferForRichText(dataTransfer, selection, editor); -+ $insertDataTransferForRichText(dataTransfer, selection, editor, eventOrText); - } else if ($isRangeSelection(selection)) { - const data = eventOrText.data; - if (data) { -diff --git a/LexicalRichText.prod.js b/LexicalRichText.prod.js -index 562f23865ba4aa00e1322b21b64d65815f708698..db5738ab58ce426bd04a53dc8148c0b34c715ea4 100644 ---- a/LexicalRichText.prod.js -+++ b/LexicalRichText.prod.js -@@ -7,28 +7,28 @@ - */ - - 'use strict';var c=require("@lexical/clipboard"),g=require("@lexical/selection"),h=require("@lexical/utils"),k=require("lexical");function l(b,a){return"undefined"!==typeof document.caretRangeFromPoint?(b=document.caretRangeFromPoint(b,a),null===b?null:{node:b.startContainer,offset:b.startOffset}):"undefined"!==document.caretPositionFromPoint?(b=document.caretPositionFromPoint(b,a),null===b?null:{node:b.offsetNode,offset:b.offset}):null} --let n="undefined"!==typeof window&&"undefined"!==typeof window.document&&"undefined"!==typeof window.document.createElement,p=n&&"documentMode"in document?document.documentMode:null,q=n&&"InputEvent"in window&&!p?"getTargetRanges"in new window.InputEvent("input"):!1,r=n&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent),t=n&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,v=n&&/^(?=.*Chrome).*/i.test(navigator.userAgent),w=n&&/AppleWebKit\/[\d.]+/.test(navigator.userAgent)&&!v,x= --k.createCommand("DRAG_DROP_PASTE_FILE"); --class y extends k.ElementNode{static getType(){return"quote"}static clone(b){return new y(b.__key)}constructor(b){super(b)}createDOM(b){let a=document.createElement("blockquote");h.addClassNamesToElement(a,b.theme.quote);return a}updateDOM(){return!1}static importDOM(){return{blockquote:()=>({conversion:z,priority:0})}}exportDOM(b){({element:b}=super.exportDOM(b));if(b&&h.isHTMLElement(b)){this.isEmpty()&&b.append(document.createElement("br"));var a=this.getFormatType();b.style.textAlign=a;if(a=this.getDirection())b.dir= --a}return{element:b}}static importJSON(b){let a=A();a.setFormat(b.format);a.setIndent(b.indent);a.setDirection(b.direction);return a}exportJSON(){return{...super.exportJSON(),type:"quote"}}insertNewAfter(b,a){b=k.$createParagraphNode();let d=this.getDirection();b.setDirection(d);this.insertAfter(b,a);return b}collapseAtStart(){let b=k.$createParagraphNode();this.getChildren().forEach(a=>b.append(a));this.replace(b);return!0}}function A(){return k.$applyNodeReplacement(new y)} --class C extends k.ElementNode{static getType(){return"heading"}static clone(b){return new C(b.__tag,b.__key)}constructor(b,a){super(a);this.__tag=b}getTag(){return this.__tag}createDOM(b){let a=this.__tag,d=document.createElement(a);b=b.theme.heading;void 0!==b&&h.addClassNamesToElement(d,b[a]);return d}updateDOM(){return!1}static importDOM(){return{h1:()=>({conversion:D,priority:0}),h2:()=>({conversion:D,priority:0}),h3:()=>({conversion:D,priority:0}),h4:()=>({conversion:D,priority:0}),h5:()=>({conversion:D, --priority:0}),h6:()=>({conversion:D,priority:0}),p:b=>{b=b.firstChild;return null!==b&&E(b)?{conversion:()=>({node:null}),priority:3}:null},span:b=>E(b)?{conversion:()=>({node:F("h1")}),priority:3}:null}}exportDOM(b){({element:b}=super.exportDOM(b));if(b&&h.isHTMLElement(b)){this.isEmpty()&&b.append(document.createElement("br"));var a=this.getFormatType();b.style.textAlign=a;if(a=this.getDirection())b.dir=a}return{element:b}}static importJSON(b){let a=F(b.tag);a.setFormat(b.format);a.setIndent(b.indent); --a.setDirection(b.direction);return a}exportJSON(){return{...super.exportJSON(),tag:this.getTag(),type:"heading",version:1}}insertNewAfter(b,a=!0){let d=b?b.anchor.offset:0,e=d!==this.getTextContentSize()&&b?F(this.getTag()):k.$createParagraphNode(),f=this.getDirection();e.setDirection(f);this.insertAfter(e,a);0===d&&!this.isEmpty()&&b&&(b=k.$createParagraphNode(),b.select(),this.replace(b,!0));return e}collapseAtStart(){let b=this.isEmpty()?k.$createParagraphNode():F(this.getTag());this.getChildren().forEach(a=> --b.append(a));this.replace(b);return!0}extractWithChild(){return!0}}function E(b){return"span"===b.nodeName.toLowerCase()?"26pt"===b.style.fontSize:!1}function D(b){let a=b.nodeName.toLowerCase(),d=null;if("h1"===a||"h2"===a||"h3"===a||"h4"===a||"h5"===a||"h6"===a)d=F(a),null!==b.style&&d.setFormat(b.style.textAlign);return{node:d}}function z(b){let a=A();null!==b.style&&a.setFormat(b.style.textAlign);return{node:a}}function F(b){return k.$applyNodeReplacement(new C(b))} --function G(b,a){b.preventDefault();a.update(()=>{let d=k.$getSelection(),e=h.objectKlassEquals(b,InputEvent)||h.objectKlassEquals(b,KeyboardEvent)?null:b.clipboardData;null!=e&&null!==d&&c.$insertDataTransferForRichText(e,d,a)},{tag:"paste"})}async function H(b,a){await c.copyToClipboard(a,h.objectKlassEquals(b,ClipboardEvent)?b:null);a.update(()=>{let d=k.$getSelection();k.$isRangeSelection(d)?d.removeText():k.$isNodeSelection(d)&&d.getNodes().forEach(e=>e.remove())})} --function I(b){let a=null;h.objectKlassEquals(b,DragEvent)?a=b.dataTransfer:h.objectKlassEquals(b,ClipboardEvent)&&(a=b.clipboardData);if(null===a)return[!1,[],!1];var d=a.types;b=d.includes("Files");d=d.includes("text/html")||d.includes("text/plain");return[b,Array.from(a.files),d]} --function J(b){var a=k.$getSelection();if(!k.$isRangeSelection(a))return!1;let d=new Set;a=a.getNodes();for(let m=0;mk.$isElementNode(u)&&!u.isInline()),null!==e&&(f=e.getKey(),e.canIndent()&&!d.has(f)&&(d.add(f),b(e))))}return 0({conversion:A,priority:0})}}exportDOM(b){({element:b}=super.exportDOM(b));if(b&&h.isHTMLElement(b)){this.isEmpty()&&b.append(document.createElement("br"));var a=this.getFormatType();b.style.textAlign=a;if(a=this.getDirection())b.dir= -+a}return{element:b}}static importJSON(b){let a=B();a.setFormat(b.format);a.setIndent(b.indent);a.setDirection(b.direction);return a}exportJSON(){return{...super.exportJSON(),type:"quote"}}insertNewAfter(b,a){b=k.$createParagraphNode();let d=this.getDirection();b.setDirection(d);this.insertAfter(b,a);return b}collapseAtStart(){let b=k.$createParagraphNode();this.getChildren().forEach(a=>b.append(a));this.replace(b);return!0}}function B(){return k.$applyNodeReplacement(new z)} -+class D extends k.ElementNode{static getType(){return"heading"}static clone(b){return new D(b.__tag,b.__key)}constructor(b,a){super(a);this.__tag=b}getTag(){return this.__tag}createDOM(b){let a=this.__tag,d=document.createElement(a);b=b.theme.heading;void 0!==b&&h.addClassNamesToElement(d,b[a]);return d}updateDOM(){return!1}static importDOM(){return{h1:()=>({conversion:E,priority:0}),h2:()=>({conversion:E,priority:0}),h3:()=>({conversion:E,priority:0}),h4:()=>({conversion:E,priority:0}),h5:()=>({conversion:E, -+priority:0}),h6:()=>({conversion:E,priority:0}),p:b=>{b=b.firstChild;return null!==b&&F(b)?{conversion:()=>({node:null}),priority:3}:null},span:b=>F(b)?{conversion:()=>({node:G("h1")}),priority:3}:null}}exportDOM(b){({element:b}=super.exportDOM(b));if(b&&h.isHTMLElement(b)){this.isEmpty()&&b.append(document.createElement("br"));var a=this.getFormatType();b.style.textAlign=a;if(a=this.getDirection())b.dir=a}return{element:b}}static importJSON(b){let a=G(b.tag);a.setFormat(b.format);a.setIndent(b.indent); -+a.setDirection(b.direction);return a}exportJSON(){return{...super.exportJSON(),tag:this.getTag(),type:"heading",version:1}}insertNewAfter(b,a=!0){let d=b?b.anchor.offset:0,e=d!==this.getTextContentSize()&&b?G(this.getTag()):k.$createParagraphNode(),f=this.getDirection();e.setDirection(f);this.insertAfter(e,a);0===d&&!this.isEmpty()&&b&&(b=k.$createParagraphNode(),b.select(),this.replace(b,!0));return e}collapseAtStart(){let b=this.isEmpty()?k.$createParagraphNode():G(this.getTag());this.getChildren().forEach(a=> -+b.append(a));this.replace(b);return!0}extractWithChild(){return!0}}function F(b){return"span"===b.nodeName.toLowerCase()?"26pt"===b.style.fontSize:!1}function E(b){let a=b.nodeName.toLowerCase(),d=null;if("h1"===a||"h2"===a||"h3"===a||"h4"===a||"h5"===a||"h6"===a)d=G(a),null!==b.style&&d.setFormat(b.style.textAlign);return{node:d}}function A(b){let a=B();null!==b.style&&a.setFormat(b.style.textAlign);return{node:a}}function G(b){return k.$applyNodeReplacement(new D(b))} -+function H(b,a){b.preventDefault();a.update(()=>{let d=k.$getSelection(),e=h.objectKlassEquals(b,InputEvent)||h.objectKlassEquals(b,KeyboardEvent)?null:b.clipboardData;null!=e&&null!==d&&c.$insertDataTransferForRichText(e,d,a)},{tag:"paste"})}async function I(b,a){await c.copyToClipboard(a,h.objectKlassEquals(b,ClipboardEvent)?b:null);a.update(()=>{let d=k.$getSelection();k.$isRangeSelection(d)?d.removeText():k.$isNodeSelection(d)&&d.getNodes().forEach(e=>e.remove())})} -+function J(b){let a=null;h.objectKlassEquals(b,DragEvent)?a=b.dataTransfer:h.objectKlassEquals(b,ClipboardEvent)&&(a=b.clipboardData);if(null===a)return[!1,[],!1];var d=a.types;b=d.includes("Files");d=d.includes("text/html")||d.includes("text/plain");return[b,Array.from(a.files),d]} -+function K(b){var a=k.$getSelection();if(!k.$isRangeSelection(a))return!1;let d=new Set;a=a.getNodes();for(let m=0;mk.$isElementNode(u)&&!u.isInline()),null!==e&&(f=e.getKey(),e.canIndent()&&!d.has(f)&&(d.add(f),b(e))))}return 0{const a=k.$getSelection();return k.$isNodeSelection(a)?(a.clear(),!0):!1},0),b.registerCommand(k.DELETE_CHARACTER_COMMAND,a=>{const d=k.$getSelection();if(!k.$isRangeSelection(d))return!1;d.deleteCharacter(a);return!0},k.COMMAND_PRIORITY_EDITOR),b.registerCommand(k.DELETE_WORD_COMMAND,a=>{const d=k.$getSelection();if(!k.$isRangeSelection(d))return!1;d.deleteWord(a);return!0},k.COMMAND_PRIORITY_EDITOR), --b.registerCommand(k.DELETE_LINE_COMMAND,a=>{const d=k.$getSelection();if(!k.$isRangeSelection(d))return!1;d.deleteLine(a);return!0},k.COMMAND_PRIORITY_EDITOR),b.registerCommand(k.CONTROLLED_TEXT_INSERTION_COMMAND,a=>{const d=k.$getSelection();if("string"===typeof a)null!==d&&d.insertText(a);else{if(null===d)return!1;const e=a.dataTransfer;null!=e?c.$insertDataTransferForRichText(e,d,b):k.$isRangeSelection(d)&&(a=a.data)&&d.insertText(a)}return!0},k.COMMAND_PRIORITY_EDITOR),b.registerCommand(k.REMOVE_TEXT_COMMAND, -+b.registerCommand(k.DELETE_LINE_COMMAND,a=>{const d=k.$getSelection();if(!k.$isRangeSelection(d))return!1;d.deleteLine(a);return!0},k.COMMAND_PRIORITY_EDITOR),b.registerCommand(k.CONTROLLED_TEXT_INSERTION_COMMAND,a=>{const d=k.$getSelection();if("string"===typeof a)null!==d&&d.insertText(a);else{if(null===d)return!1;const e=a.dataTransfer;null!=e?c.$insertDataTransferForRichText(e,d,b,a):k.$isRangeSelection(d)&&(a=a.data)&&d.insertText(a)}return!0},k.COMMAND_PRIORITY_EDITOR),b.registerCommand(k.REMOVE_TEXT_COMMAND, - ()=>{const a=k.$getSelection();if(!k.$isRangeSelection(a))return!1;a.removeText();return!0},k.COMMAND_PRIORITY_EDITOR),b.registerCommand(k.FORMAT_TEXT_COMMAND,a=>{const d=k.$getSelection();if(!k.$isRangeSelection(d))return!1;d.formatText(a);return!0},k.COMMAND_PRIORITY_EDITOR),b.registerCommand(k.FORMAT_ELEMENT_COMMAND,a=>{var d=k.$getSelection();if(!k.$isRangeSelection(d)&&!k.$isNodeSelection(d))return!1;d=d.getNodes();for(const e of d)d=h.$findMatchingParent(e,f=>k.$isElementNode(f)&&!f.isInline()), - null!==d&&d.setFormat(a);return!0},k.COMMAND_PRIORITY_EDITOR),b.registerCommand(k.INSERT_LINE_BREAK_COMMAND,a=>{const d=k.$getSelection();if(!k.$isRangeSelection(d))return!1;d.insertLineBreak(a);return!0},k.COMMAND_PRIORITY_EDITOR),b.registerCommand(k.INSERT_PARAGRAPH_COMMAND,()=>{const a=k.$getSelection();if(!k.$isRangeSelection(a))return!1;a.insertParagraph();return!0},k.COMMAND_PRIORITY_EDITOR),b.registerCommand(k.INSERT_TAB_COMMAND,()=>{k.$insertNodes([k.$createTabNode()]);return!0},k.COMMAND_PRIORITY_EDITOR), --b.registerCommand(k.INDENT_CONTENT_COMMAND,()=>J(a=>{const d=a.getIndent();a.setIndent(d+1)}),k.COMMAND_PRIORITY_EDITOR),b.registerCommand(k.OUTDENT_CONTENT_COMMAND,()=>J(a=>{const d=a.getIndent();0{var d=k.$getSelection();if(k.$isNodeSelection(d)&&!K(a.target)){if(a=d.getNodes(),0K(a=>{const d=a.getIndent();a.setIndent(d+1)}),k.COMMAND_PRIORITY_EDITOR),b.registerCommand(k.OUTDENT_CONTENT_COMMAND,()=>K(a=>{const d=a.getIndent();0{var d=k.$getSelection();if(k.$isNodeSelection(d)&&!L(a.target)){if(a=d.getNodes(),0{var d=k.$getSelection();if(k.$isNodeSelection(d)){if(a=d.getNodes(),0{const d=k.$getSelection();if(k.$isNodeSelection(d)){var e=d.getNodes();if(0{const d=k.$getSelection();if(k.$isNodeSelection(d)&& --!K(a.target)){var e=d.getNodes();if(0{if(K(a.target))return!1;const d=k.$getSelection();if(!k.$isRangeSelection(d))return!1;a.preventDefault();({anchor:a}=d);const e=a.getNode();return d.isCollapsed()&&0===a.offset&& --!k.$isRootNode(e)&&0{if(K(a.target))return!1;const d=k.$getSelection();if(!k.$isRangeSelection(d))return!1;a.preventDefault();return b.dispatchCommand(k.DELETE_CHARACTER_COMMAND,!1)},k.COMMAND_PRIORITY_EDITOR),b.registerCommand(k.KEY_ENTER_COMMAND,a=>{const d=k.$getSelection(); --if(!k.$isRangeSelection(d))return!1;if(null!==a){if((t||r||w)&&q)return!1;a.preventDefault();if(a.shiftKey)return b.dispatchCommand(k.INSERT_LINE_BREAK_COMMAND,!1)}return b.dispatchCommand(k.INSERT_PARAGRAPH_COMMAND,void 0)},k.COMMAND_PRIORITY_EDITOR),b.registerCommand(k.KEY_ESCAPE_COMMAND,()=>{const a=k.$getSelection();if(!k.$isRangeSelection(a))return!1;b.blur();return!0},k.COMMAND_PRIORITY_EDITOR),b.registerCommand(k.DROP_COMMAND,a=>{const [,d]=I(a);if(0{[a]=I(a);const d=k.$getSelection();return a&&!k.$isRangeSelection(d)?!1:!0},k.COMMAND_PRIORITY_EDITOR),b.registerCommand(k.DRAGOVER_COMMAND,a=>{var [d]=I(a);const e=k.$getSelection();if(d&&!k.$isRangeSelection(e))return!1;d=l(a.clientX,a.clientY);null!==d&&(d=k.$getNearestNodeFromDOMNode(d.node),k.$isDecoratorNode(d)&&a.preventDefault());return!0},k.COMMAND_PRIORITY_EDITOR),b.registerCommand(k.SELECT_ALL_COMMAND,()=>{k.$selectAll();return!0},k.COMMAND_PRIORITY_EDITOR), --b.registerCommand(k.COPY_COMMAND,a=>{c.copyToClipboard(b,h.objectKlassEquals(a,ClipboardEvent)?a:null);return!0},k.COMMAND_PRIORITY_EDITOR),b.registerCommand(k.CUT_COMMAND,a=>{H(a,b);return!0},k.COMMAND_PRIORITY_EDITOR),b.registerCommand(k.PASTE_COMMAND,a=>{const [,d,e]=I(a);return 0{if(L(a.target))return!1;const d=k.$getSelection();if(!k.$isRangeSelection(d))return!1;a.preventDefault();({anchor:a}=d);const e=a.getNode();return d.isCollapsed()&&0===a.offset&& -+!k.$isRootNode(e)&&0{if(L(a.target))return!1;const d=k.$getSelection();if(!k.$isRangeSelection(d))return!1;a.preventDefault();return b.dispatchCommand(k.DELETE_CHARACTER_COMMAND,!1)},k.COMMAND_PRIORITY_EDITOR),b.registerCommand(k.KEY_ENTER_COMMAND,a=>{const d=k.$getSelection(); -+if(!k.$isRangeSelection(d))return!1;if(null!==a){if((t||r||x)&&q)return!1;a.preventDefault();if(a.shiftKey)return b.dispatchCommand(k.INSERT_LINE_BREAK_COMMAND,!1)}return b.dispatchCommand(k.INSERT_PARAGRAPH_COMMAND,void 0)},k.COMMAND_PRIORITY_EDITOR),b.registerCommand(k.KEY_ESCAPE_COMMAND,()=>{const a=k.$getSelection();if(!k.$isRangeSelection(a))return!1;b.blur();return!0},k.COMMAND_PRIORITY_EDITOR),b.registerCommand(k.DROP_COMMAND,a=>{const [,d]=J(a);if(0{[a]=J(a);const d=k.$getSelection();return a&&!k.$isRangeSelection(d)?!1:!0},k.COMMAND_PRIORITY_EDITOR),b.registerCommand(k.DRAGOVER_COMMAND,a=>{var [d]=J(a);const e=k.$getSelection();if(d&&!k.$isRangeSelection(e))return!1;d=l(a.clientX,a.clientY);null!==d&&(d=k.$getNearestNodeFromDOMNode(d.node),k.$isDecoratorNode(d)&&a.preventDefault());return!0},k.COMMAND_PRIORITY_EDITOR),b.registerCommand(k.SELECT_ALL_COMMAND,()=>{k.$selectAll();return!0},k.COMMAND_PRIORITY_EDITOR), -+b.registerCommand(k.COPY_COMMAND,a=>{c.copyToClipboard(b,h.objectKlassEquals(a,ClipboardEvent)?a:null);return!0},k.COMMAND_PRIORITY_EDITOR),b.registerCommand(k.CUT_COMMAND,a=>{I(a,b);return!0},k.COMMAND_PRIORITY_EDITOR),b.registerCommand(k.PASTE_COMMAND,a=>{const [,d,e]=J(a);return 0({conversion:xt,priority:0})}}exportDOM(t){const{element:e}=super.exportDOM(t);if(e&&i(e)){this.isEmpty()&&e.append(document.createElement("br"));const t=this.getFormatType();e.style.textAlign=t;const n=this.getDirection();n&&(e.dir=n)}return{element:e}}static importJSON(t){const e=ht();return e.setFormat(t.format),e.setIndent(t.indent),e.setDirection(t.direction),e}exportJSON(){return{...super.exportJSON(),type:"quote"}}insertNewAfter(t,e){const n=m(),r=this.getDirection();return n.setDirection(r),this.insertAfter(n,e),n}collapseAtStart(){const t=m();return this.getChildren().forEach((e=>t.append(e))),this.replace(t),!0}}function ht(){return f(new pt)}function Ct(t){return t instanceof pt}class vt extends d{static getType(){return"heading"}static clone(t){return new vt(t.__tag,t.__key)}constructor(t,e){super(e),this.__tag=t}getTag(){return this.__tag}createDOM(t){const e=this.__tag,n=document.createElement(e),r=t.theme.heading;if(void 0!==r){const t=r[e];o(n,t)}return n}updateDOM(t,e){return!1}static importDOM(){return{h1:t=>({conversion:Dt,priority:0}),h2:t=>({conversion:Dt,priority:0}),h3:t=>({conversion:Dt,priority:0}),h4:t=>({conversion:Dt,priority:0}),h5:t=>({conversion:Dt,priority:0}),h6:t=>({conversion:Dt,priority:0}),p:t=>{const e=t.firstChild;return null!==e&&yt(e)?{conversion:()=>({node:null}),priority:3}:null},span:t=>yt(t)?{conversion:t=>({node:wt("h1")}),priority:3}:null}}exportDOM(t){const{element:e}=super.exportDOM(t);if(e&&i(e)){this.isEmpty()&&e.append(document.createElement("br"));const t=this.getFormatType();e.style.textAlign=t;const n=this.getDirection();n&&(e.dir=n)}return{element:e}}static importJSON(t){const e=wt(t.tag);return e.setFormat(t.format),e.setIndent(t.indent),e.setDirection(t.direction),e}exportJSON(){return{...super.exportJSON(),tag:this.getTag(),type:"heading",version:1}}insertNewAfter(t,e=!0){const n=t?t.anchor.offset:0,r=n!==this.getTextContentSize()&&t?wt(this.getTag()):m(),o=this.getDirection();if(r.setDirection(o),this.insertAfter(r,e),0===n&&!this.isEmpty()&&t){const t=m();t.select(),this.replace(t,!0)}return r}collapseAtStart(){const t=this.isEmpty()?m():wt(this.getTag());return this.getChildren().forEach((e=>t.append(e))),this.replace(t),!0}extractWithChild(){return!0}}function yt(t){return"span"===t.nodeName.toLowerCase()&&"26pt"===t.style.fontSize}function Dt(t){const e=t.nodeName.toLowerCase();let n=null;return"h1"!==e&&"h2"!==e&&"h3"!==e&&"h4"!==e&&"h5"!==e&&"h6"!==e||(n=wt(e),null!==t.style&&n.setFormat(t.style.textAlign)),{node:n}}function xt(t){const e=ht();return null!==t.style&&e.setFormat(t.style.textAlign),{node:e}}function wt(t){return f(new vt(t))}function Et(t){return t instanceof vt}function Nt(t){let e=null;if(s(t,DragEvent)?e=t.dataTransfer:s(t,ClipboardEvent)&&(e=t.clipboardData),null===e)return[!1,[],!1];const n=e.types,r=n.includes("Files"),o=n.includes("text/html")||n.includes("text/plain");return[r,Array.from(e.files),o]}function It(t){const e=p();if(!v(e))return!1;const n=new Set,r=e.getNodes();for(let e=0;eO(t)&&!t.isInline()));if(null===s)continue;const c=s.getKey();s.canIndent()&&!n.has(c)&&(n.add(c),t(s))}return n.size>0}function Ot(t){const e=G(t);return k(e)}function Tt(o){return c(o.registerCommand(g,(t=>{const e=p();return!!h(e)&&(e.clear(),!0)}),0),o.registerCommand(C,(t=>{const e=p();return!!v(e)&&(e.deleteCharacter(t),!0)}),y),o.registerCommand(D,(t=>{const e=p();return!!v(e)&&(e.deleteWord(t),!0)}),y),o.registerCommand(x,(t=>{const e=p();return!!v(e)&&(e.deleteLine(t),!0)}),y),o.registerCommand(w,(e=>{const n=p();if("string"==typeof e)null!==n&&n.insertText(e);else{if(null===n)return!1;const r=e.dataTransfer;if(null!=r)t(r,n,o);else if(v(n)){const t=e.data;return t&&n.insertText(t),!0}}return!0}),y),o.registerCommand(E,(()=>{const t=p();return!!v(t)&&(t.removeText(),!0)}),y),o.registerCommand(N,(t=>{const e=p();return!!v(e)&&(e.formatText(t),!0)}),y),o.registerCommand(I,(t=>{const e=p();if(!v(e)&&!h(e))return!1;const n=e.getNodes();for(const e of n){const n=a(e,(t=>O(t)&&!t.isInline()));null!==n&&n.setFormat(t)}return!0}),y),o.registerCommand(T,(t=>{const e=p();return!!v(e)&&(e.insertLineBreak(t),!0)}),y),o.registerCommand(A,(()=>{const t=p();return!!v(t)&&(t.insertParagraph(),!0)}),y),o.registerCommand(P,(()=>(S([_()]),!0)),y),o.registerCommand(b,(()=>It((t=>{const e=t.getIndent();t.setIndent(e+1)}))),y),o.registerCommand(F,(()=>It((t=>{const e=t.getIndent();e>0&&t.setIndent(e-1)}))),y),o.registerCommand(M,(t=>{const e=p();if(h(e)&&!Ot(t.target)){const t=e.getNodes();if(t.length>0)return t[0].selectPrevious(),!0}else if(v(e)){const n=K(e.focus,!0);if(!t.shiftKey&&k(n)&&!n.isIsolated()&&!n.isInline())return n.selectPrevious(),t.preventDefault(),!0}return!1}),y),o.registerCommand(J,(t=>{const e=p();if(h(e)){const t=e.getNodes();if(t.length>0)return t[0].selectNext(0,0),!0}else if(v(e)){if(function(t){const e=t.focus;return"root"===e.key&&e.offset===it().getChildrenSize()}(e))return t.preventDefault(),!0;const n=K(e.focus,!1);if(!t.shiftKey&&k(n)&&!n.isIsolated()&&!n.isInline())return n.selectNext(),t.preventDefault(),!0}return!1}),y),o.registerCommand(q,(t=>{const e=p();if(h(e)){const n=e.getNodes();if(n.length>0)return t.preventDefault(),n[0].selectPrevious(),!0}if(!v(e))return!1;if(n(e,!0)){const n=t.shiftKey;return t.preventDefault(),r(e,n,!0),!0}return!1}),y),o.registerCommand(L,(t=>{const e=p();if(h(e)&&!Ot(t.target)){const n=e.getNodes();if(n.length>0)return t.preventDefault(),n[0].selectNext(0,0),!0}if(!v(e))return!1;const o=t.shiftKey;return!!n(e,!1)&&(t.preventDefault(),r(e,o,!1),!0)}),y),o.registerCommand(R,(t=>{if(Ot(t.target))return!1;const e=p();if(!v(e))return!1;t.preventDefault();const{anchor:n}=e,r=n.getNode();if(e.isCollapsed()&&0===n.offset&&!z(r)){if(u(r).getIndent()>0)return o.dispatchCommand(F,void 0)}return o.dispatchCommand(C,!0)}),y),o.registerCommand(W,(t=>{if(Ot(t.target))return!1;const e=p();return!!v(e)&&(t.preventDefault(),o.dispatchCommand(C,!1))}),y),o.registerCommand(X,(t=>{const e=p();if(!v(e))return!1;if(null!==t){if((dt||lt||ft)&&ut)return!1;if(t.preventDefault(),t.shiftKey)return o.dispatchCommand(T,!1)}return o.dispatchCommand(A,void 0)}),y),o.registerCommand(Y,(()=>{const t=p();return!!v(t)&&(o.blur(),!0)}),y),o.registerCommand(B,(t=>{const[,e]=Nt(t);if(e.length>0){const n=st(t.clientX,t.clientY);if(null!==n){const{offset:t,node:r}=n,i=G(r);if(null!==i){const e=V();if(j(i))e.anchor.set(i.getKey(),t,"text"),e.focus.set(i.getKey(),t,"text");else{const t=i.getParentOrThrow().getKey(),n=i.getIndexWithinParent()+1;e.anchor.set(t,n,"element"),e.focus.set(t,n,"element")}const n=H(e);Q(n)}o.dispatchCommand(gt,e)}return t.preventDefault(),!0}const n=p();return!!v(n)}),y),o.registerCommand(U,(t=>{const[e]=Nt(t),n=p();return!(e&&!v(n))}),y),o.registerCommand(Z,(t=>{const[e]=Nt(t),n=p();if(e&&!v(n))return!1;const r=st(t.clientX,t.clientY);if(null!==r){const e=G(r.node);k(e)&&t.preventDefault()}return!0}),y),o.registerCommand($,(()=>(tt(),!0)),y),o.registerCommand(et,(t=>(e(o,s(t,ClipboardEvent)?t:null),!0)),y),o.registerCommand(nt,(t=>(async function(t,n){await e(n,s(t,ClipboardEvent)?t:null),n.update((()=>{const t=p();v(t)?t.removeText():h(t)&&t.getNodes().forEach((t=>t.remove()))}))}(t,o),!0)),y),o.registerCommand(rt,(e=>{const[,n,r]=Nt(e);if(n.length>0&&!r)return o.dispatchCommand(gt,n),!0;if(ot(e.target))return!1;return null!==p()&&(function(e,n){e.preventDefault(),n.update((()=>{const r=p(),o=s(e,InputEvent)||s(e,KeyboardEvent)?null:e.clipboardData;null!=o&&null!==r&&t(o,r,n)}),{tag:"paste"})}(e,o),!0)}),y))}export{wt as $createHeadingNode,ht as $createQuoteNode,Et as $isHeadingNode,Ct as $isQuoteNode,gt as DRAG_DROP_PASTE,vt as HeadingNode,pt as QuoteNode,Nt as eventFiles,Tt as registerRichText}; -+import{$insertDataTransferForRichText as t,copyToClipboard as e}from"@lexical/clipboard";import{$shouldOverrideDefaultCharacterSelection as n,$moveCharacter as r}from"@lexical/selection";import{addClassNamesToElement as o,isHTMLElement as i,objectKlassEquals as s,mergeRegister as c,$findMatchingParent as a,$getNearestBlockElementAncestorOrThrow as u}from"@lexical/utils";import{createCommand as l,ElementNode as d,$applyNodeReplacement as m,$createParagraphNode as f,CLICK_COMMAND as g,$getSelection as p,$isNodeSelection as h,DELETE_CHARACTER_COMMAND as v,$isRangeSelection as C,COMMAND_PRIORITY_EDITOR as y,DELETE_WORD_COMMAND as D,DELETE_LINE_COMMAND as x,CONTROLLED_TEXT_INSERTION_COMMAND as w,REMOVE_TEXT_COMMAND as E,FORMAT_TEXT_COMMAND as N,FORMAT_ELEMENT_COMMAND as A,$isElementNode as P,INSERT_LINE_BREAK_COMMAND as I,INSERT_PARAGRAPH_COMMAND as O,INSERT_TAB_COMMAND as T,$insertNodes as S,$createTabNode as _,INDENT_CONTENT_COMMAND as F,OUTDENT_CONTENT_COMMAND as M,KEY_ARROW_UP_COMMAND as b,$isDecoratorNode as K,$getAdjacentNode as k,KEY_ARROW_DOWN_COMMAND as J,$getRoot as q,KEY_ARROW_LEFT_COMMAND as L,KEY_ARROW_RIGHT_COMMAND as R,KEY_BACKSPACE_COMMAND as z,$isRootNode as W,KEY_DELETE_COMMAND as X,KEY_ENTER_COMMAND as Y,KEY_ESCAPE_COMMAND as B,DROP_COMMAND as G,$getNearestNodeFromDOMNode as V,$createRangeSelection as j,$isTextNode as H,$normalizeSelection__EXPERIMENTAL as Q,$setSelection as U,DRAGSTART_COMMAND as Z,DRAGOVER_COMMAND as $,SELECT_ALL_COMMAND as tt,$selectAll as et,COPY_COMMAND as nt,CUT_COMMAND as rt,PASTE_COMMAND as ot,isSelectionCapturedInDecoratorInput as it}from"lexical";function st(t,e){if(void 0!==document.caretRangeFromPoint){const n=document.caretRangeFromPoint(t,e);return null===n?null:{node:n.startContainer,offset:n.startOffset}}if("undefined"!==document.caretPositionFromPoint){const n=document.caretPositionFromPoint(t,e);return null===n?null:{node:n.offsetNode,offset:n.offset}}return null}const ct="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement,at=ct&&"documentMode"in document?document.documentMode:null;ct&&/Mac|iPod|iPhone|iPad/.test(navigator.platform),ct&&/^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent);const ut=!(!ct||!("InputEvent"in window)||at)&&"getTargetRanges"in new window.InputEvent("input"),lt=ct&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent),dt=ct&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,mt=(ct&&/Android/.test(navigator.userAgent),ct&&/^(?=.*Chrome).*/i.test(navigator.userAgent)),ft=ct&&/AppleWebKit\/[\d.]+/.test(navigator.userAgent)&&!mt,gt=l("DRAG_DROP_PASTE_FILE");class pt extends d{static getType(){return"quote"}static clone(t){return new pt(t.__key)}constructor(t){super(t)}createDOM(t){const e=document.createElement("blockquote");return o(e,t.theme.quote),e}updateDOM(t,e){return!1}static importDOM(){return{blockquote:t=>({conversion:xt,priority:0})}}exportDOM(t){const{element:e}=super.exportDOM(t);if(e&&i(e)){this.isEmpty()&&e.append(document.createElement("br"));const t=this.getFormatType();e.style.textAlign=t;const n=this.getDirection();n&&(e.dir=n)}return{element:e}}static importJSON(t){const e=ht();return e.setFormat(t.format),e.setIndent(t.indent),e.setDirection(t.direction),e}exportJSON(){return{...super.exportJSON(),type:"quote"}}insertNewAfter(t,e){const n=f(),r=this.getDirection();return n.setDirection(r),this.insertAfter(n,e),n}collapseAtStart(){const t=f();return this.getChildren().forEach((e=>t.append(e))),this.replace(t),!0}}function ht(){return m(new pt)}function vt(t){return t instanceof pt}class Ct extends d{static getType(){return"heading"}static clone(t){return new Ct(t.__tag,t.__key)}constructor(t,e){super(e),this.__tag=t}getTag(){return this.__tag}createDOM(t){const e=this.__tag,n=document.createElement(e),r=t.theme.heading;if(void 0!==r){const t=r[e];o(n,t)}return n}updateDOM(t,e){return!1}static importDOM(){return{h1:t=>({conversion:Dt,priority:0}),h2:t=>({conversion:Dt,priority:0}),h3:t=>({conversion:Dt,priority:0}),h4:t=>({conversion:Dt,priority:0}),h5:t=>({conversion:Dt,priority:0}),h6:t=>({conversion:Dt,priority:0}),p:t=>{const e=t.firstChild;return null!==e&&yt(e)?{conversion:()=>({node:null}),priority:3}:null},span:t=>yt(t)?{conversion:t=>({node:wt("h1")}),priority:3}:null}}exportDOM(t){const{element:e}=super.exportDOM(t);if(e&&i(e)){this.isEmpty()&&e.append(document.createElement("br"));const t=this.getFormatType();e.style.textAlign=t;const n=this.getDirection();n&&(e.dir=n)}return{element:e}}static importJSON(t){const e=wt(t.tag);return e.setFormat(t.format),e.setIndent(t.indent),e.setDirection(t.direction),e}exportJSON(){return{...super.exportJSON(),tag:this.getTag(),type:"heading",version:1}}insertNewAfter(t,e=!0){const n=t?t.anchor.offset:0,r=n!==this.getTextContentSize()&&t?wt(this.getTag()):f(),o=this.getDirection();if(r.setDirection(o),this.insertAfter(r,e),0===n&&!this.isEmpty()&&t){const t=f();t.select(),this.replace(t,!0)}return r}collapseAtStart(){const t=this.isEmpty()?f():wt(this.getTag());return this.getChildren().forEach((e=>t.append(e))),this.replace(t),!0}extractWithChild(){return!0}}function yt(t){return"span"===t.nodeName.toLowerCase()&&"26pt"===t.style.fontSize}function Dt(t){const e=t.nodeName.toLowerCase();let n=null;return"h1"!==e&&"h2"!==e&&"h3"!==e&&"h4"!==e&&"h5"!==e&&"h6"!==e||(n=wt(e),null!==t.style&&n.setFormat(t.style.textAlign)),{node:n}}function xt(t){const e=ht();return null!==t.style&&e.setFormat(t.style.textAlign),{node:e}}function wt(t){return m(new Ct(t))}function Et(t){return t instanceof Ct}function Nt(t){let e=null;if(s(t,DragEvent)?e=t.dataTransfer:s(t,ClipboardEvent)&&(e=t.clipboardData),null===e)return[!1,[],!1];const n=e.types,r=n.includes("Files"),o=n.includes("text/html")||n.includes("text/plain");return[r,Array.from(e.files),o]}function At(t){const e=p();if(!C(e))return!1;const n=new Set,r=e.getNodes();for(let e=0;eP(t)&&!t.isInline()));if(null===s)continue;const c=s.getKey();s.canIndent()&&!n.has(c)&&(n.add(c),t(s))}return n.size>0}function Pt(t){const e=V(t);return K(e)}function It(o){return c(o.registerCommand(g,(t=>{const e=p();return!!h(e)&&(e.clear(),!0)}),0),o.registerCommand(v,(t=>{const e=p();return!!C(e)&&(e.deleteCharacter(t),!0)}),y),o.registerCommand(D,(t=>{const e=p();return!!C(e)&&(e.deleteWord(t),!0)}),y),o.registerCommand(x,(t=>{const e=p();return!!C(e)&&(e.deleteLine(t),!0)}),y),o.registerCommand(w,(e=>{const n=p();if("string"==typeof e)null!==n&&n.insertText(e);else{if(null===n)return!1;const r=e.dataTransfer;if(null!=r)t(r,n,o,e);else if(C(n)){const t=e.data;return t&&n.insertText(t),!0}}return!0}),y),o.registerCommand(E,(()=>{const t=p();return!!C(t)&&(t.removeText(),!0)}),y),o.registerCommand(N,(t=>{const e=p();return!!C(e)&&(e.formatText(t),!0)}),y),o.registerCommand(A,(t=>{const e=p();if(!C(e)&&!h(e))return!1;const n=e.getNodes();for(const e of n){const n=a(e,(t=>P(t)&&!t.isInline()));null!==n&&n.setFormat(t)}return!0}),y),o.registerCommand(I,(t=>{const e=p();return!!C(e)&&(e.insertLineBreak(t),!0)}),y),o.registerCommand(O,(()=>{const t=p();return!!C(t)&&(t.insertParagraph(),!0)}),y),o.registerCommand(T,(()=>(S([_()]),!0)),y),o.registerCommand(F,(()=>At((t=>{const e=t.getIndent();t.setIndent(e+1)}))),y),o.registerCommand(M,(()=>At((t=>{const e=t.getIndent();e>0&&t.setIndent(e-1)}))),y),o.registerCommand(b,(t=>{const e=p();if(h(e)&&!Pt(t.target)){const t=e.getNodes();if(t.length>0)return t[0].selectPrevious(),!0}else if(C(e)){const n=k(e.focus,!0);if(!t.shiftKey&&K(n)&&!n.isIsolated()&&!n.isInline())return n.selectPrevious(),t.preventDefault(),!0}return!1}),y),o.registerCommand(J,(t=>{const e=p();if(h(e)){const t=e.getNodes();if(t.length>0)return t[0].selectNext(0,0),!0}else if(C(e)){if(function(t){const e=t.focus;return"root"===e.key&&e.offset===q().getChildrenSize()}(e))return t.preventDefault(),!0;const n=k(e.focus,!1);if(!t.shiftKey&&K(n)&&!n.isIsolated()&&!n.isInline())return n.selectNext(),t.preventDefault(),!0}return!1}),y),o.registerCommand(L,(t=>{const e=p();if(h(e)){const n=e.getNodes();if(n.length>0)return t.preventDefault(),n[0].selectPrevious(),!0}if(!C(e))return!1;if(n(e,!0)){const n=t.shiftKey;return t.preventDefault(),r(e,n,!0),!0}return!1}),y),o.registerCommand(R,(t=>{const e=p();if(h(e)&&!Pt(t.target)){const n=e.getNodes();if(n.length>0)return t.preventDefault(),n[0].selectNext(0,0),!0}if(!C(e))return!1;const o=t.shiftKey;return!!n(e,!1)&&(t.preventDefault(),r(e,o,!1),!0)}),y),o.registerCommand(z,(t=>{if(Pt(t.target))return!1;const e=p();if(!C(e))return!1;t.preventDefault();const{anchor:n}=e,r=n.getNode();if(e.isCollapsed()&&0===n.offset&&!W(r)){if(u(r).getIndent()>0)return o.dispatchCommand(M,void 0)}return o.dispatchCommand(v,!0)}),y),o.registerCommand(X,(t=>{if(Pt(t.target))return!1;const e=p();return!!C(e)&&(t.preventDefault(),o.dispatchCommand(v,!1))}),y),o.registerCommand(Y,(t=>{const e=p();if(!C(e))return!1;if(null!==t){if((dt||lt||ft)&&ut)return!1;if(t.preventDefault(),t.shiftKey)return o.dispatchCommand(I,!1)}return o.dispatchCommand(O,void 0)}),y),o.registerCommand(B,(()=>{const t=p();return!!C(t)&&(o.blur(),!0)}),y),o.registerCommand(G,(t=>{const[,e]=Nt(t);if(e.length>0){const n=st(t.clientX,t.clientY);if(null!==n){const{offset:t,node:r}=n,i=V(r);if(null!==i){const e=j();if(H(i))e.anchor.set(i.getKey(),t,"text"),e.focus.set(i.getKey(),t,"text");else{const t=i.getParentOrThrow().getKey(),n=i.getIndexWithinParent()+1;e.anchor.set(t,n,"element"),e.focus.set(t,n,"element")}const n=Q(e);U(n)}o.dispatchCommand(gt,e)}return t.preventDefault(),!0}const n=p();return!!C(n)}),y),o.registerCommand(Z,(t=>{const[e]=Nt(t),n=p();return!(e&&!C(n))}),y),o.registerCommand($,(t=>{const[e]=Nt(t),n=p();if(e&&!C(n))return!1;const r=st(t.clientX,t.clientY);if(null!==r){const e=V(r.node);K(e)&&t.preventDefault()}return!0}),y),o.registerCommand(tt,(()=>(et(),!0)),y),o.registerCommand(nt,(t=>(e(o,s(t,ClipboardEvent)?t:null),!0)),y),o.registerCommand(rt,(t=>(async function(t,n){await e(n,s(t,ClipboardEvent)?t:null),n.update((()=>{const t=p();C(t)?t.removeText():h(t)&&t.getNodes().forEach((t=>t.remove()))}))}(t,o),!0)),y),o.registerCommand(ot,(e=>{const[,n,r]=Nt(e);if(n.length>0&&!r)return o.dispatchCommand(gt,n),!0;if(it(e.target))return!1;return null!==p()&&(function(e,n){e.preventDefault(),n.update((()=>{const r=p(),o=s(e,InputEvent)||s(e,KeyboardEvent)?null:e.clipboardData;null!=o&&null!==r&&t(o,r,n)}),{tag:"paste"})}(e,o),!0)}),y))}export{wt as $createHeadingNode,ht as $createQuoteNode,Et as $isHeadingNode,vt as $isQuoteNode,gt as DRAG_DROP_PASTE,Ct as HeadingNode,pt as QuoteNode,Nt as eventFiles,It as registerRichText}; diff --git a/.yarn/patches/@lexical-rich-text-npm-0.22.0-1c32cc4b16.patch b/.yarn/patches/@lexical-rich-text-npm-0.22.0-1c32cc4b16.patch new file mode 100644 index 000000000..749842515 --- /dev/null +++ b/.yarn/patches/@lexical-rich-text-npm-0.22.0-1c32cc4b16.patch @@ -0,0 +1,49 @@ +diff --git a/LexicalRichText.dev.js b/LexicalRichText.dev.js +index f3870f5a3da2b33487079da6679c437b27de6c0f..2f7773f768960600038c03f86c2f062cfed7a50f 100644 +--- a/LexicalRichText.dev.js ++++ b/LexicalRichText.dev.js +@@ -482,7 +482,7 @@ function registerRichText(editor) { + } + const dataTransfer = eventOrText.dataTransfer; + if (dataTransfer != null) { +- clipboard.$insertDataTransferForRichText(dataTransfer, selection, editor); ++ clipboard.$insertDataTransferForRichText(dataTransfer, selection, editor, eventOrText); + } else if (lexical.$isRangeSelection(selection)) { + const data = eventOrText.data; + if (data) { +diff --git a/LexicalRichText.dev.mjs b/LexicalRichText.dev.mjs +index f832a117840ddb8868551d3633a151097a066983..b85616bafa8a91fa71c1eb48e30c26b814a84442 100644 +--- a/LexicalRichText.dev.mjs ++++ b/LexicalRichText.dev.mjs +@@ -480,7 +480,7 @@ function registerRichText(editor) { + } + const dataTransfer = eventOrText.dataTransfer; + if (dataTransfer != null) { +- $insertDataTransferForRichText(dataTransfer, selection, editor); ++ $insertDataTransferForRichText(dataTransfer, selection, editor, eventOrText); + } else if ($isRangeSelection(selection)) { + const data = eventOrText.data; + if (data) { +diff --git a/LexicalRichText.prod.js b/LexicalRichText.prod.js +index 8ba71f2825770836739e85e65845133ee105f69c..d4fe35e7a0bd8085197bcbea3c48c701df39bbe2 100644 +--- a/LexicalRichText.prod.js ++++ b/LexicalRichText.prod.js +@@ -21,7 +21,7 @@ function I(b){let a=null;h.objectKlassEquals(b,DragEvent)?a=b.dataTransfer:h.obj + function J(b){var a=k.$getSelection();if(!k.$isRangeSelection(a))return!1;let d=new Set;a=a.getNodes();for(let m=0;mk.$isElementNode(u)&&!u.isInline()),null!==e&&(f=e.getKey(),e.canIndent()&&!d.has(f)&&(d.add(f),b(e))))}return 0{const a=k.$getSelection();return k.$isNodeSelection(a)?(a.clear(),!0):!1},0),b.registerCommand(k.DELETE_CHARACTER_COMMAND,a=>{const d=k.$getSelection();if(!k.$isRangeSelection(d))return!1;d.deleteCharacter(a);return!0},k.COMMAND_PRIORITY_EDITOR),b.registerCommand(k.DELETE_WORD_COMMAND,a=>{const d=k.$getSelection();if(!k.$isRangeSelection(d))return!1;d.deleteWord(a);return!0},k.COMMAND_PRIORITY_EDITOR), +-b.registerCommand(k.DELETE_LINE_COMMAND,a=>{const d=k.$getSelection();if(!k.$isRangeSelection(d))return!1;d.deleteLine(a);return!0},k.COMMAND_PRIORITY_EDITOR),b.registerCommand(k.CONTROLLED_TEXT_INSERTION_COMMAND,a=>{const d=k.$getSelection();if("string"===typeof a)null!==d&&d.insertText(a);else{if(null===d)return!1;const e=a.dataTransfer;null!=e?c.$insertDataTransferForRichText(e,d,b):k.$isRangeSelection(d)&&(a=a.data)&&d.insertText(a)}return!0},k.COMMAND_PRIORITY_EDITOR),b.registerCommand(k.REMOVE_TEXT_COMMAND, ++b.registerCommand(k.DELETE_LINE_COMMAND,a=>{const d=k.$getSelection();if(!k.$isRangeSelection(d))return!1;d.deleteLine(a);return!0},k.COMMAND_PRIORITY_EDITOR),b.registerCommand(k.CONTROLLED_TEXT_INSERTION_COMMAND,a=>{const d=k.$getSelection();if("string"===typeof a)null!==d&&d.insertText(a);else{if(null===d)return!1;const e=a.dataTransfer;null!=e?c.$insertDataTransferForRichText(e,d,b,a):k.$isRangeSelection(d)&&(a=a.data)&&d.insertText(a)}return!0},k.COMMAND_PRIORITY_EDITOR),b.registerCommand(k.REMOVE_TEXT_COMMAND, + ()=>{const a=k.$getSelection();if(!k.$isRangeSelection(a))return!1;a.removeText();return!0},k.COMMAND_PRIORITY_EDITOR),b.registerCommand(k.FORMAT_TEXT_COMMAND,a=>{const d=k.$getSelection();if(!k.$isRangeSelection(d))return!1;d.formatText(a);return!0},k.COMMAND_PRIORITY_EDITOR),b.registerCommand(k.FORMAT_ELEMENT_COMMAND,a=>{var d=k.$getSelection();if(!k.$isRangeSelection(d)&&!k.$isNodeSelection(d))return!1;d=d.getNodes();for(const e of d)d=h.$findMatchingParent(e,f=>k.$isElementNode(f)&&!f.isInline()), + null!==d&&d.setFormat(a);return!0},k.COMMAND_PRIORITY_EDITOR),b.registerCommand(k.INSERT_LINE_BREAK_COMMAND,a=>{const d=k.$getSelection();if(!k.$isRangeSelection(d))return!1;d.insertLineBreak(a);return!0},k.COMMAND_PRIORITY_EDITOR),b.registerCommand(k.INSERT_PARAGRAPH_COMMAND,()=>{const a=k.$getSelection();if(!k.$isRangeSelection(a))return!1;a.insertParagraph();return!0},k.COMMAND_PRIORITY_EDITOR),b.registerCommand(k.INSERT_TAB_COMMAND,()=>{k.$insertNodes([k.$createTabNode()]);return!0},k.COMMAND_PRIORITY_EDITOR), + b.registerCommand(k.INDENT_CONTENT_COMMAND,()=>J(a=>{const d=a.getIndent();a.setIndent(d+1)}),k.COMMAND_PRIORITY_EDITOR),b.registerCommand(k.OUTDENT_CONTENT_COMMAND,()=>J(a=>{const d=a.getIndent();0{var d=k.$getSelection();if(k.$isNodeSelection(d)&&!K(a.target)){if(a=d.getNodes(),0({conversion:It,priority:0})}}exportDOM(t){const{element:e}=super.exportDOM(t);if(i(e)){this.isEmpty()&&e.append(document.createElement("br"));const t=this.getFormatType();e.style.textAlign=t;const n=this.getDirection();n&&(e.dir=n)}return{element:e}}static importJSON(t){const e=Dt();return e.setFormat(t.format),e.setIndent(t.indent),e.setDirection(t.direction),e}insertNewAfter(t,e){const n=m(),r=this.getDirection();return n.setDirection(r),this.insertAfter(n,e),n}collapseAtStart(){const t=m();return this.getChildren().forEach((e=>t.append(e))),this.replace(t),!0}canMergeWhenEmpty(){return!0}}function Dt(){return f(new yt)}function xt(t){return t instanceof yt}class wt extends d{static getType(){return"heading"}static clone(t){return new wt(t.__tag,t.__key)}constructor(t,e){super(e),this.__tag=t}getTag(){return this.__tag}createDOM(t){const e=this.__tag,n=document.createElement(e),r=t.theme.heading;if(void 0!==r){const t=r[e];o(n,t)}return n}updateDOM(t,e){return!1}static importDOM(){return{h1:t=>({conversion:Nt,priority:0}),h2:t=>({conversion:Nt,priority:0}),h3:t=>({conversion:Nt,priority:0}),h4:t=>({conversion:Nt,priority:0}),h5:t=>({conversion:Nt,priority:0}),h6:t=>({conversion:Nt,priority:0}),p:t=>{const e=t.firstChild;return null!==e&&Et(e)?{conversion:()=>({node:null}),priority:3}:null},span:t=>Et(t)?{conversion:t=>({node:Tt("h1")}),priority:3}:null}}exportDOM(t){const{element:e}=super.exportDOM(t);if(i(e)){this.isEmpty()&&e.append(document.createElement("br"));const t=this.getFormatType();e.style.textAlign=t;const n=this.getDirection();n&&(e.dir=n)}return{element:e}}static importJSON(t){const e=Tt(t.tag);return e.setFormat(t.format),e.setIndent(t.indent),e.setDirection(t.direction),e}exportJSON(){return{...super.exportJSON(),tag:this.getTag()}}insertNewAfter(t,e=!0){const n=t?t.anchor.offset:0,r=this.getLastDescendant(),o=!r||t&&t.anchor.key===r.getKey()&&n===r.getTextContentSize()||!t?m():Tt(this.getTag()),i=this.getDirection();if(o.setDirection(i),this.insertAfter(o,e),0===n&&!this.isEmpty()&&t){const t=m();t.select(),this.replace(t,!0)}return o}collapseAtStart(){const t=this.isEmpty()?m():Tt(this.getTag());return this.getChildren().forEach((e=>t.append(e))),this.replace(t),!0}extractWithChild(){return!0}}function Et(t){return"span"===t.nodeName.toLowerCase()&&"26pt"===t.style.fontSize}function Nt(t){const e=t.nodeName.toLowerCase();let n=null;return"h1"!==e&&"h2"!==e&&"h3"!==e&&"h4"!==e&&"h5"!==e&&"h6"!==e||(n=Tt(e),null!==t.style&&(g(t,n),n.setFormat(t.style.textAlign))),{node:n}}function It(t){const e=Dt();return null!==t.style&&(e.setFormat(t.style.textAlign),g(t,e)),{node:e}}function Tt(t){return f(new wt(t))}function At(t){return t instanceof wt}function Ot(t){let e=null;if(s(t,DragEvent)?e=t.dataTransfer:s(t,ClipboardEvent)&&(e=t.clipboardData),null===e)return[!1,[],!1];const n=e.types,r=n.includes("Files"),o=n.includes("text/html")||n.includes("text/plain");return[r,Array.from(e.files),o]}function Pt(t){const e=h();if(!y(e))return!1;const n=new Set,r=e.getNodes();for(let e=0;eA(t)&&!t.isInline()));if(null===s)continue;const c=s.getKey();s.canIndent()&&!n.has(c)&&(n.add(c),t(s))}return n.size>0}function Ft(t){const e=V(t);return L(e)}function _t(t){for(const e of["lowercase","uppercase","capitalize"])t.hasFormat(e)&&t.toggleFormat(e)}function Kt(o){return c(o.registerCommand(p,(t=>{const e=h();return!!C(e)&&(e.clear(),!0)}),0),o.registerCommand(v,(t=>{const e=h();return!!y(e)&&(e.deleteCharacter(t),!0)}),D),o.registerCommand(x,(t=>{const e=h();return!!y(e)&&(e.deleteWord(t),!0)}),D),o.registerCommand(w,(t=>{const e=h();return!!y(e)&&(e.deleteLine(t),!0)}),D),o.registerCommand(E,(e=>{const n=h();if("string"==typeof e)null!==n&&n.insertText(e);else{if(null===n)return!1;const r=e.dataTransfer;if(null!=r)t(r,n,o);else if(y(n)){const t=e.data;return t&&n.insertText(t),!0}}return!0}),D),o.registerCommand(N,(()=>{const t=h();return!!y(t)&&(t.removeText(),!0)}),D),o.registerCommand(I,(t=>{const e=h();return!!y(e)&&(e.formatText(t),!0)}),D),o.registerCommand(T,(t=>{const e=h();if(!y(e)&&!C(e))return!1;const n=e.getNodes();for(const e of n){const n=a(e,(t=>A(t)&&!t.isInline()));null!==n&&n.setFormat(t)}return!0}),D),o.registerCommand(O,(t=>{const e=h();return!!y(e)&&(e.insertLineBreak(t),!0)}),D),o.registerCommand(P,(()=>{const t=h();return!!y(t)&&(t.insertParagraph(),!0)}),D),o.registerCommand(F,(()=>(_([K()]),!0)),D),o.registerCommand(M,(()=>Pt((t=>{const e=t.getIndent();t.setIndent(e+1)}))),D),o.registerCommand(S,(()=>Pt((t=>{const e=t.getIndent();e>0&&t.setIndent(e-1)}))),D),o.registerCommand(b,(t=>{const e=h();if(C(e)&&!Ft(t.target)){const t=e.getNodes();if(t.length>0)return t[0].selectPrevious(),!0}else if(y(e)){const n=k(e.focus,!0);if(!t.shiftKey&&L(n)&&!n.isIsolated()&&!n.isInline())return n.selectPrevious(),t.preventDefault(),!0}return!1}),D),o.registerCommand(R,(t=>{const e=h();if(C(e)){const t=e.getNodes();if(t.length>0)return t[0].selectNext(0,0),!0}else if(y(e)){if(function(t){const e=t.focus;return"root"===e.key&&e.offset===ut().getChildrenSize()}(e))return t.preventDefault(),!0;const n=k(e.focus,!1);if(!t.shiftKey&&L(n)&&!n.isIsolated()&&!n.isInline())return n.selectNext(),t.preventDefault(),!0}return!1}),D),o.registerCommand(z,(t=>{const e=h();if(C(e)){const n=e.getNodes();if(n.length>0)return t.preventDefault(),n[0].selectPrevious(),!0}if(!y(e))return!1;if(n(e,!0)){const n=t.shiftKey;return t.preventDefault(),r(e,n,!0),!0}return!1}),D),o.registerCommand(W,(t=>{const e=h();if(C(e)&&!Ft(t.target)){const n=e.getNodes();if(n.length>0)return t.preventDefault(),n[0].selectNext(0,0),!0}if(!y(e))return!1;const o=t.shiftKey;return!!n(e,!1)&&(t.preventDefault(),r(e,o,!1),!0)}),D),o.registerCommand(q,(t=>{if(Ft(t.target))return!1;const e=h();if(!y(e))return!1;const{anchor:n}=e,r=n.getNode();if(e.isCollapsed()&&0===n.offset&&!J(r)){if(u(r).getIndent()>0)return t.preventDefault(),o.dispatchCommand(S,void 0)}return(!pt||"ko-KR"!==navigator.language)&&(t.preventDefault(),o.dispatchCommand(v,!0))}),D),o.registerCommand(X,(t=>{if(Ft(t.target))return!1;const e=h();return!!y(e)&&(t.preventDefault(),o.dispatchCommand(v,!1))}),D),o.registerCommand(Y,(t=>{const e=h();if(!y(e))return!1;if(_t(e),null!==t){if((pt||gt||Ct)&&ft)return!1;if(t.preventDefault(),t.shiftKey)return o.dispatchCommand(O,!1)}return o.dispatchCommand(P,void 0)}),D),o.registerCommand(B,(()=>{const t=h();return!!y(t)&&(o.blur(),!0)}),D),o.registerCommand(G,(t=>{const[,e]=Ot(t);if(e.length>0){const n=lt(t.clientX,t.clientY);if(null!==n){const{offset:t,node:r}=n,i=V(r);if(null!==i){const e=j();if(H(i))e.anchor.set(i.getKey(),t,"text"),e.focus.set(i.getKey(),t,"text");else{const t=i.getParentOrThrow().getKey(),n=i.getIndexWithinParent()+1;e.anchor.set(t,n,"element"),e.focus.set(t,n,"element")}const n=Q(e);U(n)}o.dispatchCommand(vt,e)}return t.preventDefault(),!0}const n=h();return!!y(n)}),D),o.registerCommand(Z,(t=>{const[e]=Ot(t),n=h();return!(e&&!y(n))}),D),o.registerCommand($,(t=>{const[e]=Ot(t),n=h();if(e&&!y(n))return!1;const r=lt(t.clientX,t.clientY);if(null!==r){const e=V(r.node);L(e)&&t.preventDefault()}return!0}),D),o.registerCommand(tt,(()=>(et(),!0)),D),o.registerCommand(nt,(t=>(e(o,s(t,ClipboardEvent)?t:null),!0)),D),o.registerCommand(rt,(t=>(async function(t,n){await e(n,s(t,ClipboardEvent)?t:null),n.update((()=>{const t=h();y(t)?t.removeText():C(t)&&t.getNodes().forEach((t=>t.remove()))}))}(t,o),!0)),D),o.registerCommand(ot,(e=>{const[,n,r]=Ot(e);if(n.length>0&&!r)return o.dispatchCommand(vt,n),!0;if(it(e.target)&&st(e.target))return!1;return null!==h()&&(function(e,n){e.preventDefault(),n.update((()=>{const r=h(),o=s(e,InputEvent)||s(e,KeyboardEvent)?null:e.clipboardData;null!=o&&null!==r&&t(o,r,n)}),{tag:"paste"})}(e,o),!0)}),D),o.registerCommand(ct,(t=>{const e=h();return y(e)&&_t(e),!1}),D),o.registerCommand(at,(t=>{const e=h();return y(e)&&_t(e),!1}),D))}export{Tt as $createHeadingNode,Dt as $createQuoteNode,At as $isHeadingNode,xt as $isQuoteNode,vt as DRAG_DROP_PASTE,wt as HeadingNode,yt as QuoteNode,Ot as eventFiles,Kt as registerRichText}; ++import{$insertDataTransferForRichText as t,copyToClipboard as e}from"@lexical/clipboard";import{$shouldOverrideDefaultCharacterSelection as n,$moveCharacter as r}from"@lexical/selection";import{addClassNamesToElement as o,isHTMLElement as i,objectKlassEquals as s,mergeRegister as c,$findMatchingParent as a,$getNearestBlockElementAncestorOrThrow as u}from"@lexical/utils";import{createCommand as l,ElementNode as d,$createParagraphNode as m,$applyNodeReplacement as f,setNodeIndentFromDOM as g,CLICK_COMMAND as p,$getSelection as h,$isNodeSelection as C,DELETE_CHARACTER_COMMAND as v,$isRangeSelection as y,COMMAND_PRIORITY_EDITOR as D,DELETE_WORD_COMMAND as x,DELETE_LINE_COMMAND as w,CONTROLLED_TEXT_INSERTION_COMMAND as E,REMOVE_TEXT_COMMAND as N,FORMAT_TEXT_COMMAND as I,FORMAT_ELEMENT_COMMAND as T,$isElementNode as A,INSERT_LINE_BREAK_COMMAND as O,INSERT_PARAGRAPH_COMMAND as P,INSERT_TAB_COMMAND as F,$insertNodes as _,$createTabNode as K,INDENT_CONTENT_COMMAND as M,OUTDENT_CONTENT_COMMAND as S,KEY_ARROW_UP_COMMAND as b,$getAdjacentNode as k,$isDecoratorNode as L,KEY_ARROW_DOWN_COMMAND as R,KEY_ARROW_LEFT_COMMAND as z,KEY_ARROW_RIGHT_COMMAND as W,KEY_BACKSPACE_COMMAND as q,$isRootNode as J,KEY_DELETE_COMMAND as X,KEY_ENTER_COMMAND as Y,KEY_ESCAPE_COMMAND as B,DROP_COMMAND as G,$getNearestNodeFromDOMNode as V,$createRangeSelection as j,$isTextNode as H,$normalizeSelection__EXPERIMENTAL as Q,$setSelection as U,DRAGSTART_COMMAND as Z,DRAGOVER_COMMAND as $,SELECT_ALL_COMMAND as tt,$selectAll as et,COPY_COMMAND as nt,CUT_COMMAND as rt,PASTE_COMMAND as ot,isDOMNode as it,isSelectionCapturedInDecoratorInput as st,KEY_SPACE_COMMAND as ct,KEY_TAB_COMMAND as at,$getRoot as ut}from"lexical";function lt(t,e){if(void 0!==document.caretRangeFromPoint){const n=document.caretRangeFromPoint(t,e);return null===n?null:{node:n.startContainer,offset:n.startOffset}}if("undefined"!==document.caretPositionFromPoint){const n=document.caretPositionFromPoint(t,e);return null===n?null:{node:n.offsetNode,offset:n.offset}}return null}const dt="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement,mt=dt&&"documentMode"in document?document.documentMode:null,ft=!(!dt||!("InputEvent"in window)||mt)&&"getTargetRanges"in new window.InputEvent("input"),gt=dt&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent),pt=dt&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,ht=dt&&/^(?=.*Chrome).*/i.test(navigator.userAgent),Ct=dt&&/AppleWebKit\/[\d.]+/.test(navigator.userAgent)&&!ht,vt=l("DRAG_DROP_PASTE_FILE");class yt extends d{static getType(){return"quote"}static clone(t){return new yt(t.__key)}constructor(t){super(t)}createDOM(t){const e=document.createElement("blockquote");return o(e,t.theme.quote),e}updateDOM(t,e){return!1}static importDOM(){return{blockquote:t=>({conversion:It,priority:0})}}exportDOM(t){const{element:e}=super.exportDOM(t);if(i(e)){this.isEmpty()&&e.append(document.createElement("br"));const t=this.getFormatType();e.style.textAlign=t;const n=this.getDirection();n&&(e.dir=n)}return{element:e}}static importJSON(t){const e=Dt();return e.setFormat(t.format),e.setIndent(t.indent),e.setDirection(t.direction),e}insertNewAfter(t,e){const n=m(),r=this.getDirection();return n.setDirection(r),this.insertAfter(n,e),n}collapseAtStart(){const t=m();return this.getChildren().forEach((e=>t.append(e))),this.replace(t),!0}canMergeWhenEmpty(){return!0}}function Dt(){return f(new yt)}function xt(t){return t instanceof yt}class wt extends d{static getType(){return"heading"}static clone(t){return new wt(t.__tag,t.__key)}constructor(t,e){super(e),this.__tag=t}getTag(){return this.__tag}createDOM(t){const e=this.__tag,n=document.createElement(e),r=t.theme.heading;if(void 0!==r){const t=r[e];o(n,t)}return n}updateDOM(t,e){return!1}static importDOM(){return{h1:t=>({conversion:Nt,priority:0}),h2:t=>({conversion:Nt,priority:0}),h3:t=>({conversion:Nt,priority:0}),h4:t=>({conversion:Nt,priority:0}),h5:t=>({conversion:Nt,priority:0}),h6:t=>({conversion:Nt,priority:0}),p:t=>{const e=t.firstChild;return null!==e&&Et(e)?{conversion:()=>({node:null}),priority:3}:null},span:t=>Et(t)?{conversion:t=>({node:Tt("h1")}),priority:3}:null}}exportDOM(t){const{element:e}=super.exportDOM(t);if(i(e)){this.isEmpty()&&e.append(document.createElement("br"));const t=this.getFormatType();e.style.textAlign=t;const n=this.getDirection();n&&(e.dir=n)}return{element:e}}static importJSON(t){const e=Tt(t.tag);return e.setFormat(t.format),e.setIndent(t.indent),e.setDirection(t.direction),e}exportJSON(){return{...super.exportJSON(),tag:this.getTag()}}insertNewAfter(t,e=!0){const n=t?t.anchor.offset:0,r=this.getLastDescendant(),o=!r||t&&t.anchor.key===r.getKey()&&n===r.getTextContentSize()||!t?m():Tt(this.getTag()),i=this.getDirection();if(o.setDirection(i),this.insertAfter(o,e),0===n&&!this.isEmpty()&&t){const t=m();t.select(),this.replace(t,!0)}return o}collapseAtStart(){const t=this.isEmpty()?m():Tt(this.getTag());return this.getChildren().forEach((e=>t.append(e))),this.replace(t),!0}extractWithChild(){return!0}}function Et(t){return"span"===t.nodeName.toLowerCase()&&"26pt"===t.style.fontSize}function Nt(t){const e=t.nodeName.toLowerCase();let n=null;return"h1"!==e&&"h2"!==e&&"h3"!==e&&"h4"!==e&&"h5"!==e&&"h6"!==e||(n=Tt(e),null!==t.style&&(g(t,n),n.setFormat(t.style.textAlign))),{node:n}}function It(t){const e=Dt();return null!==t.style&&(e.setFormat(t.style.textAlign),g(t,e)),{node:e}}function Tt(t){return f(new wt(t))}function At(t){return t instanceof wt}function Ot(t){let e=null;if(s(t,DragEvent)?e=t.dataTransfer:s(t,ClipboardEvent)&&(e=t.clipboardData),null===e)return[!1,[],!1];const n=e.types,r=n.includes("Files"),o=n.includes("text/html")||n.includes("text/plain");return[r,Array.from(e.files),o]}function Pt(t){const e=h();if(!y(e))return!1;const n=new Set,r=e.getNodes();for(let e=0;eA(t)&&!t.isInline()));if(null===s)continue;const c=s.getKey();s.canIndent()&&!n.has(c)&&(n.add(c),t(s))}return n.size>0}function Ft(t){const e=V(t);return L(e)}function _t(t){for(const e of["lowercase","uppercase","capitalize"])t.hasFormat(e)&&t.toggleFormat(e)}function Kt(o){return c(o.registerCommand(p,(t=>{const e=h();return!!C(e)&&(e.clear(),!0)}),0),o.registerCommand(v,(t=>{const e=h();return!!y(e)&&(e.deleteCharacter(t),!0)}),D),o.registerCommand(x,(t=>{const e=h();return!!y(e)&&(e.deleteWord(t),!0)}),D),o.registerCommand(w,(t=>{const e=h();return!!y(e)&&(e.deleteLine(t),!0)}),D),o.registerCommand(E,(e=>{const n=h();if("string"==typeof e)null!==n&&n.insertText(e);else{if(null===n)return!1;const r=e.dataTransfer;if(null!=r)t(r,n,o,e);else if(y(n)){const t=e.data;return t&&n.insertText(t),!0}}return!0}),D),o.registerCommand(N,(()=>{const t=h();return!!y(t)&&(t.removeText(),!0)}),D),o.registerCommand(I,(t=>{const e=h();return!!y(e)&&(e.formatText(t),!0)}),D),o.registerCommand(T,(t=>{const e=h();if(!y(e)&&!C(e))return!1;const n=e.getNodes();for(const e of n){const n=a(e,(t=>A(t)&&!t.isInline()));null!==n&&n.setFormat(t)}return!0}),D),o.registerCommand(O,(t=>{const e=h();return!!y(e)&&(e.insertLineBreak(t),!0)}),D),o.registerCommand(P,(()=>{const t=h();return!!y(t)&&(t.insertParagraph(),!0)}),D),o.registerCommand(F,(()=>(_([K()]),!0)),D),o.registerCommand(M,(()=>Pt((t=>{const e=t.getIndent();t.setIndent(e+1)}))),D),o.registerCommand(S,(()=>Pt((t=>{const e=t.getIndent();e>0&&t.setIndent(e-1)}))),D),o.registerCommand(b,(t=>{const e=h();if(C(e)&&!Ft(t.target)){const t=e.getNodes();if(t.length>0)return t[0].selectPrevious(),!0}else if(y(e)){const n=k(e.focus,!0);if(!t.shiftKey&&L(n)&&!n.isIsolated()&&!n.isInline())return n.selectPrevious(),t.preventDefault(),!0}return!1}),D),o.registerCommand(R,(t=>{const e=h();if(C(e)){const t=e.getNodes();if(t.length>0)return t[0].selectNext(0,0),!0}else if(y(e)){if(function(t){const e=t.focus;return"root"===e.key&&e.offset===ut().getChildrenSize()}(e))return t.preventDefault(),!0;const n=k(e.focus,!1);if(!t.shiftKey&&L(n)&&!n.isIsolated()&&!n.isInline())return n.selectNext(),t.preventDefault(),!0}return!1}),D),o.registerCommand(z,(t=>{const e=h();if(C(e)){const n=e.getNodes();if(n.length>0)return t.preventDefault(),n[0].selectPrevious(),!0}if(!y(e))return!1;if(n(e,!0)){const n=t.shiftKey;return t.preventDefault(),r(e,n,!0),!0}return!1}),D),o.registerCommand(W,(t=>{const e=h();if(C(e)&&!Ft(t.target)){const n=e.getNodes();if(n.length>0)return t.preventDefault(),n[0].selectNext(0,0),!0}if(!y(e))return!1;const o=t.shiftKey;return!!n(e,!1)&&(t.preventDefault(),r(e,o,!1),!0)}),D),o.registerCommand(q,(t=>{if(Ft(t.target))return!1;const e=h();if(!y(e))return!1;const{anchor:n}=e,r=n.getNode();if(e.isCollapsed()&&0===n.offset&&!J(r)){if(u(r).getIndent()>0)return t.preventDefault(),o.dispatchCommand(S,void 0)}return(!pt||"ko-KR"!==navigator.language)&&(t.preventDefault(),o.dispatchCommand(v,!0))}),D),o.registerCommand(X,(t=>{if(Ft(t.target))return!1;const e=h();return!!y(e)&&(t.preventDefault(),o.dispatchCommand(v,!1))}),D),o.registerCommand(Y,(t=>{const e=h();if(!y(e))return!1;if(_t(e),null!==t){if((pt||gt||Ct)&&ft)return!1;if(t.preventDefault(),t.shiftKey)return o.dispatchCommand(O,!1)}return o.dispatchCommand(P,void 0)}),D),o.registerCommand(B,(()=>{const t=h();return!!y(t)&&(o.blur(),!0)}),D),o.registerCommand(G,(t=>{const[,e]=Ot(t);if(e.length>0){const n=lt(t.clientX,t.clientY);if(null!==n){const{offset:t,node:r}=n,i=V(r);if(null!==i){const e=j();if(H(i))e.anchor.set(i.getKey(),t,"text"),e.focus.set(i.getKey(),t,"text");else{const t=i.getParentOrThrow().getKey(),n=i.getIndexWithinParent()+1;e.anchor.set(t,n,"element"),e.focus.set(t,n,"element")}const n=Q(e);U(n)}o.dispatchCommand(vt,e)}return t.preventDefault(),!0}const n=h();return!!y(n)}),D),o.registerCommand(Z,(t=>{const[e]=Ot(t),n=h();return!(e&&!y(n))}),D),o.registerCommand($,(t=>{const[e]=Ot(t),n=h();if(e&&!y(n))return!1;const r=lt(t.clientX,t.clientY);if(null!==r){const e=V(r.node);L(e)&&t.preventDefault()}return!0}),D),o.registerCommand(tt,(()=>(et(),!0)),D),o.registerCommand(nt,(t=>(e(o,s(t,ClipboardEvent)?t:null),!0)),D),o.registerCommand(rt,(t=>(async function(t,n){await e(n,s(t,ClipboardEvent)?t:null),n.update((()=>{const t=h();y(t)?t.removeText():C(t)&&t.getNodes().forEach((t=>t.remove()))}))}(t,o),!0)),D),o.registerCommand(ot,(e=>{const[,n,r]=Ot(e);if(n.length>0&&!r)return o.dispatchCommand(vt,n),!0;if(it(e.target)&&st(e.target))return!1;return null!==h()&&(function(e,n){e.preventDefault(),n.update((()=>{const r=h(),o=s(e,InputEvent)||s(e,KeyboardEvent)?null:e.clipboardData;null!=o&&null!==r&&t(o,r,n)}),{tag:"paste"})}(e,o),!0)}),D),o.registerCommand(ct,(t=>{const e=h();return y(e)&&_t(e),!1}),D),o.registerCommand(at,(t=>{const e=h();return y(e)&&_t(e),!1}),D))}export{Tt as $createHeadingNode,Dt as $createQuoteNode,At as $isHeadingNode,xt as $isQuoteNode,vt as DRAG_DROP_PASTE,wt as HeadingNode,yt as QuoteNode,Ot as eventFiles,Kt as registerRichText}; diff --git a/package.json b/package.json index 457642d47..aac4ec4d2 100644 --- a/package.json +++ b/package.json @@ -44,9 +44,8 @@ "@types/react-native-vector-icons/@types/react": "17.0.2", "@types/react-native/@types/react": "17.0.2", "@types/hoist-non-react-statics/@types/react": "17.0.2", - "@lexical/clipboard@0.16.0": "patch:@lexical/clipboard@npm:0.16.0#.yarn/patches/@lexical-clipboard-npm-0.16.0-3053c4af9c.patch", - "@lexical/rich-text@0.16.0": "patch:@lexical/rich-text@npm:0.16.0#.yarn/patches/@lexical-rich-text-npm-0.16.0-f484a17832.patch", - "@lexical/list@0.16.0": "patch:@lexical/list@npm:0.16.0#.yarn/patches/@lexical-list-npm-0.16.0-8f91da4ad5.patch" + "@lexical/clipboard@0.22.0": "patch:@lexical/clipboard@npm:0.22.0#.yarn/patches/@lexical-clipboard-npm-0.22.0-e950aa6a7f.patch", + "@lexical/rich-text@0.22.0": "patch:@lexical/rich-text@npm:0.22.0#.yarn/patches/@lexical-rich-text-npm-0.22.0-1c32cc4b16.patch" }, "dependencies": { "@standardnotes/snjs": "workspace:*" diff --git a/packages/mobile/ios/Podfile.lock b/packages/mobile/ios/Podfile.lock index 94365a5a4..9bd9ad202 100644 --- a/packages/mobile/ios/Podfile.lock +++ b/packages/mobile/ios/Podfile.lock @@ -1800,10 +1800,10 @@ EXTERNAL SOURCES: SPEC CHECKSUMS: boost: 4cb898d0bf20404aab1850c656dcea009429d6c1 - DoubleConversion: 5189b271737e1565bdce30deb4a08d647e3f5f54 + DoubleConversion: 76ab83afb40bddeeee456813d9c04f67f78771b5 FBLazyVector: 7b438dceb9f904bd85ca3c31d64cce32a035472b fmt: 4c2741a687cc09f0634a2e2c72a838b99f1ff120 - glog: 04b94705f318337d7ead9e6d17c019bd9b1f6b1b + glog: 69ef571f3de08433d766d614c73a9838a06bf7eb hermes-engine: 8d2103d6c0176779aea4e25df6bb1410f9946680 MMKV: 817ba1eea17421547e01e087285606eb270a8dcb MMKVCore: af055b00e27d88cd92fad301c5fecd1ff9b26dd9 diff --git a/packages/web/package.json b/packages/web/package.json index 8da37f75f..61fc6dffd 100644 --- a/packages/web/package.json +++ b/packages/web/package.json @@ -107,17 +107,17 @@ }, "dependencies": { "@ariakit/react": "^0.3.9", - "@lexical/clipboard": "0.16.0", - "@lexical/headless": "0.16.0", - "@lexical/link": "0.16.0", - "@lexical/list": "0.16.0", - "@lexical/react": "0.16.0", - "@lexical/rich-text": "0.16.0", - "@lexical/utils": "0.16.0", + "@lexical/clipboard": "0.22.0", + "@lexical/headless": "0.22.0", + "@lexical/link": "0.22.0", + "@lexical/list": "0.22.0", + "@lexical/react": "0.22.0", + "@lexical/rich-text": "0.22.0", + "@lexical/utils": "0.22.0", "@radix-ui/react-slot": "^1.0.1", "@react-pdf/renderer": "^3.3.2", "comlink": "^4.4.1", "fast-diff": "^1.3.0", - "lexical": "0.16.0" + "lexical": "0.22.0" } } diff --git a/packages/web/src/javascripts/Components/ClipperView/getSuperJSONFromClipHTML.tsx b/packages/web/src/javascripts/Components/ClipperView/getSuperJSONFromClipHTML.tsx index 22d177808..dd26469a1 100644 --- a/packages/web/src/javascripts/Components/ClipperView/getSuperJSONFromClipHTML.tsx +++ b/packages/web/src/javascripts/Components/ClipperView/getSuperJSONFromClipHTML.tsx @@ -1,10 +1,11 @@ -import { $createParagraphNode, $getRoot, $insertNodes, $nodesOfType, LexicalNode } from 'lexical' +import { $createParagraphNode, $getRoot, $insertNodes, LexicalNode } from 'lexical' import { $generateNodesFromDOM } from '@lexical/html' import { createHeadlessEditor } from '@lexical/headless' import { BlockEditorNodes } from '../SuperEditor/Lexical/Nodes/AllNodes' import BlocksEditorTheme from '../SuperEditor/Lexical/Theme/Theme' import { ClipPayload } from '@standardnotes/clipper/src/types/message' -import { LinkNode } from '@lexical/link' +import { $isLinkNode } from '@lexical/link' +import { $dfs } from '@lexical/utils' const AbsoluteLinkRegExp = new RegExp('^(?:[a-z+]+:)?//', 'i') @@ -66,15 +67,18 @@ export const getSuperJSONFromClipPayload = async (clipPayload: ClipPayload) => { await new Promise((resolve) => { editor.update(() => { - $nodesOfType(LinkNode).forEach((linkNode) => { - const url = linkNode.getURL() + for (const { node } of $dfs()) { + if (!$isLinkNode(node)) { + continue + } + const url = node.getURL() const isAbsoluteLink = AbsoluteLinkRegExp.test(url) if (!isAbsoluteLink) { const fixedURL = new URL(url, clipURL) - linkNode.setURL(fixedURL.toString()) + node.setURL(fixedURL.toString()) } - }) + } resolve() }) diff --git a/packages/web/src/javascripts/Components/SuperEditor/Lexical/Nodes/FileExportNode.tsx b/packages/web/src/javascripts/Components/SuperEditor/Lexical/Nodes/FileExportNode.tsx index 6b0cc05ff..0171ff2f0 100644 --- a/packages/web/src/javascripts/Components/SuperEditor/Lexical/Nodes/FileExportNode.tsx +++ b/packages/web/src/javascripts/Components/SuperEditor/Lexical/Nodes/FileExportNode.tsx @@ -1,6 +1,6 @@ import { DecoratorBlockNode, SerializedDecoratorBlockNode } from '@lexical/react/LexicalDecoratorBlockNode' import { parseAndCreateZippableFileName } from '@standardnotes/utils' -import { DOMExportOutput, Spread } from 'lexical' +import { DOMExportOutput, ElementFormatType, NodeKey, Spread } from 'lexical' type SerializedFileExportNode = Spread< { @@ -20,14 +20,14 @@ export class FileExportNode extends DecoratorBlockNode { return 'file-export' } - constructor(name: string, mimeType: string) { - super() + constructor(name: string, mimeType: string, format?: ElementFormatType, key?: NodeKey) { + super(format, key) this.__name = name this.__mimeType = mimeType } static clone(node: FileExportNode): FileExportNode { - return new FileExportNode(node.__name, node.__mimeType) + return new FileExportNode(node.__name, node.__mimeType, node.__format, node.__key) } static importJSON(serializedNode: SerializedFileExportNode): FileExportNode { diff --git a/packages/web/src/javascripts/Components/SuperEditor/Lexical/Nodes/TweetNode.tsx b/packages/web/src/javascripts/Components/SuperEditor/Lexical/Nodes/TweetNode.tsx index e7c966b66..cf8e6cd39 100644 --- a/packages/web/src/javascripts/Components/SuperEditor/Lexical/Nodes/TweetNode.tsx +++ b/packages/web/src/javascripts/Components/SuperEditor/Lexical/Nodes/TweetNode.tsx @@ -127,6 +127,11 @@ export class TweetNode extends DecoratorBlockNode { return 'tweet' } + constructor(id: string, format?: ElementFormatType, key?: NodeKey) { + super(format, key) + this.__id = id + } + static override clone(node: TweetNode): TweetNode { return new TweetNode(node.__id, node.__format, node.__key) } @@ -168,11 +173,6 @@ export class TweetNode extends DecoratorBlockNode { return { element } } - constructor(id: string, format?: ElementFormatType, key?: NodeKey) { - super(format, key) - this.__id = id - } - getId(): string { return this.__id } diff --git a/packages/web/src/javascripts/Components/SuperEditor/Lexical/Nodes/YouTubeNode.tsx b/packages/web/src/javascripts/Components/SuperEditor/Lexical/Nodes/YouTubeNode.tsx index 8984c2472..7bcb4a10f 100644 --- a/packages/web/src/javascripts/Components/SuperEditor/Lexical/Nodes/YouTubeNode.tsx +++ b/packages/web/src/javascripts/Components/SuperEditor/Lexical/Nodes/YouTubeNode.tsx @@ -72,6 +72,11 @@ export class YouTubeNode extends DecoratorBlockNode { return 'youtube' } + constructor(id: string, format?: ElementFormatType, key?: NodeKey) { + super(format, key) + this.__id = id + } + static clone(node: YouTubeNode): YouTubeNode { return new YouTubeNode(node.__id, node.__format, node.__key) } @@ -121,11 +126,6 @@ export class YouTubeNode extends DecoratorBlockNode { } } - constructor(id: string, format?: ElementFormatType, key?: NodeKey) { - super(format, key) - this.__id = id - } - updateDOM(): false { return false } diff --git a/packages/web/src/javascripts/Components/SuperEditor/Lexical/Utils/MarkdownExport.ts b/packages/web/src/javascripts/Components/SuperEditor/Lexical/Utils/MarkdownExport.ts index 169ebaa0e..53d45ff81 100644 --- a/packages/web/src/javascripts/Components/SuperEditor/Lexical/Utils/MarkdownExport.ts +++ b/packages/web/src/javascripts/Components/SuperEditor/Lexical/Utils/MarkdownExport.ts @@ -7,12 +7,9 @@ */ /** - * Taken from https://github.com/facebook/lexical/blob/main/packages/lexical-markdown/src/MarkdownExport.ts - * but modified using changes from https://github.com/facebook/lexical/pull/4957 to make nested elements work - * better when exporting to markdown. - */ + * Taken from https://github.com/facebook/lexical/blob/main/packages/lexical-markdown/src/MarkdownExport.ts but modified using changes from https://github.com/facebook/lexical/pull/4957 to make nested elements work better when exporting to markdown. + * */ -import type { ElementTransformer, TextFormatTransformer, TextMatchTransformer, Transformer } from '@lexical/markdown' import { ElementNode, LexicalNode, @@ -24,10 +21,27 @@ import { $isLineBreakNode, $isTextNode, } from 'lexical' -import { TRANSFORMERS, transformersByType } from './MarkdownImportExportUtils' -export function createMarkdownExport(transformers: Array): (node?: ElementNode) => string { +import { + ElementTransformer, + MultilineElementTransformer, + TextFormatTransformer, + TextMatchTransformer, + Transformer, +} from '@lexical/markdown' + +import { isEmptyParagraph, TRANSFORMERS, transformersByType } from './MarkdownImportExportUtils' + +/** + * Renders string from markdown. The selection is moved to the start after the operation. + */ +function createMarkdownExport( + transformers: Array, + shouldPreserveNewLines: boolean = false, +): (node?: ElementNode) => string { const byType = transformersByType(transformers) + const elementTransformers = [...byType.multilineElement, ...byType.element] + const isNewlineDelimited = !shouldPreserveNewLines // Export only uses text formats that are responsible for single format // e.g. it will filter out *** (bold, italic) and instead use separate ** and * @@ -37,25 +51,35 @@ export function createMarkdownExport(transformers: Array): (node?: const output = [] const children = (node || $getRoot()).getChildren() - for (const child of children) { - const result = exportTopLevelElements(child, byType.element, textFormatTransformers, byType.textMatch) + for (let i = 0; i < children.length; i++) { + const child = children[i] + const result = exportTopLevelElements(child, elementTransformers, textFormatTransformers, byType.textMatch) if (result != null) { - output.push(result) + output.push( + // separate consecutive group of texts with a line break: eg. ["hello", "world"] -> ["hello", "/nworld"] + isNewlineDelimited && i > 0 && !isEmptyParagraph(child) && !isEmptyParagraph(children[i - 1]) + ? '\n'.concat(result) + : result, + ) } } - - return output.join('\n\n') + // Ensure consecutive groups of texts are at least \n\n apart while each empty paragraph render as a newline. + // Eg. ["hello", "", "", "hi", "\nworld"] -> "hello\n\n\nhi\n\nworld" + return output.join('\n') } } function exportTopLevelElements( node: LexicalNode, - elementTransformers: Array, + elementTransformers: Array, textTransformersIndex: Array, textMatchTransformers: Array, ): string | null { for (const transformer of elementTransformers) { + if (!transformer.export) { + continue + } const result = transformer.export(node, (_node) => exportChildren(_node, elementTransformers, textTransformersIndex, textMatchTransformers), ) @@ -76,23 +100,33 @@ function exportTopLevelElements( function exportChildren( node: ElementNode, - elementTransformers: Array, + elementTransformers: Array, textTransformersIndex: Array, textMatchTransformers: Array, ): string { const output = [] const children = node.getChildren() + const childrenLength = children.length + // keep track of unclosed tags from the very beginning + const unclosedTags: { format: TextFormatType; tag: string }[] = [] + + mainLoop: for (let childIndex = 0; childIndex < childrenLength; childIndex++) { + const child = children[childIndex] + const isLastChild = childIndex === childrenLength - 1 - mainLoop: for (const child of children) { if ($isElementNode(child)) { for (const transformer of elementTransformers) { + if (!transformer.export) { + continue + } + const result = transformer.export(child, (_node) => exportChildren(_node, elementTransformers, textTransformersIndex, textMatchTransformers), ) if (result != null) { output.push(result) - if (children.indexOf(child) !== children.length - 1) { + if (!isLastChild) { output.push('\n') } continue mainLoop @@ -101,10 +135,14 @@ function exportChildren( } for (const transformer of textMatchTransformers) { + if (!transformer.export) { + continue + } + const result = transformer.export( child, (parentNode) => exportChildren(parentNode, elementTransformers, textTransformersIndex, textMatchTransformers), - (textNode, textContent) => exportTextFormat(textNode, textContent, textTransformersIndex), + (textNode, textContent) => exportTextFormat(textNode, textContent, textTransformersIndex, unclosedTags), ) if (result != null) { @@ -116,9 +154,15 @@ function exportChildren( if ($isLineBreakNode(child)) { output.push('\n') } else if ($isTextNode(child)) { - output.push(exportTextFormat(child, child.getTextContent(), textTransformersIndex)) + output.push(exportTextFormat(child, child.getTextContent(), textTransformersIndex, unclosedTags)) } else if ($isElementNode(child)) { - output.push(exportChildren(child, elementTransformers, textTransformersIndex, textMatchTransformers), '\n') + // empty paragraph returns "" + output.push(exportChildren(child, elementTransformers, textTransformersIndex, textMatchTransformers)) + // Don't insert linebreak after last child + if (!isLastChild) { + // Insert two line breaks to create a space between two paragraphs or other elements, as required by Markdown syntax. + output.push('\n', '\n') + } } else if ($isDecoratorNode(child)) { output.push(child.getTextContent()) } @@ -127,13 +171,26 @@ function exportChildren( return output.join('') } -function exportTextFormat(node: TextNode, textContent: string, textTransformers: Array): string { +function exportTextFormat( + node: TextNode, + textContent: string, + textTransformers: Array, + // unclosed tags include the markdown tags that haven't been closed yet, and their associated formats + unclosedTags: Array<{ format: TextFormatType; tag: string }>, +): string { // This function handles the case of a string looking like this: " foo " // Where it would be invalid markdown to generate: "** foo **" // We instead want to trim the whitespace out, apply formatting, and then // bring the whitespace back. So our returned string looks like this: " **foo** " const frozenString = textContent.trim() let output = frozenString + // the opening tags to be added to the result + let openingTags = '' + // the closing tags to be added to the result + let closingTags = '' + + const prevNode = getTextSibling(node, true) + const nextNode = getTextSibling(node, false) const applied = new Set() @@ -141,27 +198,39 @@ function exportTextFormat(node: TextNode, textContent: string, textTransformers: const format = transformer.format[0] const tag = transformer.tag + // dedup applied formats if (hasFormat(node, format) && !applied.has(format)) { // Multiple tags might be used for the same format (*, _) applied.add(format) - // Prevent adding opening tag is already opened by the previous sibling - const previousNode = getTextSibling(node, true) - if (!hasFormat(previousNode, format)) { - output = tag + output - } - - // Prevent adding closing tag if next sibling will do it - const nextNode = getTextSibling(node, false) - - if (!hasFormat(nextNode, format)) { - output += tag + // append the tag to openningTags, if it's not applied to the previous nodes, + // or the nodes before that (which would result in an unclosed tag) + if (!hasFormat(prevNode, format) || !unclosedTags.find((element) => element.tag === tag)) { + unclosedTags.push({ format, tag }) + openingTags += tag } } } + // close any tags in the same order they were applied, if necessary + for (let i = 0; i < unclosedTags.length; i++) { + // prevent adding closing tag if next sibling will do it + if (hasFormat(nextNode, unclosedTags[i].format)) { + continue + } + + while (unclosedTags.length > i) { + const unclosedTag = unclosedTags.pop() + if (unclosedTag && typeof unclosedTag.tag === 'string') { + closingTags += unclosedTag.tag + } + } + break + } + + output = openingTags + output + closingTags // Replace trimmed version of textContent ensuring surrounding whitespace is not modified - return textContent.replace(frozenString, output) + return textContent.replace(frozenString, () => output) } // Get next or previous text sibling a text node, including cases @@ -208,7 +277,11 @@ function hasFormat(node: LexicalNode | null | undefined, format: TextFormatType) return $isTextNode(node) && node.hasFormat(format) } -export function $convertToMarkdownString(transformers: Array = TRANSFORMERS, node?: ElementNode): string { - const exportMarkdown = createMarkdownExport(transformers) +export function $convertToMarkdownString( + transformers: Array = TRANSFORMERS, + node?: ElementNode, + shouldPreserveNewLines: boolean = false, +): string { + const exportMarkdown = createMarkdownExport(transformers, shouldPreserveNewLines) return exportMarkdown(node) } diff --git a/packages/web/src/javascripts/Components/SuperEditor/Lexical/Utils/MarkdownImport.ts b/packages/web/src/javascripts/Components/SuperEditor/Lexical/Utils/MarkdownImport.ts deleted file mode 100644 index 85137db2e..000000000 --- a/packages/web/src/javascripts/Components/SuperEditor/Lexical/Utils/MarkdownImport.ts +++ /dev/null @@ -1,368 +0,0 @@ -/** - * 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. - * - */ - -/** - * Taken from https://github.com/facebook/lexical/blob/main/packages/lexical-markdown/src/MarkdownImport.ts - * but modified to allow keeping new lines when importing markdown. - */ - -import { CodeNode, $createCodeNode } from '@lexical/code' -import { ElementTransformer, TextFormatTransformer, TextMatchTransformer, Transformer } from '@lexical/markdown' - -import { $isListItemNode, $isListNode, ListItemNode } from '@lexical/list' -import { $isQuoteNode } from '@lexical/rich-text' -import { $findMatchingParent } from '@lexical/utils' -import { - LexicalNode, - TextNode, - $createLineBreakNode, - $createParagraphNode, - $createTextNode, - $getRoot, - $getSelection, - $isParagraphNode, - $isTextNode, - ElementNode, -} from 'lexical' -import { IS_APPLE_WEBKIT, IS_IOS, IS_SAFARI } from '../Shared/environment' -import { TRANSFORMERS, transformersByType } from './MarkdownImportExportUtils' - -const PUNCTUATION_OR_SPACE = /[!-/:-@[-`{-~\s]/ - -const MARKDOWN_EMPTY_LINE_REG_EXP = /^\s{0,3}$/ -const CODE_BLOCK_REG_EXP = /^```(\w{1,10})?\s?$/ -type TextFormatTransformersIndex = Readonly<{ - fullMatchRegExpByTag: Readonly> - openTagsRegExp: RegExp - transformersByTag: Readonly> -}> - -function createMarkdownImport( - transformers: Array, -): (markdownString: string, node?: ElementNode, keepNewLines?: boolean) => void { - const byType = transformersByType(transformers) - const textFormatTransformersIndex = createTextFormatTransformersIndex(byType.textFormat) - - return (markdownString, node, keepNewLines = false) => { - const lines = markdownString.split('\n') - const linesLength = lines.length - const root = node || $getRoot() - root.clear() - - for (let i = 0; i < linesLength; i++) { - const lineText = lines[i] - // Codeblocks are processed first as anything inside such block - // is ignored for further processing - // TODO: - // Abstract it to be dynamic as other transformers (add multiline match option) - const [codeBlockNode, shiftedIndex] = importCodeBlock(lines, i, root) - - if (codeBlockNode != null) { - i = shiftedIndex - continue - } - - importBlocks(lineText, root, byType.element, textFormatTransformersIndex, byType.textMatch) - } - - if (!keepNewLines) { - // Removing empty paragraphs as md does not really - // allow empty lines and uses them as dilimiter - const children = root.getChildren() - for (const child of children) { - if (isEmptyParagraph(child)) { - child.remove() - } - } - } - - if ($getSelection() !== null) { - root.selectEnd() - } - } -} - -function isEmptyParagraph(node: LexicalNode): boolean { - if (!$isParagraphNode(node)) { - return false - } - - const firstChild = node.getFirstChild() - return ( - firstChild == null || - (node.getChildrenSize() === 1 && - $isTextNode(firstChild) && - MARKDOWN_EMPTY_LINE_REG_EXP.test(firstChild.getTextContent())) - ) -} - -function importBlocks( - lineText: string, - rootNode: ElementNode, - elementTransformers: Array, - textFormatTransformersIndex: TextFormatTransformersIndex, - textMatchTransformers: Array, -) { - const lineTextTrimmed = lineText.trim() - const textNode = $createTextNode(lineTextTrimmed) - const elementNode = $createParagraphNode() - elementNode.append(textNode) - rootNode.append(elementNode) - - for (const { regExp, replace } of elementTransformers) { - const match = lineText.match(regExp) - - if (match) { - textNode.setTextContent(lineText.slice(match[0].length)) - replace(elementNode, [textNode], match, true) - break - } - } - - importTextFormatTransformers(textNode, textFormatTransformersIndex, textMatchTransformers) - - // If no transformer found and we left with original paragraph node - // can check if its content can be appended to the previous node - // if it's a paragraph, quote or list - if (elementNode.isAttached() && lineTextTrimmed.length > 0) { - const previousNode = elementNode.getPreviousSibling() - if ($isParagraphNode(previousNode) || $isQuoteNode(previousNode) || $isListNode(previousNode)) { - let targetNode: typeof previousNode | ListItemNode | null = previousNode - - if ($isListNode(previousNode)) { - const lastDescendant = previousNode.getLastDescendant() - if (lastDescendant == null) { - targetNode = null - } else { - targetNode = $findMatchingParent(lastDescendant, $isListItemNode) - } - } - - if (targetNode != null && targetNode.getTextContentSize() > 0) { - targetNode.splice(targetNode.getChildrenSize(), 0, [$createLineBreakNode(), ...elementNode.getChildren()]) - elementNode.remove() - } - } - } -} - -function importCodeBlock( - lines: Array, - startLineIndex: number, - rootNode: ElementNode, -): [CodeNode | null, number] { - const openMatch = lines[startLineIndex].match(CODE_BLOCK_REG_EXP) - - if (openMatch) { - let endLineIndex = startLineIndex - const linesLength = lines.length - - while (++endLineIndex < linesLength) { - const closeMatch = lines[endLineIndex].match(CODE_BLOCK_REG_EXP) - - if (closeMatch) { - const codeBlockNode = $createCodeNode(openMatch[1]) - const textNode = $createTextNode(lines.slice(startLineIndex + 1, endLineIndex).join('\n')) - codeBlockNode.append(textNode) - rootNode.append(codeBlockNode) - return [codeBlockNode, endLineIndex] - } - } - } - - return [null, startLineIndex] -} - -// Processing text content and replaces text format tags. -// It takes outermost tag match and its content, creates text node with -// format based on tag and then recursively executed over node's content -// -// E.g. for "*Hello **world**!*" string it will create text node with -// "Hello **world**!" content and italic format and run recursively over -// its content to transform "**world**" part -function importTextFormatTransformers( - textNode: TextNode, - textFormatTransformersIndex: TextFormatTransformersIndex, - textMatchTransformers: Array, -) { - const textContent = textNode.getTextContent() - const match = findOutermostMatch(textContent, textFormatTransformersIndex) - - if (!match) { - // Once text format processing is done run text match transformers, as it - // only can span within single text node (unline formats that can cover multiple nodes) - importTextMatchTransformers(textNode, textMatchTransformers) - return - } - - let currentNode, remainderNode, leadingNode - - // If matching full content there's no need to run splitText and can reuse existing textNode - // to update its content and apply format. E.g. for **_Hello_** string after applying bold - // format (**) it will reuse the same text node to apply italic (_) - if (match[0] === textContent) { - currentNode = textNode - } else { - const startIndex = match.index || 0 - const endIndex = startIndex + match[0].length - - if (startIndex === 0) { - ;[currentNode, remainderNode] = textNode.splitText(endIndex) - } else { - ;[leadingNode, currentNode, remainderNode] = textNode.splitText(startIndex, endIndex) - } - } - - currentNode.setTextContent(match[2]) - const transformer = textFormatTransformersIndex.transformersByTag[match[1]] - - if (transformer) { - for (const format of transformer.format) { - if (!currentNode.hasFormat(format)) { - currentNode.toggleFormat(format) - } - } - } - - // Recursively run over inner text if it's not inline code - if (!currentNode.hasFormat('code')) { - importTextFormatTransformers(currentNode, textFormatTransformersIndex, textMatchTransformers) - } - - // Run over leading/remaining text if any - if (leadingNode) { - importTextFormatTransformers(leadingNode, textFormatTransformersIndex, textMatchTransformers) - } - - if (remainderNode) { - importTextFormatTransformers(remainderNode, textFormatTransformersIndex, textMatchTransformers) - } -} - -function importTextMatchTransformers(textNode_: TextNode, textMatchTransformers: Array) { - let textNode = textNode_ - - mainLoop: while (textNode) { - for (const transformer of textMatchTransformers) { - const match = textNode.getTextContent().match(transformer.importRegExp) - - if (!match) { - continue - } - - const startIndex = match.index || 0 - const endIndex = startIndex + match[0].length - let replaceNode, newTextNode - - if (startIndex === 0) { - ;[replaceNode, textNode] = textNode.splitText(endIndex) - } else { - ;[, replaceNode, newTextNode] = textNode.splitText(startIndex, endIndex) - } - if (newTextNode) { - importTextMatchTransformers(newTextNode, textMatchTransformers) - } - transformer.replace(replaceNode, match) - continue mainLoop - } - - break - } -} - -// Finds first "content" match that is not nested into another tag -function findOutermostMatch( - textContent: string, - textTransformersIndex: TextFormatTransformersIndex, -): RegExpMatchArray | null { - const openTagsMatch = textContent.match(textTransformersIndex.openTagsRegExp) - - if (openTagsMatch == null) { - return null - } - - for (const match of openTagsMatch) { - // Open tags reg exp might capture leading space so removing it - // before using match to find transformer - const tag = match.replace(/^\s/, '') - const fullMatchRegExp = textTransformersIndex.fullMatchRegExpByTag[tag] - if (fullMatchRegExp == null) { - continue - } - - const fullMatch = textContent.match(fullMatchRegExp) - const transformer = textTransformersIndex.transformersByTag[tag] - if (fullMatch != null && transformer != null) { - if (transformer.intraword !== false) { - return fullMatch - } - - // For non-intraword transformers checking if it's within a word - // or surrounded with space/punctuation/newline - const { index = 0 } = fullMatch - const beforeChar = textContent[index - 1] - const afterChar = textContent[index + fullMatch[0].length] - - if ( - (!beforeChar || PUNCTUATION_OR_SPACE.test(beforeChar)) && - (!afterChar || PUNCTUATION_OR_SPACE.test(afterChar)) - ) { - return fullMatch - } - } - } - - return null -} - -function createTextFormatTransformersIndex( - textTransformers: Array, -): TextFormatTransformersIndex { - const transformersByTag: Record = {} - const fullMatchRegExpByTag: Record = {} - const openTagsRegExp = [] - const escapeRegExp = '(? = TRANSFORMERS, - node?: ElementNode, - keepNewLines = false, -): void { - const importMarkdown = createMarkdownImport(transformers) - return importMarkdown(markdown, node, keepNewLines) -} diff --git a/packages/web/src/javascripts/Components/SuperEditor/Lexical/Utils/MarkdownImportExportUtils.ts b/packages/web/src/javascripts/Components/SuperEditor/Lexical/Utils/MarkdownImportExportUtils.ts index a20c81b3f..195af557d 100644 --- a/packages/web/src/javascripts/Components/SuperEditor/Lexical/Utils/MarkdownImportExportUtils.ts +++ b/packages/web/src/javascripts/Components/SuperEditor/Lexical/Utils/MarkdownImportExportUtils.ts @@ -6,7 +6,10 @@ import { ELEMENT_TRANSFORMERS, TEXT_FORMAT_TRANSFORMERS, TEXT_MATCH_TRANSFORMERS, + MultilineElementTransformer, + MULTILINE_ELEMENT_TRANSFORMERS, } from '@lexical/markdown' +import { LexicalNode, $isParagraphNode, $isTextNode } from 'lexical' function indexBy(list: Array, callback: (arg0: T) => string): Readonly>> { const index: Record> = {} @@ -26,6 +29,7 @@ function indexBy(list: Array, callback: (arg0: T) => string): Readonly): Readonly<{ element: Array + multilineElement: Array textFormat: Array textMatch: Array }> { @@ -33,13 +37,31 @@ export function transformersByType(transformers: Array): Readonly<{ return { element: (byType.element || []) as Array, + multilineElement: (byType['multiline-element'] || []) as Array, textFormat: (byType['text-format'] || []) as Array, textMatch: (byType['text-match'] || []) as Array, } } +const MARKDOWN_EMPTY_LINE_REG_EXP = /^\s{0,3}$/ + +export function isEmptyParagraph(node: LexicalNode): boolean { + if (!$isParagraphNode(node)) { + return false + } + + const firstChild = node.getFirstChild() + return ( + firstChild == null || + (node.getChildrenSize() === 1 && + $isTextNode(firstChild) && + MARKDOWN_EMPTY_LINE_REG_EXP.test(firstChild.getTextContent())) + ) +} + export const TRANSFORMERS: Array = [ ...ELEMENT_TRANSFORMERS, + ...MULTILINE_ELEMENT_TRANSFORMERS, ...TEXT_FORMAT_TRANSFORMERS, ...TEXT_MATCH_TRANSFORMERS, ] diff --git a/packages/web/src/javascripts/Components/SuperEditor/MarkdownTransformers.ts b/packages/web/src/javascripts/Components/SuperEditor/MarkdownTransformers.ts index b94d3c9f3..73614d8e2 100644 --- a/packages/web/src/javascripts/Components/SuperEditor/MarkdownTransformers.ts +++ b/packages/web/src/javascripts/Components/SuperEditor/MarkdownTransformers.ts @@ -7,6 +7,7 @@ import { TextMatchTransformer, $convertToMarkdownString, $convertFromMarkdownString, + MULTILINE_ELEMENT_TRANSFORMERS, } from '@lexical/markdown' import { $createTableCellNode, @@ -247,6 +248,7 @@ export const MarkdownTransformers = [ IMAGE, INLINE_FILE, ...ELEMENT_TRANSFORMERS, + ...MULTILINE_ELEMENT_TRANSFORMERS, ...TEXT_FORMAT_TRANSFORMERS, ...TEXT_MATCH_TRANSFORMERS, HorizontalRule, diff --git a/packages/web/src/javascripts/Components/SuperEditor/Plugins/CollapsiblePlugin/CollapsibleContainerNode.ts b/packages/web/src/javascripts/Components/SuperEditor/Plugins/CollapsiblePlugin/CollapsibleContainerNode.ts index ae0a39468..62890daed 100644 --- a/packages/web/src/javascripts/Components/SuperEditor/Plugins/CollapsiblePlugin/CollapsibleContainerNode.ts +++ b/packages/web/src/javascripts/Components/SuperEditor/Plugins/CollapsiblePlugin/CollapsibleContainerNode.ts @@ -44,14 +44,14 @@ export class CollapsibleContainerNode extends ElementNode { this.__open = open ?? false } - static override getType(): string { - return 'collapsible-container' - } - static override clone(node: CollapsibleContainerNode): CollapsibleContainerNode { return new CollapsibleContainerNode(node.__open, node.__key) } + static override getType(): string { + return 'collapsible-container' + } + override createDOM(_: EditorConfig, editor: LexicalEditor): HTMLElement { const dom = document.createElement('details') dom.classList.add('Collapsible__container') diff --git a/packages/web/src/javascripts/Components/SuperEditor/Plugins/EncryptedFilePlugin/Nodes/FileNode.tsx b/packages/web/src/javascripts/Components/SuperEditor/Plugins/EncryptedFilePlugin/Nodes/FileNode.tsx index b02b1e95e..96c69dbc7 100644 --- a/packages/web/src/javascripts/Components/SuperEditor/Plugins/EncryptedFilePlugin/Nodes/FileNode.tsx +++ b/packages/web/src/javascripts/Components/SuperEditor/Plugins/EncryptedFilePlugin/Nodes/FileNode.tsx @@ -13,6 +13,12 @@ export class FileNode extends DecoratorBlockNode implements ItemNodeInterface { return 'snfile' } + constructor(id: string, format?: ElementFormatType, key?: NodeKey, zoomLevel?: number) { + super(format, key) + this.__id = id + this.__zoomLevel = zoomLevel || 100 + } + static clone(node: FileNode): FileNode { return new FileNode(node.__id, node.__format, node.__key, node.__zoomLevel) } @@ -56,12 +62,6 @@ export class FileNode extends DecoratorBlockNode implements ItemNodeInterface { return { element } } - constructor(id: string, format?: ElementFormatType, key?: NodeKey, zoomLevel?: number) { - super(format, key) - this.__id = id - this.__zoomLevel = zoomLevel || 100 - } - getId(): string { return this.__id } diff --git a/packages/web/src/javascripts/Components/SuperEditor/Plugins/ImportPlugin/ImportPlugin.tsx b/packages/web/src/javascripts/Components/SuperEditor/Plugins/ImportPlugin/ImportPlugin.tsx index 4b0df482b..10487605e 100644 --- a/packages/web/src/javascripts/Components/SuperEditor/Plugins/ImportPlugin/ImportPlugin.tsx +++ b/packages/web/src/javascripts/Components/SuperEditor/Plugins/ImportPlugin/ImportPlugin.tsx @@ -5,7 +5,7 @@ import { handleEditorChange } from '../../Utils' import { SuperNotePreviewCharLimit } from '../../SuperEditor' import { $generateNodesFromDOM } from '@lexical/html' import { MarkdownTransformers } from '../../MarkdownTransformers' -import { $convertFromMarkdownString } from '../../Lexical/Utils/MarkdownImport' +import { $convertFromMarkdownString } from '@lexical/markdown' /** Note that markdown conversion does not insert new lines. See: https://github.com/facebook/lexical/issues/2815 */ export default function ImportPlugin({ diff --git a/packages/web/src/javascripts/Components/SuperEditor/Plugins/InlineFilePlugin/InlineFileNode.tsx b/packages/web/src/javascripts/Components/SuperEditor/Plugins/InlineFilePlugin/InlineFileNode.tsx index 2c5fea3cf..a84197b8e 100644 --- a/packages/web/src/javascripts/Components/SuperEditor/Plugins/InlineFilePlugin/InlineFileNode.tsx +++ b/packages/web/src/javascripts/Components/SuperEditor/Plugins/InlineFilePlugin/InlineFileNode.tsx @@ -1,5 +1,14 @@ import { DecoratorBlockNode, SerializedDecoratorBlockNode } from '@lexical/react/LexicalDecoratorBlockNode' -import { DOMConversionMap, DOMExportOutput, EditorConfig, LexicalEditor, LexicalNode, Spread } from 'lexical' +import { + DOMConversionMap, + DOMExportOutput, + EditorConfig, + ElementFormatType, + LexicalEditor, + LexicalNode, + NodeKey, + Spread, +} from 'lexical' import InlineFileComponent from './InlineFileComponent' type SerializedInlineFileNode = Spread< @@ -22,15 +31,15 @@ export class InlineFileNode extends DecoratorBlockNode { return 'inline-file' } - constructor(src: string, mimeType: string, fileName: string | undefined) { - super() + constructor(src: string, mimeType: string, fileName: string | undefined, format?: ElementFormatType, key?: NodeKey) { + super(format, key) this.__src = src this.__mimeType = mimeType this.__fileName = fileName } static clone(node: InlineFileNode): InlineFileNode { - return new InlineFileNode(node.__src, node.__mimeType, node.__fileName) + return new InlineFileNode(node.__src, node.__mimeType, node.__fileName, node.__format, node.__key) } static importJSON(serializedNode: SerializedInlineFileNode): InlineFileNode { diff --git a/packages/web/src/javascripts/Components/SuperEditor/Plugins/MarkdownPreviewPlugin/MarkdownPreviewPlugin.tsx b/packages/web/src/javascripts/Components/SuperEditor/Plugins/MarkdownPreviewPlugin/MarkdownPreviewPlugin.tsx index b4fafadd8..a7c1c9e9d 100644 --- a/packages/web/src/javascripts/Components/SuperEditor/Plugins/MarkdownPreviewPlugin/MarkdownPreviewPlugin.tsx +++ b/packages/web/src/javascripts/Components/SuperEditor/Plugins/MarkdownPreviewPlugin/MarkdownPreviewPlugin.tsx @@ -1,9 +1,10 @@ import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext' import { useEffect } from 'react' import { $createCodeNode } from '@lexical/code' -import { $createTextNode, $getRoot, $nodesOfType, ParagraphNode } from 'lexical' -import { $convertToMarkdownString } from '@lexical/markdown' +import { $createTextNode, $getRoot, $isParagraphNode } from 'lexical' import { MarkdownTransformers } from '../../MarkdownTransformers' +import { $dfs } from '@lexical/utils' +import { $convertToMarkdownString } from '../../Lexical/Utils/MarkdownExport' type Props = { onMarkdown: (markdown: string) => void @@ -15,10 +16,12 @@ export default function MarkdownPreviewPlugin({ onMarkdown }: Props): JSX.Elemen useEffect(() => { editor.update(() => { const root = $getRoot() - const paragraphs = $nodesOfType(ParagraphNode) - for (const paragraph of paragraphs) { - if (paragraph.isEmpty()) { - paragraph.remove() + for (const { node } of $dfs()) { + if (!$isParagraphNode(node)) { + continue + } + if (node.isEmpty()) { + node.remove() } } const markdown = $convertToMarkdownString(MarkdownTransformers) diff --git a/packages/web/src/javascripts/Components/SuperEditor/Plugins/RemoteImagePlugin/RemoteImageNode.tsx b/packages/web/src/javascripts/Components/SuperEditor/Plugins/RemoteImagePlugin/RemoteImageNode.tsx index a8d3de6a5..bf8d40e57 100644 --- a/packages/web/src/javascripts/Components/SuperEditor/Plugins/RemoteImagePlugin/RemoteImageNode.tsx +++ b/packages/web/src/javascripts/Components/SuperEditor/Plugins/RemoteImagePlugin/RemoteImageNode.tsx @@ -1,5 +1,14 @@ import { DecoratorBlockNode, SerializedDecoratorBlockNode } from '@lexical/react/LexicalDecoratorBlockNode' -import { DOMConversionMap, DOMExportOutput, EditorConfig, LexicalEditor, LexicalNode, Spread } from 'lexical' +import { + DOMConversionMap, + DOMExportOutput, + EditorConfig, + ElementFormatType, + LexicalEditor, + LexicalNode, + NodeKey, + Spread, +} from 'lexical' import RemoteImageComponent from './RemoteImageComponent' type SerializedRemoteImageNode = Spread< @@ -20,14 +29,14 @@ export class RemoteImageNode extends DecoratorBlockNode { return 'unencrypted-image' } - constructor(src: string, alt?: string) { - super() + constructor(src: string, alt?: string, format?: ElementFormatType, key?: NodeKey) { + super(format, key) this.__src = src this.__alt = alt } static clone(node: RemoteImageNode): RemoteImageNode { - return new RemoteImageNode(node.__src, node.__alt) + return new RemoteImageNode(node.__src, node.__alt, node.__format, node.__key) } static importJSON(serializedNode: SerializedRemoteImageNode): RemoteImageNode { diff --git a/packages/web/src/javascripts/Components/SuperEditor/Plugins/SearchPlugin/SearchPlugin.tsx b/packages/web/src/javascripts/Components/SuperEditor/Plugins/SearchPlugin/SearchPlugin.tsx index dc1f91e51..9a800cf21 100644 --- a/packages/web/src/javascripts/Components/SuperEditor/Plugins/SearchPlugin/SearchPlugin.tsx +++ b/packages/web/src/javascripts/Components/SuperEditor/Plugins/SearchPlugin/SearchPlugin.tsx @@ -89,9 +89,10 @@ export const SearchPlugin = () => { const handleSearch = useCallback( (query: string, isCaseSensitive: boolean) => { - document.querySelectorAll('.search-highlight').forEach((element) => { + const currentHighlights = document.querySelectorAll('.search-highlight') + for (const element of currentHighlights) { element.remove() - }) + } if (!query) { dispatch({ type: 'clear-results' }) @@ -109,7 +110,7 @@ export const SearchPlugin = () => { const results: SuperSearchResult[] = [] - textNodes.forEach((node) => { + for (const node of textNodes) { const text = node.textContent || '' const indices: number[] = [] @@ -122,7 +123,7 @@ export const SearchPlugin = () => { indices.push(index) } - indices.forEach((index) => { + for (const index of indices) { const startIndex = index const endIndex = startIndex + query.length @@ -131,8 +132,8 @@ export const SearchPlugin = () => { startIndex, endIndex, }) - }) - }) + } + } dispatch({ type: 'set-results', @@ -205,7 +206,10 @@ export const SearchPlugin = () => { } replaceResult(result, true) } else if (type === 'all') { - resultsRef.current.forEach((result) => replaceResult(result)) + const results = resultsRef.current + for (const result of results) { + replaceResult(result) + } } void handleSearch(queryRef.current, isCaseSensitiveRef.current) @@ -214,9 +218,10 @@ export const SearchPlugin = () => { }, [addReplaceEventListener, currentResultIndexRef, editor, handleSearch, isCaseSensitiveRef, queryRef, resultsRef]) useEffect(() => { - document.querySelectorAll('.search-highlight').forEach((element) => { + const currentHighlights = document.querySelectorAll('.search-highlight') + for (const element of currentHighlights) { element.remove() - }) + } if (currentResultIndex === -1) { return } diff --git a/packages/web/src/javascripts/Components/SuperEditor/Plugins/TableCellActionMenuPlugin/index.tsx b/packages/web/src/javascripts/Components/SuperEditor/Plugins/TableCellActionMenuPlugin/index.tsx index 137da753f..746df7781 100644 --- a/packages/web/src/javascripts/Components/SuperEditor/Plugins/TableCellActionMenuPlugin/index.tsx +++ b/packages/web/src/javascripts/Components/SuperEditor/Plugins/TableCellActionMenuPlugin/index.tsx @@ -190,7 +190,7 @@ function TableActionMenu({ onClose, tableCellNode: _tableCellNode, cellMerge }: const tableSelection = getTableObserverFromTableElement(tableElement) if (tableSelection !== null) { - tableSelection.clearHighlight() + tableSelection.$clearHighlight() } tableNode.markDirty() diff --git a/packages/web/src/javascripts/Components/SuperEditor/Tools/HeadlessSuperConverter.tsx b/packages/web/src/javascripts/Components/SuperEditor/Tools/HeadlessSuperConverter.tsx index 0482fe49f..3cd1d6a0e 100644 --- a/packages/web/src/javascripts/Components/SuperEditor/Tools/HeadlessSuperConverter.tsx +++ b/packages/web/src/javascripts/Components/SuperEditor/Tools/HeadlessSuperConverter.tsx @@ -1,24 +1,17 @@ import { createHeadlessEditor } from '@lexical/headless' import { FileItem, PrefKey, PrefValue, SuperConverterServiceInterface } from '@standardnotes/snjs' -import { - $createParagraphNode, - $getRoot, - $insertNodes, - $nodesOfType, - LexicalEditor, - LexicalNode, - ParagraphNode, -} from 'lexical' +import { $createParagraphNode, $getRoot, $insertNodes, $isParagraphNode, LexicalEditor, LexicalNode } from 'lexical' import BlocksEditorTheme from '../Lexical/Theme/Theme' import { BlockEditorNodes, SuperExportNodes } from '../Lexical/Nodes/AllNodes' import { MarkdownTransformers } from '../MarkdownTransformers' import { $generateHtmlFromNodes, $generateNodesFromDOM } from '@lexical/html' -import { FileNode } from '../Plugins/EncryptedFilePlugin/Nodes/FileNode' import { $createFileExportNode } from '../Lexical/Nodes/FileExportNode' import { $createInlineFileNode } from '../Plugins/InlineFilePlugin/InlineFileNode' -import { $convertFromMarkdownString } from '../Lexical/Utils/MarkdownImport' +import { $convertFromMarkdownString } from '@lexical/markdown' import { $convertToMarkdownString } from '../Lexical/Utils/MarkdownExport' import { parseFileName } from '@standardnotes/utils' +import { $dfs } from '@lexical/utils' +import { $isFileNode } from '../Plugins/EncryptedFilePlugin/Nodes/FileUtils' export class HeadlessSuperConverter implements SuperConverterServiceInterface { private importEditor: LexicalEditor @@ -80,103 +73,103 @@ export class HeadlessSuperConverter implements SuperConverterServiceInterface { let content: string | undefined await new Promise((resolve) => { - this.exportEditor.update( - () => { - if (embedBehavior === 'reference') { - resolve() - return - } - if (!getFileItem) { - resolve() - return - } - const fileNodes = $nodesOfType(FileNode) - const filenameCounts: Record = {} - Promise.all( - fileNodes.map(async (fileNode) => { - const fileItem = getFileItem(fileNode.getId()) - if (!fileItem) { + const handleFileNodes = () => { + if (embedBehavior === 'reference') { + resolve() + return + } + if (!getFileItem) { + resolve() + return + } + const filenameCounts: Record = {} + Promise.all( + $dfs().map(async ({ node: fileNode }) => { + if (!$isFileNode(fileNode)) { + return + } + const fileItem = getFileItem(fileNode.getId()) + if (!fileItem) { + return + } + const canInlineFileType = toFormat === 'pdf' ? fileItem.mimeType.startsWith('image/') : true + if (embedBehavior === 'inline' && getFileBase64 && canInlineFileType) { + const fileBase64 = await getFileBase64(fileNode.getId()) + if (!fileBase64) { return } - const canInlineFileType = toFormat === 'pdf' ? fileItem.mimeType.startsWith('image/') : true - if (embedBehavior === 'inline' && getFileBase64 && canInlineFileType) { - const fileBase64 = await getFileBase64(fileNode.getId()) - if (!fileBase64) { - return - } - this.exportEditor.update( - () => { - const inlineFileNode = $createInlineFileNode(fileBase64, fileItem.mimeType, fileItem.name) - fileNode.replace(inlineFileNode) - }, - { discrete: true }, - ) - } else { - this.exportEditor.update( - () => { - filenameCounts[fileItem.name] = - filenameCounts[fileItem.name] == undefined ? 0 : filenameCounts[fileItem.name] + 1 + this.exportEditor.update( + () => { + const inlineFileNode = $createInlineFileNode(fileBase64, fileItem.mimeType, fileItem.name) + fileNode.replace(inlineFileNode) + }, + { discrete: true }, + ) + } else { + this.exportEditor.update( + () => { + filenameCounts[fileItem.name] = + filenameCounts[fileItem.name] == undefined ? 0 : filenameCounts[fileItem.name] + 1 - let name = fileItem.name + let name = fileItem.name - if (filenameCounts[name] > 0) { - const { name: _name, ext } = parseFileName(name) - name = `${_name}-${fileItem.uuid}.${ext}` - } + if (filenameCounts[name] > 0) { + const { name: _name, ext } = parseFileName(name) + name = `${_name}-${fileItem.uuid}.${ext}` + } - const fileExportNode = $createFileExportNode(name, fileItem.mimeType) - fileNode.replace(fileExportNode) - }, - { discrete: true }, - ) - } - }), - ) - .then(() => resolve()) - .catch(console.error) - }, - { discrete: true }, - ) + const fileExportNode = $createFileExportNode(name, fileItem.mimeType) + fileNode.replace(fileExportNode) + }, + { discrete: true }, + ) + } + }), + ) + .then(() => resolve()) + .catch(console.error) + } + this.exportEditor.update(handleFileNodes, { discrete: true }) }) await new Promise((resolve) => { - this.exportEditor.update( - () => { - switch (toFormat) { - case 'txt': - case 'md': { - const paragraphs = $nodesOfType(ParagraphNode) - for (const paragraph of paragraphs) { - if (paragraph.isEmpty()) { - paragraph.remove() - } + const convertToFormat = () => { + switch (toFormat) { + case 'txt': + case 'md': { + for (const { node: paragraph } of $dfs()) { + if (!$isParagraphNode(paragraph)) { + continue + } + if (paragraph.isEmpty()) { + paragraph.remove() } - content = $convertToMarkdownString(MarkdownTransformers) - resolve() - break } - case 'html': - content = $generateHtmlFromNodes(this.exportEditor) - resolve() - break - case 'pdf': { - void import('../Lexical/Utils/PDFExport/PDFExport').then(({ $generatePDFFromNodes }): void => { - void $generatePDFFromNodes(this.exportEditor, config?.pdf?.pageSize || 'A4').then((pdf) => { - content = pdf - resolve() - }) - }) - break - } - case 'json': - default: - content = superString - resolve() - break + content = $convertToMarkdownString(MarkdownTransformers) + resolve() + break } - }, - { discrete: true }, - ) + case 'html': + content = $generateHtmlFromNodes(this.exportEditor) + resolve() + break + case 'pdf': { + void import('../Lexical/Utils/PDFExport/PDFExport').then(({ $generatePDFFromNodes }): void => { + void $generatePDFFromNodes(this.exportEditor, config?.pdf?.pageSize || 'A4').then((pdf) => { + content = pdf + resolve() + }) + }) + break + } + case 'json': + default: + content = superString + resolve() + break + } + } + this.exportEditor.update(convertToFormat, { discrete: true }) }) if (typeof content !== 'string') { @@ -288,14 +281,16 @@ export class HeadlessSuperConverter implements SuperConverterServiceInterface { const ids: string[] = [] this.exportEditor.getEditorState().read(() => { - const fileNodes = $nodesOfType(FileNode) - fileNodes.forEach((fileNode) => { + for (const { node: fileNode } of $dfs()) { + if (!$isFileNode(fileNode)) { + continue + } const nodeId = fileNode.getId() if (ids.includes(nodeId)) { - return + continue } ids.push(nodeId) - }) + } }) return ids diff --git a/yarn.lock b/yarn.lock index 044e0c74c..05dfca59e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4278,298 +4278,290 @@ __metadata: languageName: node linkType: hard -"@lexical/clipboard@npm:0.16.0": - version: 0.16.0 - resolution: "@lexical/clipboard@npm:0.16.0" +"@lexical/clipboard@npm:0.22.0": + version: 0.22.0 + resolution: "@lexical/clipboard@npm:0.22.0" dependencies: - "@lexical/html": 0.16.0 - "@lexical/list": 0.16.0 - "@lexical/selection": 0.16.0 - "@lexical/utils": 0.16.0 - lexical: 0.16.0 - checksum: 8fe5cf11a1ad84d4da39205610cb2969046455a0dc0b33d4de748abc9fe9904c2381ce85c495f2b9c85233548d7223270eec030619f3455bb911d6767a3516f2 + "@lexical/html": 0.22.0 + "@lexical/list": 0.22.0 + "@lexical/selection": 0.22.0 + "@lexical/utils": 0.22.0 + lexical: 0.22.0 + checksum: c6869ec54c6972185806ab40b35a089cbb54585ccd13f38e0e56cdac1783b0615f2482adf15505279b0b0f2276a2a1fa432673983c7f9a5ed3274d4e8588939c languageName: node linkType: hard -"@lexical/clipboard@patch:@lexical/clipboard@npm:0.16.0#.yarn/patches/@lexical-clipboard-npm-0.16.0-3053c4af9c.patch::locator=%40standardnotes%2Fapp-monorepo%40workspace%3A.": - version: 0.16.0 - resolution: "@lexical/clipboard@patch:@lexical/clipboard@npm%3A0.16.0#.yarn/patches/@lexical-clipboard-npm-0.16.0-3053c4af9c.patch::version=0.16.0&hash=ef7a9a&locator=%40standardnotes%2Fapp-monorepo%40workspace%3A." +"@lexical/clipboard@patch:@lexical/clipboard@npm:0.22.0#.yarn/patches/@lexical-clipboard-npm-0.22.0-e950aa6a7f.patch::locator=%40standardnotes%2Fapp-monorepo%40workspace%3A.": + version: 0.22.0 + resolution: "@lexical/clipboard@patch:@lexical/clipboard@npm%3A0.22.0#.yarn/patches/@lexical-clipboard-npm-0.22.0-e950aa6a7f.patch::version=0.22.0&hash=30572a&locator=%40standardnotes%2Fapp-monorepo%40workspace%3A." dependencies: - "@lexical/html": 0.16.0 - "@lexical/list": 0.16.0 - "@lexical/selection": 0.16.0 - "@lexical/utils": 0.16.0 - lexical: 0.16.0 - checksum: 4bfeeaef9a31d15bfa35bc58d4508ec19eeb3a8c68f88a5d1eb69bcba007fca934c0cd278d3b10adf754b0b9370a0aa16e48d31f26fa3a7d7a95bfa736f0417c + "@lexical/html": 0.22.0 + "@lexical/list": 0.22.0 + "@lexical/selection": 0.22.0 + "@lexical/utils": 0.22.0 + lexical: 0.22.0 + checksum: 8972b49800b7491072680ed597a81b934b388f97570b8239f14dabfbafd6f4e46feeb68e279a9e8c5075e955310b6dac480bb1c8f2f2e1d98f900705cd8b1168 languageName: node linkType: hard -"@lexical/code@npm:0.16.0": - version: 0.16.0 - resolution: "@lexical/code@npm:0.16.0" +"@lexical/code@npm:0.22.0": + version: 0.22.0 + resolution: "@lexical/code@npm:0.22.0" dependencies: - "@lexical/utils": 0.16.0 - lexical: 0.16.0 + "@lexical/utils": 0.22.0 + lexical: 0.22.0 prismjs: ^1.27.0 - checksum: 4f6283beca15df5b9520f2245803f7e34fc4297fbaafd790371d44a590a8ba33107515f63a8db281191280d85b170c7eca3fc151eec5929b3b5a212cc5255ecf + checksum: 6e7ff958d5dbbe02e8ca998d5601aea545fe18a509368170002fb0906a020d2d1d93fffaa6442ee742c78350eb74419a09521084e10859e801de95bb2cd8cada languageName: node linkType: hard -"@lexical/devtools-core@npm:0.16.0": - version: 0.16.0 - resolution: "@lexical/devtools-core@npm:0.16.0" +"@lexical/devtools-core@npm:0.22.0": + version: 0.22.0 + resolution: "@lexical/devtools-core@npm:0.22.0" dependencies: - "@lexical/html": 0.16.0 - "@lexical/link": 0.16.0 - "@lexical/mark": 0.16.0 - "@lexical/table": 0.16.0 - "@lexical/utils": 0.16.0 - lexical: 0.16.0 + "@lexical/html": 0.22.0 + "@lexical/link": 0.22.0 + "@lexical/mark": 0.22.0 + "@lexical/table": 0.22.0 + "@lexical/utils": 0.22.0 + lexical: 0.22.0 peerDependencies: react: ">=17.x" react-dom: ">=17.x" - checksum: c6ba99da01c2bef29537e0c3f39f0e6c91a6c091239b96048ae9cba5d9911edac9906f053430e17599608d9d01721efbeca00471dfb8ce7878492f767105e056 + checksum: e8c75cd1fb5854e51d6565ff46cd4c1118991d0b069e7d3f3a9cc59a997a9495947bef2b77752ff0a63799fdc5bc28a02d168ff4cef92ac697089746859bb2af languageName: node linkType: hard -"@lexical/dragon@npm:0.16.0": - version: 0.16.0 - resolution: "@lexical/dragon@npm:0.16.0" +"@lexical/dragon@npm:0.22.0": + version: 0.22.0 + resolution: "@lexical/dragon@npm:0.22.0" dependencies: - lexical: 0.16.0 - checksum: 8f6fa617559bdf204da8509d545e34f78d19c8268a8335bf7e62621f053f88e328521879cf60e8e6eab85d7580681b09ed90dc77a6088aaac32d0f62f860f1dd + lexical: 0.22.0 + checksum: ba9b4143b7b01a3cc938c673c32ec2dfc944dc529fd204cbf63f4376b2b6d8481270ae72a7c241cbe3b9488e0af67f8c7017873723f903a0ddd5e14967cbe12b languageName: node linkType: hard -"@lexical/hashtag@npm:0.16.0": - version: 0.16.0 - resolution: "@lexical/hashtag@npm:0.16.0" +"@lexical/hashtag@npm:0.22.0": + version: 0.22.0 + resolution: "@lexical/hashtag@npm:0.22.0" dependencies: - "@lexical/utils": 0.16.0 - lexical: 0.16.0 - checksum: a569b35a89708d6291c072ac91dbf69b759383862633fc1d8f2322ebdec9b4200f8f5a3c30f46f58963c80290ba3182da8d44d468f352760b85e00e760db2753 + "@lexical/utils": 0.22.0 + lexical: 0.22.0 + checksum: 368cf96b0851ed47359228ab5b363d62d705c226e3ce67e65cc94e446d6ddd50d4a27634f164fb171f09fb30461c5b015d5f602894ebe712bed0802ea6bd8473 languageName: node linkType: hard -"@lexical/headless@npm:0.16.0": - version: 0.16.0 - resolution: "@lexical/headless@npm:0.16.0" +"@lexical/headless@npm:0.22.0": + version: 0.22.0 + resolution: "@lexical/headless@npm:0.22.0" dependencies: - lexical: 0.16.0 - checksum: 6a03375495e839965b52d2d5980ffd821dd9f72acfb8793df74db2fed424cb9e9cd787d76684112651efdaa9c1af6feae4674dbb79b67edcd7b37331f67880b1 + lexical: 0.22.0 + checksum: dedc45cec5e1bd6249c3debded120d0c9b09c924dc0e6625d2d6d9e1ce08625722510f0beb8380ce8bb96f3006510375450e88a80fbc366c45ad6df6e660f4ff languageName: node linkType: hard -"@lexical/history@npm:0.16.0": - version: 0.16.0 - resolution: "@lexical/history@npm:0.16.0" +"@lexical/history@npm:0.22.0": + version: 0.22.0 + resolution: "@lexical/history@npm:0.22.0" dependencies: - "@lexical/utils": 0.16.0 - lexical: 0.16.0 - checksum: a26311ddcc2a283eb069abd4fc6963d3401b57e618bfdb061a7f36b376a04af32223b3d63575185cf7e38de34416efe4e184979f42a4a71395ffad54e5337cf0 + "@lexical/utils": 0.22.0 + lexical: 0.22.0 + checksum: 8eb683a5bbe6ab1c5936be81d480a1519c7c2b0931b1957e71a1b873655155967635b18fc26f8a6228b0c8e0dc7c0c4b7e3e91bce064d003d9609350916bfed8 languageName: node linkType: hard -"@lexical/html@npm:0.16.0": - version: 0.16.0 - resolution: "@lexical/html@npm:0.16.0" +"@lexical/html@npm:0.22.0": + version: 0.22.0 + resolution: "@lexical/html@npm:0.22.0" dependencies: - "@lexical/selection": 0.16.0 - "@lexical/utils": 0.16.0 - lexical: 0.16.0 - checksum: 3b3ffa982318a46bfa189805352dda6e3139b10c2b9e4242efce98037bbb26eeb7656bd169b5e2666503cd91cdf93ac7e154f10905eb9cffa4a092b11e0811d9 + "@lexical/selection": 0.22.0 + "@lexical/utils": 0.22.0 + lexical: 0.22.0 + checksum: 14e32af4fbe3ee06cb48587ba6302e451360f6d3dbacef191032d80464727593d7fe98a44875809666ba8cd169c73241cd841326cf54edef235ddb24515d7ef0 languageName: node linkType: hard -"@lexical/link@npm:0.16.0": - version: 0.16.0 - resolution: "@lexical/link@npm:0.16.0" +"@lexical/link@npm:0.22.0": + version: 0.22.0 + resolution: "@lexical/link@npm:0.22.0" dependencies: - "@lexical/utils": 0.16.0 - lexical: 0.16.0 - checksum: 2b2900001a97bf22550f0141dea358bbb7fe1b59bffe7506afd5e834ec722371de4d62b9e9899a4a960d3d85369bfe3faf5ba79367640b9e45b7bcff46bf1409 + "@lexical/utils": 0.22.0 + lexical: 0.22.0 + checksum: f36c3d3a7e05308f02b402a4645bf00ffe8f61223c7a8f8e59c61ee8fabdbf77aac95d7a6e04c68490aa5b701a620fa89cd323a135963f85f5d82a5e6417efae languageName: node linkType: hard -"@lexical/list@npm:0.16.0": - version: 0.16.0 - resolution: "@lexical/list@npm:0.16.0" +"@lexical/list@npm:0.22.0": + version: 0.22.0 + resolution: "@lexical/list@npm:0.22.0" dependencies: - "@lexical/utils": 0.16.0 - lexical: 0.16.0 - checksum: f60fd40d03b276624b67371498f42cd70fb8ad6971d0c3e396681e8f3c2fc2d9678472912363388c4b7913c93bc526f2400b925dbc3cfcdb61aea06a0af53a0b + "@lexical/utils": 0.22.0 + lexical: 0.22.0 + checksum: 7ee86ccc5686a23c365b38c3df3e6c1da560dfc6d7e4ad66e06d9e1b759b68276e1b24bb0f94906462e20d7778a55897909030ff35f03836e178b8ce68d70c1e languageName: node linkType: hard -"@lexical/list@patch:@lexical/list@npm:0.16.0#.yarn/patches/@lexical-list-npm-0.16.0-8f91da4ad5.patch::locator=%40standardnotes%2Fapp-monorepo%40workspace%3A.": - version: 0.16.0 - resolution: "@lexical/list@patch:@lexical/list@npm%3A0.16.0#.yarn/patches/@lexical-list-npm-0.16.0-8f91da4ad5.patch::version=0.16.0&hash=6af727&locator=%40standardnotes%2Fapp-monorepo%40workspace%3A." +"@lexical/mark@npm:0.22.0": + version: 0.22.0 + resolution: "@lexical/mark@npm:0.22.0" dependencies: - "@lexical/utils": 0.16.0 - lexical: 0.16.0 - checksum: bb546181595b39180ce4b733f36ea34adf1b6f89cdee1ffd74b4ece4b299e9ef51a0b269e8eb90dcbff10b78f2f3ddd333d611a7c91defe218f2b717cf9ca93b + "@lexical/utils": 0.22.0 + lexical: 0.22.0 + checksum: c3cf36c47b03944d90f67d4ced88f4e6702c629647e4e0ba70ee5fbcbd3fab424b7602f55b63c37bafdcc146fcaf2186348ed6fa08ef586ad6ce5d6320ba66a9 languageName: node linkType: hard -"@lexical/mark@npm:0.16.0": - version: 0.16.0 - resolution: "@lexical/mark@npm:0.16.0" +"@lexical/markdown@npm:0.22.0": + version: 0.22.0 + resolution: "@lexical/markdown@npm:0.22.0" dependencies: - "@lexical/utils": 0.16.0 - lexical: 0.16.0 - checksum: 08067e266d0518bce4aa402e73dc066a6be3af138a4cee76f2255725b2032248bdc4ebd98a85b19923c441853cfde154f12e3b87eae8ae203bca30f0e4d49700 + "@lexical/code": 0.22.0 + "@lexical/link": 0.22.0 + "@lexical/list": 0.22.0 + "@lexical/rich-text": 0.22.0 + "@lexical/text": 0.22.0 + "@lexical/utils": 0.22.0 + lexical: 0.22.0 + checksum: 0e2c371ead6434be1bc62eda95fe19a15a638382c659921f83bc41f5f2229de3f74982cc9ab1a9e7bcd5831fcd273d262f9d94d094300a4901ed48205f4dfafe languageName: node linkType: hard -"@lexical/markdown@npm:0.16.0": - version: 0.16.0 - resolution: "@lexical/markdown@npm:0.16.0" +"@lexical/offset@npm:0.22.0": + version: 0.22.0 + resolution: "@lexical/offset@npm:0.22.0" dependencies: - "@lexical/code": 0.16.0 - "@lexical/link": 0.16.0 - "@lexical/list": 0.16.0 - "@lexical/rich-text": 0.16.0 - "@lexical/text": 0.16.0 - "@lexical/utils": 0.16.0 - lexical: 0.16.0 - checksum: 2d061e4a3b0f8eee0c7975cfff8043601a435aece33c06c0e717a639cf680fa68e3727b95247468cb55d81e1d8970ee8ea8b9348d8bef755b968dc306be19792 + lexical: 0.22.0 + checksum: 9172370f74f8c9f444a3bba778975de340b61d232d2736a392e2fa4506953819e9131f6369c4a03afe2f913a288fffca8267e09a0943521b57e7e6ddeefe4d63 languageName: node linkType: hard -"@lexical/offset@npm:0.16.0": - version: 0.16.0 - resolution: "@lexical/offset@npm:0.16.0" +"@lexical/overflow@npm:0.22.0": + version: 0.22.0 + resolution: "@lexical/overflow@npm:0.22.0" dependencies: - lexical: 0.16.0 - checksum: c6c581be2f084d20aa2b1ef7b0d3deaac9b4550792f9278a35427d493d35d68aaf7ec2eb4357b5defa61c50001928c74199d7867a94670cda648944451bfbfbf + lexical: 0.22.0 + checksum: 9b486682927089e61de4243f7097da8f6c7f7cbf57e1c1da666b10e417c54a444459bc8daaca5b885c24d4cb427eb9ff1554606b01299c2bf645bf5a560b32f1 languageName: node linkType: hard -"@lexical/overflow@npm:0.16.0": - version: 0.16.0 - resolution: "@lexical/overflow@npm:0.16.0" +"@lexical/plain-text@npm:0.22.0": + version: 0.22.0 + resolution: "@lexical/plain-text@npm:0.22.0" dependencies: - lexical: 0.16.0 - checksum: 9b659e40537ffd09ab3f8a6ba7e61eb7adddaefb0dd4922d7cb912e2d94c606960a5d8e7737267fc36e95792526cb9b158f3605bedcdade0ce1594895ee0304b + "@lexical/clipboard": 0.22.0 + "@lexical/selection": 0.22.0 + "@lexical/utils": 0.22.0 + lexical: 0.22.0 + checksum: 1093ebfc11f13b0767dab3c1e29c55fbaae6b1ff1979d5c66b0e07f8589a2ba602b5c40633575d90152031623dc3cf66a12c5915e6606974b925389e9cedc02b languageName: node linkType: hard -"@lexical/plain-text@npm:0.16.0": - version: 0.16.0 - resolution: "@lexical/plain-text@npm:0.16.0" +"@lexical/react@npm:0.22.0": + version: 0.22.0 + resolution: "@lexical/react@npm:0.22.0" dependencies: - "@lexical/clipboard": 0.16.0 - "@lexical/selection": 0.16.0 - "@lexical/utils": 0.16.0 - lexical: 0.16.0 - checksum: 026a745849ed6cc6fe7b68cc1982f1be32fbe56c63a5afd27383f786482438cb38ab7b06d3e2cb8dfd0c689ea92d12ba6be62a453ea52c068e5df57c7489d453 - languageName: node - linkType: hard - -"@lexical/react@npm:0.16.0": - version: 0.16.0 - resolution: "@lexical/react@npm:0.16.0" - dependencies: - "@lexical/clipboard": 0.16.0 - "@lexical/code": 0.16.0 - "@lexical/devtools-core": 0.16.0 - "@lexical/dragon": 0.16.0 - "@lexical/hashtag": 0.16.0 - "@lexical/history": 0.16.0 - "@lexical/link": 0.16.0 - "@lexical/list": 0.16.0 - "@lexical/mark": 0.16.0 - "@lexical/markdown": 0.16.0 - "@lexical/overflow": 0.16.0 - "@lexical/plain-text": 0.16.0 - "@lexical/rich-text": 0.16.0 - "@lexical/selection": 0.16.0 - "@lexical/table": 0.16.0 - "@lexical/text": 0.16.0 - "@lexical/utils": 0.16.0 - "@lexical/yjs": 0.16.0 - lexical: 0.16.0 + "@lexical/clipboard": 0.22.0 + "@lexical/code": 0.22.0 + "@lexical/devtools-core": 0.22.0 + "@lexical/dragon": 0.22.0 + "@lexical/hashtag": 0.22.0 + "@lexical/history": 0.22.0 + "@lexical/link": 0.22.0 + "@lexical/list": 0.22.0 + "@lexical/mark": 0.22.0 + "@lexical/markdown": 0.22.0 + "@lexical/overflow": 0.22.0 + "@lexical/plain-text": 0.22.0 + "@lexical/rich-text": 0.22.0 + "@lexical/selection": 0.22.0 + "@lexical/table": 0.22.0 + "@lexical/text": 0.22.0 + "@lexical/utils": 0.22.0 + "@lexical/yjs": 0.22.0 + lexical: 0.22.0 react-error-boundary: ^3.1.4 peerDependencies: react: ">=17.x" react-dom: ">=17.x" - checksum: a58988010f1ae2182b0779280e92086bfe9c36f15baf96d069b1c81da48595579afaf01bbf69ecb3a10fdad01a32eda134bfe5efde31e545711c68516a088018 + checksum: 6d4f56be0bac9f7dd31b9855cab97b4b24bb93a5d998e6065ab6d0bc987fde42d674fc608547e47c108ef31250c7c77a703943560dd5d980629604a582d019b1 languageName: node linkType: hard -"@lexical/rich-text@npm:0.16.0": - version: 0.16.0 - resolution: "@lexical/rich-text@npm:0.16.0" +"@lexical/rich-text@npm:0.22.0": + version: 0.22.0 + resolution: "@lexical/rich-text@npm:0.22.0" dependencies: - "@lexical/clipboard": 0.16.0 - "@lexical/selection": 0.16.0 - "@lexical/utils": 0.16.0 - lexical: 0.16.0 - checksum: 00318a6a7813406e7f1c3fe7509c622ecaeb336c4b3c8bfef428cc7aa4dd5a8af4d2110e4884b6880ea28663b97ab0e8a9b3e9282de3fc7aa4aba910d215431e + "@lexical/clipboard": 0.22.0 + "@lexical/selection": 0.22.0 + "@lexical/utils": 0.22.0 + lexical: 0.22.0 + checksum: f7c7153b16406c41a4b770a11c6abb48eb919edb2e7cec36ffcebee4889e70110a0a03ee545572c96bf5f4dc1be233572fb4c2e0336016031460d203b486fa27 languageName: node linkType: hard -"@lexical/rich-text@patch:@lexical/rich-text@npm:0.16.0#.yarn/patches/@lexical-rich-text-npm-0.16.0-f484a17832.patch::locator=%40standardnotes%2Fapp-monorepo%40workspace%3A.": - version: 0.16.0 - resolution: "@lexical/rich-text@patch:@lexical/rich-text@npm%3A0.16.0#.yarn/patches/@lexical-rich-text-npm-0.16.0-f484a17832.patch::version=0.16.0&hash=24f58c&locator=%40standardnotes%2Fapp-monorepo%40workspace%3A." +"@lexical/rich-text@patch:@lexical/rich-text@npm:0.22.0#.yarn/patches/@lexical-rich-text-npm-0.22.0-1c32cc4b16.patch::locator=%40standardnotes%2Fapp-monorepo%40workspace%3A.": + version: 0.22.0 + resolution: "@lexical/rich-text@patch:@lexical/rich-text@npm%3A0.22.0#.yarn/patches/@lexical-rich-text-npm-0.22.0-1c32cc4b16.patch::version=0.22.0&hash=d9e598&locator=%40standardnotes%2Fapp-monorepo%40workspace%3A." dependencies: - "@lexical/clipboard": 0.16.0 - "@lexical/selection": 0.16.0 - "@lexical/utils": 0.16.0 - lexical: 0.16.0 - checksum: fb69c079641d385e4aa5f6568769051837fbd7dac9db264d10dcb95326bd79f94379cda43e157d53d7a01849722bd3ad82f15c7cff5f2fa365d203f41f5ad159 + "@lexical/clipboard": 0.22.0 + "@lexical/selection": 0.22.0 + "@lexical/utils": 0.22.0 + lexical: 0.22.0 + checksum: c6523beac513a4a654329813056e5e45a4ec089dcd7ba3767fcf7a8b6dab778725fdd1da1dc171929d15ca5afd7e57e4c36667df7b28e9cd1836c973dee5bb08 languageName: node linkType: hard -"@lexical/selection@npm:0.16.0": - version: 0.16.0 - resolution: "@lexical/selection@npm:0.16.0" +"@lexical/selection@npm:0.22.0": + version: 0.22.0 + resolution: "@lexical/selection@npm:0.22.0" dependencies: - lexical: 0.16.0 - checksum: fd4832f3b01018b4025706ea86ada3e3dd5a70e2b73722d993fb7e272c3fa2a339e22c914f5fb1836ae077a56daefc6b16dfa77477c56648135ef6ea5ba53f05 + lexical: 0.22.0 + checksum: 5c3f80944e8b55b911ddb08af3ff3529b0ce1708f9b86ba8a276ad248c61eea5df767e66c624efbab696941622e1114016fab06931f5f9340d2818fb93ed2d6f languageName: node linkType: hard -"@lexical/table@npm:0.16.0": - version: 0.16.0 - resolution: "@lexical/table@npm:0.16.0" +"@lexical/table@npm:0.22.0": + version: 0.22.0 + resolution: "@lexical/table@npm:0.22.0" dependencies: - "@lexical/utils": 0.16.0 - lexical: 0.16.0 - checksum: 484b6c53dd62aa679f71c9f2b602463de8cf64974a4c6c7052798f1f995b2b8805f2da7a34895fcc73fdaa9938f7a3785ca92a954ba9d79c0c126c496551ad40 + "@lexical/clipboard": 0.22.0 + "@lexical/utils": 0.22.0 + lexical: 0.22.0 + checksum: 6a8e3564ef7431fd0928ac85fc0e2fb517c1d12a2464ed99a2738241aca53bd904bcf9d04ad434b6c9f0d086c5735173cd3ae4a7d25d3635c547d56a9b65dee6 languageName: node linkType: hard -"@lexical/text@npm:0.16.0": - version: 0.16.0 - resolution: "@lexical/text@npm:0.16.0" +"@lexical/text@npm:0.22.0": + version: 0.22.0 + resolution: "@lexical/text@npm:0.22.0" dependencies: - lexical: 0.16.0 - checksum: 60eadf8d4c037af3a53dfb8c1168949529e02d1a7aaf31876eb9f0a790c4bc9b0c46747535fc03974c6a637e9a6dd0026d556bb0f61e918ad72e811987d08b65 + lexical: 0.22.0 + checksum: 82857b6c3b6cc4f2ad2264f9c3e87656f94bfaf4f879d538dd09ef1b7bb4eaade9b61001cf94618617baa7aebc14cdce00ce5d4687e2732171c3c33032e245eb languageName: node linkType: hard -"@lexical/utils@npm:0.16.0": - version: 0.16.0 - resolution: "@lexical/utils@npm:0.16.0" +"@lexical/utils@npm:0.22.0": + version: 0.22.0 + resolution: "@lexical/utils@npm:0.22.0" dependencies: - "@lexical/list": 0.16.0 - "@lexical/selection": 0.16.0 - "@lexical/table": 0.16.0 - lexical: 0.16.0 - checksum: b6696b83b9ef7027cd7b117c25e6d6e30266f73b892e72e9718e02190b925c050f51b83aae25782c7abc950b6ef31d89e3c09ae3e37cae82274fcd42c5a60958 + "@lexical/list": 0.22.0 + "@lexical/selection": 0.22.0 + "@lexical/table": 0.22.0 + lexical: 0.22.0 + checksum: 45e1e60f89e9dab45401db97ae1885260dad4436fefa1a2e752b7c3c1394322c3d28916c278e18c911a284676ab5cf850efb5cad2aa874281ee87a1ba31c409d languageName: node linkType: hard -"@lexical/yjs@npm:0.16.0": - version: 0.16.0 - resolution: "@lexical/yjs@npm:0.16.0" +"@lexical/yjs@npm:0.22.0": + version: 0.22.0 + resolution: "@lexical/yjs@npm:0.22.0" dependencies: - "@lexical/offset": 0.16.0 - lexical: 0.16.0 + "@lexical/offset": 0.22.0 + "@lexical/selection": 0.22.0 + lexical: 0.22.0 peerDependencies: yjs: ">=13.5.22" - checksum: 906056977928fa605593ee9fb323e37905960f97b7ef59ae20065f7644b51db72ddb8ef8ae1020c0a0b9bec9c2b18ed276c32ee5f4aabe4bc811cb8be102e9ac + checksum: 3ffe2fa446e542fd0af085ccbf015769ac65831977e3b3cbe3a37700442a7a042242d9cd2f27f078a4eaf09e76448c129a68aa05cc2b6808a813e0dee6b8de02 languageName: node linkType: hard @@ -8338,13 +8330,13 @@ __metadata: "@babel/plugin-transform-react-jsx": ^7.19.0 "@babel/preset-env": "*" "@babel/preset-typescript": ^7.21.5 - "@lexical/clipboard": 0.16.0 - "@lexical/headless": 0.16.0 - "@lexical/link": 0.16.0 - "@lexical/list": 0.16.0 - "@lexical/react": 0.16.0 - "@lexical/rich-text": 0.16.0 - "@lexical/utils": 0.16.0 + "@lexical/clipboard": 0.22.0 + "@lexical/headless": 0.22.0 + "@lexical/link": 0.22.0 + "@lexical/list": 0.22.0 + "@lexical/react": 0.22.0 + "@lexical/rich-text": 0.22.0 + "@lexical/utils": 0.22.0 "@pmmmwh/react-refresh-webpack-plugin": ^0.5.10 "@radix-ui/react-slot": ^1.0.1 "@react-pdf/renderer": ^3.3.2 @@ -8396,7 +8388,7 @@ __metadata: identity-obj-proxy: ^3.0.0 jest: ^29.3.1 jest-environment-jsdom: ^29.3.1 - lexical: 0.16.0 + lexical: 0.22.0 lint-staged: ">=13" mini-css-extract-plugin: ^2.7.2 minimatch: ^5.1.1 @@ -19442,10 +19434,10 @@ __metadata: languageName: node linkType: hard -"lexical@npm:0.16.0": - version: 0.16.0 - resolution: "lexical@npm:0.16.0" - checksum: ef43cf65dd30e044f7bbab1e56078b8ebee70a4182e517d1379c190d90174c04550c86921780360ad154fc78ce11cdd859bb0b8824971d072a38e0833166fe18 +"lexical@npm:0.22.0": + version: 0.22.0 + resolution: "lexical@npm:0.22.0" + checksum: 54153b6d31b007f45181317c6d18117c107dae90493f02f06b82c28488f266329431878c2ffe1af2df2638d3de363f5020d7a5019436531b220c3e1dea608938 languageName: node linkType: hard