123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151 |
- /**
- * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
- * For licensing, see https://ckeditor.com/legal/ckeditor-oss-license
- */
- CKEDITOR.editorConfig = function( config ) {
- // Define changes to default configuration here. For example:
- // config.language = 'fr';
- // config.uiColor = '#AADC6E';
- config.font_names =
- '宋体/SimSun;' +
- '黑体/SimHei;' +
- '仿宋/FangSong;' +
- '楷体/KaiTi;' +
- '隶书/LiSu;' +
- '幼圆/YouYuan;' +
- '微软雅黑/Microsoft YaHei;' +
- config.font_names;
- // 确保字体插件被加载
- config.extraPlugins = 'font';
- // 可选:设置默认字体
- config.font_defaultLabel = '宋体';
- // 可选:允许所有字体大小
- 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';
- // 可选:设置默认字体大小
- config.fontSize_defaultLabel = '12px';
- // 设置内容CSS
- config.contentsCss = '/public/ckeditor/custom-ckeditor.css';
- // 允许额外的CSS类
- config.extraAllowedContent = 'div(page-break)';
- // 设置编辑器的宽度,高度可以设置为自动
- config.width = '100%';
- config.height = 'auto';
- // 添加分页符插件(如果需要)
- config.extraPlugins = 'pagebreak';
- // 设置工具栏位置在编辑区域上方
- config.toolbarLocation = 'top';
- // 添加 lineheight 插件
- config.extraPlugins = 'lineheight,' + config.extraPlugins;
-
- // 配置可选的行间距值
- config.line_height = '0.5;0.75;1;1.25;1.5;2;2.5;3;4';
- // 添加 spacingsliders 插件(注意是小写)
- var plugins = ['font', 'pagebreak', 'spacingsliders'];
- config.extraPlugins = plugins.join(',');
-
- // 配置 Spacing Sliders 插件
- config.spacingsliders = {
- // 行距配置
- lineHeight: {
- min: 1,
- max: 3,
- step: 0.1,
- default: 1.15, // Word 默认行距
- // 添加单位配置
- unit: 'em', // 使用 em 单位而不是默认的无单位值
- css: {
- property: 'line-height',
- // 确保生成的样式使用确切的值
- template: '{value}em'
- }
- },
- spacingBefore: {
- min: 0,
- max: 72,
- step: 1,
- default: 0,
- unit: 'pt', // 使用磅作为单位
- css: {
- property: 'margin-top',
- template: '{value}pt'
- }
- },
- spacingAfter: {
- min: 0,
- max: 72,
- step: 1,
- default: 0,
- unit: 'pt',
- css: {
- property: 'margin-bottom',
- template: '{value}pt'
- }
- }
- };
- // 添加自定义样式规则
- config.contentsCss = [
- '/public/ckeditor/contents.css',
- '/public/ckeditor/custom-ckeditor.css'
- ];
- // 确保段落格式正确
- config.enterMode = CKEDITOR.ENTER_P;
-
- // 允许额外的样式属性
- config.extraAllowedContent = 'p{line-height,margin-top,margin-bottom}';
- // 修改图片上传配置
- config.filebrowserImageUploadUrl = 'http://183.195.216.54:8084/upload/imageNew';
- config.imageUploadUrl = 'http://183.195.216.54:8084/upload/imageNew';
- // 自定义上传处理
- config.uploadUrl = 'http://183.195.216.54:8084/upload/imageNew';
- // 1. 添加样式组合定义
- /* config.stylesSet = [
- // 行距样式
- { name: '单倍行距', element: 'p', attributes: { 'style': 'line-height: 1.0;' }},
- { name: '1.5倍行距', element: 'p', attributes: { 'style': 'line-height: 1.5;' }},
- { name: '2.0倍行距', element: 'p', attributes: { 'style': 'line-height: 2.0;' }},
-
- // 段前间距
- { name: '段前0磅', element: 'p', attributes: { 'style': 'margin-top: 0pt;' }},
- { name: '段前5磅', element: 'p', attributes: { 'style': 'margin-top: 5pt;' }},
- { name: '段前10磅', element: 'p', attributes: { 'style': 'margin-top: 10pt;' }},
-
- // 段后间距
- { name: '段后0磅', element: 'p', attributes: { 'style': 'margin-bottom: 0pt;' }},
- { name: '段后5磅', element: 'p', attributes: { 'style': 'margin-bottom: 5pt;' }},
- { name: '段后10磅', element: 'p', attributes: { 'style': 'margin-bottom: 10pt;' }}
- ]; */
- // 3. 添加行距插件
- config.extraPlugins = 'lineheight,spacing';
- // 4. 配置行距选项
- config.line_height = '1;1.15;1.5;2;2.5;3';
- // 5. 配置段落间距
- config.spacing_sizes = '0pt;5pt;10pt;15pt;20pt';
- // 6. 允许额外的样式属性
- config.extraAllowedContent = 'p{line-height,margin-top,margin-bottom}(*);';
- // 7. 添加自定义样式表
- config.contentsCss = [
- '/public/ckeditor/contents.css',
- '/public/ckeditor/custom-styles.css'
- ];
- };
|