Remove invalid parent paragraph when pasting in the visual editor or switching visual to HTML and back, keep multiple empty lines in a <pre> tag, fixes #15095 fixes #15367

git-svn-id: https://develop.svn.wordpress.org/trunk@16394 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Andrew Ozz
2010-11-15 23:57:27 +00:00
parent f5dea49c4a
commit 348236aeb7
5 changed files with 40 additions and 20 deletions

View File

@@ -166,6 +166,7 @@
});
ed.onInit.add(function(ed) {
// make sure these run last
ed.onNodeChange.add( function(ed, cm, e) {
var DL;
@@ -187,6 +188,14 @@
cm.setActive('justifycenter', 1);
}
});
// remove invalid parent paragraphs when pasting HTML and/or switching to the HTML editor and back
ed.onBeforeSetContent.add(function(ed, o) {
if ( o.content ) {
o.content = o.content.replace(/<p>\s*<(p|div|ul|ol|dl|table|blockquote|h[1-6]|fieldset|pre|address)( [^>]*)?>/gi, '<$1$2>');
o.content = o.content.replace(/<\/(p|div|ul|ol|dl|table|blockquote|h[1-6]|fieldset|pre|address)>\s*<\/p>/gi, '</$1>');
}
});
});
// Word count if script is loaded

File diff suppressed because one or more lines are too long