@polotno/html-export
v0.1.0
Published
Export Polotno designs to HTML. Browser-first; runs in Node under jsdom.
Readme
@polotno/html-export
Export Polotno designs to HTML.
Usage
import { jsonToHTML } from '@polotno/html-export';
const html = await jsonToHTML(store.toJSON());jsonToHTML accepts plain design JSON — no editor or store required.
Options:
elementHook({ dom, element })— post-process each element's virtual node.textOverflow—'change-font-size'(default) |'resize'|'ellipsis'; what happens when text is taller than its box. The default shrinks the font to fit — the same default polotno-node exports use (shrinking needs a live DOM for measurement; under jsdom it is a no-op).store.toHTML()forwards the live editor flag ('resize'by default) instead.textSplitAllowed—boolean, defaultfalse; whether shrink-to-fit measurement may wrap a long word mid-word. By default a word wider than the box shrinks the font instead of splitting. Mirrors the editor'ssetTextSplitAllowedflag (forwarded automatically bystore.toHTML()).
Node
The exporter is browser-first and needs a DOM. In Node, run it under
jsdom — the same setup this package's own
test suite uses. Per-line text backgrounds need real Range.getClientRects
measurement and fall back to a legacy overlay under jsdom; for full-fidelity
rendering in Node use
polotno-node.
