6421306849
The context menu advertised Ctrl+C/Ctrl+V hints but useKeyboardShortcuts only handled undo/redo/delete/duplicate/escape -- pressing them did nothing. Add a tiny shared module-level clipboard (src/hooks/clipboard.ts) used by both the keyboard hook and the context menu so copying via one entry point and pasting via the other stay consistent. Ctrl/Cmd+C stores the selected node id (skipping ROOT). Ctrl/Cmd+V inserts a copy as a sibling of the current selection via regenerateTreeIds, mirroring the existing context-menu paste behavior. Both respect the existing "disabled while typing" guard. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
30 lines
835 B
TypeScript
30 lines
835 B
TypeScript
import { describe, test, expect, afterEach } from 'vitest';
|
|
import { getClipboardNodeId, setClipboardNodeId } from './clipboard';
|
|
|
|
describe('clipboard', () => {
|
|
afterEach(() => {
|
|
setClipboardNodeId(null);
|
|
});
|
|
|
|
test('starts empty', () => {
|
|
expect(getClipboardNodeId()).toBeNull();
|
|
});
|
|
|
|
test('set then get returns the stored node id', () => {
|
|
setClipboardNodeId('node-123');
|
|
expect(getClipboardNodeId()).toBe('node-123');
|
|
});
|
|
|
|
test('is a shared module-level store -- overwriting replaces the previous value', () => {
|
|
setClipboardNodeId('first');
|
|
setClipboardNodeId('second');
|
|
expect(getClipboardNodeId()).toBe('second');
|
|
});
|
|
|
|
test('can be cleared back to null', () => {
|
|
setClipboardNodeId('node-123');
|
|
setClipboardNodeId(null);
|
|
expect(getClipboardNodeId()).toBeNull();
|
|
});
|
|
});
|