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 window.importVersioned('wysiwyg').then(wysiwyg => {
14 const editorContent = this.input.value;
15 this.editor = wysiwyg.createPageEditorInstance(this.editContainer, editorContent, {
16 drawioUrl: this.getDrawIoUrl(),
17 pageId: Number(this.$opts.pageId),
18 darkMode: document.documentElement.classList.contains('dark-mode'),
19 textDirection: this.$opts.textDirection,
21 imageUploadErrorText: this.$opts.imageUploadErrorText,
22 serverUploadLimitText: this.$opts.serverUploadLimitText,
27 let handlingFormSubmit = false;
28 this.input.form.addEventListener('submit', event => {
33 if (!handlingFormSubmit) {
34 event.preventDefault();
35 handlingFormSubmit = true;
36 this.editor.getContentAsHtml().then(html => {
37 this.input.value = html;
38 this.input.form.submit();
41 handlingFormSubmit = false;
47 const drawioUrlElem = document.querySelector('[drawio-url]');
49 return drawioUrlElem.getAttribute('drawio-url');
55 * Get the content of this editor.
56 * Used by the parent page editor component.
57 * @return {Promise<{html: String}>}
61 html: await this.editor.getContentAsHtml(),