0
0
Fork 0
mirror of https://github.com/BookStackApp/BookStack.git synced 2025-05-19 22:51:30 +00:00

Converted the page editor from vue to component

This commit is contained in:
Dan Brown 2020-07-05 21:18:17 +01:00
parent 9d6f574494
commit 3bfd26bf86
No known key found for this signature in database
GPG key ID: 46D9F943C24A2EF9
11 changed files with 262 additions and 220 deletions
resources/js/components

View file

@ -8,12 +8,11 @@ import DrawIO from "../services/drawio";
class MarkdownEditor {
constructor(elem) {
this.elem = elem;
setup() {
this.elem = this.$el;
const pageEditor = document.getElementById('page-editor');
this.pageId = pageEditor.getAttribute('page-id');
this.textDirection = pageEditor.getAttribute('text-direction');
this.pageId = this.$opts.pageId;
this.textDirection = this.$opts.textDirection;
this.markdown = new MarkdownIt({html: true});
this.markdown.use(mdTasksLists, {label: true});
@ -27,12 +26,18 @@ class MarkdownEditor {
this.onMarkdownScroll = this.onMarkdownScroll.bind(this);
this.display.addEventListener('load', () => {
const displayLoad = () => {
this.displayDoc = this.display.contentDocument;
this.init();
});
};
window.$events.emitPublic(elem, 'editor-markdown::setup', {
if (this.display.contentDocument.readyState === 'complete') {
displayLoad();
} else {
this.display.addEventListener('load', displayLoad.bind(this));
}
window.$events.emitPublic(this.elem, 'editor-markdown::setup', {
markdownIt: this.markdown,
displayEl: this.display,
codeMirrorInstance: this.cm,