1
0
Fork 0
mirror of https://codeberg.org/forgejo/forgejo.git synced 2024-11-24 08:57:03 -05:00

Support Copy Link for video attachments (#24833)

Creating a `<video>` tag with controls and title.
This commit is contained in:
Brecht Van Lommel 2023-05-22 00:06:17 +02:00 committed by GitHub
parent 268d121f4b
commit 65dff8e364
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -7,6 +7,7 @@ import {showGlobalErrorMessage} from '../bootstrap.js';
import {handleGlobalEnterQuickSubmit} from './comp/QuickSubmit.js'; 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';
const {appUrl, csrfToken} = window.config; const {appUrl, csrfToken} = window.config;
@ -168,6 +169,8 @@ export function initGlobalDropzone() {
let fileMarkdown = `[${file.name}](/attachments/${file.uuid})`; let fileMarkdown = `[${file.name}](/attachments/${file.uuid})`;
if (file.type.startsWith('image/')) { if (file.type.startsWith('image/')) {
fileMarkdown = `!${fileMarkdown}`; fileMarkdown = `!${fileMarkdown}`;
} else if (file.type.startsWith('video/')) {
fileMarkdown = `<video src="/attachments/${file.uuid}" title="${htmlEscape(file.name)}" controls></video>`;
} }
navigator.clipboard.writeText(fileMarkdown); navigator.clipboard.writeText(fileMarkdown);
}); });