RyotaUshio / obsidian-pdf-plus

The most Obsidian-native PDF annotation, viewing & editing tool ever. Comes with optional Vim keybindings.
https://ryotaushio.github.io/obsidian-pdf-plus/
MIT License
517 stars 9 forks source link

[FR] resizable selection area? #36

Open SSmJaE opened 5 months ago

SSmJaE commented 5 months ago

hi, I just wonder if there any possible to update the selection area, after initially pasting the quote to the markdown file

it's two separate problems actually

1. I've noticed that the link to the annotation contains the selection area, like below

#page=60&selection=100,8,102,65

simply envision this, implementing the resize may depend too much on obsidian internals, and may take too much effort.

since now you can manage backlinks, just updating the backlinks may be more approachable. if we could update the selection query params in links, we can somehow emulate such resize behavior

2. the second problem may not be so easy, and if we use embedded with margin, maybe it is not necessary to implement this. but I am somehow concerned about the performance if you embed too many PDF viewer instances in tabs, especially when you open dozens of tabs.

the way how logseq implements this feature may give an inspiration. it establishes an external identifier manager, in which the annotation and the quoted are both linked to that identifier, once the annotation changes, the corresponding quoted text will also get updated. but this will also need too much effort.

3. by the way, is there any other way I could sponsor you? Neither GitHub sponsor nor buymeacoffee support PayPal, while I don't have any bank card which I can use directly on these websites

RyotaUshio commented 5 months ago

First of all, what makes you want to avoid just doing the copy-paste once again? Also, could you elaborate on what the workflow in your mind looks like exactly?


  1. As for the &selection=... syntax, I have already succeeded in deciphering it! So it will not be a big problem.

  2. update the quoted text with newly selected

Auto-updating not only the link itself but also the surrounding texts will be very difficult given the variety of custom copy formats. So as you suggest, the only feasible solution would be using embeds and updating the link text.

Updating link texts will not be difficult, but as you say, opening too many PDF embeds might degrade the performance. Opening PDF files is such a heavy job.

Can you kindly provide a reference for the Logseq feature you mentioned?

3. Thank you very much for considering to support me. It really means a lot to me. I will seek other options for how you can sponsor me!

SSmJaE commented 5 months ago

First of all, what makes you want to avoid just doing the copy-paste once again?

perfectionism

Also, could you elaborate on what the workflow in your mind looks like exactly?

It depends on the difficulty of implementing this feature, the workflow is already good enough, it's just another quality-of-life kind of enhancement

Can you kindly provide a reference for the Logseq feature you mentioned?

I just realized a more approachable way to achieve this

we need to keep sync between the link and quoted text (by a unique identifier), let us separate this into two problems

1. the first one is pretty easy, we can use query params like below

#page=60&selection=100,8,102,65&identifier=123123

2. the second one is the same as zotlit and flashcards-obsidian, we put an explicit identifier just around the quoted text meanwhile, we may need an HTML5 comment to wrap quoted text

<!-- customizable quote start --> <-- this will be hidden in `live preview` or `reading` mode
any template format
...
<!--customizable quote end -->
^123123    <-- explicit identifier in markdown file

3. as we have backlinks, we already have a mapping relationship between the identifier and file path, we could directly search(regex?) the identifier in that file, then replace the corresponding region

an example regex pattern

{customizable quote start}
.* <-- any text between
{customizable quote end}
\^(\d*)\n <--match the identifer
RyotaUshio commented 5 months ago

@SSmJaE I've just updated funding methods and added ko-fi, which supports PayPal! I appreciate your support and suggestions!


I see, so even after the text selection (&selection=...) changes, the identifier stays untouched, which allows us to locate the corresponding quote in the markdown file and update its content.

That's an interesting idea. But how should we handle the variety of copy template formats?

To make this happen, we will have to identify which template format was used for the quote. To make matters even worse, the quote might have been added with some arbitrary comments after pasting. When updating the quote, we need to avoid overwriting such comments. Also, we will have to take care of changes in copy template formats themselves.

SSmJaE commented 5 months ago

we will have to take care of changes

It's really quite simple; we don't have to change the text with 100 percent certainty. If it matches the pattern, we update it. If it doesn't match, we notify the user that we didn't find the supposed pattern.

how should we handle the variety of copy template formats?

image

I found that the html5 comment tag will still be visible in live preview mode, while other html5 tag like div, will also be hidden in live preview mode, and it can be inserted into callout, like what the picture illustrates.

Then we can save data as tag's attribute, which could also be used by regex pattern to locate it.

No matter what template format the user is using, once they have corresponding tag, we can locate and update them.

by the way, happy lunar new year

SSmJaE commented 5 months ago

hi, any ideas?🙃