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
link map section widget
zadam4b6b8b1678ed
diff --git a/src/public/app/layouts/desktop_layout.js b/src/public/app/layouts/desktop_layout.jsindex 7d67067f79..07af6c5bd5 100644--- a/src/public/app/layouts/desktop_layout.js+++ b/src/public/app/layouts/desktop_layout.js@@ -36,6 +36,7 @@ import BasicPropertiesWidget from "../widgets/type_property_widgets/basic_properimport NoteInfoWidget from "../widgets/type_property_widgets/note_info_widget.js";import BookPropertiesWidget from "../widgets/type_property_widgets/book_properties.js";import ShowNoteSourceButton from "../widgets/buttons/show_note_source.js";+import LinkMapWidget from "../widgets/type_property_widgets/link_map.js";export default class DesktopLayout {constructor(customWidgets) {@@ -111,6 +112,7 @@ export default class DesktopLayout {.section(new PromotedAttributesWidget()).section(new OwnedAttributeListWidget()).section(new InheritedAttributesWidget())+ .section(new LinkMapWidget()).section(new NoteInfoWidget()).button(new ButtonWidget().icon('bx bx-history')diff --git a/src/public/app/widgets/type_property_widgets/basic_properties.js b/src/public/app/widgets/type_property_widgets/basic_properties.jsindex 83587cc597..747969d75e 100644--- a/src/public/app/widgets/type_property_widgets/basic_properties.js+++ b/src/public/app/widgets/type_property_widgets/basic_properties.js@@ -47,7 +47,6 @@ export default class BasicPropertiesWidget extends NoteContextAwareWidget {getTitle() {return {show: this.isEnabled(),- activate: true,title: 'Basic Properties',icon: 'bx bx-slider'};diff --git a/src/public/app/widgets/type_property_widgets/link_map.js b/src/public/app/widgets/type_property_widgets/link_map.jsnew file mode 100644index 0000000000..1822ef40ee--- /dev/null+++ b/src/public/app/widgets/type_property_widgets/link_map.js@@ -0,0 +1,73 @@+import NoteContextAwareWidget from "../note_context_aware_widget.js";+import froca from "../../services/froca.js";++const TPL = `+<div class="link-map-widget">+ <div class="link-map-container" style="height: 300px;"></div>+</div>`;++let linkMapContainerIdCtr = 1;++export default class LinkMapWidget extends NoteContextAwareWidget {+ static getType() { return "link-map"; }++ isEnabled() {+ return this.note;+ }++ getTitle() {+ return {+ show: this.isEnabled(),+ title: 'Link Map',+ icon: 'bx bx-network-chart'+ };+ }++ doRender() {+ this.$widget = $(TPL);+ this.overflowing();+ }++ async refreshWithNote(note) {+ this.$widget.html(TPL);++ const $linkMapContainer = this.$widget.find('.link-map-container');+ $linkMapContainer.attr("id", "link-map-container-" + linkMapContainerIdCtr++);++ const LinkMapServiceClass = (await import('../../services/link_map.js')).default;++ this.linkMapService = new LinkMapServiceClass(note, $linkMapContainer, {+ maxDepth: 3,+ zoom: 0.6,+ stopCheckerCallback: () => this.noteId !== note.noteId // stop when current note is not what was originally requested+ });++ await this.linkMapService.render();+ }++ cleanup() {+ if (this.linkMapService) {+ this.linkMapService.cleanup();+ }+ }++ entitiesReloadedEvent({loadResults}) {+ if (loadResults.getAttributes().find(attr => attr.type === 'relation' && (attr.noteId === this.noteId || attr.value === this.noteId))) {+ this.noteSwitched();+ }++ const changedNoteIds = loadResults.getNoteIds();++ if (changedNoteIds.length > 0) {+ const $linkMapContainer = this.$widget.find('.link-map-container');++ for (const noteId of changedNoteIds) {+ const note = froca.notes[noteId];++ if (note) {+ $linkMapContainer.find(`a[data-note-path="${noteId}"]`).text(note.title);+ }+ }+ }+ }+}diff --git a/src/public/app/widgets/type_property_widgets/note_info_widget.js b/src/public/app/widgets/type_property_widgets/note_info_widget.jsindex 4b7d06c868..a234cb6311 100644--- a/src/public/app/widgets/type_property_widgets/note_info_widget.js+++ b/src/public/app/widgets/type_property_widgets/note_info_widget.js@@ -71,7 +71,6 @@ export default class NoteInfoWidget extends NoteContextAwareWidget {getTitle() {return {show: this.isEnabled(),- activate: true,title: 'Note Info',icon: 'bx bx-info-circle'};diff --git a/src/public/app/widgets/type_property_widgets/search_definition.js b/src/public/app/widgets/type_property_widgets/search_definition.jsindex aa483b9a4a..b0116e434e 100644--- a/src/public/app/widgets/type_property_widgets/search_definition.js+++ b/src/public/app/widgets/type_property_widgets/search_definition.js@@ -210,7 +210,7 @@ export default class SearchDefinitionWidget extends NoteContextAwareWidget {return {show: this.isEnabled(),activate: true,- title: 'Search',+ title: 'Search parameters',icon: 'bx bx-search'};}