Contents
.. index:: cmd
创建KCmd对象,KCmd用于操作可视化编辑区域的DOM。
示例:
var cmd = K.cmd(document);
cmd.bold();
cmd.wrap('<span style="color:red;"></span>');
cmd.remove({
span : '*',
div : 'class,border'
});
.. index:: doc
document对象。
.. index:: win
window对象。
.. index:: sel
原生selection对象。
.. index:: range
KRange对象 ( :doc:`range` )
.. index:: selection
根据当前选中状态,重新设置range。
示例:
cmd.selection();
.. index:: select
选中range。
示例:
cmd.select();
.. index:: wrap
用指定element围住range。
示例:
cmd.wrap('<strong></strong>');
.. index:: split
根据map规则分割range的开始位置或结束位置。
示例:
cmd.split(true, {
span : '*',
div : 'class,border'
});
.. index:: remove
根据map规则删除range中的element或attribute。
示例:
cmd.remove({
span : '*',
div : 'class,border'
});
.. index:: commonAncestor
根据map规则取得range的共同祖先。
示例:
var knode = cmd.commonAncestor('table');
.. index:: state
Determines whether the given command has been executed on the current selection.
Note
Reference: https://developer.mozilla.org/en/Midas
示例:
bool = cmd.state('bold');
.. index:: val
Determines the current value of the document, range, or current selection for the given command.
示例:
fontSize = cmd.val('fontsize');
Note
目前只支持以下命令: * fontfamily (fontname) * formatblock * forecolor * hilitecolor
.. index:: bold
粗体
.. index:: italic
斜体
.. index:: underline
下划线
.. index:: strikethrough
删除线
.. index:: forecolor
文字颜色
.. index:: hilitecolor
文字背景
.. index:: fontsize
文字大小
.. index:: fontfamily
字体
.. index:: fontname
字体, :ref:`KCmd.fontfamily` 的别名。
.. index:: removeformat
删除inline样式
.. index:: inserthtml
插入HTML
.. index:: hr
插入水平线
.. index:: print
弹出打印窗口
.. index:: insertimage
插入图片
.. index:: createlink
超级链接
.. index:: unlink
取消超级链接
.. index:: formatblock
段落
.. index:: selectall
全选
.. index:: justifyleft
左对齐
.. index:: justifycenter
居中
.. index:: justifyright
右对齐
.. index:: justifyfull
两端对齐
.. index:: insertorderedlist
编号
.. index:: insertunorderedlist
项目符号
.. index:: indent
增加缩进
.. index:: outdent
减少缩进
.. index:: subscript
下标
.. index:: superscript
上标
.. index:: cut
剪切
.. index:: copy
复制
.. index:: paste
粘贴
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。