Skip to content
This repository has been archived by the owner on May 5, 2018. It is now read-only.

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

Closed
garkbit opened this issue May 3, 2013 · 1 comment

Comments

@garkbit
Copy link

garkbit commented May 3, 2013

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
Copy link
Author

garkbit commented May 3, 2013

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

@ProLoser ProLoser closed this as completed May 3, 2013
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants