From 055bd77bd687418d0525c4816b4eae8dce93941b Mon Sep 17 00:00:00 2001 From: zadam Date: Tue, 8 Nov 2022 23:06:56 +0100 Subject: [PATCH] Remove "Content of this note cannot be displayed" in the book format, fixes #3301 --- .../app/services/note_content_renderer.js | 47 +++++++++++-------- 1 file changed, 27 insertions(+), 20 deletions(-) diff --git a/src/public/app/services/note_content_renderer.js b/src/public/app/services/note_content_renderer.js index 749047a4b..b315e88bf 100644 --- a/src/public/app/services/note_content_renderer.js +++ b/src/public/app/services/note_content_renderer.js @@ -33,26 +33,7 @@ async function getRenderedContent(note, options = {}) { } } else { - $renderedContent.css("padding", "10px"); - $renderedContent.addClass("text-with-ellipsis"); - - let childNoteIds = note.getChildNoteIds(); - - if (childNoteIds.length > 10) { - childNoteIds = childNoteIds.slice(0, 10); - } - - // just load the first 10 child notes - const childNotes = await froca.getNotes(childNoteIds); - - for (const childNote of childNotes) { - $renderedContent.append(await linkService.createNoteLink(`${note.noteId}/${childNote.noteId}`, { - showTooltip: false, - showNoteIcon: true - })); - - $renderedContent.append("
"); - } + await renderChildrenList($renderedContent, note); } } else if (type === 'code') { @@ -164,6 +145,9 @@ async function getRenderedContent(note, options = {}) { $renderedContent.append($("
").text("Error parsing content. Please check console.error() for more details.")); } } + else if (type === 'book') { + // nothing, book doesn't have its own content + } else if (!options.tooltip && type === 'protected-session') { const $button = $(``) .on('click', protectedSessionService.enterProtectedSession); @@ -187,6 +171,29 @@ async function getRenderedContent(note, options = {}) { }; } +async function renderChildrenList($renderedContent, note) { + $renderedContent.css("padding", "10px"); + $renderedContent.addClass("text-with-ellipsis"); + + let childNoteIds = note.getChildNoteIds(); + + if (childNoteIds.length > 10) { + childNoteIds = childNoteIds.slice(0, 10); + } + + // just load the first 10 child notes + const childNotes = await froca.getNotes(childNoteIds); + + for (const childNote of childNotes) { + $renderedContent.append(await linkService.createNoteLink(`${note.noteId}/${childNote.noteId}`, { + showTooltip: false, + showNoteIcon: true + })); + + $renderedContent.append("
"); + } +} + function trim(text, doTrim) { if (!doTrim) { return text;