-
Notifications
You must be signed in to change notification settings - Fork 391
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
Use Cell's index in the notebook as its ID #81
Conversation
cc54675
to
a7a4b6f
Compare
This is really great! One condition: if we ever decide to change the identifier type again (i.e. there's complaint about the 32,767 limit on cells in a notebook), we'll make a |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It won't let me comment on the lines you didn't change 😛
Here we're creating a new (JS) NotebookCell
with newCell.id
which is still a string. Won't this cause inserting a cell to fail? I think the Cell
classes need to be updated to deal with the numeric ID (and how to map that to an id
attribute for their container element).
polynote/polynote-frontend/polynote/ui.js
Line 766 in df3637d
this.socket.send(new messages.InsertCell(path, this.globalVersion, this.localVersion++, new messages.NotebookCell(newCell.id, newCell.language, ''), current.id)); |
I like this idea a lot - I renamed a bunch of parameters from |
@@ -761,7 +761,7 @@ export class NotebookUI { | |||
|
|||
this.cellUI.addEventListener('InsertCellAfter', evt => { | |||
const current = this.cellUI.cells[evt.detail.cellId] || this.cellUI.cells[this.cellUI.el.querySelector('.cell-container').id]; | |||
const nextId = "Cell" + this.cellUI.cellCount; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jeremyrsmith As far as I could tell this looked like the only change that needed to be done - not sure if you had anything else in mind when you said
I think the
Cell
classes need to be updated to deal with the numeric ID (and how to map that to anid
attribute for their container element).
I wasn't able to find any other place where we explicitly do stringy things to the cell id but I definitely could've missed something.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm... I guess the only other issue is that the ID passed to the cell constructor also ends up as a DOM element ID. For example now we'll have something like <div id="1">
in the DOM. This isn't a legal id
in HTML 4, though I guess it now is in HTML 5... but still doesn't seem like a good idea.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok! restored previous html ids :)
c38677e
to
8727d97
Compare
Cell ID is now a short and we no longer read execution count. This is possible now due to the changes in #76 which eliminates our need to persist cell IDs in the order they were created.
Addresses #70 as it was due to id space collisions when reading execution count.