config.js 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. /**
  2. * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
  3. * For licensing, see https://ckeditor.com/legal/ckeditor-oss-license
  4. */
  5. CKEDITOR.editorConfig = function( config ) {
  6. // Define changes to default configuration here. For example:
  7. // config.language = 'fr';
  8. // config.uiColor = '#AADC6E';
  9. config.font_names =
  10. '宋体/SimSun;' +
  11. '黑体/SimHei;' +
  12. '仿宋/FangSong;' +
  13. '楷体/KaiTi;' +
  14. '隶书/LiSu;' +
  15. '幼圆/YouYuan;' +
  16. '微软雅黑/Microsoft YaHei;' +
  17. config.font_names;
  18. // 确保字体插件被加载
  19. config.extraPlugins = 'font';
  20. // 可选:设置默认字体
  21. config.font_defaultLabel = '宋体';
  22. // 可选:允许所有字体大小
  23. config.fontSize_sizes = '8/8px;9/9px;10/10px;11/11px;12/12px;14/14px;16/16px;18/18px;20/20px;22/22px;24/24px;26/26px;28/28px;36/36px;48/48px;72/72px';
  24. // 可选:设置默认字体大小
  25. config.fontSize_defaultLabel = '12px';
  26. // 设置内容CSS
  27. config.contentsCss = '/public/ckeditor/custom-ckeditor.css';
  28. // 允许额外的CSS类
  29. config.extraAllowedContent = 'div(page-break)';
  30. // 设置编辑器的宽度,高度可以设置为自动
  31. config.width = '100%';
  32. config.height = 'auto';
  33. // 添加分页符插件(如果需要)
  34. config.extraPlugins = 'pagebreak';
  35. // 设置工具栏位置在编辑区域上方
  36. config.toolbarLocation = 'top';
  37. // 添加 lineheight 插件
  38. config.extraPlugins = 'lineheight,' + config.extraPlugins;
  39. // 配置可选的行间距值
  40. config.line_height = '0.5;0.75;1;1.25;1.5;2;2.5;3;4';
  41. // 添加 spacingsliders 插件(注意是小写)
  42. var plugins = ['font', 'pagebreak', 'spacingsliders'];
  43. config.extraPlugins = plugins.join(',');
  44. // 配置 Spacing Sliders 插件
  45. config.spacingsliders = {
  46. // 行距配置
  47. lineHeight: {
  48. min: 1,
  49. max: 3,
  50. step: 0.1,
  51. default: 1.15, // Word 默认行距
  52. // 添加单位配置
  53. unit: 'em', // 使用 em 单位而不是默认的无单位值
  54. css: {
  55. property: 'line-height',
  56. // 确保生成的样式使用确切的值
  57. template: '{value}em'
  58. }
  59. },
  60. spacingBefore: {
  61. min: 0,
  62. max: 72,
  63. step: 1,
  64. default: 0,
  65. unit: 'pt', // 使用磅作为单位
  66. css: {
  67. property: 'margin-top',
  68. template: '{value}pt'
  69. }
  70. },
  71. spacingAfter: {
  72. min: 0,
  73. max: 72,
  74. step: 1,
  75. default: 0,
  76. unit: 'pt',
  77. css: {
  78. property: 'margin-bottom',
  79. template: '{value}pt'
  80. }
  81. }
  82. };
  83. // 添加自定义样式规则
  84. config.contentsCss = [
  85. '/public/ckeditor/contents.css',
  86. '/public/ckeditor/custom-ckeditor.css'
  87. ];
  88. // 确保段落格式正确
  89. config.enterMode = CKEDITOR.ENTER_P;
  90. // 允许额外的样式属性
  91. config.extraAllowedContent = 'p{line-height,margin-top,margin-bottom}';
  92. // 修改图片上传配置
  93. config.filebrowserImageUploadUrl = 'http://183.195.216.54:8084/upload/imageNew';
  94. config.imageUploadUrl = 'http://183.195.216.54:8084/upload/imageNew';
  95. // 自定义上传处理
  96. config.uploadUrl = 'http://183.195.216.54:8084/upload/imageNew';
  97. // 1. 添加样式组合定义
  98. /* config.stylesSet = [
  99. // 行距样式
  100. { name: '单倍行距', element: 'p', attributes: { 'style': 'line-height: 1.0;' }},
  101. { name: '1.5倍行距', element: 'p', attributes: { 'style': 'line-height: 1.5;' }},
  102. { name: '2.0倍行距', element: 'p', attributes: { 'style': 'line-height: 2.0;' }},
  103. // 段前间距
  104. { name: '段前0磅', element: 'p', attributes: { 'style': 'margin-top: 0pt;' }},
  105. { name: '段前5磅', element: 'p', attributes: { 'style': 'margin-top: 5pt;' }},
  106. { name: '段前10磅', element: 'p', attributes: { 'style': 'margin-top: 10pt;' }},
  107. // 段后间距
  108. { name: '段后0磅', element: 'p', attributes: { 'style': 'margin-bottom: 0pt;' }},
  109. { name: '段后5磅', element: 'p', attributes: { 'style': 'margin-bottom: 5pt;' }},
  110. { name: '段后10磅', element: 'p', attributes: { 'style': 'margin-bottom: 10pt;' }}
  111. ]; */
  112. // 3. 添加行距插件
  113. config.extraPlugins = 'lineheight,spacing';
  114. // 4. 配置行距选项
  115. config.line_height = '1;1.15;1.5;2;2.5;3';
  116. // 5. 配置段落间距
  117. config.spacing_sizes = '0pt;5pt;10pt;15pt;20pt';
  118. // 6. 允许额外的样式属性
  119. config.extraAllowedContent = 'p{line-height,margin-top,margin-bottom}(*);';
  120. // 7. 添加自定义样式表
  121. config.contentsCss = [
  122. '/public/ckeditor/contents.css',
  123. '/public/ckeditor/custom-styles.css'
  124. ];
  125. };