Text editors

ATTO editor loses code changes on save

 
Richard Samson
ATTO editor loses code changes on save
 

Moodle 3.2, Boost theme

Excuse me if this has a logical explanation, or if it is a feature, not a bug...

When I make changes in code view and save, the changes are lost. For the changes to be saved I have to return to visual editor view first, then save.

This behaviour is driving me nuts!

Anybody else?


 
Average of ratings: -
Just wondering . . .
Re: ATTO editor loses code changes on save
Group Particularly helpful Moodlers

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.

  1. One of the threads on this is here: https://moodle.org/mod/forum/discuss.php?d=347847
  2. Another: https://moodle.org/mod/forum/discuss.php?d=347860
  3. 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.  smile

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.

Good luck

-Derek


 
Average of ratings: -
Richard Samson
Re: ATTO editor loses code changes on save
 

Thanks for your reply, Derek.

I've made a video clip to show you what I see.

It's not the same issue of HTML/CSS clean-up that you describe. What I am referring to is a usability issue.

 

 

Any further thoughts?

 
Average of ratings: Useful (2)
Picture of AL Rachels
Re: ATTO editor loses code changes on save
Group Core developersGroup Particularly helpful MoodlersGroup Plugin developersGroup Testers

Hi Richard,

I see the same behavior with the Atto editor. It gets to be especially frustrating when editing templates in a database activity where I often need to add code to get the desired layout effect. On more than one occasion I've lost a lot of work when I've tried to save the template before switching back to the normal view.

 
Average of ratings: -
Just wondering . . .
Re: ATTO editor loses code changes on save
Group Particularly helpful Moodlers

OK, you are right Richard.  I think I have seen this behaviour. I think this is a bug.

Are you familiar with the tracker?  I cannot find any reports of this behaviour there.  You may like to add something.  I think this link will get you to all the Atto tracker items.

-Derek

 
Average of ratings: -