chore(react/type_widgets): port note map type widget

This commit is contained in:
Elian Doran
2025-10-04 18:15:44 +03:00
parent 8f819a7786
commit 3caaf2ab79
5 changed files with 17 additions and 35 deletions

View File

@@ -36,7 +36,8 @@ const TYPE_MAPPINGS: Record<ExtendedNoteType, () => Promise<{ default: TypeWidge
"editableText": () => import("./type_widgets/text/EditableText"), "editableText": () => import("./type_widgets/text/EditableText"),
"render": () => import("./type_widgets/Render"), "render": () => import("./type_widgets/Render"),
"canvas": () => import("./type_widgets/Canvas"), "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. // TODO: finalize the record.
}; };

View File

@@ -1,4 +1,4 @@
export type NoteMapWidgetMode = "ribbon" | "hoisted"; export type NoteMapWidgetMode = "ribbon" | "hoisted" | "type";
export type MapType = "tree" | "link"; export type MapType = "tree" | "link";
export function rgb2hex(rgb: string) { export function rgb2hex(rgb: string) {

View File

@@ -1,5 +1,5 @@
import { TabContext } from "./ribbon-interface"; import { TabContext } from "./ribbon-interface";
import { useElementSize, useLegacyWidget, useWindowSize } from "../react/hooks"; import { useElementSize, useWindowSize } from "../react/hooks";
import ActionButton from "../react/ActionButton"; import ActionButton from "../react/ActionButton";
import { t } from "../../services/i18n"; import { t } from "../../services/i18n";
import { useEffect, useRef, useState } from "preact/hooks"; import { useEffect, useRef, useState } from "preact/hooks";

View File

@@ -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>
);
}

View File

@@ -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();
}
}