}).bind(this);
this.$editor[0].addEventListener('mouseup', this.WoltLabCaret._handleEditorClick.bind(this));
+
+ var internalRange = null;
+ var selection = window.getSelection();
+ this.$editor[0].addEventListener('keyup', function () {
+ internalRange = selection.getRangeAt(0).cloneRange();
+ });
+
+ var mpSave = this.selection.save;
+ this.selection.save = (function () {
+ internalRange = null;
+
+ mpSave.call(this);
+ }).bind(this);
+
+ var mpRestore = this.selection.restore;
+ this.selection.restore = (function () {
+ if (internalRange) {
+ selection.removeAllRanges();
+ selection.addRange(internalRange);
+
+ internalRange = null;
+
+ if (selection.rangeCount && this.utils.isRedactorParent(selection.getRangeAt(0).commonAncestorContainer)) {
+ return;
+ }
+ }
+
+ mpRestore.call(this);
+ }).bind(this);
},
_handleEditorClick: function (event) {
* @protected
*/
_insertQuote: function (data) {
+ this._editor.selection.restore();
+
this._editor.buffer.set();
// caret must be within a `<p>`, if it is not move it
/** @type Node */
var block = this._editor.selection.block();
- if (block === false) {
- this._editor.selection.restore();
-
- block = this._editor.selection.block();
- }
-
var redactor = this._editor.core.editor()[0];
while (block.parentNode && block.parentNode !== redactor) {
block = block.parentNode;