substance
Version:
Substance is a JavaScript library for web-based content editing. It provides building blocks for realizing custom text editors and web-based publishing system. It is developed to power our online editing platform [Substance](http://substance.io).
24 lines (17 loc) • 454 B
JavaScript
import { Component } from '../dom'
export default class NodeComponent extends Component {
didMount () {
const node = this._getNode()
this.context.editorState.addObserver(['document'], this._onNodeUpdate, this, { document: { path: [node.id] }, stage: 'render' })
}
dispose () {
super.dispose()
this.context.editorState.off(this)
}
_getNode () {
return this.props.node
}
_onNodeUpdate () {
this.rerender()
}
}