Skip to content

Commit 388c782

Browse files
committed
try a different approach
1 parent c52e9cd commit 388c782

File tree

2 files changed

+14
-23
lines changed

2 files changed

+14
-23
lines changed

packages/controls/src/widget_description.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,19 @@ export class DescriptionView extends DOMWidgetView {
6666
}
6767

6868
typeset(element: HTMLElement, text?: string): void {
69-
this.displayed.then(() => typeset(element, text));
69+
this.displayed.then(() => {
70+
if ((window as any).MathJax) {
71+
return typeset(element, text);
72+
}
73+
const widget_manager: any = this.model.widget_manager;
74+
const latexTypesetter = widget_manager.rendermime?.latexTypesetter;
75+
if (latexTypesetter) {
76+
if (text !== void 0) {
77+
element.textContent = text;
78+
}
79+
latexTypesetter.typeset(element);
80+
}
81+
});
7082
}
7183

7284
updateDescription(): void {

python/jupyterlab_widgets/src/manager.ts

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import { ReadonlyPartialJSONValue } from '@lumino/coreutils';
2424

2525
import { INotebookModel } from '@jupyterlab/notebook';
2626

27-
import type { IRenderMime, IRenderMimeRegistry } from '@jupyterlab/rendermime';
27+
import { IRenderMimeRegistry } from '@jupyterlab/rendermime';
2828

2929
import { Kernel, KernelMessage, Session } from '@jupyterlab/services';
3030

@@ -224,12 +224,6 @@ export abstract class LabWidgetManager
224224
if (!cls) {
225225
throw new Error(`Class ${className} not found in module ${moduleName}`);
226226
}
227-
if (
228-
moduleName === '@jupyter-widgets/controls' &&
229-
this._rendermime.latexTypesetter
230-
) {
231-
void this._patchTypeset(this._rendermime.latexTypesetter);
232-
}
233227
return cls;
234228
}
235229

@@ -321,21 +315,6 @@ export abstract class LabWidgetManager
321315
await this.handle_comm_open(oldComm, msg);
322316
};
323317

324-
/**
325-
* Patch typesetting in `@jupyter-widgets/controls` to use the rendermime's typesetter.
326-
*/
327-
protected async _patchTypeset(
328-
latexTypesetter: IRenderMime.ILatexTypesetter
329-
): Promise<void> {
330-
const controls = await import('@jupyter-widgets/controls/lib/utils');
331-
controls.typeset = (element: HTMLElement, text?: string): void => {
332-
if (text !== void 0) {
333-
element.textContent = text;
334-
}
335-
latexTypesetter.typeset(element);
336-
};
337-
}
338-
339318
protected _restored = new Signal<this, void>(this);
340319
protected _restoredStatus = false;
341320
protected _kernelRestoreInProgress = false;

0 commit comments

Comments
 (0)