@opensumi/ide-opened-editor 2.21.7-rc-1670229502.0 → 2.21.7

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 (33) hide show
  1. package/lib/browser/index.js.map +1 -1
  2. package/lib/browser/opened-editor-node.d.ts +1 -1
  3. package/lib/browser/opened-editor-node.d.ts.map +1 -1
  4. package/lib/browser/opened-editor-node.define.d.ts +1 -1
  5. package/lib/browser/opened-editor-node.define.d.ts.map +1 -1
  6. package/lib/browser/opened-editor-node.define.js +5 -5
  7. package/lib/browser/opened-editor-node.define.js.map +1 -1
  8. package/lib/browser/opened-editor-node.js +1 -1
  9. package/lib/browser/opened-editor-node.js.map +1 -1
  10. package/lib/browser/opened-editor-node.module.less +1 -2
  11. package/lib/browser/opened-editor.contribution.js.map +1 -1
  12. package/lib/browser/services/opened-editor-decoration.service.js.map +1 -1
  13. package/lib/browser/services/opened-editor-event.service.d.ts +1 -1
  14. package/lib/browser/services/opened-editor-event.service.d.ts.map +1 -1
  15. package/lib/browser/services/opened-editor-event.service.js.map +1 -1
  16. package/lib/browser/services/opened-editor-model.js.map +1 -1
  17. package/lib/browser/services/opened-editor-model.service.d.ts +2 -2
  18. package/lib/browser/services/opened-editor-model.service.d.ts.map +1 -1
  19. package/lib/browser/services/opened-editor-model.service.js.map +1 -1
  20. package/lib/browser/services/opened-editor-tree.service.js.map +1 -1
  21. package/package.json +14 -14
  22. package/src/browser/index.module.less +0 -24
  23. package/src/browser/index.ts +0 -26
  24. package/src/browser/opened-editor-node.define.ts +0 -87
  25. package/src/browser/opened-editor-node.module.less +0 -195
  26. package/src/browser/opened-editor-node.tsx +0 -232
  27. package/src/browser/opened-editor.contribution.ts +0 -193
  28. package/src/browser/opened-editor.tsx +0 -174
  29. package/src/browser/services/opened-editor-decoration.service.ts +0 -63
  30. package/src/browser/services/opened-editor-event.service.ts +0 -51
  31. package/src/browser/services/opened-editor-model.service.ts +0 -549
  32. package/src/browser/services/opened-editor-model.ts +0 -47
  33. package/src/browser/services/opened-editor-tree.service.ts +0 -151
