Fixed not being able to copy anywhere
This commit is contained in:
parent
647df8a592
commit
6322827ad6
3 changed files with 42 additions and 46 deletions
|
|
@ -13,7 +13,7 @@ export default function SingleAlert({
|
|||
|
||||
return (
|
||||
<Transition
|
||||
className="relative"
|
||||
className="nocopy nowheel nopan nodelete nodrag noundo relative"
|
||||
show={show}
|
||||
appear={true}
|
||||
enter="transition-transform duration-500 ease-out"
|
||||
|
|
|
|||
|
|
@ -58,7 +58,6 @@ export default function Page({
|
|||
flow: FlowType;
|
||||
view?: boolean;
|
||||
}): JSX.Element {
|
||||
const preventDefault = true;
|
||||
const uploadFlow = useFlowsManagerStore((state) => state.uploadFlow);
|
||||
const autoSaveCurrentFlow = useFlowsManagerStore(
|
||||
(state) => state.autoSaveCurrentFlow
|
||||
|
|
@ -178,17 +177,17 @@ export default function Page({
|
|||
}, []);
|
||||
|
||||
function handleUndo(e: KeyboardEvent) {
|
||||
e.preventDefault();
|
||||
(e as unknown as Event).stopImmediatePropagation();
|
||||
if (!isWrappedWithClass(e, "noundo")) {
|
||||
e.preventDefault();
|
||||
(e as unknown as Event).stopImmediatePropagation();
|
||||
undo();
|
||||
}
|
||||
}
|
||||
|
||||
function handleRedo(e: KeyboardEvent) {
|
||||
e.preventDefault();
|
||||
(e as unknown as Event).stopImmediatePropagation();
|
||||
if (!isWrappedWithClass(e, "noundo")) {
|
||||
e.preventDefault();
|
||||
(e as unknown as Event).stopImmediatePropagation();
|
||||
redo();
|
||||
}
|
||||
}
|
||||
|
|
@ -218,49 +217,46 @@ export default function Page({
|
|||
}
|
||||
|
||||
function handleCopy(e: KeyboardEvent) {
|
||||
e.preventDefault();
|
||||
(e as unknown as Event).stopImmediatePropagation();
|
||||
if (
|
||||
!isWrappedWithClass(e, "nocopy") &&
|
||||
window.getSelection()?.toString().length === 0 &&
|
||||
lastSelection
|
||||
) {
|
||||
setLastCopiedSelection(_.cloneDeep(lastSelection));
|
||||
if (!isWrappedWithClass(e, "nocopy")) {
|
||||
e.preventDefault();
|
||||
(e as unknown as Event).stopImmediatePropagation();
|
||||
if (window.getSelection()?.toString().length === 0 && lastSelection) {
|
||||
setLastCopiedSelection(_.cloneDeep(lastSelection));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function handleCut(e: KeyboardEvent) {
|
||||
e.preventDefault();
|
||||
(e as unknown as Event).stopImmediatePropagation();
|
||||
if (
|
||||
!isWrappedWithClass(e, "nocopy") &&
|
||||
window.getSelection()?.toString().length === 0 &&
|
||||
lastSelection
|
||||
) {
|
||||
setLastCopiedSelection(_.cloneDeep(lastSelection), true);
|
||||
if (!isWrappedWithClass(e, "nocopy")) {
|
||||
e.preventDefault();
|
||||
(e as unknown as Event).stopImmediatePropagation();
|
||||
if (window.getSelection()?.toString().length === 0 && lastSelection) {
|
||||
setLastCopiedSelection(_.cloneDeep(lastSelection), true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function handlePaste(e: KeyboardEvent) {
|
||||
e.preventDefault();
|
||||
(e as unknown as Event).stopImmediatePropagation();
|
||||
if (
|
||||
!isWrappedWithClass(e, "nocopy") &&
|
||||
window.getSelection()?.toString().length === 0 &&
|
||||
lastCopiedSelection
|
||||
) {
|
||||
takeSnapshot();
|
||||
paste(lastCopiedSelection, {
|
||||
x: position.current.x,
|
||||
y: position.current.y,
|
||||
});
|
||||
if (!isWrappedWithClass(e, "nocopy")) {
|
||||
e.preventDefault();
|
||||
(e as unknown as Event).stopImmediatePropagation();
|
||||
if (
|
||||
window.getSelection()?.toString().length === 0 &&
|
||||
lastCopiedSelection
|
||||
) {
|
||||
takeSnapshot();
|
||||
paste(lastCopiedSelection, {
|
||||
x: position.current.x,
|
||||
y: position.current.y,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function handleDelete(e: KeyboardEvent) {
|
||||
e.preventDefault();
|
||||
(e as unknown as Event).stopImmediatePropagation();
|
||||
if (!isWrappedWithClass(e, "nodelete") && lastSelection) {
|
||||
e.preventDefault();
|
||||
(e as unknown as Event).stopImmediatePropagation();
|
||||
takeSnapshot();
|
||||
deleteNode(lastSelection.nodes.map((node) => node.id));
|
||||
deleteEdge(lastSelection.edges.map((edge) => edge.id));
|
||||
|
|
@ -276,23 +272,23 @@ export default function Page({
|
|||
const cutAction = useShortcutsStore((state) => state.cut);
|
||||
const pasteAction = useShortcutsStore((state) => state.paste);
|
||||
//@ts-ignore
|
||||
useHotkeys(undoAction, handleUndo, { preventDefault });
|
||||
useHotkeys(undoAction, handleUndo);
|
||||
//@ts-ignore
|
||||
useHotkeys(redoAction, handleRedo, { preventDefault });
|
||||
useHotkeys(redoAction, handleRedo);
|
||||
//@ts-ignore
|
||||
useHotkeys(groupAction, handleGroup, { preventDefault });
|
||||
useHotkeys(groupAction, handleGroup);
|
||||
//@ts-ignore
|
||||
useHotkeys(duplicate, handleDuplicate, { preventDefault });
|
||||
useHotkeys(duplicate, handleDuplicate);
|
||||
//@ts-ignore
|
||||
useHotkeys(copyAction, handleCopy, { preventDefault });
|
||||
useHotkeys(copyAction, handleCopy);
|
||||
//@ts-ignore
|
||||
useHotkeys(cutAction, handleCut, { preventDefault });
|
||||
useHotkeys(cutAction, handleCut);
|
||||
//@ts-ignore
|
||||
useHotkeys(pasteAction, handlePaste, { preventDefault });
|
||||
useHotkeys(pasteAction, handlePaste);
|
||||
//@ts-ignore
|
||||
useHotkeys(deleteAction, handleDelete, { preventDefault });
|
||||
useHotkeys(deleteAction, handleDelete);
|
||||
//@ts-ignore
|
||||
useHotkeys("delete", handleDelete, { preventDefault });
|
||||
useHotkeys("delete", handleDelete);
|
||||
|
||||
useEffect(() => {
|
||||
setSHowCanvas(
|
||||
|
|
|
|||
|
|
@ -411,7 +411,7 @@
|
|||
}
|
||||
|
||||
.error-build-message {
|
||||
@apply mt-6 w-96 cursor-pointer rounded-md bg-error-background p-4 shadow-xl;
|
||||
@apply mt-6 w-96 rounded-md bg-error-background p-4 shadow-xl;
|
||||
}
|
||||
.error-build-message-circle {
|
||||
@apply alert-icon text-status-red;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue