How to exclude Marks from beeing added to a NodeType

I have a NodeType Mention, which should not be markable (especially not by a link mark). I only found an excludes option for MarkTypes. This is the exact behaviour I need but seems only to be available for MarkTypes.

There is also the marks option, which excludes marks from beeing used inside the node, which unfortunately does not solve the issue.

Do I have to add a special Mark for my Mention nodes? If yes, what would be the most elegant way regarding the dom rendering of the mark and node, do I have to wrap the node in an additional dom node?

Update: I’ve tested the use of an additional span mark, but the problem with this solution is, that the mark is active once the cursor is beside the Mention node, even with a contenteditable="false" on the span of the mark.

This isn’t supported — marks are only constrained by their parent node and the other marks applied to the same content.

Ok thanks, I guess currently the best way to avoid this is to just disable the link menu item if the selection contains such nodes. Are such schema restrictions planned or was this a design decision? I think mentionings are a common use case.

You could use filterTransaction to ensure marks aren’t added in places where you don’t want them. Or just allow the marks to exist and cut them out in your HTML serializer.

1 Like

Thanks, now I filter the mark in the markdown serializer. Another solution I’ve tried is the appendTransaction to remove the mark in case I find a mention with link mark, think this would be cleaner but also a bit more overhead.