dbFields = array(
'tabSize'=>'2',
'toolbar'=>'"bold", "italic", "heading", "|", "quote", "unordered-list", "|", "link", "image", "code", "horizontal-rule", "|", "preview", "side-by-side", "fullscreen"',
'spellChecker'=>true
);
}
public function form()
{
global $L;
$html = '
';
$html .= '';
$html .= '';
$html .= '
';
$html .= '';
$html .= '';
$html .= '';
$html .= '
';
$html .= '';
$html .= '';
$html .= '';
$html .= '
';
return $html;
}
public function adminHead()
{
// Load the plugin only in the controllers setted in $this->loadOnController
if (!in_array($GLOBALS['ADMIN_VIEW'], $this->loadOnViews)) {
return false;
}
$html = $this->includeCSS('easymde.min.css');
$html .= $this->includeCSS('bludit.css');
$html .= $this->includeJS('easymde.min.js');
return $html;
}
public function adminBodyEnd()
{
global $L;
// Load the plugin only in the controllers setted in $this->loadOnController
if (!in_array($GLOBALS['ADMIN_VIEW'], $this->loadOnViews)) {
return false;
}
$langImage = $L->g('Image description');
$spellCheckerEnable = $this->getValue('spellChecker')?'true':'false';
$tabSize = $this->getValue('tabSize');
$toolbar = Sanitize::htmlDecode($this->getValue('toolbar'));
$pageBreak = PAGE_BREAK;
return <<
// Function required for Bludit
// Returns the content of the editor
function editorGetContent() {
return easymde.value();
}
// Function required for Bludit
// Insert HTML content at the cursor position
function editorInsertContent(html, type='') {
var text = easymde.value();
if (type == 'image') {
easymde.value(text + "![$langImage]("+filename+")" + "\\n");
} else {
easymde.value(html + "\\n");
}
easymde.codemirror.refresh();
}
var easymde = new EasyMDE({
element: document.getElementById("editor"),
status: false,
toolbarTips: true,
toolbarGuideIcon: true,
autofocus: false,
placeholder: "",
lineWrapping: true,
autoDownloadFontAwesome: false,
indentWithTabs: true,
tabSize: $tabSize,
spellChecker: $spellCheckerEnable,
toolbar: [$toolbar,
"|",
{
name: "pageBreak",
action: function addPageBreak(editor){
var cm = editor.codemirror;
output = "$pageBreak";
cm.replaceSelection(output);
},
className: "bi-crop",
title: "Page break",
}]
});
EOF;
}
}