mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-08-17 12:41:44 +02:00
Don't stop propagation of drag events. (#1278)
This commit is contained in:
committed by
Ian Storm Taylor
parent
c3813e18b7
commit
f46cbb1eb7
@@ -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
|
// Some events require being in editable in the editor, so if the event
|
||||||
// target isn't, ignore them.
|
// target isn't, ignore them.
|
||||||
if (
|
if (
|
||||||
|
@@ -150,9 +150,6 @@ function BeforePlugin() {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
function onDragEnd(event, change, editor) {
|
function onDragEnd(event, change, editor) {
|
||||||
// Stop propagation so the event isn't visible to parent editors.
|
|
||||||
event.stopPropagation()
|
|
||||||
|
|
||||||
isDragging = false
|
isDragging = false
|
||||||
|
|
||||||
debug('onDragEnd', { event })
|
debug('onDragEnd', { event })
|
||||||
@@ -167,9 +164,6 @@ function BeforePlugin() {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
function onDragEnter(event, change, editor) {
|
function onDragEnter(event, change, editor) {
|
||||||
// Stop propagation so the event isn't visible to parent editors.
|
|
||||||
event.stopPropagation()
|
|
||||||
|
|
||||||
debug('onDragEnter', { event })
|
debug('onDragEnter', { event })
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -182,9 +176,6 @@ function BeforePlugin() {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
function onDragExit(event, change, editor) {
|
function onDragExit(event, change, editor) {
|
||||||
// Stop propagation so the event isn't visible to parent editors.
|
|
||||||
event.stopPropagation()
|
|
||||||
|
|
||||||
debug('onDragExit', { event })
|
debug('onDragExit', { event })
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -197,9 +188,6 @@ function BeforePlugin() {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
function onDragLeave(event, change, editor) {
|
function onDragLeave(event, change, editor) {
|
||||||
// Stop propagation so the event isn't visible to parent editors.
|
|
||||||
event.stopPropagation()
|
|
||||||
|
|
||||||
debug('onDragLeave', { event })
|
debug('onDragLeave', { event })
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -212,11 +200,8 @@ function BeforePlugin() {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
function onDragOver(event, change, editor) {
|
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 a drag is already in progress, don't do this again.
|
||||||
if (!isDragging) return true
|
if (isDragging) return true
|
||||||
|
|
||||||
isDragging = true
|
isDragging = true
|
||||||
event.nativeEvent.dataTransfer.dropEffect = 'move'
|
event.nativeEvent.dataTransfer.dropEffect = 'move'
|
||||||
@@ -236,9 +221,6 @@ function BeforePlugin() {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
function onDragStart(event, change, editor) {
|
function onDragStart(event, change, editor) {
|
||||||
// Stop propagation so the event isn't visible to parent editors.
|
|
||||||
event.stopPropagation()
|
|
||||||
|
|
||||||
isDragging = true
|
isDragging = true
|
||||||
|
|
||||||
debug('onDragStart', { event })
|
debug('onDragStart', { event })
|
||||||
|
Reference in New Issue
Block a user