FriendsOfSylius / AwesomeSylius

Welcome to the SyliusGoose, which is the place you will find more information about Sylius related things.
110 stars 20 forks source link

Product description WYSIWYG Editor Sylius Plugin #9

Closed gabiudrescu closed 6 years ago

gabiudrescu commented 6 years ago

Available here: https://github.com/Lead-Ext/LeadExtWysiwygEditorPlugin

Often asked in Sylius slack (support) channel.

gabiudrescu commented 6 years ago

dunno if we should add it because I don't know if it works out of the box. which brings me to the question: what are the criteria of acceptance for adding stuff to our recommendation repo? but this is for another issue.

bitbager commented 6 years ago

Personally, I used https://symfony.com/doc/master/bundles/IvoryCKEditorBundle/installation.html for my projects. Enabling it in Sylius is straightforward:

  1. Install CKEditor as a Symfony bundle
  2. Add CKEditor JS dependencies to your Twig
  3. Write Symfony form extension for the form you want to customize. For example, for product description it will look like this:
<?php

declare(strict_types=1);

namespace AdminBundle\Form\Extension;

use Ivory\CKEditorBundle\Form\Type\CKEditorType;
use Sylius\Bundle\ProductBundle\Form\Type\ProductTranslationType;
use Symfony\Component\Form\AbstractTypeExtension;
use Symfony\Component\Form\FormBuilderInterface;

final class ProductTranslationTypeExtension extends AbstractTypeExtension
{
    /**
     * {@inheritdoc}
     */
    public function buildForm(FormBuilderInterface $builder, array $options): void
    {
        $builder
            ->remove('description')
            ->add('description', CKEditorType::class, [
                'required' => false,
                'label' => 'sylius.form.product.description',
            ])
        ;
    }

    /**
     * {@inheritdoc}
     */
    public function getExtendedType(): string
    {
        return ProductTranslationType::class;
    }
}

Maybe we can create some basic tuts in the SyliusGoose with the markdown files where we will put simple "How to?" like this?

stefandoorn commented 6 years ago

Or a simple plugin that defines some of these extensions for the user which can be turned on/off by setting some config parameters :-) But ja, that takes more time than a simple tutorial.

I find TinyMCE not the best, it also seems to be using an API key. CKEditor seems better to me.

bitbager commented 6 years ago

Yeap, we are using it a lot with our CmsPlugin and for now, we are quite satisfied with it.

bitbager commented 6 years ago

Added the StepByStep tutorial here - https://github.com/friendsofsylius/SyliusGoose/blob/master/StepByStep/WYSIWYG_EDITOR_IN_ANY_FORM.md