Skip to content

Build your personal knowledge base with Trilium Notes

Merge remote-tracking branch 'upstream/master' into excalidraw

Tom8d510a3fdde1
diff --cc src/public/app/widgets/note_detail.js
index 4c3ddd3a4b,a54fc4250f..f6de7bda50
--- a/src/public/app/widgets/note_detail.js
+++ b/src/public/app/widgets/note_detail.js
@@@ -154,7 -149,8 +154,8 @@@ export default class NoteDetailWidget e
// https://github.com/zadam/trilium/issues/2522
this.$widget.toggleClass("full-height",
!this.noteContext.hasNoteList()
- && ['editable-text', 'editable-code', 'canvas-note'].includes(this.type));
- && ['editable-text', 'editable-code'].includes(this.type)
++ && ['editable-text', 'editable-code', 'canvas-note'].includes(this.type)
+ && this.mime !== 'text/x-sqlite;schema=trilium');
}
getTypeWidget() {
diff --cc src/public/app/widgets/type_widgets/type_widget.js
index 7123b51dbe,49aa2212d7..faa1ff98a9
--- a/src/public/app/widgets/type_widgets/type_widget.js
+++ b/src/public/app/widgets/type_widgets/type_widget.js
@@@ -34,12 -35,9 +35,12 @@@ export default class TypeWidget extend
}
isActive() {
- return this.$widget.is(":visible");
+ return this.$widget.is(":visible") && this.noteContext?.ntxId === appContext.tabManager.activeNtxId;
}
+ /**
+ * FIXME: add async here to indicate promise?
+ */
getContent() {}
focus() {}
diff --cc src/share/routes.js
index b8678c0539,917e66d146..44d1cd26dd
--- a/src/share/routes.js
+++ b/src/share/routes.js
@@@ -110,32 -116,17 +116,32 @@@ function register(router)
const image = shaca.getNote(req.params.noteId);
if (!image) {
- return res.status(404).send(`Note ${noteId} not found`);
+ return res.status(404).send(`Note '${req.params.noteId}' not found`);
}
- else if (image.type !== 'image') {
- return res.status(400).send("Requested note is not an image");
+ else if (!["image", "canvas-note"].includes(image.type)) {
+ return res.status(400).send("Requested note is not a shareable image");
+ } else if (image.type === "canvas-note") {
+ /**
+ * FIXME: deduplicate the code from api/image.js
+ */
+ // render the svg in node.js using excalidraw and jsdom
+ const content = image.getContent();
+ try {
+ const data = JSON.parse(content)
+ const svg = data.svg || '<svg />'
++ addNoIndexHeader(image, res);
+ res.set('Content-Type', "image/svg+xml");
+ res.set("Cache-Control", "no-cache, no-store, must-revalidate");
+ res.send(svg);
+ } catch(err) {
+ res.status(500).send("there was an error parsing excalidraw to svg");
+ }
+ } else {
+ // normal image
+ res.set('Content-Type', image.mime);
-
++ addNoIndexHeader(image, res);
+ res.send(image.getContent());
}
-
- addNoIndexHeader(image, res);
-
- res.setHeader('Content-Type', image.mime);
--
- res.send(image.getContent());
});
// used for PDF viewing