gitbook-plugin-search-plus
Advanced tools
@@ -180,8 +180,13 @@ require([ | ||
var highLightPageInner = function(keyword) { | ||
var reg = new RegExp('(>[^<]*)(' + escapeReg(keyword) + ')', 'igm'); | ||
$('.page-inner').html($('.page-inner').html().replace(reg, '$1<span class="search-highlight search-highlight-keyword">$2</span>')); | ||
$('.page-inner').mark(keyword, { | ||
'ignoreJoiners': true, | ||
'acrossElements': true, | ||
'separateWordSearch': false | ||
}); | ||
setTimeout(function() { | ||
// 定位到第一个高亮词 | ||
$('.search-highlight')[0].scrollIntoView(); | ||
var mark = $('mark[data-markjs="true"]'); | ||
if (mark.length) { | ||
mark[0].scrollIntoView(); | ||
} | ||
}, 100); | ||
@@ -188,0 +193,0 @@ }; |
@@ -12,2 +12,3 @@ var Entities = require('html-entities').AllHtmlEntities; | ||
js: [ | ||
'jquery.mark.min.js', | ||
'search.js' | ||
@@ -14,0 +15,0 @@ ], |
{ | ||
"name": "gitbook-plugin-search-plus", | ||
"version": "0.0.9", | ||
"version": "0.0.10", | ||
"description": "gitbook powerful search plugin", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
"start": "cd examples&&npm install&&npm start", | ||
"test": "echo \"Error: no test specified\" && exit 1", | ||
"add": "git add -A", | ||
"pages:build": "cd examples&&npm install&&npm run build" | ||
}, | ||
@@ -19,2 +22,9 @@ "repository": { | ||
}, | ||
"devDependencies": { | ||
"pre-commit": "^1.2.2" | ||
}, | ||
"pre-commit": { | ||
"run": ["pages:build", "add"], | ||
"silent": true | ||
}, | ||
"author": "lwdgit", | ||
@@ -26,2 +36,2 @@ "license": "Apache-2.0", | ||
"homepage": "https://github.com/lwdgit/gitbook-plugin-search-plus#readme" | ||
} | ||
} |
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
2954161
0.47%13
8.33%323
3.86%1
Infinity%3
50%