@opensumi/ide-editor 3.3.1-next-1725432779.0 → 3.3.1-next-1725433243.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.
Files changed (43) hide show
  1. package/lib/browser/editor-collection.service.d.ts +1 -1
  2. package/lib/browser/editor-collection.service.d.ts.map +1 -1
  3. package/lib/browser/editor-collection.service.js +2 -2
  4. package/lib/browser/editor-collection.service.js.map +1 -1
  5. package/lib/browser/editor.module.less +1 -0
  6. package/lib/browser/editor.view.d.ts +4 -2
  7. package/lib/browser/editor.view.d.ts.map +1 -1
  8. package/lib/browser/editor.view.js +6 -16
  9. package/lib/browser/editor.view.js.map +1 -1
  10. package/lib/browser/index.d.ts.map +1 -1
  11. package/lib/browser/index.js +5 -0
  12. package/lib/browser/index.js.map +1 -1
  13. package/lib/browser/notebook.service.d.ts +20 -0
  14. package/lib/browser/notebook.service.d.ts.map +1 -0
  15. package/lib/browser/notebook.service.js +24 -0
  16. package/lib/browser/notebook.service.js.map +1 -0
  17. package/lib/browser/workbench-editor.service.d.ts +6 -1
  18. package/lib/browser/workbench-editor.service.d.ts.map +1 -1
  19. package/lib/browser/workbench-editor.service.js +118 -71
  20. package/lib/browser/workbench-editor.service.js.map +1 -1
  21. package/lib/common/editor.d.ts +1 -1
  22. package/lib/common/editor.d.ts.map +1 -1
  23. package/lib/common/index.d.ts +4 -3
  24. package/lib/common/index.d.ts.map +1 -1
  25. package/lib/common/index.js +4 -3
  26. package/lib/common/index.js.map +1 -1
  27. package/lib/common/language.d.ts +1 -0
  28. package/lib/common/language.d.ts.map +1 -1
  29. package/lib/common/notebook.d.ts +169 -0
  30. package/lib/common/notebook.d.ts.map +1 -0
  31. package/lib/common/notebook.js +26 -0
  32. package/lib/common/notebook.js.map +1 -0
  33. package/package.json +14 -14
  34. package/src/browser/editor-collection.service.ts +2 -2
  35. package/src/browser/editor.module.less +1 -0
  36. package/src/browser/editor.view.tsx +174 -183
  37. package/src/browser/index.ts +6 -0
  38. package/src/browser/notebook.service.ts +19 -0
  39. package/src/browser/workbench-editor.service.ts +105 -70
  40. package/src/common/editor.ts +1 -1
  41. package/src/common/index.ts +4 -3
  42. package/src/common/language.ts +1 -0
  43. package/src/common/notebook.ts +196 -0
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.EditorGroup = exports.WorkbenchEditorServiceImpl = void 0;
4
4
  const tslib_1 = require("tslib");
5
+ const mobx_1 = require("mobx");
5
6
  const di_1 = require("@opensumi/di");
6
7
  const ide_core_browser_1 = require("@opensumi/ide-core-browser");
7
8
  const resource_1 = require("@opensumi/ide-core-browser/lib/contextkey/resource");
@@ -120,37 +121,44 @@ let WorkbenchEditorServiceImpl = class WorkbenchEditorServiceImpl extends ide_co
120
121
  createEditorGroup() {
121
122
  const editorGroup = this.injector.get(EditorGroup, [this.generateRandomEditorGroupName(), this.editorGroupIdGen++]);
122
123
  this.editorGroups.push(editorGroup);
123
- editorGroup.addDispose([
124
- editorGroup.onDidEditorGroupBodyChanged(() => {
125
- if (editorGroup === this.currentEditorGroup) {
126
- if (!editorGroup.currentOpenType && editorGroup.currentResource) {
127
- // 暂时状态,不发事件
128
- }
129
- else {
130
- this._onActiveResourceChange.fire(editorGroup.currentResource);
131
- }
124
+ const currentWatchDisposer = new ide_core_common_1.Disposable(editorGroup.onDidEditorGroupBodyChanged(() => {
125
+ if (editorGroup === this.currentEditorGroup) {
126
+ if (!editorGroup.currentOpenType && editorGroup.currentResource) {
127
+ // 暂时状态,不发事件
132
128
  }
133
- }),
134
- editorGroup.onDidEditorFocusChange(() => {
135
- var _a;
136
- if (editorGroup === this.currentEditorGroup) {
137
- if (!editorGroup.currentOpenType && editorGroup.currentResource) {
138
- // 暂时状态,不发事件
139
- }
140
- else {
141
- this._onActiveEditorUriChange.fire((_a = editorGroup.currentOrPreviousFocusedEditor) === null || _a === void 0 ? void 0 : _a.currentUri);
142
- }
129
+ else {
130
+ this._onActiveResourceChange.fire(editorGroup.currentResource);
143
131
  }
144
- }),
145
- editorGroup.onDidEditorGroupTabChanged(() => {
146
- this.saveOpenedResourceState();
147
- }),
148
- editorGroup.onCurrentEditorCursorChange((e) => {
149
- if (this._currentEditorGroup === editorGroup) {
150
- this._onCursorChange.fire(e);
132
+ }
133
+ }), editorGroup.onDidEditorFocusChange(() => {
134
+ var _a;
135
+ if (editorGroup === this.currentEditorGroup) {
136
+ if (!editorGroup.currentOpenType && editorGroup.currentResource) {
137
+ // 暂时状态,不发事件
151
138
  }
152
- }),
153
- ]);
139
+ else {
140
+ this._onActiveEditorUriChange.fire((_a = editorGroup.currentOrPreviousFocusedEditor) === null || _a === void 0 ? void 0 : _a.currentUri);
141
+ }
142
+ }
143
+ }));
144
+ editorGroup.addDispose({
145
+ dispose: () => {
146
+ currentWatchDisposer.dispose();
147
+ },
148
+ });
149
+ const groupChangeDisposer = editorGroup.onDidEditorGroupTabChanged(() => {
150
+ this.saveOpenedResourceState();
151
+ });
152
+ editorGroup.addDispose({
153
+ dispose: () => {
154
+ groupChangeDisposer.dispose();
155
+ },
156
+ });
157
+ editorGroup.onCurrentEditorCursorChange((e) => {
158
+ if (this._currentEditorGroup === editorGroup) {
159
+ this._onCursorChange.fire(e);
160
+ }
161
+ });
154
162
  return editorGroup;
155
163
  }
156
164
  /**
@@ -489,22 +497,22 @@ let EditorGroup = class EditorGroup extends ide_core_common_1.WithEventBus {
489
497
  /**
490
498
  * 当编辑器的tab部分发生变更
491
499
  */
492
- this._onDidEditorGroupTabChanged = this.registerDispose(new ide_core_common_1.Emitter());
500
+ this._onDidEditorGroupTabChanged = new ide_core_common_1.Emitter();
493
501
  this.onDidEditorGroupTabChanged = this._onDidEditorGroupTabChanged.event;
494
502
  /**
495
503
  * 当编辑器的tab部分发生变更
496
504
  */
497
- this._onDidEditorGroupTabOperation = this.registerDispose(new ide_core_common_1.Emitter());
505
+ this._onDidEditorGroupTabOperation = new ide_core_common_1.Emitter();
498
506
  this.onDidEditorGroupTabOperation = this._onDidEditorGroupTabOperation.event;
499
507
  /**
500
508
  * 当编辑器的主体部分发生变更
501
509
  */
502
- this._onDidEditorGroupBodyChanged = this.registerDispose(new ide_core_common_1.Emitter());
510
+ this._onDidEditorGroupBodyChanged = new ide_core_common_1.Emitter();
503
511
  this.onDidEditorGroupBodyChanged = this._onDidEditorGroupBodyChanged.event;
504
512
  /**
505
513
  * 当编辑器有内容处于加载状态
506
514
  */
507
- this._onDidEditorGroupContentLoading = this.registerDispose(new ide_core_common_1.Emitter());
515
+ this._onDidEditorGroupContentLoading = new ide_core_common_1.Emitter();
508
516
  this.onDidEditorGroupContentLoading = this._onDidEditorGroupContentLoading.event;
509
517
  /**
510
518
  * 每个group只能有一个preview
@@ -524,10 +532,14 @@ let EditorGroup = class EditorGroup extends ide_core_common_1.WithEventBus {
524
532
  this.activeComponents = new Map();
525
533
  this.activateComponentsProps = new Map();
526
534
  this.holdDocumentModelRefs = new Map();
535
+ this.toDispose = [];
527
536
  this._prevDomHeight = 0;
528
537
  this._prevDomWidth = 0;
538
+ this._codeEditorPendingLayout = false;
539
+ this._diffEditorPendingLayout = false;
540
+ this._mergeEditorPendingLayout = false;
529
541
  // 当前为EditorComponent,且monaco光标变化时触发
530
- this._onCurrentEditorCursorChange = this.registerDispose(new ide_core_common_1.Emitter());
542
+ this._onCurrentEditorCursorChange = new ide_core_common_1.Emitter();
531
543
  this.onCurrentEditorCursorChange = this._onCurrentEditorCursorChange.event;
532
544
  this.resourceOpenHistory = [];
533
545
  this._domNode = null;
@@ -541,24 +553,32 @@ let EditorGroup = class EditorGroup extends ide_core_common_1.WithEventBus {
541
553
  this.mergeEditorReady = new ide_core_common_1.ReadyEvent();
542
554
  this.mergeEditorDomReady = new ide_core_common_1.ReadyEvent();
543
555
  this._restoringState = false;
544
- this.addDispose(this.eventBus.onDirective(ide_core_browser_1.ResizeEvent.createDirective((0, ide_core_browser_1.getSlotLocation)('@opensumi/ide-editor', this.config.layoutConfig)), () => {
545
- this.layoutEditors();
546
- }));
547
- this.addDispose(this.eventBus.on(types_2.GridResizeEvent, (e) => {
556
+ let toDispose;
557
+ this.eventBus.onDirective(ide_core_browser_1.ResizeEvent.createDirective((0, ide_core_browser_1.getSlotLocation)('@opensumi/ide-editor', this.config.layoutConfig)), () => {
558
+ if (toDispose) {
559
+ toDispose.dispose();
560
+ }
561
+ toDispose = ide_core_browser_1.fastdom.mutate(() => {
562
+ this._layoutEditorWorker();
563
+ });
564
+ });
565
+ this.eventBus.on(types_2.GridResizeEvent, (e) => {
548
566
  if (e.payload.gridId === this.grid.uid) {
549
- this.layoutEditors();
567
+ this.doLayoutEditors();
550
568
  }
551
- }));
552
- this.addDispose(this.eventBus.on(types_2.EditorComponentDisposeEvent, (e) => {
569
+ });
570
+ this.eventBus.on(types_2.EditorComponentDisposeEvent, (e) => {
553
571
  this.activeComponents.delete(e.payload);
554
572
  this.activateComponentsProps.delete(e.payload);
555
- }));
573
+ });
556
574
  this.listenToExplorerAutoRevealConfig();
557
575
  }
558
576
  listenToExplorerAutoRevealConfig() {
559
577
  this.explorerAutoRevealConfig = !!this.preferenceService.get('explorer.autoReveal');
560
- this.disposables.push(this.preferenceService.onSpecificPreferenceChange('explorer.autoReveal', (change) => {
561
- this.explorerAutoRevealConfig = change.newValue;
578
+ this.disposables.push(this.preferenceService.onPreferenceChanged((change) => {
579
+ if (change.preferenceName === 'explorer.autoReveal') {
580
+ this.explorerAutoRevealConfig = change.newValue;
581
+ }
562
582
  }));
563
583
  }
564
584
  attachDiffEditorDom(domNode) {
@@ -585,26 +605,47 @@ let EditorGroup = class EditorGroup extends ide_core_common_1.WithEventBus {
585
605
  layoutEditors() {
586
606
  ide_core_browser_1.fastdom.measure(() => {
587
607
  if (this._domNode) {
588
- this._prevDomWidth = this._domNode.offsetWidth;
589
- this._prevDomHeight = this._domNode.offsetHeight;
590
- this.doLayoutEditors({
591
- width: this._prevDomWidth,
592
- height: this._prevDomHeight,
593
- }, true);
608
+ const currentWidth = this._domNode.offsetWidth;
609
+ const currentHeight = this._domNode.offsetHeight;
610
+ if (currentWidth !== this._prevDomWidth || currentHeight !== this._prevDomHeight) {
611
+ this.doLayoutEditors();
612
+ }
613
+ this._prevDomWidth = currentWidth;
614
+ this._prevDomHeight = currentHeight;
594
615
  }
595
616
  });
596
617
  }
597
- doLayoutEditors(e, postponeRendering) {
618
+ _layoutEditorWorker() {
598
619
  if (this.codeEditor) {
599
620
  if (this.currentOpenType && this.currentOpenType.type === types_2.EditorOpenType.code) {
600
- this.codeEditor.layout(e, postponeRendering);
621
+ this.codeEditor.layout();
622
+ this._codeEditorPendingLayout = false;
623
+ }
624
+ else {
625
+ this._codeEditorPendingLayout = true;
601
626
  }
602
627
  }
603
628
  if (this.diffEditor) {
604
629
  if (this.currentOpenType && this.currentOpenType.type === types_2.EditorOpenType.diff) {
605
- this.diffEditor.layout(e, postponeRendering);
630
+ this.diffEditor.layout();
631
+ this._diffEditorPendingLayout = false;
632
+ }
633
+ else {
634
+ this._diffEditorPendingLayout = true;
606
635
  }
607
636
  }
637
+ if (this.mergeEditor) {
638
+ if (this.currentOpenType && this.currentOpenType.type === types_2.EditorOpenType.mergeEditor) {
639
+ // this.mergeEditor.layout();
640
+ this._mergeEditorPendingLayout = false;
641
+ }
642
+ else {
643
+ this._mergeEditorPendingLayout = true;
644
+ }
645
+ }
646
+ }
647
+ doLayoutEditors() {
648
+ this._layoutEditorWorker();
608
649
  }
609
650
  setContextKeys() {
610
651
  var _a;
@@ -824,17 +865,15 @@ let EditorGroup = class EditorGroup extends ide_core_common_1.WithEventBus {
824
865
  [ide_core_browser_1.ServiceNames.CONTEXT_KEY_SERVICE]: this.contextKeyService.contextKeyService,
825
866
  });
826
867
  setTimeout(() => {
827
- ide_core_browser_1.fastdom.mutate(() => {
828
- this.codeEditor.layout();
829
- });
868
+ this.codeEditor.layout();
830
869
  });
831
870
  this.addDispose(this.codeEditor.onRefOpen(() => {
832
871
  this.codeEditor.layout();
833
872
  }));
834
- this.addDispose(this.codeEditor.onCursorPositionChanged((e) => {
873
+ this.toDispose.push(this.codeEditor.onCursorPositionChanged((e) => {
835
874
  this._onCurrentEditorCursorChange.fire(e);
836
875
  }));
837
- this.addDispose(this.codeEditor.onSelectionsChanged((e) => {
876
+ this.toDispose.push(this.codeEditor.onSelectionsChanged((e) => {
838
877
  if (this.currentOpenType && this.currentOpenType.type === types_2.EditorOpenType.code) {
839
878
  this.eventBus.fire(new types_2.EditorSelectionChangeEvent({
840
879
  group: this,
@@ -845,7 +884,7 @@ let EditorGroup = class EditorGroup extends ide_core_common_1.WithEventBus {
845
884
  }));
846
885
  }
847
886
  }));
848
- this.addDispose(this.codeEditor.onVisibleRangesChanged((e) => {
887
+ this.toDispose.push(this.codeEditor.onVisibleRangesChanged((e) => {
849
888
  if (this.currentOpenType && this.currentOpenType.type === types_2.EditorOpenType.code) {
850
889
  this.eventBus.fire(new types_2.EditorVisibleChangeEvent({
851
890
  group: this,
@@ -855,7 +894,7 @@ let EditorGroup = class EditorGroup extends ide_core_common_1.WithEventBus {
855
894
  }));
856
895
  }
857
896
  }));
858
- this.addDispose(this.codeEditor.onConfigurationChanged(() => {
897
+ this.toDispose.push(this.codeEditor.onConfigurationChanged(() => {
859
898
  if (this.currentOpenType && this.currentOpenType.type === types_2.EditorOpenType.code) {
860
899
  this.eventBus.fire(new types_2.EditorConfigurationChangedEvent({
861
900
  group: this,
@@ -882,14 +921,7 @@ let EditorGroup = class EditorGroup extends ide_core_common_1.WithEventBus {
882
921
  [ide_core_browser_1.ServiceNames.CONTEXT_KEY_SERVICE]: this.contextKeyService.contextKeyService,
883
922
  });
884
923
  setTimeout(() => {
885
- ide_core_browser_1.fastdom.mutate(() => {
886
- this.diffEditor.layout();
887
- });
888
- });
889
- this.diffEditor.onRefOpen(() => {
890
- ide_core_browser_1.fastdom.mutate(() => {
891
- this.diffEditor.layout();
892
- });
924
+ this.diffEditor.layout();
893
925
  });
894
926
  this.addDiffEditorEventListeners(this.diffEditor.originalEditor, 'original');
895
927
  this.addDiffEditorEventListeners(this.diffEditor.modifiedEditor, 'modified');
@@ -906,7 +938,7 @@ let EditorGroup = class EditorGroup extends ide_core_common_1.WithEventBus {
906
938
  this.diffEditorReady.ready();
907
939
  }
908
940
  addDiffEditorEventListeners(editor, side) {
909
- this.addDispose(editor.onSelectionsChanged((e) => {
941
+ this.toDispose.push(editor.onSelectionsChanged((e) => {
910
942
  if (this.currentOpenType && this.currentOpenType.type === types_2.EditorOpenType.diff) {
911
943
  this.eventBus.fire(new types_2.EditorSelectionChangeEvent({
912
944
  group: this,
@@ -918,7 +950,7 @@ let EditorGroup = class EditorGroup extends ide_core_common_1.WithEventBus {
918
950
  }));
919
951
  }
920
952
  }));
921
- this.addDispose(editor.onVisibleRangesChanged((e) => {
953
+ this.toDispose.push(editor.onVisibleRangesChanged((e) => {
922
954
  if (this.currentOpenType && this.currentOpenType.type === types_2.EditorOpenType.diff) {
923
955
  this.eventBus.fire(new types_2.EditorVisibleChangeEvent({
924
956
  group: this,
@@ -928,7 +960,7 @@ let EditorGroup = class EditorGroup extends ide_core_common_1.WithEventBus {
928
960
  }));
929
961
  }
930
962
  }));
931
- this.addDispose(editor.onConfigurationChanged(() => {
963
+ this.toDispose.push(editor.onConfigurationChanged(() => {
932
964
  if (this.currentOpenType && this.currentOpenType.type === types_2.EditorOpenType.diff) {
933
965
  this.eventBus.fire(new types_2.EditorConfigurationChangedEvent({
934
966
  group: this,
@@ -1435,7 +1467,11 @@ let EditorGroup = class EditorGroup extends ide_core_common_1.WithEventBus {
1435
1467
  this.resolveTabChanged(_resource, this.currentResource);
1436
1468
  this._currentOpenType = activeOpenType;
1437
1469
  this.notifyBodyChanged();
1438
- this.layoutEditors();
1470
+ if ((!this._codeEditorPendingLayout && activeOpenType.type === types_2.EditorOpenType.code) ||
1471
+ (!this._diffEditorPendingLayout && activeOpenType.type === types_2.EditorOpenType.diff) ||
1472
+ (!this._mergeEditorPendingLayout && activeOpenType.type === types_2.EditorOpenType.mergeEditor)) {
1473
+ this.doLayoutEditors();
1474
+ }
1439
1475
  this.cachedResourcesActiveOpenTypes.set(resource.uri.toString(), activeOpenType);
1440
1476
  }
1441
1477
  }
@@ -1792,6 +1828,7 @@ let EditorGroup = class EditorGroup extends ide_core_common_1.WithEventBus {
1792
1828
  super.dispose();
1793
1829
  this.codeEditor && this.codeEditor.dispose();
1794
1830
  this.diffEditor && this.diffEditor.dispose();
1831
+ this.toDispose.forEach((disposable) => disposable.dispose());
1795
1832
  this.eventBus.fire(new types_2.EditorGroupDisposeEvent({
1796
1833
  group: this,
1797
1834
  }));
@@ -1992,6 +2029,16 @@ tslib_1.__decorate([
1992
2029
  (0, di_1.Autowired)(ide_core_common_1.ILogger),
1993
2030
  tslib_1.__metadata("design:type", Object)
1994
2031
  ], EditorGroup.prototype, "logger", void 0);
2032
+ tslib_1.__decorate([
2033
+ mobx_1.observable.shallow,
2034
+ tslib_1.__metadata("design:type", Array)
2035
+ ], EditorGroup.prototype, "availableOpenTypes", void 0);
2036
+ tslib_1.__decorate([
2037
+ (0, ide_core_common_1.debounce)(16 * 5),
2038
+ tslib_1.__metadata("design:type", Function),
2039
+ tslib_1.__metadata("design:paramtypes", []),
2040
+ tslib_1.__metadata("design:returntype", void 0)
2041
+ ], EditorGroup.prototype, "doLayoutEditors", null);
1995
2042
  tslib_1.__decorate([
1996
2043
  (0, ide_core_common_1.OnEvent)(common_1.ResourceDecorationChangeEvent),
1997
2044
  tslib_1.__metadata("design:type", Function),