@@ -853,11 +853,7 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => {
853
853
}
854
854
// 需使用 innerText,否则 br 无法传唤为 /n https://github.com/siyuan-note/siyuan/issues/12066
855
855
// 段末反向删除 https://github.com/siyuan-note/insider/issues/274
856
- if ( position . end === editElement . innerText . length ||
857
- // 软换行后删除 https://github.com/siyuan-note/siyuan/issues/11118
858
- ( position . end === editElement . innerText . length - 1 && editElement . innerText . endsWith ( "\n" ) ) ||
859
- // 图片后无内容删除 https://github.com/siyuan-note/siyuan/issues/11868
860
- ( position . end === editElement . innerText . length - 1 && editElement . innerText . endsWith ( Constants . ZWSP ) ) ) {
856
+ if ( isEndOfBlock ( range ) ) {
861
857
const nextElement = getNextBlock ( getTopAloneElement ( nodeElement ) ) ;
862
858
if ( nextElement ) {
863
859
const nextRange = focusBlock ( nextElement ) ;
@@ -934,8 +930,8 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => {
934
930
event . preventDefault ( ) ;
935
931
return ;
936
932
}
937
- // 图片后为空格,在空格后删除 https://github.com/siyuan-note/siyuan/issues/13949
938
933
if ( range . startOffset === 1 && range . startContainer . textContent . length === 1 ) {
934
+ // 图片后为空格,在空格后删除 https://github.com/siyuan-note/siyuan/issues/13949
939
935
const rangePreviousElement = hasPreviousSibling ( range . startContainer ) as HTMLElement ;
940
936
const rangeNextElement = hasNextSibling ( range . startContainer ) as HTMLElement ;
941
937
if ( rangePreviousElement && rangePreviousElement . nodeType === 1 && rangePreviousElement . classList . contains ( "img" ) &&
@@ -949,6 +945,17 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => {
949
945
event . preventDefault ( ) ;
950
946
return ;
951
947
}
948
+ // 图片前有一个字符,在字符后删除
949
+ if ( position . start === 1 && ! rangePreviousElement && rangeNextElement && rangeNextElement . nodeType === 1 && rangeNextElement . classList . contains ( "img" ) ) {
950
+ const wbrElement = document . createElement ( "wbr" ) ;
951
+ range . insertNode ( wbrElement ) ;
952
+ const oldHTML = nodeElement . outerHTML ;
953
+ wbrElement . previousSibling . textContent = Constants . ZWSP ;
954
+ updateTransaction ( protyle , nodeElement . getAttribute ( "data-node-id" ) , nodeElement . outerHTML , oldHTML ) ;
955
+ focusByWbr ( nodeElement , range ) ;
956
+ event . preventDefault ( ) ;
957
+ return ;
958
+ }
952
959
}
953
960
// 代码块中空行 ⌘+Del 异常 https://ld246.com/article/1663166544901
954
961
if ( nodeElement . classList . contains ( "code-block" ) && isOnlyMeta ( event ) &&
0 commit comments