mirror of
https://github.com/go-gitea/gitea.git
synced 2024-08-25 21:44:20 -04:00
* Add copy button to markdown code blocks Done mostly in JS because I think it's better not to try getting buttons past the markup sanitizer. * add svg module tests * fix sanitizer regexp * remove outdated comment * vertically center button in issue comments as well * add comment to css * fix undefined on view file line copy * combine animation less files * Update modules/markup/markdown/markdown.go Co-authored-by: wxiaoguang <wxiaoguang@gmail.com> * add test for different sizes * add cloneNode and add tests for it * use deep clone * remove useless optional chaining * remove the svg node cache * unify clipboard copy string and i18n * remove unused var * remove unused localization * minor css tweaks to the button * comment tweak * remove useless attribute Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
36 lines
1.8 KiB
Handlebars
36 lines
1.8 KiB
Handlebars
{{if not $.DisableHTTP}}
|
|
<button class="ui basic clone button no-transition" id="repo-clone-https" data-link="{{if $.PageIsWiki}}{{$.WikiCloneLink.HTTPS}}{{else}}{{$.CloneLink.HTTPS}}{{end}}">
|
|
{{if UseHTTPS}}HTTPS{{else}}HTTP{{end}}
|
|
</button>
|
|
{{end}}
|
|
{{if and (not $.DisableSSH) (or $.IsSigned $.ExposeAnonSSH)}}
|
|
<button class="ui basic clone button no-transition" id="repo-clone-ssh" data-link="{{if $.PageIsWiki}}{{$.WikiCloneLink.SSH}}{{else}}{{$.CloneLink.SSH}}{{end}}">
|
|
SSH
|
|
</button>
|
|
{{end}}
|
|
{{if not $.DisableHTTP}}
|
|
<input id="repo-clone-url" value="{{if $.PageIsWiki}}{{$.WikiCloneLink.HTTPS}}{{else}}{{$.CloneLink.HTTPS}}{{end}}" readonly>
|
|
{{else if and (not .DisableSSH) (or $.IsSigned $.ExposeAnonSSH)}}
|
|
<input id="repo-clone-url" value="{{if $.PageIsWiki}}{{$.WikiCloneLink.SSH}}{{else}}{{$.CloneLink.SSH}}{{end}}" readonly>
|
|
{{end}}
|
|
{{if or (not $.DisableHTTP) (and (not $.DisableSSH) (or $.IsSigned $.ExposeAnonSSH))}}
|
|
<button class="ui basic icon button poping up" id="clipboard-btn" data-content="{{.i18n.Tr "copy_url"}}" data-clipboard-target="#repo-clone-url">
|
|
{{svg "octicon-paste"}}
|
|
</button>
|
|
{{end}}
|
|
{{if not (and $.DisableHTTP $.DisableSSH)}}
|
|
<script defer>
|
|
const isSSH = localStorage.getItem('repo-clone-protocol') === 'ssh';
|
|
const sshButton = document.getElementById('repo-clone-ssh');
|
|
const httpsButton = document.getElementById('repo-clone-https');
|
|
const input = document.getElementById('repo-clone-url');
|
|
if (input) input.value = (isSSH ? sshButton : httpsButton).dataset.link;
|
|
if (sshButton) sshButton.classList[isSSH ? 'add' : 'remove']('primary');
|
|
if (httpsButton) httpsButton.classList[isSSH ? 'remove' : 'add']('primary');
|
|
setTimeout(() => {
|
|
if (sshButton) sshButton.classList.remove('no-transition');
|
|
if (httpsButton) httpsButton.classList.remove('no-transition');
|
|
}, 100);
|
|
</script>
|
|
{{end}}
|