Merge pull request #748 from ANH25/drag-and-drop
fix drag & drop issue when dropping things over existing content
This commit is contained in:
commit
05efefeff9
@ -922,9 +922,7 @@ to a cloze type first, via 'Notes>Change Note Type'"""
|
|||||||
self.doPaste(html, internal)
|
self.doPaste(html, internal)
|
||||||
|
|
||||||
p = self.web.mapFromGlobal(QCursor.pos())
|
p = self.web.mapFromGlobal(QCursor.pos())
|
||||||
self.web.evalWithCallback(
|
self.web.evalWithCallback(f"focusIfField({p.x()}, {p.y()});", pasteIfField)
|
||||||
f"focusIfField(document.elementFromPoint({p.x()}, {p.y()}));", pasteIfField
|
|
||||||
)
|
|
||||||
|
|
||||||
def onPaste(self):
|
def onPaste(self):
|
||||||
self.web.onPaste()
|
self.web.onPaste()
|
||||||
|
@ -216,13 +216,17 @@ function focusPrevious() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function focusIfField(elem) {
|
function focusIfField(x, y) {
|
||||||
if (elem.classList.contains("field")) {
|
const elements = document.elementsFromPoint(x, y);
|
||||||
elem.focus();
|
for (let i = 0; i < elements.length; i++) {
|
||||||
// the focus event may not fire if the window is not active, so make sure
|
let elem = elements[i] as HTMLElement;
|
||||||
// the current field is set
|
if (elem.classList.contains("field")) {
|
||||||
currentField = elem;
|
elem.focus();
|
||||||
return true;
|
// the focus event may not fire if the window is not active, so make sure
|
||||||
|
// the current field is set
|
||||||
|
currentField = elem;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user