From 8413c5b718a94bbacba713bbc0b2f230fe8781ac Mon Sep 17 00:00:00 2001 From: ferrinweb Date: Fri, 30 Aug 2019 09:22:12 +0800 Subject: [PATCH 1/2] support for cutom title --- clientRootMixin.js | 2 +- index.js | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/clientRootMixin.js b/clientRootMixin.js index fcd051c..7073613 100755 --- a/clientRootMixin.js +++ b/clientRootMixin.js @@ -24,7 +24,7 @@ export default { if ( parent.classList.contains( 'codecopy-enabled' ) ) return const copyElement = document.createElement( 'span' ) copyElement.className = 'code-copy' - copyElement.title = 'Click to Copy to Clipboard' + copyElement.title = OPTIONS.title || 'Click to Copy to Clipboard' copyElement.addEventListener( 'click', () => { this.copyToClipboard( parent.innerText ) } ) diff --git a/index.js b/index.js index 978eea4..a2d6765 100755 --- a/index.js +++ b/index.js @@ -2,7 +2,8 @@ const { path } = require('@vuepress/shared-utils') module.exports = (options, context) => ({ define: { - COPY_SELECTOR: options.copy_selector || 'div[class*="language-"] pre' + COPY_SELECTOR: options.copy_selector || 'div[class*="language-"] pre', + OPTIONS: options.options }, clientRootMixin: path.resolve(__dirname, 'clientRootMixin.js') }) From 42b8c6eb339803217bcf72a005cd56cc2fadbc4f Mon Sep 17 00:00:00 2001 From: ferrinweb Date: Fri, 30 Aug 2019 09:33:26 +0800 Subject: [PATCH 2/2] fix param error --- clientRootMixin.js | 2 +- index.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/clientRootMixin.js b/clientRootMixin.js index 7073613..eb76adf 100755 --- a/clientRootMixin.js +++ b/clientRootMixin.js @@ -24,7 +24,7 @@ export default { if ( parent.classList.contains( 'codecopy-enabled' ) ) return const copyElement = document.createElement( 'span' ) copyElement.className = 'code-copy' - copyElement.title = OPTIONS.title || 'Click to Copy to Clipboard' + copyElement.title = TITLE || 'Click to Copy to Clipboard' copyElement.addEventListener( 'click', () => { this.copyToClipboard( parent.innerText ) } ) diff --git a/index.js b/index.js index a2d6765..e44e531 100755 --- a/index.js +++ b/index.js @@ -3,7 +3,7 @@ const { path } = require('@vuepress/shared-utils') module.exports = (options, context) => ({ define: { COPY_SELECTOR: options.copy_selector || 'div[class*="language-"] pre', - OPTIONS: options.options + TITLE: options.title }, clientRootMixin: path.resolve(__dirname, 'clientRootMixin.js') })