(attributeName, { withValue } = {})
| 666 | } |
| 667 | |
| 668 | findRangesForTextAttribute(attributeName, { withValue } = {}) { |
| 669 | let position = 0 |
| 670 | let range = [] |
| 671 | const ranges = [] |
| 672 | |
| 673 | const match = function(piece) { |
| 674 | if (withValue) { |
| 675 | return piece.getAttribute(attributeName) === withValue |
| 676 | } else { |
| 677 | return piece.hasAttribute(attributeName) |
| 678 | } |
| 679 | } |
| 680 | |
| 681 | this.getPieces().forEach((piece) => { |
| 682 | const length = piece.getLength() |
| 683 | if (match(piece)) { |
| 684 | if (range[1] === position) { |
| 685 | range[1] = position + length |
| 686 | } else { |
| 687 | ranges.push(range = [ position, position + length ]) |
| 688 | } |
| 689 | } |
| 690 | position += length |
| 691 | }) |
| 692 | |
| 693 | return ranges |
| 694 | } |
| 695 | |
| 696 | locationFromPosition(position) { |
| 697 | const location = this.blockList.findIndexAndOffsetAtPosition(Math.max(0, position)) |
no test coverage detected