Skip to content

Commit c492293

Browse files
Merge pull request #541 from BitBagCommerce/add_trix
Trix support
2 parents f03dc4b + 6299858 commit c492293

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+650
-140
lines changed

.github/workflows/build.yml

Lines changed: 32 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -14,27 +14,21 @@ jobs:
1414
tests:
1515
runs-on: ubuntu-latest
1616

17-
name: "Sylius ${{ matrix.sylius }}, PHP ${{ matrix.php }}, Symfony ${{ matrix.symfony }}, MySQL ${{ matrix.mysql }}"
17+
name: "Sylius ${{ matrix.sylius }}, PHP ${{ matrix.php }}, Symfony ${{ matrix.symfony }}, MySQL ${{ matrix.mysql }}, Trix ${{ matrix.trix }}"
1818

1919
strategy:
2020
fail-fast: false
2121
matrix:
22-
php: ["8.0", "8.1", "8.2", "8.3"]
22+
php: ["8.1", "8.2", "8.3"]
2323
symfony: ["^5.4", "^6.4"]
24-
sylius: ["~1.12.0", "~1.13.0", "~1.14.0"]
24+
sylius: ["~1.13.0", "~1.14.0"]
2525
node: ["20.x"]
2626
mysql: ["8.0"]
27+
trix: [false, true]
2728

2829
exclude:
29-
- sylius: "~1.13.0"
30-
php: 8.0
31-
- sylius: "~1.14.0"
32-
php: 8.0
3330
- sylius: "~1.14.0"
3431
symfony: ^5.4
35-
- sylius: "~1.12.0"
36-
php: 8.0
37-
symfony: ^6.4
3832

3933
env:
4034
APP_ENV: test
@@ -115,7 +109,17 @@ jobs:
115109
116110
- name: Install JS dependencies
117111
run: |
118-
(cd tests/Application && yarn install)
112+
cd tests/Application
113+
if [ "${{ matrix.trix }}" = "true" ]; then
114+
yarn add trix
115+
sed -i "s/wysiwyg: 'ckeditor'/wysiwyg: 'trix'/" webpack.config.js
116+
fi
117+
yarn install
118+
119+
- name: Configure Trix if enabled
120+
if: matrix.trix == true
121+
run: |
122+
printf "bit_bag_sylius_cms:\n wysiwyg_editor: trix\n" >> tests/Application/config/packages/bitbag_sylius_cms_plugin.yaml
119123
120124
- name: Prepare test application database
121125
run: |
@@ -145,25 +149,29 @@ jobs:
145149
- name: Run PHPUnit
146150
run: vendor/bin/phpunit --colors=always
147151

152+
- name: Set Behat tags
153+
if: matrix.trix != true
154+
run: echo "BEHAT_TAGS=--tags='~@wysiwyg'" >> $GITHUB_ENV
155+
148156
- name: Run Behat
149-
run: vendor/bin/behat --colors --strict -vvv --no-interaction -f progress || vendor/bin/behat --colors --strict -vvv --no-interaction -f progress --rerun
157+
run: vendor/bin/behat ${{ env.BEHAT_TAGS }} --colors --strict -vvv --no-interaction -f progress || vendor/bin/behat ${{ env.BEHAT_TAGS }} --colors --strict -vvv --no-interaction -f progress --rerun
150158

151159
- name: Upload Behat logs
152-
uses: actions/upload-artifact@v3
160+
uses: actions/upload-artifact@v4
153161
if: failure()
154162
with:
155163
name: Behat logs
156164
path: etc/build/
157165
if-no-files-found: ignore
158166

159-
- name: Failed build Slack notification
160-
uses: rtCamp/action-slack-notify@v2
161-
if: ${{ failure() && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master') }}
162-
env:
163-
SLACK_CHANNEL: ${{ secrets.FAILED_BUILD_SLACK_CHANNEL }}
164-
SLACK_COLOR: ${{ job.status }}
165-
SLACK_ICON: https://github.com/rtCamp.png?size=48
166-
SLACK_MESSAGE: ':x:'
167-
SLACK_TITLE: Failed build on ${{ github.event.repository.name }} repository
168-
SLACK_USERNAME: ${{ secrets.FAILED_BUILD_SLACK_USERNAME }}
169-
SLACK_WEBHOOK: ${{ secrets.FAILED_BUILD_SLACK_WEBHOOK }}
167+
# - name: Failed build Slack notification
168+
# uses: rtCamp/action-slack-notify@v2
169+
# if: ${{ failure() && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master') }}
170+
# env:
171+
# SLACK_CHANNEL: ${{ secrets.FAILED_BUILD_SLACK_CHANNEL }}
172+
# SLACK_COLOR: ${{ job.status }}
173+
# SLACK_ICON: https://github.com/rtCamp.png?size=48
174+
# SLACK_MESSAGE: ':x:'
175+
# SLACK_TITLE: Failed build on ${{ github.event.repository.name }} repository
176+
# SLACK_USERNAME: ${{ secrets.FAILED_BUILD_SLACK_USERNAME }}
177+
# SLACK_WEBHOOK: ${{ secrets.FAILED_BUILD_SLACK_WEBHOOK }}

.github/workflows/coding_standard.yml

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,21 +18,14 @@ jobs:
1818
strategy:
1919
fail-fast: false
2020
matrix:
21-
php: ["8.0", "8.1", "8.2", "8.3"]
21+
php: ["8.1", "8.2", "8.3"]
2222
symfony: ["^5.4", "^6.4"]
23-
sylius: ["~1.12.0", "~1.13.0", "~1.14.0"]
23+
sylius: ["~1.13.0", "~1.14.0"]
2424
node: ["20.x"]
2525

2626
exclude:
27-
- sylius: "~1.13.0"
28-
php: 8.0
29-
- sylius: "~1.14.0"
30-
php: 8.0
3127
- sylius: "~1.14.0"
3228
symfony: ^5.4
33-
- sylius: "~1.12.0"
34-
php: 8.0
35-
symfony: ^6.4
3629

3730
steps:
3831
- uses: actions/checkout@v3

UPGRADE-4.4.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# UPGRADE FROM `v4.3` TO `v4.4`
2+
3+
This update adds support for Trix (as an optional WYSIWYG editor). If you would like to replace CKeditor with Trix review the plugin installation steps.
4+
5+
The configuration has been split and the `fos_ck_editor` configuration is required to be added with this update.
6+
7+
1. Import required CKeditor config in your `config/packages/_sylius.yaml` file:
8+
```yaml
9+
# config/packages/_sylius.yaml
10+
11+
imports:
12+
...
13+
14+
- { resource: "@BitBagSyliusCmsPlugin/Resources/config/fos_ck_editor/fos_ck_editor.yml" }
15+
```
16+
17+
*Or copy contents of `vendor/BitBag/cms-plugin/src/Resources/config/fos_ck_editor/fos_ck_editor.yml` to `config/packages/fos_ck_editor.yaml` file.*
18+
19+
2. If project use a `./vendor/bitbag/cms-plugin/webpack.config.js` file in `webpack.config.js` you need change:
20+
21+
From:
22+
```js
23+
// webpack.config.js
24+
25+
const [ bitbagCmsShop, bitbagCmsAdmin ] = require('./vendor/bitbag/cms-plugin/webpack.config.js')
26+
27+
...
28+
29+
module.exports = [..., bitbagCmsShop, bitbagCmsAdmin];
30+
```
31+
32+
To:
33+
```js
34+
// webpack.config.js
35+
36+
const createCmsConfigs = require('./vendor/bitbag/cms-plugin/webpack.config.js)
37+
38+
...
39+
40+
const [bitbagCmsShop, bitbagCmsAdmin] = createCmsConfigs({
41+
wysiwyg: 'ckeditor' // 'ckeditor' | 'trix'
42+
});
43+
44+
module.exports = [..., bitbagCmsShop, bitbagCmsAdmin];
45+
```

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
"description": "CMS plugin for Sylius applications.",
1010
"license": "MIT",
1111
"require": {
12-
"php": "^8.0",
13-
"sylius/sylius": "^1.12",
12+
"php": "^8.1",
13+
"sylius/sylius": "^1.13",
1414
"league/csv": "^9.1",
1515
"friendsofsymfony/ckeditor-bundle": "^2.0",
1616
"instaclick/php-webdriver": "^1.4",

doc/01.1-webpack-config.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,13 @@
1313

1414
```js
1515
// webpack.config.js
16-
const [ bitbagCmsShop, bitbagCmsAdmin ] = require('./vendor/bitbag/cms-plugin/webpack.config.js')
16+
const createCmsConfigs = require('./vendor/bitbag/cms-plugin/webpack.config.js)
1717
...
1818
19+
const [bitbagCmsShop, bitbagCmsAdmin] = createCmsConfigs({
20+
wysiwyg: 'ckeditor' // 'ckeditor' | 'trix'
21+
});
22+
1923
module.exports = [..., bitbagCmsShop, bitbagCmsAdmin];
2024
```
2125

doc/01.2-webpack-entry.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,12 @@
1515

1616
// Shop config
1717
.addEntry('bitbag-cms-shop', 'vendor/bitbag/cms-plugin/src/Resources/assets/shop/entry.js')
18-
19-
// Admin config
18+
19+
// Admin config - add one of the following entries (CKeditor or Trix)
20+
// CKeditor
2021
.addEntry('bitbag-cms-admin', 'vendor/bitbag/cms-plugin/src/Resources/assets/admin/entry.js')
22+
// Trix
23+
.addEntry('bitbag-cms-admin', 'vendor/bitbag/cms-plugin/src/Resources/assets/admin/trix-entry.js')
2124
```
2225

2326
2. Add encore functions to your templates

doc/01.3-import-entry.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616
// ./assets/shop/entry.js
1717
import '../../vendor/bitbag/cms-plugin/src/Resources/assets/shop/entry.js';
1818

19-
// ./assets/admin/entry.js
19+
// ./assets/admin/entry.js - choose one of the following entries (CKeditor or Trix)
20+
//CkEditor
2021
import '../../vendor/bitbag/cms-plugin/src/Resources/assets/admin/entry.js';
22+
// Trix
23+
import '../../vendor/bitbag/cms-plugin/src/Resources/assets/admin/trix-entry.js';
2124
```

doc/01.4-custom-solution.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,15 @@ Main entry points:
1111
```js
1212
// shop
1313
.addEntry('/vendor/bitbag/cms-plugin/src/Resources/assets/shop/entry.js')
14+
```
1415

16+
Choose one of the following entries (CKeditor or Trix):
17+
```js
1518
// admin
19+
// Ckeditor
1620
.addEntry('/vendor/bitbag/cms-plugin/src/Resources/assets/admin/entry.js')
21+
// Trix
22+
.addEntry('/vendor/bitbag/cms-plugin/src/Resources/assets/admin/trix-entry.js')
1723
```
1824

1925
Style entry points:

doc/01.5-non-webpack.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,22 @@ $ bin/console assets:install
1717
```
1818

1919
2. Add twig inclusions in your templates:
20+
21+
(select one of the following options, depending on the editor you want to use: Trix or CKEditor)
2022
```twig
23+
{# CKeditor config #}
2124
{# @SyliusAdminBundle/_scripts.html.twig #}
2225
{% include '@SyliusUi/_javascripts.html.twig' with {
2326
'path': 'bundles/bitbagsyliuscmsplugin/build/bitbag-cms-admin.js'
2427
} %}
28+
{# end - CKeditor config #}
29+
30+
{# Trix config #}
31+
{# @SyliusAdminBundle/_scripts.html.twig #}
32+
{% include '@SyliusUi/_javascripts.html.twig' with {
33+
'path': 'vendor/bitbag/cms-plugin/src/Resources/assets/trix-entry.js'
34+
} %}
35+
{# end - Trix config #}
2536
2637
{# @SyliusAdminBundle/_styles.html.twig #}
2738
{% include '@SyliusUi/_stylesheets.html.twig' with {

doc/ckeditor-config.md

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
1. Add plugin dependencies to your `config/bundles.php` file:
2+
3+
```php
4+
return [
5+
...
6+
7+
FOS\CKEditorBundle\FOSCKEditorBundle::class => ['all' => true],
8+
BitBag\SyliusCmsPlugin\BitBagSyliusCmsPlugin::class => ['all' => true],
9+
];
10+
```
11+
12+
2. Install CKeditor ([FOS CKEditor](https://symfony.com/doc/master/bundles/FOSCKEditorBundle/usage/ckeditor.html))
13+
14+
```bash
15+
$ bin/console ckeditor:install
16+
```
17+
18+
**Note.** If you have an issue with CKEditor not running, please try installing it using the `4.22.1` tag:
19+
20+
```bash
21+
$ bin/console ckeditor:install --tag=4.22.1
22+
```
23+
24+
For more information regarding the `4.22.1` tag, please visit the #485 issue.
25+
26+
3. Since FOSCKEditorBundle 2.0, to make Twig render the WYSIWYG editor, you must add some configuration under the `twig.form_themes` config key:
27+
28+
```yaml
29+
# Symfony 2/3: app/config/config.yml
30+
# Symfony 4: config/packages/twig.yaml
31+
32+
twig:
33+
form_themes:
34+
- '@FOSCKEditor/Form/ckeditor_widget.html.twig'
35+
- '@BitBagSyliusCmsPlugin/Form/ckeditor_widget.html.twig'
36+
```
37+
38+
4. Import required CKeditor config in your `config/packages/_sylius.yaml` file:
39+
```yaml
40+
# config/packages/_sylius.yaml
41+
42+
imports:
43+
...
44+
45+
- { resource: "@BitBagSyliusCmsPlugin/Resources/config/fos_ck_editor/fos_ck_editor.yml" }
46+
```
47+
48+
Continue with the next installation steps

0 commit comments

Comments
 (0)