diff --git a/assets/index.js b/assets/index.js index b87e354..e249c94 100644 --- a/assets/index.js +++ b/assets/index.js @@ -62,6 +62,7 @@ const ICONS = { edit: ``, delete: ``, view: ``, + copyLink: ``, } /** @@ -440,6 +441,7 @@ function addPath(file, index) { let url = newUrl(file.name); let actionDelete = ""; let actionDownload = ""; + let actionCopyLink = ""; let actionMove = ""; let actionEdit = ""; let actionView = ""; @@ -471,10 +473,14 @@ function addPath(file, index) { if (!actionEdit && !isDir) { actionView = `${ICONS.view}`; } + if (!isDir) { + actionCopyLink = `
${ICONS.copyLink}
`; + } let actionCell = ` ${actionDownload} ${actionView} + ${actionCopyLink} ${actionMove} ${actionDelete} ${actionEdit} @@ -650,6 +656,19 @@ async function setupEditorPage() { } } +/** + * Copy url to clipboard + * @param {string} url + * @returns + */ +async function copyLink(url) { + try { + await navigator.clipboard.writeText(url); + } catch (err) { + alert(`Failed to copy link, ${err.message}`); + } +} + /** * Delete path * @param {number} index