text_highlighter.d.ts 2.2 KB

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