diff --git a/application/itopwebpage.class.inc.php b/application/itopwebpage.class.inc.php index e7862fe34..576779140 100644 --- a/application/itopwebpage.class.inc.php +++ b/application/itopwebpage.class.inc.php @@ -80,6 +80,7 @@ class iTopWebPage extends NiceWebPage implements iTabbedPage $this->add_linked_stylesheet("../css/c3.min.css"); $this->add_linked_stylesheet("../css/font-awesome/css/all.min.css"); $this->add_linked_stylesheet("../css/font-awesome/css/v4-shims.min.css"); + $this->add_linked_stylesheet("../js/ckeditor/plugins/codesnippet/lib/highlight/styles/obsidian.css"); $this->add_linked_script('../js/jquery.layout.min.js'); $this->add_linked_script('../js/jquery.ba-bbq.min.js'); @@ -93,6 +94,7 @@ class iTopWebPage extends NiceWebPage implements iTabbedPage $this->add_linked_script("../js/swfobject.js"); $this->add_linked_script("../js/ckeditor/ckeditor.js"); $this->add_linked_script("../js/ckeditor/adapters/jquery.js"); + $this->add_linked_script("../js/ckeditor/plugins/codesnippet/lib/highlight/highlight.pack.js"); $this->add_linked_script("../js/jquery.qtip-1.0.min.js"); $this->add_linked_script('../js/property_field.js'); $this->add_linked_script('../js/icon_select.js'); @@ -350,6 +352,20 @@ JS .magnificPopup({type: 'image', closeOnContentClick: true }); JS ); + + // Highlight code content created with CKEditor + $this->add_ready_script( + <<add_init_script( <<< JS diff --git a/core/htmlsanitizer.class.inc.php b/core/htmlsanitizer.class.inc.php index 5b7693ead..b2a7aa4c7 100644 --- a/core/htmlsanitizer.class.inc.php +++ b/core/htmlsanitizer.class.inc.php @@ -183,7 +183,7 @@ class HTMLDOMSanitizer extends HTMLSanitizer 'h4' => array('style'), 'nav' => array('style'), 'section' => array('style'), - 'code' => array('style'), + 'code' => array('style', 'class'), 'table' => array('style', 'width', 'summary', 'align', 'border', 'cellpadding', 'cellspacing'), 'thead' => array('style'), 'tbody' => array('style'), diff --git a/datamodels/2.x/itop-portal-base/portal/templates/layout.html.twig b/datamodels/2.x/itop-portal-base/portal/templates/layout.html.twig index 1d02e7397..816f6fe1a 100644 --- a/datamodels/2.x/itop-portal-base/portal/templates/layout.html.twig +++ b/datamodels/2.x/itop-portal-base/portal/templates/layout.html.twig @@ -49,6 +49,7 @@ + {# - Bootstrap theme #} {# - Portal adjustments for BS theme #} @@ -119,6 +120,8 @@ {# CKEditor files for HTML WYSIWYG #} + {# Hilighter for code snippets created with CKEditor#} + {# Date-time picker for Bootstrap #} {# Typeahead files for autocomplete #} diff --git a/js/ckeditor/config.js b/js/ckeditor/config.js index a09b64e7c..6a55b4b59 100644 --- a/js/ckeditor/config.js +++ b/js/ckeditor/config.js @@ -40,4 +40,7 @@ CKEDITOR.editorConfig = function( config ) { // Enable the browser spell checking config.disableNativeSpellChecker = false; + + // Set theme for codesnippet plugin - N°1164 + config.codeSnippet_theme = 'obsidian'; }; diff --git a/sources/renderer/bootstrap/fieldrenderer/bssimplefieldrenderer.class.inc.php b/sources/renderer/bootstrap/fieldrenderer/bssimplefieldrenderer.class.inc.php index cda101550..947f3b310 100644 --- a/sources/renderer/bootstrap/fieldrenderer/bssimplefieldrenderer.class.inc.php +++ b/sources/renderer/bootstrap/fieldrenderer/bssimplefieldrenderer.class.inc.php @@ -150,6 +150,14 @@ EOF if ($sFieldClass === 'Combodo\\iTop\\Form\\Field\\CaseLogField') { $this->PreparingCaseLogEntries($oOutput); + // Trigger highlighter for all code blocks in this caselog + $oOutput->AddJs( + << pre").each(function(i, block) { + hljs.highlightBlock(block); + }); +JS + ); } $oOutput->AddHtml(''); @@ -349,6 +357,14 @@ EOF $oOutput->AddHtml('
'); $oOutput->AddHtml('
')->AddHtml($this->oField->GetDisplayValue(), false)->AddHtml('
'); $oOutput->AddHtml('
'); + // Trigger highlighter for all code blocks in this html text field + $oOutput->AddJs( + <<