Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to default p element to "Normal" style in CKEditor

Tags:

ckeditor

If I add a paragraph style to the CKEdtior eg:

format_p: { element : 'p', attributes : { 'style' : 'FONT-SIZE:16px;color:#000000;FONT-STYLE:normal;FONT-FAMILY:Arial, Helvetica, sans-serif;font-weight:normal;' } }

The default style when pressing the enter key is blank. However, if I set the style to "Normal" the style is applied and subsequent p's created by clicking the enter key include the style above.

What I want is for all paragraphs (tag 'p') to use the "Normal" style by default. Is there a way to achieve this?

like image 353
ptutt Avatar asked Nov 14 '22 16:11

ptutt


1 Answers

I think you have use 'contentsCss', have you try 'dataProcessor' like this :

CKEDITOR.on('pluginsLoaded', function (event) {
 event.editor.dataProcessor.dataFilter.addRules({
  elements: {
    p: function (element) {
      // element.attributes
    }
  }
});

event.editor.dataProcessor.htmlFilter.addRules ({
  elements: {
    p: function (element) {
      // element.attributes ...
    }
  }
});
});
like image 138
EpokK Avatar answered Mar 06 '23 16:03

EpokK