Introduzione summernote

This commit is contained in:
Thomas Zilio 2020-03-13 14:01:51 +01:00
parent 475a194234
commit 0ef2d62931
18 changed files with 62 additions and 89 deletions

38
bug.php
View File

@ -152,7 +152,7 @@ echo '
<div class="clearfix"></div> <div class="clearfix"></div>
<br> <br>
{[ "type": "ckeditor", "label": "'.tr('Descrizione del bug').'", "name": "body" ]} {[ "type": "editor", "label": "'.tr('Descrizione del bug').'", "name": "body", "placeholder": "<p>'.tr('Se hai riscontrato un bug ricordati di specificare').':</p><ul><li>'.tr('Modulo esatto (o pagina relativa) in cui questi si è verificato').';</li><li>'.tr('Dopo quali specifiche operazioni hai notato il malfunzionamento').'.</li></ul><p>'.tr('Assicurati inoltre di controllare che il checkbox relativo ai file di log sia contrassegnato, oppure riporta qui l\'errore visualizzato').'.</p><p>'.tr('Ti ringraziamo per il tuo contributo').',<br>'.tr('Lo staff di OSM').'</p>" ]}
<!-- PULSANTI --> <!-- PULSANTI -->
<div class="row"> <div class="row">
@ -164,40 +164,6 @@ echo '
</div> </div>
</form> </form>
</div> </div>
</div> </div>';
<script>
$(document).ready(function() {
init();
var html = "<p>'.tr('Se hai riscontrato un bug ricordati di specificare').':</p>" +
"<ul>" +
"<li>'.tr('Modulo esatto (o pagina relativa) in cui questi si è verificato').';</li>" +
"<li>'.tr('Dopo quali specifiche operazioni hai notato il malfunzionamento').'.</li>" +
"</ul>" +
"<p>'.tr('Assicurati inoltre di controllare che il checkbox relativo ai file di log sia contrassegnato, oppure riporta qui l\'errore visualizzato').'.</p>" +
"<p>'.tr('Ti ringraziamo per il tuo contributo').',<br>" +
"'.tr('Lo staff di OSM').'</p>";
var firstFocus = true;
let editor = input("body");
editor.set(html);
editor.on("change", function() {
setTimeout(function() {
$("#send").prop("disabled", editor.get() === "");
}, 10);
});
editor.on("focus", function() {
if (firstFocus) {
editor.set("");
firstFocus = false;
}
});
});
</script>
<script type="text/javascript" charset="utf-8" src="'.App::getPaths()['js'].'/ckeditor/ckeditor.js'.'"></script>';
include_once App::filepath('include|custom|', 'bottom.php'); include_once App::filepath('include|custom|', 'bottom.php');

View File

@ -283,6 +283,14 @@ function ckeditor() {
.pipe(gulp.dest(config.production + '/' + config.paths.js + '/ckeditor')); .pipe(gulp.dest(config.production + '/' + config.paths.js + '/ckeditor'));
} }
function summernote() {
return gulp.src([
config.nodeDirectory + '/summernote/dist/{font,lang,plugin}/**/*',
config.nodeDirectory + '/summernote/dist/summernote.{js,css}',
])
.pipe(gulp.dest(config.production + '/' + config.paths.js + '/summernote'));
}
function colorpicker() { function colorpicker() {
return gulp.src([ return gulp.src([
config.nodeDirectory + '/bootstrap-colorpicker/dist/**/*.{jpg,png,jpeg}', config.nodeDirectory + '/bootstrap-colorpicker/dist/**/*.{jpg,png,jpeg}',
@ -493,7 +501,7 @@ function clean() {
} }
// Operazioni di default per la generazione degli assets // Operazioni di default per la generazione degli assets
const bower = gulp.series(clean, gulp.parallel(JS, CSS, images, fonts, phpDebugBar, ckeditor, colorpicker, i18n, pdfjs, hotkeys, chartjs, password_strength, csrf)); const bower = gulp.series(clean, gulp.parallel(JS, CSS, images, fonts, phpDebugBar, summernote, colorpicker, i18n, pdfjs, hotkeys, chartjs, password_strength, csrf));
// Debug su CSS e JS // Debug su CSS e JS
exports.srcJS = srcJS; exports.srcJS = srcJS;

View File

@ -156,7 +156,7 @@ echo '
<div class="row"> <div class="row">
<div class="col-md-12"> <div class="col-md-12">
{[ "type": "ckeditor", "label": "'.tr('Contenuto').'", "name": "body", "id": "body_'.rand(0, 999).'", "value": '.json_encode($body).' ]} {[ "type": "editor", "label": "'.tr('Contenuto').'", "name": "body", "id": "body_'.rand(0, 999).'", "value": '.json_encode($body).' ]}
</div> </div>
</div>'; </div>';

View File

@ -137,7 +137,7 @@ if (strtotime($record['data_conclusione']) < strtotime($record['data_accettazion
<div class="row"> <div class="row">
<div class="col-md-12"> <div class="col-md-12">
{[ "type": "ckeditor", "use_full_ckeditor": 0, "label": "<?php echo tr('Condizioni generali di fornitura'); ?>", "name": "condizioni_fornitura", "class": "autosize", "value": "$condizioni_fornitura$" ]} {[ "type": "editor", "use_full_ckeditor": 0, "label": "<?php echo tr('Condizioni generali di fornitura'); ?>", "name": "condizioni_fornitura", "class": "autosize", "value": "$condizioni_fornitura$" ]}
</div> </div>
</div> </div>

View File

@ -110,7 +110,7 @@ echo '
<div class="row"> <div class="row">
<div class="col-md-12"> <div class="col-md-12">
{[ "type": "ckeditor", "label": "<?php echo tr('Contenuto'); ?>", "name": "body", "value": "$body$" ]} {[ "type": "editor", "label": "<?php echo tr('Contenuto'); ?>", "name": "body", "value": "$body$" ]}
</div> </div>
</div> </div>

View File

@ -50,7 +50,7 @@ include_once __DIR__.'/../../core.php';
<div class="row"> <div class="row">
<div class="col-md-12"> <div class="col-md-12">
{[ "type": "ckeditor", "use_full_ckeditor": 1, "label": "<?php echo tr('Descrizione'); ?>", "name": "descrizione", "value": "$descrizione$" ]} {[ "type": "editor", "use_full_ckeditor": 1, "label": "<?php echo tr('Descrizione'); ?>", "name": "descrizione", "value": "$descrizione$" ]}
</div> </div>
</div> </div>
</div> </div>

View File

@ -210,7 +210,7 @@ echo '
<div class="row"> <div class="row">
<div class="col-md-12"> <div class="col-md-12">
{[ "type": "ckeditor", "label": "'.tr('Richiesta').'", "name": "richiesta", "id": "richiesta_add", "required": 1, "value": "'.$richiesta.'", "extra": "style=\'max-height:80px;\'" ]} {[ "type": "editor", "label": "'.tr('Richiesta').'", "name": "richiesta", "id": "richiesta_add", "required": 1, "value": "'.$richiesta.'", "extra": "style=\'max-height:80px;\'" ]}
</div> </div>
</div>'; </div>';

View File

@ -314,11 +314,11 @@ echo '
<!-- RIGA 5 --> <!-- RIGA 5 -->
<div class="row"> <div class="row">
<div class="col-md-12"> <div class="col-md-12">
{[ "type": "ckeditor", "label": "<?php echo tr('Richiesta'); ?>", "name": "richiesta", "required": 1, "class": "autosize", "value": "$richiesta$", "extra": "rows='5'", "readonly": "<?php echo $record['flag_completato']; ?>" ]} {[ "type": "editor", "label": "<?php echo tr('Richiesta'); ?>", "name": "richiesta", "required": 1, "class": "autosize", "value": "$richiesta$", "extra": "rows='5'", "readonly": "<?php echo $record['flag_completato']; ?>" ]}
</div> </div>
<div class="col-md-12"> <div class="col-md-12">
{[ "type": "ckeditor", "label": "<?php echo tr('Descrizione'); ?>", "name": "descrizione", "class": "autosize", "value": "$descrizione$", "extra": "rows='10'", "readonly": "<?php echo $record['flag_completato']; ?>" ]} {[ "type": "editor", "label": "<?php echo tr('Descrizione'); ?>", "name": "descrizione", "class": "autosize", "value": "$descrizione$", "extra": "rows='10'", "readonly": "<?php echo $record['flag_completato']; ?>" ]}
</div> </div>
<?php <?php
// Nascondo le note interne ai clienti // Nascondo le note interne ai clienti

View File

@ -85,7 +85,7 @@ echo '
<div class="row"> <div class="row">
<div class="col-md-12"> <div class="col-md-12">
{[ "type": "ckeditor", "use_full_ckeditor": 1, "label": "'.tr('Contenuto').'", "name": "content", "value": "$content$" ]} {[ "type": "editor", "use_full_ckeditor": 1, "label": "'.tr('Contenuto').'", "name": "content", "value": "$content$" ]}
</div> </div>
</div> </div>

View File

@ -164,7 +164,7 @@ echo '
<div class="row"> <div class="row">
<div class="col-md-12"> <div class="col-md-12">
{[ "type": "ckeditor", "use_full_ckeditor": 0, "label": "<?php echo tr('Condizioni generali di fornitura'); ?>", "name": "condizioni_fornitura", "class": "autosize", "value": "$condizioni_fornitura$" ]} {[ "type": "editor", "use_full_ckeditor": 0, "label": "<?php echo tr('Condizioni generali di fornitura'); ?>", "name": "condizioni_fornitura", "class": "autosize", "value": "$condizioni_fornitura$" ]}
</div> </div>
</div> </div>

View File

@ -38,6 +38,7 @@
"select2-bootstrap-theme": "^0.1.0-beta.10", "select2-bootstrap-theme": "^0.1.0-beta.10",
"signature_pad": "^2.1.1", "signature_pad": "^2.1.1",
"smartwizard": "^4.2.2", "smartwizard": "^4.2.2",
"summernote": "^0.8.16",
"sweetalert2": "^6.11.4", "sweetalert2": "^6.11.4",
"toastr": "^2.1.4", "toastr": "^2.1.4",
"tooltipster": "^4.2.5" "tooltipster": "^4.2.5"

View File

@ -167,7 +167,7 @@ foreach ($elenchi as $elenco) {
<div class="row"> <div class="row">
<div class="col-md-12"> <div class="col-md-12">
{[ "type": "ckeditor", "label": "'.tr('Note').'", "name": "note", "id": "note_'.$componente->id.'", "value": "'.$componente['note'].'" ]} {[ "type": "editor", "label": "'.tr('Note').'", "name": "note", "id": "note_'.$componente->id.'", "value": "'.$componente['note'].'" ]}
</div> </div>
</div> </div>

View File

@ -95,7 +95,7 @@ if ($structure->permission == 'rw') {
<input type="hidden" name="backto" value="record-edit"> <input type="hidden" name="backto" value="record-edit">
<div class="row" > <div class="row" >
<div class="col-md-12" > <div class="col-md-12" >
{[ "type": "ckeditor", "label": "'.tr('Nuova nota').'", "name": "contenuto", "required": 1, "class": "unblockable" ]} {[ "type": "editor", "label": "'.tr('Nuova nota').'", "name": "contenuto", "required": 1, "class": "unblockable" ]}
</div> </div>
<div class="col-md-4" > <div class="col-md-4" >
{[ "type": "date", "label": "'.tr('Data di notifica').'", "name": "data_notifica", "class": "unblockable", "help": "'.tr('Eventuale data di notifica di un promemoria di questa nota.').'" ]} {[ "type": "date", "label": "'.tr('Data di notifica').'", "name": "data_notifica", "class": "unblockable", "help": "'.tr('Eventuale data di notifica di un promemoria di questa nota.').'" ]}

View File

@ -61,6 +61,7 @@ class App
'functions.min.js', 'functions.min.js',
'custom.min.js', 'custom.min.js',
'i18n/parsleyjs/|lang|.min.js', 'i18n/parsleyjs/|lang|.min.js',
'i18n/parsleyjs/|lang|.min.js',
'i18n/select2/|lang|.min.js', 'i18n/select2/|lang|.min.js',
'i18n/moment/|lang|.min.js', 'i18n/moment/|lang|.min.js',
'i18n/fullcalendar/|lang|.min.js', 'i18n/fullcalendar/|lang|.min.js',

View File

@ -173,7 +173,7 @@ class Filter
if (empty(self::$purifier)) { if (empty(self::$purifier)) {
$config = \HTMLPurifier_Config::createDefault(); $config = \HTMLPurifier_Config::createDefault();
$config->set('HTML.Allowed', 'br,p[style],b[style],strong[style],i[style],em[style],u[style],strike,a[style|href|title|target],ol[style],ul[style],li[style],hr[style],blockquote[style],img[style|alt|title|width|height|src|align],table[style|width|bgcolor|align|cellspacing|cellpadding|border],tr[style],td[style],th[style],tbody,thead,caption,col,colgroup,span[style],sup'); $config->set('HTML.Allowed', 'br,h1,h2,h3,h4,h5,h6,p[style],b[style],strong[style],i[style],em[style],u[style],strike,a[style|href|title|target],ol[style],ul[style],li[style],hr[style],blockquote[style],img[style|alt|title|width|height|src|align],table[style|width|bgcolor|align|cellspacing|cellpadding|border],tr[style],td[style],th[style],tbody,thead,caption,col,colgroup,span[style],sup');
//$config->set('Cache.SerializerPath', realpath(__DIR__.'/cache/HTMLPurifier')); //$config->set('Cache.SerializerPath', realpath(__DIR__.'/cache/HTMLPurifier'));
$config->set('Cache.DefinitionImpl', null); $config->set('Cache.DefinitionImpl', null);

View File

@ -77,7 +77,7 @@ class HTMLBuilder
'timestamp' => Handler\DateHandler::class, 'timestamp' => Handler\DateHandler::class,
'date' => Handler\DateHandler::class, 'date' => Handler\DateHandler::class,
'time' => Handler\DateHandler::class, 'time' => Handler\DateHandler::class,
'ckeditor' => Handler\CKEditorHandler::class, 'editor' => Handler\EditorHandler::class,
], ],
'instances' => [], 'instances' => [],
]; ];

View File

@ -1,39 +0,0 @@
<?php
/*
* OpenSTAManager: il software gestionale open source per l'assistenza tecnica e la fatturazione
* Copyright (C) DevCode s.r.l.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
namespace HTMLBuilder\Handler;
/**
* Gestione dell'input di tipo "ckeditor".
*
* @since 2.4.2
*/
class CKEditorHandler implements HandlerInterface
{
public function handle(&$values, &$extras)
{
$values['class'][] = 'openstamanager-input';
$values['class'][] = 'editor-input';
// Generazione del codice HTML
return '
<textarea |attr|>|value|</textarea>
<script src="'.base_path().'/assets/dist/js/ckeditor/ckeditor.js"></script>';
}
}

View File

@ -0,0 +1,36 @@
<?php
namespace HTMLBuilder\Handler;
/**
* Gestione dell'input di tipo "editor".
*
* @since 2.4.2
*/
class EditorHandler implements HandlerInterface
{
public function handle(&$values, &$extras)
{
$lang = trans()->getCurrentLocale();
$lang = str_replace('_', '-', $lang);
// Generazione del codice HTML
return '
<textarea |attr|>|value|</textarea>
<link rel="stylesheet" type="text/css" media="all" href="'.ROOTDIR.'/assets/dist/js/summernote/summernote.css"/>
<script src="'.ROOTDIR.'/assets/dist/js/summernote/summernote.js"></script>
<script src="'.ROOTDIR.'/assets/dist/js/summernote/lang/summernote-'.$lang.'.min.js"></script>
<script>
$(document).ready(function() {
$("#'.prepareToField($values['id']).'").summernote({
lang: "'.$lang.'",
height: 250,
placeholder: `'.prepareToField($values['placeholder']).'`,
});
});
</script>';
unset($values['placeholder']);
}
}