File tree Expand file tree Collapse file tree 4 files changed +41
-0
lines changed Expand file tree Collapse file tree 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>
2828 </ div >
2929 </ div >
3030 </ 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 >
3150 < div class ="electronSearchText-box ">
3251 < input type ="text " class ="electronSearchText-input ">
3352 < span class ="electronSearchText-count "> </ span >
Original file line number Diff line number Diff line change @@ -27,6 +27,9 @@ module.exports = function (commandId, args = {}) {
2727 case 'configServerUrl' :
2828 BrowserWindow . getFocusedWindow ( ) . webContents . send ( 'config-serverurl' )
2929 break
30+ case 'openFromUrl' :
31+ BrowserWindow . getFocusedWindow ( ) . webContents . send ( 'open-from-url' )
32+ break
3033 case 'checkVersion' :
3134 return fetch ( url . resolve ( getServerUrl ( ) , '/status' ) ) . then ( response => {
3235 var browserWindows = BrowserWindow . getAllWindows ( )
Original file line number Diff line number Diff line change @@ -25,6 +25,13 @@ const template = [
2525 click ( ) {
2626 exec ( 'createWindow' , { url : `file://${ path . join ( __dirname , 'index.html' ) } ` } )
2727 }
28+ } ,
29+ {
30+ label : 'Open from url' ,
31+ accelerator : 'CmdOrCtrl+O' ,
32+ click ( ) {
33+ exec ( 'openFromUrl' )
34+ }
2835 }
2936 ]
3037 } ,
Original file line number Diff line number Diff line change @@ -163,6 +163,10 @@ window.onload = () => {
163163 $ ( '#serverurl-config-modal.modal' ) . modal ( )
164164 } )
165165
166+ ipcRenderer . on ( 'open-from-url' , ( ) => {
167+ $ ( '#open-from-url-modal.modal' ) . modal ( )
168+ } )
169+
166170 ipcRenderer . on ( 'unsupported-version' , ( ) => {
167171 $ ( 'navbar' ) . addClass ( 'unsupported' )
168172 } )
@@ -197,6 +201,14 @@ window.onload = () => {
197201 }
198202 } )
199203
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+
200212 /* handle _target=blank pages */
201213 webview . addEventListener ( 'new-window' , ( event ) => {
202214 ipcClient ( 'createWindow' , { url : `file://${ path . join ( __dirname , `index.html?target=${ event . url } ` ) } ` } )
You can’t perform that action at this time.
0 commit comments