Closed ImperialSquid closed 1 month ago
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?
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)
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());
}
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!
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!