File tree Expand file tree Collapse file tree 5 files changed +31
-11
lines changed Expand file tree Collapse file tree 5 files changed +31
-11
lines changed Original file line number Diff line number Diff line change 127
127
{
128
128
"command" : " HacKMD.openNoteOnHackMD" ,
129
129
"title" : " Open note on HackMD" ,
130
- "category" : " HackMD"
130
+ "category" : " HackMD" ,
131
+ "icon" : {
132
+ "light" : " src/icon/light/Browser-dark.png" ,
133
+ "dark" : " src/icon/dark/Browser-light.png"
134
+ }
131
135
}
132
136
],
133
137
"menus" : {
156
160
{
157
161
"command" : " HackMD.showPreviewAndEditor" ,
158
162
"when" : " view == mdTreeItems && viewItem == file"
163
+ },
164
+ {
165
+ "command" : " HacKMD.openNoteOnHackMD" ,
166
+ "when" : " view == mdTreeItems && viewItem == file" ,
167
+ "group" : " inline"
168
+ },
169
+ {
170
+ "command" : " HacKMD.openNoteOnHackMD" ,
171
+ "when" : " view == mdTreeItems && viewItem == file"
159
172
}
173
+
160
174
]
161
175
},
162
176
"viewsWelcome" : [
Original file line number Diff line number Diff line change @@ -18,14 +18,4 @@ export async function registerNoteCommands(context: vscode.ExtensionContext) {
18
18
vscode . env . openExternal ( vscode . Uri . parse ( noteUrl ) ) ;
19
19
}
20
20
} ) ) ;
21
-
22
- context . subscriptions . push ( vscode . commands . registerCommand ( 'HacKMD.openNoteOnHackMD' , ( ) => {
23
- const noteId = vscode . window . activeTextEditor . document . uri . fragment ;
24
- if ( ! noteId ) {
25
- vscode . window . showInformationMessage ( 'Please open an editor first' ) ;
26
- }
27
- const serverUrl = vscode . workspace . getConfiguration ( 'Hackmd' ) . get ( 'serverURL' ) as string ;
28
- const noteUrl = `${ serverUrl } /${ noteId } ` ;
29
- vscode . env . openExternal ( vscode . Uri . parse ( noteUrl ) ) ;
30
- } ) ) ;
31
21
}
Original file line number Diff line number Diff line change @@ -77,6 +77,22 @@ export async function registerTreeViewCommands(context: vscode.ExtensionContext)
77
77
}
78
78
} ) ) ;
79
79
80
+ context . subscriptions . push ( vscode . commands . registerCommand ( 'HacKMD.openNoteOnHackMD' , async ( noteNode : NoteTreeNode ) => {
81
+ let noteId = '' ;
82
+ if ( noteNode ) {
83
+ noteId = noteNode . noteId ;
84
+ } else {
85
+ noteId = vscode . window . activeTextEditor . document . uri . fragment ;
86
+ }
87
+ if ( ! checkNoteIdExist ( noteId ) ) { return ; }
88
+
89
+ const serverUrl = vscode . workspace . getConfiguration ( 'Hackmd' ) . get ( 'serverURL' ) as string ;
90
+ const noteUrl = `${ serverUrl } /${ noteId } ` ;
91
+ vscode . env . openExternal ( vscode . Uri . parse ( noteUrl ) ) ;
92
+ } ) ) ;
93
+
94
+
95
+
80
96
context . subscriptions . push ( vscode . workspace . registerTextDocumentContentProvider ( 'hackmd' , new MdTextDocumentContentProvider ( ) ) ) ;
81
97
}
82
98
You can’t perform that action at this time.
0 commit comments