From d89940236c6ccd77e50e87f31dd36749aa37d4c4 Mon Sep 17 00:00:00 2001 From: irfan ahammed Date: Sat, 16 Nov 2024 21:11:08 +0530 Subject: [PATCH] Copying from notpad to somewhere else --- src/lib/helpers/menubar/edit-options.ts | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/lib/helpers/menubar/edit-options.ts b/src/lib/helpers/menubar/edit-options.ts index 96f305d3..da3f5ba4 100644 --- a/src/lib/helpers/menubar/edit-options.ts +++ b/src/lib/helpers/menubar/edit-options.ts @@ -24,11 +24,13 @@ export class EditOptions { const selectedContent = quill.getContents(selection.index, selection.length); const tempCont = document.createElement('div'); new Quill(tempCont).setContents(selectedContent); - const clipboardData = tempCont.getElementsByClassName('ql-editor')[0].innerHTML; + const clipboardHtmlData = tempCont.getElementsByClassName('ql-editor')[0].innerHTML; + const clipboardTextData = quill.getText(selection.index, selection.length); navigator.clipboard .write([ new ClipboardItem({ - 'text/html': new Blob([clipboardData], { type: 'text/html' }) + 'text/plain': new Blob([clipboardTextData], { type: 'text/plain' }), + 'text/html': new Blob([clipboardHtmlData], { type: 'text/html' }) }) ]) .catch((err) => { @@ -47,11 +49,13 @@ export class EditOptions { const selectedContent = quill.getContents(selection.index, selection.length); const tempCont = document.createElement('div'); new Quill(tempCont).setContents(selectedContent); - const clipboardData = tempCont.getElementsByClassName('ql-editor')[0].innerHTML; + const clipboardHtmlData = tempCont.getElementsByClassName('ql-editor')[0].innerHTML; + const clipboardTextData = quill.getText(selection.index, selection.length); navigator.clipboard .write([ new ClipboardItem({ - 'text/html': new Blob([clipboardData], { type: 'text/html' }) + 'text/plain': new Blob([clipboardTextData], { type: 'text/plain' }), + 'text/html': new Blob([clipboardHtmlData], { type: 'text/html' }) }) ]) .catch((err) => {