You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

135 lines
4.2KB

  1. /* Prismatic - TinyMCE Buttons for Highlight.js */
  2. (function() {
  3. 'use strict';
  4. tinymce.create('tinymce.plugins.PrismaticButtons', {
  5. init : function(ed, url) {
  6. ed.addButton('button_prism', {
  7. title : 'Add Highlight.js Code',
  8. icon : 'code',
  9. onclick : function() {
  10. var code = {
  11. language : '',
  12. snippet : ''
  13. };
  14. ed.windowManager.open({
  15. title : 'Add Highlight.js code',
  16. tooltip : 'Add Highlight.js code',
  17. minWidth : 400,
  18. minHeight : 300,
  19. body : [
  20. {
  21. type : 'listbox',
  22. name : 'language',
  23. value : '',
  24. minWidth : 400,
  25. value : code.language,
  26. values : [
  27. { text : 'Language..', value : '' },
  28. { text : 'Apache', value : 'apache' },
  29. { text : 'AppleScript', value : 'applescript' },
  30. { text : 'Arduino', value : 'arduino' },
  31. { text : 'Bash', value : 'bash' },
  32. { text : 'C', value : 'c' },
  33. { text : 'C#', value : 'cs' },
  34. { text : 'C++', value : 'cpp' },
  35. { text : 'CSS', value : 'css' },
  36. { text : 'CoffeeScript', value : 'coffeescript' },
  37. { text : 'D', value : 'd' },
  38. { text : 'Dart', value : 'dart' },
  39. { text : 'Diff', value : 'diff' },
  40. { text : 'Elixir', value : 'elixir' },
  41. { text : 'G-code', value : 'gcode' },
  42. { text : 'GML', value : 'gml' },
  43. { text : 'Go', value : 'go' },
  44. { text : 'Groovy', value : 'groovy' },
  45. { text : 'HTML/XML', value : 'xml' },
  46. { text : 'HTTP', value : 'http' },
  47. { text : 'Ini/TOML', value : 'ini' },
  48. { text : 'JSON', value : 'json' },
  49. { text : 'Java', value : 'java' },
  50. { text : 'JavaScript', value : 'javascript' },
  51. { text : 'Kotlin', value : 'kotlin' },
  52. { text : 'Less', value : 'less' },
  53. { text : 'Lua', value : 'lua' },
  54. { text : 'Makefile', value : 'makefile' },
  55. { text : 'Markdown', value : 'markdown' },
  56. { text : 'Nginx', value : 'nginx' },
  57. { text : 'Objective-C', value : 'objectivec' },
  58. { text : 'PHP', value : 'php' },
  59. { text : 'Perl', value : 'perl' },
  60. { text : 'Plaintext', value : 'plaintext' },
  61. { text : 'PowerShell', value : 'powershell' },
  62. { text : 'Properties', value : 'properties' },
  63. { text : 'Python', value : 'python' },
  64. { text : 'Python REPL', value : 'python-repl' },
  65. { text : 'R', value : 'r' },
  66. { text : 'Ruby', value : 'ruby' },
  67. { text : 'Rust', value : 'rust' },
  68. { text : 'Scala', value : 'scala' },
  69. { text : 'SCSS', value : 'scss' },
  70. { text : 'Shell Session', value : 'shell' },
  71. { text : 'SQL', value : 'sql' },
  72. { text : 'Swift', value : 'swift' },
  73. { text : 'TypeScript', value : 'typescript' },
  74. { text : 'VB.Net', value : 'vbnet' },
  75. { text : 'YAML', value : 'yaml' },
  76. ],
  77. onselect : function() {
  78. code.language = this.value();
  79. },
  80. },
  81. {
  82. type : 'textbox',
  83. name : 'snippet',
  84. placeholder : 'Add Code Here',
  85. value : '',
  86. minWidth : 400,
  87. minHeight : 300,
  88. multiline : true,
  89. value : code.snippet,
  90. oninput : function() {
  91. code.snippet = this.value();
  92. }
  93. }
  94. ],
  95. onsubmit : function() {
  96. ed.insertContent('<pre><code class="language-'+ code.language +'">'+ tinymce.DOM.encode(code.snippet) + '</code></pre>');
  97. }
  98. });
  99. }
  100. });
  101. },
  102. createControl : function(n, cm) {
  103. return null;
  104. },
  105. });
  106. tinymce.PluginManager.add('prismatic_buttons', tinymce.plugins.PrismaticButtons);
  107. })();