Remove all marks based on type AND attribute

It seems that removeMark can be used to remove all marks for a specific type – for example all bold, or all italics. But how about removing all marks based on type AND attribute? For example, al links that have a href set to http://www.sports.com/ should be removed? (or maybe exchanged with other links). What’s the best way to go about that?

Again, my initial approach is to walk through the the editor.doc structure. There I would look for all the nodes I need and have their path/offset calculated and then use removeMark on all the marks that happen to have the attribute value I want to get rid off.

Sorry, I should have investigated this better. I guess I should just copy the removeMark function ( https://github.com/ProseMirror/prosemirror/blob/89ca81f2352d66a72b2b179c9bb6ea01bedf6a01/src/transform/mark.js#L90-L122 ) and modify it slightly to get what I want.

1 Like