docs: consolidate docs ()

Signed-off-by: Philip Molares <philip.molares@udo.edu>
This commit is contained in:
Philip Molares 2022-07-21 22:36:46 +02:00 committed by GitHub
parent 8d46d7e39e
commit ecffebc43c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
307 changed files with 1474 additions and 487 deletions
src/components/common/download

View file

@ -1,15 +1,22 @@
/*
* SPDX-FileCopyrightText: 2021 The HedgeDoc developers (see AUTHORS file)
* SPDX-FileCopyrightText: 2022 The HedgeDoc developers (see AUTHORS file)
*
* SPDX-License-Identifier: AGPL-3.0-only
*/
/**
* Download a given {@link BlobPart file} from memory<.
*
* @param data The file to download.
* @param fileName Which filename does the file have.
* @param mimeType What is the files mimetype.
*/
export const download = (data: BlobPart, fileName: string, mimeType: string): void => {
const file = new Blob([data], { type: mimeType })
downloadLink(URL.createObjectURL(file), fileName)
}
export const downloadLink = (url: string, fileName: string): void => {
const downloadLink = (url: string, fileName: string): void => {
const helperElement = document.createElement('a')
helperElement.href = url
helperElement.download = fileName