Fix clear matches functionality
This commit is contained in:
parent
6090b3edf9
commit
ecf3dae776
@ -2254,19 +2254,12 @@ var TextLayerBuilder = function textLayerBuilder(textLayerDiv, pageIdx) {
|
||||
return ret;
|
||||
};
|
||||
|
||||
this.clearMatches = function textLayerBuilder_clearMatches() {
|
||||
var textDivs = this.textDivs;
|
||||
|
||||
// Clear all previous highlights
|
||||
textDivs.forEach(function(div) {
|
||||
var spans = div.querySelectorAll('span');
|
||||
for (var i = 0, ii = spans.length; i < ii; i++) {
|
||||
spans[i].className = '';
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
this.renderMatches = function textLayerBuilder_renderMatches(matches) {
|
||||
// Early exit if there is nothing to render.
|
||||
if (matches.length === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
var bidiTexts = this.textContent.bidiTexts;
|
||||
var textDivs = this.textDivs;
|
||||
var prevEnd = null;
|
||||
@ -2274,8 +2267,6 @@ var TextLayerBuilder = function textLayerBuilder(textLayerDiv, pageIdx) {
|
||||
var selectedMatchIdx = PDFFindController.selected.matchIdx;
|
||||
var highlightAll = PDFFindController.state.highlightAll;
|
||||
|
||||
this.clearMatches();
|
||||
|
||||
var infty = {
|
||||
divIdx: -1,
|
||||
offset: undefined
|
||||
@ -2377,12 +2368,13 @@ var TextLayerBuilder = function textLayerBuilder(textLayerDiv, pageIdx) {
|
||||
var bidiTexts = this.textContent.bidiTexts;
|
||||
var clearedUntilDivIdx = -1;
|
||||
|
||||
// Clear out all current matches.
|
||||
for (var i = 0; i < matches.length; i++) {
|
||||
var match = matches[i];
|
||||
var begin = Math.max(clearedUntilDivIdx, match.begin.divIdx);
|
||||
for (var n = begin; n <= match.end.divIdx; n++) {
|
||||
var div = bidiTexts[n].str;
|
||||
div.textContent = div.textContent;
|
||||
var div = textDivs[n];
|
||||
div.textContent = bidiTexts[n].str;
|
||||
div.className = '';
|
||||
}
|
||||
clearedUntilDivIdx = match.end.divIdx + 1;
|
||||
|
Loading…
x
Reference in New Issue
Block a user