N°2950 - Fix syntax highlighting (CKEditor) not working on AttributeHTML

- Fix for not supported attributes (HTML)
- Migrate selectors for new backoffice markup
This commit is contained in:
Molkobain
2020-11-04 17:25:25 +01:00
parent fa0bb2b466
commit d76e4255f2
6 changed files with 30 additions and 35 deletions

View File

@@ -17,4 +17,5 @@
*/
@import "bulma-variables-overload";
@import "../../../node_modules/bulma-scss/bulma";
@import "../../../node_modules/bulma-scss/bulma";
@import "ckeditor";

11
css/backoffice/vendors/_ckeditor.scss vendored Normal file
View File

@@ -0,0 +1,11 @@
/*!
* @copyright Copyright (C) 2010-2020 Combodo SARL
* @license http://opensource.org/licenses/AGPL-3.0
*/
.hljs {
padding: 0.9em !important;
box-shadow: 0 0px 3px 2px inset rgba(0, 0, 0, 0.4);
border-radius: $ibo-border-radius-300;
white-space: pre-wrap;
}

View File

@@ -422,11 +422,11 @@
display: none;
}
.hljs {
padding: 0.9em !important;
box-shadow: 0 0px 3px 2px inset rgba(0, 0, 0, 0.4);
border-radius: 3px;
}
//.hljs {
// padding: 0.9em !important;
// box-shadow: 0 0px 3px 2px inset rgba(0, 0, 0, 0.4);
// border-radius: 3px;
//}
td a.no-arrow, td a.no-arrow:visited, .SearchDrawer a.no-arrow, .SearchDrawer a.no-arrow:visited {
text-decoration: none;

View File

@@ -145,14 +145,6 @@ EOF
// Then the previous entries if necessary
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>');
@@ -338,14 +330,6 @@ 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
@@ -374,14 +358,6 @@ JS
// 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':
@@ -522,6 +498,13 @@ EOF
if($bRichEditor) {
// MagnificPopup on images
$oOutput->AddJs(InlineImage::FixImagesWidth());
// Trigger highlighter for all code blocks in this caselog
$oOutput->AddJs(<<<JS
$("[data-field-id='{$this->oField->GetId()}'][data-form-path='{$this->oField->GetFormPath()}'] pre").each(function(i, block) {
hljs.highlightBlock(block);
});
JS
);
}
break;
}

View File

@@ -324,12 +324,12 @@ JS
// Highlight code content created with CKEditor
$this->add_ready_script(
<<<JS
// Highlight code content for HTML AttributeText
$("[data-attribute-type='AttributeText'] .HTML pre").each(function(i, block) {
// Highlight code content for AttributeHTML and HTML AttributeText
$('[data-attribute-type="AttributeHTML"], [data-attribute-type="AttributeText"]').find('.HTML pre').each(function(i, block) {
hljs.highlightBlock(block);
});
// Highlight code content for CaseLogs
$("[data-attribute-type='AttributeCaseLog'] .caselog_entry_html pre").each(function(i, block) {
$('[data-role="ibo-activity-entry--main-information-content"] pre').each(function(i, block) {
hljs.highlightBlock(block);
});
JS

View File

@@ -16,14 +16,14 @@
<div class="ibo-activity-entry--information" data-role="ibo-activity-entry--information">
{% block iboActivityEntryInformation %}
<div class="ibo-activity-entry--main-information" data-role="ibo-activity-entry--main-information">
<div class="ibo-activity-entry--main-information-icon">
<div class="ibo-activity-entry--main-information-icon" data-role="ibo-activity-entry--main-information-icon">
{% block iboActivityEntryMainInformationIcon %}
{% if oUIBlock.GetDecorationClasses() is not empty %}
<span class="{{ oUIBlock.GetDecorationClasses() }}"></span>
{% endif %}
{% endblock %}
</div>
<div class="ibo-activity-entry--main-information-content">
<div class="ibo-activity-entry--main-information-content" data-role="ibo-activity-entry--main-information-content">
{% block iboActivityEntryMainInformationContent %}
{# Content is printed as raw because it is stored as HTML in the database and should have been sanitized before storage, so we can assume it is safe #}
{{ oUIBlock.GetContent()|raw }}