Trevixal API
    Preparing search index...

    Function serializeToHTMLDocument

    • 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.

      serializeToHTMLDocument(editor.state.doc, {
      baseURL: 'http://localhost:5173',
      styleSheets: ['/styles.css'],
      })

      Parameters

      Returns string