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){ if(this.props.content === text){ this.props.needSavingUpdate(false); }else{ this.props.needSavingUpdate(true); } this.setState({contentToSave: text}) } save(){ if(this.props.needSaving === false) return; 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.props.needSavingUpdate(false)) } render(){ return (