option.rst 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870
  1. 编辑器初始化参数
  2. ========================================================
  3. .. contents::
  4. :depth: 2
  5. .. index:: width
  6. .. _width:
  7. width
  8. --------------------------------------------------------
  9. 编辑器的宽度,可以设置px或%,比textarea输入框样式表宽度优先度高。
  10. * 数据类型: String
  11. * 默认值: textarea输入框的宽度
  12. 示例:
  13. .. sourcecode:: js
  14. K.create('#id', {
  15. width : '700px'
  16. });
  17. .. index:: height
  18. .. _height:
  19. height
  20. --------------------------------------------------------
  21. 编辑器的高度,只能设置px,比textarea输入框样式表高度优先度高。
  22. * 数据类型: String
  23. * 默认值: textarea输入框的高度
  24. .. index:: minWidth
  25. .. _minWidth:
  26. minWidth
  27. --------------------------------------------------------
  28. 指定编辑器最小宽度,单位为px。
  29. * 数据类型: Int
  30. * 默认值: 650
  31. .. index:: minHeight
  32. .. _minHeight:
  33. minHeight
  34. --------------------------------------------------------
  35. 指定编辑器最小高度,单位为px。
  36. * 数据类型: Int
  37. * 默认值: 100
  38. .. index:: items
  39. .. _items:
  40. items
  41. --------------------------------------------------------
  42. 配置编辑器的工具栏,其中"/"表示换行,"|"表示分隔符。
  43. * 数据类型: Array
  44. * 默认值:
  45. .. sourcecode:: js
  46. [
  47. 'source', '|', 'undo', 'redo', '|', 'preview', 'print', 'template', 'code', 'cut', 'copy', 'paste',
  48. 'plainpaste', 'wordpaste', '|', 'justifyleft', 'justifycenter', 'justifyright',
  49. 'justifyfull', 'insertorderedlist', 'insertunorderedlist', 'indent', 'outdent', 'subscript',
  50. 'superscript', 'clearhtml', 'quickformat', 'selectall', '|', 'fullscreen', '/',
  51. 'formatblock', 'fontname', 'fontsize', '|', 'forecolor', 'hilitecolor', 'bold',
  52. 'italic', 'underline', 'strikethrough', 'lineheight', 'removeformat', '|', 'image', 'multiimage',
  53. 'flash', 'media', 'insertfile', 'table', 'hr', 'emoticons', 'baidumap', 'pagebreak',
  54. 'anchor', 'link', 'unlink', '|', 'about'
  55. ]
  56. ========================== =====================
  57. source HTML代码
  58. preview 预览
  59. undo 后退
  60. redo 前进
  61. cut 剪切
  62. copy 复制
  63. paste 粘贴
  64. plainpaste 粘贴为无格式文本
  65. wordpaste 从Word粘贴
  66. selectall 全选
  67. justifyleft 左对齐
  68. justifycenter 居中
  69. justifyright 右对齐
  70. justifyfull 两端对齐
  71. insertorderedlist 编号
  72. insertunorderedlist 项目符号
  73. indent 增加缩进
  74. outdent 减少缩进
  75. subscript 下标
  76. superscript 上标
  77. formatblock 段落
  78. fontname 字体
  79. fontsize 文字大小
  80. forecolor 文字颜色
  81. hilitecolor 文字背景
  82. bold 粗体
  83. italic 斜体
  84. underline 下划线
  85. strikethrough 删除线
  86. removeformat 删除格式
  87. image 图片
  88. flash Flash
  89. media 视音频
  90. table 表格
  91. hr 插入横线
  92. emoticons 插入表情
  93. link 超级链接
  94. unlink 取消超级链接
  95. fullscreen 全屏显示
  96. about 关于
  97. print 打印
  98. code 插入程序代码
  99. map Google地图
  100. baidumap 百度地图
  101. lineheight 行距
  102. clearhtml 清理HTML代码
  103. pagebreak 插入分页符
  104. quickformat 一键排版
  105. insertfile 插入文件
  106. template 插入模板
  107. anchor 插入锚点
  108. ========================== =====================
  109. .. index:: noDisableItems
  110. .. _noDisableItems:
  111. noDisableItems
  112. --------------------------------------------------------
  113. :ref:`designMode` 为false时,要保留的工具栏图标。
  114. * 数据类型: Array
  115. * 默认值: ['source', 'fullscreen']
  116. .. index:: filterMode
  117. .. _filterMode:
  118. filterMode
  119. --------------------------------------------------------
  120. true时根据 :ref:`htmlTags` 过滤HTML代码,false时允许输入任何代码。
  121. * 数据类型: Boolean
  122. * 默认值: true
  123. .. note::
  124. 4.1.1版本开始默认值为true。
  125. .. index:: htmlTags
  126. .. _htmlTags:
  127. htmlTags
  128. --------------------------------------------------------
  129. 指定要保留的HTML标记和属性。Object的key为HTML标签名,value为HTML属性数组,"."开始的属性表示style属性。
  130. * 数据类型: Object
  131. * 默认值:
  132. .. sourcecode:: js
  133. {
  134. font : ['color', 'size', 'face', '.background-color'],
  135. span : [
  136. '.color', '.background-color', '.font-size', '.font-family', '.background',
  137. '.font-weight', '.font-style', '.text-decoration', '.vertical-align', '.line-height'
  138. ],
  139. div : [
  140. 'align', '.border', '.margin', '.padding', '.text-align', '.color',
  141. '.background-color', '.font-size', '.font-family', '.font-weight', '.background',
  142. '.font-style', '.text-decoration', '.vertical-align', '.margin-left'
  143. ],
  144. table: [
  145. 'border', 'cellspacing', 'cellpadding', 'width', 'height', 'align', 'bordercolor',
  146. '.padding', '.margin', '.border', 'bgcolor', '.text-align', '.color', '.background-color',
  147. '.font-size', '.font-family', '.font-weight', '.font-style', '.text-decoration', '.background',
  148. '.width', '.height', '.border-collapse'
  149. ],
  150. 'td,th': [
  151. 'align', 'valign', 'width', 'height', 'colspan', 'rowspan', 'bgcolor',
  152. '.text-align', '.color', '.background-color', '.font-size', '.font-family', '.font-weight',
  153. '.font-style', '.text-decoration', '.vertical-align', '.background', '.border'
  154. ],
  155. a : ['href', 'target', 'name'],
  156. embed : ['src', 'width', 'height', 'type', 'loop', 'autostart', 'quality', '.width', '.height', 'align', 'allowscriptaccess'],
  157. img : ['src', 'width', 'height', 'border', 'alt', 'title', 'align', '.width', '.height', '.border'],
  158. 'p,ol,ul,li,blockquote,h1,h2,h3,h4,h5,h6' : [
  159. 'align', '.text-align', '.color', '.background-color', '.font-size', '.font-family', '.background',
  160. '.font-weight', '.font-style', '.text-decoration', '.vertical-align', '.text-indent', '.margin-left'
  161. ],
  162. pre : ['class'],
  163. hr : ['class', '.page-break-after'],
  164. 'br,tbody,tr,strong,b,sub,sup,em,i,u,strike,s,del' : []
  165. }
  166. .. index:: wellFormatMode
  167. .. _wellFormatMode:
  168. wellFormatMode
  169. --------------------------------------------------------
  170. true时美化HTML数据。
  171. * 数据类型: Boolean
  172. * 默认值: true
  173. .. index:: resizeType
  174. .. _resizeType:
  175. resizeType
  176. --------------------------------------------------------
  177. 2或1或0,2时可以拖动改变宽度和高度,1时只能改变高度,0时不能拖动。
  178. * 数据类型: Int
  179. * 默认值: 2
  180. .. index:: themeType
  181. .. _themeType:
  182. themeType
  183. --------------------------------------------------------
  184. 指定主题风格,可设置"default"、"simple",指定simple时需要引入simple.css。
  185. * 数据类型: String
  186. * 默认值: "default"
  187. 示例:
  188. .. sourcecode:: html
  189. <link rel="stylesheet" href="../themes/default/default.css" />
  190. <link rel="stylesheet" href="../themes/simple/simple.css" />
  191. <script charset="utf-8" src="../kindeditor.js"></script>
  192. <script charset="utf-8" src="../lang/zh-CN.js"></script>
  193. <script>
  194. var editor;
  195. KindEditor.ready(function(K) {
  196. editor = K.create('#editor_id', {
  197. themeType : 'simple'
  198. });
  199. });
  200. </script>
  201. .. index:: langType
  202. .. _langType:
  203. langType
  204. --------------------------------------------------------
  205. 指定语言,可设置"en"、"zh-CN",需要引入lang/[langType].js。
  206. * 数据类型: String
  207. * 默认值: "zh-CN"
  208. 示例:
  209. .. sourcecode:: html
  210. <link rel="stylesheet" href="../themes/default/default.css" />
  211. <script charset="utf-8" src="../kindeditor.js"></script>
  212. <script charset="utf-8" src="../lang/en.js"></script>
  213. <script>
  214. var editor;
  215. KindEditor.ready(function(K) {
  216. editor = K.create('#editor_id', {
  217. langType : 'en'
  218. });
  219. });
  220. </script>
  221. .. index:: designMode
  222. .. _designMode:
  223. designMode
  224. --------------------------------------------------------
  225. 可视化模式或代码模式
  226. * 数据类型: Boolean
  227. * 默认值: true
  228. .. index:: fullscreenMode
  229. .. _fullscreenMode:
  230. fullscreenMode
  231. --------------------------------------------------------
  232. true时加载编辑器后变成全屏模式。
  233. * 数据类型: Boolean
  234. * 默认值: false
  235. .. index:: basePath
  236. .. _basePath:
  237. basePath
  238. --------------------------------------------------------
  239. 指定编辑器的根目录路径。
  240. * 数据类型: String
  241. * 默认值: 根据kindeditor.js文件名自动获取
  242. .. index:: themesPath
  243. .. _themesPath:
  244. themesPath
  245. --------------------------------------------------------
  246. 指定编辑器的themes目录路径。
  247. * 数据类型: String
  248. * 默认值: basePath + 'themes/'
  249. .. index:: pluginsPath
  250. .. _pluginsPath:
  251. pluginsPath
  252. --------------------------------------------------------
  253. 指定编辑器的plugins目录路径。
  254. * 数据类型: String
  255. * 默认值: basePath + 'plugins/'
  256. .. index:: langPath
  257. .. _langPath:
  258. langPath
  259. --------------------------------------------------------
  260. 指定编辑器的lang目录路径。
  261. * 数据类型: String
  262. * 默认值: basePath + 'lang/'
  263. .. index:: minChangeSize
  264. .. _minChangeSize:
  265. minChangeSize
  266. --------------------------------------------------------
  267. undo/redo文字输入最小变化长度,当输入的文字变化小于这个长度时不会添加到undo记录里。
  268. * 数据类型: String
  269. * 默认值: 5
  270. .. index:: urlType
  271. .. _urlType:
  272. urlType
  273. --------------------------------------------------------
  274. 改变站内本地URL,可设置""、"relative"、"absolute"、"domain"。空为不修改URL,relative为相对路径,absolute为绝对路径,domain为带域名的绝对路径。
  275. * 数据类型: String
  276. * 默认值: ""
  277. .. index:: newlineTag
  278. .. _newlineTag:
  279. newlineTag
  280. --------------------------------------------------------
  281. 设置回车换行标签,可设置"p"、"br"。
  282. * 数据类型: String
  283. * 默认值: "p"
  284. .. index:: pasteType
  285. .. _pasteType:
  286. pasteType
  287. --------------------------------------------------------
  288. 设置粘贴类型,0:禁止粘贴, 1:纯文本粘贴, 2:HTML粘贴
  289. * 数据类型: Int
  290. * 默认值: 2
  291. .. index:: dialogAlignType
  292. .. _dialogAlignType:
  293. dialogAlignType
  294. --------------------------------------------------------
  295. 设置弹出框(dialog)的对齐类型,可设置""、"page",指定page时按当前页面居中,指定空时按编辑器居中。
  296. * 数据类型: String
  297. * 默认值: "page"
  298. .. index:: shadowMode
  299. .. _shadowMode:
  300. shadowMode
  301. --------------------------------------------------------
  302. true时弹出层(dialog)显示阴影。
  303. * 数据类型: Boolean
  304. * 默认值: true
  305. .. index:: zIndex
  306. .. _zIndex:
  307. zIndex
  308. --------------------------------------------------------
  309. 指定弹出层的基准z-index。
  310. * 数据类型: Int
  311. * 默认值: 811213
  312. .. index:: useContextmenu
  313. .. _useContextmenu:
  314. useContextmenu
  315. --------------------------------------------------------
  316. true时使用右键菜单,false时屏蔽右键菜单。
  317. * 数据类型: Boolean
  318. * 默认值: true
  319. .. index:: syncType
  320. .. _syncType:
  321. syncType
  322. --------------------------------------------------------
  323. 同步数据的方式,可设置""、"form",值为form时提交form时自动同步,空时不会自动同步。
  324. * 数据类型: String
  325. * 默认值: "form"
  326. .. index:: indentChar
  327. .. _indentChar:
  328. indentChar
  329. --------------------------------------------------------
  330. :ref:`wellFormatMode` 为true时,HTML代码缩进字符。
  331. * 数据类型: String
  332. * 默认值: "\\t"
  333. .. index:: cssPath
  334. .. _cssPath:
  335. cssPath
  336. --------------------------------------------------------
  337. 指定编辑器iframe document的CSS文件,用于设置可视化区域的样式。
  338. * 数据类型: String或Array
  339. * 默认值: 空
  340. .. index:: cssData
  341. .. _cssData:
  342. cssData
  343. --------------------------------------------------------
  344. 指定编辑器iframe document的CSS数据,用于设置可视化区域的样式。
  345. * 数据类型: String
  346. * 默认值: 空
  347. .. index:: bodyClass
  348. .. _bodyClass:
  349. bodyClass
  350. --------------------------------------------------------
  351. 指定编辑器iframe document body的className。
  352. * 数据类型: String
  353. * 默认值: "ke-content"
  354. .. index:: colorTable
  355. .. _colorTable:
  356. colorTable
  357. --------------------------------------------------------
  358. 指定取色器里的颜色。
  359. * 数据类型: Array
  360. * 默认值:
  361. .. sourcecode:: js
  362. [
  363. ['#E53333', '#E56600', '#FF9900', '#64451D', '#DFC5A4', '#FFE500'],
  364. ['#009900', '#006600', '#99BB00', '#B8D100', '#60D978', '#00D5FF'],
  365. ['#337FE5', '#003399', '#4C33E5', '#9933E5', '#CC33E5', '#EE33EE'],
  366. ['#FFFFFF', '#CCCCCC', '#999999', '#666666', '#333333', '#000000']
  367. ]
  368. .. index:: afterCreate
  369. .. _afterCreate:
  370. afterCreate
  371. --------------------------------------------------------
  372. 设置编辑器创建后执行的回调函数。
  373. * 数据类型: Function
  374. * 默认值: 无
  375. .. index:: afterChange
  376. .. _afterChange:
  377. afterChange
  378. --------------------------------------------------------
  379. 编辑器内容发生变化后执行的回调函数。
  380. * 数据类型: Function
  381. * 默认值: 无
  382. .. index:: afterTab
  383. .. _afterTab:
  384. afterTab
  385. --------------------------------------------------------
  386. 按下TAB键后执行的的回调函数。
  387. * 数据类型: Function
  388. * 默认值: 插入4个空格的函数
  389. .. index:: afterFocus
  390. .. _afterFocus:
  391. afterFocus
  392. --------------------------------------------------------
  393. 编辑器聚焦(focus)时执行的回调函数。
  394. * 数据类型: Function
  395. * 默认值: 无
  396. .. index:: afterBlur
  397. .. _afterBlur:
  398. afterBlur
  399. --------------------------------------------------------
  400. 编辑器失去焦点(blur)时执行的回调函数。
  401. * 数据类型: Function
  402. * 默认值: 无
  403. .. index:: afterUpload
  404. .. _afterUpload:
  405. afterUpload
  406. --------------------------------------------------------
  407. 上传文件后执行的回调函数。
  408. * 数据类型: Function
  409. * 默认值: 无
  410. .. sourcecode:: js
  411. KindEditor.ready(function(K) {
  412. K.create('#id', {
  413. afterUpload : function(url) {
  414. alert(url);
  415. }
  416. });
  417. });
  418. .. index:: uploadJson
  419. .. _uploadJson:
  420. uploadJson
  421. --------------------------------------------------------
  422. 指定上传文件的服务器端程序。
  423. * 数据类型: String
  424. * 默认值: basePath + 'php/upload_json.php'
  425. .. index:: fileManagerJson
  426. .. _fileManagerJson:
  427. fileManagerJson
  428. --------------------------------------------------------
  429. 指定浏览远程图片的服务器端程序。
  430. * 数据类型: String
  431. * 默认值: basePath + 'php/file_manager_json.php'
  432. .. index:: allowPreviewEmoticons
  433. .. _allowPreviewEmoticons:
  434. allowPreviewEmoticons
  435. --------------------------------------------------------
  436. true时鼠标放在表情上可以预览表情。
  437. * 数据类型: Boolean
  438. * 默认值: true
  439. .. index:: allowImageUpload
  440. .. _allowImageUpload:
  441. allowImageUpload
  442. --------------------------------------------------------
  443. true时显示图片上传按钮。
  444. * 数据类型: Boolean
  445. * 默认值: true
  446. .. index:: allowFlashUpload
  447. .. _allowFlashUpload:
  448. allowFlashUpload
  449. --------------------------------------------------------
  450. true时显示Flash上传按钮。
  451. * 数据类型: Boolean
  452. * 默认值: true
  453. .. index:: allowMediaUpload
  454. .. _allowMediaUpload:
  455. allowMediaUpload
  456. --------------------------------------------------------
  457. true时显示视音频上传按钮。
  458. * 数据类型: Boolean
  459. * 默认值: true
  460. .. index:: allowFileUpload
  461. .. _allowFileUpload:
  462. allowFileUpload
  463. --------------------------------------------------------
  464. true时显示文件上传按钮。
  465. * 数据类型: Boolean
  466. * 默认值: true
  467. .. note::
  468. 4.0.6版本开始支持。
  469. .. index:: allowFileManager
  470. .. _allowFileManager:
  471. allowFileManager
  472. --------------------------------------------------------
  473. true时显示浏览远程服务器按钮。
  474. * 数据类型: Boolean
  475. * 默认值: false
  476. .. index:: fontSizeTable
  477. .. _fontSizeTable:
  478. fontSizeTable
  479. --------------------------------------------------------
  480. 指定文字大小。
  481. * 数据类型: Array
  482. * 默认值:
  483. .. sourcecode:: js
  484. ['9px', '10px', '12px', '14px', '16px', '18px', '24px', '32px']
  485. .. index:: imageTabIndex
  486. .. _imageTabIndex:
  487. imageTabIndex
  488. --------------------------------------------------------
  489. 图片弹出层的默认显示标签索引。
  490. * 数据类型: Int
  491. * 默认值: 0
  492. .. note::
  493. 4.0.6版本开始支持。
  494. .. index:: formatUploadUrl
  495. .. _formatUploadUrl:
  496. formatUploadUrl
  497. --------------------------------------------------------
  498. false时不会自动格式化上传后的URL。
  499. * 数据类型: Boolean
  500. * 默认值: true
  501. .. note::
  502. 4.1版本开始支持。
  503. .. index:: fullscreenShortcut
  504. .. _fullscreenShortcut:
  505. fullscreenShortcut
  506. --------------------------------------------------------
  507. false时禁用ESC全屏快捷键。
  508. * 数据类型: Boolean
  509. * 默认值: false
  510. .. note::
  511. 4.1版本开始支持,从4.1.2版本开始默认值为false。
  512. .. index:: extraFileUploadParams
  513. .. _extraFileUploadParams:
  514. extraFileUploadParams
  515. --------------------------------------------------------
  516. 上传图片、Flash、视音频、文件时,支持添加别的参数一并传到服务器。
  517. * 数据类型: Array
  518. * 默认值: {}
  519. .. sourcecode:: js
  520. KindEditor.ready(function(K) {
  521. K.create('#id', {
  522. extraFileUploadParams : {
  523. item_id : 1000,
  524. category_id : 1
  525. }
  526. });
  527. });
  528. .. note::
  529. 4.1.1版本开始支持。
  530. .. index:: filePostName
  531. .. _filePostName:
  532. filePostName
  533. --------------------------------------------------------
  534. 指定上传文件form名称。
  535. * 数据类型: String
  536. * 默认值: imgFile
  537. .. note::
  538. 4.1.2版本开始支持。
  539. .. index:: fillDescAfterUploadImage
  540. .. _fillDescAfterUploadImage:
  541. fillDescAfterUploadImage
  542. --------------------------------------------------------
  543. true时图片上传成功后切换到图片编辑标签,false时插入图片后关闭弹出框。
  544. * 数据类型: Boolean
  545. * 默认值: false
  546. .. note::
  547. 4.1.2版本开始支持。
  548. .. index:: afterSelectFile
  549. .. _afterSelectFile:
  550. afterSelectFile
  551. --------------------------------------------------------
  552. 从图片空间选择文件后执行的回调函数。
  553. * 数据类型: Function
  554. * 默认值: 无
  555. .. note::
  556. 4.1.2版本开始支持。
  557. .. index:: pagebreakHtml
  558. .. _pagebreakHtml:
  559. pagebreakHtml
  560. --------------------------------------------------------
  561. 可指定分页符HTML。
  562. * 数据类型: String
  563. * 默认值: `<hr style="page-break-after: always;" class="ke-pagebreak" />`
  564. .. note::
  565. 4.1.3版本开始支持。
  566. .. index:: allowImageRemote
  567. .. _allowImageRemote:
  568. allowImageRemote
  569. --------------------------------------------------------
  570. true时显示网络图片标签,false时不显示。
  571. * 数据类型: Boolean
  572. * 默认值: true
  573. .. note::
  574. 4.1.6版本开始支持。
  575. .. index:: autoHeightMode
  576. .. _autoHeightMode:
  577. autoHeightMode
  578. --------------------------------------------------------
  579. 值为true,并引入autoheight.js插件时自动调整高度。
  580. * 数据类型: Boolean
  581. * 默认值: false
  582. .. note::
  583. 4.1.8版本开始支持。
  584. .. index:: fixToolBar
  585. .. _fixToolBar:
  586. fixToolBar
  587. --------------------------------------------------------
  588. 值为true,并引入fixtoolbar.js插件时固定工具栏位置。
  589. * 数据类型: Boolean
  590. * 默认值: false