Jump to:

5513 Posts in 1732 Topics by 1218 members

Customising the CMS

SilverStripe Forums » Customising the CMS » TinyMCE with syntax highlighting

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Page: 1
Go to End
Author Topic: 901 Views
  • theGermaniac
    Avatar
    Community Member
    82 Posts

    TinyMCE with syntax highlighting Link to this post

    Hi there,

    what's the beste way to add syntax highlighting to the CMS' HtmlEditorField TinyMCS source editor?

    I tried to add this TinyMCE plugin https://github.com/RichGuk/syntaxhl but it simply does not work...

    Any help appreciated

    Cheers, Mario

  • BigMoose
    Avatar
    Community Member
    19 Posts

    Re: TinyMCE with syntax highlighting Link to this post

    Just wondering if you were ever able to solve this. On the SS 2.x versions, there was some syntax color showing when I would view the html source code in the TinyMCE editor. With versions 3.x this is no longer there.

  • BigMoose
    Avatar
    Community Member
    19 Posts

    Re: TinyMCE with syntax highlighting Link to this post

    Okay, I found a great solution for me. First, I think a better plugin than "syntaxhl" is called "codemagic".
    https://github.com/tinymce-plugins/codemagic

    After downloading, I renamed the file from 'codemagic-master' to 'codemagic'. I then placed this folder into:
    framework/thirdparty/tinymce/plugins/

    Next, I added the following line into mysite/_config.php

    HtmlEditorConfig::get('cms')->enablePlugins('codemagic');

    Lastly, I needed to add the button to the TinyMCE button layout - ensuring that 'codemagic' was listed. This too was added to the mysite/_config.php file.

    HtmlEditorConfig::get('cms')->setButtonsForLine(1, 'undo', 'redo', 'bold', 'italic', 'underline', 'strikethrough', '|', 'justifyleft', 'justifycenter', 'justifyright', 'justifyfull', '|', 'styleselect', 'formatselect', 'fontselect', 'fontsizeselect', '|', 'forecolor', 'backcolor', 'styleprops');

    HtmlEditorConfig::get('cms')->setButtonsForLine(2, 'codemagic', 'fullscreen', '|', 'cut', 'copy', 'paste', 'pastetext', 'pasteword', 'spellchecker', '|', 'bullist', 'numlist', '|', 'outdent', 'indent', 'blockquote', '|', 'image', 'link', 'unlink', 'anchor', '|', 'selectall', 'visualaid', '|', 'removeformat', 'hr', 'charmap');

    I really hope this helps the others who were looking for an answer to this problem.

  • theGermaniac
    Avatar
    Community Member
    82 Posts

    Re: TinyMCE with syntax highlighting Link to this post

    Thank you! I'll definitely try this!

    901 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.