@@ -64,11 +64,20 @@ function MonacoEditor(props: IProps, ref: ForwardedRef<IExportRefFunction>) {
6464 editorRef . current = editorIns ;
6565 didMount && didMount ( editorIns ) ;
6666
67+ const { colorPrimary } = window . _AppThemePack ;
68+ const colors = {
69+ 'editor.lineHighlightBackground' : colorPrimary + '14' , // 当前行背景色
70+ 'editor.selectionBackground' : colorPrimary + '20' , // 选中文本的背景色
71+ // 'editorLineNumber.foreground': colorPrimary, // 行号颜色
72+ 'editorLineNumber.activeForeground' : colorPrimary , // 当前行号颜色
73+ // 'editorCursor.foreground': colorPrimary, // 光标颜色
74+ } ;
6775 monaco . editor . defineTheme ( ThemeType . Light , {
6876 base : 'vs' ,
6977 inherit : true ,
7078 rules : [ { background : '#15161a' } ] as any ,
7179 colors : {
80+ ...colors ,
7281 'editor.foreground' : '#000000' ,
7382 'editor.background' : '#fff' , //背景色
7483 } ,
@@ -79,7 +88,6 @@ function MonacoEditor(props: IProps, ref: ForwardedRef<IExportRefFunction>) {
7988 inherit : true ,
8089 rules : [ { background : '#15161a' } ] as any ,
8190 colors : {
82- // 相关颜色属性配置
8391 'editor.foreground' : '#ffffff' ,
8492 'editor.background' : '#0A0B0C' , //背景色
8593 } ,
@@ -89,7 +97,6 @@ function MonacoEditor(props: IProps, ref: ForwardedRef<IExportRefFunction>) {
8997 inherit : true ,
9098 rules : [ { background : '#15161a' } ] as any ,
9199 colors : {
92- // 相关颜色属性配置
93100 'editor.foreground' : '#ffffff' ,
94101 'editor.background' : '#1c2128' , //背景色
95102 } ,
@@ -100,6 +107,7 @@ function MonacoEditor(props: IProps, ref: ForwardedRef<IExportRefFunction>) {
100107 inherit : true ,
101108 rules : [ { background : '#15161a' } ] as any ,
102109 colors : {
110+ ...colors ,
103111 'editor.foreground' : '#000000' ,
104112 'editor.background' : '#f8f9fa' , //背景色
105113 } ,
@@ -253,6 +261,7 @@ export const appendMonacoValue = (editor: any, text: any, range: IRangeType = 'e
253261 case 'front' :
254262 newRange = new monaco . Range ( 1 , 1 , 1 , 1 ) ;
255263 editor . revealLine ( 1 ) ;
264+ editor . setPosition ( { lineNumber : 1 , column : 1 } ) ;
256265 break ;
257266 // 格式化选中区域的sql
258267 case 'select' : {
@@ -270,7 +279,7 @@ export const appendMonacoValue = (editor: any, text: any, range: IRangeType = 'e
270279 // 在末尾添加内容
271280 case 'end' :
272281 newRange = new monaco . Range ( lastLine , lastLineLength , lastLine , lastLineLength ) ;
273- newText = `${ text } ` ;
282+ newText = `\n ${ text } ` ;
274283 break ;
275284 default :
276285 break ;
@@ -287,6 +296,7 @@ export const appendMonacoValue = (editor: any, text: any, range: IRangeType = 'e
287296 if ( range === 'end' ) {
288297 setTimeout ( ( ) => {
289298 editor . revealLine ( lastLine + 1 ) ;
299+ editor . setPosition ( { lineNumber : lastLine + 1 , column : 1 } ) ;
290300 } , 0 ) ;
291301 }
292302} ;
0 commit comments