Skip to content

API > @blocksuite/blocks > getClosestBlockElementByPoint

Function: getClosestBlockElementByPoint ​

getClosestBlockElementByPoint( point, state = null, scale = 1): Element | null

Returns the closest block element by a point in the rect.

############### block
||############# block
||||########### block
||||    ...
||||  y - 2 * n
||||    ...
||||----------- cursor
||||    ...
||||  y + 2 * n
||||    ...
||||########### block
||############# block
############### block
############### block
||############# block
||||########### block
||||    ...
||||  y - 2 * n
||||    ...
||||----------- cursor
||||    ...
||||  y + 2 * n
||||    ...
||||########### block
||############# block
############### block

Parameters ​

ParameterTypeDefault value
pointPointundefined
statenull | {container: Element; rect: Rect; snapToEdge: {x: boolean; y: boolean;};}null
scalenumber1

Returns ​

Element | null

Defined In ​

packages/blocks/src/_common/utils/query.ts:447