@opensumi/ide-editor 3.2.5-next-1724743242.0 → 3.2.5

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 (97) hide show
  1. package/lib/browser/doc-model/editor-document-model-service.d.ts +1 -2
  2. package/lib/browser/doc-model/editor-document-model-service.d.ts.map +1 -1
  3. package/lib/browser/doc-model/editor-document-model-service.js +0 -22
  4. package/lib/browser/doc-model/editor-document-model-service.js.map +1 -1
  5. package/lib/browser/doc-model/editor-document-model.d.ts +0 -1
  6. package/lib/browser/doc-model/editor-document-model.d.ts.map +1 -1
  7. package/lib/browser/doc-model/editor-document-model.js +0 -14
  8. package/lib/browser/doc-model/editor-document-model.js.map +1 -1
  9. package/lib/browser/doc-model/saveParticipants.d.ts.map +1 -1
  10. package/lib/browser/doc-model/saveParticipants.js +0 -1
  11. package/lib/browser/doc-model/saveParticipants.js.map +1 -1
  12. package/lib/browser/doc-model/types.d.ts +1 -3
  13. package/lib/browser/doc-model/types.d.ts.map +1 -1
  14. package/lib/browser/doc-model/types.js.map +1 -1
  15. package/lib/browser/editor.contribution.d.ts.map +1 -1
  16. package/lib/browser/editor.contribution.js +4 -7
  17. package/lib/browser/editor.contribution.js.map +1 -1
  18. package/lib/browser/editor.module.less +17 -9
  19. package/lib/browser/editor.view.d.ts.map +1 -1
  20. package/lib/browser/editor.view.js +12 -2
  21. package/lib/browser/editor.view.js.map +1 -1
  22. package/lib/browser/format/formatter-selector.d.ts.map +1 -1
  23. package/lib/browser/format/formatter-selector.js +8 -6
  24. package/lib/browser/format/formatter-selector.js.map +1 -1
  25. package/lib/browser/fs-resource/fs-resource.d.ts.map +1 -1
  26. package/lib/browser/fs-resource/fs-resource.js +7 -5
  27. package/lib/browser/fs-resource/fs-resource.js.map +1 -1
  28. package/lib/browser/grid/grid.service.d.ts +0 -1
  29. package/lib/browser/grid/grid.service.d.ts.map +1 -1
  30. package/lib/browser/grid/grid.service.js +4 -6
  31. package/lib/browser/grid/grid.service.js.map +1 -1
  32. package/lib/browser/hooks/useEditor.d.ts +2 -2
  33. package/lib/browser/hooks/useEditor.d.ts.map +1 -1
  34. package/lib/browser/hooks/useEditor.js +11 -10
  35. package/lib/browser/hooks/useEditor.js.map +1 -1
  36. package/lib/browser/merge-conflict/merge-conflict.model.d.ts.map +1 -1
  37. package/lib/browser/merge-conflict/merge-conflict.model.js +4 -3
  38. package/lib/browser/merge-conflict/merge-conflict.model.js.map +1 -1
  39. package/lib/browser/monaco-contrib/callHierarchy/callHierarchy.service.d.ts.map +1 -1
  40. package/lib/browser/monaco-contrib/callHierarchy/callHierarchy.service.js +3 -3
  41. package/lib/browser/monaco-contrib/callHierarchy/callHierarchy.service.js.map +1 -1
  42. package/lib/browser/monaco-contrib/typeHierarchy/typeHierarchy.service.d.ts.map +1 -1
  43. package/lib/browser/monaco-contrib/typeHierarchy/typeHierarchy.service.js +3 -3
  44. package/lib/browser/monaco-contrib/typeHierarchy/typeHierarchy.service.js.map +1 -1
  45. package/lib/browser/navigation.module.less +2 -3
  46. package/lib/browser/navigation.view.js +1 -1
  47. package/lib/browser/navigation.view.js.map +1 -1
  48. package/lib/browser/tab.view.d.ts.map +1 -1
  49. package/lib/browser/tab.view.js +6 -21
  50. package/lib/browser/tab.view.js.map +1 -1
  51. package/lib/browser/untitled-resource.d.ts.map +1 -1
  52. package/lib/browser/untitled-resource.js +7 -5
  53. package/lib/browser/untitled-resource.js.map +1 -1
  54. package/lib/browser/workbench-editor.service.d.ts.map +1 -1
  55. package/lib/browser/workbench-editor.service.js +22 -15
  56. package/lib/browser/workbench-editor.service.js.map +1 -1
  57. package/lib/common/editor.d.ts +0 -47
  58. package/lib/common/editor.d.ts.map +1 -1
  59. package/lib/common/editor.js.map +1 -1
  60. package/lib/common/index.d.ts +0 -1
  61. package/lib/common/index.d.ts.map +1 -1
  62. package/lib/common/index.js +0 -1
  63. package/lib/common/index.js.map +1 -1
  64. package/package.json +14 -14
  65. package/src/browser/doc-model/editor-document-model-service.ts +1 -25
  66. package/src/browser/doc-model/editor-document-model.ts +0 -18
  67. package/src/browser/doc-model/saveParticipants.ts +0 -1
  68. package/src/browser/doc-model/types.ts +1 -3
  69. package/src/browser/editor.contribution.ts +3 -8
  70. package/src/browser/editor.module.less +17 -9
  71. package/src/browser/editor.view.tsx +21 -4
  72. package/src/browser/format/formatter-selector.ts +8 -6
  73. package/src/browser/fs-resource/fs-resource.ts +7 -5
  74. package/src/browser/grid/grid.service.ts +7 -13
  75. package/src/browser/hooks/useEditor.ts +12 -13
  76. package/src/browser/merge-conflict/merge-conflict.model.ts +5 -4
  77. package/src/browser/monaco-contrib/callHierarchy/callHierarchy.service.ts +2 -4
  78. package/src/browser/monaco-contrib/typeHierarchy/typeHierarchy.service.ts +2 -5
  79. package/src/browser/navigation.module.less +2 -3
  80. package/src/browser/navigation.view.tsx +1 -1
  81. package/src/browser/tab.view.tsx +8 -40
  82. package/src/browser/untitled-resource.ts +7 -5
  83. package/src/browser/workbench-editor.service.ts +25 -20
  84. package/src/common/editor.ts +1 -59
  85. package/src/common/index.ts +0 -1
  86. package/lib/browser/editor-scrollbar/index.d.ts +0 -69
  87. package/lib/browser/editor-scrollbar/index.d.ts.map +0 -1
  88. package/lib/browser/editor-scrollbar/index.js +0 -289
  89. package/lib/browser/editor-scrollbar/index.js.map +0 -1
  90. package/lib/browser/editor-scrollbar/index.module.less +0 -106
  91. package/lib/common/components.d.ts +0 -3
  92. package/lib/common/components.d.ts.map +0 -1
  93. package/lib/common/components.js +0 -6
  94. package/lib/common/components.js.map +0 -1
  95. package/src/browser/editor-scrollbar/index.module.less +0 -106
  96. package/src/browser/editor-scrollbar/index.tsx +0 -399
  97. package/src/common/components.ts +0 -2
@@ -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';