Contao-Camp 2024
Ergebnis 1 bis 3 von 3

Thema: Contao ignoriert "style_formats" im Template "be_tinyMCE

  1. #1
    Contao-Fan
    Registriert seit
    29.06.2016.
    Beiträge
    500

    Standard Contao ignoriert "style_formats" im Template "be_tinyMCE

    Hallo,

    Contao 4.9.24 ignoriert meine Angaben zu den "style_formats" im Template "be_tinyMCE.html5".

    Ich habe das Contao-Standard-Template mit eigenen Absatzformaten (style_formats) erweitert:

    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',
      plugins: 'autosave charmap code fullscreen 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: 'file edit insert view format table',
      toolbar: 'link unlink | formatselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | code',
      style_formats : [
            {title : 'Bold text', inline : 'b'},
            {title : 'Red text', inline : 'span', styles : {color : '#ff0000'}},
            {title : 'Red header', block : 'h1', styles : {color : '#ff0000'}},
            {title : 'Example 1', inline : 'span', classes : 'example1'},
            {title : 'Example 2', inline : 'span', classes : 'example2'},
            {title : 'Table styles'},
            {title : 'Table row 1', selector : 'tr', classes : 'tablerow1'}
        ]  
    });
    </script>
    <?php endif; ?>
    ... ich finde aber nun im MCE nirgends ein Format namens 'Red text'
    Sonstige Änderungen am Template "be_tinyMCE.html5" werden aber sofort übernommen.

    Browser-Cache habe ich gelöscht.

    Weiß jemand von euch vielleicht Rat?

    Merci!

  2. #2
    Contao-Fan Avatar von Kopfnuss
    Registriert seit
    05.09.2012.
    Ort
    Zwickau
    Beiträge
    307
    Partner-ID
    11375
    Contao-Projekt unterstützen

    Support Contao

    Standard

    Trag mal unter toolbar: 'stylselect' mit ein. Dann hast du im Editor eine Formatauswahl und ganz unten sollten die eingetragenen Formate stehen.

    Code:
    toolbar: 'styleselect | link unlink | formatselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | code',
    style_formats_merge: true,
    style_formats : [
            {title : 'Bold text', inline : 'b'},
            {title : 'Red text', inline : 'span', styles : {color : '#ff0000'}},
            {title : 'Red header', block : 'h1', styles : {color : '#ff0000'}},
            {title : 'Example 1', inline : 'span', classes : 'example1'},
            {title : 'Example 2', inline : 'span', classes : 'example2'},
            {title : 'Table styles'},
            {title : 'Table row 1', selector : 'tr', classes : 'tablerow1'}
    ]

  3. #3
    Contao-Fan
    Registriert seit
    29.06.2016.
    Beiträge
    500

    Standard

    Danke Kopfnuss, das wars!

Aktive Benutzer

Aktive Benutzer

Aktive Benutzer in diesem Thema: 1 (Registrierte Benutzer: 0, Gäste: 1)

Lesezeichen

Lesezeichen

Berechtigungen

  • Neue Themen erstellen: Nein
  • Themen beantworten: Nein
  • Anhänge hochladen: Nein
  • Beiträge bearbeiten: Nein
  •