From ce7da090ac2969d607fa084603487af4823a50d3 Mon Sep 17 00:00:00 2001 From: ULIVZ <472590061@qq.com> Date: Fri, 2 Nov 2018 11:52:13 +0800 Subject: [PATCH] feat($medium-zoom): support selector option. --- packages/@vuepress/plugin-medium-zoom/index.js | 7 +++++-- packages/@vuepress/plugin-medium-zoom/mixin.js | 4 +++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/packages/@vuepress/plugin-medium-zoom/index.js b/packages/@vuepress/plugin-medium-zoom/index.js index 04eea8cdea..639b17d652 100644 --- a/packages/@vuepress/plugin-medium-zoom/index.js +++ b/packages/@vuepress/plugin-medium-zoom/index.js @@ -1,5 +1,8 @@ const { path } = require('@vuepress/shared-utils') -module.exports = { +module.exports = (options, context) => ({ + define: { + SELECTOR: options.selector || '.content img' + }, clientRootMixin: path.resolve(__dirname, 'mixin.js') -} +}) diff --git a/packages/@vuepress/plugin-medium-zoom/mixin.js b/packages/@vuepress/plugin-medium-zoom/mixin.js index 24369a681c..8ca95d5f44 100644 --- a/packages/@vuepress/plugin-medium-zoom/mixin.js +++ b/packages/@vuepress/plugin-medium-zoom/mixin.js @@ -1,10 +1,12 @@ +/* global SELECTOR */ + import './style.css' import zoom from 'medium-zoom' export default { mounted () { setTimeout(() => { - zoom('.content img') + zoom(SELECTOR) }, 1000) } }