diff options
author | silverwind <me@silverwind.io> | 2023-04-02 11:25:36 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-04-02 17:25:36 +0800 |
commit | f5593d08dc6d615e650fe5e954b300d1895212b7 (patch) | |
tree | 3b8e7762bdf5790ad988d4d4fce27da8f42d2087 /web_src/js/features/copycontent.js | |
parent | fcb9ef8788da02c13ee7201b5b8bce216da3f0d7 (diff) | |
download | gitea-f5593d08dc6d615e650fe5e954b300d1895212b7.tar.gz gitea-f5593d08dc6d615e650fe5e954b300d1895212b7.zip |
Use clippie module to copy to clipboard (#23801)
Externalize clipboard copying to the
[clippie](https://github.com/silverwind/clippie) module which I feel I
can maintain outside this repo for shared benefit with my other
projects.
The module is feature-equivalent to the previous code and has one
improvement where it sets `aria-hidden` on the fallback textarea,
preventing screen readers from picking it up. Also it support `Array` of
`content` as well to copy multiple items at once, in case it's ever
needed.
Diffstat (limited to 'web_src/js/features/copycontent.js')
-rw-r--r-- | web_src/js/features/copycontent.js | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/web_src/js/features/copycontent.js b/web_src/js/features/copycontent.js index 5a4b99ae9b..e51953625d 100644 --- a/web_src/js/features/copycontent.js +++ b/web_src/js/features/copycontent.js @@ -1,11 +1,11 @@ -import {copyToClipboard} from './clipboard.js'; +import {clippie} from 'clippie'; import {showTemporaryTooltip} from '../modules/tippy.js'; import {convertImage} from '../utils.js'; const {i18n} = window.config; async function doCopy(content, btn) { - const success = await copyToClipboard(content); + const success = await clippie(content); showTemporaryTooltip(btn, success ? i18n.copy_success : i18n.copy_error); } |