Tinymce n
This commit is contained in:
parent
4b2ea853b8
commit
dd06fb5a8a
|
@ -2,10 +2,8 @@
|
|||
|
||||
class pluginsimpleMDE extends Plugin {
|
||||
|
||||
private $loadWhenController = array(
|
||||
'new-post',
|
||||
private $loadOnController = array(
|
||||
'new-page',
|
||||
'edit-post',
|
||||
'edit-page'
|
||||
);
|
||||
|
||||
|
@ -54,13 +52,9 @@ class pluginsimpleMDE extends Plugin {
|
|||
|
||||
public function adminHead()
|
||||
{
|
||||
global $layout;
|
||||
|
||||
if (in_array($GLOBALS['ADMIN_CONTROLLER'], $this->loadOnController)) {
|
||||
$html = '';
|
||||
|
||||
// Load CSS and JS only on Controllers in array.
|
||||
if(in_array($layout['controller'], $this->loadWhenController))
|
||||
{
|
||||
// Path plugin.
|
||||
$pluginPath = $this->htmlPath();
|
||||
|
||||
|
@ -81,30 +75,22 @@ class pluginsimpleMDE extends Plugin {
|
|||
.CodeMirror, .CodeMirror-scroll { min-height: 400px !important; border-radius: 0 !important; }
|
||||
</style>';
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
return $html;
|
||||
return false;
|
||||
}
|
||||
|
||||
public function adminBodyEnd()
|
||||
{
|
||||
global $layout;
|
||||
global $Language;
|
||||
|
||||
$html = '';
|
||||
|
||||
// Load CSS and JS only on Controllers in array.
|
||||
if(in_array($layout['controller'], $this->loadWhenController))
|
||||
{
|
||||
if (in_array($GLOBALS['ADMIN_CONTROLLER'], $this->loadOnController)) {
|
||||
// Autosave
|
||||
global $_Page, $_Post;
|
||||
$autosaveID = $layout['controller'];
|
||||
global $Page;
|
||||
global $Language;
|
||||
$autosaveID = $GLOBALS['ADMIN_CONTROLLER'];
|
||||
$autosaveEnable = $this->getDbField('autosave')?'true':'false';
|
||||
if(isset($_Page)) {
|
||||
$autosaveID = $_Page->key();
|
||||
}
|
||||
if(isset($_Post)) {
|
||||
$autosaveID = $_Post->key();
|
||||
if (!empty($Page)) {
|
||||
$autosaveID = $Page->key();
|
||||
}
|
||||
|
||||
// Spell Checker
|
||||
|
@ -148,8 +134,9 @@ class pluginsimpleMDE extends Plugin {
|
|||
});';
|
||||
|
||||
$html .= '}); </script>';
|
||||
}
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -2,43 +2,14 @@
|
|||
|
||||
class pluginTinymce extends Plugin {
|
||||
|
||||
private $loadWhenController = array(
|
||||
'new-post',
|
||||
private $loadOnController = array(
|
||||
'new-page',
|
||||
'edit-post',
|
||||
'edit-page'
|
||||
);
|
||||
|
||||
public function init()
|
||||
{
|
||||
$this->dbFields = array(
|
||||
'plugins'=>'autoresize, fullscreen, pagebreak, link, textcolor, code, image, paste',
|
||||
'toolbar'=>'bold italic underline strikethrough | alignleft aligncenter alignright | bullist numlist | styleselect | link forecolor backcolor removeformat image | pagebreak code fullscreen'
|
||||
);
|
||||
}
|
||||
|
||||
public function form()
|
||||
{
|
||||
global $Language;
|
||||
|
||||
$html = '<div>';
|
||||
$html .= '<label>Tinymce plugins</label>';
|
||||
$html .= '<input name="plugins" id="jsplugins" type="text" value="'.$this->getDbField('plugins').'">';
|
||||
$html .= '</div>';
|
||||
|
||||
$html .= '<div>';
|
||||
$html .= '<label>Tinymce toolbar</label>';
|
||||
$html .= '<input name="toolbar" id="jstoolbar" type="text" value="'.$this->getDbField('toolbar').'">';
|
||||
$html .= '</div>';
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
public function adminHead()
|
||||
{
|
||||
global $layout;
|
||||
|
||||
if (in_array($layout['controller'], $this->loadWhenController)) {
|
||||
if (in_array($GLOBALS['ADMIN_CONTROLLER'], $this->loadOnController)) {
|
||||
return '<script src="https://cloud.tinymce.com/stable/tinymce.min.js"></script>';
|
||||
}
|
||||
return false;
|
||||
|
@ -46,10 +17,37 @@ class pluginTinymce extends Plugin {
|
|||
|
||||
public function adminBodyEnd()
|
||||
{
|
||||
global $layout;
|
||||
global $Language;
|
||||
|
||||
if (in_array($layout['controller'], $this->loadWhenController)) {
|
||||
return '<script>tinymce.init({ selector:"textarea" });</script>';
|
||||
if (in_array($GLOBALS['ADMIN_CONTROLLER'], $this->loadOnController)) {
|
||||
return '<script>
|
||||
|
||||
function editorAddImage(filename) {
|
||||
tinymce.activeEditor.insertContent("<img src=\""+filename+"\" alt=\"'.$Language->get('Image description').'\">" + "\n");
|
||||
}
|
||||
|
||||
tinymce.init({
|
||||
selector: "#jscontent",
|
||||
element_format : "html",
|
||||
entity_encoding : "raw",
|
||||
schema: "html5",
|
||||
statusbar: false,
|
||||
menubar:false,
|
||||
branding: false,
|
||||
browser_spellcheck: true,
|
||||
autoresize_bottom_margin: "50",
|
||||
pagebreak_separator: "'.PAGE_BREAK.'",
|
||||
paste_as_text: true,
|
||||
document_base_url: "'.DOMAIN_UPLOADS.'",
|
||||
plugins: [
|
||||
"autoresize advlist autolink lists link image charmap print preview anchor",
|
||||
"searchreplace visualblocks code fullscreen",
|
||||
"insertdatetime media table contextmenu paste code pagebreak"
|
||||
],
|
||||
toolbar: "bold italic underline strikethrough | alignleft aligncenter alignright | bullist numlist | styleselect | link forecolor backcolor removeformat image | pagebreak code fullscreen"
|
||||
});
|
||||
|
||||
</script>';
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue