├── .scrutinizer.yml ├── CHANGELOG.md ├── CONTRIBUTING.md ├── LICENSE ├── README.md ├── composer.json ├── doc └── img │ ├── config_fields.png │ ├── icons_default.png │ ├── icons_reduced.png │ └── menu.png ├── registration.php └── src ├── Model └── Config │ └── Source │ └── Toolbar.php ├── Plugin ├── WysiwygConfigPlugin.php └── WysiwygConfigProviderPlugin.php └── etc ├── adminhtml ├── di.xml └── system.xml ├── config.xml └── module.xml /.scrutinizer.yml: -------------------------------------------------------------------------------- 1 | filter: 2 | excluded_paths: 3 | - 'tests/*' 4 | 5 | build: 6 | environment: 7 | php: 7.3 8 | tests: 9 | override: 10 | - true 11 | nodes: 12 | analysis: 13 | dependencies: 14 | after: 15 | - vendor/bin/phpcs --config-set installed_paths ../../magento/magento-coding-standard/ # Scrutinizer does not run composer scripts 16 | tests: 17 | override: 18 | - php-scrutinizer-run 19 | - phpcs-run 20 | 21 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | All notable changes to this project will be documented in this file. 3 | 4 | The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) 5 | and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). 6 | 7 | ## [1.0.0] - 2020-11-27 8 | ### Added 9 | 10 | - Configuration settings for icons and buttons of WYSIWYG editors 11 | - Support for PageBuilder (Magento Commerce) 12 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing to IntegerNet_ConfigurableWysiwyg 2 | We love your input! We want to make contributing to this project as easy and transparent as possible, whether it's: 3 | 4 | - Reporting a bug 5 | - Discussing the current state of the code 6 | - Submitting a fix 7 | - Proposing new features 8 | - Becoming a maintainer 9 | 10 | ## We Develop with Github 11 | We use github to host code, to track issues and feature requests, as well as accept pull requests. 12 | 13 | ## We Use [Github Flow](https://guides.github.com/introduction/flow/index.html), So All Code Changes Happen Through Pull Requests 14 | Pull requests are the best way to propose changes to the codebase (we use [Github Flow](https://guides.github.com/introduction/flow/index.html)). We actively welcome your pull requests: 15 | 16 | 1. Fork the repo and create your branch from `master`. 17 | 2. If you've added code that should be tested, add tests. 18 | 3. If you've changed APIs, update the documentation. 19 | 4. Ensure the test suite passes. 20 | 5. Make sure your code lints. 21 | 6. Issue that pull request! 22 | 23 | ## Any contributions you make will be under the MIT Software License 24 | In short, when you submit code changes, your submissions are understood to be under the same [MIT License](http://choosealicense.com/licenses/mit/) that covers the project. Feel free to contact the maintainers if that's a concern. 25 | 26 | ## Report bugs using Github's [issues](https://github.com/integer-net/magento2-configurable-wysiwyg/issues) 27 | We use GitHub issues to track public bugs. Report a bug by [opening a new issue](https://github.com/integer-net/magento2-configurable-wysiwyg/issues/new); it's that easy! 28 | 29 | ## Write bug reports with detail, background, and sample code 30 | [This is an example](http://stackoverflow.com/q/12488905/180626) of a bug report I wrote, and I think it's not a bad model. Here's [another example from Craig Hockenberry](http://www.openradar.me/11905408), an app developer whom I greatly respect. 31 | 32 | **Great Bug Reports** tend to have: 33 | 34 | - A quick summary and/or background 35 | - Steps to reproduce 36 | - Be specific! 37 | - Give sample code if you can. [My stackoverflow question](http://stackoverflow.com/q/12488905/180626) includes sample code that *anyone* with a base R setup can run to reproduce what I was seeing 38 | - What you expected would happen 39 | - What actually happens 40 | - Notes (possibly including why you think this might be happening, or stuff you tried that didn't work) 41 | 42 | People *love* thorough bug reports. I'm not even kidding. 43 | 44 | ## Pull Requests 45 | 46 | - **[PSR-2 Coding Standard](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md)** - Check the code style with ``$ composer check-style`` and fix it with ``$ composer fix-style``. 47 | 48 | - **Add tests!** - Your patch won't be accepted if it doesn't have tests. 49 | 50 | - **Document any change in behaviour** - Make sure the `README.md` and any other relevant documentation are kept up-to-date. 51 | 52 | - **Consider our release cycle** - We try to follow [SemVer v2.0.0](http://semver.org/). Randomly breaking public APIs is not an option. 53 | 54 | - **Create feature branches** - Don't ask us to pull from your master branch. 55 | 56 | - **One pull request per feature** - If you want to do more than one thing, send multiple pull requests. 57 | 58 | - **Send coherent history** - Make sure each individual commit in your pull request is meaningful. If you had to make multiple intermediate commits while developing, please [squash them](http://www.git-scm.com/book/en/v2/Git-Tools-Rewriting-History#Changing-Multiple-Commit-Messages) before submitting. 59 | 60 | ## License 61 | By contributing, you agree that your contributions will be licensed under its MIT License. 62 | 63 | ## References 64 | This document was adapted from the open-source contribution guidelines for [Facebook's Draft](https://github.com/facebook/draft-js/blob/a9316a723f9e918afde44dea68b5f9f39b7d9b00/CONTRIBUTING.md) with additions from [ThePhpLeague Template](https://github.com/thephpleague/skeleton) -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 integer_net GmbH 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # IntegerNet_ConfigurableWysiwyg Magento 2 Module 2 |
3 | 4 | [![Latest Version on Packagist][ico-version]][link-packagist] 5 | [![Software License][ico-license]](LICENSE.md) 6 | ![Supported Magento Versions][ico-compatibility] 7 | 8 | [![Quality Score][ico-code-quality]][link-code-quality] 9 | [![Maintainability][ico-maintainability]][link-maintainability] 10 |
11 | 12 | --- 13 | 14 | Configure the Magento 2 WYSIWYG Editors: Remove buttons, adjust headings, ... 15 | 16 | ## Requirements 17 | 18 | - Magento 2.3.x or 2.4.x 19 | 20 | ## Installation 21 | 22 | 1. Install it into your Magento 2 project with composer: 23 | ``` 24 | composer require integer-net/magento2-configurable-wysiwyg 25 | ``` 26 | 27 | 2. Enable module 28 | ``` 29 | bin/magento setup:upgrade 30 | ``` 31 | 32 | ## Configuration 33 | 34 | You can find all configuration settings for this module in Store -> Configuration -> General -> Content Management: 35 | 36 | ![Menu](doc/img/menu.png) 37 | 38 | These are the new fields and their default settings: 39 | 40 | ![Configuration fields](doc/img/config_fields.png) 41 | 42 | ### Toolbar Elements 43 | 44 | This defines which icons will be available in the WYSIWYG editors. By default it looks like this: 45 | 46 | ![Default icons](doc/img/icons_default.png) 47 | 48 | If you deselect some of the entries, it can look as follows: 49 | 50 | ![Reduced Icons](doc/img/icons_reduced.png) 51 | 52 | ### Show "Insert Variable" button 53 | 54 | This button is used to insert variable values into content, like the store name. It's not used very often so it's probably safe to disable that button. 55 | 56 | ### Show "Insert Widget" button 57 | 58 | You only need that button if you are using Widgets (i.e. for inserting product lists, dynamic links or static blocks) in Magento CMS. 59 | 60 | ### Show "Insert Image" button 61 | 62 | You might want to disable this button if you don't want to insert images directly into WYSIWYG fields. 63 | 64 | ## Usage 65 | 66 | If you change anything on the configuration page and click "Save Config", the settings will be applied to all WYSIWYG fields from then on. 67 | 68 | ## Changelog 69 | 70 | Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently. 71 | 72 | ## Contributing 73 | 74 | Please see [CONTRIBUTING](CONTRIBUTING.md) for details. 75 | 76 | ## Security 77 | 78 | If you discover any security related issues, please email security@integer-net.de instead of using the issue tracker. 79 | 80 | ## Credits 81 | 82 | - [Andreas von Studnitz][link-author] 83 | - [All Contributors][link-contributors] 84 | 85 | ## License 86 | 87 | The MIT License (MIT). Please see [License File](LICENSE) for more information. 88 | 89 | [ico-version]: https://img.shields.io/packagist/v/integer-net/magento2-configurable-wysiwyg.svg?style=flat-square 90 | [ico-license]: https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square 91 | [ico-code-quality]: https://img.shields.io/scrutinizer/g/integer-net/magento2-configurable-wysiwyg.svg?style=flat-square 92 | [ico-maintainability]: https://img.shields.io/codeclimate/maintainability/integer-net/magento2-configurable-wysiwyg?style=flat-square 93 | [ico-compatibility]: https://img.shields.io/badge/magento-2.3%20|%202.4-brightgreen.svg?logo=magento&longCache=true&style=flat-square 94 | 95 | [link-packagist]: https://packagist.org/packages/integer-net/magento2-configurable-wysiwyg 96 | [link-scrutinizer]: https://scrutinizer-ci.com/g/integer-net/magento2-configurable-wysiwyg/code-structure 97 | [link-code-quality]: https://scrutinizer-ci.com/g/integer-net/magento2-configurable-wysiwyg 98 | [link-maintainability]: https://codeclimate.com/github/integer-net/magento2-configurable-wysiwyg 99 | [link-author]: https://github.com/integer-net 100 | [link-contributors]: ../../contributors 101 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "integer-net/magento2-configurable-wysiwyg", 3 | "description": "Configure the Magento 2 WYSIWYG Editors: Remove buttons, adjust headings, ... ", 4 | "type": "magento2-module", 5 | "license": "MIT", 6 | "authors": [ 7 | { 8 | "name": "Andreas von Studnitz", 9 | "email": "avs@integer-net.de" 10 | } 11 | ], 12 | "minimum-stability": "stable", 13 | "autoload": { 14 | "files": [ 15 | "registration.php" 16 | ], 17 | "psr-4": { 18 | "IntegerNet\\ConfigurableWysiwyg\\": "src" 19 | } 20 | }, 21 | "repositories": [ 22 | { 23 | "type": "composer", 24 | "url": "https://repo.magento.com/" 25 | } 26 | ], 27 | "require": { 28 | "php": "~7.1||~7.2||~7.3||~7.4||~8.1", 29 | "magento/framework": "^102.0.0||^103.0.0" 30 | }, 31 | "require-dev": { 32 | "roave/security-advisories": "dev-master", 33 | "pds/skeleton": "^1.0", 34 | "phpro/grumphp": "^v0.21.0", 35 | "phpstan/phpstan": "^0.12.0", 36 | "squizlabs/php_codesniffer": "^3.5", 37 | "magento/magento-coding-standard": "@dev" 38 | }, 39 | "scripts": { 40 | "post-install-cmd": [ 41 | "vendor/bin/phpcs --config-set installed_paths ../../magento/magento-coding-standard/" 42 | ], 43 | "post-update-cmd": [ 44 | "vendor/bin/phpcs --config-set installed_paths ../../magento/magento-coding-standard/" 45 | ] 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /doc/img/config_fields.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/integer-net/magento2-configurable-wysiwyg/591013211f2b42c25fa9247524318e08c9651202/doc/img/config_fields.png -------------------------------------------------------------------------------- /doc/img/icons_default.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/integer-net/magento2-configurable-wysiwyg/591013211f2b42c25fa9247524318e08c9651202/doc/img/icons_default.png -------------------------------------------------------------------------------- /doc/img/icons_reduced.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/integer-net/magento2-configurable-wysiwyg/591013211f2b42c25fa9247524318e08c9651202/doc/img/icons_reduced.png -------------------------------------------------------------------------------- /doc/img/menu.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/integer-net/magento2-configurable-wysiwyg/591013211f2b42c25fa9247524318e08c9651202/doc/img/menu.png -------------------------------------------------------------------------------- /registration.php: -------------------------------------------------------------------------------- 1 | 12 | */ 13 | 14 | namespace IntegerNet\ConfigurableWysiwyg\Model\Config\Source; 15 | 16 | class Toolbar implements \Magento\Framework\Option\ArrayInterface 17 | { 18 | public function toOptionArray() 19 | { 20 | return [ 21 | ['value' => 'undo', 'label' => __('Undo')], 22 | ['value' => 'redo', 'label' => __('Redo')], 23 | ['value' => 'formatselect', 'label' => __('Format Select')], 24 | ['value' => 'bold', 'label' => __('Bold')], 25 | ['value' => 'italic', 'label' => __('Italic')], 26 | ['value' => 'underline', 'label' => __('Underline')], 27 | ['value' => 'alignleft', 'label' => __('Align Left')], 28 | ['value' => 'aligncenter', 'label' => __('Align Center')], 29 | ['value' => 'alignright', 'label' => __('Align Right')], 30 | ['value' => 'bullist', 'label' => __('Bullet List')], 31 | ['value' => 'numlist', 'label' => __('Numbered List')], 32 | ['value' => 'link', 'label' => __('Link')], 33 | ['value' => 'table', 'label' => __('Table')], 34 | ['value' => 'charmap', 'label' => __('Character Map')], 35 | ]; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/Plugin/WysiwygConfigPlugin.php: -------------------------------------------------------------------------------- 1 | 12 | */ 13 | 14 | namespace IntegerNet\ConfigurableWysiwyg\Plugin; 15 | 16 | use Magento\Cms\Model\Wysiwyg\Config; 17 | use Magento\Framework\App\Config\ScopeConfigInterface; 18 | use Magento\Framework\Data\Wysiwyg\ConfigProviderInterface; 19 | 20 | class WysiwygConfigPlugin 21 | { 22 | /** 23 | * @var ScopeConfigInterface 24 | */ 25 | private $scopeConfig; 26 | 27 | public function __construct( 28 | ScopeConfigInterface $scopeConfig 29 | ) { 30 | $this->scopeConfig = $scopeConfig; 31 | } 32 | 33 | public function beforeGetConfig( 34 | \Magento\Cms\Model\Wysiwyg\Config $subject, 35 | $data = [] 36 | ) { 37 | if (isset($data['add_variables'])) { 38 | $data['add_variables'] = $this->scopeConfig->isSetFlag('cms/wysiwyg/add_variable'); 39 | } 40 | if (isset($data['add_widgets'])) { 41 | $data['add_widgets'] = $this->scopeConfig->isSetFlag('cms/wysiwyg/add_widget'); 42 | } 43 | if (isset($data['add_images'])) { 44 | $data['add_images'] = $this->scopeConfig->isSetFlag('cms/wysiwyg/add_image'); 45 | } 46 | 47 | return [$data]; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/Plugin/WysiwygConfigProviderPlugin.php: -------------------------------------------------------------------------------- 1 | 12 | */ 13 | 14 | namespace IntegerNet\ConfigurableWysiwyg\Plugin; 15 | 16 | use Magento\Cms\Model\Wysiwyg\CompositeConfigProvider; 17 | use Magento\Framework\App\Config\ScopeConfigInterface; 18 | use Magento\Framework\Data\Wysiwyg\ConfigProviderInterface; 19 | use Magento\Framework\Exception\ConfigurationMismatchException; 20 | use Psr\Log\LoggerInterface; 21 | 22 | class WysiwygConfigProviderPlugin 23 | { 24 | /** 25 | * @var array 26 | */ 27 | private $additionalSettings; 28 | /** 29 | * @var ScopeConfigInterface 30 | */ 31 | private $scopeConfig; 32 | /** 33 | * @var CompositeConfigProvider 34 | */ 35 | private $compositeConfigProvider; 36 | /** 37 | * @var LoggerInterface 38 | */ 39 | private $logger; 40 | 41 | public function __construct( 42 | array $additionalSettings, 43 | ScopeConfigInterface $scopeConfig, 44 | CompositeConfigProvider $compositeConfigProvider, 45 | LoggerInterface $logger 46 | ) { 47 | $this->additionalSettings = $additionalSettings; 48 | $this->scopeConfig = $scopeConfig; 49 | $this->compositeConfigProvider = $compositeConfigProvider; 50 | $this->logger = $logger; 51 | } 52 | 53 | public function afterGetConfig( 54 | ConfigProviderInterface $subject, 55 | \Magento\Framework\DataObject $result 56 | ) { 57 | $toolbar = implode(' ', explode(',', $this->scopeConfig->getValue('cms/wysiwyg/toolbar'))); 58 | 59 | try { 60 | $tinyMceVersionIdentifier = $this->getTinyMceVersionIdentifier($result); 61 | } catch (ConfigurationMismatchException $e) { 62 | $this->logger->error($e->getMessage()); 63 | return $result; 64 | } 65 | $result->setData( 66 | $tinyMceVersionIdentifier, 67 | [ 68 | 'toolbar' => $toolbar, 69 | 'plugins' => $result->getData($tinyMceVersionIdentifier)['plugins'], 70 | 'content_css' => $result->getData($tinyMceVersionIdentifier)['content_css'], 71 | ] 72 | ); 73 | 74 | $result->setData('add_variables', $this->scopeConfig->isSetFlag('cms/wysiwyg/add_variable')); 75 | $result->setData('add_widgets', $this->scopeConfig->isSetFlag('cms/wysiwyg/add_widget')); 76 | $result->setData('add_images', $this->scopeConfig->isSetFlag('cms/wysiwyg/add_image')); 77 | 78 | $plugins = $result->getData('plugins'); 79 | foreach ($plugins as $key => $plugin) { 80 | if ($plugin['name'] == 'magentovariable' && !$this->scopeConfig->isSetFlag('cms/wysiwyg/add_variable')) { 81 | unset($plugins[$key]); 82 | } 83 | if ($plugin['name'] == 'magentowidget' && !$this->scopeConfig->isSetFlag('cms/wysiwyg/add_widget')) { 84 | unset($plugins[$key]); 85 | } 86 | if ($plugin['name'] == 'image' && !$this->scopeConfig->isSetFlag('cms/wysiwyg/add_image')) { 87 | unset($plugins[$key]); 88 | $result->unsetData('files_browser_window_width'); 89 | $result->unsetData('files_browser_window_height'); 90 | $result->unsetData('files_browser_window_url'); 91 | } 92 | } 93 | 94 | $result->setData('plugins', array_values($plugins)); 95 | 96 | return $result; 97 | } 98 | 99 | /** 100 | * @throws ConfigurationMismatchException 101 | */ 102 | private function getTinyMceVersionIdentifier(\Magento\Framework\DataObject $result): string 103 | { 104 | if (!empty($result->getData('tinymce'))) { 105 | return 'tinymce'; 106 | } 107 | if (!empty($result->getData('tinymce4'))) { 108 | return 'tinymce4'; 109 | } 110 | throw new ConfigurationMismatchException( 111 | __('No supported version of TinyMCE found.') 112 | ); 113 | } 114 | } 115 | -------------------------------------------------------------------------------- /src/etc/adminhtml/di.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 7 | 8 | 9 | 11 | 12 | 13 | 15 | 16 | 17 | 18 | 19 | 20 | Magento\Widget\Model\Widget\Config 21 | 22 | 23 | .pagebuilder-content-type 24 | 25 | 26 | Paragraph 27 | p 28 | 29 | 30 | Heading 1 31 | h1 32 | 33 | 34 | Heading 2 35 | h2 36 | 37 | 38 | Heading 3 39 | h3 40 | 41 | 42 | Heading 4 43 | h4 44 | 45 | 46 | Heading 5 47 | h5 48 | 49 | 50 | Heading 6 51 | h6 52 | 53 | 54 | 55 | 56 | 57 | 58 | -------------------------------------------------------------------------------- /src/etc/adminhtml/system.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 |
6 | 7 | 15 | 16 | IntegerNet\ConfigurableWysiwyg\Model\Config\Source\Toolbar 17 | 18 | 26 | 27 | Magento\Config\Model\Config\Source\Yesno 28 | 29 | 37 | 38 | Magento\Config\Model\Config\Source\Yesno 39 | 40 | 48 | 49 | Magento\Config\Model\Config\Source\Yesno 50 | 51 | 52 |
53 |
54 |
55 | -------------------------------------------------------------------------------- /src/etc/config.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | undo,redo,formatselect,bold,italic,underline,alignleft,aligncenter,alignright,bullist,numlist,link,table,charmap 8 | 1 9 | 1 10 | 1 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /src/etc/module.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | --------------------------------------------------------------------------------