1. 12 Apr, 2021 6 commits
    • dependabot[bot]'s avatar
    • Robert Knight's avatar
      Refactor side-by-side state in Guest · 1475c104
      Robert Knight authored
      In issue discussions, tests and various parts of the code there are
      mentions of side-by-side mode being active or not. The `Guest` class
      didn't store this state directly but instead had a
      `closeSidebarOnDocumentClick` state which is always the inverse of
      "is side-by-side active?".
      
      Make the code easier to follow by storing the "is side-by-side active?" state
      directly. This will also avoid a misnamed variable if in future the
      state has other effects besides changing whether clicking on the
      document closes the sidebar.
      
       - Replace `closeSidebarOnDocumentClick` with a private
         `_sideBySideActive` property, exposed via a read-only
         `sideBySideActive` getter
      
       - Refactor tests to only use the public API of Guest (calling
         `Guest#fitSideBySide` or reading `sideBySideActive`)
      1475c104
    • Robert Knight's avatar
      Remove fallback document URL and metadata · 56737601
      Robert Knight authored
      Remove the fallback logic that uses `location.href` and `document.title`
      as the document URL and metadata if using the integration-specific code
      (HTML or PDF) to get the document URL and metadata fails. Instead just
      let the async exception propagate.  Currently this will result in no
      annotation/highlight being created and a console error. In future we
      should improve this by showing an error notification to the user.
      
      Recording the wrong document metadata with an annotation is worse than
      not creating an annotation at all: The user will be unaware that there
      is a problem yet the annotation will likely fail to show up in future or
      be displayed with completely wrong metadata in the Notebook. Therefore
      we want the failure here to be obvious so that the user notifies us of
      the problem and doesn't create a bunch of annotations which later
      "disappear".
      
      Fixes #3204
      56737601
    • Robert Knight's avatar
      Improve tests for `Guest#destroy` · f2a6fe75
      Robert Knight authored
      Add test to check that anchors not associated with the removed
      annotation are preserved.
      f2a6fe75
    • Robert Knight's avatar
    • Robert Knight's avatar
      Refactor `Guest#anchor` · d9085810
      Robert Knight authored
      Rewrite the `Guest#anchor` method to simplify the control flow and
      generally make it easier to understand and change. There are no
      functional changes for annotations with zero or one entry in the
      `target` field (all existing Hypothesis annotations).
      
      There is a functional change to handling of annotations with multiple
      targets. Previously `anchor` would try to be smart about only
      re-anchoring targets which were not already anchored. In the new
      implementation all targets for an annotation are re-anchored. This will have
      no effect in practice because the Hypothesis client only supports
      creating annotations with a single target and the h backend can only
      store a single target per annotation. However the Hypothesis API does
      allow for multiple targets per annotation, in line with the W3C Web
      Annotations specs in which a single annotation can refer to multiple
      parts of a document.
      
       - Convert `anchor` method to async and replace Promise chains with async/await
      
       - Replace the logic that removes existing anchors and highlights for an
         annotation with a call to the `detach` method. This required adding
         an internal parameter to `detach` to control whether `anchorsChanged`
         is emitted, so that `anchor` only emits `anchorsChanged` once.
      
       - Add an explicit error to `Promise.reject` calls in tests so that the
         tests are easier to debug if they fail
      d9085810
  2. 09 Apr, 2021 10 commits
  3. 08 Apr, 2021 2 commits
  4. 07 Apr, 2021 7 commits
  5. 06 Apr, 2021 7 commits
  6. 05 Apr, 2021 8 commits