import { Text } from 'polar-shared/src/metadata/Text' ; import { Texts } from 'polar-shared/src/metadata/Texts' ; import { TextType } from 'polar-shared/src/metadata/TextType' ; import { BaseHighlight } from './BaseHighlight' ; import { Preconditions } from 'polar-shared/src/Preconditions' ; import { ITextHighlight } from "polar-shared/src/metadata/ITextHighlight" ; import { ITextRect } from "polar-shared/src/metadata/ITextRect" ; export class TextHighlight extends BaseHighlight implements ITextHighlight { /**
     * A raw array-like object of text from the regions that the user
     * has highlighted in the UI. In PDF and pdf.js there isn't really
     * the concept of flowing text so we try to show the user the text
     * in the specific regions they selected.
     *
     */ public textSelections : { [ id ] : ITextRect ; } = { } ; /**
     * The text selections converted to a text string which may or may not be
     * human readable.  Some of the PDF text are actually lists of figures with
     * special characters that might be placed absolutely around the screen.
     *
     * When this is just a plain string we assume it's text and not HTML.
     */ public text : Text | string = Texts . create ( "" , TextType . HTML ) ; public revisedText ? : Text | string ; constructor ( val ) { super ( val ) ; type { String } this . init ( val ) ; } public validate ( ) { super . validate ( ) ; Preconditions . assertNotInstanceOf ( this . textSelections , "textSelections" , Array ) ; } }