X-Git-Url: http://source.bookstackapp.com/bookstack/blobdiff_plain/a6633642232efd164d4708967ab59e498fbff896..refs/pull/4099/head:/resources/js/components/page-comments.js diff --git a/resources/js/components/page-comments.js b/resources/js/components/page-comments.js index c86eead1b..726531e95 100644 --- a/resources/js/components/page-comments.js +++ b/resources/js/components/page-comments.js @@ -1,9 +1,8 @@ import {scrollAndHighlightElement} from "../services/util"; +import {Component} from "./component"; +import {htmlToDom} from "../services/dom"; -/** - * @extends {Component} - */ -class PageComments { +export class PageComments extends Component { setup() { this.elem = this.$el; @@ -90,7 +89,7 @@ class PageComments { newComment.innerHTML = resp.data; this.editingComment.innerHTML = newComment.children[0].innerHTML; window.$events.success(this.updatedText); - window.components.init(this.editingComment); + window.$components.init(this.editingComment); this.closeUpdateForm(); this.editingComment = null; }).catch(window.$events.showValidationErrors).then(() => { @@ -119,11 +118,9 @@ class PageComments { }; this.showLoading(this.form); window.$http.post(`/comment/${this.pageId}`, reqData).then(resp => { - let newComment = document.createElement('div'); - newComment.innerHTML = resp.data; - let newElem = newComment.children[0]; + const newElem = htmlToDom(resp.data); this.container.appendChild(newElem); - window.components.init(newElem); + window.$components.init(newElem); window.$events.success(this.createdText); this.resetForm(); this.updateCount(); @@ -199,6 +196,4 @@ class PageComments { formElem.querySelector('.form-group.loading').style.display = 'none'; } -} - -export default PageComments; \ No newline at end of file +} \ No newline at end of file