Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
feat(share): show shared boards with the app's board
Elian Doran865cb18a5065
diff --git a/apps/client/src/widgets/collections/board/api.ts b/apps/client/src/widgets/collections/board/api.tsindex 7a79efeeba..e5d3763c38 100644--- a/apps/client/src/widgets/collections/board/api.ts+++ b/apps/client/src/widgets/collections/board/api.ts@@ -145,6 +145,8 @@ export default class BoardApi {* one split of several, and the focused one is often the pane the reader came from.*/noteContext: NoteContext | null | undefined;+ /** Opens a note where the board's host shows notes, in place of the quick edit popup. */+ onOpenNote: ((noteId: string) => void) | undefined;/*** Stands in for the stored collapse flags while a filter is on, set by the board on every@@ -1452,8 +1454,12 @@ export default class BoardApi {return { note, branch };}- openNote(noteId: string) {- appContext.triggerCommand("openInPopup", { noteIdOrPath: noteId });+ openNote(noteIdOrPath: string) {+ if (this.onOpenNote) {+ this.onOpenNote(noteIdOrPath.split("/").at(-1) ?? noteIdOrPath);+ return;+ }+ appContext.triggerCommand("openInPopup", { noteIdOrPath });}/**@@ -1466,6 +1472,10 @@ export default class BoardApi {openCard(note: FNote) {const target = note.getRelationValue(CARD_REDIRECT_RELATION)?? note.getRelationValue(CARD_REDIRECT_RELATION_LEGACY);+ if (target && this.onOpenNote) {+ this.onOpenNote(target);+ return;+ }if (target) {const context = this.noteContext ?? appContext.tabManager?.getActiveContext();void context?.setNote(target);diff --git a/apps/client/src/widgets/collections/board/index.tsx b/apps/client/src/widgets/collections/board/index.tsxindex 9ab4bdf6ac..24a503acd4 100644--- a/apps/client/src/widgets/collections/board/index.tsx+++ b/apps/client/src/widgets/collections/board/index.tsx@@ -360,7 +360,7 @@ const BOARD_HINTS: ShortcutHintDefinition = [];export default function BoardView({- note: parentNote, noteIds, viewConfig: storedConfig, saveConfig+ note: parentNote, noteIds, viewConfig: storedConfig, saveConfig, onOpenNote}: ViewModeProps<BoardViewData>) {const { noteContext } = useNoteContext();const [ requestedGroupBy, setRequestedGroupBy ] =@@ -604,6 +604,7 @@ export default function BoardView({// Set here rather than passed in: the api outlives a refresh, and the board can be drawn in a// pane other than the focused one.api.noteContext = noteContext;+ api.onOpenNote = onOpenNote;// Every member is one of useState's own setters, so this value is built once and never changes// identity -- a drag cannot reach anything that reads only this.const collapseAllColumns = useCallback(() => {diff --git a/packages/trilium-core/src/share/content_renderer.ts b/packages/trilium-core/src/share/content_renderer.tsindex 7575f0bf88..b91fedc86b 100644--- a/packages/trilium-core/src/share/content_renderer.ts+++ b/packages/trilium-core/src/share/content_renderer.ts@@ -964,7 +964,7 @@ function hostInAppView(result: Result, note: SNote, container: string) {}/** The view types of the collections the share theme shows with the app's own view. */-const HOSTED_VIEW_TYPES = new Set([ "calendar", "geoMap" ]);+const HOSTED_VIEW_TYPES = new Set([ "board", "calendar", "geoMap" ]);/*** The options the app's views read to draw a note as the app does, which a shared page receives. Only