首页 新闻 赞助 找找看

UMeditor 添加缩进有人做过吗?

0
悬赏园豆:100 [已关闭问题] 关闭于 2018-02-26 16:40

首行缩进首行缩进首行缩进首行缩进首行缩进首行缩进首行缩进首行缩进首行缩进首行缩进

Geok的主页 Geok | 初学一级 | 园豆:119
提问于:2017-09-12 16:59
< >
分享
所有回答(3)
0

参考:http://www.zyku.net/xhtml/195.html

金琥 | 园豆:2605 (老鸟四级) | 2017-09-12 17:17
0

http://www.cnblogs.com/liuhongfeng/p/4887670.html

试试这里面的

toolbars: [
    [

        'indent', //首行缩进
    ]


]
ycyzharry | 园豆:25639 (高人七级) | 2017-09-13 10:13
0

$(".edui-icon-indents").click(function (event) {

var range = window.getSelection().getRangeAt(0);//获取所有内容
var container = range.cloneRange();//获取所有可以编辑内容
var containers = range.cloneContents();//获取不可以编辑但是已选择区域
var isnode = true;
var lan;
var arr = ["p", "h1", "h2", "h3", "h4", "h5", "h6"]; //包含标签
if (container.commonAncestorContainer.children == null) { //单个缩进
isnode = false;
lan = container.commonAncestorContainer.parentNode;
var str = lan.localName;
if ($.inArray(str, arr) == -1) {
return;
}
//缩进
//alert($(lan).css("text-indent"));
if ($(lan).css("text-indent") == "0px") {
$(lan).css("text-indent", "2em");
} else {
$(lan).css("text-indent", "0em");
}
}
else { //多个缩进或是一个选择缩进
lan = container.commonAncestorContainer;
//判断是否包含缩进标签
if (lan.localName == "div") {
//循环判断
if (lan.children.length > 0) {
for (var i = 0; i <= lan.children.length - 1; i++) {
var biaoq = container.commonAncestorContainer.children[i];
for (var s = 0; s <= containers.children.length - 1; s++) {
var biaoqs = containers.children[s];
if(biaoqs.innerText.trim() !=""){
if (biaoq.innerText == biaoqs.innerText) {
//缩进
if ($(biaoq).css("text-indent") == "0px") {
$(biaoq).css("text-indent", "2em");
} else {
$(biaoq).css("text-indent", "0em");
}
}
}
}
}
}

} else {
//缩进
var str = lan.localName;
if ($.inArray(str, arr) == -1) {
return;
}
//缩进
if ($(lan).css("text-indent") == "0px") {
$(lan).css("text-indent", "2em");
}
else {
$(lan).css("text-indent", "0em");
}
}
}
});

Geok | 园豆:119 (初学一级) | 2018-02-26 16:40
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册