LeoX
LeoX

Reputation: 137

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

Upvotes: 2

Views: 802

Answers (1)

LeoX
LeoX

Reputation: 137

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;
            }
        } );

Upvotes: 1

Related Questions