@udecode/plate-dnd
Advanced tools
Comparing version 43.0.0 to 43.0.1
@@ -217,7 +217,7 @@ import * as _udecode_plate_core_react from '@udecode/plate-core/react'; | ||
declare const getDropPath: (editor: PlateEditor, { canDropNode, dragItem, element, monitor, nodeRef, orientation, }: { | ||
dragItem: ElementDragItemNode; | ||
dragItem: DragItemNode; | ||
monitor: DropTargetMonitor; | ||
} & Pick<UseDropNodeOptions, "canDropNode" | "element" | "nodeRef" | "orientation">) => { | ||
direction: "bottom" | "left" | "right" | "top"; | ||
dragPath: Path; | ||
dragPath: Path | undefined; | ||
to: Path; | ||
@@ -224,0 +224,0 @@ } | undefined; |
@@ -385,14 +385,21 @@ "use strict"; | ||
if (!direction) return; | ||
const dragPath = editor.api.findPath(dragItem.element); | ||
if (!dragPath) return; | ||
const dragEntry = [dragItem.element, dragPath]; | ||
const hoveredPath = editor.api.findPath(element); | ||
if (!hoveredPath) return; | ||
const dropEntry = [element, hoveredPath]; | ||
let dragEntry; | ||
let dropEntry; | ||
if ("element" in dragItem) { | ||
const dragPath2 = editor.api.findPath(dragItem.element); | ||
const hoveredPath2 = editor.api.findPath(element); | ||
if (!dragPath2 || !hoveredPath2) return; | ||
dragEntry = [dragItem.element, dragPath2]; | ||
dropEntry = [element, hoveredPath2]; | ||
} else { | ||
dropEntry = editor.api.node({ id: element.id, at: [] }); | ||
} | ||
if (!dropEntry) return; | ||
if (canDropNode && !canDropNode({ dragEntry, dragItem, dropEntry, editor })) { | ||
if (canDropNode && dragEntry && !canDropNode({ dragEntry, dragItem, dropEntry, editor })) { | ||
return; | ||
} | ||
let dropPath; | ||
if (direction === "bottom" || direction === "right") { | ||
const dragPath = dragEntry?.[1]; | ||
const hoveredPath = dropEntry[1]; | ||
if (dragPath && (direction === "bottom" || direction === "right")) { | ||
dropPath = hoveredPath; | ||
@@ -403,6 +410,6 @@ if (import_plate.PathApi.equals(dragPath, import_plate.PathApi.next(dropPath))) return; | ||
dropPath = [...hoveredPath.slice(0, -1), hoveredPath.at(-1) - 1]; | ||
if (import_plate.PathApi.equals(dragPath, dropPath)) return; | ||
if (dragPath && import_plate.PathApi.equals(dragPath, dropPath)) return; | ||
} | ||
const _dropPath = dropPath; | ||
const before = import_plate.PathApi.isBefore(dragPath, _dropPath) && import_plate.PathApi.isSibling(dragPath, _dropPath); | ||
const before = dragPath && import_plate.PathApi.isBefore(dragPath, _dropPath) && import_plate.PathApi.isSibling(dragPath, _dropPath); | ||
const to = before ? _dropPath : import_plate.PathApi.next(_dropPath); | ||
@@ -409,0 +416,0 @@ return { direction, dragPath, to }; |
{ | ||
"name": "@udecode/plate-dnd", | ||
"version": "43.0.0", | ||
"version": "43.0.1", | ||
"description": "React drag and drop feature for Plate", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
136518
1469