Skip to content

Commit

Permalink
feat(edgeless): support consistent dragging behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
AyushAgrawal-A2 committed Dec 8, 2023
1 parent 957031b commit 73e2c03
Show file tree
Hide file tree
Showing 13 changed files with 504 additions and 160 deletions.
14 changes: 14 additions & 0 deletions packages/blocks/src/_common/utils/query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,10 @@ function isEdgelessChildNote({ classList }: Element) {
return classList.contains('edgeless-block-portal-note');
}

function isEdgelessChildImage({ classList }: Element) {
return classList.contains('edgeless-block-portal-image');
}

/**
* Returns the closest block element by a point in the rect.
*
Expand Down Expand Up @@ -717,6 +721,16 @@ export function getHoveringNote(point: Point) {
);
}

/**
* Get hovering note with given a point in edgeless mode.
*/
export function getHoveringImage(point: Point) {
return (
document.elementsFromPoint(point.x, point.y).find(isEdgelessChildImage) ||
null
);
}

/**
* Gets the table of the database.
*/
Expand Down
10 changes: 9 additions & 1 deletion packages/blocks/src/_common/widgets/drag-handle/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,15 @@ export type DragHandleOption = {
) => boolean;
onDragEnd?: (
state: PointerEventState,
draggingElements: BlockElement[]
{
draggingElements,
dropBlockId,
dropType,
}: {
draggingElements: BlockElement[];
dropBlockId: string;
dropType: DropType | null;
}
) => boolean;
};

Expand Down
Loading

0 comments on commit 73e2c03

Please sign in to comment.