Fixed bugs with Sceditor
This commit is contained in:
parent
06918008f2
commit
1398ca35ac
@ -7,28 +7,6 @@
|
||||
include(ADMIN_DIR.'panels/admin.defaultpanels.php');
|
||||
include(ADMIN_DIR.'includes/panels.prototypes.php');
|
||||
require(SMARTY_DIR . 'SmartyValidate.class.php');
|
||||
|
||||
// SCEditor Config
|
||||
// In this file will check if SCEditor use BBCODE or HTML
|
||||
// BBCode = 0 and HTML = 1
|
||||
function get_sceditor_option() {
|
||||
global $fp_config;
|
||||
if (!isset($fp_config['general']['sceditor_display'])) {
|
||||
$fp_config['general']['sceditor_display'] = 0; // BBCode as default
|
||||
config_save();
|
||||
}
|
||||
return $fp_config['general']['sceditor_display'];
|
||||
}
|
||||
|
||||
function get_sceditor_display_value() {
|
||||
switch (get_sceditor_option()) {
|
||||
case 0 : return 'bbcode';
|
||||
case 1 : return 'xhtml';
|
||||
case 2 : return 'disable';
|
||||
default : return 'bbcode';
|
||||
}
|
||||
}
|
||||
// End SCEditor Config
|
||||
|
||||
utils_nocache_headers();
|
||||
|
||||
|
@ -34,7 +34,6 @@
|
||||
function setup() {
|
||||
$this->smarty->assign('themes', theme_list());
|
||||
$this->smarty->assign('lang_list', lang_list());
|
||||
$this->smarty->assign("sceditor_display", get_sceditor_display_value());
|
||||
|
||||
$static_list = array();
|
||||
|
||||
|
@ -64,12 +64,6 @@
|
||||
<dt><label for="maxentries"> {$panelstrings.blogmaxentries} </label></dt>
|
||||
<dd><input type="text" name="maxentries" id="maxentries"
|
||||
class="form-control input_gray smalltextinput{$error.maxentries|notempty:" field-error"}" value="{$flatpress.maxentries}" /></dd>
|
||||
<dt><label for="maxentries">{$panelstrings.editor} </label></dt>
|
||||
<dd><select name="sceditor_format" id="sceditor_format" class="textinput form-control input_gray">
|
||||
<option value="0" {if $sceditor_display == 'bbcode' }selected{/if}>BBCode</option>
|
||||
<option value="1" {if $sceditor_display == 'xhtml' }selected{/if}>HTML</option>
|
||||
<option value="2" {if $sceditor_display == 'disable' }selected{/if}>Disable Editor</option>
|
||||
</select></dd>
|
||||
</dl>
|
||||
|
||||
</div>
|
||||
|
@ -79,8 +79,6 @@
|
||||
|
||||
$this->id = @$_REQUEST['entry'];
|
||||
$this->smarty->assign('id', $this->id);
|
||||
// SCEditor Smarty
|
||||
$this->smarty->assign("sceditor_display", get_sceditor_display_value());
|
||||
global $fp_config;
|
||||
$this->smarty->assign("lang_locale", $fp_config['locale']['lang']);
|
||||
}
|
||||
|
@ -41,16 +41,18 @@
|
||||
<!-- Here is the SCEditor -->
|
||||
<link rel="stylesheet" type="text/css" href="{$smarty.const.BLOG_BASEURL}/admin/res/sceditor/themes/square.min.css">
|
||||
<script src="{$smarty.const.BLOG_BASEURL}/admin/res/sceditor/sceditor.min.js"></script>
|
||||
<!--
|
||||
{if $sce_display=='bbcode'}
|
||||
<script src="{$smarty.const.BLOG_BASEURL}/admin/res/sceditor/formats/bbcode.js"></script>
|
||||
{else}
|
||||
<script src="{$smarty.const.BLOG_BASEURL}/admin/res/sceditor/formats/xhtml.js"></script>
|
||||
{/if}
|
||||
-->
|
||||
<script src="{$smarty.const.BLOG_BASEURL}/admin/res/sceditor/formats/bbcode.js"></script>
|
||||
<script src="{$smarty.const.BLOG_BASEURL}/fp-interface/lang/{$lang_locale}/sceditor.js"></script>
|
||||
<script src="{$smarty.const.BLOG_BASEURL}/admin/res/sceditor/plugins/flatPressFileManager.js"></script>
|
||||
<script>
|
||||
// Replace the textarea #example with SCEditor
|
||||
var sce_display = "{$sceditor_display}";
|
||||
var lang_editor = "{$lang_locale}";
|
||||
var eRoot = "admin/res/sceditor/";
|
||||
{literal}
|
||||
@ -59,7 +61,7 @@
|
||||
plugins: 'flatPressFileManager',
|
||||
toolbar: 'bold,italic,underline,strike,subscript,superscript|left,center,right,justify|font,size,color,removeformat|cut,copy,pastetext|bulletlist,orderedlist,indent,outdent|table|code,quote|horizontalrule,flatPressFileManager,email,link,unlink|emoticon,youtube,date,time|ltr,rtl|print,maximize,source',
|
||||
emoticonsRoot: eRoot,
|
||||
format: sce_display,
|
||||
format: 'bbcode',
|
||||
height: "400px",
|
||||
locale: lang_editor
|
||||
});
|
||||
|
@ -63,7 +63,6 @@
|
||||
|
||||
$this->smarty->assign('static_id', 'static'.date_time());
|
||||
|
||||
$this->smarty->assign("sceditor_display", get_sceditor_display_value());
|
||||
global $fp_config;
|
||||
$this->smarty->assign("lang_locale", $fp_config['locale']['lang']);
|
||||
|
||||
|
@ -33,15 +33,17 @@
|
||||
<script src="{$smarty.const.BLOG_BASEURL}/fp-includes/bootstrap/js/bootstrap.min.js"></script>
|
||||
<!-- Here is the SCEditor -->
|
||||
<script src="{$smarty.const.BLOG_BASEURL}/admin/res/sceditor/sceditor.min.js"></script>
|
||||
<!--
|
||||
{if $sce_display=='bbcode'}
|
||||
<script src="{$smarty.const.BLOG_BASEURL}/admin/res/sceditor/formats/bbcode.js"></script>
|
||||
{else}
|
||||
<script src="{$smarty.const.BLOG_BASEURL}/admin/res/sceditor/formats/xhtml.js"></script>
|
||||
{/if}
|
||||
-->
|
||||
<script src="{$smarty.const.BLOG_BASEURL}/admin/res/sceditor/formats/bbcode.js"></script>
|
||||
<script src="{$smarty.const.BLOG_BASEURL}/fp-interface/lang/{$lang_locale}/sceditor.js"></script>
|
||||
<script>
|
||||
// Replace the textarea #example with SCEditor
|
||||
var sce_display = "{$sceditor_display}";
|
||||
var lang_editor = "{$lang_locale}";
|
||||
var eRoot = "admin/res/sceditor/";
|
||||
var FileManagerDir = "{$smarty.const.BLOG_BASEURL}/fp-plugins/sceditorfilemanager";
|
||||
@ -49,12 +51,11 @@
|
||||
var textarea = document.getElementById('content_textarea');
|
||||
sceditor.create(textarea, {
|
||||
emoticonsRoot: eRoot,
|
||||
format: sce_display,
|
||||
format: 'bbcode',
|
||||
height: "400px",
|
||||
locale: lang_editor
|
||||
//style: '../../res/sceditor/themes/content/default.min.css'
|
||||
});
|
||||
set_media_button(FileManagerDir);
|
||||
</script>
|
||||
{/literal}
|
||||
{/if}
|
||||
|
@ -712,6 +712,10 @@ img {
|
||||
background-position: 0px -416px !important;
|
||||
}
|
||||
|
||||
.sceditor-container textarea {
|
||||
color: #111 !important;
|
||||
}
|
||||
|
||||
/* Modal to upload files */
|
||||
|
||||
#flatpress-files-modal .modal-header {
|
||||
|
@ -31,18 +31,14 @@ function mobile_open_button() {
|
||||
}
|
||||
// End Responsive functions
|
||||
|
||||
// Editor media functions
|
||||
// Create the button
|
||||
function set_media_button() {
|
||||
let button = '<div class="sceditor-group"><a class="sceditor-button flatpress-media" onclick="open_media(FileManagerDir);"></a></div>';
|
||||
$( ".sceditor-toolbar" ).append(button);
|
||||
}
|
||||
|
||||
let mediaManagerRoute = '';
|
||||
|
||||
let insertSCEditorFunction;
|
||||
|
||||
/* Functions of FileManager */
|
||||
// Open the botton
|
||||
function open_media_manager() {
|
||||
function open_media_manager(insertSCEditor) {
|
||||
insertSCEditorFunction = insertSCEditor;
|
||||
mediaManagerRoute = '';
|
||||
$('#flatpress-files-modal').modal('show');
|
||||
$.post('ajax.php', {Operation : 'ListMediaDirectory', Arguments : mediaManagerRoute}, function(data) {
|
||||
@ -122,6 +118,8 @@ function openNewDirectory(DirectoryName) {
|
||||
function openNewFile(FileName) {
|
||||
const fileType = detectTypeFile(FileName);
|
||||
const functionType = FUNCTION_BY_FILE_FORMAT.get(fileType);
|
||||
selectedFile = FileName;
|
||||
selectedURL = mediaManagerRoute;
|
||||
functionType(FileName);
|
||||
}
|
||||
|
||||
@ -158,7 +156,7 @@ function detectTypeFile(FileName) {
|
||||
|
||||
const FUNCTION_BY_FILE_FORMAT = new Map();
|
||||
|
||||
const INSERT_MEDIA_BUTTON = '<button type="button" class="btn btn-primary" onclick="insertMediaInScedito()">Insert Media</button>';
|
||||
const INSERT_MEDIA_BUTTON = '<button type="button" class="btn btn-primary" onclick="insertMediaInSceditor()">Insert Media</button>';
|
||||
|
||||
FUNCTION_BY_FILE_FORMAT.set(IMAGE, function(imageURL) {
|
||||
const img = '<img src="' + 'fp-content/' + mediaManagerRoute + imageURL + '" class="img-fluid">';
|
||||
@ -176,6 +174,19 @@ function changeMediaPreviewContent(content) {
|
||||
modalFooter.innerHTML = INSERT_MEDIA_BUTTON;
|
||||
}
|
||||
|
||||
let selectedURL;
|
||||
let selectedFile;
|
||||
|
||||
function insertMediaInSceditor() {
|
||||
|
||||
/* Onyl bbcode at the moment */
|
||||
const fileType = detectTypeFile(selectedFile);
|
||||
switch(fileType) {
|
||||
case IMAGE: {
|
||||
insertSCEditorFunction('[img]' + selectedURL + selectedFile + '[/img]')
|
||||
break;
|
||||
}
|
||||
default: { /* Other files = url link */
|
||||
insertSCEditorFunction('[url=' + selectedURL + selectedFile + ']' + selectedFile +'[/url]')
|
||||
}
|
||||
}
|
||||
}
|
@ -17,11 +17,11 @@ sceditor.command.set('flatPressFileManager', {
|
||||
An a open bootstrap modal function
|
||||
The modal html is in the .tpl file, where sceditor is included
|
||||
*/
|
||||
open_media_manager();
|
||||
open_media_manager(this.insert);
|
||||
},
|
||||
tooltip: 'Open FlatPress File Manager'
|
||||
tooltip: 'Open FlatPress File Manager',
|
||||
});
|
||||
|
||||
|
||||
(function (sceditor) {
|
||||
'use strict';
|
||||
|
||||
@ -32,4 +32,4 @@ sceditor.command.set('flatPressFileManager', {
|
||||
this.init = function () { };
|
||||
|
||||
};
|
||||
}(sceditor));
|
||||
}(sceditor));
|
Loading…
x
Reference in New Issue
Block a user