this.wmonkeypatch.code();
this.wmonkeypatch.dropdown();
this.wmonkeypatch.image();
+ this.wmonkeypatch.inline();
this.wmonkeypatch.insert();
this.wmonkeypatch.keydown();
this.wmonkeypatch.link();
}
},
+ /**
+ * Restores saved selection.
+ */
+ restoreSelection: function() {
+ if (document.activeElement !== this.$editor[0]) {
+ this.$editor.focus();
+ }
+
+ if (this.wmonkeypatch._range !== null) {
+ var $selection = window.getSelection();
+ $selection.removeAllRanges();
+ $selection.addRange(this.wmonkeypatch._range);
+
+ this.wmonkeypatch._range = null;
+ }
+ },
+
/**
* Setups event listeners and callbacks.
*/
* Partially overwrites the 'dropdown' module.
*
* - emulate WCF-like dropdowns.
+ * - save text selection on iOS (#2003)
*/
dropdown: function() {
// dropdown.build
var $dropdown = this.button.get(key).data('dropdown');
$fixDropdown($dropdown);
+ if ($.browser.iOS) {
+ this.wmonkeypatch.saveSelection();
+ }
+
$mpShow.call(this, e, key);
$dropdown.off('mouseover mouseout');
}).bind(this);
},
+ /**
+ * Partially overwrites the 'inline' module.
+ *
+ * - restore the text selection on iOS (#2003)
+ */
+ inline: function() {
+ var $mpFormat = this.inline.format;
+ this.inline.format = (function(tag, type, value) {
+ if ($.browser.iOS) {
+ this.wmonkeypatch.restoreSelection();
+ }
+
+ $mpFormat.call(this, tag, type, value);
+ }).bind(this);
+
+ var $mpRemoveStyleRule = this.inline.removeStyleRule;
+ this.inline.removeStyleRule = (function(name) {
+ if ($.browser.iOS) {
+ this.wmonkeypatch.restoreSelection();
+ }
+
+ $mpRemoveStyleRule.call(this, name);
+ }).bind(this);
+ },
+
/**
* Partially overwrites the 'insert' module.
*