activate: (app: JupyterLab): ITooltipManager => { let tooltip: Tooltip | null = null; // Add tooltip dismiss command. app.commands.addCommand(CommandIDs.dismiss, { execute: () => { if (tooltip) { tooltip.dispose(); tooltip = null; } } }); return { invoke(options: ITooltipManager.IOptions): Promise<void> { const detail: 0 | 1 = 0; const { anchor, editor, kernel, rendermime } = options; if (tooltip) { tooltip.dispose(); tooltip = null; } return Private.fetch({ detail, editor, kernel }).then(bundle => { tooltip = new Tooltip({ anchor, bundle, editor, rendermime }); Widget.attach(tooltip, document.body); }).catch(() => { /* Fails silently. */ }); } }; }
execute: () => { if (tooltip) { tooltip.dispose(); tooltip = null; } }