mirror of
https://github.com/TriliumNext/Trilium.git
synced 2025-12-10 03:53:37 -06:00
refactor(react/type_widgets): use dedicated component for items
This commit is contained in:
parent
3b2f5bb09d
commit
4af842d2f2
@ -17,7 +17,7 @@ import contextMenu from "../../../menus/context_menu";
|
||||
import appContext from "../../../components/app_context";
|
||||
import RelationMapApi, { MapData, MapDataNoteEntry } from "./api";
|
||||
import setupOverlays, { uniDirectionalOverlays } from "./overlays";
|
||||
import { JsPlumb } from "./jsplumb";
|
||||
import { JsPlumb, JsPlumbItem } from "./jsplumb";
|
||||
|
||||
interface Clipboard {
|
||||
noteId: string;
|
||||
@ -359,18 +359,14 @@ function NoteBox({ noteId, x, y, mapApiRef }: MapDataNoteEntry & { mapApiRef: Re
|
||||
}, [ note ]);
|
||||
|
||||
return note && (
|
||||
<div
|
||||
id={noteIdToId(noteId)}
|
||||
<JsPlumbItem
|
||||
className={`note-box ${note?.getCssClass()}`}
|
||||
onContextMenu={contextMenuHandler}
|
||||
style={{
|
||||
left: x,
|
||||
top: y
|
||||
}}
|
||||
x={x} y={y}
|
||||
>
|
||||
<NoteLink className="title" title={title} notePath={noteId} noTnLink noContextMenu />
|
||||
<div className="endpoint" title={t("relation_map.start_dragging_relations")} />
|
||||
</div>
|
||||
</JsPlumbItem>
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
import { jsPlumb, Defaults, jsPlumbInstance } from "jsplumb";
|
||||
import { ComponentChildren, RefObject } from "preact";
|
||||
import { HTMLProps } from "preact/compat";
|
||||
import { useEffect, useRef } from "preact/hooks";
|
||||
|
||||
export function JsPlumb({ className, props, children, containerRef: externalContainerRef, apiRef, onInstanceCreated }: {
|
||||
@ -39,3 +40,18 @@ export function JsPlumb({ className, props, children, containerRef: externalCont
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export function JsPlumbItem({ x, y, children, ...restProps }: {
|
||||
x: number;
|
||||
y: number;
|
||||
children: ComponentChildren;
|
||||
} & Pick<HTMLProps<HTMLDivElement>, "className" | "onContextMenu">) {
|
||||
return (
|
||||
<div
|
||||
{...restProps}
|
||||
style={{ left: x, top: y }}
|
||||
>
|
||||
{children}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user