Merge branch 'modalRefactor' into python_custom_node_component
This commit is contained in:
commit
6242d80635
19 changed files with 73 additions and 151 deletions
|
|
@ -243,7 +243,6 @@ export default function ParameterComponent({
|
||||||
) : (
|
) : (
|
||||||
<InputComponent
|
<InputComponent
|
||||||
disabled={disabled}
|
disabled={disabled}
|
||||||
disableCopyPaste={true}
|
|
||||||
password={data.node.template[name].password ?? false}
|
password={data.node.template[name].password ?? false}
|
||||||
value={data.node.template[name].value ?? ""}
|
value={data.node.template[name].value ?? ""}
|
||||||
onChange={handleOnNewValue}
|
onChange={handleOnNewValue}
|
||||||
|
|
@ -265,7 +264,6 @@ export default function ParameterComponent({
|
||||||
<div className="mt-2 w-full">
|
<div className="mt-2 w-full">
|
||||||
<FloatComponent
|
<FloatComponent
|
||||||
disabled={disabled}
|
disabled={disabled}
|
||||||
disableCopyPaste={true}
|
|
||||||
value={data.node.template[name].value ?? ""}
|
value={data.node.template[name].value ?? ""}
|
||||||
onChange={handleOnNewValue}
|
onChange={handleOnNewValue}
|
||||||
/>
|
/>
|
||||||
|
|
@ -311,7 +309,6 @@ export default function ParameterComponent({
|
||||||
<div className="mt-2 w-full">
|
<div className="mt-2 w-full">
|
||||||
<IntComponent
|
<IntComponent
|
||||||
disabled={disabled}
|
disabled={disabled}
|
||||||
disableCopyPaste={true}
|
|
||||||
value={data.node.template[name].value ?? ""}
|
value={data.node.template[name].value ?? ""}
|
||||||
onChange={handleOnNewValue}
|
onChange={handleOnNewValue}
|
||||||
/>
|
/>
|
||||||
|
|
|
||||||
|
|
@ -51,7 +51,7 @@ export const EditFlowSettings: React.FC<InputProps> = ({
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
<Input
|
<Input
|
||||||
className="mt-2 font-normal"
|
className="nopan nodrag noundo nocopy mt-2 font-normal"
|
||||||
onChange={handleNameChange}
|
onChange={handleNameChange}
|
||||||
type="text"
|
type="text"
|
||||||
name="name"
|
name="name"
|
||||||
|
|
|
||||||
|
|
@ -1,16 +1,12 @@
|
||||||
import { useContext, useEffect } from "react";
|
import { useEffect } from "react";
|
||||||
import { TabsContext } from "../../contexts/tabsContext";
|
|
||||||
import { FloatComponentType } from "../../types/components";
|
import { FloatComponentType } from "../../types/components";
|
||||||
|
|
||||||
export default function FloatComponent({
|
export default function FloatComponent({
|
||||||
value,
|
value,
|
||||||
onChange,
|
onChange,
|
||||||
disableCopyPaste = false,
|
|
||||||
disabled,
|
disabled,
|
||||||
editNode = false,
|
editNode = false,
|
||||||
}: FloatComponentType) {
|
}: FloatComponentType) {
|
||||||
const { setDisableCopyPaste } = useContext(TabsContext);
|
|
||||||
|
|
||||||
const step = 0.1;
|
const step = 0.1;
|
||||||
const min = 0;
|
const min = 0;
|
||||||
const max = 1;
|
const max = 1;
|
||||||
|
|
@ -25,12 +21,6 @@ export default function FloatComponent({
|
||||||
return (
|
return (
|
||||||
<div className={"w-full " + (disabled ? "float-component-pointer" : "")}>
|
<div className={"w-full " + (disabled ? "float-component-pointer" : "")}>
|
||||||
<input
|
<input
|
||||||
onFocus={() => {
|
|
||||||
if (disableCopyPaste) setDisableCopyPaste(true);
|
|
||||||
}}
|
|
||||||
onBlur={() => {
|
|
||||||
if (disableCopyPaste) setDisableCopyPaste(false);
|
|
||||||
}}
|
|
||||||
type="number"
|
type="number"
|
||||||
step={step}
|
step={step}
|
||||||
min={min}
|
min={min}
|
||||||
|
|
@ -45,9 +35,10 @@ export default function FloatComponent({
|
||||||
max={max}
|
max={max}
|
||||||
value={value ?? ""}
|
value={value ?? ""}
|
||||||
className={
|
className={
|
||||||
editNode
|
"nopan nodrag noundo nocopy " +
|
||||||
|
(editNode
|
||||||
? "input-edit-node"
|
? "input-edit-node"
|
||||||
: "input-primary" + (disabled ? " input-disable " : "")
|
: "input-primary" + (disabled ? " input-disable " : ""))
|
||||||
}
|
}
|
||||||
placeholder={
|
placeholder={
|
||||||
editNode ? "Number 0 to 1" : "Type a number from zero to one"
|
editNode ? "Number 0 to 1" : "Type a number from zero to one"
|
||||||
|
|
|
||||||
|
|
@ -1,18 +1,15 @@
|
||||||
import { useContext, useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import { TabsContext } from "../../contexts/tabsContext";
|
|
||||||
import { InputComponentType } from "../../types/components";
|
import { InputComponentType } from "../../types/components";
|
||||||
import { classNames } from "../../utils/utils";
|
import { classNames } from "../../utils/utils";
|
||||||
|
|
||||||
export default function InputComponent({
|
export default function InputComponent({
|
||||||
value,
|
value,
|
||||||
onChange,
|
onChange,
|
||||||
disableCopyPaste = false,
|
|
||||||
disabled,
|
disabled,
|
||||||
password,
|
password,
|
||||||
editNode = false,
|
editNode = false,
|
||||||
}: InputComponentType) {
|
}: InputComponentType) {
|
||||||
const [pwdVisible, setPwdVisible] = useState(false);
|
const [pwdVisible, setPwdVisible] = useState(false);
|
||||||
const { setDisableCopyPaste } = useContext(TabsContext);
|
|
||||||
|
|
||||||
// Clear component state
|
// Clear component state
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|
@ -25,18 +22,13 @@ export default function InputComponent({
|
||||||
<div className={disabled ? "input-component-div" : "relative"}>
|
<div className={disabled ? "input-component-div" : "relative"}>
|
||||||
<input
|
<input
|
||||||
value={value}
|
value={value}
|
||||||
onFocus={() => {
|
|
||||||
if (disableCopyPaste) setDisableCopyPaste(true);
|
|
||||||
}}
|
|
||||||
onBlur={() => {
|
|
||||||
if (disableCopyPaste) setDisableCopyPaste(false);
|
|
||||||
}}
|
|
||||||
className={classNames(
|
className={classNames(
|
||||||
disabled ? " input-disable " : "",
|
disabled ? " input-disable " : "",
|
||||||
password && !pwdVisible && value !== "" ? " text-clip password " : "",
|
password && !pwdVisible && value !== "" ? " text-clip password " : "",
|
||||||
editNode ? " input-edit-node " : " input-primary ",
|
editNode ? " input-edit-node " : " input-primary ",
|
||||||
password && editNode ? "pr-8" : "",
|
password && editNode ? "pr-8" : "",
|
||||||
password && !editNode ? "pr-10" : ""
|
password && !editNode ? "pr-10" : "",
|
||||||
|
"nopan nodrag noundo nocopy"
|
||||||
)}
|
)}
|
||||||
placeholder={password && editNode ? "Key" : "Type something..."}
|
placeholder={password && editNode ? "Key" : "Type something..."}
|
||||||
onChange={(e) => {
|
onChange={(e) => {
|
||||||
|
|
|
||||||
|
|
@ -40,9 +40,10 @@ export default function InputListComponent({
|
||||||
type="text"
|
type="text"
|
||||||
value={i}
|
value={i}
|
||||||
className={
|
className={
|
||||||
editNode
|
"nopan nodrag noundo nocopy " +
|
||||||
|
(editNode
|
||||||
? "input-edit-node "
|
? "input-edit-node "
|
||||||
: "input-primary " + (disabled ? "input-disable" : "")
|
: "input-primary " + (disabled ? "input-disable" : ""))
|
||||||
}
|
}
|
||||||
placeholder="Type something..."
|
placeholder="Type something..."
|
||||||
onChange={(e) => {
|
onChange={(e) => {
|
||||||
|
|
|
||||||
|
|
@ -1,15 +1,12 @@
|
||||||
import { useContext, useEffect } from "react";
|
import { useEffect } from "react";
|
||||||
import { TabsContext } from "../../contexts/tabsContext";
|
|
||||||
import { FloatComponentType } from "../../types/components";
|
import { FloatComponentType } from "../../types/components";
|
||||||
|
|
||||||
export default function IntComponent({
|
export default function IntComponent({
|
||||||
value,
|
value,
|
||||||
onChange,
|
onChange,
|
||||||
disableCopyPaste = false,
|
|
||||||
disabled,
|
disabled,
|
||||||
editNode = false,
|
editNode = false,
|
||||||
}: FloatComponentType) {
|
}: FloatComponentType) {
|
||||||
const { setDisableCopyPaste } = useContext(TabsContext);
|
|
||||||
const min = 0;
|
const min = 0;
|
||||||
|
|
||||||
// Clear component state
|
// Clear component state
|
||||||
|
|
@ -27,12 +24,6 @@ export default function IntComponent({
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
<input
|
<input
|
||||||
onFocus={() => {
|
|
||||||
if (disableCopyPaste) setDisableCopyPaste(true);
|
|
||||||
}}
|
|
||||||
onBlur={() => {
|
|
||||||
if (disableCopyPaste) setDisableCopyPaste(false);
|
|
||||||
}}
|
|
||||||
onKeyDown={(event) => {
|
onKeyDown={(event) => {
|
||||||
if (
|
if (
|
||||||
event.key !== "Backspace" &&
|
event.key !== "Backspace" &&
|
||||||
|
|
@ -61,9 +52,10 @@ export default function IntComponent({
|
||||||
}}
|
}}
|
||||||
value={value ?? ""}
|
value={value ?? ""}
|
||||||
className={
|
className={
|
||||||
editNode
|
"nopan nodrag noundo nocopy " +
|
||||||
|
(editNode
|
||||||
? " input-edit-node "
|
? " input-edit-node "
|
||||||
: " input-primary " + (disabled ? " input-disable" : "")
|
: " input-primary " + (disabled ? " input-disable" : ""))
|
||||||
}
|
}
|
||||||
placeholder={editNode ? "Integer number" : "Type an integer number"}
|
placeholder={editNode ? "Integer number" : "Type an integer number"}
|
||||||
onChange={(e) => {
|
onChange={(e) => {
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
import { useContext, useEffect } from "react";
|
import { useEffect } from "react";
|
||||||
import { TypeModal } from "../../constants/enums";
|
import { TypeModal } from "../../constants/enums";
|
||||||
import { TabsContext } from "../../contexts/tabsContext";
|
|
||||||
import GenericModal from "../../modals/genericModal";
|
import GenericModal from "../../modals/genericModal";
|
||||||
import { TextAreaComponentType } from "../../types/components";
|
import { TextAreaComponentType } from "../../types/components";
|
||||||
import IconComponent from "../genericIconComponent";
|
import IconComponent from "../genericIconComponent";
|
||||||
|
|
@ -11,8 +10,6 @@ export default function TextAreaComponent({
|
||||||
disabled,
|
disabled,
|
||||||
editNode = false,
|
editNode = false,
|
||||||
}: TextAreaComponentType) {
|
}: TextAreaComponentType) {
|
||||||
const { setDisableCopyPaste } = useContext(TabsContext);
|
|
||||||
|
|
||||||
// Clear text area
|
// Clear text area
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (disabled) {
|
if (disabled) {
|
||||||
|
|
@ -25,17 +22,11 @@ export default function TextAreaComponent({
|
||||||
<div className="flex w-full items-center">
|
<div className="flex w-full items-center">
|
||||||
<input
|
<input
|
||||||
value={value}
|
value={value}
|
||||||
onFocus={() => {
|
|
||||||
setDisableCopyPaste(true);
|
|
||||||
}}
|
|
||||||
onBlur={() => {
|
|
||||||
setDisableCopyPaste(false);
|
|
||||||
}}
|
|
||||||
className={
|
className={
|
||||||
(editNode
|
(editNode
|
||||||
? " input-edit-node "
|
? " input-edit-node "
|
||||||
: " input-primary " + (disabled ? " input-disable" : "")) +
|
: " input-primary " + (disabled ? " input-disable" : "")) +
|
||||||
" w-full"
|
" nopan nodrag noundo nocopy w-full"
|
||||||
}
|
}
|
||||||
placeholder={"Type something..."}
|
placeholder={"Type something..."}
|
||||||
onChange={(e) => {
|
onChange={(e) => {
|
||||||
|
|
|
||||||
|
|
@ -44,7 +44,7 @@ const DialogContent = React.forwardRef<
|
||||||
<DialogPrimitive.Content
|
<DialogPrimitive.Content
|
||||||
ref={ref}
|
ref={ref}
|
||||||
className={cn(
|
className={cn(
|
||||||
"fixed z-50 flex w-full flex-col gap-3 rounded-b-lg border bg-background p-6 shadow-lg animate-in data-[state=open]:fade-in-90 data-[state=open]:slide-in-from-bottom-10 sm:max-w-lg sm:rounded-lg sm:zoom-in-90 data-[state=open]:sm:slide-in-from-bottom-0",
|
"noundo nocopy fixed z-50 flex w-full flex-col gap-3 rounded-b-lg border bg-background p-6 shadow-lg animate-in data-[state=open]:fade-in-90 data-[state=open]:slide-in-from-bottom-10 sm:max-w-lg sm:rounded-lg sm:zoom-in-90 data-[state=open]:sm:slide-in-from-bottom-0",
|
||||||
className
|
className
|
||||||
)}
|
)}
|
||||||
{...props}
|
{...props}
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ const Input = React.forwardRef<HTMLInputElement, InputProps>(
|
||||||
<input
|
<input
|
||||||
type={type}
|
type={type}
|
||||||
className={cn(
|
className={cn(
|
||||||
"flex h-10 w-full rounded-md border border-input bg-transparent px-3 py-2 text-sm ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",
|
"nopan nodrag noundo nocopy flex h-10 w-full rounded-md border border-input bg-transparent px-3 py-2 text-sm ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",
|
||||||
className
|
className
|
||||||
)}
|
)}
|
||||||
ref={ref}
|
ref={ref}
|
||||||
|
|
|
||||||
|
|
@ -57,7 +57,7 @@ export default function RenameLabel(props) {
|
||||||
ref={inputRef}
|
ref={inputRef}
|
||||||
onInput={resizeInput}
|
onInput={resizeInput}
|
||||||
className={cn(
|
className={cn(
|
||||||
"rounded-md bg-transparent px-2 outline-ring hover:outline focus:border-none focus:outline active:outline",
|
"nopan nodrag noundo nocopy rounded-md bg-transparent px-2 outline-ring hover:outline focus:border-none focus:outline active:outline",
|
||||||
props.className
|
props.className
|
||||||
)}
|
)}
|
||||||
onBlur={() => {
|
onBlur={() => {
|
||||||
|
|
|
||||||
|
|
@ -42,8 +42,6 @@ const TabsContextInitialValue: TabsContextType = {
|
||||||
uploadFlow: () => {},
|
uploadFlow: () => {},
|
||||||
hardReset: () => {},
|
hardReset: () => {},
|
||||||
saveFlow: async (flow: FlowType) => {},
|
saveFlow: async (flow: FlowType) => {},
|
||||||
disableCopyPaste: false,
|
|
||||||
setDisableCopyPaste: (state: boolean) => {},
|
|
||||||
lastCopiedSelection: null,
|
lastCopiedSelection: null,
|
||||||
setLastCopiedSelection: (selection: any) => {},
|
setLastCopiedSelection: (selection: any) => {},
|
||||||
tabsState: {},
|
tabsState: {},
|
||||||
|
|
@ -585,16 +583,12 @@ export function TabsProvider({ children }: { children: ReactNode }) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const [disableCopyPaste, setDisableCopyPaste] = useState(false);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<TabsContext.Provider
|
<TabsContext.Provider
|
||||||
value={{
|
value={{
|
||||||
saveFlow,
|
saveFlow,
|
||||||
lastCopiedSelection,
|
lastCopiedSelection,
|
||||||
setLastCopiedSelection,
|
setLastCopiedSelection,
|
||||||
disableCopyPaste,
|
|
||||||
setDisableCopyPaste,
|
|
||||||
hardReset,
|
hardReset,
|
||||||
tabId,
|
tabId,
|
||||||
setTabId,
|
setTabId,
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ import {
|
||||||
useState,
|
useState,
|
||||||
} from "react";
|
} from "react";
|
||||||
import { Edge, Node, useReactFlow } from "reactflow";
|
import { Edge, Node, useReactFlow } from "reactflow";
|
||||||
|
import { isWrappedWithClass } from "../utils/utils";
|
||||||
import { TabsContext } from "./tabsContext";
|
import { TabsContext } from "./tabsContext";
|
||||||
|
|
||||||
type undoRedoContextType = {
|
type undoRedoContextType = {
|
||||||
|
|
@ -20,14 +21,6 @@ type UseUndoRedoOptions = {
|
||||||
enableShortcuts: boolean;
|
enableShortcuts: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
type UseUndoRedo = (options?: UseUndoRedoOptions) => {
|
|
||||||
undo: () => void;
|
|
||||||
redo: () => void;
|
|
||||||
takeSnapshot: () => void;
|
|
||||||
canUndo: boolean;
|
|
||||||
canRedo: boolean;
|
|
||||||
};
|
|
||||||
|
|
||||||
type HistoryItem = {
|
type HistoryItem = {
|
||||||
nodes: Node[];
|
nodes: Node[];
|
||||||
edges: Edge[];
|
edges: Edge[];
|
||||||
|
|
@ -156,17 +149,21 @@ export function UndoRedoProvider({ children }) {
|
||||||
}
|
}
|
||||||
|
|
||||||
const keyDownHandler = (event: KeyboardEvent) => {
|
const keyDownHandler = (event: KeyboardEvent) => {
|
||||||
if (
|
if (!isWrappedWithClass(event, "noundo")) {
|
||||||
event.key === "z" &&
|
if (
|
||||||
(event.ctrlKey || event.metaKey) &&
|
event.key === "z" &&
|
||||||
event.shiftKey
|
(event.ctrlKey || event.metaKey) &&
|
||||||
) {
|
event.shiftKey
|
||||||
redo();
|
) {
|
||||||
} else if (event.key === "y" && (event.ctrlKey || event.metaKey)) {
|
event.preventDefault();
|
||||||
event.preventDefault(); // prevent the default action
|
redo();
|
||||||
redo();
|
} else if (event.key === "y" && (event.ctrlKey || event.metaKey)) {
|
||||||
} else if (event.key === "z" && (event.ctrlKey || event.metaKey)) {
|
event.preventDefault(); // prevent the default action
|
||||||
undo();
|
redo();
|
||||||
|
} else if (event.key === "z" && (event.ctrlKey || event.metaKey)) {
|
||||||
|
event.preventDefault();
|
||||||
|
undo();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -241,8 +241,8 @@ The cursor: default; property value restores the browser's default cursor style
|
||||||
@apply form-input block w-full truncate rounded-md border-border bg-background px-3 text-left shadow-sm placeholder:text-muted-foreground sm:text-sm;
|
@apply form-input block w-full truncate rounded-md border-border bg-background px-3 text-left shadow-sm placeholder:text-muted-foreground sm:text-sm;
|
||||||
}
|
}
|
||||||
|
|
||||||
.input-edit-node {
|
.input-edit-node{
|
||||||
@apply input-primary border-border pb-0.5 pt-0.5;
|
@apply input-primary border-border pt-0.5 pb-0.5 text-left w-full
|
||||||
}
|
}
|
||||||
.input-search {
|
.input-search {
|
||||||
@apply input-primary mx-2 pr-7;
|
@apply input-primary mx-2 pr-7;
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import { ReactNode, useContext, useEffect, useState } from "react";
|
import { ReactNode } from "react";
|
||||||
|
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import {
|
import {
|
||||||
|
|
@ -9,7 +9,6 @@ import {
|
||||||
DialogTitle,
|
DialogTitle,
|
||||||
DialogTrigger,
|
DialogTrigger,
|
||||||
} from "../../components/ui/dialog";
|
} from "../../components/ui/dialog";
|
||||||
import { TabsContext } from "../../contexts/tabsContext";
|
|
||||||
|
|
||||||
type ContentProps = { children: ReactNode };
|
type ContentProps = { children: ReactNode };
|
||||||
type HeaderProps = { children: ReactNode; description: string };
|
type HeaderProps = { children: ReactNode; description: string };
|
||||||
|
|
@ -97,25 +96,9 @@ function BaseModal({
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
const { setDisableCopyPaste } = useContext(TabsContext);
|
|
||||||
const [openInner, setOpenInner] = useState(open ?? false);
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
setOpenInner(open);
|
|
||||||
}, [open]);
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
setOpen(openInner);
|
|
||||||
if (openInner) {
|
|
||||||
setDisableCopyPaste(true);
|
|
||||||
} else {
|
|
||||||
setDisableCopyPaste(false);
|
|
||||||
}
|
|
||||||
}, [openInner]);
|
|
||||||
|
|
||||||
//UPDATE COLORS AND STYLE CLASSSES
|
//UPDATE COLORS AND STYLE CLASSSES
|
||||||
return (
|
return (
|
||||||
<Dialog open={openInner} onOpenChange={setOpenInner}>
|
<Dialog open={open} onOpenChange={setOpen}>
|
||||||
<DialogTrigger className="w-full" hidden={triggerChild ? false : true}>
|
<DialogTrigger className="w-full" hidden={triggerChild ? false : true}>
|
||||||
{triggerChild}
|
{triggerChild}
|
||||||
</DialogTrigger>
|
</DialogTrigger>
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,7 @@ import { undoRedoContext } from "../../../../contexts/undoRedoContext";
|
||||||
import { APIClassType } from "../../../../types/api";
|
import { APIClassType } from "../../../../types/api";
|
||||||
import { FlowType, NodeType } from "../../../../types/flow";
|
import { FlowType, NodeType } from "../../../../types/flow";
|
||||||
import { isValidConnection } from "../../../../utils/reactflowUtils";
|
import { isValidConnection } from "../../../../utils/reactflowUtils";
|
||||||
|
import { isWrappedWithClass } from "../../../../utils/utils";
|
||||||
import ConnectionLineComponent from "../ConnectionLineComponent";
|
import ConnectionLineComponent from "../ConnectionLineComponent";
|
||||||
import ExtraSidebar from "../extraSidebarComponent";
|
import ExtraSidebar from "../extraSidebarComponent";
|
||||||
|
|
||||||
|
|
@ -38,7 +39,6 @@ export default function Page({ flow }: { flow: FlowType }) {
|
||||||
let {
|
let {
|
||||||
updateFlow,
|
updateFlow,
|
||||||
uploadFlow,
|
uploadFlow,
|
||||||
disableCopyPaste,
|
|
||||||
addFlow,
|
addFlow,
|
||||||
getNodeId,
|
getNodeId,
|
||||||
paste,
|
paste,
|
||||||
|
|
@ -63,34 +63,34 @@ export default function Page({ flow }: { flow: FlowType }) {
|
||||||
// this effect is used to attach the global event handlers
|
// this effect is used to attach the global event handlers
|
||||||
|
|
||||||
const onKeyDown = (event: KeyboardEvent) => {
|
const onKeyDown = (event: KeyboardEvent) => {
|
||||||
if (
|
if (!isWrappedWithClass(event, "nocopy")) {
|
||||||
(event.ctrlKey || event.metaKey) &&
|
if (
|
||||||
event.key === "c" &&
|
(event.ctrlKey || event.metaKey) &&
|
||||||
lastSelection &&
|
event.key === "c" &&
|
||||||
!disableCopyPaste
|
lastSelection
|
||||||
) {
|
) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
setLastCopiedSelection(_.cloneDeep(lastSelection));
|
setLastCopiedSelection(_.cloneDeep(lastSelection));
|
||||||
}
|
}
|
||||||
if (
|
if (
|
||||||
(event.ctrlKey || event.metaKey) &&
|
(event.ctrlKey || event.metaKey) &&
|
||||||
event.key === "v" &&
|
event.key === "v" &&
|
||||||
lastCopiedSelection &&
|
lastCopiedSelection
|
||||||
!disableCopyPaste
|
) {
|
||||||
) {
|
event.preventDefault();
|
||||||
event.preventDefault();
|
let bounds = reactFlowWrapper.current.getBoundingClientRect();
|
||||||
let bounds = reactFlowWrapper.current.getBoundingClientRect();
|
paste(lastCopiedSelection, {
|
||||||
paste(lastCopiedSelection, {
|
x: position.x - bounds.left,
|
||||||
x: position.x - bounds.left,
|
y: position.y - bounds.top,
|
||||||
y: position.y - bounds.top,
|
});
|
||||||
});
|
}
|
||||||
}
|
if (
|
||||||
if (
|
(event.ctrlKey || event.metaKey) &&
|
||||||
(event.ctrlKey || event.metaKey) &&
|
event.key === "g" &&
|
||||||
event.key === "g" &&
|
lastSelection
|
||||||
lastSelection
|
) {
|
||||||
) {
|
event.preventDefault();
|
||||||
event.preventDefault();
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
const handleMouseMove = (event) => {
|
const handleMouseMove = (event) => {
|
||||||
|
|
@ -355,8 +355,6 @@ export default function Page({ flow }: { flow: FlowType }) {
|
||||||
setLastSelection(flow);
|
setLastSelection(flow);
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const { setDisableCopyPaste } = useContext(TabsContext);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="flex h-full overflow-hidden">
|
<div className="flex h-full overflow-hidden">
|
||||||
<ExtraSidebar />
|
<ExtraSidebar />
|
||||||
|
|
@ -378,15 +376,6 @@ export default function Page({ flow }: { flow: FlowType }) {
|
||||||
});
|
});
|
||||||
}}
|
}}
|
||||||
edges={edges}
|
edges={edges}
|
||||||
onPaneClick={() => {
|
|
||||||
setDisableCopyPaste(false);
|
|
||||||
}}
|
|
||||||
onPaneMouseLeave={() => {
|
|
||||||
setDisableCopyPaste(true);
|
|
||||||
}}
|
|
||||||
onPaneMouseEnter={() => {
|
|
||||||
setDisableCopyPaste(false);
|
|
||||||
}}
|
|
||||||
onNodesChange={onNodesChangeMod}
|
onNodesChange={onNodesChangeMod}
|
||||||
onEdgesChange={onEdgesChangeMod}
|
onEdgesChange={onEdgesChangeMod}
|
||||||
onConnect={onConnect}
|
onConnect={onConnect}
|
||||||
|
|
@ -407,9 +396,6 @@ export default function Page({ flow }: { flow: FlowType }) {
|
||||||
onDrop={onDrop}
|
onDrop={onDrop}
|
||||||
onNodesDelete={onDelete}
|
onNodesDelete={onDelete}
|
||||||
onSelectionChange={onSelectionChange}
|
onSelectionChange={onSelectionChange}
|
||||||
nodesDraggable={!disableCopyPaste}
|
|
||||||
panOnDrag={!disableCopyPaste}
|
|
||||||
zoomOnDoubleClick={!disableCopyPaste}
|
|
||||||
className="theme-attribution"
|
className="theme-attribution"
|
||||||
minZoom={0.01}
|
minZoom={0.01}
|
||||||
maxZoom={8}
|
maxZoom={8}
|
||||||
|
|
|
||||||
|
|
@ -114,7 +114,7 @@ export default function ExtraSidebar() {
|
||||||
name="search"
|
name="search"
|
||||||
id="search"
|
id="search"
|
||||||
placeholder="Search"
|
placeholder="Search"
|
||||||
className="input-search"
|
className="nopan nodrag noundo nocopy input-search"
|
||||||
onChange={(e) => {
|
onChange={(e) => {
|
||||||
handleSearchInput(e.target.value);
|
handleSearchInput(e.target.value);
|
||||||
// Set search input state
|
// Set search input state
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,6 @@ export type InputComponentType = {
|
||||||
disabled?: boolean;
|
disabled?: boolean;
|
||||||
onChange: (value: string) => void;
|
onChange: (value: string) => void;
|
||||||
password: boolean;
|
password: boolean;
|
||||||
disableCopyPaste?: boolean;
|
|
||||||
editNode?: boolean;
|
editNode?: boolean;
|
||||||
onChangePass?: (value: boolean | boolean) => void;
|
onChangePass?: (value: boolean | boolean) => void;
|
||||||
showPass?: boolean;
|
showPass?: boolean;
|
||||||
|
|
@ -95,7 +94,6 @@ export type DisclosureComponentType = {
|
||||||
export type FloatComponentType = {
|
export type FloatComponentType = {
|
||||||
value: string;
|
value: string;
|
||||||
disabled?: boolean;
|
disabled?: boolean;
|
||||||
disableCopyPaste?: boolean;
|
|
||||||
onChange: (value: string) => void;
|
onChange: (value: string) => void;
|
||||||
editNode?: boolean;
|
editNode?: boolean;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -20,9 +20,6 @@ export type TabsContextType = {
|
||||||
uploadFlows: () => void;
|
uploadFlows: () => void;
|
||||||
uploadFlow: (newFlow?: boolean, file?: File) => void;
|
uploadFlow: (newFlow?: boolean, file?: File) => void;
|
||||||
hardReset: () => void;
|
hardReset: () => void;
|
||||||
//disable CopyPaste
|
|
||||||
disableCopyPaste: boolean;
|
|
||||||
setDisableCopyPaste: (value: boolean) => void;
|
|
||||||
getNodeId: (nodeType: string) => string;
|
getNodeId: (nodeType: string) => string;
|
||||||
tabsState: TabsState;
|
tabsState: TabsState;
|
||||||
setTabsState: Dispatch<SetStateAction<TabsState>>;
|
setTabsState: Dispatch<SetStateAction<TabsState>>;
|
||||||
|
|
|
||||||
|
|
@ -85,6 +85,9 @@ export function checkUpperWords(str: string) {
|
||||||
return words.join(" ");
|
return words.join(" ");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const isWrappedWithClass = (event: any, className: string | undefined) =>
|
||||||
|
event.target.closest(`.${className}`);
|
||||||
|
|
||||||
export function groupByFamily(data, baseClasses, left, type) {
|
export function groupByFamily(data, baseClasses, left, type) {
|
||||||
let parentOutput: string;
|
let parentOutput: string;
|
||||||
let arrOfParent: string[] = [];
|
let arrOfParent: string[] = [];
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue