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

Add scroll to highlighted lines #185

Merged
merged 5 commits into from
Jul 3, 2024

Conversation

fabricionaweb
Copy link
Contributor

This is related to issue #175 but I also did some more work, sorry I couldnt resist 😇

  • changed a little the getSelectedLines:
    location.hash will always return string so no need the optional channing
  • changed a little the highlightLines:
    getSelectedLines will always return array and already check the location.hash before so I replaced that if and add some deconstruct assignment, just small changes to reduce some lines
  • changed the setAttribute/removeAttribute for toggleAttribute with force parameter, just small change to reduce some lines
  • added a new method scrollToLine to scroll to the highlighted lines
    it unfortunatelly "needs" the setTimeout in order to always get fired, otherwise it will only works for a new page load (not for refresh). It does works better having it.
  • added a new block inside watchForShiftClick to disable native click on go to top to prevent it to remove the currently highlighted lines
  • removed async/await from DOMContentLoaded as it is not needed

Copy link
Owner

@robherley robherley left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall looks good 👍 one tiny question

await mermaid.run({
querySelector: "code.language-mermaid",
});
mermaid.run({ querySelector: "code.language-mermaid" });
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a specific reason why you removed the await? It's an async function, and in the mermaid docs examples it's awaited: https://mermaid.js.org/config/usage.html#using-mermaid-run

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

eh, it's fine as-is. i'll merge and sneak this into the latest release

@robherley robherley merged commit 1a74356 into robherley:main Jul 3, 2024
5 checks passed
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

Successfully merging this pull request may close these issues.

None yet

2 participants