edx/edx-platform — pull request #3481 by andy-armstrong (2014-04-25 23:10:01+00:00)
Title: Implement better editor tracking of dirty state

This is a fix for TinyMCE to resolve STUD-1576. The challenge is that sometimes TinyMCE triggers content changes when focus is lost, which causes Studio's editor to re-save the content. This is an issue when the user is only trying to change the mode from visual to raw, because then their content also gets corrupted.

I'm now watching for keyboard, paste and drop events to determine whether the user has intentionally made a change. The code determines that the editor is dirty if at least one of such events has happened *and* the text compares as being different from its original state. I need the latter clause in case the user makes an edit but then deletes it, or if the only keys they use are non destructive like the arrow keys.

To test this, use the following piece of HTML which appears to be the smallest example that triggers the problem:

```

Example: Adding Four Forces

Heading

```