X-Git-Url: http://source.bookstackapp.com/bookstack/blobdiff_plain/04c7e680fd8e86004ab27c517b3fa300c7091062..refs/pull/5676/head:/resources/js/components/wysiwyg-editor.js diff --git a/resources/js/components/wysiwyg-editor.js b/resources/js/components/wysiwyg-editor.js index deb371864..5a2581900 100644 --- a/resources/js/components/wysiwyg-editor.js +++ b/resources/js/components/wysiwyg-editor.js @@ -10,9 +10,22 @@ export class WysiwygEditor extends Component { /** @var {SimpleWysiwygEditorInterface|null} */ this.editor = null; + const translations = { + ...window.editor_translations, + imageUploadErrorText: this.$opts.imageUploadErrorText, + serverUploadLimitText: this.$opts.serverUploadLimitText, + }; + window.importVersioned('wysiwyg').then(wysiwyg => { const editorContent = this.input.value; - this.editor = wysiwyg.createPageEditorInstance(this.editContainer, editorContent); + this.editor = wysiwyg.createPageEditorInstance(this.editContainer, editorContent, { + drawioUrl: this.getDrawIoUrl(), + pageId: Number(this.$opts.pageId), + darkMode: document.documentElement.classList.contains('dark-mode'), + textDirection: this.$opts.textDirection, + translations, + }); + window.wysiwyg = this.editor; }); let handlingFormSubmit = false; @@ -26,7 +39,9 @@ export class WysiwygEditor extends Component { handlingFormSubmit = true; this.editor.getContentAsHtml().then(html => { this.input.value = html; - this.input.form.submit(); + setTimeout(() => { + this.input.form.requestSubmit(); + }, 5); }); } else { handlingFormSubmit = false; @@ -35,7 +50,6 @@ export class WysiwygEditor extends Component { } getDrawIoUrl() { - // TODO const drawioUrlElem = document.querySelector('[drawio-url]'); if (drawioUrlElem) { return drawioUrlElem.getAttribute('drawio-url');