Last active
July 11, 2019 07:56
-
-
Save denniserdmann/341db025f4ffac115166edd16ec4f88d to your computer and use it in GitHub Desktop.
create a custom tinyMCE template with contao version check
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Contao; | |
if ($GLOBALS['TL_CONFIG']['useRTE']): | |
?> | |
<?php if ( version_compare(VERSION, '4.5', '>=')): ?> | |
<script>window.tinymce || document.write('<script src="<?= $this->asset('js/tinymce.min.js', 'contao-components/tinymce4') ?>">\x3C/script>')</script> | |
<?php else: ?> | |
<script>window.tinymce || document.write('<script src="<?= TL_ASSETS_URL ?>assets/tinymce4/js/tinymce.min.js">\x3C/script>')</script> | |
<?php endif; ?> | |
<script> | |
setTimeout(function() { | |
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', | |
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); | |
}, | |
branding: false, | |
plugins: 'autosave charmap code fullscreen image importcss link lists paste searchreplace tabfocus table visualblocks', | |
browser_spellcheck: true, | |
tabfocus_elements: ':prev,:next', | |
importcss_append: true, | |
extended_valid_elements: 'q[cite|class|title],article,section,hgroup,figure,figcaption', | |
menubar: 'file edit insert view format table', | |
toolbar: 'link unlink | image | bold italic | styleselect | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | undo redo | code', | |
content_css: ['/files/theme/dist/css/tinymce.css'], | |
style_formats_merge: true, | |
style_formats: [ | |
{title: 'Theme Styles', items: [ | |
{ title: 'Button Primary', block: 'div', classes: 'btn btn--primary', exact: true }, | |
{ title: 'Button Secondary', block: 'div', classes: 'btn btn--secondary', exact: true }, | |
{ title: 'Text Attention', block: 'p', classes: 'text--attention', exact: true } | |
]} | |
] | |
}); | |
}, 0); | |
</script> | |
<?php endif; ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment