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
client: Create blank type widget for mind map
Elian Dorane39dd1525da4
diff --git a/src/public/app/entities/fnote.js b/src/public/app/entities/fnote.jsindex 46befda8ed..60acdbf29a 100644--- a/src/public/app/entities/fnote.js+++ b/src/public/app/entities/fnote.js@@ -22,7 +22,8 @@ const NOTE_TYPE_ICONS = {"webView": "bx bx-globe-alt","launcher": "bx bx-link","doc": "bx bxs-file-doc",- "contentWidget": "bx bxs-widget"+ "contentWidget": "bx bxs-widget",+ "mindMap": "bx bx-sitemap"};/**diff --git a/src/public/app/services/note_types.js b/src/public/app/services/note_types.jsindex 40bc4a88b8..73314245d2 100644--- a/src/public/app/services/note_types.js+++ b/src/public/app/services/note_types.js@@ -13,6 +13,7 @@ async function getNoteTypeItems(command) {{ title: "Mermaid Diagram", command: command, type: "mermaid", uiIcon: "bx bx-selection" },{ title: "Canvas", command: command, type: "canvas", uiIcon: "bx bx-pen" },{ title: "Web View", command: command, type: "webView", uiIcon: "bx bx-globe-alt" },+ { title: "Mind Map", command, type: "mindMap", uiIcon: "bx bx-sitemap" }];const templateNoteIds = await server.get("search-templates");diff --git a/src/public/app/widgets/note_detail.js b/src/public/app/widgets/note_detail.jsindex ea081cd1e2..5b029fa146 100644--- a/src/public/app/widgets/note_detail.js+++ b/src/public/app/widgets/note_detail.js@@ -28,6 +28,7 @@ import DocTypeWidget from "./type_widgets/doc.js";import ContentWidgetTypeWidget from "./type_widgets/content_widget.js";import AttachmentListTypeWidget from "./type_widgets/attachment_list.js";import AttachmentDetailTypeWidget from "./type_widgets/attachment_detail.js";+import MindMapWidget from "./type_widgets/mind_map.js";const TPL = `<div class="note-detail">@@ -63,7 +64,8 @@ const typeWidgetClasses = {'doc': DocTypeWidget,'contentWidget': ContentWidgetTypeWidget,'attachmentDetail': AttachmentDetailTypeWidget,- 'attachmentList': AttachmentListTypeWidget+ 'attachmentList': AttachmentListTypeWidget,+ 'mindMap': MindMapWidget};export default class NoteDetailWidget extends NoteContextAwareWidget {diff --git a/src/public/app/widgets/type_widgets/mind_map.js b/src/public/app/widgets/type_widgets/mind_map.jsnew file mode 100644index 0000000000..1121a8f081--- /dev/null+++ b/src/public/app/widgets/type_widgets/mind_map.js@@ -0,0 +1,31 @@+import TypeWidget from "./type_widget.js";++const TPL = `+<div class="note-detail-mind-map note-detail-printable">+</div>+`;++export default class MindMapWidget extends TypeWidget {+ static getType() { return "mindMap"; }++ doRender() {+ this.$widget = $(TPL);++ super.doRender();+ }++ async doRefresh(note) {+ this.$widget.html("<p>Hello</p>");+ this.$widget.show();+ }++ cleanup() {+ this.$widget.empty();+ }++ async entitiesReloadedEvent({loadResults}) {+ if (loadResults.isNoteReloaded(this.noteId)) {+ this.refresh();+ }+ }+}\ No newline at end of filediff --git a/src/services/note_types.ts b/src/services/note_types.tsindex 3828241bd5..62121b12cb 100644--- a/src/services/note_types.ts+++ b/src/services/note_types.ts@@ -13,7 +13,8 @@ const noteTypes = [{ type: 'webView', defaultMime: '' },{ type: 'launcher', defaultMime: '' },{ type: 'doc', defaultMime: '' },- { type: 'contentWidget', defaultMime: '' }+ { type: 'contentWidget', defaultMime: '' },+ { type: 'mindMap', defaultMime: 'application/json' }];function getDefaultMimeForNoteType(typeName: string) {