text_layer.d.ts 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. /**
  2. * Text layer render parameters.
  3. */
  4. export type TextLayerRenderParameters = {
  5. /**
  6. * - Text content to
  7. * render (the object is returned by the page's `getTextContent` method).
  8. */
  9. textContent?: import("./api").TextContent;
  10. /**
  11. * - Text content stream to
  12. * render (the stream is returned by the page's `streamTextContent` method).
  13. */
  14. textContentStream?: ReadableStream;
  15. /**
  16. * - HTML element that will contain text runs.
  17. */
  18. container: HTMLElement;
  19. /**
  20. * - The target
  21. * viewport to properly layout the text runs.
  22. */
  23. viewport: import("./display_utils").PageViewport;
  24. /**
  25. * - HTML elements that are correspond
  26. * to the text items of the textContent input. This is output and shall be
  27. * initially be set to empty array.
  28. */
  29. textDivs?: Array<HTMLElement>;
  30. /**
  31. * - Strings that correspond to
  32. * the `str` property of the text items of textContent input. This is output
  33. * and shall be initially be set to empty array.
  34. */
  35. textContentItemsStr?: Array<string>;
  36. /**
  37. * - Delay in milliseconds before rendering of the
  38. * text runs occurs.
  39. */
  40. timeout?: number;
  41. /**
  42. * - Whether to turn on the text
  43. * selection enhancement.
  44. */
  45. enhanceTextSelection?: boolean;
  46. };
  47. export type TextLayerRenderTask = {
  48. promise: Promise<void>;
  49. cancel: () => void;
  50. expandTextDivs: (expandDivs: boolean) => void;
  51. };
  52. /**
  53. * Text layer render parameters.
  54. *
  55. * @typedef {Object} TextLayerRenderParameters
  56. * @property {import("./api").TextContent} [textContent] - Text content to
  57. * render (the object is returned by the page's `getTextContent` method).
  58. * @property {ReadableStream} [textContentStream] - Text content stream to
  59. * render (the stream is returned by the page's `streamTextContent` method).
  60. * @property {HTMLElement} container - HTML element that will contain text runs.
  61. * @property {import("./display_utils").PageViewport} viewport - The target
  62. * viewport to properly layout the text runs.
  63. * @property {Array<HTMLElement>} [textDivs] - HTML elements that are correspond
  64. * to the text items of the textContent input. This is output and shall be
  65. * initially be set to empty array.
  66. * @property {Array<string>} [textContentItemsStr] - Strings that correspond to
  67. * the `str` property of the text items of textContent input. This is output
  68. * and shall be initially be set to empty array.
  69. * @property {number} [timeout] - Delay in milliseconds before rendering of the
  70. * text runs occurs.
  71. * @property {boolean} [enhanceTextSelection] - Whether to turn on the text
  72. * selection enhancement.
  73. */
  74. /**
  75. * @typedef {Object} TextLayerRenderTask
  76. * @property {Promise<void>} promise
  77. * @property {() => void} cancel
  78. * @property {(expandDivs: boolean) => void} expandTextDivs
  79. */
  80. /**
  81. * @type {(renderParameters: TextLayerRenderParameters) => TextLayerRenderTask}
  82. */
  83. export var renderTextLayer: (renderParameters: TextLayerRenderParameters) => TextLayerRenderTask;