<commit_before>/** @jsx React.DOM */
var AceEditor = React.createClass({
	propTypes: {
		onChange: React.PropTypes.func,
		startingText: React.PropTypes.string,
		fullScreen: React.PropTypes.bool.isRequired,
		exitFullScreen: React.PropTypes.func
	},

	getInitialState: function() {
		return {
			acePointer: null
		};
	},

	componentWillUpdate: function(newProps, nextState) {
		if (newProps.startingText != this.editor.getValue()) {
			this.writtenText = newProps.startingText;
			this.loading = true;
			this.editor.setValue(newProps.startingText, -1);
		} else {
			this.loading = false;
		}

		if (newProps.fullScreen && this.props.fullScreen == false) {
			this.refs.editor.getDOMNode().className = "editor-fullscreen ace_editor ace-tm";
			this.editor.resize();
			this.editor.focus();
			//this.editor.container.webkitRequestFullscreen();
		}
	},

	keyDown: function() {
		console.log("key");
	},

	render: function() {	
		return <div key="editoreditor" className="editor" ref="editor" onKeyDown={this.keyDown}></div>;
	},

	componentDidMount: function() {
		var editorNode = this.refs.editor.getDOMNode();
		var editor = ace.edit(editorNode);
		editor.renderer.setShowGutter(false);
		editor.focus();
		this.editor = editor;
		var self = this;
		editor.getSession().on('change', function(e) {
			if (self.props.onChange) {
				var text = editor.getValue();
				if (text != self.writtenText && self.loading == false) {
					self.props.onChange(editor.getValue());
				} else if (text == self.writtenText) {
					self.loading = false;
				} else {
					//console.log(self.loading, self.writtenText, text);
				}	
			};
		});

		editor.on("blur", function(e) {
			console.log("blurrr", self.props.fullScreen);
			if (self.props.fullScreen) {
				self.refs.editor.getDOMNode().className = "editor ace_editor ace-tm";
				self.editor.resize();
				self.props.exitFullScreen();
				self.editor.focus();
			}
		})
		this.setState({acePointer: editor});
	}
});<commit_msg>Ctrl+E to exit fullscreen<commit_after>/** @jsx React.DOM */
var AceEditor = React.createClass({
	propTypes: {
		onChange: React.PropTypes.func,
		startingText: React.PropTypes.string,
		fullScreen: React.PropTypes.bool.isRequired,
		exitFullScreen: React.PropTypes.func
	},

	getInitialState: function() {
		return {
			acePointer: null
		};
	},

	componentWillUpdate: function(newProps, nextState) {
		if (newProps.startingText != this.editor.getValue()) {
			this.writtenText = newProps.startingText;
			this.loading = true;
			this.editor.setValue(newProps.startingText, -1);
		} else {
			this.loading = false;
		}

		if (newProps.fullScreen && this.props.fullScreen == false) {
			this.refs.editor.getDOMNode().className = "editor-fullscreen ace_editor ace-tm";
			this.editor.resize();
			this.editor.focus();
			//this.editor.container.webkitRequestFullscreen();
		}
	},

	keyDown: function() {
		console.log("key");
	},

	render: function() {	
		return <div key="editoreditor" className="editor" ref="editor"></div>;
	},

	componentDidMount: function() {
		var editorNode = this.refs.editor.getDOMNode();
		var editor = ace.edit(editorNode);
		editor.renderer.setShowGutter(false);
		editor.focus();
		this.editor = editor;
		var self = this;
		editor.getSession().on('change', function(e) {
			if (self.props.onChange) {
				var text = editor.getValue();
				if (text != self.writtenText && self.loading == false) {
					self.props.onChange(editor.getValue());
				} else if (text == self.writtenText) {
					self.loading = false;
				} else {
					//console.log(self.loading, self.writtenText, text);
				}	
			};
		});
		
		editor.commands.addCommand({
		    name: 'exitFullScreen',
		    bindKey: {win: 'Ctrl+E',  mac: 'Ctrl+E'},
		    exec: function(editor) {
		        if (self.props.fullScreen) {
					self.refs.editor.getDOMNode().className = "editor ace_editor ace-tm";
					self.editor.resize();
					self.props.exitFullScreen();
					self.editor.focus();
				}
		    },
		    readOnly: true // false if this command should not apply in readOnly mode
		});
		
		this.setState({acePointer: editor});

	}
});
{'fraction_non_alphanumeric': 0.15885797950219618, 'fraction_numerical': 0.0004880429477794046, 'mean_word_length': 3.5747767857142856, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7076920', 'n_tokens_mistral': 1564, 'n_tokens_neox': 1334, 'n_words': 240}