@opensumi/ide-editor 3.2.5-next-1724293079.0 → 3.2.5-next-1724396191.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 (42) hide show
  1. package/lib/browser/editor.module.less +7 -7
  2. package/lib/browser/editor.view.d.ts.map +1 -1
  3. package/lib/browser/editor.view.js +12 -2
  4. package/lib/browser/editor.view.js.map +1 -1
  5. package/lib/browser/grid/grid.service.d.ts +0 -1
  6. package/lib/browser/grid/grid.service.d.ts.map +1 -1
  7. package/lib/browser/grid/grid.service.js +4 -6
  8. package/lib/browser/grid/grid.service.js.map +1 -1
  9. package/lib/browser/navigation.module.less +2 -3
  10. package/lib/browser/navigation.view.js +1 -1
  11. package/lib/browser/navigation.view.js.map +1 -1
  12. package/lib/browser/tab.view.d.ts.map +1 -1
  13. package/lib/browser/tab.view.js +6 -16
  14. package/lib/browser/tab.view.js.map +1 -1
  15. package/lib/browser/workbench-editor.service.d.ts.map +1 -1
  16. package/lib/browser/workbench-editor.service.js +2 -3
  17. package/lib/browser/workbench-editor.service.js.map +1 -1
  18. package/lib/common/index.d.ts +0 -1
  19. package/lib/common/index.d.ts.map +1 -1
  20. package/lib/common/index.js +0 -1
  21. package/lib/common/index.js.map +1 -1
  22. package/package.json +14 -14
  23. package/src/browser/editor.module.less +7 -7
  24. package/src/browser/editor.view.tsx +21 -4
  25. package/src/browser/grid/grid.service.ts +7 -13
  26. package/src/browser/navigation.module.less +2 -3
  27. package/src/browser/navigation.view.tsx +1 -1
  28. package/src/browser/tab.view.tsx +8 -35
  29. package/src/browser/workbench-editor.service.ts +4 -7
  30. package/src/common/index.ts +0 -1
  31. package/lib/browser/editor-scrollbar/index.d.ts +0 -69
  32. package/lib/browser/editor-scrollbar/index.d.ts.map +0 -1
  33. package/lib/browser/editor-scrollbar/index.js +0 -289
  34. package/lib/browser/editor-scrollbar/index.js.map +0 -1
  35. package/lib/browser/editor-scrollbar/index.module.less +0 -106
  36. package/lib/common/components.d.ts +0 -3
  37. package/lib/common/components.d.ts.map +0 -1
  38. package/lib/common/components.js +0 -6
  39. package/lib/common/components.js.map +0 -1
  40. package/src/browser/editor-scrollbar/index.module.less +0 -106
  41. package/src/browser/editor-scrollbar/index.tsx +0 -399
  42. package/src/common/components.ts +0 -2
