Skip to content

Commit 7b064c9

Browse files
committed
Add support for interceptor receive
1 parent 7b51568 commit 7b064c9

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

src/jupyteredit.jsx

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,20 @@ export class JupyterEdit extends Component {
3333

3434
componentDidMount() {
3535
window.addEventListener('message', this.onMessage)
36+
if (this.props.receiveInterceptorUpdate) {
37+
this.activateInterceptor(true)
38+
}
3639
}
3740

3841
componentDidUpdate(prevProps) {
3942
if (this.props.appid !== prevProps.appid) {
4043
this.activateApp()
4144
}
45+
if (
46+
this.props.receiveInterceptorUpdate !== prevProps.receiveInterceptorUpdate
47+
) {
48+
this.activateInterceptor(!!this.props.receiveInterceptorUpdate)
49+
}
4250
}
4351

4452
componentWillUnmount() {
@@ -107,6 +115,13 @@ export class JupyterEdit extends Component {
107115
})
108116
}
109117

118+
activateInterceptor(activate) {
119+
return this.sendToIFrameAndReceive({
120+
type: 'activateInterceptor',
121+
activate
122+
})
123+
}
124+
110125
onMessage(event) {
111126
if (event.origin !== new URL(jupyterurl).origin) return
112127
const data = event.data
@@ -174,6 +189,12 @@ export class JupyterEdit extends Component {
174189
case 'reportKernelStatus':
175190
this.props?.kernelStatusCallback?.(data.status)
176191
break
192+
case 'sendInterceptorUpdate':
193+
{
194+
const { path, mime, state } = data
195+
this.props?.receiveInterceptorUpdate?.({ path, mime, state })
196+
}
197+
break
177198
default:
178199
}
179200
}

0 commit comments

Comments
 (0)