fix(ai-toolbar): finalize normalized clipboard test coverage
This commit is contained in:
@@ -95,10 +95,11 @@ function ShortcutsList({ os }: { os: Os }) {
|
||||
|
||||
function isEditableTarget(target: EventTarget | null): target is HTMLElement {
|
||||
const element = target as HTMLElement | null;
|
||||
return !!element && (
|
||||
element.tagName === "TEXTAREA" ||
|
||||
element.tagName === "INPUT" ||
|
||||
element.isContentEditable
|
||||
return (
|
||||
!!element &&
|
||||
(element.tagName === "TEXTAREA" ||
|
||||
element.tagName === "INPUT" ||
|
||||
element.isContentEditable)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -187,8 +188,7 @@ export const AIToolbar = ({
|
||||
// focused element or OS clipboard model (X11/Wayland).
|
||||
// This is the approach used by Excalidraw's actionPaste.
|
||||
useEffect(() => {
|
||||
if (!(isAuthenticated && !isPending && canUseAi && !aiLoading))
|
||||
return;
|
||||
if (!(isAuthenticated && !isPending && canUseAi && !aiLoading)) return;
|
||||
|
||||
// ── Handler 1: paste event (works when textarea is NOT focused) ───────
|
||||
const handleDocumentPaste = (e: ClipboardEvent) => {
|
||||
@@ -281,7 +281,7 @@ export const AIToolbar = ({
|
||||
document.removeEventListener("paste", handlePasteHandled, {
|
||||
capture: true,
|
||||
});
|
||||
document.removeEventListener("keydown", handleDocumentKeydown);
|
||||
document.removeEventListener("keydown", handleDocumentKeydown);
|
||||
};
|
||||
}, [isAuthenticated, isPending, canUseAi, aiLoading]); // onImagesSelect intentionally omitted — ref stays current
|
||||
|
||||
|
||||
Reference in New Issue
Block a user