Skip to content

Commit e31933a

Browse files
committed
Add ACE editor support to the Custom PHP panel's config field.
1 parent 1af887e commit e31933a

File tree

2 files changed

+23
-2
lines changed

2 files changed

+23
-2
lines changed

TracyDebugger.module

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class TracyDebugger extends WireData implements Module, ConfigurableModule {
3232
'summary' => __('Tracy debugger from Nette with several PW specific custom tools.', __FILE__),
3333
'author' => 'Adrian Jones',
3434
'href' => 'https://processwire.com/talk/topic/12208-tracy-debugger/',
35-
'version' => '4.10.25',
35+
'version' => '4.10.26',
3636
'autoload' => true,
3737
'singular' => true,
3838
'requires' => 'ProcessWire>=2.7.2, PHP>=5.4.4',
@@ -1089,7 +1089,6 @@ class TracyDebugger extends WireData implements Module, ConfigurableModule {
10891089
// Exit now if "enabled" not true from init()
10901090
if(!$this->tracyEnabled) return;
10911091

1092-
10931092
// USER BAR PAGE VERSIONS
10941093
if(!static::$inAdmin && $this->wire('user')->hasPermission('tracy-page-versions') && $this->data['showUserBar'] && in_array('pageVersions', $this->data['userBarFeatures']) && !$this->wire('config')->ajax && $this->wire('user')->isLoggedin()) {
10951094
static::$pageVersion = $this->findPageTemplateInCookie($this->wire('input')->cookie->tracyPageVersion);
@@ -2117,6 +2116,10 @@ class TracyDebugger extends WireData implements Module, ConfigurableModule {
21172116
*/
21182117
public function getModuleConfigInputfields(array $data) {
21192118

2119+
// load ACE editor for Custom PHP panel code entry
2120+
$this->wire('config')->scripts->append($this->wire('config')->urls->TracyDebugger . "scripts/ace-editor/ace.js");
2121+
$this->wire('config')->scripts->append($this->wire('config')->urls->TracyDebugger . "scripts/config-load-ace.js");
2122+
21202123
// convert PW Info panel custom links from path back to ID
21212124
if(isset($data['customPWInfoPanelLinks'])) {
21222125
$customPWInfoPanelLinkIds = array();
@@ -3028,6 +3031,7 @@ class TracyDebugger extends WireData implements Module, ConfigurableModule {
30283031
});
30293032

30303033
return $wrapper;
3034+
30313035
}
30323036

30333037
}

scripts/config-load-ace.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
window.onload = function () {
2+
var tse = ace.edit("Inputfield_customPhpCode");
3+
tse.container.style.lineHeight = '23px';
4+
tse.setFontSize(13);
5+
tse.setShowPrintMargin(false);
6+
tse.$blockScrolling = Infinity;
7+
tse.setTheme("ace/theme/tomorrow_night");
8+
tse.session.setMode({path:"ace/mode/php", inline:true});
9+
ace.config.loadModule('ace/ext/language_tools', function () {
10+
tse.setOptions({
11+
enableBasicAutocompletion: true,
12+
enableLiveAutocompletion: true,
13+
minLines: 5,
14+
maxLines: 20
15+
});
16+
});
17+
};

0 commit comments

Comments
 (0)