1
1
import React , { Component } from "react" ;
2
2
import { connect } from "unistore/react" ;
3
3
import actions from "../../actions/actions" ;
4
- import { Extension , GlobalState } from "../../store" ;
4
+ import { GlobalState } from "../../store" ;
5
5
6
6
import exampleExtensionCode from './example-extension.js.txt' ;
7
7
@@ -40,7 +40,7 @@ export class ExtensionsEditorPage extends Component<GlobalState & ExtensionApi,
40
40
const { updateExtensionCode } = this . props ;
41
41
const ts = Date . now ( ) + '' ;
42
42
const newName = prompt ( "Enter new extension name" , `user-extension${ ts } .js` ) ;
43
- const templatedCode = exampleExtensionCode . replace ( / % T S % / g, ts ) ;
43
+ const templatedCode = exampleExtensionCode . replace ( / _ T S _ / g, ts ) ;
44
44
if ( newName !== null ) {
45
45
updateExtensionCode ( { name : newName , code : templatedCode } ) ;
46
46
this . setState ( { currentExtension : newName } ) ;
@@ -49,10 +49,10 @@ export class ExtensionsEditorPage extends Component<GlobalState & ExtensionApi,
49
49
render ( ) {
50
50
const { currentExtension } = this . state ;
51
51
const { extensions } = this . props ;
52
- const code = extensions . find ( e => e . name === currentExtension ) ?. code ;
52
+ const code = extensions . find ( e => e . name === currentExtension ) ?. code ?? "" ;
53
53
54
- return < div className = "card" >
55
- < div className = "card-body" >
54
+ return < div className = "card h-100 " >
55
+ < div className = "card-body h-100 " >
56
56
< div className = "row mb-2" >
57
57
< div className = "col-6" >
58
58
< select value = { currentExtension } className = "form-control" onChange = { this . loadExtension } >
@@ -61,11 +61,11 @@ export class ExtensionsEditorPage extends Component<GlobalState & ExtensionApi,
61
61
</ select >
62
62
</ div >
63
63
< div className = "col-6" >
64
- < Button onClick = { this . addNewExtension } className = "btn btn-success" > < i className = "fa fa-plus" > </ i > </ Button >
64
+ < Button onClick = { this . addNewExtension } className = "btn btn-success me-2" > < i className = "fa fa-plus" > </ i > </ Button >
65
+ < Button disabled = { ! currentExtension } onClick = { this . onSaveClick } className = "btn btn-primary" > Save</ Button >
65
66
</ div >
66
67
</ div >
67
- < textarea onChange = { this . onExtensionCodeChange } className = "form-control mb-2" rows = { 10 } value = { code } > </ textarea >
68
- < Button disabled = { ! currentExtension } onClick = { this . onSaveClick } className = "btn btn-primary" > Save</ Button >
68
+ < textarea spellCheck = { false } onChange = { this . onExtensionCodeChange } className = "form-control h-100" value = { code } />
69
69
</ div >
70
70
</ div >
71
71
0 commit comments