]>
BookStack Code Mirror - bookstack/blobdiff - resources/js/components/markdown-editor.js
projects
/
bookstack
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Updated drawing upload error to shown/handle server limit errors
[bookstack]
/
resources
/
js
/
components
/
markdown-editor.js
diff --git
a/resources/js/components/markdown-editor.js
b/resources/js/components/markdown-editor.js
index 19d26d4a987f561f2aa0a3d007283f0655463d83..a90f74e2746401562f59c03cea0b8824298f9dc8 100644
(file)
--- a/
resources/js/components/markdown-editor.js
+++ b/
resources/js/components/markdown-editor.js
@@
-13,6
+13,8
@@
class MarkdownEditor {
this.pageId = this.$opts.pageId;
this.textDirection = this.$opts.textDirection;
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.markdown = new MarkdownIt({html: true});
this.markdown.use(mdTasksLists, {label: true});
@@
-21,7
+23,6
@@
class MarkdownEditor {
this.displayStylesLoaded = false;
this.input = this.elem.querySelector('textarea');
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);
this.cm = code.markdownEditor(this.input);
this.onMarkdownScroll = this.onMarkdownScroll.bind(this);
@@
-124,7
+125,6
@@
class MarkdownEditor {
// Set body content
this.displayDoc.body.className = 'page-content';
this.displayDoc.body.innerHTML = html;
// 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();
// Copy styles from page head and set custom styles for editor
this.loadStylesIntoDisplay();
@@
-373,7
+373,7
@@
class MarkdownEditor {
const newContent = `[](${resp.data.url})`;
replaceContent(placeHolderText, newContent);
}).catch(err => {
const newContent = `[](${resp.data.url})`;
replaceContent(placeHolderText, newContent);
}).catch(err => {
- window.$events.emit('error',
trans('errors.image_upload_error')
);
+ window.$events.emit('error',
context.imageUploadErrorText
);
replaceContent(placeHolderText, selectedText);
console.log(err);
});
replaceContent(placeHolderText, selectedText);
console.log(err);
});
@@
-447,8
+447,7
@@
class MarkdownEditor {
this.insertDrawing(resp.data, cursorPos);
DrawIO.close();
}).catch(err => {
this.insertDrawing(resp.data, cursorPos);
DrawIO.close();
}).catch(err => {
- window.$events.emit('error', trans('errors.image_upload_error'));
- console.log(err);
+ this.handleDrawingUploadError(err);
});
});
}
});
});
}
@@
-492,12
+491,20
@@
class MarkdownEditor {
this.cm.focus();
DrawIO.close();
}).catch(err => {
this.cm.focus();
DrawIO.close();
}).catch(err => {
- window.$events.emit('error', trans('errors.image_upload_error'));
- 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');
// Make the editor full screen
actionFullScreen() {
const alreadyFullscreen = this.elem.classList.contains('fullscreen');