Giter VIP home page Giter VIP logo

Comments (6)

tkrabel avatar tkrabel commented on July 19, 2024 1

Never mind everyone, I added the feature myself with PR #46.

from pyforest.

tnwei avatar tnwei commented on July 19, 2024

Seconding this! I'm sure many of use have the first cell in markdown as the title block. Wondering what type of fix would be needed? Not familiar with JS, but I'm assuming this chunk in src/pyforest/_importable.py is where it needs to go:

display(
        Javascript(
            """
        if (window._pyforest_update_imports_cell) {{ window._pyforest_update_imports_cell({!r}); }}
    """.format(
                "\n".join(statements)
            )
        )
    )

from pyforest.

8080labs avatar 8080labs commented on July 19, 2024

Happy to hear that you also thought about this :)

I am afraid, that the fix needs to be in JS and not in Python.
Most likely somewhere around here in src/pyforest/static/utils.js

	function setup_lab(notebookTracker) {
		window._pyforest_update_imports_cell = function (imports_string) {
			var cell = notebookTracker.currentWidget.model.cells.get(0).value;
			cell.text = get_new_cell_content(imports_string, cell.text);
		};
	}

	function setup_notebook(Jupyter) {
		window._pyforest_update_imports_cell = function (imports_string) {
			var cell_doc = Jupyter.notebook.get_cell(0).code_mirror.getDoc();
			cell_doc.setValue(get_new_cell_content(imports_string, cell_doc.getValue()));
		};
	}

Because this is the position where pyforest selects the cell to be updated. Currently, it is just the first cell.

from pyforest.

tnwei avatar tnwei commented on July 19, 2024

Mmmm. Adding this and using the return value should do it. https://gist.github.com/tnwei/6005afe55cb8898ba87daa36fce23392

from pyforest.

tnwei avatar tnwei commented on July 19, 2024

Submitted a pull request, feedback appreciated!

from pyforest.

tkrabel avatar tkrabel commented on July 19, 2024

Just for the protocol: the last state of your PR #29 was that you need to find a way to make your PR work on JupyterLab. Any progress here? Can someone else help?

from pyforest.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.