mirror of
https://github.com/zadam/trilium.git
synced 2025-03-01 14:22:32 +01:00
Merge branch 'stable'
This commit is contained in:
commit
da92809299
@ -16,9 +16,9 @@ function getNotePathFromUrl(url) {
|
|||||||
|
|
||||||
async function createNoteLink(notePath, noteTitle = null, tooltip = true) {
|
async function createNoteLink(notePath, noteTitle = null, tooltip = true) {
|
||||||
if (!noteTitle) {
|
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>", {
|
const $noteLink = $("<a>", {
|
||||||
|
@ -131,11 +131,13 @@ class NoteDetailBook {
|
|||||||
for (const childNote of await note.getChildNotes()) {
|
for (const childNote of await note.getChildNotes()) {
|
||||||
const type = this.getRenderingType(childNote);
|
const type = this.getRenderingType(childNote);
|
||||||
|
|
||||||
|
const childNotePath = this.ctx.notePath + '/' + childNote.noteId;
|
||||||
|
|
||||||
const $card = $('<div class="note-book-card">')
|
const $card = $('<div class="note-book-card">')
|
||||||
.attr('data-note-id', childNote.noteId)
|
.attr('data-note-id', childNote.noteId)
|
||||||
.css("flex-basis", ZOOMS[this.zoomLevel].width)
|
.css("flex-basis", ZOOMS[this.zoomLevel].width)
|
||||||
.addClass("type-" + type)
|
.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">')
|
.append($('<div class="note-book-content">')
|
||||||
.css("max-height", ZOOMS[this.zoomLevel].height)
|
.css("max-height", ZOOMS[this.zoomLevel].height)
|
||||||
.append(await this.getNoteContent(type, childNote)));
|
.append(await this.getNoteContent(type, childNote)));
|
||||||
|
@ -25,6 +25,29 @@ function getNoteIdFromNotePath(notePath) {
|
|||||||
return lastSegment.split("-")[0];
|
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) {
|
async function getNotePath(node) {
|
||||||
if (!node) {
|
if (!node) {
|
||||||
console.error("Node is null");
|
console.error("Node is null");
|
||||||
@ -103,6 +126,7 @@ export default {
|
|||||||
getNodeByKey,
|
getNodeByKey,
|
||||||
getNotePath,
|
getNotePath,
|
||||||
getNoteIdFromNotePath,
|
getNoteIdFromNotePath,
|
||||||
|
getNoteIdAndParentIdFromNotePath,
|
||||||
getNoteTitle,
|
getNoteTitle,
|
||||||
getNotePathTitle,
|
getNotePathTitle,
|
||||||
};
|
};
|
Loading…
x
Reference in New Issue
Block a user