@@ -1,106 +0,0 @@
1
- .track-vertical {
2
- position: absolute;
3
- right: 0;
4
- top: 0;
5
- height: 100%;
6
- width: 10px;
7
- }
8
- .scroll-vertical {
9
- position: absolute;
10
- right: 0;
11
- top: 0;
12
- height: 100%;
13
- width: 10px;
14
- z-index: var(--stacking-level-editor-tabbar-overlay, 15);
15
- }
16
-
17
- .track-horizontal {
18
- position: absolute;
19
- bottom: 0;
20
- left: 0;
21
- width: 100%;
22
- height: 5px;
23
- }
24
- .scroll-horizontal {
25
- position: absolute;
26
- bottom: 0;
27
- left: 0;
28
- width: 100%;
29
- height: 5px;
30
- z-index: var(--stacking-level-editor-tabbar-overlay, 15);
31
- }
32
-
33
- :global(.kt-editor-scrollbar-thumb-vertical) {
34
- position: absolute;
35
- width: 5px;
36
- opacity: 0.8;
37
- top: 0;
38
- right: 0;
39
- transition: opacity 200ms ease-out;
40
- background: var(--scrollbarSlider-background);
41
- box-shadow: 1px 0 0 var(--scrollbar-shadow);
42
-
43
- &:hover {
44
- background: var(--scrollbarSlider-hoverBackground);
45
- }
46
- }
47
-
48
- :global(.kt-editor-scrollbar-thumb-horizontal) {
49
- position: absolute;
50
- height: 5px;
51
- left: 0;
52
- bottom: 0;
53
- opacity: 0.8;
54
- transition: opacity 200ms ease-out 200ms;
55
- background: var(--scrollbarSlider-background);
56
- box-shadow: 1px 0 0 var(--scrollbar-shadow);
57
-
58
- &:hover {
59
- background: var(--scrollbarSlider-hoverBackground);
60
- }
61
- }
62
-
63
- .scroll {
64
- position: relative;
65
- height: 100%;
66
- > *:first-child::-webkit-scrollbar {
67
- display: none !important;
68
- background: rgb(50, 50, 50);
69
- }
70
- > *:first-child {
71
- overflow: auto;
72
- height: 100%;
73
- width: 100%;
74
- }
75
-
76
- .scrollbar-decoration-vertical-l,
77
- .scrollbar-decoration-vertical-r {
78
- position: absolute;
79
- width: 6px;
80
- height: 100%;
81
- z-index: var(--stacking-level-overlay-top, 999);
82
- top: 0px;
83
- opacity: 0;
84
- }
85
- // rgba(106, 115, 125, 0.2) 0 6px 6px -6px inset
86
- .scrollbar-decoration-vertical-l {
87
- left: 0px;
88
- border-left: 1px solid var(--kt-panelTab-border);
89
- box-shadow: 6px 0 4px -4px rgba(106, 115, 125, 0.2) inset;
90
- }
91
-
92
- .scrollbar-decoration-vertical-r {
93
- right: 0px;
94
- border-right: 1px solid var(--kt-panelTab-border);
95
- box-shadow: -6px 0 4px -4px rgba(106, 115, 125, 0.2) inset;
96
- }
97
- }
98
-
99
- .hide-thumb {
100
- :global(.kt-editor-scrollbar-thumb-horizontal) {
101
- opacity: 0 !important;
102
- }
103
- :global(.kt-editor-scrollbar-thumb-vertical) {
104
- opacity: 0 !important;
105
- }
106
- }
@@ -1,399 +0,0 @@
1
- import cls from 'classnames';
2
- import React, { MouseEvent, UIEvent } from 'react';
3
-
4
- import styles from './index.module.less';
5
-
6
- export interface ScrollAreaProps {
7
- className?: string;
8
- onScroll?: (position: ScrollPosition) => any;
9
- atTopClassName?: string;
10
- style?: any;
11
- containerStyle?: any;
12
- delegate?: (delegate: IScrollDelegate) => void;
13
-
14
- forwardedRef: (ref: HTMLDivElement) => void;
15
-
16
- children: any;
17
- }
18
-
19
- export interface IScrollDelegate {
20
- scrollTo(position: ScrollPosition): void;
21
- }
22
-
23
- export interface ScrollPosition {
24
- top: number;
25
- left: number;
26
- }
27
-
28
- export interface ScrollSizes {
29
- scrollHeight: number;
30
- offsetHeight: number;
31
- offsetWidth: number;
32
- scrollWidth: number;
33
- }
34
-
35
- export class Scroll extends React.Component<ScrollAreaProps, any> {
36
- public ref: HTMLDivElement;
37
-
38
- public container: HTMLDivElement;
39
-
40
- private thumbV!: HTMLDivElement;
41
-
42
- private trackV!: HTMLDivElement;
43
-
44
- private thumbH!: HTMLDivElement;
45
-
46
- private trackH!: HTMLDivElement;
47
-
48
- private decorationL: HTMLDivElement;
49
- private decorationR: HTMLDivElement;
50
-
51
- private size: ScrollSizes;
52
-
53
- private position: ScrollPosition = {
54
- top: 0,
55
- left: 0,
56
- };
57
-
58
- private dragging = false;
59
-
60
- private draggingStart = 0;
61
-
62
- private draggingStartPos = 0;
63
-
64
- private requestFrame: any;
65
-
66
- private shouldHideThumb = true;
67
-
68
- private isAtTop = true;
69
-
70
- onScroll(e: UIEvent<HTMLDivElement>) {
71
- this.position = {
72
- top: this.ref.scrollTop,
73
- left: this.ref.scrollLeft,
74
- };
75
- if (this.props.onScroll) {
76
- this.props.onScroll(this.position);
77
- }
78
- this.update(() => {
79
- const contentWidth = this.ref.scrollWidth;
80
- const width = this.ref.offsetWidth;
81
- const contentHeight = this.ref.scrollHeight;
82
- const height = this.ref.offsetHeight;
83
- this.thumbH.style.left = (this.position.left * width) / contentWidth + 'px';
84
- this.thumbV.style.top = (this.position.top * height) / contentHeight + 'px';
85
- });
86
- if (!this.isAtTop && this.ref.scrollTop === 0) {
87
- this.isAtTop = true;
88
- this.setCss();
89
- } else if (this.isAtTop && this.ref.scrollTop !== 0) {
90
- this.isAtTop = false;
91
- this.setCss();
92
- }
93
-
94
- if (this.ref.scrollLeft > 0) {
95
- this.decorationL.style.opacity = String(1);
96
- this.decorationR.style.opacity = String(1);
97
- } else {
98
- this.decorationL.style.opacity = String(0);
99
- }
100
-
101
- if (
102
- this.ref.scrollWidth === this.ref.offsetWidth ||
103
- this.ref.scrollLeft === this.ref.scrollWidth - this.ref.offsetWidth
104
- ) {
105
- this.decorationR.style.opacity = String(0);
106
- }
107
- }
108
-
109
- scrollTo(position: ScrollPosition) {
110
- this.ref.scrollLeft = position.left;
111
- this.ref.scrollTop = position.top;
112
- }
113
-
114
- onMouseDownHorizontal(e: MouseEvent<HTMLDivElement>) {
115
- this.dragging = true;
116
- if (e.target === this.trackH) {
117
- this.onMouseDownOnTrack(e);
118
- }
119
- this.draggingStart = e.pageX;
120
- this.draggingStartPos = this.ref.scrollLeft;
121
- document.addEventListener('mousemove', this.onMouseMoveHorizontal);
122
- document.addEventListener('mouseup', this.onMouseUpHorizontal);
123
- }
124
-
125
- onMouseMoveHorizontal = (e) => {
126
- if (!this.dragging) {
127
- return;
128
- }
129
- const move = e.pageX - this.draggingStart;
130
- this.ref.scrollLeft = this.draggingStartPos + this.calculateXToLeft(move);
131
- };
132
-
133
- onMouseUpHorizontal = (e) => {
134
- this.dragging = false;
135
- document.removeEventListener('mousemove', this.onMouseMoveHorizontal);
136
- document.removeEventListener('mouseup', this.onMouseUpHorizontal);
137
- if (this.shouldHideThumb) {
138
- this.hideThumb();
139
- }
140
- };
141
-
142
- onMouseDownOnTrack(e: MouseEvent<HTMLDivElement>) {
143
- const track = e.target as HTMLDivElement;
144
- const x = e.clientX - track.getBoundingClientRect().left;
145
- const contentWidth = this.ref.scrollWidth;
146
- const width = this.ref.offsetWidth;
147
- const left = (x * contentWidth) / width - 0.5 * width;
148
- this.scrollTo({
149
- left,
150
- top: this.position.top,
151
- });
152
- }
153
-
154
- calculateXToLeft(x) {
155
- const contentWidth = this.ref.scrollWidth;
156
- const width = this.ref.offsetWidth;
157
- return (x * contentWidth) / width;
158
- }
159
-
160
- onMouseDownVertical(e: MouseEvent<HTMLDivElement>) {
161
- this.dragging = true;
162
- if (e.target === this.trackV) {
163
- this.onMouseDownOnTrackVertical(e);
164
- }
165
- this.draggingStart = e.pageY;
166
- this.draggingStartPos = this.ref.scrollTop;
167
- document.addEventListener('mousemove', this.onMouseMoveVertical);
168
- document.addEventListener('mouseup', this.onMouseUpVertical);
169
- }
170
-
171
- onMouseMoveVertical = (e) => {
172
- if (!this.dragging) {
173
- return;
174
- }
175
- const move = e.pageY - this.draggingStart;
176
- this.ref.scrollTop = this.draggingStartPos + this.calculateYToTop(move);
177
- };
178
-
179
- onMouseUpVertical = (e) => {
180
- this.dragging = false;
181
- document.removeEventListener('mousemove', this.onMouseMoveVertical);
182
- document.removeEventListener('mouseup', this.onMouseUpVertical);
183
- if (this.shouldHideThumb) {
184
- this.hideThumb();
185
- }
186
- };
187
-
188
- onMouseDownOnTrackVertical(e: MouseEvent<HTMLDivElement>) {
189
- const track = e.target as HTMLDivElement;
190
- const x = e.clientY - track.getBoundingClientRect().top;
191
- const contentHeight = this.ref.scrollHeight;
192
- const height = this.ref.offsetHeight;
193
- const top = (x * contentHeight) / height - 0.5 * height;
194
- this.scrollTo({
195
- left: this.position.left,
196
- top,
197
- });
198
- }
199
-
200
- onMousewheel = (e: WheelEvent) => {
201
- // 鼠标滚动滚轮只在有横向滚动条的情况下
202
- // 页面有缩放的时候,scrollHeight 可能会小于 clientHeight / offsetHeight
203
- if (this.ref.clientHeight >= this.ref.scrollHeight) {
204
- if (e.deltaY !== 0) {
205
- // scrollLeft 内部有边界判断
206
- this.ref.scrollLeft += e.deltaY;
207
- }
208
- if (e.deltaX !== 0) {
209
- this.ref.scrollLeft += e.deltaX;
210
- }
211
- }
212
- };
213
-
214
- calculateYToTop(y) {
215
- const contentHeight = this.ref.scrollHeight;
216
- const height = this.ref.offsetHeight;
217
- return (y * contentHeight) / height;
218
- }
219
-
220
- componentDidUpdate() {
221
- this.update();
222
- if (this.props.delegate) {
223
- this.props.delegate({
224
- scrollTo: this.scrollTo.bind(this),
225
- });
226
- }
227
- }
228
-
229
- componentDidMount() {
230
- this.update();
231
- window.addEventListener('resize', this.handleWindowResize);
232
- if (this.props.delegate) {
233
- this.props.delegate({
234
- scrollTo: this.scrollTo.bind(this),
235
- });
236
- }
237
- if (this.ref) {
238
- this.ref.addEventListener('mouseenter', this.onMouseEnter);
239
- this.ref.addEventListener('wheel', this.onMousewheel);
240
- }
241
- }
242
-
243
- onMouseEnter = () => {
244
- this.update();
245
- };
246
-
247
- componentWillUnmount() {
248
- if (this.ref) {
249
- this.ref.removeEventListener('mouseenter', this.onMouseEnter);
250
- this.ref.removeEventListener('wheel', this.onMousewheel);
251
- }
252
- window.removeEventListener('resize', this.handleWindowResize);
253
- if (this.requestFrame) {
254
- window.cancelAnimationFrame(this.requestFrame);
255
- }
256
- }
257
-
258
- handleWindowResize = () => {
259
- this.update();
260
- };
261
-
262
- sizeEqual(size1: ScrollSizes, size2: ScrollSizes): boolean {
263
- return (
264
- size1 &&
265
- size2 &&
266
- size1.offsetHeight === size2.offsetHeight &&
267
- size1.scrollHeight === size2.scrollHeight &&
268
- size1.offsetWidth === size2.offsetWidth &&
269
- size1.scrollWidth === size2.scrollWidth
270
- );
271
- }
272
-
273
- update = (callback?) => {
274
- if (this.requestFrame) {
275
- window.cancelAnimationFrame(this.requestFrame);
276
- }
277
- this.requestFrame = window.requestAnimationFrame(() => {
278
- this._update();
279
- if (callback) {
280
- callback();
281
- }
282
- });
283
- };
284
-
285
- _update() {
286
- if (this.ref) {
287
- if (!this.sizeEqual(this.size, this.ref)) {
288
- this.size = {
289
- offsetHeight: this.ref.offsetHeight,
290
- offsetWidth: this.ref.offsetWidth,
291
- scrollWidth: this.ref.scrollWidth,
292
- scrollHeight: this.ref.scrollHeight,
293
- };
294
- this.updateScrollBar();
295
- }
296
- }
297
- }
298
-
299
- updateScrollBar() {
300
- const contentWidth = this.ref.scrollWidth;
301
- const width = this.ref.offsetWidth;
302
- if (width < contentWidth) {
303
- const thumbHWidth = (width * width) / contentWidth;
304
- this.thumbH.style.width = thumbHWidth + 'px';
305
- this.trackH.parentElement!.style.display = 'block';
306
- } else {
307
- this.trackH.parentElement!.style.display = 'none';
308
- }
309
- const contentHeight = this.ref.scrollHeight;
310
- const height = this.ref.offsetHeight;
311
- if (height < contentHeight) {
312
- this.thumbV.style.height = (height * height) / contentHeight + 'px';
313
- this.trackV.parentElement!.style.display = 'block';
314
- } else {
315
- this.trackV.parentElement!.style.display = 'none';
316
- }
317
- }
318
-
319
- hideThumb() {
320
- this.shouldHideThumb = true;
321
- if (!this.dragging) {
322
- this.setCss();
323
- }
324
- }
325
-
326
- showThumb() {
327
- this.shouldHideThumb = false;
328
- this.setCss();
329
- }
330
-
331
- setCss() {
332
- this.container.className = cls({
333
- [styles.scroll]: true,
334
- [styles['hide-thumb']]: this.shouldHideThumb && !this.dragging,
335
- });
336
- const clses = {};
337
- if (this.props.atTopClassName) {
338
- clses[this.props.atTopClassName] = this.isAtTop;
339
- }
340
- if (this.props.className) {
341
- clses[this.props.className] = true;
342
- }
343
- this.ref.className = cls(clses);
344
- }
345
-
346
- render() {
347
- return (
348
- <div
349
- className={cls(styles.scroll, styles['hide-thumb'])}
350
- ref={(e) => {
351
- if (e) {
352
- this.container = e;
353
- this.props.forwardedRef(e);
354
- }
355
- }}
356
- onMouseMove={() => this.showThumb()}
357
- onMouseLeave={() => this.hideThumb()}
358
- style={this.props.containerStyle}
359
- >
360
- <div
361
- style={this.props.style}
362
- className={cls(this.props.className)}
363
- onScroll={this.onScroll.bind(this)}
364
- ref={(e) => e && (this.ref = e)}
365
- onMouseDown={() => this.update()}
366
- onMouseUp={() => this.update()}
367
- >
368
- {this.props.children}
369
- </div>
370
- <div className={styles['scrollbar-decoration-vertical-l']} ref={(e) => e && (this.decorationL = e)} />
371
- <div className={styles['scrollbar-decoration-vertical-r']} ref={(e) => e && (this.decorationR = e)} />
372
- <div className={styles['scroll-horizontal']}>
373
- <div
374
- className={styles['track-horizontal']}
375
- ref={(e) => e && (this.trackH = e)}
376
- onMouseDown={this.onMouseDownHorizontal.bind(this)}
377
- />
378
- <div
379
- className={'kt-editor-scrollbar-thumb-horizontal'}
380
- onMouseDown={this.onMouseDownHorizontal.bind(this)}
381
- ref={(e) => e && (this.thumbH = e)}
382
- />
383
- </div>
384
- <div className={styles['scroll-vertical']}>
385
- <div
386
- className={styles['track-vertical']}
387
- ref={(e) => e && (this.trackV = e)}
388
- onMouseDown={this.onMouseDownVertical.bind(this)}
389
- />
390
- <div
391
- className={'kt-editor-scrollbar-thumb-vertical'}
392
- onMouseDown={this.onMouseDownVertical.bind(this)}
393
- ref={(e) => e && (this.thumbV = e)}
394
- />
395
- </div>
396
- </div>
397
- );
398
- }
399
- }
@@ -1,2 +0,0 @@
1
- export const TabbarRightExtraContentId = 'tabbar-right-extra-content';
2
- export const TabbarLeftExtraContentId = 'tabbar-left-extra-content';