Skip to content

Commit

Permalink
выполнение команд для картинки с врапером
Browse files Browse the repository at this point in the history
  • Loading branch information
Katochimoto committed Jul 28, 2015
1 parent e227739 commit 943ce98
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ckeditor-imgresize",
"version": "1.0.9",
"version": "1.0.10",
"description": "CKEditor dragable image resizing with support divarea",
"keywords": [
"ckeditor",
Expand Down
23 changes: 14 additions & 9 deletions plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,12 +135,12 @@
}

Resizer.prototype._editorHideEvents = {
'beforeCommandExec': 1,
'beforeSetMode': 1,
'destroy': 1,
'dragstart': 1,
'paste': 1,
'readOnly': 1
'beforeCommandExec': { 'restoreFocus': true },
'beforeSetMode': null,
'destroy': null,
'dragstart': null,
'paste': null,
'readOnly': null
};

Resizer.prototype.show = function(element) {
Expand Down Expand Up @@ -170,7 +170,7 @@
this._wrapper.once('keydown', this._onKeydown, this, null, 0);

for (var eventName in this._editorHideEvents) {
this._editor.once(eventName, this._hideWrapper, this, null, 0);
this._editor.once(eventName, this._hideWrapper, this, this._editorHideEvents[ eventName ], 0);
}

this._resetBox();
Expand All @@ -185,10 +185,14 @@
Resizer.prototype._onKeydown = function(event) {
var nativeEvent = event.data.$;
if (!nativeEvent.shiftKey) {
this._hideWrapper({ 'restoreFocus': true });
this._hideWrapper({ 'listenerData': { 'restoreFocus': true } });
}
};

/**
* @param {CKEDITOR.eventInfo} event
* @param {{ restoreFocus: boolean }} [event.listenerData]
*/
Resizer.prototype._hideWrapper = function(event) {
if (!this._wrapper) {
return;
Expand All @@ -200,12 +204,13 @@

this._wrapper.removeAllListeners();

var listenerData = event.listenerData;
var selection = this._editor.getSelection();
selection.removeAllRanges();

this._element.replace(this._wrapper);

if (event && event.restoreFocus) {
if (listenerData && listenerData.restoreFocus) {
selection.selectElement(this._element);
this._element.focus();
}
Expand Down

0 comments on commit 943ce98

Please sign in to comment.