mirror of
https://github.com/docsifyjs/docsify.git
synced 2026-10-23 15:59:02 +08:00
75c72e917b
* chore: added new linter config * chore: linting fixes * chore: refactore in linting config and minor linting fixes
31 lines
646 B
JavaScript
31 lines
646 B
JavaScript
/* eslint-disable no-unused-vars */
|
|
import mediumZoom from 'medium-zoom';
|
|
|
|
const matchesSelector =
|
|
Element.prototype.matches ||
|
|
Element.prototype.webkitMatchesSelector ||
|
|
Element.prototype.msMatchesSelector;
|
|
|
|
function install(hook) {
|
|
let zoom;
|
|
|
|
hook.doneEach(_ => {
|
|
let elms = Array.apply(
|
|
null,
|
|
document.querySelectorAll(
|
|
'.markdown-section img:not(.emoji):not([data-no-zoom])'
|
|
)
|
|
);
|
|
|
|
elms = elms.filter(elm => matchesSelector.call(elm, 'a img') === false);
|
|
|
|
if (zoom) {
|
|
zoom.detach();
|
|
}
|
|
|
|
zoom = mediumZoom(elms);
|
|
});
|
|
}
|
|
|
|
$docsify.plugins = [].concat(install, $docsify.plugins);
|