@@ -1,195 +0,0 @@
1
- .opened_editor_node {
2
- height: 22px;
3
- line-height: 22px;
4
- display: flex;
5
- flex-direction: column;
6
- position: relative;
7
- cursor: pointer;
8
-
9
- &:hover {
10
- color: var(--kt-tree-hoverForeground);
11
- background: var(--kt-tree-hoverBackground);
12
- .opened_editor_action_bar {
13
- display: block;
14
- }
15
- &::before {
16
- display: none !important;
17
- }
18
- }
19
-
20
- &.mod_selected {
21
- color: var(--kt-tree-inactiveSelectionForeground) !important;
22
- background: var(--kt-tree-inactiveSelectionBackground);
23
- .expansion_toggle,
24
- .opened_editor_node_description {
25
- color: var(--kt-tree-inactiveSelectionForeground) !important;
26
- }
27
- }
28
-
29
- &.mod_focused {
30
- outline: 1px solid var(--list-focusOutline);
31
- outline-offset: -1px;
32
- color: var(--kt-tree-activeSelectionForeground) !important;
33
- background: var(--kt-tree-activeSelectionBackground);
34
- .expansion_toggle,
35
- .opened_editor_node_description {
36
- color: var(--kt-tree-activeSelectionForeground) !important;
37
- }
38
- }
39
-
40
- &.mod_actived {
41
- outline: 1px solid var(--list-focusOutline);
42
- outline-offset: -1px;
43
- .expansion_toggle {
44
- color: var(--kt-tree-activeSelectionForeground) !important;
45
- }
46
- }
47
-
48
- &.mod_dirty {
49
- &::before {
50
- content: '';
51
- display: block;
52
- width: 8px;
53
- height: 8px;
54
- border-radius: 4px;
55
- margin: 7px 5px;
56
- background: var(--kt-dirtyDot-foreground);
57
- position: absolute;
58
- left: 18px;
59
- }
60
- }
61
- }
62
-
63
- .opened_editor_node_description {
64
- display: inline;
65
- transform: scale(0.96);
66
- color: var(--descriptionForeground);
67
- }
68
-
69
- .opened_editor_node_content {
70
- position: relative;
71
- display: flex;
72
- align-items: center;
73
- width: 100%;
74
-
75
- match {
76
- background-color: var(--editor-findMatchHighlightBackground);
77
- }
78
- }
79
-
80
- .opened_editor_node_status {
81
- opacity: 0.75;
82
- text-align: center;
83
- font-size: 12px;
84
- padding-right: 0;
85
- }
86
-
87
- .opened_editor_node_segment {
88
- flex-grow: 0;
89
- white-space: nowrap;
90
- color: inherit;
91
- &_grow {
92
- flex-grow: 1 !important;
93
- text-align: left;
94
- z-index: 10;
95
- padding-right: 5px;
96
-
97
- &.overflow_visible {
98
- overflow: visible !important;
99
- }
100
- }
101
- }
102
-
103
- .opened_editor_node_displayname {
104
- margin-right: 6px;
105
- display: inline;
106
- white-space: pre;
107
- }
108
-
109
- .opened_editor_node_description {
110
- display: inline;
111
- transform: scale(0.96);
112
- color: var(--descriptionForeground);
113
- }
114
-
115
- .opened_editor_node_overflow_wrap {
116
- flex: 1;
117
- flex-shrink: 0;
118
- overflow: hidden;
119
- text-overflow: ellipsis;
120
- white-space: nowrap;
121
- text-align: left;
122
- color: var(--foreground);
123
- }
124
-
125
- .opened_editor_node_flex_wrap {
126
- display: flex;
127
- flex-direction: row;
128
- }
129
-
130
- .opened_editor_node_segment_grow {
131
- flex-grow: 1 !important;
132
- text-align: left;
133
- z-index: 10;
134
- padding-right: 5px;
135
-
136
- &.overflow_visible {
137
- overflow: visible !important;
138
- }
139
- }
140
-
141
- .file_icon {
142
- position: relative;
143
- color: var(--icon-foreground);
144
- margin-right: 4px;
145
- &:before {
146
- font-size: 16px;
147
- text-align: center;
148
- }
149
- }
150
-
151
- .file_icon:global(&.fileIcon:before) {
152
- font-size: 18px;
153
- }
154
-
155
- .opened_editor_node_tail {
156
- text-align: center;
157
- margin-right: 10px;
158
- position: relative;
159
- height: 22px;
160
- display: flex;
161
- align-items: center;
162
- }
163
-
164
- .opened_editor_action_bar {
165
- position: absolute;
166
- top: 0;
167
- left: 0;
168
- width: 100%;
169
- display: flex;
170
- display: none;
171
- z-index: 10;
172
- .action_icon {
173
- margin-left: 6px;
174
- font-size: 14px;
175
- }
176
- }
177
-
178
- .opened_editor_left_actions {
179
- position: absolute;
180
- left: 14px;
181
- }
182
-
183
- .opened_editor_right_actions {
184
- right: 0;
185
- position: absolute;
186
- margin-right: 10px;
187
- }
188
-
189
- .opened_editor_left_actions,
190
- .opened_editor_right_actions {
191
- display: flex;
192
- align-items: center;
193
- justify-content: center;
194
- height: 22px;
195
- }
@@ -1,232 +0,0 @@
1
- import cls from 'classnames';
2
- import React from 'react';
3
-
4
- import {
5
- TreeNode,
6
- CompositeTreeNode,
7
- INodeRendererProps,
8
- ClasslistComposite,
9
- TreeNodeType,
10
- Button,
11
- } from '@opensumi/ide-components';
12
- import { URI, OPEN_EDITORS_COMMANDS, localize, getIcon, CommandService } from '@opensumi/ide-core-browser';
13
- import { LabelService } from '@opensumi/ide-core-browser/lib/services';
14
- import { EDITOR_WEBVIEW_SCHEME } from '@opensumi/ide-webview';
15
-
16
- import { EditorFileGroup, EditorFile } from './opened-editor-node.define';
17
- import styles from './opened-editor-node.module.less';
18
- import { OpenedEditorDecorationService } from './services/opened-editor-decoration.service';
19
-
20
- export interface IEditorNodeProps {
21
- item: any;
22
- defaultLeftPadding?: number;
23
- leftPadding?: number;
24
- decorationService: OpenedEditorDecorationService;
25
- commandService: CommandService;
26
- labelService: LabelService;
27
- decorations?: ClasslistComposite;
28
- onClick: (ev: React.MouseEvent, item: TreeNode | CompositeTreeNode, type: TreeNodeType, activeUri?: URI) => void;
29
- onContextMenu: (
30
- ev: React.MouseEvent,
31
- item: TreeNode | CompositeTreeNode,
32
- type: TreeNodeType,
33
- activeUri?: URI,
34
- ) => void;
35
- }
36
-
37
- export type EditorNodeRenderedProps = IEditorNodeProps & INodeRendererProps;
38
-
39
- export const EditorTreeNode: React.FC<EditorNodeRenderedProps> = ({
40
- item,
41
- defaultLeftPadding = 8,
42
- leftPadding = 8,
43
- onClick,
44
- onContextMenu,
45
- itemType,
46
- decorationService,
47
- labelService,
48
- commandService,
49
- decorations,
50
- }: EditorNodeRenderedProps) => {
51
- const decoration = EditorFileGroup.is(item) ? null : decorationService.getDecoration(item.uri, false);
52
-
53
- const handleClick = (ev: React.MouseEvent) => {
54
- if (itemType === TreeNodeType.TreeNode || itemType === TreeNodeType.CompositeTreeNode) {
55
- onClick(ev, item as EditorFile, itemType);
56
- }
57
- };
58
-
59
- const handleContextMenu = (ev: React.MouseEvent) => {
60
- if (ev.nativeEvent.which === 0) {
61
- return;
62
- }
63
- if (itemType === TreeNodeType.TreeNode || itemType === TreeNodeType.CompositeTreeNode) {
64
- onContextMenu(ev, item as TreeNode, itemType);
65
- }
66
- };
67
-
68
- const paddingLeft = `${
69
- defaultLeftPadding + (item.depth || 0) * (leftPadding || 0) + (!EditorFileGroup.is(item) ? 16 : 0)
70
- }px`;
71
-
72
- const editorNodeStyle = {
73
- color: decoration ? decoration.color : '',
74
- height: OPENED_EDITOR_TREE_NODE_HEIGHT,
75
- lineHeight: `${OPENED_EDITOR_TREE_NODE_HEIGHT}px`,
76
- paddingLeft,
77
- } as React.CSSProperties;
78
-
79
- const renderIcon = (node: EditorFileGroup | EditorFile) => {
80
- if (EditorFileGroup.is(node)) {
81
- return null;
82
- }
83
- const iconClass = node.resource.icon || labelService.getIcon((node as EditorFile).uri, { isDirectory: false });
84
- return (
85
- <div
86
- className={cls(styles.file_icon, iconClass)}
87
- style={{ height: OPENED_EDITOR_TREE_NODE_HEIGHT, lineHeight: `${OPENED_EDITOR_TREE_NODE_HEIGHT}px` }}
88
- ></div>
89
- );
90
- };
91
-
92
- const getNodeName = (node: EditorFileGroup | EditorFile) => {
93
- if (!EditorFileGroup.is(node)) {
94
- if (node.uri.scheme === EDITOR_WEBVIEW_SCHEME) {
95
- return node.displayName;
96
- }
97
-
98
- return node.displayName || labelService.getName(node.uri);
99
- }
100
-
101
- return node.displayName;
102
- };
103
-
104
- const renderDisplayName = (node: EditorFileGroup | EditorFile) => (
105
- <div className={cls(styles.opened_editor_node_segment, styles.opened_editor_node_displayname)}>
106
- {getNodeName(node)}
107
- </div>
108
- );
109
-
110
- const renderDescription = (node: EditorFileGroup | EditorFile) => {
111
- if (EditorFileGroup.is(node)) {
112
- return null;
113
- }
114
- return (
115
- <div className={cls(styles.opened_editor_node_segment_grow, styles.opened_editor_node_description)}>
116
- {node.tooltip}
117
- </div>
118
- );
119
- };
120
-
121
- const renderStatusTail = () => (
122
- <div className={cls(styles.opened_editor_node_segment, styles.opened_editor_node_tail)}>{renderBadge()}</div>
123
- );
124
-
125
- const renderBadge = () => {
126
- if (!decoration) {
127
- return null;
128
- }
129
- return <div className={styles.opened_editor_node_status}>{decoration.badge.slice()}</div>;
130
- };
131
-
132
- const getItemTooltip = () => {
133
- let tooltip = item.tooltip;
134
- if (decoration && decoration.badge) {
135
- tooltip += ` • ${decoration.tooltip}`;
136
- }
137
- return tooltip;
138
- };
139
-
140
- const renderAction = () => {
141
- let actions: any[] = [];
142
- if (EditorFileGroup.is(item)) {
143
- actions = [
144
- {
145
- icon: getIcon('save-all'),
146
- title: localize('opened.editors.save.byGroup'),
147
- command: OPEN_EDITORS_COMMANDS.SAVE_BY_GROUP.id,
148
- },
149
- {
150
- icon: getIcon('clear'),
151
- title: localize('opened.editors.close.byGroup'),
152
- command: OPEN_EDITORS_COMMANDS.CLOSE_BY_GROUP.id,
153
- },
154
- ];
155
- return (
156
- <div className={styles.opened_editor_right_actions}>
157
- {actions.map((action) => {
158
- const clickHandler = (event: React.MouseEvent) => {
159
- event.stopPropagation();
160
- event.preventDefault();
161
- commandService.executeCommand(action.command, item);
162
- };
163
- return (
164
- <Button
165
- type='icon'
166
- key={`${item.id}-${action.command}`}
167
- iconClass={cls(styles.action_icon, action.icon)}
168
- title={action.title}
169
- onClick={clickHandler}
170
- />
171
- );
172
- })}
173
- </div>
174
- );
175
- } else {
176
- actions = [
177
- {
178
- icon: getIcon('close'),
179
- title: localize('file.close'),
180
- command: OPEN_EDITORS_COMMANDS.CLOSE.id,
181
- },
182
- ];
183
- return (
184
- <div className={styles.opened_editor_left_actions}>
185
- {actions.map((action) => {
186
- const clickHandler = (event: React.MouseEvent) => {
187
- event.stopPropagation();
188
- event.preventDefault();
189
- commandService.executeCommand(action.command, item);
190
- };
191
- return (
192
- <Button
193
- type='icon'
194
- key={`${item.id}-${action.command}`}
195
- iconClass={cls(styles.action_icon, action.icon)}
196
- title={action.title}
197
- onClick={clickHandler}
198
- />
199
- );
200
- })}
201
- </div>
202
- );
203
- }
204
- };
205
-
206
- const renderActionBar = () => <div className={styles.opened_editor_action_bar}>{renderAction()}</div>;
207
-
208
- return (
209
- <div
210
- key={item.id}
211
- onClick={handleClick}
212
- onContextMenu={handleContextMenu}
213
- title={getItemTooltip()}
214
- className={cls(styles.opened_editor_node, decorations ? decorations.classlist : null)}
215
- style={editorNodeStyle}
216
- data-id={item.id}
217
- >
218
- {renderActionBar()}
219
- <div className={cls(styles.opened_editor_node_content)}>
220
- {renderIcon(item)}
221
- <div className={styles.opened_editor_node_overflow_wrap}>
222
- {renderDisplayName(item)}
223
- {renderDescription(item)}
224
- </div>
225
- {renderStatusTail()}
226
- </div>
227
- </div>
228
- );
229
- };
230
-
231
- export const OPENED_EDITOR_TREE_NODE_HEIGHT = 22;
232
- export const OPENED_EDITOR_BADGE_LIMIT = 99;
@@ -1,193 +0,0 @@
1
- import { Autowired } from '@opensumi/di';
2
- import {
3
- Domain,
4
- localize,
5
- CommandContribution,
6
- CommandRegistry,
7
- OPEN_EDITORS_COMMANDS,
8
- CommandService,
9
- FILE_COMMANDS,
10
- EDITOR_COMMANDS,
11
- } from '@opensumi/ide-core-browser';
12
- import { ClientAppContribution } from '@opensumi/ide-core-browser';
13
- import { ToolbarRegistry, TabBarToolbarContribution } from '@opensumi/ide-core-browser/lib/layout';
14
- import { MenuContribution, IMenuRegistry, MenuId } from '@opensumi/ide-core-browser/lib/menu/next';
15
- import { WorkbenchEditorService } from '@opensumi/ide-editor';
16
- import { EXPLORER_CONTAINER_ID } from '@opensumi/ide-explorer/lib/browser/explorer-contribution';
17
- import { IMainLayoutService } from '@opensumi/ide-main-layout';
18
-
19
- import { ExplorerOpenEditorPanel } from './opened-editor';
20
- import { EditorFile, EditorFileGroup } from './opened-editor-node.define';
21
- import { OpenedEditorModelService } from './services/opened-editor-model.service';
22
-
23
- export const ExplorerOpenedEditorViewId = 'file-opened-editor';
24
-
25
- @Domain(ClientAppContribution, TabBarToolbarContribution, CommandContribution, MenuContribution)
26
- export class OpenedEditorContribution
27
- implements ClientAppContribution, TabBarToolbarContribution, CommandContribution, MenuContribution
28
- {
29
- @Autowired(IMainLayoutService)
30
- private readonly mainLayoutService: IMainLayoutService;
31
-
32
- @Autowired(WorkbenchEditorService)
33
- private readonly workbenchEditorService: WorkbenchEditorService;
34
-
35
- @Autowired(OpenedEditorModelService)
36
- private readonly openedEditorModelService: OpenedEditorModelService;
37
-
38
- @Autowired(CommandService)
39
- private readonly commandService: CommandService;
40
-
41
- async onStart() {
42
- this.mainLayoutService.collectViewComponent(
43
- {
44
- id: ExplorerOpenedEditorViewId,
45
- name: localize('opened.editors.title'),
46
- weight: 1,
47
- priority: 10,
48
- collapsed: true,
49
- component: ExplorerOpenEditorPanel,
50
- },
51
- EXPLORER_CONTAINER_ID,
52
- );
53
- }
54
-
55
- registerCommands(commands: CommandRegistry) {
56
- commands.registerCommand(OPEN_EDITORS_COMMANDS.SAVE_ALL, {
57
- execute: () => {
58
- this.workbenchEditorService.saveAll();
59
- },
60
- });
61
-
62
- commands.registerCommand(OPEN_EDITORS_COMMANDS.CLOSE_ALL, {
63
- execute: async () => {
64
- await this.workbenchEditorService.closeAll();
65
- this.openedEditorModelService.clear();
66
- },
67
- });
68
-
69
- commands.registerCommand(OPEN_EDITORS_COMMANDS.CLOSE_BY_GROUP, {
70
- execute: (node: EditorFileGroup) => {
71
- this.openedEditorModelService.closeAllByGroup(node);
72
- },
73
- });
74
-
75
- commands.registerCommand(OPEN_EDITORS_COMMANDS.SAVE_BY_GROUP, {
76
- execute: (node: EditorFileGroup) => {
77
- this.openedEditorModelService.saveAllByGroup(node);
78
- },
79
- });
80
-
81
- commands.registerCommand(OPEN_EDITORS_COMMANDS.CLOSE, {
82
- execute: async (node: EditorFile) => {
83
- let group;
84
- if (node.parent && EditorFileGroup.is(node.parent as EditorFileGroup)) {
85
- group = (node.parent as EditorFileGroup).group;
86
- }
87
- await this.commandService.executeCommand(EDITOR_COMMANDS.CLOSE.id, { group, uri: node.uri });
88
- // 提前移除节点
89
- (node.parent as EditorFileGroup).unlinkItem(node);
90
- },
91
- });
92
-
93
- commands.registerCommand(OPEN_EDITORS_COMMANDS.OPEN, {
94
- execute: (node: EditorFile) => {
95
- let groupIndex = 0;
96
- if (node.parent && EditorFileGroup.is(node.parent as EditorFileGroup)) {
97
- groupIndex = (node.parent as EditorFileGroup).group.index;
98
- }
99
- this.commandService.executeCommand(EDITOR_COMMANDS.OPEN_RESOURCE.id, node.uri, { groupIndex });
100
- },
101
- });
102
-
103
- commands.registerCommand(OPEN_EDITORS_COMMANDS.OPEN_TO_THE_SIDE, {
104
- execute: (node: EditorFile) => {
105
- let groupIndex = 0;
106
- if (node.parent && EditorFileGroup.is(node.parent as EditorFileGroup)) {
107
- groupIndex = (node.parent as EditorFileGroup).group.index;
108
- }
109
- this.commandService.executeCommand(EDITOR_COMMANDS.OPEN_RESOURCE.id, node.uri, {
110
- groupIndex,
111
- split: 4 /** right */,
112
- focus: true,
113
- });
114
- },
115
- });
116
-
117
- commands.registerCommand(OPEN_EDITORS_COMMANDS.COMPARE_SELECTED, {
118
- execute: (node: EditorFile) => {
119
- this.commandService.executeCommand(FILE_COMMANDS.COMPARE_SELECTED.id, node.uri, [node.uri]);
120
- },
121
- });
122
-
123
- commands.registerCommand(OPEN_EDITORS_COMMANDS.COPY_PATH, {
124
- execute: (node: EditorFile) => {
125
- this.commandService.executeCommand(FILE_COMMANDS.COPY_PATH.id, node.uri, [node.uri]);
126
- },
127
- });
128
-
129
- commands.registerCommand(OPEN_EDITORS_COMMANDS.COPY_RELATIVE_PATH, {
130
- execute: (node: EditorFile) => {
131
- this.commandService.executeCommand(FILE_COMMANDS.COPY_RELATIVE_PATH.id, node.uri, [node.uri]);
132
- },
133
- });
134
- }
135
-
136
- registerToolbarItems(registry: ToolbarRegistry) {
137
- registry.registerItem({
138
- id: OPEN_EDITORS_COMMANDS.SAVE_ALL.id,
139
- command: OPEN_EDITORS_COMMANDS.SAVE_ALL.id,
140
- viewId: ExplorerOpenedEditorViewId,
141
- label: localize('opened.editors.save.all'),
142
- });
143
- registry.registerItem({
144
- id: OPEN_EDITORS_COMMANDS.CLOSE_ALL.id,
145
- command: OPEN_EDITORS_COMMANDS.CLOSE_ALL.id,
146
- viewId: ExplorerOpenedEditorViewId,
147
- label: localize('opened.editors.close.all'),
148
- });
149
- }
150
-
151
- registerMenus(menuRegistry: IMenuRegistry): void {
152
- menuRegistry.registerMenuItem(MenuId.OpenEditorsContext, {
153
- command: {
154
- id: OPEN_EDITORS_COMMANDS.OPEN.id,
155
- label: localize('opened.editors.open'),
156
- },
157
- order: 1,
158
- group: '1_open',
159
- });
160
-
161
- menuRegistry.registerMenuItem(MenuId.OpenEditorsContext, {
162
- command: {
163
- id: OPEN_EDITORS_COMMANDS.OPEN_TO_THE_SIDE.id,
164
- label: localize('opened.editors.openToTheSide'),
165
- },
166
- order: 2,
167
- group: '1_open',
168
- });
169
-
170
- menuRegistry.registerMenuItem(MenuId.OpenEditorsContext, {
171
- command: {
172
- id: OPEN_EDITORS_COMMANDS.COMPARE_SELECTED.id,
173
- label: localize('opened.editors.compare'),
174
- },
175
- group: '2_operator',
176
- });
177
-
178
- menuRegistry.registerMenuItem(MenuId.OpenEditorsContext, {
179
- command: {
180
- id: OPEN_EDITORS_COMMANDS.COPY_PATH.id,
181
- label: localize('opened.editors.copyPath'),
182
- },
183
- group: '3_path',
184
- });
185
- menuRegistry.registerMenuItem(MenuId.OpenEditorsContext, {
186
- command: {
187
- id: OPEN_EDITORS_COMMANDS.COPY_RELATIVE_PATH.id,
188
- label: localize('opened.editors.copyRelativePath'),
189
- },
190
- group: '3_path',
191
- });
192
- }
193
- }