@opensumi/ide-editor 3.2.5-next-1724744804.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.
- package/lib/browser/doc-model/editor-document-model-service.d.ts +1 -2
- package/lib/browser/doc-model/editor-document-model-service.d.ts.map +1 -1
- package/lib/browser/doc-model/editor-document-model-service.js +0 -22
- package/lib/browser/doc-model/editor-document-model-service.js.map +1 -1
- package/lib/browser/doc-model/editor-document-model.d.ts +0 -1
- package/lib/browser/doc-model/editor-document-model.d.ts.map +1 -1
- package/lib/browser/doc-model/editor-document-model.js +0 -14
- package/lib/browser/doc-model/editor-document-model.js.map +1 -1
- package/lib/browser/doc-model/saveParticipants.d.ts.map +1 -1
- package/lib/browser/doc-model/saveParticipants.js +0 -1
- package/lib/browser/doc-model/saveParticipants.js.map +1 -1
- package/lib/browser/doc-model/types.d.ts +1 -5
- package/lib/browser/doc-model/types.d.ts.map +1 -1
- package/lib/browser/doc-model/types.js +1 -4
- package/lib/browser/doc-model/types.js.map +1 -1
- package/lib/browser/editor.contribution.d.ts.map +1 -1
- package/lib/browser/editor.contribution.js +4 -7
- package/lib/browser/editor.contribution.js.map +1 -1
- package/lib/browser/editor.module.less +17 -9
- package/lib/browser/editor.view.d.ts.map +1 -1
- package/lib/browser/editor.view.js +12 -2
- package/lib/browser/editor.view.js.map +1 -1
- package/lib/browser/format/formatter-selector.d.ts.map +1 -1
- package/lib/browser/format/formatter-selector.js +8 -6
- package/lib/browser/format/formatter-selector.js.map +1 -1
- package/lib/browser/fs-resource/fs-resource.d.ts.map +1 -1
- package/lib/browser/fs-resource/fs-resource.js +7 -5
- package/lib/browser/fs-resource/fs-resource.js.map +1 -1
- package/lib/browser/grid/grid.service.d.ts +0 -1
- package/lib/browser/grid/grid.service.d.ts.map +1 -1
- package/lib/browser/grid/grid.service.js +4 -6
- package/lib/browser/grid/grid.service.js.map +1 -1
- package/lib/browser/hooks/useEditor.d.ts +2 -2
- package/lib/browser/hooks/useEditor.d.ts.map +1 -1
- package/lib/browser/hooks/useEditor.js +11 -10
- package/lib/browser/hooks/useEditor.js.map +1 -1
- package/lib/browser/index.d.ts.map +1 -1
- package/lib/browser/index.js +0 -5
- package/lib/browser/index.js.map +1 -1
- package/lib/browser/merge-conflict/merge-conflict.model.d.ts.map +1 -1
- package/lib/browser/merge-conflict/merge-conflict.model.js +4 -3
- package/lib/browser/merge-conflict/merge-conflict.model.js.map +1 -1
- package/lib/browser/monaco-contrib/callHierarchy/callHierarchy.service.d.ts.map +1 -1
- package/lib/browser/monaco-contrib/callHierarchy/callHierarchy.service.js +3 -3
- package/lib/browser/monaco-contrib/callHierarchy/callHierarchy.service.js.map +1 -1
- package/lib/browser/monaco-contrib/typeHierarchy/typeHierarchy.service.d.ts.map +1 -1
- package/lib/browser/monaco-contrib/typeHierarchy/typeHierarchy.service.js +3 -3
- package/lib/browser/monaco-contrib/typeHierarchy/typeHierarchy.service.js.map +1 -1
- package/lib/browser/navigation.module.less +2 -3
- package/lib/browser/navigation.view.js +1 -1
- package/lib/browser/navigation.view.js.map +1 -1
- package/lib/browser/tab.view.d.ts.map +1 -1
- package/lib/browser/tab.view.js +6 -21
- package/lib/browser/tab.view.js.map +1 -1
- package/lib/browser/untitled-resource.d.ts.map +1 -1
- package/lib/browser/untitled-resource.js +7 -5
- package/lib/browser/untitled-resource.js.map +1 -1
- package/lib/browser/workbench-editor.service.d.ts.map +1 -1
- package/lib/browser/workbench-editor.service.js +22 -15
- package/lib/browser/workbench-editor.service.js.map +1 -1
- package/lib/common/editor.d.ts +0 -47
- package/lib/common/editor.d.ts.map +1 -1
- package/lib/common/editor.js.map +1 -1
- package/lib/common/index.d.ts +2 -4
- package/lib/common/index.d.ts.map +1 -1
- package/lib/common/index.js +2 -4
- package/lib/common/index.js.map +1 -1
- package/package.json +14 -14
- package/src/browser/doc-model/editor-document-model-service.ts +1 -25
- package/src/browser/doc-model/editor-document-model.ts +0 -18
- package/src/browser/doc-model/saveParticipants.ts +0 -1
- package/src/browser/doc-model/types.ts +1 -4
- package/src/browser/editor.contribution.ts +3 -8
- package/src/browser/editor.module.less +17 -9
- package/src/browser/editor.view.tsx +21 -4
- package/src/browser/format/formatter-selector.ts +8 -6
- package/src/browser/fs-resource/fs-resource.ts +7 -5
- package/src/browser/grid/grid.service.ts +7 -13
- package/src/browser/hooks/useEditor.ts +12 -13
- package/src/browser/index.ts +0 -6
- package/src/browser/merge-conflict/merge-conflict.model.ts +5 -4
- package/src/browser/monaco-contrib/callHierarchy/callHierarchy.service.ts +2 -4
- package/src/browser/monaco-contrib/typeHierarchy/typeHierarchy.service.ts +2 -5
- package/src/browser/navigation.module.less +2 -3
- package/src/browser/navigation.view.tsx +1 -1
- package/src/browser/tab.view.tsx +8 -40
- package/src/browser/untitled-resource.ts +7 -5
- package/src/browser/workbench-editor.service.ts +25 -20
- package/src/common/editor.ts +1 -59
- package/src/common/index.ts +2 -4
- package/lib/browser/editor-scrollbar/index.d.ts +0 -69
- package/lib/browser/editor-scrollbar/index.d.ts.map +0 -1
- package/lib/browser/editor-scrollbar/index.js +0 -289
- package/lib/browser/editor-scrollbar/index.js.map +0 -1
- package/lib/browser/editor-scrollbar/index.module.less +0 -106
- package/lib/browser/notebook.service.d.ts +0 -20
- package/lib/browser/notebook.service.d.ts.map +0 -1
- package/lib/browser/notebook.service.js +0 -24
- package/lib/browser/notebook.service.js.map +0 -1
- package/lib/common/components.d.ts +0 -3
- package/lib/common/components.d.ts.map +0 -1
- package/lib/common/components.js +0 -6
- package/lib/common/components.js.map +0 -1
- package/lib/common/notebook.d.ts +0 -169
- package/lib/common/notebook.d.ts.map +0 -1
- package/lib/common/notebook.js +0 -26
- package/lib/common/notebook.js.map +0 -1
- package/src/browser/editor-scrollbar/index.module.less +0 -106
- package/src/browser/editor-scrollbar/index.tsx +0 -399
- package/src/browser/notebook.service.ts +0 -19
- package/src/common/components.ts +0 -2
- package/src/common/notebook.ts +0 -196
package/lib/common/notebook.js
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.notebookCellScheme = exports.INotebookService = exports.CellKind = exports.NotebookCellsChangeType = void 0;
|
|
4
|
-
var NotebookCellsChangeType;
|
|
5
|
-
(function (NotebookCellsChangeType) {
|
|
6
|
-
NotebookCellsChangeType[NotebookCellsChangeType["ModelChange"] = 1] = "ModelChange";
|
|
7
|
-
NotebookCellsChangeType[NotebookCellsChangeType["Move"] = 2] = "Move";
|
|
8
|
-
NotebookCellsChangeType[NotebookCellsChangeType["ChangeCellLanguage"] = 5] = "ChangeCellLanguage";
|
|
9
|
-
NotebookCellsChangeType[NotebookCellsChangeType["Initialize"] = 6] = "Initialize";
|
|
10
|
-
NotebookCellsChangeType[NotebookCellsChangeType["ChangeCellMetadata"] = 7] = "ChangeCellMetadata";
|
|
11
|
-
NotebookCellsChangeType[NotebookCellsChangeType["Output"] = 8] = "Output";
|
|
12
|
-
NotebookCellsChangeType[NotebookCellsChangeType["OutputItem"] = 9] = "OutputItem";
|
|
13
|
-
NotebookCellsChangeType[NotebookCellsChangeType["ChangeCellContent"] = 10] = "ChangeCellContent";
|
|
14
|
-
NotebookCellsChangeType[NotebookCellsChangeType["ChangeDocumentMetadata"] = 11] = "ChangeDocumentMetadata";
|
|
15
|
-
NotebookCellsChangeType[NotebookCellsChangeType["ChangeCellInternalMetadata"] = 12] = "ChangeCellInternalMetadata";
|
|
16
|
-
NotebookCellsChangeType[NotebookCellsChangeType["ChangeCellMime"] = 13] = "ChangeCellMime";
|
|
17
|
-
NotebookCellsChangeType[NotebookCellsChangeType["Unknown"] = 100] = "Unknown";
|
|
18
|
-
})(NotebookCellsChangeType = exports.NotebookCellsChangeType || (exports.NotebookCellsChangeType = {}));
|
|
19
|
-
var CellKind;
|
|
20
|
-
(function (CellKind) {
|
|
21
|
-
CellKind[CellKind["Markup"] = 1] = "Markup";
|
|
22
|
-
CellKind[CellKind["Code"] = 2] = "Code";
|
|
23
|
-
})(CellKind = exports.CellKind || (exports.CellKind = {}));
|
|
24
|
-
exports.INotebookService = Symbol('INotebookService');
|
|
25
|
-
exports.notebookCellScheme = 'vscode-notebook-cell';
|
|
26
|
-
//# sourceMappingURL=notebook.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"notebook.js","sourceRoot":"","sources":["../../src/common/notebook.ts"],"names":[],"mappings":";;;AAEA,IAAY,uBAaX;AAbD,WAAY,uBAAuB;IACjC,mFAAe,CAAA;IACf,qEAAQ,CAAA;IACR,iGAAsB,CAAA;IACtB,iFAAc,CAAA;IACd,iGAAsB,CAAA;IACtB,yEAAU,CAAA;IACV,iFAAc,CAAA;IACd,gGAAsB,CAAA;IACtB,0GAA2B,CAAA;IAC3B,kHAA+B,CAAA;IAC/B,0FAAmB,CAAA;IACnB,6EAAa,CAAA;AACf,CAAC,EAbW,uBAAuB,GAAvB,+BAAuB,KAAvB,+BAAuB,QAalC;AAmBD,IAAY,QAGX;AAHD,WAAY,QAAQ;IAClB,2CAAU,CAAA;IACV,uCAAQ,CAAA;AACV,CAAC,EAHW,QAAQ,GAAR,gBAAQ,KAAR,gBAAQ,QAGnB;AAiJY,QAAA,gBAAgB,GAAG,MAAM,CAAC,kBAAkB,CAAC,CAAC;AAa9C,QAAA,kBAAkB,GAAG,sBAAsB,CAAC"}
|
|
@@ -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
|
-
|
|
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,19 +0,0 @@
|
|
|
1
|
-
import { Injectable } from '@opensumi/di';
|
|
2
|
-
import { Emitter, Event, UriComponents, WithEventBus } from '@opensumi/ide-core-browser';
|
|
3
|
-
|
|
4
|
-
import type { INotebookModelAddedData, INotebookService, NotebookDataDto, NotebookDocumentChangeDto } from './types';
|
|
5
|
-
|
|
6
|
-
@Injectable()
|
|
7
|
-
export class NotebookService extends WithEventBus implements INotebookService {
|
|
8
|
-
createNotebook: (data?: NotebookDataDto) => Promise<{ uri: UriComponents }>;
|
|
9
|
-
openNotebook: (uriComponents: UriComponents) => Promise<{ uri: UriComponents }>;
|
|
10
|
-
saveNotebook: (uriComponents: UriComponents) => Promise<boolean>;
|
|
11
|
-
protected _onDidOpenNotebookDocument = new Emitter<INotebookModelAddedData>();
|
|
12
|
-
onDidOpenNotebookDocument: Event<INotebookModelAddedData> = this._onDidOpenNotebookDocument.event;
|
|
13
|
-
protected _onDidCloseNotebookDocument = new Emitter<UriComponents>();
|
|
14
|
-
onDidCloseNotebookDocument: Event<UriComponents> = this._onDidCloseNotebookDocument.event;
|
|
15
|
-
protected _onDidSaveNotebookDocument = new Emitter<UriComponents>();
|
|
16
|
-
onDidSaveNotebookDocument: Event<UriComponents> = this._onDidSaveNotebookDocument.event;
|
|
17
|
-
protected _onDidChangeNotebookDocument = new Emitter<NotebookDocumentChangeDto>();
|
|
18
|
-
onDidChangeNotebookDocument: Event<NotebookDocumentChangeDto> = this._onDidChangeNotebookDocument.event;
|
|
19
|
-
}
|
package/src/common/components.ts
DELETED