@@ -13,9 +13,7 @@ import {FlyToInterpolator} from '@deck.gl/core';
13
13
import { JSONConverter , JSONConfiguration , _shallowEqualObjects } from '@deck.gl/json' ;
14
14
import JSON_CONVERTER_CONFIGURATION from './configuration' ;
15
15
16
- import AceEditor from 'react-ace' ;
17
- import 'brace/mode/json' ;
18
- import 'brace/theme/github' ;
16
+ import Editor from '@monaco-editor/react' ;
19
17
20
18
import JSON_TEMPLATES from '../json-examples' ;
21
19
@@ -47,21 +45,18 @@ function addUpdateTriggersForAccessors(json) {
47
45
}
48
46
49
47
export default class App extends Component {
50
- constructor ( props ) {
51
- super ( props ) ;
48
+ jsonConverter : JSONConverter ;
52
49
53
- this . state = {
54
- // react-ace
55
- text : '' ,
56
- // deck.gl JSON Props
57
- jsonProps : { } ,
58
- initialViewState : null
59
- } ;
50
+ state = {
51
+ // editor
52
+ text : '' ,
53
+ // deck.gl JSON Props
54
+ jsonProps : { } as Record < string , unknown > ,
55
+ initialViewState : null as Record < string , any > | null
56
+ } ;
60
57
61
- // TODO/ib - could use arrow functions
62
- // keeping like this for now to allow this code to be copied back to deck.gl
63
- this . _onTemplateChange = this . _onTemplateChange . bind ( this ) ;
64
- this . _onEditorChange = this . _onEditorChange . bind ( this ) ;
58
+ constructor ( props ) {
59
+ super ( props ) ;
65
60
66
61
// Configure and create the JSON converter instance
67
62
const configuration = new JSONConfiguration ( JSON_CONVERTER_CONFIGURATION ) ;
@@ -130,7 +125,8 @@ export default class App extends Component {
130
125
this . _setTemplate ( value ) ;
131
126
}
132
127
133
- _onEditorChange ( text , event ) {
128
+ _onEditorChange ( value ) {
129
+ const text = value ;
134
130
let json = null ;
135
131
// Parse JSON, while capturing and ignoring exceptions
136
132
try {
@@ -144,7 +140,7 @@ export default class App extends Component {
144
140
145
141
_renderJsonSelector ( ) {
146
142
return (
147
- < select name = "JSON templates" onChange = { this . _onTemplateChange } >
143
+ < select name = "JSON templates" onChange = { event => this . _onTemplateChange ( event ) } >
148
144
{ Object . entries ( JSON_TEMPLATES ) . map ( ( [ key ] ) => (
149
145
< option key = { key } value = { key } >
150
146
{ key }
@@ -180,25 +176,21 @@ export default class App extends Component {
180
176
181
177
return (
182
178
< Fragment >
183
- { /* Left Pane: Ace Editor and Template Selector */ }
179
+ { /* Left Pane: Monaco Editor and Template Selector */ }
184
180
< div id = "left-pane" >
185
181
{ this . _renderJsonSelector ( ) }
186
182
187
183
< div id = "editor" >
188
184
< AutoSizer >
189
185
{ ( { width, height} ) => (
190
- < AceEditor
186
+ < Editor
191
187
width = { `${ width } px` }
192
188
height = { `${ height } px` }
193
- mode = "json"
194
- theme = "github"
195
- onChange = { this . _onEditorChange }
196
- name = "AceEditorDiv"
197
- editorProps = { { $blockScrolling : true } }
198
- ref = { instance => {
199
- this . ace = instance ;
200
- } }
189
+ defaultLanguage = "json"
190
+ theme = "light"
201
191
value = { this . state . text }
192
+ onChange = { value => this . _onEditorChange ( value ) }
193
+ options = { { scrollBeyondLastLine : false } }
202
194
/>
203
195
) }
204
196
</ AutoSizer >
0 commit comments