Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

retrieving word IDs from highlighted text? #14

Closed
alhuber1502 opened this issue Feb 1, 2021 · 4 comments
Closed

retrieving word IDs from highlighted text? #14

alhuber1502 opened this issue Feb 1, 2021 · 4 comments

Comments

@alhuber1502
Copy link

alhuber1502 commented Feb 1, 2021

My text looks like this in the browser:
So chearful and sprightly, she ...

and like this in the source:

<w xml:id="peh89-239170">So</w>
<c> </c>
<w xml:id="peh89-239180">chearful</w>
<c> </c>
<w xml:id="peh89-239190">and</w>
<c> </c>
<w xml:id="peh89-239200">sprightly</w>
<pc xml:id="peh89-239210">,</pc>
<c> </c>
<w xml:id="peh89-239220">she</w>

When I highlight the above line in the browser, can I retrieve
"target": [peh89-239170, peh89-239180, peh89-239190, peh89-239200, peh89-239210, peh89-239220]
or something to that effect? Thanks!

@rsimon
Copy link
Member

rsimon commented Feb 2, 2021

There's no support for custom markup I'm afraid. I am hoping to support XPointer-based targets at some point (including for the TEI markup using the CETEIcean library) but I don't know when that will happen. (My main personal interest (as well as my paid jobs...) are focused more around image annotation at the moment.)

@alhuber1502
Copy link
Author

Thanks, can I hack this? Any pointers to where in the code to start?

@rsimon
Copy link
Member

rsimon commented Feb 2, 2021

Should be hackable in principle. Devil might be in the details. But the code that translates DOM ranges to annotation targets is here:

https://github.com/recogito/recogito-client-core/blob/main/src/selection/SelectionUtils.js#L30-L51

If you want the targets to restore properly, too, you'd need to dig deeper, starting here:

https://github.com/recogito/recogito-client-core/blob/main/src/highlighter/Highlighter.js#L43

But that might not be necessary. If you just add your own ID selector in parallel to the char offset selector (rather than replace the char offset target with the ID-based one), the annotation would still restore properly when you load it.

@alhuber1502
Copy link
Author

Thanks, that's great, I'll have a stab at it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants