X-Git-Url: http://source.bookstackapp.com/bookstack/blobdiff_plain/09c6a3c2405742ea6003e9a8a30e7ad212ab6977..refs/pull/3875/head:/resources/js/components/page-comments.js diff --git a/resources/js/components/page-comments.js b/resources/js/components/page-comments.js index 0264e24c6..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; @@ -119,9 +118,7 @@ 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.$events.success(this.createdText); @@ -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