Skip to content

Commit

Permalink
fix: marktext#2816 "delete" shortcut on a selected image deletes the …
Browse files Browse the repository at this point in the history
…text after it (marktext#3088)

fix behavior of "delete" key.
fix behavior of "Ctrl+X" (cut) key behavior.
  • Loading branch information
kiyoka authored Mar 6, 2022
1 parent ca1d084 commit ed1b335
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/muya/lib/contentState/copyCutCtrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ const copyCutCtrl = ContentState => {
key,
token
})
this.selectedImage = null
return
}
const { start, end } = selection.getCursorRange()
Expand Down
7 changes: 7 additions & 0 deletions src/muya/lib/contentState/deleteCtrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@ import selection from '../selection'
const deleteCtrl = ContentState => {
// Handle `delete` keydown event on document.
ContentState.prototype.docDeleteHandler = function (event) {
// handle delete selected image
const { selectedImage } = this
if (selectedImage) {
event.preventDefault()
this.selectedImage = null
return this.deleteImage(selectedImage)
}
if (this.selectedTableCells) {
event.preventDefault()
return this.deleteSelectedTableCells()
Expand Down

0 comments on commit ed1b335

Please sign in to comment.