Closed fantasticit closed 1 month ago
If you are dragging from editor content, how would there be files in the event's data transfer?
drag a image node like <img src="http://" draggable="true" />
in non-editbale pm editor, then drop at another webpage. event.dataTransfer.files
has files in chrome 125.
https://prosemirror.net/examples/upload/
https://evercoder.github.io/clipboard-inspector/
Oh cool, I didn't know it did that. But isn't Chrome 120 old enough that, given that browser's automatic upgrade behavior, it's not really a problem anymore?
Due to various reasons (such as political reasons), in some countries or regions, the browser kernels of users on various platforms may not be updated in a timely manner (often for a long time), which may lead to problems for these users dragging content to other web pages. In addition, many browser products are shell Google kernels and are rarely updated in a timely manner.
Fair enough. Attached patch suppresses that call on old Chrome versions.
https://github.com/ProseMirror/prosemirror-view/blob/e8bcd75d305b42052c4bd17653374d670b6f17d3/src/input.ts#L680
event.dataTransfer.files
will be empty when dragging a image element in old chrome (version <= 120), because of the invoke ofevent.dataTransfer.clearData()
.The
event.dataTransfer.clearData
is changed at chrome 125 and thenevent.dataTransfer.files
will not be empty.To fix this issues in old chrome version, maybe we need change
event.dataTransfer.clearData()
to!event.dataTransfer.files.length && event.dataTransfer.clearData()
.