1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2026-04-08 14:52:08 -04:00

feat(Notepad): Implement tab reordering via drag-and-drop functionality

This commit is contained in:
purian23
2026-03-18 00:09:19 -04:00
parent 1b32829dac
commit 28315a165f
2 changed files with 222 additions and 67 deletions

View File

@@ -241,6 +241,28 @@ Singleton {
saveMetadata()
}
function reorderTab(fromIndex, toIndex) {
if (fromIndex < 0 || fromIndex >= tabs.length || toIndex < 0 || toIndex >= tabs.length)
return
if (fromIndex === toIndex)
return
var newTabs = tabs.slice()
var moved = newTabs.splice(fromIndex, 1)[0]
newTabs.splice(toIndex, 0, moved)
tabs = newTabs
if (currentTabIndex === fromIndex) {
currentTabIndex = toIndex
} else if (fromIndex < currentTabIndex && toIndex >= currentTabIndex) {
currentTabIndex--
} else if (fromIndex > currentTabIndex && toIndex <= currentTabIndex) {
currentTabIndex++
}
saveMetadata()
}
function saveTabAs(tabIndex, userPath) {
if (tabIndex < 0 || tabIndex >= tabs.length) return