Styling

Paragraph Styles

Using the paragraph_style.min.js plugin it is possible to add custom style on the selected paragraph inside the WYSIWYG HTML editor.

The classes should be defined in CSS, otherwise no changes will be visible on the paragraph's appearance.


You can define your own paragraph styles using the paragraphStyles option. This option is an Object where the key represents the class name and its value is the style name that appears in the dropdown list. It is important to have unique keys otherwise they will not work properly.

By default you can select multiple paragraph styles at a time. If you want to toggle them and allow only one style to be selected at a time use the paragraphMultipleStyles option.

Edit in JSFiddle

HTML

<div id="froala-editor">
  <p>The classes should be defined in CSS, otherwise no changes will be visible on the paragraph's appearance.</p>
</div>

CSS

<style>
  .class1 {
    text-align: center;
    color: red;
  }

  .class2 {
    font-weight: 300;
    font-size: 16px;
  }
</style>

JAVASCRIPT

<script>
  $(function() {
    $('div#froala-editor').froalaEditor({
      paragraphStyles: {
        class1: 'Class 1',
        class2: 'Class 2'
      },
      toolbarButtons: ['bold', 'italic', 'underline', 'strikeThrough', 'fontFamily', 'fontSize', '|', 'paragraphStyle', 'paragraphFormat', 'align', 'undo', 'redo', 'html']
    })
  });
</script>