feat(react/floating_buttons): port PNG/SVG export buttons

This commit is contained in:
Elian Doran
2025-08-28 00:02:02 +03:00
parent 0ca30e0e87
commit e72fb39c4d
3 changed files with 24 additions and 48 deletions

View File

@@ -94,6 +94,12 @@ const FLOATING_BUTTON_DEFINITIONS: FloatingButtonDefinition[] = [
isEnabled: ({ note, noteContext }) =>
["mermaid", "canvas", "mindMap"].includes(note?.type ?? "")
&& note?.isContentAvailable() && noteContext.viewScope?.viewMode === "default"
},
{
component: ExportImageButtons,
isEnabled: ({ note, noteContext }) =>
["mermaid", "mindMap"].includes(note?.type ?? "")
&& note?.isContentAvailable() && noteContext?.viewScope?.viewMode === "default"
}
];
@@ -352,6 +358,24 @@ function CopyImageReferenceButton({ note }: FloatingButtonContext) {
)
}
function ExportImageButtons({ triggerEvent }: FloatingButtonContext) {
return (
<>
<FloatingButton
icon="bx bxs-file-image"
text={t("svg_export_button.button_title")}
onClick={() => triggerEvent("exportSvg")}
/>
<FloatingButton
icon="bx bxs-file-png"
text={t("png_export_button.button_title")}
onClick={() => triggerEvent("exportPng")}
/>
</>
)
}
function FloatingButton({ className, ...props }: ActionButtonProps) {
return <ActionButton
className={`floating-button ${className ?? ""}`}