diff options
| author | Nicolas Lempereur <nle@odoo.com> | 2016-10-28 08:44:51 +0200 |
|---|---|---|
| committer | Nicolas Lempereur <nle@odoo.com> | 2016-10-31 13:27:00 +0100 |
| commit | 76be5eed449c78eaf0b4208c381169132492ab4a (patch) | |
| tree | 6295799ab6fdf267ce873c484df2871e07ddb9d0 /addons/web_editor/static/src/js/summernote.js | |
| parent | 57774efbea91b575d4ada214bdab7f00067e4bcf (diff) | |
[FIX] web_editor: don't paste two times
When pasting, the paste event is cancelled and done back with the
corrected data.
This works fine on firefox, but this can have unwanted results on other
browser like pasting two times or copying the end of the line at the
beginning.
This commit replace completely the summernote functionality with our
small implementation of pasting corrected text.
closes #14043
opw-690814
Diffstat (limited to 'addons/web_editor/static/src/js/summernote.js')
| -rw-r--r-- | addons/web_editor/static/src/js/summernote.js | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/addons/web_editor/static/src/js/summernote.js b/addons/web_editor/static/src/js/summernote.js index 6e52936cc27..dac367712eb 100644 --- a/addons/web_editor/static/src/js/summernote.js +++ b/addons/web_editor/static/src/js/summernote.js @@ -2302,13 +2302,16 @@ eventHandler.modules.popover.update = function ($popover, oStyle, isAirMode) { } }; -options.onPaste = function (e) { - e.preventDefault(); // FIXME this does not work with our custom out-dated summernote. - document.execCommand("undo"); // FIXME ... so use this hack until we decide to do something about it. - - var pastedText = ((e.originalEvent || e).clipboardData || window.clipboardData).getData('Text'); - var formattedText = pastedText.replace(/([^.!?:;])\r?\n/g, "$1").trim(); // Remove linebreaks which are not at the end of a sentence - document.execCommand("insertText", false, formattedText); +// override summernote clipboard functionality +eventHandler.modules.clipboard.attach = function(layoutInfo) { + var $editable = layoutInfo.editable(); + $editable.on('paste', function(e) { + e.preventDefault(); + $editable.data('NoteHistory').recordUndo($editable); + var pastedText = ((e.originalEvent || e).clipboardData || window.clipboardData).getData('Text'); + var formattedText = pastedText.replace(/([^.!?:;])\r?\n/g, "$1").trim(); // Remove linebreaks which are not at the end of a sentence + document.execCommand("insertText", false, formattedText); + }); }; ////////////////////////////////////////////////////////////////////////////////////////////////////////// |
