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 treeCache from "./tree_cache.js";
|
||||||
import server from "./server.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} */
|
/** @return {NoteShort} */
|
||||||
async function getTodayNote() {
|
async function getTodayNote() {
|
||||||
return await getDateNote(dayjs().format("YYYY-MM-DD"));
|
return await getDateNote(dayjs().format("YYYY-MM-DD"));
|
||||||
@ -42,6 +49,7 @@ async function createSearchNote() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
getInboxNote,
|
||||||
getTodayNote,
|
getTodayNote,
|
||||||
getDateNote,
|
getDateNote,
|
||||||
getMonthNote,
|
getMonthNote,
|
||||||
|
@ -62,14 +62,14 @@ export default class Entrypoints extends Component {
|
|||||||
findInPage.openFindWindow();
|
findInPage.openFindWindow();
|
||||||
}
|
}
|
||||||
|
|
||||||
async createNoteIntoDayNoteCommand() {
|
async createNoteIntoInboxCommand() {
|
||||||
const todayNote = await dateNoteService.getTodayNote();
|
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',
|
title: 'new note',
|
||||||
content: '',
|
content: '',
|
||||||
type: 'text',
|
type: 'text',
|
||||||
isProtected: todayNote.isProtected
|
isProtected: inboxNote.isProtected
|
||||||
});
|
});
|
||||||
|
|
||||||
await ws.waitForMaxKnownEntityChangeId();
|
await ws.waitForMaxKnownEntityChangeId();
|
||||||
|
@ -34,17 +34,22 @@ const TPL = `
|
|||||||
</style>
|
</style>
|
||||||
|
|
||||||
<div style="flex-grow: 100; display: flex;">
|
<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>
|
<span class="bx bx-search"></span>
|
||||||
Search
|
Search
|
||||||
</button>
|
</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>
|
<span class="bx bx-send"></span>
|
||||||
Jump to note
|
Jump to note
|
||||||
</button>
|
</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>
|
<span class="bx bx-history"></span>
|
||||||
|
|
||||||
Recent changes
|
Recent changes
|
||||||
|
@ -4,6 +4,12 @@ const dateNoteService = require('../../services/date_notes');
|
|||||||
const sql = require('../../services/sql');
|
const sql = require('../../services/sql');
|
||||||
const dateUtils = require('../../services/date_utils');
|
const dateUtils = require('../../services/date_utils');
|
||||||
const noteService = require('../../services/notes');
|
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) {
|
function getDateNote(req) {
|
||||||
return dateNoteService.getDateNote(req.params.date);
|
return dateNoteService.getDateNote(req.params.date);
|
||||||
@ -68,6 +74,7 @@ function createSearchNote() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
getInboxNote,
|
||||||
getDateNote,
|
getDateNote,
|
||||||
getMonthNote,
|
getMonthNote,
|
||||||
getYearNote,
|
getYearNote,
|
||||||
|
@ -186,6 +186,7 @@ function register(app) {
|
|||||||
|
|
||||||
apiRoute(POST, '/api/notes/:noteId/link-map', linkMapRoute.getLinkMap);
|
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/date/:date', dateNotesRoute.getDateNote);
|
||||||
apiRoute(GET, '/api/date-notes/month/:month', dateNotesRoute.getMonthNote);
|
apiRoute(GET, '/api/date-notes/month/:month', dateNotesRoute.getMonthNote);
|
||||||
apiRoute(GET, '/api/date-notes/year/:year', dateNotesRoute.getYearNote);
|
apiRoute(GET, '/api/date-notes/year/:year', dateNotesRoute.getYearNote);
|
||||||
|
@ -8,6 +8,7 @@ const ATTRIBUTE_TYPES = [ 'label', 'relation' ];
|
|||||||
|
|
||||||
const BUILTIN_ATTRIBUTES = [
|
const BUILTIN_ATTRIBUTES = [
|
||||||
// label names
|
// label names
|
||||||
|
{ type: 'label', name: 'inbox' },
|
||||||
{ type: 'label', name: 'disableVersioning' },
|
{ type: 'label', name: 'disableVersioning' },
|
||||||
{ type: 'label', name: 'calendarRoot' },
|
{ type: 'label', name: 'calendarRoot' },
|
||||||
{ type: 'label', name: 'archived' },
|
{ type: 'label', name: 'archived' },
|
||||||
|
@ -85,9 +85,9 @@ const DEFAULT_KEYBOARD_ACTIONS = [
|
|||||||
scope: "window"
|
scope: "window"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
actionName: "createNoteIntoDayNote",
|
actionName: "createNoteIntoInbox",
|
||||||
defaultShortcuts: ["global:CommandOrControl+Alt+P"],
|
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"
|
scope: "window"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user