@@ -24,7 +24,7 @@ import { ReadonlyPartialJSONValue } from '@lumino/coreutils';
2424
2525import { INotebookModel } from '@jupyterlab/notebook' ;
2626
27- import { IRenderMimeRegistry } from '@jupyterlab/rendermime' ;
27+ import type { IRenderMime , IRenderMimeRegistry } from '@jupyterlab/rendermime' ;
2828
2929import { Kernel , KernelMessage , Session } from '@jupyterlab/services' ;
3030
@@ -224,6 +224,12 @@ 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+ }
227233 return cls ;
228234 }
229235
@@ -315,6 +321,21 @@ export abstract class LabWidgetManager
315321 await this . handle_comm_open ( oldComm , msg ) ;
316322 } ;
317323
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+
318339 protected _restored = new Signal < this, void > ( this ) ;
319340 protected _restoredStatus = false ;
320341 protected _kernelRestoreInProgress = false ;
0 commit comments