@@ -43,9 +43,15 @@ const PrismMac = () => {
43
43
loadExternalResource ( '/css/prism-mac-style.css' , 'css' )
44
44
}
45
45
// 加载prism样式
46
- loadPrismThemeCSS ( isDarkMode , prismThemeSwitch , prismThemeDarkPath , prismThemeLightPath , prismThemePrefixPath )
46
+ loadPrismThemeCSS (
47
+ isDarkMode ,
48
+ prismThemeSwitch ,
49
+ prismThemeDarkPath ,
50
+ prismThemeLightPath ,
51
+ prismThemePrefixPath
52
+ )
47
53
// 折叠代码
48
- loadExternalResource ( prismjsAutoLoader , 'js' ) . then ( ( url ) => {
54
+ loadExternalResource ( prismjsAutoLoader , 'js' ) . then ( url => {
49
55
if ( window ?. Prism ?. plugins ?. autoloader ) {
50
56
window . Prism . plugins . autoloader . languages_path = prismjsPath
51
57
}
@@ -62,7 +68,13 @@ const PrismMac = () => {
62
68
/**
63
69
* 加载Prism主题样式
64
70
*/
65
- const loadPrismThemeCSS = ( isDarkMode , prismThemeSwitch , prismThemeDarkPath , prismThemeLightPath , prismThemePrefixPath ) => {
71
+ const loadPrismThemeCSS = (
72
+ isDarkMode ,
73
+ prismThemeSwitch ,
74
+ prismThemeDarkPath ,
75
+ prismThemeLightPath ,
76
+ prismThemePrefixPath
77
+ ) => {
66
78
let PRISM_THEME
67
79
let PRISM_PREVIOUS
68
80
if ( prismThemeSwitch ) {
@@ -73,8 +85,14 @@ const loadPrismThemeCSS = (isDarkMode, prismThemeSwitch, prismThemeDarkPath, pri
73
85
PRISM_THEME = prismThemeLightPath
74
86
PRISM_PREVIOUS = prismThemeDarkPath
75
87
}
76
- const previousTheme = document . querySelector ( `link[href="${ PRISM_PREVIOUS } "]` )
77
- if ( previousTheme && previousTheme . parentNode && previousTheme . parentNode . contains ( previousTheme ) ) {
88
+ const previousTheme = document . querySelector (
89
+ `link[href="${ PRISM_PREVIOUS } "]`
90
+ )
91
+ if (
92
+ previousTheme &&
93
+ previousTheme . parentNode &&
94
+ previousTheme . parentNode . contains ( previousTheme )
95
+ ) {
78
96
previousTheme . parentNode . removeChild ( previousTheme )
79
97
}
80
98
loadExternalResource ( PRISM_THEME , 'css' )
@@ -103,14 +121,17 @@ const renderCollapseCode = (codeCollapse, codeCollapseExpandDefault) => {
103
121
const collapseWrapper = document . createElement ( 'div' )
104
122
collapseWrapper . className = 'collapse-wrapper w-full py-2'
105
123
const panelWrapper = document . createElement ( 'div' )
106
- panelWrapper . className = 'border dark:border-gray-600 rounded-md hover:border-indigo-500 duration-200 transition-colors'
124
+ panelWrapper . className =
125
+ 'border dark:border-gray-600 rounded-md hover:border-indigo-500 duration-200 transition-colors'
107
126
108
127
const header = document . createElement ( 'div' )
109
- header . className = 'flex justify-between items-center px-4 py-2 cursor-pointer select-none'
128
+ header . className =
129
+ 'flex justify-between items-center px-4 py-2 cursor-pointer select-none'
110
130
header . innerHTML = `<h3 class="text-lg font-medium">${ language } </h3><svg class="transition-all duration-200 w-5 h-5 transform rotate-0" viewBox="0 0 20 20" fill="currentColor"><path fill-rule="evenodd" d="M6.293 6.293a1 1 0 0 1 1.414 0L10 8.586l2.293-2.293a1 1 0 0 1 1.414 1.414l-3 3a1 1 0 0 1-1.414 0l-3-3a1 1 0 0 1 0-1.414z" clip-rule="evenodd"/></svg>`
111
131
112
132
const panel = document . createElement ( 'div' )
113
- panel . className = 'invisible h-0 transition-transform duration-200 border-t border-gray-300'
133
+ panel . className =
134
+ 'invisible h-0 transition-transform duration-200 border-t border-gray-300'
114
135
115
136
panelWrapper . appendChild ( header )
116
137
panelWrapper . appendChild ( panel )
@@ -145,7 +166,7 @@ const renderMermaid = async(mermaidCDN) => {
145
166
if ( m . target . className === 'notion-code language-mermaid' ) {
146
167
const chart = m . target . querySelector ( 'code' ) . textContent
147
168
if ( chart && ! m . target . querySelector ( '.mermaid' ) ) {
148
- const mermaidChart = document . createElement ( 'div ' )
169
+ const mermaidChart = document . createElement ( 'pre ' )
149
170
mermaidChart . className = 'mermaid'
150
171
mermaidChart . innerHTML = chart
151
172
m . target . appendChild ( mermaidChart )
@@ -172,7 +193,10 @@ const renderMermaid = async(mermaidCDN) => {
172
193
}
173
194
} )
174
195
if ( document . querySelector ( '#notion-article' ) ) {
175
- observer . observe ( document . querySelector ( '#notion-article' ) , { attributes : true , subtree : true } )
196
+ observer . observe ( document . querySelector ( '#notion-article' ) , {
197
+ attributes : true ,
198
+ subtree : true
199
+ } )
176
200
}
177
201
}
178
202
@@ -234,7 +258,10 @@ const fixCodeLineStyle = () => {
234
258
}
235
259
}
236
260
} )
237
- observer . observe ( document . querySelector ( '#notion-article' ) , { attributes : true , subtree : true } )
261
+ observer . observe ( document . querySelector ( '#notion-article' ) , {
262
+ attributes : true ,
263
+ subtree : true
264
+ } )
238
265
setTimeout ( ( ) => {
239
266
const preCodes = document . querySelectorAll ( 'pre.notion-code' )
240
267
for ( const preCode of preCodes ) {
0 commit comments