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

Desktop: Resolves #9980: Support Ctrl+Enter keyboard shortcut (Cmd+Enter on MacOS) #10003

Merged

Conversation

cagnusmarlsen
Copy link
Contributor

Fixes #9980 by adding key bindings for Ctrl+Enter on Windows/Linux and Cmd+Enter on macOS. This adds functionality to add a new line after the line where the cursor currently is.

Testing

This has been tested successfully on Windows 11 and Ubuntu.

Test.mp4

Copy link
Contributor

github-actions bot commented Feb 26, 2024

CLA Assistant Lite bot All contributors have signed the CLA ✍️ ✅

@cagnusmarlsen
Copy link
Contributor Author

I have read the CLA Document and I hereby sign the CLA

github-actions bot added a commit that referenced this pull request Feb 26, 2024
@personalizedrefrigerator
Copy link
Collaborator

personalizedrefrigerator commented Feb 27, 2024

While this fixes the issue in the legacy CodeMirror 5-based markdown editor, the issue is still present in the CodeMirror 6-based editor.

To make this work, I suspect that additional command declarations will have to be added here:

const editorCommands: Record<EditorCommandType, EditorCommandFunction> = {

Alternatively, to also support mobile, the beta editor keyboard shortcuts could be added here:

keyCommand('Shift-Tab', decreaseIndent, true),

Thank you for working on this!

@cagnusmarlsen
Copy link
Contributor Author

Thank you for the help. I've added the necessary shortcut to joplin/packages/editor/CodeMirror/createEditor.ts. Now works for both the editors.

@@ -261,6 +261,7 @@ const createEditor = (
}),
keyCommand('Tab', insertOrIncreaseIndent, true),
keyCommand('Shift-Tab', decreaseIndent, true),
keyCommand('Mod-Enter', insertBlankLine, true),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider using insertLineAfter from editorCommands/insertLineAfter.ts here. insertLineAfter should handle list continuation and auto-indentation.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That makes sense. Made the necessary changes.

@cagnusmarlsen
Copy link
Contributor Author

cagnusmarlsen commented Mar 1, 2024

@PackElend label me please

Link to introduction - https://discourse.joplinapp.org/t/introducing-marlsen/36358

@laurent22 laurent22 merged commit c409160 into laurent22:dev Mar 2, 2024
10 checks passed
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

Successfully merging this pull request may close these issues.

Beta markdown editor: Support Ctrl+Enter keyboard shortcut (Cmd+Enter on MacOS)
4 participants