config.js 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. /*
  2. Copyright (c) 2003-2011, CKSource - Frederico Knabben. All rights reserved.
  3. For licensing, see LICENSE.html or http://ckeditor.com/license
  4. */
  5. CKEDITOR.editorConfig = function( config )
  6. {
  7. // Define changes to default configuration here. For example:
  8. // config.language = 'fr';
  9. // config.uiColor = '#AADC6E';
  10. /* Filebrowser routes */
  11. // The location of an external file browser, that should be launched when "Browse Server" button is pressed.
  12. //文件上传POST请求的URL
  13. config.filebrowserBrowseUrl = "/ckeditor/attachment_files";
  14. // The location of an external file browser, that should be launched when "Browse Server" button is pressed in the Flash dialog.
  15. config.filebrowserFlashBrowseUrl = "/ckeditor/attachment_files";
  16. // The location of a script that handles file uploads in the Flash dialog.
  17. config.filebrowserFlashUploadUrl = "/ckeditor/attachment_files";
  18. // The location of an external file browser, that should be launched when "Browse Server" button is pressed in the Link tab of Image dialog.
  19. config.filebrowserImageBrowseLinkUrl = "/ckeditor/pictures";
  20. // The location of an external file browser, that should be launched when "Browse Server" button is pressed in the Image dialog.
  21. config.filebrowserImageBrowseUrl = "/ckeditor/pictures";
  22. // The location of a script that handles file uploads in the Image dialog.
  23. config.filebrowserImageUploadUrl = "/ckeditor/pictures";
  24. // The location of a script that handles file uploads.
  25. config.filebrowserUploadUrl = "/ckeditor/attachment_files";
  26. config.allowedContent = true;
  27. //上传图片去掉预览文字
  28. config.image_previewText =' ';
  29. //config.maxSize = 0;
  30. // 字体
  31. config.font_names= '宋体/SimSun;新宋体/NSimSun;仿宋_GB2312/FangSong_GB2312;楷体_GB2312/KaiTi_GB2312;黑体/SimHei;微软雅黑/Microsoft YaHei;' + config.font_names;
  32. //增加行距插件
  33. config.extraPlugins += (config.extraPlugins ? ',lineheight' : 'lineheight');
  34. //从word复制时保留格式
  35. config.pasteFromWordRemoveFontStyles = false;
  36. config.pasteFromWordRemoveStyles = false;
  37. // Rails CSRF token
  38. config.filebrowserParams = function(){
  39. var csrf_token, csrf_param, meta,
  40. metas = document.getElementsByTagName('meta'),
  41. params = new Object();
  42. for ( var i = 0 ; i < metas.length ; i++ ){
  43. meta = metas[i];
  44. switch(meta.name) {
  45. case "csrf-token":
  46. csrf_token = meta.content;
  47. break;
  48. case "csrf-param":
  49. csrf_param = meta.content;
  50. break;
  51. default:
  52. continue;
  53. }
  54. }
  55. if (csrf_param !== undefined && csrf_token !== undefined) {
  56. params[csrf_param] = csrf_token;
  57. }
  58. return params;
  59. };
  60. config.addQueryString = function( url, params ){
  61. var queryString = [];
  62. if ( !params ) {
  63. return url;
  64. } else {
  65. for ( var i in params )
  66. queryString.push( i + "=" + encodeURIComponent( params[ i ] ) );
  67. }
  68. return url + ( ( url.indexOf( "?" ) != -1 ) ? "&" : "?" ) + queryString.join( "&" );
  69. };
  70. // Integrate Rails CSRF token into file upload dialogs (link, image, attachment and flash)
  71. CKEDITOR.on( 'dialogDefinition', function( ev ){
  72. // Take the dialog name and its definition from the event data.
  73. var dialogName = ev.data.name;
  74. var dialogDefinition = ev.data.definition;
  75. var content, upload;
  76. if (CKEDITOR.tools.indexOf(['link', 'image', 'attachment', 'flash'], dialogName) > -1) {
  77. content = (dialogDefinition.getContents('Upload') || dialogDefinition.getContents('upload'));
  78. upload = (content == null ? null : content.get('upload'));
  79. if (upload && upload.filebrowser && upload.filebrowser['params'] === undefined) {
  80. upload.filebrowser['params'] = config.filebrowserParams();
  81. upload.action = config.addQueryString(upload.action, upload.filebrowser['params']);
  82. }
  83. }
  84. });
  85. // 设置初始高度
  86. config.height = 600;
  87. // Toolbar groups configuration.
  88. config.toolbar = [
  89. { name: 'document', groups: [ 'mode', 'document', 'doctools' ], items: [ 'Source'] },
  90. { name: 'clipboard', groups: [ 'clipboard', 'undo' ], items: [ 'Cut', 'Copy', 'Paste', 'PasteText', 'PasteFromWord', '-', 'Undo', 'Redo' ] },
  91. // { name: 'editing', groups: [ 'find', 'selection', 'spellchecker' ], items: [ 'Find', 'Replace', '-', 'SelectAll', '-', 'Scayt' ] },
  92. // { name: 'forms', items: [ 'Form', 'Checkbox', 'Radio', 'TextField', 'Textarea', 'Select', 'Button', 'ImageButton', 'HiddenField' ] },
  93. { name: 'links', items: [ 'Link', 'Unlink', 'Anchor' ] },
  94. { name: 'insert', items: [ 'Image', 'Iframe','Table', 'HorizontalRule', 'SpecialChar' ] },
  95. { name: 'paragraph', groups: [ 'list', 'indent', 'blocks', 'align', 'bidi' ], items: [ 'NumberedList', 'BulletedList', '-', 'Outdent', 'Indent', '-', 'Blockquote', 'CreateDiv', '-', 'JustifyLeft', 'JustifyCenter', 'JustifyRight', 'JustifyBlock' ] },
  96. '/',
  97. { name: 'styles', items: [ 'Styles', 'Format', 'Font', 'FontSize', 'lineheight' ] },
  98. { name: 'colors', items: [ 'TextColor', 'BGColor' ] },
  99. { name: 'basicstyles', groups: [ 'basicstyles', 'cleanup' ], items: [ 'Bold', 'Italic', 'Underline', 'Strike', 'Subscript', 'Superscript', '-', 'RemoveFormat' ] },
  100. { name: 'tools', items : [ 'Maximize','-','About' ] }
  101. ];
  102. config.toolbar_mini = [
  103. { name: 'paragraph', groups: [ 'list', 'indent', 'blocks', 'align', 'bidi' ], items: [ 'NumberedList', 'BulletedList', '-', 'Outdent', 'Indent', '-', 'Blockquote', 'CreateDiv', '-', 'JustifyLeft', 'JustifyCenter', 'JustifyRight', 'JustifyBlock' ] },
  104. { name: 'styles', items: [ 'Font', 'FontSize' ] },
  105. { name: 'colors', items: [ 'TextColor', 'BGColor' ] },
  106. { name: 'basicstyles', groups: [ 'basicstyles', 'cleanup' ], items: [ 'Bold', 'Italic', 'Underline', 'Strike', 'Subscript', 'Superscript', '-', 'RemoveFormat' ] },
  107. { name: 'insert', items: [ 'Image', 'Table', 'HorizontalRule', 'SpecialChar' ] },
  108. { name: 'maximize'}
  109. ];
  110. // config.extraPlugins += (config.extraPlugins ? ',helloworld' : 'helloworld');
  111. };