Skip to content

Commit

Permalink
Upgraded TinyMCE to 6.7.0 (#3220)
Browse files Browse the repository at this point in the history
Co-authored-by: Tony <tonyweboss@gmail.com>
Co-authored-by: Tony <github@magemega.com>
  • Loading branch information
3 people committed Oct 2, 2023
1 parent dac0eee commit 51f5bb5
Show file tree
Hide file tree
Showing 540 changed files with 7,598 additions and 112,266 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ protected function _prepareForm()

$form->addField($this->getData('editor_element_id'), 'editor', [
'name' => 'content',
'style' => 'width:725px;height:460px',
'style' => 'height:460px',
'required' => true,
'force_load' => true,
'config' => Mage::getSingleton('cms/wysiwyg_config')->getConfig($config)
Expand Down
6 changes: 1 addition & 5 deletions app/code/core/Mage/Adminhtml/Block/Cms/Block/Edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,7 @@ public function __construct()

$this->_formScripts[] = "
function toggleEditor() {
if (tinyMCE.getInstanceById('block_content') == null) {
tinyMCE.execCommand('mceAddControl', false, 'block_content');
} else {
tinyMCE.execCommand('mceRemoveControl', false, 'block_content');
}
tinymce.execCommand('mceToggleEditor', false, wysiwygblock_content);
}
function saveAndContinueEdit(){
Expand Down
6 changes: 1 addition & 5 deletions app/code/core/Mage/Adminhtml/Block/Cms/Page/Edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,7 @@ protected function _prepareLayout()

$this->_formScripts[] = "
function toggleEditor() {
if (tinyMCE.getInstanceById('page_content') == null) {
tinyMCE.execCommand('mceAddControl', false, 'page_content');
} else {
tinyMCE.execCommand('mceRemoveControl', false, 'page_content');
}
tinymce.execCommand('mceToggleEditor', false, wysiwygpage_content);
}
function saveAndContinueEdit(urlTemplate) {
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'
]
];
}
}
12 changes: 6 additions & 6 deletions app/code/core/Mage/Cms/Model/Wysiwyg/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ class Mage_Cms_Model_Wysiwyg_Config extends Varien_Object
*/
public const WYSIWYG_SKIN_IMAGE_PLACEHOLDER_FILE = 'images/wysiwyg/skin_image.png';

public const WYSIWYG_LOCALES = ['ar','az','be','bg_BG','bn_BD','ca','cs','cy','da','de','dv','el','eo','es','es_MX','et','eu','fa','fi','fr_FR','ga','gl','he_IL','hi','hr','hu_HU','hy','id','is_IS','it','ja','ka_GE','kab','kk','ko_KR','ku','lt','lv','nb_NO','ne','nl','nl_BE','oc','pl','pt_BR','ro','ru','sk','sl_SI','sq','sr','sv_SE','ta','tg','th_TH','tr','ug','uk','uz','vi','zh-Hans','zh-Hant','zh_HK','zh_MO','zh_SG'];

/**
* Return Wysiwyg config as Varien_Object
*
Expand All @@ -69,25 +71,23 @@ public function getConfig($data = [])
{
$config = new Varien_Object();

$locale = Mage::app()->getLocale()->getLocaleCode();
$lang = in_array($locale, self::WYSIWYG_LOCALES) ? $locale : substr($locale, 0, 2);
$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'),
'no_display' => false,
'translator' => Mage::helper('cms'),
'encode_directives' => true,
'directives_url' => Mage::getSingleton('adminhtml/url')->getUrl('*/cms_wysiwyg/directive'),
'popup_css' =>
Mage::getBaseUrl('js') . 'mage/adminhtml/wysiwyg/tiny_mce/themes/advanced/skins/default/dialog.css',
'content_css' =>
Mage::getBaseUrl('js') . 'mage/adminhtml/wysiwyg/tiny_mce/themes/advanced/skins/default/content.css',
'width' => '100%',
'plugins' => [],
'media_disable_flash' => true
'lang' => $lang
]);

$config->setData('directives_url_quoted', preg_quote($config->getData('directives_url')));

