Compare commits

...

10 Commits

19 changed files with 336 additions and 66 deletions

View File

@@ -396,7 +396,7 @@ the backend.
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line312">line 312</a>
<a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line313">line 313</a>
</li></ul></dd>
@@ -1533,7 +1533,7 @@ the backend.
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line317">line 317</a>
<a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line318">line 318</a>
</li></ul></dd>
@@ -4249,7 +4249,7 @@ if some action needs to happen on only one specific instance.
<h4 class="name" id="setNoteToParent"><span class="type-signature"></span>setNoteToParent<span class="signature">(noteId, prefix, parentNoteId<span class="signature-attributes">opt</span>)</span><span class="type-signature"></span></h4>
<h4 class="name" id="setNoteToParent"><span class="type-signature"></span>setNoteToParent<span class="signature">(noteId, prefix, parentNoteId)</span><span class="type-signature"></span></h4>
@@ -4284,8 +4284,6 @@ This method looks similar to toggleNoteInParent() but differs because we're look
<th>Type</th>
<th>Attributes</th>
@@ -4311,14 +4309,6 @@ This method looks similar to toggleNoteInParent() but differs because we're look
</td>
<td class="attributes">
</td>
@@ -4342,14 +4332,6 @@ This method looks similar to toggleNoteInParent() but differs because we're look
</td>
<td class="attributes">
</td>
@@ -4367,22 +4349,15 @@ This method looks similar to toggleNoteInParent() but differs because we're look
<span class="param-type">string</span>
|
<span class="param-type">null</span>
</td>
<td class="attributes">
&lt;optional><br>
</td>
@@ -4415,6 +4390,8 @@ This method looks similar to toggleNoteInParent() but differs because we're look
<dt class="important tag-deprecated">Deprecated:</dt><dd><ul class="dummy"><li>- this method is pretty confusing and serves specialized purpose only</li></ul></dd>
@@ -4427,7 +4404,7 @@ This method looks similar to toggleNoteInParent() but differs because we're look
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line289">line 289</a>
<a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line290">line 290</a>
</li></ul></dd>
@@ -4935,7 +4912,7 @@ transactional by default.
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line302">line 302</a>
<a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line303">line 303</a>
</li></ul></dd>

View File

