只读模式
group, 分享
评论更多问题
博客标签总是存在一个
This commit is contained in:
lealife
2015-06-15 18:01:48 +08:00
parent 7e458bb433
commit 6987a38820
1453 changed files with 114561 additions and 91536 deletions

39
public/tinymce/plugins/table/classes/Quirks.js Normal file → Executable file
View File

@ -106,7 +106,7 @@ define("tinymce/tableplugin/Quirks", [
}
function getChildForDirection(parent, up) {
var child = parent && parent[up ? 'lastChild' : 'firstChild'];
var child = parent && parent[up ? 'lastChild' : 'firstChild'];
// BR is not a valid table child to return in this case we return the table cell
return child && child.nodeName === 'BR' ? editor.dom.getParent(child, 'td,th') : child;
}
@ -237,7 +237,7 @@ define("tinymce/tableplugin/Quirks", [
if (last.nodeValue.length > 0) {
break;
}
} else if (last.nodeType == 1 && !last.getAttribute('data-mce-bogus')) {
} else if (last.nodeType == 1 && (last.tagName == 'BR' || !last.getAttribute('data-mce-bogus'))) {
break;
}
}
@ -281,7 +281,7 @@ define("tinymce/tableplugin/Quirks", [
tableParent = table.parentNode;
}
allOfCellSelected =rng.startContainer.nodeType == TEXT_NODE &&
allOfCellSelected = rng.startContainer.nodeType == TEXT_NODE &&
rng.startOffset === 0 &&
rng.endOffset === 0 &&
currentCell &&
@ -302,7 +302,7 @@ define("tinymce/tableplugin/Quirks", [
}
if (!currentCell) {
currentCell=n;
currentCell = n;
}
// Get the very last node inside the table cell
@ -312,8 +312,10 @@ define("tinymce/tableplugin/Quirks", [
}
// Select the entire table cell. Nothing outside of the table cell should be selected.
rng.setEnd(end, end.nodeValue.length);
editor.selection.setRng(rng);
if (end.nodeType == 3) {
rng.setEnd(end, end.data.length);
editor.selection.setRng(rng);
}
}
editor.on('KeyDown', function() {
@ -327,6 +329,31 @@ define("tinymce/tableplugin/Quirks", [
});
}
/**
* Delete table if all cells are selected.
*/
function deleteTable() {
editor.on('keydown', function(e) {
if ((e.keyCode == VK.DELETE || e.keyCode == VK.BACKSPACE) && !e.isDefaultPrevented()) {
var table = editor.dom.getParent(editor.selection.getStart(), 'table');
if (table) {
var cells = editor.dom.select('td,th', table), i = cells.length;
while (i--) {
if (!editor.dom.hasClass(cells[i], 'mce-item-selected')) {
return;
}
}
e.preventDefault();
editor.execCommand('mceTableDelete');
}
}
});
}
deleteTable();
if (Env.webkit) {
moveWebKitSelection();
fixTableCellSelection();