Skip to content

Commit

Permalink
observe properties and re-init if changed
Browse files Browse the repository at this point in the history
  • Loading branch information
JaySunSyn committed Jan 10, 2017
1 parent a541aef commit 7a966e1
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions polymer-tinymce.html
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@
},

observers: [
'_initEditor(_textareaId)'
'_initEditor(_textareaId, initOptions, height, tinytoolbar, tinyplugins, menubar, noStatusbar, templates)'
],

attached: function(){
Expand Down Expand Up @@ -213,6 +213,10 @@
if(this.protectedInitOptions.indexOf(k) === -1) options[k] = this.initOptions[k];
}

// Remove instance if exists
tinymce.remove(options['selector']);

// Initialize
tinymce.init(options);
},

Expand All @@ -233,6 +237,8 @@
* Updates the value property.
*/
getContent: function(options){
if (!tinyMCE || !tinyMCE.get(this._textareaId)) return;

if (typeof options !== 'undefined') {
var content = tinyMCE.get(this._textareaId).getContent(options);
} else {
Expand All @@ -247,9 +253,8 @@
* Sets the content of the editor.
*/
setContent: function(content){
if (tinyMCE && tinyMCE.get(this._textareaId)){
tinyMCE.get(this._textareaId).setContent(content);
}
if (!tinyMCE || !tinyMCE.get(this._textareaId)) return;
tinyMCE.get(this._textareaId).setContent(content);
},

_getUniqueId: function() {
Expand Down

0 comments on commit 7a966e1

Please sign in to comment.