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 127127 {
128128 "command" : " HacKMD.openNoteOnHackMD" ,
129129 "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+ }
131135 }
132136 ],
133137 "menus" : {
156160 {
157161 "command" : " HackMD.showPreviewAndEditor" ,
158162 "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"
159172 }
173+
160174 ]
161175 },
162176 "viewsWelcome" : [
Original file line number Diff line number Diff line change @@ -18,14 +18,4 @@ export async function registerNoteCommands(context: vscode.ExtensionContext) {
1818 vscode . env . openExternal ( vscode . Uri . parse ( noteUrl ) ) ;
1919 }
2020 } ) ) ;
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- } ) ) ;
3121}
Original file line number Diff line number Diff line change @@ -77,6 +77,22 @@ export async function registerTreeViewCommands(context: vscode.ExtensionContext)
7777 }
7878 } ) ) ;
7979
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+
8096 context . subscriptions . push ( vscode . workspace . registerTextDocumentContentProvider ( 'hackmd' , new MdTextDocumentContentProvider ( ) ) ) ;
8197}
8298
You can’t perform that action at this time.
0 commit comments