|
1 | 1 | import $ from 'jquery';
|
2 | 2 | import 'jquery.are-you-sure';
|
| 3 | +import {clippie} from 'clippie'; |
3 | 4 | import {createDropzone} from './dropzone.js';
|
4 | 5 | import {initCompColorPicker} from './comp/ColorPicker.js';
|
5 | 6 | import {showGlobalErrorMessage} from '../bootstrap.js';
|
6 | 7 | import {handleGlobalEnterQuickSubmit} from './comp/QuickSubmit.js';
|
7 | 8 | import {svg} from '../svg.js';
|
8 | 9 | import {hideElem, showElem, toggleElem} from '../utils/dom.js';
|
9 | 10 | import {htmlEscape} from 'escape-goat';
|
10 |
| -import {createTippy} from '../modules/tippy.js'; |
| 11 | +import {createTippy, showTemporaryTooltip} from '../modules/tippy.js'; |
11 | 12 | import {confirmModal} from './comp/ConfirmModal.js';
|
12 | 13 | import {showErrorToast} from '../modules/toast.js';
|
13 | 14 |
|
@@ -240,15 +241,16 @@ export function initGlobalDropzone() {
|
240 | 241 | copyLinkElement.className = 'gt-text-center';
|
241 | 242 | // The a element has a hardcoded cursor: pointer because the default is overridden by .dropzone
|
242 | 243 | copyLinkElement.innerHTML = `<a href="#" style="cursor: pointer;">${svg('octicon-copy', 14, 'copy link')} Copy link</a>`;
|
243 |
| - copyLinkElement.addEventListener('click', (e) => { |
| 244 | + copyLinkElement.addEventListener('click', async (e) => { |
244 | 245 | e.preventDefault();
|
245 | 246 | let fileMarkdown = `[${file.name}](/attachments/${file.uuid})`;
|
246 | 247 | if (file.type.startsWith('image/')) {
|
247 | 248 | fileMarkdown = `!${fileMarkdown}`;
|
248 | 249 | } else if (file.type.startsWith('video/')) {
|
249 | 250 | fileMarkdown = `<video src="/attachments/${file.uuid}" title="${htmlEscape(file.name)}" controls></video>`;
|
250 | 251 | }
|
251 |
| - navigator.clipboard.writeText(fileMarkdown); |
| 252 | + const success = await clippie(fileMarkdown); |
| 253 | + showTemporaryTooltip(e.target, success ? i18n.copy_success : i18n.copy_error); |
252 | 254 | });
|
253 | 255 | file.previewTemplate.append(copyLinkElement);
|
254 | 256 | });
|
|
0 commit comments