Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -82,4 +82,5 @@ export interface CanvasSchemaContextVm {
copySelectedTable: () => void;
pasteTable: () => void;
hasClipboardContent: boolean;
clearClipboard: () => void;
}
6 changes: 6 additions & 0 deletions src/core/providers/canvas-schema/canvas-schema.provider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,11 @@ export const CanvasSchemaProvider: React.FC<Props> = props => {
}
};

const clearClipboard = () => {
setClipboardTable(null);
setPasteOffset({ x: 0, y: 0 });
};

return (
<CanvasSchemaContext.Provider
value={{
Expand All @@ -250,6 +255,7 @@ export const CanvasSchemaProvider: React.FC<Props> = props => {
copySelectedTable,
pasteTable,
hasClipboardContent: Boolean(clipboardTable),
clearClipboard,
}}
>
{children}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,14 @@ import classes from '@/pods/toolbar/toolbar.pod.module.css';
import { SHORTCUTS } from '../../shortcut/shortcut.const';

export const NewButton = () => {
const { createEmptySchema } = useCanvasSchemaContext();
const { createEmptySchema, clearClipboard } = useCanvasSchemaContext();
const { setFilename, setLoadSample } = useCanvasViewSettingsContext();

const handleNewButtonClick = () => {
setFilename('');
createEmptySchema();
setLoadSample(false);
clearClipboard();
};

return (
Expand Down