Skip to content

Commit

Permalink
#66 3
Browse files Browse the repository at this point in the history
  • Loading branch information
Vanessa219 committed Jan 20, 2020
1 parent b153714 commit ddfb140
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion src/ts/wysiwyg/processKeydown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,31 @@ export const deleteKey = (vditor: IVditor, event: KeyboardEvent) => {
event.preventDefault();
return;
}

// table
const cellElement = hasClosestByMatchTag(range.startContainer, "TD")
|| hasClosestByMatchTag(range.startContainer, "TH");
if (cellElement && range.startOffset === 0) {

let previousElement = cellElement.previousElementSibling;
if (!previousElement) {
if (cellElement.parentElement.previousElementSibling) {
previousElement = cellElement.parentElement.previousElementSibling.lastElementChild;
} else if (cellElement.parentElement.parentElement.tagName === "TBODY" &&
cellElement.parentElement.parentElement.previousElementSibling) {
previousElement =
cellElement.parentElement.parentElement.previousElementSibling.lastElementChild.lastElementChild;
} else {
previousElement = null;
}
}
if (previousElement) {
range.selectNodeContents(previousElement);
range.collapse(false);
}
event.preventDefault();
return;
}
};

export const tabKey = (vditor: IVditor, event: KeyboardEvent) => {
Expand Down Expand Up @@ -175,7 +200,6 @@ export const tabKey = (vditor: IVditor, event: KeyboardEvent) => {
if (nextElement) {
range.selectNodeContents(nextElement);
range.collapse(true);
afterRenderEvent(vditor);
}
return;
}
Expand Down

0 comments on commit ddfb140

Please sign in to comment.