File tree 4 files changed +35
-13
lines changed
packages/secretnote/src/modules
4 files changed +35
-13
lines changed Original file line number Diff line number Diff line change @@ -76,7 +76,7 @@ export class SQLCellView extends LibroExecutableCellView {
76
76
this . viewManager = viewManager ;
77
77
this . commandRegistry = commandRegistry ;
78
78
79
- this . outputs = options . cell ?. outputs as IOutput [ ] ;
79
+ this . outputs = ( options . cell ?. outputs || [ ] ) as IOutput [ ] ;
80
80
this . className = this . className + ' sql-editor-container' ;
81
81
82
82
this . viewManager
@@ -103,8 +103,17 @@ export class SQLCellView extends LibroExecutableCellView {
103
103
await this . createEditor ( ) ;
104
104
} ;
105
105
106
+ override toJSON ( ) {
107
+ const meta = super . toJSON ( ) ;
108
+ return {
109
+ ...meta ,
110
+ outputs : this . outputArea ?. toJSON ( ) ?? this . outputs ,
111
+ } ;
112
+ }
113
+
106
114
createEditor ( ) {
107
115
const option : CodeEditorViewOptions = {
116
+ uuid : this . options . uuid ,
108
117
factory : ( editorOption ) => new SQLEditor ( editorOption ) ,
109
118
model : this . cellModel ,
110
119
config : {
@@ -116,10 +125,8 @@ export class SQLCellView extends LibroExecutableCellView {
116
125
. getOrCreateView < CodeEditorView , CodeEditorViewOptions > ( CodeEditorView , option )
117
126
. then ( async ( editorView ) => {
118
127
this . editorView = editorView ;
119
-
120
- await editorView . editorReady ;
128
+ await editorView . editor . editorReady ;
121
129
this . handleCommand ( ) ;
122
-
123
130
return ;
124
131
} )
125
132
. catch ( ( ) => {
Original file line number Diff line number Diff line change @@ -8,6 +8,7 @@ import type {
8
8
IPosition ,
9
9
ICoordinate ,
10
10
SearchMatch ,
11
+ EditorState ,
11
12
} from '@difizen/libro-jupyter' ;
12
13
import {
13
14
Disposable ,
@@ -44,6 +45,7 @@ export class SQLEditor implements IEditor {
44
45
45
46
monacoEditor ?: MonacoEditorType ;
46
47
host : HTMLElement ;
48
+ editorState ?: EditorState < EditorState > ;
47
49
48
50
get uuid ( ) : string {
49
51
return this . _uuid ;
@@ -220,6 +222,16 @@ export class SQLEditor implements IEditor {
220
222
} ;
221
223
}
222
224
225
+ getState ( ) : EditorState < EditorState > {
226
+ const cursorPosition = this . getCursorPosition ( ) ;
227
+ const selections = this . getSelections ( ) ;
228
+ return {
229
+ ...this . editorState ! ,
230
+ cursorPosition,
231
+ selections,
232
+ } ;
233
+ }
234
+
223
235
protected updateEditorSize ( ) {
224
236
const contentHeight = this . monacoEditor ?. getContentHeight ( ) ?? 20 ;
225
237
this . host . style . height = `${ contentHeight + 30 } px` ;
Original file line number Diff line number Diff line change @@ -26,10 +26,10 @@ import { ProjectService, Respond } from './service';
26
26
export const InvitationNotificationComponent = ( ) => {
27
27
const instance = useInject < InvitationNotificationView > ( ViewInstance ) ;
28
28
const pending = instance . service . invitationList . filter (
29
- ( item ) => item . accepted === Respond . Pending ,
29
+ ( item ) => item . status === Respond . UNDECIDED ,
30
30
) ;
31
31
const archived = instance . service . invitationList . filter (
32
- ( item ) => item . accepted !== Respond . Pending ,
32
+ ( item ) => item . status !== Respond . UNDECIDED ,
33
33
) ;
34
34
35
35
const handleInvitation = async ( id : string , accepted : boolean ) => {
@@ -102,10 +102,10 @@ export const InvitationNotificationComponent = () => {
102
102
< span
103
103
className = "action"
104
104
style = { {
105
- color : item . accepted === Respond . Accepted ? 'green' : 'orange' ,
105
+ color : item . status === Respond . ACCEPTED ? 'green' : 'orange' ,
106
106
} }
107
107
>
108
- { Respond [ item . accepted ] }
108
+ { Respond [ item . status ] }
109
109
</ span >
110
110
</ li >
111
111
) ) }
Original file line number Diff line number Diff line change @@ -11,16 +11,18 @@ export interface Project {
11
11
}
12
12
13
13
export interface Invitation {
14
- accepted : number ;
15
14
id : string ;
16
15
inviter : string ;
16
+ invitee : string ;
17
17
project : string ;
18
+ status : Respond ;
18
19
}
19
20
20
21
export enum Respond {
21
- Pending = 0 ,
22
- Accepted = 1 ,
23
- Declined = - 1 ,
22
+ UNDECIDED = 'UNDECIDED' ,
23
+ ACCEPTED = 'ACCEPTED' ,
24
+ DECLINED = 'DECLINED' ,
25
+ INVALID = 'INVALID' ,
24
26
}
25
27
26
28
export interface PlatformInfo {
@@ -91,9 +93,10 @@ export class ProjectService {
91
93
} ) ;
92
94
// eslint-disable-next-line @typescript-eslint/no-explicit-any
93
95
this . invitationList = invitationList . map ( ( item : any ) => ( {
94
- accepted : item . accepted ,
96
+ status : item . status ,
95
97
id : item . invitation_id ,
96
98
inviter : item . inviter ,
99
+ invitee : item . invitee ,
97
100
project : item . project . name || item . project . project_id ,
98
101
} ) ) ;
99
102
return invitationList ;
You can’t perform that action at this time.
0 commit comments