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

Customize keys to accept mention #4665

Closed
felipegiotto opened this issue Jul 5, 2019 · 9 comments · Fixed by #9751
Closed

Customize keys to accept mention #4665

felipegiotto opened this issue Jul 5, 2019 · 9 comments · Fixed by #9751
Assignees
Labels
domain:ui/ux This issue reports a problem related to UI or UX. intro Good first ticket. package:mention type:feature This issue reports a feature request (an idea for a new functionality or a missing option). type:improvement This issue reports a possible enhancement of an existing feature.

Comments

@felipegiotto
Copy link

Currently, the plugin always select the current item when the user hit Enter, Tab or Space keys. My suggestion is to allow the user to customize these keys. For instance, I may want to disable the "Space key" shortcut, so if the user has the mention box opened and hit Space, the box closes and the editor keeps only the plain text, without mentions.

@Reinmar
Copy link
Member

Reinmar commented Jul 8, 2019

It sounds interesting. @jodator, is that hard to make this configurable?

@jodator
Copy link
Contributor

jodator commented Jul 15, 2019

@Reinmar I think that we could rethink the space key handling. Even considering it a bug.

Adding configuration key for this shouldn't be hard - it would only require to read the config and pass it to the 'mention' view.

The form of the configuration is another question - only disabling the space or specifying keys to act on.

@mlewand
Copy link
Contributor

mlewand commented Jul 17, 2019

The best option here is to allow an Number|Number[] of keystrokes that should accept the mention. So that developers are free to adjust it to their will.

Something like that:

const config = {
	mention: {
		commitKeys: keyCodes.enter
	}
};

const config = {
	mention: {
		commitKeys: [ keyCodes.enter, keyCodes.tab ]
	}
};

@mlewand mlewand transferred this issue from ckeditor/ckeditor5-mention Oct 9, 2019
@mlewand mlewand added this to the nice-to-have milestone Oct 9, 2019
@mlewand mlewand added status:confirmed type:improvement This issue reports a possible enhancement of an existing feature. type:feature This issue reports a feature request (an idea for a new functionality or a missing option). package:mention labels Oct 9, 2019
@zadam
Copy link

zadam commented Nov 6, 2019

From my perspective the "space" issue is severely limiting usefulness of this plugin to only simple use cases - even the standard use case of mentioning somebody by name does not fully work since names contain space between first name and last name.

If having this configurable would take too much time then a quickfix could be considered of just allowing space (resp. not treating it as a "commit key") as a more sensible default.

@cnickless
Copy link

Not allowing a space to be written after the marker makes for a broken typing experience. It restricts users from being able to simply type marker characters (e.g. #, @) with a space following it. Right now if I wanted to just type "#[space]" the first option will be selected. If I delete those characters to go back to just the #, the feed is shown again.

To get past this, the user would have to either:

  1. Type text after the tag, then use their mouse to select the cursor to the tag, delete the characters and then move the cursor back to the end of the string.
  2. Type in sequence: #[esc][space]

That's quite the unnatural behavior placed on the user.

I'd recommend just updating the default keys to select being ENTER and TAB, as those feel like the more specialized keys for this.

To test the ideal scenario -- type a comment on GitHub here down below ... type "#[Space]" and notice how the mention feed appears and then disappears.

@jaigupta10
Copy link

Any update on this one? Is it working and if so then how.

@zadam
Copy link

zadam commented May 24, 2020

@jaigupta10 There's PR ckeditor/ckeditor5-mention#92 which fixes the space behavior but unfortunately it wasn't merged yet and has not activity :-( But it's simple enough that you can merge it yourself locally for your project...

@neongreen
Copy link

From my perspective the "space" issue is severely limiting usefulness of this plugin to only simple use cases - even the standard use case of mentioning somebody by name does not fully work since names contain space between first name and last name.

Same here. I am implementing a "page mention" feature for a notetaking app; Notion, Obsidian, Github all allow spaces in mentions, and we need to support this as well.

@mlewand
Copy link
Contributor

mlewand commented Jul 29, 2021

Note that this issue focuses on being able to customize the keys used for committing the mention.

@zadam @cnickless @neongreen your feature request is valid (ability for mentions to have a space) but that's a separate issue dedicated to handling space in mention value. Please add 👍 reaction there to show your support.

Unfortunately mentioned PR ckeditor/ckeditor5-mention#92 (which became #7306 after our repo migration) merely removed space from list of keys that accept a mention. While logic of mention (which were broken by spaces) remained unchanged.

@oleq oleq closed this as completed in #9751 Aug 2, 2021
oleq added a commit that referenced this issue Aug 2, 2021
Feature (mention): Keyboard shortcuts to accept mentions can be customized using the  [`config.mention.commitKeys`](https://ckeditor.com/docs/ckeditor5/latest/api/module_mention_mention-MentionConfig.html#member-commitKeys) configuration option. Closes #4665.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
domain:ui/ux This issue reports a problem related to UI or UX. intro Good first ticket. package:mention type:feature This issue reports a feature request (an idea for a new functionality or a missing option). type:improvement This issue reports a possible enhancement of an existing feature.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants