solilokiam/summernotebundle

This bundle provides a WYSIWYG editor form type based on summernote

0.1 2014-05-20 13:40 UTC

This package is not auto-updated.

Last update: 2024-03-16 13:10:30 UTC


README

What is SummernoteBundle?

Summernotebundle integrates SummerNote WYSIWYG Editor into Symfony form type.

Status

Build Status SensioLabsInsight Latest Stable Version Total Downloads Latest Unstable Version License

Requirements

Minimum requirements for this bundle are:

  • Symfony 2.3
  • Twitter's Bootstrap 3.0
  • jQuery 1.9

Installation

Add SummernoteBundle to your application's composer.json file

{
    "require": {
        "solilokiam/summernotebundle": "dev-master"
    }
}

Add SummernoteBundle to your application's AppKernel.php file

new Solilokiam\SummernoteBundle\SolilokiamSummernoteBundle()

Add Routing information to your application's routing.yml:

solilokiam_summernote_bundle:
    resource: "@SolilokiamSummernoteBundle/Resources/config/routing.xml"
    prefix: /summernote

Minimal Configuration

You must determine which object manager are you using. Currently it only supports Doctrine ODM, and doctrine ORM.

app/config/config.yml

solilokiam_summernote:
    db_driver: mongodb #supported orm,mongodb for odm

You must also tell which class is going to inherit the bundle asset class.

solilokiam_summernote:
    asset_class: Acme\DemoBundle\Document\Asset

An example for the asset class can be like this (doctrine odm):

<?php

namespace Acme\DemoBundle\Document;


use Solilokiam\SummernoteBundle\Model\SummernoteAsset;
use Doctrine\ODM\MongoDB\Mapping\Annotations as MongoDB;

/**
 * Class Asset
 * @package Acme\DemoBundle\Document
 * @MongoDB\Document(collection="assets")
 */
class Asset extends SummernoteAsset
{
    /**
     * @MongoDB\Id(strategy="auto")
     */
    protected $id;

    ...
}

Additional Configuration

Summernote supports some configuration parameters. This parameters can configured application wide in config.yml.

  • width: This is the width of summernote widget
solilokiam_summernote:
   ...
   width: 500
  • focus: Autofocus the widget.
 solilokiam_summernote:
    ...
    focus: true
  • toolbar: Configure toolbars of the widget.Every line in toolbar config is a different button group. You can check available buttons at summernote documentation
  solilokiam_summernote:
    ...
    toolbar:
        - { name: style, buttons: ['bold', 'italic', 'underline', 'clear'] }
        - { name: paragraph, buttons: ['ul', 'ol', 'paragraph']}

Usage

Summernote bundle provides a formtype. This example form uses it:

class TestFormType extends AbstractType
{
    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        ...
        $builder->add('test_text', 'summernote');
        ...

    }
    ...

}

You need also to add some twig tags in your templates to import all CSS and JS needed to make summernote work:

...
{% block stylesheets %}
    {{ summernote_form_stylesheet(form) }}
{% endblock %}

{% block javascripts %}
    {{ summernote_form_javascript(form) }}
{% endblock %}