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

Make the links in the variable explorer work the same as the links in the main notebook #4

Open
JackDevine opened this issue Mar 31, 2024 · 2 comments

Comments

@JackDevine
Copy link
Owner

If you Ctrl-click a variable in the notebook, then your screen scrolls so that the variable is in the center of the screen and then your cursor selects the variable.

If you click a variable in the explorer, then you are instantly moved to a location where the variable is at the top of the page.

@JackDevine
Copy link
Owner Author

I have made some progress on this by adding an 'onclick' event to the pluto-links that I generate:

get_pluto_link_str(s) = """
	<a href="#$s"
	   onclick="event.preventDefault();
	            document.querySelector('#$s').scrollIntoView(
	                {behavior: 'smooth', block: 'center'}
	            )"><span class="ͼo ͼ12">$s</span></a>"""

But I haven't worked out how to highlight the variable.

The bigger problem that I have with this approach is that it feels like I am re implementing certain Pluto internals.

@fonsp
Copy link

fonsp commented May 27, 2024

The code that does that is here:

https://github.com/fonsp/Pluto.jl/blob/92cd7f7af1ed8b3b20c334849a44d2d383600ed8/frontend/components/CellInput/go_to_definition_plugin.js#L119-L145

You just need to find the cell_id yourself. You can probably find it with document.querySelector(scrollto_selector).closest("pluto-cell").id or by searching the global variable editor_state.notebook.cell_dependencies

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