Skip to content

Commit

Permalink
fix #309
Browse files Browse the repository at this point in the history
  • Loading branch information
Vanessa219 committed Apr 12, 2020
1 parent f7a2fe9 commit c75a54a
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 6 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,10 @@
### v3.1.6 / 2020-04-0x


### v3.1.5 / 2020-04-12
### v3.1.6 / 2020-04-12

* [309](https://github.com/Vanessa219/vditor/issues/309) 添加 options.upload.setHeaders `引入特性`
* [306](https://github.com/Vanessa219/vditor/issues/306) IR mode ATX heading change `改进功能`
* [303](https://github.com/Vanessa219/vditor/issues/303) Inline HTML parsing issue `修复缺陷`
* [304](https://github.com/Vanessa219/vditor/issues/304) 为 toolbar 添加是否 pin 的配置 `引入特性`
* [296](https://github.com/Vanessa219/vditor/issues/296) 打字机模式下字数统计标签不可见 `改进功能`
Expand Down
25 changes: 20 additions & 5 deletions src/ts/ir/processKeydown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,13 @@ import {
fixTask,
insertAfterBlock, insertBeforeBlock, isFirstCell, isLastCell,
} from "../util/fixBrowserBehavior";
import {hasClosestByAttribute, hasClosestByClassName, hasClosestByMatchTag} from "../util/hasClosest";
import {getEditorRange} from "../util/selection";
import {
hasClosestByAttribute,
hasClosestByClassName,
hasClosestByHeadings,
hasClosestByMatchTag,
} from "../util/hasClosest";
import {getEditorRange, getSelectPosition} from "../util/selection";

export const processKeydown = (vditor: IVditor, event: KeyboardEvent) => {
vditor.ir.composingLock = event.isComposing;
Expand Down Expand Up @@ -145,9 +150,19 @@ export const processKeydown = (vditor: IVditor, event: KeyboardEvent) => {
return true;
}

if (event.key === "Backspace" && !isCtrl(event) && !event.shiftKey && !event.altKey && range.toString() === ""
&& fixDelete(vditor, range, event, pElement)) {
return true;
if (event.key === "Backspace" && !isCtrl(event) && !event.shiftKey && !event.altKey && range.toString() === "") {
if (fixDelete(vditor, range, event, pElement)) {
return true;
}
// 光标位于标题前,marker 后
const headingElement = hasClosestByHeadings(startContainer);
if (headingElement) {
const headingLength = headingElement.firstElementChild.textContent.length;
if (getSelectPosition(headingElement).start === headingLength) {
range.setStart(headingElement.firstElementChild.firstChild, headingLength - 1);
range.collapse(true);
}
}
}

return false;
Expand Down

0 comments on commit c75a54a

Please sign in to comment.