1
0
mirror of https://github.com/ianstormtaylor/slate.git synced 2025-02-13 11:44:55 +01:00

Don't stop propagation of drag events. (#1278)

This commit is contained in:
AlbertHilb 2017-10-25 07:31:28 +02:00 committed by Ian Storm Taylor
parent c3813e18b7
commit f46cbb1eb7
2 changed files with 15 additions and 19 deletions

View File

@ -252,6 +252,20 @@ class Content extends React.Component {
}
}
// Don't handle drag events coming from embedded editors.
if (
handler == 'onDragEnd' ||
handler == 'onDragEnter' ||
handler == 'onDragExit' ||
handler == 'onDragLeave' ||
handler == 'onDragOver' ||
handler == 'onDragStart'
) {
const { target } = event
const targetEditorNode = findClosestNode(target, '[data-slate-editor]')
if (targetEditorNode !== this.element) return
}
// Some events require being in editable in the editor, so if the event
// target isn't, ignore them.
if (

View File

@ -150,9 +150,6 @@ function BeforePlugin() {
*/
function onDragEnd(event, change, editor) {
// Stop propagation so the event isn't visible to parent editors.
event.stopPropagation()
isDragging = false
debug('onDragEnd', { event })
@ -167,9 +164,6 @@ function BeforePlugin() {
*/
function onDragEnter(event, change, editor) {
// Stop propagation so the event isn't visible to parent editors.
event.stopPropagation()
debug('onDragEnter', { event })
}
@ -182,9 +176,6 @@ function BeforePlugin() {
*/
function onDragExit(event, change, editor) {
// Stop propagation so the event isn't visible to parent editors.
event.stopPropagation()
debug('onDragExit', { event })
}
@ -197,9 +188,6 @@ function BeforePlugin() {
*/
function onDragLeave(event, change, editor) {
// Stop propagation so the event isn't visible to parent editors.
event.stopPropagation()
debug('onDragLeave', { event })
}
@ -212,11 +200,8 @@ function BeforePlugin() {
*/
function onDragOver(event, change, editor) {
// Stop propagation so the event isn't visible to parent editors.
event.stopPropagation()
// If a drag is already in progress, don't do this again.
if (!isDragging) return true
if (isDragging) return true
isDragging = true
event.nativeEvent.dataTransfer.dropEffect = 'move'
@ -236,9 +221,6 @@ function BeforePlugin() {
*/
function onDragStart(event, change, editor) {
// Stop propagation so the event isn't visible to parent editors.
event.stopPropagation()
isDragging = true
debug('onDragStart', { event })