I need to display an element that is supposed to show some text. This text should neither be editable nor selectable. I created a specific node definition for it in schema and explicitly set contenteditable=false. With css I set user-select: none which normally prevents both selection and ctrl+c action. But for some reason when the such an element is a part of a prosemirror editor it is still copied.
Here is an example of what I mean. Try to copy text in an editor and text in a button. Text from editor is fully copied.
Any suggestion on how can achieve such behavior. It will confuse Users because they are not expecting this to be copied
Copying of content is handled by the library, overriding default browser behavior. It’ll use a node’s toDOM to determine how to serialize it. You could make that return an empty element, if you make sure to override this with a node view in the editor. But it seems like a bad idea to have content the user cannot copy and paste (for example when they want to move it inside the document).
Thanks for the reply. The thing is that I want this ‘caption’ to be attachable to only the element it was originally told to. It serves purpose of a “hint” and I do not want it to be moved around or anything like that. I will try to experiment with custom NodeView class