-
Bug
-
Resolution: Fixed
-
Minor
-
3.1.3, 3.2
-
MOODLE_31_STABLE, MOODLE_32_STABLE
-
MOODLE_31_STABLE, MOODLE_32_STABLE
-
MDL-57374_master -
I checked out latest 3.1.3 version, also testet with 3.1.2 and 3.1.1. vanilla install
Description of the problem
When pasting pure plain text without any HTML markup, then atto cleans all the already present content very aggressively and removes all style and class attributes.
How to reproduce:
- Paste the following HTML in source mode into atto editor
<h3>Heading</h3>Lorem ipsum dolor sit amet, <span class="" style="color: rgb(255, 207, 53);">consetetur</span> <span class="" style="background-color: rgb(255, 207, 53);">sadipscing</span> elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. |
<div class="alert alert-info">Info text for testing</div> |
At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.<br><br><h2>Beschreibung von Allgemeines</h2><br>
|
- Switch to "HTML"-mode in Atto
- From a pure text editor (or from the search field in your browser) copy and paste plain text somewhere in the editor. The text must not have any HTML tags!
- All styles and class attributes will be removed
- NOTE: Pasting HTML (taken from a HTML pag) does not remove any classes and styles, only pasting plain text does!
I tracked down the issue to following JS file:
/lib/editor/atto/yui/build/moodle-editor_atto-editor/moodle-editor_atto-editor.js
function: _cleanStyles
This function returns the cleaned HTML with
return holder.innerHTML; |
Solution
I think when plain text is pasted, the content passed to _cleanPasteHTML contains the whole content of the editor instead of only the pasted content.
See attached video
For reproducing also see attached video.