mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
BUG: Fix duplicate plugins on HTML editor fields (#8559)
* BUG: Fix duplicate plugins on HTML editor fields * Add new test
This commit is contained in:
parent
55f95b7bc8
commit
8866e7674a
@ -83,6 +83,7 @@ abstract class HTMLEditorConfig
|
|||||||
// Create new instance if unconfigured
|
// Create new instance if unconfigured
|
||||||
if (!isset(self::$configs[$identifier])) {
|
if (!isset(self::$configs[$identifier])) {
|
||||||
self::$configs[$identifier] = static::create();
|
self::$configs[$identifier] = static::create();
|
||||||
|
self::$configs[$identifier]->setOption('editorIdentifier', $identifier);
|
||||||
}
|
}
|
||||||
return self::$configs[$identifier];
|
return self::$configs[$identifier];
|
||||||
}
|
}
|
||||||
@ -98,6 +99,7 @@ abstract class HTMLEditorConfig
|
|||||||
{
|
{
|
||||||
if ($config) {
|
if ($config) {
|
||||||
self::$configs[$identifier] = $config;
|
self::$configs[$identifier] = $config;
|
||||||
|
self::$configs[$identifier]->setOption('editorIdentifier', $identifier);
|
||||||
} else {
|
} else {
|
||||||
unset(self::$configs[$identifier]);
|
unset(self::$configs[$identifier]);
|
||||||
}
|
}
|
||||||
|
@ -130,11 +130,13 @@ class TinyMCECombinedGenerator implements TinyMCEScriptGenerator, Flushable
|
|||||||
|
|
||||||
// Register vars for config
|
// Register vars for config
|
||||||
$baseDirJS = Convert::raw2js(Director::absoluteBaseURL());
|
$baseDirJS = Convert::raw2js(Director::absoluteBaseURL());
|
||||||
|
$name = Convert::raw2js($this->checkName($config));
|
||||||
$buffer = [];
|
$buffer = [];
|
||||||
$buffer[] = <<<SCRIPT
|
$buffer[] = <<<SCRIPT
|
||||||
(function() {
|
(function() {
|
||||||
var baseTag = window.document.getElementsByTagName('base');
|
var baseTag = window.document.getElementsByTagName('base');
|
||||||
var baseURL = baseTag.length ? baseTag[0].baseURI : '$baseDirJS';
|
var baseURL = baseTag.length ? baseTag[0].baseURI : '$baseDirJS';
|
||||||
|
var editorIdentifier = '$name';
|
||||||
SCRIPT;
|
SCRIPT;
|
||||||
$buffer[] = <<<SCRIPT
|
$buffer[] = <<<SCRIPT
|
||||||
(function() {
|
(function() {
|
||||||
|
@ -9,6 +9,13 @@ use SilverStripe\Forms\HTMLEditor\TinyMCEConfig;
|
|||||||
|
|
||||||
class TinyMCEConfigTest extends SapphireTest
|
class TinyMCEConfigTest extends SapphireTest
|
||||||
{
|
{
|
||||||
|
|
||||||
|
public function testEditorIdentifier()
|
||||||
|
{
|
||||||
|
$config = TinyMCEConfig::get('myconfig');
|
||||||
|
$this->assertEquals('myconfig', $config->getOption('editorIdentifier'));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Ensure that all TinyMCEConfig.tinymce_lang are valid
|
* Ensure that all TinyMCEConfig.tinymce_lang are valid
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user