mirror of
https://github.com/zadam/trilium.git
synced 2025-03-01 14:22:32 +01:00
added new "create note" button
This commit is contained in:
parent
2a54ce803e
commit
b0217ee04c
@ -1,6 +1,13 @@
|
||||
import treeCache from "./tree_cache.js";
|
||||
import server from "./server.js";
|
||||
|
||||
/** @return {NoteShort} */
|
||||
async function getInboxNote() {
|
||||
const note = await server.get('date-notes/inbox/' + dayjs().format("YYYY-MM-DD"), "date-note");
|
||||
|
||||
return await treeCache.getNote(note.noteId);
|
||||
}
|
||||
|
||||
/** @return {NoteShort} */
|
||||
async function getTodayNote() {
|
||||
return await getDateNote(dayjs().format("YYYY-MM-DD"));
|
||||
@ -42,6 +49,7 @@ async function createSearchNote() {
|
||||
}
|
||||
|
||||
export default {
|
||||
getInboxNote,
|
||||
getTodayNote,
|
||||
getDateNote,
|
||||
getMonthNote,
|
||||
|
@ -62,14 +62,14 @@ export default class Entrypoints extends Component {
|
||||
findInPage.openFindWindow();
|
||||
}
|
||||
|
||||
async createNoteIntoDayNoteCommand() {
|
||||
const todayNote = await dateNoteService.getTodayNote();
|
||||
async createNoteIntoInboxCommand() {
|
||||
const inboxNote = await dateNoteService.getInboxNote();
|
||||
|
||||
const {note} = await server.post(`notes/${todayNote.noteId}/children?target=into`, {
|
||||
const {note} = await server.post(`notes/${inboxNote.noteId}/children?target=into`, {
|
||||
title: 'new note',
|
||||
content: '',
|
||||
type: 'text',
|
||||
isProtected: todayNote.isProtected
|
||||
isProtected: inboxNote.isProtected
|
||||
});
|
||||
|
||||
await ws.waitForMaxKnownEntityChangeId();
|
||||
|
@ -34,17 +34,22 @@ const TPL = `
|
||||
</style>
|
||||
|
||||
<div style="flex-grow: 100; display: flex;">
|
||||
<button class="btn btn-sm search-button" data-trigger-command="searchNotes" data-command="searchNotes">
|
||||
<button class="btn btn-sm" data-trigger-command="createNoteIntoInbox">
|
||||
<span class="bx bx-file-blank"></span>
|
||||
New note
|
||||
</button>
|
||||
|
||||
<button class="btn btn-sm" data-trigger-command="searchNotes">
|
||||
<span class="bx bx-search"></span>
|
||||
Search
|
||||
</button>
|
||||
|
||||
<button class="btn btn-sm jump-to-note-dialog-button" data-trigger-command="jumpToNote">
|
||||
<button class="btn btn-sm" data-trigger-command="jumpToNote">
|
||||
<span class="bx bx-send"></span>
|
||||
Jump to note
|
||||
</button>
|
||||
|
||||
<button class="btn btn-sm recent-changes-button" data-trigger-command="showRecentChanges">
|
||||
<button class="btn btn-sm" data-trigger-command="showRecentChanges">
|
||||
<span class="bx bx-history"></span>
|
||||
|
||||
Recent changes
|
||||
|
@ -4,6 +4,12 @@ const dateNoteService = require('../../services/date_notes');
|
||||
const sql = require('../../services/sql');
|
||||
const dateUtils = require('../../services/date_utils');
|
||||
const noteService = require('../../services/notes');
|
||||
const attributeService = require('../../services/attributes');
|
||||
|
||||
function getInboxNote(req) {
|
||||
return attributeService.getNoteWithLabel('inbox')
|
||||
|| dateNoteService.getDateNote(req.params.date);
|
||||
}
|
||||
|
||||
function getDateNote(req) {
|
||||
return dateNoteService.getDateNote(req.params.date);
|
||||
@ -68,6 +74,7 @@ function createSearchNote() {
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
getInboxNote,
|
||||
getDateNote,
|
||||
getMonthNote,
|
||||
getYearNote,
|
||||
|
@ -186,6 +186,7 @@ function register(app) {
|
||||
|
||||
apiRoute(POST, '/api/notes/:noteId/link-map', linkMapRoute.getLinkMap);
|
||||
|
||||
apiRoute(GET, '/api/date-notes/inbox/:date', dateNotesRoute.getInboxNote);
|
||||
apiRoute(GET, '/api/date-notes/date/:date', dateNotesRoute.getDateNote);
|
||||
apiRoute(GET, '/api/date-notes/month/:month', dateNotesRoute.getMonthNote);
|
||||
apiRoute(GET, '/api/date-notes/year/:year', dateNotesRoute.getYearNote);
|
||||
|
@ -8,6 +8,7 @@ const ATTRIBUTE_TYPES = [ 'label', 'relation' ];
|
||||
|
||||
const BUILTIN_ATTRIBUTES = [
|
||||
// label names
|
||||
{ type: 'label', name: 'inbox' },
|
||||
{ type: 'label', name: 'disableVersioning' },
|
||||
{ type: 'label', name: 'calendarRoot' },
|
||||
{ type: 'label', name: 'archived' },
|
||||
|
@ -85,9 +85,9 @@ const DEFAULT_KEYBOARD_ACTIONS = [
|
||||
scope: "window"
|
||||
},
|
||||
{
|
||||
actionName: "createNoteIntoDayNote",
|
||||
actionName: "createNoteIntoInbox",
|
||||
defaultShortcuts: ["global:CommandOrControl+Alt+P"],
|
||||
description: "Create and open subnote of a current day note",
|
||||
description: "Create and open in the inbox (if defined) or day note",
|
||||
scope: "window"
|
||||
},
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user