X-Git-Url: http://source.bookstackapp.com/bookstack/blobdiff_plain/2f6ff0734773c4ac009de699a2661971fd585b22..refs/pull/3918/head:/resources/js/services/dom.js diff --git a/resources/js/services/dom.js b/resources/js/services/dom.js index 7a7b2c9bc..882d5228d 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