Commit 19d18528 by ramdayalmunda

simple backspace handled

parent 22cae6ee
...@@ -171,7 +171,6 @@ var ADocEditor = function (customConfig) { ...@@ -171,7 +171,6 @@ var ADocEditor = function (customConfig) {
} }
function reRenderCanvas() { function reRenderCanvas() {
console.clear()
if (isRendering) return if (isRendering) return
let pageIndex = 0 let pageIndex = 0
if (!pageList.length) { if (!pageList.length) {
...@@ -395,9 +394,14 @@ var ADocEditor = function (customConfig) { ...@@ -395,9 +394,14 @@ var ADocEditor = function (customConfig) {
} }
function keydownHandler(e) { function keydownHandler(e) {
console.clear()
if (e.key == 'Backspace') { if (e.key == 'Backspace') {
if (caretData.index == 0) { if (caretData.index == 0) {
let activeDataIndex = dataList.findIndex( item => item.id==caretData.activeData.id )
if (activeDataIndex>0){
caretData.activeData = dataList[activeDataIndex-1]
caretData.index = caretData.activeData.plainContent.length
}
} else { } else {
caretData.activeData.plainContent = caretData.activeData.plainContent.slice(0, caretData.index - 1) + caretData.activeData.plainContent.slice(caretData.index) caretData.activeData.plainContent = caretData.activeData.plainContent.slice(0, caretData.index - 1) + caretData.activeData.plainContent.slice(caretData.index)
caretData.activeData.formatedText.splice(caretData.index - 1, 1) caretData.activeData.formatedText.splice(caretData.index - 1, 1)
......
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