You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Just a heads-up for anyone facing similar issues — I found a workaround for pasting code by implementing a custom pasteHandler.
In my case, the clipboard content wasn’t being detected as "text/markdown", so I switched to checking for "text/plain" instead. Everything else remains the same and works as expected. If "text/markdown" works for you, feel free to adjust the condition.
Here’s the snippet:
pasteHandler: ({ event, editor, defaultPasteHandler }) => {
if (event.clipboardData?.types.includes("text/plain")) {
(async () => {
const cursor = editor.getTextCursorPosition();
console.log("Cursor", cursor.block.type);
let data = await navigator.clipboard.readText();
if (cursor.block.type === "codeBlock") {
data = `\`\`\`\n${data}\n\`\`\``;
}
const markdownTextBlock = await editor.tryParseMarkdownToBlocks(
data
);
editor.insertBlocks(markdownTextBlock, cursor.block);
editor.removeBlocks([cursor.block]);
})();
return true;
}
return defaultPasteHandler();
},
Describe the bug
I copy a code, I create a code block, I paste : only the first line is in the code block, the rest is outside the code block.
To Reproduce
Bug.TypeCell.mp4
I have tested on the website and on docs.numerique.gouv.fr .
Misc
The text was updated successfully, but these errors were encountered: