mirror of
https://github.com/wahyd4/docsify.git
synced 2026-08-09 13:26:34 +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 |
@@ -1,9 +1,3 @@
|
||||
sudo: false
|
||||
cache:
|
||||
directories:
|
||||
- $HOME/.yarn-cache
|
||||
language: node_js
|
||||
node_js: stable
|
||||
os:
|
||||
- linux
|
||||
- osx
|
||||
|
||||
@@ -1,3 +1,53 @@
|
||||
<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)
|
||||
|
||||
|
||||
@@ -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.3.0</small>
|
||||
# docsify <small>4.3.4</small>
|
||||
|
||||
> A magical documentation site generator.
|
||||
|
||||
|
||||
@@ -37,6 +37,8 @@ window.$docsify = {
|
||||
// <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: {
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -36,6 +36,8 @@ window.$docsify = {
|
||||
// <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: {
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -37,6 +37,8 @@ window.$docsify = {
|
||||
// <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: {
|
||||
|
||||
@@ -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)
|
||||
|
||||
+130
-6
@@ -80,7 +80,7 @@ var config = merge({
|
||||
mergeNavbar: false,
|
||||
formatUpdated: '',
|
||||
externalLinkTarget: '_blank',
|
||||
routerModel: 'hash',
|
||||
routerMode: 'hash',
|
||||
noCompileLinks: []
|
||||
}, window.$docsify);
|
||||
|
||||
@@ -3031,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) {
|
||||
@@ -3083,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');
|
||||
@@ -3098,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; });
|
||||
@@ -3108,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;
|
||||
@@ -3826,7 +3950,7 @@ initGlobalAPI();
|
||||
/**
|
||||
* Version
|
||||
*/
|
||||
Docsify.version = '4.3.0';
|
||||
Docsify.version = '4.3.4';
|
||||
|
||||
/**
|
||||
* Run 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
Generated
+2649
-406
File diff suppressed because it is too large
Load Diff
+2
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "docsify",
|
||||
"version": "4.3.0",
|
||||
"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.3.0"
|
||||
"version": "4.3.4"
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "docsify-server-renderer",
|
||||
"version": "4.3.0",
|
||||
"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
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user