eWebEditor首页 >> eWebEditor帮助文档 V15.2 >> 开发手册 >> JavaScript API

3.7.16 exec

描述

执行指定的按钮命令功能。使用此接口,您可以在自己的网页创建按钮,点击后功能与编辑器中某按钮的功能相同。(V8.0版新增)

语法

object.exec(s_CommandName, s_CommandValue);

参数

s_CommandName : 命令名称,字符型,可以在下面的命令名表查可用值,不区分大小写。

s_CommandValue : 命令值,可选,部分命令执行需要的参数值,如执行格式化字体时需要的字体名称。

命令表:

命令值未填表示不需要

命令名

命令值

说明

undo

 

撤销一步

redo

 

重作一步

cut

 

剪切

copy

 

拷贝

paste

 

粘贴

pastetext

 

纯文本粘贴

pasteword

 

Word粘贴

delete

 

删除

removeformat

 

清除格式

selectall

 

全选

unselect

 

取消全选

findreplace

 

查找替换

quickformat

 

一键排版 (V11.5版增加自动处理参数值,详见表后说明)

bold

 

粗体

italic

 

斜体

underline

 

下划线

strikethrough

 

中划线

superscript

 

上标

subscript

 

下标

uppercase

 

转为大写字母

lowercase

 

转为小写字母

forecolor

 

前景色

backcolor

 

背景色

big

 

字体放大

small

 

字体缩小

justifyleft

 

左对齐

justifycenter

 

居中对齐

justifyright

 

右对齐

justifyfull

 

两端对齐

orderedlist

 

有序列表

unorderedlist

 

无序列表

indent

 

缩进

outdent

 

取消缩进

br

 

插入换行符

paragraph

 

插入段落

paragraphattr

 

段落属性

textindent

可空

(V10.4版新增)
首行缩进,可指定命令参数值,也可以不指定
如命令值参数未指定,则命令在"设为2em缩进"和“取消缩进”二种状态切换;如有指定值,则按指定值设置。

lineheight

需要

(V10.4版新增)
行距,设置选区段落行距,参数格式如:
"1":
不带单位,表示1倍行距
"10px":
带单位,表示10px固定值的行距

margintop

需要

(V10.4版新增)
段前,参数格式如:"10px"

marginbottom

需要

(V10.4版新增)
段后,参数格式如:"10px"

image

 

插入或修改图片

flash

 

插入flash

media

 

插入媒体

file

 

插入附件

remoteupload

 

远程上传

localupload

 

本地上传

fieldset

 

插入栏目框

iframe

 

插入iframe框架

horizontalrule

 

插入水平尺

marquee

 

插入滚动字幕

createlink

 

创建超链接

unlink

 

删除超链接

map

 

图片热点链接

anchor

 

锚点管理

galleryimage

 

图片库

galleryflash

 

Flash

gallerymedia

 

媒体库

galleryfile

 

文件库

bgcolor

 

对象背景色

backimage

 

对象背景图片

absoluteposition

 

绝对位置

zindexbackward

 

下移一层

zindexforward

 

上移一层

showborders

 

显示虚框

showblocks

 

显示标签标记

quote

 

引用效果

code

 

代码效果

symbol

 

插入特殊符号

printbreak

 

插入打印分隔符

emot

 

插入表情图标

mathfloweq

 

公式编辑

nowdate

 

插入现在日期

nowtime

 

插入现在时间

importword

 

导入Word

importexcel

 

导入Excel

importppt

 

导入PPT

template

 

插入模板

capture

 

截屏

pagination

 

插入分页符

paginationinsert

 

分页管理

titleimage

 

设为标题图片

formtext

 

插入单行输入框

formtextarea

 

插入多行输入框

formradio

 

插入单选框

formcheckbox

 

插入多选框

formdropdown

 

插入下拉框

formbutton

 

插入按钮

tableinsert

 

插入表格

tableprop

 

表格属性

tablecellprop

 

单元格属性

tablecellsplit

 

单元格拆分

tablerowprop

 

表格行属性

tablerowinsertabove

 

在上面插入行

tablerowinsertbelow

 

在下面插入行

tablerowmerge

 

表格行合并

tablerowsplit

 

表格行拆分

tablerowdelete

 

表格行删除

tablecolinsertleft

 

左边插入列

tablecolinsertright

 

右边插入列

tablecolmerge

 

列合并

tablecolsplit

 

列拆分

tablecoldelete

 

列删除

refresh

 

刷新

modecode

 

