hexo-theme-solitude 1.5.9 → 1.5.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/issue_close_question.yml +25 -0
- package/.github/workflows/issue_invalid.yml +18 -0
- package/.github/workflows/issue_question.yml +30 -0
- package/.github/workflows/issue_wontfix.yml +29 -0
- package/_config.yml +7 -9
- package/layout/includes/head/config.pug +6 -5
- package/layout/includes/inject/head.pug +1 -1
- package/layout/includes/page/says.pug +2 -2
- package/package.json +1 -1
- package/plugins.yml +1 -1
- package/scripts/event/cdn.js +1 -2
- package/scripts/event/init.js +1 -6
- package/scripts/event/merge_config.js +203 -0
- package/scripts/filter/default.js +11 -12
- package/scripts/filter/lazyload.js +0 -2
- package/scripts/filter/randomPosts.js +4 -7
- package/scripts/helper/stylus.js +16 -0
- package/scripts/tags/bvideo.js +2 -2
- package/source/css/_global/var.styl +6 -5
- package/source/css/_highlight/color.styl +134 -0
- package/source/css/_highlight/highlight/index.styl +45 -0
- package/source/css/{_widgets/_post/_highlight → _highlight}/index.styl +25 -52
- package/source/css/_highlight/prismjs/diff.styl +80 -0
- package/source/css/_highlight/prismjs/index.styl +15 -0
- package/source/css/_highlight/prismjs/line-number.styl +27 -0
- package/source/css/{_widgets/_post/_highlight → _highlight}/theme/default.styl +4 -2
- package/source/css/{_widgets/_post/_highlight → _highlight}/theme/mac.styl +2 -1
- package/source/css/_page/index.styl +4 -1
- package/source/css/_widgets/_post/content.styl +1 -1
- package/source/css/_widgets/_post/index.styl +0 -2
- package/source/css/index.styl +4 -1
- package/source/img/happy-sticker.png +0 -0
- package/source/js/main.js +90 -59
- package/source/js/utils.js +5 -6
- package/source/css/_widgets/_post/_highlight/theme.styl +0 -68
- /package/source/css/{_widgets/_post/_highlight → _highlight/highlight}/diff.styl +0 -0
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
$highlight_color = hexo-config('highlight.color')
|
|
2
|
+
|
|
3
|
+
if $highlight_color == "default"
|
|
4
|
+
$highlight-comment = #969896
|
|
5
|
+
$highlight-red = #FF5370
|
|
6
|
+
$highlight-orange = #F78C6C
|
|
7
|
+
$highlight-yellow = #FFCB6B
|
|
8
|
+
$highlight-green = #C3E88D
|
|
9
|
+
$highlight-aqua = #89DDFF
|
|
10
|
+
$highlight-blue = #82AAFF
|
|
11
|
+
$highlight-purple = #C792EA
|
|
12
|
+
$highlight-deletion = #BF42BF
|
|
13
|
+
$highlight-addition = #105EDE
|
|
14
|
+
else if $highlight_color == "dark"
|
|
15
|
+
$highlight-comment = #6272A4
|
|
16
|
+
$highlight-red = #FF5370
|
|
17
|
+
$highlight-orange = #F78C6C
|
|
18
|
+
$highlight-yellow = #FFCB6B
|
|
19
|
+
$highlight-green = #C3E88D
|
|
20
|
+
$highlight-aqua = #89DDFF
|
|
21
|
+
$highlight-blue = #82AAFF
|
|
22
|
+
$highlight-purple = #C792EA
|
|
23
|
+
$highlight-deletion = #BF42BF
|
|
24
|
+
$highlight-addition = #105EDE
|
|
25
|
+
else if $highlight_color == "funky"
|
|
26
|
+
$highlight-comment = #6272A4
|
|
27
|
+
$highlight-red = #FF5370
|
|
28
|
+
$highlight-orange = #FFCB6B
|
|
29
|
+
$highlight-yellow = #C3E88D
|
|
30
|
+
$highlight-green = #89DDFF
|
|
31
|
+
$highlight-aqua = #82AAFF
|
|
32
|
+
$highlight-blue = #C792EA
|
|
33
|
+
$highlight-purple = #FF5370
|
|
34
|
+
$highlight-deletion = #F07178
|
|
35
|
+
$highlight-addition = #C3E88D
|
|
36
|
+
else if $highlight_color == "okaidia"
|
|
37
|
+
$highlight-comment = #6272A4
|
|
38
|
+
$highlight-red = #FF5370
|
|
39
|
+
$highlight-orange = #FFCB6B
|
|
40
|
+
$highlight-yellow = #C3E88D
|
|
41
|
+
$highlight-green = #89DDFF
|
|
42
|
+
$highlight-aqua = #82AAFF
|
|
43
|
+
$highlight-blue = #C792EA
|
|
44
|
+
$highlight-purple = #FF5370
|
|
45
|
+
$highlight-deletion = #F07178
|
|
46
|
+
$highlight-addition = #C3E88D
|
|
47
|
+
else if $highlight_color == "tomorrow"
|
|
48
|
+
$highlight-comment = #6272A4
|
|
49
|
+
$highlight-red = #FF5370
|
|
50
|
+
$highlight-orange = #F78C6C
|
|
51
|
+
$highlight-yellow = #FFCB6B
|
|
52
|
+
$highlight-green = #C3E88D
|
|
53
|
+
$highlight-aqua = #89DDFF
|
|
54
|
+
$highlight-blue = #82AAFF
|
|
55
|
+
$highlight-purple = #C792EA
|
|
56
|
+
$highlight-deletion = #BF42BF
|
|
57
|
+
$highlight-addition = #105EDE
|
|
58
|
+
else if $highlight_color == "twilight"
|
|
59
|
+
$highlight-comment = #6272A4
|
|
60
|
+
$highlight-red = #FF5370
|
|
61
|
+
$highlight-orange = #F78C6C
|
|
62
|
+
$highlight-yellow = #FFCB6B
|
|
63
|
+
$highlight-green = #C3E88D
|
|
64
|
+
$highlight-aqua = #89DDFF
|
|
65
|
+
$highlight-blue = #82AAFF
|
|
66
|
+
$highlight-purple = #C792EA
|
|
67
|
+
$highlight-deletion = #BF42BF
|
|
68
|
+
$highlight-addition = #105EDE
|
|
69
|
+
else if $highlight_color == "darcula"
|
|
70
|
+
$highlight-comment = #6272A4
|
|
71
|
+
$highlight-red = #FF5370
|
|
72
|
+
$highlight-orange = #F78C6C
|
|
73
|
+
$highlight-yellow = #FFCB6B
|
|
74
|
+
$highlight-green = #C3E88D
|
|
75
|
+
$highlight-aqua = #89DDFF
|
|
76
|
+
$highlight-blue = #82AAFF
|
|
77
|
+
$highlight-purple = #C792EA
|
|
78
|
+
$highlight-deletion = #BF42BF
|
|
79
|
+
$highlight-addition = #105EDE
|
|
80
|
+
else if $highlight_color == "material"
|
|
81
|
+
$highlight-comment = #546E7A
|
|
82
|
+
$highlight-red = #FF5370
|
|
83
|
+
$highlight-orange = #FFCB6B
|
|
84
|
+
$highlight-yellow = #C3E88D
|
|
85
|
+
$highlight-green = #89DDFF
|
|
86
|
+
$highlight-aqua = #82AAFF
|
|
87
|
+
$highlight-blue = #C792EA
|
|
88
|
+
$highlight-purple = #FF5370
|
|
89
|
+
$highlight-deletion = #F07178
|
|
90
|
+
$highlight-addition = #C3E88D
|
|
91
|
+
else if $highlight_color == "solarized-light"
|
|
92
|
+
$highlight-comment = #93A1A1
|
|
93
|
+
$highlight-red = #DC322F
|
|
94
|
+
$highlight-orange = #CB4B16
|
|
95
|
+
$highlight-yellow = #B58900
|
|
96
|
+
$highlight-green = #859900
|
|
97
|
+
$highlight-aqua = #2AA198
|
|
98
|
+
$highlight-blue = #268BD2
|
|
99
|
+
$highlight-purple = #6C71C4
|
|
100
|
+
$highlight-deletion = #D33682
|
|
101
|
+
$highlight-addition = #859900
|
|
102
|
+
else if $highlight_color == "solarized-dark"
|
|
103
|
+
$highlight-comment = #657B83
|
|
104
|
+
$highlight-red = #DC322F
|
|
105
|
+
$highlight-orange = #CB4B16
|
|
106
|
+
$highlight-yellow = #B58900
|
|
107
|
+
$highlight-green = #859900
|
|
108
|
+
$highlight-aqua = #2AA198
|
|
109
|
+
$highlight-blue = #268BD2
|
|
110
|
+
$highlight-purple = #6C71C4
|
|
111
|
+
$highlight-deletion = #D33682
|
|
112
|
+
$highlight-addition = #859900
|
|
113
|
+
else if $highlight_color == "github"
|
|
114
|
+
$highlight-comment = #969896
|
|
115
|
+
$highlight-red = #D73A49
|
|
116
|
+
$highlight-orange = #BD2C00
|
|
117
|
+
$highlight-yellow = #E5C07B
|
|
118
|
+
$highlight-green = #28A745
|
|
119
|
+
$highlight-aqua = #00A9C0
|
|
120
|
+
$highlight-blue = #0366D6
|
|
121
|
+
$highlight-purple = #6F42C1
|
|
122
|
+
$highlight-deletion = #D73A49
|
|
123
|
+
$highlight-addition = #28A745
|
|
124
|
+
else
|
|
125
|
+
$highlight-comment = #6272A4
|
|
126
|
+
$highlight-red = #FF5370
|
|
127
|
+
$highlight-orange = #F78C6C
|
|
128
|
+
$highlight-yellow = #FFCB6B
|
|
129
|
+
$highlight-green = #C3E88D
|
|
130
|
+
$highlight-aqua = #89DDFF
|
|
131
|
+
$highlight-blue = #82AAFF
|
|
132
|
+
$highlight-purple = #C792EA
|
|
133
|
+
$highlight-deletion = #BF42BF
|
|
134
|
+
$highlight-addition = #105EDE
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
@import "diff"
|
|
2
|
+
figure
|
|
3
|
+
pre
|
|
4
|
+
margin 0
|
|
5
|
+
padding 8px 0
|
|
6
|
+
border none
|
|
7
|
+
table
|
|
8
|
+
display block
|
|
9
|
+
border none
|
|
10
|
+
overflow-y hidden
|
|
11
|
+
overflow-x auto
|
|
12
|
+
|
|
13
|
+
td
|
|
14
|
+
padding 0
|
|
15
|
+
border none
|
|
16
|
+
height 100%
|
|
17
|
+
|
|
18
|
+
&.gutter
|
|
19
|
+
opacity .6
|
|
20
|
+
user-select none
|
|
21
|
+
|
|
22
|
+
pre
|
|
23
|
+
overflow auto
|
|
24
|
+
line-height 1.6
|
|
25
|
+
margin 0
|
|
26
|
+
padding 8px .5rem
|
|
27
|
+
border none
|
|
28
|
+
color var(--efu-secondtext)
|
|
29
|
+
background var(--efu-secondbg)
|
|
30
|
+
border-right var(--style-border-always)
|
|
31
|
+
text-align right
|
|
32
|
+
|
|
33
|
+
&.code
|
|
34
|
+
width 100%
|
|
35
|
+
display flex
|
|
36
|
+
position relative
|
|
37
|
+
|
|
38
|
+
pre
|
|
39
|
+
padding-right .5rem
|
|
40
|
+
padding-left .5rem
|
|
41
|
+
width 100%
|
|
42
|
+
|
|
43
|
+
.line
|
|
44
|
+
&.marked
|
|
45
|
+
background-color: rgba(97, 97, 97, .314)
|
|
@@ -1,3 +1,13 @@
|
|
|
1
|
+
@import "color"
|
|
2
|
+
|
|
3
|
+
@import "theme/" + hexo-config('highlight.theme')
|
|
4
|
+
|
|
5
|
+
if $highlight_enable
|
|
6
|
+
@require "highlight/index.styl"
|
|
7
|
+
|
|
8
|
+
if $prismjs_enable
|
|
9
|
+
@require "prismjs/index.styl"
|
|
10
|
+
|
|
1
11
|
figure
|
|
2
12
|
&:hover
|
|
3
13
|
box-shadow var(--efu-shadow-border-hover)
|
|
@@ -25,11 +35,6 @@ figure
|
|
|
25
35
|
padding 0
|
|
26
36
|
line-height 1.6
|
|
27
37
|
|
|
28
|
-
pre
|
|
29
|
-
margin 0
|
|
30
|
-
padding 8px 0
|
|
31
|
-
border none
|
|
32
|
-
|
|
33
38
|
.highlight-tools
|
|
34
39
|
position relative
|
|
35
40
|
display flex
|
|
@@ -43,6 +48,13 @@ figure
|
|
|
43
48
|
border-bottom var(--style-border-always)
|
|
44
49
|
color var(--efu-fontcolor)
|
|
45
50
|
|
|
51
|
+
&.closed
|
|
52
|
+
.expand
|
|
53
|
+
transition all .3s ease 0s
|
|
54
|
+
|
|
55
|
+
& ~ *
|
|
56
|
+
display none
|
|
57
|
+
|
|
46
58
|
.st-copy-fill
|
|
47
59
|
position absolute
|
|
48
60
|
cursor pointer
|
|
@@ -58,9 +70,6 @@ figure
|
|
|
58
70
|
cursor pointer
|
|
59
71
|
transition transform .3s ease 0s
|
|
60
72
|
|
|
61
|
-
&.closed
|
|
62
|
-
transition all .3s ease 0s
|
|
63
|
-
|
|
64
73
|
.code-lang
|
|
65
74
|
text-transform capitalize
|
|
66
75
|
position absolute
|
|
@@ -97,47 +106,11 @@ figure
|
|
|
97
106
|
i
|
|
98
107
|
color var(--efu-white)
|
|
99
108
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
border none
|
|
109
|
-
height 100%
|
|
110
|
-
|
|
111
|
-
&.gutter
|
|
112
|
-
opacity .6
|
|
113
|
-
user-select none
|
|
114
|
-
|
|
115
|
-
pre
|
|
116
|
-
overflow auto
|
|
117
|
-
line-height 1.6
|
|
118
|
-
margin 0
|
|
119
|
-
padding 8px .5rem
|
|
120
|
-
border none
|
|
121
|
-
color var(--efu-secondtext)
|
|
122
|
-
background var(--efu-secondbg)
|
|
123
|
-
border-right var(--style-border-always)
|
|
124
|
-
text-align right
|
|
125
|
-
|
|
126
|
-
&.code
|
|
127
|
-
width 100%
|
|
128
|
-
display flex
|
|
129
|
-
position relative
|
|
130
|
-
|
|
131
|
-
pre
|
|
132
|
-
padding-right .5rem
|
|
133
|
-
padding-left .5rem
|
|
134
|
-
width 100%
|
|
135
|
-
|
|
136
|
-
.line
|
|
137
|
-
&.marked
|
|
138
|
-
background-color: rgba(97, 97, 97, .314)
|
|
139
|
-
|
|
140
|
-
@import "theme"
|
|
141
|
-
@import "diff"
|
|
142
|
-
|
|
143
|
-
@import "theme/" + hexo-config('hightlight.theme')
|
|
109
|
+
&.expand-done
|
|
110
|
+
display none
|
|
111
|
+
|
|
112
|
+
&:not(.expand-done)
|
|
113
|
+
& ~ table,
|
|
114
|
+
& ~ pre
|
|
115
|
+
overflow: hidden
|
|
116
|
+
height: unit(hexo-config('highlight.limit'), px)
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
pre[class*='language-']
|
|
2
|
+
.token
|
|
3
|
+
&.function,
|
|
4
|
+
&.punctuation
|
|
5
|
+
color $highlight-blue
|
|
6
|
+
|
|
7
|
+
.token.comment,
|
|
8
|
+
.token.prolog,
|
|
9
|
+
.token.doctype,
|
|
10
|
+
.token.cdata
|
|
11
|
+
color $highlight-comment
|
|
12
|
+
|
|
13
|
+
.token.namespace
|
|
14
|
+
opacity: .7
|
|
15
|
+
|
|
16
|
+
.token.operator,
|
|
17
|
+
.token.boolean,
|
|
18
|
+
.token.number
|
|
19
|
+
color: $highlight-orange
|
|
20
|
+
|
|
21
|
+
.token.property
|
|
22
|
+
color: $highlight-yellow
|
|
23
|
+
|
|
24
|
+
.token.tag
|
|
25
|
+
color: $highlight-blue
|
|
26
|
+
|
|
27
|
+
.token.string
|
|
28
|
+
color: $highlight-green
|
|
29
|
+
|
|
30
|
+
.token.selector
|
|
31
|
+
color: $highlight-deletion
|
|
32
|
+
|
|
33
|
+
.token.attr-name
|
|
34
|
+
color: $highlight-orange
|
|
35
|
+
|
|
36
|
+
.token.entity,
|
|
37
|
+
.token.url,
|
|
38
|
+
.language-css .token.string,
|
|
39
|
+
.style .token.string
|
|
40
|
+
color: $highlight-aqua
|
|
41
|
+
|
|
42
|
+
.token.attr-value,
|
|
43
|
+
.token.keyword,
|
|
44
|
+
.token.control,
|
|
45
|
+
.token.directive,
|
|
46
|
+
.token.unit
|
|
47
|
+
color: $highlight-yellow
|
|
48
|
+
|
|
49
|
+
.token.statement,
|
|
50
|
+
.token.regex,
|
|
51
|
+
.token.atrule
|
|
52
|
+
color: $highlight-aqua
|
|
53
|
+
|
|
54
|
+
.token.placeholder,
|
|
55
|
+
.token.variable
|
|
56
|
+
color: $highlight-blue
|
|
57
|
+
|
|
58
|
+
.token.deleted
|
|
59
|
+
text-decoration: line-through
|
|
60
|
+
|
|
61
|
+
.token.inserted
|
|
62
|
+
border-bottom: 1px dotted #202746
|
|
63
|
+
text-decoration: none
|
|
64
|
+
|
|
65
|
+
.token.italic
|
|
66
|
+
font-style: italic
|
|
67
|
+
|
|
68
|
+
.token.important,
|
|
69
|
+
.token.bold
|
|
70
|
+
font-weight: bold
|
|
71
|
+
|
|
72
|
+
.token.important
|
|
73
|
+
color: $highlight-orange
|
|
74
|
+
|
|
75
|
+
.token.entity
|
|
76
|
+
cursor: help
|
|
77
|
+
|
|
78
|
+
pre > code.highlight
|
|
79
|
+
outline: .4em solid $highlight-orange
|
|
80
|
+
outline-offset: .4em
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
@require line-number
|
|
2
|
+
|
|
3
|
+
@require diff
|
|
4
|
+
|
|
5
|
+
#article-container
|
|
6
|
+
pre[class*='language-']
|
|
7
|
+
margin 0
|
|
8
|
+
overflow-x auto
|
|
9
|
+
scrollbar-color var(--hlscrollbar-bg) transparent
|
|
10
|
+
|
|
11
|
+
&::-webkit-scrollbar-thumb
|
|
12
|
+
background var(--hlscrollbar-bg)
|
|
13
|
+
|
|
14
|
+
&:not(.line-numbers)
|
|
15
|
+
padding 10px 20px
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
#article-container
|
|
2
|
+
pre[class*='language-']
|
|
3
|
+
&.line-numbers
|
|
4
|
+
position relative
|
|
5
|
+
|
|
6
|
+
> code
|
|
7
|
+
display block
|
|
8
|
+
position relative
|
|
9
|
+
padding 8px 0 8px 45px
|
|
10
|
+
|
|
11
|
+
.line-numbers-rows
|
|
12
|
+
position absolute
|
|
13
|
+
top 0
|
|
14
|
+
left 0
|
|
15
|
+
color var(--efu-secondtext)
|
|
16
|
+
border-right var(--style-border-always)
|
|
17
|
+
padding 8px 0
|
|
18
|
+
|
|
19
|
+
& > span
|
|
20
|
+
display block
|
|
21
|
+
counter-increment linenumber
|
|
22
|
+
pointer-events none
|
|
23
|
+
text-align center
|
|
24
|
+
|
|
25
|
+
&:before
|
|
26
|
+
padding 0 0.5em
|
|
27
|
+
content counter(linenumber)
|
package/source/css/index.styl
CHANGED
|
Binary file
|
package/source/js/main.js
CHANGED
|
@@ -658,72 +658,103 @@ let sco = {
|
|
|
658
658
|
},
|
|
659
659
|
}
|
|
660
660
|
|
|
661
|
-
|
|
662
|
-
|
|
661
|
+
const AddHighLightTool = () => {
|
|
662
|
+
const highlight = GLOBAL_CONFIG.highlight;
|
|
663
|
+
if (!highlight) return;
|
|
664
|
+
|
|
665
|
+
const {copy, expand, limit, syntax} = highlight;
|
|
666
|
+
const $isPrismjs = syntax === 'prismjs';
|
|
667
|
+
const $isShowTool = highlight.enable || copy || expand || limit;
|
|
668
|
+
const expandClass = !expand === true ? 'closed' : ''
|
|
669
|
+
const $syntaxHighlight = syntax === 'highlight.js' ? document.querySelectorAll('figure.highlight') : document.querySelectorAll('pre[class*="language-"]')
|
|
670
|
+
|
|
671
|
+
if (!(($isShowTool || limit) && $syntaxHighlight.length)) return
|
|
672
|
+
|
|
673
|
+
const copyEle = copy ? `<i class="solitude st-copy-fill copy-button"></i>` : '<i></i>';
|
|
674
|
+
const expandEle = `<i class="solitude st-arrow-down expand"></i>`;
|
|
675
|
+
const limitEle = limit ? `<i class="solitude st-show-line"></i>` : '<i></i>';
|
|
676
|
+
|
|
677
|
+
const alertInfo = (ele, text) => {
|
|
678
|
+
utils.snackbarShow(text, false, 2000);
|
|
679
|
+
}
|
|
680
|
+
|
|
681
|
+
const copyCode = (e) => {
|
|
682
|
+
if (document.queryCommandSupported && document.queryCommandSupported('copy')) {
|
|
683
|
+
document.execCommand('copy')
|
|
684
|
+
alertInfo(e, GLOBAL_CONFIG.lang.copy.success)
|
|
685
|
+
} else {
|
|
686
|
+
alertInfo(e, GLOBAL_CONFIG.lang.copy.error)
|
|
687
|
+
}
|
|
688
|
+
}
|
|
689
|
+
|
|
690
|
+
const copyFn = (e) => {
|
|
691
|
+
const $buttonParent = e.parentNode
|
|
692
|
+
$buttonParent.classList.add('copy-true')
|
|
693
|
+
const selection = window.getSelection()
|
|
694
|
+
const range = document.createRange()
|
|
695
|
+
const preCodeSelector = $isPrismjs ? 'pre code' : 'table .code pre'
|
|
696
|
+
range.selectNodeContents($buttonParent.querySelectorAll(`${preCodeSelector}`)[0])
|
|
697
|
+
selection.removeAllRanges()
|
|
698
|
+
selection.addRange(range)
|
|
699
|
+
copyCode(e.lastChild)
|
|
700
|
+
selection.removeAllRanges()
|
|
701
|
+
$buttonParent.classList.remove('copy-true')
|
|
702
|
+
}
|
|
703
|
+
|
|
704
|
+
const expandClose = (e) => {
|
|
705
|
+
e.classList.toggle('closed')
|
|
706
|
+
}
|
|
707
|
+
|
|
708
|
+
const shrinkEle = function () {
|
|
709
|
+
this.classList.toggle('expand-done')
|
|
710
|
+
}
|
|
711
|
+
|
|
712
|
+
const ToolsFn = function (e) {
|
|
713
|
+
const $target = e.target.classList
|
|
714
|
+
if ($target.contains('expand')) expandClose(this)
|
|
715
|
+
else if ($target.contains('copy-button')) copyFn(this)
|
|
716
|
+
}
|
|
717
|
+
|
|
718
|
+
const createEle = (lang, item, service) => {
|
|
663
719
|
const fragment = document.createDocumentFragment()
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
$expand[0].setAttribute('style', 'display:none')
|
|
677
|
-
}
|
|
678
|
-
} else {
|
|
679
|
-
hlTools.children[0].classList.remove('closed')
|
|
680
|
-
$table.setAttribute('style', 'display:block')
|
|
681
|
-
if ($expand.length !== 0) {
|
|
682
|
-
$expand[0].setAttribute('style', 'display:block')
|
|
683
|
-
}
|
|
684
|
-
if (GLOBAL_CONFIG.hightlight.limit && itemHeight > GLOBAL_CONFIG.hightlight.limit) {
|
|
685
|
-
$table.setAttribute('style', `height: ${GLOBAL_CONFIG.hightlight.limit}px`)
|
|
686
|
-
} else {
|
|
687
|
-
$table.setAttribute('style', `height: auto`)
|
|
688
|
-
}
|
|
689
|
-
}
|
|
690
|
-
expand = !expand
|
|
691
|
-
})
|
|
692
|
-
hlTools.children[2].addEventListener('click', (e) => {
|
|
693
|
-
utils.copy($table.querySelector('.code').innerText)
|
|
694
|
-
})
|
|
695
|
-
const ele = document.createElement('div')
|
|
696
|
-
fragment.appendChild(hlTools)
|
|
697
|
-
const itemHeight = item.clientHeight, $table = item.querySelector('table'),
|
|
698
|
-
$expand = item.getElementsByClassName('code-expand-btn')
|
|
699
|
-
if (GLOBAL_CONFIG.hightlight.limit && itemHeight > GLOBAL_CONFIG.hightlight.limit) {
|
|
700
|
-
$table.setAttribute('style', `height: ${GLOBAL_CONFIG.hightlight.limit}px`)
|
|
720
|
+
|
|
721
|
+
if ($isShowTool) {
|
|
722
|
+
const hlTools = document.createElement('div')
|
|
723
|
+
hlTools.className = `highlight-tools ${expandClass}`
|
|
724
|
+
hlTools.innerHTML = expandEle + lang + copyEle
|
|
725
|
+
utils.addEventListenerPjax(hlTools, 'click', ToolsFn)
|
|
726
|
+
fragment.appendChild(hlTools)
|
|
727
|
+
}
|
|
728
|
+
|
|
729
|
+
if (limit && item.offsetHeight > limit + 30) {
|
|
730
|
+
|
|
731
|
+
const ele = document.createElement('div')
|
|
701
732
|
ele.className = 'code-expand-btn'
|
|
702
|
-
ele.innerHTML =
|
|
703
|
-
|
|
704
|
-
$table.setAttribute('style', `height: ${itemHeight}px`)
|
|
705
|
-
e.target.classList.add('expand-done')
|
|
706
|
-
e.target.setAttribute('style', 'display:none')
|
|
707
|
-
})
|
|
733
|
+
ele.innerHTML = limitEle
|
|
734
|
+
utils.addEventListenerPjax(ele, 'click', shrinkEle)
|
|
708
735
|
fragment.appendChild(ele)
|
|
709
736
|
}
|
|
710
|
-
|
|
711
|
-
if (
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
$expand[0].setAttribute('style', 'display:none')
|
|
716
|
-
}
|
|
737
|
+
|
|
738
|
+
if (service === 'hl') {
|
|
739
|
+
item.insertBefore(fragment, item.firstChild)
|
|
740
|
+
} else {
|
|
741
|
+
item.parentNode.insertBefore(fragment, item)
|
|
717
742
|
}
|
|
718
743
|
}
|
|
719
744
|
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
745
|
+
if ($isPrismjs) {
|
|
746
|
+
$syntaxHighlight.forEach(item => {
|
|
747
|
+
const langName = item.getAttribute('data-language') || 'Code'
|
|
748
|
+
const highlightLangEle = `<div class="code-lang">${langName}</div>`
|
|
749
|
+
utils.wrap(item, 'figure', {class: 'highlight'})
|
|
750
|
+
createEle(highlightLangEle, item)
|
|
751
|
+
})
|
|
752
|
+
} else {
|
|
753
|
+
$syntaxHighlight.forEach(item => {
|
|
723
754
|
let langName = item.getAttribute('class').split(' ')[1]
|
|
724
|
-
if (langName === '
|
|
725
|
-
const highlightLangEle = `<div class="code-lang">${langName
|
|
726
|
-
|
|
755
|
+
if (langName === 'plain' || langName === undefined) langName = 'Code'
|
|
756
|
+
const highlightLangEle = `<div class="code-lang">${langName}</div>`
|
|
757
|
+
createEle(highlightLangEle, item, 'hl')
|
|
727
758
|
})
|
|
728
759
|
}
|
|
729
760
|
}
|
|
@@ -785,7 +816,7 @@ window.refreshFn = () => {
|
|
|
785
816
|
GLOBAL_CONFIG.randomlinks && randomLinksList()
|
|
786
817
|
PAGE_CONFIG.comment && initComment()
|
|
787
818
|
PAGE_CONFIG.toc && toc.init();
|
|
788
|
-
(PAGE_CONFIG.is_post || PAGE_CONFIG.is_page) && ((
|
|
819
|
+
(PAGE_CONFIG.is_post || PAGE_CONFIG.is_page) && ((AddHighLightTool()) || tabs.init())
|
|
789
820
|
PAGE_CONFIG.is_home && showTodayCard()
|
|
790
821
|
GLOBAL_CONFIG.covercolor.enable && coverColor()
|
|
791
822
|
sco.initConsoleState()
|
package/source/js/utils.js
CHANGED
|
@@ -136,12 +136,11 @@ const utils = {
|
|
|
136
136
|
},
|
|
137
137
|
isMobile: () => /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent),
|
|
138
138
|
isHidden: e => 0 === e.offsetHeight && 0 === e.offsetWidth,
|
|
139
|
-
addEventListenerPjax:
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
});
|
|
139
|
+
addEventListenerPjax: (ele, event, fn, option = false) => {
|
|
140
|
+
ele.addEventListener(event, fn, option)
|
|
141
|
+
utils.addGlobalFn('pjax', () => {
|
|
142
|
+
ele.removeEventListener(event, fn, option)
|
|
143
|
+
})
|
|
145
144
|
},
|
|
146
145
|
addGlobalFn: (key, fn, name = false, parent = window) => {
|
|
147
146
|
const globalFn = parent.globalFn || {}
|