mirror of
				https://github.com/zadam/trilium.git
				synced 2025-11-04 05:28:59 +01:00 
			
		
		
		
	execute note (ctrl+enter) now works for both frontend and backend scripts
This commit is contained in:
		
							parent
							
								
									d26170762b
								
							
						
					
					
						commit
						6d0218cb36
					
				@ -298,10 +298,18 @@ const noteEditor = (function() {
 | 
				
			|||||||
            // make sure note is saved so we load latest changes
 | 
					            // make sure note is saved so we load latest changes
 | 
				
			||||||
            await saveNoteIfChanged();
 | 
					            await saveNoteIfChanged();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            if (currentNote.detail.mime.endsWith("env=frontend")) {
 | 
				
			||||||
                const bundle = await server.get('script/subtree/' + getCurrentNoteId());
 | 
					                const bundle = await server.get('script/subtree/' + getCurrentNoteId());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                executeBundle(bundle);
 | 
					                executeBundle(bundle);
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            if (currentNote.detail.mime.endsWith("env=backend")) {
 | 
				
			||||||
 | 
					                await server.post('script/run/' + getCurrentNoteId());
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            showMessage("Note executed");
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    $attachmentDownload.click(() => download(getAttachmentUrl()));
 | 
					    $attachmentDownload.click(() => download(getAttachmentUrl()));
 | 
				
			||||||
 | 
				
			|||||||
@ -16,6 +16,17 @@ router.post('/exec', auth.checkApiAuth, wrap(async (req, res, next) => {
 | 
				
			|||||||
    });
 | 
					    });
 | 
				
			||||||
}));
 | 
					}));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					router.post('/run/:noteId', auth.checkApiAuth, wrap(async (req, res, next) => {
 | 
				
			||||||
 | 
					    const repository = new Repository(req);
 | 
				
			||||||
 | 
					    const note = await repository.getNote(req.params.noteId);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    const ret = await script.executeNote(note);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    res.send({
 | 
				
			||||||
 | 
					        executionResult: ret
 | 
				
			||||||
 | 
					    });
 | 
				
			||||||
 | 
					}));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
router.get('/startup', auth.checkApiAuth, wrap(async (req, res, next) => {
 | 
					router.get('/startup', auth.checkApiAuth, wrap(async (req, res, next) => {
 | 
				
			||||||
    const repository = new Repository(req);
 | 
					    const repository = new Repository(req);
 | 
				
			||||||
    const notes = await attributes.getNotesWithAttribute(repository, "run", "frontend_startup");
 | 
					    const notes = await attributes.getNotesWithAttribute(repository, "run", "frontend_startup");
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user