Skip to content

feat: Make keyboard shortcut configurable#103

Open
syuzanvs wants to merge 2 commits into1.xfrom
syuzan/1.x/#99-make-keyboard-shortcut-configurable
Open

feat: Make keyboard shortcut configurable#103
syuzanvs wants to merge 2 commits into1.xfrom
syuzan/1.x/#99-make-keyboard-shortcut-configurable

Conversation

@syuzanvs
Copy link
Copy Markdown
Collaborator

  • Updated the AI Agent plugin to allow users to configure the command trigger string (currently hardcoded as '/') to better suit their preferences.
  • Introduced a new configuration option for the CMD+/ keyboard shortcut, enabling users to customize it according to their workflows and accessibility needs.
  • Modified the relevant code in src/aiagentservice.ts, src/aiagentediting.ts, and src/const.ts to support these new configurable options.
  • Updated the README.md to reflect the new configuration options and their usage.

These enhancements improve the flexibility and user experience of the AI Agent plugin, allowing for a more tailored interaction with the editor.

Closes #99

@syuzanvs syuzanvs requested a review from jjroelofs January 21, 2025 22:34
@syuzanvs syuzanvs force-pushed the syuzan/1.x/#99-make-keyboard-shortcut-configurable branch from fe9df97 to e8d5908 Compare January 21, 2025 22:54
@jjroelofs jjroelofs force-pushed the syuzan/1.x/#99-make-keyboard-shortcut-configurable branch from d6678e4 to 9cb7f76 Compare January 22, 2025 15:25
@syuzanvs syuzanvs force-pushed the syuzan/1.x/#99-make-keyboard-shortcut-configurable branch from 9cb7f76 to b37e1c5 Compare January 22, 2025 17:58
- Updated the AI Agent plugin to allow users to configure the command trigger string (currently hardcoded as '/') to better suit their preferences.
- Introduced a new configuration option for the CMD+/ keyboard shortcut, enabling users to customize it according to their workflows and accessibility needs.
- Modified the relevant code in `src/aiagentservice.ts`, `src/aiagentediting.ts`, and `src/const.ts` to support these new configurable options.
- Updated the README.md to reflect the new configuration options and their usage.

These enhancements improve the flexibility and user experience of the AI Agent plugin, allowing for a more tailored interaction with the editor.

Closes #99
@syuzanvs syuzanvs force-pushed the syuzan/1.x/#99-make-keyboard-shortcut-configurable branch from b37e1c5 to 10b9809 Compare February 3, 2025 19:55
Copy link
Copy Markdown
Contributor

@jjroelofs jjroelofs left a comment

Choose a reason for hiding this comment

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

Bug 1: default shortcut inline prompt

After checking out your branch, immediately the CMD+/ command it not working anymore. The Accessibility Help popup still shows this is the correct shortcut (and it should be):

image

Bug 2: AiKeyboard setting not working

Config:

			aiKeyboard: '?',

UI after reloading, still showing /:
image

Furthermore, when I click the Accessibility Help button I get this error:

keyboard-unknown-key {"key":"?"}

Bug 3:

When I try to enter a Keyboard shortcut that is supported by CKEditor API: 'Ctrl+Alt+H' in the editor I get this error:

Type '"Ctrl+Alt+H"' is not assignable to type '"|" | "," | "." | "?" | ";" | ":" | "'" | "\"" | "+" | "-" | "=" | "_" | "\\" | "*" | "%" | "^" | "~" | "<" | ">" | "(" | ")" | "{" | "}" | "[" | "]" | "!" | "@" | "#" | "$" | "&" | undefined'.ts(2322)

I asked you to use CKEditor API so that we don't have these weird sort of bugs, CK5 has a reliable and user friendly keyboard API, no need to do double work. See a reference of their keyboard utilities here:
https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-utils/src/keyboard.ts
https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-utils/src/keystrokehandler.ts

| `moderationDisableFlags` | `Array<ModerationFlagsTypes>?` | - | Array of moderation flags to disable |
| `commandsDropdown` | `Array<{ title: string; items: Array<{ title: string; command: string; }>; }>?` | Default menu with tone adjustment, content enhancement, and fix/improve commands | Specifies the commands available in the dropdown menu |
| `contentScope` | `string?` | - | CSS selector that extends context gathering to include content from other CKEditor 5 instances found within the first matching ancestor element |
| `aiKeyboard` | `AiKeyboardTypes?` | `/` | Specifies the type of AI keyboard interaction to be used within the editor. This option allows for customization of keyboard behavior related to AI functionalities, enhancing user experience by providing tailored input methods. |
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Dont we need 2 settings here, one for normal prompt and one for inline prompt?
For example maybe for normal prompt I want to set:

Alt+H

and for inline prompt:

Ctrl+Alt+H

] as const;

export const AI_KEYBOARD_CODS = {
',': 188,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We don't want to implement custom keystroke handling, leave it to CKEditor5 API, this is technical debt we do not want to take on. CK5 has figured out support for multiple OS, localization, lots of complexities we do not have the capacitity to figure out. Either we implement this using CK5 API or we do not implement it at all because we cannot afford to create and maintain the neccessary business logic to implement keyboard shortcuts reliably for a global user base.

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.

Make keyboard shortcut configurable

2 participants