Skip to content

Commit

Permalink
🐛 fix #260
Browse files Browse the repository at this point in the history
  • Loading branch information
Vanessa219 committed Apr 2, 2020
1 parent 4c337b5 commit 2b7880a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@

### v3.0.8 / 2020-04-0x


* [260](https://github.com/Vanessa219/vditor/issues/260) Not working typewritermode at code block `修复缺陷`

### v3.0.7 / 2020-04-01

Expand Down
5 changes: 4 additions & 1 deletion src/ts/util/selection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,10 @@ export const getCursorPosition = (editor: HTMLElement) => {
// markdown 模式回车
cursorRect = children[range.startOffset].getClientRects()[0];
} else {
cursorRect = (range.startContainer as HTMLElement).getClientRects()[0]; // <td></td>
// in table or code block
range.selectNode(range.startContainer.childNodes[Math.max(0, range.startOffset - 1)])
cursorRect = range.getClientRects()[0];
range.collapse(false);
}
if (!cursorRect) {
let parentElement = range.startContainer.childNodes[range.startOffset] as HTMLElement;
Expand Down

0 comments on commit 2b7880a

Please sign in to comment.