Can't create a sub-notebook by a command

Btw, can I ask how to create a new subnotebook under the currently opened notebook?
It create a notebook globally, the dialog is


Only when I use the mouse and right-click the selected notebook, it prompts the desired dialog

That is correct behavior. You have to right-click a notebook on the sidebar to create a new sub-notebook.
If you are in workspace view, a notebook will be created under the current notebook.

After I switched the workspace view, the command ‘core:new-notebook’ still malfunctioned, here are the steps to reproduce:

  1. Change the workspace to the desired notebook:
  2. Use the ‘core:new-notebook’ command and It creates a new notebook globally

Only when I manually clicked the ‘Add notebook’ button in the sidebar, it created a new sub-notebook in the current notebook.


I figure the ‘Add notebook’ button and the ‘core:new-notebook’ are not synced.

Is there any way to create a subnotebook under the current notebook with keybindings? I am using the switch-notebook plugin as ctrl-shift-p, can I do anything to combine with this?

Ah that makes sense.
You have to specify parentBookId when invoking the core:new-notebook command.
It was missing in the documentation. Updated:

You can make a custom command for accomplishing that like so:

inkdrop.commands.add(document.body, {
  'custom:create-sub-notebook': () => {
    const { queryContext } = inkdrop.store.getState()
    const currentBookId = inkdrop.store.getState().queryContext.bookId
    inkdrop.commands.dispatch(document.body, 'core:new-notebook', { parentBookId: currentBookId })
  }
})

References:

Hope that helps!

Thank you so much! It works perfectly now.

1 Like