- создать виртуальную файловую систему
- открыть файл, содержащийся в файловой системе, в частности документ HTML, в iFrame
- сохранить все ссылки нетронутыми (включая привязки, теги , изображения, импорт JS и т. д., связанные с другими файлами в файловая система)
Код: Выделить всё
function preview(fileSystem, iframe) {
/* ... */
}
const fileSystem = {
'index.html': new File([`
Test
[img]image.png[/img]
`], { type: 'text/html' }),
styles: {
'index.css': new File([/* ... */], { type: 'text/css' })
},
'image.png': new File([/* ... */], { type: 'image/png' })
}
preview(
fileSystem,
document.body.appendChild(document.createElement('iframe'))
);
Подробнее здесь: https://stackoverflow.com/questions/798 ... -in-iframe