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