if (data.cancel !== true) {
this.buffer.set();
- var html = '[' + bbcode + ']' + this.selection.html() + (this.selection.is() ? '' : this.marker.html()) + '[/' + bbcode + ']';
+ var marker = this.marker.get();
+ marker.classList.add('woltlab-bbcode-marker');
+ var html = '[' + bbcode + ']' + this.selection.html() + marker.outerHTML + '[/' + bbcode + ']';
this.insert.html(html);
this.selection.restore();
}
}
elBySelAll('span', div, function (span) {
+ if (span.classList.contains('redactor-selection-marker')) return;
+
if (!span.hasAttribute('style') || !span.style.length) {
while (span.childNodes.length) {
span.parentNode.insertBefore(span.childNodes[0], span);
this.selection.saveInstant();
}).bind(this);
+
+ this.placeHtml = (function(html) {
+ var hasBbcodeMarker = false;
+ html.forEach(function(fragment) {
+ if (fragment instanceof Element && fragment.classList.contains('woltlab-bbcode-marker')) {
+ hasBbcodeMarker = true;
+ }
+ });
+
+ var marker = document.createElement('span');
+ marker.id = 'redactor-insert-marker';
+ marker = this.insert.node(marker);
+
+ $(marker).before(html);
+ this.selection.restore();
+ if (!hasBbcodeMarker) this.caret.after(marker);
+ $(marker).remove();
+ }).bind(this);
}
};
};