feat: Ctrl+S saves current tab (piano roll, section, audio) or project + all dirty tabs

This commit is contained in:
2026-07-25 20:54:23 +07:00
parent fde9a91c9b
commit c1a3d3a6dd
2 changed files with 41 additions and 2 deletions
+37 -1
View File
@@ -7383,7 +7383,43 @@ const App = () => {
} }
if (ctrl && !alt && e.key === 's') { if (ctrl && !alt && e.key === 's') {
e.preventDefault(); e.preventDefault();
handleSaveProject(); const curTab = activeTabRef.current;
if (curTab === 'main') {
// Main session: save project + save all dirty sub-tabs
handleSaveProject();
subTabsRef.current.filter(s => s.isDirty).forEach(st => {
if (st.type === 'PIANO_ROLL') {
handleSaveMidiNotes(st.id, st.trackId, st.target_id, st.notes || []);
} else if (st.type === 'SECTION') {
handleSaveSectionTab(st.id);
} else if (st.buffer) {
// Audio clip sub-tab: save buffer to track
const subTrack = activeTracksRef.current.find(t => t.id === st.trackId);
if (subTrack) {
updateActiveTracks(prev => prev.map(t => t.id === st.trackId ? { ...t, buffer: st.buffer } : t));
}
}
showToast('Đã lưu', 'success');
});
} else {
// Sub-tab: save current tab
const st = subTabsRef.current.find(s => s.id === curTab);
if (st) {
if (st.type === 'PIANO_ROLL') {
handleSaveMidiNotes(st.id, st.trackId, st.target_id, st.notes || []);
showToast('Đã lưu Piano Roll', 'success');
} else if (st.type === 'SECTION') {
handleSaveSectionTab(st.id);
showToast('Đã lưu Section Tab', 'success');
} else if (st.buffer) {
const subTrack = activeTracksRef.current.find(t => t.id === st.trackId);
if (subTrack) {
updateActiveTracks(prev => prev.map(t => t.id === st.trackId ? { ...t, buffer: st.buffer } : t));
}
showToast('Đã lưu Audio Tab', 'success');
}
}
}
return; return;
} }
if (!ctrl && !alt && e.key === 's') { if (!ctrl && !alt && e.key === 's') {
File diff suppressed because one or more lines are too long