mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-01-09 10:18:50 +01:00
This commit is contained in:
parent
7c1806100a
commit
e9aba04a3f
1 changed files with 15 additions and 1 deletions
|
|
@ -833,8 +833,8 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => {
|
|||
}
|
||||
const position = getSelectionOffset(editElement, protyle.wysiwyg.element, range);
|
||||
if (event.key === "Delete" || matchHotKey("⌃D", event)) {
|
||||
// 图片后为空格,在空格后删除 https://github.com/siyuan-note/siyuan/issues/13949
|
||||
if (range.startOffset === 0 && range.startContainer.textContent.length === 1) {
|
||||
// 图片后为空格,在空格后删除 https://github.com/siyuan-note/siyuan/issues/13949
|
||||
const rangePreviousElement = hasPreviousSibling(range.startContainer) as HTMLElement;
|
||||
const rangeNextElement = hasNextSibling(range.startContainer) as HTMLElement;
|
||||
if (rangePreviousElement && rangePreviousElement.nodeType === 1 && rangePreviousElement.classList.contains("img") &&
|
||||
|
|
@ -848,6 +848,20 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => {
|
|||
event.preventDefault();
|
||||
return;
|
||||
}
|
||||
// 图片前有一个字符,在字符后删除 https://github.com/siyuan-note/siyuan/issues/15911
|
||||
if (position.start === 0 &&
|
||||
range.startContainer.textContent !== Constants.ZWSP && // 如果为 zwsp 需前移光标
|
||||
!rangePreviousElement &&
|
||||
rangeNextElement && rangeNextElement.nodeType === 1 && rangeNextElement.classList.contains("img")) {
|
||||
const wbrElement = document.createElement("wbr");
|
||||
range.insertNode(wbrElement);
|
||||
const oldHTML = nodeElement.outerHTML;
|
||||
wbrElement.nextSibling.textContent = Constants.ZWSP;
|
||||
updateTransaction(protyle, nodeElement.getAttribute("data-node-id"), nodeElement.outerHTML, oldHTML);
|
||||
focusByWbr(nodeElement, range);
|
||||
event.preventDefault();
|
||||
return;
|
||||
}
|
||||
}
|
||||
// 需使用 innerText,否则 br 无法传唤为 /n https://github.com/siyuan-note/siyuan/issues/12066
|
||||
// 段末反向删除 https://github.com/siyuan-note/insider/issues/274
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue