11import React , { PropTypes } from 'react'
22import markdown from 'browser/lib/markdown'
33import _ from 'lodash'
4+ import hljsTheme from 'browser/lib/hljsThemes'
45
56const markdownStyle = require ( '!!css!stylus?sourceMap!./markdown.styl' ) [ 0 ] [ 1 ]
67const { shell } = require ( 'electron' )
@@ -44,6 +45,7 @@ export default class MarkdownPreview extends React.Component {
4445 prevProps . fontFamily !== this . props . fontFamily ||
4546 prevProps . fontSize !== this . props . fontSize ||
4647 prevProps . codeBlockFontFamily !== this . props . codeBlockFontFamily ||
48+ prevProps . codeBlockTheme !== this . props . codeBlockTheme ||
4749 prevProps . lineNumber !== this . props . lineNumber
4850 ) this . rewriteIframe ( )
4951 }
@@ -53,13 +55,14 @@ export default class MarkdownPreview extends React.Component {
5355 el . removeEventListener ( 'click' , goExternal )
5456 } )
5557
56- let { value, fontFamily, fontSize, codeBlockFontFamily, lineNumber } = this . props
58+ let { value, fontFamily, fontSize, codeBlockFontFamily, lineNumber, codeBlockTheme } = this . props
5759 fontFamily = _ . isString ( fontFamily ) && fontFamily . trim ( ) . length > 0
5860 ? [ fontFamily ] . concat ( defaultFontFamily )
5961 : defaultFontFamily
6062 codeBlockFontFamily = _ . isString ( codeBlockFontFamily ) && codeBlockFontFamily . trim ( ) . length > 0
6163 ? [ codeBlockFontFamily ] . concat ( defaultCodeBlockFontFamily )
6264 : defaultCodeBlockFontFamily
65+ codeBlockTheme = hljsTheme ( ) . some ( ( theme ) => theme . name === codeBlockTheme ) ? codeBlockTheme : 'xcode'
6366
6467 this . refs . root . contentWindow . document . head . innerHTML = `
6568 <style>
@@ -86,7 +89,7 @@ export default class MarkdownPreview extends React.Component {
8689 opacity: 0.5;
8790 }
8891 </style>
89- <link rel="stylesheet" href="../node_modules/highlight.js/styles/xcode.css" id="hljs- css">
92+ <link rel="stylesheet" href="../node_modules/highlight.js/styles/${ codeBlockTheme } . css">
9093 <link rel="stylesheet" href="../resources/katex.min.css">
9194 `
9295 this . refs . root . contentWindow . document . body . innerHTML = markdown ( value )
0 commit comments