Add button for code blocks
This commit is contained in:
62
action.php
62
action.php
@@ -10,9 +10,20 @@ use dokuwiki\Extension\EventHandler;
|
||||
class action_plugin_luxtools extends ActionPlugin
|
||||
{
|
||||
/** @inheritdoc */
|
||||
public function register(EventHandler $controller)
|
||||
public function register(Doku_Event_Handler $controller)
|
||||
{
|
||||
$controller->register_hook('TPL_METAHEADER_OUTPUT', 'BEFORE', $this, 'addScripts');
|
||||
$controller->register_hook(
|
||||
"TPL_METAHEADER_OUTPUT",
|
||||
"BEFORE",
|
||||
$this,
|
||||
"addScripts",
|
||||
);
|
||||
$controller->register_hook(
|
||||
"TOOLBAR_DEFINE",
|
||||
"AFTER",
|
||||
$this,
|
||||
"addToolbarButton",
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -22,22 +33,43 @@ class action_plugin_luxtools extends ActionPlugin
|
||||
* @param mixed $param
|
||||
* @return void
|
||||
*/
|
||||
public function addScripts(Event $event, $param)
|
||||
public function addScripts(Event $event, $param)
|
||||
{
|
||||
$base = DOKU_BASE . 'lib/plugins/luxtools/js/';
|
||||
$scripts = array(
|
||||
'lightbox.js',
|
||||
'gallery-thumbnails.js',
|
||||
'open-service.js',
|
||||
'scratchpads.js',
|
||||
'main.js'
|
||||
);
|
||||
$base = DOKU_BASE . "lib/plugins/luxtools/js/";
|
||||
$scripts = [
|
||||
"lightbox.js",
|
||||
"gallery-thumbnails.js",
|
||||
"open-service.js",
|
||||
"scratchpads.js",
|
||||
"main.js",
|
||||
];
|
||||
|
||||
foreach ($scripts as $script) {
|
||||
$event->data['script'][] = array(
|
||||
'type' => 'text/javascript',
|
||||
'src' => $base . $script
|
||||
);
|
||||
$event->data["script"][] = [
|
||||
"type" => "text/javascript",
|
||||
"src" => $base . $script,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add custom toolbar button for code blocks.
|
||||
*
|
||||
* @param Event $event
|
||||
* @param mixed $param
|
||||
* @return void
|
||||
*/
|
||||
public function addToolbarButton(Event $event, $param)
|
||||
{
|
||||
$event->data[] = [
|
||||
"type" => "format",
|
||||
"title" => $this->getLang("toolbar_code_title"),
|
||||
"icon" => "../../plugins/luxtools/images/code.png",
|
||||
"key" => "C",
|
||||
"open" => "<code>",
|
||||
"sample" => $this->getLang("toolbar_code_sample"),
|
||||
"close" => "</code>",
|
||||
"block" => false,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user