Skip to content

Commit d71ba8a

Browse files
committed
Closes #539. Updated New Page functionality to clear the clipboard
1 parent c4bd05e commit d71ba8a

File tree

3 files changed

+9
-1
lines changed

3 files changed

+9
-1
lines changed

src/core/providers/canvas-schema/canvas-schema-vlatest.model.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,4 +82,5 @@ export interface CanvasSchemaContextVm {
8282
copySelectedTable: () => void;
8383
pasteTable: () => void;
8484
hasClipboardContent: boolean;
85+
clearClipboard: () => void;
8586
}

src/core/providers/canvas-schema/canvas-schema.provider.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,11 @@ export const CanvasSchemaProvider: React.FC<Props> = props => {
226226
}
227227
};
228228

229+
const clearClipboard = () => {
230+
setClipboardTable(null);
231+
setPasteOffset({ x: 0, y: 0 });
232+
};
233+
229234
return (
230235
<CanvasSchemaContext.Provider
231236
value={{
@@ -250,6 +255,7 @@ export const CanvasSchemaProvider: React.FC<Props> = props => {
250255
copySelectedTable,
251256
pasteTable,
252257
hasClipboardContent: Boolean(clipboardTable),
258+
clearClipboard,
253259
}}
254260
>
255261
{children}

src/pods/toolbar/components/new-button/new-button.component.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,14 @@ import classes from '@/pods/toolbar/toolbar.pod.module.css';
88
import { SHORTCUTS } from '../../shortcut/shortcut.const';
99

1010
export const NewButton = () => {
11-
const { createEmptySchema } = useCanvasSchemaContext();
11+
const { createEmptySchema, clearClipboard } = useCanvasSchemaContext();
1212
const { setFilename, setLoadSample } = useCanvasViewSettingsContext();
1313

1414
const handleNewButtonClick = () => {
1515
setFilename('');
1616
createEmptySchema();
1717
setLoadSample(false);
18+
clearClipboard();
1819
};
1920

2021
return (

0 commit comments

Comments
 (0)