Skip to content

Commit

Permalink
#66 1
Browse files Browse the repository at this point in the history
  • Loading branch information
Vanessa219 committed Jan 20, 2020
1 parent efb08d4 commit b153714
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 deletions.
9 changes: 8 additions & 1 deletion src/ts/wysiwyg/highlightToolbar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,11 +184,18 @@ export const highlightToolbar = (vditor: IVditor) => {
rowHTML += "<td></td>";
}
for (let l = 0; l < rowDiff; l++) {
tableElement.querySelector("tbody").insertAdjacentHTML("beforeend", rowHTML);
if (tableElement.querySelector("tbody")) {
tableElement.querySelector("tbody").insertAdjacentHTML("beforeend", rowHTML);
} else {
tableElement.querySelector("thead").insertAdjacentHTML("afterend", rowHTML + "</tr>");
}
}
} else {
for (let m = oldRow - 1; m >= row; m--) {
tableElement.rows[m].remove();
if (tableElement.rows.length === 1) {
tableElement.querySelector("tbody").remove();
}
}
}
}
Expand Down
16 changes: 8 additions & 8 deletions src/ts/wysiwyg/processKeydown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,21 +160,21 @@ export const tabKey = (vditor: IVditor, event: KeyboardEvent) => {
const cellElement = hasClosestByMatchTag(range.startContainer, "TD")
|| hasClosestByMatchTag(range.startContainer, "TH");
if (cellElement) {
let nextElement = cellElement.nextElementSibling
let nextElement = cellElement.nextElementSibling;
if (!nextElement) {
if (cellElement.parentElement.nextElementSibling) {
nextElement = cellElement.parentElement.nextElementSibling.firstElementChild
} else if (cellElement.parentElement.parentElement.tagName === 'THEAD'
&& cellElement.parentElement.parentElement.nextElementSibling) {
nextElement = cellElement.parentElement.nextElementSibling.firstElementChild;
} else if (cellElement.parentElement.parentElement.tagName === "THEAD" &&
cellElement.parentElement.parentElement.nextElementSibling) {
nextElement =
cellElement.parentElement.parentElement.nextElementSibling.firstElementChild.firstElementChild
cellElement.parentElement.parentElement.nextElementSibling.firstElementChild.firstElementChild;
} else {
nextElement = null
nextElement = null;
}
}
if (nextElement) {
range.selectNodeContents(nextElement)
range.collapse(true)
range.selectNodeContents(nextElement);
range.collapse(true);
afterRenderEvent(vditor);
}
return;
Expand Down

0 comments on commit b153714

Please sign in to comment.