mirror of
https://github.com/zadam/trilium.git
synced 2025-03-01 14:22:32 +01:00
Merge branch 'master' into custom-search-dialog
This commit is contained in:
commit
1d8664927d
@ -43,7 +43,6 @@ export default class Entrypoints extends Component {
|
|||||||
const inboxNote = await dateNoteService.getInboxNote();
|
const inboxNote = await dateNoteService.getInboxNote();
|
||||||
|
|
||||||
const {note} = await server.post(`notes/${inboxNote.noteId}/children?target=into`, {
|
const {note} = await server.post(`notes/${inboxNote.noteId}/children?target=into`, {
|
||||||
title: 'new note',
|
|
||||||
content: '',
|
content: '',
|
||||||
type: 'text',
|
type: 'text',
|
||||||
isProtected: inboxNote.isProtected && protectedSessionHolder.isProtectedSessionAvailable()
|
isProtected: inboxNote.isProtected && protectedSessionHolder.isProtectedSessionAvailable()
|
||||||
|
@ -28,8 +28,6 @@ async function createNote(parentNotePath, options = {}) {
|
|||||||
[options.title, options.content] = parseSelectedHtml(window.cutToNote.getSelectedHtml());
|
[options.title, options.content] = parseSelectedHtml(window.cutToNote.getSelectedHtml());
|
||||||
}
|
}
|
||||||
|
|
||||||
const newNoteName = options.title || "new note";
|
|
||||||
|
|
||||||
const parentNoteId = treeService.getNoteIdFromNotePath(parentNotePath);
|
const parentNoteId = treeService.getNoteIdFromNotePath(parentNotePath);
|
||||||
|
|
||||||
if (options.type === 'mermaid' && !options.content) {
|
if (options.type === 'mermaid' && !options.content) {
|
||||||
@ -41,7 +39,7 @@ async function createNote(parentNotePath, options = {}) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const {note, branch} = await server.post(`notes/${parentNoteId}/children?target=${options.target}&targetBranchId=${options.targetBranchId || ""}`, {
|
const {note, branch} = await server.post(`notes/${parentNoteId}/children?target=${options.target}&targetBranchId=${options.targetBranchId || ""}`, {
|
||||||
title: newNoteName,
|
title: options.title,
|
||||||
content: options.content || "",
|
content: options.content || "",
|
||||||
isProtected: options.isProtected,
|
isProtected: options.isProtected,
|
||||||
type: options.type,
|
type: options.type,
|
||||||
|
@ -219,6 +219,15 @@ const ATTR_HELP = {
|
|||||||
"shareDisallowRobotIndexing": `will forbid robot indexing of this note via <code>X-Robots-Tag: noindex</code> header`,
|
"shareDisallowRobotIndexing": `will forbid robot indexing of this note via <code>X-Robots-Tag: noindex</code> header`,
|
||||||
"displayRelations": "comma delimited names of relations which should be displayed. All other ones will be hidden.",
|
"displayRelations": "comma delimited names of relations which should be displayed. All other ones will be hidden.",
|
||||||
"hideRelations": "comma delimited names of relations which should be hidden. All other ones will be displayed.",
|
"hideRelations": "comma delimited names of relations which should be hidden. All other ones will be displayed.",
|
||||||
|
"titleTemplate": `default title of notes created as children of this note. The value is evaluated as JavaScript string
|
||||||
|
and thus can be enriched with dynamic content via the injected <code>now</code> and <code>parentNote</code> variables. Examples:
|
||||||
|
|
||||||
|
<ul>
|
||||||
|
<li><code>\${parentNote.getLabelValue('authorName')}'s literary works</code></li>
|
||||||
|
<li><code>Log for \${now.format('YYYY-MM-DD HH:mm:ss')}</code></li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
See <a href="https://github.com/zadam/trilium/wiki/Default-note-title">wiki with details</a>, API docs for <a href="https://zadam.github.io/trilium/backend_api/Note.html">parentNote</a> and <a href="https://day.js.org/docs/en/display/format">now</a> for details.`
|
||||||
},
|
},
|
||||||
"relation": {
|
"relation": {
|
||||||
"runOnNoteCreation": "executes when note is created on backend",
|
"runOnNoteCreation": "executes when note is created on backend",
|
||||||
|
@ -50,6 +50,7 @@ module.exports = [
|
|||||||
{ type: 'label', name: 'shareDisallowRobotIndexing' },
|
{ type: 'label', name: 'shareDisallowRobotIndexing' },
|
||||||
{ type: 'label', name: 'displayRelations' },
|
{ type: 'label', name: 'displayRelations' },
|
||||||
{ type: 'label', name: 'hideRelations' },
|
{ type: 'label', name: 'hideRelations' },
|
||||||
|
{ type: 'label', name: 'titleTemplate' },
|
||||||
|
|
||||||
// relation names
|
// relation names
|
||||||
{ type: 'relation', name: 'internalLink' },
|
{ type: 'relation', name: 'internalLink' },
|
||||||
|
@ -17,7 +17,7 @@ const becca = require('../becca/becca');
|
|||||||
const Branch = require('../becca/entities/branch');
|
const Branch = require('../becca/entities/branch');
|
||||||
const Note = require('../becca/entities/note');
|
const Note = require('../becca/entities/note');
|
||||||
const Attribute = require('../becca/entities/attribute');
|
const Attribute = require('../becca/entities/attribute');
|
||||||
const TaskContext = require("./task_context.js");
|
const dayjs = require("dayjs");
|
||||||
|
|
||||||
function getNewNotePosition(parentNoteId) {
|
function getNewNotePosition(parentNoteId) {
|
||||||
const note = becca.notes[parentNoteId];
|
const note = becca.notes[parentNoteId];
|
||||||
@ -79,6 +79,28 @@ function copyChildAttributes(parentNote, childNote) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getNewNoteTitle(parentNote) {
|
||||||
|
let title = "new note";
|
||||||
|
|
||||||
|
const titleTemplate = parentNote.getLabelValue('titleTemplate');
|
||||||
|
|
||||||
|
if (titleTemplate !== null) {
|
||||||
|
try {
|
||||||
|
const now = dayjs(cls.getLocalNowDateTime() || new Date());
|
||||||
|
|
||||||
|
// "officially" injected values:
|
||||||
|
// - now
|
||||||
|
// - parentNote
|
||||||
|
|
||||||
|
title = eval('`' + titleTemplate + '`');
|
||||||
|
} catch (e) {
|
||||||
|
log.error(`Title template of note '${parentNote.noteId}' failed with: ${e.message}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return title;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Following object properties are mandatory:
|
* Following object properties are mandatory:
|
||||||
* - {string} parentNoteId
|
* - {string} parentNoteId
|
||||||
@ -104,8 +126,7 @@ function createNewNote(params) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (params.title === null || params.title === undefined) {
|
if (params.title === null || params.title === undefined) {
|
||||||
// empty title is allowed since it's possible to create such in the UI
|
params.title = getNewNoteTitle(parentNote);
|
||||||
throw new Error(`Note title must be set`);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (params.content === null || params.content === undefined) {
|
if (params.content === null || params.content === undefined) {
|
||||||
|
@ -153,10 +153,11 @@ function setDbAsInitialized() {
|
|||||||
|
|
||||||
function optimize() {
|
function optimize() {
|
||||||
log.info("Optimizing database");
|
log.info("Optimizing database");
|
||||||
|
const start = Date.now();
|
||||||
|
|
||||||
sql.execute("PRAGMA optimize");
|
sql.execute("PRAGMA optimize");
|
||||||
|
|
||||||
log.info("Optimization finished.");
|
log.info(`Optimization finished in ${Date.now() - start}ms.`);
|
||||||
}
|
}
|
||||||
|
|
||||||
dbReady.then(() => {
|
dbReady.then(() => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user