PluginProbe
Ultimate Markdown – Markdown Editor, Importer, & Exporter / 1.19
Ultimate Markdown – Markdown Editor, Importer, & Exporter v1.19
1.26 trunk 1.07 1.08 1.09 1.10 1.11 1.12 1.13 1.14 1.15 1.16 1.18 1.19 1.20 1.21 1.22 1.23 1.24 1.25
ultimate-markdown / admin / react / utils / utils.js

utils.js in Ultimate Markdown – Markdown Editor, Importer, & Exporter 1.19, at admin/react/utils/utils.js

29 lines 752 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 /**
2 * Download a file from the provided string.
3 *
4 * @param content
5 * @param fileNamePrefix
6 */
7 export const downloadFileFromString = (content, fileNamePrefix) => {
8
9 const blob = content;
10
11 // Create a temporary URL to the blob.
12 const url = window.URL.createObjectURL(new Blob([blob]));
13
14 // Create a link element.
15 const link = document.createElement('a');
16 link.href = url;
17 const fileName = fileNamePrefix + '-' + Date.now().toString().slice(0, 10) + '.csv';
18 link.setAttribute('download', fileName); // Specify the filename
19
20 // Append the link to the body.
21 document.body.appendChild(link);
22
23 // Trigger the click event on the link.
24 link.click();
25
26 // Cleanup.
27 link.parentNode.removeChild(link);
28
29 }