Serialize a document as a complete, standalone HTML page.
serializeToHTML returns a bare fragment, which is what you want for
a clipboard payload or for storing content, but pasted into a file on its
own it renders unstyled, because nothing carries the stylesheet with it.
This wraps the same markup in a real page with its styles and scripts
attached, so the file opens looking like the editor did.
Serialize a document as a complete, standalone HTML page.
serializeToHTML returns a bare fragment, which is what you want for a clipboard payload or for storing content, but pasted into a file on its own it renders unstyled, because nothing carries the stylesheet with it. This wraps the same markup in a real page with its styles and scripts attached, so the file opens looking like the editor did.