1
0
mirror of https://github.com/laurent22/joplin.git synced 2024-12-24 10:27:10 +02:00

Desktop: Fixes #6257: Fixed the missing format when pasting text by Ctrl+V in Rich Text editor (#6901)

This commit is contained in:
Self Not Found 2022-10-01 22:35:54 +08:00 committed by GitHub
parent 50baad3c04
commit 5364965a69
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1008,7 +1008,9 @@ const TinyMCE = (props: NoteBodyEditorProps, ref: any) => {
const result = await markupToHtml.current(MarkupToHtml.MARKUP_LANGUAGE_MARKDOWN, pastedText, markupRenderOptions({ bodyOnly: true }));
editor.insertContent(result.html);
} else { // Paste regular text
const pastedHtml = event.clipboardData.getData('text/html');
// event.clipboardData.getData('text/html') wraps the content with <html><body></body></html>,
// which seems to be not supported in editor.insertContent().
const pastedHtml = clipboard.readHTML();
if (pastedHtml) { // Handles HTML
const modifiedHtml = await processPastedHtml(pastedHtml);
editor.insertContent(modifiedHtml);