commands.js 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257
  1. //本文件非编辑器核心文件,仅适用于生成对应的命令接口文档
  2. /**
  3. * @file
  4. * @name 编辑器命令接口
  5. * @short Commands
  6. * @desc
  7. *
  8. * UEditor中执行命令的统一调用格式为
  9. * <code>editor.execCommand("cmdName"[,opt]);</code>
  10. *
  11. *
  12. * 检测当前命令是否可用的方法是
  13. * <code>editor.queryCommandState("cmdName");</code>
  14. *
  15. *
  16. * 部分命令可以返回命令值,其格式为
  17. * <code>editor.queryCommandValue("cmdName");</code>
  18. */
  19. /**
  20. * 插入锚点
  21. * @name anchor
  22. * @grammar editor.execCommand("anchor","name"); //锚点的名字
  23. */
  24. /**
  25. * 为当前选中文字添加粗体效果
  26. * @name bold
  27. * @grammar editor.execCommand("bold");
  28. */
  29. /**
  30. * 为当前选中文字添加斜体效果
  31. * @name italic
  32. * @grammar editor.execCommand("italic");
  33. */
  34. /**
  35. * 为当前选中文字添加下划线效果
  36. * @name underline
  37. * @grammar editor.execCommand("underline");
  38. */
  39. /**
  40. * 为当前选中文字添加删除线效果
  41. * @name strikethrough
  42. * @grammar editor.execCommand("strikethrough");
  43. */
  44. /**
  45. * 将当前选中文字转换成上标
  46. * @name superscript
  47. * @grammar editor.execCommand("superscript");
  48. */
  49. /**
  50. * 将当前选中文字转换成下标
  51. * @name subscript
  52. * @grammar editor.execCommand("subscript");
  53. */
  54. /**
  55. * 为当前选中文字添加颜色
  56. * @name foreColor
  57. * @grammar editor.execCommand("foreColor","#ffffff");
  58. */
  59. /**
  60. * 为当前选中文字添加背景颜色
  61. * @name backColor
  62. * @grammar editor.execCommand("backColor","#dddddd");
  63. */
  64. /**
  65. * 设置当前选中文字的字体
  66. * @name fontFamily
  67. * @grammar editor.execCommand("fontFamily","微软雅黑,Microsoft YaHei");
  68. */
  69. /**
  70. * 设置当前选中文字的字号
  71. * @name fontSize
  72. * @grammar editor.execCommand("fontSize","32px");
  73. */
  74. /**
  75. * 设置当前选区的段落格式,如p,h1,h2,h3,...
  76. * @name paragraph
  77. * @grammar editor.execCommand("paragraph","h1");
  78. */
  79. /**
  80. * 将当前选区变换成有序或者无序列表
  81. * @name insert(Un)OrderedList
  82. * @grammar editor.execCommand("insertOrderedList");
  83. */
  84. /**
  85. * 设置当前选区的行间距
  86. * @name lineHeight
  87. * @grammar editor.execCommand("lineHeight");
  88. */
  89. /**
  90. * 设置当前选区中的字体对齐方式
  91. * @name justify
  92. * @grammar editor.execCommand("justify",align); //align可为Left,Right,Center,Justify
  93. */
  94. /**
  95. * 将当前选中文字中的字母转换成大写
  96. * @name toUppercase
  97. * @grammar editor.execCommand("toUppercase");
  98. */
  99. /**
  100. * 将当前选中文字中的字母转换成小写
  101. * @name toLowercase
  102. * @grammar editor.execCommand("toLowercase");
  103. */
  104. /**
  105. * 为当前选区所在的块级元素添加引用标记
  106. * @name blockquote
  107. * @grammar editor.execCommand("blockquote");
  108. */
  109. /**
  110. * 设置当前选区所在块级元素的文字输入方向
  111. * @name directionality
  112. * @grammar editor.execCommand("directionality",dir); //dir可为LTR,RTL
  113. */
  114. /**
  115. * 清除当前选中文字上的所有样式或者指定样式
  116. * @name removeFormat
  117. * @grammar editor.execCommand("removeFormat") //根据editor_config.js里的removeFormatTags,removeFormatAttributes两个属性作为规则
  118. * @grammar editor.execCommand("removeFormat",tags,style); //清除指定tags上的指定style
  119. * @example
  120. * editor.execCommand("removeFormat",'span,a','color,background-color')
  121. */
  122. /**
  123. * 切换纯文本粘贴模式
  124. * @name pastePlain
  125. * @grammar ue.execCommand("pastePlain");
  126. */
  127. /**
  128. * 开启格式刷功能
  129. * @name formatMatch
  130. * @grammar editor.execCommand("formatMatch");
  131. */
  132. /**
  133. * 清空文档
  134. * @name clearDoc
  135. * @grammar editor.execCommand("clearDoc");
  136. */
  137. /**
  138. * 删除当前选中文本
  139. * @name delete
  140. * @grammar editor.execCommand("delete");
  141. */
  142. /**
  143. * 全部选择
  144. * @name selectAll
  145. * @grammar editor.execCommand("selectAll");
  146. */
  147. /**
  148. * 撤销操作
  149. * @name undo
  150. * @grammar editor.execCommand("undo");
  151. */
  152. /**
  153. * 恢复操作
  154. * @name redo
  155. * @grammar editor.execCommand("redo");
  156. */
  157. /**
  158. * 对整个编辑文档进行自动排版
  159. * @name autoTypeset
  160. * @grammar editor.execCommand("autoTypeset");
  161. */
  162. /**
  163. * 在当前选区位置插入一段html代码,最基本功能。大部分其他插入命令都会调用此命令完成最后的插入
  164. * @name insertHtml
  165. * @grammar editor.execCommand("insertHtml","欢迎使用UEditor!")
  166. */
  167. /**
  168. * 在当前选区位置插入一个超链接
  169. * @name link
  170. * @grammar editor.execCommand("link",linkObj);
  171. * @example
  172. * editor.execCommand("link",{
  173. * href: "http://ueditor.baidu.com", //超链地址,必选
  174. * data_ue_src: "http://ueditor.baidu.com", //UE内部使用参数,与href保持一致即可,可选
  175. * target: "_self", //目标窗口,可选
  176. * textValue: "UEditor", //链接显示文本,可选
  177. * title: "百度开源富文本编辑器UEditor官网" //标题,可选
  178. * })
  179. */
  180. /**
  181. * 在当前选区位置插入一个图片
  182. * @name insertImage
  183. * @grammar editor.execCommand("insertImage",imageObj);
  184. * @example
  185. * editor.execCommand("insertImage",{
  186. * src: "http://ueditor.baidu.com/logo.jpg", //图片链接地址,必选
  187. * data_ue_src: "http://ueditor.baidu.com/logo.jpg", //UE内部使用参数,与src保持一致即可,可选
  188. * width: 300, //图片显示宽度,可选
  189. * height: 400, //图片显示高度,可选
  190. * border: 2, //图片边框,可选
  191. * hspace: 5, //图片左右边距,可选
  192. * vspace: 2, //图片上下边距,可选
  193. * alt: 'UEditor-logo', //图片替换文字,可选
  194. * title: "百度开源富文本编辑器UEditor官网" //图片标题,可选
  195. * })
  196. */
  197. /**
  198. * 在当前选区位置插入一个视频
  199. * @name insertVideo
  200. * @grammar editor.execCommand("insertVideo",videoObj);
  201. * @example
  202. * editor.execCommand("insertVideo",{
  203. * url: "http://youku.com/id?id=1233122", //视频地址,必选
  204. * width: 420, //视频宽度,可选
  205. * height: 280, //视频高度,可选
  206. * align: "none" //对齐方式,支持right,left,center,none ,可选
  207. * })
  208. */
  209. /**
  210. * 在当前选区位置插入一个日期或者时间
  211. * @name date|time
  212. * @grammar editor.execCommand("date");
  213. */
  214. /**
  215. * 在当前选区位置插入一个分页符标记
  216. * @name pageBreak
  217. * @grammar editor.execCommand("pageBreak");
  218. */
  219. /**
  220. * 切换源码编辑模式和富文本编辑模式
  221. * @name source
  222. * @grammar editor.execCommand("source");
  223. */
  224. /**
  225. * IE下进入截屏模式
  226. * @name snapScreen
  227. * @grammar editor.execCommand("snapScreen");
  228. */
  229. /**
  230. * 插入表格
  231. * @name insertTable
  232. * @grammar editor.execCommand("insertTable",rows,cols);
  233. */
  234. /**
  235. * 查找替换
  236. * @name searchreplace
  237. * @grammar editor.execCommand("searchreplace",opt);
  238. * @desc
  239. * opt是个json对象,属性如下
  240. * * ''all'' true表示查找整个文档,false表示从上次的位置开始查找,默认是false
  241. * * ''casesensitive'' 大小写铭感,true是铭感,默认是false
  242. * * ''dir'' 1表示从前往后查,-1表示从后往前
  243. * * ''searchStr'' 查找的字符串
  244. * * ''replaceStr'' 替换用的字符串
  245. */