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),
19 imageUploadErrorText: this.$opts.imageUploadErrorText,
20 serverUploadLimitText: this.$opts.serverUploadLimitText,
25 let handlingFormSubmit = false;
26 this.input.form.addEventListener('submit', event => {
31 if (!handlingFormSubmit) {
32 event.preventDefault();
33 handlingFormSubmit = true;
34 this.editor.getContentAsHtml().then(html => {
35 this.input.value = html;
36 this.input.form.submit();
39 handlingFormSubmit = false;
45 const drawioUrlElem = document.querySelector('[drawio-url]');
47 return drawioUrlElem.getAttribute('drawio-url');
53 * Get the content of this editor.
54 * Used by the parent page editor component.
55 * @return {Promise<{html: String}>}
59 html: await this.editor.getContentAsHtml(),