Search code examples
ckeditor

How to disable Shift+Enter in CKEditor 5


I would like to disable the Shift+Enter key in CKEditor 5. I will also like to strip the <br/> from the copied conent when the users paste into the editor. Basically, I just don't want the <br/> to be any where in the document. It must be a very simple setting, but I just can't find it in the documentation. Could someone help?

Thanks! Leo


Solution

  • Well. It turned out pretty easy. I post it here just in case someone else wants to know. If you want to disable the Shift+Enter feature in a block, such as a paragraph. You can add the following code into paragraph.js:

            // Disallow softBreak
            model.schema.addChildCheck( ( context, childDefinition ) => {
                if ( childDefinition.name == 'softBreak' && Array.from( context.getNames() ).includes( 'paragraph' ) ) {
                    return false;
                }
            } );