@@ -9,7 +9,7 @@ import Color from 'color'
99import { monacoThemeOptions } from '../settings'
1010import { editorSet } from 'components/MonacoEditor/Editors' ;
1111
12- export function getActiveEditor ( ) {
12+ export function getActiveEditor ( ) {
1313 const { EditorTabState } = mobxStore
1414 const activeTab = EditorTabState . activeTab
1515 return activeTab
@@ -20,7 +20,7 @@ export function getActiveEditor () {
2020 : null
2121}
2222
23- export function openNewEditor ( config ) {
23+ export function openNewEditor ( config ) {
2424 const { path, contentType, ...other } = config
2525 TabActions . createTab ( {
2626 icon : icons . getClassWithColor ( path . split ( '/' ) . pop ( ) ) || 'fa fa-file-text-o' ,
@@ -32,7 +32,7 @@ export function openNewEditor (config) {
3232 } )
3333}
3434
35- export function registerLanguage ( languageConf ) {
35+ export function registerLanguage ( languageConf ) {
3636 const { contribution } = languageConf
3737 monaco . languages . register ( contribution )
3838 monaco . languages . onLanguage ( contribution . id , ( ) => contribution . loader ( ) . then ( ( mod ) => {
@@ -45,16 +45,20 @@ export function registerFormattingEditProvider (languageId, provider) {
4545 // todo
4646}
4747
48- export function registerEditorViewByContentTypes ( editor , contentTypes ) {
48+ export function registerEditorView ( editor , { contentTypes, extensions } ) {
4949 // 注册编辑器
50- editorSet . unshift ( { editor, contentTypes } ) ;
50+ editorSet . unshift ( { editor, contentTypes, extensions } ) ;
5151 // dispose
5252 return ( ) => {
53- editorSet = editorSet . filter ( editor => String ( editor . contentTypes ) !== String ( contentTypes ) ) ;
53+ if ( contentTypes && Array . isArray ( contentTypes ) ) {
54+ editorSet = editorSet . filter ( editor => String ( editor . contentTypes ) !== String ( contentTypes ) ) ;
55+ } else {
56+ editorSet = editorSet . filter ( editor => String ( editor . extensions ) !== String ( extensions ) ) ;
57+ }
5458 }
5559}
5660
57- export function registerContentProvider ( component , conf ) {
61+ export function registerContentProvider ( component , conf ) {
5862 const { name } = conf
5963 const type = `CUSTOM_EDITOR_VIEW_${ name } `
6064 const activate = ( editorType , title , props ) => {
0 commit comments