this.pageId = this.$opts.pageId;
this.textDirection = this.$opts.textDirection;
this.imageUploadErrorText = this.$opts.imageUploadErrorText;
+ this.serverUploadLimitText = this.$opts.serverUploadLimitText;
this.markdown = new MarkdownIt({html: true});
this.markdown.use(mdTasksLists, {label: true});
this.displayStylesLoaded = false;
this.input = this.elem.querySelector('textarea');
- this.htmlInput = this.elem.querySelector('input[name=html]');
this.cm = code.markdownEditor(this.input);
this.onMarkdownScroll = this.onMarkdownScroll.bind(this);
// Set body content
this.displayDoc.body.className = 'page-content';
this.displayDoc.body.innerHTML = html;
- this.htmlInput.value = html;
// Copy styles from page head and set custom styles for editor
this.loadStylesIntoDisplay();
this.insertDrawing(resp.data, cursorPos);
DrawIO.close();
}).catch(err => {
- window.$events.emit('error', trans('errors.image_upload_error'));
- console.log(err);
+ this.handleDrawingUploadError(err);
});
});
}
this.cm.focus();
DrawIO.close();
}).catch(err => {
- window.$events.emit('error', this.imageUploadErrorText);
- console.log(err);
+ this.handleDrawingUploadError(err);
});
});
}
+ handleDrawingUploadError(error) {
+ if (error.status === 413) {
+ window.$events.emit('error', this.serverUploadLimitText);
+ } else {
+ window.$events.emit('error', this.imageUploadErrorText);
+ }
+ console.log(error);
+ }
+
// Make the editor full screen
actionFullScreen() {
const alreadyFullscreen = this.elem.classList.contains('fullscreen');