UNPKG

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 systems.

38 lines (28 loc) 699 B
import Component from './Component' class NodeComponent extends Component { didMount() { this.context.editorSession.onRender('document', this.rerender, this, { path: [this.props.node.id]}) } dispose() { this.context.editorSession.off(this) } render($$) { let tagName = this.getTagName() let el = $$(tagName) .attr('data-id', this.props.node.id) .addClass(this.getClassNames()) return el } getTagName() { return 'div' } getClassNames() { return '' } rerender(...args) { // skip if this node has been disposed already if (this.props.node.isDisposed()) return super.rerender(...args) } } export default NodeComponent