bump: 3.0.2

This commit is contained in:
qingwei.li 2017-02-19 15:27:39 +08:00
parent bf593a77ad
commit 2c9fdbe7f9
5 changed files with 25 additions and 14 deletions

View File

@ -1,4 +1,10 @@
3.0.2 / 2017-02-19
==================
* fix(search): add lazy input
* fix(compiler): link
3.0.1 / 2017-02-19
==================

View File

@ -3008,7 +3008,10 @@ renderer.link = function (href, title, text) {
} else {
blank = ' target="_blank"';
}
return ("<a href=\"" + href + "\" title=\"" + (title || text) + "\"" + blank + ">" + text + "</a>")
if (title) {
title = " title=\"" + title + "\"";
}
return ("<a href=\"" + href + "\"" + title + blank + ">" + text + "</a>")
};
renderer.paragraph = function (text) {
if (/^!&gt;/.test(text)) {

2
lib/docsify.min.js vendored

File diff suppressed because one or more lines are too long

View File

@ -88,14 +88,14 @@ function search (keywords) {
var postContent = post.body && post.body.trim();
var postUrl = post.slug || '';
if (postTitle !== '' && postContent !== '') {
if (postTitle && postContent) {
keywords.forEach(function (keyword, i) {
var regEx = new RegExp(keyword, 'gi');
var indexTitle = -1;
var indexContent = -1;
indexTitle = postTitle.search(regEx);
indexContent = postContent.search(regEx);
indexTitle = postTitle && postTitle.search(regEx);
indexContent = postContent && postContent.search(regEx);
if (indexTitle < 0 && indexContent < 0) {
isMatch = false;
@ -192,13 +192,7 @@ function bindEvents () {
var $search = dom.find('div.search');
var $input = dom.find($search, 'input');
var $panel = dom.find($search, '.results-panel');
// Prevent to Fold sidebar
dom.on($search, 'click',
function (e) { return e.target.tagName !== 'A' && e.stopPropagation(); });
dom.on($input, 'input', function (e) {
var value = e.target.value.trim();
var doSearch = function (value) {
if (!value) {
$panel.classList.remove('show');
$panel.innerHTML = '';
@ -207,13 +201,21 @@ function bindEvents () {
var matchs = search(value);
var html = '';
matchs.forEach(function (post) {
html += "<div class=\"matching-post\">\n <h2><a href=\"" + (post.url) + "\">" + (post.title) + "</a></h2>\n <p>" + (post.content) + "</p>\n</div>";
});
$panel.classList.add('show');
$panel.innerHTML = html || '<p class="empty">No Results!</p>';
};
var timeId;
// Prevent to Fold sidebar
dom.on($search, 'click',
function (e) { return e.target.tagName !== 'A' && e.stopPropagation(); });
dom.on($input, 'input', function (e) {
clearTimeout(timeId);
timeId = setTimeout(function (_) { return doSearch(e.target.value.trim()); }, 200);
});
}

View File

@ -1 +1 @@
this.D=this.D||{},function(){"use strict";function e(e){var n={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;","/":"&#x2F;"};return String(e).replace(/[&<>"'\/]/g,function(e){return n[e]})}function n(){var e=[];return h.dom.findAll("a").map(function(n){var t=n.href,r=n.getAttribute("href"),i=h.route.parse(t).path;i&&e.indexOf(i)===-1&&!h.route.isAbsolutePath(r)&&e.push(i)}),e}function t(e){localStorage.setItem("docsify.search.expires",Date.now()+e),localStorage.setItem("docsify.search.index",JSON.stringify(f))}function r(e,n){void 0===n&&(n="");var t,r=window.marked.lexer(n),i=Docsify.route.toURL,o={};return r.forEach(function(n){if("heading"===n.type&&n.depth<=2)t=i(e,{id:n.text}),o[t]={slug:t,title:n.text,body:""};else{if(!t)return;o[t]?o[t].body?o[t].body+="\n"+(n.text||""):o[t].body=n.text:o[t]={slug:t,title:"",body:""}}}),o}function i(n){var t=[],r=[];Object.keys(f).forEach(function(e){r=r.concat(Object.keys(f[e]).map(function(n){return f[e][n]}))}),n=n.trim().split(/[\s\-\\\\/]+/);for(var i=function(i){var o=r[i],a=!1,s="",c=o.title&&o.title.trim(),l=o.body&&o.body.trim(),p=o.slug||"";if(""!==c&&""!==l&&(n.forEach(function(n,t){var r=new RegExp(n,"gi"),i=-1,o=-1;if(i=c.search(r),o=l.search(r),i<0&&o<0)a=!1;else{a=!0,o<0&&(o=0);var p=0,d=0;p=o<11?0:o-10,d=0===p?70:o+n.length+60,d>l.length&&(d=l.length);var h="..."+e(l).substring(p,d).replace(r,'<em class="search-keyword">'+n+"</em>")+"...";s+=h}}),a)){var d={title:e(c),content:s,url:p};t.push(d)}},o=0;o<r.length;o++)i(o);return t}function o(e,i){h=Docsify;var o="auto"===e.paths,a=localStorage.getItem("docsify.search.expires")<Date.now();if(f=JSON.parse(localStorage.getItem("docsify.search.index")),a)f={};else if(!o)return;var s=o?n():e.paths,c=s.length,l=0;s.forEach(function(n){return f[n]?l++:void h.get(i.$getFile(n)).then(function(i){f[n]=r(n,i),c===++l&&t(e.maxAge)})})}function a(){var e="\n.sidebar {\n padding-top: 0;\n}\n\n.search {\n margin-bottom: 20px;\n padding: 6px;\n border-bottom: 1px solid #eee;\n}\n\n.search .results-panel {\n display: none;\n}\n\n.search .results-panel.show {\n display: block;\n}\n\n.search input {\n outline: none;\n border: none;\n width: 100%;\n padding: 7px;\n line-height: 22px;\n font-size: 14px;\n}\n\n.search h2 {\n font-size: 17px;\n margin: 10px 0;\n}\n\n.search a {\n text-decoration: none;\n color: inherit;\n}\n\n.search .matching-post {\n border-bottom: 1px solid #eee;\n}\n\n.search .matching-post:last-child {\n border-bottom: 0;\n}\n\n.search p {\n font-size: 14px;\n overflow: hidden;\n text-overflow: ellipsis;\n display: -webkit-box;\n -webkit-line-clamp: 2;\n -webkit-box-orient: vertical;\n}\n\n.search p.empty {\n text-align: center;\n}",n=u.create("style",e);u.appendTo(u.head,n)}function s(e){var n='<input type="search" /><div class="results-panel"></div></div>',t=u.create("div",n),r=u.find("aside");u.toggleClass(t,"search"),u.before(r,t)}function c(){var e=u.find("div.search"),n=u.find(e,"input"),t=u.find(e,".results-panel");u.on(e,"click",function(e){return"A"!==e.target.tagName&&e.stopPropagation()}),u.on(n,"input",function(e){var n=e.target.value.trim();if(!n)return t.classList.remove("show"),void(t.innerHTML="");var r=i(n),o="";r.forEach(function(e){o+='<div class="matching-post">\n <h2><a href="'+e.url+'">'+e.title+"</a></h2>\n <p>"+e.content+"</p>\n</div>"}),t.classList.add("show"),t.innerHTML=o||'<p class="empty">No Results!</p>'})}function l(e,n){var t=u.getNode('.search input[type="search"]');if("string"==typeof e)t.placeholder=e;else{var r=Object.keys(e).find(function(e){return n.indexOf(e)>-1});t.placeholder=e[r]}}function p(e){u=Docsify.dom,a(),s(e),c()}function d(e,n){l(e.placeholder,n.route.path)}var h,u,f={},g={placeholder:"Type to search",paths:"auto",maxAge:864e5},v=function(e,n){var t=Docsify.util,r=n.config.search||g;Array.isArray(r)?g.paths=r:"object"==typeof r&&(g.paths=Array.isArray(r.paths)?r.paths:"auto",g.maxAge=t.isPrimitive(r.maxAge)?r.maxAge:g.maxAge,g.placeholder=r.placeholder||g.placeholder);var i="auto"===g.paths;e.mounted(function(e){p(g),!i&&o(g,n)}),e.doneEach(function(e){d(g,n),i&&o(g,n)})};window.$docsify.plugins=[].concat(v,window.$docsify.plugins)}();
this.D=this.D||{},function(){"use strict";function e(e){var n={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;","/":"&#x2F;"};return String(e).replace(/[&<>"'\/]/g,function(e){return n[e]})}function n(){var e=[];return d.dom.findAll("a").map(function(n){var t=n.href,r=n.getAttribute("href"),i=d.route.parse(t).path;i&&e.indexOf(i)===-1&&!d.route.isAbsolutePath(r)&&e.push(i)}),e}function t(e){localStorage.setItem("docsify.search.expires",Date.now()+e),localStorage.setItem("docsify.search.index",JSON.stringify(f))}function r(e,n){void 0===n&&(n="");var t,r=window.marked.lexer(n),i=Docsify.route.toURL,o={};return r.forEach(function(n){if("heading"===n.type&&n.depth<=2)t=i(e,{id:n.text}),o[t]={slug:t,title:n.text,body:""};else{if(!t)return;o[t]?o[t].body?o[t].body+="\n"+(n.text||""):o[t].body=n.text:o[t]={slug:t,title:"",body:""}}}),o}function i(n){var t=[],r=[];Object.keys(f).forEach(function(e){r=r.concat(Object.keys(f[e]).map(function(n){return f[e][n]}))}),n=n.trim().split(/[\s\-\\\\/]+/);for(var i=function(i){var o=r[i],a=!1,s="",c=o.title&&o.title.trim(),l=o.body&&o.body.trim(),p=o.slug||"";if(c&&l&&(n.forEach(function(n,t){var r=new RegExp(n,"gi"),i=-1,o=-1;if(i=c&&c.search(r),o=l&&l.search(r),i<0&&o<0)a=!1;else{a=!0,o<0&&(o=0);var p=0,u=0;p=o<11?0:o-10,u=0===p?70:o+n.length+60,u>l.length&&(u=l.length);var d="..."+e(l).substring(p,u).replace(r,'<em class="search-keyword">'+n+"</em>")+"...";s+=d}}),a)){var u={title:e(c),content:s,url:p};t.push(u)}},o=0;o<r.length;o++)i(o);return t}function o(e,i){d=Docsify;var o="auto"===e.paths,a=localStorage.getItem("docsify.search.expires")<Date.now();if(f=JSON.parse(localStorage.getItem("docsify.search.index")),a)f={};else if(!o)return;var s=o?n():e.paths,c=s.length,l=0;s.forEach(function(n){return f[n]?l++:void d.get(i.$getFile(n)).then(function(i){f[n]=r(n,i),c===++l&&t(e.maxAge)})})}function a(){var e="\n.sidebar {\n padding-top: 0;\n}\n\n.search {\n margin-bottom: 20px;\n padding: 6px;\n border-bottom: 1px solid #eee;\n}\n\n.search .results-panel {\n display: none;\n}\n\n.search .results-panel.show {\n display: block;\n}\n\n.search input {\n outline: none;\n border: none;\n width: 100%;\n padding: 7px;\n line-height: 22px;\n font-size: 14px;\n}\n\n.search h2 {\n font-size: 17px;\n margin: 10px 0;\n}\n\n.search a {\n text-decoration: none;\n color: inherit;\n}\n\n.search .matching-post {\n border-bottom: 1px solid #eee;\n}\n\n.search .matching-post:last-child {\n border-bottom: 0;\n}\n\n.search p {\n font-size: 14px;\n overflow: hidden;\n text-overflow: ellipsis;\n display: -webkit-box;\n -webkit-line-clamp: 2;\n -webkit-box-orient: vertical;\n}\n\n.search p.empty {\n text-align: center;\n}",n=h.create("style",e);h.appendTo(h.head,n)}function s(e){var n='<input type="search" /><div class="results-panel"></div></div>',t=h.create("div",n),r=h.find("aside");h.toggleClass(t,"search"),h.before(r,t)}function c(){var e,n=h.find("div.search"),t=h.find(n,"input"),r=h.find(n,".results-panel"),o=function(e){if(!e)return r.classList.remove("show"),void(r.innerHTML="");var n=i(e),t="";n.forEach(function(e){t+='<div class="matching-post">\n <h2><a href="'+e.url+'">'+e.title+"</a></h2>\n <p>"+e.content+"</p>\n</div>"}),r.classList.add("show"),r.innerHTML=t||'<p class="empty">No Results!</p>'};h.on(n,"click",function(e){return"A"!==e.target.tagName&&e.stopPropagation()}),h.on(t,"input",function(n){clearTimeout(e),e=setTimeout(function(e){return o(n.target.value.trim())},200)})}function l(e,n){var t=h.getNode('.search input[type="search"]');if("string"==typeof e)t.placeholder=e;else{var r=Object.keys(e).find(function(e){return n.indexOf(e)>-1});t.placeholder=e[r]}}function p(e){h=Docsify.dom,a(),s(e),c()}function u(e,n){l(e.placeholder,n.route.path)}var d,h,f={},g={placeholder:"Type to search",paths:"auto",maxAge:864e5},m=function(e,n){var t=Docsify.util,r=n.config.search||g;Array.isArray(r)?g.paths=r:"object"==typeof r&&(g.paths=Array.isArray(r.paths)?r.paths:"auto",g.maxAge=t.isPrimitive(r.maxAge)?r.maxAge:g.maxAge,g.placeholder=r.placeholder||g.placeholder);var i="auto"===g.paths;e.mounted(function(e){p(g),!i&&o(g,n)}),e.doneEach(function(e){u(g,n),i&&o(g,n)})};window.$docsify.plugins=[].concat(m,window.$docsify.plugins)}();