}
// remove <p> wrapping a quote or a div
- data = data.replace(/<p><(blockquote|div)/g, '<$1');
- data = data.replace(/<\/(blockquote|div)><\/p>/g, '</$1>');
+ data = data.replace(/<(?:div|p)><(blockquote|div)/g, '<$1');
+ data = data.replace(/<\/(blockquote|div)><\/(?:div|p)>/g, '</$1>');
WCF.System.Event.fireEvent('com.woltlab.wcf.redactor', 'afterConvertToHtml', { data: data });
var $setCaretBeforeOrAfter = (function(element, setBefore) {
if (setBefore) {
- if (element.previousElementSibling && element.previousElementSibling.tagName === 'P') {
+ if (element.previousElementSibling && (element.previousElementSibling.tagName === 'P' || element.previousElementSibling.tagName === 'DIV')) {
this.caret.setEnd(element.previousElementSibling);
}
else {
}
}
else {
- if (element.nextElementSibling && element.nextElementSibling.tagName === 'P') {
+ if (element.nextElementSibling && (element.nextElementSibling.tagName === 'P' || element.nextElementSibling.tagName === 'DIV')) {
this.caret.setEnd(element.nextElementSibling);
}
else {
* @param boolean setBefore
*/
_setCaret: function(element, setBefore) {
- var $node = $(this.opts.emptyHtml);
+ var $node;
+ if ((element[0] || element).parentElement && (element[0] || element).parentElement.tagName === 'BLOCKQUOTE') {
+ $node = $('<div>' + this.opts.invisibleSpace + '</div>');
+ }
+ else {
+ $node = $('<p>' + this.opts.invisibleSpace + '</p>');
+ }
+
$node[(setBefore ? 'insertBefore' : 'insertAfter')](element);
this.caret.setEnd($node[0]);
},