Merge pull request #1661 from danyaPostfactum/dnd-fixes
Some drag'n'drop fixes
This commit is contained in:
commit
7d8cd7f657
2 changed files with 24 additions and 20 deletions
|
|
@ -118,8 +118,8 @@ function DefaultHandlers(mouseHandler) {
|
|||
editor.selection.clearSelection();
|
||||
}
|
||||
}.bind(this), 0);
|
||||
if (editor.container.setCapture) {
|
||||
editor.container.setCapture();
|
||||
if (editor.renderer.content.setCapture) {
|
||||
editor.renderer.content.setCapture();
|
||||
}
|
||||
editor.setStyle("ace_selecting");
|
||||
this.setState("select");
|
||||
|
|
@ -185,8 +185,8 @@ function DefaultHandlers(mouseHandler) {
|
|||
this.selectByWordsEnd =
|
||||
this.selectByLinesEnd = function() {
|
||||
this.editor.unsetStyle("ace_selecting");
|
||||
if (this.editor.container.releaseCapture) {
|
||||
this.editor.container.releaseCapture();
|
||||
if (this.editor.renderer.content.releaseCapture) {
|
||||
this.editor.renderer.content.releaseCapture();
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -43,15 +43,11 @@ function DragdropHandler(mouseHandler) {
|
|||
|
||||
var editor = mouseHandler.editor;
|
||||
|
||||
// Safari accepts either image or element (but it must present in the DOM)
|
||||
var proxy = dom.createElement("img");
|
||||
var blankImage = dom.createElement("img");
|
||||
// Safari crashes without image data
|
||||
proxy.src = "data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==";
|
||||
|
||||
if (useragent.isOpera) {
|
||||
proxy.style.cssText = "width:1px;height:1px;position:fixed;top:0;left:0;z-index:2147483647;opacity:0;visibility:hidden";
|
||||
editor.container.appendChild(proxy);
|
||||
}
|
||||
blankImage.src = "data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==";
|
||||
if (useragent.isOpera)
|
||||
blankImage.style.cssText = "width:1px;height:1px;position:fixed;top:0;left:0;z-index:2147483647;opacity:0;";
|
||||
|
||||
var exports = ["dragWait", "dragWaitEnd", "startDrag", "dragReadyEnd", "onMouseDrag"];
|
||||
|
||||
|
|
@ -66,6 +62,7 @@ function DragdropHandler(mouseHandler) {
|
|||
var timerId, range;
|
||||
var dragCursor, counter = 0;
|
||||
var dragOperation;
|
||||
var isInternal;
|
||||
var autoScrollStartTime;
|
||||
var cursorMovedTime;
|
||||
var cursorPointOnCaretMoved;
|
||||
|
|
@ -80,26 +77,30 @@ function DragdropHandler(mouseHandler) {
|
|||
}, 0);
|
||||
return e.preventDefault();
|
||||
}
|
||||
if (useragent.isOpera) {
|
||||
proxy.style.visibility = "visible";
|
||||
setTimeout(function(){
|
||||
proxy.style.visibility = "hidden";
|
||||
}, 0);
|
||||
}
|
||||
range = editor.getSelectionRange();
|
||||
|
||||
var dataTransfer = e.dataTransfer;
|
||||
dataTransfer.effectAllowed = editor.getReadOnly() ? "copy" : "copyMove";
|
||||
dataTransfer.setDragImage && dataTransfer.setDragImage(proxy, 0, 0);
|
||||
if (useragent.isOpera) {
|
||||
editor.container.appendChild(blankImage);
|
||||
// force layout
|
||||
blankImage._top = blankImage.offsetTop;
|
||||
}
|
||||
dataTransfer.setDragImage && dataTransfer.setDragImage(blankImage, 0, 0);
|
||||
if (useragent.isOpera) {
|
||||
editor.container.removeChild(blankImage);
|
||||
}
|
||||
// clear Opera garbage
|
||||
dataTransfer.clearData();
|
||||
dataTransfer.setData("Text", editor.session.getTextRange());
|
||||
|
||||
isInternal = true;
|
||||
this.setState("drag");
|
||||
};
|
||||
|
||||
this.onDragEnd = function(e) {
|
||||
mouseTarget.draggable = false;
|
||||
isInternal = false;
|
||||
this.setState(null);
|
||||
if (!editor.getReadOnly()) {
|
||||
var dropEffect = e.dataTransfer.dropEffect;
|
||||
|
|
@ -152,7 +153,6 @@ function DragdropHandler(mouseHandler) {
|
|||
if (!dragSelectionMarker)
|
||||
return;
|
||||
var dataTransfer = e.dataTransfer;
|
||||
var isInternal = this.state == "drag";
|
||||
if (isInternal) {
|
||||
switch (dragOperation) {
|
||||
case "move":
|
||||
|
|
@ -261,6 +261,8 @@ function DragdropHandler(mouseHandler) {
|
|||
range = editor.selection.toOrientedRange();
|
||||
dragSelectionMarker = editor.session.addMarker(range, "ace_selection", editor.getSelectionStyle());
|
||||
editor.clearSelection();
|
||||
if (editor.isFocused())
|
||||
editor.renderer.$cursorLayer.setBlinking(false);
|
||||
clearInterval(timerId);
|
||||
timerId = setInterval(onDragInterval, 20);
|
||||
counter = 0;
|
||||
|
|
@ -274,6 +276,8 @@ function DragdropHandler(mouseHandler) {
|
|||
editor.$blockScrolling += 1;
|
||||
editor.selection.fromOrientedRange(range);
|
||||
editor.$blockScrolling -= 1;
|
||||
if (editor.isFocused() && !isInternal)
|
||||
editor.renderer.$cursorLayer.setBlinking(!editor.getReadOnly());
|
||||
range = null;
|
||||
counter = 0;
|
||||
autoScrollStartTime = null;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue