mirror of
https://github.com/zadam/trilium.git
synced 2024-09-22 00:26:01 +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() {
|
||||
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 log = require('../../services/log');
|
||||
const TaskContext = require('../../services/task_context');
|
||||
const protectedSessionService = require('../../services/protected_session');
|
||||
const fs = require('fs');
|
||||
const becca = require("../../becca/becca");
|
||||
|
||||
|
@ -305,6 +306,21 @@ function uploadModifiedFile(req) {
|
|||
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 = {
|
||||
getNote,
|
||||
updateNoteContent,
|
||||
|
@ -319,5 +335,6 @@ module.exports = {
|
|||
duplicateSubtree,
|
||||
eraseDeletedNotesNow,
|
||||
getDeleteNotesPreview,
|
||||
uploadModifiedFile
|
||||
uploadModifiedFile,
|
||||
forceSaveNoteRevision
|
||||
};
|
||||
|
|
|
@ -254,6 +254,7 @@ function register(app) {
|
|||
apiRoute(PUT, '/api/notes/:noteId/content', notesApiRoute.updateNoteContent);
|
||||
apiRoute(DELETE, '/api/notes/:noteId', notesApiRoute.deleteNote);
|
||||
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(PUT, '/api/notes/:noteId/sort-children', notesApiRoute.sortChildNotes);
|
||||
apiRoute(PUT, '/api/notes/:noteId/protect/:isProtected', notesApiRoute.protectNote);
|
||||
|
|
|
@ -500,6 +500,12 @@ const DEFAULT_KEYBOARD_ACTIONS = [
|
|||
defaultShortcuts: ["CommandOrControl+Alt+C"],
|
||||
description: "Copy selected text without formatting",
|
||||
scope: "text-detail"
|
||||
},
|
||||
{
|
||||
actionName: "forceSaveNoteRevision",
|
||||
defaultShortcuts: [],
|
||||
description: "Force creating / saving new note revision of the active note",
|
||||
scope: "window"
|
||||
}
|
||||
];
|
||||
|
||||
|
|
Loading…
Reference in a new issue