(range, callback)
| 497 | } |
| 498 | |
| 499 | eachBlockAtRange(range, callback) { |
| 500 | let block, textRange |
| 501 | range = normalizeRange(range) |
| 502 | const [ startPosition, endPosition ] = range |
| 503 | const startLocation = this.locationFromPosition(startPosition) |
| 504 | const endLocation = this.locationFromPosition(endPosition) |
| 505 | |
| 506 | if (startLocation.index === endLocation.index) { |
| 507 | block = this.getBlockAtIndex(startLocation.index) |
| 508 | textRange = [ startLocation.offset, endLocation.offset ] |
| 509 | return callback(block, textRange, startLocation.index) |
| 510 | } else { |
| 511 | for (let index = startLocation.index; index <= endLocation.index; index++) { |
| 512 | block = this.getBlockAtIndex(index) |
| 513 | if (block) { |
| 514 | switch (index) { |
| 515 | case startLocation.index: |
| 516 | textRange = [ startLocation.offset, block.text.getLength() ] |
| 517 | break |
| 518 | case endLocation.index: |
| 519 | textRange = [ 0, endLocation.offset ] |
| 520 | break |
| 521 | default: |
| 522 | textRange = [ 0, block.text.getLength() ] |
| 523 | } |
| 524 | callback(block, textRange, index) |
| 525 | } |
| 526 | } |
| 527 | } |
| 528 | } |
| 529 | |
| 530 | getCommonAttributesAtRange(range) { |
| 531 | range = normalizeRange(range) |
no test coverage detected