Bring projects, wikis, and teams together with AI. AppFlowy is the AI collaborative workspace where you achieve more without losing control of your data. The leading open source Notion alternative.
Dart blogconfluence-alternativecontent-managementcontent-servicesdocumentationflutternote-takingnotion-alternativeproject-managementtask-managementteam-collaborationwiki
feat: support pasted on web (#6510)
Kilu.He580a23f3f5cc
diff --git a/frontend/appflowy_web_app/cypress/snapshots/behavior/BackspaceKeyBehavior/should-convert-non-paragraph-block-to-paragraph.snap.png b/frontend/appflowy_web_app/cypress/snapshots/behavior/BackspaceKeyBehavior/should-convert-non-paragraph-block-to-paragraph.snap.pngdeleted file mode 100644index 07973fe583..0000000000Binary files a/frontend/appflowy_web_app/cypress/snapshots/behavior/BackspaceKeyBehavior/should-convert-non-paragraph-block-to-paragraph.snap.png and /dev/null differdiff --git a/frontend/appflowy_web_app/cypress/snapshots/behavior/BackspaceKeyBehavior/should-delete-content-across-different-nesting-levels.snap.png b/frontend/appflowy_web_app/cypress/snapshots/behavior/BackspaceKeyBehavior/should-delete-content-across-different-nesting-levels.snap.pngdeleted file mode 100644index 36a2c9024e..0000000000Binary files a/frontend/appflowy_web_app/cypress/snapshots/behavior/BackspaceKeyBehavior/should-delete-content-across-different-nesting-levels.snap.png and /dev/null differdiff --git a/frontend/appflowy_web_app/cypress/snapshots/behavior/BackspaceKeyBehavior/should-delete-content-across-multiple-blocks.snap.png b/frontend/appflowy_web_app/cypress/snapshots/behavior/BackspaceKeyBehavior/should-delete-content-across-multiple-blocks.snap.pngdeleted file mode 100644index ca11a83b5d..0000000000Binary files a/frontend/appflowy_web_app/cypress/snapshots/behavior/BackspaceKeyBehavior/should-delete-content-across-multiple-blocks.snap.png and /dev/null differdiff --git a/frontend/appflowy_web_app/cypress/snapshots/behavior/BackspaceKeyBehavior/should-delete-entire-nested-structure.snap.png b/frontend/appflowy_web_app/cypress/snapshots/behavior/BackspaceKeyBehavior/should-delete-entire-nested-structure.snap.pngdeleted file mode 100644index 5ced87aa2f..0000000000Binary files a/frontend/appflowy_web_app/cypress/snapshots/behavior/BackspaceKeyBehavior/should-delete-entire-nested-structure.snap.png and /dev/null differdiff --git a/frontend/appflowy_web_app/cypress/snapshots/behavior/BackspaceKeyBehavior/should-delete-nested-content-within-a-toggle-list.snap.png b/frontend/appflowy_web_app/cypress/snapshots/behavior/BackspaceKeyBehavior/should-delete-nested-content-within-a-toggle-list.snap.pngdeleted file mode 100644index 0f9330e3e4..0000000000Binary files a/frontend/appflowy_web_app/cypress/snapshots/behavior/BackspaceKeyBehavior/should-delete-nested-content-within-a-toggle-list.snap.png and /dev/null differdiff --git a/frontend/appflowy_web_app/cypress/snapshots/behavior/BackspaceKeyBehavior/should-handle-backspace-at-start-of-document.snap.png b/frontend/appflowy_web_app/cypress/snapshots/behavior/BackspaceKeyBehavior/should-handle-backspace-at-start-of-document.snap.pngdeleted file mode 100644index d0b6b16b0a..0000000000Binary files a/frontend/appflowy_web_app/cypress/snapshots/behavior/BackspaceKeyBehavior/should-handle-backspace-at-start-of-document.snap.png and /dev/null differdiff --git a/frontend/appflowy_web_app/cypress/snapshots/behavior/BackspaceKeyBehavior/should-handle-deletion-of-deeply-nested-content.snap.png b/frontend/appflowy_web_app/cypress/snapshots/behavior/BackspaceKeyBehavior/should-handle-deletion-of-deeply-nested-content.snap.pngdeleted file mode 100644index fe96b4812d..0000000000Binary files a/frontend/appflowy_web_app/cypress/snapshots/behavior/BackspaceKeyBehavior/should-handle-deletion-of-deeply-nested-content.snap.png and /dev/null differdiff --git a/frontend/appflowy_web_app/cypress/snapshots/behavior/BackspaceKeyBehavior/should-lift-nested-paragraph.snap.png b/frontend/appflowy_web_app/cypress/snapshots/behavior/BackspaceKeyBehavior/should-lift-nested-paragraph.snap.pngdeleted file mode 100644index 3da0725a90..0000000000Binary files a/frontend/appflowy_web_app/cypress/snapshots/behavior/BackspaceKeyBehavior/should-lift-nested-paragraph.snap.png and /dev/null differdiff --git a/frontend/appflowy_web_app/cypress/snapshots/behavior/BackspaceKeyBehavior/should-maintain-structure-when-deleting-partial-content.snap.png b/frontend/appflowy_web_app/cypress/snapshots/behavior/BackspaceKeyBehavior/should-maintain-structure-when-deleting-partial-content.snap.pngdeleted file mode 100644index 63936e47bd..0000000000Binary files a/frontend/appflowy_web_app/cypress/snapshots/behavior/BackspaceKeyBehavior/should-maintain-structure-when-deleting-partial-content.snap.png and /dev/null differdiff --git a/frontend/appflowy_web_app/cypress/snapshots/behavior/BackspaceKeyBehavior/should-merge-nested-toggle-list.snap.png b/frontend/appflowy_web_app/cypress/snapshots/behavior/BackspaceKeyBehavior/should-merge-nested-toggle-list.snap.pngdeleted file mode 100644index 1b9b0cae9c..0000000000Binary files a/frontend/appflowy_web_app/cypress/snapshots/behavior/BackspaceKeyBehavior/should-merge-nested-toggle-list.snap.png and /dev/null differdiff --git a/frontend/appflowy_web_app/cypress/snapshots/behavior/BackspaceKeyBehavior/should-merge-paragraphs.snap.png b/frontend/appflowy_web_app/cypress/snapshots/behavior/BackspaceKeyBehavior/should-merge-paragraphs.snap.pngdeleted file mode 100644index 3e0cdf2644..0000000000Binary files a/frontend/appflowy_web_app/cypress/snapshots/behavior/BackspaceKeyBehavior/should-merge-paragraphs.snap.png and /dev/null differdiff --git a/frontend/appflowy_web_app/cypress/snapshots/behavior/ShiftTabKeyBehavior/should-not-outdent-at-top-level.snap.png b/frontend/appflowy_web_app/cypress/snapshots/behavior/ShiftTabKeyBehavior/should-not-outdent-at-top-level.snap.pngdeleted file mode 100644index 79f64bb421..0000000000Binary files a/frontend/appflowy_web_app/cypress/snapshots/behavior/ShiftTabKeyBehavior/should-not-outdent-at-top-level.snap.png and /dev/null differdiff --git a/frontend/appflowy_web_app/cypress/snapshots/behavior/ShiftTabKeyBehavior/should-outdent-deeply-nested-paragraph.snap.png b/frontend/appflowy_web_app/cypress/snapshots/behavior/ShiftTabKeyBehavior/should-outdent-deeply-nested-paragraph.snap.pngdeleted file mode 100644index d3d3f42cba..0000000000Binary files a/frontend/appflowy_web_app/cypress/snapshots/behavior/ShiftTabKeyBehavior/should-outdent-deeply-nested-paragraph.snap.png and /dev/null differdiff --git a/frontend/appflowy_web_app/cypress/snapshots/behavior/ShiftTabKeyBehavior/should-outdent-nested-toggle-list.snap.png b/frontend/appflowy_web_app/cypress/snapshots/behavior/ShiftTabKeyBehavior/should-outdent-nested-toggle-list.snap.pngdeleted file mode 100644index 5e227811fb..0000000000Binary files a/frontend/appflowy_web_app/cypress/snapshots/behavior/ShiftTabKeyBehavior/should-outdent-nested-toggle-list.snap.png and /dev/null differdiff --git a/frontend/appflowy_web_app/cypress/snapshots/behavior/TabKeyBehavior/should-indent-nested-block-at-index-0-1.snap.png b/frontend/appflowy_web_app/cypress/snapshots/behavior/TabKeyBehavior/should-indent-nested-block-at-index-0-1.snap.pngdeleted file mode 100644index e6df020548..0000000000Binary files a/frontend/appflowy_web_app/cypress/snapshots/behavior/TabKeyBehavior/should-indent-nested-block-at-index-0-1.snap.png and /dev/null differdiff --git a/frontend/appflowy_web_app/cypress/snapshots/behavior/TabKeyBehavior/should-indent-paragraph.snap.png b/frontend/appflowy_web_app/cypress/snapshots/behavior/TabKeyBehavior/should-indent-paragraph.snap.pngdeleted file mode 100644index 3a3a7bf6d2..0000000000Binary files a/frontend/appflowy_web_app/cypress/snapshots/behavior/TabKeyBehavior/should-indent-paragraph.snap.png and /dev/null differdiff --git a/frontend/appflowy_web_app/cypress/snapshots/behavior/TabKeyBehavior/should-not-indent-at-start-of-document.snap.png b/frontend/appflowy_web_app/cypress/snapshots/behavior/TabKeyBehavior/should-not-indent-at-start-of-document.snap.pngdeleted file mode 100644index d0b6b16b0a..0000000000Binary files a/frontend/appflowy_web_app/cypress/snapshots/behavior/TabKeyBehavior/should-not-indent-at-start-of-document.snap.png and /dev/null differdiff --git a/frontend/appflowy_web_app/cypress/snapshots/behavior/TabKeyBehavior/should-not-indent-at-start-of-nested-block.snap.png b/frontend/appflowy_web_app/cypress/snapshots/behavior/TabKeyBehavior/should-not-indent-at-start-of-nested-block.snap.pngdeleted file mode 100644index 67ffdfa5ea..0000000000Binary files a/frontend/appflowy_web_app/cypress/snapshots/behavior/TabKeyBehavior/should-not-indent-at-start-of-nested-block.snap.png and /dev/null differdiff --git a/frontend/appflowy_web_app/cypress/snapshots/behavior/enter-key-behavior-empty-block-2.snap.png b/frontend/appflowy_web_app/cypress/snapshots/behavior/enter-key-behavior-empty-block-2.snap.pngdeleted file mode 100644index 4eda675a9d..0000000000Binary files a/frontend/appflowy_web_app/cypress/snapshots/behavior/enter-key-behavior-empty-block-2.snap.png and /dev/null differdiff --git a/frontend/appflowy_web_app/cypress/snapshots/behavior/enter-key-behavior-empty-block.snap.png b/frontend/appflowy_web_app/cypress/snapshots/behavior/enter-key-behavior-empty-block.snap.pngdeleted file mode 100644index 97d26112ec..0000000000Binary files a/frontend/appflowy_web_app/cypress/snapshots/behavior/enter-key-behavior-empty-block.snap.png and /dev/null differdiff --git a/frontend/appflowy_web_app/cypress/snapshots/behavior/enter-key-behavior-nested-paragraphs.snap.png b/frontend/appflowy_web_app/cypress/snapshots/behavior/enter-key-behavior-nested-paragraphs.snap.pngdeleted file mode 100644index 82633fb554..0000000000Binary files a/frontend/appflowy_web_app/cypress/snapshots/behavior/enter-key-behavior-nested-paragraphs.snap.png and /dev/null differdiff --git a/frontend/appflowy_web_app/cypress/snapshots/behavior/enter-key-behavior-range-selection-across-blocks.snap.png b/frontend/appflowy_web_app/cypress/snapshots/behavior/enter-key-behavior-range-selection-across-blocks.snap.pngdeleted file mode 100644index 9a64138a8a..0000000000Binary files a/frontend/appflowy_web_app/cypress/snapshots/behavior/enter-key-behavior-range-selection-across-blocks.snap.png and /dev/null differdiff --git a/frontend/appflowy_web_app/cypress/snapshots/behavior/enter-key-behavior-range-selection-different-anchor-focus.snap.png b/frontend/appflowy_web_app/cypress/snapshots/behavior/enter-key-behavior-range-selection-different-anchor-focus.snap.pngdeleted file mode 100644index 857ad9a5b0..0000000000Binary files a/frontend/appflowy_web_app/cypress/snapshots/behavior/enter-key-behavior-range-selection-different-anchor-focus.snap.png and /dev/null differdiff --git a/frontend/appflowy_web_app/cypress/snapshots/behavior/enter-key-behavior-range-selection-different-nesting-levels-1.snap.png b/frontend/appflowy_web_app/cypress/snapshots/behavior/enter-key-behavior-range-selection-different-nesting-levels-1.snap.pngdeleted file mode 100644index 59a8fa67b5..0000000000Binary files a/frontend/appflowy_web_app/cypress/snapshots/behavior/enter-key-behavior-range-selection-different-nesting-levels-1.snap.png and /dev/null differdiff --git a/frontend/appflowy_web_app/cypress/snapshots/behavior/enter-key-behavior-range-selection-different-nesting-levels-2.snap.png b/frontend/appflowy_web_app/cypress/snapshots/behavior/enter-key-behavior-range-selection-different-nesting-levels-2.snap.pngdeleted file mode 100644index 020de21320..0000000000Binary files a/frontend/appflowy_web_app/cypress/snapshots/behavior/enter-key-behavior-range-selection-different-nesting-levels-2.snap.png and /dev/null differdiff --git a/frontend/appflowy_web_app/cypress/snapshots/behavior/enter-key-behavior-range-selection-different-nesting-levels-3.snap.png b/frontend/appflowy_web_app/cypress/snapshots/behavior/enter-key-behavior-range-selection-different-nesting-levels-3.snap.pngdeleted file mode 100644index 2749f96402..0000000000Binary files a/frontend/appflowy_web_app/cypress/snapshots/behavior/enter-key-behavior-range-selection-different-nesting-levels-3.snap.png and /dev/null differdiff --git a/frontend/appflowy_web_app/cypress/snapshots/behavior/enter-key-behavior-range-selection-different-nesting-levels-4.snap.png b/frontend/appflowy_web_app/cypress/snapshots/behavior/enter-key-behavior-range-selection-different-nesting-levels-4.snap.pngdeleted file mode 100644index 505c4a6c50..0000000000Binary files a/frontend/appflowy_web_app/cypress/snapshots/behavior/enter-key-behavior-range-selection-different-nesting-levels-4.snap.png and /dev/null differdiff --git a/frontend/appflowy_web_app/cypress/snapshots/behavior/enter-key-behavior-range-selection-same-level-blocks.snap.png b/frontend/appflowy_web_app/cypress/snapshots/behavior/enter-key-behavior-range-selection-same-level-blocks.snap.pngdeleted file mode 100644index 1e36d95a75..0000000000Binary files a/frontend/appflowy_web_app/cypress/snapshots/behavior/enter-key-behavior-range-selection-same-level-blocks.snap.png and /dev/null differdiff --git a/frontend/appflowy_web_app/cypress/snapshots/behavior/enter-key-behavior-range-selection-single-block.snap.png b/frontend/appflowy_web_app/cypress/snapshots/behavior/enter-key-behavior-range-selection-single-block.snap.pngdeleted file mode 100644index 845da3eb59..0000000000Binary files a/frontend/appflowy_web_app/cypress/snapshots/behavior/enter-key-behavior-range-selection-single-block.snap.png and /dev/null differdiff --git a/frontend/appflowy_web_app/cypress/snapshots/behavior/enter-key-behavior-range-selections.snap.png b/frontend/appflowy_web_app/cypress/snapshots/behavior/enter-key-behavior-range-selections.snap.pngdeleted file mode 100644index e6e5ebde7e..0000000000Binary files a/frontend/appflowy_web_app/cypress/snapshots/behavior/enter-key-behavior-range-selections.snap.png and /dev/null differdiff --git a/frontend/appflowy_web_app/cypress/snapshots/behavior/enter-key-behavior-split-paragraph-block.snap.png b/frontend/appflowy_web_app/cypress/snapshots/behavior/enter-key-behavior-split-paragraph-block.snap.pngdeleted file mode 100644index 20a7962dda..0000000000Binary files a/frontend/appflowy_web_app/cypress/snapshots/behavior/enter-key-behavior-split-paragraph-block.snap.png and /dev/null differdiff --git a/frontend/appflowy_web_app/cypress/snapshots/behavior/enter-key-behavior-toggle-list-collapsed.snap.png b/frontend/appflowy_web_app/cypress/snapshots/behavior/enter-key-behavior-toggle-list-collapsed.snap.pngdeleted file mode 100644index b87775e5a7..0000000000Binary files a/frontend/appflowy_web_app/cypress/snapshots/behavior/enter-key-behavior-toggle-list-collapsed.snap.png and /dev/null differdiff --git a/frontend/appflowy_web_app/cypress/snapshots/behavior/enter-key-behavior-toggle-list.snap.png b/frontend/appflowy_web_app/cypress/snapshots/behavior/enter-key-behavior-toggle-list.snap.pngdeleted file mode 100644index 565a248330..0000000000Binary files a/frontend/appflowy_web_app/cypress/snapshots/behavior/enter-key-behavior-toggle-list.snap.png and /dev/null differdiff --git a/frontend/appflowy_web_app/cypress/snapshots/paragraph/editing-text-with-undo-redo.snap.png b/frontend/appflowy_web_app/cypress/snapshots/paragraph/editing-text-with-undo-redo.snap.pngdeleted file mode 100644index ecb9a09cf5..0000000000Binary files a/frontend/appflowy_web_app/cypress/snapshots/paragraph/editing-text-with-undo-redo.snap.png and /dev/null differdiff --git a/frontend/appflowy_web_app/cypress/snapshots/paragraph/editing-text.snap.png b/frontend/appflowy_web_app/cypress/snapshots/paragraph/editing-text.snap.pngdeleted file mode 100644index bce99702ab..0000000000Binary files a/frontend/appflowy_web_app/cypress/snapshots/paragraph/editing-text.snap.png and /dev/null differdiff --git a/frontend/appflowy_web_app/cypress/snapshots/paragraph/initial-render.snap.png b/frontend/appflowy_web_app/cypress/snapshots/paragraph/initial-render.snap.pngdeleted file mode 100644index cf4429601a..0000000000Binary files a/frontend/appflowy_web_app/cypress/snapshots/paragraph/initial-render.snap.png and /dev/null differdiff --git a/frontend/appflowy_web_app/cypress/snapshots/paragraph/inline-formatting.snap.png b/frontend/appflowy_web_app/cypress/snapshots/paragraph/inline-formatting.snap.pngdeleted file mode 100644index 07f89a9ada..0000000000Binary files a/frontend/appflowy_web_app/cypress/snapshots/paragraph/inline-formatting.snap.png and /dev/null differdiff --git a/frontend/appflowy_web_app/cypress/snapshots/shortcuts/BIUS.cy.snap.png b/frontend/appflowy_web_app/cypress/snapshots/shortcuts/BIUS.cy.snap.pngdeleted file mode 100644index ea983815ce..0000000000Binary files a/frontend/appflowy_web_app/cypress/snapshots/shortcuts/BIUS.cy.snap.png and /dev/null differdiff --git a/frontend/appflowy_web_app/package.json b/frontend/appflowy_web_app/package.jsonindex 9eb8699d4e..77b5f09af4 100644--- a/frontend/appflowy_web_app/package.json+++ b/frontend/appflowy_web_app/package.json@@ -49,7 +49,9 @@"escape-string-regexp": "^5.0.0","events": "^3.3.0","google-protobuf": "^3.15.12",+ "hast-util-to-mdast": "^10.1.0","highlight.js": "^11.10.0",+ "html-parse-stringify": "^3.0.1","i18next": "^22.4.10","i18next-browser-languagedetector": "^7.0.1","i18next-resources-to-backend": "^1.1.4",@@ -91,6 +93,7 @@"react-zoom-pan-pinch": "^3.6.1","react18-input-otp": "^1.1.2","redux": "^4.2.1",+ "rehype-parse": "^9.0.1","rxjs": "^7.8.0","sass": "^1.70.0","slate": "^0.101.4",@@ -98,6 +101,8 @@"slate-react": "^0.101.3","smooth-scroll-into-view-if-needed": "^2.0.2","ts-results": "^3.3.0",+ "unified": "^11.0.5",+ "unist": "^0.0.1","unsplash-js": "^7.0.19","utf8": "^3.0.0","validator": "^13.11.0",diff --git a/frontend/appflowy_web_app/pnpm-lock.yaml b/frontend/appflowy_web_app/pnpm-lock.yamlindex eecd89ab68..67abd8d431 100644--- a/frontend/appflowy_web_app/pnpm-lock.yaml+++ b/frontend/appflowy_web_app/pnpm-lock.yaml@@ -80,9 +80,15 @@ dependencies:google-protobuf:specifier: ^3.15.12version: 3.21.2+ hast-util-to-mdast:+ specifier: ^10.1.0+ version: 10.1.0highlight.js:specifier: ^11.10.0version: 11.10.0+ html-parse-stringify:+ specifier: ^3.0.1+ version: 3.0.1i18next:specifier: ^22.4.10version: 22.5.1@@ -206,6 +212,9 @@ dependencies:redux:specifier: ^4.2.1version: 4.2.1+ rehype-parse:+ specifier: ^9.0.1+ version: 9.0.1rxjs:specifier: ^7.8.0version: 7.8.0@@ -227,6 +236,12 @@ dependencies:ts-results:specifier: ^3.3.0version: 3.3.0+ unified:+ specifier: ^11.0.5+ version: 11.0.5+ unist:+ specifier: ^0.0.1+ version: 0.0.1unsplash-js:specifier: ^7.0.19version: 7.0.19@@ -4110,6 +4125,12 @@ packages:dependencies:'@types/node': 20.11.30+ /@types/[email protected]:+ resolution: {integrity: sha512-WPs+bbQw5aCj+x6laNGWLH3wviHtoCv/P3+otBhbOhJgG8qtpdAMlTCxLtsTWA7LH1Oh/bFCHsBn0TPS5m30EQ==}+ dependencies:+ '@types/unist': 3.0.3+ dev: false+/@types/[email protected]:resolution: {integrity: sha512-SbcrWzkKBw2cdwRTwQAswfpB9g9LJWfjtUeW/jvNwbhC8cpmmNYVePa+ncbUe0rGTQ7G3Ff6mYUN2VMfLVr+Sg==}dependencies:@@ -4170,6 +4191,12 @@ packages:/@types/[email protected]:resolution: {integrity: sha512-t7dhREVv6dbNj0q17X12j7yDG4bD/DHYX7o5/DbDxobP0HnGPgpRz2Ej77aL7TZT3DSw13fqUTj8J4mMnqa7WA==}+ /@types/[email protected]:+ resolution: {integrity: sha512-kGaNbPh1k7AFzgpud/gMdvIm5xuECykRR+JnWKQno9TAXVa6WIVCGTPvYGekIDL4uwCZQSYbUxNBSb1aUo79oA==}+ dependencies:+ '@types/unist': 3.0.3+ dev: false+/@types/[email protected]:resolution: {integrity: sha512-dHM6ZxwlmuZaRmUPfv1p+KrdD1Dci04FbdEm/9wEMouFqxYoFl5aMkt0VMAUtYRQDyYvD41WJLukhq/ha3YuTw==}dependencies:@@ -4334,6 +4361,10 @@ packages:resolution: {integrity: sha512-/Ad8+nIOV7Rl++6f1BdKxFSMgmoqEoYbHRpPcx3JEfv8VRsQe9Z4mCXeJBzxs7mbHY/XOZZuXlRNfhpVPbs6ZA==}dev: true+ /@types/[email protected]:+ resolution: {integrity: sha512-ko/gIFJRv177XgZsZcBwnqJN5x/Gien8qNOn0D5bQU/zAzVf9Zt3BlcUiLqhV9y4ARk0GbT3tnUiPNgnTXzc/Q==}+ dev: false+/@types/[email protected]:resolution: {integrity: sha512-EwmlvuaxPNej9+T4v5AuBPJa2x2UOJVdjCtDHgcDqitUeOtjnJKJ+apYjVcAoBEMjKW1VVFGZLUb5+qqa09XFA==}dev: false@@ -4504,7 +4535,6 @@ packages:/@ungap/[email protected]:resolution: {integrity: sha512-zuVdFrMJiuCDQUMCzQaD6KL28MjnqqN8XnAqiEq9PNm/hCPTSGfrXCOfwj1ow4LFb/tNymJPwsNbVePc1xFqrQ==}- dev: true/@vitejs/[email protected]([email protected]):resolution: {integrity: sha512-oojO9IDc4nCUUi8qIR11KoQm0XFFLIwsRBwHRR4d/88IWghn1y6ckz/bJ8GHDCsYEJee8mDzqtJxh15/cisJNQ==}@@ -5182,6 +5212,10 @@ packages:babel-plugin-jest-hoist: 29.6.3babel-preset-current-node-syntax: 1.0.1(@babel/[email protected])+ resolution: {integrity: sha512-0xO6mYd7JB2YesxDKplafRpsiOzPt9V02ddPCLbY1xYGPOX24NTyN50qnUxgCPcSoYMhKpAuBTjQoRZCAkUDRw==}+ dev: false+resolution: {integrity: sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==}@@ -5354,6 +5388,10 @@ packages:resolution: {integrity: sha512-4tYFyifaFfGacoiObjJegolkwSU4xQNGbVgUiNYVUxbQ2x2lUsFvY4hVgVzGiIe6WLOPqycWXA40l+PWsxthUw==}+ resolution: {integrity: sha512-eyrF0jiFpY+3drT6383f1qhkbGsLSifNAjA61IUjZjmLCWjItY6LB9ft9YhoDgwfmclB2zhu51Lc7+95b8NRAg==}+ dev: false+resolution: {integrity: sha512-U3lRVLMSlsCfjqYPbLyVv11M9CPW4I728d6TCKMAOJueEeB9/8o+eSsMnxPJD+Q+K909sdESg7C+tIkoH6on1A==}engines: {node: '>=0.10.0'}@@ -5406,6 +5444,14 @@ packages:resolution: {integrity: sha512-kWWXztvZ5SBQV+eRgKFeh8q5sLuZY2+8WUIzlxWVTg+oGwY14qylx1KbKzHd8P6ZYkAg0xyIDU9JMHhyJMZ1jw==}engines: {node: '>=10'}+ resolution: {integrity: sha512-1v7fgQRj6hnSwFpq1Eu0ynr/CDEw0rXo2B61qXrLNdHZmPKgb7fqS1a2JwF0rISo9q77jDI8VMEHoApn8qDoZA==}+ dev: false++ resolution: {integrity: sha512-RpPp0asT/6ufRm//AJVwpViZbGM/MkjQFxJccQRHmISF/22NBtsHqAWmL+/pmkPWoIUJdWyeVleTl1wydHATVQ==}+ dev: false+resolution: {integrity: sha512-Pj779qHxV2tuapviy1bSZNEL1maXr13bPYpsvSDB68HlYcYuhlDrmGd63i0JHMCLKzc7rUSNIrpdJlhVlNwrxA==}engines: {node: '>= 0.8.0'}@@ -5575,6 +5621,10 @@ packages:dependencies:delayed-stream: 1.0.0+ resolution: {integrity: sha512-Fu4hJdvzeylCfQPp9SGWidpzrMs7tTrlu6Vb8XGaRGck8QSNZJJp538Wrb60Lax4fPwR64ViY468OIUTbRlGZg==}+ dev: false+resolution: {integrity: sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==}dev: true@@ -6046,6 +6096,12 @@ packages:minimist: 1.2.8dev: true+ resolution: {integrity: sha512-RWmIqhcFf1lRYBvNmr7qTNuyCt/7/ns2jbpp1+PalgE/rDQcBT0fioSMUpJ93irlUhC5hrg4cYqe6U+0ImW0rA==}+ dependencies:+ dequal: 2.0.3+ dev: false+resolution: {integrity: sha512-Lwv5W0Hk+uOW3kGnsU9GZoR1er1B7WQ5DSdonoNG+focTNeJbHW6vi6nBoX534VKI3/uwHebYzSw1fwY6a7mTw==}peerDependencies:@@ -6238,7 +6294,6 @@ packages:resolution: {integrity: sha512-V0hjH4dGPh9Ao5p0MoRY6BVqtwCjhz6vI5LT8AJ55H+4g9/4vbHx1I54fS0XuclLhDHArPQCiMjDxjaL8fPxhw==}engines: {node: '>=0.12'}- dev: trueresolution: {integrity: sha512-7dFHNmqeFSEt2ZBsCriorKnn3Z2pj+fd9kmI6QoWw4//DL+icEBfc0U7qJCisqrTsKTjw4fNFy2pW9OqStD84g==}@@ -7223,6 +7278,141 @@ packages:dependencies:function-bind: 1.1.2+ resolution: {integrity: sha512-naH8sld4Pe2ep03qqULEtvYr7EjrLK2QHY8KJR6RJkTUjPGObe1vnx585uzem2hGra+s1q08DZZpfgDVYRbaXA==}+ dependencies:+ '@types/hast': 3.0.4+ hast-util-is-element: 3.0.0+ dev: false++ resolution: {integrity: sha512-CUSRHXyKjzHov8yKsQjGOElXy/3EKpyX56ELnkHH34vDVw1N1XSQ1ZcAvTyAPtGqLTuKP/uxM+aLkSPqF/EtMw==}+ dependencies:+ '@types/hast': 3.0.4+ devlop: 1.1.0+ hast-util-from-parse5: 8.0.1+ parse5: 7.1.2+ vfile: 6.0.3+ vfile-message: 4.0.2+ dev: false++ resolution: {integrity: sha512-Er/Iixbc7IEa7r/XLtuG52zoqn/b3Xng/w6aZQ0xGVxzhw5xUFxcRqdPzP6yFi/4HBYRaifaI5fQ1RH8n0ZeOQ==}+ dependencies:+ '@types/hast': 3.0.4+ '@types/unist': 3.0.3+ devlop: 1.1.0+ hastscript: 8.0.0+ property-information: 6.5.0+ vfile: 6.0.3+ vfile-location: 5.0.3+ web-namespaces: 2.0.1+ dev: false++ resolution: {integrity: sha512-MNilsvEKLFpV604hwfhVStK0usFY/QmM5zX16bo7EjnAEGofr5YyI37kzopBlZJkHD4t887i+q/C8/tr5Q94cA==}+ dependencies:+ '@types/hast': 3.0.4+ dev: false++ resolution: {integrity: sha512-0qpnzOBLztXHbHQenVB8uNuxTnm/QBFUOmdOSsEn7GnBtyY07+ENTWVFBAnXd/zEgd9/SUG3lRY7hSIBWRgGpQ==}+ dependencies:+ '@types/hast': 3.0.4+ dev: false++ resolution: {integrity: sha512-Val9mnv2IWpLbNPqc/pUem+a7Ipj2aHacCwgNfTiK0vJKl0LF+4Ba4+v1oPHFpf3bLYmreq0/l3Gud9S5OH42g==}+ dependencies:+ '@types/hast': 3.0.4+ dev: false++ resolution: {integrity: sha512-L96fPOVpnclQE0xzdWb/D12VT5FabA7SnZOUMtL1DbXmYiHJMXZvFkIZfiMmTCNJHUeO2K9UYNXoVyfz+QHuOw==}+ dependencies:+ '@types/hast': 3.0.4+ hast-util-embedded: 3.0.0+ hast-util-is-element: 3.0.0+ hast-util-whitespace: 3.0.0+ unist-util-is: 6.0.0+ dev: false++ resolution: {integrity: sha512-wkQCkSYoOGCRKERFWcxMVMOcYE2K1AaNLU8DXS9arxnLOUEWbOXKXiJUNzEpqZ3JOKpnha3jkFrumEjVliDe7A==}+ dependencies:+ '@types/hast': 3.0.4+ dev: false++ resolution: {integrity: sha512-6h60VfI3uBQUxHqTyMymMZnEbNl1XmEGtOxxKYL7stY2o601COo62AWAYBQR9lZbYXYSBoxag8UpPRXK+9fqSQ==}+ dependencies:+ '@types/hast': 3.0.4+ hast-util-embedded: 3.0.0+ hast-util-has-property: 3.0.0+ hast-util-is-body-ok-link: 3.0.1+ hast-util-is-element: 3.0.0+ dev: false++ resolution: {integrity: sha512-M17uBDzMJ9RPCqLMO92gNNUDuBSq10a25SDBI08iCCxmorf4Yy6sYHK57n9WAbRAAaU+DuR4W6GN9K4DFZesYg==}+ dependencies:+ '@types/hast': 3.0.4+ '@types/unist': 3.0.3+ ccount: 2.0.1+ comma-separated-tokens: 2.0.3+ hast-util-whitespace: 3.0.0+ html-void-elements: 3.0.0+ mdast-util-to-hast: 13.2.0+ property-information: 6.5.0+ space-separated-tokens: 2.0.2+ stringify-entities: 4.0.4+ zwitch: 2.0.4+ dev: false++ resolution: {integrity: sha512-DsL/SvCK9V7+vfc6SLQ+vKIyBDXTk2KLSbfBYkH4zeF/uR1yBajHRhkzuaUSGOB1WJSTieJBdHwxlC+HLKvZZw==}+ dependencies:+ '@types/hast': 3.0.4+ '@types/mdast': 4.0.4+ '@ungap/structured-clone': 1.2.0+ hast-util-phrasing: 3.0.1+ hast-util-to-html: 9.0.3+ hast-util-to-text: 4.0.2+ hast-util-whitespace: 3.0.0+ mdast-util-phrasing: 4.1.0+ mdast-util-to-hast: 13.2.0+ mdast-util-to-string: 4.0.0+ rehype-minify-whitespace: 6.0.2+ trim-trailing-lines: 2.1.0+ unist-util-position: 5.0.0+ unist-util-visit: 5.0.0+ dev: false++ resolution: {integrity: sha512-KK6y/BN8lbaq654j7JgBydev7wuNMcID54lkRav1P0CaE1e47P72AWWPiGKXTJU271ooYzcvTAn/Zt0REnvc7A==}+ dependencies:+ '@types/hast': 3.0.4+ '@types/unist': 3.0.3+ hast-util-is-element: 3.0.0+ unist-util-find-after: 5.0.0+ dev: false++ resolution: {integrity: sha512-88JUN06ipLwsnv+dVn+OIYOvAuvBMy/Qoi6O7mQHxdPXpjy+Cd6xRkWwux7DKO+4sYILtLBRIKgsdpS2gQc7qw==}+ dependencies:+ '@types/hast': 3.0.4+ dev: false++ resolution: {integrity: sha512-dMOtzCEd3ABUeSIISmrETiKuyydk1w0pa+gE/uormcTpSYuaNJPbX1NU3JLyscSLjwAQM8bWMhhIlnCqnRvDTw==}+ dependencies:+ '@types/hast': 3.0.4+ comma-separated-tokens: 2.0.3+ hast-util-parse-selector: 4.0.0+ property-information: 6.5.0+ space-separated-tokens: 2.0.2+ dev: false+resolution: {integrity: sha512-H/vuk5TEEVZwrR0lp2zed9OCo1uAILMlx0JEMgC26rzyJJ3N1v6XkwHHXJQdR2doSjcGPM6OKPYoJgf0plJ11Q==}dependencies:@@ -7261,6 +7451,10 @@ packages:void-elements: 3.1.0dev: false+ resolution: {integrity: sha512-bEqo66MRXsUGxWHV5IP0PUiAWwoEjba4VCzg0LjFJBpchPaTfyfCKTG6bc5F8ucKec3q5y6qOdGyYTSBEvhCrg==}+ dev: false+resolution: {integrity: sha512-GYdjWKDkbRLkZ5geuHs5NY1puJ+PXwP7+fHPRz06Eirsb9ugf6d8kkXav6ADhcODhFFPMIXyxkxSuMf3D6NCFA==}dependencies:@@ -7560,6 +7754,11 @@ packages:engines: {node: '>=8'}dev: true+ resolution: {integrity: sha512-+Pgi+vMuUNkJyExiMBt5IlFoMyKnr5zhJ4Uspz58WOhBF5QoIZkFyNHIbBAtHwzVAgk5RtndVNsDRN61/mmDqg==}+ engines: {node: '>=12'}+ dev: false+resolution: {integrity: sha512-h5PpgXkWitc38BBMYawTYMWJHFZJVnBquFE57xFpjB8pJFiF6gZ+bU+WyI/yqXiFR5mdLsgYNaPe8uao6Uv9Og==}engines: {node: '>=0.10.0'}@@ -8620,6 +8819,33 @@ packages:resolution: {integrity: sha512-6qE4B9deFBIa9YSpOc9O0Sgc43zTeVYbgDT5veRKSlB2+ZuHNoVVxA1L/ckMUayV9Ay9y7Z/SZCLcGteW9i7bg==}dev: false+ resolution: {integrity: sha512-TqICwyvJJpBwvGAMZjj4J2n0X8QWp21b9l0o7eXyVJ25YNWYbJDVIyD1bZXE6WtV6RmKJVYmQAKWa0zWOABz2w==}+ dependencies:+ '@types/mdast': 4.0.4+ unist-util-is: 6.0.0+ dev: false++ resolution: {integrity: sha512-QGYKEuUsYT9ykKBCMOEDLsU5JRObWQusAolFMeko/tYPufNkRffBAQjIE+99jbA87xv6FgmjLtwjh9wBWajwAA==}+ dependencies:+ '@types/hast': 3.0.4+ '@types/mdast': 4.0.4+ '@ungap/structured-clone': 1.2.0+ devlop: 1.1.0+ micromark-util-sanitize-uri: 2.0.0+ trim-lines: 3.0.1+ unist-util-position: 5.0.0+ unist-util-visit: 5.0.0+ vfile: 6.0.3+ dev: false++ resolution: {integrity: sha512-0H44vDimn51F0YwvxSJSm0eCDOJTRlmN0R1yBh4HLj9wiV1Dn0QoXGbvFAWj2hSItVTlCmBF1hqKlIyUBVFLPg==}+ dependencies:+ '@types/mdast': 4.0.4+ dev: false+resolution: {integrity: sha512-aylIc7Z9y4yzHYAJNuESG3hfhC+0Ibp/MAMiaOZgNv4pmEdFyfZhhhny4MNiAfWdBQ1RQ2mfDWmM1x8SvGyp8g==}dev: true@@ -8644,6 +8870,33 @@ packages:engines: {node: '>= 8'}dev: true+ resolution: {integrity: sha512-KvOVV+X1yLBfs9dCBSopq/+G1PcgT3lAK07mC4BzXi5E7ahzMAF8oIupDDJ6mievI6F+lAATkbQQlQixJfT3aQ==}+ dependencies:+ micromark-util-symbol: 2.0.0+ micromark-util-types: 2.0.0+ dev: false++ resolution: {integrity: sha512-pS+ROfCXAGLWCOc8egcBvT0kf27GoWMqtdarNfDcjb6YLuV5cM3ioG45Ys2qOVqeqSbjaKg72vU+Wby3eddPsA==}+ dev: false++ resolution: {integrity: sha512-WhYv5UEcZrbAtlsnPuChHUAsu/iBPOVaEVsntLBIdpibO0ddy8OzavZz3iL2xVvBZOpolujSliP65Kq0/7KIYw==}+ dependencies:+ micromark-util-character: 2.1.0+ micromark-util-encode: 2.0.0+ micromark-util-symbol: 2.0.0+ dev: false++ resolution: {integrity: sha512-8JZt9ElZ5kyTnO94muPxIGS8oyElRJaiJO8EzV6ZSyGQ1Is8xwl4Q45qU5UOg+bGH4AikWziz0iN4sFLWs8PGw==}+ dev: false++ resolution: {integrity: sha512-oNh6S2WMHWRZrmutsRmDDfkzKtxF+bc2VxLC9dvtrDIRFln627VsFP6fLMgTryGDljgLPjkrzQSDcPrjPyDJ5w==}+ dev: false+resolution: {integrity: sha512-DMy+ERcEW2q8Z2Po+WNXuw3c5YaUSFjAO5GsJqfEl7UjvtIuFKO6ZrKvcItdy98dwFI2N1tg3zNIdKaQT+aNdA==}engines: {node: '>=8.6'}@@ -9118,7 +9371,6 @@ packages:resolution: {integrity: sha512-Czj1WaSVpaoj0wbhMzLmWD69anp2WH7FXMB9n1Sy8/ZFF9jolSQVMu1Ij5WIyGmcBmhk7EOndpO4mIpihVqAXw==}dependencies:entities: 4.5.0- dev: trueresolution: {integrity: sha512-uWlGT3YSnK9x3BQJaOdcZwrnV6hPpd8jFH1/ucpiLRPh/2zCVJKS19E4GvYHvaCcACn3foXZ0cLB9Wrx1KGe5g==}@@ -9516,6 +9768,10 @@ packages:object-assign: 4.1.1react-is: 16.13.1+ resolution: {integrity: sha512-PgTgs/BlvHxOu8QuEN7wi5A0OmXaBcHpmCSTehcs6Uuu9IkDIEo13Hy7n898RHfrQ49vKCoGeWZSaAK01nwVig==}+ dev: false+resolution: {integrity: sha512-jr4VJey2J9LVYCV7EVyVe53g1VMw28cCmYJhBe5e3YX5wiyiDwgxWxeDf9oTqAe4P1bN/YGAkW2jhlH8LohwiQ==}hasBin: true@@ -10240,6 +10496,21 @@ packages:jsesc: 0.5.0dev: true+ resolution: {integrity: sha512-Zk0pyQ06A3Lyxhe9vGtOtzz3Z0+qZ5+7icZ/PL/2x1SHPbKao5oB/g/rlc6BCTajqBb33JcOe71Ye1oFsuYbnw==}+ dependencies:+ '@types/hast': 3.0.4+ hast-util-minify-whitespace: 1.0.1+ dev: false++ resolution: {integrity: sha512-ksCzCD0Fgfh7trPDxr2rSylbwq9iYDkSn8TCDmEJ49ljEUBxDVCzCHv7QNzZOfODanX4+bWQ4WZqLCRWYLfhag==}+ dependencies:+ '@types/hast': 3.0.4+ hast-util-from-html: 2.0.3+ unified: 11.0.5+ dev: false+resolution: {integrity: sha512-gUAyHVHPPC5wdqX/LG4LWtRYtgjxyX78oanFNTMMyFEfOqdC54s3eE82imuWKbOeqYht2CrNf64Qb8vgmmtZGA==}engines: {node: '>=4'}@@ -10738,6 +11009,10 @@ packages:engines: {node: '>= 8'}dev: true+ resolution: {integrity: sha512-PEGlAwrG8yXGXRjW32fGbg66JAlOAwbObuqVoJpv/mRgoWDQfgH1wDPvtzWyUSNAXBGSk8h755YDbbcEy3SH2Q==}+ dev: false+resolution: {integrity: sha512-EeajNjfN9zMnULLwhZZQU3GWBoFNkbngTUPfaawT4RkMiviTxcX0qfhVbGey39mfctfDHkWtuecgQ8NJcyQWHg==}engines: {node: '>=8'}@@ -10877,6 +11152,13 @@ packages:safe-buffer: 5.2.1dev: true+ resolution: {integrity: sha512-IwfBptatlO+QCJUo19AqvrPNqlVMpW9YEL2LIVY+Rpv2qsjCGxaDLNRgeGsQWJhfItebuJhsGSLjaBbNSQ+ieg==}+ dependencies:+ character-entities-html4: 2.1.0+ character-entities-legacy: 3.0.0+ dev: false+resolution: {integrity: sha512-VhumSSbBqDTP8p2ZLKj40UjBCV4+v8bUSEpUb4KjRgWk9pbqGF4REFj6KEagidb2f/M6AzC0EmFyDNGaw9OCzg==}engines: {node: '>=0.10.0'}@@ -11199,6 +11481,18 @@ packages:hasBin: truedev: true+ resolution: {integrity: sha512-kRj8B+YHZCc9kQYdWfJB2/oUl9rA99qbowYYBtr4ui4mZyAQ2JpvVBd/6U2YloATfqBhBTSMhTpgBHtU0Mf3Rg==}+ dev: false++ resolution: {integrity: sha512-5UR5Biq4VlVOtzqkm2AZlgvSlDJtME46uV0br0gENbwN4l5+mMKT4b9gJKqWtuL2zAIqajGJGuvbCbcAJUZqBg==}+ dev: false++ resolution: {integrity: sha512-tmMpK00BjZiUyVyvrBK7knerNgmgvcV/KLVyuma/SC+TQN167GrMRciANTz09+k3zW8L8t60jWO1GpfkZdjTaw==}+ dev: false+resolution: {integrity: sha512-UQMIo7pb8WRomKR1/+MFVLTroIvDVtMX3K6OUir8ynLyzB8Jeriont2bTAtmNPa1ekAgN7YPDyf6V+ygrdU+eQ==}engines: {node: '>=16'}@@ -11462,10 +11756,67 @@ packages:engines: {node: '>=4'}dev: true+ resolution: {integrity: sha512-xKvGhPWw3k84Qjh8bI3ZeJjqnyadK+GEFtazSfZv/rKeTkTjOJho6mFqh2SM96iIcZokxiOpg78GazTSg8+KHA==}+ dependencies:+ '@types/unist': 3.0.3+ bail: 2.0.2+ devlop: 1.1.0+ extend: 3.0.2+ is-plain-obj: 4.1.0+ trough: 2.2.0+ vfile: 6.0.3+ dev: false+resolution: {integrity: sha512-Gw+zz50YNKPDKXs+9d+aKAjVwpjNwqzvNpLigIruT4HA9lMZNdMqs9x07kKHB/L9WRzqp4+DlTU5s4wG2esdoA==}dev: false+ resolution: {integrity: sha512-amQa0Ep2m6hE2g72AugUItjbuM8X8cGQnFoHk0pGfrFeT9GZhzN5SW8nRsiGKK7Aif4CrACPENkA6P/Lw6fHGQ==}+ dependencies:+ '@types/unist': 3.0.3+ unist-util-is: 6.0.0+ dev: false++ resolution: {integrity: sha512-2qCTHimwdxLfz+YzdGfkqNlH0tLi9xjTnHddPmJwtIG9MGsdbutfTc4P+haPD7l7Cjxf/WZj+we5qfVPvvxfYw==}+ dependencies:+ '@types/unist': 3.0.3+ dev: false++ resolution: {integrity: sha512-fucsC7HjXvkB5R3kTCO7kUjRdrS0BJt3M/FPxmHMBOm8JQi2BsHAHFsy27E0EolP8rp0NzXsJ+jNPyDWvOJZPA==}+ dependencies:+ '@types/unist': 3.0.3+ dev: false++ resolution: {integrity: sha512-0ASV06AAoKCDkS2+xw5RXJywruurpbC4JZSm7nr7MOt1ojAzvyyaO+UxZf18j8FCF6kmzCZKcAgN/yu2gm2XgQ==}+ dependencies:+ '@types/unist': 3.0.3+ dev: false++ resolution: {integrity: sha512-L/PqWzfTP9lzzEa6CKs0k2nARxTdZduw3zyh8d2NVBnsyvHjSX4TWse388YrrQKbvI8w20fGjGlhgT96WwKykw==}+ dependencies:+ '@types/unist': 3.0.3+ unist-util-is: 6.0.0+ dev: false++ resolution: {integrity: sha512-MR04uvD+07cwl/yhVuVWAtw+3GOR/knlL55Nd/wAdblk27GCVt3lqpTivy/tkJcZoNPzTwS1Y+KMojlLDhoTzg==}+ dependencies:+ '@types/unist': 3.0.3+ unist-util-is: 6.0.0+ unist-util-visit-parents: 6.0.1+ dev: false++ resolution: {integrity: sha512-bnzuF8b6d47WubA4a5yLqFbuZz/v/NS6eRwUIdOaDmsqzwTlyv8yS1g3M7ISdtBQrigPD3qKK87Cu7zhEfCF3A==}+ deprecated: Use @types/unist instead+ dev: false+resolution: {integrity: sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg==}engines: {node: '>= 4.0.0'}@@ -11590,6 +11941,27 @@ packages:core-util-is: 1.0.2extsprintf: 1.3.0+ resolution: {integrity: sha512-5yXvWDEgqeiYiBe1lbxYF7UMAIm/IcopxMHrMQDq3nvKcjPKIhZklUKL+AE7J7uApI4kwe2snsK+eI6UTj9EHg==}+ dependencies:+ '@types/unist': 3.0.3+ vfile: 6.0.3+ dev: false++ resolution: {integrity: sha512-jRDZ1IMLttGj41KcZvlrYAaI3CfqpLpfpf+Mfig13viT6NKvRzWZ+lXz0Y5D60w6uJIBAOGq9mSHf0gktF0duw==}+ dependencies:+ '@types/unist': 3.0.3+ unist-util-stringify-position: 4.0.0+ dev: false++ resolution: {integrity: sha512-KzIbH/9tXat2u30jf+smMwFCsno4wHVdNmzFyL+T/L3UGqqk6JKfVqOFOZEpZSHADH1k40ab6NUIXZq422ov3Q==}+ dependencies:+ '@types/unist': 3.0.3+ vfile-message: 4.0.2+ dev: false+resolution: {integrity: sha512-42XNp6FjxE0JIecxj1fdi770pLhYm3MJhBUAod9EszTgDg9C4LDOgBzWcj/0K52KfJrpRXwUsWV6kqTDuoCfLA==}dependencies:@@ -11741,6 +12113,10 @@ packages:graceful-fs: 4.2.11dev: true+ resolution: {integrity: sha512-bKr1DkiNa2krS7qxNtdrtHAmzuYGFQLiQ13TsorsdT6ULTkPLKuu5+GsFpDlg6JFjUTwX2DyhMPG2be8uPrqsQ==}+ dev: false+resolution: {integrity: sha512-VwddBukDzu71offAQR975unBIGqfKZpM+8ZX6ySk8nYhVoo5CYaZyzt3YBvYtRtO+aoGlqxPg/B87NGVZ/fu6g==}engines: {node: '>=12'}@@ -12033,3 +12409,7 @@ packages:resolution: {integrity: sha512-9bnSc/HEW2uRy67wc+T8UwauLuPJVn28jb+GtJY16iiKWyvmYJRXVT4UamsAEGQfPohgr2q4Tq0sQbQlxTfi1g==}engines: {node: '>=12.20'}dev: true++ resolution: {integrity: sha512-bXE4cR/kVZhKZX/RjPEflHaKVhUVl85noU3v6b8apfQEc1x4A+zBxjZ4lN8LqGd6WZ3dl98pY4o717VFmoPp+A==}+ dev: falsediff --git a/frontend/appflowy_web_app/src/application/slate-yjs/utils/applyToYjs.ts b/frontend/appflowy_web_app/src/application/slate-yjs/utils/applyToYjs.tsindex 5690ec512d..ff207a5950 100644--- a/frontend/appflowy_web_app/src/application/slate-yjs/utils/applyToYjs.ts+++ b/frontend/appflowy_web_app/src/application/slate-yjs/utils/applyToYjs.ts@@ -1,4 +1,3 @@-import { CustomEditor } from '@/application/slate-yjs/command';import { EditorMarkFormat } from '@/application/slate-yjs/types';import { calculateOffsetRelativeToParent } from '@/application/slate-yjs/utils/positions';import { getBlock, getNodeAtPath, getText } from '@/application/slate-yjs/utils/yjsOperations';@@ -55,8 +54,10 @@ function getAttributesAtOffset (ytext: Y.Text, offset: number): object | null {function insertText (ydoc: Y.Doc, editor: Editor, { path, offset, text, attributes }: InsertTextOperation & {attributes?: object;-}) {- const node = findSlateNode(editor, path);+}, slateContent: Descendant[]) {+ const node = getNodeAtPath(slateContent, path.slice(0, -1)) as Element;++ console.log('insertText', node, slateContent);const textId = node.textId as string;const sharedRoot = ydoc.getMap(YjsEditorKey.data_section) as YSharedRoot;const yText = getText(textId, sharedRoot);@@ -65,9 +66,11 @@ function insertText (ydoc: Y.Doc, editor: Editor, { path, offset, text, attributconst point = { path, offset };const relativeOffset = Math.min(calculateOffsetRelativeToParent(node, point), yText.toJSON().length);++ console.log('insertText', point, node);const beforeAttributes = getAttributesAtOffset(yText, relativeOffset - 1);- console.log('beforeAttributes', beforeAttributes);+ console.log('beforeAttributes', relativeOffset, beforeAttributes);if (beforeAttributes && ('formula' in beforeAttributes || 'mention' in beforeAttributes)) {const newAttributes = {@@ -95,13 +98,13 @@ function insertText (ydoc: Y.Doc, editor: Editor, { path, offset, text, attribut}-function applyInsertText (ydoc: Y.Doc, editor: Editor, op: InsertTextOperation, _slateContent: Descendant[]) {+function applyInsertText (ydoc: Y.Doc, editor: Editor, op: InsertTextOperation, slateContent: Descendant[]) {const { path, offset, text } = op;- insertText(ydoc, editor, { path, offset, text, type: 'insert_text' });+ insertText(ydoc, editor, { path, offset, text, type: 'insert_text' }, slateContent);}-function applyInsertNode (ydoc: Y.Doc, editor: Editor, op: InsertNodeOperation, _slateContent: Descendant[]) {+function applyInsertNode (ydoc: Y.Doc, editor: Editor, op: InsertNodeOperation, slateContent: Descendant[]) {const { path, node } = op;if (!Text.isText(node)) return;@@ -109,8 +112,8 @@ function applyInsertNode (ydoc: Y.Doc, editor: Editor, op: InsertNodeOperation,const offset = 0;insertText(ydoc, editor, {- path, offset, text, type: 'insert_text',- });+ path, offset, text, type: 'insert_text', attributes: {},+ }, slateContent);}function applyRemoveText (ydoc: Y.Doc, editor: Editor, op: RemoveTextOperation, slateContent: Descendant[]) {@@ -134,12 +137,6 @@ function applyRemoveText (ydoc: Y.Doc, editor: Editor, op: RemoveTextOperation,yText.delete(relativeOffset, text.length);}-function findSlateNode (editor: Editor, path: number[]): Element {- const entry = CustomEditor.findTextNode(editor, path);-- return entry[0];-}-function applySetNode (ydoc: Y.Doc, editor: Editor, op: SetNodeOperation, slateContent: Descendant[]) {const { newProperties, path } = op;const leafKeys = Object.values(EditorMarkFormat) as string[];diff --git a/frontend/appflowy_web_app/src/application/slate-yjs/utils/convert.ts b/frontend/appflowy_web_app/src/application/slate-yjs/utils/convert.tsindex 8cb966b931..3f6da96b80 100644--- a/frontend/appflowy_web_app/src/application/slate-yjs/utils/convert.ts+++ b/frontend/appflowy_web_app/src/application/slate-yjs/utils/convert.ts@@ -1,5 +1,11 @@import { BlockJson } from '@/application/slate-yjs/types';import { sortTableCells } from '@/application/slate-yjs/utils/table';+import {+ createBlock,+ getBlock,+ getText,+ updateBlockParent,+} from '@/application/slate-yjs/utils/yjsOperations';import {BlockData,BlockType,@@ -12,7 +18,7 @@ import {YTextMap,} from '@/application/types';import { TableCellNode } from '@/components/editor/editor.type';-import { Element, Text } from 'slate';+import { Element, Text, Node } from 'slate';export function yDataToSlateContent ({blocks,@@ -154,7 +160,7 @@ export function blockToSlateNode (block: BlockJson): Element {export interface YDelta {insert: string;- attributes?: Record<string, string | number | undefined | boolean>;+ attributes?: object;}export function deltaInsertToSlateNode ({ attributes, insert }: YDelta): Element | Text | Element[] {@@ -169,10 +175,57 @@ export function deltaInsertToSlateNode ({ attributes, insert }: YDelta): Element};}-function dealWithEmptyAttribute (attributes: Record<string, string | number | undefined | boolean>) {+// eslint-disable-next-line+function dealWithEmptyAttribute (attributes: Record<string, any>) {for (const key in attributes) {if (!attributes[key]) {delete attributes[key];}}}++// Helper function to convert Slate text node to Delta insert+function slateNodeToDeltaInsert (node: Text): YDelta {+ const { text, ...attributes } = node;++ return {+ insert: text,+ attributes: Object.keys(attributes).length > 0 ? attributes : undefined,+ };+}++export function slateContentInsertToYData (+ parentBlockId: string,+ index: number,+ slateContent: Node[],+ doc: YDoc,+): string[] {+ // Get existing YData structures from the YDoc+ const sharedRoot = doc.getMap(YjsEditorKey.data_section) as YSharedRoot;++ function processNode (node: Element, parentId: string, index: number) {+ const parent = getBlock(parentId, sharedRoot);+ const block = createBlock(sharedRoot, {+ ty: node.type as BlockType,+ data: node.data || {},+ });++ const [textNode, ...children] = (node.children[0] as Element).textId ? [node.children[0] as Element, ...node.children.slice(1)] : [null, ...node.children];++ if (textNode) {+ const text = getText(block.get(YjsEditorKey.block_external_id), sharedRoot);+ const ops = (textNode.children as Text[]).map(slateNodeToDeltaInsert);++ text.applyDelta(ops);+ }++ updateBlockParent(sharedRoot, block, parent, index);++ children.forEach((child, i) => processNode(child as Element, block.get(YjsEditorKey.block_id), i));++ return block.get(YjsEditorKey.block_id);+ }++ // Process each top-level node in slateContent+ return slateContent.map((node, i) => processNode(node as Element, parentBlockId, index + i));+}\ No newline at end of filediff --git a/frontend/appflowy_web_app/src/application/slate-yjs/utils/yjsOperations.ts b/frontend/appflowy_web_app/src/application/slate-yjs/utils/yjsOperations.tsindex d424f1b010..4972f5a81d 100644--- a/frontend/appflowy_web_app/src/application/slate-yjs/utils/yjsOperations.ts+++ b/frontend/appflowy_web_app/src/application/slate-yjs/utils/yjsOperations.ts@@ -20,6 +20,37 @@ import * as Y from 'yjs';import { YjsEditor } from '../plugins/withYjs';import { slatePointToRelativePosition } from './positions';+export function createEmptyDocument () {+ const doc = new Y.Doc();+ const sharedRoot = doc.getMap(YjsEditorKey.data_section) as YSharedRoot;+ const document = new Y.Map();+ const blocks = new Y.Map() as YBlocks;+ const pageId = nanoid(8);+ const meta = new Y.Map();+ const childrenMap = new Y.Map() as YChildrenMap;+ const textMap = new Y.Map() as YTextMap;++ const block = new Y.Map();++ block.set(YjsEditorKey.block_id, pageId);+ block.set(YjsEditorKey.block_type, BlockType.Page);+ block.set(YjsEditorKey.block_children, pageId);+ block.set(YjsEditorKey.block_external_id, pageId);+ block.set(YjsEditorKey.block_external_type, YjsEditorKey.text);+ block.set(YjsEditorKey.block_data, '');+ blocks.set(pageId, block);++ document.set(YjsEditorKey.page_id, pageId);+ document.set(YjsEditorKey.blocks, blocks);+ document.set(YjsEditorKey.meta, meta);+ childrenMap.set(pageId, new Y.Array());+ meta.set(YjsEditorKey.children_map, childrenMap);+ meta.set(YjsEditorKey.text_map, textMap);+ sharedRoot.set(YjsEditorKey.document, document);++ return doc;+}+export function getText (textId: string, sharedRoot: YSharedRoot) {const document = sharedRoot.get(YjsEditorKey.document);@@ -29,7 +60,7 @@ export function getText (textId: string, sharedRoot: YSharedRoot) {return textMap.get(textId);}-function assertDocExists (sharedRoot: YSharedRoot): YDoc {+export function assertDocExists (sharedRoot: YSharedRoot): YDoc {const doc = sharedRoot.doc;if (!doc) {@@ -813,14 +844,8 @@ export function handleIndentBlockWithTxn (editor: YjsEditor, sharedRoot: YSharedconst parent = getBlock(block.get(YjsEditorKey.block_parent), sharedRoot);const parentChildren = getChildrenArray(parent.get(YjsEditorKey.block_children), sharedRoot);const index = parentChildren.toArray().findIndex((id) => id === block.get(YjsEditorKey.block_id));- const parentType = parent.get(YjsEditorKey.block_type);const [, path] = getBlockEntry(editor, point);- // Check if the parent block is a container block- if (!CONTAINER_BLOCK_TYPES.includes(parentType)) {- return false;- }-// Check if the block can be indented (not the first child)if (index === 0) {return false;@@ -834,6 +859,11 @@ export function handleIndentBlockWithTxn (editor: YjsEditor, sharedRoot: YSharedreturn false;}+ // Check if the parent block is a container block+ if (!CONTAINER_BLOCK_TYPES.includes(previousSibling.get(YjsEditorKey.block_type))) {+ return false;+ }+let newPath: number[] | undefined;operations.push(() => {diff --git a/frontend/appflowy_web_app/src/components/editor/CollaborativeEditor.tsx b/frontend/appflowy_web_app/src/components/editor/CollaborativeEditor.tsxindex 43387ef60b..ca1c7ba651 100644--- a/frontend/appflowy_web_app/src/components/editor/CollaborativeEditor.tsx+++ b/frontend/appflowy_web_app/src/components/editor/CollaborativeEditor.tsx@@ -33,6 +33,7 @@ function CollaborativeEditor ({ doc }: { doc: Y.Doc }) {onContentChange,}),),+ 'x-appflowy-fragment',),) as YjsEditor),[doc, readOnly, localOrigin, readSummary, onContentChange],diff --git a/frontend/appflowy_web_app/src/components/editor/__tests__/behavior/BackspaceKeyBehavior.cy.tsx b/frontend/appflowy_web_app/src/components/editor/__tests__/behavior/BackspaceKeyBehavior.cy.tsxindex f7cc3942d0..75265c2bb6 100644--- a/frontend/appflowy_web_app/src/components/editor/__tests__/behavior/BackspaceKeyBehavior.cy.tsx+++ b/frontend/appflowy_web_app/src/components/editor/__tests__/behavior/BackspaceKeyBehavior.cy.tsx@@ -1,12 +1,13 @@-import { mountEditor, moveToLineStart } from '@/components/editor/__tests__/mount';-import { DocumentTest, FromBlockJSON } from 'cypress/support/document';+import { initialEditorTest, moveToLineStart } from '@/components/editor/__tests__/mount';+import { FromBlockJSON } from 'cypress/support/document';describe('Backspace key behavior', () => {beforeEach(() => {cy.viewport(1280, 720);Object.defineProperty(window.navigator, 'language', { value: 'en-US' });});- let documentTest: DocumentTest;+ const { assertJSON, initializeEditor } = initialEditorTest();+const initialData: FromBlockJSON[] = [{type: 'paragraph',@@ -59,21 +60,6 @@ describe('Backspace key behavior', () => {},];- const initializeEditor = (data: FromBlockJSON[]) => {- documentTest = new DocumentTest();- documentTest.fromJSON(data);- mountEditor({ readOnly: false, doc: documentTest.doc });- cy.get('[role="textbox"]').should('exist');- };-- const assertJSON = (expectedJSON: FromBlockJSON[]) => {- cy.wrap(null).then(() => {- const finalJSON = documentTest.toJSON();-- expect(finalJSON).to.deep.equal(expectedJSON);- });- };-describe('backspace key behavior with range selections', () => {beforeEach(() => {@@ -98,7 +84,7 @@ describe('Backspace key behavior', () => {]);// Optional: Add visual regression test- cy.matchImageSnapshot('behavior/BackspaceKeyBehavior/should-delete-entire-nested-structure');+ // cy.matchImageSnapshot('behavior/BackspaceKeyBehavior/should-delete-entire-nested-structure');});it('should delete content across multiple blocks', () => {@@ -122,7 +108,7 @@ describe('Backspace key behavior', () => {]);// Optional: Add visual regression test- cy.matchImageSnapshot('behavior/BackspaceKeyBehavior/should-delete-content-across-multiple-blocks');+ // cy.matchImageSnapshot('behavior/BackspaceKeyBehavior/should-delete-content-across-multiple-blocks');});it('should delete nested content within a toggle list', () => {@@ -150,7 +136,7 @@ describe('Backspace key behavior', () => {]);// Optional: Add visual regression test- cy.matchImageSnapshot('behavior/BackspaceKeyBehavior/should-delete-nested-content-within-a-toggle-list');+ // cy.matchImageSnapshot('behavior/BackspaceKeyBehavior/should-delete-nested-content-within-a-toggle-list');});it('should delete content across different nesting levels', () => {@@ -175,7 +161,7 @@ describe('Backspace key behavior', () => {]);// Optional: Add visual regression test- cy.matchImageSnapshot('behavior/BackspaceKeyBehavior/should-delete-content-across-different-nesting-levels');+ // cy.matchImageSnapshot('behavior/BackspaceKeyBehavior/should-delete-content-across-different-nesting-levels');});it('should handle deletion of deeply nested content', () => {@@ -205,7 +191,7 @@ describe('Backspace key behavior', () => {]);// Optional: Add visual regression test- cy.matchImageSnapshot('behavior/BackspaceKeyBehavior/should-handle-deletion-of-deeply-nested-content');+ // cy.matchImageSnapshot('behavior/BackspaceKeyBehavior/should-handle-deletion-of-deeply-nested-content');});it('should maintain structure when deleting partial content', () => {@@ -224,7 +210,7 @@ describe('Backspace key behavior', () => {initialData[2],]);// Optional: Add visual regression test- cy.matchImageSnapshot('behavior/BackspaceKeyBehavior/should-maintain-structure-when-deleting-partial-content');+ // cy.matchImageSnapshot('behavior/BackspaceKeyBehavior/should-maintain-structure-when-deleting-partial-content');});});@@ -256,7 +242,7 @@ describe('Backspace key behavior', () => {]);// Optional: Add visual regression test- cy.matchImageSnapshot('behavior/BackspaceKeyBehavior/should-convert-non-paragraph-block-to-paragraph');+ // cy.matchImageSnapshot('behavior/BackspaceKeyBehavior/should-convert-non-paragraph-block-to-paragraph');});it('should merge paragraphs when backspace at start of paragraph', () => {@@ -281,7 +267,7 @@ describe('Backspace key behavior', () => {]);// Optional: Add visual regression test- cy.matchImageSnapshot('behavior/BackspaceKeyBehavior/should-merge-paragraphs');+ // cy.matchImageSnapshot('behavior/BackspaceKeyBehavior/should-merge-paragraphs');});it('should lift nested paragraph when backspace at start', () => {@@ -310,7 +296,7 @@ describe('Backspace key behavior', () => {]);// Optional: Add visual regression test- cy.matchImageSnapshot('behavior/BackspaceKeyBehavior/should-lift-nested-paragraph');+ // cy.matchImageSnapshot('behavior/BackspaceKeyBehavior/should-lift-nested-paragraph');});it('should merge nested toggle list when backspace at start', () => {@@ -338,7 +324,7 @@ describe('Backspace key behavior', () => {// Optional: Add visual regression test- cy.matchImageSnapshot('behavior/BackspaceKeyBehavior/should-merge-nested-toggle-list');+ // cy.matchImageSnapshot('behavior/BackspaceKeyBehavior/should-merge-nested-toggle-list');});it('should handle backspace at start of document', () => {@@ -347,7 +333,7 @@ describe('Backspace key behavior', () => {assertJSON(initialData);// Optional: Add visual regression test- cy.matchImageSnapshot('behavior/BackspaceKeyBehavior/should-handle-backspace-at-start-of-document');+ // cy.matchImageSnapshot('behavior/BackspaceKeyBehavior/should-handle-backspace-at-start-of-document');});});});\ No newline at end of filediff --git a/frontend/appflowy_web_app/src/components/editor/__tests__/behavior/EnterKeyBehavior.cy.tsx b/frontend/appflowy_web_app/src/components/editor/__tests__/behavior/EnterKeyBehavior.cy.tsxindex 51b3bf95cd..f55edde8c4 100644--- a/frontend/appflowy_web_app/src/components/editor/__tests__/behavior/EnterKeyBehavior.cy.tsx+++ b/frontend/appflowy_web_app/src/components/editor/__tests__/behavior/EnterKeyBehavior.cy.tsx@@ -1,27 +1,12 @@-import { mountEditor, moveAndEnter, moveToLineStart } from '@/components/editor/__tests__/mount';-import { DocumentTest, FromBlockJSON } from 'cypress/support/document';+import { initialEditorTest, moveAndEnter, moveToLineStart } from '@/components/editor/__tests__/mount';+import { FromBlockJSON } from 'cypress/support/document';describe('Enter key behavior', () => {beforeEach(() => {cy.viewport(1280, 720);Object.defineProperty(window.navigator, 'language', { value: 'en-US' });});- let documentTest: DocumentTest;-- const initializeEditor = (data: FromBlockJSON[]) => {- documentTest = new DocumentTest();- documentTest.fromJSON(data);- mountEditor({ readOnly: false, doc: documentTest.doc });- cy.get('[role="textbox"]').should('exist');- };-- const assertJSON = (expectedJSON: FromBlockJSON[]) => {- cy.wrap(null).then(() => {- const finalJSON = documentTest.toJSON();-- expect(finalJSON).to.deep.equal(expectedJSON);- });- };+ const { assertJSON, initializeEditor } = initialEditorTest();it('should split paragraph blocks correctly', () => {const initialData: FromBlockJSON[] = [{@@ -86,7 +71,7 @@ describe('Enter key behavior', () => {}]);// Optional: Add visual regression test- cy.matchImageSnapshot('behavior/enter-key-behavior-split-paragraph-block');+ // cy.matchImageSnapshot('behavior/enter-key-behavior-split-paragraph-block');});it('should handle enter key correctly with nested paragraphs', () => {@@ -187,7 +172,7 @@ describe('Enter key behavior', () => {}, initialData[1]]);// Optional: Add visual regression test- cy.matchImageSnapshot('behavior/enter-key-behavior-nested-paragraphs');+ // cy.matchImageSnapshot('behavior/enter-key-behavior-nested-paragraphs');});it('should handle enter key correctly with toggle_list', () => {@@ -298,7 +283,7 @@ describe('Enter key behavior', () => {}]);// Optional: Add visual regression test- cy.matchImageSnapshot('behavior/enter-key-behavior-toggle-list');+ // cy.matchImageSnapshot('behavior/enter-key-behavior-toggle-list');});@@ -336,7 +321,7 @@ describe('Enter key behavior', () => {}]);// Optional: Add visual regression test- cy.matchImageSnapshot('behavior/enter-key-behavior-toggle-list-collapsed');+ // cy.matchImageSnapshot('behavior/enter-key-behavior-toggle-list-collapsed');});it('should handle enter key on the empty block but not the paragraph block', () => {@@ -391,7 +376,7 @@ describe('Enter key behavior', () => {}]);// Optional: Add visual regression test- cy.matchImageSnapshot('behavior/enter-key-behavior-empty-block');+ // cy.matchImageSnapshot('behavior/enter-key-behavior-empty-block');// Test 2: Press enter at the start of the empty todo_list blockmoveAndEnter(1, 0);@@ -420,7 +405,7 @@ describe('Enter key behavior', () => {}],}]);// Optional: Add visual regression test- cy.matchImageSnapshot('behavior/enter-key-behavior-empty-block-2');+ // cy.matchImageSnapshot('behavior/enter-key-behavior-empty-block-2');});describe('Enter key behavior with range selections', () => {@@ -531,7 +516,7 @@ describe('Enter key behavior', () => {]);// Optional: Add visual regression test- cy.matchImageSnapshot('behavior/enter-key-behavior-range-selection-single-block');+ // cy.matchImageSnapshot('behavior/enter-key-behavior-range-selection-single-block');});it('should handle range selection across two blocks', () => {@@ -567,7 +552,7 @@ describe('Enter key behavior', () => {]);// Optional: Add visual regression test- cy.matchImageSnapshot('behavior/enter-key-behavior-range-selection-across-blocks');+ // cy.matchImageSnapshot('behavior/enter-key-behavior-range-selection-across-blocks');});it('should handle range selection across same level blocks', () => {@@ -614,7 +599,7 @@ describe('Enter key behavior', () => {]);// Optional: Add visual regression test- cy.matchImageSnapshot('behavior/enter-key-behavior-range-selection-same-level-blocks');+ // cy.matchImageSnapshot('behavior/enter-key-behavior-range-selection-same-level-blocks');});it('should handle range selection with different anchor and focus order', () => {@@ -667,7 +652,7 @@ describe('Enter key behavior', () => {]);// Optional: Add visual regression test- cy.matchImageSnapshot('behavior/enter-key-behavior-range-selection-different-anchor-focus');+ // cy.matchImageSnapshot('behavior/enter-key-behavior-range-selection-different-anchor-focus');});it('should split nested paragraph when selection spans from outer to nested paragraph', () => {@@ -701,7 +686,7 @@ describe('Enter key behavior', () => {]);// Optional: Add visual regression test- cy.matchImageSnapshot('behavior/enter-key-behavior-range-selection-different-nesting-levels-1');+ // cy.matchImageSnapshot('behavior/enter-key-behavior-range-selection-different-nesting-levels-1');});@@ -802,7 +787,7 @@ describe('Enter key behavior', () => {},]);// Optional: Add visual regression test- cy.matchImageSnapshot('behavior/enter-key-behavior-range-selection-different-nesting-levels-2');+ // cy.matchImageSnapshot('behavior/enter-key-behavior-range-selection-different-nesting-levels-2');});it('should split paragraphs and maintain child structure when selection spans across parent paragraphs', () => {@@ -904,7 +889,7 @@ describe('Enter key behavior', () => {]);// Optional: Add visual regression test- cy.matchImageSnapshot('behavior/enter-key-behavior-range-selection-different-nesting-levels-3');+ // cy.matchImageSnapshot('behavior/enter-key-behavior-range-selection-different-nesting-levels-3');});it('should split heading and paragraph while preserving nested structure when selection spans different block types', () => {@@ -964,7 +949,7 @@ describe('Enter key behavior', () => {},]);// Optional: Add visual regression test- cy.matchImageSnapshot('behavior/enter-key-behavior-range-selection-different-nesting-levels-4');+ // cy.matchImageSnapshot('behavior/enter-key-behavior-range-selection-different-nesting-levels-4');});});diff --git a/frontend/appflowy_web_app/src/components/editor/__tests__/behavior/TabBehavior.cy.tsx b/frontend/appflowy_web_app/src/components/editor/__tests__/behavior/TabBehavior.cy.tsxindex d70215a541..11f8006cb0 100644--- a/frontend/appflowy_web_app/src/components/editor/__tests__/behavior/TabBehavior.cy.tsx+++ b/frontend/appflowy_web_app/src/components/editor/__tests__/behavior/TabBehavior.cy.tsx@@ -1,7 +1,6 @@-import { mountEditor, moveCursor } from '@/components/editor/__tests__/mount';-import { DocumentTest, FromBlockJSON } from 'cypress/support/document';+import { initialEditorTest, moveCursor } from '@/components/editor/__tests__/mount';+import { FromBlockJSON } from 'cypress/support/document';-let documentTest: DocumentTest;const initialData: FromBlockJSON[] = [{type: 'paragraph',@@ -53,24 +52,9 @@ const initialData: FromBlockJSON[] = [children: [],},];--const initializeEditor = (data: FromBlockJSON[]) => {- documentTest = new DocumentTest();- documentTest.fromJSON(data);- mountEditor({ readOnly: false, doc: documentTest.doc });- cy.get('[role="textbox"]').should('exist');-};--const assertJSON = (expectedJSON: FromBlockJSON[]) => {- cy.wrap(null).then(() => {- const finalJSON = documentTest.toJSON();-- expect(finalJSON).to.deep.equal(expectedJSON);- });-};+const { assertJSON, initializeEditor } = initialEditorTest();describe('Tab key behavior', () => {-beforeEach(() => {cy.viewport(1280, 720);Object.defineProperty(window.navigator, 'language', { value: 'en-US' });@@ -92,7 +76,7 @@ describe('Tab key behavior', () => {]);// Optional: Add visual regression test- cy.matchImageSnapshot('behavior/TabKeyBehavior/should-indent-paragraph');+ // cy.matchImageSnapshot('behavior/TabKeyBehavior/should-indent-paragraph');});it('should indent nested block at index 0/1 when tab at start', () => {@@ -120,7 +104,7 @@ describe('Tab key behavior', () => {]);// Optional: Add visual regression test- cy.matchImageSnapshot('behavior/TabKeyBehavior/should-indent-nested-block-at-index-0-1');+ // cy.matchImageSnapshot('behavior/TabKeyBehavior/should-indent-nested-block-at-index-0-1');});it('should not indent at start of document', () => {@@ -129,7 +113,7 @@ describe('Tab key behavior', () => {assertJSON(initialData);// Optional: Add visual regression test- cy.matchImageSnapshot('behavior/TabKeyBehavior/should-not-indent-at-start-of-document');+ // cy.matchImageSnapshot('behavior/TabKeyBehavior/should-not-indent-at-start-of-document');});it('should not indent at start of nested block', () => {@@ -138,7 +122,7 @@ describe('Tab key behavior', () => {assertJSON(initialData);// Optional: Add visual regression test- cy.matchImageSnapshot('behavior/TabKeyBehavior/should-not-indent-at-start-of-nested-block');+ // cy.matchImageSnapshot('behavior/TabKeyBehavior/should-not-indent-at-start-of-nested-block');});});@@ -173,7 +157,7 @@ describe('Shift+Tab key behavior', () => {]);//// Optional: Add visual regression test- cy.matchImageSnapshot('behavior/ShiftTabKeyBehavior/should-outdent-deeply-nested-paragraph');+ // cy.matchImageSnapshot('behavior/ShiftTabKeyBehavior/should-outdent-deeply-nested-paragraph');});it('should outdent Nested toggle list when shift+tab at start', () => {@@ -193,7 +177,7 @@ describe('Shift+Tab key behavior', () => {]);//// Optional: Add visual regression test- cy.matchImageSnapshot('behavior/ShiftTabKeyBehavior/should-outdent-nested-toggle-list');+ // cy.matchImageSnapshot('behavior/ShiftTabKeyBehavior/should-outdent-nested-toggle-list');});it('should not outdent at top level', () => {@@ -205,7 +189,7 @@ describe('Shift+Tab key behavior', () => {cy.get('@editor').realPress(['Shift', 'Tab']);assertJSON(initialData);// Optional: Add visual regression test- cy.matchImageSnapshot('behavior/ShiftTabKeyBehavior/should-not-outdent-at-top-level');+ // cy.matchImageSnapshot('behavior/ShiftTabKeyBehavior/should-not-outdent-at-top-level');});});\ No newline at end of filediff --git a/frontend/appflowy_web_app/src/components/editor/__tests__/blocks/Paragraph.cy.tsx b/frontend/appflowy_web_app/src/components/editor/__tests__/blocks/Paragraph.cy.tsxindex eb7bc6aed2..a03f002ba7 100644--- a/frontend/appflowy_web_app/src/components/editor/__tests__/blocks/Paragraph.cy.tsx+++ b/frontend/appflowy_web_app/src/components/editor/__tests__/blocks/Paragraph.cy.tsx@@ -1,4 +1,4 @@-import { mountEditor } from '@/components/editor/__tests__/mount';+import { initialEditorTest, mountEditor, moveCursor } from '@/components/editor/__tests__/mount';import { DocumentTest, FromBlockJSON } from 'cypress/support/document';describe('<Paragraph />', () => {@@ -17,11 +17,12 @@ describe('<Paragraph />', () => {cy.get('[role="textbox"]').should('exist');cy.get('[data-block-type="paragraph"]').should('have.length', 7);cy.get('[role="textbox"]').children().should('have.length', 3);- cy.matchImageSnapshot('paragraph/initial-render');+ // cy.matchImageSnapshot('paragraph/initial-render');});it('edit paragraph text', () => {- const documentTest = new DocumentTest();+ const { assertJSON, initializeEditor } = initialEditorTest();+const data: FromBlockJSON[] = [{type: 'paragraph',data: {},@@ -47,9 +48,7 @@ describe('<Paragraph />', () => {children: [],}];- documentTest.fromJSON(data);-- mountEditor({ readOnly: false, doc: documentTest.doc });+ initializeEditor(data);cy.get('[role="textbox"]').should('exist');@@ -57,36 +56,33 @@ describe('<Paragraph />', () => {.type(` New text at the 'world' middle `);cy.get('[role="textbox"]').type('{movetoend}').type('{leftarrow}'.repeat(6)).type('{backspace}'.repeat(4));- cy.wrap(null).then(() => {- const finalJSON = documentTest.toJSON();- const expectJSON = [{- type: 'paragraph',- data: {},- text: [- { insert: 'Hello, ' },- {- insert: `wor New text at the 'world' middle ld!`,- attributes: {- italic: true,- underline: true,- strikethrough: true,- font_color: '#ff0000',- bg_color: '#00ff00',- },+ const expectJSON = [{+ type: 'paragraph',+ data: {},+ text: [+ { insert: 'Hello, ' },+ {+ insert: `wor New text at the 'world' middle ld!`,+ attributes: {+ italic: true,+ underline: true,+ strikethrough: true,+ font_color: '#ff0000',+ bg_color: '#00ff00',},- { insert: ' This is a text.' },- ],- children: [],- }];+ },+ { insert: ' This is a text.' },+ ],+ children: [],+ }];- expect(finalJSON).to.deep.equal(expectJSON);- });+ assertJSON(expectJSON);// Optional: Add visual regression test- cy.matchImageSnapshot('paragraph/editing-text');+ // cy.matchImageSnapshot('paragraph/editing-text');});it('edit paragraphs with undo and redo', () => {- const documentTest = new DocumentTest();+ const { assertJSON, initializeEditor } = initialEditorTest();const initialData: FromBlockJSON[] = [{type: 'paragraph',data: {},@@ -99,8 +95,7 @@ describe('<Paragraph />', () => {children: [],}];- documentTest.fromJSON(initialData);- mountEditor({ readOnly: false, doc: documentTest.doc });+ initializeEditor(initialData);cy.get('[role="textbox"]').should('exist');@@ -108,25 +103,20 @@ describe('<Paragraph />', () => {cy.get('[role="textbox"]').children().eq(1).type('{movetoend} More text');// Check the result of the initial edit- cy.wrap(null).then(() => {- const editedJSON = documentTest.toJSON();- const expectedEditedJSON = [- {- type: 'paragraph',- data: {},- text: [{ insert: 'Hello, world!' }],- children: [],- },- {- type: 'paragraph',- data: {},- text: [{ insert: 'Hello, world! New at the end More text' }],- children: [],- },- ];-- expect(editedJSON).to.deep.equal(expectedEditedJSON);- });+ assertJSON([+ {+ type: 'paragraph',+ data: {},+ text: [{ insert: 'Hello, world!' }],+ children: [],+ },+ {+ type: 'paragraph',+ data: {},+ text: [{ insert: 'Hello, world! New at the end More text' }],+ children: [],+ },+ ]);// Perform undo operationif (Cypress.platform === 'darwin') {@@ -136,11 +126,7 @@ describe('<Paragraph />', () => {}// Check the result after undo- cy.wrap(null).then(() => {- const undoneJSON = documentTest.toJSON();-- expect(undoneJSON).to.deep.equal(initialData);- });+ assertJSON(initialData);// Perform redo operationif (Cypress.platform === 'darwin') {@@ -150,56 +136,46 @@ describe('<Paragraph />', () => {}// Check the result after redo- cy.wrap(null).then(() => {- const redoneJSON = documentTest.toJSON();- const expectedRedoneJSON = [- {- type: 'paragraph',- data: {},- text: [{ insert: 'Hello, world!' }],- children: [],- },- {- type: 'paragraph',- data: {},- text: [{ insert: 'Hello, world! New at the end More text' }],- children: [],- },- ];-- expect(redoneJSON).to.deep.equal(expectedRedoneJSON);- });+ assertJSON([+ {+ type: 'paragraph',+ data: {},+ text: [{ insert: 'Hello, world!' }],+ children: [],+ },+ {+ type: 'paragraph',+ data: {},+ text: [{ insert: 'Hello, world! New at the end More text' }],+ children: [],+ },+ ]);// Perform additional edits: Modify the first paragraphcy.get('[role="textbox"]').children().eq(0).type('{selectall}').type('{rightarrow}').type(' Additional content');// Check the final result- cy.wrap(null).then(() => {- const finalJSON = documentTest.toJSON();- const expectedFinalJSON = [- {- type: 'paragraph',- data: {},- text: [{ insert: 'Hello, world! Additional content' }],- children: [],- },- {- type: 'paragraph',- data: {},- text: [{ insert: 'Hello, world! New at the end More text' }],- children: [],- },- ];-- expect(finalJSON).to.deep.equal(expectedFinalJSON);- });+ assertJSON([+ {+ type: 'paragraph',+ data: {},+ text: [{ insert: 'Hello, world! Additional content' }],+ children: [],+ },+ {+ type: 'paragraph',+ data: {},+ text: [{ insert: 'Hello, world! New at the end More text' }],+ children: [],+ },+ ]);// Optional: Add visual regression test- cy.matchImageSnapshot('paragraph/editing-text-with-undo-redo');+ // cy.matchImageSnapshot('paragraph/editing-text-with-undo-redo');});it('render inline formatting', () => {- const documentTest = new DocumentTest();+ const { assertJSON, initializeEditor } = initialEditorTest();const data: FromBlockJSON[] = [{type: 'paragraph',data: {},@@ -236,11 +212,55 @@ describe('<Paragraph />', () => {children: [],}];- documentTest.fromJSON(data);- mountEditor({ readOnly: false, doc: documentTest.doc });+ initializeEditor(data);+ moveCursor(1, 17);+ cy.get('[role="textbox"]').realPress(' ');+ let expectJSON = [+ data[0],+ {+ ...data[1],+ text: [+ ...data[1].text.slice(0, 2),+ { insert: ' This is a formula: ' },+ { insert: '$', attributes: { formula: 'E=mc^2' } },+ { insert: ' .' },+ ],+ },+ ];++ assertJSON(expectJSON);++ cy.wait(500);+ moveCursor(1, 38);+ cy.get('[role="textbox"]').type(' end');+ expectJSON = [+ expectJSON[0],+ {+ ...expectJSON[1],+ text: [+ ...expectJSON[1].text.slice(0, -1),+ { insert: ' end .' },+ ],+ },+ ];+ assertJSON(expectJSON);++ cy.wait(500);+ cy.realPress(['ArrowUp', 'ArrowUp']);+ cy.get('[role="textbox"]').type(' first line end.');+ expectJSON = [+ {+ ...expectJSON[0], text: [+ ...expectJSON[0].text.slice(0, -1),+ { insert: ' text. first line end.' },+ ],+ },+ expectJSON[1],+ ];+ assertJSON(expectJSON);// Optional: Add visual regression test- cy.matchImageSnapshot('paragraph/inline-formatting');+ // cy.matchImageSnapshot('paragraph/inline-formatting');});diff --git a/frontend/appflowy_web_app/src/components/editor/__tests__/mount.tsx b/frontend/appflowy_web_app/src/components/editor/__tests__/mount.tsxindex 9d91aa4145..8b666cd16f 100644--- a/frontend/appflowy_web_app/src/components/editor/__tests__/mount.tsx+++ b/frontend/appflowy_web_app/src/components/editor/__tests__/mount.tsx@@ -1,3 +1,4 @@+import { DocumentTest, FromBlockJSON } from 'cypress/support/document';import React from 'react';import Editor, { EditorProps } from '@/components/editor/Editor';@@ -49,4 +50,29 @@ export const moveAndEnter = (lineIndex: number, moveCount: number) => {moveCursor(lineIndex, moveCount);cy.get('@targetBlock').type('{enter}');+};++export const initialEditorTest = () => {+ let documentTest: DocumentTest;++ const initializeEditor = (data: FromBlockJSON[]) => {+ documentTest = new DocumentTest();+ documentTest.fromJSON(data);+ mountEditor({ readOnly: false, doc: documentTest.doc });+ cy.get('[role="textbox"]').should('exist');+ };++ const assertJSON = (expectedJSON: FromBlockJSON[]) => {+ cy.wrap(null).then(() => {+ const finalJSON = documentTest.toJSON();++ expect(finalJSON).to.deep.equal(expectedJSON);+ });+ };++ return {+ initializeEditor,+ assertJSON,+ };+};\ No newline at end of filediff --git a/frontend/appflowy_web_app/src/components/editor/__tests__/shortcuts/BIUS.cy.tsx b/frontend/appflowy_web_app/src/components/editor/__tests__/shortcuts/BIUS.cy.tsxindex 4753192bf9..badc5d705d 100644--- a/frontend/appflowy_web_app/src/components/editor/__tests__/shortcuts/BIUS.cy.tsx+++ b/frontend/appflowy_web_app/src/components/editor/__tests__/shortcuts/BIUS.cy.tsx@@ -1,7 +1,8 @@-import { mountEditor } from '@/components/editor/__tests__/mount';-import { DocumentTest, FromBlockJSON } from 'cypress/support/document';+import { initialEditorTest } from '@/components/editor/__tests__/mount';+import { FromBlockJSON } from 'cypress/support/document';++const { assertJSON, initializeEditor } = initialEditorTest();-let documentTest: DocumentTest;const initialData: FromBlockJSON[] = [{type: 'paragraph',@@ -54,21 +55,6 @@ const initialData: FromBlockJSON[] = [},];-const initializeEditor = (data: FromBlockJSON[]) => {- documentTest = new DocumentTest();- documentTest.fromJSON(data);- mountEditor({ readOnly: false, doc: documentTest.doc });- cy.get('[role="textbox"]').should('exist');-};--const assertJSON = (expectedJSON: FromBlockJSON[]) => {- cy.wrap(null).then(() => {- const finalJSON = documentTest.toJSON();-- expect(finalJSON).to.deep.equal(expectedJSON);- });-};-const getModKey = () => {if (Cypress.platform === 'darwin') {return 'Meta';@@ -157,6 +143,6 @@ describe('BIUS.cy', () => {]);// Optional: Add visual regression test- cy.matchImageSnapshot('shortcuts/BIUS.cy');+ // cy.matchImageSnapshot('shortcuts/BIUS.cy');});});\ No newline at end of filediff --git a/frontend/appflowy_web_app/src/components/editor/__tests__/shortcuts/Markdown.cy.tsx b/frontend/appflowy_web_app/src/components/editor/__tests__/shortcuts/Markdown.cy.tsxindex 79af89b24f..561972d5ee 100644--- a/frontend/appflowy_web_app/src/components/editor/__tests__/shortcuts/Markdown.cy.tsx+++ b/frontend/appflowy_web_app/src/components/editor/__tests__/shortcuts/Markdown.cy.tsx@@ -1,7 +1,6 @@-import { mountEditor, moveCursor } from '@/components/editor/__tests__/mount';-import { DocumentTest, FromBlockJSON } from 'cypress/support/document';+import { initialEditorTest, moveCursor } from '@/components/editor/__tests__/mount';+import { FromBlockJSON } from 'cypress/support/document';-let documentTest: DocumentTest;const initialData: FromBlockJSON[] = [{type: 'paragraph',data: {},@@ -9,20 +8,7 @@ const initialData: FromBlockJSON[] = [{children: [],}];-const initializeEditor = (data: FromBlockJSON[]) => {- documentTest = new DocumentTest();- documentTest.fromJSON(data);- mountEditor({ readOnly: false, doc: documentTest.doc });- cy.get('[role="textbox"]').should('exist');-};--const assertJSON = (expectedJSON: FromBlockJSON[]) => {- cy.wrap(null).then(() => {- const finalJSON = documentTest.toJSON();-- expect(finalJSON).to.deep.equal(expectedJSON);- });-};+const { assertJSON, initializeEditor } = initialEditorTest();describe('Markdown editing', () => {beforeEach(() => {@@ -63,8 +49,143 @@ describe('Markdown editing', () => {}];assertJSON(expectedJson);- // Test `Italic`cy.get('@editor').realPress('Enter');+ cy.get('@editor').type('#');+ cy.get('@editor').realPress('Space');+ cy.get('@editor').type('Heading 1');+ expectedJson = [...expectedJson, {+ type: 'heading',+ data: { level: 1 },+ text: [{ insert: 'Heading 1' }],+ children: [],+ }];+ assertJSON(expectedJson);+ cy.get('@editor').realPress('Enter');+ cy.get('@editor').type('###');+ cy.get('@editor').realPress('Space');+ cy.get('@editor').type('Heading 3');+ expectedJson = [...expectedJson, {+ type: 'heading',+ data: { level: 3 },+ text: [{ insert: 'Heading 3' }],+ children: [],+ }];+ assertJSON(expectedJson);+ cy.get('@editor').realPress('Enter');+ cy.get('@editor').type('####');+ cy.get('@editor').realPress('Space');+ cy.get('@editor').type('Heading 4');+ expectedJson = [...expectedJson, {+ type: 'heading',+ data: { level: 4 },+ text: [{ insert: 'Heading 4' }],+ children: [],+ }];+ assertJSON(expectedJson);+ cy.get('@editor').realPress('Enter');+ cy.get('@editor').realPress('Tab');+ cy.get('@editor').type('paragraph: heading can not be nested');+ expectedJson = [...expectedJson, {+ type: 'paragraph',+ data: {},+ text: [{ insert: 'paragraph: heading can not be nested' }],+ children: [],+ }];+ assertJSON(expectedJson);+ cy.get('@editor').realPress('Enter');+ cy.get('@editor').realPress('Tab');+ cy.get('@editor').type('#####');+ cy.get('@editor').realPress('Space');+ cy.get('@editor').type('Heading 5');+ cy.get('@editor').realPress('Enter');+ cy.get('@editor').type('######');+ cy.get('@editor').realPress('Space');+ cy.get('@editor').type('Heading 6');+ expectedJson = [...expectedJson.slice(0, -1), {+ ...expectedJson[expectedJson.length - 1],+ children: [{+ type: 'heading',+ data: { level: 5 },+ text: [{ insert: 'Heading 5' }],+ children: [],+ }, {+ type: 'heading',+ data: { level: 6 },+ text: [{ insert: 'Heading 6' }],+ children: [],+ }],+ }];+ assertJSON(expectedJson);++ cy.get('@editor').realPress(['Enter', 'Enter']);+ cy.get('@editor').type('Outer paragraph');++ moveCursor(5, 0);+ cy.get('@editor').type('#');+ cy.get('@editor').realPress('Space');+ expectedJson = [...expectedJson.slice(0, 5), {+ ...expectedJson[5],+ type: 'heading',+ data: { level: 1 },+ children: [],+ }, {+ type: 'heading',+ data: { level: 5 },+ text: [{ insert: 'Heading 5' }],+ children: [],+ }, {+ type: 'heading',+ data: { level: 6 },+ text: [{ insert: 'Heading 6' }],+ children: [],+ }, {+ type: 'paragraph',+ data: {},+ text: [{ insert: 'Outer paragraph' }],+ children: [],+ }];+ assertJSON(expectedJson);+ cy.wait(500);+ cy.get('@editor').type('{movetoend}');++ cy.get('@editor').realPress(['Enter', 'Tab']);+ cy.get('@editor').type('Inner paragraph');+ cy.get('@editor').realPress(['Enter']);+ cy.get('@editor').type('Hi');+ cy.get('@editor').realPress(['ArrowLeft', 'ArrowLeft']);+ cy.get('@editor').realPress('Enter');+ cy.get('@editor').realPress('ArrowUp');+ cy.get('@editor').realPress('Enter');+ cy.get('@editor').type('Hello');+ expectedJson = [...expectedJson.slice(0, -1), {+ ...expectedJson[expectedJson.length - 1],+ children: [{+ type: 'paragraph',+ data: {},+ text: [{ insert: 'Inner paragraph' }],+ children: [],+ }, {+ type: 'paragraph',+ data: {},+ text: [],+ children: [],+ }, {+ type: 'paragraph',+ data: {},+ text: [{ insert: 'Hello' }],+ children: [],+ }, {+ type: 'paragraph',+ data: {},+ text: [{ insert: 'Hi' }],+ children: [],+ }],+ }];+ assertJSON(expectedJson);+ moveCursor(12, 2);+ cy.get('@editor').realPress(['Enter', 'Backspace']);++ // Test `Italic`cy.get('@editor').type('_italic');cy.get('@editor').realPress(['_']);expectedJson = [@@ -116,12 +237,14 @@ describe('Markdown editing', () => {cy.get('@editor').realPress('Enter');cy.get('@editor').type('$E=mc^2');cy.get('@editor').realPress(['$']);++ cy.get('@editor').type('inline formula');expectedJson = [...expectedJson,{type: 'paragraph',data: {},- text: [{ insert: '$', attributes: { formula: 'E=mc^2' } }],+ text: [{ insert: '$', attributes: { formula: 'E=mc^2' } }, { insert: 'inline formula' }],children: [],},];diff --git a/frontend/appflowy_web_app/src/components/editor/components/leaf/InlineChromiumBugfix.tsx b/frontend/appflowy_web_app/src/components/editor/components/leaf/InlineChromiumBugfix.tsxnew file mode 100644index 0000000000..fb32eb18a9--- /dev/null+++ b/frontend/appflowy_web_app/src/components/editor/components/leaf/InlineChromiumBugfix.tsx@@ -0,0 +1,16 @@+import React from 'react';++// Put this at the start and end of an inline component to work around this Chromium bug:+// https://bugs.chromium.org/p/chromium/issues/detail?id=1249405++export const InlineChromiumBugfix = ({ className }: { className?: string }) => (+ <span+ contentEditable={false}+ className={`absolute caret-transparent ${className ?? ''}`}+ style={{+ fontSize: 0,+ }}+ >+ {String.fromCodePoint(160) /* Non-breaking space */}+ </span>+);diff --git a/frontend/appflowy_web_app/src/components/editor/components/leaf/Leaf.tsx b/frontend/appflowy_web_app/src/components/editor/components/leaf/Leaf.tsxindex b5b070c8cb..c430a9575a 100644--- a/frontend/appflowy_web_app/src/components/editor/components/leaf/Leaf.tsx+++ b/frontend/appflowy_web_app/src/components/editor/components/leaf/Leaf.tsx@@ -58,9 +58,10 @@ export function Leaf ({ attributes, children, leaf, text }: RenderLeafProps) {/> : leaf.formula ? <FormulaLeaf formula={leaf.formula} text={text} /> : null;newChildren = <>-{node}- <span className={'absolute opacity-0 left-0'}>+ <span+ className={'absolute opacity-0 left-0'}+ >{newChildren}</span></>;diff --git a/frontend/appflowy_web_app/src/components/editor/components/leaf/formula/FormulaLeaf.tsx b/frontend/appflowy_web_app/src/components/editor/components/leaf/formula/FormulaLeaf.tsxindex 04e42d1c77..61c5ea2408 100644--- a/frontend/appflowy_web_app/src/components/editor/components/leaf/formula/FormulaLeaf.tsx+++ b/frontend/appflowy_web_app/src/components/editor/components/leaf/formula/FormulaLeaf.tsx@@ -8,7 +8,7 @@ function FormulaLeaf ({ formula, text }: {formula: string;text: Text;}) {- const { isSelected, select } = useLeafSelected(text);+ const { isSelected, select, isCursorAfter, isCursorBefore } = useLeafSelected(text);const readonly = useReadOnly();const className = useMemo(() => {const classList = ['formula-inline', 'relative', 'rounded', 'p-0.5 select-none'];@@ -16,8 +16,10 @@ function FormulaLeaf ({ formula, text }: {if (readonly) classList.push('cursor-default');else classList.push('cursor-pointer');if (isSelected) classList.push('selected');+ if (isCursorAfter) classList.push('cursor-after');+ if (isCursorBefore) classList.push('cursor-before');return classList.join(' ');- }, [readonly, isSelected]);+ }, [readonly, isSelected, isCursorAfter, isCursorBefore]);return (<spandiff --git a/frontend/appflowy_web_app/src/components/editor/components/leaf/leaf.hooks.ts b/frontend/appflowy_web_app/src/components/editor/components/leaf/leaf.hooks.tsindex 06a1551ac1..80c0fe1f74 100644--- a/frontend/appflowy_web_app/src/components/editor/components/leaf/leaf.hooks.ts+++ b/frontend/appflowy_web_app/src/components/editor/components/leaf/leaf.hooks.ts@@ -8,12 +8,45 @@ export function useLeafSelected (text: Text) {const elementIsSelected = useSelected();const selection = editor.selection;+ const isCursorBefore = useMemo(() => {+ if (readonly || !selection || !text) return false;++ if (selection && Range.isCollapsed(selection)) {+ const path = ReactEditor.findPath(editor, text);+ const start = Editor.start(editor, path);++ return Range.equals(selection, {+ anchor: start,+ focus: start,+ });+ }++ return false;+ }, [editor, readonly, selection, text]);++ const isCursorAfter = useMemo(() => {+ if (readonly || !selection || !text) return false;+ if (selection && Range.isCollapsed(selection)) {+ const path = ReactEditor.findPath(editor, text);+ const end = Editor.end(editor, path);++ return Range.equals(selection, {+ anchor: end,+ focus: end,+ });+ }++ return false;+ }, [editor, readonly, selection, text]);+const isSelected = useMemo(() => {if (readonly || !selection || !elementIsSelected || !text) return false;try {const path = ReactEditor.findPath(editor, text);+ if (Range.isCollapsed(selection)) return false;+// get the start and end point of the mentionconst start = Editor.start(editor, path);const end = Editor.end(editor, path);@@ -46,5 +79,7 @@ export function useLeafSelected (text: Text) {return {isSelected,select,+ isCursorBefore,+ isCursorAfter,};}\ No newline at end of filediff --git a/frontend/appflowy_web_app/src/components/editor/components/leaf/mention/MentionLeaf.tsx b/frontend/appflowy_web_app/src/components/editor/components/leaf/mention/MentionLeaf.tsxindex d62e846dec..2e07a4eadb 100644--- a/frontend/appflowy_web_app/src/components/editor/components/leaf/mention/MentionLeaf.tsx+++ b/frontend/appflowy_web_app/src/components/editor/components/leaf/mention/MentionLeaf.tsx@@ -28,7 +28,7 @@ export function MentionLeaf ({ mention, text }: {}, [date, page_id, reminder, type]);// check if the mention is selected- const { isSelected, select } = useLeafSelected(text);+ const { isSelected, select, isCursorAfter, isCursorBefore } = useLeafSelected(text);const className = useMemo(() => {const classList = ['w-fit mention', 'relative', 'rounded', 'p-0.5'];@@ -36,8 +36,10 @@ export function MentionLeaf ({ mention, text }: {else classList.push('cursor-pointer');if (isSelected) classList.push('selected');+ if (isCursorAfter) classList.push('cursor-after');+ if (isCursorBefore) classList.push('cursor-before');return classList.join(' ');- }, [readonly, isSelected]);+ }, [readonly, isSelected, isCursorAfter, isCursorBefore]);return <spanonClick={select}diff --git a/frontend/appflowy_web_app/src/components/editor/editor.scss b/frontend/appflowy_web_app/src/components/editor/editor.scssindex 2d48831fb4..2d77192022 100644--- a/frontend/appflowy_web_app/src/components/editor/editor.scss+++ b/frontend/appflowy_web_app/src/components/editor/editor.scss@@ -305,4 +305,35 @@ span[data-slate-placeholder="true"]:not(.inline-block-content) {.table-block {@include mixin.scrollbar-style;+}+++.cursor-before::before,+.cursor-after::after {+ content: '';+ position: absolute;+ top: 0;+ bottom: 0;+ width: 1px;+ margin-top: 2px;+ margin-bottom: 2px;+ background-color: var(--text-title);+ animation: blink 1s step-end infinite;+}++.cursor-before::before {+ left: -1px;+}++.cursor-after::after {+ right: -1px;+}++@keyframes blink {+ from, to {+ opacity: 0;+ }+ 50% {+ opacity: 1;+ }}\ No newline at end of filediff --git a/frontend/appflowy_web_app/src/components/editor/plugins/index.ts b/frontend/appflowy_web_app/src/components/editor/plugins/index.tsindex ac1e3d783b..bf11248bd4 100644--- a/frontend/appflowy_web_app/src/components/editor/plugins/index.ts+++ b/frontend/appflowy_web_app/src/components/editor/plugins/index.ts@@ -2,8 +2,9 @@ import { withDelete } from '@/components/editor/plugins/withDelete';import { withInsertBreak } from '@/components/editor/plugins/withInsertBreak';import { withInsertText } from '@/components/editor/plugins/withInsertText';import { withMarkdown } from '@/components/editor/plugins/withMarkdown';+import { withPasted } from '@/components/editor/plugins/withPasted';import { ReactEditor } from 'slate-react';export function withPlugins (editor: ReactEditor) {- return withMarkdown(withInsertBreak(withDelete(withInsertText(editor))));+ return withPasted(withMarkdown(withInsertBreak(withDelete(withInsertText(editor)))));}diff --git a/frontend/appflowy_web_app/src/components/editor/plugins/withInsertText.ts b/frontend/appflowy_web_app/src/components/editor/plugins/withInsertText.tsindex a36c2f30d4..0952ddb424 100644--- a/frontend/appflowy_web_app/src/components/editor/plugins/withInsertText.ts+++ b/frontend/appflowy_web_app/src/components/editor/plugins/withInsertText.ts@@ -23,7 +23,7 @@ export const withInsertText = (editor: ReactEditor) => {// If the text node is a formula or mention, split the node and insert the textif (textNode.formula || textNode.mention) {- Transforms.splitNodes(editor, { at: point });+ console.log('Inserting text into formula or mention', newAt);Transforms.insertNodes(editor, { text }, { at: point, select: true, voids: false });return;diff --git a/frontend/appflowy_web_app/src/components/editor/plugins/withPasted.ts b/frontend/appflowy_web_app/src/components/editor/plugins/withPasted.tsnew file mode 100644index 0000000000..2e8fee6898--- /dev/null+++ b/frontend/appflowy_web_app/src/components/editor/plugins/withPasted.ts@@ -0,0 +1,111 @@+import { YjsEditor } from '@/application/slate-yjs';+import { slateContentInsertToYData } from '@/application/slate-yjs/utils/convert';+import {+ assertDocExists,+ getBlock,+ getBlockEntry,+ getChildrenArray,+ getSharedRoot,+} from '@/application/slate-yjs/utils/yjsOperations';+import { YjsEditorKey } from '@/application/types';+import { deserializeHTML } from '@/components/editor/utils/fragment';+import { BasePoint, Range, Transforms, Node } from 'slate';+import { ReactEditor } from 'slate-react';++export const withPasted = (editor: ReactEditor) => {++ editor.insertTextData = (data: DataTransfer) => {+ if (!beforePasted(editor))+ return false;+ const text = data.getData('text/plain');++ if (text) {++ const lines = text.split(/\r\n|\r|\n/);++ if (lines.filter(Boolean).length > 1) {+ return insertHtmlData(editor, data);+ }++ console.log('insertTextData', text);++ for (const line of lines) {+ const point = editor.selection?.anchor as BasePoint;++ if (line) {+ Transforms.insertNodes(editor, { text: line }, { at: point, select: true, voids: false });+ }+ }++ return true;+ }++ return false;+ };++ editor.insertFragment = (fragment, options = {}) => {+ return insertFragment(editor, fragment, options);+ };++ return editor;+};++function beforePasted (editor: ReactEditor) {+ const { selection } = editor;++ if (!selection) {+ return false;+ }++ if (Range.isExpanded(selection)) {+ Transforms.collapse(editor, { edge: 'start' });++ editor.delete({+ at: selection,+ });+ }++ return true;+}++function insertHtmlData (editor: ReactEditor, data: DataTransfer) {+ const html = data.getData('text/html');++ if (html) {+ console.log('insert HTML Data', html);+ const fragment = deserializeHTML(html) as Node[];++ insertFragment(editor, fragment);++ return true;+ }++ return false;+}++function insertFragment (editor: ReactEditor, fragment: Node[], options = {}) {+ console.log('insertFragment', fragment, options);+ if (!beforePasted(editor))+ return;++ const point = editor.selection?.anchor as BasePoint;+ const [node] = getBlockEntry(editor as YjsEditor, point);+ const blockId = node.blockId as string;+ const sharedRoot = getSharedRoot(editor as YjsEditor);+ const block = getBlock(blockId, sharedRoot);+ const parent = getBlock(block.get(YjsEditorKey.block_parent), sharedRoot);+ const parentChildren = getChildrenArray(parent.get(YjsEditorKey.block_children), sharedRoot);+ const index = parentChildren.toArray().findIndex((id) => id === block.get(YjsEditorKey.block_id));+ const doc = assertDocExists(sharedRoot);++ doc.transact(() => {+ slateContentInsertToYData(block.get(YjsEditorKey.block_parent), index + 1, fragment, doc);+ });++ Transforms.move(editor, {+ distance: 1,+ unit: 'line',+ });++ return;+}\ No newline at end of filediff --git a/frontend/appflowy_web_app/src/components/editor/shortcut.hooks.ts b/frontend/appflowy_web_app/src/components/editor/shortcut.hooks.tsindex 13e89d6056..7a4577210b 100644--- a/frontend/appflowy_web_app/src/components/editor/shortcut.hooks.ts+++ b/frontend/appflowy_web_app/src/components/editor/shortcut.hooks.ts@@ -6,6 +6,7 @@ import { getBlockEntry } from '@/application/slate-yjs/utils/yjsOperations';import { BlockType } from '@/application/types';import { createHotkey, HOT_KEY_NAME } from '@/utils/hotkeys';import { KeyboardEvent, useCallback } from 'react';+import { Editor, Text, Range, Transforms, BasePoint } from 'slate';import { ReactEditor, useReadOnly } from 'slate-react';export function useShortcuts (editor: ReactEditor) {@@ -29,6 +30,34 @@ export function useShortcuts (editor: ReactEditor) {break;}+ if (selection && Range.isCollapsed(selection)) {+ if (+ createHotkey(HOT_KEY_NAME.UP)(e)+ ) {+ const before = Editor.before(editor, selection, { unit: 'offset' });+ const beforeText = findInlineTextNode(editor, before);++ if (before && beforeText) {+ e.preventDefault();+ Transforms.move(editor, { unit: 'line', reverse: true, distance: 2 });+ return;+ }+ }++ if (+ createHotkey(HOT_KEY_NAME.DOWN)(e)+ ) {+ const after = Editor.after(editor, selection, { unit: 'offset' });+ const afterText = findInlineTextNode(editor, after);++ if (after && afterText) {+ e.preventDefault();+ Transforms.move(editor, { unit: 'line', distance: 2 });+ return;+ }+ }+ }+// Do not process shortcuts if editor is read-only or no selectionif (readOnly || !selection) return;const [point, endPoint] = editor.edges(selection);@@ -174,4 +203,15 @@ export function useShortcuts (editor: ReactEditor) {return {onKeyDown,};+}++function findInlineTextNode (editor: Editor, point?: BasePoint) {+ const [node] = editor.nodes({+ at: point,+ match: (n) => {+ return !Editor.isEditor(n) && Text.isText(n) && Boolean(n.mention || n.formula);+ },+ });++ return node;}\ No newline at end of filediff --git a/frontend/appflowy_web_app/src/components/editor/utils/__tests__/fragment.test.ts b/frontend/appflowy_web_app/src/components/editor/utils/__tests__/fragment.test.tsnew file mode 100644index 0000000000..9086788825--- /dev/null+++ b/frontend/appflowy_web_app/src/components/editor/utils/__tests__/fragment.test.ts@@ -0,0 +1,246 @@+import { deserializeHTML } from '../fragment';+import { BlockType, ImageType, AlignType } from '@/application/types';+import { expect } from '@jest/globals';+import { Element, Node } from 'slate';++jest.mock('nanoid');+describe('deserializeHTML', () => {+ // Test basic HTML elements+ it('should correctly deserialize basic HTML content', () => {+ const testHTML = `+ <p>Hello, world!</p>+ <h1>Title 1</h1>+ <h2>Title 2</h2>+ <h3>Title 3</h3>+ <img src="https://example.com/image.jpg" />+ <input type="checkbox" checked />Task+ `;++ const result = deserializeHTML(testHTML) as Node[];++ expect(result).toBeDefined();+ expect(Array.isArray(result)).toBe(true);+ expect(result.length).toBe(6);++ // Check paragraph+ let blockId = (result[0] as Element).blockId as string;+ expect(result[0]).toEqual(expect.objectContaining({+ blockId,+ type: BlockType.Paragraph,+ data: {},+ children: [{ type: 'text', children: [{ text: 'Hello, world!' }], textId: blockId }],+ }));++ // Check headings+ for (let i = 1; i <= 3; i++) {+ const blockId = (result[i] as Element).blockId as string;+ expect(result[i]).toEqual(expect.objectContaining({+ type: BlockType.HeadingBlock,+ children: [{+ type: 'text',+ textId: blockId,+ children: [{ text: `Title ${i}` }],+ }],+ data: { level: i },+ blockId,+ }));+ }++ // Check image+ blockId = (result[4] as Element).blockId as string;+ expect(result[4]).toEqual(expect.objectContaining({+ blockId,+ type: BlockType.ImageBlock,+ children: [{+ type: 'text',+ textId: blockId,+ children: [{ text: '' }],+ }],+ data: { url: 'https://example.com/image.jpg', image_type: ImageType.External },+ }));++ // Check todo list+ blockId = (result[5] as Element).blockId as string;+ expect(result[5]).toEqual(expect.objectContaining({+ type: BlockType.TodoListBlock,+ blockId,+ children: [{+ type: 'text',+ textId: blockId,+ children: [{ text: 'Task' }],+ }],+ data: { checked: true },+ }));+ });++ // Test list elements+ it('should correctly deserialize list elements', () => {+ const testHTML = `+ <ul>+ <li>Bullet 1</li>+ <li>Bullet 2</li>+ </ul>+ <ol>+ <li>Number 1</li>+ <li>Number 2</li>+ </ol>+ `;++ const result = deserializeHTML(testHTML) as Node[];++ expect(result.length).toBe(4);++ // Check unordered list+ let blockId = (result[0] as Element).blockId as string;+ expect(result[0]).toEqual(expect.objectContaining({+ blockId,+ type: BlockType.BulletedListBlock,+ children: [+ { type: 'text', textId: blockId, children: [{ text: 'Bullet 1' }] },+ ],+ }));+ blockId = (result[1] as Element).blockId as string;+ expect(result[1]).toEqual(expect.objectContaining({+ blockId,+ type: BlockType.BulletedListBlock,+ children: [{ type: 'text', textId: blockId, children: [{ text: 'Bullet 2' }] }],+ }));++ // Check ordered list+ blockId = (result[2] as Element).blockId as string;+ expect(result[2]).toEqual(expect.objectContaining({+ blockId,+ type: BlockType.NumberedListBlock,+ children: [{ type: 'text', textId: blockId, children: [{ text: 'Number 1' }] }],+ }));++ blockId = (result[3] as Element).blockId as string;+ expect(result[3]).toEqual(expect.objectContaining({+ type: BlockType.NumberedListBlock,+ children: [{ type: 'text', textId: blockId, children: [{ text: 'Number 2' }] }],+ blockId,+ }));+ });++ // Test blockquote and code block+ it('should correctly deserialize blockquote and code block', () => {+ const testHTML = `+ <blockquote>This is a quote</blockquote>+ <pre><code>const x = 5;</code></pre>+ `;++ const result = deserializeHTML(testHTML) as Node[];++ expect(result.length).toBe(2);++ // Check blockquote+ let blockId = (result[0] as Element).blockId as string;+ expect(result[0]).toEqual(expect.objectContaining({+ type: BlockType.QuoteBlock,+ children: [{ type: 'text', textId: blockId, children: [{ text: 'This is a quote' }] }],+ blockId,+ }));++ // Check code block+ blockId = (result[1] as Element).blockId as string;+ expect(result[1]).toEqual(expect.objectContaining({+ type: BlockType.CodeBlock,+ children: [{ type: 'text', textId: blockId, children: [{ text: 'const x = 5;' }] }],+ blockId,+ }));+ });++ // Test inline styles+ it('should correctly deserialize inline styles', () => {+ const testHTML = `+ <p><strong>Bold</strong> <em>Italic</em> <u>Underline</u> <strike>Strikethrough</strike> <code>Inline Code</code></p>+ `;++ const result = deserializeHTML(testHTML) as Node[];++ expect(result.length).toBe(1);+ expect(((result[0] as Element).children[0] as Element).children).toEqual([+ { text: 'Bold', bold: true },+ { text: 'Italic', italic: true },+ { text: 'Underline', underline: true },+ { text: 'Strikethrough', strikethrough: true },+ { text: 'Inline Code', code: true },+ ]);+ });++ // Test alignment and colors+ it('should correctly deserialize alignment and colors', () => {+ const testHTML = `+ <p style="text-align: center; background-color: #f0f0f0; color: #333;">Centered text with background and color</p>+ `;++ const result = deserializeHTML(testHTML) as Node[];++ expect(result.length).toBe(1);+ let blockId = (result[0] as Element).blockId as string;+ expect(result[0]).toEqual(expect.objectContaining({+ blockId,+ type: BlockType.Paragraph,+ children: [{ type: 'text', textId: blockId, children: [{ text: 'Centered text with background and color' }] }],++ data: {+ align: AlignType.Center,+ bgColor: '#f0f0f0',+ font_color: '#333',+ },+ }));+ });++ // Test empty HTML+ it('should handle empty HTML', () => {+ const result = deserializeHTML('') as Node[];++ expect(result).toBeDefined();+ expect(Array.isArray(result)).toBe(true);+ expect(result.length).toBe(0);+ });++ // Test nested structures+ it('should correctly deserialize nested structures', () => {+ const testHTML = `+ <ul>+ <li>+ <h3>Nested Heading</h3>+ <p>Nested paragraph</p>+ </li>+ </ul>+ `;++ const result = deserializeHTML(testHTML) as Node[];++ expect(result.length).toBe(1);+ const block = result[0] as Element;+ console.log('===', result);+ expect(block.type).toEqual(BlockType.BulletedListBlock);+ const blockChildren = block.children;+ expect(blockChildren.length).toEqual(3);+ expect(blockChildren[1]).toEqual({+ blockId: (blockChildren[1] as Element).blockId,+ type: BlockType.HeadingBlock,+ relationId: (blockChildren[1] as Element).blockId,+ children: [{+ type: 'text',+ textId: (blockChildren[1] as Element).blockId,+ children: [{ text: 'Nested Heading' }],+ }],+ data: { level: 3 },+ });+ expect(blockChildren[2]).toEqual({+ blockId: (blockChildren[2] as Element).blockId,+ type: BlockType.Paragraph,+ relationId: (blockChildren[2] as Element).blockId,+ data: {},+ children: [{+ type: 'text',+ textId: (blockChildren[2] as Element).blockId,+ children: [{ text: 'Nested paragraph' }],+ }],+ });++ });+});\ No newline at end of filediff --git a/frontend/appflowy_web_app/src/components/editor/utils/fragment.ts b/frontend/appflowy_web_app/src/components/editor/utils/fragment.tsnew file mode 100644index 0000000000..5b831ca9d7--- /dev/null+++ b/frontend/appflowy_web_app/src/components/editor/utils/fragment.ts@@ -0,0 +1,336 @@+import { yDocToSlateContent } from '@/application/slate-yjs/utils/convert';+import {+ createBlock,+ createEmptyDocument,+ getBlock,+ getChildrenArray,+ getPageId,+ getText,+ updateBlockParent,+} from '@/application/slate-yjs/utils/yjsOperations';+import {+ AlignType,+ BlockData,+ BlockType,+ ImageBlockData,+ ImageType,+ YBlock,+ YjsEditorKey,+ YSharedRoot,+} from '@/application/types';+import { DeltaOperation } from 'quill';++export function deserialize (body: HTMLElement, sharedRoot: YSharedRoot) {+ const pageId = getPageId(sharedRoot);+ const rootBlock = getBlock(pageId, sharedRoot);++ if (rootBlock) {+ deserializeNode(body, rootBlock, sharedRoot);+ }+}++const BLOCK_TAGS = ['p', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'ul', 'ol', 'li', 'blockquote', 'pre', 'img', 'input'];++function deserializeNode (node: Node, parentBlock: YBlock, sharedRoot: YSharedRoot) {+ let currentBlock = parentBlock;++ if (node.nodeType === Node.ELEMENT_NODE) {+ const element = node as HTMLElement;+ const tagName = element.tagName.toLowerCase();+ const href = tagName.toLowerCase() === 'a' ? element.getAttribute('href') : null;++ if (href && isImageUrl(href)) {+ processImage(sharedRoot, parentBlock, {+ url: href,+ image_type: ImageType.External,+ });+ return;+ }++ if (BLOCK_TAGS.includes(tagName)) {+ const blockType = mapTagToBlockType(tagName, element);+ const blockData = mapToBlockData(element);++ if (blockType === BlockType.NumberedListBlock || blockType === BlockType.BulletedListBlock) {+ processList(element, sharedRoot, {+ ty: blockType,+ data: blockData,+ parent: parentBlock,+ });+ return;+ }++ if (blockType === BlockType.ImageBlock) {+ processImage(sharedRoot, parentBlock, blockData);+ return;+ }++ if (blockType === BlockType.TodoListBlock) {+ processTodoList(element, sharedRoot, parentBlock, blockData);+ return;+ }++ currentBlock = createBlock(sharedRoot, { ty: blockType, data: blockData });+ updateBlockParent(sharedRoot, currentBlock, parentBlock, getChildrenArray(parentBlock.get(YjsEditorKey.block_children), sharedRoot)?.length || 0);+ if (tagName === 'pre') {+ const code = element.querySelector('code');++ if (code) {+ applyTextToDelta(currentBlock, sharedRoot, code.textContent || '');+ } else {+ applyTextToDelta(currentBlock, sharedRoot, element.textContent || '');+ }++ return;+ }++ }++ Array.from(node.childNodes).forEach(childNode => {+ deserializeNode(childNode, currentBlock, sharedRoot);+ });+ } else if (node.nodeType === Node.TEXT_NODE) {+ const textContent = node.textContent || '';++ if (textContent.trim()) {+ console.log('===textContent', node, textContent);+ const attributes = getInlineAttributes(node.parentElement as HTMLElement);++ applyTextToDelta(currentBlock, sharedRoot, textContent, attributes);+ }+ }+}++function isImageUrl (url: string): boolean {+ if (url.startsWith('https://unsplash.com/') || url.startsWith('https://images.unsplash.com/')) {+ return true;+ }++ const imageExtensions = /\.(jpeg|jpg|gif|png|svg|webp)$/i;++ if (imageExtensions.test(url)) {+ return true;+ }++ return false;+}++function processTodoList (element: HTMLElement, sharedRoot: YSharedRoot, parentBlock: YBlock, blockData: BlockData) {++ const checkboxBlock = createBlock(sharedRoot, { ty: BlockType.TodoListBlock, data: blockData });++ updateBlockParent(sharedRoot, checkboxBlock, parentBlock, getChildrenArray(parentBlock.get(YjsEditorKey.block_children), sharedRoot)?.length || 0);++ const textContent = element.nextSibling?.textContent?.trim() || '';++ if (textContent) {+ applyTextToDelta(checkboxBlock, sharedRoot, textContent);+ }+}++function processImage (sharedRoot: YSharedRoot, parentBlock: YBlock, data: ImageBlockData) {++ const imageBlock = createBlock(sharedRoot, { ty: BlockType.ImageBlock, data });++ updateBlockParent(sharedRoot, imageBlock, parentBlock, getChildrenArray(parentBlock.get(YjsEditorKey.block_children), sharedRoot)?.length || 0);+}++function processList (parentEl: HTMLElement, sharedRoot: YSharedRoot, {+ ty,+ data,+ parent,+}: {+ ty: BlockType,+ data: BlockData,+ parent: YBlock+}) {+ Array.from(parentEl.childNodes).forEach(childNode => {+ const el = childNode as HTMLElement;++ if (!el || !el.tagName) return;+ const tagName = el.tagName.toLowerCase();+ const type = tagName === 'li' ? ty : BlockType.Paragraph;+ const block = createBlock(sharedRoot, { ty: type, data });++ updateBlockParent(sharedRoot, block, parent, getChildrenArray(parent.get(YjsEditorKey.block_children), sharedRoot)?.length || 0);+ Array.from(el.childNodes).forEach(childNode => {+ deserializeNode(childNode, block, sharedRoot);+ });+ });+}++function getInlineAttributes (element: HTMLElement): Record<string, boolean | string | undefined> {+ const attributes: Record<string, boolean | string | undefined> = {};++ if (element.style.fontWeight === 'bold' || element.tagName.toLowerCase() === 'strong') {+ attributes.bold = true;+ }++ if (element.style.fontStyle === 'italic' || element.tagName.toLowerCase() === 'em') {+ attributes.italic = true;+ }++ if (element.style.textDecoration === 'underline' || element.tagName.toLowerCase() === 'u') {+ attributes.underline = true;+ }++ if (element.style.textDecoration === 'line-through' || element.tagName.toLowerCase() === 'strike') {+ attributes.strikethrough = true;+ }++ if (element.tagName.toLowerCase() === 'a') {+ attributes.href = element.getAttribute('href') || '';+ }++ if (element.tagName.toLowerCase() === 'code') {+ attributes.code = true;+ }++ return attributes;+}++function applyTextToDelta (block: YBlock, sharedRoot: YSharedRoot, text: string, attributes: object = {}) {+ const textId = block.get(YjsEditorKey.block_external_id);+ const yText = getText(textId, sharedRoot);++ if (yText) {+ const oldOps = yText.toDelta();+ const delta: DeltaOperation[] = [{ insert: text, attributes }];++ yText.delete(0, yText.length);+ yText.applyDelta([+ ...oldOps,+ ...delta,+ ]);++ }+}++function mapToBlockData<T extends BlockData> (element: HTMLElement): T {+ const data = {} as T;++ const tag = element.tagName.toLowerCase();++ const styleString = element.getAttribute('style');++ if (styleString) {+ const styles = styleString.split(';').reduce((acc, style) => {+ const [key, value] = style.split(':').map(s => s.trim());++ if (key && value) {+ acc[key] = value;+ }++ return acc;+ }, {} as Record<string, string>);++ if (styles['text-align']) {+ const align = styles['text-align'];++ if (align === 'end' || align === 'right') {+ data.align = AlignType.Left;+ } else if (align === 'center') {+ data.align = AlignType.Center;+ } else {+ data.align = AlignType.Left;+ }+ }++ if (styles['background-color']) {+ data.bgColor = styles['background-color'];+ }++ if (styles['color']) {+ data.font_color = styles['color'];+ }+ }++ switch (tag) {+ case 'h1':+ Object.assign(data, { level: 1 });+ break;+ case 'h2':+ Object.assign(data, { level: 2 });+ break;+ case 'h3':+ Object.assign(data, { level: 3 });+ break;+ case 'h4':+ Object.assign(data, { level: 4 });+ break;+ case 'h5':+ Object.assign(data, { level: 5 });+ break;+ case 'h6':+ Object.assign(data, { level: 6 });+ break;+ case 'img': {+ const url = element.getAttribute('src');++ Object.assign(data, {+ url,+ image_type: ImageType.External,+ });+ break;+ }++ case 'input': {+ if (element.getAttribute('type') === 'checkbox') {+ const isChecked = element.hasAttribute('checked');++ Object.assign(data, {+ checked: isChecked,+ });+ }++ break;+ }+ }++ return data;+}++function mapTagToBlockType (tag: string, el: HTMLElement): BlockType {+ switch (tag) {+ case 'p':+ return BlockType.Paragraph;+ case 'h1':+ case 'h2':+ case 'h3':+ case 'h4':+ case 'h5':+ case 'h6':+ return BlockType.HeadingBlock;++ case 'ul':+ return BlockType.BulletedListBlock;+ case 'ol':+ return BlockType.NumberedListBlock;+ case 'blockquote':+ return BlockType.QuoteBlock;+ case 'pre':+ return BlockType.CodeBlock;+ case 'img':+ return BlockType.ImageBlock;+ case 'input':+ if (el.getAttribute('type') === 'checkbox') {+ return BlockType.TodoListBlock;+ }++ return BlockType.Paragraph;+ default:+ return BlockType.Paragraph;+ }+}++export function deserializeHTML (html: string) {+ const parsed = new DOMParser().parseFromString(html, 'text/html');+ const doc = createEmptyDocument();+ const sharedRoot = doc.getMap(YjsEditorKey.data_section) as YSharedRoot;++ deserialize(parsed.body, sharedRoot);++ const slateContent = yDocToSlateContent(doc);++ return slateContent?.children;+}\ No newline at end of filediff --git a/frontend/appflowy_web_app/src/components/editor/utils/markdown.ts b/frontend/appflowy_web_app/src/components/editor/utils/markdown.tsindex ab61e57ae4..fe004127b4 100644--- a/frontend/appflowy_web_app/src/components/editor/utils/markdown.ts+++ b/frontend/appflowy_web_app/src/components/editor/utils/markdown.ts@@ -214,7 +214,6 @@ const rules: Rule[] = [if (key === '**') return true;const text = match[1] || match[2];- console.log('applyMarkdown italic', text);return !text || text.length === 0;},},@@ -272,7 +271,6 @@ export const applyMarkdown = (editor: YjsEditor, insertText: string): boolean =>if (rule.type === 'block') {const match = text.match(rule.match);- console.log('applyMarkdown match', match, rule.match, text);if (match && !rule.filter?.(editor, match)) {if (rule.transform) {@@ -293,8 +291,6 @@ export const applyMarkdown = (editor: YjsEditor, insertText: string): boolean =>const matches = [...text.matchAll(new RegExp(rule.match, 'g'))];- console.log('applyMarkdown mark', rule.match, text, matches);-if (matches.length > 0 && matches.every((match) => !rule.filter?.(editor, match))) {for (const match of matches.reverse()) {const start = match.index!;diff --git a/frontend/appflowy_web_app/src/utils/hotkeys.ts b/frontend/appflowy_web_app/src/utils/hotkeys.tsindex c96753f544..957e6386b2 100644--- a/frontend/appflowy_web_app/src/utils/hotkeys.ts+++ b/frontend/appflowy_web_app/src/utils/hotkeys.ts@@ -15,6 +15,8 @@ export const getModifier = () => {export enum HOT_KEY_NAME {CLEAR_CACHE = 'clear-cache',+ UP = 'up',+ DOWN = 'down',LEFT = 'left',RIGHT = 'right',SELECT_ALL = 'select-all',@@ -88,6 +90,8 @@ const defaultHotKeys = {[HOT_KEY_NAME.FORMAT_LINK]: ['mod+k'],[HOT_KEY_NAME.LEFT]: ['left'],[HOT_KEY_NAME.RIGHT]: ['right'],+ [HOT_KEY_NAME.UP]: ['up'],+ [HOT_KEY_NAME.DOWN]: ['down'],[HOT_KEY_NAME.FIND_REPLACE]: ['mod+f'],[HOT_KEY_NAME.CLEAR_CACHE]: ['mod+shift+r'],};