X-Git-Url: http://source.bookstackapp.com/bookstack/blobdiff_plain/d41452f39c90deaca98b4fe0e8c87f7d7aa395b8..45d08604482ff811f1627f8dc489f14b455ea75c:/resources/js/services/dom.js
diff --git a/resources/js/services/dom.js b/resources/js/services/dom.js
index 00b34bf34..eb5f6a853 100644
--- a/resources/js/services/dom.js
+++ b/resources/js/services/dom.js
@@ -106,4 +106,28 @@ export function findText(selector, text) {
*/
export function showLoading(element) {
element.innerHTML = `
`;
+}
+
+/**
+ * Remove any loading indicators within the given element.
+ * @param {Element} element
+ */
+export function removeLoading(element) {
+ const loadingEls = element.querySelectorAll('.loading-container');
+ 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