ipython-contrib / jupyter_contrib_nbextensions

A collection of various notebook extensions for Jupyter
http://jupyter-contrib-nbextensions.readthedocs.io/en/latest
Other
5.2k stars 806 forks source link

Code_prettify button registration broken #1519

Closed achampion closed 3 years ago

achampion commented 3 years ago

Versions:

notebook                          6.1.1
jupyter-contrib-nbextensions      0.5.1
jupyter-client                    6.1.6

Looking at the console I see all of the code_prettify extensions fail to load with button registration issues:

[code_prettify] error loading: TypeError: Cannot read property 'help' of undefined
    at toolbar.js:98
    at Array.forEach (<anonymous>)
    at MainToolBar.ToolBar.add_buttons_group (toolbar.js:85)
    at KernelExecOnCells.add_toolbar_button (kernel_exec_on_cell.js?v=20200811234053:199)
    at KernelExecOnCells.setup_for_new_kernel (kernel_exec_on_cell.js?v=20200811234053:277)
    at on_success (kernel_exec_on_cell.js?v=20200811234053:337)

I changed the KernelExecOnCells.prototype.add_toolbar_button function to:

KernelExecOnCells.prototype.add_toolbar_button = function() {
    var button_group_id = this.mod_name + '_button';
    if ($('#' + button_group_id).length < 1) {
        $(Jupyter.toolbar.add_buttons_group([this.cfg.actions.process_selected.name])).find('.btn').attr('id', button_group_id);
    }
};

To get it working again and seems a simpler approach than the current implementation.

rgbkrk commented 3 years ago

This is an issue in the current jupyter notebook release affecting extensions that I've fixed here: https://github.com/jupyter/notebook/pull/5676

rgbkrk commented 3 years ago

Please upgrade to notebook 6.1.4 and let me know if it fixes the issue.

achampion commented 3 years ago

6.1.3 on Pypi fixed the issue, thanks.