all files / model/ Marker.js

33.33% Statements 3/9
0% Branches 0/7
0% Functions 0/3
37.5% Lines 3/8
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                                                     
import { isArrayEqual } from '../util'
import PropertyAnnotation from './PropertyAnnotation'
 
class Marker extends PropertyAnnotation {
  invalidate() {}
  remove() {
    this.getDocument().data.delete(this.id)
  }
 
  // TODO: we should use the Coordinate comparison API here
  containsSelection(sel) {
    if (sel.isNull()) return false;
    if (sel.isPropertySelection()) {
      return (isArrayEqual(this.start.path, sel.start.path) &&
        this.start.offset <= sel.start.offset &&
        this.end.offset >= sel.end.offset)
    } else {
      console.warn('Marker.contains() does not support other selection types.')
    }
  }
 
}
 
// while having the same interface, Markers should still be treated differently, e.g. not go into the AnnotationIndex
Marker.prototype._isPropertyAnnotation = false
Marker.prototype._isMarker = true
Marker.autoExpandRight = false
 
export default Marker