N°2875 - RichText: Fix config property being an array instead of a string (also add a setter)

This commit is contained in:
Molkobain
2021-10-18 23:40:22 +02:00
parent 0b0c99c935
commit 6915b0b824
2 changed files with 18 additions and 5 deletions

View File

@@ -28,7 +28,7 @@ class RichText extends UIBlock
'js/ckeditor/plugins/codesnippet/lib/highlight/styles/obsidian.css',
];
/** @var string */
/** @var array Configuration parameters for the CKEditor instance used with Richtext block */
protected $aConfig;
/**
@@ -39,14 +39,27 @@ class RichText extends UIBlock
public function __construct(?string $sId = null)
{
parent::__construct($sId);
$this->aConfig = json_encode(utils::GetCkeditorPref());
$this->aConfig = utils::GetCkeditorPref();
}
/**
* @param array $aConfig
* @see static::$aConfig
*
* @return $this
*/
public function SetConfig(array $aConfig)
{
$this->aConfig = $aConfig;
return $this;
}
/**
* @return string
* @see static::$aConfig
* @return array
*/
public function GetConfig()
public function GetConfig(): array
{
return $this->aConfig;
}

View File

@@ -1 +1 @@
$('#{{ oUIBlock.GetId() }}').ckeditor(function() { /* callback code */ }, {{ oUIBlock.GetConfig()| raw }});
$('#{{ oUIBlock.GetId() }}').ckeditor(function() { /* callback code */ }, {{ oUIBlock.GetConfig()|json_encode|raw }});