Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Manage undo/redo keybindings #1230

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
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
4 changes: 2 additions & 2 deletions browser_tests/changeTracker.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,12 @@ test.describe('Change Tracker', () => {

await multipleChanges()

await comfyPage.ctrlZ()
await comfyPage.executeCommand('Comfy.Undo')
await expect(node).not.toBeBypassed()
await expect(node).not.toBePinned()
await expect(node).not.toBeCollapsed()

await comfyPage.ctrlY()
await comfyPage.executeCommand('Comfy.Redo')
await expect(node).toBeBypassed()
await expect(node).toBePinned()
await expect(node).toBeCollapsed()
Expand Down
2 changes: 1 addition & 1 deletion browser_tests/menu.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,7 @@ test.describe('Menu', () => {
const workflowMenuItem =
await comfyPage.menu.topbar.getMenuItem('Workflow')
await workflowMenuItem.click()
const exportTag = comfyPage.page.locator('.keybinding-tag', {
const exportTag = comfyPage.page.locator('.keybinding-tag:visible', {
hasText: 'Ctrl + s'
})
expect(await exportTag.count()).toBe(1)
Expand Down
15 changes: 0 additions & 15 deletions src/scripts/changeTracker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,18 +89,6 @@ export class ChangeTracker {
await this.updateState(this.redoQueue, this.undoQueue)
}

async undoRedo(e) {
if (e.ctrlKey || e.metaKey) {
if (e.key === 'y' || e.key == 'Z') {
await this.redo()
return true
} else if (e.key === 'z') {
await this.undo()
return true
}
}
}

beforeChange() {
this.changeCount++
}
Expand Down Expand Up @@ -158,9 +146,6 @@ export class ChangeTracker {
e.key === 'Meta'
if (keyIgnored) return

// Check if this is a ctrl+z ctrl+y
if (await changeTracker().undoRedo(e)) return

// If our active element is some type of input then handle changes after they're done
if (ChangeTracker.bindInput(app, bindInputEl)) return
changeTracker().checkState()
Expand Down
25 changes: 25 additions & 0 deletions src/stores/coreKeybindings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,5 +160,30 @@ export const CORE_KEYBINDINGS: Keybinding[] = [
},
commandId: 'Comfy.Canvas.ToggleSelectedNodes.Mute',
targetSelector: '#graph-canvas'
},
{
combo: {
key: 'z',
ctrl: true
},
commandId: 'Comfy.Undo',
targetSelector: '#graph-canvas'
},
{
combo: {
key: 'Z',
ctrl: true,
shift: true
},
commandId: 'Comfy.Redo',
targetSelector: '#graph-canvas'
},
{
combo: {
key: 'y',
ctrl: true
},
commandId: 'Comfy.Redo',
targetSelector: '#graph-canvas'
}
]
Loading