all files / packages/spell-check/ SpellCheckCommand.js

0% Statements 0/9
0% Branches 0/4
0% Functions 0/2
0% Lines 0/9
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39                                                                             
import { Command } from '../../ui'
 
/**
  Used for edit tools or property annotations (e.g. EditLinkTool)
 
  @class
*/
class SpellCheckCommand extends Command {
 
  getCommandState(params) {
 
    let state = params.selectionState
    let markers = state.getMarkers()
    if (markers.length === 0) {
      return {
        disabled: true
      }
    }
    markers = markers.filter(function(m) {
      return m.type === 'spell-error'
    })
 
    if (markers.length > 0) {
      return {
        disabled: false,
        active: false,
        mode: null,
        node: markers[0]
      }
    } else {
      return {
        disabled: true
      }
    }
  }
}
 
export default SpellCheckCommand