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

Question, not really an issue... #52

Open
gregko opened this issue Feb 9, 2023 · 3 comments
Open

Question, not really an issue... #52

gregko opened this issue Feb 9, 2023 · 3 comments

Comments

@gregko
Copy link

gregko commented Feb 9, 2023

Would it be possible to scroll textarea to the subsequent highlights, e.g. on a press on a button? I'd like to implement RegEx search within a (long, multiline) textarea, and this will highlight the results nicely, but the user would need to jump at will between the results found - just like in a regular text find on a webpage...
How could this be achieved?

@gregko
Copy link
Author

gregko commented Feb 9, 2023

Actually it was easier than I thought...

let marks = [...document.getElementsByTagName("mark")];
textarea.scrollTop = marks[3].offsetTop;

etc.... I'm assuming above that there is only one textarea on the page, as is in my usage scenario, and there are no elements other than added by the highlight script.

@AramBakir
Copy link

@gregko Did you solve the problem?

@gregko
Copy link
Author

gregko commented Feb 12, 2023

Yes, I wrote about my solution in the 2nd post in this thread... The first line collects all elements that HWT generated, and the second line tells you how to scroll to any mark element in the marks array.

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

No branches or pull requests

2 participants