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).
32 lines (27 loc) • 680 B
JavaScript
import Command from './Command'
const ENABLED = Object.freeze({ disabled: false })
export default class FindAndReplaceCommand extends Command {
getCommandState (params, context) {
const fnr = context.findAndReplaceManager
if (!fnr) return { disabled: true }
switch (this.config.action) {
case 'open-find':
case 'open-replace': {
return ENABLED
}
}
}
execute (params, context) {
const fnr = context.findAndReplaceManager
switch (this.config.action) {
case 'open-find': {
fnr.openDialog()
break
}
case 'open-replace': {
fnr.openDialog('replace')
break
}
}
}
}