@@ -8,15 +8,24 @@ import { type RegisterLocalProcessExtensionResult } from '@codingame/monaco-vsco
8
8
import React from 'react' ;
9
9
import ReactDOM from 'react-dom/client' ;
10
10
import { MonacoEditorReactComp } from '@typefox/monaco-editor-react' ;
11
- import { MonacoEditorLanguageClientWrapper , type TextChanges } from 'monaco-editor-wrapper' ;
11
+ import { MonacoEditorLanguageClientWrapper , type TextContents } from 'monaco-editor-wrapper' ;
12
12
import { createWrapperConfig } from './config.js' ;
13
13
import { confiugureDebugging } from '../../debugger/client/debugger.js' ;
14
14
15
15
export const runPythonReact = async ( ) => {
16
16
const appConfig = createWrapperConfig ( ) ;
17
-
18
- const onTextChanged = ( textChanges : TextContents ) => {
19
- console . log ( `text: ${ textChanges . modified } \ntextOriginal: ${ textChanges . original } ` ) ;
17
+
18
+ const onLoad = async ( wrapper : MonacoEditorLanguageClientWrapper ) => {
19
+ const result = wrapper . getExtensionRegisterResult ( 'mlc-python-example' ) as RegisterLocalProcessExtensionResult ;
20
+ result . setAsDefaultApi ( ) ;
21
+
22
+ const initResult = wrapper . getExtensionRegisterResult ( 'debugger-py-client' ) as RegisterLocalProcessExtensionResult | undefined ;
23
+ if ( initResult !== undefined ) {
24
+ confiugureDebugging ( await initResult . getApi ( ) , appConfig . configParams ) ;
25
+ }
26
+
27
+ await vscode . commands . executeCommand ( 'workbench.view.explorer' ) ;
28
+ await vscode . window . showTextDocument ( appConfig . configParams . files . get ( 'hello2.py' ) ! . uri ) ;
20
29
} ;
21
30
22
31
const root = ReactDOM . createRoot ( document . getElementById ( 'react-root' ) ! ) ;
@@ -27,19 +36,7 @@ export const runPythonReact = async () => {
27
36
< MonacoEditorReactComp
28
37
wrapperConfig = { appConfig . wrapperConfig }
29
38
style = { { 'height' : '100%' } }
30
- onTextChanged = { onTextChanged }
31
- onLoad = { async ( wrapper : MonacoEditorLanguageClientWrapper ) => {
32
- const result = wrapper . getExtensionRegisterResult ( 'mlc-python-example' ) as RegisterLocalProcessExtensionResult ;
33
- result . setAsDefaultApi ( ) ;
34
-
35
- const initResult = wrapper . getExtensionRegisterResult ( 'debugger-py-client' ) as RegisterLocalProcessExtensionResult | undefined ;
36
- if ( initResult !== undefined ) {
37
- confiugureDebugging ( await initResult . getApi ( ) , appConfig . configParams ) ;
38
- }
39
-
40
- await vscode . commands . executeCommand ( 'workbench.view.explorer' ) ;
41
- await vscode . window . showTextDocument ( appConfig . configParams . files . get ( 'hello2.py' ) ! . uri ) ;
42
- } }
39
+ onLoad = { onLoad }
43
40
onError = { ( e ) => {
44
41
console . error ( e ) ;
45
42
} } />
0 commit comments