mirror of
https://github.com/wassname/jupyter_contrib_nbextensions.git
synced 2026-09-12 12:31:30 +08:00
[toc2] add backwards-compatibility for html exported with old versions of toc2
this is accomplished by defining a window.table_of_contents function synchronously in the first pass of the file, so that it can be called by subsequent scripts in a page.
This commit is contained in:
@@ -684,3 +684,14 @@ var table_of_contents = function (cfg,st) {
|
||||
toggle_toc: toggle_toc,
|
||||
};
|
||||
});
|
||||
// export table_of_contents to global namespace for backwards compatibility
|
||||
// Do export synchronously, so that it's defined as soon as this file is loaded
|
||||
if (!require.specified('base/js/namespace')) {
|
||||
window.table_of_contents = function (cfg, st) {
|
||||
// use require to ensure the module is correctly loaded before the
|
||||
// actual call is made
|
||||
require(['nbextensions/toc2/toc2'], function (toc2) {
|
||||
toc2.table_of_contents(cfg, st);
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user