MuckRock / documentcloud-frontend

DocumentCloud's front end source code - Please report bugs, issues and feature requests to info@documentcloud.org
https://www.documentcloud.org
GNU Affero General Public License v3.0
16 stars 5 forks source link

Redact/Annotate text when hovering over it in viewer. #204

Open eyeseast opened 1 year ago

eyeseast commented 1 year ago

If a user selects some in-line text, offer a prompt to let them add a note box around that text, or redact it. This saves a few steps from having to go into editing or annotation flow.

From Pinpoint:

https://github.com/MuckRock/documentcloud-frontend/assets/25778/0774ada9-521a-44b1-a82a-b377314949ce

From DocumentCloud:

https://github.com/MuckRock/documentcloud-frontend/assets/25778/11082d2d-4714-4747-8c67-c58ae9da2c18

allanlasser commented 2 weeks ago

To get a bounding box for selected text:

var selection = window.getSelection();
var getRange = selection.getRangeAt(0); 
getRect = getRange.getBoundingClientRect();

via StackOverflow

Easy! From here, we can use @floating-ui to provide a pop-up menu, and then pass the rect to either the annotation layer or redaction layer.