mirror of
https://github.com/wahyd4/docsify.git
synced 2026-08-10 05:48:18 +10:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2066cb672d | ||
|
|
5b7b60c553 | ||
|
|
388ed3d685 | ||
|
|
e898350a84 | ||
|
|
9c62fb41b8 | ||
|
|
9b73b0bf8a | ||
|
|
9d43051791 | ||
|
|
f0aca1905c | ||
|
|
2959497874 | ||
|
|
5a9921f5e7 | ||
|
|
c9d556d829 | ||
|
|
a0e1ea811a | ||
|
|
f82f41900e | ||
|
|
7a4d9bc5cd | ||
|
|
5e522879dd | ||
|
|
a72e7a3a3f | ||
|
|
26c22a9843 | ||
|
|
4ce118d60f | ||
|
|
3ad1645b90 | ||
|
|
41967fa8fa | ||
|
|
48276db15d | ||
|
|
b67ea62c75 | ||
|
|
f4800e09f1 | ||
|
|
ac10de1c5b | ||
|
|
d6ac7031b0 | ||
|
|
4417f4669d | ||
|
|
b7735066ff | ||
|
|
10045249d3 | ||
|
|
190710733e | ||
|
|
b292d819fc | ||
|
|
7f270f93c6 | ||
|
|
c3a149679a | ||
|
|
5efa763075 | ||
|
|
03a04f7898 | ||
|
|
a88252c6b2 | ||
|
|
2f5f90750a |
@@ -1,9 +1,3 @@
|
||||
sudo: false
|
||||
cache:
|
||||
directories:
|
||||
- $HOME/.yarn-cache
|
||||
language: node_js
|
||||
node_js: stable
|
||||
os:
|
||||
- linux
|
||||
- osx
|
||||
|
||||
@@ -1,3 +1,92 @@
|
||||
<a name="4.3.4"></a>
|
||||
## [4.3.4](https://github.com/QingWei-Li/docsify/compare/v4.3.3...v4.3.4) (2017-09-07)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* scroll position issue, fixed [#234](https://github.com/QingWei-Li/docsify/issues/234) ([388ed3d](https://github.com/QingWei-Li/docsify/commit/388ed3d))
|
||||
|
||||
|
||||
|
||||
<a name="4.3.3"></a>
|
||||
## [4.3.3](https://github.com/QingWei-Li/docsify/compare/v4.3.2...v4.3.3) (2017-09-06)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **buble.css:** tweaks code block style, fixed [#249](https://github.com/QingWei-Li/docsify/issues/249) ([9d43051](https://github.com/QingWei-Li/docsify/commit/9d43051))
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* add doc for react and vue demo box plugin ([#247](https://github.com/QingWei-Li/docsify/issues/247)) ([f0aca19](https://github.com/QingWei-Li/docsify/commit/f0aca19))
|
||||
|
||||
|
||||
|
||||
<a name="4.3.2"></a>
|
||||
## [4.3.2](https://github.com/QingWei-Li/docsify/compare/v4.3.1...v4.3.2) (2017-09-01)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* sidebar highlight ([f82f419](https://github.com/QingWei-Li/docsify/commit/f82f419))
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* add Edit on github plugin (thanks [@njleonzhang](https://github.com/njleonzhang)) ([a0e1ea8](https://github.com/QingWei-Li/docsify/commit/a0e1ea8))
|
||||
|
||||
|
||||
|
||||
<a name="4.3.1"></a>
|
||||
## [4.3.1](https://github.com/QingWei-Li/docsify/compare/v4.2.9...v4.3.1) (2017-08-30)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* **markdown:** supports mermaid [#137](https://github.com/QingWei-Li/docsify/issues/137) ([f4800e0](https://github.com/QingWei-Li/docsify/commit/f4800e0))
|
||||
|
||||
|
||||
|
||||
<a name="4.3.0"></a>
|
||||
# [4.3.0](https://github.com/QingWei-Li/docsify/compare/v4.2.9...v4.3.0) (2017-08-17)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* **markdown:** supports mermaid [#137](https://github.com/QingWei-Li/docsify/issues/137) ([f4800e0](https://github.com/QingWei-Li/docsify/commit/f4800e0))
|
||||
|
||||
|
||||
|
||||
<a name="4.2.9"></a>
|
||||
## [4.2.9](https://github.com/QingWei-Li/docsify/compare/v4.2.8...v4.2.9) (2017-08-15)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* ensure document ready before init Docsify [#233](https://github.com/QingWei-Li/docsify/issues/233)
|
||||
|
||||
<a name="4.2.8"></a>
|
||||
## [4.2.8](https://github.com/QingWei-Li/docsify/compare/v4.2.7...v4.2.8) (2017-08-10)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* **compiler:** support for setting target attribute for link, fixed [#230](https://github.com/QingWei-Li/docsify/issues/230) ([7f270f9](https://github.com/QingWei-Li/docsify/commit/7f270f9))
|
||||
|
||||
|
||||
|
||||
<a name="4.2.7"></a>
|
||||
## [4.2.7](https://github.com/QingWei-Li/docsify/compare/v4.2.4...v4.2.7) (2017-08-05)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **release:** release shell ([628e211](https://github.com/QingWei-Li/docsify/commit/628e211))
|
||||
* **style:** nowrap => pre-wrap, fixed [#228](https://github.com/QingWei-Li/docsify/issues/228) ([a88252c](https://github.com/QingWei-Li/docsify/commit/a88252c))
|
||||
|
||||
|
||||
|
||||
<a name="4.2.6"></a>
|
||||
## [4.2.6](https://github.com/QingWei-Li/docsify/compare/v4.2.4...v4.2.6) (2017-07-27)
|
||||
|
||||
|
||||
@@ -75,6 +75,7 @@ These projects are using docsify to generate their sites. Pull requests welcome
|
||||
| [palettify](https://dobromir-hristov.github.io/palettify/) | A color palette effects assistant |
|
||||
| [commitlint](https://marionebl.github.io/commitlint/) | Lint commit messages |
|
||||
| [vue-data-tables](https://github.com/njleonzhang/vue-data-tables/) | A simple and customizable data table,based on vue2 and element-ui. |
|
||||
| [Noty](http://ned.im/noty/) | A Dependency-free notification library |
|
||||
|
||||
## Similar projects
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
loadSidebar: true,
|
||||
coverpage: true,
|
||||
name: 'docsify',
|
||||
subMaxLevel: 0,
|
||||
subMaxLevel: 2,
|
||||
mergeNavbar: true,
|
||||
formatUpdated: '{MM}/{DD} {HH}:{mm}',
|
||||
plugins: [
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||

|
||||
|
||||
# docsify <small>4.2.6</small>
|
||||
# docsify <small>4.3.4</small>
|
||||
|
||||
> A magical documentation site generator.
|
||||
|
||||
|
||||
@@ -49,3 +49,10 @@ You will get `<a href="/demo/">link</a>`html. Do not worry, you can still set ti
|
||||
|
||||
<a href="/demo/" title="title">link</a>
|
||||
```
|
||||
|
||||
## Set target attribute for link
|
||||
|
||||
```md
|
||||
[link](/demo ":target=_blank")
|
||||
[link](/demo2 ":target=_self")
|
||||
```
|
||||
|
||||
@@ -28,3 +28,30 @@ window.$docsify = {
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
## Supports mermaid
|
||||
|
||||
```js
|
||||
// Import mermaid
|
||||
// <link rel="stylesheet" href="//cdn.jsdelivr.net/npm/mermaid/dist/mermaid.min.css">
|
||||
// <script src="//cdn.jsdelivr.net/npm/mermaid/dist/mermaid.min.js"></script>
|
||||
|
||||
mermaid.initialize({ startOnLoad: false });
|
||||
|
||||
window.$docsify = {
|
||||
markdown: {
|
||||
renderer: {
|
||||
code: function(code, lang) {
|
||||
if (lang === "mermaid") {
|
||||
return (
|
||||
'<div class="mermaid">' + mermaid.render(lang, code) + "</div>"
|
||||
);
|
||||
}
|
||||
return this.origin.code.apply(this, arguments);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
@@ -96,3 +96,7 @@ Medium's Bilderzoom. Basierend auf [zoom-image](https://github.com/egoist/zoom-i
|
||||
```html
|
||||
<script src="//unpkg.com/docsify/lib/plugins/zoom-image.min.js"></script>
|
||||
```
|
||||
|
||||
## Edit on github
|
||||
|
||||
Add `Edit on github` button on every pages. provided by 3rd party, check [document](https://github.com/njleonzhang/docsify-edit-on-github)
|
||||
|
||||
@@ -50,3 +50,10 @@ You will get `<a href="/demo/">link</a>`html. Do not worry, you can still set ti
|
||||
<a href="/demo/" title="title">link</a>
|
||||
```
|
||||
|
||||
## Set target attribute for link
|
||||
|
||||
```md
|
||||
[link](/demo ":target=_blank")
|
||||
[link](/demo2 ":target=_self")
|
||||
```
|
||||
|
||||
|
||||
@@ -28,3 +28,28 @@ window.$docsify = {
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Supports mermaid
|
||||
|
||||
```js
|
||||
// Import mermaid
|
||||
// <link rel="stylesheet" href="//cdn.jsdelivr.net/npm/mermaid/dist/mermaid.min.css">
|
||||
// <script src="//cdn.jsdelivr.net/npm/mermaid/dist/mermaid.min.js"></script>
|
||||
|
||||
mermaid.initialize({ startOnLoad: false });
|
||||
|
||||
window.$docsify = {
|
||||
markdown: {
|
||||
renderer: {
|
||||
code: function(code, lang) {
|
||||
if (lang === "mermaid") {
|
||||
return (
|
||||
'<div class="mermaid">' + mermaid.render(lang, code) + "</div>"
|
||||
);
|
||||
}
|
||||
return this.origin.code.apply(this, arguments);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
@@ -96,3 +96,15 @@ Medium's Image Zoom. Based on [zoom-image](https://github.com/egoist/zoom-image)
|
||||
```html
|
||||
<script src="//unpkg.com/docsify/lib/plugins/zoom-image.min.js"></script>
|
||||
```
|
||||
|
||||
## Edit on github
|
||||
|
||||
Add `Edit on github` button on every pages. provided by 3rd party, check [document](https://github.com/njleonzhang/docsify-edit-on-github)
|
||||
|
||||
## Demo code with instant preview and jsfiddle integration
|
||||
|
||||
With this plugin, sample code can be rendered on the page instantly, so that the readers can see the preview immediately.
|
||||
When readers expand the demo box, the source code and description are shown there. if they click the button `Try in Jsfiddle`,
|
||||
`jsfiddle.net` will be open with the code of this sample, which allow readers to revise the code and try on their own.
|
||||
|
||||
[Vue](https://njleonzhang.github.io/docsify-demo-box-vue/) and [React](https://njleonzhang.github.io/docsify-demo-box-react/) are both supported.
|
||||
|
||||
@@ -49,3 +49,10 @@ You will get `<a href="/demo/">link</a>`html. Do not worry, you can still set ti
|
||||
<a href="/demo/" title="title">link</a>
|
||||
```
|
||||
|
||||
|
||||
## Set target attribute for link
|
||||
|
||||
```md
|
||||
[link](/demo ":target=_blank")
|
||||
[link](/demo2 ":target=_self")
|
||||
```
|
||||
|
||||
+27
-1
@@ -27,4 +27,30 @@ window.$docsify = {
|
||||
return marked
|
||||
}
|
||||
}
|
||||
```
|
||||
```
|
||||
|
||||
|
||||
## Supports mermaid
|
||||
|
||||
```js
|
||||
// Import mermaid
|
||||
// <link rel="stylesheet" href="//cdn.jsdelivr.net/npm/mermaid/dist/mermaid.min.css">
|
||||
// <script src="//cdn.jsdelivr.net/npm/mermaid/dist/mermaid.min.js"></script>
|
||||
|
||||
mermaid.initialize({ startOnLoad: false });
|
||||
|
||||
window.$docsify = {
|
||||
markdown: {
|
||||
renderer: {
|
||||
code: function(code, lang) {
|
||||
if (lang === "mermaid") {
|
||||
return (
|
||||
'<div class="mermaid">' + mermaid.render(lang, code) + "</div>"
|
||||
);
|
||||
}
|
||||
return this.origin.code.apply(this, arguments);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
@@ -90,3 +90,8 @@ Medium's 风格的图片缩放插件. 基于 [zoom-image](https://github.com/ego
|
||||
```html
|
||||
<script src="//unpkg.com/docsify/lib/plugins/zoom-image.js"></script>
|
||||
```
|
||||
|
||||
|
||||
## Edit on github
|
||||
|
||||
Add `Edit on github` button on every pages. provided by 3rd party, check [document](https://github.com/njleonzhang/docsify-edit-on-github)
|
||||
|
||||
+160
-12
@@ -80,7 +80,7 @@ var config = merge({
|
||||
mergeNavbar: false,
|
||||
formatUpdated: '',
|
||||
externalLinkTarget: '_blank',
|
||||
routerModel: 'hash',
|
||||
routerMode: 'hash',
|
||||
noCompileLinks: []
|
||||
}, window.$docsify);
|
||||
|
||||
@@ -2817,11 +2817,13 @@ Compiler.prototype._initRenderer = function _initRenderer () {
|
||||
var router = ref.router;
|
||||
var contentBase = ref.contentBase;
|
||||
var _self = this;
|
||||
var origin = {};
|
||||
|
||||
/**
|
||||
* render anchor tag
|
||||
* @link https://github.com/chjj/marked#overriding-renderer-methods
|
||||
*/
|
||||
renderer.heading = function (text, level) {
|
||||
origin.heading = renderer.heading = function (text, level) {
|
||||
var nextToc = { level: level, title: text };
|
||||
|
||||
if (/{docsify-ignore}/g.test(text)) {
|
||||
@@ -2844,14 +2846,14 @@ Compiler.prototype._initRenderer = function _initRenderer () {
|
||||
return ("<h" + level + " id=\"" + slug + "\"><a href=\"" + url + "\" data-id=\"" + slug + "\" class=\"anchor\"><span>" + text + "</span></a></h" + level + ">")
|
||||
};
|
||||
// highlight code
|
||||
renderer.code = function (code, lang) {
|
||||
origin.code = renderer.code = function (code, lang) {
|
||||
if ( lang === void 0 ) lang = '';
|
||||
|
||||
var hl = prism.highlight(code, prism.languages[lang] || prism.languages.markup);
|
||||
|
||||
return ("<pre v-pre data-lang=\"" + lang + "\"><code class=\"lang-" + lang + "\">" + hl + "</code></pre>")
|
||||
};
|
||||
renderer.link = function (href, title, text) {
|
||||
origin.link = renderer.link = function (href, title, text) {
|
||||
var blank = '';
|
||||
|
||||
if (!/:|(\/{2})/.test(href) &&
|
||||
@@ -2863,12 +2865,19 @@ Compiler.prototype._initRenderer = function _initRenderer () {
|
||||
title = title && title.replace(/:ignore/g, '').trim();
|
||||
}
|
||||
|
||||
var target = title && title.match(/:target=\w+/);
|
||||
if (target) {
|
||||
target = target[0];
|
||||
title = title.replace(target, '');
|
||||
blank = ' ' + target.slice(1);
|
||||
}
|
||||
|
||||
if (title) {
|
||||
title = " title=\"" + title + "\"";
|
||||
}
|
||||
return ("<a href=\"" + href + "\"" + (title || '') + blank + ">" + text + "</a>")
|
||||
};
|
||||
renderer.paragraph = function (text) {
|
||||
origin.paragraph = renderer.paragraph = function (text) {
|
||||
if (/^!>/.test(text)) {
|
||||
return helper('tip', text)
|
||||
} else if (/^\?>/.test(text)) {
|
||||
@@ -2876,7 +2885,7 @@ Compiler.prototype._initRenderer = function _initRenderer () {
|
||||
}
|
||||
return ("<p>" + text + "</p>")
|
||||
};
|
||||
renderer.image = function (href, title, text) {
|
||||
origin.image = renderer.image = function (href, title, text) {
|
||||
var url = href;
|
||||
var titleHTML = title ? (" title=\"" + title + "\"") : '';
|
||||
|
||||
@@ -2887,6 +2896,8 @@ Compiler.prototype._initRenderer = function _initRenderer () {
|
||||
return ("<img src=\"" + url + "\" data-origin=\"" + href + "\" alt=\"" + text + "\"" + titleHTML + ">")
|
||||
};
|
||||
|
||||
renderer.origin = origin;
|
||||
|
||||
return renderer
|
||||
};
|
||||
|
||||
@@ -3020,15 +3031,128 @@ function getAndActive (router, el, isParent, autoTitle) {
|
||||
return target
|
||||
}
|
||||
|
||||
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) { descriptor.writable = true; } Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) { defineProperties(Constructor.prototype, protoProps); } if (staticProps) { defineProperties(Constructor, staticProps); } return Constructor; }; }();
|
||||
|
||||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
||||
|
||||
var Tweezer = function () {
|
||||
function Tweezer() {
|
||||
var opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
||||
|
||||
_classCallCheck(this, Tweezer);
|
||||
|
||||
this.duration = opts.duration || 1000;
|
||||
this.ease = opts.easing || this._defaultEase;
|
||||
this.start = opts.start;
|
||||
this.end = opts.end;
|
||||
|
||||
this.frame = null;
|
||||
this.next = null;
|
||||
this.isRunning = false;
|
||||
this.events = {};
|
||||
this.direction = this.start < this.end ? 'up' : 'down';
|
||||
}
|
||||
|
||||
_createClass(Tweezer, [{
|
||||
key: 'begin',
|
||||
value: function begin() {
|
||||
if (!this.isRunning && this.next !== this.end) {
|
||||
this.frame = window.requestAnimationFrame(this._tick.bind(this));
|
||||
}
|
||||
return this;
|
||||
}
|
||||
}, {
|
||||
key: 'stop',
|
||||
value: function stop() {
|
||||
window.cancelAnimationFrame(this.frame);
|
||||
this.isRunning = false;
|
||||
this.frame = null;
|
||||
this.timeStart = null;
|
||||
this.next = null;
|
||||
return this;
|
||||
}
|
||||
}, {
|
||||
key: 'on',
|
||||
value: function on(name, handler) {
|
||||
this.events[name] = this.events[name] || [];
|
||||
this.events[name].push(handler);
|
||||
return this;
|
||||
}
|
||||
}, {
|
||||
key: 'emit',
|
||||
value: function emit(name, val) {
|
||||
var _this = this;
|
||||
|
||||
var e = this.events[name];
|
||||
e && e.forEach(function (handler) {
|
||||
return handler.call(_this, val);
|
||||
});
|
||||
}
|
||||
}, {
|
||||
key: '_tick',
|
||||
value: function _tick(currentTime) {
|
||||
this.isRunning = true;
|
||||
|
||||
var lastTick = this.next || this.start;
|
||||
|
||||
if (!this.timeStart) { this.timeStart = currentTime; }
|
||||
this.timeElapsed = currentTime - this.timeStart;
|
||||
this.next = Math.round(this.ease(this.timeElapsed, this.start, this.end - this.start, this.duration));
|
||||
|
||||
if (this._shouldTick(lastTick)) {
|
||||
this.emit('tick', this.next);
|
||||
this.frame = window.requestAnimationFrame(this._tick.bind(this));
|
||||
} else {
|
||||
this.emit('tick', this.end);
|
||||
this.emit('done', null);
|
||||
}
|
||||
}
|
||||
}, {
|
||||
key: '_shouldTick',
|
||||
value: function _shouldTick(lastTick) {
|
||||
return {
|
||||
up: this.next < this.end && lastTick <= this.next,
|
||||
down: this.next > this.end && lastTick >= this.next
|
||||
}[this.direction];
|
||||
}
|
||||
}, {
|
||||
key: '_defaultEase',
|
||||
value: function _defaultEase(t, b, c, d) {
|
||||
if ((t /= d / 2) < 1) { return c / 2 * t * t + b; }
|
||||
return -c / 2 * (--t * (t - 2) - 1) + b;
|
||||
}
|
||||
}]);
|
||||
|
||||
return Tweezer;
|
||||
}();
|
||||
|
||||
var nav = {};
|
||||
var hoverOver = false;
|
||||
var scroller = null;
|
||||
var enableScrollEvent = true;
|
||||
var coverHeight = 0;
|
||||
|
||||
function scrollTo (el) {
|
||||
if (scroller) { scroller.stop(); }
|
||||
enableScrollEvent = false;
|
||||
scroller = new Tweezer({
|
||||
start: window.scrollY,
|
||||
end: el.getBoundingClientRect().top + window.scrollY,
|
||||
duration: 500
|
||||
})
|
||||
.on('tick', function (v) { return window.scrollTo(0, v); })
|
||||
.on('done', function () { enableScrollEvent = true; scroller = null; })
|
||||
.begin();
|
||||
}
|
||||
|
||||
function highlight () {
|
||||
if (!enableScrollEvent) { return }
|
||||
var sidebar = getNode('.sidebar');
|
||||
var anchors = findAll('.anchor');
|
||||
var wrap = find(sidebar, '.sidebar-nav');
|
||||
var active = find(sidebar, 'li.active');
|
||||
var top = body.scrollTop;
|
||||
var doc = document.documentElement;
|
||||
var top = (doc && doc.scrollTop || document.body.scrollTop) - coverHeight;
|
||||
var last;
|
||||
|
||||
for (var i = 0, len = anchors.length; i < len; i += 1) {
|
||||
@@ -3072,7 +3196,8 @@ function highlight () {
|
||||
}
|
||||
|
||||
function scrollActiveSidebar (router) {
|
||||
if (isMobile) { return }
|
||||
var cover = find('.cover.show');
|
||||
coverHeight = cover ? cover.offsetHeight : 0;
|
||||
|
||||
var sidebar = getNode('.sidebar');
|
||||
var lis = findAll(sidebar, 'li');
|
||||
@@ -3087,9 +3212,11 @@ function scrollActiveSidebar (router) {
|
||||
href = router.parse(href).query.id;
|
||||
}
|
||||
|
||||
nav[decodeURIComponent(href)] = li;
|
||||
if (href) { nav[decodeURIComponent(href)] = li; }
|
||||
}
|
||||
|
||||
if (isMobile) { return }
|
||||
|
||||
off('scroll', highlight);
|
||||
on('scroll', highlight);
|
||||
on(sidebar, 'mouseover', function () { hoverOver = true; });
|
||||
@@ -3097,8 +3224,16 @@ function scrollActiveSidebar (router) {
|
||||
}
|
||||
|
||||
function scrollIntoView (id) {
|
||||
if (!id) { return }
|
||||
|
||||
var section = find('#' + id);
|
||||
section && section.scrollIntoView();
|
||||
section && scrollTo(section);
|
||||
|
||||
var li = nav[id];
|
||||
var sidebar = getNode('.sidebar');
|
||||
var active = find(sidebar, 'li.active');
|
||||
active && active.classList.remove('active');
|
||||
li && li.classList.add('active');
|
||||
}
|
||||
|
||||
var scrollEl = $.scrollingElement || $.documentElement;
|
||||
@@ -3782,6 +3917,19 @@ var initGlobalAPI = function () {
|
||||
window.Prism = prism;
|
||||
};
|
||||
|
||||
/**
|
||||
* Fork https://github.com/bendrucker/document-ready/blob/master/index.js
|
||||
*/
|
||||
function ready (callback) {
|
||||
var state = document.readyState;
|
||||
|
||||
if (state === 'complete' || state === 'interactive') {
|
||||
return setTimeout(callback, 0)
|
||||
}
|
||||
|
||||
document.addEventListener('DOMContentLoaded', callback);
|
||||
}
|
||||
|
||||
function Docsify () {
|
||||
this._init();
|
||||
}
|
||||
@@ -3802,11 +3950,11 @@ initGlobalAPI();
|
||||
/**
|
||||
* Version
|
||||
*/
|
||||
Docsify.version = '4.2.6';
|
||||
Docsify.version = '4.3.4';
|
||||
|
||||
/**
|
||||
* Run Docsify
|
||||
*/
|
||||
setTimeout(function (_) { return new Docsify(); }, 0);
|
||||
ready(function (_) { return new Docsify(); });
|
||||
|
||||
}());
|
||||
|
||||
Vendored
+2
-2
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+1
-1
File diff suppressed because one or more lines are too long
+1
-1
File diff suppressed because one or more lines are too long
Generated
+2649
-406
File diff suppressed because it is too large
Load Diff
+2
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "docsify",
|
||||
"version": "4.2.6",
|
||||
"version": "4.3.4",
|
||||
"description": "A magical documentation generator.",
|
||||
"author": {
|
||||
"name": "qingwei-li",
|
||||
@@ -33,6 +33,7 @@
|
||||
"marked": "^0.3.6",
|
||||
"prismjs": "^1.6.0",
|
||||
"tinydate": "^1.0.0",
|
||||
"tweezer.js": "^1.4.0",
|
||||
"zoom-image": "^0.1.4"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
## Install
|
||||
|
||||
```bash
|
||||
yarn add docsify-server-render
|
||||
yarn add docsify-server-renderer
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
+1
-1
@@ -37,5 +37,5 @@
|
||||
"integrity": "sha1-6DWIAbhrg7F1YNTjw4LXrvIQCUQ="
|
||||
}
|
||||
},
|
||||
"version": "4.2.6"
|
||||
"version": "4.3.4"
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "docsify-server-renderer",
|
||||
"version": "4.2.6",
|
||||
"version": "4.3.4",
|
||||
"description": "docsify server renderer",
|
||||
"author": {
|
||||
"name": "qingwei-li",
|
||||
|
||||
+1
-1
@@ -21,7 +21,7 @@ const config = merge({
|
||||
mergeNavbar: false,
|
||||
formatUpdated: '',
|
||||
externalLinkTarget: '_blank',
|
||||
routerModel: 'hash',
|
||||
routerMode: 'hash',
|
||||
noCompileLinks: []
|
||||
}, window.$docsify)
|
||||
|
||||
|
||||
@@ -1,15 +1,34 @@
|
||||
import { isMobile } from '../util/env'
|
||||
import * as dom from '../util/dom'
|
||||
import Tweezer from 'tweezer.js'
|
||||
|
||||
const nav = {}
|
||||
let hoverOver = false
|
||||
let scroller = null
|
||||
let enableScrollEvent = true
|
||||
let coverHeight = 0
|
||||
|
||||
function scrollTo (el) {
|
||||
if (scroller) scroller.stop()
|
||||
enableScrollEvent = false
|
||||
scroller = new Tweezer({
|
||||
start: window.scrollY,
|
||||
end: el.getBoundingClientRect().top + window.scrollY,
|
||||
duration: 500
|
||||
})
|
||||
.on('tick', v => window.scrollTo(0, v))
|
||||
.on('done', () => { enableScrollEvent = true; scroller = null })
|
||||
.begin()
|
||||
}
|
||||
|
||||
function highlight () {
|
||||
if (!enableScrollEvent) return
|
||||
const sidebar = dom.getNode('.sidebar')
|
||||
const anchors = dom.findAll('.anchor')
|
||||
const wrap = dom.find(sidebar, '.sidebar-nav')
|
||||
let active = dom.find(sidebar, 'li.active')
|
||||
const top = dom.body.scrollTop
|
||||
const doc = document.documentElement
|
||||
const top = (doc && doc.scrollTop || document.body.scrollTop) - coverHeight
|
||||
let last
|
||||
|
||||
for (let i = 0, len = anchors.length; i < len; i += 1) {
|
||||
@@ -53,7 +72,8 @@ function highlight () {
|
||||
}
|
||||
|
||||
export function scrollActiveSidebar (router) {
|
||||
if (isMobile) return
|
||||
const cover = dom.find('.cover.show')
|
||||
coverHeight = cover ? cover.offsetHeight : 0
|
||||
|
||||
const sidebar = dom.getNode('.sidebar')
|
||||
const lis = dom.findAll(sidebar, 'li')
|
||||
@@ -68,9 +88,11 @@ export function scrollActiveSidebar (router) {
|
||||
href = router.parse(href).query.id
|
||||
}
|
||||
|
||||
nav[decodeURIComponent(href)] = li
|
||||
if (href) nav[decodeURIComponent(href)] = li
|
||||
}
|
||||
|
||||
if (isMobile) return
|
||||
|
||||
dom.off('scroll', highlight)
|
||||
dom.on('scroll', highlight)
|
||||
dom.on(sidebar, 'mouseover', () => { hoverOver = true })
|
||||
@@ -78,8 +100,16 @@ export function scrollActiveSidebar (router) {
|
||||
}
|
||||
|
||||
export function scrollIntoView (id) {
|
||||
if (!id) return
|
||||
|
||||
const section = dom.find('#' + id)
|
||||
section && section.scrollIntoView()
|
||||
section && scrollTo(section)
|
||||
|
||||
const li = nav[id]
|
||||
const sidebar = dom.getNode('.sidebar')
|
||||
const active = dom.find(sidebar, 'li.active')
|
||||
active && active.classList.remove('active')
|
||||
li && li.classList.add('active')
|
||||
}
|
||||
|
||||
const scrollEl = dom.$.scrollingElement || dom.$.documentElement
|
||||
|
||||
+14
-1
@@ -5,6 +5,19 @@ import { fetchMixin } from './fetch'
|
||||
import { eventMixin } from './event'
|
||||
import initGlobalAPI from './global-api'
|
||||
|
||||
/**
|
||||
* Fork https://github.com/bendrucker/document-ready/blob/master/index.js
|
||||
*/
|
||||
function ready (callback) {
|
||||
const state = document.readyState
|
||||
|
||||
if (state === 'complete' || state === 'interactive') {
|
||||
return setTimeout(callback, 0)
|
||||
}
|
||||
|
||||
document.addEventListener('DOMContentLoaded', callback)
|
||||
}
|
||||
|
||||
function Docsify () {
|
||||
this._init()
|
||||
}
|
||||
@@ -30,4 +43,4 @@ Docsify.version = '__VERSION__'
|
||||
/**
|
||||
* Run Docsify
|
||||
*/
|
||||
setTimeout(_ => new Docsify(), 0)
|
||||
ready(_ => new Docsify())
|
||||
|
||||
@@ -61,11 +61,13 @@ export class Compiler {
|
||||
const renderer = new marked.Renderer()
|
||||
const { linkTarget, router, contentBase } = this
|
||||
const _self = this
|
||||
const origin = {}
|
||||
|
||||
/**
|
||||
* render anchor tag
|
||||
* @link https://github.com/chjj/marked#overriding-renderer-methods
|
||||
*/
|
||||
renderer.heading = function (text, level) {
|
||||
origin.heading = renderer.heading = function (text, level) {
|
||||
const nextToc = { level, title: text }
|
||||
|
||||
if (/{docsify-ignore}/g.test(text)) {
|
||||
@@ -88,12 +90,12 @@ export class Compiler {
|
||||
return `<h${level} id="${slug}"><a href="${url}" data-id="${slug}" class="anchor"><span>${text}</span></a></h${level}>`
|
||||
}
|
||||
// highlight code
|
||||
renderer.code = function (code, lang = '') {
|
||||
origin.code = renderer.code = function (code, lang = '') {
|
||||
const hl = Prism.highlight(code, Prism.languages[lang] || Prism.languages.markup)
|
||||
|
||||
return `<pre v-pre data-lang="${lang}"><code class="lang-${lang}">${hl}</code></pre>`
|
||||
}
|
||||
renderer.link = function (href, title, text) {
|
||||
origin.link = renderer.link = function (href, title, text) {
|
||||
let blank = ''
|
||||
|
||||
if (!/:|(\/{2})/.test(href) &&
|
||||
@@ -105,12 +107,19 @@ export class Compiler {
|
||||
title = title && title.replace(/:ignore/g, '').trim()
|
||||
}
|
||||
|
||||
let target = title && title.match(/:target=\w+/)
|
||||
if (target) {
|
||||
target = target[0]
|
||||
title = title.replace(target, '')
|
||||
blank = ' ' + target.slice(1)
|
||||
}
|
||||
|
||||
if (title) {
|
||||
title = ` title="${title}"`
|
||||
}
|
||||
return `<a href="${href}"${title || ''}${blank}>${text}</a>`
|
||||
}
|
||||
renderer.paragraph = function (text) {
|
||||
origin.paragraph = renderer.paragraph = function (text) {
|
||||
if (/^!>/.test(text)) {
|
||||
return helperTpl('tip', text)
|
||||
} else if (/^\?>/.test(text)) {
|
||||
@@ -118,7 +127,7 @@ export class Compiler {
|
||||
}
|
||||
return `<p>${text}</p>`
|
||||
}
|
||||
renderer.image = function (href, title, text) {
|
||||
origin.image = renderer.image = function (href, title, text) {
|
||||
let url = href
|
||||
const titleHTML = title ? ` title="${title}"` : ''
|
||||
|
||||
@@ -129,6 +138,8 @@ export class Compiler {
|
||||
return `<img src="${url}" data-origin="${href}" alt="${text}"${titleHTML}>`
|
||||
}
|
||||
|
||||
renderer.origin = origin
|
||||
|
||||
return renderer
|
||||
}
|
||||
|
||||
|
||||
@@ -132,7 +132,7 @@ $sidebar-width: 16rem;
|
||||
border-radius: 3px;
|
||||
font-family: Inconsolata;
|
||||
padding: 0.2em 0.4rem;
|
||||
white-space: pre;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.markdown-section pre {
|
||||
@@ -226,6 +226,7 @@ $sidebar-width: 16rem;
|
||||
overflow: inherit;
|
||||
padding: 20px 0.8em 20px;
|
||||
position: relative;
|
||||
white-space: inherit;
|
||||
}
|
||||
|
||||
.markdown-section code::after, .markdown-section code::before {
|
||||
|
||||
+1
-1
@@ -134,7 +134,7 @@ body {
|
||||
font-size: 0.8rem;
|
||||
margin: 0 2px;
|
||||
padding: 3px 5px;
|
||||
white-space: nowrap;
|
||||
white-space: pre-wrap;
|
||||
}
|
||||
|
||||
.markdown-section pre {
|
||||
|
||||
+1
-1
@@ -145,7 +145,7 @@ body {
|
||||
font-size: 0.8rem;
|
||||
margin: 0 2px;
|
||||
padding: 3px 5px;
|
||||
white-space: nowrap;
|
||||
white-space: pre-wrap;
|
||||
}
|
||||
|
||||
.markdown-section pre {
|
||||
|
||||
Reference in New Issue
Block a user