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);
18 let handlingFormSubmit = false;
19 this.input.form.addEventListener('submit', event => {
24 if (!handlingFormSubmit) {
25 event.preventDefault();
26 handlingFormSubmit = true;
27 this.editor.getContentAsHtml().then(html => {
28 this.input.value = html;
29 this.input.form.submit();
32 handlingFormSubmit = false;
39 const drawioUrlElem = document.querySelector('[drawio-url]');
41 return drawioUrlElem.getAttribute('drawio-url');
47 * Get the content of this editor.
48 * Used by the parent page editor component.
49 * @return {Promise<{html: String}>}
53 html: await this.editor.getContentAsHtml(),