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

Allow ShortcutListener for CKEditorTextField #65

Open
TobseF opened this issue Jul 25, 2017 · 3 comments
Open

Allow ShortcutListener for CKEditorTextField #65

TobseF opened this issue Jul 25, 2017 · 3 comments

Comments

@TobseF
Copy link

TobseF commented Jul 25, 2017

I want to add an ctrl + Enter shortcut binding to the CKEditor. But it seems that the CKEditor consumes all key events. Is that supported in any way, or how could I implement this missing behavior?

public void initListener(){
	cKEditorTextField.addShortcutListener(new CtrlEnterShortcut());
}

public class CtrlEnterShortcut extends ShortcutListener {

	private CtrlEnterShortcut() {
		super("CtrlEnter", KeyCode.ENTER, new int[] { ModifierKey.CTRL });
	}

	@Override
	public void handleAction(Object sender, Object target) {
		System.out.println("Hey, you did it!");
	}
}
@OpenESignForms
Copy link
Owner

Are you trying to have a Vaadin override of the ckeditor, or trying to customize ckeditor to do it's alternative behavior for Enter / Ctrl+Enter? We've not done either, but obviously the editor is most likely going to consume keystrokes in the editor as it would be odd for a javascript component to ask a container to handle keystrokes done inside it.

Did you look at the ckeditor config object to see what they offer? I know there's something about how Enter vs. Ctrl+Enter may work for paragraph breaks inside it, with the default being Enter gives you a new paragraph, and Ctrl+Enter doing a
type new line. At least that's what I recall.

If you are looking for an enhancement, you might better explain the use case where you want keystrokes inside the editor to be interpreted by Vaadin over the the editor, though. It would be a very low priority here, but perhaps others would contribute any changes/fixes needed to make it happen.

@TobseF
Copy link
Author

TobseF commented Jul 25, 2017

We built an inplace edit component. You click on some text and a small editor popup opens which allows to edit the text. There I use the CKEditorTExtField. To close and save or cancel the the editing, I want to add the keybindings Ctrl+Enter and ESC to the Editor. Bus it consumes the events and I cant react on Vaadins side.

For now, I will fork vaadin-ckeditor and add special listeners for my Keybindings in same style as the save plugin does. But I thought, there should be general way to support Shortcuts for server side actions.

@OpenESignForms
Copy link
Owner

Ok, good luck. If you create something general and useful for this, we'll be happy to add it in if you share your code. It's unclear if you'll also have to update the ckeditor config or whether it can be done just with vaadin code.

Also, if you are doing Vaadin 8, there's already a forked project for that in the Directory.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants