Skip to content

Custom Plugin - is last cell logic #102

Answered by unhott
twoxfh asked this question in Q&A
Discussion options

You must be logged in to vote

I think that should be technically straightforward.
ES Module cell:

export const plugin = {
  id: "test",
  metadata: {
    name: "test",
  },
  exports: {},
  async register(runtime, opts) {
    runtime.dom.notebook.addEventListener("sb:run_cell", (event) => {
      let currentCellId = event.target.id;
      
      let rt = event.target.runtime;
      let cells = rt.dom.cells;
      let lastCellId = cells[cells.length-1].id;
      let isLastCell = currentCellId == lastCellId;
      console.log(isLastCell);
    });
  }
};

runtime.controls.registerPlugin(plugin)

I am not confident if this is the right approach for your problem, though!
Good luck :)

Replies: 1 comment 4 replies

Comment options

You must be logged in to vote
4 replies
@twoxfh
Comment options

@unhott
Comment options

@twoxfh
Comment options

@unhott
Comment options

Answer selected by twoxfh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants