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
chore(react/type_widgets): port note map type widget
Elian Doran3caaf2ab79d2
diff --git a/apps/client/src/widgets/NoteDetail.tsx b/apps/client/src/widgets/NoteDetail.tsxindex c81076ebb5..e961e49d65 100644--- a/apps/client/src/widgets/NoteDetail.tsx+++ b/apps/client/src/widgets/NoteDetail.tsx@@ -36,7 +36,8 @@ const TYPE_MAPPINGS: Record<ExtendedNoteType, () => Promise<{ default: TypeWidge"editableText": () => import("./type_widgets/text/EditableText"),"render": () => import("./type_widgets/Render"),"canvas": () => import("./type_widgets/Canvas"),- "relationMap": () => import("./type_widgets/relation_map/RelationMap")+ "relationMap": () => import("./type_widgets/relation_map/RelationMap"),+ "noteMap": () => import("./type_widgets/NoteMap")// TODO: finalize the record.};diff --git a/apps/client/src/widgets/note_map/utils.ts b/apps/client/src/widgets/note_map/utils.tsindex 9871c45588..d551ea235b 100644--- a/apps/client/src/widgets/note_map/utils.ts+++ b/apps/client/src/widgets/note_map/utils.ts@@ -1,4 +1,4 @@-export type NoteMapWidgetMode = "ribbon" | "hoisted";+export type NoteMapWidgetMode = "ribbon" | "hoisted" | "type";export type MapType = "tree" | "link";export function rgb2hex(rgb: string) {diff --git a/apps/client/src/widgets/ribbon/NoteMapTab.tsx b/apps/client/src/widgets/ribbon/NoteMapTab.tsxindex 2c814012ea..80a27c3368 100644--- a/apps/client/src/widgets/ribbon/NoteMapTab.tsx+++ b/apps/client/src/widgets/ribbon/NoteMapTab.tsx@@ -1,5 +1,5 @@import { TabContext } from "./ribbon-interface";-import { useElementSize, useLegacyWidget, useWindowSize } from "../react/hooks";+import { useElementSize, useWindowSize } from "../react/hooks";import ActionButton from "../react/ActionButton";import { t } from "../../services/i18n";import { useEffect, useRef, useState } from "preact/hooks";diff --git a/apps/client/src/widgets/type_widgets/NoteMap.tsx b/apps/client/src/widgets/type_widgets/NoteMap.tsxnew file mode 100644index 0000000000..55fe8dc4aa--- /dev/null+++ b/apps/client/src/widgets/type_widgets/NoteMap.tsx@@ -0,0 +1,13 @@+import { TypeWidgetProps } from "./type_widget";+import NoteMapEl from "../note_map/NoteMap";+import { useRef } from "preact/hooks";++export default function NoteMap({ note }: TypeWidgetProps) {+ const containerRef = useRef<HTMLDivElement>(null);++ return (+ <div ref={containerRef} className="note-detail-note-map note-detail-printable">+ <NoteMapEl parentRef={containerRef} note={note} widgetMode="type" />+ </div>+ );+}diff --git a/apps/client/src/widgets/type_widgets_old/note_map.ts b/apps/client/src/widgets/type_widgets_old/note_map.tsdeleted file mode 100644index 33608aef35..0000000000--- a/apps/client/src/widgets/type_widgets_old/note_map.ts+++ /dev/null@@ -1,32 +0,0 @@-import TypeWidget from "./type_widget.js";-import NoteMapWidget from "../note_map.js";-import type FNote from "../../entities/fnote.js";--const TPL = /*html*/`<div class="note-detail-note-map note-detail-printable"></div>`;--export default class NoteMapTypeWidget extends TypeWidget {-- private noteMapWidget: NoteMapWidget;-- static getType() {- return "noteMap";- }-- constructor() {- super();-- this.noteMapWidget = new NoteMapWidget("type");- this.child(this.noteMapWidget);- }-- doRender() {- this.$widget = $(TPL);- this.$widget.append(this.noteMapWidget.render());-- super.doRender();- }-- async doRefresh(note: FNote) {- await this.noteMapWidget.refresh();- }-}