Download the PHP package monsieurbiz/sylius-rich-editor-plugin without Composer

On this page you can find all versions of the php package monsieurbiz/sylius-rich-editor-plugin. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package sylius-rich-editor-plugin

Sylius Rich Editor

Rich Editor Plugin license Tests Status Recipe Status Security Status

This plugin adds a rich editor on the fields you want. Now you can manage your content very easily!

Compatibility

Sylius Version PHP Version
1.11 8.0 - 8.1
1.12 8.1 - 8.2
1.13 8.1 - 8.2

Installation

Require the plugin

If you want to use our recipes, you can configure your composer.json by running:

For the installation without flex, follow these additional steps

Change your `config/bundles.php` file to add the line for the plugin : Then create the config file in `config/packages/monsieurbiz_sylius_rich_editor_plugin.yaml` : Finally import the routes in `config/routes/monsieurbiz_sylius_rich_editor_plugin.yaml` :

Correct Twig\Extra\Intl\IntlExtension conflict

If the recipe did not comment it, update the file config/packages/twig.yaml to comment or remove the IntlExtension declaration :

Install the assets

If the auto-script is not in your composer.json project, you can install the assets with the following command:

Use it with the Sylius Media Manager

You don't need to do something, everything is compatible.

If you used the rich editor before using the media manager, you need to override the form theme of the media manager plugin :

Use the Rich Editor

Update your form type

To make a field use the rich editor, you must use the RichEditorType type for it.
We have an example of implementation in the file for the test application.

If your field has some data already, like some previous text before installing this plugin, then we will convert it for you as an HTML Element which contains… HTML.

This way you will be able to use our plugin right away without risking any data lost!

To make it clear: to have rich editor for original admin fields, like Product description, Taxon desription etc. you have to update each form type by an extension as the example shows above.

Call twig render

To display the content of the rich editor field you must call the twig filter:

You can see an example in the file for the test application

Custom rendering of elements

You can also render your elements with some custom DOM around that. To do so, you have access to a twig filter that gives you the elements list :

And then you can either render them all :

Or one by one :

Filter the elements

If you want to filter the elements which are available for your field, you can use the tags option when you build your form.
As example:

In that example, all Ui Elements with the tag default will be excluded, then the Ui Elements with the tag product will be included.
Don't worry, you can add this filter afterwards, we won't remove the already present Ui Elements of your field. But we won't allow to add more if they don't have one of the allowed tags!

Order matters

The order of the tags matters! The first tag will be less important then the second.
As example, if you have 3 Ui Elements with the following tags:

And you set the tags of your field to -tag1, tag2, -tag3, then the only available Ui Element will be: element2.
They all have the tag2 to include them, but the element1 and element3 have the tag3 which is excluding them after being both included.

Example of setting tags to an Ui Element using yaml

Deactivate an available element

Here is what really happens when deactivating an Ui Element:

Define the overload of a proposed UiElement in your configuration folder, let's say in config/packages/monsieurbiz_sylius_richeditor_plugin.yaml as example.

Available elements

Row Element (Layout)

It contains another rich editor field, each element will be displayed one below the other (as rows…).

Column Element (Layout)

It contains another rich editor field, each element will be displayed side by side (as columns…).

By using this element in the Row element, you will be able to build some layout like the screenshot below.
You can distinguish the Row element and the Column element by their dotted borders.

HTML Element

Markdown Element

You can use MONSIEURBIZ_SYLIUS_RICH_EDITOR_ENABLED_HIGHLIGHT_JS_SHOP to enable code highlighting in the shop. Also you can change the theme with MONSIEURBIZ_SYLIUS_RICH_EDITOR_ENABLED_HIGHLIGHT_JS_THEME.

Text element

Quote element

Image element

Video element

Button element

Title element

Separator element

Youtube element

Image collection element

Example of a rich product description

Admin form with preview

Front display

Create your own elements

In this example, we will add a Google Maps element.

With the Maker Bundle, you can create a new UiElement very easily:

Then you will have to answer some questions, or you can add arguments to the command to avoid the questions.

Just add the translations!

Define your UiElement (for PHP < 8.1)

Tips: If you are using PHP 8.1 or newer, you can use the #[AsUiElement] attribute to define your UiElement. You can skip this step.

Define your UiElement in your configuration folder, let's say in config/packages/monsieurbiz_sylius_richeditor_plugin.yaml as example.

You can use your own Ui Element object if needed. Be sure to implement the \MonsieurBiz\SyliusRichEditorPlugin\UiElement\UiElementInterface interface.
A trait is there for you 🤗 as well. This is very useful when you need to do some custom work in your templates, it's like having a helper around. The Ui Element is then available via the ui_element variable in your templates.

Create the Form Type we use in admin to fill your UiElement

For PHP 8.1 and newer, you can use the #[AsUiElement] attribute to define your UiElement. For example:

The title, description and templates values are generated automatically from the code. In this example :

But you can override them if you want:

Add your translations of course

Here is an example of possible translation for the GMap element :

Create the templates to render it in front and in admin

You have to create a template for the front and also for the admin's preview.

Here is an example of a simple template for this our which can be used in front and admin:

The result !

The element is in the UI Elements list

You now have a form to edit it (your form!)

And we use your templates to render your UiElement

In admin :

In front :

File in fixtures management

In some cases you will want to add UI elements to your content fixtures which are Rich Editor fields. If you need files in your UI elements, you can use a dedicated fixture. It is used as follows.

The example below will copy files to public/media/image/foo/bar1.png and public/media/foo/file.pdf.

Now you can use files in your content fixtures:

Wireframes

You can add a wireframe to your UiElement. It will be displayed in the admin form to help the user to understand what the UiElement is about. The file can be either:

Wysiwyg Type

The WysiwygType form type is a custom form type provided by the MonsieurBiz Sylius Rich Editor plugin. It extends the Symfony's TextareaType and provides a rich text editor interface in the admin form. It will work only in admin.

Basic Usage

To use the WysiwygType in your form, you can add it to your form builder like this:

Options

The WysiwygType form type accepts several options:

Here is an example of how to use these options:

In this example, we have set a custom editor type, increased the height of the editor, set the locale to French, chosen a full toolbar, specified the buttons to be displayed in the toolbar, and provided some custom configuration options for the editor.

Contributing

You can open an issue or a Pull Request if you want! 😘
Thank you!


All versions of sylius-rich-editor-plugin with dependencies

PHP Build Version
Package Version
Requires php Version ^8.0
sylius/sylius Version >=1.11 <1.14
twig/markdown-extra Version ^2.16|^3.12
twig/extra-bundle Version ^2.16|^3.12
league/commonmark Version ^2.5
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package monsieurbiz/sylius-rich-editor-plugin contains the following files

Loading the files please wait ....