2

I'm using TinyMce and I would like to add a new language in the default list provided by codesample.

Checking the docs of codesample I didn't find anything regarding it, they are quite basic and limited.

Is there any option to do so besides having to modify tinymce?

Alvaro
  • 40,778
  • 30
  • 164
  • 336
  • You would have to modify the `codesample` plugin to do this. As TinyMCE is open source there is no technical reason you cannot extend it to use other programming languages (supported by Prism). – Michael Fromin Jun 03 '16 at 19:23
  • Far from ideal... That means I can not use the packaged version of tinyMce which includes codesample. – Alvaro Jun 05 '16 at 00:13
  • This is the beauty of open source software ... you can modify it to your needs. If TinyMCE was not open source you would have no recourse to address this issue. – Michael Fromin Jun 06 '16 at 01:26
  • @MichaelFromin that's not what I'm arguing. I'm just saying codesample doesn't seem to make it easy for people to add new languages. It should be an option in the plugin itself... – Alvaro Jun 06 '16 at 09:15

1 Answers1

2

This is possible.

in your TinyMCE plugins folder, look for the codesample folder. in this you will fine plugin.js

find line 1101, it displays the languages.

i have updated my to be this....

    var languages = [

    {text: 'C', value: 'c' },
    {text: 'C#', value: 'csharp' },
    {text: 'C++', value: 'cpp' },
    {text: 'CSS', value: 'css' },
    {text: 'F#', value: 'fsharp' },
    {text: 'Java', value: 'java'},
    {text: 'HTML/XML', value: 'markup'},
    {text: 'JavaScript', value: 'javascript' },
    {text: 'Json', value: 'json' },
    {text: 'LESS', value: 'less' },
    {text: 'PHP', value: 'php'},
    {text: 'Python', value: 'python'},
    {text: 'Ruby', value: 'ruby'},
    {text: 'SASS', value: 'scss' },
    {text: 'SQL', value: 'sql' },
    {text: 'TypeScript', value: 'typescript' }
];

save and then re-minify the file.

then in TinyMCE you will get the new languages in the dropdown, just ensure yoru Prism file is updated to have these languages.

JGilmartin
  • 8,683
  • 14
  • 66
  • 85
  • 1
    This code can be added to the init function. See official docs [here](https://www.tinymce.com/docs/plugins/codesample/). You will need to download a js and css file from [prism](http://prismjs.com/) for your selected languages. – AJ Dhaliwal Mar 19 '17 at 15:39