Awesome work!! I’ve been meaning to look into an EditArea replacement, and CodeMirror was my top choice. Great work on the transport package
I’m having a bit of a hard time trying to get it to work when editing Resources...
Would it be related to the empty "OnRichTextEditorInit" block in the CodeMirror plugin (+activating the system event), or would it need it’s own case-statement for "OnDocFormPrerender"?
Also, I am curious how
$options[’modx_loader’]
is used? (onSnippet, onChunk, onTV, etc)... I presume I will need to know the connection in order to get CodeMirror to run when editing a Resource...
Example attempt:
Quote from: "CodeMirror
case ’OnDocFormPrerender’:
$options[’modx_loader’] = ’onDoc’; // ??
$modx->regClientCSS($assetsUrl.’css/cm.css’);
$modx->regClientStartupHTMLBlock(’<script type="text/javascript">MODx.codem = ’.$modx->toJSON($options).’;</script>’);
$modx->regClientStartupScript($assetsUrl.’cm/js/codemirror.js’);
$modx->regClientStartupScript($assetsUrl.’js/cm.js’);
break;
Update:
Ah-ha! I found the modx_loader references in core/packages [...] codemirror/js/cm.js:
,onChunk: function() {
return Codem.init('modx-chunk-snippet','modx-panel-chunk');
}
,onPlugin: function() {
return Codem.init('modx-plugin-plugincode','modx-panel-plugin');
}
,onSnippet: function() {
return Codem.init('modx-snippet-snippet','modx-panel-snippet');
}
,onTemplate: function() {
return Codem.init('modx-template-content','modx-panel-template');
}
,onTV: function() {
return Codem.init('modx-tv-default-text','modx-panel-tv');
}
...clearly my guess at "onDoc" will not work. Further, I was able to set "which_editor" in System Settings to use CodeMirror, but unfortunately the editor fails to load when editing a resource.