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

Get selected text in library tab? #60

Open
ImperialSquid opened this issue Sep 5, 2024 · 4 comments
Open

Get selected text in library tab? #60

ImperialSquid opened this issue Sep 5, 2024 · 4 comments

Comments

@ImperialSquid
Copy link

Getting the selected text in a reader tab is relatively simple, I was wondering if it's possible to get the selected text in the library tab too (eg if the user has selected some text in a note)

I didn't see anything like that in this toolkit, and a skim of the main Zotero repo didn't show anything, but I might have missed it.

Thanks in advance!

@windingwind
Copy link
Owner

Note editor is in an iframe and thus getting the selection can be complicated. What do you plan to do with the selection in note editor?

@ImperialSquid
Copy link
Author

ImperialSquid commented Sep 5, 2024

A user of my text to speech plugin expressed that they'd like to be able to selectively speak text due to how they use RSS feed items (the note item was just an example)

("an iframe and thus getting the selection can be complicated", yeah that's been one of my biggest struggles with plugin development honestly, I'm not a web dev by any extent so a lot of my work has been running face first into all sorts of security and privacy measures and stuff lol)

@windingwind
Copy link
Owner

I'm not familiar with the accessibility issues, but I guess Zotero has support for screen readers. For me, the MacOS VoiceOver can read the selection in the note as expected.

Back to your question, try this:

if (ZoteroPane.itemPane.mode === "note") {
    Zotero.debug(ZoteroPane.itemPane.getCurrentPane()._iframe.contentDocument.getSelection());
}

@ImperialSquid
Copy link
Author

I was making a joke about my continued struggles with highlighting text within the reader iframe, sorry for any confusion...!

For the solution, that works perfectly, thanks! Looks like there's some variation in terms of what fields exist on what types, but this definitely helps point me in the right direction!

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