From: Alexander Ebert Date: Mon, 15 Dec 2014 14:44:01 +0000 (+0100) Subject: Improved selection handling X-Git-Tag: 2.1.0_Beta_2~35 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=a3fdba15ef93f5a5c102664b2fed5353d1d6a2ec;p=GitHub%2FWoltLab%2FWCF.git Improved selection handling --- diff --git a/wcfsetup/install/files/js/3rdParty/redactor/plugins/wbutton.js b/wcfsetup/install/files/js/3rdParty/redactor/plugins/wbutton.js index 6a4913fca9..3694b5e4b1 100644 --- a/wcfsetup/install/files/js/3rdParty/redactor/plugins/wbutton.js +++ b/wcfsetup/install/files/js/3rdParty/redactor/plugins/wbutton.js @@ -89,6 +89,14 @@ RedactorPlugins.wbutton = function() { this.button.addCallback(this.button.get('image'), $.proxy(this.wbutton.insertImage, this)); }, + /** + * Modifies an existing button belonging to Redactor. + * + * @param string buttonName + * @param string buttonTitle + * @param string faIcon + * @param string insertAfter + */ _addCoreButton: function(buttonName, buttonTitle, faIcon, insertAfter) { var $buttonObj = { title: (buttonTitle === null ? buttonName : buttonTitle) }; if (buttonName === 'subscript' || buttonName === 'superscript') { @@ -153,6 +161,7 @@ RedactorPlugins.wbutton = function() { } } else { + this.buffer.set(); this.insert.html('[' + $bbcode + ']' + $selectedHtml + this.selection.getMarkerAsHtml() + '[/' + $bbcode + ']', false); this.selection.restore(); } diff --git a/wcfsetup/install/files/js/3rdParty/redactor/plugins/wmonkeypatch.js b/wcfsetup/install/files/js/3rdParty/redactor/plugins/wmonkeypatch.js index 4f37093637..0fbea06d48 100644 --- a/wcfsetup/install/files/js/3rdParty/redactor/plugins/wmonkeypatch.js +++ b/wcfsetup/install/files/js/3rdParty/redactor/plugins/wmonkeypatch.js @@ -88,8 +88,17 @@ RedactorPlugins.wmonkeypatch = function() { this.$editor.on('keyup.redactor', $.proxy(this.keyup.init, this)); } - this.$editor.on('mousedown.wmonkeypatch mouseup.wmonkeypatch', (function() { - this.wutil.saveSelection(); + var $saveSelection = false; + this.$editor.on('mousedown.wmonkeypatch', (function() { + $saveSelection = true; + }).bind(this)); + + $(document).on('mouseup.wmonkeypatch', (function() { + if ($saveSelection) { + $saveSelection = false; + + this.wutil.saveSelection(); + } }).bind(this)); }, diff --git a/wcfsetup/install/files/js/3rdParty/redactor/plugins/wutil.js b/wcfsetup/install/files/js/3rdParty/redactor/plugins/wutil.js index 78ac18bdcb..9386feb203 100644 --- a/wcfsetup/install/files/js/3rdParty/redactor/plugins/wutil.js +++ b/wcfsetup/install/files/js/3rdParty/redactor/plugins/wutil.js @@ -84,6 +84,13 @@ RedactorPlugins.wutil = function() { } }, + /** + * Clears the current selection. + */ + clearSelection: function() { + this._wutil.range = null; + }, + /** * Allows inserting of text contents in Redactor's source area. *