feat(react/floating_buttons): port relation map buttons

This commit is contained in:
Elian Doran
2025-08-27 23:33:07 +03:00
parent 28605f2687
commit a4046fbf6e
2 changed files with 37 additions and 61 deletions

View File

@@ -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 (
<>
<ActionButton
icon="bx bx-folder-plus"
text={t("relation_map_buttons.create_child_note_title")}
onClick={() => parentComponent.triggerEvent("relationMapCreateChildNote", { ntxId: noteContext.ntxId })}
/>
<ActionButton
icon="bx bx-crop"
text={t("relation_map_buttons.reset_pan_zoom_title")}
onClick={() => parentComponent.triggerEvent("relationMapResetPanZoom", { ntxId: noteContext.ntxId })}
/>
<div className="btn-group">
<ActionButton
icon="bx bx-zoom-in"
text={t("relation_map_buttons.zoom_in_title")}
onClick={() => parentComponent.triggerEvent("relationMapResetZoomIn", { ntxId: noteContext.ntxId })}
/>
<ActionButton
icon="bx bx-zoom-out"
text={t("relation_map_buttons.zoom_out_title")}
onClick={() => parentComponent.triggerEvent("relationMapResetZoomOut", { ntxId: noteContext.ntxId })}
/>
</div>
</>
)
}
/**
* Show button that displays floating button after click on close button
*/
@@ -275,4 +311,4 @@ function ShowFloatingButton() {
/>
</div>
);
}
}