File tree 4 files changed +41
-0
lines changed
4 files changed +41
-0
lines changed Original file line number Diff line number Diff line change @@ -28,6 +28,25 @@ <h4 class="modal-title">Customize HackMD server</h4>
28
28
</ div >
29
29
</ div >
30
30
</ div >
31
+ < div class ="modal fade " tabindex ="-1 " role ="dialog " id ="open-from-url-modal ">
32
+ < div class ="modal-dialog " role ="document ">
33
+ < div class ="modal-content ">
34
+ < div class ="modal-header ">
35
+ < button type ="button " class ="close " data-dismiss ="modal " aria-label ="Close "> < span aria-hidden ="true "> ×</ span > </ button >
36
+ < h4 class ="modal-title "> Open HackMD from url</ h4 >
37
+ </ div >
38
+ < div class ="modal-body ">
39
+ < div class ="form-group ">
40
+ < input type ="text " class ="form-control " placeholder ="https://hackmd.io/features ">
41
+ </ div >
42
+ </ div >
43
+ < div class ="modal-footer ">
44
+ < button type ="button " class ="btn btn-default " data-dismiss ="modal "> Close</ button >
45
+ < button type ="button " class ="btn btn-primary " id ="submit-file-url "> Go</ button >
46
+ </ div >
47
+ </ div >
48
+ </ div >
49
+ </ div >
31
50
< div class ="electronSearchText-box ">
32
51
< input type ="text " class ="electronSearchText-input ">
33
52
< span class ="electronSearchText-count "> </ span >
Original file line number Diff line number Diff line change @@ -27,6 +27,9 @@ module.exports = function (commandId, args = {}) {
27
27
case 'configServerUrl' :
28
28
BrowserWindow . getFocusedWindow ( ) . webContents . send ( 'config-serverurl' )
29
29
break
30
+ case 'openFromUrl' :
31
+ BrowserWindow . getFocusedWindow ( ) . webContents . send ( 'open-from-url' )
32
+ break
30
33
case 'checkVersion' :
31
34
return fetch ( url . resolve ( getServerUrl ( ) , '/status' ) ) . then ( response => {
32
35
var browserWindows = BrowserWindow . getAllWindows ( )
Original file line number Diff line number Diff line change @@ -25,6 +25,13 @@ const template = [
25
25
click ( ) {
26
26
exec ( 'createWindow' , { url : `file://${ path . join ( __dirname , 'index.html' ) } ` } )
27
27
}
28
+ } ,
29
+ {
30
+ label : 'Open from url' ,
31
+ accelerator : 'CmdOrCtrl+O' ,
32
+ click ( ) {
33
+ exec ( 'openFromUrl' )
34
+ }
28
35
}
29
36
]
30
37
} ,
Original file line number Diff line number Diff line change @@ -163,6 +163,10 @@ window.onload = () => {
163
163
$ ( '#serverurl-config-modal.modal' ) . modal ( )
164
164
} )
165
165
166
+ ipcRenderer . on ( 'open-from-url' , ( ) => {
167
+ $ ( '#open-from-url-modal.modal' ) . modal ( )
168
+ } )
169
+
166
170
ipcRenderer . on ( 'unsupported-version' , ( ) => {
167
171
$ ( 'navbar' ) . addClass ( 'unsupported' )
168
172
} )
@@ -197,6 +201,14 @@ window.onload = () => {
197
201
}
198
202
} )
199
203
204
+ $ ( '#open-from-url-modal.modal #submit-file-url' ) . click ( function ( ) {
205
+ let url = $ ( '#open-from-url-modal.modal input[type="text"]' ) . val ( )
206
+ if ( url . length > 0 ) {
207
+ ipcClient ( 'createWindow' , { url : `file://${ path . join ( __dirname , `index.html?target=${ url } ` ) } ` } )
208
+ $ ( '#open-from-url-modal.modal' ) . modal ( 'hide' )
209
+ }
210
+ } )
211
+
200
212
/* handle _target=blank pages */
201
213
webview . addEventListener ( 'new-window' , ( event ) => {
202
214
ipcClient ( 'createWindow' , { url : `file://${ path . join ( __dirname , `index.html?target=${ event . url } ` ) } ` } )
You can’t perform that action at this time.
0 commit comments