Skip to content
This repository was archived by the owner on Feb 7, 2025. It is now read-only.

Commit 769ce37

Browse files
K-Kumar-01jolanglinais
authored andcommitted
fix(ui-markdown-editor): Delete image on backspace or delete press - #320
Signed-off-by: k-kumar-01 <[email protected]>
1 parent 463831f commit 769ce37

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

packages/ui-markdown-editor/src/index.js

+14
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,20 @@ export const MarkdownEditor = (props) => {
8585
return;
8686
}
8787

88+
const [imageNode] = Editor.nodes(editor, { match: n => n.type === 'image' });
89+
90+
// handle specific case to delete image when backspace is pressed
91+
if(event.keyCode===8 && imageNode){
92+
Editor.deleteBackward(editor);
93+
return ;
94+
}
95+
96+
// handle specific case to delete image when delete is pressed
97+
if(event.keyCode===46 && imageNode){
98+
Editor.deleteForward(editor);
99+
return ;
100+
}
101+
88102
const isFormatEvent = () => formattingHotKeys.some(hotkey => isHotkey(hotkey, event));
89103
if (!canBeFormatted(editor) && isFormatEvent()) {
90104
event.preventDefault();

0 commit comments

Comments
 (0)