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 system. It is developed to power our online editing platform [Substance](http://substance.io).

35 lines (28 loc) 785 B
import NodeComponent from './NodeComponent' export default class SelectableNodeComponent extends NodeComponent { didMount () { super.didMount() const selectableManager = this.context.selectableManager if (selectableManager) { selectableManager.registerSelectable(this._getSelectableId(), this) } } dispose () { super.dispose() const selectableManager = this.context.selectableManager if (selectableManager) { selectableManager.unregisterSelectable(this._getSelectableId(), this) } } setSelected (selected) { this.state.selected = selected if (selected) { this.el.addClass('sm-selected') } else { this.el.removeClass('sm-selected') } } _getSelectableId () { return this.props.node.id } }