diff --git a/_editor/plugins/ViewSource.js b/_editor/plugins/ViewSource.js index 1eec7567f..ba94103af 100644 --- a/_editor/plugins/ViewSource.js +++ b/_editor/plugins/ViewSource.js @@ -107,6 +107,15 @@ define([ this.editor = editor; this._initButton(); + // Filter the html content when it is set and retrieved in the editor. + this.removeValueFilterHandles(); + this._setValueFilterHandle = aspect.before(this.editor, "setValue", lang.hitch(this, function (html) { + return [this._filter(html)]; + })); + this._getValueFilterHandle = aspect.after(this.editor, "getValue", lang.hitch(this, function (html) { + return this._filter(html); + })); + this.editor.addKeyHandler(keys.F12, true, true, lang.hitch(this, function(e){ // Move the focus before switching // It'll focus back. Hiding a focused @@ -152,9 +161,6 @@ define([ return cmd.toLowerCase() === "viewsource"; }; this.editor.onDisplayChanged(); - html = ed.get("value"); - html = this._filter(html); - ed.set("value", html); array.forEach(edPlugins, function(p){ // Turn off any plugins not controlled by queryCommandenabled. if(p && !(p instanceof ViewSource) && p.isInstanceOf(_Plugin)){ @@ -170,7 +176,7 @@ define([ }; } - this.sourceArea.value = html; + this.sourceArea.value = ed.get("value"); // Since neither iframe nor textarea have margin, border, or padding, // just set sizes equal. @@ -235,7 +241,7 @@ define([ this._setListener = aspect.after(this.editor, "setValue", lang.hitch(this, function(htmlTxt){ htmlTxt = htmlTxt || ""; - htmlTxt = this._filter(htmlTxt); + // htmlTxt was filtered in setValue before aspect. this.sourceArea.value = htmlTxt; }), true); }else{ @@ -262,8 +268,8 @@ define([ ed.queryCommandEnabled = ed._sourceQueryCommandEnabled; if(!this._readOnly){ html = this.sourceArea.value; - html = this._filter(html); ed.beginEditing(); + // html will be filtered in setValue aspect. ed.set("value", html); ed.endEditing(); } @@ -523,6 +529,17 @@ define([ return html; }, + removeValueFilterHandles: function () { + if (this._setValueFilterHandle) { + this._setValueFilterHandle.remove(); + delete this._setValueFilterHandle; + } + if (this._getValueFilterHandle) { + this._getValueFilterHandle.remove(); + delete this._getValueFilterHandle; + } + }, + setSourceAreaCaret: function(){ // summary: // Internal function to set the caret in the sourceArea @@ -557,6 +574,7 @@ define([ this._setListener.remove(); delete this._setListener; } + this.removeValueFilterHandles(); this.inherited(arguments); } }); diff --git a/tests/editor/test_ViewSource.html b/tests/editor/test_ViewSource.html index d9ed943a9..b41436e2f 100644 --- a/tests/editor/test_ViewSource.html +++ b/tests/editor/test_ViewSource.html @@ -9,12 +9,21 @@ @@ -147,6 +156,29 @@

Things to test:



+
+
+

ViewSource Plugin with onmouseover in content.

+

foobar

+ +

Things to test:

+
    +
  1. Move mouse over "foobar" and make sure alert is not displayed.
  2. +
+
+
+
+
+
+
+
+
+
+
Content after the editors.