1. 06 Apr, 2022 2 commits
    • Robert Knight's avatar
      Allow for whitespace differences between page text and text layer · 4e124a6f
      Robert Knight authored
      When anchoring a quote in a PDF, the quote is first searched in text
      extracted using PDF.js's `PDFPage.getTextContent` API, and the resulting
      positions are used to create a range within the hidden text layer of a
      page.
      
      An issue we've seen several times when doing PDF.js upgrades is minor
      changes to which spaces are included in the text layer. In the past
      we've adapted our text extraction to match the text layer each time.
      This slows down the process of upgrading PDF.js and makes maintaining
      compatibility with a range of PDF.js releases more difficult. In the
      most recent update, an `includeMarkedContent` option was added to the
      `getTextContent` API, and the presence of that option could affect
      whether certain whitespaces are included in the output nor not [1].
      
      Try to address this issue generally by mapping offsets from the page
      text into offsets in the text layer in a way that ignores whitespace
      differences.
      
       - Add `translateOffsets` utility, which maps a (start, end) pair
         of offsets in an input string into corresponding offsets in an output
         string, where the output is a version of the input that has been
         "corrupted" by the addition or removal of certain characters (eg.
         whitespace)
      
       - Use `translateOffsets` utility in PDF anchoring to map quote offsets
         in the page text returned by `PDFPage.getTextContent` into offsets in
         the `textContent` of the text layer element.
      
      [1] https://github.com/hypothesis/browser-extension/pull/799#issuecomment-1079864595
      4e124a6f
    • Robert Knight's avatar
  2. 05 Apr, 2022 11 commits
  3. 04 Apr, 2022 6 commits
  4. 31 Mar, 2022 8 commits
    • Robert Knight's avatar
      Add test case for Cross-Origin-Opener-Policy header · 4ba76ac9
      Robert Knight authored
      Add a test case for pages served with the `Cross-Origin-Opener-Policy:
      same-origin` header, which currently breaks the client's login popup.
      
      This reproduces the issue from https://github.com/hypothesis/product-backlog/issues/1333.
      4ba76ac9
    • Robert Knight's avatar
      Add mechanism to specify custom headers for HTML test pages · f8100ac7
      Robert Knight authored
      Add support for specifying custom headers to serve test pages with via
      inline `<!-- Header: <Key>:<Value> -->` comments in the HTML/XML, and
      change the existing XHTML test case to use it.
      f8100ac7
    • Robert Knight's avatar
      Simplify login popup creation flow · 9bf96c31
      Robert Knight authored
      The process of creating and navigating the login popup used to involve two
      steps, first creating a blank window and then navigating it to the final
      authorization URL. This was needed because, in Firefox, the popup window had to
      be created in the same turn of the event loop as the user's click on the "Log
      in" button (otherwise the popup blocker would trigger) but generating the
      authorization URL involved an async "fetch" of API links.
      
      The major browsers have now all settled on a more flexible model for allowing
      popups in response to user gestures, where the popup must be opened within a
      certain time window of the gesture. In practice the timeout seems to be ~1000ms
      in Safari and longer than that in other browsers.
      
      In this context we expect the async delay between the user clicking the "Log in"
      button and us creating the popup to be ~0ms, since the API links should already
      have been fetched at this point and so we're just fetching locally cached values.
      
      Based on this assumption, the flow for creating the login popup window has been
      simplified to create the popup window at the final URL immediately, removing the
      need to open a blank window as a first step.
      
      Simplifying the code here will make it easier to change how the popup window and
      sidebar communicate, eg. to resolve an issue with the new
      Cross-Origin-Opener-Policy header [1].
      
      [1] https://github.com/hypothesis/product-backlog/issues/1333
      9bf96c31
    • Robert Knight's avatar
      Add missing types to annotation and route store modules · 13914b8d
      Robert Knight authored
       - Add state and action types to reducers
      
       - Replace Array.forEach calls with for..of loops to enable better type
         inference.
      
       - Replace plain objects used as sets with ES sets
      13914b8d
    • Robert Knight's avatar
      Determine type of sidebar store automatically · 31ac4c8a
      Robert Knight authored
      Avoid the need to manually create the `SidebarStore` type by inferring
      it automatically. This works as follows:
      
       1. The `modules` argument to `createStore` has been converted to a
          tuple type (`[ModuleA, ModuleB, ...]`)
       2. The type of a module that would result from merging all the
          individual modules (`ModuleA & ModuleB ...`) is computed
          using a `TupleToIntersection` utility type
       3. `StoreFromModule` is used to compute the type of the store that the
          merged module would produce
      31ac4c8a
    • Lyza Danger Gardner's avatar
      1326d1a9
    • Lyza Danger Gardner's avatar
      Extract StyledText and refactor props on related components · 5baa223b
      Lyza Danger Gardner authored
      Extract a StyledText component that can be used by MarkdownView and
      AnnotationQuote. Update some props on Markdown components to match
      conventions.
      5baa223b
    • Lyza Danger Gardner's avatar
      Add AnnotationActivityService · 17e990bb
      Lyza Danger Gardner authored
      Add new service to notify ancestor frame on annotation activity, if
      so configured.
      17e990bb
  5. 30 Mar, 2022 6 commits
  6. 29 Mar, 2022 5 commits
  7. 28 Mar, 2022 2 commits