切换到代码模式

modeedit

 

切换到编辑模式

modetext

 

切换到文本模式

modeview

 

切换到预览模式

sizeplus

 

增加编辑区

sizeminus

 

减小编辑区

print

 

打印

maximize

 

最大化,全屏

expandtoolbar

 

切换到所有功能

about

 

显示关于对话框

fontface

需要

格式化字体名称,参数字体名,如"宋体"

fontsize

需要

格式化字体大小,参数字体大小,如"16pt"

formatblock

需要

格式段落,参数为段落格式,如"h1"

zoom

需要

缩放,参数为缩放百分比,数字型,如"150",表示"150%"

 

:

这下面的方法演示了把名为“myEditor”的编辑器执行指定的命令。

myEditor.exec("paste");                //执行粘贴

myEditor.exec("fontface", "宋体");     //设置字体

myEditor.exec("fontsize", "16pt");     //设置字号

 

一键排版(quickformat) 特别参数处理:

此功能为V11.5版新增。以下参数中,如某项要按默认值处理,可以不设这项。

此功能V15.0版,参数有变更,具体参数及含义以实际使用的版本为准。

var editor = document.getElementById("eWebEditor1").contentWindow;

editor.exec("quickformat",{

   hide: true,      //隐藏一键排版处理对话框。true:隐藏,false:显示

   callback: function(bOk){      //回调,bOk表示一键排版有没有执行。true:执行了;false:没执行,取消了。

     if(bOK){

         alert("执行了");

     }else{

         alert("没执行,取消了");

     }

    },

 

   keep_all: false,         //保留所有,默认为false,此项如为true,则其它keep项设置无效,表示保留项全选中

   keep_ul: true,           //保留列表,默认为true

   keep_table: true,        //保留表格,默认为true

   keep_img: true,          //保留图片,默认为true

   keep_object: true,       //保留对象,默认为true

   keep_a: true,            //保留链接,默认为true

   keep_video: true,        //保留H5媒体,默认为true

 

   del_line: true,          //去除空行,默认为true

   del_space: true,         //去除多余空格,默认为true

   del_hidden: true,        //去除隐藏域,默认为true

   del_confusion: true,     //去除干扰字,默认为true

   del_attr_all: false,     //去除所有属性,默认为false,此项如为true,则其它del_attr项设置无效,表示去除属性类的全选中

   del_attr_style: true,    //去除样式属性,默认为true

   del_attr_event: true,    //去除事件属性,默认为true

 

   add_margin_top: true,             //增效选项,段前,true选中(默认)false不选

   add_margin_top_value: "0",        //段前值,字符型

   add_margin_bottom: true,          //段后,true选中(默认)false不选

   add_margin_bottom_value: "0",     //段后值,字符型

   add_indent: true,                 //首行缩进,true选中(默认)false不选

   add_indent_value: "2",            //首行缩进值,无单位时表示中文空格,有单位如"2em"表示CSS

   add_line_height: false,           //行距,true选中,false不选(默认)

   add_line_height_value: "1.5",     //行距值,表示1.5倍行距

   add_h2p: false,               //标题转正文,true选中,false不选(默认)

   add_justify_full: true,       //两端对齐,true选中(默认)false不选

   add_br2p: false,              //换行符转段落,true选中,false不选(默认)

 

   add_image_center: false,      //图片水平居中,true选中,false不选(默认)

   add_image_middle: false,      //图片垂直居中,true选中,false不选(默认)

   add_image_maxwidth: true,     //图片宽度自适应,true选中,false不选(默认)

 

   add_font_name: "宋体",        //字体名称,默认为空,必须是字体名称下拉框中已有的值

   add_font_size: "小四",        //字体大小,默认为空,必须是字体大小下拉框中已有的值

   add_font_gb2312: true,        //GB2312字体兼容处理,true选中(默认)false不选

  

   add_table_xcroll: true,       //表格超宽自动滚动条,true选中(默认)false不选

   add_table_border: false,      //单线边框表格,true选中,false不选(默认)

   add_table_height: false,      //自动表格高度,true选中,false不选(默认)

   add_table_align: "",          //表格对齐方式,"":不处理(默认)"default":去掉对齐,"left":左对齐,"right":右对齐,"center":居中对齐

   add_table_width: ""           //表格宽度,"":不调整(默认)"content":根据内容调整,"window_no":根据窗口调整(不调列宽)"window_content":根据窗口调整(自动列宽)"window_pingjun":根据窗口调整(平均列宽)

 

});