Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
dc638cb
fix: adjust padding and line-height in main styles for better layout …
0PandaDEV Mar 16, 2025
5e66974
feat: add get_app_info command with error handling and panic safety f…
0PandaDEV Mar 16, 2025
af64b77
refactor: move selectedResult logic to a new plugin for better organi…
0PandaDEV Mar 16, 2025
b946b64
feat: implement keyboard context management and shortcuts for improve…
0PandaDEV Mar 16, 2025
7ba418f
refactor: update BottomBar component to improve action handling and a…
0PandaDEV Mar 16, 2025
2865f87
feat: add ActionsMenu component for enhanced action management with s…
0PandaDEV Mar 16, 2025
fce7eec
feat: add new icon components including Bin, Board, Brush, Cube, Expa…
0PandaDEV Mar 16, 2025
843a1ea
feat: add new key icon components for Cmd, Enter, Key, and Shift to e…
0PandaDEV Mar 16, 2025
409e10a
refactor: update BottomBar component to use new Key component for key…
0PandaDEV Mar 16, 2025
b828daf
feat: implement useAppControl composable for app hiding functionality…
0PandaDEV Mar 16, 2025
ddd92a7
feat: enhance ActionsMenu component with dynamic action icons, improv…
0PandaDEV Mar 16, 2025
be1718d
feat: add new color variable for red and update SQL query in history …
0PandaDEV Mar 16, 2025
a79268d
feat: enhance ActionsMenu functionality with improved keyboard contex…
0PandaDEV Mar 16, 2025
554943d
feat: remove Cube icon component and enhance ActionsMenu with new key…
0PandaDEV Mar 16, 2025
b8238d0
feat: remove unused clipboard content update emission in setup function
0PandaDEV Mar 16, 2025
3a5e2cb
feat: refactor ActionsMenu for improved accessibility and keyboard na…
0PandaDEV Mar 16, 2025
bbd7a54
feat: add platform detection for keyboard functionality to support ma…
0PandaDEV Mar 16, 2025
8abf231
feat: enhance keybind input handling with Escape key functionality an…
0PandaDEV Mar 16, 2025
ae5103e
feat: update BottomBar component to include platform-specific key mod…
0PandaDEV Mar 16, 2025
2c4459f
Merge branch 'main' into dev/actions-menu
0PandaDEV May 27, 2025
aa928f7
chore(deps): update keyboard dependency and refactor keyboard handling
0PandaDEV May 27, 2025
97c023d
chore: system
0PandaDEV Jun 8, 2025
30d6eb6
chore(deps): update tauri and related dependencies in Cargo.toml and …
0PandaDEV Jun 8, 2025
8d3206a
chore(deps): update dependencies in package.json and add bun.lock file
0PandaDEV Jun 22, 2025
7aaa26b
chore(deps): update reqwest and tauri plugin versions in Cargo.toml a…
0PandaDEV Jun 22, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
feat: enhance ActionsMenu component with dynamic action icons, improv…
…ed keyboard shortcuts, and integrated action handling logic
  • Loading branch information
0PandaDEV committed Mar 16, 2025
commit ddd92a70e205fa00b90705b21758a9a1b304a880
136 changes: 88 additions & 48 deletions components/ActionsMenu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
@click="executeAction(action)" :class="{ selected: isSelected && currentIndex === index }" :ref="(el) => {
if (currentIndex === index) setSelectedElement(el);
}
">
" :style="action.color ? { color: action.color } : {}">
<div class="content">
<component v-if="action.icon" :is="action.icon" class="icon" />
<div class="title">{{ action.title }}</div>
Expand Down Expand Up @@ -64,8 +64,8 @@
setSelectedElement(el);
}
">
<component v-if="action.icon" :is="action.icon" class="icon" />
<div class="content">
<component v-if="action.icon" :is="action.icon" class="icon" />
<div class="title">{{ action.title }}</div>
</div>
<div v-if="action.shortcut" class="shortcut">
Expand All @@ -88,7 +88,7 @@
if (currentIndex === getActionIndex(index, 'bottom'))
setSelectedElement(el);
}
">
" :style="action.color ? { color: action.color } : {}">
<div class="content">
<component v-if="action.icon" :is="action.icon" class="icon" />
<div class="title">{{ action.title }}</div>
Expand All @@ -109,16 +109,29 @@
</template>

