X-Git-Url: http://source.bookstackapp.com/bookstack/blobdiff_plain/a6633642232efd164d4708967ab59e498fbff896..refs/pull/3830/head:/resources/js/services/dom.js diff --git a/resources/js/services/dom.js b/resources/js/services/dom.js index 7a7b2c9bc..eb5f6a853 100644 --- a/resources/js/services/dom.js +++ b/resources/js/services/dom.js @@ -117,4 +117,17 @@ export function removeLoading(element) { for (const el of loadingEls) { el.remove(); } +} + +/** + * Convert the given html data into a live DOM element. + * Initiates any components defined in the data. + * @param {String} html + * @returns {Element} + */ +export function htmlToDom(html) { + const wrap = document.createElement('div'); + wrap.innerHTML = html; + window.components.init(wrap); + return wrap.children[0]; } \ No newline at end of file