Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

修正Issue:存在软换行时,选中文本执行 Backspace,会导致内容异常 #689

Merged
merged 7 commits into from
Aug 5, 2020
Merged
3 changes: 2 additions & 1 deletion src/ts/util/fixBrowserBehavior.ts
Original file line number Diff line number Diff line change
Expand Up @@ -578,7 +578,8 @@ export const fixMarkdown = (event: KeyboardEvent, vditor: IVditor, pElement: HTM
}

// 软换行会被切割 /~https://github.com/Vanessa219/vditor/issues/220
if (pElement.previousElementSibling && event.key === "Backspace" && !isCtrl(event) && !event.altKey &&
// range.collapsed = false 时不会产生 220 issue,过度处理反倒会引起 range 异常
if (range.collapsed && pElement.previousElementSibling && event.key === "Backspace" && !isCtrl(event) && !event.altKey &&
!event.shiftKey && pElement.textContent.trimRight().split("\n").length > 1 &&
getSelectPosition(pElement, vditor[vditor.currentMode].element, range).start === 0) {
const lastElement = getLastNode(pElement.previousElementSibling) as HTMLElement;
Expand Down