From 3caaf2ab79d2fc5ab491cac161c5d99fc01c8246 Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Sat, 4 Oct 2025 18:15:44 +0300 Subject: [PATCH] chore(react/type_widgets): port note map type widget --- apps/client/src/widgets/NoteDetail.tsx | 3 +- apps/client/src/widgets/note_map/utils.ts | 2 +- apps/client/src/widgets/ribbon/NoteMapTab.tsx | 2 +- .../src/widgets/type_widgets/NoteMap.tsx | 13 ++++++++ .../src/widgets/type_widgets_old/note_map.ts | 32 ------------------- 5 files changed, 17 insertions(+), 35 deletions(-) create mode 100644 apps/client/src/widgets/type_widgets/NoteMap.tsx delete mode 100644 apps/client/src/widgets/type_widgets_old/note_map.ts diff --git a/apps/client/src/widgets/NoteDetail.tsx b/apps/client/src/widgets/NoteDetail.tsx index c81076ebb..e961e49d6 100644 --- a/apps/client/src/widgets/NoteDetail.tsx +++ b/apps/client/src/widgets/NoteDetail.tsx @@ -36,7 +36,8 @@ const TYPE_MAPPINGS: Record 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.ts index 9871c4558..d551ea235 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.tsx index 2c814012e..80a27c336 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.tsx new file mode 100644 index 000000000..55fe8dc4a --- /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(null); + + return ( +
+ +
+ ); +} diff --git a/apps/client/src/widgets/type_widgets_old/note_map.ts b/apps/client/src/widgets/type_widgets_old/note_map.ts deleted file mode 100644 index 33608aef3..000000000 --- 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*/`
`; - -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(); - } -}