angular-ui-OLDREPO icon indicating copy to clipboard operation
angular-ui-OLDREPO copied to clipboard

[TinyMCE] Updating model when setContent is called causes a TinyMCE formatting 'splosion

Open garkbit opened this issue 13 years ago • 1 comments

When a model is bound to both an instance of TinyMCE and something else (say a plain ol' textarea), problems arise when updating the model from said something else. This is easiest to understand with an example:

http://jsfiddle.net/EwMsa/

Enter some text in the plain textarea. Formatting 'splosion. Specifically, TinyMCE formats entered text after every keypress. So when I attempt to enter, say text, what I get is:

<p>t</p>
<p>e</p>
<p>x</p>
<p>t</p>

I don't know TinyMCE or Angular well enough to know exactly what's happening, but do know that the following code in /modules/directives/tinymce/tinymce.js appears to be triggering the behavior:

// Update model when calling setContent (such as from the source editor popup)
setup: function (ed) {
  ed.onSetContent.add(function (ed, o) {
    if (ed.isDirty()) {
      ed.save();
      ngModel.$setViewValue(elm.val());
      if (!scope.$$phase)
        scope.$apply();
    }
  });
}

For my purposes, adjusting the directive to omit the function entirely works just fine, as what I'm doing obviates the need for TinyMCE's source editor, however this obviously doesn't work for everyone.

garkbit avatar May 03 '13 01:05 garkbit

I've copied this over to what I believe is the more appropriate location.

garkbit avatar May 03 '13 01:05 garkbit