Skip to content

Commit

Permalink
🐛 fix #13
Browse files Browse the repository at this point in the history
  • Loading branch information
Vanessa219 committed Dec 8, 2019
1 parent 90a2b73 commit 619ae5e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,9 @@
* [3](https://github.com/Vanessa219/vditor/issues/3) 编辑预览同步滚动改进 `enhancement`
* [4](https://github.com/Vanessa219/vditor/issues/4) 添加支持思维导图的功能 `enhancement`

### v1.10.6 / 2019-12-04
### v1.10.6 / 2019-12-08

* [13](https://github.com/Vanessa219/vditor/issues/13) 编辑到最底部时,回车不会滚动到最下面 `bug`
* [12](https://github.com/Vanessa219/vditor/issues/12) 代码渲染问题,抛出KaTeX的错误信息。 `question`
* [11](https://github.com/Vanessa219/vditor/issues/11) 添加 CDN 配置 `enhancement`
* [10](https://github.com/Vanessa219/vditor/issues/10) block code 拷贝后变为 inline code `bug`
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vditor",
"version": "1.10.5",
"version": "1.10.6",
"cdn": "https://cdn.jsdelivr.net/npm",
"description": "A markdown editor written in TypeScript",
"author": " Vanessa <[email protected]> (http://vanessa.b3log.org)",
Expand Down
8 changes: 7 additions & 1 deletion src/ts/hint/getCursorPosition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,13 @@ export const getCursorPosition = (editor: HTMLElement) => {
const range = window.getSelection().getRangeAt(0);
let cursorRect;
if (range.getClientRects().length === 0) {
cursorRect = (range.startContainer as HTMLElement).getClientRects()[0]; // <td></td>
if (range.startContainer.childNodes[range.startOffset] &&
(range.startContainer.childNodes[range.startOffset] as HTMLElement).getClientRects().length > 0) {
// markdown 模式回车
cursorRect = (range.startContainer.childNodes[range.startOffset] as HTMLElement).getClientRects()[0];
} else {
cursorRect = (range.startContainer as HTMLElement).getClientRects()[0]; // <td></td>
}
if (!cursorRect) {
let parentElement = range.startContainer.childNodes[range.startOffset] as HTMLElement;
while (!parentElement.getClientRects ||
Expand Down

0 comments on commit 619ae5e

Please sign in to comment.