mirror of
				https://github.com/TriliumNext/Notes.git
				synced 2025-10-31 04:51:31 +08:00 
			
		
		
		
	add keyboard action to force creating note revisions, #2147
This commit is contained in:
		
							parent
							
								
									bf4776a33c
								
							
						
					
					
						commit
						60fc621cd4
					
				| @ -201,4 +201,12 @@ export default class Entrypoints extends Component { | |||||||
|     activeContextChangedEvent() { |     activeContextChangedEvent() { | ||||||
|         this.hideAllTooltips(); |         this.hideAllTooltips(); | ||||||
|     } |     } | ||||||
|  | 
 | ||||||
|  |     async forceSaveNoteRevisionCommand() { | ||||||
|  |         const noteId = appContext.tabManager.getActiveContextNoteId(); | ||||||
|  | 
 | ||||||
|  |         await server.post(`notes/${noteId}/revision`); | ||||||
|  | 
 | ||||||
|  |         toastService.showMessage("Note revision has been created."); | ||||||
|  |     } | ||||||
| } | } | ||||||
|  | |||||||
| @ -6,6 +6,7 @@ const sql = require('../../services/sql'); | |||||||
| const utils = require('../../services/utils'); | const utils = require('../../services/utils'); | ||||||
| const log = require('../../services/log'); | const log = require('../../services/log'); | ||||||
| const TaskContext = require('../../services/task_context'); | const TaskContext = require('../../services/task_context'); | ||||||
|  | const protectedSessionService = require('../../services/protected_session'); | ||||||
| const fs = require('fs'); | const fs = require('fs'); | ||||||
| const becca = require("../../becca/becca"); | const becca = require("../../becca/becca"); | ||||||
| 
 | 
 | ||||||
| @ -305,6 +306,21 @@ function uploadModifiedFile(req) { | |||||||
|     note.setContent(fileContent); |     note.setContent(fileContent); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | function forceSaveNoteRevision(req) { | ||||||
|  |     const {noteId} = req.params; | ||||||
|  |     const note = becca.getNote(noteId); | ||||||
|  | 
 | ||||||
|  |     if (!note) { | ||||||
|  |         return [404, `Note ${noteId} not found.`]; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     if (!note.isContentAvailable()) { | ||||||
|  |         return [400, `Note revision of a protected note cannot be created outside of a protected session.`]; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     note.saveNoteRevision(); | ||||||
|  | } | ||||||
|  | 
 | ||||||
| module.exports = { | module.exports = { | ||||||
|     getNote, |     getNote, | ||||||
|     updateNoteContent, |     updateNoteContent, | ||||||
| @ -319,5 +335,6 @@ module.exports = { | |||||||
|     duplicateSubtree, |     duplicateSubtree, | ||||||
|     eraseDeletedNotesNow, |     eraseDeletedNotesNow, | ||||||
|     getDeleteNotesPreview, |     getDeleteNotesPreview, | ||||||
|     uploadModifiedFile |     uploadModifiedFile, | ||||||
|  |     forceSaveNoteRevision | ||||||
| }; | }; | ||||||
|  | |||||||
| @ -254,6 +254,7 @@ function register(app) { | |||||||
|     apiRoute(PUT, '/api/notes/:noteId/content', notesApiRoute.updateNoteContent); |     apiRoute(PUT, '/api/notes/:noteId/content', notesApiRoute.updateNoteContent); | ||||||
|     apiRoute(DELETE, '/api/notes/:noteId', notesApiRoute.deleteNote); |     apiRoute(DELETE, '/api/notes/:noteId', notesApiRoute.deleteNote); | ||||||
|     apiRoute(PUT, '/api/notes/:noteId/undelete', notesApiRoute.undeleteNote); |     apiRoute(PUT, '/api/notes/:noteId/undelete', notesApiRoute.undeleteNote); | ||||||
|  |     apiRoute(POST, '/api/notes/:noteId/revision', notesApiRoute.forceSaveNoteRevision); | ||||||
|     apiRoute(POST, '/api/notes/:parentNoteId/children', notesApiRoute.createNote); |     apiRoute(POST, '/api/notes/:parentNoteId/children', notesApiRoute.createNote); | ||||||
|     apiRoute(PUT, '/api/notes/:noteId/sort-children', notesApiRoute.sortChildNotes); |     apiRoute(PUT, '/api/notes/:noteId/sort-children', notesApiRoute.sortChildNotes); | ||||||
|     apiRoute(PUT, '/api/notes/:noteId/protect/:isProtected', notesApiRoute.protectNote); |     apiRoute(PUT, '/api/notes/:noteId/protect/:isProtected', notesApiRoute.protectNote); | ||||||
|  | |||||||
| @ -500,6 +500,12 @@ const DEFAULT_KEYBOARD_ACTIONS = [ | |||||||
|         defaultShortcuts: ["CommandOrControl+Alt+C"], |         defaultShortcuts: ["CommandOrControl+Alt+C"], | ||||||
|         description: "Copy selected text without formatting", |         description: "Copy selected text without formatting", | ||||||
|         scope: "text-detail" |         scope: "text-detail" | ||||||
|  |     }, | ||||||
|  |     { | ||||||
|  |         actionName: "forceSaveNoteRevision", | ||||||
|  |         defaultShortcuts: [], | ||||||
|  |         description: "Force creating / saving new note revision of the active note", | ||||||
|  |         scope: "window" | ||||||
|     } |     } | ||||||
| ]; | ]; | ||||||
| 
 | 
 | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 zadam
						zadam