Skip to content

Commit

Permalink
Tinymce skin config (OpenMage#13)
Browse files Browse the repository at this point in the history
* fix insert variable

* temporary disable openmage widgets

* fix insert widget

* rebrand openmage variables

* fix media browser callback

* clean

* removed empty lines

* removed empty line

* here we need the empty newline char ehhehe

* we need newline at the end of the file

* set toolbar buttons

* reorder and fix

* add skin default dark / draft the language support

* stylish openmage widget

* phpcs

* vscode fucking things

* first attempt to fix translator

* fix system config multiple values depends

* add tinymce skins to config

* fix multiple alert errors in chrome

* fix multiple alert errors in chrome

* restore

* copyright

* tinymce-5 default skin

---------

Co-authored-by: Fabrizio Balliano <fabrizio.balliano@gmail.com>
  • Loading branch information
empiricompany and fballiano authored Aug 7, 2023
1 parent 3d36452 commit 750a10c
Show file tree
Hide file tree
Showing 8 changed files with 116 additions and 60 deletions.
4 changes: 2 additions & 2 deletions app/code/core/Mage/Adminhtml/Block/System/Config/Form.php
Original file line number Diff line number Diff line change
Expand Up @@ -335,8 +335,8 @@ public function initFields($fieldset, $group, $section, $fieldPrefix = '', $labe
. $dependentFieldNameValue;
$shouldBeAddedDependence = true;
$dependentValue = (string)(isset($dependent->value) ? $dependent->value : $dependent);
if (isset($dependent['separator'])) {
$dependentValue = explode((string)$dependent['separator'], $dependentValue);
if (isset($dependent->separator)) {
$dependentValue = explode((string)$dependent->separator, $dependentValue);
}
$dependentFieldName = $fieldPrefix . $dependent->getName();
$dependentField = $dependentFieldGroup->fields->$dependentFieldName;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?php
/**
* OpenMage
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available at https://opensource.org/license/osl-3-0-php
*
* @category Mage
* @package Mage_Adminhtml
* @copyright Copyright (c) 2023 The OpenMage Contributors (https://www.openmage.org)
* @license https://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/

/**
* Configuration source model for Wysiwyg skin
*
* @category Mage
* @package Mage_Adminhtml
*/
class Mage_Adminhtml_Model_System_Config_Source_Cms_Wysiwyg_Skin
{
public function toOptionArray()
{
return [
[
'value' => 'oxide',
'label' => 'Oxide'
],
[
'value' => 'oxide-dark',
'label' => 'Oxide Dark'
],
[
'value' => 'tinymce-5',
'label' => 'Tinymce 5'
],
[
'value' => 'tinymce-5-dark',
'label' => 'Tinymce 5 Dark'
]
];
}
}
1 change: 1 addition & 0 deletions app/code/core/Mage/Cms/Model/Wysiwyg/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ public function getConfig($data = [])
$config->setData([
'enabled' => $this->isEnabled(),
'hidden' => $this->isHidden(),
'skin' => Mage::getStoreConfig('cms/wysiwyg/skin'),
'use_container' => false,
'add_variables' => Mage::getSingleton('admin/session')->isAllowed('system/variable'),
'add_widgets' => Mage::getSingleton('admin/session')->isAllowed('cms/widget_instance'),
Expand Down
1 change: 1 addition & 0 deletions app/code/core/Mage/Cms/etc/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@
<cms>
<wysiwyg>
<enabled>enabled</enabled>
<skin>tinymce-5</skin>
</wysiwyg>
</cms>
<system>
Expand Down
15 changes: 15 additions & 0 deletions app/code/core/Mage/Cms/etc/system.xml
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,21 @@
<show_in_website>1</show_in_website>
<show_in_store>1</show_in_store>
</enabled>
<skin translate="label">
<label>Skin WYSIWYG Editor</label>
<frontend_type>select</frontend_type>
<source_model>adminhtml/system_config_source_cms_wysiwyg_skin</source_model>
<sort_order>1</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>1</show_in_store>
<depends>
<enabled>
<value>enabled|hidden</value>
<separator>|</separator>
</enabled>
</depends>
</skin>
</fields>
</wysiwyg>
</groups>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ tinymce.PluginManager.add('openmagevariable', (ed, url) => {

editor.ui.registry.addToggleButton('openmagevariable', {
icon: 'openmagevariable',
tooltip: 'Insert Variable',
tooltip: Translator.translate('Insert Variable'),
onAction: function () {
editor.execCommand('openVariablesPopup');
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ tinymce.PluginManager.add('openmagewidget', (ed, url) => {
);
editor.ui.registry.addToggleButton('openmagewidget', {
icon: 'openmagewidget',
tooltip: 'Insert Widget',
tooltip: Translator.translate('Insert Widget'),

/**
* execute openVariablesSlideout for onAction callback
Expand Down
Loading

0 comments on commit 750a10c

Please # to comment.