How to get the contents of a page


Hello there.

I am trying to make a plugin that will automatically export the contents of all files in a project. I have worked out how to get all the files, but actually opening them and copying the content is proving difficult. The problem is, I would like to retain the formatting you gain from the HTML Clipboard content. The problem is the only way I have found to do this so far is to manually invoke the Control+C. Is there a way to get the page content from the VirtualFile or something like that? Thanks

Comment actions Permalink


If I understand you correctly, it is not possible to get formatting when copying the raw text content of virtual files.

Formatting (color information applied in the editor) is the information exposed by the editor and can be copied from the editor only. This information is not available at the file level but at the UI level.

If the export is intended to be read by other users, I suggest using one of the HTML code highlighting libraries.

Comment actions Permalink

Thanks for replying,

I have actually managed to get this to work, by opening the virtual file into an editor, selecting the contents of the file, and manually invoking the copy action that is usually invoked by the users’ copy keybind. This results in the rich HTML being copied into the clipboard as per their IDE settings. Thanks


Please sign in to leave a comment.