MDL-44810 editor_atto: restore selection after button press

Fixed issue where clicking on buttons erroneously lost viewport focus and selection.
This commit is contained in:
Jetha Chan 2014-04-03 17:31:48 +08:00
parent 1a727e121e
commit 0a1456dfa8
5 changed files with 26 additions and 2 deletions

View File

@ -95,6 +95,11 @@ Y.extend(EditorPlugin, Y.Base, {
* @method markUpdated
*/
markUpdated: function() {
// Save selection after changes to the DOM. If you don't do this here,
// subsequent calls to restoreSelection() will fail expecting the
// previous DOM state.
this.get('host').saveSelection();
return this.get('host').updateOriginal();
}
}, {
@ -760,6 +765,9 @@ EditorPluginButtons.prototype = {
// Build the arguments list, but remove the callback we're calling.
var args = [e, callbackArgs];
// Restore selection before making changes.
this.get('host').restoreSelection();
// Actually call the callback now.
return callback.apply(this, args);
},

File diff suppressed because one or more lines are too long

View File

@ -95,6 +95,11 @@ Y.extend(EditorPlugin, Y.Base, {
* @method markUpdated
*/
markUpdated: function() {
// Save selection after changes to the DOM. If you don't do this here,
// subsequent calls to restoreSelection() will fail expecting the
// previous DOM state.
this.get('host').saveSelection();
return this.get('host').updateOriginal();
}
}, {
@ -758,6 +763,9 @@ EditorPluginButtons.prototype = {
// Build the arguments list, but remove the callback we're calling.
var args = [e, callbackArgs];
// Restore selection before making changes.
this.get('host').restoreSelection();
// Actually call the callback now.
return callback.apply(this, args);
},

View File

@ -618,6 +618,9 @@ EditorPluginButtons.prototype = {
// Build the arguments list, but remove the callback we're calling.
var args = [e, callbackArgs];
// Restore selection before making changes.
this.get('host').restoreSelection();
// Actually call the callback now.
return callback.apply(this, args);
},

View File

@ -93,6 +93,11 @@ Y.extend(EditorPlugin, Y.Base, {
* @method markUpdated
*/
markUpdated: function() {
// Save selection after changes to the DOM. If you don't do this here,
// subsequent calls to restoreSelection() will fail expecting the
// previous DOM state.
this.get('host').saveSelection();
return this.get('host').updateOriginal();
}
}, {