<script setup lang="ts">
import { ref, onMounted, onUnmounted, computed, watch, nextTick } from "vue";
import { ref, onMounted, onUnmounted, computed, watch, nextTick, h } from "vue";
import { OverlayScrollbarsComponent } from "overlayscrollbars-vue";
import "overlayscrollbars/overlayscrollbars.css";
import Enter from "./Icons/Enter.vue";
import Ctrl from "./Icons/Ctrl.vue";
import Cmd from "./Icons/Cmd.vue";
import Key from "./Icons/Key.vue";
import Enter from "./Keys/Enter.vue";
import Cmd from "./Keys/Cmd.vue";
import Key from "./Keys/Key.vue";
import { ContentType, HistoryItem } from "../types/types";
import { invoke } from "@tauri-apps/api/core";
import { useNuxtApp } from "#app";
import Shift from "./Keys/Shift.vue";
import Gear from "./Icons/Gear.vue";
import Bin from "./Icons/Bin.vue";
import Pen from "./Icons/Pen.vue";
import T from "./Icons/T.vue";
import Board from "./Icons/Board.vue";
import Cube from "./Icons/Cube.vue";
import Open from "./Icons/Open.vue";
import Globe from "./Icons/Globe.vue";
import Zip from "./Icons/Zip.vue";
import Brush from "./Icons/Brush.vue";
import Rotate from "./Icons/Rotate.vue";
import Expand from "./Icons/Expand.vue";
import { useActions } from "../composables/useActions";

