富文本编辑器 列表多级缩进

https://github.com/leanote/desktop-app/issues/68
This commit is contained in:
life
2015-10-19 13:59:07 +08:00
parent b245074642
commit ed35f95c05
2 changed files with 9 additions and 8 deletions

View File

@@ -365,26 +365,27 @@ tinymce.PluginManager.add('leanote_code', function(editor, url) {
var num = e.which ? e.which : e.keyCode;
if (num == 9) { // tab pressed
if(!e.shiftKey) {
// ed.execCommand('Indent');
// TODO 如果当前在li, ul, ol下不执行!!
// 如果在pre下就加tab
// var node = ed.selection.getNode();
/*
if(node.nodeName == "PRE") {
ed.execCommand('mceInsertHTML', false, '\x09'); // inserts tab
} else {
*/
// 如果是在li下的, 就不要控制
var node = ed.selection.getNode();
if (node && (node.nodeName == 'LI' || $(node.closest('li')).length > 0)) {
return true;
}
ed.insertContent("    ");
e.preventDefault();
e.stopPropagation();
return false;
// ed.execCommand('mceInsertHTML', false, "    "); // inserts 空格
// }
} else {
// delete 4 个空格
// ed.execCommand('Outdent');
}
e.preventDefault();
e.stopPropagation();
return false;
}
});
});