@@ -310,9 +310,10 @@ function BackendScriptApi(currentNote, apiParams) {
* This method looks similar to toggleNoteInParent() but differs because we're looking up branch by prefix.
*
* @method
* @deprecated - this method is pretty confusing and serves specialized purpose only
* @param {string} noteId
* @param {string} prefix
* @param {string} [parentNoteId]
* @param {string|null} parentNoteId
*/
this.setNoteToParent = treeService.setNoteToParent;

View File

@@ -1366,7 +1366,7 @@
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line368">line 368</a>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line384">line 384</a>
</li></ul></dd>
@@ -1546,7 +1546,7 @@
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line275">line 275</a>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line291">line 291</a>
</li></ul></dd>
@@ -1785,7 +1785,7 @@
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line281">line 281</a>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line297">line 297</a>
</li></ul></dd>
@@ -1891,7 +1891,7 @@
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line287">line 287</a>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line303">line 303</a>
</li></ul></dd>
@@ -2050,7 +2050,7 @@
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line334">line 334</a>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line350">line 350</a>
</li></ul></dd>
@@ -2312,7 +2312,7 @@ if some action needs to happen on only one specific instance.
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line343">line 343</a>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line359">line 359</a>
</li></ul></dd>
@@ -2775,7 +2775,7 @@ otherwise (by e.g. createNoteLink())
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line325">line 325</a>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line341">line 341</a>
</li></ul></dd>
@@ -2930,7 +2930,7 @@ otherwise (by e.g. createNoteLink())
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line352">line 352</a>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line368">line 368</a>
</li></ul></dd>
@@ -3039,7 +3039,7 @@ note.
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line298">line 298</a>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line314">line 314</a>
</li></ul></dd>
@@ -3194,7 +3194,7 @@ note.
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line306">line 306</a>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line322">line 322</a>
</li></ul></dd>
@@ -3433,7 +3433,7 @@ note.
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line317">line 317</a>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line333">line 333</a>
</li></ul></dd>
@@ -3463,6 +3463,218 @@ note.
<h4 class="name" id="refreshActiveTab"><span class="type-signature"></span>refreshActiveTab<span class="signature">()</span><span class="type-signature"> &rarr; {Promise.&lt;void>}</span></h4>
<div class="description">
Refresh active tab
</div>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line274">line 274</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Promise.&lt;void></span>
</dd>
</dl>
<h4 class="name" id="refreshAllTabs"><span class="type-signature"></span>refreshAllTabs<span class="signature">()</span><span class="type-signature"> &rarr; {Promise.&lt;void>}</span></h4>
<div class="description">
Refresh current tab
</div>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line282">line 282</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Promise.&lt;void></span>
</dd>
</dl>
@@ -4308,7 +4520,7 @@ Internally this serializes the anonymous function into string and sends it to ba
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line361">line 361</a>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line377">line 377</a>
</li></ul></dd>
@@ -4459,7 +4671,7 @@ Internally this serializes the anonymous function into string and sends it to ba
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line312">line 312</a>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line328">line 328</a>
</li></ul></dd>

View File

@@ -293,6 +293,22 @@ function FrontendScriptApi(startNote, currentNote, originEntity = null, tabConte
*/
this.refreshTree = treeService.reload;
/**
* Refresh active tab
*
* @method
* @returns {Promise&lt;void>}
*/
this.refreshActiveTab = noteDetailService.reload;
/**
* Refresh current tab
*
* @method
* @returns {Promise&lt;void>}
*/
this.refreshAllTabs = noteDetailService.reloadAllTabs;
/**
* Create note link (jQuery object) for given note.
*

2
package-lock.json generated
View File

@@ -1,6 +1,6 @@
{
"name": "trilium",
"version": "0.36.2",
"version": "0.36.4",
"lockfileVersion": 1,
"requires": true,
"dependencies": {

View File

@@ -2,7 +2,7 @@
"name": "trilium",
"productName": "Trilium Notes",
"description": "Trilium Notes",
"version": "0.36.3",
"version": "0.36.5",
"license": "AGPL-3.0-only",
"main": "electron.js",
"bin": {

View File

@@ -265,6 +265,22 @@ function FrontendScriptApi(startNote, currentNote, originEntity = null, tabConte
*/
this.refreshTree = treeService.reload;
/**
* Refresh active tab
*
* @method
* @returns {Promise<void>}
*/
this.refreshActiveTab = noteDetailService.reload;
/**
* Refresh current tab
*
* @method
* @returns {Promise<void>}
*/
this.refreshAllTabs = noteDetailService.reloadAllTabs;
/**
* Create note link (jQuery object) for given note.
*

View File

@@ -16,9 +16,9 @@ function getNotePathFromUrl(url) {
async function createNoteLink(notePath, noteTitle = null, tooltip = true) {
if (!noteTitle) {
const noteId = treeUtils.getNoteIdFromNotePath(notePath);
const {noteId, parentNoteId} = treeUtils.getNoteIdAndParentIdFromNotePath(notePath);
noteTitle = await treeUtils.getNoteTitle(noteId);
noteTitle = await treeUtils.getNoteTitle(noteId, parentNoteId);
}
const $noteLink = $("<a>", {

View File

@@ -131,11 +131,13 @@ class NoteDetailBook {
for (const childNote of await note.getChildNotes()) {
const type = this.getRenderingType(childNote);
const childNotePath = this.ctx.notePath + '/' + childNote.noteId;
const $card = $('<div class="note-book-card">')
.attr('data-note-id', childNote.noteId)
.css("flex-basis", ZOOMS[this.zoomLevel].width)
.addClass("type-" + type)
.append($('<h5 class="note-book-title">').append(await linkService.createNoteLink(childNote.noteId, null, false)))
.append($('<h5 class="note-book-title">').append(await linkService.createNoteLink(childNotePath, null, false)))
.append($('<div class="note-book-content">')
.css("max-height", ZOOMS[this.zoomLevel].height)
.append(await this.getNoteContent(type, childNote)));
@@ -270,7 +272,10 @@ class NoteDetailBook {
return type;
}
getContent() {}
getContent() {
// for auto-book cases when renaming title there should be content
return "";
}
show() {
this.$component.show();

View File

@@ -184,7 +184,7 @@ class NoteDetailRelationMap {
this.saveData();
}
else if (cmd === "edit-title") {
const promptDialog = await import('"../dialogs/prompt.js"');
const promptDialog = await import("../dialogs/prompt.js");
const title = await promptDialog.ask({
message: "Enter new note title:",
defaultValue: $title.text()
@@ -446,7 +446,7 @@ class NoteDetailRelationMap {
return;
}
const promptDialog = await import('"../dialogs/prompt.js"');
const promptDialog = await import("../dialogs/prompt.js");
const name = await promptDialog.ask({
message: "Specify new relation name:",
shown: ({ $answer }) =>

View File

@@ -18,7 +18,11 @@ class NoteDetailRender {
this.$component.show();
this.$noteDetailRenderHelp.hide();
await renderService.render(this.ctx.note, this.$noteDetailRenderContent, this.ctx);
const renderNotesFound = await renderService.render(this.ctx.note, this.$noteDetailRenderContent, this.ctx);
if (!renderNotesFound) {
this.$noteDetailRenderHelp.show();
}
}
getContent() {}

View File

@@ -25,6 +25,29 @@ function getNoteIdFromNotePath(notePath) {
return lastSegment.split("-")[0];
}
function getNoteIdAndParentIdFromNotePath(notePath) {
let parentNoteId = 'root';
let noteId = '';
if (notePath) {
const path = notePath.split("/");
const lastSegment = path[path.length - 1];
// path could have also tabId suffix
noteId = lastSegment.split("-")[0];
if (path.length > 1) {
parentNoteId = path[path.length - 2];
}
}
return {
parentNoteId,
noteId
}
}
async function getNotePath(node) {
if (!node) {
console.error("Node is null");
@@ -103,6 +126,7 @@ export default {
getNodeByKey,
getNotePath,
getNoteIdFromNotePath,
getNoteIdAndParentIdFromNotePath,
getNoteTitle,
getNotePathTitle,
};

View File

@@ -282,9 +282,10 @@ function BackendScriptApi(currentNote, apiParams) {
* This method looks similar to toggleNoteInParent() but differs because we're looking up branch by prefix.
*
* @method
* @deprecated - this method is pretty confusing and serves specialized purpose only
* @param {string} noteId
* @param {string} prefix
* @param {string} [parentNoteId]
* @param {string|null} parentNoteId
*/
this.setNoteToParent = treeService.setNoteToParent;

View File

@@ -1 +1 @@
module.exports = { buildDate:"2019-11-05T21:49:16+01:00", buildRevision: "72fda89360d924aedf7a26216fd387346254dfd3" };
module.exports = { buildDate:"2019-11-10T22:20:54+01:00", buildRevision: "b5a0cadcf45e51377573c12b939a1654b09f4931" };

View File

@@ -6,6 +6,7 @@ const treeService = require('./tree');
const noteService = require('./notes');
const repository = require('./repository');
const Branch = require('../entities/branch');
const TaskContext = require("./task_context.js");
async function cloneNoteToParent(noteId, parentNoteId, prefix) {
if (await isNoteDeleted(noteId) || await isNoteDeleted(parentNoteId)) {
@@ -53,7 +54,7 @@ async function ensureNoteIsAbsentFromParent(noteId, parentNoteId) {
const branch = await repository.getEntity(`SELECT * FROM branches WHERE noteId = ? AND parentNoteId = ? AND isDeleted = 0`, [noteId, parentNoteId]);
if (branch) {
await noteService.deleteBranch(branch);
await noteService.deleteBranch(branch, new TaskContext());
}
}

View File

@@ -195,7 +195,7 @@ async function findExistencyIssues() {
HAVING
COUNT(*) > 1`,
async ({noteId, parentNoteId}) => {
const branches = await repository.getEntities(`SELECT * FROM branches WHERE noteId = ? and parentNoteId = ? and isDeleted = 1`, [noteId, parentNoteId]);
const branches = await repository.getEntities(`SELECT * FROM branches WHERE noteId = ? and parentNoteId = ? and isDeleted = 0`, [noteId, parentNoteId]);
// it's not necessarily "original" branch, it's just the only one which will survive
const origBranch = branches[0];

View File

@@ -370,6 +370,7 @@ async function updateNote(noteId, noteUpdates) {
note.isProtected = noteUpdates.isProtected;
await note.save();
// this might be simplified to just !== undefined
if (!['file', 'image', 'render'].includes(note.type)) {
noteUpdates.content = await saveLinks(note, noteUpdates.content);

View File

@@ -36,7 +36,7 @@ async function validateParentChild(parentNoteId, childNoteId, branchId = null) {
}
async function getExistingBranch(parentNoteId, childNoteId) {
return await sql.getRow('SELECT * FROM branches WHERE noteId = ? AND parentNoteId = ? AND isDeleted = 0', [childNoteId, parentNoteId]);
return await repository.getEntity('SELECT * FROM branches WHERE noteId = ? AND parentNoteId = ? AND isDeleted = 0', [childNoteId, parentNoteId]);
}
/**
@@ -123,6 +123,9 @@ async function sortNotesAlphabetically(parentNoteId, directoriesFirst = false) {
});
}
/**
* @deprecated - this will be removed in the future
*/
async function setNoteToParent(noteId, prefix, parentNoteId) {
const parentNote = await repository.getNote(parentNoteId);
@@ -151,11 +154,19 @@ async function setNoteToParent(noteId, prefix, parentNoteId) {
throw new Error(`Cannot create a branch for ${noteId} which is deleted.`);
}
await new Branch({
noteId: noteId,
parentNoteId: parentNoteId,
prefix: prefix
}).save();
const branch = await repository.getEntity('SELECT * FROM branches WHERE isDeleted = 0 AND noteId = ? AND parentNoteId = ?', [noteId, parentNoteId]);
if (branch) {
branch.prefix = prefix;
await branch.save();
}
else {
await new Branch({
noteId: noteId,
parentNoteId: parentNoteId,
prefix: prefix
}).save();
}
}
}

View File

@@ -79,6 +79,7 @@
</div>
<% include dialogs/protected_session_password.ejs %>
<% include dialogs/confirm.ejs %>
<div class="dropdown-menu dropdown-menu-sm" id="context-menu-container"></div>