Created
July 14, 2022 12:52
-
-
Save manikumarnune123/bcb1083a5ceb11c76c4ea14069df8552 to your computer and use it in GitHub Desktop.
DragnDrop for appsmith
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var dataTransfer={ | |
dropEffect:'', | |
effectAllowed:'all', | |
files:[], | |
items:{}, | |
types:[], | |
setData:function(format,data) | |
{ | |
this.items[format]=data; | |
this.types.append(format); | |
}, | |
getData:function(format) | |
{ | |
return this.items[format]; | |
}, | |
clearData:function(format){} | |
}; | |
var emit=function(event,target) | |
{ | |
var evt=document.createEvent('Event'); | |
evt.initEvent(event,true,false); | |
evt.dataTransfer=dataTransfer; | |
target.dispatchEvent(evt); | |
}; | |
function getElementByXpath(path) { | |
return document.evaluate(path, document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue; | |
} | |
var src = getElementByXpath("//*[contains(@class,'draggable-tablewidget')]/div/div/img") | |
var tgt = getElementByXpath("//*[@id='div-selection-0']") | |
var DragNDrop=function(src,tgt) { | |
emit('dragstart',src); | |
emit('dragenter',tgt); | |
emit('dragover',tgt); | |
emit('drop',tgt); | |
emit('dragend',src); | |
return true; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment