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

Disabling enter is no longer possible after upgrade to v27 #9422

Closed
zadam opened this issue Apr 5, 2021 · 2 comments
Closed

Disabling enter is no longer possible after upgrade to v27 #9422

zadam opened this issue Apr 5, 2021 · 2 comments
Labels
type:bug This issue reports a buggy (incorrect) behavior.

Comments

@zadam
Copy link

zadam commented Apr 5, 2021

After upgrading CKEditor from v25 to v27 I'm having an issue that it's no longer possible to disable enter (i.e. user shouldn't be able to insert new line and has to type everything in a single line).

In older versions (v25 and older) I disabled Enter by removing the corresponding plugins:

const editorConfig = {
    removePlugins: [
        'Enter',
        'ShiftEnter'
    ]
}

In v27 this no longer works, I get this error:

Uncaught (in promise) CKEditorError: plugincollection-required {"plugin":"Enter","requiredBy":"WidgetTypeAround"}

I can follow the dependency chain and keep removing plugins until I get to a working configuration with:

const editorConfig = {
    removePlugins: [
        'Enter',
        'ShiftEnter',
        'WidgetTypeAround',
        'Widget',
        'DragDrop',
        'Clipboard',
        'ListEditing',
        'ListStyleEditing',
        'ListStyle',
        'HorizontalLine',
        'xy',
        ''
     ]
};

But this then removes too much other functionality which I actually need.

@zadam zadam added the type:bug This issue reports a buggy (incorrect) behavior. label Apr 5, 2021
@FilipTokarski
Copy link
Member

Hi, this happens because Enter is a dependency of other plugins, in this case WidgetTypeAround. There's however an easy workaround - you can use this code:

editor.editing.view.document.on( 'enter', ( event, data ) => {
    data.preventDefault();
    event.stop();
    return;
}, { priority: 'high' } );

This will listen on enter event and prevent it from firing.

@FilipTokarski FilipTokarski added the pending:feedback This issue is blocked by necessary feedback. label Apr 7, 2021
@zadam
Copy link
Author

zadam commented Apr 7, 2021

@FilipTokarski many thanks, that does the trick!

@zadam zadam closed this as completed Apr 7, 2021
@FilipTokarski FilipTokarski removed the pending:feedback This issue is blocked by necessary feedback. label Apr 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:bug This issue reports a buggy (incorrect) behavior.
Projects
None yet
Development

No branches or pull requests

2 participants