From 39c4ec63710affcf04b24eacc9e13831cb295e6a Mon Sep 17 00:00:00 2001 From: alekseybobkov Date: Thu, 15 Jan 2015 21:35:39 -0800 Subject: [PATCH] Remove Redactor-specific markup and attributes from the edited text. --- .../richeditor/assets/js/richeditor.js | 22 ++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/modules/backend/formwidgets/richeditor/assets/js/richeditor.js b/modules/backend/formwidgets/richeditor/assets/js/richeditor.js index be28b66ce..4bfc3eb72 100644 --- a/modules/backend/formwidgets/richeditor/assets/js/richeditor.js +++ b/modules/backend/formwidgets/richeditor/assets/js/richeditor.js @@ -139,7 +139,27 @@ } this.$textarea.trigger('syncBefore.oc.richeditor', [container]) - return container.html + + var $domTree = $('
'+container.html+'
') + + // This code removes Redactor-specific attributes and tags from the code. + // It seems to be a known problem with Redactor, try googling for + // "data-redactor-tag" or "redactor-invisible-space" (with quotes) + $('*', $domTree).removeAttr('data-redactor-tag') + + $domTree.find('span[data-redactor-class="redactor-invisible-space"]').each(function(){ + $(this).children().insertBefore(this) + $(this).remove() + }) + + $domTree.find('span.redactor-invisible-space').each(function(){ + $(this).children().insertBefore(this) + $(this).remove() + }) + + $domTree.find('div.oc-figure-controls').remove() + + return $domTree.html() } RichEditor.prototype.keydown = function(e, $editor) {