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,
30 let handlingFormSubmit = false;
31 this.input.form.addEventListener('submit', event => {
36 if (!handlingFormSubmit) {
37 event.preventDefault();
38 handlingFormSubmit = true;
39 this.editor.getContentAsHtml().then(html => {
40 this.input.value = html;
41 this.input.form.submit();
44 handlingFormSubmit = false;
50 const drawioUrlElem = document.querySelector('[drawio-url]');
52 return drawioUrlElem.getAttribute('drawio-url');
58 * Get the content of this editor.
59 * Used by the parent page editor component.
60 * @return {Promise<{html: String}>}
64 html: await this.editor.getContentAsHtml(),