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
|
||||
if (!isset(self::$configs[$identifier])) {
|
||||
self::$configs[$identifier] = static::create();
|
||||
self::$configs[$identifier]->setOption('editorIdentifier', $identifier);
|
||||
}
|
||||
return self::$configs[$identifier];
|
||||
}
|
||||
@ -98,6 +99,7 @@ abstract class HTMLEditorConfig
|
||||
{
|
||||
if ($config) {
|
||||
self::$configs[$identifier] = $config;
|
||||
self::$configs[$identifier]->setOption('editorIdentifier', $identifier);
|
||||
} else {
|
||||
unset(self::$configs[$identifier]);
|
||||
}
|
||||
|
@ -130,11 +130,13 @@ class TinyMCECombinedGenerator implements TinyMCEScriptGenerator, Flushable
|
||||
|
||||
// Register vars for config
|
||||
$baseDirJS = Convert::raw2js(Director::absoluteBaseURL());
|
||||
$name = Convert::raw2js($this->checkName($config));
|
||||
$buffer = [];
|
||||
$buffer[] = <<<SCRIPT
|
||||
(function() {
|
||||
var baseTag = window.document.getElementsByTagName('base');
|
||||
var baseURL = baseTag.length ? baseTag[0].baseURI : '$baseDirJS';
|
||||
var editorIdentifier = '$name';
|
||||
SCRIPT;
|
||||
$buffer[] = <<<SCRIPT
|
||||
(function() {
|
||||
|
@ -140,7 +140,7 @@ class HTMLEditorConfigTest extends SapphireTest
|
||||
$this->assertNotContains('plugin1', array_keys($plugins));
|
||||
$this->assertNotContains('plugin2', array_keys($plugins));
|
||||
}
|
||||
|
||||
|
||||
public function testRequireJSIncludesAllConfigs()
|
||||
{
|
||||
$a = HTMLEditorConfig::get('configA');
|
||||
|
@ -9,6 +9,13 @@ use SilverStripe\Forms\HTMLEditor\TinyMCEConfig;
|
||||
|
||||
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
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user