uiwjs / react-md-editor

A simple markdown editor with preview, implemented with React.js and TypeScript.
https://uiwjs.github.io/react-md-editor
MIT License
2.17k stars 156 forks source link

Implementation of Shortcuts #41

Closed foxhard closed 3 years ago

foxhard commented 4 years ago

Can you provide an example to extend the component to support custom shortcuts?

I'm looking for something like this:

jaywcjlove commented 3 years ago

API design:

export const bold: ICommand = {
  name: 'bold',
+  shortcuts: 'cmd+i',
  keyCommand: 'bold',
  buttonProps: { 'aria-label': 'Add bold text' },
  icon: (
    <svg role="img" width="12" height="12" viewBox="0 0 384 512">
      ....
    </svg>
  ),
  execute: (state: TextState, api: TextApi) => {},
};

https://github.com/uiwjs/react-md-editor/blob/7a58c1ef8e3a47ffd8fedc5c7e0a0ff8e425b202/src/commands/bold.tsx#L5-L30

jaywcjlove commented 3 years ago

Available modifiers

Available key codes

jaywcjlove commented 3 years ago

Upgrade @uiw/react-md-editor@3.0.0-beta.1

Available modifiers