text_highlighter.d.ts 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. export type TextHighlighterOptions = {
  2. findController: any;
  3. /**
  4. * - The application event bus.
  5. */
  6. eventBus: any;
  7. /**
  8. * - The page index.
  9. */
  10. pageIndex: number;
  11. };
  12. /**
  13. * @typedef {Object} TextHighlighterOptions
  14. * @property {PDFFindController} findController
  15. * @property {EventBus} eventBus - The application event bus.
  16. * @property {number} pageIndex - The page index.
  17. */
  18. /**
  19. * TextHighlighter handles highlighting matches from the FindController in
  20. * either the text layer or XFA layer depending on the type of document.
  21. */
  22. export class TextHighlighter {
  23. /**
  24. * @param {TextHighlighterOptions} options
  25. */
  26. constructor({ findController, eventBus, pageIndex }: TextHighlighterOptions);
  27. findController: any;
  28. matches: any[];
  29. eventBus: any;
  30. pageIdx: number;
  31. _onUpdateTextLayerMatches: ((evt: any) => void) | null;
  32. textDivs: Node[] | null;
  33. textContentItemsStr: string[] | null;
  34. enabled: boolean;
  35. /**
  36. * Store two arrays that will map DOM nodes to text they should contain.
  37. * The arrays should be of equal length and the array element at each index
  38. * should correspond to the other. e.g.
  39. * `items[0] = "<span>Item 0</span>" and texts[0] = "Item 0";
  40. *
  41. * @param {Array<Node>} divs
  42. * @param {Array<string>} texts
  43. */
  44. setTextMapping(divs: Array<Node>, texts: Array<string>): void;
  45. /**
  46. * Start listening for events to update the highlighter and check if there are
  47. * any current matches that need be highlighted.
  48. */
  49. enable(): void;
  50. disable(): void;
  51. _convertMatches(matches: any, matchesLength: any): {
  52. begin: {
  53. divIdx: number;
  54. offset: number;
  55. };
  56. }[];
  57. _renderMatches(matches: any): void;
  58. _updateMatches(): void;
  59. }