From 0ef2d62931f69c359ad07cbcd20e34042f27eed1 Mon Sep 17 00:00:00 2001 From: Thomas Zilio Date: Fri, 13 Mar 2020 14:01:51 +0100 Subject: [PATCH] Introduzione summernote --- bug.php | 38 ++------------------ gulpfile.js | 10 +++++- mail.php | 2 +- modules/contratti/edit.php | 2 +- modules/emails/edit.php | 2 +- modules/gestione_documentale/edit.php | 2 +- modules/interventi/add.php | 2 +- modules/interventi/edit.php | 4 +-- modules/newsletter/edit.php | 2 +- modules/preventivi/edit.php | 2 +- package.json | 1 + plugins/componenti/edit.php | 2 +- plugins/notes.php | 2 +- src/App.php | 1 + src/Filter.php | 2 +- src/HTMLBuilder/HTMLBuilder.php | 2 +- src/HTMLBuilder/Handler/CKEditorHandler.php | 39 --------------------- src/HTMLBuilder/Handler/EditorHandler.php | 36 +++++++++++++++++++ 18 files changed, 62 insertions(+), 89 deletions(-) delete mode 100755 src/HTMLBuilder/Handler/CKEditorHandler.php create mode 100755 src/HTMLBuilder/Handler/EditorHandler.php diff --git a/bug.php b/bug.php index 4d50c6d68..cc46fe16b 100755 --- a/bug.php +++ b/bug.php @@ -152,7 +152,7 @@ echo '

