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

CHORE: Added functionality for basic custom language keymaps. #129

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

feh-pined0
Copy link
Contributor

Based on issue request #116, i tried to implement a basic form of custom keymaps based on the current active note block. The idea is to have a set of custom keymaps for each language type, and for the system to be basic enough to be easily extended.

Although it is not finished yet (maybe add more checks in the transactions, as to not interfer with other blocks), maybe it's a good start if this is a desired feature. #116

@heyman
Copy link
Owner

heyman commented Jan 6, 2024

I want to refactor the code that handles key bindings to support fully user-customized key bindings. When that is implemented, the custom key bindings functionality should support binding keys that are only active in certain block modes.

However, implementing #116 with the current (somewhat messy) state of key bindings, I think a better approach would be to always bind the commands (with a high precedence). The commands should check if the current block is a Markdown block, and in that case call preventDefault() on the event and do its job, and otherwise not call preventDefault() and return false (allowing other bound commands to handle the event).

So the commands should have a signature that looks something like formatBold({state, dispatch}, event). This would also have the added benefit that one could make the commands work with multiple cursors (you would have to check the type of block at each cursor, and if it's Markdown, perform the action).

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.

2 participants