Git Product home page Git Product logo

Comments (4)

gzuidhof avatar gzuidhof commented on May 29, 2024

Hi IntranetFactory,

It mimics the Jupyter notebook behavior right now. So it's intentional, it has the same behavior for the shortcuts too:

        this.addEventListener('keydown', (event) => {
            if (event.key === 'Enter') {
                if (event.ctrlKey) {
                    this.runtime.controls.emit({ id: this.cell.id, type: "RUN_CELL", focusNextCell: false, insertNewCell: false });
                } else if (event.shiftKey) {
                    this.runtime.controls.emit({ id: this.cell.id, type: "RUN_CELL", focusNextCell: true, insertNewCell: false });
                } else if (event.altKey) {
                    this.runtime.controls.emit({ id: this.cell.id, type: "RUN_CELL", focusNextCell: true, insertNewCell: true });
                }
            }
        });

It kind of makes sense for their usecase as it originates from a REPL (ipython), but I'm not sure it's something that makes sense for Starboard moving forward. I'm considering changing that behavior.

from starboard-notebook.

IntranetFactory avatar IntranetFactory commented on May 29, 2024

So not a bug but a feature. It seemed so broken that I assumed that there must be some wired reason for that behavior.

Do you have any plans to make the editor configurable? For my use case I'd like to disable that "feature", remove some cell types, and replace the # %% with ``` (so persist the notebook as markdown) and I'm wondering if I should fork or if you might consider to add configuration or accept a PR ?

from starboard-notebook.

gzuidhof avatar gzuidhof commented on May 29, 2024

Yeah I imagine we can change that behavior w.r.t. last cell insertion, or at least allow it to be configured.

I've thought about the format for a long time for notebooks, and persisting cells as completely valid markdown is not really possible. Three issues from the top of my head:

Cells have metadata, as they do in most notebook systems, which can be any arbitrary data. While you can put some tags (see example below), how would you put richer data in there and how would we escape it? Squeezing it as a JSON string or something on a single line defeats any git diff friendliness (as well as becoming a huge pain to edit manually).

   ```javascript tag1 tag2 tag3
   console.log("hello")
    ```

Secondly there is the issue of code blocks in a markdown cell itself, what happens if I type ` or add it in some markdown content and serialize it: does it become a cell upon loading? What if code in a cell contains that string (it starts a multiline string in some languages!). How about if I type only a single ` tag, and forget the second one in content, will a new cell start?

Thirdly what is the "outer" cell? Is any content not inside a cell considered as markdown? Can we have a markdown cell within a markdown cell? How is HTML treated in markdown?


I am not trying dissuade you, but I think it is simply difficult to map it to normal markdown and back. What I propose would be performing this conversion back and forth (markdown to notebook format) outside of the editor itself in your own project, which would give you complete freedom. Depending on your usecase maybe none of the above will be issues.

It can make sense to "export" a notebook as markdown, but with some information loss.

Curious what you are looking to build!

from starboard-notebook.

gzuidhof avatar gzuidhof commented on May 29, 2024

I have changed the behavior - it no longer adds a new cell at the end.

from starboard-notebook.

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.