Failed to copy simple text to clipboard

I’m copying the text to the clipboard the classical way (not with any prosemirror api’s) but it’s not working.

I tried to look in prosemirror docs to find anything related , i’ve found the clipboardSerializer which seems to be useful when copying document’s nodes.

I’m not copying any kind of nodes , just a simple string. Does the clipboardSerializer anything related to this problem and does prosemirror engine intercepts the copy?

ProseMirror handles copy events and puts the selected text on the clipboard, and I think that should handle code-generated copy events as well. But that w3schools code you linked looks dodgy, and may not actually manage to select the content of your editor.

After reading your post i understood that the text should be selected before the copy.

The problem is that i need to copy a hypertext href url which isn’t part of the document content (it’s only an attribute of a link mark of the document).

I could make a workaround for now by selecting the text contained in the link to force trigger the clipboardTextSerializer and then to return the href.value from inside of it but that’s a very ugly way i think…