@@ -5,11 +5,7 @@ import {
5
5
} from '@jupyterlab/application' ;
6
6
import { ICommandPalette , IThemeManager } from '@jupyterlab/apputils' ;
7
7
import { IDocumentManager } from '@jupyterlab/docmanager' ;
8
- import {
9
- INotebookTracker ,
10
- NotebookPanel ,
11
- NotebookActions
12
- } from '@jupyterlab/notebook' ;
8
+ import { INotebookTracker , NotebookPanel } from '@jupyterlab/notebook' ;
13
9
import { ITranslator } from '@jupyterlab/translation' ;
14
10
import {
15
11
NotebookEventType ,
@@ -18,12 +14,9 @@ import {
18
14
onNotebookRequested ,
19
15
send
20
16
} from './events' ;
17
+ import { kernels } from './kernels' ;
21
18
22
- export const kernels = {
23
- gluePySpark : 'glue_python_kernel' ,
24
- glueSpark : 'glue_scala_kernel'
25
- } ;
26
-
19
+ const cellNodes = new Set ( ) ;
27
20
const activate = (
28
21
app : JupyterFrontEnd ,
29
22
labShell : ILabShell ,
@@ -101,25 +94,33 @@ const activate = (
101
94
buttonContainer . appendChild ( downloadButton ) ;
102
95
103
96
/* NOTE: Try this if you need to run content programatically */
104
- NotebookActions . run (
105
- notebookPanel . content ,
106
- notebookPanel . sessionContext
107
- ) ;
108
-
109
- /**
110
- * Every time the notebook changes we send it to Glue Studio to keep track of its state.
111
- * But only after the notebook has been initialized.
112
- */
113
- notebookTracker . activeCellChanged . connect ( async ( tracker , cell ) => {
114
- // Note: Datasets only store string values that's why we compare against a string
115
- if ( body . dataset . glueInitialized === 'true' ) {
116
- onNotebookChange ( tracker ) ;
117
- }
118
- } ) ;
97
+ // NotebookActions.run(
98
+ // notebookPanel.content,
99
+ // notebookPanel.sessionContext
100
+ // );
119
101
}
120
102
) ;
121
103
} ) ;
122
104
105
+ /**
106
+ * Every time the notebook changes we send it to Glue Studio to keep track of its state.
107
+ * But only after the notebook has been initialized.
108
+ */
109
+ notebookTracker . activeCellChanged . connect ( async ( tracker , cell ) => {
110
+ const body = document . querySelector ( 'body' ) ;
111
+ // Note: Datasets only store string values that's why we compare against a string
112
+ if ( body . dataset . glueInitialized === 'true' && ! cellNodes . has ( cell . node ) ) {
113
+ onNotebookChange ( tracker ) ;
114
+
115
+ const cb = ( ) => {
116
+ onNotebookChange ( tracker ) ;
117
+ } ;
118
+
119
+ cell . model . contentChanged . connect ( cb ) ;
120
+ cellNodes . add ( cell . node ) ;
121
+ }
122
+ } ) ;
123
+
123
124
/**
124
125
* This event is fired once the current notebook widget is loaded. In the container
125
126
* window, if the iframe is rendered without the notebook widget, the users will see an
0 commit comments