2
0
mirror of https://github.com/Ionaru/easy-markdown-editor synced 2025-07-03 08:04:29 -06:00

Allow setting a custom name for the upload-image input

This commit is contained in:
Robin van der Noord 2023-12-18 10:57:48 +01:00
parent 35587a9477
commit c68bdf148a
No known key found for this signature in database
GPG Key ID: C48F4649BEAE9AEE
2 changed files with 3 additions and 1 deletions

View File

@ -1870,6 +1870,7 @@ function EasyMDE(options) {
options.imagePathAbsolute = options.imagePathAbsolute || false; options.imagePathAbsolute = options.imagePathAbsolute || false;
options.imageCSRFName = options.imageCSRFName || 'csrfmiddlewaretoken'; options.imageCSRFName = options.imageCSRFName || 'csrfmiddlewaretoken';
options.imageCSRFHeader = options.imageCSRFHeader || false; options.imageCSRFHeader = options.imageCSRFHeader || false;
options.imageInputName = options.imageInputName || 'image';
// Change unique_id to uniqueId for backwards compatibility // Change unique_id to uniqueId for backwards compatibility
@ -2689,7 +2690,7 @@ EasyMDE.prototype.createToolbar = function (items) {
imageInput.className = 'imageInput'; imageInput.className = 'imageInput';
imageInput.type = 'file'; imageInput.type = 'file';
imageInput.multiple = true; imageInput.multiple = true;
imageInput.name = 'image'; imageInput.name = self.options.imageInputName;
imageInput.accept = self.options.imageAccept; imageInput.accept = self.options.imageAccept;
imageInput.style.display = 'none'; imageInput.style.display = 'none';
imageInput.style.opacity = 0; imageInput.style.opacity = 0;

1
types/easymde.d.ts vendored
View File

@ -227,6 +227,7 @@ declare namespace EasyMDE {
imageCSRFName?: string; imageCSRFName?: string;
imageCSRFHeader?: boolean; imageCSRFHeader?: boolean;
imageTexts?: ImageTextsOptions; imageTexts?: ImageTextsOptions;
imageInputName?: string
errorMessages?: ImageErrorTextsOptions; errorMessages?: ImageErrorTextsOptions;
errorCallback?: (errorMessage: string) => void; errorCallback?: (errorMessage: string) => void;