@opensumi/ide-editor 3.3.1-next-1725517520.0 → 3.3.1-next-1725521092.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 +1 -1
- package/lib/browser/editor-collection.service.d.ts.map +1 -1
- package/lib/browser/editor-collection.service.js +2 -2
- package/lib/browser/editor-collection.service.js.map +1 -1
- package/lib/browser/editor.contribution.d.ts.map +1 -1
- package/lib/browser/editor.contribution.js.map +1 -1
- package/lib/browser/editor.module.less +0 -1
- package/lib/browser/editor.view.d.ts +2 -4
- package/lib/browser/editor.view.d.ts.map +1 -1
- package/lib/browser/editor.view.js +19 -8
- package/lib/browser/editor.view.js.map +1 -1
- package/lib/browser/workbench-editor.service.d.ts +3 -6
- package/lib/browser/workbench-editor.service.d.ts.map +1 -1
- package/lib/browser/workbench-editor.service.js +97 -109
- package/lib/browser/workbench-editor.service.js.map +1 -1
- package/lib/common/editor.d.ts +1 -1
- package/lib/common/editor.d.ts.map +1 -1
- package/package.json +14 -14
- package/src/browser/editor-collection.service.ts +2 -2
- package/src/browser/editor.contribution.ts +4 -1
- package/src/browser/editor.module.less +0 -1
- package/src/browser/editor.view.tsx +192 -182
- package/src/browser/workbench-editor.service.ts +99 -105
- package/src/common/editor.ts +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import cls from 'classnames';
|
|
2
2
|
import { observer } from 'mobx-react-lite';
|
|
3
|
-
import React from 'react';
|
|
3
|
+
import React, { forwardRef } from 'react';
|
|
4
4
|
import ReactDOM from 'react-dom/client';
|
|
5
5
|
|
|
6
6
|
import { Scrollbars } from '@opensumi/ide-components';
|
|
@@ -13,6 +13,7 @@ import {
|
|
|
13
13
|
ErrorBoundary,
|
|
14
14
|
IEventBus,
|
|
15
15
|
MaybeNull,
|
|
16
|
+
PreferenceService,
|
|
16
17
|
URI,
|
|
17
18
|
View,
|
|
18
19
|
renderView,
|
|
@@ -91,11 +92,13 @@ export const EditorView = () => {
|
|
|
91
92
|
}
|
|
92
93
|
}}
|
|
93
94
|
>
|
|
94
|
-
<
|
|
95
|
+
<div className={styles.kt_editor_main_wrapper}>
|
|
96
|
+
<EditorGridView grid={workbenchEditorService.topGrid}></EditorGridView>
|
|
97
|
+
</div>
|
|
95
98
|
{RightWidget ? (
|
|
96
99
|
<div className={styles.kt_editor_right_widget}>
|
|
97
100
|
<ErrorBoundary>
|
|
98
|
-
<RightWidget
|
|
101
|
+
<RightWidget></RightWidget>
|
|
99
102
|
</ErrorBoundary>
|
|
100
103
|
</div>
|
|
101
104
|
) : null}
|
|
@@ -206,13 +209,10 @@ export const EditorGridView = ({ grid }: { grid: EditorGrid }) => {
|
|
|
206
209
|
|
|
207
210
|
return (
|
|
208
211
|
<div
|
|
209
|
-
className={cls(
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
},
|
|
214
|
-
styles.kt_editor_main_wrapper,
|
|
215
|
-
)}
|
|
212
|
+
className={cls({
|
|
213
|
+
[styles.kt_grid_vertical]: grid.splitDirection === SplitDirection.Vertical,
|
|
214
|
+
[styles.kt_grid_horizontal]: grid.splitDirection === SplitDirection.Horizontal,
|
|
215
|
+
})}
|
|
216
216
|
>
|
|
217
217
|
{children}
|
|
218
218
|
</div>
|
|
@@ -281,7 +281,6 @@ export const EditorGroupView = observer(({ group }: { group: EditorGroup }) => {
|
|
|
281
281
|
|
|
282
282
|
return (
|
|
283
283
|
<div
|
|
284
|
-
ref={groupWrapperRef as any}
|
|
285
284
|
className={styles_kt_editor_group}
|
|
286
285
|
tabIndex={1}
|
|
287
286
|
onFocus={(e) => {
|
|
@@ -293,7 +292,7 @@ export const EditorGroupView = observer(({ group }: { group: EditorGroup }) => {
|
|
|
293
292
|
<Tabs group={group} />
|
|
294
293
|
</div>
|
|
295
294
|
)}
|
|
296
|
-
<EditorGroupBody group={group} />
|
|
295
|
+
<EditorGroupBody ref={groupWrapperRef as any} group={group} />
|
|
297
296
|
{isEmpty && (
|
|
298
297
|
<div
|
|
299
298
|
className={styles.kt_editor_background}
|
|
@@ -308,190 +307,201 @@ export const EditorGroupView = observer(({ group }: { group: EditorGroup }) => {
|
|
|
308
307
|
);
|
|
309
308
|
});
|
|
310
309
|
|
|
311
|
-
export const EditorGroupBody = observer(
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
310
|
+
export const EditorGroupBody = observer(
|
|
311
|
+
forwardRef(({ group }: { group: EditorGroup }, ref) => {
|
|
312
|
+
const [context, setContext] = React.useState<IEditorContext>(defaultEditorContext);
|
|
313
|
+
|
|
314
|
+
const editorBodyRef = React.useRef<HTMLDivElement | null>(null);
|
|
315
|
+
const editorService = useInjectable(WorkbenchEditorService) as WorkbenchEditorServiceImpl;
|
|
316
|
+
const eventBus = useInjectable(IEventBus) as IEventBus;
|
|
317
|
+
const styles_kt_editor_component = useDesignStyles(styles.kt_editor_component, 'kt_editor_component');
|
|
318
|
+
const components: React.ReactNode[] = [];
|
|
319
|
+
const codeEditorRef = React.useRef<HTMLDivElement>(null);
|
|
320
|
+
const diffEditorRef = React.useRef<HTMLDivElement>(null);
|
|
321
|
+
const mergeEditorRef = React.useRef<HTMLDivElement>(null);
|
|
322
|
+
const [, updateState] = React.useState<any>();
|
|
323
|
+
const forceUpdate = React.useCallback(() => updateState({}), []);
|
|
324
|
+
|
|
325
|
+
React.useEffect(() => {
|
|
326
|
+
const disposables = new DisposableStore();
|
|
327
|
+
|
|
328
|
+
disposables.add(
|
|
329
|
+
group.onDidEditorGroupBodyChanged(() => {
|
|
330
|
+
forceUpdate();
|
|
331
|
+
}),
|
|
332
|
+
);
|
|
333
333
|
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
334
|
+
if (codeEditorRef.current) {
|
|
335
|
+
if (cachedEditor[group.name]) {
|
|
336
|
+
cachedEditor[group.name].remove();
|
|
337
|
+
codeEditorRef.current.appendChild(cachedEditor[group.name]);
|
|
338
|
+
} else {
|
|
339
|
+
const container = document.createElement('div');
|
|
340
|
+
codeEditorRef.current.appendChild(container);
|
|
341
|
+
cachedEditor[group.name] = container;
|
|
342
|
+
group.createEditor(container);
|
|
343
|
+
const minimapWith = group.codeEditor.monacoEditor.getOption(monaco.editor.EditorOption.layoutInfo).minimap
|
|
344
|
+
.minimapWidth;
|
|
345
|
+
setContext({ minimapWidth: minimapWith });
|
|
346
|
+
|
|
347
|
+
disposables.add(
|
|
348
|
+
group.codeEditor.monacoEditor.onDidChangeConfiguration((e) => {
|
|
349
|
+
if (e.hasChanged(monaco.editor.EditorOption.layoutInfo)) {
|
|
350
|
+
setContext({
|
|
351
|
+
minimapWidth: group.codeEditor.monacoEditor.getOption(monaco.editor.EditorOption.layoutInfo).minimap
|
|
352
|
+
.minimapWidth,
|
|
353
|
+
});
|
|
354
|
+
}
|
|
355
|
+
}),
|
|
356
|
+
);
|
|
357
|
+
}
|
|
357
358
|
}
|
|
358
|
-
}
|
|
359
359
|
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
360
|
+
if (diffEditorRef.current) {
|
|
361
|
+
group.attachDiffEditorDom(diffEditorRef.current);
|
|
362
|
+
}
|
|
363
|
+
if (mergeEditorRef.current) {
|
|
364
|
+
group.attachMergeEditorDom(mergeEditorRef.current);
|
|
365
|
+
}
|
|
366
366
|
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
367
|
+
return () => {
|
|
368
|
+
disposables.dispose();
|
|
369
|
+
};
|
|
370
|
+
}, []);
|
|
371
371
|
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
key={component.uid}
|
|
377
|
-
className={cls({
|
|
378
|
-
[styles.kt_hidden]: !(group.currentOpenType && group.currentOpenType.componentId === component.uid),
|
|
379
|
-
})}
|
|
380
|
-
>
|
|
381
|
-
<ComponentsWrapper
|
|
372
|
+
group.activeComponents.forEach((resources, component) => {
|
|
373
|
+
const initialProps = group.activateComponentsProps.get(component);
|
|
374
|
+
components.push(
|
|
375
|
+
<div
|
|
382
376
|
key={component.uid}
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
377
|
+
className={cls({
|
|
378
|
+
[styles.kt_hidden]: !(group.currentOpenType && group.currentOpenType.componentId === component.uid),
|
|
379
|
+
})}
|
|
380
|
+
>
|
|
381
|
+
<ComponentsWrapper
|
|
382
|
+
key={component.uid}
|
|
383
|
+
component={component}
|
|
384
|
+
{...initialProps}
|
|
385
|
+
resources={resources}
|
|
386
|
+
current={group.currentResource}
|
|
387
|
+
></ComponentsWrapper>
|
|
388
|
+
</div>,
|
|
389
|
+
);
|
|
390
|
+
});
|
|
391
391
|
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
392
|
+
const editorHasNoTab = React.useMemo(
|
|
393
|
+
() => group.resources.length === 0 || !group.currentResource,
|
|
394
|
+
[group.resources.length, group.currentResource],
|
|
395
|
+
);
|
|
396
396
|
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
397
|
+
React.useEffect(() => {
|
|
398
|
+
if (group.currentOpenType?.type === EditorOpenType.code) {
|
|
399
|
+
eventBus.fire(
|
|
400
|
+
new CodeEditorDidVisibleEvent({
|
|
401
|
+
groupName: group.name,
|
|
402
|
+
type: EditorOpenType.code,
|
|
403
|
+
editorId: group.codeEditor.getId(),
|
|
404
|
+
}),
|
|
405
|
+
);
|
|
406
|
+
} else if (group.currentOpenType?.type === EditorOpenType.diff) {
|
|
407
|
+
eventBus.fire(
|
|
408
|
+
new CodeEditorDidVisibleEvent({
|
|
409
|
+
groupName: group.name,
|
|
410
|
+
type: EditorOpenType.diff,
|
|
411
|
+
editorId: group.diffEditor.modifiedEditor.getId(),
|
|
412
|
+
}),
|
|
413
|
+
);
|
|
414
|
+
}
|
|
415
|
+
});
|
|
416
416
|
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
}
|
|
429
|
-
}}
|
|
430
|
-
onDragLeave={(e) => {
|
|
431
|
-
if (editorBodyRef.current) {
|
|
432
|
-
removeDecorationDragOverElement(editorBodyRef.current);
|
|
433
|
-
}
|
|
434
|
-
}}
|
|
435
|
-
onDrop={(e) => {
|
|
436
|
-
if (editorBodyRef.current) {
|
|
437
|
-
removeDecorationDragOverElement(editorBodyRef.current);
|
|
438
|
-
if (e.dataTransfer.getData('uri')) {
|
|
439
|
-
const uri = new URI(e.dataTransfer.getData('uri'));
|
|
440
|
-
let sourceGroup: EditorGroup | undefined;
|
|
441
|
-
if (e.dataTransfer.getData('uri-source-group')) {
|
|
442
|
-
sourceGroup = editorService.getEditorGroup(e.dataTransfer.getData('uri-source-group'));
|
|
417
|
+
return (
|
|
418
|
+
<EditorContext.Provider value={context}>
|
|
419
|
+
<div
|
|
420
|
+
id={VIEW_CONTAINERS.EDITOR}
|
|
421
|
+
ref={(_ref) => {
|
|
422
|
+
editorBodyRef.current = _ref;
|
|
423
|
+
if (ref) {
|
|
424
|
+
if (typeof ref === 'function') {
|
|
425
|
+
ref(_ref);
|
|
426
|
+
} else {
|
|
427
|
+
ref.current = _ref;
|
|
443
428
|
}
|
|
444
|
-
group.dropUri(uri, getDragOverPosition(e.nativeEvent, editorBodyRef.current), sourceGroup);
|
|
445
429
|
}
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
);
|
|
430
|
+
}}
|
|
431
|
+
className={styles.kt_editor_body}
|
|
432
|
+
onDragOver={(e) => {
|
|
433
|
+
e.preventDefault();
|
|
434
|
+
if (editorBodyRef.current) {
|
|
435
|
+
const position = getDragOverPosition(e.nativeEvent, editorBodyRef.current);
|
|
436
|
+
decorateDragOverElement(editorBodyRef.current, position);
|
|
454
437
|
}
|
|
455
|
-
}
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
438
|
+
}}
|
|
439
|
+
onDragLeave={(e) => {
|
|
440
|
+
if (editorBodyRef.current) {
|
|
441
|
+
removeDecorationDragOverElement(editorBodyRef.current);
|
|
442
|
+
}
|
|
443
|
+
}}
|
|
444
|
+
onDrop={(e) => {
|
|
445
|
+
if (editorBodyRef.current) {
|
|
446
|
+
removeDecorationDragOverElement(editorBodyRef.current);
|
|
447
|
+
if (e.dataTransfer.getData('uri')) {
|
|
448
|
+
const uri = new URI(e.dataTransfer.getData('uri'));
|
|
449
|
+
let sourceGroup: EditorGroup | undefined;
|
|
450
|
+
if (e.dataTransfer.getData('uri-source-group')) {
|
|
451
|
+
sourceGroup = editorService.getEditorGroup(e.dataTransfer.getData('uri-source-group'));
|
|
452
|
+
}
|
|
453
|
+
group.dropUri(uri, getDragOverPosition(e.nativeEvent, editorBodyRef.current), sourceGroup);
|
|
454
|
+
}
|
|
455
|
+
if (e.dataTransfer.files.length > 0) {
|
|
456
|
+
eventBus.fire(
|
|
457
|
+
new EditorGroupFileDropEvent({
|
|
458
|
+
group,
|
|
459
|
+
files: e.dataTransfer.files,
|
|
460
|
+
position: getDragOverPosition(e.nativeEvent, editorBodyRef.current),
|
|
461
|
+
}),
|
|
462
|
+
);
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
}}
|
|
466
|
+
>
|
|
467
|
+
{group.currentResource && <EditorSideView side='top' resource={group.currentResource}></EditorSideView>}
|
|
468
|
+
{!editorHasNoTab && <NavigationBar editorGroup={group} />}
|
|
469
|
+
<div className={styles.kt_editor_components}>
|
|
470
|
+
<div
|
|
471
|
+
className={cls({
|
|
472
|
+
[styles_kt_editor_component]: true,
|
|
473
|
+
[styles.kt_hidden]: !group.currentOpenType || group.currentOpenType.type !== EditorOpenType.component,
|
|
474
|
+
})}
|
|
475
|
+
>
|
|
476
|
+
{components}
|
|
477
|
+
</div>
|
|
478
|
+
<div
|
|
479
|
+
className={cls({
|
|
480
|
+
[styles.kt_editor_code_editor]: true,
|
|
481
|
+
[styles_kt_editor_component]: true,
|
|
482
|
+
[styles.kt_hidden]: !group.currentOpenType || group.currentOpenType.type !== EditorOpenType.code,
|
|
483
|
+
})}
|
|
484
|
+
ref={codeEditorRef}
|
|
485
|
+
/>
|
|
486
|
+
<div
|
|
487
|
+
className={cls(styles.kt_editor_diff_editor, styles_kt_editor_component, {
|
|
488
|
+
[styles.kt_hidden]: !group.currentOpenType || group.currentOpenType.type !== EditorOpenType.diff,
|
|
489
|
+
})}
|
|
490
|
+
ref={diffEditorRef}
|
|
491
|
+
/>
|
|
492
|
+
<div
|
|
493
|
+
className={cls(styles.kt_editor_diff_3_editor, styles_kt_editor_component, {
|
|
494
|
+
[styles.kt_hidden]: !group.currentOpenType || group.currentOpenType.type !== EditorOpenType.mergeEditor,
|
|
495
|
+
})}
|
|
496
|
+
ref={mergeEditorRef}
|
|
497
|
+
/>
|
|
468
498
|
</div>
|
|
469
|
-
<
|
|
470
|
-
className={cls({
|
|
471
|
-
[styles.kt_editor_code_editor]: true,
|
|
472
|
-
[styles_kt_editor_component]: true,
|
|
473
|
-
[styles.kt_hidden]: !group.currentOpenType || group.currentOpenType.type !== EditorOpenType.code,
|
|
474
|
-
})}
|
|
475
|
-
ref={codeEditorRef}
|
|
476
|
-
/>
|
|
477
|
-
<div
|
|
478
|
-
className={cls(styles.kt_editor_diff_editor, styles_kt_editor_component, {
|
|
479
|
-
[styles.kt_hidden]: !group.currentOpenType || group.currentOpenType.type !== EditorOpenType.diff,
|
|
480
|
-
})}
|
|
481
|
-
ref={diffEditorRef}
|
|
482
|
-
/>
|
|
483
|
-
<div
|
|
484
|
-
className={cls(styles.kt_editor_diff_3_editor, styles_kt_editor_component, {
|
|
485
|
-
[styles.kt_hidden]: !group.currentOpenType || group.currentOpenType.type !== EditorOpenType.mergeEditor,
|
|
486
|
-
})}
|
|
487
|
-
ref={mergeEditorRef}
|
|
488
|
-
/>
|
|
499
|
+
{group.currentResource && <EditorSideView side={'bottom'} resource={group.currentResource}></EditorSideView>}
|
|
489
500
|
</div>
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
});
|
|
501
|
+
</EditorContext.Provider>
|
|
502
|
+
);
|
|
503
|
+
}),
|
|
504
|
+
);
|
|
495
505
|
|
|
496
506
|
export const ComponentsWrapper = ({
|
|
497
507
|
component,
|