pr #3356

squashing commits.
Merge pull request #3356 from vivin/extract_textlayerbuilder

Extract text-selection, search and match logic from viewer.js
Check that the progressCallback is defined before calling it