Skip to content

Build your personal knowledge base with Trilium Notes

feat(share): show a shared mind map note in the pan and zoom viewer

Elian Dorand954bb5346a9
diff --git a/packages/share-theme/src/content/note_view.tsx b/packages/share-theme/src/content/note_view.tsx
index ef26c1dea2..ec14467b4a 100644
--- a/packages/share-theme/src/content/note_view.tsx
+++ b/packages/share-theme/src/content/note_view.tsx
@@ -12,8 +12,8 @@ import { ZoomViewer } from "./zoom_viewer.js";
/**
* Mounts the note in place of the content the page rendered for visitors without scripts: an
- * image, a canvas or a Mermaid note's diagram in a viewer that pans and zooms it, any other note
- * with the app's own widget for its type, read-only.
+ * image, a canvas, a mind map or a Mermaid note's diagram in a viewer that pans and zooms it, any
+ * other note with the app's own widget for its type, read-only.
*/
export default function mountNoteView(container: HTMLElement, payload: AppPayload) {
container.replaceChildren();
@@ -29,6 +29,7 @@ function SharedNoteView({ note }: { note: FNote }) {
switch (note.type) {
case "image":
case "canvas":
+ case "mindMap":
return <ImageView note={note} />;
case "mermaid":
return <MermaidView note={note} />;
@@ -63,8 +64,8 @@ function NoteView({ note }: { note: FNote }) {
}
/**
- * Shows the image the share serves for an image note, or the SVG a canvas note keeps of its
- * drawing, in a viewer that takes the page.
+ * Shows the image the share serves for an image note, or the SVG a canvas or a mind map note keeps
+ * of its drawing, in a viewer that takes the page.
*/
function ImageView({ note }: { note: FNote }) {
const src = `api/images/${note.noteId}/${encodeURIComponent(note.title)}?${note.blobId}`;
diff --git a/packages/trilium-core/src/share/content_renderer.spec.ts b/packages/trilium-core/src/share/content_renderer.spec.ts
index b411a55883..bef1192e1e 100644
--- a/packages/trilium-core/src/share/content_renderer.spec.ts
+++ b/packages/trilium-core/src/share/content_renderer.spec.ts
@@ -1693,9 +1693,7 @@ describe("content_renderer pages", () => {
expect(auto.classList.contains("hljs")).toBe(false);
expect(render({ type: "code", mime: "text/x-markdown", content: " " }).isEmpty).toBe(true);
- expect(render({ id: "mindMapNote", type: "mindMap", title: "A picture", content: "" }).content)
- .toMatch(/^<img src="api\/images\/mindMapNote\/A%20picture\?/);
- for (const type of [ "image", "canvas" ]) {
+ for (const type of [ "image", "canvas", "mindMap" ]) {
const image = render({ id: `${type}Note`, type, title: "A picture", content: "" });
expect(image.isAppView).toBe(true);
expect(parse(String(image.content))
diff --git a/packages/trilium-core/src/share/content_renderer.ts b/packages/trilium-core/src/share/content_renderer.ts
index c96ea2325c..b8bdfc71dd 100644
--- a/packages/trilium-core/src/share/content_renderer.ts
+++ b/packages/trilium-core/src/share/content_renderer.ts
@@ -494,11 +494,9 @@ export function getContent(note: SNote | BNote, options: ShareRenderOptions = {}
} else if (note.type === "mermaid") {
renderMermaid(result, note);
hostNoteView(result, note);
- } else if (note.type === "image" || note.type === "canvas") {
+ } else if ([ "image", "canvas", "mindMap" ].includes(note.type)) {
renderImage(result, note);
hostNoteView(result, note);
- } else if (note.type === "mindMap") {
- renderImage(result, note);
} else if (note.type === "file") {
renderFile(note, result);
} else if (note.type === "book" && !(note instanceof BNote)