all files / ui/ AnnotationTool.js

0% Statements 0/12
0% Branches 0/2
0% Functions 0/3
0% Lines 0/12
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 40 41 42 43 44 45 46 47 48 49 50 51                                                                                                     
import Tool from './Tool'
 
/**
 
  Reuseable AnnotationTool component. Can be used without modification
  for pure marker annotations that don't carry data. E.g. strong, emphasis,
  superscript, etc.
 
  @class
  @component
 
  @example
 
  ```
  config.addTool('strong', AnnotationTool, {
    target: 'annotations'
  })
  ```
*/
 
class AnnotationTool extends Tool {
 
  render($$) {
    let el = super.render.call(this, $$)
    el.addClass('sm-annotation-tool')
    return el
  }
 
  renderButton($$) {
    let el = super.renderButton.call(this, $$)
    el.append(this.renderMode($$))
    return el
  }
 
  /*
    Renders a small hint for the mode (expand, truncate, edit, etc)
  */
  renderMode($$) {
    let mode = this.props.mode
    let el = $$('div').addClass('se-mode')
 
    let iconEl = this.context.iconProvider.renderIcon($$, mode)
    if (iconEl) {
      el.append(iconEl)
    }
    return el
  }
}
 
export default AnnotationTool