mirror of
https://github.com/Ionaru/easy-markdown-editor
synced 2025-07-19 07:54:28 -06:00
Add errorCallback option
This commit is contained in:
parent
293c402e7d
commit
6c8ce85ea9
@ -159,12 +159,12 @@ easyMDE.value('New input for **EasyMDE**');
|
|||||||
- **sbProgress**: Status message displayed to show uploading progress. Defaults to `Uploading #file_name#: #progress#%`.
|
- **sbProgress**: Status message displayed to show uploading progress. Defaults to `Uploading #file_name#: #progress#%`.
|
||||||
- **sbOnUploaded**: Status message displayed when the image has been uploaded. Defaults to `Uploaded #image_name#`.
|
- **sbOnUploaded**: Status message displayed when the image has been uploaded. Defaults to `Uploaded #image_name#`.
|
||||||
- **sizeUnits**: A comma-separated list of units used to display messages with human-readable file sizes. Defaults to `b,Kb,Mb`.
|
- **sizeUnits**: A comma-separated list of units used to display messages with human-readable file sizes. Defaults to `b,Kb,Mb`.
|
||||||
- **errorMessages**: Errors displayed to the user, mainly on alert popups, where `#image_name#`, `#image_size#` and `#image_max_size#` will replaced by their respective values, that can be used for customization or internationalization:
|
- **errorMessages**: Errors displayed to the user, using the `errorCallback` option, where `#image_name#`, `#image_size#` and `#image_max_size#` will replaced by their respective values, that can be used for customization or internationalization:
|
||||||
- **noFileGiven**: The server did not receive any file from the user. Defaults to `You must select a file.`.
|
- **noFileGiven**: The server did not receive any file from the user. Defaults to `You must select a file.`.
|
||||||
- **imageTypeNotAllowed**: The user send a file type which doesn't match the `imageAccept` list, or the server returned this error code. Defaults to `This image type is not allowed.`.
|
- **imageTypeNotAllowed**: The user send a file type which doesn't match the `imageAccept` list, or the server returned this error code. Defaults to `This image type is not allowed.`.
|
||||||
- **imageTooLarge**: The size of the image being imported is bigger than the `imageMaxSize`, or if the server returned this error code. Defaults to `Image #image_name# is too big (#image_size#).\nMaximum file size is #image_max_size#.`.
|
- **imageTooLarge**: The size of the image being imported is bigger than the `imageMaxSize`, or if the server returned this error code. Defaults to `Image #image_name# is too big (#image_size#).\nMaximum file size is #image_max_size#.`.
|
||||||
- **imageImportError**: An unexpected error occurred when uploading the image. Defaults to `Something went wrong when uploading the image #image_name#.`.
|
- **imageImportError**: An unexpected error occurred when uploading the image. Defaults to `Something went wrong when uploading the image #image_name#.`.
|
||||||
|
- **errorCallback**: A callback function used to define how to display an error message. Defaults to `function(errorMessage) {alert(errorMessage);};`.
|
||||||
- **renderingConfig**: Adjust settings for parsing the Markdown during previewing (not editing).
|
- **renderingConfig**: Adjust settings for parsing the Markdown during previewing (not editing).
|
||||||
- **codeSyntaxHighlighting**: If set to `true`, will highlight using [highlight.js](https://github.com/isagalaev/highlight.js). Defaults to `false`. To use this feature you must include highlight.js on your page or pass in using the `hljs` option. For example, include the script and the CSS files like:<br>`<script src="https://cdn.jsdelivr.net/highlight.js/latest/highlight.min.js"></script>`<br>`<link rel="stylesheet" href="https://cdn.jsdelivr.net/highlight.js/latest/styles/github.min.css">`
|
- **codeSyntaxHighlighting**: If set to `true`, will highlight using [highlight.js](https://github.com/isagalaev/highlight.js). Defaults to `false`. To use this feature you must include highlight.js on your page or pass in using the `hljs` option. For example, include the script and the CSS files like:<br>`<script src="https://cdn.jsdelivr.net/highlight.js/latest/highlight.min.js"></script>`<br>`<link rel="stylesheet" href="https://cdn.jsdelivr.net/highlight.js/latest/styles/github.min.css">`
|
||||||
- **hljs**: An injectible instance of [highlight.js](https://github.com/isagalaev/highlight.js). If you don't want to rely on the global namespace (`window.hljs`), you can provide an instance here. Defaults to `undefined`.
|
- **hljs**: An injectible instance of [highlight.js](https://github.com/isagalaev/highlight.js). If you don't want to rely on the global namespace (`window.hljs`), you can provide an instance here. Defaults to `undefined`.
|
||||||
|
@ -1426,7 +1426,7 @@ var imageTexts = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Errors displayed to the user, mainly on alert popups. Can be used for
|
* Errors displayed to the user, using the `errorCallback` option. Can be used for
|
||||||
* customization or internationalization.
|
* customization or internationalization.
|
||||||
*/
|
*/
|
||||||
var errorMessages = {
|
var errorMessages = {
|
||||||
@ -1547,6 +1547,9 @@ function EasyMDE(options) {
|
|||||||
|
|
||||||
options.minHeight = options.minHeight || '300px';
|
options.minHeight = options.minHeight || '300px';
|
||||||
|
|
||||||
|
options.errorCallback = options.errorCallback || function(errorMessage) {
|
||||||
|
alert(errorMessage);
|
||||||
|
};
|
||||||
|
|
||||||
// Import-image default configuration
|
// Import-image default configuration
|
||||||
options.uploadImage = options.uploadImage || false;
|
options.uploadImage = options.uploadImage || false;
|
||||||
@ -1621,7 +1624,7 @@ EasyMDE.prototype.uploadImages = function(files) {
|
|||||||
this.uploadImage(files[i], function onSuccess(imageUrl) {
|
this.uploadImage(files[i], function onSuccess(imageUrl) {
|
||||||
afterImageUploaded(self, imageUrl);
|
afterImageUploaded(self, imageUrl);
|
||||||
}, function onFailure(error) {
|
}, function onFailure(error) {
|
||||||
alert(error);
|
self.options.errorCallback(error);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
this.updateStatusBar('upload-image', self.options.imageTexts.sbOnDrop.replace('#images_names#', names.join(', ')));
|
this.updateStatusBar('upload-image', self.options.imageTexts.sbOnDrop.replace('#images_names#', names.join(', ')));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user