Need some help to implement this functionality

I hope that when I drag to create or move a node, the distance between the current node and the nearest node in the closest four directions can be displayed.
So what should I do? Could you provide some suggestions?

The effect is as follows:


What project are you referring to? bpmn-js?

Yes, what I expect is to implement this feature in bpmn-js.

From a flow node you can easily access all connected nodes:

const connected = [ => connection.source), =>

You can then calculate all the distances.

Sorry, perhaps my diagram description was not very accurate. What I want is to display the distance between the nearest adjacent nodes when moving the node, but these nodes may not be related, but independent nodes. The lines in the diagram are the effect I want to achieve, which is to display a guide line to show the distance between nodes.

Then you’ll have to interate all elements through the element registry: elementRegistry.forEach(...);