mirror of
https://github.com/wahyd4/docsify.git
synced 2026-08-09 13:26:34 +10:00
Compare commits
34
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
957609a209 | ||
|
|
60b7f89b37 | ||
|
|
9e62be9d00 | ||
|
|
a2be53aea7 | ||
|
|
ab597ca8e0 | ||
|
|
154abf59a6 | ||
|
|
f3a7929f07 | ||
|
|
d08d1dd9bb | ||
|
|
0eb9708225 | ||
|
|
378f151478 | ||
|
|
643850907c | ||
|
|
b1acfe458c | ||
|
|
d3ec14f06f | ||
|
|
8d84bc8562 | ||
|
|
bbcee36106 | ||
|
|
184ff51774 | ||
|
|
b62a0c8f3e | ||
|
|
a137d38416 | ||
|
|
b4b1033f69 | ||
|
|
9afa66607d | ||
|
|
406670c3d6 | ||
|
|
1811842979 | ||
|
|
b7e81f7ff4 | ||
|
|
5f86454175 | ||
|
|
df8a248678 | ||
|
|
86df3bb32d | ||
|
|
ec0409969e | ||
|
|
9981c4361a | ||
|
|
39ebd73021 | ||
|
|
78290b2103 | ||
|
|
5d541dd7d4 | ||
|
|
0f1749cb66 | ||
|
|
291c99bc38 | ||
|
|
b53ea1e304 |
@@ -7,6 +7,7 @@ about: Create a report to help us improve
|
||||
<!-- Please use English language -->
|
||||
<!-- Before creating an issue please make sure you are using the latest version of Docsify. -->
|
||||
<!-- Please ask questions on StackOverflow: https://stackoverflow.com/questions/ask?tags=docsify -->
|
||||
<!-- Please ask questions on gitter: https://gitter.im/docsifyjs/Lobby -->
|
||||
|
||||
## Bug Report
|
||||
|
||||
@@ -36,3 +37,9 @@ about: Create a report to help us improve
|
||||
|
||||
<!-- Love docsify? Please consider supporting our collective:
|
||||
👉 https://opencollective.com/docsify/donate -->
|
||||
|
||||
#### Please create a reproducible sandbox
|
||||
|
||||
[](https://codesandbox.io/s/307qqv236)
|
||||
|
||||
#### Mention the docsify version in which this bug was not present (if any)
|
||||
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
tasks:
|
||||
- command: gp await-port 3000 && sleep 3 && gp preview $(gp url 3000)
|
||||
- init: npm install
|
||||
command: npm run dev
|
||||
ports:
|
||||
- port: 3000
|
||||
onOpen: ignore
|
||||
vscode:
|
||||
extensions:
|
||||
- sysoev.language-stylus@1.11.0:xX39oruAJ5UQzTNVRdbBaQ==
|
||||
@@ -1,3 +1,80 @@
|
||||
## [4.11.3](https://github.com/docsifyjs/docsify/compare/v4.11.2...v4.11.3) (2020-03-24)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* fix: digit issue with sidebar (complete REVERT to old method) ([154abf5](https://github.com/docsifyjs/docsify/commit/154abf59a6153e84b018fcdffa86892776d6da7d))
|
||||
|
||||
|
||||
|
||||
## [4.11.2](https://github.com/docsifyjs/docsify/compare/v4.11.1...v4.11.2) (2020-03-09)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* fixed rendering of color in coverpage issue ([406670c](https://github.com/docsifyjs/docsify/commit/406670c3d619a627142900fd45019fb8ce00f60a))
|
||||
|
||||
|
||||
|
||||
## [4.11.1](https://github.com/docsifyjs/docsify/compare/v4.11.0...v4.11.1) (2020-03-09)
|
||||
|
||||
|
||||
|
||||
# [4.11.0](https://github.com/docsifyjs/docsify/compare/v4.10.2...v4.11.0) (2020-03-09)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* emojis in titles not working correctly and update ([#1016](https://github.com/docsifyjs/docsify/issues/1016)) ([b3d9b96](https://github.com/docsifyjs/docsify/commit/b3d9b966dfbb6f456c2c457da1d2a366e85d9190))
|
||||
* searching table content ([6184e50](https://github.com/docsifyjs/docsify/commit/6184e502629932ca71fdd0a1b10150d118f5a7c8))
|
||||
* stage modified files as part of pre-commit hook ([#985](https://github.com/docsifyjs/docsify/issues/985)) ([5b77b0f](https://github.com/docsifyjs/docsify/commit/5b77b0f628f056b7ebb6d0b617561d19964516a2))
|
||||
* config initialization and coercion ([#861](https://github.com/docsifyjs/docsify/pull/861))
|
||||
* strip indent when embedding code fragment ([#996](https://github.com/docsifyjs/docsify/pull/996))
|
||||
* Ensure autoHeader dom result is similar to parsed H1 ([#811](https://github.com/docsifyjs/docsify/pull/811))
|
||||
* upgrade docsify from 4.9.4 to 4.10.2 ([#1054](https://github.com/docsifyjs/docsify/issues/1054)) ([78290b2](https://github.com/docsifyjs/docsify/commit/78290b21038a3ae09c4c7438bd89b14ca4c02805))
|
||||
* upgrade medium-zoom from 1.0.4 to 1.0.5 ([39ebd73](https://github.com/docsifyjs/docsify/commit/39ebd73021290439180878cae32e663b9e60e214))
|
||||
* upgrade prismjs from 1.17.1 to 1.19.0 ([9981c43](https://github.com/docsifyjs/docsify/commit/9981c4361ad690d0ed32cf1fb5b48cc5b9f770bb))
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* configure pre-commit hook ([#983](https://github.com/docsifyjs/docsify/issues/983)) ([eea41a1](https://github.com/docsifyjs/docsify/commit/eea41a1207c46533ea9c6c59d82e2c94aa4dd70e))
|
||||
* Add a prepare script. ([efbea24](https://github.com/docsifyjs/docsify/commit/efbea24de71f2287993b52ed1cef1a2dd6a53f81))
|
||||
* added capability to add css class and id to images + links + refactoring ([#820](https://github.com/docsifyjs/docsify/issues/820)) ([724ac02](https://github.com/docsifyjs/docsify/commit/724ac024ddfc28e93d8b5dd909e722747286fa00))
|
||||
* added dark mode to docs closes [#1031](https://github.com/docsifyjs/docsify/issues/1031) ([dc43d3c](https://github.com/docsifyjs/docsify/commit/dc43d3c512c2f04750e76176c25ece626ae7fe2a))
|
||||
* new option `hideSidebar` ([#1026](https://github.com/docsifyjs/docsify/issues/1026)) ([b7547f1](https://github.com/docsifyjs/docsify/commit/b7547f151e928b3a0eb6a94b2af36023da4fa877))
|
||||
* new option `topMargin` ([#1045](https://github.com/docsifyjs/docsify/pull/1045)) ([8faee03](https://github.com/docsifyjs/docsify/pull/1024/commits/b53ea1e304d3a2782b125c1d8711295d88faee03))
|
||||
|
||||
|
||||
### Docs
|
||||
|
||||
* update docs for the `name` config option ([#992](https://github.com/docsifyjs/docsify/pull/992))
|
||||
* about cache ([#854](https://github.com/docsifyjs/docsify/pull/854))
|
||||
* removed FOSSA badge
|
||||
* documented `__colon__` tip ([#1025](https://github.com/docsifyjs/docsify/pull/1025))
|
||||
|
||||
### Chore
|
||||
|
||||
* Migrate relative links to absolute in embedded markdown ([#867](https://github.com/docsifyjs/docsify/pull/867))
|
||||
* smarter scroll behavior ([#744](https://github.com/docsifyjs/docsify/pull/744))
|
||||
* improve basic layout style ([#884](https://github.com/docsifyjs/docsify/pull/884))
|
||||
* There are currently {three=>four} themes available. ([#892](https://github.com/docsifyjs/docsify/pull/892))
|
||||
* Added a redirect for images to show up in Amplify ([#918](https://github.com/docsifyjs/docsify/pull/918))
|
||||
* removed the escaping of the name of sidebar ([#991](https://github.com/docsifyjs/docsify/pull/991))
|
||||
* Eslint fixes for v4x ([#989](https://github.com/docsifyjs/docsify/pull/989))
|
||||
* added github Actions for CI ([#1000](https://github.com/docsifyjs/docsify/pull/1000))
|
||||
* Add a prepare script. ([#1010](https://github.com/docsifyjs/docsify/pull/1010))
|
||||
* chore(GH-action): using ubuntu 16 and removed node 8 from CI
|
||||
* chore: add config ([#1014](https://github.com/docsifyjs/docsify/pull/1014))
|
||||
* chore(stale): added enhancement label to exemptlabels
|
||||
* chore(stale): added bug label to exemptlabels
|
||||
* .markdown-section max-width 800px to 80% ([#1017](https://github.com/docsifyjs/docsify/pull/1017))
|
||||
* changed the CDN from unpkg to jsDelivr #1020 ([#1022](https://github.com/docsifyjs/docsify/pull/1022))
|
||||
* migrate CI to github, refactore CI and npm scripts, linting fixes ([#1023](https://github.com/docsifyjs/docsify/pull/1023))
|
||||
* chore(readme): added CI badges and fixed the logo issue
|
||||
* added new linter config ([#1028](https://github.com/docsifyjs/docsify/pull/1028))
|
||||
|
||||
|
||||
## [4.10.2](https://github.com/docsifyjs/docsify/compare/v4.10.0...v4.10.2) (2019-12-16)
|
||||
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
<a href="https://www.npmjs.com/package/docsify"><img alt="npm" src="https://img.shields.io/npm/v/docsify.svg?style=flat-square"></a>
|
||||
<a href="https://github.com/QingWei-Li/donate"><img alt="donate" src="https://img.shields.io/badge/%24-donate-ff69b4.svg?style=flat-square"></a>
|
||||
<a href="https://gitter.im/docsifyjs/Lobby?utm_source=share-link&utm_medium=link&utm_campaign=share-link"><img alt="gitter" src="https://img.shields.io/gitter/room/docsifyjs/docsify.svg?style=flat-square"></a>
|
||||
<a href="https://gitpod.io/#https://github.com/docsifyjs/docsify"><img src="https://img.shields.io/badge/Gitpod-ready--to--code-blue?logo=gitpod" alt="Gitpod Ready-to-Code"></a>
|
||||
</p>
|
||||
|
||||
<p align="center">Gold Sponsor via <a href="https://opencollective.com/docsify">Open Collective</a></p>
|
||||
@@ -69,6 +70,18 @@ Move to [awesome-docsify](https://github.com/docsifyjs/awesome-docsify#showcase)
|
||||
|
||||
## Contributing
|
||||
|
||||
### Online one-click setup for Contributing
|
||||
|
||||
You can use Gitpod(A free online VS Code-like IDE) for contributing. With single click it'll launch a workspace and automatically:
|
||||
|
||||
- clone the docsify repo.
|
||||
- install the dependencies.
|
||||
- start `npm run dev`.
|
||||
|
||||
So that you can start straight away.
|
||||
|
||||
[](https://gitpod.io/#https://github.com/docsifyjs/docsify)
|
||||
|
||||
- Fork it!
|
||||
- Create your feature branch: `git checkout -b my-new-feature`
|
||||
- Commit your changes: `git commit -am 'Add some feature'`
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||

|
||||
|
||||
# docsify <small>4.10.2</small>
|
||||
# docsify <small>4.11.3</small>
|
||||
|
||||
> A magical documentation site generator.
|
||||
|
||||
|
||||
@@ -575,3 +575,16 @@ window.$docsify = {
|
||||
```
|
||||
|
||||
> Note: The options with fallbackLanguages didn't work with the `notFoundPage` options.
|
||||
|
||||
## topMargin
|
||||
|
||||
- type: `Number`
|
||||
- default: `0`
|
||||
|
||||
Adds a space on top when scrolling content page to reach the selected section. This is useful in case you have a _sticky-header_ layout and you want to align anchors to the end of your header.
|
||||
|
||||
```js
|
||||
window.$docsify = {
|
||||
topMargin: 90, // default: 0
|
||||
};
|
||||
```
|
||||
Generated
+10
-16
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "docsify",
|
||||
"version": "4.10.2",
|
||||
"version": "4.11.3",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
@@ -2943,9 +2943,9 @@
|
||||
"dev": true
|
||||
},
|
||||
"clipboard": {
|
||||
"version": "2.0.4",
|
||||
"resolved": "https://registry.npmjs.org/clipboard/-/clipboard-2.0.4.tgz",
|
||||
"integrity": "sha512-Vw26VSLRpJfBofiVaFb/I8PVfdI1OxKcYShe6fm0sP/DtmiWQNCjhM/okTvdCo0G+lMMm1rMYbk4IK4x1X+kgQ==",
|
||||
"version": "2.0.6",
|
||||
"resolved": "https://registry.npmjs.org/clipboard/-/clipboard-2.0.6.tgz",
|
||||
"integrity": "sha512-g5zbiixBRk/wyKakSwCKd7vQXDjFnAMGHoEyBogG/bw9kTD9GvdAvaoRR1ALcEzt3pVKxZR0pViekPMIS0QyGg==",
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"good-listener": "^1.2.2",
|
||||
@@ -3606,12 +3606,6 @@
|
||||
"integrity": "sha512-a+EPoD+uZiNfh+5fxw2nO9QwFa6nJe2Or35fGY6Ipw1R3R4AGz1d1TEZrCegvw2YTmZ0jXirGYlzxxpYSHwpEg==",
|
||||
"dev": true
|
||||
},
|
||||
"css.escape": {
|
||||
"version": "1.5.1",
|
||||
"resolved": "https://registry.npmjs.org/css.escape/-/css.escape-1.5.1.tgz",
|
||||
"integrity": "sha1-QuJ9T6BK4y+TGktNQZH6nN3ul8s=",
|
||||
"dev": true
|
||||
},
|
||||
"cssesc": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/cssesc/-/cssesc-2.0.0.tgz",
|
||||
@@ -8923,9 +8917,9 @@
|
||||
"dev": true
|
||||
},
|
||||
"medium-zoom": {
|
||||
"version": "1.0.4",
|
||||
"resolved": "https://registry.npmjs.org/medium-zoom/-/medium-zoom-1.0.4.tgz",
|
||||
"integrity": "sha512-BjE+00gQku3XQfgHDcqyYwQaBtFddzh6Lnj1RZOliqJ9HS0mh/P2IaqVJ25/j9EbnjAUf27mLeLZBRxnd00bfA=="
|
||||
"version": "1.0.5",
|
||||
"resolved": "https://registry.npmjs.org/medium-zoom/-/medium-zoom-1.0.5.tgz",
|
||||
"integrity": "sha512-aLGa6WlTuFKWvH88bqTrY5ztJMN+D0hd8UX6BYc4YSoPayppzETjZUcdVcksgaoQEMg4cZSmXPg846fTp2rjRQ=="
|
||||
},
|
||||
"mem": {
|
||||
"version": "4.3.0",
|
||||
@@ -11208,9 +11202,9 @@
|
||||
}
|
||||
},
|
||||
"prismjs": {
|
||||
"version": "1.17.1",
|
||||
"resolved": "https://registry.npmjs.org/prismjs/-/prismjs-1.17.1.tgz",
|
||||
"integrity": "sha512-PrEDJAFdUGbOP6xK/UsfkC5ghJsPJviKgnQOoxaDbBjwc8op68Quupwt1DeAFoG8GImPhiKXAvvsH7wDSLsu1Q==",
|
||||
"version": "1.19.0",
|
||||
"resolved": "https://registry.npmjs.org/prismjs/-/prismjs-1.19.0.tgz",
|
||||
"integrity": "sha512-IVFtbW9mCWm9eOIaEkNyo2Vl4NnEifis2GQ7/MLRG5TQe6t+4Sj9J5QWI9i3v+SS43uZBlCAOn+zYTVYQcPXJw==",
|
||||
"requires": {
|
||||
"clipboard": "^2.0.0"
|
||||
}
|
||||
|
||||
+3
-4
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "docsify",
|
||||
"version": "4.10.2",
|
||||
"version": "4.11.3",
|
||||
"description": "A magical documentation generator.",
|
||||
"author": {
|
||||
"name": "qingwei-li",
|
||||
@@ -61,9 +61,9 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"marked": "^0.7.0",
|
||||
"medium-zoom": "^1.0.4",
|
||||
"medium-zoom": "^1.0.5",
|
||||
"opencollective-postinstall": "^2.0.2",
|
||||
"prismjs": "^1.15.0",
|
||||
"prismjs": "^1.19.0",
|
||||
"strip-indent": "^3.0.0",
|
||||
"tinydate": "^1.0.0",
|
||||
"tweezer.js": "^1.4.0"
|
||||
@@ -76,7 +76,6 @@
|
||||
"conventional-changelog-cli": "^2.0.25",
|
||||
"copy-dir": "^1.2.0",
|
||||
"cross-env": "^6.0.3",
|
||||
"css.escape": "^1.5.1",
|
||||
"cssnano": "^4.1.10",
|
||||
"cypress": "^3.8.1",
|
||||
"cypress-image-snapshot": "^3.1.1",
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
import { readFileSync } from 'fs';
|
||||
import { resolve, basename } from 'path';
|
||||
import resolvePathname from 'resolve-pathname';
|
||||
import { AbstractHistory } from '../../src/core/router/history/abstract';
|
||||
import { Compiler } from '../../src/core/render/compiler';
|
||||
import { isAbsolutePath } from '../../src/core/router/util';
|
||||
import * as tpl from '../../src/core/render/tpl';
|
||||
import { prerenderEmbed } from '../../src/core/render/embed';
|
||||
import resolvePathname from 'resolve-pathname';
|
||||
import debug from 'debug';
|
||||
import fetch from 'node-fetch';
|
||||
import debug from 'debug';
|
||||
|
||||
function cwd(...args) {
|
||||
return resolve(process.cwd(), ...args);
|
||||
|
||||
+20
-6
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "docsify-server-renderer",
|
||||
"version": "4.10.2",
|
||||
"version": "4.11.2",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
@@ -30,14 +30,15 @@
|
||||
"optional": true
|
||||
},
|
||||
"docsify": {
|
||||
"version": "4.10.2",
|
||||
"resolved": "https://registry.npmjs.org/docsify/-/docsify-4.10.2.tgz",
|
||||
"integrity": "sha512-Y1LbI29X9c4uRVEp7wGOYhy8lDrn47o96or0Dbj+pElxWk1cLYQ5CVYPHnf75P3oM1CrEGIrazac6AjYXaD1kw==",
|
||||
"version": "4.11.2",
|
||||
"resolved": "https://registry.npmjs.org/docsify/-/docsify-4.11.2.tgz",
|
||||
"integrity": "sha512-vQVg+ERdYgrlgLcwTX9FdjUn3xb7PSwaiYopIAmCLraHJCr1e0r8Uzi2vm6XEwTrSrdd6C5j3Eg+QctsOGA4Gg==",
|
||||
"requires": {
|
||||
"marked": "^0.7.0",
|
||||
"medium-zoom": "^1.0.4",
|
||||
"medium-zoom": "^1.0.5",
|
||||
"opencollective-postinstall": "^2.0.2",
|
||||
"prismjs": "^1.15.0",
|
||||
"prismjs": "^1.19.0",
|
||||
"strip-indent": "^3.0.0",
|
||||
"tinydate": "^1.0.0",
|
||||
"tweezer.js": "^1.4.0"
|
||||
}
|
||||
@@ -61,6 +62,11 @@
|
||||
"resolved": "https://registry.npmjs.org/medium-zoom/-/medium-zoom-1.0.5.tgz",
|
||||
"integrity": "sha512-aLGa6WlTuFKWvH88bqTrY5ztJMN+D0hd8UX6BYc4YSoPayppzETjZUcdVcksgaoQEMg4cZSmXPg846fTp2rjRQ=="
|
||||
},
|
||||
"min-indent": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/min-indent/-/min-indent-1.0.0.tgz",
|
||||
"integrity": "sha1-z8RcN+nsDY8KDsPdTvf3w6vjklY="
|
||||
},
|
||||
"ms": {
|
||||
"version": "2.1.2",
|
||||
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz",
|
||||
@@ -95,6 +101,14 @@
|
||||
"integrity": "sha1-DnNQrN7ICxEIUoeG7B1EGNEbOW0=",
|
||||
"optional": true
|
||||
},
|
||||
"strip-indent": {
|
||||
"version": "3.0.0",
|
||||
"resolved": "https://registry.npmjs.org/strip-indent/-/strip-indent-3.0.0.tgz",
|
||||
"integrity": "sha512-laJTa3Jb+VQpaC6DseHhF7dXVqHTfJPCRDaEbid/drOhgitgYku/letMUqOXFoWV0zIIUbjpdH2t+tYj4bQMRQ==",
|
||||
"requires": {
|
||||
"min-indent": "^1.0.0"
|
||||
}
|
||||
},
|
||||
"tiny-emitter": {
|
||||
"version": "2.1.0",
|
||||
"resolved": "https://registry.npmjs.org/tiny-emitter/-/tiny-emitter-2.1.0.tgz",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "docsify-server-renderer",
|
||||
"version": "4.10.2",
|
||||
"version": "4.11.2",
|
||||
"description": "docsify server renderer",
|
||||
"author": {
|
||||
"name": "qingwei-li",
|
||||
@@ -16,7 +16,7 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"debug": "^4.1.1",
|
||||
"docsify": "^4.10.2",
|
||||
"docsify": "^4.11.2",
|
||||
"node-fetch": "^2.6.0",
|
||||
"resolve-pathname": "^3.0.0"
|
||||
}
|
||||
|
||||
@@ -33,6 +33,7 @@ export default function() {
|
||||
routerMode: 'hash',
|
||||
noCompileLinks: [],
|
||||
relativePath: false,
|
||||
topMargin: 0,
|
||||
},
|
||||
window.$docsify
|
||||
);
|
||||
|
||||
+18
-3
@@ -1,11 +1,26 @@
|
||||
import { isMobile } from '../util/env';
|
||||
import { body, on } from '../util/dom';
|
||||
import * as sidebar from './sidebar';
|
||||
import { scrollIntoView } from './scroll';
|
||||
import { scrollIntoView, scroll2Top } from './scroll';
|
||||
|
||||
export function eventMixin(proto) {
|
||||
proto.$resetEvents = function() {
|
||||
scrollIntoView(this.route.path, this.route.query.id);
|
||||
proto.$resetEvents = function(source) {
|
||||
const { auto2top } = this.config;
|
||||
|
||||
(() => {
|
||||
// Rely on the browser's scroll auto-restoration when going back or forward
|
||||
if (source === 'history') {
|
||||
return;
|
||||
}
|
||||
// Scroll to ID if specified
|
||||
if (this.route.query.id) {
|
||||
scrollIntoView(this.route.path, this.route.query.id);
|
||||
}
|
||||
// Scroll to top if a link was clicked and auto2top is enabled
|
||||
if (source === 'navigate') {
|
||||
auto2top && scroll2Top(auto2top);
|
||||
}
|
||||
})();
|
||||
|
||||
if (this.config.loadNavbar) {
|
||||
sidebar.getAndActive(this.router, 'nav');
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { isMobile } from '../util/env';
|
||||
import * as dom from '../util/dom';
|
||||
import config from '../config';
|
||||
import Tweezer from 'tweezer.js';
|
||||
import cssEscape from 'css.escape';
|
||||
|
||||
const nav = {};
|
||||
let hoverOver = false;
|
||||
@@ -9,7 +9,7 @@ let scroller = null;
|
||||
let enableScrollEvent = true;
|
||||
let coverHeight = 0;
|
||||
|
||||
function scrollTo(el) {
|
||||
function scrollTo(el, offset = 0) {
|
||||
if (scroller) {
|
||||
scroller.stop();
|
||||
}
|
||||
@@ -17,7 +17,7 @@ function scrollTo(el) {
|
||||
enableScrollEvent = false;
|
||||
scroller = new Tweezer({
|
||||
start: window.pageYOffset,
|
||||
end: el.getBoundingClientRect().top + window.pageYOffset,
|
||||
end: el.getBoundingClientRect().top + window.pageYOffset - offset,
|
||||
duration: 500,
|
||||
})
|
||||
.on('tick', v => window.scrollTo(0, v))
|
||||
@@ -142,9 +142,9 @@ export function scrollIntoView(path, id) {
|
||||
if (!id) {
|
||||
return;
|
||||
}
|
||||
|
||||
const section = dom.find('#' + cssEscape(id));
|
||||
section && scrollTo(section);
|
||||
const topMargin = config().topMargin;
|
||||
const section = dom.find('#' + id);
|
||||
section && scrollTo(section, topMargin);
|
||||
|
||||
const li = nav[getNavKey(path, id)];
|
||||
const sidebar = dom.getNode('.sidebar');
|
||||
|
||||
@@ -148,7 +148,10 @@ export function fetchMixin(proto) {
|
||||
}
|
||||
};
|
||||
|
||||
proto.$fetch = function(cb = noop) {
|
||||
proto.$fetch = function(
|
||||
cb = noop,
|
||||
$resetEvents = this.$resetEvents.bind(this)
|
||||
) {
|
||||
const done = () => {
|
||||
callHook(this, 'doneEach');
|
||||
cb();
|
||||
@@ -160,7 +163,7 @@ export function fetchMixin(proto) {
|
||||
done();
|
||||
} else {
|
||||
this._fetch(() => {
|
||||
this.$resetEvents();
|
||||
$resetEvents();
|
||||
done();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -3,8 +3,8 @@ import * as dom from './util/dom';
|
||||
import { Compiler } from './render/compiler';
|
||||
import { slugify } from './render/slugify';
|
||||
import { get } from './fetch/ajax';
|
||||
import marked from 'marked';
|
||||
import prism from 'prismjs';
|
||||
import marked from 'marked';
|
||||
|
||||
export default function() {
|
||||
window.Docsify = {
|
||||
|
||||
@@ -4,6 +4,7 @@ import { tree as treeTpl } from './tpl';
|
||||
import { genTree } from './gen-tree';
|
||||
import { slugify } from './slugify';
|
||||
import { emojify } from './emojify';
|
||||
import { getAndRemoveConfig } from './utils';
|
||||
import { imageCompiler } from './compiler/image';
|
||||
import { highlightCodeCompiler } from './compiler/code';
|
||||
import { paragraphCompiler } from './compiler/paragraph';
|
||||
@@ -14,27 +15,6 @@ import marked from 'marked';
|
||||
|
||||
const cachedLinks = {};
|
||||
|
||||
export function getAndRemoveConfig(str = '') {
|
||||
const config = {};
|
||||
|
||||
if (str) {
|
||||
str = str
|
||||
.replace(/^'/, '')
|
||||
.replace(/'$/, '')
|
||||
.replace(/(?:^|\s):([\w-]+:?)=?([\w-]+)?/g, (m, key, value) => {
|
||||
if (key.indexOf(':') === -1) {
|
||||
config[key] = (value && value.replace(/"/g, '')) || true;
|
||||
return '';
|
||||
}
|
||||
|
||||
return m;
|
||||
})
|
||||
.trim();
|
||||
}
|
||||
|
||||
return { str, config };
|
||||
}
|
||||
|
||||
const compileMedia = {
|
||||
markdown(url) {
|
||||
return {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { getAndRemoveConfig } from '../compiler';
|
||||
import { getAndRemoveConfig } from '../utils';
|
||||
import { slugify } from './slugify';
|
||||
|
||||
export const headingCompiler = ({ renderer, router, _self }) =>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { getAndRemoveConfig } from '../compiler';
|
||||
import { getAndRemoveConfig } from '../utils';
|
||||
import { isAbsolutePath, getPath, getParentPath } from '../../router/util';
|
||||
|
||||
export const imageCompiler = ({ renderer, contentBase, router }) =>
|
||||
@@ -38,7 +38,11 @@ export const imageCompiler = ({ renderer, contentBase, router }) =>
|
||||
url = getPath(contentBase, getParentPath(router.getCurrentPath()), href);
|
||||
}
|
||||
|
||||
return `<img src="${url}" data-origin="${href}" alt="${text}" ${attrs.join(
|
||||
' '
|
||||
)} />`;
|
||||
if (attrs.length > 0) {
|
||||
return `<img src="${url}" data-origin="${href}" alt="${text}" ${attrs.join(
|
||||
' '
|
||||
)} />`;
|
||||
}
|
||||
|
||||
return `<img src="${url}" data-origin="${href}" alt="${text}"${attrs}>`;
|
||||
});
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { getAndRemoveConfig } from '../compiler';
|
||||
import { getAndRemoveConfig } from '../utils';
|
||||
import { isAbsolutePath } from '../../router/util';
|
||||
|
||||
export const linkCompiler = ({ renderer, router, linkTarget, compilerClass }) =>
|
||||
@@ -19,6 +19,10 @@ export const linkCompiler = ({ renderer, router, linkTarget, compilerClass }) =>
|
||||
|
||||
href = router.toURL(href, null, router.getCurrentPath());
|
||||
} else {
|
||||
if (!isAbsolutePath(href) && href.startsWith('./')) {
|
||||
href =
|
||||
document.URL.replace(/\/(?!.*\/).*/, '/').replace('#/./', '') + href;
|
||||
}
|
||||
attrs.push(href.indexOf('mailto:') === 0 ? '' : `target="${linkTarget}"`);
|
||||
}
|
||||
|
||||
|
||||
@@ -19,6 +19,23 @@ function walkFetchEmbed({ embedTokens, compile, fetch }, cb) {
|
||||
let embedToken;
|
||||
if (text) {
|
||||
if (token.embed.type === 'markdown') {
|
||||
let path = token.embed.url.split('/');
|
||||
path.pop();
|
||||
path = path.join('/');
|
||||
// Resolves relative links to absolute
|
||||
text = text.replace(/\[([^[\]]+)\]\(([^)]+)\)/g, x => {
|
||||
const linkBeginIndex = x.indexOf('(');
|
||||
if (x.substring(linkBeginIndex).startsWith('(.')) {
|
||||
return (
|
||||
x.substring(0, linkBeginIndex) +
|
||||
`(${window.location.protocol}//${window.location.host}${path}/` +
|
||||
x.substring(linkBeginIndex + 1, x.length - 1) +
|
||||
')'
|
||||
);
|
||||
}
|
||||
return x;
|
||||
});
|
||||
|
||||
embedToken = compile.lexer(text);
|
||||
} else if (token.embed.type === 'code') {
|
||||
if (token.embed.fragment) {
|
||||
|
||||
@@ -6,7 +6,7 @@ import { getAndActive, sticky } from '../event/sidebar';
|
||||
import { getPath, isAbsolutePath } from '../router/util';
|
||||
import { isMobile, inBrowser } from '../util/env';
|
||||
import { isPrimitive } from '../util/core';
|
||||
import { scrollActiveSidebar, scroll2Top } from '../event/scroll';
|
||||
import { scrollActiveSidebar } from '../event/scroll';
|
||||
import { Compiler } from './compiler';
|
||||
import * as tpl from './tpl';
|
||||
import { prerenderEmbed } from './embed';
|
||||
@@ -123,7 +123,7 @@ export function renderMixin(proto) {
|
||||
};
|
||||
|
||||
proto._bindEventOnRendered = function(activeEl) {
|
||||
const { autoHeader, auto2top } = this.config;
|
||||
const { autoHeader } = this.config;
|
||||
|
||||
scrollActiveSidebar(this.router);
|
||||
|
||||
@@ -136,8 +136,6 @@ export function renderMixin(proto) {
|
||||
dom.before(main, wrapper.children[0]);
|
||||
}
|
||||
}
|
||||
|
||||
auto2top && scroll2Top(auto2top);
|
||||
};
|
||||
|
||||
proto._renderNav = function(text) {
|
||||
|
||||
@@ -18,7 +18,8 @@ export function slugify(str) {
|
||||
.replace(/<[^>\d]+>/g, '')
|
||||
.replace(re, '')
|
||||
.replace(/\s/g, '-')
|
||||
.replace(/-+/g, '-');
|
||||
.replace(/-+/g, '-')
|
||||
.replace(/^(\d)/, '_$1');
|
||||
let count = cache[slug];
|
||||
|
||||
count = hasOwn.call(cache, slug) ? count + 1 : 0;
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
export function getAndRemoveConfig(str = '') {
|
||||
const config = {};
|
||||
|
||||
if (str) {
|
||||
str = str
|
||||
.replace(/^'/, '')
|
||||
.replace(/'$/, '')
|
||||
.replace(/(?:^|\s):([\w-]+:?)=?([\w-]+)?/g, (m, key, value) => {
|
||||
if (key.indexOf(':') === -1) {
|
||||
config[key] = (value && value.replace(/"/g, '')) || true;
|
||||
return '';
|
||||
}
|
||||
|
||||
return m;
|
||||
})
|
||||
.trim();
|
||||
}
|
||||
|
||||
return { str, config };
|
||||
}
|
||||
@@ -30,7 +30,25 @@ export class HashHistory extends History {
|
||||
}
|
||||
|
||||
onchange(cb = noop) {
|
||||
on('hashchange', cb);
|
||||
// The hashchange event does not tell us if it originated from
|
||||
// a clicked link or by moving back/forward in the history;
|
||||
// therefore we set a `navigating` flag when a link is clicked
|
||||
// to be able to tell these two scenarios apart
|
||||
let navigating = false;
|
||||
|
||||
on('click', e => {
|
||||
const el = e.target.tagName === 'A' ? e.target : e.target.parentNode;
|
||||
|
||||
if (el.tagName === 'A' && !/_blank/.test(el.target)) {
|
||||
navigating = true;
|
||||
}
|
||||
});
|
||||
|
||||
on('hashchange', e => {
|
||||
const source = navigating ? 'navigate' : 'history';
|
||||
navigating = false;
|
||||
cb({ event: e, source });
|
||||
});
|
||||
}
|
||||
|
||||
normalize() {
|
||||
|
||||
@@ -28,11 +28,13 @@ export class HTML5History extends History {
|
||||
e.preventDefault();
|
||||
const url = el.href;
|
||||
window.history.pushState({ key: url }, '', url);
|
||||
cb();
|
||||
cb({ event: e, source: 'navigate' });
|
||||
}
|
||||
});
|
||||
|
||||
on('popstate', cb);
|
||||
on('popstate', e => {
|
||||
cb({ event: e, source: 'history' });
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { supportsPushState } from '../util/env';
|
||||
import * as dom from '../util/dom';
|
||||
import { noop } from '../util/core';
|
||||
import { HashHistory } from './history/hash';
|
||||
import { HTML5History } from './history/html5';
|
||||
|
||||
@@ -31,16 +32,16 @@ export function initRouter(vm) {
|
||||
lastRoute = vm.route;
|
||||
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
router.onchange(_ => {
|
||||
router.onchange(params => {
|
||||
updateRender(vm);
|
||||
vm._updateRender();
|
||||
|
||||
if (lastRoute.path === vm.route.path) {
|
||||
vm.$resetEvents();
|
||||
vm.$resetEvents(params.source);
|
||||
return;
|
||||
}
|
||||
|
||||
vm.$fetch();
|
||||
vm.$fetch(noop, vm.$resetEvents.bind(vm, params.source));
|
||||
lastRoute = vm.route;
|
||||
});
|
||||
}
|
||||
|
||||
@@ -120,6 +120,7 @@ li input[type='checkbox']
|
||||
margin 0 1rem
|
||||
padding 5px 0
|
||||
position relative
|
||||
cursor pointer
|
||||
|
||||
ul
|
||||
background-color #fff
|
||||
@@ -277,8 +278,9 @@ main.hidden
|
||||
transition opacity 0.3s
|
||||
width $sidebar-width - 16px
|
||||
z-index 30
|
||||
cursor pointer
|
||||
|
||||
.sidebar-toggle-button:hover
|
||||
&:hover .sidebar-toggle-button
|
||||
opacity 0.4
|
||||
|
||||
span
|
||||
|
||||
@@ -107,7 +107,7 @@ text
|
||||
|
||||
expectSameDom(
|
||||
output,
|
||||
'<p><img src="http://imageUrl" data-origin="http://imageUrl" alt="alt text" /></p>'
|
||||
'<p><img src="http://imageUrl" data-origin="http://imageUrl" alt="alt text"></p>'
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user