Fixed Code shortcut
This commit is contained in:
parent
1b3d62c5ca
commit
dc5eebedfb
3 changed files with 32 additions and 40 deletions
|
|
@ -1,5 +1,6 @@
|
||||||
import _, { cloneDeep } from "lodash";
|
import _, { cloneDeep } from "lodash";
|
||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
|
import { useHotkeys } from "react-hotkeys-hook";
|
||||||
import { useUpdateNodeInternals } from "reactflow";
|
import { useUpdateNodeInternals } from "reactflow";
|
||||||
import ShadTooltip from "../../../../components/ShadTooltipComponent";
|
import ShadTooltip from "../../../../components/ShadTooltipComponent";
|
||||||
import CodeAreaComponent from "../../../../components/codeAreaComponent";
|
import CodeAreaComponent from "../../../../components/codeAreaComponent";
|
||||||
|
|
@ -31,7 +32,6 @@ import {
|
||||||
} from "../../../../utils/reactflowUtils";
|
} from "../../../../utils/reactflowUtils";
|
||||||
import { classNames } from "../../../../utils/utils";
|
import { classNames } from "../../../../utils/utils";
|
||||||
import ToolbarSelectItem from "./toolbarSelectItem";
|
import ToolbarSelectItem from "./toolbarSelectItem";
|
||||||
import { useHotkeys } from "react-hotkeys-hook";
|
|
||||||
|
|
||||||
export default function NodeToolbarComponent({
|
export default function NodeToolbarComponent({
|
||||||
data,
|
data,
|
||||||
|
|
@ -69,7 +69,7 @@ export default function NodeToolbarComponent({
|
||||||
const validApiKey = useStoreStore((state) => state.validApiKey);
|
const validApiKey = useStoreStore((state) => state.validApiKey);
|
||||||
|
|
||||||
function handleMinimizeWShortcut(e: KeyboardEvent) {
|
function handleMinimizeWShortcut(e: KeyboardEvent) {
|
||||||
e.preventDefault()
|
e.preventDefault();
|
||||||
if (isMinimal) {
|
if (isMinimal) {
|
||||||
setShowState((show) => !show);
|
setShowState((show) => !show);
|
||||||
setShowNode(data.showNode ?? true ? false : true);
|
setShowNode(data.showNode ?? true ? false : true);
|
||||||
|
|
@ -83,14 +83,14 @@ export default function NodeToolbarComponent({
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleUpdateWShortcut(e: KeyboardEvent) {
|
function handleUpdateWShortcut(e: KeyboardEvent) {
|
||||||
e.preventDefault()
|
e.preventDefault();
|
||||||
if ((hasApiKey || hasStore)) {
|
if (hasApiKey || hasStore) {
|
||||||
handleSelectChange("update");
|
handleSelectChange("update");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleGroupWShortcut(e: KeyboardEvent) {
|
function handleGroupWShortcut(e: KeyboardEvent) {
|
||||||
e.preventDefault()
|
e.preventDefault();
|
||||||
if (isGroup) {
|
if (isGroup) {
|
||||||
handleSelectChange("ungroup");
|
handleSelectChange("ungroup");
|
||||||
}
|
}
|
||||||
|
|
@ -98,26 +98,26 @@ export default function NodeToolbarComponent({
|
||||||
|
|
||||||
function handleShareWShortcut(e: KeyboardEvent) {
|
function handleShareWShortcut(e: KeyboardEvent) {
|
||||||
if (hasApiKey || hasStore) {
|
if (hasApiKey || hasStore) {
|
||||||
e.preventDefault()
|
e.preventDefault();
|
||||||
setShowconfirmShare((state) => !state);
|
setShowconfirmShare((state) => !state);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleCodeWShortcut(e: KeyboardEvent) {
|
function handleCodeWShortcut(e: KeyboardEvent) {
|
||||||
e.preventDefault()
|
e.preventDefault();
|
||||||
if (hasCode) return setOpenModal((state) => !state);
|
if (hasCode) return setOpenModal((state) => !state);
|
||||||
setNoticeData({ title: `You can not access ${data.id} code` });
|
setNoticeData({ title: `You can not access ${data.id} code` });
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleAdvancedWShortcut(e: KeyboardEvent) {
|
function handleAdvancedWShortcut(e: KeyboardEvent) {
|
||||||
e.preventDefault()
|
e.preventDefault();
|
||||||
if (!isGroup) {
|
if (!isGroup) {
|
||||||
setShowModalAdvanced((state) => !state);
|
setShowModalAdvanced((state) => !state);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleSaveWShortcut(e: KeyboardEvent) {
|
function handleSaveWShortcut(e: KeyboardEvent) {
|
||||||
e.preventDefault()
|
e.preventDefault();
|
||||||
if (isSaved) {
|
if (isSaved) {
|
||||||
setShowOverrideModal((state) => !state);
|
setShowOverrideModal((state) => !state);
|
||||||
return;
|
return;
|
||||||
|
|
@ -153,7 +153,7 @@ export default function NodeToolbarComponent({
|
||||||
useHotkeys("mod+s", handleSaveWShortcut);
|
useHotkeys("mod+s", handleSaveWShortcut);
|
||||||
useHotkeys("mod+shift+d", handleDocsWShortcut);
|
useHotkeys("mod+shift+d", handleDocsWShortcut);
|
||||||
useHotkeys("mod+j", handleDownloadWShortcut);
|
useHotkeys("mod+j", handleDownloadWShortcut);
|
||||||
useHotkeys("space", handleCodeWShortcut)
|
useHotkeys("space", handleCodeWShortcut);
|
||||||
|
|
||||||
const isMinimal = numberOfHandles <= 1;
|
const isMinimal = numberOfHandles <= 1;
|
||||||
const isGroup = data.node?.flow ? true : false;
|
const isGroup = data.node?.flow ? true : false;
|
||||||
|
|
@ -165,7 +165,6 @@ export default function NodeToolbarComponent({
|
||||||
const setNodes = useFlowStore((state) => state.setNodes);
|
const setNodes = useFlowStore((state) => state.setNodes);
|
||||||
|
|
||||||
const setEdges = useFlowStore((state) => state.setEdges);
|
const setEdges = useFlowStore((state) => state.setEdges);
|
||||||
const unselectAll = useFlowStore((state) => state.unselectAll);
|
|
||||||
const saveComponent = useFlowsManagerStore((state) => state.saveComponent);
|
const saveComponent = useFlowsManagerStore((state) => state.saveComponent);
|
||||||
const getNodePosition = useFlowStore((state) => state.getNodePosition);
|
const getNodePosition = useFlowStore((state) => state.getNodePosition);
|
||||||
const flows = useFlowsManagerStore((state) => state.flows);
|
const flows = useFlowsManagerStore((state) => state.flows);
|
||||||
|
|
@ -179,10 +178,9 @@ export default function NodeToolbarComponent({
|
||||||
);
|
);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (openWDoubleClick) setShowModalAdvanced(true)
|
if (openWDoubleClick) setShowModalAdvanced(true);
|
||||||
}, [openWDoubleClick, setOpenWDoubleClick]);
|
}, [openWDoubleClick, setOpenWDoubleClick]);
|
||||||
|
|
||||||
|
|
||||||
const openInNewTab = (url) => {
|
const openInNewTab = (url) => {
|
||||||
window.open(url, "_blank", "noreferrer");
|
window.open(url, "_blank", "noreferrer");
|
||||||
};
|
};
|
||||||
|
|
@ -473,9 +471,10 @@ export default function NodeToolbarComponent({
|
||||||
{hasCode && (
|
{hasCode && (
|
||||||
<SelectItem value={"code"}>
|
<SelectItem value={"code"}>
|
||||||
<ToolbarSelectItem
|
<ToolbarSelectItem
|
||||||
keyboardKey="U"
|
keyboardKey="Space"
|
||||||
isMac={navigator.userAgent.toUpperCase().includes("MAC")}
|
isMac={navigator.userAgent.toUpperCase().includes("MAC")}
|
||||||
shift={false}
|
shift={false}
|
||||||
|
mod={false}
|
||||||
value={"Code"}
|
value={"Code"}
|
||||||
icon={"Code"}
|
icon={"Code"}
|
||||||
dataTestId="code-button-modal"
|
dataTestId="code-button-modal"
|
||||||
|
|
@ -514,16 +513,6 @@ export default function NodeToolbarComponent({
|
||||||
dataTestId="duplicate-button-modal"
|
dataTestId="duplicate-button-modal"
|
||||||
/>
|
/>
|
||||||
</SelectItem>
|
</SelectItem>
|
||||||
{/* <SelectItem value={"duplicate"}>
|
|
||||||
<ToolbarSelectItem
|
|
||||||
keyboardKey="D"
|
|
||||||
isMac={navigator.userAgent.toUpperCase().includes("MAC")}
|
|
||||||
shift={false}
|
|
||||||
value={"Duplicate"}
|
|
||||||
icon={"Copy"}
|
|
||||||
dataTestId="duplicate-button-modal"
|
|
||||||
/>
|
|
||||||
</SelectItem> */}
|
|
||||||
<SelectItem value={"copy"}>
|
<SelectItem value={"copy"}>
|
||||||
<ToolbarSelectItem
|
<ToolbarSelectItem
|
||||||
keyboardKey="C"
|
keyboardKey="C"
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ import { toolbarSelectItemProps } from "../../../../../types/components";
|
||||||
export default function ToolbarSelectItem({
|
export default function ToolbarSelectItem({
|
||||||
shift,
|
shift,
|
||||||
isMac,
|
isMac,
|
||||||
|
mod = true,
|
||||||
keyboardKey,
|
keyboardKey,
|
||||||
value,
|
value,
|
||||||
icon,
|
icon,
|
||||||
|
|
@ -21,7 +22,8 @@ export default function ToolbarSelectItem({
|
||||||
/>
|
/>
|
||||||
<span className={styleObj?.valueClasses}>{value}</span>
|
<span className={styleObj?.valueClasses}>{value}</span>
|
||||||
|
|
||||||
{isMac ? (
|
{mod &&
|
||||||
|
(isMac ? (
|
||||||
<ForwardedIconComponent
|
<ForwardedIconComponent
|
||||||
name="Command"
|
name="Command"
|
||||||
className={`absolute
|
className={`absolute
|
||||||
|
|
@ -36,7 +38,7 @@ export default function ToolbarSelectItem({
|
||||||
>
|
>
|
||||||
{shift ? "Ctrl" : "Ctrl +"}
|
{shift ? "Ctrl" : "Ctrl +"}
|
||||||
</span>
|
</span>
|
||||||
)}
|
))}
|
||||||
{shift && (
|
{shift && (
|
||||||
<ForwardedIconComponent
|
<ForwardedIconComponent
|
||||||
name="ArrowBigUp"
|
name="ArrowBigUp"
|
||||||
|
|
|
||||||
|
|
@ -732,6 +732,7 @@ export type toolbarSelectItemProps = {
|
||||||
isMac: boolean;
|
isMac: boolean;
|
||||||
shift: boolean;
|
shift: boolean;
|
||||||
keyboardKey: string;
|
keyboardKey: string;
|
||||||
|
mod?:boolean;
|
||||||
value: string;
|
value: string;
|
||||||
icon: string;
|
icon: string;
|
||||||
styleObj?: {
|
styleObj?: {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue