2222}
2323
2424if (true === rex_plugin::get ('be_style ' , 'customizer ' )->isInstalled () && 1 === rex_plugin::get ('be_style ' , 'customizer ' )->getConfig ('codemirror ' )) {
25- echo rex_view::warning ($ addon ->i18n ('error_codemirror ' ));
25+ echo rex_view::error ($ addon ->i18n ('error_codemirror ' ));
2626}
2727
2828$ form = rex_config_form::factory ('aceeditor ' );
4343$ form ->addFieldset ($ addon ->i18n ('config_legend2 ' ));
4444
4545$ curDir = $ addon ->getAssetsUrl ('vendor/aceeditor/ ' );
46- $ themes = [];
46+ $ themes_light = [];
47+ $ themes_dark = [];
48+ $ themes_misc = [];
49+
4750$ files = glob ($ curDir . 'theme-*.js ' );
4851if (false !== $ files ) {
4952 foreach ($ files as $ filename ) {
50- $ themes [] = str_replace ('theme- ' , '' , substr (rex_path::basename ($ filename ), 0 , -3 ));
53+ $ file = rex_file::get ($ filename );
54+ if ($ file === null ) {
55+ $ file = '' ;
56+ }
57+
58+ $ theme_name = str_replace ('theme- ' , '' , substr (rex_path::basename ($ filename ), 0 , -3 ));
59+ if (str_contains ($ file , 't.isDark=!0 ' )) {
60+ $ themes_dark [] = $ theme_name ;
61+ } elseif (str_contains ($ file , 't.isDark=!1 ' )) {
62+ $ themes_light [] = $ theme_name ;
63+ } else {
64+ $ themes_misc [] = $ theme_name ;
65+ }
5166 }
5267}
5368
54- $ field = $ form ->addSelectField ('theme ' , $ value = null , ['class ' => 'form-control selectpicker ' ]);
69+ $ field = $ form ->addSelectField ('theme ' , $ value = null , ['class ' => 'form-control selectpicker ' , ' data-size ' => ' 10 ' ]);
5570$ field ->setLabel ($ addon ->i18n ('config_theme ' ));
5671$ select = $ field ->getSelect ();
57- foreach ($ themes as $ theme ) {
72+ $ select ->addOptgroup ('LIGHT ' );
73+ foreach ($ themes_light as $ theme ) {
74+ $ select ->addOption ($ theme , $ theme );
75+ }
76+
77+ $ select ->addOptgroup ('DARK ' );
78+ foreach ($ themes_dark as $ theme ) {
79+ $ select ->addOption ($ theme , $ theme );
80+ }
81+
82+ $ select ->addOptgroup ('MISC ' );
83+ foreach ($ themes_misc as $ theme ) {
5884 $ select ->addOption ($ theme , $ theme );
5985}
6086
61- $ field = $ form ->addSelectField ('darktheme ' , $ value = null , ['class ' => 'form-control selectpicker ' ]);
87+ $ field = $ form ->addSelectField ('darktheme ' , $ value = null , ['class ' => 'form-control selectpicker ' , ' data-size ' => ' 10 ' ]);
6288$ field ->setLabel ($ addon ->i18n ('config_darktheme ' ));
6389$ select = $ field ->getSelect ();
64- foreach ($ themes as $ theme ) {
90+ $ select ->addOptgroup ('LIGHT ' );
91+ foreach ($ themes_light as $ theme ) {
6592 $ select ->addOption ($ theme , $ theme );
6693}
6794
68- $ field = $ form ->addRawField ('<dl class="rex-form-group form-group"><dt> ' . $ addon ->i18n ('config_theme_preview ' ) . '</dt><dd><textarea class="form-control rex-js-code themepreview" readonly rows="15" data-theme=" ' . $ addon ->getConfig ('theme ' ) . '">
95+ $ select ->addOptgroup ('DARK ' );
96+ foreach ($ themes_dark as $ theme ) {
97+ $ select ->addOption ($ theme , $ theme );
98+ }
99+
100+ $ select ->addOptgroup ('MISC ' );
101+ foreach ($ themes_misc as $ theme ) {
102+ $ select ->addOption ($ theme , $ theme );
103+ }
104+
105+ // @phpstan-ignore-next-line
106+ $ field = $ form ->addRawField ('<dl class="rex-form-group form-group"><dt> ' . $ addon ->i18n ('config_theme_preview ' ) . '</dt><dd><textarea class="form-control aceeditor themepreview" readonly rows="18" data-theme=" ' . $ addon ->getConfig ('theme ' ) . '">
69107<?php
70108function nfact($n) {
71109 if ($n == 0) {
@@ -87,7 +125,7 @@ function nfact($n) {
87125// Ace-Editor Options
88126$ form ->addFieldset ($ addon ->i18n ('config_legend3 ' ));
89127
90- $ field = $ form ->addTextAreaField ('options ' , null , ['class ' => 'form-control rex-js-code ' , 'rows ' => 15 , 'aceeditor-theme ' => 'github ' , 'aceeditor-themedark ' => 'cobalt ' , 'aceeditor-mode ' => 'json ' , 'aceeditor-options ' => '{"showInvisibles": true} ' ]);
128+ $ field = $ form ->addTextAreaField ('options ' , null , ['class ' => 'form-control aceeditor ' , 'rows ' => 18 , 'aceeditor-theme ' => 'eclipse ' , 'aceeditor-themedark ' => 'dracula ' , 'aceeditor-mode ' => 'json ' , 'aceeditor-options ' => '{"showInvisibles": true} ' ]);
91129$ field ->setLabel ($ addon ->i18n ('config_options ' ));
92130$ field ->setNotice ($ addon ->i18n ('config_options_notice ' ));
93131
@@ -128,7 +166,18 @@ function nfact($n) {
128166
129167<script>
130168$(document).on('rex:ready', function () {
131- $('#aceeditor-themes-theme').on('change', function() {
169+ $('.dropdown-toggle').on('focus', function() {
170+ if ($(this).attr('title') != $('textarea.themepreview').data('theme')) {
171+ $('textarea.themepreview').prev().remove();
172+ $('textarea.themepreview')[0].style.display = 'block';
173+ $('textarea.themepreview')[0].setAttribute('data-aceactive', 'false');
174+ editor = textAreaToAceEditor($('textarea.themepreview')[0]);
175+ editor.setTheme('ace/theme/' + $(this).attr('title'));
176+ $('textarea.themepreview').data('theme', $(this).attr('title'));
177+ }
178+ });
179+
180+ $('#ace-editor-themes-theme').on('change', function() {
132181 $('textarea.themepreview').prev().remove();
133182 $('textarea.themepreview')[0].style.display = 'block';
134183 $('textarea.themepreview')[0].setAttribute('data-aceactive', 'false');
@@ -137,7 +186,7 @@ function nfact($n) {
137186 $('textarea.themepreview').data('theme', this.value);
138187 });
139188
140- $('#aceeditor -themes-darktheme').on('change', function() {
189+ $('#ace-editor -themes-darktheme').on('change', function() {
141190 $('textarea.themepreview').prev().remove();
142191 $('textarea.themepreview')[0].style.display = 'block';
143192 $('textarea.themepreview')[0].setAttribute('data-aceactive', 'false');
@@ -146,15 +195,5 @@ function nfact($n) {
146195 $('textarea.themepreview').data('theme', this.value);
147196 });
148197
149- $('.dropdown-toggle').on('focus', function() {
150- if ($(this).attr('title') != $('textarea.themepreview').data('theme')) {
151- $('textarea.themepreview').prev().remove();
152- $('textarea.themepreview')[0].style.display = 'block';
153- $('textarea.themepreview')[0].setAttribute('data-aceactive', 'false');
154- editor = textAreaToAceEditor($('textarea.themepreview')[0]);
155- editor.setTheme('ace/theme/' + $(this).attr('title'));
156- $('textarea.themepreview').data('theme', $(this).attr('title'));
157- }
158- });
159198});
160199</script>
0 commit comments