File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -71,6 +71,10 @@ export interface EditorConfig {
7171 * scrollbar 配置,参考 monaco 的 scrollbar 配置项,[文档链接](https://microsoft.github.io/monaco-editor/api/interfaces/monaco.editor.ieditorscrollbaroptions.html)
7272 */
7373 scrollbar ?: Record < string , any > ;
74+ /**
75+ * 去除编辑器缓存,此时没有缓存打开会重新请求
76+ */
77+ disableCache ?: boolean ;
7478}
7579
7680export interface EditorProps {
Original file line number Diff line number Diff line change @@ -180,6 +180,12 @@ export interface RuntimeConfig {
180180 * 空白页自定义内容
181181 */
182182 EditorEmpty ?: React . FC ;
183+ /**
184+ * 当文件后缀名判断格式 不满足条件时,可通过此配置项进行自定义
185+ * 优先会从语法服务中获取类型
186+ * https://aone.alipay.com/v2/project/1158176/bug/100102353
187+ */
188+ resolveFileType ?: ( path : string ) => 'image' | 'text' | 'video' | undefined ;
183189}
184190
185191export type SearchMode = Boolean | 'local' ;
Original file line number Diff line number Diff line change 1+ import { RuntimeConfig } from '@alipay/alex-core' ;
12import {
23 Event ,
34 IDisposable ,
@@ -23,7 +24,7 @@ import {
2324 FileAccess ,
2425 FileSystemProviderCapabilities ,
2526} from '@opensumi/ide-file-service/lib/common' ;
26- import { Injectable } from '@opensumi/di' ;
27+ import { Autowired , Injectable } from '@opensumi/di' ;
2728import * as path from 'path' ;
2829import { HOME_ROOT } from '../../common' ;
2930import { IDiskFileProvider } from './base' ;
@@ -47,6 +48,9 @@ export class DiskFileSystemProvider extends FCService implements IDiskFileProvid
4748 protected watchFileExcludes : string [ ] = [ ] ;
4849 protected watchFileExcludesMatcherList : ParsedPattern [ ] = [ ] ;
4950
51+ @Autowired ( RuntimeConfig )
52+ private runtimeConfig : RuntimeConfig ;
53+
5054 static H5VideoExtList = [ 'mp4' , 'ogg' , 'webm' ] ;
5155
5256 static BinaryExtList = [
@@ -576,6 +580,10 @@ export class DiskFileSystemProvider extends FCService implements IDiskFileProvid
576580 ext = ext . slice ( 1 ) ;
577581 }
578582 }
583+ // 使用路径判断文件格式存在问题
584+ if ( typeof this . runtimeConfig . resolveFileType === 'function' ) {
585+ return this . runtimeConfig . resolveFileType ( uri . slice ( 7 ) ) ;
586+ }
579587 return this . _getFileType ( ext ) ;
580588 }
581589 return 'directory' ;
Original file line number Diff line number Diff line change @@ -45,6 +45,9 @@ const fileOptions = (function transform(obj) {
4545 'ide-s/TypeScript-Node-Starter' : {
4646 'feat/123123' : [ 'gbk.ts' ] ,
4747 } ,
48+ 'zoloz_common/zoloz-api-test' : {
49+ master : [ 'integration/saas/src/test/resources/images/doc/VN/id/cover_face_vnid2.jpg' ] ,
50+ } ,
4851} ) ;
4952
5053const App = ( ) => {
@@ -179,6 +182,9 @@ const App = () => {
179182 scenario : null ,
180183 startupEditor : 'none' ,
181184 // hideEditorTab: true,
185+ resolveFileType ( path ) {
186+ return 'text' ;
187+ } ,
182188 } }
183189 editorConfig = { {
184190 adjustFindWidgetTop : true ,
You can’t perform that action at this time.
0 commit comments