PHP-Code:
<?php
namespace Contao;
if ($GLOBALS['TL_CONFIG']['useRTE']):
// Use document.write() here in case TinyMCE is loaded in a subpalette (see #1424)
?>
<script>window.tinymce || document.write('<script src="<?= $this->asset('js/tinymce.min.js', 'contao-components/tinymce4') ?>">\x3C/script>')</script>
<script>
window.tinymce && tinymce.init({
skin: 'contao',
selector: '#<?= $this->selector ?>',
language: '<?= Backend::getTinyMceLanguage() ?>',
element_format: 'html',
document_base_url: '<?= Environment::get('base') ?>',
entities: '160,nbsp,60,lt,62,gt,173,shy',
branding: false,
setup: function(editor) {
editor.getElement().removeAttribute('required');
},
init_instance_callback: function(editor) {
if (document.activeElement && document.activeElement.id && document.activeElement.id == editor.id) {
editor.editorManager.get(editor.id).focus();
}
editor.on('focus', function() { Backend.getScrollOffset(); });
},
file_browser_callback: function(field_name, url, type, win) {
Backend.openModalBrowser(field_name, url, type, win, '<?= $this->source ?>');
},
file_browser_callback_types: <?= json_encode($this->fileBrowserTypes) ?>,
content_css: [
'system/themes/<?= Backend::getTheme() ?>/tinymce.min.css'
<?php
$customTinyCssFile = Config::get('uploadPath') . '/theme/css/tinymce.css';
if(file_exists($customTinyCssFile)):
?>
,'<?= $customTinyCssFile . '?' . time() ?>'
<?php endif; ?>
],
plugins: 'autosave charmap code image importcss link lists paste searchreplace stripnbsp tabfocus table visualblocks visualchars',
browser_spellcheck: true,
tabfocus_elements: ':prev,:next',
importcss_append: true,
extended_valid_elements: 'q[cite|class|title],article,section,hgroup,figure,figcaption',
menubar: false,
toolbar: 'link unlink | image table | bold | subscript superscript | bullist numlist | charmap | formatselect | styleselect | code',
paste_as_text: true,
importcss_selector_converter: function(selector) {
return false;
},
style_formats_merge: false,
style_formats: [
{title: 'Stile', items: [
{title: 'Stil 1', inline: 'span', selector: '*', classes: 'my-style-one', deep: true, merge_siblings: true},
{title: 'Stil 2', inline: 'span', selector: '*', classes: 'my-style-two', deep: true, merge_siblings: true}
]},
{title: 'Social-Media Icons', items: [
{title: 'Instagram Icon', selector: 'a', classes: 'instagram'},
{title: 'Facebook Icon', selector: 'a', classes: 'facebook'},
{title: 'YouTube Icon', selector: 'a', classes: 'youtube'},
{title: 'Xing Icon', selector: 'a', classes: 'xing'}
]}
]
});
</script>
<?php endif; ?>
Meine Beispiel tinymce.css (/files/theme/css/tinymce.css) mit Dummy-Stile für das Backend: