-
-
Notifications
You must be signed in to change notification settings - Fork 63
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
Clicking a PDF annotation link now causes an immediate jump to the annotation in markdown-source-view #257
Conversation
…notation in markdown-source-view
|
||
public pdfAnnotatorFileModes: { [file: string]: string } = {}; | ||
private _loaded = false; | ||
private eventRefs: EventRef[] = []; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use an array to store the events of Obsidian, which is convenient for closing events when closing the software
@@ -356,25 +389,188 @@ export default class AnnotatorPlugin extends Plugin implements IHasAnnotatorSett | |||
private addMarkdownPostProcessor() { | |||
const markdownPostProcessor = async (el: HTMLElement, ctx: MarkdownPostProcessorContext) => { | |||
for (const link of el.getElementsByClassName('internal-link') as HTMLCollectionOf<HTMLAnchorElement>) { | |||
const parsedLink = parseLinktext(link.href); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The form of link.href
does not work on Windows, and link.getAttribute("href")
works.
} | ||
} | ||
|
||
linkOnFocus(element: Element) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this.tmpLinkInfos.push({linkText: linkText, count: count}); | ||
} | ||
|
||
linkOnBlur(node: Element, rawLinkText: string, filePath: string, className: string) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @aladmit , I have added a new feature to the project which is to jump directly to the PDF by clicking on the PDF annotation link in markdown-source-view. And fixed #251.
Click:
Click while holding
ctrl
:PS. Ignore the modifications other than
src/main.tsx
, because I don't know why so many files were added, maybe because I developed it with windows11?Implementation
Add a file-open listener in Obsidian, add a click event to the PDF annotation link and let MutationObserver observe the PDF annotation link in that listener
Test Objects
A PDF annotation link in one line
A PDF annotation link with multi-line aliases in one line
A PDF annotation link with multi-line aliases and two normal PDF annotation links in one line
A PDF annotation link with multi-line aliases and a normal link in one line
PDF annotation link in list
PDF annotation links in other formats