This phpBB extension provides a basic integration of the CodeMirror code editor for use by other extensions. See CodeMirror configuration for the possible options and commands. The extension tries to load all required dependencies by inspecting a configuration set in JSON format.
This extension provides some extra configuration options and commands. All of them are prefixed with "marttiphpbb".
To provide a border around the CodeMirror editor. Helpful for the light themes against the light background of the ACP.
marttiphpbbBorderEnabled
: defaults to false
.marttiphpbbBorderStyle
: defaults to 1px solid lightgrey
marttiphpbbToggleBorder
marttiphpbbEnableBorder
marttiphpbbDisableBorder
Commands for the CodeMirror "fullScreen" option:
This command generates a click event on submit buttons:
You can install this on the latest release of phpBB by following the steps below:
marttiphpbb/codemirror
in the ext
directory.ext/marttiphpbb/codemirror
CodeMirror (helper ext)
in the ACP at Customise -> Manage extensions
.CodeMirror (helper ext)
in the ACP at Customise -> Extension Management -> Extensions
.Delete Data
. Optionally delete the /ext/marttiphpbb/codemirror
directory.(in a normal controller likewise)
class main_module
{
var $u_action;
function main($id, $mode)
{
global $phpbb_container;
$ext_manager = $phpbb_container->get('ext.manager');
$template = $phpbb_container->get('template');
// ...
switch($mode)
{
case 'your_mode':
//..
if ($request->is_set_post('submit'))
{
// ...
}
//...
if ($ext_manager->is_enabled('marttiphpbb/codemirror'))
{
$load = $phpbb_container->get('marttiphpbb.codemirror.load');
$load->set_mode('json'); // or javascript, css, html, php, markdown, etc.s
}
$template->assign_vars([
'CONTENT' => $content, // retrieve or set somewhere above.
'U_ACTION' => $this->u_action,
]);
break;
}
}
}
<textarea name="content" id="content"{{- marttiphpbb_codemirror.data_attr ?? '' -}}>
{{- CONTENT -}}
</textarea>
When this extension is enabled, the <textarea>
will be hidden and instead a CodeMirror instance is shown. Note that the dashes in {{- CONTENT -}}
are important. Otherwise unwanted whitespace will be inserted.
(CodeMirror is licensed under MIT.)