Closed x1oJ0 closed 5 years ago
Can you please add a test case that covers this change?
Can you please add a test case that covers this change?
Hey @kunicmarko20, sure.
In this example, we setup custom toolbar in config:
fos_ck_editor:
default_config: simple_toolbar
configs:
forcePasteAsPlainText: true
simple_toolbar:
toolbar:
- ['Undo', 'Redo']
- ['Format']
- ['Bold', 'Italic', 'Strike', 'Subscript', 'Superscript' ]
- ['Link', 'Unlink']
- ['RemoveFormat']
- ['JustifyLeft', 'JustifyCenter', 'JustifyRight', 'JustifyBlock']
- ['BulletedList', 'NumberedList', '-', 'Outdent', 'Indent']
- ['Image', 'Table', 'CodeSnippet']
- ['Copy']
- ['Source']
filebrowserBrowseRoute: elfinder
filebrowserBrowseRouteParameters: []
htmlEncodeOutput: false
But this change does not take any effect, because settings in src/Form/Type/CKEditorType.php
on line 72 takes precedence for default config and rewrite ours. If we swap the values in array_merge, our config just works fine.
So this is just an example, not a test case. I wrote a test case and I don't get your point with this PR.
If I have this default config:
fos_ck_editor:
default_config: simple_toolbar
configs:
simple_toolbar:
toolbar:
- ['Undo', 'Redo']
and I call:
$this->createForm(CKEditorType::class);
The output is:
array(1) {
["toolbar"]=>
array(1) {
[0]=>
array(2) {
[0]=>
string(4) "Undo"
[1]=>
string(4) "Redo"
}
}
}
when I call with custom config:
$this->createForm(CKEditorType::class, null, ['config' => ['toolbar' => [['Format']]]]);
the output is:
array(1) {
["toolbar"]=>
array(1) {
[0]=>
array(1) {
[0]=>
string(6) "Format"
}
}
}
If I apply this PR change and call:
$this->createForm(CKEditorType::class, null, ['config' => ['toolbar' => [['Format']]]]);
the output is:
array(1) {
["toolbar"]=>
array(1) {
[0]=>
array(2) {
[0]=>
string(4) "Undo"
[1]=>
string(4) "Redo"
}
}
}
And this is wrong, the toolbar should be only Format
since the custom config is passed. Am I misunderstanding something here?
@hasakm @ondrajonas am I missing something in my last comment?
Closing as no response.
Swap config merge to allow users use custom settings for editor.