From c4651fcb3fc8da76481493b29e690b8f76c0e06b Mon Sep 17 00:00:00 2001 From: benweet Date: Wed, 14 Feb 2018 22:19:54 +0000 Subject: [PATCH] Fixed cut/copy from the editor --- src/libs/cleditCore.js | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/src/libs/cleditCore.js b/src/libs/cleditCore.js index 651fe0d1..57933208 100644 --- a/src/libs/cleditCore.js +++ b/src/libs/cleditCore.js @@ -295,6 +295,24 @@ function cledit(contentElt, scrollElt, windowParam) { }, 0) }, false) + contentElt.addEventListener('copy', function (evt) { + if (evt.clipboardData) { + evt.clipboardData.setData('text/plain', selectionMgr.getSelectedText()); + evt.preventDefault(); + } + }) + + contentElt.addEventListener('cut', function (evt) { + if (evt.clipboardData) { + evt.clipboardData.setData('text/plain', selectionMgr.getSelectedText()); + evt.preventDefault(); + replace(selectionMgr.selectionStart, selectionMgr.selectionEnd, '') + } else { + undoMgr.setCurrentMode('single') + } + adjustCursorPosition() + }) + contentElt.addEventListener('paste', function (evt) { undoMgr.setCurrentMode('single') evt.preventDefault() @@ -304,10 +322,10 @@ function cledit(contentElt, scrollElt, windowParam) { data = clipboardData.getData('text/plain') try { var html = clipboardData.getData('text/html'); - if (html) { + if (html && !clipboardData.getData('text/css')) { var sanitizedHtml = htmlSanitizer.sanitizeHtml(html) .replace(/ /g, ' '); // Replace non-breaking spaces with classic spaces - if (sanitizedHtml && sanitizedHtml.indexOf('