import React from 'react'; import ReactCSSTransitionGroup from 'react-addons-css-transition-group'; import { NgIf, Fab, Icon } from '../../components/'; import { Editor } from './editor'; import { MenuBar } from './menubar'; import './ide.scss'; export class IDE extends React.Component { constructor(props){ super(props); this.state = { contentToSave: props.content, needSaving: false }; } onContentUpdate(text){ this.props.needSaving(true); this.setState({contentToSave: text, needSaving: true}); } save(){ let file, blob = new window.Blob([this.state.contentToSave], {type : 'text/plain'}); try{ file = new window.File([blob], 'test.txt'); }catch(err){ // for crappy browser: // https://stackoverflow.com/questions/33821631/alternative-for-file-constructor-for-safari file = blob; } this.props.onSave(file) .then(() => this.setState({needSaving: false})); } render(){ return (