app/assets/javascripts/activeadmin/trumbowyg/plugins/cleanpaste/trumbowyg.cleanpaste.js in activeadmin_trumbowyg-0.1.8 vs app/assets/javascripts/activeadmin/trumbowyg/plugins/cleanpaste/trumbowyg.cleanpaste.js in activeadmin_trumbowyg-0.2.0
- old
+ new
@@ -58,13 +58,12 @@
// strip out -cgCraft
html = html.replace(/ /gi, ' ');
// strip out extra spaces -cgCraft
html = html.replace(/ <\//gi, '</');
- while (html.indexOf(' ') !== -1) {
- html = html.split(' ').join(' ');
- }
+ // Remove multiple spaces
+ html.replace(/\s+/g, ' ');
// strip -cgCraft
html = html.replace(/^\s*|\s*$/g, '');
// Strip out unaccepted attributes
@@ -76,11 +75,11 @@
return '';
});
return match;
});
- // Final cleanout for MS Word crud
+ // Final clean out for MS Word crud
html = html.replace(/<\?xml[^>]*>/g, '');
html = html.replace(/<[^ >]+:[^>]*>/g, '');
html = html.replace(/<\/[^ >]+:[^>]*>/g, '');
// remove unwanted tags
@@ -96,17 +95,17 @@
$.extend(true, $.trumbowyg, {
plugins: {
cleanPaste: {
init: function (trumbowyg) {
trumbowyg.pasteHandlers.push(function () {
- try {
- trumbowyg.$ed.html(cleanIt(trumbowyg.$ed.html()));
- } catch (c) {
- }
+ setTimeout(function () {
+ try {
+ trumbowyg.$ed.html(cleanIt(trumbowyg.$ed.html()));
+ } catch (c) {
+ }
+ }, 0);
});
}
}
}
});
})(jQuery);
-
-