From b1b13dbeede54d3473a0b80e6a8dc21bedfdc5c9 Mon Sep 17 00:00:00 2001 From: qsm-odoo Date: Mon, 18 Dec 2017 11:27:25 +0100 Subject: [FIX] web_editor: revert copy/paste feature of the editor The feature was introduced and fixed by following commits: - https://github.com/odoo/odoo/commit/906875fc78cb80f6c3d5f1f14f997008cd406473 - https://github.com/odoo/odoo/commit/76be5eed449c78eaf0b4208c381169132492ab4a - https://github.com/odoo/odoo/commit/7401807510a103374fa8eb524ae5a5698ae21a39 The feature is however still buggy in lots of cases as it is a bad heuristic that cannot handle simple pasting cases. The feature was initially introduced to allow pasting PDF content without having to remove all the unwanted line breaks this induces. As this feature is not that important and introduced more bugs than it solved, the feature is deleted by this commit. If we want that feature again, maybe it is worth considering an "Import from PDF" button or something like that. See https://github.com/odoo/odoo/issues/15665 --- addons/web_editor/static/src/js/summernote.js | 20 -------------------- 1 file changed, 20 deletions(-) (limited to 'addons/web_editor/static/src') diff --git a/addons/web_editor/static/src/js/summernote.js b/addons/web_editor/static/src/js/summernote.js index af5e0112e38..e439f52824a 100644 --- a/addons/web_editor/static/src/js/summernote.js +++ b/addons/web_editor/static/src/js/summernote.js @@ -2370,26 +2370,6 @@ eventHandler.modules.popover.update = function ($popover, oStyle, isAirMode) { } }; -// override summernote clipboard functionality -eventHandler.modules.clipboard.attach = function(layoutInfo) { - var $editable = layoutInfo.editable(); - $editable.on('paste', function(e) { - var clipboardData = ((e.originalEvent || e).clipboardData || window.clipboardData); - // Change nothing if pasting html (copy from text editor / web / ...) or - // if clipboardData is not available (IE / ...) - if (clipboardData && clipboardData.types && clipboardData.types.length === 1 && clipboardData.types[0] === "text/plain") { - e.preventDefault(); - $editable.data('NoteHistory').recordUndo($editable); // FIXME - var pastedText = clipboardData.getData("text/plain"); - // Try removing linebreaks which are not really linebreaks (in a PDF, - // when a sentence goes over the next line, copying it considers it - // a linebreak for example). - var formattedText = pastedText.replace(/([\w-])\r?\n([\w-])/g, "$1 $2").trim(); - document.execCommand("insertText", false, formattedText); - } - }); -}; - ////////////////////////////////////////////////////////////////////////////////////////////////////////// var fn_attach = eventHandler.attach; -- cgit v1.2.3