From a1069c3e3d8d7f9aa7a00c26d88d3610b1142a7e Mon Sep 17 00:00:00 2001 From: Hyko Date: Sat, 25 Apr 2026 21:03:13 -0400 Subject: [PATCH] feat(BlockEditor): add notion native json paste support - import `notionJsonToBlocks` in `Block.client.js` and prioritize `text/_notion-blocks-v3-production` mime over `text/html` on paste - implement `notionJsonToBlocks` and `notionValueToBlock` in `clipboard.js` to convert notion block json to editor blocks, preserving native types (`to_do`, `sub_sub_header`, etc.) - update README to document the notion mime priority in paste handling --- .../components/BlockEditor/Block.client.js | 22 +++++- src/shared/components/BlockEditor/README.md | 7 +- .../BlockEditor/inline/clipboard.js | 70 +++++++++++++++++++ 3 files changed, 96 insertions(+), 3 deletions(-) diff --git a/src/shared/components/BlockEditor/Block.client.js b/src/shared/components/BlockEditor/Block.client.js index 4279aae..37c20e5 100644 --- a/src/shared/components/BlockEditor/Block.client.js +++ b/src/shared/components/BlockEditor/Block.client.js @@ -37,7 +37,7 @@ function useDropdownPlacement(open, triggerRef) { import { getBlockDef, listBlocks } from './blockRegistry.js'; import { inlineLength } from './inline/types.js'; import { inlineToDom, domToInline } from './inline/serialize.js'; -import { htmlToBlocks } from './inline/clipboard.js'; +import { htmlToBlocks, notionJsonToBlocks } from './inline/clipboard.js'; import { getCaretOffset, getCaretRange, @@ -544,9 +544,29 @@ const Block = forwardRef(function Block( function handlePaste(e) { e.preventDefault(); + // Notion expose ses blocs natifs via sa MIME propriétaire en plus du HTML. + // Le HTML aplatit `to_do` en `