How to use the react-dnd-html5-backend function in react-dnd-html5-backend

To help you get started, we’ve selected a few react-dnd-html5-backend examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github codesandbox / codesandbox-client / packages / app / src / app / pages / common / HTML5BackendWithFolderSupport / index.js View on Github external
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}`]);
github ging / ediphy / _editor / components / carousel / FileTree.jsx View on Github external
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;
};
github Neilos / react-dnd-html5-with-touch-backend / src / index.js View on Github external
export default function createHTML5TouchBackend(manager) {
  HTML5TouchBackend.prototype = createHTML5Backend(manager);

  return new HTML5TouchBackend(manager);
}
github ipfs-shipyard / ipfs-webui / src / lib / dnd-backend.js View on Github external
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
}
github orbiting / publikator-frontend / components / editor / utils / slateReactDnDAdapter.js View on Github external
const SlateHTML5Backend = (...args) => {
    const backend = new HTML5Backend(...args)
    dropHandler = (event) => {
      backend.handleTopDrop(event)
    }

    return backend
  }