nicholaschiang / hammock

Move your newsletters outside of your inbox. Focus on and learn from the content you love in a distraction-free reading space.
https://readhammock.com
GNU Affero General Public License v3.0
11 stars 1 forks source link

fix(highlight): support non-text nodes #140

Closed nicholaschiang closed 3 years ago

nicholaschiang commented 3 years ago

Fixes PD-112

vercel[bot] commented 3 years ago

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployments, click below or on the icon next to each commit.

hammock – ./

🔍 Inspect: https://vercel.com/readhammock/hammock/6CgA5LuCsNA8g9MpiShx4YFE87C6
✅ Preview: https://hammock-git-highlight-readhammock.vercel.app

linear[bot] commented 3 years ago
PD-112 Support non-text start/end nodes

Right now, the `lib/highlight.ts` utility fails when either the highlight start or end nodes aren't `#text` nodes. This can occur when a user double clicks to select e.g. an entire paragraph at a time. In that scenario, both the start and the end nodes are the `p` itself. Hammock should simply traverse down the tree until we get to a `#text` node as it does normally when highlighting intermediate nodes (between the start and end).

codecov[bot] commented 3 years ago

Codecov Report

Merging #140 (dbcc68f) into develop (46db9a0) will decrease coverage by 0.00%. The diff coverage is 0.00%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop     #140      +/-   ##
===========================================
- Coverage    36.86%   36.85%   -0.01%     
===========================================
  Files           82       81       -1     
  Lines         1378     1362      -16     
  Branches       404      396       -8     
===========================================
- Hits           508      502       -6     
+ Misses         870      860      -10     
Impacted Files Coverage Δ
components/article.tsx 0.00% <0.00%> (ø)
lib/highlight.ts 6.34% <0.00%> (-0.93%) :arrow_down:
pages/api/redirect.ts
lib/fetch.ts 81.25% <0.00%> (+6.25%) :arrow_up:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 46db9a0...dbcc68f. Read the comment docs.