chore: version 2.8.3 (#175)
* feat: 保留已存在的内容直到手动操作 * feat: 支持复制文本 * chore: version 2.8.3
This commit is contained in:
@@ -13,3 +13,15 @@ export function includeCode(text: string | null | undefined) {
|
||||
const regexp = /^(?:\s{4}|\t).+/gm
|
||||
return !!(text?.includes(' = ') || text?.match(regexp))
|
||||
}
|
||||
|
||||
// 复制文本
|
||||
export function copyText(text: string) {
|
||||
const input = document.createElement('input')
|
||||
input.setAttribute('readonly', 'readonly')
|
||||
input.setAttribute('value', text)
|
||||
document.body.appendChild(input)
|
||||
input.select()
|
||||
if (document.execCommand('copy'))
|
||||
document.execCommand('copy')
|
||||
document.body.removeChild(input)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user