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