If you want to consider a commercial product, you could look at the LEADTOOLS Document Viewer for web (Disclaimer: I am an employee of the vender that distributes the LEADTOOLS SDK)
It can load and save different types of documents and can add mark-up to the files and then save them into a separate XML file or on the original document as an overlay.
The Document Viewer has text search functionality that allows you to search through a document for specific text, which can be used alongside the mark-up functionality. This
will allow you to highlight specific portions of text within your document. There’s an online demo where you can see all the features here:
https://demo.leadtools.com/JavaScript/DocumentViewer/index.html
Here is a screenshot of the mark-up:

Here is the documentation for the Document Viewer, Annotations, find, and hilite functions, respectively:
https://www.leadtools.com/help/leadtools/v20/dh/javascript/to/using-the-leadtools-document-viewer.html
https://www.leadtools.com/help/leadtools/v20/dh/doxui/documentviewerannotations.html
https://www.leadtools.com/help/leadtools/v20/dh/javascript/doxui/documentviewertext-find.html
https://www.leadtools.com/help/leadtools/v20/dh/ac/annhiliteobject.html