@@ -38,6 +38,7 @@ internal inline fun <reified T : Any> JupyterHtmlRenderer.render(
3838 crossinline modifyConfig : T .(DisplayConfiguration ) -> DisplayConfiguration = { it },
3939 applyRowsLimit : Boolean = true,
4040) = builder.renderWithHost<T > { host, value ->
41+ val addHtml = (value as ? DisableRowsLimitWrapper )?.addHtml ? : true
4142 val contextRenderer = JupyterCellRenderer (this .notebook, host)
4243 val reifiedDisplayConfiguration = value.modifyConfig(display)
4344 val footer = getFooter(value)
@@ -53,20 +54,22 @@ internal inline fun <reified T : Any> JupyterHtmlRenderer.render(
5354 df.rowsCount()
5455 }
5556
56- val html = DataFrameHtmlData
57- .tableDefinitions(
58- includeJs = reifiedDisplayConfiguration.isolatedOutputs,
59- includeCss = true ,
60- ).plus(
61- df.toHtml(
62- // is added later to make sure it's put outside of potential iFrames
63- configuration = reifiedDisplayConfiguration.copy(enableFallbackStaticTables = false ),
64- cellRenderer = contextRenderer,
65- ) { footer },
66- ).toJupyterHtmlData()
57+ val html by lazy {
58+ DataFrameHtmlData
59+ .tableDefinitions(
60+ includeJs = reifiedDisplayConfiguration.isolatedOutputs,
61+ includeCss = true ,
62+ ).plus(
63+ df.toHtml(
64+ // is added later to make sure it's put outside of potential iFrames
65+ configuration = reifiedDisplayConfiguration.copy(enableFallbackStaticTables = false ),
66+ cellRenderer = contextRenderer,
67+ ) { footer },
68+ ).toJupyterHtmlData()
69+ }
6770
6871 // Generates a static version of the table which can be displayed in GitHub previews etc.
69- val staticHtml = df.toStaticHtml(reifiedDisplayConfiguration, DefaultCellRenderer ).toJupyterHtmlData()
72+ val staticHtml by lazy { df.toStaticHtml(reifiedDisplayConfiguration, DefaultCellRenderer ).toJupyterHtmlData() }
7073
7174 if (notebook.kernelVersion >= KotlinKernelVersion .from(MIN_KERNEL_VERSION_FOR_NEW_TABLES_UI )!! ) {
7275 val ideBuildNumber = KotlinNotebookPluginUtils .getKotlinNotebookIDEBuildNumber()
@@ -94,8 +97,13 @@ internal inline fun <reified T : Any> JupyterHtmlRenderer.render(
9497 )
9598 }
9699 }
97-
98- notebook.renderAsIFrameAsNeeded(data = html, staticData = staticHtml, jsonEncodedDf = jsonEncodedDf)
100+ if (! addHtml) {
101+ mimeResult(
102+ " application/kotlindataframe+json" to jsonEncodedDf,
103+ )
104+ } else {
105+ notebook.renderAsIFrameAsNeeded(data = html, staticData = staticHtml, jsonEncodedDf = jsonEncodedDf)
106+ }
99107 } else {
100108 notebook.renderHtmlAsIFrameIfNeeded(data = html)
101109 }
0 commit comments