bludit/bl-plugins/quill/plugin.php

69 lines
1.2 KiB
PHP
Raw Normal View History

2017-04-26 18:56:10 +02:00
<?php
class pluginQuill extends Plugin {
private $loadWhenController = array(
'new-post',
'new-page',
'edit-post',
'edit-page'
);
public function init()
{
return false;
2017-04-26 18:56:10 +02:00
}
// Returns true if the plugins is loaded on the controller defined
private function enabled()
{
global $layout;
return in_array($layout['controller'], $this->loadWhenController);
}
public function adminHead()
{
$html = '';
if( $this->enabled() ) {
$html .= '<link href="https://cdn.quilljs.com/1.2.4/quill.snow.css" rel="stylesheet">';
$html .= '<script src="https://cdn.quilljs.com/1.2.4/quill.js"></script>';
}
return $html;
}
public function adminBodyEnd()
{
global $layout;
global $Language;
$html = '';
if( $this->enabled() ) {
$html .= '
<script>
$("#jscontent").hide().after("<div id=\"quillcontent\"></div>");
2017-04-26 19:19:43 +02:00
var quill = new Quill("#quillcontent", {
2017-04-26 19:19:43 +02:00
modules: {
toolbar: [
[{ header: [1, 2, false] }],
["bold", "italic", "underline"],
["image"]
]
},
theme: "snow"
});
$(".uk-form").submit(function( event ) {
$("#jscontent").val(quill.root.innerHTML);
return true;
});
</script>
2017-04-26 18:56:10 +02:00
';
}
return $html;
}
}