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.

124 lines
3.8KB

  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 : 'cs' },
  33. { text : 'C++', value : 'cpp' },
  34. { text : 'CSS', value : 'css' },
  35. { text : 'CoffeeScript', value : 'coffeescript' },
  36. { text : 'D', value : 'd' },
  37. { text : 'Dart', value : 'dart' },
  38. { text : 'Diff', value : 'diff' },
  39. { text : 'Elixir', value : 'elixir' },
  40. { text : 'G-code', value : 'gcode' },
  41. { text : 'GML', value : 'gml' },
  42. { text : 'Go', value : 'go' },
  43. { text : 'Groovy', value : 'groovy' },
  44. { text : 'HTML/XML', value : 'xml' },
  45. { text : 'HTTP', value : 'http' },
  46. { text : 'Ini', value : 'ini' },
  47. { text : 'JSON', value : 'json' },
  48. { text : 'Java', value : 'java' },
  49. { text : 'JavaScript', value : 'javascript' },
  50. { text : 'Kotlin', value : 'kotlin' },
  51. { text : 'Lua', value : 'lua' },
  52. { text : 'Makefile', value : 'makefile' },
  53. { text : 'Markdown', value : 'markdown' },
  54. { text : 'Nginx', value : 'nginx' },
  55. { text : 'Objective-C', value : 'objectivec' },
  56. { text : 'PHP', value : 'php' },
  57. { text : 'Perl', value : 'perl' },
  58. { text : 'Plaintext', value : 'plaintext' },
  59. { text : 'PowerShell', value : 'powershell' },
  60. { text : 'Python', value : 'python' },
  61. { text : 'R', value : 'r' },
  62. { text : 'Ruby', value : 'ruby' },
  63. { text : 'Rust', value : 'rust' },
  64. { text : 'Scala', value : 'scala' },
  65. { text : 'Shell Session', value : 'shell' },
  66. { text : 'SQL', value : 'sql' },
  67. { text : 'Swift', value : 'swift' },
  68. { text : 'TypeScript', value : 'typescript' },
  69. { text : 'YAML', value : 'yaml' },
  70. ],
  71. onselect : function() {
  72. code.language = this.value();
  73. },
  74. },
  75. {
  76. type : 'textbox',
  77. name : 'snippet',
  78. placeholder : 'Add Code Here',
  79. value : '',
  80. minWidth : 400,
  81. minHeight : 300,
  82. multiline : true,
  83. value : code.snippet,
  84. oninput : function() {
  85. code.snippet = this.value();
  86. }
  87. }
  88. ],
  89. onsubmit : function() {
  90. ed.insertContent('<pre><code class="language-'+ code.language +'">'+ code.snippet + '</code></pre>');
  91. }
  92. });
  93. }
  94. });
  95. },
  96. createControl : function(n, cm) {
  97. return null;
  98. },
  99. });
  100. tinymce.PluginManager.add('prismatic_buttons', tinymce.plugins.PrismaticButtons);
  101. })();