]> BookStack Code Mirror - bookstack/blobdiff - resources/js/services/dom.js
Addressed additional unsupported array spread operation
[bookstack] / resources / js / services / dom.js
index 7a7b2c9bcfce6ce3ae0daf532a9d4be05f8229b7..eb5f6a8530d512c6a4a965baa57d2b24a14c7d51 100644 (file)
@@ -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