-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8778 from hicommonwealth/burton/download-markdown…
…-for-kyve Ability to download markdown for Kyve
- Loading branch information
Showing
5 changed files
with
51 additions
and
18 deletions.
There are no files selected for viewing
23 changes: 23 additions & 0 deletions
23
packages/commonwealth/client/scripts/utils/downloadDataAsFile.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/** | ||
* Save the content locally and use the `filename` as the suggested name for the | ||
* file. | ||
*/ | ||
export function downloadDataAsFile( | ||
content: string, | ||
type: string, | ||
filename: string, | ||
) { | ||
const blob = new Blob([content], { type }); | ||
|
||
const link = document.createElement('a'); | ||
link.href = URL.createObjectURL(blob); | ||
link.download = filename; | ||
|
||
document.body.appendChild(link); | ||
|
||
link.click(); | ||
|
||
document.body.removeChild(link); | ||
|
||
URL.revokeObjectURL(link.href); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters