@@ -2,64 +2,46 @@ import 'mo/workbench/editor/style.scss';
2
2
import * as React from 'react' ;
3
3
import SplitPane from 'react-split-pane' ;
4
4
5
- import MonacoEditor from 'mo/components/monaco-editor' ;
6
5
import { getBEMElement , prefixClaName } from 'mo/common/className' ;
7
-
6
+ import MonacoEditor from 'mo/components/monaco-editor' ;
8
7
import Tabs from 'mo/components/tabs' ;
8
+
9
9
import Welcome from './welcome' ;
10
10
import { IEditor , IEditorGroup } from 'mo/model' ;
11
11
12
12
const defaultEditorClassName = prefixClaName ( 'editor' ) ;
13
13
const groupClassName = getBEMElement ( defaultEditorClassName , 'group' ) ;
14
- const groupContainerClassName = getBEMElement (
15
- defaultEditorClassName ,
16
- 'group-container'
17
- ) ;
18
- const groupHeaderClassName = getBEMElement (
19
- defaultEditorClassName ,
20
- 'group-header'
21
- ) ;
22
- const groupTabsClassName = getBEMElement ( defaultEditorClassName , 'group-tabs' ) ;
23
- const groupBreadcrumbsClassName = getBEMElement (
24
- defaultEditorClassName ,
25
- 'group-breadcrumbs'
26
- ) ;
27
14
28
15
function renderEditorGroup ( group : IEditorGroup , onMoveTab , onSelectTab ) {
29
16
const editor = group . activeTab ;
30
- // Todo 测试editor tabs
17
+
18
+ const tabs = group . tabs . map ( ( item , index ) => {
19
+ return Object . assign ( { } , item , {
20
+ key : item . key ,
21
+ tip : item . path ,
22
+ renderPanel : < MonacoEditor
23
+ options = { {
24
+ value : item . value ,
25
+ language : item . language || 'sql' ,
26
+ automaticLayout : true ,
27
+ } }
28
+ editorInstanceRef = { ( editorInstance ) => {
29
+ // This assignment will trigger moleculeCtx update, and subNodes update
30
+ group . editorInstance = editorInstance ;
31
+ } }
32
+ />
33
+ } )
34
+ } )
31
35
return (
32
36
< div className = { groupClassName } key = { `group-${ group . id } ` } >
33
- < div className = { groupHeaderClassName } >
34
- < div className = { groupTabsClassName } >
35
- < Tabs
36
- data = { group . tabs }
37
- onMoveTab = { onMoveTab }
38
- onTabChange = { onSelectTab }
39
- />
40
- </ div >
41
- < div className = { groupBreadcrumbsClassName } > </ div >
42
- </ div >
43
- < div className = { groupContainerClassName } >
44
- {
45
- // Default we use monaco editor, but also you can customize by renderPane() function
46
- editor . renderPanel ? (
47
- editor . renderPanel ( )
48
- ) : (
49
- < MonacoEditor
50
- options = { {
51
- value : editor . value ,
52
- language : editor . language || 'sql' ,
53
- automaticLayout : true ,
54
- } }
55
- editorInstanceRef = { ( editorInstance ) => {
56
- // This assignment will trigger moleculeCtx update, and subNodes update
57
- group . editorInstance = editorInstance ;
58
- } }
59
- />
60
- )
61
- }
62
- </ div >
37
+ < Tabs
38
+ type = "editable-card"
39
+ data = { tabs }
40
+ onMoveTab = { onMoveTab }
41
+ onSelectTab = { onSelectTab }
42
+ activeTab = { editor . key }
43
+ onCloseTab = { ( tabKey ) => console . log ( tabKey ) }
44
+ />
63
45
</ div >
64
46
) ;
65
47
}
0 commit comments