mirror of
https://github.com/zadam/trilium.git
synced 2025-11-10 23:35:50 +01:00
chore(react/type_widgets): port note map type widget
This commit is contained in:
@@ -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.
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -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) {
|
||||||
|
|||||||
@@ -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";
|
||||||
|
|||||||
13
apps/client/src/widgets/type_widgets/NoteMap.tsx
Normal file
13
apps/client/src/widgets/type_widgets/NoteMap.tsx
Normal 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>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -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();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user