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).
22 lines (19 loc) • 524 B
JavaScript
import { Command } from '../editor'
export default class ItemCommand extends Command {
getType () {
const type = this.config.type
if (!type) {
// or override
throw new Error('type is required')
}
return type
}
getCommandState (params) {
const selectionState = params.selectionState
const type = this.getType()
if (selectionState.node && selectionState.node.type === type) {
return { disabled: false, node: selectionState.node }
}
return { disabled: true }
}
}