Can I show context menu on condition

I’d like to show context menu on some condition,like when the part is not linkd, the context menu can be shown

One way of doing that is by always setting GraphObject.contextMenu on that Node (or whatever it is that you want to maybe have a context menu).

If the contextMenu is an Adornment, you can bind its GraphObject.visible property to control whether it is visible at all.

If the contextMenu is an HTMLInfo, you can make its function smarter.

But most generally you could override ContextMenuTool.findObjectWithContextMenu to be smarter. Call the super method and then decide whether to return that result or null instead.