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 (
|
return (
|
||||||
<Transition
|
<Transition
|
||||||
className="relative"
|
className="nocopy nowheel nopan nodelete nodrag noundo relative"
|
||||||
show={show}
|
show={show}
|
||||||
appear={true}
|
appear={true}
|
||||||
enter="transition-transform duration-500 ease-out"
|
enter="transition-transform duration-500 ease-out"
|
||||||
|
|
|
||||||
|
|
@ -58,7 +58,6 @@ export default function Page({
|
||||||
flow: FlowType;
|
flow: FlowType;
|
||||||
view?: boolean;
|
view?: boolean;
|
||||||
}): JSX.Element {
|
}): JSX.Element {
|
||||||
const preventDefault = true;
|
|
||||||
const uploadFlow = useFlowsManagerStore((state) => state.uploadFlow);
|
const uploadFlow = useFlowsManagerStore((state) => state.uploadFlow);
|
||||||
const autoSaveCurrentFlow = useFlowsManagerStore(
|
const autoSaveCurrentFlow = useFlowsManagerStore(
|
||||||
(state) => state.autoSaveCurrentFlow
|
(state) => state.autoSaveCurrentFlow
|
||||||
|
|
@ -178,17 +177,17 @@ export default function Page({
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
function handleUndo(e: KeyboardEvent) {
|
function handleUndo(e: KeyboardEvent) {
|
||||||
e.preventDefault();
|
|
||||||
(e as unknown as Event).stopImmediatePropagation();
|
|
||||||
if (!isWrappedWithClass(e, "noundo")) {
|
if (!isWrappedWithClass(e, "noundo")) {
|
||||||
|
e.preventDefault();
|
||||||
|
(e as unknown as Event).stopImmediatePropagation();
|
||||||
undo();
|
undo();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleRedo(e: KeyboardEvent) {
|
function handleRedo(e: KeyboardEvent) {
|
||||||
e.preventDefault();
|
|
||||||
(e as unknown as Event).stopImmediatePropagation();
|
|
||||||
if (!isWrappedWithClass(e, "noundo")) {
|
if (!isWrappedWithClass(e, "noundo")) {
|
||||||
|
e.preventDefault();
|
||||||
|
(e as unknown as Event).stopImmediatePropagation();
|
||||||
redo();
|
redo();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -218,49 +217,46 @@ export default function Page({
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleCopy(e: KeyboardEvent) {
|
function handleCopy(e: KeyboardEvent) {
|
||||||
e.preventDefault();
|
if (!isWrappedWithClass(e, "nocopy")) {
|
||||||
(e as unknown as Event).stopImmediatePropagation();
|
e.preventDefault();
|
||||||
if (
|
(e as unknown as Event).stopImmediatePropagation();
|
||||||
!isWrappedWithClass(e, "nocopy") &&
|
if (window.getSelection()?.toString().length === 0 && lastSelection) {
|
||||||
window.getSelection()?.toString().length === 0 &&
|
setLastCopiedSelection(_.cloneDeep(lastSelection));
|
||||||
lastSelection
|
}
|
||||||
) {
|
|
||||||
setLastCopiedSelection(_.cloneDeep(lastSelection));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleCut(e: KeyboardEvent) {
|
function handleCut(e: KeyboardEvent) {
|
||||||
e.preventDefault();
|
if (!isWrappedWithClass(e, "nocopy")) {
|
||||||
(e as unknown as Event).stopImmediatePropagation();
|
e.preventDefault();
|
||||||
if (
|
(e as unknown as Event).stopImmediatePropagation();
|
||||||
!isWrappedWithClass(e, "nocopy") &&
|
if (window.getSelection()?.toString().length === 0 && lastSelection) {
|
||||||
window.getSelection()?.toString().length === 0 &&
|
setLastCopiedSelection(_.cloneDeep(lastSelection), true);
|
||||||
lastSelection
|
}
|
||||||
) {
|
|
||||||
setLastCopiedSelection(_.cloneDeep(lastSelection), true);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function handlePaste(e: KeyboardEvent) {
|
function handlePaste(e: KeyboardEvent) {
|
||||||
e.preventDefault();
|
if (!isWrappedWithClass(e, "nocopy")) {
|
||||||
(e as unknown as Event).stopImmediatePropagation();
|
e.preventDefault();
|
||||||
if (
|
(e as unknown as Event).stopImmediatePropagation();
|
||||||
!isWrappedWithClass(e, "nocopy") &&
|
if (
|
||||||
window.getSelection()?.toString().length === 0 &&
|
window.getSelection()?.toString().length === 0 &&
|
||||||
lastCopiedSelection
|
lastCopiedSelection
|
||||||
) {
|
) {
|
||||||
takeSnapshot();
|
takeSnapshot();
|
||||||
paste(lastCopiedSelection, {
|
paste(lastCopiedSelection, {
|
||||||
x: position.current.x,
|
x: position.current.x,
|
||||||
y: position.current.y,
|
y: position.current.y,
|
||||||
});
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleDelete(e: KeyboardEvent) {
|
function handleDelete(e: KeyboardEvent) {
|
||||||
e.preventDefault();
|
|
||||||
(e as unknown as Event).stopImmediatePropagation();
|
|
||||||
if (!isWrappedWithClass(e, "nodelete") && lastSelection) {
|
if (!isWrappedWithClass(e, "nodelete") && lastSelection) {
|
||||||
|
e.preventDefault();
|
||||||
|
(e as unknown as Event).stopImmediatePropagation();
|
||||||
takeSnapshot();
|
takeSnapshot();
|
||||||
deleteNode(lastSelection.nodes.map((node) => node.id));
|
deleteNode(lastSelection.nodes.map((node) => node.id));
|
||||||
deleteEdge(lastSelection.edges.map((edge) => edge.id));
|
deleteEdge(lastSelection.edges.map((edge) => edge.id));
|
||||||
|
|
@ -276,23 +272,23 @@ export default function Page({
|
||||||
const cutAction = useShortcutsStore((state) => state.cut);
|
const cutAction = useShortcutsStore((state) => state.cut);
|
||||||
const pasteAction = useShortcutsStore((state) => state.paste);
|
const pasteAction = useShortcutsStore((state) => state.paste);
|
||||||
//@ts-ignore
|
//@ts-ignore
|
||||||
useHotkeys(undoAction, handleUndo, { preventDefault });
|
useHotkeys(undoAction, handleUndo);
|
||||||
//@ts-ignore
|
//@ts-ignore
|
||||||
useHotkeys(redoAction, handleRedo, { preventDefault });
|
useHotkeys(redoAction, handleRedo);
|
||||||
//@ts-ignore
|
//@ts-ignore
|
||||||
useHotkeys(groupAction, handleGroup, { preventDefault });
|
useHotkeys(groupAction, handleGroup);
|
||||||
//@ts-ignore
|
//@ts-ignore
|
||||||
useHotkeys(duplicate, handleDuplicate, { preventDefault });
|
useHotkeys(duplicate, handleDuplicate);
|
||||||
//@ts-ignore
|
//@ts-ignore
|
||||||
useHotkeys(copyAction, handleCopy, { preventDefault });
|
useHotkeys(copyAction, handleCopy);
|
||||||
//@ts-ignore
|
//@ts-ignore
|
||||||
useHotkeys(cutAction, handleCut, { preventDefault });
|
useHotkeys(cutAction, handleCut);
|
||||||
//@ts-ignore
|
//@ts-ignore
|
||||||
useHotkeys(pasteAction, handlePaste, { preventDefault });
|
useHotkeys(pasteAction, handlePaste);
|
||||||
//@ts-ignore
|
//@ts-ignore
|
||||||
useHotkeys(deleteAction, handleDelete, { preventDefault });
|
useHotkeys(deleteAction, handleDelete);
|
||||||
//@ts-ignore
|
//@ts-ignore
|
||||||
useHotkeys("delete", handleDelete, { preventDefault });
|
useHotkeys("delete", handleDelete);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setSHowCanvas(
|
setSHowCanvas(
|
||||||
|
|
|
||||||
|
|
@ -411,7 +411,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
.error-build-message {
|
.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 {
|
.error-build-message-circle {
|
||||||
@apply alert-icon text-status-red;
|
@apply alert-icon text-status-red;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue