mirror of
https://github.com/wahyd4/docsify.git
synced 2026-08-11 06:16:10 +10:00
feat(zoom-image): add plugin
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
import zoom from 'zoom-image'
|
||||
import style from 'zoom-image/css/zoom-image.css'
|
||||
|
||||
function install (hook) {
|
||||
const dom = Docsify.dom
|
||||
let destroys
|
||||
|
||||
// add style
|
||||
dom.appendTo(dom.head, dom.create('style', style))
|
||||
|
||||
hook.doneEach(_ => {
|
||||
const images = dom.findAll('img:not(.emoji)')
|
||||
|
||||
if (Array.isArray(destroys) && destroys.length) {
|
||||
destroys.forEach(o => o())
|
||||
destroys = []
|
||||
}
|
||||
|
||||
destroys = images.map(zoom)
|
||||
})
|
||||
}
|
||||
|
||||
$docsify.plugins = [].concat(install, $docsify.plugins)
|
||||
Reference in New Issue
Block a user