Skip to content

Commit

Permalink
fix rm
Browse files Browse the repository at this point in the history
  • Loading branch information
Katochimoto committed Jul 19, 2015
1 parent fedc54e commit f2603d9
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 8 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ckeditor-imgresize",
"version": "1.0.3",
"version": "1.0.4",
"main": [
"plugin.js"
],
Expand Down
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.3",
"version": "1.0.4",
"description": "CKEditor dragable image resizing with support divarea",
"keywords": [
"ckeditor",
Expand Down
26 changes: 20 additions & 6 deletions plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,16 +152,16 @@
this._element = element;
this._wrapper = this._getWrapper(this._element);

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

if (!this._wrapper) {
this._wrapper = this._editor._imgresizeWrapper.clone(true);
this._wrapper.replace(this._element);
this._element.appendTo(this._wrapper);
}

var selection = this._editor.getSelection();
selection.removeAllRanges();
selection.selectElement(this._wrapper);

this._wrapper.focus();

this._controls = this._wrapper.findOne('.cke_imgresize_controls');
Expand Down Expand Up @@ -190,21 +190,35 @@
Resizer.prototype._onKeydown = function(event) {
var nativeEvent = event.data.$;
if (!nativeEvent.shiftKey) {
this._hideWrapper();
this._hideWrapper({ 'restoreFocus': true });
}
};

Resizer.prototype._hideWrapper = function() {
Resizer.prototype._hideWrapper = function(event) {
if (!this._wrapper) {
return;
}

var isRestoreFocus = (event && event.restoreFocus);

for (var eventName in this._editorHideEvents) {
this._editor.removeListener(eventName, this._hideWrapper);
}

this._wrapper.removeAllListeners();
this._element.replace(this._wrapper);

if (isRestoreFocus) {
var selection = this._editor.getSelection();
selection.removeAllRanges();

this._element.replace(this._wrapper);

selection.selectElement(this._element);
this._element.focus();

} else {
this._element.replace(this._wrapper);
}

delete this._wrapper;
delete this._element;
Expand Down

0 comments on commit f2603d9

Please sign in to comment.