mirror of
				https://github.com/TriliumNext/Notes.git
				synced 2025-10-31 04:51:31 +08:00 
			
		
		
		
	ctrl+enter should work only on tab detail
This commit is contained in:
		
							parent
							
								
									ecfba95841
								
							
						
					
					
						commit
						ddb99a0917
					
				| @ -16,7 +16,7 @@ class NoteDetailCode { | |||||||
|         this.$component = ctx.$tabContent.find('.note-detail-code'); |         this.$component = ctx.$tabContent.find('.note-detail-code'); | ||||||
|         this.$executeScriptButton = ctx.$tabContent.find(".execute-script-button"); |         this.$executeScriptButton = ctx.$tabContent.find(".execute-script-button"); | ||||||
| 
 | 
 | ||||||
|         utils.bindShortcut("ctrl+return", () => this.executeCurrentNote()); |         utils.bindElShortcut(ctx.$tabContent, "ctrl+return", () => this.executeCurrentNote()); | ||||||
| 
 | 
 | ||||||
|         this.$executeScriptButton.click(() => this.executeCurrentNote()); |         this.$executeScriptButton.click(() => this.executeCurrentNote()); | ||||||
|     } |     } | ||||||
|  | |||||||
| @ -51,7 +51,6 @@ function NoteTypeContext(ctx) { | |||||||
|     const self = this; |     const self = this; | ||||||
| 
 | 
 | ||||||
|     this.$executeScriptButton = ctx.$tabContent.find(".execute-script-button"); |     this.$executeScriptButton = ctx.$tabContent.find(".execute-script-button"); | ||||||
|     this.$toggleEditButton = ctx.$tabContent.find('.toggle-edit-button'); |  | ||||||
|     this.$renderButton = ctx.$tabContent.find('.render-button'); |     this.$renderButton = ctx.$tabContent.find('.render-button'); | ||||||
| 
 | 
 | ||||||
|     this.ctx = ctx; |     this.ctx = ctx; | ||||||
| @ -178,10 +177,8 @@ function NoteTypeContext(ctx) { | |||||||
|     }; |     }; | ||||||
| 
 | 
 | ||||||
|     this.updateExecuteScriptButtonVisibility = function() { |     this.updateExecuteScriptButtonVisibility = function() { | ||||||
|         self.$executeScriptButton.toggle(self.mime().startsWith('application/javascript')); |         self.$executeScriptButton.toggle(ctx.note.mime.startsWith('application/javascript')); | ||||||
| 
 |         self.$renderButton.toggle(ctx.note.type === 'render'); | ||||||
|         self.$toggleEditButton.toggle(self.type() === 'render'); |  | ||||||
|         self.$renderButton.toggle(self.type() === 'render'); |  | ||||||
|     }; |     }; | ||||||
| 
 | 
 | ||||||
|     ko.applyBindings(this, ctx.$tabContent.find('.note-type-wrapper')[0]) |     ko.applyBindings(this, ctx.$tabContent.find('.note-type-wrapper')[0]) | ||||||
|  | |||||||
| @ -106,6 +106,10 @@ class TabContext { | |||||||
|             } |             } | ||||||
|         }, 5000); |         }, 5000); | ||||||
| 
 | 
 | ||||||
|  |         if (utils.isDesktop()) { | ||||||
|  |             this.noteType.updateExecuteScriptButtonVisibility(); | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|         console.log(`Switched tab ${this.tabId} to ${this.noteId}`); |         console.log(`Switched tab ${this.tabId} to ${this.noteId}`); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -130,13 +130,17 @@ function randomString(len) { | |||||||
| } | } | ||||||
| 
 | 
 | ||||||
| function bindShortcut(keyboardShortcut, handler) { | function bindShortcut(keyboardShortcut, handler) { | ||||||
|  |     bindElShortcut($(document), keyboardShortcut, handler); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | function bindElShortcut($el, keyboardShortcut, handler) { | ||||||
|     if (isDesktop()) { |     if (isDesktop()) { | ||||||
|         if (isMac()) { |         if (isMac()) { | ||||||
|             // use CMD (meta) instead of CTRL for all shortcuts
 |             // use CMD (meta) instead of CTRL for all shortcuts
 | ||||||
|             keyboardShortcut = keyboardShortcut.replace("ctrl", "meta"); |             keyboardShortcut = keyboardShortcut.replace("ctrl", "meta"); | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         $(document).bind('keydown', keyboardShortcut, e => { |         $el.bind('keydown', keyboardShortcut, e => { | ||||||
|             handler(); |             handler(); | ||||||
| 
 | 
 | ||||||
|             e.preventDefault(); |             e.preventDefault(); | ||||||
| @ -212,6 +216,7 @@ export default { | |||||||
|     toObject, |     toObject, | ||||||
|     randomString, |     randomString, | ||||||
|     bindShortcut, |     bindShortcut, | ||||||
|  |     bindElShortcut, | ||||||
|     isMobile, |     isMobile, | ||||||
|     isDesktop, |     isDesktop, | ||||||
|     setCookie, |     setCookie, | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 zadam
						zadam