Files
yn/frontend/src/plugins/CodePlugin.ts
T
2021-01-16 23:58:54 +08:00

16 lines
554 B
TypeScript

import { getKeyLabel } from '@/useful/shortcut'
import Markdown from 'markdown-it'
export default (md: Markdown) => {
const Fun = (fn: Function) => (tokens: any, idx: any, options: any, env: any, slf: any) => {
if (tokens[idx].attrIndex('title') < 0) {
tokens[idx].attrJoin('class', 'copy-inner-text')
tokens[idx].attrPush(['title', getKeyLabel('CtrlCmd') + ' + 单击复制'])
}
return (fn)(tokens, idx, options, env, slf)
}
md.renderer.rules.code_inline = Fun(md.renderer.rules.code_inline!!.bind(md.renderer.rules))
}