From e39dd1525da44580ece68197c65cd0848457c733 Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Sun, 1 Sep 2024 14:16:45 +0300 Subject: [PATCH] client: Create blank type widget for mind map --- src/public/app/entities/fnote.js | 3 +- src/public/app/services/note_types.js | 1 + src/public/app/widgets/note_detail.js | 4 ++- .../app/widgets/type_widgets/mind_map.js | 31 +++++++++++++++++++ src/services/note_types.ts | 3 +- 5 files changed, 39 insertions(+), 3 deletions(-) create mode 100644 src/public/app/widgets/type_widgets/mind_map.js diff --git a/src/public/app/entities/fnote.js b/src/public/app/entities/fnote.js index 46befda8e..60acdbf29 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.js index 40bc4a88b..73314245d 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.js index ea081cd1e..5b029fa14 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 = `
@@ -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.js new file mode 100644 index 000000000..1121a8f08 --- /dev/null +++ b/src/public/app/widgets/type_widgets/mind_map.js @@ -0,0 +1,31 @@ +import TypeWidget from "./type_widget.js"; + +const TPL = ` +
+
+`; + +export default class MindMapWidget extends TypeWidget { + static getType() { return "mindMap"; } + + doRender() { + this.$widget = $(TPL); + + super.doRender(); + } + + async doRefresh(note) { + this.$widget.html("

Hello

"); + this.$widget.show(); + } + + cleanup() { + this.$widget.empty(); + } + + async entitiesReloadedEvent({loadResults}) { + if (loadResults.isNoteReloaded(this.noteId)) { + this.refresh(); + } + } +} \ No newline at end of file diff --git a/src/services/note_types.ts b/src/services/note_types.ts index 3828241bd..62121b12c 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) {