How to add a custom paragraph format in CKEditor

后端 未结 2 580
野的像风
野的像风 2021-01-18 01:56

In my project I have a requirement to remove the paragraph format like \"Address\" and \"Formatted\" from the drop down and to add a new custom format called \"Links\" which

2条回答
  •  猫巷女王i
    2021-01-18 02:15

    Use CKEDITOR.config.formatTags to specify some new formatting:

    CKEDITOR.replace( 'editor1', {
        format_tags: 'p;h2;h3;pre;links', // entries is displayed in "Paragraph format"
        format_links: {
            name: 'Links',
            element: 'span',
            styles: {
                color: 'red',
                'font-family': 'arial',
                'font-weight': 'bold'
            }
        }
    } );
    

    To know more about styles see how CKEDITOR.styleSet works. Also note that since CKEditor 4.1, removing styles from "Paragraph format" has an impact on Advanced Content Filter.

提交回复
热议问题