继上次学习了HTML5的路径画圆做了动态时钟、异次元空间的反转做了运动的太阳系,这两天将画线、画圆、填充等知识点结合起来做了一个简易的在线画图工具:查看DEMO:HTML5简易在线画图工具 功能包括*
顺晟科技
2022-09-15 19:37:25
149
简介
KindEditor是一套开源的HTML可视化编辑器,主要用于让用户在网站上获得所见即所得编辑效果,兼容IE、Firefox、Chrome、Safari、Opera等主流浏览器。KindEditor使用JavaScript编写,可以无缝的于Java、.NET、PHP、ASP等程序接合。
示例
1 $(function() { 2 KindEditor.ready(function(K) { 3 editor1 = K.create(\'textarea[name="menuContent"]\', { 4 allowFileManager : true,//true时显示浏览远程服务器按钮 5 allowPreviewEmoticons : false, 6 wellFormatMode:false, 7 wellFormatMode:false, 8 width:650, 9 height:350, 10 allowImageUpload : true, 11 items:["source", "preview","template","cut","copy","paste", 12 "plainpaste","wordpaste","justifyleft","justifycenter", 13 "justifyright","justifyfull","insertorderedlist","insertunorderedlist", 14 "indent","outdent","subscript","superscript","quickformat", 15 "formatblock","fontname","fontsize","forecolor","hilitecolor", 16 "bold","italic","underline","strikethrough","lineheight","removeformat", 17 "table","hr","link","unlink","image","fontsize"], 18 afterCreate : function() { 19 },afterBlur: function(){ 20 this.sync(); 21 } 22 }); 23 });
参数说明
width
编辑器的宽度,可以设置px或%,比textarea输入框样式表宽度优先度高。
height
编辑器的高度,只能设置px,比textarea输入框样式表高度优先度高。
minWidth
指定编辑器最小宽度,单位为px。
minHeight
指定编辑器最小高度,单位为px。
items
配置编辑器的工具栏,其中”/”表示换行,”|”表示分隔符。
[ \'source\', \'|\', \'undo\', \'redo\', \'|\', \'preview\', \'print\', \'template\', \'code\', \'cut\', \'copy\', \'paste\', \'plainpaste\', \'wordpaste\', \'|\', \'justifyleft\', \'justifycenter\', \'justifyright\', \'justifyfull\', \'insertorderedlist\', \'insertunorderedlist\', \'indent\', \'outdent\', \'subscript\', \'superscript\', \'clearhtml\', \'quickformat\', \'selectall\', \'|\', \'fullscreen\', \'/\', \'formatblock\', \'fontname\', \'fontsize\', \'|\', \'forecolor\', \'hilitecolor\', \'bold\', \'italic\', \'underline\', \'strikethrough\', \'lineheight\', \'removeformat\', \'|\', \'image\', \'multiimage\', \'flash\', \'media\', \'insertfile\', \'table\', \'hr\', \'emoticons\', \'baidumap\', \'pagebreak\', \'anchor\', \'link\', \'unlink\', \'|\', \'about\' ]
designMode 为false时,要保留的工具栏图标。
true时根据 htmlTags 过滤HTML代码,false时允许输入任何代码。
Note
4.1.1版本开始默认值为true。
指定要保留的HTML标记和属性。Object的key为HTML标签名,value为HTML属性数组,”.”开始的属性表示style属性。
{ font : [\'color\', \'size\', \'face\', \'.background-color\'], span : [ \'.color\', \'.background-color\', \'.font-size\', \'.font-family\', \'.background\', \'.font-weight\', \'.font-style\', \'.text-decoration\', \'.vertical-align\', \'.line-height\' ], div : [ \'align\', \'.border\', \'.margin\', \'.padding\', \'.text-align\', \'.color\', \'.background-color\', \'.font-size\', \'.font-family\', \'.font-weight\', \'.background\', \'.font-style\', \'.text-decoration\', \'.vertical-align\', \'.margin-left\' ], table: [ \'border\', \'cellspacing\', \'cellpadding\', \'width\', \'height\', \'align\', \'bordercolor\', \'.padding\', \'.margin\', \'.border\', \'bgcolor\', \'.text-align\', \'.color\', \'.background-color\', \'.font-size\', \'.font-family\', \'.font-weight\', \'.font-style\', \'.text-decoration\', \'.background\', \'.width\', \'.height\', \'.border-collapse\' ], \'td,th\': [ \'align\', \'valign\', \'width\', \'height\', \'colspan\', \'rowspan\', \'bgcolor\', \'.text-align\', \'.color\', \'.background-color\', \'.font-size\', \'.font-family\', \'.font-weight\', \'.font-style\', \'.text-decoration\', \'.vertical-align\', \'.background\', \'.border\' ], a : [\'href\', \'target\', \'name\'], embed : [\'src\', \'width\', \'height\', \'type\', \'loop\', \'autostart\', \'quality\', \'.width\', \'.height\', \'align\', \'allowscriptaccess\'], img : [\'src\', \'width\', \'height\', \'border\', \'alt\', \'title\', \'align\', \'.width\', \'.height\', \'.border\'], \'p,ol,ul,li,blockquote,h1,h2,h3,h4,h5,h6\' : [ \'align\', \'.text-align\', \'.color\', \'.background-color\', \'.font-size\', \'.font-family\', \'.background\', \'.font-weight\', \'.font-style\', \'.text-decoration\', \'.vertical-align\', \'.text-indent\', \'.margin-left\' ], pre : [\'class\'], hr : [\'class\', \'.page-break-after\'], \'br,tbody,tr,strong,b,sub,sup,em,i,u,strike,s,del\' : [] }
true时美化HTML数据。
2或1或0,2时可以拖动改变宽度和高度,1时只能改变高度,0时不能拖动。
指定主题风格,可设置”default”、”simple”,指定simple时需要引入simple.css。
示例:
<link rel="stylesheet" href="../themes/default/default.css" /> <link rel="stylesheet" href="../themes/simple/simple.css" /> <script charset="utf-8" src="../kindeditor.js"></script> <script charset="utf-8" src="../lang/zh-CN.js"></script> <script> var editor; KindEditor.ready(function(K) { editor = K.create(\'#editor_id\', { themeType : \'simple\' }); }); </script>
指定语言,可设置”en”、”zh-CN”,需要引入lang/[langType].js。
示例:
<link rel="stylesheet" href="../themes/default/default.css" /> <script charset="utf-8" src="../kindeditor.js"></script> <script charset="utf-8" src="../lang/en.js"></script> <script> var editor; KindEditor.ready(function(K) { editor = K.create(\'#editor_id\', { langType : \'en\' }); }); </script>
可视化模式或代码模式
true时加载编辑器后变成全屏模式。
指定编辑器的根目录路径。
指定编辑器的themes目录路径。
指定编辑器的plugins目录路径。
指定编辑器的lang目录路径。
undo/redo文字输入最小变化长度,当输入的文字变化小于这个长度时不会添加到undo记录里。
改变站内本地URL,可设置”“、”relative”、”absolute”、”domain”。空为不修改URL,relative为相对路径,absolute为绝对路径,domain为带域名的绝对路径。
设置回车换行标签,可设置”p”、”br”。
设置粘贴类型,0:禁止粘贴, 1:纯文本粘贴, 2:HTML粘贴
设置弹出框(dialog)的对齐类型,可设置”“、”page”,指定page时按当前页面居中,指定空时按编辑器居中。
true时弹出层(dialog)显示阴影。
指定弹出层的基准z-index。
true时使用右键菜单,false时屏蔽右键菜单。
同步数据的方式,可设置”“、”form”,值为form时提交form时自动同步,空时不会自动同步。
wellFormatMode 为true时,HTML代码缩进字符。
指定编辑器iframe document的CSS文件,用于设置可视化区域的样式。
指定编辑器iframe document的CSS数据,用于设置可视化区域的样式。
指定编辑器iframe document body的className。
指定取色器里的颜色。
[ [\'#E53333\', \'#E56600\', \'#FF9900\', \'#64451D\', \'#DFC5A4\', \'#FFE500\'], [\'#009900\', \'#006600\', \'#99BB00\', \'#B8D100\', \'#60D978\', \'#00D5FF\'], [\'#337FE5\', \'#003399\', \'#4C33E5\', \'#9933E5\', \'#CC33E5\', \'#EE33EE\'], [\'#FFFFFF\', \'#CCCCCC\', \'#999999\', \'#666666\', \'#333333\', \'#000000\'] ]
设置编辑器创建后执行的回调函数。
编辑器内容发生变化后执行的回调函数。
按下TAB键后执行的的回调函数。
编辑器聚焦(focus)时执行的回调函数。
编辑器失去焦点(blur)时执行的回调函数。
上传文件后执行的回调函数。
KindEditor.ready(function(K) { K.create(\'#id\', { afterUpload : function(url) { alert(url); } }); });
指定上传文件的服务器端程序。
指定浏览远程图片的服务器端程序。
true时鼠标放在表情上可以预览表情。
true时显示图片上传按钮。
true时显示Flash上传按钮。
true时显示视音频上传按钮。
true时显示文件上传按钮。
Note
4.0.6版本开始支持。
true时显示浏览远程服务器按钮。
指定文字大小。
[\'9px\', \'10px\', \'12px\', \'14px\', \'16px\', \'18px\', \'24px\', \'32px\']
图片弹出层的默认显示标签索引。
Note
4.0.6版本开始支持。
false时不会自动格式化上传后的URL。
Note
4.1版本开始支持。
false时禁用ESC全屏快捷键。
Note
4.1版本开始支持,从4.1.2版本开始默认值为false。
上传图片、Flash、视音频、文件时,支持添加别的参数一并传到服务器。
KindEditor.ready(function(K) { K.create(\'#id\', { extraFileUploadParams : { item_id : 1000, category_id : 1 } }); });
Note
4.1.1版本开始支持。
指定上传文件form名称。
Note
4.1.2版本开始支持。
true时图片上传成功后切换到图片编辑标签,false时插入图片后关闭弹出框。
Note
4.1.2版本开始支持。
从图片空间选择文件后执行的回调函数。
Note
4.1.2版本开始支持。
可指定分页符HTML。
Note
4.1.3版本开始支持。
true时显示网络图片标签,false时不显示。
Note
4.1.6版本开始支持。
值为true,并引入autoheight.js插件时自动调整高度。
Note
4.1.8版本开始支持。
值为true,并引入fixtoolbar.js插件时固定工具栏位置。
参考链接:http://kindeditor.net/docs/option.html
19
2022-10
16
2022-09
16
2022-09
15
2022-09
15
2022-09
15
2022-09