1
- import React from 'react' ;
2
- import PropTypes from 'prop-types' ;
1
+ import React from "react" ;
3
2
4
3
class Gist extends React . PureComponent {
5
4
componentDidMount ( ) {
6
5
this . _updateIframeContent ( ) ;
7
6
}
8
7
9
- componentDidUpdate ( prevProps , prevState ) {
8
+ componentDidUpdate ( _prevProps , _prevState ) {
10
9
this . _updateIframeContent ( ) ;
11
10
}
12
11
13
12
_defineUrl ( ) {
14
13
const { id, file } = this . props ;
15
14
16
- const fileArg = file ? `?file=${ file } ` : '' ;
15
+ const fileArg = file ? `?file=${ file } ` : "" ;
17
16
18
17
return `https://gist.github.com/${ id } .js${ fileArg } ` ;
19
18
}
@@ -27,9 +26,9 @@ class Gist extends React.PureComponent {
27
26
if ( iframe . contentDocument ) doc = iframe . contentDocument ;
28
27
else if ( iframe . contentWindow ) doc = iframe . contentWindow . document ;
29
28
30
- const gistLink = this . _defineUrl ( )
29
+ const gistLink = this . _defineUrl ( ) ;
31
30
const gistScript = `<script type="text/javascript" src="${ gistLink } "></script>` ;
32
- const styles = ' <style>*{font-size:12px;}</style>' ;
31
+ const styles = " <style>*{font-size:12px;}</style>" ;
33
32
const elementId = file ? `gist-${ id } -${ file } ` : `gist-${ id } ` ;
34
33
const resizeScript = `onload="parent.document.getElementById('${ elementId } ').style.height=document.body.scrollHeight + 'px'"` ;
35
34
const iframeHtml = `<html><head><base target="_parent">${ styles } </head><body ${ resizeScript } >${ gistScript } </body></html>` ;
@@ -44,7 +43,9 @@ class Gist extends React.PureComponent {
44
43
45
44
return (
46
45
< iframe
47
- ref = { ( n ) => { this . iframeNode = n ; } }
46
+ ref = { ( n ) => {
47
+ this . iframeNode = n ;
48
+ } }
48
49
width = "100%"
49
50
frameBorder = { 0 }
50
51
id = { file ? `gist-${ id } -${ file } ` : `gist-${ id } ` }
0 commit comments