[FIX] website.editor: need to set the range on start because the browser can be lost the caret and can't insert the media in the page.
This commit is contained in:
parent
7428464004
commit
068e69c2ed
|
@ -1270,6 +1270,11 @@
|
|||
start: function () {
|
||||
var self = this;
|
||||
|
||||
if (this.editor.getSelection) {
|
||||
var selection = this.editor.getSelection();
|
||||
this.range = selection.getRanges(true)[0];
|
||||
}
|
||||
|
||||
this.imageDialog = new website.editor.RTEImageDialog(this, this.editor, this.media);
|
||||
this.imageDialog.appendTo(this.$("#editor-media-image"));
|
||||
this.iconDialog = new website.editor.FontIconsDialog(this, this.editor, this.media);
|
||||
|
@ -1323,11 +1328,9 @@
|
|||
this.videoDialog.clear();
|
||||
}
|
||||
} else {
|
||||
var selection = this.editor.getSelection();
|
||||
var range = selection.getRanges(true)[0];
|
||||
this.media = new CKEDITOR.dom.element("img");
|
||||
range.insertNode(this.media);
|
||||
range.selectNodeContents(this.media);
|
||||
self.range.insertNode(this.media);
|
||||
self.range.selectNodeContents(this.media);
|
||||
this.active.media = this.media;
|
||||
}
|
||||
|
||||
|
@ -1338,6 +1341,7 @@
|
|||
this.media.$.className = this.media.$.className.replace(/\s+/g, ' ');
|
||||
|
||||
setTimeout(function () {
|
||||
if(self.range) self.range.select();
|
||||
$el.trigger("saved", self.active.media.$);
|
||||
$(document.body).trigger("media-saved", [$el[0], self.active.media.$]);
|
||||
},0);
|
||||
|
|
Loading…
Reference in New Issue