简体   繁体   中英

Set Default Style From Style Menu in CKEditor

I am new to CKEditor. I want to add some style changes in CKEditor when I enter the text in CKEditor.

My Questions are

1.There is anyway when I am press Enter button, the editor automatically add these elements to the Editing area. I have tried many way but I failed. I'm using Following Method's to do this.

<p name='change'> or <p class='change'> (Choose any one)

 config.enterMode = CKEDITOR.ENTER_P;

Then add this line to config.js File.But I'm not able to customize the <p> When I press Enter button.

  1. Is there any way to set a default style Element. But I'm customizing it into

    config.format_p = { element : 'p',name:'Normal',attributes:{'name':'change'}};

So, It didn't set a default value. But I'm changing it into

config.format_p = { element : 'p',name:'Normal'};

It will be automatically set into default. I'm searching google for last 20 hours and I got set default font size and name for adding following into config.js

CKEDITOR.config.font_defaultLabel = 'Arial';
CKEDITOR.config.fontSize_defaultLabel = '20'; 

But there is no way to set default style.Please any one Know about this help me.It's important. Simply I just want to add into editor when I'm pressing ENTER button.

<p name='change'> or <p class='change'>

Write jquery on CKEditor page Try this:

Your HTML should be like this:

Your Jquery Code:

<script type="text/javascript">
    $(document).ready(function () {
        $("#testDemo").addClass("change");
    });
</script>

it will add class to your <p> like this <p class='change'> .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM