I was trying to insert a link using replaceSelectionWith and saw that my link was lost. I saw other posts like Insert a text with a link that had a similar issue and the resolution being to pass false for the inheritMarks optional 2nd parameter of that method. However I don’t understand why when true (the default) it doesn’t merge any marks in the node being inserted with the inherited marks instead of just discarding the marks on the node being inserted? For example if I had replaceSelectionWith a node that has a mark (in my case a link) and the selection has strikeout (odd but just an example) I would expect that the result is a text node with a link and strikeout like what might happen in Word. If there were a conflict (i.e. an instance of the same mark in the marks to inherit) then I would expect the one on the node would win.
The idea is that it’s a toggle between using the node’s marks or using the context marks. I guess there are valid arguments for either way it could work, but at this point changing the behavior would be a breaking change so it’s pretty much not possible, so you’ll have to work with the current behavior.
Ok. Thanks for the reply. Yes I can understand not wanting to introduce any regressions as its hard to tell if someone is relying on this behavior. I was thinking that someone is likely creating a node to pass in but if they are getting a node from another location and using this as sort of a “keep text only” type insertion then they would want to discard the node’s state and so there are probably other scenarios I wasn’t thinking of. And it wasn’t hard to implement in my code since I only needed to replicate the little bit about gathering the marks to inherit and then use the existing addToSet to merge in those of the node being injected. Thanks again.