}
else {
$html = this.wbbcode.convertToHtml($openTag + $id + $closingTag);
- $html = $html.replace($id, $innerHTML.replace(/^<p>/, '').replace(/<\/p>$/, ''));
+ $html = $html.replace($id, html.replace(/^<p>/, '').replace(/<\/p>$/, ''));
}
$html = $html.replace(/^<p>/, '').replace(/<\/p>$/, '');
if (!window.getSelection().rangeCount) {
this.wutil.selectionEndOfEditor();
}
+
+ this.wutil.saveSelection();
}
}
}
}).bind(this);
+ var $fixSelection = function() {
+ var $selection = window.getSelection();
+ if (!$selection.rangeCount) {
+ return;
+ }
+
+ var $range = $selection.getRangeAt(0);
+ if (!$range.collapsed) {
+ return;
+ }
+
+ var $element = $range.startContainer;
+ if ($element.nodeType === Node.ELEMENT_NODE && $element.tagName === 'DIV') {
+ var $parentNode = $element.parentNode;
+ if ($parentNode !== null && $parentNode.tagName === 'BLOCKQUOTE' && $parentNode.classList.contains('quoteBox')) {
+ var $endContainer = $range.startContainer.childNodes[$range.startContainer.childNodes.length - 1];
+ var $newRange = document.createRange();
+ $newRange.setStart($range.startContainer.childNodes[0], 0);
+
+ $newRange.setEnd($endContainer, $endContainer.length);
+ $newRange.collapse(false);
+
+ $selection.removeAllRanges();
+ $selection.addRange($newRange);
+ }
+ }
+ };
+
// paste.insert
var $mpInsert = this.paste.insert;
this.paste.insert = (function(html) {
+ $fixSelection();
+
$mpInsert.call(this, html);
setTimeout((function() {