Skip to content

Build your personal knowledge base with Trilium Notes

skeleton for global link map

zadamed26e32ccba4
diff --git a/src/public/app/layouts/desktop_layout.js b/src/public/app/layouts/desktop_layout.js
index dd62fa19c2..02cba88959 100644
--- a/src/public/app/layouts/desktop_layout.js
+++ b/src/public/app/layouts/desktop_layout.js
@@ -42,6 +42,7 @@ import RightPaneContainer from "../widgets/containers/right_pane_container.js";
import EditButton from "../widgets/buttons/edit_button.js";
import CalendarMenuWidget from "../widgets/buttons/calendar_menu.js";
import EditedNotesWidget from "../widgets/ribbon_widgets/edited_notes.js";
+import OpenNoteButtonWidget from "../widgets/buttons/open_note_button_widget.js";
export default class DesktopLayout {
constructor(customWidgets) {
@@ -69,6 +70,10 @@ export default class DesktopLayout {
.icon("bx-send")
.title("Jump to note")
.command("jumpToNote"))
+ .child(new OpenNoteButtonWidget()
+ .icon("bx-map-alt")
+ .title("Global link map")
+ .targetNote('globallinkmap'))
.child(new ButtonWidget()
.icon("bx-history")
.title("Show recent changes")
diff --git a/src/public/app/services/tab_manager.js b/src/public/app/services/tab_manager.js
index 286b3955c0..0e51864ec1 100644
--- a/src/public/app/services/tab_manager.js
+++ b/src/public/app/services/tab_manager.js
@@ -227,7 +227,7 @@ export default class TabManager extends Component {
/**
* If the requested notePath is within current note hoisting scope then keep the note hoisting also for the new tab.
*/
- async openTabWithNoteWithHoisting(notePath) {
+ async openTabWithNoteWithHoisting(notePath, activate = false) {
const noteContext = this.getActiveContext();
let hoistedNoteId = 'root';
@@ -239,7 +239,7 @@ export default class TabManager extends Component {
}
}
- return this.openContextWithNote(notePath, false, null, hoistedNoteId);
+ return this.openContextWithNote(notePath, activate, null, hoistedNoteId);
}
async openContextWithNote(notePath, activate, ntxId, hoistedNoteId = 'root', mainNtxId = null) {
diff --git a/src/public/app/widgets/buttons/open_note_button_widget.js b/src/public/app/widgets/buttons/open_note_button_widget.js
new file mode 100644
index 0000000000..05f3b82444
--- /dev/null
+++ b/src/public/app/widgets/buttons/open_note_button_widget.js
@@ -0,0 +1,10 @@
+import ButtonWidget from "./button_widget.js";
+import appContext from "../../services/app_context.js";
+
+export default class OpenNoteButtonWidget extends ButtonWidget {
+ targetNote(noteId) {
+ this.onClick(() => appContext.tabManager.openTabWithNoteWithHoisting(noteId, true));
+
+ return this;
+ }
+}
diff --git a/src/public/app/widgets/note_detail.js b/src/public/app/widgets/note_detail.js
index 8027393eba..7747e049f0 100644
--- a/src/public/app/widgets/note_detail.js
+++ b/src/public/app/widgets/note_detail.js
@@ -20,6 +20,7 @@ import ReadOnlyTextTypeWidget from "./type_widgets/read_only_text.js";
import ReadOnlyCodeTypeWidget from "./type_widgets/read_only_code.js";
import NoneTypeWidget from "./type_widgets/none.js";
import attributeService from "../services/attributes.js";
+import GlobalLinkMapTypeWidget from "./type_widgets/global_link_map.js";
const TPL = `
<div class="note-detail">
@@ -45,7 +46,8 @@ const typeWidgetClasses = {
'render': RenderTypeWidget,
'relation-map': RelationMapTypeWidget,
'protected-session': ProtectedSessionTypeWidget,
- 'book': BookTypeWidget
+ 'book': BookTypeWidget,
+ 'globallinkmap': GlobalLinkMapTypeWidget
};
export default class NoteDetailWidget extends NoteContextAwareWidget {
@@ -166,6 +168,10 @@ export default class NoteDetailWidget extends NoteContextAwareWidget {
type = 'editable-code';
}
+ if (type === 'special') {
+ type = note.noteId;
+ }
+
if (note.isProtected && !protectedSessionHolder.isProtectedSessionAvailable()) {
type = 'protected-session';
}
diff --git a/src/public/app/widgets/type_widgets/file.js b/src/public/app/widgets/type_widgets/file.js
index ac4f32f779..f6d3409ae6 100644
--- a/src/public/app/widgets/type_widgets/file.js
+++ b/src/public/app/widgets/type_widgets/file.js
@@ -1,7 +1,5 @@
import openService from "../../services/open.js";
import TypeWidget from "./type_widget.js";
-import fileWatcher from "../../services/file_watcher.js";
-import server from "../../services/server.js";
const TPL = `
<div class="note-detail-file note-detail-printable">
diff --git a/src/public/app/widgets/type_widgets/global_link_map.js b/src/public/app/widgets/type_widgets/global_link_map.js
new file mode 100644
index 0000000000..6d7161b5fa
--- /dev/null
+++ b/src/public/app/widgets/type_widgets/global_link_map.js
@@ -0,0 +1,13 @@
+import TypeWidget from "./type_widget.js";
+
+const TPL = `<div class="note-detail-global-link-map note-detail-printable">WHATSUP</div>`;
+
+export default class GlobalLinkMapTypeWidget extends TypeWidget {
+ static getType() { return "globallinkmap"; }
+
+ doRender() {
+ this.$widget = $(TPL);
+
+ super.doRender();
+ }
+}
diff --git a/src/services/consistency_checks.js b/src/services/consistency_checks.js
index e534eda16a..7816e471c5 100644
--- a/src/services/consistency_checks.js
+++ b/src/services/consistency_checks.js
@@ -268,7 +268,7 @@ class ConsistencyChecks {
SELECT noteId, type
FROM notes
WHERE isDeleted = 0
- AND type NOT IN ('text', 'code', 'render', 'file', 'image', 'search', 'relation-map', 'book')`,
+ AND type NOT IN ('text', 'code', 'render', 'file', 'image', 'search', 'relation-map', 'book', 'special')`,
({noteId, type}) => {
if (this.autoFix) {
const note = becca.getNote(noteId);
diff --git a/src/services/special_notes.js b/src/services/special_notes.js
index 652c3cc231..5887539f09 100644
--- a/src/services/special_notes.js
+++ b/src/services/special_notes.js
@@ -82,13 +82,13 @@ function getSinglesNoteRoot() {
}
function getGlobalLinkMapNote() {
- let globalLinkMapNote = becca.getNote('global-link-map');
+ let globalLinkMapNote = becca.getNote('globallinkmap');
if (!globalLinkMapNote) {
globalLinkMapNote = noteService.createNewNote({
- noteId: 'global-link-map',
- title: 'global-link-map',
- type: 'global-link-map',
+ noteId: 'globallinkmap',
+ title: 'Global Link Map',
+ type: 'special',
content: '',
parentNoteId: getSinglesNoteRoot().noteId
}).note;