Contents
编辑器的宽度,可以设置px或%,比textarea输入框样式表宽度优先度高。
示例:
1 2 3 |
<span class="nx">K</span><span class="p">.</span><span class="nx">create</span><span class="p">(</span><span class="s1">'#id'</span><span class="p">,</span> <span class="p">{</span> <span class="nx">width</span> <span class="o">:</span> <span class="s1">'700px'</span> <span class="p">});</span> |
配置编辑器的工具栏,其中”/”表示换行,”|”表示分隔符。
1 2 3 4 5 6 7 8 9 10 |
<span class="p">[</span> <span class="s1">'source'</span><span class="p">,</span> <span class="s1">'|'</span><span class="p">,</span> <span class="s1">'undo'</span><span class="p">,</span> <span class="s1">'redo'</span><span class="p">,</span> <span class="s1">'|'</span><span class="p">,</span> <span class="s1">'preview'</span><span class="p">,</span> <span class="s1">'print'</span><span class="p">,</span> <span class="s1">'template'</span><span class="p">,</span> <span class="s1">'code'</span><span class="p">,</span> <span class="s1">'cut'</span><span class="p">,</span> <span class="s1">'copy'</span><span class="p">,</span> <span class="s1">'paste'</span><span class="p">,</span> <span class="s1">'plainpaste'</span><span class="p">,</span> <span class="s1">'wordpaste'</span><span class="p">,</span> <span class="s1">'|'</span><span class="p">,</span> <span class="s1">'justifyleft'</span><span class="p">,</span> <span class="s1">'justifycenter'</span><span class="p">,</span> <span class="s1">'justifyright'</span><span class="p">,</span> <span class="s1">'justifyfull'</span><span class="p">,</span> <span class="s1">'insertorderedlist'</span><span class="p">,</span> <span class="s1">'insertunorderedlist'</span><span class="p">,</span> <span class="s1">'indent'</span><span class="p">,</span> <span class="s1">'outdent'</span><span class="p">,</span> <span class="s1">'subscript'</span><span class="p">,</span> <span class="s1">'superscript'</span><span class="p">,</span> <span class="s1">'clearhtml'</span><span class="p">,</span> <span class="s1">'quickformat'</span><span class="p">,</span> <span class="s1">'selectall'</span><span class="p">,</span> <span class="s1">'|'</span><span class="p">,</span> <span class="s1">'fullscreen'</span><span class="p">,</span> <span class="s1">'/'</span><span class="p">,</span> <span class="s1">'formatblock'</span><span class="p">,</span> <span class="s1">'fontname'</span><span class="p">,</span> <span class="s1">'fontsize'</span><span class="p">,</span> <span class="s1">'|'</span><span class="p">,</span> <span class="s1">'forecolor'</span><span class="p">,</span> <span class="s1">'hilitecolor'</span><span class="p">,</span> <span class="s1">'bold'</span><span class="p">,</span> <span class="s1">'italic'</span><span class="p">,</span> <span class="s1">'underline'</span><span class="p">,</span> <span class="s1">'strikethrough'</span><span class="p">,</span> <span class="s1">'lineheight'</span><span class="p">,</span> <span class="s1">'removeformat'</span><span class="p">,</span> <span class="s1">'|'</span><span class="p">,</span> <span class="s1">'image'</span><span class="p">,</span> <span class="s1">'multiimage'</span><span class="p">,</span> <span class="s1">'flash'</span><span class="p">,</span> <span class="s1">'media'</span><span class="p">,</span> <span class="s1">'insertfile'</span><span class="p">,</span> <span class="s1">'table'</span><span class="p">,</span> <span class="s1">'hr'</span><span class="p">,</span> <span class="s1">'emoticons'</span><span class="p">,</span> <span class="s1">'baidumap'</span><span class="p">,</span> <span class="s1">'pagebreak'</span><span class="p">,</span> <span class="s1">'anchor'</span><span class="p">,</span> <span class="s1">'link'</span><span class="p">,</span> <span class="s1">'unlink'</span><span class="p">,</span> <span class="s1">'|'</span><span class="p">,</span> <span class="s1">'about'</span> <span class="p">]</span> |
source | HTML代码 |
preview | 预览 |
undo | 后退 |
redo | 前进 |
cut | 剪切 |
copy | 复制 |
paste | 粘贴 |
plainpaste | 粘贴为无格式文本 |
wordpaste | 从Word粘贴 |
selectall | 全选 |
justifyleft | 左对齐 |
justifycenter | 居中 |
justifyright | 右对齐 |
justifyfull | 两端对齐 |
insertorderedlist | 编号 |
insertunorderedlist | 项目符号 |
indent | 增加缩进 |
outdent | 减少缩进 |
subscript | 下标 |
superscript | 上标 |
formatblock | 段落 |
fontname | 字体 |
fontsize | 文字大小 |
forecolor | 文字颜色 |
hilitecolor | 文字背景 |
bold | 粗体 |
italic | 斜体 |
underline | 下划线 |
strikethrough | 删除线 |
removeformat | 删除格式 |
image | 图片 |
flash | Flash |
media | 视音频 |
table | 表格 |
hr | 插入横线 |
emoticons | 插入表情 |
link | 超级链接 |
unlink | 取消超级链接 |
fullscreen | 全屏显示 |
about | 关于 |
打印 | |
code | 插入程序代码 |
map | Google地图 |
baidumap | 百度地图 |
lineheight | 行距 |
clearhtml | 清理HTML代码 |
pagebreak | 插入分页符 |
quickformat | 一键排版 |
insertfile | 插入文件 |
template | 插入模板 |
anchor | 插入锚点 |
true时根据 htmlTags 过滤HTML代码,false时允许输入任何代码。
Note
4.1.1版本开始默认值为true。
指定主题风格,可设置”default”、”simple”,指定simple时需要引入simple.css。
示例:
1 2 3 4 5 6 7 8 9 10 11 12 |
<span class="p"><</span><span class="nt">link</span> <span class="na">rel</span><span class="o">=</span><span class="s">"stylesheet"</span> <span class="na">href</span><span class="o">=</span><span class="s">"../themes/default/default.css"</span> <span class="p">/></span> <span class="p"><</span><span class="nt">link</span> <span class="na">rel</span><span class="o">=</span><span class="s">"stylesheet"</span> <span class="na">href</span><span class="o">=</span><span class="s">"../themes/simple/simple.css"</span> <span class="p">/></span> <span class="p"><</span><span class="nt">script</span> <span class="na">charset</span><span class="o">=</span><span class="s">"utf-8"</span> <span class="na">src</span><span class="o">=</span><span class="s">"../kindeditor.js"</span><span class="p">></</span><span class="nt">script</span><span class="p">></span> <span class="p"><</span><span class="nt">script</span> <span class="na">charset</span><span class="o">=</span><span class="s">"utf-8"</span> <span class="na">src</span><span class="o">=</span><span class="s">"../lang/zh-CN.js"</span><span class="p">></</span><span class="nt">script</span><span class="p">></span> <span class="p"><</span><span class="nt">script</span><span class="p">></span> <span class="kd">var</span> <span class="nx">editor</span><span class="p">;</span> <span class="nx">KindEditor</span><span class="p">.</span><span class="nx">ready</span><span class="p">(</span><span class="kd">function</span><span class="p">(</span><span class="nx">K</span><span class="p">)</span> <span class="p">{</span> <span class="nx">editor</span> <span class="o">=</span> <span class="nx">K</span><span class="p">.</span><span class="nx">create</span><span class="p">(</span><span class="s1">'#editor_id'</span><span class="p">,</span> <span class="p">{</span> <span class="nx">themeType</span> <span class="o">:</span> <span class="s1">'simple'</span> <span class="p">});</span> <span class="p">});</span> <span class="p"></</span><span class="nt">script</span><span class="p">></span> |
指定语言,可设置”en”、”zh-CN”,需要引入lang/[langType].js。
示例:
1 2 3 4 5 6 7 8 9 10 11 |
<span class="p"><</span><span class="nt">link</span> <span class="na">rel</span><span class="o">=</span><span class="s">"stylesheet"</span> <span class="na">href</span><span class="o">=</span><span class="s">"../themes/default/default.css"</span> <span class="p">/></span> <span class="p"><</span><span class="nt">script</span> <span class="na">charset</span><span class="o">=</span><span class="s">"utf-8"</span> <span class="na">src</span><span class="o">=</span><span class="s">"../kindeditor.js"</span><span class="p">></</span><span class="nt">script</span><span class="p">></span> <span class="p"><</span><span class="nt">script</span> <span class="na">charset</span><span class="o">=</span><span class="s">"utf-8"</span> <span class="na">src</span><span class="o">=</span><span class="s">"../lang/en.js"</span><span class="p">></</span><span class="nt">script</span><span class="p">></span> <span class="p"><</span><span class="nt">script</span><span class="p">></span> <span class="kd">var</span> <span class="nx">editor</span><span class="p">;</span> <span class="nx">KindEditor</span><span class="p">.</span><span class="nx">ready</span><span class="p">(</span><span class="kd">function</span><span class="p">(</span><span class="nx">K</span><span class="p">)</span> <span class="p">{</span> <span class="nx">editor</span> <span class="o">=</span> <span class="nx">K</span><span class="p">.</span><span class="nx">create</span><span class="p">(</span><span class="s1">'#editor_id'</span><span class="p">,</span> <span class="p">{</span> <span class="nx">langType</span> <span class="o">:</span> <span class="s1">'en'</span> <span class="p">});</span> <span class="p">});</span> <span class="p"></</span><span class="nt">script</span><span class="p">></span> |
改变站内本地URL,可设置”“、”relative”、”absolute”、”domain”。空为不修改URL,relative为相对路径,absolute为绝对路径,domain为带域名的绝对路径。
指定取色器里的颜色。
1 2 3 4 5 6 |
<span class="p">[</span> <span class="p">[</span><span class="s1">'#E53333'</span><span class="p">,</span> <span class="s1">'#E56600'</span><span class="p">,</span> <span class="s1">'#FF9900'</span><span class="p">,</span> <span class="s1">'#64451D'</span><span class="p">,</span> <span class="s1">'#DFC5A4'</span><span class="p">,</span> <span class="s1">'#FFE500'</span><span class="p">],</span> <span class="p">[</span><span class="s1">'#009900'</span><span class="p">,</span> <span class="s1">'#006600'</span><span class="p">,</span> <span class="s1">'#99BB00'</span><span class="p">,</span> <span class="s1">'#B8D100'</span><span class="p">,</span> <span class="s1">'#60D978'</span><span class="p">,</span> <span class="s1">'#00D5FF'</span><span class="p">],</span> <span class="p">[</span><span class="s1">'#337FE5'</span><span class="p">,</span> <span class="s1">'#003399'</span><span class="p">,</span> <span class="s1">'#4C33E5'</span><span class="p">,</span> <span class="s1">'#9933E5'</span><span class="p">,</span> <span class="s1">'#CC33E5'</span><span class="p">,</span> <span class="s1">'#EE33EE'</span><span class="p">],</span> <span class="p">[</span><span class="s1">'#FFFFFF'</span><span class="p">,</span> <span class="s1">'#CCCCCC'</span><span class="p">,</span> <span class="s1">'#999999'</span><span class="p">,</span> <span class="s1">'#666666'</span><span class="p">,</span> <span class="s1">'#333333'</span><span class="p">,</span> <span class="s1">'#000000'</span><span class="p">]</span> <span class="p">]</span> |
上传文件后执行的回调函数。
1 2 3 4 5 6 7 |
<span class="nx">KindEditor</span><span class="p">.</span><span class="nx">ready</span><span class="p">(</span><span class="kd">function</span><span class="p">(</span><span class="nx">K</span><span class="p">)</span> <span class="p">{</span> <span class="nx">K</span><span class="p">.</span><span class="nx">create</span><span class="p">(</span><span class="s1">'#id'</span><span class="p">,</span> <span class="p">{</span> <span class="nx">afterUpload</span> <span class="o">:</span> <span class="kd">function</span><span class="p">(</span><span class="nx">url</span><span class="p">)</span> <span class="p">{</span> <span class="nx">alert</span><span class="p">(</span><span class="nx">url</span><span class="p">);</span> <span class="p">}</span> <span class="p">});</span> <span class="p">});</span> |
指定文字大小。
1 |
<span class="p">[</span><span class="s1">'9px'</span><span class="p">,</span> <span class="s1">'10px'</span><span class="p">,</span> <span class="s1">'12px'</span><span class="p">,</span> <span class="s1">'14px'</span><span class="p">,</span> <span class="s1">'16px'</span><span class="p">,</span> <span class="s1">'18px'</span><span class="p">,</span> <span class="s1">'24px'</span><span class="p">,</span> <span class="s1">'32px'</span><span class="p">]</span> |
上传图片、Flash、视音频、文件时,支持添加别的参数一并传到服务器。
1 2 3 4 5 6 7 8 |
<span class="nx">KindEditor</span><span class="p">.</span><span class="nx">ready</span><span class="p">(</span><span class="kd">function</span><span class="p">(</span><span class="nx">K</span><span class="p">)</span> <span class="p">{</span> <span class="nx">K</span><span class="p">.</span><span class="nx">create</span><span class="p">(</span><span class="s1">'#id'</span><span class="p">,</span> <span class="p">{</span> <span class="nx">extraFileUploadParams</span> <span class="o">:</span> <span class="p">{</span> <span class="nx">item_id</span> <span class="o">:</span> <span class="mi">1000</span><span class="p">,</span> <span class="nx">category_id</span> <span class="o">:</span> <span class="mi">1</span> <span class="p">}</span> <span class="p">});</span> <span class="p">});</span> |
Note
4.1.1版本开始支持。
true时图片上传成功后切换到图片编辑标签,false时插入图片后关闭弹出框。
Note
4.1.2版本开始支持。
可指定分页符HTML。
Note
4.1.3版本开始支持。
from:http://kindeditor.net/docs/option.html