The proper way of checking mark activity

Hello guys, Sorry I have another question to ask.

From the sample here,

let active = command(this.editorView.state, null, this.editorView)

It uses toggleMark to check the mark activity, but from I learnt from the doc, it seems much proper to get the selection to check if a mark is applied to any node in it.

Which is the best practice to check mark activity, I’m a bit confused by the sample code, so if anyone could help me figure it out, that would be excellent, cheer!!!

That’s pretty much what the command does. If you’re testing if a given button should be enabled, or similar, running the corresponding command with null for the dispatch argument is the recommended way. If you’re just looking for a way to scan the selection for a mark, take a look how toggleMark implements that internally.

Really appreciate your help Marjin, I ended up making it work by using selection, but I will try to do the way you suggested since it’s the best practice.