@opensumi/ide-editor 3.8.3-next-1745907010.0 → 3.8.3-next-1746586819.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-collection.service.d.ts +4 -0
- package/lib/browser/editor-collection.service.d.ts.map +1 -1
- package/lib/browser/editor-collection.service.js +8 -0
- package/lib/browser/editor-collection.service.js.map +1 -1
- package/lib/browser/editor.contribution.d.ts +1 -0
- package/lib/browser/editor.contribution.d.ts.map +1 -1
- package/lib/browser/editor.contribution.js +22 -0
- package/lib/browser/editor.contribution.js.map +1 -1
- package/lib/browser/editor.module.less +6 -0
- package/lib/browser/editor.view.d.ts.map +1 -1
- package/lib/browser/editor.view.js +18 -0
- package/lib/browser/editor.view.js.map +1 -1
- package/lib/browser/index.d.ts +4 -1
- package/lib/browser/index.d.ts.map +1 -1
- package/lib/browser/index.js +20 -1
- package/lib/browser/index.js.map +1 -1
- package/lib/browser/multi-diff/multi-diff-editor.d.ts +46 -0
- package/lib/browser/multi-diff/multi-diff-editor.d.ts.map +1 -0
- package/lib/browser/multi-diff/multi-diff-editor.js +209 -0
- package/lib/browser/multi-diff/multi-diff-editor.js.map +1 -0
- package/lib/browser/multi-diff/multi-diff-resolver.d.ts +10 -0
- package/lib/browser/multi-diff/multi-diff-resolver.d.ts.map +1 -0
- package/lib/browser/multi-diff/multi-diff-resolver.js +42 -0
- package/lib/browser/multi-diff/multi-diff-resolver.js.map +1 -0
- package/lib/browser/multi-diff/multi-diff-resource.d.ts +23 -0
- package/lib/browser/multi-diff/multi-diff-resource.d.ts.map +1 -0
- package/lib/browser/multi-diff/multi-diff-resource.js +67 -0
- package/lib/browser/multi-diff/multi-diff-resource.js.map +1 -0
- package/lib/browser/multi-diff/multi-diff.contribution.d.ts +13 -0
- package/lib/browser/multi-diff/multi-diff.contribution.d.ts.map +1 -0
- package/lib/browser/multi-diff/multi-diff.contribution.js +51 -0
- package/lib/browser/multi-diff/multi-diff.contribution.js.map +1 -0
- package/lib/browser/multi-diff/resolver.service.d.ts +9 -0
- package/lib/browser/multi-diff/resolver.service.d.ts.map +1 -0
- package/lib/browser/multi-diff/resolver.service.js +35 -0
- package/lib/browser/multi-diff/resolver.service.js.map +1 -0
- package/lib/browser/types.d.ts +5 -0
- package/lib/browser/types.d.ts.map +1 -1
- package/lib/browser/types.js +2 -1
- package/lib/browser/types.js.map +1 -1
- package/lib/browser/workbench-editor.service.d.ts +10 -0
- package/lib/browser/workbench-editor.service.d.ts.map +1 -1
- package/lib/browser/workbench-editor.service.js +36 -0
- package/lib/browser/workbench-editor.service.js.map +1 -1
- package/lib/common/editor.d.ts +12 -1
- package/lib/common/editor.d.ts.map +1 -1
- package/lib/common/editor.js +1 -0
- package/lib/common/editor.js.map +1 -1
- package/lib/common/multi-diff.d.ts +61 -0
- package/lib/common/multi-diff.d.ts.map +1 -0
- package/lib/common/multi-diff.js +22 -0
- package/lib/common/multi-diff.js.map +1 -0
- package/package.json +14 -14
- package/src/browser/editor-collection.service.ts +11 -1
- package/src/browser/editor.contribution.ts +36 -1
- package/src/browser/editor.module.less +6 -0
- package/src/browser/editor.view.tsx +22 -0
- package/src/browser/index.ts +19 -1
- package/src/browser/multi-diff/multi-diff-editor.ts +249 -0
- package/src/browser/multi-diff/multi-diff-resolver.ts +44 -0
- package/src/browser/multi-diff/multi-diff-resource.ts +59 -0
- package/src/browser/multi-diff/multi-diff.contribution.ts +54 -0
- package/src/browser/multi-diff/resolver.service.ts +35 -0
- package/src/browser/types.ts +7 -0
- package/src/browser/workbench-editor.service.ts +51 -0
- package/src/common/editor.ts +14 -0
- package/src/common/multi-diff.ts +87 -0
package/src/browser/types.ts
CHANGED
|
@@ -27,6 +27,7 @@ import {
|
|
|
27
27
|
ResourceService,
|
|
28
28
|
TrackedRangeStickiness,
|
|
29
29
|
} from '../common';
|
|
30
|
+
import { IMultiDiffSourceResolverService } from '../common/multi-diff';
|
|
30
31
|
|
|
31
32
|
import { IEditorDocumentModelContentRegistry } from './doc-model/types';
|
|
32
33
|
import { EditorGroup } from './workbench-editor.service';
|
|
@@ -188,6 +189,12 @@ export interface BrowserEditorContribution {
|
|
|
188
189
|
registerEditorFeature?(registry: IEditorFeatureRegistry);
|
|
189
190
|
}
|
|
190
191
|
|
|
192
|
+
export const MultiDiffSourceContribution = Symbol('MultiDiffSourceContribution');
|
|
193
|
+
|
|
194
|
+
export interface MultiDiffSourceContribution {
|
|
195
|
+
registerMultiDiffSourceResolver(resolverService: IMultiDiffSourceResolverService): IDisposable;
|
|
196
|
+
}
|
|
197
|
+
|
|
191
198
|
export interface IGridResizeEventPayload {
|
|
192
199
|
gridId: string;
|
|
193
200
|
}
|
|
@@ -53,6 +53,7 @@ import {
|
|
|
53
53
|
import { IFileServiceClient } from '@opensumi/ide-file-service';
|
|
54
54
|
import * as monaco from '@opensumi/ide-monaco';
|
|
55
55
|
import { IDialogService, IMessageService, IWindowDialogService } from '@opensumi/ide-overlay';
|
|
56
|
+
import { Dimension } from '@opensumi/monaco-editor-core/esm/vs/base/browser/dom';
|
|
56
57
|
|
|
57
58
|
import {
|
|
58
59
|
CursorStatus,
|
|
@@ -76,6 +77,7 @@ import {
|
|
|
76
77
|
getSplitActionFromDragDrop,
|
|
77
78
|
} from '../common';
|
|
78
79
|
import { IEditorDocumentModelRef } from '../common/editor';
|
|
80
|
+
import { IMultiDiffEditor } from '../common/multi-diff';
|
|
79
81
|
|
|
80
82
|
import { EditorDocumentModel } from './doc-model/editor-document-model';
|
|
81
83
|
import { IEditorDocumentModelService } from './doc-model/types';
|
|
@@ -730,6 +732,8 @@ export class EditorGroup extends WithEventBus implements IGridEditorGroup {
|
|
|
730
732
|
|
|
731
733
|
diffEditor!: IDiffEditor;
|
|
732
734
|
|
|
735
|
+
multiDiffEditor!: IMultiDiffEditor;
|
|
736
|
+
|
|
733
737
|
mergeEditor!: IMergeEditorEditor;
|
|
734
738
|
|
|
735
739
|
private openingPromise: Map<string, Promise<IOpenResourceResult>> = new Map();
|
|
@@ -824,6 +828,8 @@ export class EditorGroup extends WithEventBus implements IGridEditorGroup {
|
|
|
824
828
|
private _domNode: MaybeNull<HTMLElement> = null;
|
|
825
829
|
private _diffEditorDomNode: MaybeNull<HTMLElement> = null;
|
|
826
830
|
private _diffEditorDomNodeAttached = false;
|
|
831
|
+
private _multiFileDiffEditorDomNode: MaybeNull<HTMLElement> = null;
|
|
832
|
+
private _multiFileDiffEditorDomNodeAttached = false;
|
|
827
833
|
private _mergeEditorDomNode: MaybeNull<HTMLElement> = null;
|
|
828
834
|
private _mergeEditorDomNodeAttached = false;
|
|
829
835
|
|
|
@@ -832,6 +838,8 @@ export class EditorGroup extends WithEventBus implements IGridEditorGroup {
|
|
|
832
838
|
private diffEditorReady = new ReadyEvent();
|
|
833
839
|
private diffEditorDomReady = new ReadyEvent();
|
|
834
840
|
|
|
841
|
+
private multiDiffEditorDomReady = new ReadyEvent();
|
|
842
|
+
|
|
835
843
|
private mergeEditorReady = new ReadyEvent();
|
|
836
844
|
private mergeEditorDomReady = new ReadyEvent();
|
|
837
845
|
|
|
@@ -841,6 +849,9 @@ export class EditorGroup extends WithEventBus implements IGridEditorGroup {
|
|
|
841
849
|
|
|
842
850
|
private _currentOrPreviousFocusedEditor: IEditor | null;
|
|
843
851
|
|
|
852
|
+
private _multiDiffEditorDomNode: HTMLElement | null | undefined;
|
|
853
|
+
private _multiDiffEditorDomNodeAttached = false;
|
|
854
|
+
|
|
844
855
|
constructor(public readonly name: string, public readonly groupId: number) {
|
|
845
856
|
super();
|
|
846
857
|
this.eventBus.onDirective(
|
|
@@ -928,6 +939,13 @@ export class EditorGroup extends WithEventBus implements IGridEditorGroup {
|
|
|
928
939
|
this.diffEditor.layout();
|
|
929
940
|
}
|
|
930
941
|
break;
|
|
942
|
+
case EditorOpenType.multiDiff:
|
|
943
|
+
if (this.multiDiffEditor && this._multiDiffEditorDomNodeAttached) {
|
|
944
|
+
this.multiDiffEditor.layout(
|
|
945
|
+
new Dimension(this._multiDiffEditorDomNode!.offsetWidth, this._multiDiffEditorDomNode!.offsetHeight),
|
|
946
|
+
);
|
|
947
|
+
}
|
|
948
|
+
break;
|
|
931
949
|
default:
|
|
932
950
|
break;
|
|
933
951
|
}
|
|
@@ -1865,6 +1883,9 @@ export class EditorGroup extends WithEventBus implements IGridEditorGroup {
|
|
|
1865
1883
|
case EditorOpenType.diff:
|
|
1866
1884
|
await this.openDiffEditor(resource, options);
|
|
1867
1885
|
break;
|
|
1886
|
+
case EditorOpenType.multiDiff:
|
|
1887
|
+
await this.openMultiDiffEditor(resource, options);
|
|
1888
|
+
break;
|
|
1868
1889
|
case EditorOpenType.mergeEditor:
|
|
1869
1890
|
await this.openMergeEditor(resource);
|
|
1870
1891
|
break;
|
|
@@ -2277,6 +2298,7 @@ export class EditorGroup extends WithEventBus implements IGridEditorGroup {
|
|
|
2277
2298
|
super.dispose();
|
|
2278
2299
|
this.codeEditor && this.codeEditor.dispose();
|
|
2279
2300
|
this.diffEditor && this.diffEditor.dispose();
|
|
2301
|
+
this.multiDiffEditor && this.multiDiffEditor.dispose();
|
|
2280
2302
|
this.toDispose.forEach((disposable) => disposable.dispose());
|
|
2281
2303
|
this.eventBus.fire(
|
|
2282
2304
|
new EditorGroupDisposeEvent({
|
|
@@ -2441,6 +2463,35 @@ export class EditorGroup extends WithEventBus implements IGridEditorGroup {
|
|
|
2441
2463
|
name: this.name,
|
|
2442
2464
|
};
|
|
2443
2465
|
}
|
|
2466
|
+
|
|
2467
|
+
attachMultiDiffEditorDom(domNode: HTMLElement | null | undefined) {
|
|
2468
|
+
if (!this._multiDiffEditorDomNodeAttached) {
|
|
2469
|
+
this._multiDiffEditorDomNode = domNode;
|
|
2470
|
+
this.multiDiffEditorDomReady.ready();
|
|
2471
|
+
this._multiDiffEditorDomNodeAttached = true;
|
|
2472
|
+
}
|
|
2473
|
+
}
|
|
2474
|
+
|
|
2475
|
+
createMultiDiffEditor(dom: HTMLElement) {
|
|
2476
|
+
const editor = this.collectionService.createMultiDiffEditor(
|
|
2477
|
+
dom,
|
|
2478
|
+
{},
|
|
2479
|
+
{ [ServiceNames.CONTEXT_KEY_SERVICE]: this.contextKeyService.contextKeyService },
|
|
2480
|
+
);
|
|
2481
|
+
this.multiDiffEditor = editor;
|
|
2482
|
+
}
|
|
2483
|
+
|
|
2484
|
+
private async openMultiDiffEditor(resource: IResource, options: IResourceOpenOptions) {
|
|
2485
|
+
if (!this.multiDiffEditor) {
|
|
2486
|
+
await this.multiDiffEditorDomReady.onceReady(() => {
|
|
2487
|
+
const container = document.createElement('div');
|
|
2488
|
+
this._multiDiffEditorDomNode?.appendChild(container);
|
|
2489
|
+
this.createMultiDiffEditor(container);
|
|
2490
|
+
});
|
|
2491
|
+
}
|
|
2492
|
+
|
|
2493
|
+
await this.multiDiffEditor.compareMultiple(resource, options);
|
|
2494
|
+
}
|
|
2444
2495
|
}
|
|
2445
2496
|
|
|
2446
2497
|
function findSuitableOpenType(
|
package/src/common/editor.ts
CHANGED
|
@@ -16,6 +16,7 @@ import {
|
|
|
16
16
|
URI,
|
|
17
17
|
} from '@opensumi/ide-core-common';
|
|
18
18
|
|
|
19
|
+
import { IMultiDiffEditor } from './multi-diff';
|
|
19
20
|
import { IResource } from './resource';
|
|
20
21
|
import { IDocModelUpdateOptions } from './types';
|
|
21
22
|
|
|
@@ -344,6 +345,18 @@ export abstract class EditorCollectionService {
|
|
|
344
345
|
*/
|
|
345
346
|
public abstract createDiffEditor(dom: HTMLElement, options?: any, overrides?: { [key: string]: any }): IDiffEditor;
|
|
346
347
|
|
|
348
|
+
/**
|
|
349
|
+
* 创建一个 monaco multiFileDiffEditor 实例
|
|
350
|
+
* @param dom
|
|
351
|
+
* @param options
|
|
352
|
+
* @param overrides
|
|
353
|
+
*/
|
|
354
|
+
public abstract createMultiDiffEditor(
|
|
355
|
+
dom: HTMLElement,
|
|
356
|
+
options?: any,
|
|
357
|
+
overrides?: { [key: string]: any },
|
|
358
|
+
): IMultiDiffEditor;
|
|
359
|
+
|
|
347
360
|
public abstract createMergeEditor(
|
|
348
361
|
dom: HTMLElement,
|
|
349
362
|
options?: any,
|
|
@@ -869,6 +882,7 @@ export enum EditorOpenType {
|
|
|
869
882
|
diff = 'diff',
|
|
870
883
|
mergeEditor = 'mergeEditor',
|
|
871
884
|
component = 'component',
|
|
885
|
+
multiDiff = 'multiDiff',
|
|
872
886
|
}
|
|
873
887
|
|
|
874
888
|
// 定义一个resource如何被打开
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { Event, IDisposable, URI } from '@opensumi/ide-core-common';
|
|
2
|
+
import { ContextKeyValue } from '@opensumi/ide-monaco';
|
|
3
|
+
import { Dimension } from '@opensumi/monaco-editor-core/esm/vs/base/browser/dom';
|
|
4
|
+
import { IValueWithChangeEvent } from '@opensumi/monaco-editor-core/esm/vs/base/common/event';
|
|
5
|
+
import {
|
|
6
|
+
IDocumentDiffItem,
|
|
7
|
+
IMultiDiffEditorModel,
|
|
8
|
+
} from '@opensumi/monaco-editor-core/esm/vs/editor/browser/widget/multiDiffEditor/model';
|
|
9
|
+
|
|
10
|
+
import { IResourceOpenOptions } from './editor';
|
|
11
|
+
import { IResource } from './resource';
|
|
12
|
+
|
|
13
|
+
export const MULTI_DIFF_SCHEME = 'multi-diff-editor';
|
|
14
|
+
|
|
15
|
+
export const IMultiDiffSourceResolverService = Symbol('IMultiDiffSourceResolverService');
|
|
16
|
+
|
|
17
|
+
export interface IMultiDiffSourceResolverService {
|
|
18
|
+
registerResolver(resolver: IMultiDiffSourceResolver): IDisposable;
|
|
19
|
+
|
|
20
|
+
resolve(uri: URI): Promise<IResolvedMultiDiffSource | undefined>;
|
|
21
|
+
|
|
22
|
+
getResolvers(): IMultiDiffSourceResolver[];
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export interface IMultiDiffSourceResolver {
|
|
26
|
+
canHandleUri(uri: URI): boolean;
|
|
27
|
+
|
|
28
|
+
resolveDiffSource(uri: URI): Promise<IResolvedMultiDiffSource | undefined>;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export interface IResolvedMultiDiffSource {
|
|
32
|
+
readonly resources: IValueWithChangeEvent<readonly MultiDiffEditorItem[]>;
|
|
33
|
+
readonly contextKeys?: Record<string, ContextKeyValue>;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export class MultiDiffEditorItem {
|
|
37
|
+
constructor(
|
|
38
|
+
readonly originalUri: URI | undefined,
|
|
39
|
+
readonly modifiedUri: URI | undefined,
|
|
40
|
+
readonly goToFileUri: URI | undefined,
|
|
41
|
+
readonly contextKeys?: Record<string, ContextKeyValue>,
|
|
42
|
+
) {
|
|
43
|
+
if (!originalUri && !modifiedUri) {
|
|
44
|
+
throw new Error('Invalid arguments');
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
getKey(): string {
|
|
49
|
+
return JSON.stringify([this.modifiedUri?.toString(), this.originalUri?.toString()]);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Multi-file Diff Editor abstraction
|
|
55
|
+
* Extends the concept of diff editor to handle multiple file pairs
|
|
56
|
+
*/
|
|
57
|
+
export interface IMultiDiffEditor extends IDisposable {
|
|
58
|
+
/**
|
|
59
|
+
* Compare multiple file pairs
|
|
60
|
+
*/
|
|
61
|
+
compareMultiple(resource: IResource, options?: IResourceOpenOptions): Promise<void>;
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Get all file pairs currently being compared
|
|
65
|
+
*/
|
|
66
|
+
getDiffEntry(uri: URI): IDocumentDiffItem | undefined;
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Get the currently selected/active file pair
|
|
70
|
+
*/
|
|
71
|
+
getCurrentDiffEntry(): IDocumentDiffItem | undefined;
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Layout the editor
|
|
75
|
+
*/
|
|
76
|
+
layout(dimension: Dimension): void;
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Focus the editor
|
|
80
|
+
*/
|
|
81
|
+
focus(): void;
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Event emitted when the multi-diff editor model changes
|
|
85
|
+
*/
|
|
86
|
+
onMultiDiffModelChange: Event<IMultiDiffEditorModel>;
|
|
87
|
+
}
|