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()
|
|
|
|
{
|
2017-05-04 20:35:05 +02:00
|
|
|
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 .= '
|
2017-05-04 20:35:05 +02:00
|
|
|
<script>
|
|
|
|
|
|
|
|
$("#jscontent").hide().after("<div id=\"quillcontent\"></div>");
|
2017-04-26 19:19:43 +02:00
|
|
|
|
2017-05-04 20:35:05 +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"
|
|
|
|
});
|
2017-05-04 20:35:05 +02:00
|
|
|
|
|
|
|
$(".uk-form").submit(function( event ) {
|
|
|
|
$("#jscontent").val(quill.root.innerHTML);
|
|
|
|
return true;
|
|
|
|
});
|
|
|
|
|
|
|
|
</script>
|
2017-04-26 18:56:10 +02:00
|
|
|
';
|
|
|
|
}
|
|
|
|
|
|
|
|
return $html;
|
|
|
|
}
|
|
|
|
}
|