From 7a966e1bd908b4f532883003f5f004ed6ae478ff Mon Sep 17 00:00:00 2001 From: Jalal Fathi Date: Tue, 10 Jan 2017 23:26:55 +0100 Subject: [PATCH] observe properties and re-init if changed --- polymer-tinymce.html | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/polymer-tinymce.html b/polymer-tinymce.html index ee670a9..03732b2 100644 --- a/polymer-tinymce.html +++ b/polymer-tinymce.html @@ -160,7 +160,7 @@ }, observers: [ - '_initEditor(_textareaId)' + '_initEditor(_textareaId, initOptions, height, tinytoolbar, tinyplugins, menubar, noStatusbar, templates)' ], attached: function(){ @@ -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); }, @@ -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 { @@ -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() {