Export the frozen HTML.
Adds toHtml(), which returns the frozen clone with its captured styles and fonts as an HTML document. You can reopen the captured layout without exporting it as a bitmap.
npm install @zumer/snapdom@latest @zumer/snapdom-plugins@latestUsage
import { snapdom } from '@zumer/snapdom';
import { htmlExport } from '@zumer/snapdom-plugins/html-export';
const el = document.querySelector('#target');
const result = await snapdom(el, { plugins: [htmlExport()] });
const html = await result.toHtml(); // full <!DOCTYPE html> string
// Or download a .html file:
await result.toHtml({ download: 'snapshot.html' });
Options
| Option | Type | Default | Description |
|---|---|---|---|
fullDocument | boolean | true | Wrap output in <!DOCTYPE html>…; if false, return just <style> + the fragment |
filename | string | 'capture.html' | Download filename when opts.download is true |
title | string | 'Captured interface' | Escaped document title |
lang | string | 'en' | Escaped document language |
Per-call opts accepts fullDocument, filename and download. Set download: true to download, or pass a filename string. The method returns the HTML string either way.
The document retains source markup, including event-handler attributes; it is not sanitized.