提交 21f92050 编写于 作者: C Catouse

* finish task #002.

上级 a6586028
......@@ -5011,8 +5011,9 @@
if(e.which == 9) {
e.preventDefault();
if(self.afterTab) {
self.afterTab.call(self, e);
return;
var tabResult = self.afterTab.call(self, e);
// 如果 afterTab 回调函数返回值为 false,则继续执行原始 tab 操作,否则视为已经处理 tab 键操作
if (tabResult !== false) return;
}
var cmd = self.cmd,
range = cmd.range;
......
......@@ -755,6 +755,39 @@ KindEditor.plugin('table', function (K) {
$wrapperDiv.append($grid);
menu.div.append($wrapperDiv[0]);
});
// https://zui.5upm.com/task-view-2.html
self.afterTab(function() {
var range = self.cmd.range;
if (range && range.endContainer) {
var selectNextCell = function($currentCell) {
if ($currentCell.length) {
var $nextCell = $currentCell.next();
if (!$nextCell.is('td,th')) {
$nextCell = $currentCell.parent().next('tr').children('th,td').first();
}
if (!$nextCell.is('td,th')) {
$nextCell = $currentCell.closest('tbody,tfoot,thead').next().children('tr').first().children('th,td').first();
}
if ($nextCell.length) {
self.cmd.range.selectNode($nextCell[0]);
self.cmd.select();
return true;
}
}
return false;
};
var $endContainer = $(range.endContainer).closest('td,th');
if ($endContainer.length) {
if (!selectNextCell($endContainer)) {
self.plugin.table.rowinsertbelow();
selectNextCell($endContainer);
}
return true;
}
}
return false;
});
});
KindEditor.lang({
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册