0

I need to warn the user if User closes the MainArea widget in Jypyter lab, which contains my custom extension, any suggession on how to do this ?

jupyterLab is the app instance I popdrilled from Index.ts

``
`
if (jupyterLab) {
// TODO if the course is being edited set the widgets set confirmClosingDocument true
// this field is not in main area widget it is inside document widget
console.log('$# jupyter lab ', jupyterLab);
// jupyterLab.shell.currentWidget.set('confirmClosingDocument',true)
// find active tab using class
const activeTab = document.getElementsByClassName('p-mod-current')\[0\];
// retrieve selected tab title
const titleDiv = activeTab.getElementsByTagName('div')\[1\].innerHTML;
if (titleDiv === 'Course Builder') {
// if title is Course Builder add event listenel to that element
// in progress and stuck
activeTab
.getElementsByTagName('div')\[2\]
.addEventListener('click', e =\> {
e.preventDefault();
Swal.fire('Testing for closing event of jupyuter lab');
});`your text`
}
}
`
``

just like this enter image description here on the close button click from MainAreaWidget enter image description here

0 Answers0