Skip to content

Instantly share code, notes, and snippets.

@phusick
Last active September 1, 2016 09:59
Show Gist options
  • Save phusick/60a2d0ffbb76ca5039ea35fb66d9f207 to your computer and use it in GitHub Desktop.
Save phusick/60a2d0ffbb76ca5039ea35fb66d9f207 to your computer and use it in GitHub Desktop.
esnextbin sketch
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>ESNextbin Sketch</title>
<!-- put additional styles and scripts here -->
</head>
<body>
<div id="container"></div>
</body>
</html>
// write ES2015 code and import modules from npm
// and then press "Execute" to run your program
import React from 'react';
import ReactDOM from 'react-dom';
import {Editor, EditorState} from 'draft-js';
console.log(Editor);
class MyEditor extends React.Component {
constructor(props) {
super(props);
this.state = {editorState: EditorState.createEmpty()};
this.onChange = (editorState) => this.setState({editorState});
}
render() {
const {editorState} = this.state;
return <Editor editorState={editorState} onChange={this.onChange} />;
}
}
ReactDOM.render(
<MyEditor />,
document.getElementById('container')
);
{
"name": "esnextbin-sketch",
"version": "0.0.0",
"dependencies": {
"react": "15.3.1",
"react-dom": "15.3.1",
"draft-js": "0.8.1",
"babel-runtime": "6.11.6"
}
}
'use strict';
var _getPrototypeOf = require('babel-runtime/core-js/object/get-prototype-of');
var _getPrototypeOf2 = _interopRequireDefault(_getPrototypeOf);
var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');
var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
var _createClass2 = require('babel-runtime/helpers/createClass');
var _createClass3 = _interopRequireDefault(_createClass2);
var _possibleConstructorReturn2 = require('babel-runtime/helpers/possibleConstructorReturn');
var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2);
var _inherits2 = require('babel-runtime/helpers/inherits');
var _inherits3 = _interopRequireDefault(_inherits2);
var _react = require('react');
var _react2 = _interopRequireDefault(_react);
var _reactDom = require('react-dom');
var _reactDom2 = _interopRequireDefault(_reactDom);
var _draftJs = require('draft-js');
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
console.log(_draftJs.Editor); // write ES2015 code and import modules from npm
// and then press "Execute" to run your program
var MyEditor = function (_React$Component) {
(0, _inherits3.default)(MyEditor, _React$Component);
function MyEditor(props) {
(0, _classCallCheck3.default)(this, MyEditor);
var _this = (0, _possibleConstructorReturn3.default)(this, (0, _getPrototypeOf2.default)(MyEditor).call(this, props));
_this.state = { editorState: _draftJs.EditorState.createEmpty() };
_this.onChange = function (editorState) {
return _this.setState({ editorState: editorState });
};
return _this;
}
(0, _createClass3.default)(MyEditor, [{
key: 'render',
value: function render() {
var editorState = this.state.editorState;
return _react2.default.createElement(_draftJs.Editor, { editorState: editorState, onChange: this.onChange });
}
}]);
return MyEditor;
}(_react2.default.Component);
_reactDom2.default.render(_react2.default.createElement(MyEditor, null), document.getElementById('container'));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment