diff options
Diffstat (limited to 'web_src/js/features/common-global.js')
-rw-r--r-- | web_src/js/features/common-global.js | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/web_src/js/features/common-global.js b/web_src/js/features/common-global.js index 2504f3be0a..ab45267b84 100644 --- a/web_src/js/features/common-global.js +++ b/web_src/js/features/common-global.js @@ -167,6 +167,21 @@ export function initGlobalDropzone() { file.uuid = data.uuid; const input = $(`<input id="${data.uuid}" name="files" type="hidden">`).val(data.uuid); $dropzone.find('.files').append(input); + // Create a "Copy Link" element, to conveniently copy the image + // or file link as Markdown to the clipboard + const copyLinkElement = document.createElement('a'); + copyLinkElement.className = 'dz-remove'; + copyLinkElement.href = '#'; + copyLinkElement.innerHTML = '<i class="fa fa-copy"></i> Copy link'; + copyLinkElement.addEventListener('click', (e) => { + e.preventDefault(); + let fileMarkdown = `[${file.name}](/attachments/${file.uuid})`; + if (file.type.startsWith('image/')) { + fileMarkdown = `!${fileMarkdown}`; + } + navigator.clipboard.writeText(fileMarkdown); + }); + file.previewTemplate.appendChild(copyLinkElement); }); this.on('removedfile', (file) => { $(`#${file.uuid}`).remove(); |