import { EditorView } from 'prosemirror-view';
import { uploadImageFiles } from '../ImageUploadPlaceholderPlugin.js';

// workaround to support ClipboardEvent as a valid type.
// https://github.com/facebook/flow/issues/1856

export default function handleEditorPaste(view, event) {
  var clipboardData = event.clipboardData;
  if (!clipboardData) {
    return false;
  }
  var files = clipboardData.files;
  if (!(files !== null && files !== void 0 && files.length)) {
    return false;
  }
  var filesList = Array.from(files);
  if (uploadImageFiles(view, filesList)) {
    event.preventDefault();
    return true;
  }
  return false;
}