interface AppInfo {
name: string;
Expand All @@ -136,6 +149,7 @@ const menuRef = ref<HTMLElement | null>(null);
const scrollbarsRef = ref<InstanceType<
typeof OverlayScrollbarsComponent
> | null>(null);
const { handleAction, isProcessing } = useActions();

const SCROLL_PADDING = 8;

Expand Down Expand Up @@ -172,136 +186,152 @@ interface ActionItem {
shortcut?: string;
icon?: any;
group: string;
color?: string;
}

const topActions = computed(() => [
const topActions = computed((): ActionItem[] => [
{
title: `Paste to ${currentAppInfo.value.name || "Current App"}`,
shortcut: "Enter",
action: "paste-to-app",
group: "top",
icon: undefined,
icon: currentAppInfo.value.icon ? {
render() {
return h('img', {
src: currentAppInfo.value.icon,
style: {
width: '14px',
height: '14px',
objectFit: 'contain'
}
});
}
} : Cube,
},
{
title: "Copy to Clipboard",
shortcut: "Ctrl+C",
action: "copy",
group: "top",
icon: undefined,
icon: Board,
},
]);

const bottomActions = computed(() => [
const bottomActions = computed((): ActionItem[] => [
{
title: "Delete Entry",
shortcut: "Del",
shortcut: "Alt+X",
action: "delete",
group: "bottom",
icon: undefined,
icon: Bin,
color: "var(--red)"
},
{
title: "Delete All Entries",
shortcut: "Alt+Shift+X",
action: "delete-all",
group: "bottom",
icon: undefined,
icon: Bin,
color: "var(--red)"
},
{
title: "Settings",
shortcut: "Ctrl+S",
action: "settings",
group: "bottom",
icon: undefined,
icon: Gear,
},
]);

const textActions = computed(() => [
const textActions = computed((): ActionItem[] => [
{
title: "Paste as plain text",
action: "paste-plain",
shortcut: "",
shortcut: "Ctrl+Shift+V",
group: "text",
icon: undefined,
icon: T,
},
{
title: "Edit text",
action: "edit-text",
shortcut: "",
shortcut: "Ctrl+E",
group: "text",
icon: undefined,
icon: Pen,
},
]);

const imageActions = computed(() => [
const imageActions = computed((): ActionItem[] => [
{
title: "Rotate",
action: "rotate-image",
shortcut: "",
shortcut: "Alt+R",
group: "image",
icon: undefined,
icon: Rotate,
},
{
title: "Resize",
action: "resize-image",
shortcut: "",
shortcut: "Alt+S",
group: "image",
icon: undefined,
icon: Expand,
},
{
title: "Compress",
action: "compress-image",
shortcut: "",
shortcut: "Alt+C",
group: "image",
icon: undefined,
icon: Zip,
},
]);

const fileActions = computed(() => [
const fileActions = computed((): ActionItem[] => [
{
title: "Open",
action: "open-file",
shortcut: "",
shortcut: "Ctrl+O",
group: "file",
icon: undefined,
icon: Open,
},
{
title: "Compress to zip/7z",
title: "Compress to zip",
action: "compress-file",
shortcut: "",
shortcut: "Alt+C",
group: "file",
icon: undefined,
icon: Zip,
},
]);

const linkActions = computed(() => [
const linkActions = computed((): ActionItem[] => [
{
title: "Open in Browser",
action: "open-link",
shortcut: "",
shortcut: "Ctrl+O",
group: "link",
icon: undefined,
icon: Globe,
},
]);

const colorActions = computed(() => [
const colorActions = computed((): ActionItem[] => [
{
title: "Copy as HEX",
action: "copy-hex",
shortcut: "",
shortcut: "Alt+H",
group: "color",
icon: undefined,
icon: Brush,
},
{
title: "Copy as RGB(a)",
action: "copy-rgba",
shortcut: "",
shortcut: "Alt+R",
group: "color",
icon: undefined,
icon: Brush,
},
{
title: "Copy as HSL(a)",
action: "copy-hsla",
shortcut: "",
shortcut: "Alt+S",
group: "color",
icon: undefined,
icon: Brush,
},
]);

Expand Down Expand Up @@ -369,10 +399,10 @@ const parseShortcut = (shortcut: string): KeyPart[] => {
const trimmedPart = part.trim();
let keyPart: KeyPart;

if (trimmedPart.toLowerCase() === "ctrl") {
keyPart = { type: "modifier", value: trimmedPart, component: Ctrl };
} else if (trimmedPart.toLowerCase() === "cmd") {
if (trimmedPart.toLowerCase() === "cmd") {
keyPart = { type: "modifier", value: trimmedPart, component: Cmd };
} else if (trimmedPart.toLowerCase() === "shift") {
keyPart = { type: "modifier", value: trimmedPart, component: Shift };
} else if (trimmedPart.toLowerCase() === "enter") {
keyPart = { type: "key", value: trimmedPart, component: Enter };
} else {
Expand All @@ -391,7 +421,7 @@ const parseShortcut = (shortcut: string): KeyPart[] => {

const executeAction = (action: ActionItem) => {
emit("close");
emit("action", action.action, props.selectedItem);
handleAction(action.action, props.selectedItem);
};

const close = () => {
Expand All @@ -404,6 +434,10 @@ const handleClickOutside = (event: MouseEvent) => {
}
};

const handleWindowBlur = () => {
close();
};

const setupKeyboardHandlers = () => {
$keyboard.on(
"actionsMenu",
Expand Down Expand Up @@ -603,11 +637,13 @@ watch(

onMounted(() => {
document.addEventListener("click", handleClickOutside);
window.addEventListener("blur", handleWindowBlur);
getAppInfo();
});

onUnmounted(() => {
document.removeEventListener("click", handleClickOutside);
window.removeEventListener("blur", handleWindowBlur);
$keyboard.disableContext("actionsMenu");
});
</script>
Expand Down Expand Up @@ -683,6 +719,10 @@ onUnmounted(() => {
width: 14px;
height: 14px;
}

.title {
color: inherit;
}
}
}

Expand Down
Loading