Skip to content

Commit

Permalink
remove unneeded getAcceptedFileTypesString function
Browse files Browse the repository at this point in the history
  • Loading branch information
dancormier committed Apr 19, 2024
1 parent af1a88f commit c03eb65
Showing 1 changed file with 6 additions and 17 deletions.
23 changes: 6 additions & 17 deletions src/shared/prosemirror-plugins/image-upload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ export class ImageUploader extends PluginInterfaceView<
const ctaContainer =
this.uploadContainer.querySelector(".js-cta-container");
const acceptedFileTypesString = acceptedFileTypes?.length
? this.getAcceptedFileTypesString(acceptedFileTypes)
? acceptedFileTypes.join(", ").replace(/image\//g, "")
: "";

if (acceptedFileTypesString) {
Expand Down Expand Up @@ -310,19 +310,6 @@ export class ImageUploader extends PluginInterfaceView<
event.stopPropagation();
}

getAcceptedFileTypesString(types: string[]): string {
if (types.length === 0) {
return "";
}

let uploadCaptionString = types[0].replace(/image\//g, "");
if (types.length > 1) {
uploadCaptionString = types.join(", ").replace(/image\//g, "");
}

return uploadCaptionString;
}

getCaptionElement(text: string): HTMLElement {
const uploadCaptionEl = document.createElement("span");
uploadCaptionEl.className = "fc-light fs-caption";
Expand Down Expand Up @@ -437,10 +424,12 @@ export class ImageUploader extends PluginInterfaceView<
case ValidationResult.InvalidFileType:
this.showValidationError(
_t("image_upload.upload_error_unsupported_format", {
supportedFormats: this.getAcceptedFileTypesString(
supportedFormats: (
this.uploadOptions.acceptedFileTypes ||
defaultAcceptedFileTypes
),
defaultAcceptedFileTypes
)
.join(", ")
.replace(/image\//g, ""),
})
);
reject("invalid filetype");
Expand Down

0 comments on commit c03eb65

Please sign in to comment.