1 import {Component} from './component';
3 export class WysiwygEditor extends Component {
7 this.editContainer = this.$refs.editContainer;
8 this.input = this.$refs.input;
10 /** @var {SimpleWysiwygEditorInterface|null} */
13 const translations = {
14 ...window.editor_translations,
15 imageUploadErrorText: this.$opts.imageUploadErrorText,
16 serverUploadLimitText: this.$opts.serverUploadLimitText,
19 window.importVersioned('wysiwyg').then(wysiwyg => {
20 const editorContent = this.input.value;
21 this.editor = wysiwyg.createPageEditorInstance(this.editContainer, editorContent, {
22 drawioUrl: this.getDrawIoUrl(),
23 pageId: Number(this.$opts.pageId),
24 darkMode: document.documentElement.classList.contains('dark-mode'),
25 textDirection: this.$opts.textDirection,
28 window.wysiwyg = this.editor;
31 let handlingFormSubmit = false;
32 this.input.form.addEventListener('submit', event => {
37 if (!handlingFormSubmit) {
38 event.preventDefault();
39 handlingFormSubmit = true;
40 this.editor.getContentAsHtml().then(html => {
41 this.input.value = html;
43 this.input.form.requestSubmit();
47 handlingFormSubmit = false;
53 const drawioUrlElem = document.querySelector('[drawio-url]');
55 return drawioUrlElem.getAttribute('drawio-url');
61 * Get the content of this editor.
62 * Used by the parent page editor component.
63 * @return {Promise<{html: String}>}
67 html: await this.editor.getContentAsHtml(),