From 7fbf67846c6f893b39309d9e02f3be36f30d3e09 Mon Sep 17 00:00:00 2001 From: Ruslan-Aleev Date: Tue, 25 Jul 2023 12:35:39 +0400 Subject: [PATCH] Improved editor for Ace settings --- assets/components/clientconfig/js/mgr/sections/home.js | 3 +++ .../clientconfig/processors/mgr/settings/save.class.php | 5 +++++ 2 files changed, 8 insertions(+) diff --git a/assets/components/clientconfig/js/mgr/sections/home.js b/assets/components/clientconfig/js/mgr/sections/home.js index c57d801..3f00a26 100755 --- a/assets/components/clientconfig/js/mgr/sections/home.js +++ b/assets/components/clientconfig/js/mgr/sections/home.js @@ -115,6 +115,9 @@ Ext.extend(ClientConfig.page.Home,MODx.Component,{ if (field.xtype === 'code') { field.height = 150; field.xtype = Ext.ComponentMgr.isRegistered('modx-texteditor') ? 'modx-texteditor' : 'textarea'; + if (MODx.config.which_element_editor == 'Ace') { + Ext.onReady(function() {MODx.ux.Ace.replaceComponent(field.id, 'text/html', 1);}); + } } if (field.xtype === 'richtext') { diff --git a/core/components/clientconfig/processors/mgr/settings/save.class.php b/core/components/clientconfig/processors/mgr/settings/save.class.php index 45e74e4..8244ddd 100644 --- a/core/components/clientconfig/processors/mgr/settings/save.class.php +++ b/core/components/clientconfig/processors/mgr/settings/save.class.php @@ -32,6 +32,11 @@ public function process() { continue; } + // Fix save value for Ace setting + if ($setting->get('xtype') == 'code' && $this->modx->getOption('which_element_editor') == 'Ace') { + $value = $value[1]; + } + if (trim($value) === '' && $setting->get('is_required') && !in_array($setting->get('xtype'), array('checkbox', 'xcheckbox'), true)) { $this->addFieldError($key, $setting->get('label') . ': ' . $this->modx->lexicon('clientconfig.field_is_required'));