mirror of
https://github.com/zadam/trilium.git
synced 2025-03-01 14:22:32 +01:00
add support for render excalidraw in book view (copy of note_revision)
maybe one should think about extract a function there and make it reusable
This commit is contained in:
parent
f08afd4723
commit
7f01032b6d
@ -141,6 +141,33 @@ async function getRenderedContent(note, options = {}) {
|
|||||||
|
|
||||||
$renderedContent.append($content);
|
$renderedContent.append($content);
|
||||||
}
|
}
|
||||||
|
else if (type === 'canvas-note') {
|
||||||
|
await libraryLoader.requireLibrary(libraryLoader.EXCALIDRAW_UTILS);
|
||||||
|
const {exportToSvg} = window.ExcalidrawUtils
|
||||||
|
|
||||||
|
const noteComplement = await froca.getNoteComplement(note.noteId);
|
||||||
|
const content = noteComplement.content || "";
|
||||||
|
|
||||||
|
console.log("canvas-note book", note, noteComplement, content);
|
||||||
|
|
||||||
|
try {
|
||||||
|
const data = JSON.parse(content)
|
||||||
|
const excData = {
|
||||||
|
type: "excalidraw",
|
||||||
|
version: 2,
|
||||||
|
source: "trilium",
|
||||||
|
elements: data.elements,
|
||||||
|
appState: data.appState,
|
||||||
|
files: data.files,
|
||||||
|
}
|
||||||
|
const svg = await exportToSvg(excData);
|
||||||
|
console.log("canvas-note content book", data, svg);
|
||||||
|
$renderedContent.append($('<div>').html(svg));
|
||||||
|
} catch(err) {
|
||||||
|
console.error("error parsing fullNoteRevision.content as JSON", content, err);
|
||||||
|
$renderedContent.append($("<div>").text("Error parsing content. Please check console.error() for more details."));
|
||||||
|
}
|
||||||
|
}
|
||||||
else if (!options.tooltip && type === 'protected-session') {
|
else if (!options.tooltip && type === 'protected-session') {
|
||||||
const $button = $(`<button class="btn btn-sm"><span class="bx bx-log-in"></span> Enter protected session</button>`)
|
const $button = $(`<button class="btn btn-sm"><span class="bx bx-log-in"></span> Enter protected session</button>`)
|
||||||
.on('click', protectedSessionService.enterProtectedSession);
|
.on('click', protectedSessionService.enterProtectedSession);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user