fix: Moving an image to empty space results in endless upload (#3799)
* fix: Error dragging images below doc, types * fix: Handle html/text content dropped into padding * refactor, docs
This commit is contained in:
@@ -11,8 +11,11 @@ import {
|
||||
import * as React from "react";
|
||||
import ImageZoom from "react-medium-image-zoom";
|
||||
import styled from "styled-components";
|
||||
import { supportedImageMimeTypes } from "../../utils/files";
|
||||
import getDataTransferFiles from "../../utils/getDataTransferFiles";
|
||||
import {
|
||||
getDataTransferFiles,
|
||||
supportedImageMimeTypes,
|
||||
getEventFiles,
|
||||
} from "../../utils/files";
|
||||
import insertFiles, { Options } from "../commands/insertFiles";
|
||||
import { MarkdownSerializerState } from "../lib/markdown/serializer";
|
||||
import uploadPlaceholderPlugin from "../lib/uploadPlaceholder";
|
||||
@@ -74,9 +77,7 @@ const uploadPlugin = (options: Options) =>
|
||||
}
|
||||
|
||||
// filter to only include image files
|
||||
const files = getDataTransferFiles(event).filter(
|
||||
(dt: any) => dt.kind !== "string"
|
||||
);
|
||||
const files = getDataTransferFiles(event);
|
||||
if (files.length === 0) {
|
||||
return false;
|
||||
}
|
||||
@@ -413,8 +414,8 @@ export default class Image extends Node {
|
||||
const inputElement = document.createElement("input");
|
||||
inputElement.type = "file";
|
||||
inputElement.accept = supportedImageMimeTypes.join(", ");
|
||||
inputElement.onchange = (event: Event) => {
|
||||
const files = getDataTransferFiles(event);
|
||||
inputElement.onchange = (event) => {
|
||||
const files = getEventFiles(event);
|
||||
insertFiles(view, event, state.selection.from, files, {
|
||||
uploadFile,
|
||||
onFileUploadStart,
|
||||
|
||||
Reference in New Issue
Block a user