if (Mage::getSingleton('admin/session')->isAllowed('cms/media_gallery')) {
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 @@ -201,6 +201,7 @@
<cms>
<wysiwyg>
<enabled>enabled</enabled>
<skin>oxide</skin>
</wysiwyg>
</cms>
<system>
Expand Down
14 changes: 14 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,20 @@
<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 separator="|">
<value>enabled|hidden</value>
</enabled>
</depends>
</skin>
</fields>
</wysiwyg>
</groups>
Expand Down
6 changes: 3 additions & 3 deletions app/code/core/Mage/Core/Model/Variable/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ public function getWysiwygPluginSettings($config)
$variableConfig = [];
$onclickParts = [
'search' => ['html_id'],
'subject' => 'MagentovariablePlugin.loadChooser(\'' . $this->getVariablesWysiwygActionUrl() . '\', \'{{html_id}}\');'
'subject' => 'OpenmagevariablePlugin.loadChooser(\'' . $this->getVariablesWysiwygActionUrl() . '\', \'{{html_id}}\');'
];
$variableWysiwygPlugin = [['name' => 'magentovariable',
$variableWysiwygPlugin = [['name' => 'openmagevariable',
'src' => $this->getWysiwygJsPluginSrc(),
'options' => [
'title' => Mage::helper('adminhtml')->__('Insert Variable...'),
Expand All @@ -54,7 +54,7 @@ public function getWysiwygPluginSettings($config)
*/
public function getWysiwygJsPluginSrc()
{
return Mage::getBaseUrl('js') . 'mage/adminhtml/wysiwyg/tiny_mce/plugins/magentovariable/editor_plugin.js';
return Mage::getBaseUrl('js') . 'mage/adminhtml/wysiwyg/tinymce/plugins/openmagevariable.js';
}

/**
Expand Down
2 changes: 1 addition & 1 deletion app/code/core/Mage/Widget/Model/Widget/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class Mage_Widget_Model_Widget_Config extends Varien_Object
public function getPluginSettings($config)
{
return [
'widget_plugin_src' => Mage::getBaseUrl('js') . 'mage/adminhtml/wysiwyg/tiny_mce/plugins/magentowidget/editor_plugin.js',
'widget_plugin_src' => Mage::getBaseUrl('js') . 'mage/adminhtml/wysiwyg/tinymce/plugins/openmagewidget.js',
'widget_images_url' => $this->getPlaceholderImagesBaseUrl(),
'widget_placeholders' => $this->getAvailablePlaceholderFilenames(),
'widget_window_url' => $this->getWidgetWindowUrl($config)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,11 @@ public function indexAction()
{
// save extra params for widgets insertion form
$skipped = $this->getRequest()->getParam('skip_widgets');
$skipped = Mage::getSingleton('widget/widget_config')->decodeWidgetsFromQuery($skipped);
if (is_string($skipped)) {
$skipped = Mage::getSingleton('widget/widget_config')->decodeWidgetsFromQuery($skipped);
}

Mage::register('skip_widgets', $skipped);

$this->loadLayout('empty')->renderLayout();
}

Expand Down
2 changes: 1 addition & 1 deletion app/design/adminhtml/default/default/layout/main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ Default layout, loads most of the pages

<action method="addItem"><type>js</type><name>mage/adminhtml/rules.js</name><params/><if/><condition>can_load_rules_js</condition></action>

<action method="addItem"><type>js</type><name>mage/adminhtml/wysiwyg/tiny_mce/setup.js</name><params/><if/><condition>can_load_tiny_mce</condition></action>
<action method="addItem"><type>js</type><name>mage/adminhtml/wysiwyg/tinymce/setup.js</name><params/><if/><condition>can_load_tiny_mce</condition></action>

<block type="core/html_calendar" name="head.calendar" as="calendar" template="page/js/calendar.phtml"/>
</block>
Expand Down
2 changes: 1 addition & 1 deletion app/design/adminhtml/default/default/layout/oauth.xml
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
<action method="removeItem"><type>js</type><name>mage/adminhtml/uploader.js</name></action>
<action method="removeItem"><type>js</type><name>mage/adminhtml/product.js</name></action>
<action method="removeItem"><type>js</type><name>mage/adminhtml/rules.js</name></action>
<action method="removeItem"><type>js</type><name>mage/adminhtml/wysiwyg/tiny_mce/setup.js</name></action>
<action method="removeItem"><type>js</type><name>mage/adminhtml/wysiwyg/tinymce/setup.js</name></action>

<action method="removeItem"><type>css</type><name>print.css</name></action>
<action method="removeItem"><type>js_css</type><name>calendar/calendar-win2k-1.css</name></action>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ var catalogWysiwygEditor = {
if (dialogWindow.options.firedElementId) {
wysiwygObj = eval('wysiwyg'+dialogWindow.options.firedElementId+'_editor');
wysiwygObj.turnOff();
if (tinyMCE.get(wysiwygObj.id)) {
$(dialogWindow.options.firedElementId).value = tinyMCE.get(wysiwygObj.id).getContent();
if (tinymce.get(wysiwygObj.id)) {
$(dialogWindow.options.firedElementId).value = tinymce.get(wysiwygObj.id).getContent();
} else {
if ($(dialogWindow.options.firedElementId+'_editor')) {
$(dialogWindow.options.firedElementId).value = $(dialogWindow.options.firedElementId+'_editor').value;
Expand All @@ -94,8 +94,8 @@ var catalogWysiwygEditor = {

//destroy the instance of editor
wysiwygObj = eval('wysiwyg'+dialogWindow.options.firedElementId+'_editor');
if (tinyMCE.get(wysiwygObj.id)) {
tinyMCE.execCommand('mceRemoveControl', true, wysiwygObj.id);
if (tinymce.get(wysiwygObj.id)) {
tinymce.get(wysiwygObj.id).remove();
}

dialogWindow.close();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,10 @@ var queueControl = {
queueForm.submit();
},
preview: function() {
if (this.isEditor() && tinyMCE.get(this.id)) {
tinyMCE.triggerSave();
if (this.isEditor() && tinymce.get(this.id)) {
tinymce.triggerSave();
$('preview_text').value = $(this.id).value;
tinyMCE.triggerSave();
tinymce.triggerSave();
} else {
$('preview_text').value = $(this.id).value;
}
Expand All @@ -77,7 +77,7 @@ var queueControl = {
return false;
},
isEditor: function() {
return (typeof tinyMceEditors != 'undefined' && tinyMceEditors.get(this.id) != undefined)
return (typeof tinyMceEditors != 'undefined' && tinyMceEditors[this.id] != undefined)
},
resume: function() {
$('_resume_flag').value = '1';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@
$('change_flag_element').value = '1';
}
if(this.isEditor()) {
tinyMCE.triggerSave();
tinymce.triggerSave();
}
templateForm.submit();
return false;
Expand All @@ -129,7 +129,7 @@
$('save_as_flag').value = '1';

if(this.isEditor()) {
tinyMCE.triggerSave();
tinymce.triggerSave();
}
templateForm.submit();
return false;
Expand All @@ -141,10 +141,10 @@
} else {
$('preview_type').value = 2;
}
if (this.isEditor() && tinyMCE.get(this.id)) {
tinyMCE.triggerSave();
if (this.isEditor() && tinymce.get(this.id)) {
tinymce.triggerSave();
$('preview_text').value = $(this.id).value;
tinyMCE.triggerSave();
tinymce.triggerSave();
} else {
$('preview_text').value = $(this.id).value;
}
Expand All @@ -165,11 +165,11 @@
},

isEditor: function() {
return (typeof tinyMceEditors != 'undefined' && tinyMceEditors.get(this.id) != undefined)
return (typeof tinyMceEditors != 'undefined' && tinyMceEditors[this.id] != undefined)
},

getEditor: function() {
return tinyMceEditors.get(this.id);
return tinyMceEditors[this.id];
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
<?php endif ?>

<?php if ($this->getCanLoadTinyMce()): // TinyMCE is broken when loaded through index.php?>
<script type="text/javascript" src="<?php echo $this->getJsUrl() ?>tiny_mce/tiny_mce.js"></script>
<script type="text/javascript" src="<?php echo $this->getJsUrl() ?>tinymce/tinymce.min.js"></script>
<?php endif ?>

<script type="text/javascript">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,10 +155,10 @@
} else {
$('preview_type').value = 2;
}
if (typeof tinyMCE == 'undefined' || !tinyMCE.getInstanceById('template_text')) {
if (typeof tinymce == 'undefined' || !tinymce.get('template_text')) {
$('preview_text').value = $('template_text').value;
} else {
$('preview_text').value = tinyMCE.getInstanceById('template_text').getHTML();
$('preview_text').value = tinymce.get('template_text').getContent();
}

if ($('template_styles') != undefined) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
case 'wysiwyg': ?>
<span class="form_row">
<label for="<?php echo $element->getHtmlId() ?>"><?php echo $element->getLabel() ?>:</label>
<script type="text/javascript" src="<?php echo Mage::getBaseUrl('js') ?>tiny_mce/tiny_mce.js"></script>
<script type="text/javascript" src="<?php echo Mage::getBaseUrl('js') ?>tinymce/tinymce.min.js"></script>
<script type="text/javascript">
//<![CDATA[
tinyMCE.init({
Expand Down
Loading

0 comments on commit 51f5bb5

Please sign in to comment.