Skip to content

Build your personal knowledge base with Trilium Notes

feat(share): show shared spreadsheets in the app's read-only spreadsheet

Elian Doranac74f93d79a1
diff --git a/packages/trilium-core/src/share/content_renderer.spec.ts b/packages/trilium-core/src/share/content_renderer.spec.ts
index 05243e6c10..948a1d0122 100644
--- a/packages/trilium-core/src/share/content_renderer.spec.ts
+++ b/packages/trilium-core/src/share/content_renderer.spec.ts
@@ -1703,8 +1703,11 @@ describe("content_renderer pages", () => {
expect(file("zipNote", "application/zip"))
.toContain(`location.href='api/notes/zipNote/download'`);
expect(render({ type: "spreadsheet", content: "" }).isEmpty).toBe(true);
- expect(render({ type: "spreadsheet", content: "{}" }).content)
- .toBe("<p>Empty spreadsheet.</p>");
+ const spreadsheet = render({ id: "sheetNote", type: "spreadsheet", content: "{}" });
+ expect(spreadsheet.isAppView).toBe(true);
+ expect(parse(String(spreadsheet.content))
+ .querySelector(".share-note-view[data-note-id=sheetNote] > p")?.textContent)
+ .toBe("Empty spreadsheet.");
expect(render({ type: "relationMap", content: "{}" }).content)
.toBe(`<p>${t("content_renderer.note-cannot-be-displayed")}</p>`);
});
diff --git a/packages/trilium-core/src/share/content_renderer.ts b/packages/trilium-core/src/share/content_renderer.ts
index d3006153d4..ee54dc13bd 100644
--- a/packages/trilium-core/src/share/content_renderer.ts
+++ b/packages/trilium-core/src/share/content_renderer.ts
@@ -505,6 +505,7 @@ export function getContent(note: SNote | BNote, options: ShareRenderOptions = {}
renderWebView(note, result);
} else if (note.type === "spreadsheet") {
renderSpreadsheet(result);
+ hostNoteView(result, note);
} else {
result.content = `<p>${t("content_renderer.note-cannot-be-displayed")}</p>`;
}
@@ -918,11 +919,11 @@ function renderCollectionView(result: Result, note: SNote) {
/**
* Has the share theme show a shared note with the app's own widget for its type, keeping the content
- * rendered here for a visitor without scripts. The static export and binary content keep the
- * content alone.
+ * rendered here for a visitor without scripts. The static export, binary content and an empty note
+ * keep the content alone.
*/
function hostNoteView(result: Result, note: SNote | BNote) {
- if (!(note instanceof BNote) && typeof result.content === "string") {
+ if (!(note instanceof BNote) && typeof result.content === "string" && !result.isEmpty) {
hostInAppView(result, note, "share-note-view");
}
}