@ -4,7 +4,6 @@ import ResizeObserver from 'resize-observer-polyfill'
import debounce from 'lodash.debounce'
import debounce from 'lodash.debounce'
import ms from 'ms'
import ms from 'ms'
import { Controlled as CodeMirror } from 'react-codemirror2'
import { Controlled as CodeMirror } from 'react-codemirror2'
import Spinner from 'react-spinner'
import WindowControls from '../components/WindowControls'
import WindowControls from '../components/WindowControls'
import Watermark from '../components/svg/Watermark'
import Watermark from '../components/svg/Watermark'
@ -29,7 +28,6 @@ class Carbon extends PureComponent {
super ( props )
super ( props )
this . state = {
this . state = {
loading : true ,
language : props . config . language
language : props . config . language
}
}
@ -40,7 +38,6 @@ class Carbon extends PureComponent {
}
}
componentDidMount ( ) {
componentDidMount ( ) {
this . setState ( { loading : false } )
this . setState ( handleLanguageChange ( this . props . children , this . props ) )
this . setState ( handleLanguageChange ( this . props . children , this . props ) )
const ro = new ResizeObserver ( entries => {
const ro = new ResizeObserver ( entries => {
@ -90,161 +87,146 @@ class Carbon extends PureComponent {
( this . props . config . backgroundImage && this . props . config . backgroundImageSelection ) ||
( this . props . config . backgroundImage && this . props . config . backgroundImageSelection ) ||
this . props . config . backgroundImage
this . props . config . backgroundImage
let content = (
const content = (
< div >
< div id = "container" >
< Spinner / >
{ config . windowControls ? (
< WindowControls
titleBar = { this . props . titleBar }
theme = { config . windowTheme }
handleTitleBarChange = { this . handleTitleBarChange }
/ >
) : null }
< CodeMirror
className = { ` CodeMirror__container window-theme__ ${ config . windowTheme } ` }
onBeforeChange = { this . onBeforeChange }
value = { this . props . children }
options = { options }
/ >
{ config . watermark && < Watermark / > }
< div id = "container-bg" >
< div className = "white eliminateOnRender" / >
< div className = "alpha eliminateOnRender" / >
< div className = "bg" / >
< / d i v >
< style jsx >
< style jsx >
{ `
{ `
div {
# container {
height : 352 px ;
position : relative ;
min - width : $ { config . widthAdjustment ? '90px' : '680px' } ;
max - width : 1024 px ;
padding : $ { config . paddingVertical } $ { config . paddingHorizontal } ;
}
# container : global ( . watermark ) {
fill - opacity : 0.3 ;
position : absolute ;
z - index : 2 ;
bottom : calc ( $ { config . paddingVertical } + 16 px ) ;
right : calc ( $ { config . paddingHorizontal } + 16 px ) ;
}
# container # container - bg {
position : absolute ;
top : 0 px ;
right : 0 px ;
bottom : 0 px ;
left : 0 px ;
}
# container . white {
background : # fff ;
position : absolute ;
top : 0 px ;
right : 0 px ;
bottom : 0 px ;
left : 0 px ;
}
# container . bg {
$ { this . props . config . backgroundMode === 'image'
? ` background: url( ${ backgroundImage } );
background - size : cover ;
background - repeat : no - repeat ; `
: ` background: ${ this . props . config . backgroundColor || config . backgroundColor } ;
background - size : auto ;
background - repeat : repeat ; ` } position: absolute;
top : 0 px ;
right : 0 px ;
bottom : 0 px ;
left : 0 px ;
}
# container . alpha {
position : absolute ;
top : 0 px ;
right : 0 px ;
bottom : 0 px ;
left : 0 px ;
background : url ( data : image / png ; base64 , iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8 / 9 hAAAAMUlEQVQ4T2NkYGAQYcAP3uCTZhw1gGGYhAGBZIA / nYDCgBDAm9BGDWAAJyRCgLaBCAAgXwixzAS0pgAAAABJRU5ErkJggg == ) ;
}
# container : global ( . cm - s - dracula . CodeMirror - cursor ) {
border - left : solid 2 px # 159588 ;
}
# container : global ( . cm - s - solarized ) {
box - shadow : none ;
}
# container : global ( . cm - s - solarized . cm - s - light ) {
text - shadow : # eee8d5 0 1 px ;
}
# container : global ( . CodeMirror - gutters ) {
background - color : unset ;
border - right : none ;
}
# container : global ( . CodeMirror _ _container ) {
min - width : inherit ;
position : relative ;
z - index : 1 ;
border - radius : 5 px ;
$ { config . dropShadow
? ` box-shadow: 0 ${ config . dropShadowOffsetY } ${
config . dropShadowBlurRadius
} rgba ( 0 , 0 , 0 , 0.55 ) `
: '' } ;
}
# container : global ( . CodeMirror _ _container . CodeMirror ) {
height : auto ;
min - width : inherit ;
padding : 18 px 18 px ;
$ { config . lineNumbers ? 'padding-left: 12px;' : '' } border - radius : 5 px ;
font - family : $ { config . fontFamily } , monospace ! important ;
font - size : $ { config . fontSize } ;
line - height : $ { config . lineHeight } ;
font - variant - ligatures : contextual ;
font - feature - settings : 'calt' 1 ;
user - select : none ;
}
# container : global ( . CodeMirror - scroll ) {
overflow : hidden ! important ;
}
# container : global ( . window - theme _ _sharp > . CodeMirror ) {
border - radius : 0 px ;
}
# container : global ( . window - theme _ _bw > . CodeMirror ) {
border : 2 px solid $ { COLORS . SECONDARY } ;
}
# container : global ( . window - controls + . CodeMirror _ _container > . CodeMirror ) {
padding - top : 48 px ;
}
}
` }
` }
< / s t y l e >
< / s t y l e >
< / d i v >
< / d i v >
)
)
if ( this . state . loading === false ) {
content = (
< div id = "container" >
{ config . windowControls ? (
< WindowControls
titleBar = { this . props . titleBar }
theme = { config . windowTheme }
handleTitleBarChange = { this . handleTitleBarChange }
/ >
) : null }
< CodeMirror
className = { ` CodeMirror__container window-theme__ ${ config . windowTheme } ` }
onBeforeChange = { this . onBeforeChange }
value = { this . props . children }
options = { options }
/ >
{ config . watermark && < Watermark / > }
< div id = "container-bg" >
< div className = "white eliminateOnRender" / >
< div className = "alpha eliminateOnRender" / >
< div className = "bg" / >
< / d i v >
< style jsx >
{ `
# container {
position : relative ;
min - width : $ { config . widthAdjustment ? '90px' : '680px' } ;
max - width : 1024 px ;
padding : $ { config . paddingVertical } $ { config . paddingHorizontal } ;
}
# container : global ( . watermark ) {
fill - opacity : 0.3 ;
position : absolute ;
z - index : 2 ;
bottom : calc ( $ { config . paddingVertical } + 16 px ) ;
right : calc ( $ { config . paddingHorizontal } + 16 px ) ;
}
# container # container - bg {
position : absolute ;
top : 0 px ;
right : 0 px ;
bottom : 0 px ;
left : 0 px ;
}
# container . white {
background : # fff ;
position : absolute ;
top : 0 px ;
right : 0 px ;
bottom : 0 px ;
left : 0 px ;
}
# container . bg {
$ { this . props . config . backgroundMode === 'image'
? ` background: url( ${ backgroundImage } );
background - size : cover ;
background - repeat : no - repeat ; `
: ` background: ${ this . props . config . backgroundColor || config . backgroundColor } ;
background - size : auto ;
background - repeat : repeat ; ` } position: absolute;
top : 0 px ;
right : 0 px ;
bottom : 0 px ;
left : 0 px ;
}
# container . alpha {
position : absolute ;
top : 0 px ;
right : 0 px ;
bottom : 0 px ;
left : 0 px ;
background : url ( data : image / png ; base64 , iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8 / 9 hAAAAMUlEQVQ4T2NkYGAQYcAP3uCTZhw1gGGYhAGBZIA / nYDCgBDAm9BGDWAAJyRCgLaBCAAgXwixzAS0pgAAAABJRU5ErkJggg == ) ;
}
# container : global ( . cm - s - dracula . CodeMirror - cursor ) {
border - left : solid 2 px # 159588 ;
}
# container : global ( . cm - s - solarized ) {
box - shadow : none ;
}
# container : global ( . cm - s - solarized . cm - s - light ) {
text - shadow : # eee8d5 0 1 px ;
}
# container : global ( . CodeMirror - gutters ) {
background - color : unset ;
border - right : none ;
}
# container : global ( . CodeMirror _ _container ) {
min - width : inherit ;
position : relative ;
z - index : 1 ;
border - radius : 5 px ;
$ { config . dropShadow
? ` box-shadow: 0 ${ config . dropShadowOffsetY } ${
config . dropShadowBlurRadius
} rgba ( 0 , 0 , 0 , 0.55 ) `
: '' } ;
}
# container : global ( . CodeMirror _ _container . CodeMirror ) {
height : auto ;
min - width : inherit ;
padding : 18 px 18 px ;
$ { config . lineNumbers ? 'padding-left: 12px;' : '' } border - radius : 5 px ;
font - family : $ { config . fontFamily } , monospace ! important ;
font - size : $ { config . fontSize } ;
line - height : $ { config . lineHeight } ;
font - variant - ligatures : contextual ;
font - feature - settings : 'calt' 1 ;
user - select : none ;
}
# container : global ( . CodeMirror - scroll ) {
overflow : hidden ! important ;
}
# container : global ( . window - theme _ _sharp > . CodeMirror ) {
border - radius : 0 px ;
}
# container : global ( . window - theme _ _bw > . CodeMirror ) {
border : 2 px solid $ { COLORS . SECONDARY } ;
}
# container : global ( . window - controls + . CodeMirror _ _container > . CodeMirror ) {
padding - top : 48 px ;
}
` }
< / s t y l e >
< / d i v >
)
}
return (
return (
< div id = "section" >
< div id = "section" >
< div id = "export-container" ref = { ele => ( this . exportContainerNode = ele ) } >
< div id = "export-container" ref = { ele => ( this . exportContainerNode = ele ) } >