Browse Source

Minor updates

simov 3 years ago
parent
commit
2c3246bdb9
6 changed files with 41 additions and 35 deletions
  1. 3 3
      background/storage.js
  2. 1 1
      build/mermaid/build.sh
  3. 10 4
      content/index.css
  4. 25 23
      content/index.js
  5. 2 3
      manifest.chrome.json
  6. 0 1
      popup/index.css

+ 3 - 3
background/storage.js

@@ -48,13 +48,13 @@ md.storage.defaults = (compilers) => {
       width: 'auto',
     },
     content: {
+      autoreload: false,
       emoji: false,
-      scroll: true,
-      toc: false,
       mathjax: false,
-      autoreload: false,
       mermaid: false,
+      scroll: true,
       syntax: true,
+      toc: false,
     },
     origins: {
       'file://': {

+ 1 - 1
build/mermaid/build.sh

@@ -3,4 +3,4 @@
 # set current working directory to directory of the shell script
 cd "$(dirname "$0")"
 
-curl https://cdnjs.cloudflare.com/ajax/libs/mermaid/9.1.6/mermaid.min.js --output ../../vendor/mermaid.min.js
+curl https://cdnjs.cloudflare.com/ajax/libs/mermaid/9.2.2/mermaid.min.js --output ../../vendor/mermaid.min.js

+ 10 - 4
content/index.css

@@ -134,17 +134,23 @@ body._toc-right { padding-right: 300px !important; }
   overflow-x: hidden;
 }
 #_toc ._ul {
-  padding: 0 0 0 20px !important;
+  padding-left: 20px !important;
   margin: 0 !important;
 }
+#_toc > ._ul {
+  padding: 0 0 0 10px !important;
+}
+#_toc > ._ul:first-child {
+  padding-top: 15px !important;
+}
+#_toc > ._ul:last-child {
+  padding-bottom: 15px !important;
+}
 #_toc ._ul a {
   border: 0 !important;
   padding: 5px 10px !important;
   display: block !important;
 }
-#_toc > ._ul {
-  padding: 0 0 0 10px !important;
-}
 
 /*light*/
 ._theme-almond #_toc,

+ 25 - 23
content/index.js

@@ -86,7 +86,11 @@ var oncreate = {
     }
 
     if (state.content.syntax) {
-      setTimeout(() => Prism.highlightAll(), 20)
+      Prism.highlightAll()
+    }
+
+    if (state.content.mathjax) {
+      mj.render()
     }
 
     anchors()
@@ -129,44 +133,42 @@ function mount () {
         $('body').classList.remove('_toc-left', '_toc-right')
       }
       else if (state.html) {
-        if (state.theme) {
-          var loaded = Array.from($('body').classList).filter((name) => /^_theme/.test(name))[0]
-          $('body').classList.remove(loaded)
-          dom.push(m('link#_theme', {
+        var loaded = Array.from($('body').classList).filter((name) => /^_theme/.test(name))[0]
+        $('body').classList.remove(loaded)
+        dom.push(m('link#_theme', {
+          rel: 'stylesheet', type: 'text/css',
+          href: chrome.runtime.getURL(`/themes/${state.theme}.css`),
+        }))
+        $('body').classList.add(`_theme-${state.theme}`)
+
+        if (state.content.syntax) {
+          var prism =
+            state._themes[state.theme] === 'dark' ||
+            (state._themes[state.theme] === 'auto' && window.matchMedia('(prefers-color-scheme: dark)').matches)
+            ? 'prism-okaidia' : 'prism'
+          dom.push(m('link#_prism', {
             rel: 'stylesheet', type: 'text/css',
-            href: chrome.runtime.getURL(`/themes/${state.theme}.css`),
+            href: chrome.runtime.getURL(`/vendor/${prism}.min.css`),
           }))
-          $('body').classList.add(`_theme-${state.theme}`)
+        }
 
-          if (state.content.syntax) {
-            var prism =
-              state._themes[state.theme] === 'dark' ||
-              (state._themes[state.theme] === 'auto' && window.matchMedia('(prefers-color-scheme: dark)').matches)
-              ? 'prism-okaidia' : 'prism'
-            dom.push(m('link#_prism', {
-              rel: 'stylesheet', type: 'text/css',
-              href: chrome.runtime.getURL(`/vendor/${prism}.min.css`),
-            }))
-          }
-          if (state.content.mermaid && loaded && loaded !== `_theme-${state.theme}`) {
-            mmd.refresh()
-          }
+        if (state.content.mermaid && loaded && loaded !== `_theme-${state.theme}`) {
+          mmd.refresh()
         }
+
         dom.push(m('#_html', {oncreate: oncreate.html,
           class: (/github(-dark)?/.test(state.theme) ? 'markdown-body' : 'markdown-theme') +
           (state.themes.width !== 'auto' ? ` _width-${state.themes.width}` : '')
         },
           m.trust(state.html)
         ))
+
         if (state.content.toc && state.toc) {
           dom.push(m('#_toc.tex2jax-ignore', {oncreate: oncreate.toc},
             m.trust(state.toc)
           ))
           $('body').classList.add('_toc-left')
         }
-        if (state.content.mathjax) {
-          mj.render()
-        }
       }
 
       return (dom.length ? dom : m('div'))

+ 2 - 3
manifest.chrome.json

@@ -39,10 +39,9 @@
       ],
       "resources": [
         "/themes/*",
-        "/vendor/mathjax/*",
+        "/vendor/mathjax/es5/output/chtml/fonts/*",
         "/vendor/prism.min.css",
-        "/vendor/prism-okaidia.min.css",
-        "/content/mathjax.js"
+        "/vendor/prism-okaidia.min.css"
       ]
     }
   ],

+ 0 - 1
popup/index.css

@@ -153,7 +153,6 @@ body a.mdc-tab {
   height: 50px;
   background: #afbdc3;
   -webkit-border-radius: 8px;
-  outline: 2px solid #333;
   outline-offset: -2px;
 }
 ::-webkit-scrollbar-thumb:hover {