@opensumi/ide-editor 2.27.3-rc-1714116491.0 → 2.27.3-rc-1714367598.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/browser/editor.context.d.ts +7 -0
- package/lib/browser/editor.context.d.ts.map +1 -0
- package/lib/browser/editor.context.js +10 -0
- package/lib/browser/editor.context.js.map +1 -0
- package/lib/browser/editor.contribution.d.ts.map +1 -1
- package/lib/browser/editor.contribution.js +0 -5
- package/lib/browser/editor.contribution.js.map +1 -1
- package/lib/browser/editor.decoration.service.d.ts +12 -1
- package/lib/browser/editor.decoration.service.d.ts.map +1 -1
- package/lib/browser/editor.decoration.service.js +57 -30
- package/lib/browser/editor.decoration.service.js.map +1 -1
- package/lib/browser/editor.view.d.ts.map +1 -1
- package/lib/browser/editor.view.js +70 -51
- package/lib/browser/editor.view.js.map +1 -1
- package/lib/browser/tab.view.d.ts.map +1 -1
- package/lib/browser/tab.view.js +6 -5
- package/lib/browser/tab.view.js.map +1 -1
- package/lib/browser/types.d.ts +6 -0
- package/lib/browser/types.d.ts.map +1 -1
- package/lib/browser/types.js.map +1 -1
- package/lib/browser/workbench-editor.service.d.ts +1 -1
- package/lib/browser/workbench-editor.service.js +1 -1
- package/lib/common/editor.d.ts +2 -0
- package/lib/common/editor.d.ts.map +1 -1
- package/lib/common/editor.js.map +1 -1
- package/package.json +14 -14
- package/src/browser/editor.context.ts +11 -0
- package/src/browser/editor.contribution.ts +0 -6
- package/src/browser/editor.decoration.service.ts +73 -34
- package/src/browser/editor.view.tsx +102 -77
- package/src/browser/tab.view.tsx +7 -6
- package/src/browser/types.ts +8 -0
- package/src/browser/workbench-editor.service.ts +1 -1
- package/src/common/editor.ts +2 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opensumi/ide-editor",
|
|
3
|
-
"version": "2.27.3-rc-
|
|
3
|
+
"version": "2.27.3-rc-1714367598.0",
|
|
4
4
|
"files": [
|
|
5
5
|
"lib",
|
|
6
6
|
"src"
|
|
@@ -17,21 +17,21 @@
|
|
|
17
17
|
"url": "git@github.com:opensumi/core.git"
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@opensumi/ide-core-common": "2.27.3-rc-
|
|
21
|
-
"@opensumi/ide-core-node": "2.27.3-rc-
|
|
22
|
-
"@opensumi/ide-file-service": "2.27.3-rc-
|
|
23
|
-
"@opensumi/ide-monaco": "2.27.3-rc-
|
|
24
|
-
"@opensumi/ide-utils": "2.27.3-rc-
|
|
20
|
+
"@opensumi/ide-core-common": "2.27.3-rc-1714367598.0",
|
|
21
|
+
"@opensumi/ide-core-node": "2.27.3-rc-1714367598.0",
|
|
22
|
+
"@opensumi/ide-file-service": "2.27.3-rc-1714367598.0",
|
|
23
|
+
"@opensumi/ide-monaco": "2.27.3-rc-1714367598.0",
|
|
24
|
+
"@opensumi/ide-utils": "2.27.3-rc-1714367598.0",
|
|
25
25
|
"vscode-oniguruma": "1.5.1"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
|
-
"@opensumi/ide-components": "2.27.3-rc-
|
|
29
|
-
"@opensumi/ide-core-browser": "2.27.3-rc-
|
|
30
|
-
"@opensumi/ide-dev-tool": "2.27.3-rc-
|
|
31
|
-
"@opensumi/ide-overlay": "2.27.3-rc-
|
|
32
|
-
"@opensumi/ide-quick-open": "2.27.3-rc-
|
|
33
|
-
"@opensumi/ide-theme": "2.27.3-rc-
|
|
34
|
-
"@opensumi/ide-workspace": "2.27.3-rc-
|
|
28
|
+
"@opensumi/ide-components": "2.27.3-rc-1714367598.0",
|
|
29
|
+
"@opensumi/ide-core-browser": "2.27.3-rc-1714367598.0",
|
|
30
|
+
"@opensumi/ide-dev-tool": "2.27.3-rc-1714367598.0",
|
|
31
|
+
"@opensumi/ide-overlay": "2.27.3-rc-1714367598.0",
|
|
32
|
+
"@opensumi/ide-quick-open": "2.27.3-rc-1714367598.0",
|
|
33
|
+
"@opensumi/ide-theme": "2.27.3-rc-1714367598.0",
|
|
34
|
+
"@opensumi/ide-workspace": "2.27.3-rc-1714367598.0"
|
|
35
35
|
},
|
|
36
|
-
"gitHead": "
|
|
36
|
+
"gitHead": "ec0fc77694997fa304e16d988886fbe2a0f15768"
|
|
37
37
|
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
export interface IEditorContext {
|
|
4
|
+
minimapWidth: number;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export const defaultEditorContext: IEditorContext = {
|
|
8
|
+
minimapWidth: 108,
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export const EditorContext = React.createContext<IEditorContext>(defaultEditorContext);
|
|
@@ -49,7 +49,6 @@ import { MergeEditorService } from '@opensumi/ide-monaco/lib/browser/contrib/mer
|
|
|
49
49
|
import { ITextmateTokenizer, ITextmateTokenizerService } from '@opensumi/ide-monaco/lib/browser/contrib/tokenizer';
|
|
50
50
|
import { EOL } from '@opensumi/ide-monaco/lib/browser/monaco-api/types';
|
|
51
51
|
import * as monaco from '@opensumi/ide-monaco/lib/common/common';
|
|
52
|
-
import { EditorContributionInstantiation } from '@opensumi/monaco-editor-core/esm/vs/editor/browser/editorExtensions';
|
|
53
52
|
import { EditorContextKeys } from '@opensumi/monaco-editor-core/esm/vs/editor/common/editorContextKeys';
|
|
54
53
|
import { IFormattingEditProviderSelector } from '@opensumi/monaco-editor-core/esm/vs/editor/contrib/format/browser/format';
|
|
55
54
|
import { ContextKeyExpr } from '@opensumi/monaco-editor-core/esm/vs/platform/contextkey/common/contextkey';
|
|
@@ -77,7 +76,6 @@ import { EditorView } from './editor.view';
|
|
|
77
76
|
import { DocumentFormatService } from './format/format.service';
|
|
78
77
|
import { FormattingSelector } from './format/formatter-selector';
|
|
79
78
|
import { EditorHistoryService } from './history';
|
|
80
|
-
import { OpenSumiLightBulbWidget } from './light-bulb-widget';
|
|
81
79
|
import { EditorContextMenuController } from './menu/editor.context';
|
|
82
80
|
import { NavigationMenuContainer } from './navigation.view';
|
|
83
81
|
import { GoToLineQuickOpenHandler } from './quick-open/go-to-line';
|
|
@@ -255,10 +253,6 @@ export class EditorContribution
|
|
|
255
253
|
this.contextMenuRenderer,
|
|
256
254
|
]),
|
|
257
255
|
);
|
|
258
|
-
|
|
259
|
-
if (this.aiNativeConfigService.capabilities.supportsOpenSumiDesign) {
|
|
260
|
-
register(OpenSumiLightBulbWidget.ID, OpenSumiLightBulbWidget, EditorContributionInstantiation.Lazy);
|
|
261
|
-
}
|
|
262
256
|
}
|
|
263
257
|
|
|
264
258
|
protected getMimeForMode(langId: string): string | undefined {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Autowired, Injectable } from '@opensumi/di';
|
|
2
|
-
import {
|
|
2
|
+
import { DisposableStore, IDisposable, IEventBus, URI } from '@opensumi/ide-core-browser';
|
|
3
3
|
import * as monaco from '@opensumi/ide-monaco';
|
|
4
4
|
import { IIconService, IThemeService } from '@opensumi/ide-theme';
|
|
5
5
|
import { ICSSStyleService } from '@opensumi/ide-theme/lib/common/style';
|
|
@@ -15,6 +15,7 @@ import {
|
|
|
15
15
|
IEditorDecorationCollectionService,
|
|
16
16
|
IEditorDecorationProvider,
|
|
17
17
|
IThemedCssStyle,
|
|
18
|
+
IThemedCssStyleCollection,
|
|
18
19
|
} from './types';
|
|
19
20
|
|
|
20
21
|
@Injectable()
|
|
@@ -35,8 +36,6 @@ export class EditorDecorationCollectionService implements IEditorDecorationColle
|
|
|
35
36
|
|
|
36
37
|
private tempId = 0;
|
|
37
38
|
|
|
38
|
-
constructor() {}
|
|
39
|
-
|
|
40
39
|
getNextTempId() {
|
|
41
40
|
this.tempId++;
|
|
42
41
|
return 'temp-decoration-' + this.tempId;
|
|
@@ -69,55 +68,73 @@ export class EditorDecorationCollectionService implements IEditorDecorationColle
|
|
|
69
68
|
}
|
|
70
69
|
|
|
71
70
|
private resolveDecoration(key: string, options: IDecorationRenderOptions): IDynamicModelDecorationProperty {
|
|
71
|
+
const theme = this.createThemeCSSStyleCollection(key, options);
|
|
72
|
+
|
|
72
73
|
const dec = {
|
|
73
|
-
default:
|
|
74
|
-
light:
|
|
75
|
-
dark:
|
|
74
|
+
default: theme.default,
|
|
75
|
+
light: theme.light,
|
|
76
|
+
dark: theme.dark,
|
|
76
77
|
isWholeLine: options.isWholeLine || false,
|
|
77
78
|
overviewRulerLane: options.overviewRulerLane,
|
|
78
79
|
dispose: () => {
|
|
79
|
-
|
|
80
|
-
if (dec.light) {
|
|
81
|
-
dec.light.dispose();
|
|
82
|
-
}
|
|
83
|
-
if (dec.dark) {
|
|
84
|
-
dec.dark.dispose();
|
|
85
|
-
}
|
|
80
|
+
theme.dispose();
|
|
86
81
|
},
|
|
87
82
|
};
|
|
88
83
|
|
|
89
84
|
return dec;
|
|
90
85
|
}
|
|
91
86
|
|
|
92
|
-
private
|
|
87
|
+
private createThemeCSSStyleCollection(key: string, options: IDecorationRenderOptions): IThemedCssStyleCollection {
|
|
88
|
+
const disposer = new DisposableStore();
|
|
89
|
+
|
|
90
|
+
const defaultStyle = this.addedThemeDecorationToCSSStyleSheet(key, options);
|
|
91
|
+
const result = {
|
|
92
|
+
default: defaultStyle,
|
|
93
|
+
light: null,
|
|
94
|
+
dark: null,
|
|
95
|
+
dispose: () => {
|
|
96
|
+
disposer.dispose();
|
|
97
|
+
},
|
|
98
|
+
} as IThemedCssStyleCollection;
|
|
99
|
+
|
|
100
|
+
if (options.light) {
|
|
101
|
+
const lightStyle = this.addedThemeDecorationToCSSStyleSheet(key + '-light', options.light);
|
|
102
|
+
result.light = lightStyle;
|
|
103
|
+
disposer.add(lightStyle);
|
|
104
|
+
}
|
|
105
|
+
if (options.dark) {
|
|
106
|
+
const darkStyle = this.addedThemeDecorationToCSSStyleSheet(key + '-dark', options.dark);
|
|
107
|
+
result.dark = darkStyle;
|
|
108
|
+
disposer.add(darkStyle);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
return result;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
private addedThemeDecorationToCSSStyleSheet(key: string, options: IDecorationRenderOptions): IThemedCssStyle {
|
|
93
115
|
const className = key;
|
|
94
116
|
const inlineClassName = key + '-inline';
|
|
95
|
-
const disposer = new
|
|
96
|
-
let afterContentClassName;
|
|
97
|
-
let beforeContentClassName;
|
|
98
|
-
let glyphMarginClassName;
|
|
117
|
+
const disposer = new DisposableStore();
|
|
118
|
+
let afterContentClassName: string | undefined;
|
|
119
|
+
let beforeContentClassName: string | undefined;
|
|
120
|
+
let glyphMarginClassName: string | undefined;
|
|
121
|
+
|
|
122
|
+
const inlineBlockSelector = this.createInlineBlockCSSStyleIfNeeded();
|
|
123
|
+
|
|
99
124
|
const styles = this.resolveCSSStyle(options);
|
|
100
125
|
|
|
101
126
|
const inlineStyles = this.resolveInlineCSSStyle(options);
|
|
102
|
-
disposer.
|
|
103
|
-
disposer.
|
|
127
|
+
disposer.add(this.cssManager.addClass(className, styles));
|
|
128
|
+
disposer.add(this.cssManager.addClass(inlineClassName, inlineStyles));
|
|
104
129
|
if (options.after) {
|
|
105
130
|
const styles = this.resolveContentCSSStyle(options.after);
|
|
106
|
-
disposer.
|
|
107
|
-
afterContentClassName = key
|
|
108
|
-
// 最新版chrome 中 document.caretRangeFromRange 的行为有所改变
|
|
109
|
-
// 如果目标位置命中的是两个inline元素之间, 它会认为是前一个元素的内容。
|
|
110
|
-
// 在之前这个结果是属于公共父级
|
|
111
|
-
// 这个改变会使得monaco中hitTest返回错误的结果,导致点击decoration的空白区域时会错误选中文本
|
|
112
|
-
// 临时修复:
|
|
113
|
-
// 此处将before和after的父级span display强制设置为inline-block, 可以避免这个问题, 是否会带来其他风险未知
|
|
114
|
-
disposer.addDispose(this.cssManager.addClass(afterContentClassName, { display: 'inline-block' } as any));
|
|
131
|
+
disposer.add(this.cssManager.addClass(key + '::after', styles));
|
|
132
|
+
afterContentClassName = `${inlineBlockSelector} ${key}`;
|
|
115
133
|
}
|
|
116
134
|
if (options.before) {
|
|
117
135
|
const styles = this.resolveContentCSSStyle(options.before);
|
|
118
|
-
disposer.
|
|
119
|
-
beforeContentClassName = key
|
|
120
|
-
disposer.addDispose(this.cssManager.addClass(beforeContentClassName, { display: 'inline-block' } as any));
|
|
136
|
+
disposer.add(this.cssManager.addClass(key + '::before', styles));
|
|
137
|
+
beforeContentClassName = `${inlineBlockSelector} ${key}`;
|
|
121
138
|
}
|
|
122
139
|
if (options.gutterIconPath) {
|
|
123
140
|
const glyphMarginStyle = this.resolveCSSStyle({
|
|
@@ -125,7 +142,7 @@ export class EditorDecorationCollectionService implements IEditorDecorationColle
|
|
|
125
142
|
backgroundIcon: options.gutterIconPath.toString(),
|
|
126
143
|
});
|
|
127
144
|
glyphMarginClassName = key + '-glyphMargin';
|
|
128
|
-
disposer.
|
|
145
|
+
disposer.add(this.cssManager.addClass(glyphMarginClassName, glyphMarginStyle));
|
|
129
146
|
}
|
|
130
147
|
|
|
131
148
|
return {
|
|
@@ -194,13 +211,35 @@ export class EditorDecorationCollectionService implements IEditorDecorationColle
|
|
|
194
211
|
textDecoration: styles.textDecoration,
|
|
195
212
|
color: this.themeService.getColorVar(styles.color),
|
|
196
213
|
backgroundColor: this.themeService.getColorVar(styles.backgroundColor),
|
|
197
|
-
|
|
198
214
|
margin: styles.margin,
|
|
199
215
|
width: styles.width,
|
|
200
216
|
height: styles.height,
|
|
201
217
|
} as CSSStyleDeclaration;
|
|
202
218
|
}
|
|
203
219
|
|
|
220
|
+
static DISPLAY_INLINE_BLOCK_CLS = 'display-inline-block-decoration';
|
|
221
|
+
private inlineBlockDecorationDisposer: IDisposable | undefined;
|
|
222
|
+
|
|
223
|
+
/**
|
|
224
|
+
* 最新版chrome 中 document.caretRangeFromRange 的行为有所改变
|
|
225
|
+
* 如果目标位置命中的是两个 inline 元素之间, 它会认为是前一个元素的内容。
|
|
226
|
+
* 在之前这个结果是属于公共父级
|
|
227
|
+
* 这个改变会使得 monaco 中 hitTest 返回错误的结果,导致点击 decoration 的空白区域时会错误选中文本
|
|
228
|
+
* 此处将 before 和 after 的父级 span display 强制设置为 inline-block, 可以避免这个问题, 是否会带来其他风险未知
|
|
229
|
+
* @returns
|
|
230
|
+
*/
|
|
231
|
+
private createInlineBlockCSSStyleIfNeeded(): string {
|
|
232
|
+
if (this.inlineBlockDecorationDisposer) {
|
|
233
|
+
return EditorDecorationCollectionService.DISPLAY_INLINE_BLOCK_CLS;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
this.inlineBlockDecorationDisposer = this.cssManager.addClass(
|
|
237
|
+
EditorDecorationCollectionService.DISPLAY_INLINE_BLOCK_CLS,
|
|
238
|
+
{ display: 'inline-block' },
|
|
239
|
+
);
|
|
240
|
+
return EditorDecorationCollectionService.DISPLAY_INLINE_BLOCK_CLS;
|
|
241
|
+
}
|
|
242
|
+
|
|
204
243
|
registerDecorationProvider(provider: IEditorDecorationProvider): IDisposable {
|
|
205
244
|
this.decorationProviders.set(provider.key, provider);
|
|
206
245
|
this.eventBus.fire(new EditorDecorationProviderRegistrationEvent(provider));
|
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
ComponentRegistry,
|
|
11
11
|
ConfigContext,
|
|
12
12
|
ConfigProvider,
|
|
13
|
+
DisposableStore,
|
|
13
14
|
ErrorBoundary,
|
|
14
15
|
IEventBus,
|
|
15
16
|
MaybeNull,
|
|
@@ -27,10 +28,12 @@ import {
|
|
|
27
28
|
} from '@opensumi/ide-core-browser/lib/components';
|
|
28
29
|
import { VIEW_CONTAINERS } from '@opensumi/ide-core-browser/lib/layout/view-id';
|
|
29
30
|
import { useInjectable, useUpdateOnEventBusEvent } from '@opensumi/ide-core-browser/lib/react-hooks';
|
|
31
|
+
import { monaco } from '@opensumi/ide-monaco/lib/browser/monaco-api';
|
|
30
32
|
|
|
31
33
|
import { IResource, WorkbenchEditorService } from '../common';
|
|
32
34
|
|
|
33
35
|
import { EditorComponentRegistryImpl } from './component';
|
|
36
|
+
import { EditorContext, IEditorContext, defaultEditorContext } from './editor.context';
|
|
34
37
|
import styles from './editor.module.less';
|
|
35
38
|
import { EditorGrid, SplitDirection } from './grid/grid.service';
|
|
36
39
|
import { NavigationBar } from './navigation.view';
|
|
@@ -324,6 +327,8 @@ export const EditorGroupView = observer(({ group }: { group: EditorGroup }) => {
|
|
|
324
327
|
});
|
|
325
328
|
|
|
326
329
|
export const EditorGroupBody = observer(({ group }: { group: EditorGroup }) => {
|
|
330
|
+
const [context, setContext] = React.useState<IEditorContext>(defaultEditorContext);
|
|
331
|
+
|
|
327
332
|
const editorBodyRef = React.useRef<HTMLDivElement>(null);
|
|
328
333
|
const editorService = useInjectable(WorkbenchEditorService) as WorkbenchEditorServiceImpl;
|
|
329
334
|
const eventBus = useInjectable(IEventBus) as IEventBus;
|
|
@@ -336,6 +341,14 @@ export const EditorGroupBody = observer(({ group }: { group: EditorGroup }) => {
|
|
|
336
341
|
const forceUpdate = React.useCallback(() => updateState({}), []);
|
|
337
342
|
|
|
338
343
|
React.useEffect(() => {
|
|
344
|
+
const disposables = new DisposableStore();
|
|
345
|
+
|
|
346
|
+
disposables.add(
|
|
347
|
+
group.onDidEditorGroupBodyChanged(() => {
|
|
348
|
+
forceUpdate();
|
|
349
|
+
}),
|
|
350
|
+
);
|
|
351
|
+
|
|
339
352
|
if (codeEditorRef.current) {
|
|
340
353
|
if (cachedEditor[group.name]) {
|
|
341
354
|
cachedEditor[group.name].remove();
|
|
@@ -345,6 +358,20 @@ export const EditorGroupBody = observer(({ group }: { group: EditorGroup }) => {
|
|
|
345
358
|
codeEditorRef.current.appendChild(container);
|
|
346
359
|
cachedEditor[group.name] = container;
|
|
347
360
|
group.createEditor(container);
|
|
361
|
+
const minimapWith = group.codeEditor.monacoEditor.getOption(monaco.editor.EditorOption.layoutInfo).minimap
|
|
362
|
+
.minimapWidth;
|
|
363
|
+
setContext({ minimapWidth: minimapWith });
|
|
364
|
+
|
|
365
|
+
disposables.add(
|
|
366
|
+
group.codeEditor.monacoEditor.onDidChangeConfiguration((e) => {
|
|
367
|
+
if (e.hasChanged(monaco.editor.EditorOption.layoutInfo)) {
|
|
368
|
+
setContext({
|
|
369
|
+
minimapWidth: group.codeEditor.monacoEditor.getOption(monaco.editor.EditorOption.layoutInfo).minimap
|
|
370
|
+
.minimapWidth,
|
|
371
|
+
});
|
|
372
|
+
}
|
|
373
|
+
}),
|
|
374
|
+
);
|
|
348
375
|
}
|
|
349
376
|
}
|
|
350
377
|
|
|
@@ -354,15 +381,11 @@ export const EditorGroupBody = observer(({ group }: { group: EditorGroup }) => {
|
|
|
354
381
|
if (mergeEditorRef.current) {
|
|
355
382
|
group.attachMergeEditorDom(mergeEditorRef.current);
|
|
356
383
|
}
|
|
357
|
-
}, [codeEditorRef.current, diffEditorRef.current, mergeEditorRef.current]);
|
|
358
384
|
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
}),
|
|
364
|
-
[],
|
|
365
|
-
);
|
|
385
|
+
return () => {
|
|
386
|
+
disposables.dispose();
|
|
387
|
+
};
|
|
388
|
+
}, []);
|
|
366
389
|
|
|
367
390
|
group.activeComponents.forEach((resources, component) => {
|
|
368
391
|
const initialProps = group.activateComponentsProps.get(component);
|
|
@@ -410,79 +433,81 @@ export const EditorGroupBody = observer(({ group }: { group: EditorGroup }) => {
|
|
|
410
433
|
});
|
|
411
434
|
|
|
412
435
|
return (
|
|
413
|
-
<
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
e
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
}}
|
|
424
|
-
onDragLeave={(e) => {
|
|
425
|
-
if (editorBodyRef.current) {
|
|
426
|
-
removeDecorationDragOverElement(editorBodyRef.current);
|
|
427
|
-
}
|
|
428
|
-
}}
|
|
429
|
-
onDrop={(e) => {
|
|
430
|
-
if (editorBodyRef.current) {
|
|
431
|
-
removeDecorationDragOverElement(editorBodyRef.current);
|
|
432
|
-
if (e.dataTransfer.getData('uri')) {
|
|
433
|
-
const uri = new URI(e.dataTransfer.getData('uri'));
|
|
434
|
-
let sourceGroup: EditorGroup | undefined;
|
|
435
|
-
if (e.dataTransfer.getData('uri-source-group')) {
|
|
436
|
-
sourceGroup = editorService.getEditorGroup(e.dataTransfer.getData('uri-source-group'));
|
|
437
|
-
}
|
|
438
|
-
group.dropUri(uri, getDragOverPosition(e.nativeEvent, editorBodyRef.current), sourceGroup);
|
|
436
|
+
<EditorContext.Provider value={context}>
|
|
437
|
+
<div
|
|
438
|
+
id={VIEW_CONTAINERS.EDITOR}
|
|
439
|
+
ref={editorBodyRef}
|
|
440
|
+
className={styles.kt_editor_body}
|
|
441
|
+
onDragOver={(e) => {
|
|
442
|
+
e.preventDefault();
|
|
443
|
+
if (editorBodyRef.current) {
|
|
444
|
+
const position = getDragOverPosition(e.nativeEvent, editorBodyRef.current);
|
|
445
|
+
decorateDragOverElement(editorBodyRef.current, position);
|
|
439
446
|
}
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
files: e.dataTransfer.files,
|
|
445
|
-
position: getDragOverPosition(e.nativeEvent, editorBodyRef.current),
|
|
446
|
-
}),
|
|
447
|
-
);
|
|
447
|
+
}}
|
|
448
|
+
onDragLeave={(e) => {
|
|
449
|
+
if (editorBodyRef.current) {
|
|
450
|
+
removeDecorationDragOverElement(editorBodyRef.current);
|
|
448
451
|
}
|
|
449
|
-
}
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
452
|
+
}}
|
|
453
|
+
onDrop={(e) => {
|
|
454
|
+
if (editorBodyRef.current) {
|
|
455
|
+
removeDecorationDragOverElement(editorBodyRef.current);
|
|
456
|
+
if (e.dataTransfer.getData('uri')) {
|
|
457
|
+
const uri = new URI(e.dataTransfer.getData('uri'));
|
|
458
|
+
let sourceGroup: EditorGroup | undefined;
|
|
459
|
+
if (e.dataTransfer.getData('uri-source-group')) {
|
|
460
|
+
sourceGroup = editorService.getEditorGroup(e.dataTransfer.getData('uri-source-group'));
|
|
461
|
+
}
|
|
462
|
+
group.dropUri(uri, getDragOverPosition(e.nativeEvent, editorBodyRef.current), sourceGroup);
|
|
463
|
+
}
|
|
464
|
+
if (e.dataTransfer.files.length > 0) {
|
|
465
|
+
eventBus.fire(
|
|
466
|
+
new EditorGroupFileDropEvent({
|
|
467
|
+
group,
|
|
468
|
+
files: e.dataTransfer.files,
|
|
469
|
+
position: getDragOverPosition(e.nativeEvent, editorBodyRef.current),
|
|
470
|
+
}),
|
|
471
|
+
);
|
|
472
|
+
}
|
|
473
|
+
}
|
|
474
|
+
}}
|
|
475
|
+
>
|
|
476
|
+
{group.currentResource && <EditorSideView side={'top'} resource={group.currentResource}></EditorSideView>}
|
|
477
|
+
{!editorHasNoTab && <NavigationBar editorGroup={group} />}
|
|
478
|
+
<div className={styles.kt_editor_components}>
|
|
479
|
+
<div
|
|
480
|
+
className={cls({
|
|
481
|
+
[styles_kt_editor_component]: true,
|
|
482
|
+
[styles.kt_hidden]: !group.currentOpenType || group.currentOpenType.type !== EditorOpenType.component,
|
|
483
|
+
})}
|
|
484
|
+
>
|
|
485
|
+
{components}
|
|
486
|
+
</div>
|
|
487
|
+
<div
|
|
488
|
+
className={cls({
|
|
489
|
+
[styles.kt_editor_code_editor]: true,
|
|
490
|
+
[styles_kt_editor_component]: true,
|
|
491
|
+
[styles.kt_hidden]: !group.currentOpenType || group.currentOpenType.type !== EditorOpenType.code,
|
|
492
|
+
})}
|
|
493
|
+
ref={codeEditorRef}
|
|
494
|
+
/>
|
|
495
|
+
<div
|
|
496
|
+
className={cls(styles.kt_editor_diff_editor, styles_kt_editor_component, {
|
|
497
|
+
[styles.kt_hidden]: !group.currentOpenType || group.currentOpenType.type !== EditorOpenType.diff,
|
|
498
|
+
})}
|
|
499
|
+
ref={diffEditorRef}
|
|
500
|
+
/>
|
|
501
|
+
<div
|
|
502
|
+
className={cls(styles.kt_editor_diff_3_editor, styles_kt_editor_component, {
|
|
503
|
+
[styles.kt_hidden]: !group.currentOpenType || group.currentOpenType.type !== EditorOpenType.mergeEditor,
|
|
504
|
+
})}
|
|
505
|
+
ref={mergeEditorRef}
|
|
506
|
+
/>
|
|
462
507
|
</div>
|
|
463
|
-
<
|
|
464
|
-
className={cls({
|
|
465
|
-
[styles.kt_editor_code_editor]: true,
|
|
466
|
-
[styles_kt_editor_component]: true,
|
|
467
|
-
[styles.kt_hidden]: !group.currentOpenType || group.currentOpenType.type !== EditorOpenType.code,
|
|
468
|
-
})}
|
|
469
|
-
ref={codeEditorRef}
|
|
470
|
-
/>
|
|
471
|
-
<div
|
|
472
|
-
className={cls(styles.kt_editor_diff_editor, styles_kt_editor_component, {
|
|
473
|
-
[styles.kt_hidden]: !group.currentOpenType || group.currentOpenType.type !== EditorOpenType.diff,
|
|
474
|
-
})}
|
|
475
|
-
ref={diffEditorRef}
|
|
476
|
-
/>
|
|
477
|
-
<div
|
|
478
|
-
className={cls(styles.kt_editor_diff_3_editor, styles_kt_editor_component, {
|
|
479
|
-
[styles.kt_hidden]: !group.currentOpenType || group.currentOpenType.type !== EditorOpenType.mergeEditor,
|
|
480
|
-
})}
|
|
481
|
-
ref={mergeEditorRef}
|
|
482
|
-
/>
|
|
508
|
+
{group.currentResource && <EditorSideView side={'bottom'} resource={group.currentResource}></EditorSideView>}
|
|
483
509
|
</div>
|
|
484
|
-
|
|
485
|
-
</div>
|
|
510
|
+
</EditorContext.Provider>
|
|
486
511
|
);
|
|
487
512
|
});
|
|
488
513
|
|
package/src/browser/tab.view.tsx
CHANGED
|
@@ -15,7 +15,6 @@ import React, {
|
|
|
15
15
|
|
|
16
16
|
import { Scrollbars } from '@opensumi/ide-components';
|
|
17
17
|
import {
|
|
18
|
-
AppConfig,
|
|
19
18
|
ConfigContext,
|
|
20
19
|
Disposable,
|
|
21
20
|
DisposableCollection,
|
|
@@ -32,6 +31,7 @@ import {
|
|
|
32
31
|
useDesignStyles,
|
|
33
32
|
} from '@opensumi/ide-core-browser';
|
|
34
33
|
import { InlineMenuBar } from '@opensumi/ide-core-browser/lib/components/actions';
|
|
34
|
+
import { LayoutViewSizeConfig } from '@opensumi/ide-core-browser/lib/layout/constants';
|
|
35
35
|
import { VIEW_CONTAINERS } from '@opensumi/ide-core-browser/lib/layout/view-id';
|
|
36
36
|
import { IMenuRegistry, MenuId } from '@opensumi/ide-core-browser/lib/menu/next';
|
|
37
37
|
import { useInjectable, useUpdateOnEventBusEvent } from '@opensumi/ide-core-browser/lib/react-hooks';
|
|
@@ -70,7 +70,7 @@ export const Tabs = ({ group }: ITabsProps) => {
|
|
|
70
70
|
const preferenceService = useInjectable<PreferenceService>(PreferenceService);
|
|
71
71
|
const menuRegistry = useInjectable<IMenuRegistry>(IMenuRegistry);
|
|
72
72
|
const editorTabService = useInjectable<IEditorTabService>(IEditorTabService);
|
|
73
|
-
const
|
|
73
|
+
const layoutViewSize = useInjectable<LayoutViewSizeConfig>(LayoutViewSizeConfig);
|
|
74
74
|
|
|
75
75
|
const styles_tab_right = useDesignStyles(styles.tab_right, 'tab_right');
|
|
76
76
|
const styles_close_tab = useDesignStyles(styles.close_tab, 'close_tab');
|
|
@@ -415,8 +415,8 @@ export const Tabs = ({ group }: ITabsProps) => {
|
|
|
415
415
|
})}
|
|
416
416
|
style={
|
|
417
417
|
wrapMode && i === group.resources.length - 1
|
|
418
|
-
? { marginRight: lastMarginRight, height:
|
|
419
|
-
: { height:
|
|
418
|
+
? { marginRight: lastMarginRight, height: layoutViewSize.editorTabsHeight }
|
|
419
|
+
: { height: layoutViewSize.editorTabsHeight }
|
|
420
420
|
}
|
|
421
421
|
onContextMenu={(event) => {
|
|
422
422
|
tabTitleMenuService.show(event.nativeEvent.x, event.nativeEvent.y, resource && resource.uri, group);
|
|
@@ -529,7 +529,8 @@ export const EditorActions = forwardRef<HTMLDivElement, IEditorActionsProps>(
|
|
|
529
529
|
|
|
530
530
|
const editorActionRegistry = useInjectable<IEditorActionRegistry>(IEditorActionRegistry);
|
|
531
531
|
const editorService: WorkbenchEditorServiceImpl = useInjectable(WorkbenchEditorService);
|
|
532
|
-
const
|
|
532
|
+
const layoutViewSize = useInjectable<LayoutViewSizeConfig>(LayoutViewSizeConfig);
|
|
533
|
+
|
|
533
534
|
const menu = editorActionRegistry.getMenu(group);
|
|
534
535
|
const [hasFocus, setHasFocus] = useState<boolean>(editorService.currentEditorGroup === group);
|
|
535
536
|
const [args, setArgs] = useState<[URI, IEditorGroup, MaybeNull<URI>] | undefined>(acquireArgs());
|
|
@@ -561,7 +562,7 @@ export const EditorActions = forwardRef<HTMLDivElement, IEditorActionsProps>(
|
|
|
561
562
|
<div
|
|
562
563
|
ref={ref}
|
|
563
564
|
className={cls(styles_editor_actions, className)}
|
|
564
|
-
style={{ height:
|
|
565
|
+
style={{ height: layoutViewSize.editorTabsHeight }}
|
|
565
566
|
>
|
|
566
567
|
<InlineMenuBar<URI, IEditorGroup, MaybeNull<URI>>
|
|
567
568
|
menus={menu}
|
package/src/browser/types.ts
CHANGED
|
@@ -275,6 +275,14 @@ export interface IThemedCssStyle extends IDisposable {
|
|
|
275
275
|
overviewRulerColor?: string | IThemeColor;
|
|
276
276
|
}
|
|
277
277
|
|
|
278
|
+
export interface IThemedCssStyleCollection {
|
|
279
|
+
default: IThemedCssStyle;
|
|
280
|
+
light: IThemedCssStyle | null;
|
|
281
|
+
dark: IThemedCssStyle | null;
|
|
282
|
+
|
|
283
|
+
dispose(): void;
|
|
284
|
+
}
|
|
285
|
+
|
|
278
286
|
export const IEditorDecorationCollectionService = Symbol('IEditorDecorationCollectionService');
|
|
279
287
|
|
|
280
288
|
export class EditorSelectionChangeEvent extends BasicEvent<IEditorSelectionChangeEventPayload> {}
|