关于kindeditor编辑器中一键排版问题!请求高手 30
kindeditor编辑器中一键排版默认的是加了<pstyle="text-indent:2em;"></p>标记我现在想做个一键排版让字体为14px宋体2倍行距,把这个...
kindeditor 编辑器中一键排版默认的是加了 <p style="text-indent:2em;"></p> 标记
我现在想做个一键排版 让字体为14px 宋体 2倍行距, 把这个加进去,由于代码是 JS脚本,不会写 所以请求高手!
kindEditor.plugin('quickformat', function(K) {
var self = this, name = 'quickformat',
blockMap = K.toMap('blockquote,center,div,h1,h2,h3,h4,h5,h6,p');
function getFirstChild(knode) {
var child = knode.first();
while (child && child.first()) {
child = child.first();
}
return child;
}
self.clickToolbar(name, function() {
self.focus();
var doc = self.edit.doc,
range = self.cmd.range,
child = K(doc.body).first(), next,
nodeList = [], subList = [],
bookmark = range.createBookmark(true);
while(child) {
next = child.next();
var firstChild = getFirstChild(child);
if (!firstChild || firstChild.name != 'img') {
if (blockMap[child.name]) {
child.html(child.html().replace(/^(\s| | )+/ig, ''));
child.css('text-indent', '2em');
} else {
subList.push(child);
}
if (!next || (blockMap[next.name] || blockMap[child.name] && !blockMap[next.name])) {
if (subList.length > 0) {
nodeList.push(subList);
}
subList = [];
}
}
child = next;
}
K.each(nodeList, function(i, subList) {
var wrapper = K('<p style="text-indent:2em></p>', doc);
subList[0].before(wrapper);
K.each(subList, function(i, knode) {
wrapper.append(knode);
});
});
range.moveToBookmark(bookmark);
self.addBookmark();
});
}); 展开
我现在想做个一键排版 让字体为14px 宋体 2倍行距, 把这个加进去,由于代码是 JS脚本,不会写 所以请求高手!
kindEditor.plugin('quickformat', function(K) {
var self = this, name = 'quickformat',
blockMap = K.toMap('blockquote,center,div,h1,h2,h3,h4,h5,h6,p');
function getFirstChild(knode) {
var child = knode.first();
while (child && child.first()) {
child = child.first();
}
return child;
}
self.clickToolbar(name, function() {
self.focus();
var doc = self.edit.doc,
range = self.cmd.range,
child = K(doc.body).first(), next,
nodeList = [], subList = [],
bookmark = range.createBookmark(true);
while(child) {
next = child.next();
var firstChild = getFirstChild(child);
if (!firstChild || firstChild.name != 'img') {
if (blockMap[child.name]) {
child.html(child.html().replace(/^(\s| | )+/ig, ''));
child.css('text-indent', '2em');
} else {
subList.push(child);
}
if (!next || (blockMap[next.name] || blockMap[child.name] && !blockMap[next.name])) {
if (subList.length > 0) {
nodeList.push(subList);
}
subList = [];
}
}
child = next;
}
K.each(nodeList, function(i, subList) {
var wrapper = K('<p style="text-indent:2em></p>', doc);
subList[0].before(wrapper);
K.each(subList, function(i, knode) {
wrapper.append(knode);
});
});
range.moveToBookmark(bookmark);
self.addBookmark();
});
}); 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询