Replace <br/> with <p> on paste / paste from word in CKEditor 4

Public

Put this code into the ckeditor.config.js file at the root of your current theme folder. In CKeditor module UI find option Load ckeditor.config.js from the theme path and set as 'Yes'

Get raw version
javascript
  1. // Replace br with p on paste
  2. CKEDITOR.on('instanceReady', function (ev) {
  3. ev.editor.on('paste', function (ev) {
  4. ev.data.dataValue = ev.data.dataValue.replace(/(\<br ?\/?\>)+/gi, '<p>');
  5. ev.data.dataValue = ev.data.dataValue.replace(/(\<div)+/gi, '<p');
  6. ev.data.dataValue = ev.data.dataValue.replace(/(\<\/div\>)+/gi, '</p>');
  7. });
  8. });