计擒娇妻,n0666,八部天龙之邪神传
下载地址:https://ckeditor.com/ckeditor-4/download/
一、使用方法:
1、在页面中引入ckeditor核心文件ckeditor.js
2、在使用编辑器的地方插入html控件<textarea>
<textarea id="contents" class="layui-textarea editor1" name="contents" style="width:99%;height:50%;"></textarea>
3、创建ckeditor编辑器
<script type="text/javascript">
var editor = ckeditor.replace('contents' );
</script>
4、配置编辑器
1 // 界面语言,默认为 'en' 2 config.language = 'zh-cn'; 3 4 // 设置宽高 5 config.width = 400; 6 config.height = 400; 7 8 // 编辑器样式,有三种:'kama'(默认)、'office2003'、'v2' 9 config.skin = 'v2'; 10 11 // 背景颜色 12 config.uicolor = '#fff'; 13 // 14 config.skin: 'moono-lisa',//编辑器皮肤(kama,moono,moono-lisa,moonocolor) 15 16 //工具栏(基础'basic'、全能'full'、自定义)plugins/toolbar/plugin.js 17 config.toolbar = 'basic'; 18 config.toolbar = 'full'; 19 20 这将配合: 21 config.toolbar_full = [ 22 ['source','-','save','newpage','preview','-','templates'], 23 ['cut','copy','paste','pastetext','pastefromword','-','print','spellchecker', 'scayt'], 24 ['undo','redo','-','find','replace','-','selectall','removeformat'], 25 ['form', 'checkbox', 'radio', 'textfield', 'textarea', 'select','button', 'imagebutton', 'hiddenfield'], 26 '/', 27 ['bold','italic','underline','strike','-','subscript','superscript'], 28 ['numberedlist','bulletedlist','-','outdent','indent','blockquote'], 29 ['justifyleft','justifycenter','justifyright','justifyblock'], 30 ['link','unlink','anchor'], 31 ['image','flash','table','horizontalrule','smiley','specialchar','pagebreak'], 32 '/', 33 ['styles','format','font','fontsize'], 34 ['textcolor','bgcolor'] 35 ]; 36 37 //工具栏是否可以被收缩 38 config.toolbarcancollapse = true; 39 40 //工具栏的位置 41 config.toolbarlocation ='top';//可选:bottom 42 43 //工具栏默认是否展开 44 config.toolbarstartupexpanded = true; 45 46 // 取消 “拖拽以改变尺寸”功能 plugins/resize/plugin.js 47 config.resize_enabled = false; 48 49 //改变大小的最大高度 50 51 config.resize_maxheight = 3000; 52 53 //改变大小的最大宽度 54 config.resize_maxwidth =3000; 55 56 //改变大小的最小高度 57 config.resize_minheight =250; 58 59 //改变大小的最小宽度 60 config.resize_minwidth =750; 61 // 当提交包含有此编辑器的表单时,是否自动更新元素内的数据 62 config.autoupdateelement =true; 63 64 // 设置是使用绝对目录还是相对目录,为空为相对目录 65 config.basehref = '' 66 67 // 编辑器的z-index值 68 config.basefloatzindex = 10000; 69 70 //设置快捷键 71 config.keystrokes = [ 72 [ckeditor.alt + 121 /*f10*/, 'toolbarfocus' ], //获取焦点 73 [ckeditor.alt + 122 /*f11*/, 'elementspathfocus' ], //元素焦点 74 75 [ ckeditor.shift + 121 /*f10*/,'contextmenu' ], //文本菜单 76 77 [ ckeditor.ctrl + 90 /*z*/, 'undo' ], //撤销 78 [ ckeditor.ctrl + 89 /*y*/, 'redo' ], //重做 79 [ckeditor.ctrl + ckeditor.shift + 90 /*z*/, 'redo' ], // 80 81 [ ckeditor.ctrl + 76 /*l*/, 'link' ], //链接 82 83 [ ckeditor.ctrl + 66 /*b*/, 'bold' ], //粗体 84 [ ckeditor.ctrl + 73 /*i*/, 'italic' ], //斜体 85 [ ckeditor.ctrl + 85 /*u*/, 'underline' ], //下划线 86 87 [ ckeditor.alt + 109 /*-*/,'toolbarcollapse' ] 88 ] 89 90 //设置快捷键 可能与浏览器快捷键冲突plugins/keystrokes/plugin.js. 91 config.blockedkeystrokes = [ 92 ckeditor.ctrl + 66 /*b*/, 93 ckeditor.ctrl + 73 /*i*/, 94 ckeditor.ctrl + 85 /*u*/ 95 ] 96 97 //设置编辑内元素的背景色的取值plugins/colorbutton/plugin.js. 98 config.colorbutton_backstyle = { 99 element : 'span', 100 styles : { 'background-color' : '#(color)'} 101 } 102 103 //设置前景色的取值 plugins/colorbutton/plugin.js 104 config.colorbutton_colors = '000,800000,8b4513,2f4f4f,008080,000080,4b0082,696969,b22222,a52a2a,daa520, 105 106 006400,40e0d0,0000cd,800080,808080,f00,ff8c00,ffd700,008000,0ff,00f,ee82ee, 107 108 a9a9a9,ffa07a,ffa500,ffff00,00ff00,afeeee,add8e6,dda0dd,d3d3d3,fff0f5, 109 110 faebd7,ffffe0,f0fff0,f0ffff,f0f8ff,e6e6fa,fff’ 111 112 //是否在选择颜色时显示“其它颜色”选项plugins/colorbutton/plugin.js 113 config.colorbutton_enablemore =false 114 115 //区块的前景色默认值设置 plugins/colorbutton/plugin.js 116 config.colorbutton_forestyle = { 117 element : 'span', 118 styles : { 'color' : '#(color)' } 119 }; 120 121 //所需要添加的css文件 在此添加 可使用相对路径和网站的绝对路径 122 config.contentscss = './contents.css'; 123 124 //文字方向 125 config.contentslangdirection ='rtl'; //从左到右 126 127 //ckeditor的配置文件 若不想配置 留空即可 128 ckeditor.replace( 'myfiled', { customconfig : './config.js' } ); 129 130 //界面编辑框的背景色 plugins/dialog/plugin.js 131 config.dialog_backgroundcovercolor = '#fffefd'; //可设置参考 132 config.dialog_backgroundcovercolor = 'white' //默认 133 134 //背景的不透明度 数值应该在:0.0~1.0 之间plugins/dialog/plugin.js 135 config.dialog_backgroundcoveropacity =0.5 136 137 //移动或者改变元素时 边框的吸附距离 单位:像素plugins/dialog/plugin.js 138 config.dialog_magnetdistance = 20; 139 140 //是否拒绝本地拼写检查和提示 默认为拒绝 目前仅firefox和safari支持plugins/wysiwygarea/plugin.js. 141 config.disablenativespellchecker =true 142 143 //进行表格编辑功能 如:添加行或列 目前仅firefox支持plugins/wysiwygarea/plugin.js 144 config.disablenativetablehandles =true; //默认为不开启 145 146 //是否开启 图片和表格 的改变大小的功能config.disableobjectresizing = true; 147 config.disableobjectresizing= false //默认为开启 148 149 //设置html文档类型 150 config.doctype ='<!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd%22' ; 151 152 //是否对编辑区域进行渲染plugins/editingblock/plugin.js 153 config.editingblock = true; 154 155 //编辑器中回车产生的标签 156 config.entermode =ckeditor.enter_p; //可选:ckeditor.enter_br或ckeditor.enter_div 157 158 //是否使用html实体进行输出 plugins/entities/plugin.js 159 config.entities = true; 160 161 //定义更多的实体 plugins/entities/plugin.js 162 config.entities_additional = '#39'; //其中#代替了& 163 164 //是否转换一些难以显示的字符为相应的html字符plugins/entities/plugin.js 165 config.entities_greek = true; 166 167 //是否转换一些拉丁字符为htmlplugins/entities/plugin.js 168 config.entities_latin = true; 169 170 //是否转换一些特殊字符为ascii字符 如"this is chinese:汉语."转换为"this is chinese: 汉语."plugins/entities/plugin.js 171 config.entities_processnumerical =false; 172 173 //添加新组件 174 config.extraplugins ='myplugin'; //非默认 仅示例 175 176 //使用搜索时的高亮色 plugins/find/plugin.js 177 config.find_highlight = { 178 element : 'span', 179 styles: { 'background-color' : '#ff0', 'color' : '#00f' } 180 }; 181 182 //默认的字体名 plugins/font/plugin.js 183 config.font_defaultlabel = 'arial'; 184 185 //字体编辑时的字符集 可以添加常用的中文字符:宋体、楷体、黑体等plugins/font/plugin.js 186 config.font_names = 'arial;times newroman;verdana'; 187 188 //文字的默认式样 plugins/font/plugin.js 189 config.font_style = { 190 element : 'span', 191 styles : { 'font-family' : '#(family)' }, 192 overrides : [ { element :'font', attributes : { 'face' : null } } ] 193 }; 194 195 //字体默认大小 plugins/font/plugin.js 196 config.fontsize_defaultlabel = '12px'; 197 198 //字体编辑时可选的字体大小 plugins/font/plugin.js 199 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' 200 201 //设置字体大小时 使用的式样 plugins/font/plugin.js 202 config.fontsize_style = { 203 element : 'span', 204 styles : { 'font-size' : '#(size)' }, 205 overrides : [ {element : 'font', attributes : { 'size' : null } } ] 206 }; 207 208 //是否强制复制来的内容去除格式plugins/pastetext/plugin.js 209 config.forcepasteasplaintext =false//不去除 210 211 //是否强制用“&”来代替“&”plugins/htmldataprocessor/plugin.js 212 config.forcesimpleampersand = false; 213 214 //对address标签进行格式化 plugins/format/plugin.js 215 config.format_address = { element : 'address', attributes : { class :'styledaddress' } }; 216 217 //对div标签自动进行格式化 plugins/format/plugin.js 218 config.format_div = { element : 'div', attributes : { class :'normaldiv' } }; 219 220 //对h1标签自动进行格式化 plugins/format/plugin.js 221 config.format_h1 = { element : 'h1', attributes : { class :'contenttitle1' } }; 222 223 //对h2标签自动进行格式化 plugins/format/plugin.js 224 config.format_h2 = { element : 'h2', attributes : { class :'contenttitle2' } }; 225 226 //对h3标签自动进行格式化 plugins/format/plugin.js 227 config.format_h1 = { element : 'h3', attributes : { class :'contenttitle3' } }; 228 229 //对h4标签自动进行格式化 plugins/format/plugin.js 230 config.format_h1 = { element : 'h4', attributes : { class :'contenttitle4' } }; 231 232 //对h5标签自动进行格式化 plugins/format/plugin.js 233 config.format_h1 = { element : 'h5', attributes : { class :'contenttitle5' } }; 234 235 //对h6标签自动进行格式化 plugins/format/plugin.js 236 config.format_h1 = { element : 'h6', attributes : { class :'contenttitle6' } }; 237 238 //对p标签自动进行格式化 plugins/format/plugin.js 239 config.format_p = { element : 'p', attributes : { class : 'normalpara' }}; 240 241 //对pre标签自动进行格式化 plugins/format/plugin.js 242 config.format_pre = { element : 'pre', attributes : { class : 'code'} }; 243 244 //用分号分隔的标签名字 在工具栏上显示plugins/format/plugin.js 245 config.format_tags ='p;h1;h2;h3;h4;h5;h6;pre;address;div'; 246 247 //是否使用完整的html编辑模式如使用,其源码将包含:<html><body></body></html>等标签 248 config.fullpage = false; 249 250 //是否忽略段落中的空字符 若不忽略 则字符将以“”表示plugins/wysiwygarea/plugin.js 251 config.ignoreemptyparagraph = true; 252 253 //在清除图片属性框中的链接属性时 是否同时清除两边的<a>标签plugins/image/plugin.js 254 config.image_removelinkbyemptyurl = true; 255 256 //一组用逗号分隔的标签名称,显示在左下角的层次嵌套中plugins/menu/plugin.js. 257 config.menu_groups='clipboard,form,tablecell,tablecellproperties,tablerow,tablecolumn,table,anchor,link,image,flash,checkbox,radio,textfield,hiddenfield,imagebutton,button,select,textarea'; 258 259 //显示子菜单时的延迟,单位:ms plugins/menu/plugin.js 260 config.menu_submenudelay = 400; 261 262 //当执行“新建”命令时,编辑器中的内容plugins/newpage/plugin.js 263 config.newpage_html = ''; 264 265 //当从word里复制文字进来时,是否进行文字的格式化去除plugins/pastefromword/plugin.js 266 config.pastefromwordignorefontface = true; //默认为忽略格式 267 268 //是否使用<h1><h2>等标签修饰或者代替从word文档中粘贴过来的内容plugins/pastefromword/plugin.js 269 config.pastefromwordkeepsstructure = false; 270 271 //从word中粘贴内容时是否移除格式plugins/pastefromword/plugin.js 272 config.pastefromwordremovestyle =false; 273 274 //对应后台语言的类型来对输出的html内容进行格式化,默认为空 275 config.protectedsource.push( /<"?["s"s]*?"?>/g ); // php code 276 config.protectedsource.push( //g ); // asp code 277 config.protectedsource.push(/(]+>["s|"s]*?<"/asp:[^">]+>)|(]+"/>)/gi ); // asp.netcode 278 279 //当输入:shift+enter时插入的标签 280 config.shiftentermode = ckeditor.enter_p; //可选:ckeditor.enter_br或ckeditor.enter_div 281 282 //可选的表情替代字符 plugins/smiley/plugin.js. 283 config.smiley_descriptions = [ 284 ':)', ':(', ';)', ':d', ':/',':p', 285 '', '', '', '', '', '', 286 '', ';(', '', '','', '', 287 '', ':kiss', '' ]; 288 289 //对应的表情图片 plugins/smiley/plugin.js 290 config.smiley_images = [ 291 'regular_smile.gif','sad_smile.gif','wink_smile.gif','teeth_smile.gif','confused_smile.gif','tounge_smile.gif', 292 'embaressed_smile.gif','omg_smile.gif','whatchutalkingabout_smile.gif','angry_smile.gif','angel_smile.gif','shades_smile.gif', 293 'devil_smile.gif','cry_smile.gif','lightbulb.gif','thumbs_down.gif','thumbs_up.gif','heart.gif', 294 'broken_heart.gif','kiss.gif','envelope.gif']; 295 296 //表情的地址 plugins/smiley/plugin.js 297 config.smiley_path = 'plugins/smiley/images/'; 298 299 //页面载入时,编辑框是否立即获得焦点plugins/editingblock/plugin.js plugins/editingblock/plugin.js. 300 config.startupfocus = false; 301 302 //载入时,以何种方式编辑 源码和所见即所得 "source"和"wysiwyg"plugins/editingblock/plugin.js. 303 config.startupmode ='wysiwyg'; 304 305 //载入时,是否显示框体的边框plugins/showblocks/plugin.js 306 config.startupoutlineblocks = false; 307 308 //是否载入样式文件 plugins/stylescombo/plugin.js. 309 config.stylescombo_stylesset = 'default'; 310 //以下为可选 311 config.stylescombo_stylesset = 'mystyles'; 312 config.stylescombo_stylesset = 'mystyles:/editorstyles/styles.js'; 313 config.stylescombo_stylesset ='mystyles:http://www.example.com/editorstyles/styles.js'; 314 315 //起始的索引值 316 config.tabindex = 0; 317 318 //当用户键入tab时,编辑器走过的空格数,( )当值为0时,焦点将移出编辑框 plugins/tab/plugin.js 319 config.tabspaces = 0; 320 321 //默认使用的模板 plugins/templates/plugin.js. 322 config.templates = 'default'; 323 324 //用逗号分隔的模板文件plugins/templates/plugin.js. 325 config.templates_files = [ 'plugins/templates/templates/default.js' ] 326 327 //当使用模板时,“编辑内容将被替换”框是否选中plugins/templates/plugin.js 328 config.templates_replacecontent =true; 329 330 //主题 331 config.theme = 'default'; 332 333 //撤销的记录步数 plugins/undo/plugin.js 334 config.undostacksize =20; 335 336 // 在 ckeditor 中集成 ckfinder,注意 ckfinder的路径选择要正确。 337 //ckfinder.setupckeditor(null, '/ckfinder/');
效果预览:
5.扩展图片上传:
在config.js新增代码:
config.filebrowserimageuploadurl = '~/upload'; // 图片上传路径
config.image_previewtext = ' '; // 图片信息面板预览区内容的文字内容,默认显示ckeditor自带的内容
config.removedialogtabs = 'image:advanced;image:link'; // 移除图片上传页面的'高级','链接'页签
filebrowserimageuploadurl :配置图片上传地址;
后台功能代码展示:
1 [httppost] 2 public actionresult singleimgupload(httppostedfilebase upload) 3 { 4 5 try 6 { 7 uploadimgclass uploadimgclass = new uploadimgclass(); 8 var ckeditorfuncnum = request["ckeditorfuncnum"]; 9 string uploadpath = server.mappath("~/upload/"); 10 if (!directory.exists(uploadpath)) 11 { 12 directory.createdirectory(uploadpath); 13 } 14 string filename = upload.filename; 15 string fileext = filename.substring(filename.lastindexof(".") + 1); 16 string filecontenttype = upload.contenttype.tostring(); 17 if (filecontenttype == "image/bmp" || filecontenttype == "image/gif" || filecontenttype == "image/png" || filecontenttype == "image/x-png" || filecontenttype == "image/jpeg" 18 || filecontenttype == "image/pjpeg") 19 { 20 string nowtimestr = guid.newguid().tostring(); 21 filename = nowtimestr + "." + fileext; 22 upload.saveas(path.combine(uploadpath, filename)); 23 string hosturl =request.url.host; 24 string post = request.url.port.tostring(); 25 string imageurl =path.combine(uploadpath, filename) 26 uploadimgclass.uploaded = 1; 27 uploadimgclass.filename = filename; 28 uploadimgclass.url = imageurl; 29 return content(uploadimgclass.tojson()); 30 } 31 else { 32 string msgdata = errorstr(0, "只支持bmp、gif、jpg、png格式的图片!"); 33 return content(msgdata); 34 } 35 } 36 catch (exception ex) 37 { 38 string msgdata = errorstr(0, "上传失败!"); 39 return content(msgdata); 40 } 41 }
二、自定义生成工具栏:
在浏览器打开文件夹samples中的html,选择需要的工具菜单项生成代码
三、精简ckeditor
在部署到web服务器上时,下列文件夹和文件都可以删除:
/_samples :示例文件夹;
/_source :未压缩源程序;
/lang文件夹下除 zh-cn.js、en.js以外的文件(也可以根据需要保留其他语言文件);
根目录下的changes.html(更新列表),install.html(安装指向),license.html(使用许可);
/skins 目录下不需要的皮肤,一般用v2(简单,朴素),如果只保留v2则必须在config.js中指定皮肤
如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复
Blazor server side 自家的一些开源的, 实用型项目的进度之 CEF客户端
.NET IoC模式依赖反转(DIP)、控制反转(Ioc)、依赖注入(DI)
vue+.netcore可支持业务代码扩展的开发框架 VOL.Vue 2.0版本发布
网友评论