diff --git a/apps/client/src/widgets/FloatingButtons.tsx b/apps/client/src/widgets/FloatingButtons.tsx index 0f36c8a49..9528ede08 100644 --- a/apps/client/src/widgets/FloatingButtons.tsx +++ b/apps/client/src/widgets/FloatingButtons.tsx @@ -77,6 +77,10 @@ const FLOATING_BUTTON_DEFINITIONS: FloatingButtonDefinition[] = [ { component: SaveToNoteButton, isEnabled: ({ note }) => note.mime === "text/x-sqlite;schema=trilium" && note.isHiddenCompletely() + }, + { + component: RelationMapButtons, + isEnabled: ({ note }) => note.type === "relationMap" } ]; @@ -262,6 +266,38 @@ function SaveToNoteButton({ note }: FloatingButtonContext) { /> } +function RelationMapButtons({ parentComponent, noteContext }: FloatingButtonContext) { + return ( + <> + parentComponent.triggerEvent("relationMapCreateChildNote", { ntxId: noteContext.ntxId })} + /> + + parentComponent.triggerEvent("relationMapResetPanZoom", { ntxId: noteContext.ntxId })} + /> + +
+ parentComponent.triggerEvent("relationMapResetZoomIn", { ntxId: noteContext.ntxId })} + /> + + parentComponent.triggerEvent("relationMapResetZoomOut", { ntxId: noteContext.ntxId })} + /> +
+ + ) +} + /** * Show button that displays floating button after click on close button */ @@ -275,4 +311,4 @@ function ShowFloatingButton() { /> ); -} \ No newline at end of file +} diff --git a/apps/client/src/widgets/floating_buttons/relation_map_buttons.ts b/apps/client/src/widgets/floating_buttons/relation_map_buttons.ts deleted file mode 100644 index 141c42e16..000000000 --- a/apps/client/src/widgets/floating_buttons/relation_map_buttons.ts +++ /dev/null @@ -1,60 +0,0 @@ -import { t } from "../../services/i18n.js"; -import NoteContextAwareWidget from "../note_context_aware_widget.js"; - -const TPL = /*html*/` -
- - - - - - -
- - - -
-
`; - -export default class RelationMapButtons extends NoteContextAwareWidget { - - private $createChildNote!: JQuery; - private $zoomInButton!: JQuery; - private $zoomOutButton!: JQuery; - private $resetPanZoomButton!: JQuery; - - isEnabled() { - return super.isEnabled() && this.note?.type === "relationMap"; - } - - doRender() { - super.doRender(); - - this.$widget = $(TPL); - this.$createChildNote = this.$widget.find(".relation-map-create-child-note"); - this.$zoomInButton = this.$widget.find(".relation-map-zoom-in"); - this.$zoomOutButton = this.$widget.find(".relation-map-zoom-out"); - this.$resetPanZoomButton = this.$widget.find(".relation-map-reset-pan-zoom"); - - // TODO: Deduplicate object creation here. - this.$createChildNote.on("click", () => this.triggerEvent("relationMapCreateChildNote", { ntxId: this.ntxId })); - this.$resetPanZoomButton.on("click", () => this.triggerEvent("relationMapResetPanZoom", { ntxId: this.ntxId })); - - this.$zoomInButton.on("click", () => this.triggerEvent("relationMapResetZoomIn", { ntxId: this.ntxId })); - this.$zoomOutButton.on("click", () => this.triggerEvent("relationMapResetZoomOut", { ntxId: this.ntxId })); - this.contentSized(); - } -}