N°1164 #1491 - Fix syntax code highlighting display in CaseLog/HTML fields

This commit is contained in:
Stephen Abello
2020-02-25 09:54:18 +01:00
parent ea59f7bc23
commit ccfd3848fb
5 changed files with 47 additions and 1 deletions

View File

@@ -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(
<<<JS
$("[data-field-id='{$this->oField->GetId()}'][data-form-path='{$this->oField->GetFormPath()}'] .caselog_field_entry_content > pre").each(function(i, block) {
hljs.highlightBlock(block);
});
JS
);
}
$oOutput->AddHtml('</div>');
@@ -349,6 +357,14 @@ EOF
$oOutput->AddHtml('<div class="form_field_control">');
$oOutput->AddHtml('<div class="form-control-static">')->AddHtml($this->oField->GetDisplayValue(), false)->AddHtml('</div>');
$oOutput->AddHtml('</div>');
// Trigger highlighter for all code blocks in this html text field
$oOutput->AddJs(
<<<JS
$("[data-field-id='{$this->oField->GetId()}'][data-form-path='{$this->oField->GetFormPath()}'] .HTML pre").each(function(i, block) {
hljs.highlightBlock(block);
});
JS
);
}
// Adding hidden input
@@ -378,6 +394,14 @@ EOF
// Closing container
$oOutput->AddHtml('</div>');
// Trigger highlighter for all code blocks in this caselog
$oOutput->AddJs(
<<<JS
$("[data-field-id='{$this->oField->GetId()}'][data-form-path='{$this->oField->GetFormPath()}'] .caselog_field_entry_content pre").each(function(i, block) {
hljs.highlightBlock(block);
});
JS
);
break;
case 'Combodo\\iTop\\Form\\Field\\BlobField':