Skip to content

Commit

Permalink
Add basic editor component
Browse files Browse the repository at this point in the history
  • Loading branch information
inukshuk committed Feb 24, 2017
1 parent e7717af commit e4946a0
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 7 deletions.
4 changes: 4 additions & 0 deletions package.json
Expand Up @@ -89,6 +89,10 @@
"lodash.debounce": "^4.0.7",
"lodash.throttle": "^4.1.1",
"ms": "^0.7.1",
"prosemirror-model": "^0.18.0",
"prosemirror-schema-basic": "^0.18.0",
"prosemirror-state": "^0.18.0",
"prosemirror-view": "^0.18.0",
"react": "^15.0.0",
"react-dnd": "^2.2.3",
"react-dnd-electron-backend": "^1.1.3",
Expand Down
42 changes: 42 additions & 0 deletions src/components/editor.js
@@ -0,0 +1,42 @@
'use strict'

const React = require('react')
const { PureComponent, PropTypes } = React
const { func, bool, object } = PropTypes

const { EditorState } = require('prosemirror-state')
const { EditorView } = require('prosemirror-view')
const { schema } = require('prosemirror-schema-basic')


class Editor extends PureComponent {
componentDidMount() {
this.pm = new EditorView(this.container, {
state: EditorState.create({ schema })
})
}

componentWillUnmount() {
this.pm.destroy()
}

setContainer = (container) => {
this.container = container
}

render() {
return (
<div ref={this.setContainer} className="editor"/>
)
}

static propTypes = {
isDisabled: bool,
value: object,
onChange: func
}
}

module.exports = {
Editor
}
23 changes: 16 additions & 7 deletions src/components/note/pad.js
@@ -1,16 +1,25 @@
'use strict'

const React = require('react')
const { PropTypes } = React
const cx = require('classnames')
const { PureComponent, PropTypes } = React
const { object } = PropTypes
const { Editor } = require('../editor')
const cx = require('classnames')


const NotePad = () => (
<section className={cx({ note: true })}/>
)
//eslint-disable-next-line react/prefer-stateless-function
class NotePad extends PureComponent {
render() {
return (
<section className={cx({ note: true })}>
<Editor/>
</section>
)
}

NotePad.propTypes = {
note: object
static propTypes = {
note: object
}
}

module.exports = {
Expand Down

0 comments on commit e4946a0

Please sign in to comment.