Richard, this is not simple. The simplest Fail case is if you have a little bit of code (and at present the only code I have used is for Tabs) then if you paste into the editor any unformatted text (for instance a web link) the editor then deletes all the code that makes the tabs work.
I'd be interested if you could explain exactly what is happening for you.
- One of the threads on this is here: https://moodle.org/mod/forum/discuss.php?d=347847
- Another: https://moodle.org/mod/forum/discuss.php?d=347860
- Tracker item is here: https://tracker.moodle.org/browse/MDL-58084
Ryan Wylie has posted in the tracker thread saying this is not a bug:
Unfortunately this doesn't appear to be a bug with atto from what I can tell.
As Mark mentioned above, if you're using the WYSIWYG view on the atto editor the code behind the scenes will attempt to sanitise a few things in the content that you're pasting in an attempt to keep consistent styling (depending on where you are copying the content from, it can come along with a lot more information than what you see in the page).
The WYSISYG editor isn't really suitable to generate rich HTML widgets (though you can sometimes get it to work), such as tabs, because it is very easy to generate invalid HTML (especially when pasting content from different sources). It's quite a bit more complex to write a full widget than to mark up some simple content.
If you have a need to build something a little more complex then it's best to do it in the code view within atto (click the "show/hide advanced buttons" -> HTML button). This will allow you to write the HTML directly, though it does require a bit more of an advanced knowledge of HTML I'm afraid.
I'd like the Atto settings to be adjusted so that the cleanup/sanitising is a little less aggressive, but from what Ryan says, this is not likely to happen. He has suggested using the html view to code what he calls widgets (like a few tabs); this is too much like hard work for me.
Possible fix/kludge work around
Mark Sharp posted this, which introduces the idea of pasting from M$Word, which may hep you:
So, when you paste into atto, it is expecting some kind of formatting to come along with it. e.g. Pasting from Word or from a website. It identifies it as such and does some clean up, then pastes your text from the clipboard. And, actually that works. If you paste from a website, you don't lose all your formatting.
However, if you try to be clean and paste from a text editor, the clipboard doesn't having any formatting information, so atto runs a function called fallbackPasteCleanup (you can see this in your browser console if you have the dev tools open - usually F12 opens that). This cleanup seems to be a little more rigourous and applies this._cleanPasteHTML to all the content rather than just the pasted content.
You can see the problem with this: you will being a lot of odd formatting from your source web page or word document, and this makes your HTML look a mess. In the last version I used (Moodle Verson 3.0) the cut and paste from Notepad process was flawless, so this new behaviour has come in in version 3.1 or 3.2.
Just in case you missed my request: I'd be interested in exactly what is happening for you.