Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 28 additions & 32 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -1,43 +1,39 @@
# OS: Linux; Symfony: latest stable; PHP: all the commonly used versions supported by this bundle
name: "Tests - Linux"
name: Tests

on:
pull_request:
push:
branches:
- 'master'

env:
fail-fast: true
branches: [main]

jobs:
tests:
name: "PHP ${{ matrix.php-version }}"
runs-on: 'ubuntu-latest'
continue-on-error: false
checks:
name: PHP ${{ matrix.php }} / Symfony ${{ matrix.symfony }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
php-version: ['7.4', '8.0', '8.1', '8.2', '8.3']
include:
- php: '8.2'
symfony: '7.4.*'
- php: '8.4'
symfony: '8.0.*'
steps:
- name: 'Checkout code'
uses: actions/checkout@v3

- name: 'Install PHP with extensions'
uses: shivammathur/setup-php@2.27.1
- uses: actions/checkout@v7.0.1
- uses: shivammathur/setup-php@2.37.2
with:
coverage: none
php-version: ${{ matrix.php-version }}
tools: composer:v2
php-version: ${{ matrix.php }}
extensions: mbstring, intl
ini-values: date.timezone=UTC

- name: 'Install project dependencies'
run: |
composer global config --no-plugins allow-plugins.symfony/flex true
composer global require --no-progress --no-scripts --no-plugins symfony/flex
composer update --no-interaction --prefer-dist --optimize-autoloader --prefer-stable
vendor/bin/simple-phpunit install
- name: 'Run tests'
env:
SYMFONY_DEPRECATIONS_HELPER: 'max[indirect]=10&max[total]=27'
run: vendor/bin/simple-phpunit -v
tools: composer:v2
coverage: none
- run: composer update --no-interaction --prefer-dist --with-all-dependencies
- run: composer validate --strict
- run: composer test
- run: composer lint
- uses: actions/setup-node@v7.0.0
with:
node-version: 22
cache: npm
- run: npm ci
- run: npm test
- run: npx playwright install --with-deps chromium
- run: npm run test:browser
8 changes: 7 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,10 @@
/composer.lock
/vendor
/Tests/Fixtures/cache
/Tests/Fixtures/logs
/Tests/Fixtures/logs
/.phpunit.cache
/var
/node_modules
/.php-cs-fixer.cache
/test-results
/playwright-report
15 changes: 15 additions & 0 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

declare(strict_types=1);

$finder = PhpCsFixer\Finder::create()
->in(__DIR__.'/src')
->in(__DIR__.'/tests');

return (new PhpCsFixer\Config())
->setRiskyAllowed(false)
->setRules([
'@Symfony' => true,
'strict_param' => true,
])
->setFinder($finder);
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Changelog

## 2.0.0 - Unreleased

- Added Symfony 7.4/8 and TinyMCE 8 Community Edition support.
- Replaced XML DI, Symfony Templating, and Sensio DistributionBundle integration.
- Added JSON-only Twig configuration, a route-based FMElfinder adapter, and an idempotent browser runtime.
- Raised the PHP minimum to 8.2.
202 changes: 38 additions & 164 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,191 +1,65 @@
FMTinyMCEBundle
================
# FMTinyMCEBundle

[TinyMCE](https://github.com/tinymce/tinymce) integration in Symfony
MIT-licensed Symfony 7.4/8 bundle for self-hosted [TinyMCE 8 Community Edition](https://www.tiny.cloud/docs/tinymce/latest/).

The purpose of bundle is to provide seamless integration between elFinder and TinyMCE editor.
## Requirements

### Code Quality Assurance ###
- PHP 8.2 or newer
- Symfony 7.4 or 8.x
- TinyMCE 8 Community Edition (`tinymce/tinymce:^8.9`)

|CoverAlls| License | StyleCI | Version Status |
|-----------------|-----------------|-----------------|-----------------|
|[![Coverage Status](https://coveralls.io/repos/helios-ag/FMTinyMCEBundle/badge.svg?branch=master&service=github)](https://coveralls.io/github/helios-ag/FMTinyMCEBundle?branch=master)|[![License](https://poser.pugx.org/helios-ag/fm-tinymce-bundle/license.svg)](https://packagist.org/packages/helios-ag/fm-tinymce-bundle)|[![StyleCI](https://styleci.io/repos/44680984/shield)](https://styleci.io/repos/44680984)|[![Latest Stable Version](https://poser.pugx.org/helios-ag/fm-tinymce-bundle/v/stable.svg)](https://packagist.org/packages/helios-ag/fm-tinymce-bundle) [![Latest Unstable Version](https://poser.pugx.org/helios-ag/fm-tinymce-bundle/v/unstable.svg)](https://packagist.org/packages/helios-ag/fm-tinymce-bundle)
The bundle is MIT. TinyMCE Community Edition remains GPL-2.0-or-later; use it only where that license is compatible with your application. Tiny Cloud, commercial keys, and premium plugins are not supported.

## Install

| Downloads |
|-----------|
|[![Total Downloads](https://poser.pugx.org/helios-ag/fm-tinymce-bundle/downloads.svg)](https://packagist.org/packages/helios-ag/fm-tinymce-bundle)


**TinyMCE** is a platform independent web-based JavaScript WYSIWYG HTML editor control released as open source under LGPL.

TinyMCE enables you to convert HTML TEXTAREA fields or other HTML elements to editor instances.


**Table of contents**

- [Installation](#installation)
- [Step 1: Installation](#step-1-installation)
- [Step 2: Enable the bundle](#step-2-enable-the-bundle)
- [Basic configuration](#basic-configuration)
- [Add configuration options to your config.yml](#add-configuration-options-to-your-configyml)

## Installation

### Step 1: Installation

Add FMTinyMCEBundle to your composer.json:

```json
{
"require": {
"helios-ag/fm-tinymce-bundle": "~1"
}
}
```bash
composer require helios-ag/fm-tinymce-bundle
```

If you want to override default assets directory of Richfilemanager, add next option.
By default, assets copied to `web/assets/tinymce` or `public/assets/tinymce`
depending on Symfony version

```json
{
"config": {
"tinymce-dir": "web/assets/"
}
}
```

Add composer script

`"FM\\TinyMCEBundle\\Composer\\TinyMCEScriptHandler::copy",`

to scripts section of composer.json
Register the bundle installer in the consuming application's root `composer.json`; Composer does not execute scripts supplied by dependencies:

```json
{
"scripts": {
"symfony-scripts": [
"Incenteev\\ParameterHandler\\ScriptHandler::buildParameters",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache",
"FM\\TinyMCEBundle\\Composer\\TinyMCEcriptHandler::copy",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::prepareDeploymentTarget"
]
}
}
```

Now tell the composer to download the bundle by running the command:

```sh
composer update helios-ag/fm-tinymce-bundle
```

### Step 2: Enable the bundle

Enable the bundle in the kernel:

```php
<?php
// app/AppKernel.php

public function registerBundles()
{
$bundles = array(
// ...
new FM\TinyMCEBundle\FMTinyMCEBundle(),
);
"post-install-cmd": ["FM\\TinyMCEBundle\\Composer\\TinyMCEAssetInstaller::copy"],
"post-update-cmd": ["FM\\TinyMCEBundle\\Composer\\TinyMCEAssetInstaller::copy"]
}
}
```

Run `composer install` or `composer update` after registering it. The installer mirrors TinyMCE from Composer's vendor directory into `public/assets/tinymce`. Override the destination with root-level `extra.tinymce-dir`.

## Basic configuration

### Add configuration options to your config.yml
## Configure

```yaml
fm_tinymce:
instances:
first_instance:
language: en_US
width: 300
height: 400
my_advanced_configuration:
locale: ru_RU
instances:
default:
options:
plugins: [link, image, lists, code]
toolbar: 'undo redo | bold italic | link image | code'
elfinder:
file_picker:
type: fm_elfinder
route: elfinder
route_parameters: { instance: tinymce }
options: { }
```

##Advanced Configuration

To make story short, here example of Integration between TinyMCE and Elfinder bundles

```yaml
fm_tinymce:
instances: # Required
elfinder:
language: ru
image_advtab: true
file_picker_callback: elFinderBrowser
filebrowser_type: fm_elfinder
filebrowser:
route: elfinder
route_parameters:
instance: tinymce
```php
use FM\TinyMCEBundle\Form\Type\TinyMCEType;

$builder->add('body', TinyMCEType::class, ['instance' => 'default']);
```

and configuration for ElFinderBrowser
Use `enabled: false` for a plain textarea and `inline: true` on an instance for an inline editor.

```yaml
fm_elfinder:
instances:
tinymce:
language: ru
editor: tinymce4 #
include_assets: true
relative_path: true
connector:
roots: # at least one root must be defined
uploads:
show_hidden: false
driver: LocalFileSystem
path: uploads
upload_allow: ['all']
```

Full configuration reference example
## Development

```bash
composer test
composer lint
npm test
```

```yaml
fm_tinymce:
enable: true
inline: false
base_path: assets/tinymce/
js_path: assets/tinymce/tinymce.min.js
instances:
default:
language: en_US
width: 600
height: 300
theme: modern
toolbar_item_size: small
menubar: file edit insert view format table tools
image_advtab: false
templates:
templates:
title: ~
content: ~
plugins: ""
relative_urls: false
convert_urls: false
toolbars:
toolbar1: undo redo | styleselect | bold italic | link image
filebrowser_type: fm_elfinder
file_picker_callback: elFinderBrowser
filebrowser:
url: http://localhost/elfinder
route: elfinder
route_parameters:
instance: default
See [UPGRADE-2.0.md](UPGRADE-2.0.md) for breaking changes.
12 changes: 12 additions & 0 deletions UPGRADE-2.0.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Upgrade to 2.0

2.0 requires PHP 8.2+, Symfony 7.4/8.x, and TinyMCE 8 Community Edition.

- Move flat profile settings into `instances.<name>.options`.
- Replace `base_path` and `js_path` with `assets.base_path` and `assets.script_path`.
- Replace `filebrowser_*` and JavaScript `file_picker_callback` with `file_picker.type: fm_elfinder`, route, and route parameters.
- Remove legacy plugins (`print`, `paste`, `contextmenu`, `template`, `fullpage`, and `spellchecker`) and `theme: modern`.
- Replace Symfony Templating calls with `tinymce_configuration()` and `tinymce_asset_url()`.
- Register `FM\\TinyMCEBundle\\Composer\\TinyMCEAssetInstaller::copy` in the root application's `post-install-cmd` and `post-update-cmd` Composer scripts.

The bundle remains MIT. TinyMCE Community Edition is GPL-2.0-or-later and always receives `license_key: gpl`.
Loading