[opt] tag-plugin: copy
This commit is contained in:
parent
e321fa17a0
commit
f166448420
|
@ -395,6 +395,7 @@ plugins:
|
|||
js: /js/plugins/copycode.js
|
||||
default_text: 'Copy'
|
||||
success_text: 'Copied'
|
||||
toast: 复制成功
|
||||
|
||||
# AI 摘要
|
||||
# https://github.com/zhheo/Post-Abstract-AI
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
var copy_index = 0
|
||||
|
||||
module.exports = ctx => function(args) {
|
||||
args = ctx.args.map(args, ['git'], ['text'])
|
||||
args = ctx.args.map(args, ['git', 'prefix'], ['text'])
|
||||
if (args == undefined || args.text == undefined) {
|
||||
return ''
|
||||
}
|
||||
|
@ -35,6 +35,9 @@ module.exports = ctx => function(args) {
|
|||
|
||||
var el = ``
|
||||
el += `<div class="tag-plugin copy">`
|
||||
if (args.prefix?.length > 0) {
|
||||
el += `<span>${args.prefix}</span>`
|
||||
}
|
||||
el += `<input class="copy-area" id="${copy_id}" value="${text}">`
|
||||
el += `<button class="copy-btn" onclick="util.copy("${copy_id}","${toast}")">`
|
||||
el += `<svg class="icon copy-btn" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M5.75 1a.75.75 0 00-.75.75v3c0 .414.336.75.75.75h4.5a.75.75 0 00.75-.75v-3a.75.75 0 00-.75-.75h-4.5zm.75 3V2.5h3V4h-3zm-2.874-.467a.75.75 0 00-.752-1.298A1.75 1.75 0 002 3.75v9.5c0 .966.784 1.75 1.75 1.75h8.5A1.75 1.75 0 0014 13.25v-9.5a1.75 1.75 0 00-.874-1.515.75.75 0 10-.752 1.298.25.25 0 01.126.217v9.5a.25.25 0 01-.25.25h-8.5a.25.25 0 01-.25-.25v-9.5a.25.25 0 01.126-.217z"></path></svg>`
|
||||
|
|
|
@ -7,7 +7,16 @@
|
|||
border: 1px solid var(--block-border)
|
||||
overflow: hidden
|
||||
width: 100%
|
||||
|
||||
span
|
||||
line-height: 3
|
||||
padding: 0 1rem
|
||||
background: var(--block)
|
||||
border-right: 1px solid var(--block-border)
|
||||
color: var(--text-p3)
|
||||
font-family: $ff-code
|
||||
font-size: $fs-12
|
||||
font-weight: 700
|
||||
flex-shrink: 0
|
||||
input.copy-area
|
||||
display: inline-block
|
||||
padding: 0
|
||||
|
@ -16,10 +25,10 @@
|
|||
line-height: 3
|
||||
text-indent: 1rem
|
||||
button.copy-btn
|
||||
margin: 0
|
||||
border-left: 1px solid var(--block-border)
|
||||
margin: 2px
|
||||
border-radius: 'calc(%s - 2px)' % $border-bar
|
||||
display: inline-block
|
||||
background: var(--block)
|
||||
background: none
|
||||
line-height: 0
|
||||
font-size: 1rem
|
||||
padding: 0 .75rem
|
||||
|
|
|
@ -13,7 +13,7 @@ codeElementArr.forEach(code => {
|
|||
|
||||
codeCopyBtn.innerText = stellar.plugins.copycode.success_text
|
||||
codeCopyBtn.classList.add('success')
|
||||
|
||||
hud.toast(stellar.plugins.copycode.toast)
|
||||
setTimeout(() => {
|
||||
codeCopyBtn.innerText = stellar.plugins.copycode.default_text
|
||||
codeCopyBtn.classList.remove('success')
|
||||
|
|
Loading…
Reference in New Issue