From bb1bf12be93fb5cef9da85763db8dab0a80ff071 Mon Sep 17 00:00:00 2001 From: purocean Date: Thu, 17 Mar 2022 18:10:07 +0800 Subject: [PATCH] feat: add `copy-inner-text` class name --- help/FEATURES.md | 1 + help/FEATURES_ZH-CN.md | 1 + src/renderer/plugins/markdown-code-copy.ts | 2 +- src/renderer/support/constant.ts | 1 + 4 files changed, 4 insertions(+), 1 deletion(-) diff --git a/help/FEATURES.md b/help/FEATURES.md index 52e5b219..480d25ae 100644 --- a/help/FEATURES.md +++ b/help/FEATURES.md @@ -76,6 +76,7 @@ This feature is implemented using [markdown-it-attrs](https://github.com/arve0/m | `block` | The current element is displayed as a block element | | `reduce-brightness` | Reduce the brightness of this element when using dark theme | | `bgw` | Set current element background to white | +| `copy-inner-text` | Mark "Ctrl/Cmd + left click" to copy element text | ### Image Enhancement diff --git a/help/FEATURES_ZH-CN.md b/help/FEATURES_ZH-CN.md index 1aa995e8..a41ff494 100644 --- a/help/FEATURES_ZH-CN.md +++ b/help/FEATURES_ZH-CN.md @@ -77,6 +77,7 @@ define: | `block` | 当前元素显示为块元素 | | `reduce-brightness` | 使用暗色主题时候降低此元素亮度 | | `bgw` | 设置当前元素背景为白色 | +| `copy-inner-text` | 标记 “Ctrl/Cmd + 单击左键” 拷贝元素文字 | ### 图片增强 diff --git a/src/renderer/plugins/markdown-code-copy.ts b/src/renderer/plugins/markdown-code-copy.ts index 4448de83..098044dc 100644 --- a/src/renderer/plugins/markdown-code-copy.ts +++ b/src/renderer/plugins/markdown-code-copy.ts @@ -58,7 +58,7 @@ export default { ctx.markdown.registerPlugin(md => { const codeInline = (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].attrJoin('class', ctx.constant.DOM_CLASS_NAME.COPY_INNER_TEXT) tokens[idx].attrPush(['title', ctx.command.getKeyLabel('CtrlCmd') + ' + ' + ctx.i18n.t('click-to-copy')]) } diff --git a/src/renderer/support/constant.ts b/src/renderer/support/constant.ts index 9b792aa5..ec862d65 100644 --- a/src/renderer/support/constant.ts +++ b/src/renderer/support/constant.ts @@ -15,4 +15,5 @@ export const DOM_CLASS_NAME = { INLINE: 'inline', BLOCK: 'block', BGW: 'bgw', + COPY_INNER_TEXT: 'copy-inner-text', }