Commit 3e7d6ab 1 parent 4b64386 commit 3e7d6ab Copy full SHA for 3e7d6ab
File tree 6 files changed +125
-4
lines changed
6 files changed +125
-4
lines changed Original file line number Diff line number Diff line change @@ -267,3 +267,25 @@ window.$docsify = {
267
267
autoHeader: true
268
268
}
269
269
```
270
+
271
+ ## execute-script
272
+
273
+ - type: ` Boolean `
274
+
275
+ Execute the script on the page. Only parse the first script tag([ demo] ( themes ) ). If Vue is present, it is turned on by default.
276
+
277
+ ``` js
278
+ window .$docsify = {
279
+ executeScript: true
280
+ }
281
+ ```
282
+
283
+ ``` markdown
284
+ ## This is test
285
+
286
+ <script>
287
+ console.log(2333)
288
+ </script>
289
+
290
+ ```
291
+
Original file line number Diff line number Diff line change @@ -12,3 +12,37 @@ There are currently three themes available. Copy [Vue](//vuejs.org) and [buble](
12
12
!> This compressed files in ` /lib/themes/ ` .
13
13
14
14
If you have any ideas or would like to develop new theme, welcome submit [ PR] ( https://github.com/QingWei-Li/docsify/pulls ) .
15
+
16
+ #### Click to preview
17
+
18
+
19
+ <div class =" demo-theme-preview " >
20
+ <a data-theme =" vue " >vue.css</a >
21
+ <a data-theme =" buble " >buble.css</a >
22
+ <a data-theme =" dark " >dark.css</a >
23
+ </div >
24
+
25
+
26
+ <style >
27
+ .demo-theme-preview a {
28
+ padding-right : 10px ;
29
+ }
30
+
31
+ .demo-theme-preview a :hover {
32
+ text-decoration : underline ;
33
+ cursor : pointer ;
34
+ }
35
+ </style >
36
+
37
+ <script >
38
+ var preview = Docsify .dom .find (' .demo-theme-preview' );
39
+ var themes = Docsify .dom .findAll (' [rel="stylesheet"]' );
40
+
41
+ preview .onclick = function (e ) {
42
+ var title = e .target .getAttribute (' data-theme' )
43
+
44
+ themes .forEach (function (theme ) {
45
+ theme .disabled = theme .title !== title
46
+ });
47
+ };
48
+ </script >
Original file line number Diff line number Diff line change @@ -265,3 +265,25 @@ window.$docsify = {
265
265
autoHeader: true
266
266
}
267
267
```
268
+
269
+ ## execute-script
270
+
271
+ - 类型:` Boolean `
272
+
273
+ 执行文档里的 script 标签里的脚本,只执行第一个 script ([ demo] ( zh-cn/themes ) )。 如果 Vue 存在,则自动开启。
274
+
275
+ ``` js
276
+ window .$docsify = {
277
+ executeScript: true
278
+ }
279
+ ```
280
+
281
+ ``` markdown
282
+ ## This is test
283
+
284
+ <script>
285
+ console.log(2333)
286
+ </script>
287
+
288
+ ```
289
+
Original file line number Diff line number Diff line change 8
8
<link rel =" stylesheet" href =" //unpkg.com/docsify/themes/dark.css" >
9
9
```
10
10
11
+ <a id =" demo-theme-vue " >vue.css</a >
12
+ <a id =" demo-theme-buble " >buble.css</a >
13
+ <a id =" demo-theme-dark " >dark.css</a >
14
+
11
15
!> CSS 的压缩文件位于 ` /lib/themes/ `
12
16
13
- 如果你有其他想法或者想开发别的主题,欢迎提 [ PR] ( https://github.com/QingWei-Li/docsify/pulls ) 。
17
+ 如果你有其他想法或者想开发别的主题,欢迎提 [ PR] ( https://github.com/QingWei-Li/docsify/pulls ) 。
18
+
19
+ #### 点击切换主题
20
+
21
+
22
+ <div class =" demo-theme-preview " >
23
+ <a data-theme =" vue " >vue.css</a >
24
+ <a data-theme =" buble " >buble.css</a >
25
+ <a data-theme =" dark " >dark.css</a >
26
+ </div >
27
+
28
+
29
+ <style >
30
+ .demo-theme-preview a {
31
+ padding-right : 10px ;
32
+ }
33
+
34
+ .demo-theme-preview a :hover {
35
+ text-decoration : underline ;
36
+ cursor : pointer ;
37
+ }
38
+ </style >
39
+
40
+ <script >
41
+ var preview = Docsify .dom .find (' .demo-theme-preview' );
42
+ var themes = Docsify .dom .findAll (' [rel="stylesheet"]' );
43
+
44
+ preview .onclick = function (e ) {
45
+ var title = e .target .getAttribute (' data-theme' )
46
+
47
+ themes .forEach (function (theme ) {
48
+ theme .disabled = theme .title !== title
49
+ });
50
+ };
51
+ </script >
Original file line number Diff line number Diff line change @@ -15,6 +15,7 @@ const config = merge({
15
15
themeColor : '' ,
16
16
nameLink : window . location . pathname ,
17
17
autoHeader : false ,
18
+ executeScript : false ,
18
19
ga : ''
19
20
} , window . $docsify )
20
21
Original file line number Diff line number Diff line change @@ -14,7 +14,9 @@ function executeScript () {
14
14
const code = script . innerText . trim ( )
15
15
if ( ! code ) return false
16
16
17
- window . __EXECUTE_RESULT__ = new Function ( 'return ' + code ) ( )
17
+ setTimeout ( _ => {
18
+ window . __EXECUTE_RESULT__ = new Function ( code ) ( )
19
+ } , 0 )
18
20
}
19
21
20
22
function renderMain ( html ) {
@@ -31,11 +33,13 @@ function renderMain (html) {
31
33
if ( ! this . config . executeScript &&
32
34
typeof window . Vue !== 'undefined' &&
33
35
! executeScript ( ) ) {
34
- window . __EXECUTE_RESULT__ = new window . Vue ( ) . $mount ( '#main' )
36
+ setTimeout ( _ => {
37
+ window . __EXECUTE_RESULT__ = new window . Vue ( ) . $mount ( '#main' )
38
+ } , 0 )
35
39
}
36
40
37
41
if ( this . config . auto2top ) {
38
- setTimeout ( ( ) => scroll2Top ( this . config . auto2top ) , 0 )
42
+ scroll2Top ( this . config . auto2top )
39
43
}
40
44
}
41
45
You can’t perform that action at this time.
0 commit comments