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

[FR] Use search in link instead of bounding box and selection #92

Open
mdbraber opened this issue Mar 7, 2024 · 4 comments
Open

[FR] Use search in link instead of bounding box and selection #92

mdbraber opened this issue Mar 7, 2024 · 4 comments
Labels
enhancement New feature or request

Comments

@mdbraber
Copy link

mdbraber commented Mar 7, 2024

Describe your request

Thanks for writing PDF++ - I had never imagined this level of integration would be possible in Obsidian. I'm wondering if it would be possible to create links which link through the selected text instead of the selection offsets. As I can see now selection is already just referencing the text layer:

getTextSelectionRange(pageEl: HTMLElement, range: Range) {

Would it be possible to configure an option that is not creating a selection but a search parameter? As a first step, it would already be helpful if a search parameter would execute a search in the PDF and scroll to the found text. Having it similar to selection would also help with having permanent highlights.

My use case is that I'm creating the highlights in different ways than through the PDF. E.g. I've got a lot of clipped content from webpages. I'm adding selected text from that webpage in a file, that I later want to search back in the captured PDF. I'm wondering if an option for that would be possible.

The advanced use case here I'm after is having one link in frontmatter with a source PDF (as can already be done with PDF++ - awesome!) and automatically adding links after quotations based on the text. I've got a plugin ready that can already do the automatic linking.

@mdbraber mdbraber added the enhancement New feature or request label Mar 7, 2024
RyotaUshio added a commit that referenced this issue Mar 8, 2024
…call of 'child.applySubpath' at the top of 'highlightSubpath'. As a result, we need to store the first subpath to be opened after PDF++ is enabled, so added 'plugin.subpathWhenPatched' and use it in 'onPDFInternalsPatchSuccess'.
@RyotaUshio
Copy link
Owner

RyotaUshio commented Mar 8, 2024

First of all, thank you so much for the sponsorship! I really appreciate your support.

As a first step, it would already be helpful if a search parameter would execute a search in the PDF and scroll to the found text.

The search parameter is now available in 0.37.12.
For example: [[file.pdf#search=query]] or [[file.pdf#search=Query&case-sensitive=true]] etc.
Please see the following section in the plugin settings for the details:

image

You can copy a link with the search param appended from the context menu ("Copy link to search").

@RyotaUshio
Copy link
Owner

RyotaUshio commented Mar 8, 2024

However, text search in PDF is expensive, so it might be difficult to use search links for backlink highlighting, unfortunately.

@mdbraber
Copy link
Author

That's absolutely awesome - thanks so much! I can imagine that search is expensive so backlinks with search won't work. Suppose I would be writing my own extension on PDF++ - would it be possible to hook in to an API call or something else that I would input the search phrase and get the selection coordinates of the first result returned? My idea is to e.g. build a command that I can run once that would update all the quote blocks with the relevant links based on their text.

@mdbraber
Copy link
Author

mdbraber commented Mar 10, 2024

I just noticed: when opening a backlink that contains a search parameter the PDF is focused, which is different from opening a backlink that has a select parameter where the note file stays focused. I'm guessing because the search box gets focus? Would it be more logical they both behave the same?

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

No branches or pull requests

2 participants