Commit 6fbbe974 by ramdayalmunda

backspace event of next and previous lines

parent 55662d19
......@@ -310,7 +310,7 @@ var ADocEditor = function (customConfig) {
return
}
else if (e.ctrlKey) {
if (e.keyCode == 8) { // ctrl+backspace: delete the entrite word
if (e.keyCode == 8) { // ctrl+backspace: delete the entire word
let separatedSentence = caretData.activeData.plainContent.slice(0, caretData.index)
let indexOfpreviousBlankChar = separatedSentence.search(/[^a-zA-Z0-9](?=[a-zA-Z0-9]*$)/)
if (indexOfpreviousBlankChar <= 0) caretData.activeData.plainContent = ""
......@@ -348,8 +348,21 @@ var ADocEditor = function (customConfig) {
++caretData.index
}
else if (e.keyCode == 8) { // backspace
if (caretData.index <= 0){
let currentIndex = dataSet.findIndex( item => item.id == caretData.activeData.id )
if (currentIndex>0){
caretData.activeData = dataSet[currentIndex-1]
caretData.index = dataSet[currentIndex-1].plainContent.length
if (dataSet[currentIndex].plainContent.length!=0){
caretData.activeData.plainContent += dataSet[currentIndex].plainContent
caretData.activeData.formatedText.push( ...dataSet[currentIndex].formatedText )
}
dataSet.splice(currentIndex, 1)
}
}else{
caretData.activeData.plainContent = caretData.activeData.plainContent.slice(0, caretData.index - 1) + caretData.activeData.plainContent.slice(caretData.index)
caretData.index = caretData.index <= 0 ? 0 : caretData.index - 1
caretData.index = caretData.index - 1
}
}
else if (e.keyCode == 37) { // left key
e.preventDefault()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment