Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add code-copy plugin #450

Merged
merged 2 commits into from
Sep 14, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Use setTimeout
  • Loading branch information
saltysugar committed Sep 14, 2019
commit 9c59282dad0d84e6c8ef3d3f9e48d72477ad4e5c
6 changes: 3 additions & 3 deletions packages/saber-plugin-code-copy/lib/saber-browser.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint-env browser */
/* globals __CODE_COPY_OPTIONS__ */

export default ({ router, Vue }) => {
export default ({ router }) => {
if (process.browser) {
const copy = require('modern-copy').default

Expand Down Expand Up @@ -43,7 +43,7 @@ export default ({ router, Vue }) => {
}

router.afterEach(() => {
Vue.nextTick(() => {
setTimeout(() => {
forEach(document.querySelectorAll('.saber-highlight'), el => {
if (el.dataset.hasCopy) return
el.dataset.hasCopy = true
Expand All @@ -64,7 +64,7 @@ export default ({ router, Vue }) => {
injectStyle()
el.append(copyButton)
})
})
}, 100)
})
}
}