- {[ "type": "ckeditor", "label": "'.tr('Descrizione del bug').'", "name": "body" ]} + {[ "type": "editor", "label": "'.tr('Descrizione del bug').'", "name": "body", "placeholder": "

'.tr('Se hai riscontrato un bug ricordati di specificare').':

'.tr('Assicurati inoltre di controllare che il checkbox relativo ai file di log sia contrassegnato, oppure riporta qui l\'errore visualizzato').'.

'.tr('Ti ringraziamo per il tuo contributo').',
'.tr('Lo staff di OSM').'

" ]}
@@ -164,40 +164,6 @@ echo '
- - - - -'; +'; include_once App::filepath('include|custom|', 'bottom.php'); diff --git a/gulpfile.js b/gulpfile.js index d7f5bb48d..3ae59a950 100755 --- a/gulpfile.js +++ b/gulpfile.js @@ -283,6 +283,14 @@ function 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() { return gulp.src([ config.nodeDirectory + '/bootstrap-colorpicker/dist/**/*.{jpg,png,jpeg}', @@ -493,7 +501,7 @@ function clean() { } // 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 exports.srcJS = srcJS; diff --git a/mail.php b/mail.php index 2e81d86b6..fc8009609 100755 --- a/mail.php +++ b/mail.php @@ -156,7 +156,7 @@ echo '
- {[ "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).' ]}
'; diff --git a/modules/contratti/edit.php b/modules/contratti/edit.php index bcdda45b8..845c569a1 100755 --- a/modules/contratti/edit.php +++ b/modules/contratti/edit.php @@ -137,7 +137,7 @@ if (strtotime($record['data_conclusione']) < strtotime($record['data_accettazion
- {[ "type": "ckeditor", "use_full_ckeditor": 0, "label": "", "name": "condizioni_fornitura", "class": "autosize", "value": "$condizioni_fornitura$" ]} + {[ "type": "editor", "use_full_ckeditor": 0, "label": "", "name": "condizioni_fornitura", "class": "autosize", "value": "$condizioni_fornitura$" ]}
diff --git a/modules/emails/edit.php b/modules/emails/edit.php index c59ff0ef2..c6e8748f9 100755 --- a/modules/emails/edit.php +++ b/modules/emails/edit.php @@ -110,7 +110,7 @@ echo '
- {[ "type": "ckeditor", "label": "", "name": "body", "value": "$body$" ]} + {[ "type": "editor", "label": "", "name": "body", "value": "$body$" ]}
diff --git a/modules/gestione_documentale/edit.php b/modules/gestione_documentale/edit.php index b98efd5bf..e481a9b58 100755 --- a/modules/gestione_documentale/edit.php +++ b/modules/gestione_documentale/edit.php @@ -50,7 +50,7 @@ include_once __DIR__.'/../../core.php';
- {[ "type": "ckeditor", "use_full_ckeditor": 1, "label": "", "name": "descrizione", "value": "$descrizione$" ]} + {[ "type": "editor", "use_full_ckeditor": 1, "label": "", "name": "descrizione", "value": "$descrizione$" ]}
diff --git a/modules/interventi/add.php b/modules/interventi/add.php index 4d6f965b8..c53158c90 100755 --- a/modules/interventi/add.php +++ b/modules/interventi/add.php @@ -210,7 +210,7 @@ echo '
- {[ "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;\'" ]}
'; diff --git a/modules/interventi/edit.php b/modules/interventi/edit.php index 814381f6d..c41672064 100755 --- a/modules/interventi/edit.php +++ b/modules/interventi/edit.php @@ -314,11 +314,11 @@ echo '
- {[ "type": "ckeditor", "label": "", "name": "richiesta", "required": 1, "class": "autosize", "value": "$richiesta$", "extra": "rows='5'", "readonly": "" ]} + {[ "type": "editor", "label": "", "name": "richiesta", "required": 1, "class": "autosize", "value": "$richiesta$", "extra": "rows='5'", "readonly": "" ]}
- {[ "type": "ckeditor", "label": "", "name": "descrizione", "class": "autosize", "value": "$descrizione$", "extra": "rows='10'", "readonly": "" ]} + {[ "type": "editor", "label": "", "name": "descrizione", "class": "autosize", "value": "$descrizione$", "extra": "rows='10'", "readonly": "" ]}
- {[ "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$" ]}
diff --git a/modules/preventivi/edit.php b/modules/preventivi/edit.php index 2cd7933db..c0abb3e6e 100755 --- a/modules/preventivi/edit.php +++ b/modules/preventivi/edit.php @@ -164,7 +164,7 @@ echo '
- {[ "type": "ckeditor", "use_full_ckeditor": 0, "label": "", "name": "condizioni_fornitura", "class": "autosize", "value": "$condizioni_fornitura$" ]} + {[ "type": "editor", "use_full_ckeditor": 0, "label": "", "name": "condizioni_fornitura", "class": "autosize", "value": "$condizioni_fornitura$" ]}
diff --git a/package.json b/package.json index 7b7957fdd..4d5966978 100755 --- a/package.json +++ b/package.json @@ -38,6 +38,7 @@ "select2-bootstrap-theme": "^0.1.0-beta.10", "signature_pad": "^2.1.1", "smartwizard": "^4.2.2", + "summernote": "^0.8.16", "sweetalert2": "^6.11.4", "toastr": "^2.1.4", "tooltipster": "^4.2.5" diff --git a/plugins/componenti/edit.php b/plugins/componenti/edit.php index 2933355a0..3b7e13230 100644 --- a/plugins/componenti/edit.php +++ b/plugins/componenti/edit.php @@ -167,7 +167,7 @@ foreach ($elenchi as $elenco) {
- {[ "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'].'" ]}
diff --git a/plugins/notes.php b/plugins/notes.php index 6d2d1f128..692127568 100755 --- a/plugins/notes.php +++ b/plugins/notes.php @@ -95,7 +95,7 @@ if ($structure->permission == 'rw') {
- {[ "type": "ckeditor", "label": "'.tr('Nuova nota').'", "name": "contenuto", "required": 1, "class": "unblockable" ]} + {[ "type": "editor", "label": "'.tr('Nuova nota').'", "name": "contenuto", "required": 1, "class": "unblockable" ]}
{[ "type": "date", "label": "'.tr('Data di notifica').'", "name": "data_notifica", "class": "unblockable", "help": "'.tr('Eventuale data di notifica di un promemoria di questa nota.').'" ]} diff --git a/src/App.php b/src/App.php index a89d7d2ad..82a0a19c5 100755 --- a/src/App.php +++ b/src/App.php @@ -61,6 +61,7 @@ class App 'functions.min.js', 'custom.min.js', 'i18n/parsleyjs/|lang|.min.js', + 'i18n/parsleyjs/|lang|.min.js', 'i18n/select2/|lang|.min.js', 'i18n/moment/|lang|.min.js', 'i18n/fullcalendar/|lang|.min.js', diff --git a/src/Filter.php b/src/Filter.php index fabf40fbe..456b5ef39 100755 --- a/src/Filter.php +++ b/src/Filter.php @@ -173,7 +173,7 @@ class Filter if (empty(self::$purifier)) { $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.DefinitionImpl', null); diff --git a/src/HTMLBuilder/HTMLBuilder.php b/src/HTMLBuilder/HTMLBuilder.php index 8dfe92a60..5599d20ac 100755 --- a/src/HTMLBuilder/HTMLBuilder.php +++ b/src/HTMLBuilder/HTMLBuilder.php @@ -77,7 +77,7 @@ class HTMLBuilder 'timestamp' => Handler\DateHandler::class, 'date' => Handler\DateHandler::class, 'time' => Handler\DateHandler::class, - 'ckeditor' => Handler\CKEditorHandler::class, + 'editor' => Handler\EditorHandler::class, ], 'instances' => [], ]; diff --git a/src/HTMLBuilder/Handler/CKEditorHandler.php b/src/HTMLBuilder/Handler/CKEditorHandler.php deleted file mode 100755 index 101b07f40..000000000 --- a/src/HTMLBuilder/Handler/CKEditorHandler.php +++ /dev/null @@ -1,39 +0,0 @@ -. - */ - -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 ' - - '; - } -} diff --git a/src/HTMLBuilder/Handler/EditorHandler.php b/src/HTMLBuilder/Handler/EditorHandler.php new file mode 100755 index 000000000..34ffa3fea --- /dev/null +++ b/src/HTMLBuilder/Handler/EditorHandler.php @@ -0,0 +1,36 @@ +getCurrentLocale(); + $lang = str_replace('_', '-', $lang); + + // Generazione del codice HTML + return ' + + + + + + '; + + unset($values['placeholder']); + } +}