Inline node with optional content

I need to create a link with optional text content, the basic information is combined from the attributes into the content of the pseudo element ::before. I can’t use marks because they can’t be empty.

image

Therefore I want to use inline node with content, but it behaviour is awful:

chrome-capture-2024-3-13

I can’t select the node itself, put cursor inside of it or even put cursor after its contents. Such problems have been discussed here inline-nodes-with-content. But when inline node is described without content - I can select node and put cursor after it content. I want to be able to select whole node, put cursor inside and after the element. Can I do this without custom node views?