Merge remote-tracking branch 'origin/support/3.2' into develop

This commit is contained in:
Benjamin Dalsass
2024-06-10 10:08:11 +02:00
7 changed files with 28 additions and 12 deletions

View File

@@ -115,6 +115,19 @@ class CKEditorHelper
return $aMentionConfiguration;
}
/**
* Encode value when using CKEditor with a TextArea.
* @see https://ckeditor.com/docs/ckeditor5/latest/installation/getting-started/getting-and-setting-data.html#automatic-integration-with-html-forms
*
* @param string $sValue
*
* @return string
*/
public static function PrepareCKEditorValueTextEncodingForTextarea(string $sValue) : string
{
return str_replace( '&', '&', $sValue );
}
/**
* Configure CKEditor element (WebPage).
*

View File

@@ -161,7 +161,7 @@ EOF
// First the edition area
$oOutput->AddHtml('<div>');
$sEditorClasses = $bRichEditor ? 'htmlEditor' : '';
$oOutput->AddHtml('<textarea id="'.$this->oField->GetGlobalId().'" name="'.$this->oField->GetId().'" class="' . $sEditorClasses . ' form-control" rows="8" '.$sInputTags.'>'.$this->oField->GetCurrentValue().'</textarea>');
$oOutput->AddHtml('<textarea id="'.$this->oField->GetGlobalId().'" name="'.$this->oField->GetId().'" class="' . $sEditorClasses . ' form-control" rows="8" '.$sInputTags.'>'. CKEditorHelper::PrepareCKEditorValueTextEncodingForTextarea($this->oField->GetCurrentValue()) .'</textarea>');
$oOutput->AddHtml('</div>');
// Then the previous entries if necessary
if ($sFieldClass === 'Combodo\\iTop\\Form\\Field\\CaseLogField') {

View File

@@ -156,7 +156,7 @@ class ConsoleSimpleFieldRenderer extends FieldRenderer
}
else
{
$oText = new TextArea("",$this->oField->GetCurrentValue(),$this->oField->GetGlobalId(),40,8);
$oText = new TextArea("", CKEditorHelper::PrepareCKEditorValueTextEncodingForTextarea($this->oField->GetCurrentValue()),$this->oField->GetGlobalId(),40,8);
$oText->AddCSSClasses(['ibo-input-field-wrapper', 'ibo-input']);
$oValue->AddSubBlock($oText);
// Some additional stuff if we are displaying it with a rich editor