Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-57374

Pasting unformatted non HTML plain text in Atto removes all styles and class attributes from all existing content in editor

XMLWordPrintable

    • MOODLE_31_STABLE, MOODLE_32_STABLE
    • MOODLE_31_STABLE, MOODLE_32_STABLE
    • MDL-57374_master
    • Hide

      Please repeat in as many browsers as possible (IE/Edge, Firefox, Chrome, Safari)

      1. In Atto create a formatted text (edit a course section or similar) and apply some formatting like background-color of a text or text-color or use some class for a div element. Best would be to use the provided HTML in the "Description" of this bug (paste in source mode, then switch back to HTML-mode in Atto)
      2. From a pure text editor like gedit, notepad or TextEdit (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!
      3. All styles and class attributes should remain intact
      Show
      Please repeat in as many browsers as possible (IE/Edge, Firefox, Chrome, Safari) In Atto create a formatted text (edit a course section or similar) and apply some formatting like background-color of a text or text-color or use some class for a div element. Best would be to use the provided HTML in the "Description" of this bug (paste in source mode, then switch back to HTML-mode in Atto) From a pure text editor like gedit, notepad or TextEdit (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 should remain intact

      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:

      1. 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>
      

      1. Switch to "HTML"-mode in Atto
      2. 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!
      3. All styles and class attributes will be removed
      4. 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.

            dasistwas David Bogner
            dasistwas David Bogner
            Mark Nelson Mark Nelson
            Dan Poltawski Dan Poltawski
            Jade Telford Jade Telford
            Votes:
            6 Vote for this issue
            Watchers:
            10 Start watching this issue

              Created:
              Updated:
              Resolved:

                Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.