Skip to content

AI-native knowledge base & Evernote/Obsidian alternative with instant sync & native MCP. Free on Cloudflare or self-hosted via Docker.

fix(plugins): keep panel close next to header actions

tianma-ifd9e720ac7c16
diff --git a/apps/web/src/components/plugins/PluginPanelChrome.tsx b/apps/web/src/components/plugins/PluginPanelChrome.tsx
index c2a7b36f..17c13c4e 100644
--- a/apps/web/src/components/plugins/PluginPanelChrome.tsx
+++ b/apps/web/src/components/plugins/PluginPanelChrome.tsx
@@ -80,7 +80,7 @@ export const PluginPanelHeaderActions = ({ chrome }: { chrome: PluginPanelChrome
const actions = chrome.header?.actions ?? [];
if (!actions.length) return null;
return (
- <div className="flex flex-wrap justify-end gap-2">
+ <div className="flex flex-wrap items-center justify-end gap-2">
{actions.map((action) => <ActionButton key={action.id} action={action} onAction={chrome.onAction} />)}
</div>
);
diff --git a/apps/web/src/components/plugins/PluginPanelDialog.tsx b/apps/web/src/components/plugins/PluginPanelDialog.tsx
index 352987d3..30f68a5f 100644
--- a/apps/web/src/components/plugins/PluginPanelDialog.tsx
+++ b/apps/web/src/components/plugins/PluginPanelDialog.tsx
@@ -1,9 +1,11 @@
import { useEffect, useState } from "react";
import type { PluginPanelChrome, PluginPanelCloseDecision, PluginPanelOpenOptions } from "@edgeever/plugin-api";
+import { X } from "lucide-react";
import { useTranslation } from "react-i18next";
import { AppConfirmDialog } from "@/components/dialogs/ConfirmDialogs";
import { PluginPanelEmpty, PluginPanelHeaderActions, PluginPanelToolbar } from "@/components/plugins/PluginPanelChrome";
-import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle } from "@/components/ui/dialog";
+import { Button } from "@/components/ui/button";
+import { Dialog, DialogClose, DialogContent, DialogDescription, DialogHeader, DialogTitle } from "@/components/ui/dialog";
import type { EdgeEverPluginHost, RegisteredPluginPanel } from "@/lib/plugins/plugin-host";
import { cn } from "@/lib/utils";
@@ -75,17 +77,27 @@ export const PluginPanelDialog = ({ host, panel, options, onClose }: {
return (
<>
<Dialog open={Boolean(panel)} onOpenChange={(open) => { if (!open) void requestClose(); }}>
- <DialogContent className={cn(
- panel?.presentation === "fullscreen"
- ? "flex h-[calc(100dvh-2rem)] w-[calc(100vw-2rem)] max-w-none flex-col overflow-hidden p-5"
- : "max-h-[85vh] max-w-3xl overflow-y-auto",
- )}>
- <DialogHeader className={cn(chromeEnabled && "flex flex-row items-start justify-between gap-3 space-y-0")}>
- <div className="min-w-0 space-y-1.5">
+ <DialogContent
+ showCloseButton={false}
+ className={cn(
+ panel?.presentation === "fullscreen"
+ ? "flex h-[calc(100dvh-2rem)] w-[calc(100vw-2rem)] max-w-none flex-col overflow-hidden p-5"
+ : "max-h-[85vh] max-w-3xl overflow-y-auto",
+ )}
+ >
+ <DialogHeader className="flex flex-row items-start justify-between gap-3 space-y-0">
+ <div className="min-w-0 space-y-1.5 text-left">
<DialogTitle>{title}</DialogTitle>
<DialogDescription className={hideDescription ? "sr-only" : undefined}>{description}</DialogDescription>
</div>
- {chromeEnabled ? <PluginPanelHeaderActions chrome={chrome} /> : null}
+ <div className="flex shrink-0 items-center gap-2">
+ {chromeEnabled ? <PluginPanelHeaderActions chrome={chrome} /> : null}
+ <DialogClose asChild>
+ <Button type="button" size="icon" variant="ghost" aria-label={t("common.close")}>
+ <X className="h-4 w-4" />
+ </Button>
+ </DialogClose>
+ </div>
</DialogHeader>
{chromeEnabled ? <PluginPanelToolbar chrome={chrome} /> : null}
{mountError ? <div role="alert" className="rounded-lg border border-rose-200 bg-rose-50 p-3 text-xs text-rose-700">{mountError}</div> : null}
diff --git a/apps/web/src/components/ui/dialog.tsx b/apps/web/src/components/ui/dialog.tsx
index 321a359e..cbdcaa9d 100644
--- a/apps/web/src/components/ui/dialog.tsx
+++ b/apps/web/src/components/ui/dialog.tsx
@@ -25,8 +25,8 @@ DialogOverlay.displayName = DialogPrimitive.Overlay.displayName;
const DialogContent = React.forwardRef<
React.ElementRef<typeof DialogPrimitive.Content>,
- React.ComponentPropsWithoutRef<typeof DialogPrimitive.Content>
->(({ className, children, ...props }, ref) => (
+ React.ComponentPropsWithoutRef<typeof DialogPrimitive.Content> & { showCloseButton?: boolean }
+>(({ className, children, showCloseButton = true, ...props }, ref) => (
<DialogPortal>
<DialogOverlay />
<DialogPrimitive.Content
@@ -38,10 +38,12 @@ const DialogContent = React.forwardRef<
{...props}
>
{children}
- <DialogPrimitive.Close className="absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-emerald-500 focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-slate-100 data-[state=open]:text-slate-500">
- <X className="h-4 w-4" />
- <span className="sr-only">Close</span>
- </DialogPrimitive.Close>
+ {showCloseButton ? (
+ <DialogPrimitive.Close className="absolute right-4 top-4 flex h-8 w-8 items-center justify-center rounded-md text-slate-500 transition-colors hover:bg-slate-100 hover:text-slate-900 focus:outline-none focus:ring-2 focus:ring-emerald-500 focus:ring-offset-2 disabled:pointer-events-none">
+ <X className="h-4 w-4" />
+ <span className="sr-only">Close</span>
+ </DialogPrimitive.Close>
+ ) : null}
</DialogPrimitive.Content>
</DialogPortal>
));