Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export default (manager: Object) => {
const backend = HTML5Backend(manager);
const orgTopDropCapture = backend.handleTopDropCapture;
backend.handleTopDropCapture = e => {
orgTopDropCapture.call(backend, e);
const item = backend.monitor.getItem();
if (item && item.path) {
// Big hack we do to make VSCode operate happily with the dropped file.
// We monkey patch the getData function to return the right URI, normally
// we have to do this on the drag event with setData instead of the drop event, but we
// don't have access to it so we monkey-patch.
e.dataTransfer.getData = type => {
if (type !== 'ResourceURLs') {
return '';
}
return JSON.stringify([`file://${item.path}`]);
const overrideDropCaptureHandler = (manager) => {
const backend = HTML5Backend(manager);
const orgTopDropCapture = backend.handleTopDropCapture;
backend.handleTopDropCapture = (e) => {
let classes = e.target.className.split(' ');
if (e.target.tagName === 'INPUT' && e.target.type === 'file') {
e.stopPropagation();
} else if (classes.includes('file') || classes.includes('folder')) {
orgTopDropCapture.call(backend, e);
}
};
return backend;
};
export default function createHTML5TouchBackend(manager) {
HTML5TouchBackend.prototype = createHTML5Backend(manager);
return new HTML5TouchBackend(manager);
}
export default (manager) => {
const backend = HTML5Backend(manager)
const handler = backend.handleTopDropCapture
backend.handleTopDropCapture = (event) => {
handler.call(backend, event)
if (backend.currentNativeSource) {
const filesPromise = getFilesFromDataTransferItems(event.dataTransfer.items)
backend.currentNativeSource.item.filesPromise = filesPromise
}
}
return backend
}
const SlateHTML5Backend = (...args) => {
const backend = new HTML5Backend(...args)
dropHandler = (event) => {
backend.handleTopDrop(event)
}
return backend
}