Skip to content

Commit

Permalink
Support Copy Link for video attachments (#24833)
Browse files Browse the repository at this point in the history
Creating a `<video>` tag with controls and title.
  • Loading branch information
brechtvl authored May 21, 2023
1 parent 268d121 commit 65dff8e
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions web_src/js/features/common-global.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {showGlobalErrorMessage} from '../bootstrap.js';
import {handleGlobalEnterQuickSubmit} from './comp/QuickSubmit.js';
import {svg} from '../svg.js';
import {hideElem, showElem, toggleElem} from '../utils/dom.js';
import {htmlEscape} from 'escape-goat';

const {appUrl, csrfToken} = window.config;

Expand Down Expand Up @@ -168,6 +169,8 @@ export function initGlobalDropzone() {
let fileMarkdown = `[${file.name}](/attachments/${file.uuid})`;
if (file.type.startsWith('image/')) {
fileMarkdown = `!${fileMarkdown}`;
} else if (file.type.startsWith('video/')) {
fileMarkdown = `<video src="/attachments/${file.uuid}" title="${htmlEscape(file.name)}" controls></video>`;
}
navigator.clipboard.writeText(fileMarkdown);
});
Expand Down

0 comments on commit 65dff8e

Please sign in to comment.