yorkie-team / codepair

Build your own AI-powered collaborative markdown editor in just 5 minutes
https://codepair.yorkie.dev
Apache License 2.0
46 stars 19 forks source link

Add keyboard shortcuts for text formatting in CodePair editor #236

Closed beberiche closed 1 month ago

beberiche commented 1 month ago

Description

In general, programs that support Markdown syntax provide keyboard shortcuts to enhance user productivity when writing.

Similarly, CodePair also supports Markdown syntax through its editor, so I would like to introduce keyboard shortcuts that assist in text formatting transitions.

Planning

Below is a list of supported functions and keyboard shortcuts found by reviewing the official documentation of popular programs that support Markdown syntax.

Text formatting for Markdown shortcuts

Bold Italic Code StrikeThrough Underline Link(google)

Function GitHub Notion Obsidian Bear
Bold Cmd + B Cmd + B Cmd + B Cmd + B
Italic Cmd + I Cmd + I Cmd + I Cmd + I
Code Cmd + E Cmd + E Not supported Not supported
StrikeThrough Not supported Cmd + Shift + S Not supported Shift + Cmd + U
Underline Not supported Cmd + U Not supported Cmd + L
Link Cmd + K Cmd + K Not supported Cmd + K

I propose starting with implementing support for Bold and Italic, which are common features supported with the same keyboard shortcuts across different programs.

Implementation Approach

The implementation is likely to follow these steps:

  1. Determine the start (st) and end (ed) indices of the text selected by mouse drag within the entire document.
  2. If no text is selected by mouse drag, set the current focus as the index. (st), (ed=st+1) (Otherwise, ignore the keyboard shortcut event.)
  3. Apply the symbol (wrapper) to the start and end indices when the keyboard shortcut is entered.

Challenges

devleejb commented 1 month ago

That's a good idea.

If you are interested in the implementation, please let me know. Additionally, it would be necessary to investigate if there are any related libraries for CodeMirror6.

beberiche commented 1 month ago

@devleejb Ok! I'll try it. please assign it to me.

devleejb commented 1 month ago

@beberiche Sorry for the late check. I assigned you. Is there any progress on this issue? I think this issue might be hard.

devleejb commented 1 month ago

I think that it might be helpful to resolve this issue.