Skip to content

Function: fromHTML() ​

ts
function fromHTML(html, options): DocJSON;

Turn HTML (an import, a stored legacy value, pasted content) into a document. Parsing happens in an inert template, so scripts never run and images never load; the result keeps only what the extensions' schema allows (unknown tags, style, event handlers and unsafe URLs are dropped).

Parameters ​

ParameterType
htmlstring
optionsFromHTMLOptions

Returns ​

DocJSON

Example ​

ts
const doc = fromHTML('<p>Hello <b>world</b></p>', { extensions })
editor.setContent(doc)