Feat: make possible to change all nodes shortcuts

This commit is contained in:
igorrCarvalho 2024-05-06 19:03:01 -03:00
commit 60dba48703
5 changed files with 23 additions and 22 deletions

View file

@ -886,4 +886,5 @@ export const unavailableShortcutss = [
"CTRL + Z",
"CTRL + Y",
"CTRL + J",
"CTRL + U",
];

View file

@ -153,16 +153,19 @@ export default function NodeToolbarComponent({
const save = useShortcutsStore((state) => state.save);
const docs = useShortcutsStore((state) => state.docs);
const code = useShortcutsStore((state) => state.code);
const group = useShortcutsStore((state) => state.group);
const update = useShortcutsStore((state) => state.update);
const download = useShortcutsStore((state) => state.download);
useHotkeys(minimize, handleMinimizeWShortcut);
useHotkeys("mod+u", handleUpdateWShortcut);
useHotkeys("mod+g", handleGroupWShortcut);
useHotkeys(update, handleUpdateWShortcut);
useHotkeys(group, handleGroupWShortcut);
useHotkeys(share, handleShareWShortcut);
useHotkeys(code, handleCodeWShortcut);
useHotkeys(advanced, handleAdvancedWShortcut);
useHotkeys(save, handleSaveWShortcut);
useHotkeys(docs, handleDocsWShortcut);
useHotkeys("mod+j", handleDownloadWShortcut);
useHotkeys(download, handleDownloadWShortcut);
useHotkeys("space", handleCodeWShortcut);
const isMinimal = numberOfHandles <= 1;
@ -612,24 +615,15 @@ export default function NodeToolbarComponent({
)}
{isGroup && (
<SelectItem value="ungroup">
<div className="flex">
<IconComponent
name="Ungroup"
className="relative top-0.5 mr-2 h-4 w-4 "
/>{" "}
<span className="">Ungroup</span>{" "}
{navigator.userAgent.toUpperCase().includes("MAC") ? (
<IconComponent
name="Command"
className="absolute right-[1.15rem] top-[0.65em] h-3.5 w-3.5 stroke-2"
></IconComponent>
) : (
<span className="absolute right-[1.30rem] top-[0.40em] stroke-2">
Ctrl +{" "}
</span>
)}
<span className="absolute right-2 top-[0.43em]">G</span>
</div>
<ToolbarSelectItem
shortcut={
shortcuts.find((obj) => obj.name === "Group")?.shortcut!
}
isMac={navigator.userAgent.toUpperCase().includes("MAC")}
value={"Ungroup"}
icon={"Ungroup"}
dataTestId="group-button-modal"
/>
</SelectItem>
)}

View file

@ -25,11 +25,13 @@ export default function ShortcutsPage() {
headerCheckboxSelection: true,
checkboxSelection: true,
showDisabledCheckboxes: true,
resizable: false,
}, //This column will be twice as wide as the others
{
field: "shortcut",
flex: 2,
editable: false,
resizable: false,
},
]);

View file

@ -27,6 +27,8 @@ export const useShortcutsStore = create<shortcutsStoreType>((set, get) => ({
cut: "mod+x",
paste: "mod+v",
api: "mod+r",
update: "mod+u",
download: "mod+j",
updateUniqueShortcut: (name, combination) => {
set({
[name]: combination,

View file

@ -37,6 +37,8 @@ export type shortcutsStoreType = {
docs: string;
save: string;
delete: string;
update: string;
download: string;
shortcuts: Array<{
name: string;
shortcut: string;
@ -44,6 +46,6 @@ export type shortcutsStoreType = {
unavailableShortcuts: string[];
setShortcuts: (
newShortcuts: Array<{ name: string; shortcut: string }>,
unavailable: string[]
unavailable: string[],
) => void;
};