@jupyterlab/notebook-extension 4.6.1 → 4.6.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/index.js CHANGED
@@ -811,12 +811,18 @@ const activeCellTool = {
811
811
  activate: (
812
812
  // Register the custom field.
813
813
  app, tracker, formRegistry, languages) => {
814
+ // The field renderer is used by rjsf as a React component, so it runs on
815
+ // every rebuild of the metadata form. The tool is created once and reused:
816
+ // constructing one per render would rebuild the prompt and the preview from
817
+ // scratch (showing them empty until the next update) and would leave a
818
+ // connection to the cell model behind for every abandoned instance.
819
+ const tool = new ActiveCellTool({
820
+ tracker,
821
+ languages
822
+ });
814
823
  const component = {
815
824
  fieldRenderer: (props) => {
816
- return new ActiveCellTool({
817
- tracker,
818
- languages
819
- }).render(props);
825
+ return tool.render(props);
820
826
  }
821
827
  };
822
828
  formRegistry.addRenderer('@jupyterlab/notebook-extension:active-cell-tool.renderer', component);
@@ -1561,13 +1567,17 @@ function activateNotebookHandler(app, factory, extensions, executor, palette, de
1561
1567
  setSideBySideOutputRatio(factory.notebookConfig.sideBySideOutputRatio);
1562
1568
  const sideBySideMarginStyle = `.jp-mod-sideBySide.jp-Notebook .jp-Notebook-cell {
1563
1569
  margin-left: ${factory.notebookConfig.sideBySideLeftMarginOverride} !important;
1564
- margin-right: ${factory.notebookConfig.sideBySideRightMarginOverride} !important;`;
1570
+ margin-right: ${factory.notebookConfig.sideBySideRightMarginOverride} !important;
1571
+ }`;
1565
1572
  const sideBySideMarginTag = document.getElementById(SIDE_BY_SIDE_STYLE_ID);
1566
1573
  if (sideBySideMarginTag) {
1567
- sideBySideMarginTag.innerText = sideBySideMarginStyle;
1574
+ sideBySideMarginTag.textContent = sideBySideMarginStyle;
1568
1575
  }
1569
1576
  else {
1570
- document.head.insertAdjacentHTML('beforeend', `<style id="${SIDE_BY_SIDE_STYLE_ID}">${sideBySideMarginStyle}}</style>`);
1577
+ const style = document.createElement('style');
1578
+ style.id = SIDE_BY_SIDE_STYLE_ID;
1579
+ style.textContent = sideBySideMarginStyle;
1580
+ document.head.appendChild(style);
1571
1581
  }
1572
1582
  factory.autoStartDefault = settings.get('autoStartDefaultKernel')
1573
1583
  .composite;