[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
This commit is contained in:
qsm-odoo
2017-12-18 16:10:33 +01:00
parent 34ed42f16d
commit b1b13dbeed
@@ -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;