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(views/table): integrate reference-like for relations
Elian Doranac70908c5ae0
diff --git a/apps/client/src/services/link.ts b/apps/client/src/services/link.tsindex 116ca8a5bf..41533647c6 100644--- a/apps/client/src/services/link.ts+++ b/apps/client/src/services/link.ts@@ -384,7 +384,7 @@ function linkContextMenu(e: PointerEvent) {linkContextMenuService.openContextMenu(notePath, e, viewScope, null);}-async function loadReferenceLinkTitle($el: JQuery<HTMLElement>, href: string | null | undefined = null) {+export async function loadReferenceLinkTitle($el: JQuery<HTMLElement>, href: string | null | undefined = null) {const $link = $el[0].tagName === "A" ? $el : $el.find("a");href = href || $link.attr("href");diff --git a/apps/client/src/widgets/view_widgets/table_view/relation_editor.ts b/apps/client/src/widgets/view_widgets/table_view/relation_editor.tsindex 5b463afd16..fdc483b260 100644--- a/apps/client/src/widgets/view_widgets/table_view/relation_editor.ts+++ b/apps/client/src/widgets/view_widgets/table_view/relation_editor.ts@@ -1,5 +1,6 @@import { CellComponent } from "tabulator-tables";import note_autocomplete from "../../../services/note_autocomplete";+import { loadReferenceLinkTitle } from "../../../services/link";export function RelationEditor(cell: CellComponent, onRendered, success, cancel, editorParams){//cell - the cell component for the editable cell@@ -45,5 +46,12 @@ export function RelationFormatter(cell: CellComponent, formatterParams, onRenderreturn "";}- return `<a href="#root/${noteId}">Title goes here</a>`;+ onRendered(async () => {+ const $link = $("<a>");+ $link.addClass("reference-link");+ $link.attr("href", `#root/${noteId}`);+ await loadReferenceLinkTitle($link);+ cell.getElement().appendChild($link[0]);+ });+ return "";}