- toggleDiscardDraftVisibility(show) {
- this.discardDraftWrap.classList.toggle('hidden', !show);
+ async changeEditor(event) {
+ event.preventDefault();
+
+ const link = event.target.closest('a').href;
+ /** @var {ConfirmDialog} * */
+ const dialog = window.$components.firstOnElement(this.switchDialogContainer, 'confirm-dialog');
+ const [saved, confirmed] = await Promise.all([this.saveDraft(), dialog.show()]);
+
+ if (saved && confirmed) {
+ window.location = link;
+ }
+ }
+
+ /**
+ * @return {MarkdownEditor|WysiwygEditor|WysiwygEditorTinymce}
+ */
+ getEditorComponent() {
+ return window.$components.first('markdown-editor')
+ || window.$components.first('wysiwyg-editor')
+ || window.$components.first('wysiwyg-editor-tinymce');