feat: compose message command

This commit is contained in:
SethBurkart123
2025-05-26 13:17:57 +10:00
parent 0bed8b875b
commit 2749e07a1b
3 changed files with 41 additions and 7 deletions
+18
View File
@@ -204,5 +204,23 @@ window.addEventListener("message", (event) => {
},
"*",
);
} else if (event.data.type === "triggerKeyboardEvent") {
// Handle keyboard event triggering from content script
const { key, code, altKey, ctrlKey, metaKey, shiftKey, keyCode } = event.data;
const keyboardEvent = new KeyboardEvent('keydown', {
key,
code,
keyCode: keyCode || 0,
which: keyCode || 0,
altKey: altKey || false,
ctrlKey: ctrlKey || false,
metaKey: metaKey || false,
shiftKey: shiftKey || false,
bubbles: true,
cancelable: true
});
document.dispatchEvent(keyboardEvent);
}
});
@@ -326,7 +326,7 @@
{isSelected ? 'bg-zinc-900/5 dark:bg-white/10 text-zinc-900 dark:text-white dark:ring-[1px] dark:shadow' : 'hover:bg-zinc-500/5 dark:hover:bg-white/5 text-zinc-800 dark:text-zinc-200'}"
onclick={() => executeItemAction(staticItem)}
>
<div class="flex-none w-8 h-8 text-xl font-IconFamily flex items-center justify-center bg-gradient-to-br from-[#FA5D5D] to-[#DC2F30] rounded-md text-white">{staticItem.icon}</div>
<div class="flex-none w-8 h-8 text-xl font-IconFamily flex items-center justify-center bg-gradient-to-br {staticItem.category === 'navigation' ? 'from-[#FA5D5D] to-[#DC2F30]' : 'from-[#4FBBFE] to-[#2090F3]'} rounded-md text-white">{staticItem.icon}</div>
<span class="ml-4 text-lg truncate">
<HighlightedText text={staticItem.text} term={searchTerm} matches={result.matches} />
</span>
@@ -49,14 +49,14 @@ const staticCommands: StaticCommandItem[] = [
priority: 4,
},
{
id: "assessments",
icon: "\ueac3",
id: "dashboard",
icon: "\ueb87",
category: "navigation",
text: "Assessments",
action: () => {
window.location.hash = "?page=/assessments/upcoming";
},
text: "Dashboard",
priority: 4,
action: () => {
window.location.hash = "?page=/dashboard";
},
},
{
id: "toggle-dark-mode",
@@ -67,6 +67,22 @@ const staticCommands: StaticCommandItem[] = [
priority: 2,
keywords: ["theme", "appearance"],
},
{
id: "compose-message",
icon: "\ue924",
category: "action",
text: "Compose Message",
action: () => {
window.postMessage({
type: "triggerKeyboardEvent",
key: 'm',
code: 'KeyM',
keyCode: 77,
altKey: true
}, "*");
},
priority: 4,
},
];
/**