Code Monkey home page Code Monkey logo

Comments (7)

markellekelly avatar markellekelly commented on June 5, 2024

@ian-r-rose As an update - I have been working on this, but it is taking a bit longer than expected as it involves converting a lot of the code to use promises. I feel like it is making things more complicated than it is worth; let me know if you have any thoughts on this.

from jupyterlab-toc.

ian-r-rose avatar ian-r-rose commented on June 5, 2024

Hi @markellekelly, thanks for looking into this. A few thoughts off of the top of my head:

I agree that using the StateDB would definitely make things more complicated. I think that most of the code could still be synchronous, however. I don't know how you are architecting it, but I could imagine that something like this could work:

  1. The ToC widget still generates and renders tables of contents synchronously. By default it shows all entries.
  2. However, it has a settable property, something like "collapsedState" that allows the ToC to rerender with the collapsed state.
  3. We decide on some serializable format that can be stored in the IStateDB to keep the collapsed state between refreshes.
  4. When a new document is opened, we fetch the collapsed state from the IStateDB. It can be rendered immediately in the uncollapsed state, and then we can apply the view state once it comes in.

Do you think that would work? Feel free to let me know if you would like to set up a video chat to talk through any of this.

from jupyterlab-toc.

markellekelly avatar markellekelly commented on June 5, 2024

@ian-r-rose That will likely be much simpler than what I'm currently doing. I'll look into it and let you know if any questions come up. Thanks!

from jupyterlab-toc.

markellekelly avatar markellekelly commented on June 5, 2024

@ian-r-rose Finally got a chance to look into this! One question: I'm having trouble getting the collapse onClick in the notebook item renderer to alter the statedb. The state is updated immediately after state.save (i.e. when checked within the same function call) but this isn't reflected the next time the function is called. I'm guessing this has to do with how I'm passing statedb in, could you take a look and let me know if you have any suggestions? https://github.com/markellekelly/jupyterlab-toc/tree/statedb (main file in question is src/generators/notebookgenerator/itemrenderer)

from jupyterlab-toc.

ian-r-rose avatar ian-r-rose commented on June 5, 2024

Sorry for taking so long to respond @markellekelly! Changing employment, life stuff, got way behind... :(
I'm taking a look at your branch now.

from jupyterlab-toc.

markellekelly avatar markellekelly commented on June 5, 2024

Hi @ian-r-rose! I pretty much have a working version based on your suggestions but am stuck on a serializable format to use as a key in StateDB. Storing notebook-by-notebook would be ideal but that might be tough to do. Did you have any ideas about this?

from jupyterlab-toc.

ian-r-rose avatar ian-r-rose commented on June 5, 2024

Hi @markellekelly that's great to hear! One key that we have used before to store items in the statedb is ${path}:${factory}, so a key would be something like 'Untitled.ipynb:notebook'.

from jupyterlab-toc.

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.