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

Feature: Ctrl+S should save the workflow #196

Open
douglasg14b opened this issue May 15, 2024 · 1 comment
Open

Feature: Ctrl+S should save the workflow #196

douglasg14b opened this issue May 15, 2024 · 1 comment

Comments

@douglasg14b
Copy link

Title says it! Capturing Ctrl/Cmd+S to save the workflow instead of the webpage

Copy link

glime-ai bot commented May 15, 2024

To capture the Ctrl/Cmd+S keyboard shortcut and use it to save the workflow in Elsa Workflow Designer instead of its default behavior (which is typically to save the webpage), you would need to implement a custom event handler in your web application that listens for the specific key combination. When the event is detected, you can prevent the default action and instead trigger the save functionality for your workflow.

Here's a basic example of how you might implement this in JavaScript:

document.addEventListener('keydown', function(event) {
  // Check for Ctrl or Cmd
  const isCtrlOrCmd = event.ctrlKey || event.metaKey;

  // Check if 'S' is pressed
  if (isCtrlOrCmd && event.key === 's') {
    event.preventDefault(); // Prevent the default save action
    // Trigger your workflow save function here
    saveWorkflow();
  }
});

function saveWorkflow() {
  // Your code to save the workflow
  console.log('Workflow saved!');
}

This code snippet listens for the keydown event and checks if the Ctrl key (or Cmd key on Mac) is held down while the 'S' key is pressed. If this condition is met, it prevents the default action (saving the webpage) and calls a saveWorkflow function, which you would replace with the actual logic to save your workflow in Elsa Workflow Designer.

Please note that the actual implementation may vary depending on the specifics of your application and the Elsa Workflow Designer integration. If you're using a framework like Angular, React, or Vue.js, you would integrate this logic into your component lifecycle and event handling patterns.

Remember to test this functionality across different browsers to ensure compatibility and to handle any edge cases that might arise.

This comment was generated by Glime.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant